@flatbiz/antd 4.5.55 → 4.5.57
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/ace-editor-groovy/index.js +1 -1
- package/esm/ace-editor-groovy/index.js.map +1 -1
- package/esm/ace-editor-java/index.js +1 -1
- package/esm/ace-editor-java/index.js.map +1 -1
- package/esm/ace-editor-json/index.js +1 -1
- package/esm/ace-editor-json/index.js.map +1 -1
- package/esm/ace-editor-mysql/index.js +1 -1
- package/esm/ace-editor-mysql/index.js.map +1 -1
- package/esm/ace-editor-xml/index.js +1 -1
- package/esm/ace-editor-xml/index.js.map +1 -1
- package/esm/anchor-steps/index.js +1 -1
- package/esm/anchor-steps/index.js.map +1 -1
- package/esm/bootstrap/index.js +1 -1
- package/esm/bootstrap/index.js.map +1 -1
- package/esm/box-grid/index.js +1 -1
- package/esm/box-grid/index.js.map +1 -1
- package/esm/button-operate/index.js +1 -1
- package/esm/button-operate/index.js.map +1 -1
- package/esm/button-wrapper/index.js +1 -1
- package/esm/button-wrapper/index.js.map +1 -1
- package/esm/card-layout/index.css +1 -1
- package/esm/card-layout/index.js +1 -1
- package/esm/card-layout/index.js.map +1 -1
- package/esm/cascader-wrapper/index.js +1 -1
- package/esm/cascader-wrapper/index.js.map +1 -1
- package/esm/check-list/index.js +1 -1
- package/esm/check-list/index.js.map +1 -1
- package/esm/checkbox-wrapper/index.js +1 -1
- package/esm/checkbox-wrapper/index.js.map +1 -1
- package/esm/code-render/index.css +1 -0
- package/esm/code-render/index.js +5 -0
- package/esm/code-render/index.js.map +1 -0
- package/esm/color-picker-wrapper/index.css +1 -1
- package/esm/color-picker-wrapper/index.js +1 -1
- package/esm/color-picker-wrapper/index.js.map +1 -1
- package/esm/config-provider-wrapper/index.js +1 -1
- package/esm/copy-wrapper/index.js +1 -1
- package/esm/copy-wrapper/index.js.map +1 -1
- package/esm/date-picker-wrapper/index.js +1 -1
- package/esm/date-picker-wrapper/index.js.map +1 -1
- package/esm/date-range-picker-wrapper/index.js +1 -1
- package/esm/date-range-picker-wrapper/index.js.map +1 -1
- package/esm/date-range-picker-wrapper-form-item/index.js +1 -1
- package/esm/date-range-picker-wrapper-form-item/index.js.map +1 -1
- package/esm/delete-node/index.js +1 -1
- package/esm/delete-node/index.js.map +1 -1
- package/esm/dialog-alert/index.js +1 -1
- package/esm/dialog-confirm/index.js +1 -1
- package/esm/dialog-drag-modal/index.js +1 -1
- package/esm/dialog-drag-modal/index.js.map +1 -1
- package/esm/dialog-drawer/index.js +1 -1
- package/esm/dialog-drawer/index.js.map +1 -1
- package/esm/dialog-drawer-content/index.js +1 -1
- package/esm/dialog-drawer-content/index.js.map +1 -1
- package/esm/dialog-loading/index.js +1 -1
- package/esm/dialog-loading/index.js.map +1 -1
- package/esm/dialog-modal/index.js +1 -1
- package/esm/dialog-modal/index.js.map +1 -1
- package/esm/dialog-preview-image/index.js +1 -1
- package/esm/dialog-preview-image/index.js.map +1 -1
- package/esm/drag-collapse/index.js +1 -1
- package/esm/drag-collapse/index.js.map +1 -1
- package/esm/drag-collapse-form-list/index.js +1 -1
- package/esm/drag-collapse-form-list/index.js.map +1 -1
- package/esm/drag-editable-card/index.js +1 -1
- package/esm/drag-editable-card/index.js.map +1 -1
- package/esm/drag-editable-table/index.js +1 -1
- package/esm/drag-editable-table/index.js.map +1 -1
- package/esm/drag-editable-table-pro/index.js +1 -1
- package/esm/drag-editable-table-pro/index.js.map +1 -1
- package/esm/drag-form-list/index.js +1 -1
- package/esm/drag-form-list/index.js.map +1 -1
- package/esm/drag-table/index.js +1 -1
- package/esm/drag-table/index.js.map +1 -1
- package/esm/drawer-wrapper/index.js +1 -1
- package/esm/drawer-wrapper/index.js.map +1 -1
- package/esm/dropdown-menu-wrapper/index.js +1 -1
- package/esm/dropdown-menu-wrapper/index.js.map +1 -1
- package/esm/easy-form/index.js +1 -1
- package/esm/easy-form/index.js.map +1 -1
- package/esm/easy-table/index.js +1 -1
- package/esm/easy-table/index.js.map +1 -1
- package/esm/editable-card/index.js +1 -1
- package/esm/editable-card/index.js.map +1 -1
- package/esm/editable-field/index.js +1 -1
- package/esm/editable-field/index.js.map +1 -1
- package/esm/editable-table/index.js +1 -1
- package/esm/editable-table/index.js.map +1 -1
- package/esm/editable-table-pro/index.js +1 -1
- package/esm/editable-table-pro/index.js.map +1 -1
- package/esm/editor-wrapper/index.js +1 -1
- package/esm/editor-wrapper/index.js.map +1 -1
- package/esm/fba-app/index.js +1 -1
- package/esm/fba-app/index.js.map +1 -1
- package/esm/fba-hooks/index.js +1 -1
- package/esm/fba-hooks/index.js.map +1 -1
- package/esm/fba-utils/index.js +1 -1
- package/esm/fba-utils/index.js.map +1 -1
- package/esm/file-export/index.js +1 -1
- package/esm/file-export/index.js.map +1 -1
- package/esm/file-import/index.js +1 -1
- package/esm/file-import/index.js.map +1 -1
- package/esm/file-select/index.js +1 -1
- package/esm/file-select/index.js.map +1 -1
- package/esm/flex-layout/index.js +1 -1
- package/esm/flex-layout/index.js.map +1 -1
- package/esm/form-grid/index.js +1 -1
- package/esm/form-grid/index.js.map +1 -1
- package/esm/form-item-group/index.js +1 -1
- package/esm/form-item-group/index.js.map +1 -1
- package/esm/form-item-text/index.js +1 -1
- package/esm/form-item-text/index.js.map +1 -1
- package/esm/form-item-wrapper/index.js +1 -1
- package/esm/form-item-wrapper/index.js.map +1 -1
- package/esm/form-list-wrapper/index.js +1 -1
- package/esm/form-list-wrapper/index.js.map +1 -1
- package/esm/form-wrapper/index.js +1 -1
- package/esm/form-wrapper/index.js.map +1 -1
- package/esm/full-screen/index.js +1 -1
- package/esm/full-screen/index.js.map +1 -1
- package/esm/icon-wrapper/index.js +1 -1
- package/esm/icon-wrapper/index.js.map +1 -1
- package/esm/{index-83bede1b.js → index-853b36e6.js} +2 -2
- package/esm/{index-83bede1b.js.map → index-853b36e6.js.map} +1 -1
- package/esm/index.js +2 -1
- package/esm/input-search-wrapper/index.js +1 -1
- package/esm/input-search-wrapper/index.js.map +1 -1
- package/esm/input-text-area-wrapper/index.js +1 -1
- package/esm/input-text-area-wrapper/index.js.map +1 -1
- package/esm/input-wrapper/index.js +1 -1
- package/esm/input-wrapper/index.js.map +1 -1
- package/esm/json-editor/index.js +1 -1
- package/esm/json-editor/index.js.map +1 -1
- package/esm/label-value-layout/index.js +1 -1
- package/esm/label-value-layout/index.js.map +1 -1
- package/esm/label-value-render/index.js +1 -1
- package/esm/label-value-render/index.js.map +1 -1
- package/esm/local-loading/index.js +1 -1
- package/esm/local-loading/index.js.map +1 -1
- package/esm/mention-editor/index.js +1 -1
- package/esm/mention-editor/index.js.map +1 -1
- package/esm/mentions-wrapper/index.js +1 -1
- package/esm/mentions-wrapper/index.js.map +1 -1
- package/esm/modal-action/index.js +1 -1
- package/esm/modal-action/index.js.map +1 -1
- package/esm/modal-wrapper/index.js +1 -1
- package/esm/modal-wrapper/index.js.map +1 -1
- package/esm/number-range-form-item/index.js +1 -1
- package/esm/number-range-form-item/index.js.map +1 -1
- package/esm/pdf/index.js +1 -1
- package/esm/pdf/index.js.map +1 -1
- package/esm/pdf-preview/index.js +1 -1
- package/esm/pdf-preview/index.js.map +1 -1
- package/esm/radio-group-wrapper/index.js +1 -1
- package/esm/radio-group-wrapper/index.js.map +1 -1
- package/esm/relation-tree/index.js +1 -1
- package/esm/relation-tree/index.js.map +1 -1
- package/esm/request-status/index.js +1 -1
- package/esm/request-status/index.js.map +1 -1
- package/esm/resizable-drawer/index.js +1 -1
- package/esm/resizable-drawer/index.js.map +1 -1
- package/esm/rich-text-editor/index.js +1 -1
- package/esm/rich-text-editor/index.js.map +1 -1
- package/esm/rich-text-viewer/index.js +1 -1
- package/esm/rich-text-viewer/index.js.map +1 -1
- package/esm/roll-location-center/index.js +1 -1
- package/esm/roll-location-center/index.js.map +1 -1
- package/esm/roll-location-in-view/index.js +1 -1
- package/esm/roll-location-in-view/index.js.map +1 -1
- package/esm/rule-describe/index.js +1 -1
- package/esm/rule-describe/index.js.map +1 -1
- package/esm/search-form/index.js +1 -1
- package/esm/search-form/index.js.map +1 -1
- package/esm/search-menu/index.js +1 -1
- package/esm/search-menu/index.js.map +1 -1
- package/esm/selector-wrapper/index.js +1 -1
- package/esm/selector-wrapper/index.js.map +1 -1
- package/esm/selector-wrapper-search/index.js +1 -1
- package/esm/selector-wrapper-search/index.js.map +1 -1
- package/esm/selector-wrapper-simple/index.js +1 -1
- package/esm/selector-wrapper-simple/index.js.map +1 -1
- package/esm/simple-layout/index.js +1 -1
- package/esm/simple-layout/index.js.map +1 -1
- package/esm/sms-count-down/index.js +1 -1
- package/esm/sms-count-down/index.js.map +1 -1
- package/esm/split-wrapper/index.js +1 -1
- package/esm/split-wrapper/index.js.map +1 -1
- package/esm/styles/index.css +1 -1
- package/esm/svg-http-view/index.js +1 -1
- package/esm/svg-http-view/index.js.map +1 -1
- package/esm/switch-confirm-wrapper/index.js +1 -1
- package/esm/switch-confirm-wrapper/index.js.map +1 -1
- package/esm/switch-wrapper/index.js +1 -1
- package/esm/switch-wrapper/index.js.map +1 -1
- package/esm/table-cell-render/index.js +1 -1
- package/esm/table-cell-render/index.js.map +1 -1
- package/esm/table-scrollbar/index.js +1 -1
- package/esm/table-scrollbar/index.js.map +1 -1
- package/esm/tabs-sticky/index.js +1 -1
- package/esm/tabs-sticky/index.js.map +1 -1
- package/esm/tabs-wrapper/index.js +1 -1
- package/esm/tabs-wrapper/index.js.map +1 -1
- package/esm/tag-group/index.js +1 -1
- package/esm/tag-group/index.js.map +1 -1
- package/esm/tag-list-render/index.js +1 -1
- package/esm/tag-list-render/index.js.map +1 -1
- package/esm/tag-list-select/index.js +1 -1
- package/esm/tag-list-select/index.js.map +1 -1
- package/esm/tag-wrapper/index.js +1 -1
- package/esm/tag-wrapper/index.js.map +1 -1
- package/esm/text-css-ellipsis/index.js +1 -1
- package/esm/text-css-ellipsis/index.js.map +1 -1
- package/esm/text-overflow/index.js +1 -1
- package/esm/text-overflow/index.js.map +1 -1
- package/esm/text-overflow-render/index.js +1 -1
- package/esm/text-symbol-wrapper/index.js +1 -1
- package/esm/text-symbol-wrapper/index.js.map +1 -1
- package/esm/time-ea73b2fb.js +3 -0
- package/esm/{time-53b3f55f.js.map → time-ea73b2fb.js.map} +1 -1
- package/esm/time-picker-wrapper/index.js +1 -1
- package/esm/time-picker-wrapper/index.js.map +1 -1
- package/esm/time-range-picker-wrapper/index.js +1 -1
- package/esm/time-range-picker-wrapper/index.js.map +1 -1
- package/esm/time-range-picker-wrapper-form-item/index.js +1 -1
- package/esm/time-range-picker-wrapper-form-item/index.js.map +1 -1
- package/esm/tree-modal/index.js +1 -1
- package/esm/tree-modal/index.js.map +1 -1
- package/esm/tree-modal-selector/index.js +1 -1
- package/esm/tree-modal-selector/index.js.map +1 -1
- package/esm/tree-selector-wrapper/index.js +1 -1
- package/esm/tree-selector-wrapper/index.js.map +1 -1
- package/esm/tree-wrapper/index.js +1 -1
- package/esm/tree-wrapper/index.js.map +1 -1
- package/esm/upload-wrapper/index.js +1 -1
- package/esm/upload-wrapper/index.js.map +1 -1
- package/esm/use-responsive-point-1e6d93d9.js +3 -0
- package/esm/{use-responsive-point-21b8c601.js.map → use-responsive-point-1e6d93d9.js.map} +1 -1
- package/esm/x-mind-preview/index.js +1 -1
- package/esm/x-mind-preview/index.js.map +1 -1
- package/index.d.ts +61 -4
- package/package.json +4 -5
- package/esm/time-53b3f55f.js +0 -3
- package/esm/use-responsive-point-21b8c601.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["@flatbiz/antd/src/number-range-form-item/number-range.tsx"],"sourcesContent":["import { isEmptyArray, isNotEmptyArray, isUndefinedOrNull } from '@flatbiz/utils';\nimport { InputNumber, InputNumberProps } from 'antd';\nimport { useMemo } from 'react';\nimport { FlexLayout } from '../flex-layout/flex-layout';\nimport { FormItemWrapper, type FormItemWrapperProps } from '../form-item-wrapper';\nimport type { FormItemNamePath } from '../types';\n\n// type InputNumberProps = GetProps<typeof InputNumber>;\n\nexport type NumberRangeFormItemProps = Omit<FormItemWrapperProps, 'name' | 'rules'> & {\n minFormItemName: FormItemNamePath;\n maxFormItemName: FormItemNamePath;\n /** 是否必填 */\n required?: boolean;\n /** 必填验证异常文案 */\n requiredRuleMessage?: string | [string, string];\n /** 范围验证异常文案 */\n rangeRuleMessage?: string | [string, string];\n minInputNumberProps?: Omit<InputNumberProps, 'value'>;\n maxInputNumberProps?: Omit<InputNumberProps, 'value'>;\n /** 最小值与最大值输入是否可以相同 */\n isInputEqual?: boolean;\n};\n/**\n * 数字输入范围组件\n */\nexport const NumberRangeFormItem = (props: NumberRangeFormItemProps) => {\n const {\n minFormItemName,\n maxFormItemName,\n required,\n requiredRuleMessage,\n rangeRuleMessage,\n minInputNumberProps,\n maxInputNumberProps,\n isInputEqual,\n ...otherProps\n } = props;\n\n const rangeRuleMessageList = useMemo(() => {\n if (!rangeRuleMessage) return ['最小值输入不能超过最大值', '最大值输入不能低于最小值'];\n if (isNotEmptyArray(rangeRuleMessage)) {\n return [rangeRuleMessage[0], rangeRuleMessage[1] || rangeRuleMessage[0]];\n }\n return [rangeRuleMessage, rangeRuleMessage] as string[];\n }, [rangeRuleMessage]);\n\n const requiredRuleMessageList = useMemo(() => {\n if (!requiredRuleMessage || isEmptyArray(requiredRuleMessage)) return [];\n if (isNotEmptyArray(requiredRuleMessage)) {\n return [requiredRuleMessage[0], requiredRuleMessage[1] || requiredRuleMessage[0]];\n }\n return [requiredRuleMessage, requiredRuleMessage] as string[];\n }, [requiredRuleMessage]);\n\n const minRules = [\n { required: required, message: requiredRuleMessageList[0] || '' },\n ({ getFieldValue }) => ({\n validator(_, value) {\n if (isUndefinedOrNull(value)) {\n return Promise.resolve();\n }\n const maxValue = getFieldValue(maxFormItemName);\n if (isUndefinedOrNull(maxValue)) {\n return Promise.resolve();\n }\n if (isInputEqual) {\n if (value <= maxValue) {\n return Promise.resolve();\n }\n } else {\n if (value < maxValue) {\n return Promise.resolve();\n }\n }\n return Promise.reject(new Error(rangeRuleMessageList[0]));\n },\n }),\n ];\n\n const maxRules = [\n { required: required, message: requiredRuleMessageList[1] || '' },\n ({ getFieldValue }) => ({\n validator(_, value) {\n if (isUndefinedOrNull(value)) {\n return Promise.resolve();\n }\n const minValue = getFieldValue(minFormItemName);\n if (isUndefinedOrNull(minValue)) {\n return Promise.resolve();\n }\n\n if (isInputEqual) {\n if (value >= minValue) {\n return Promise.resolve();\n }\n } else {\n if (value > minValue) {\n return Promise.resolve();\n }\n }\n return Promise.reject(new Error(rangeRuleMessageList[1]));\n },\n }),\n ];\n\n return (\n <FormItemWrapper {...otherProps} required={required}>\n <FlexLayout fullIndex={[0, 1]} direction=\"horizontal\" gap={10}>\n <FormItemWrapper\n name={minFormItemName}\n dependencies={[maxFormItemName]}\n rules={minRules}\n style={{ margin: 0 }}\n >\n <InputNumber\n placeholder=\"请输入\"\n {...minInputNumberProps}\n style={{ width: '100%', ...minInputNumberProps?.style }}\n />\n </FormItemWrapper>\n <FormItemWrapper\n name={maxFormItemName}\n dependencies={[minFormItemName]}\n rules={maxRules}\n style={{ margin: 0 }}\n >\n <InputNumber\n placeholder=\"请输入\"\n {...maxInputNumberProps}\n style={{ width: '100%', ...maxInputNumberProps?.style }}\n />\n </FormItemWrapper>\n </FlexLayout>\n </FormItemWrapper>\n );\n};\n"],"names":["NumberRangeFormItem","props","minFormItemName","maxFormItemName","required","requiredRuleMessage","rangeRuleMessage","minInputNumberProps","maxInputNumberProps","isInputEqual","otherProps","_objectWithoutPropertiesLoose","_excluded","rangeRuleMessageList","useMemo","isNotEmptyArray","requiredRuleMessageList","isEmptyArray","minRules","message","_ref","getFieldValue","validator","_","value","isUndefinedOrNull","Promise","resolve","maxValue","reject","Error","maxRules","_ref2","minValue","_jsx","FormItemWrapper","_extends","children","_jsxs","FlexLayout","fullIndex","direction","gap","name","dependencies","rules","style","margin","InputNumber","placeholder","width"],"mappings":";8xBA0BaA,EAAsB,SAAtBA,EAAuBC,GAClC,IACEC,EASED,EATFC,gBACAC,EAQEF,EARFE,gBACAC,EAOEH,EAPFG,SACAC,EAMEJ,EANFI,oBACAC,EAKEL,EALFK,iBACAC,EAIEN,EAJFM,oBACAC,EAGEP,EAHFO,oBACAC,EAEER,EAFFQ,aACGC,EAAUC,EACXV,EAAKW,GAET,IAAMC,EAAuBC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["@flatbiz/antd/src/number-range-form-item/number-range.tsx"],"sourcesContent":["import { isEmptyArray, isNotEmptyArray, isUndefinedOrNull } from '@flatbiz/utils';\nimport { InputNumber, InputNumberProps } from 'antd';\nimport { useMemo } from 'react';\nimport { FlexLayout } from '../flex-layout/flex-layout';\nimport { FormItemWrapper, type FormItemWrapperProps } from '../form-item-wrapper';\nimport type { FormItemNamePath } from '../types';\n\n// type InputNumberProps = GetProps<typeof InputNumber>;\n\nexport type NumberRangeFormItemProps = Omit<FormItemWrapperProps, 'name' | 'rules'> & {\n minFormItemName: FormItemNamePath;\n maxFormItemName: FormItemNamePath;\n /** 是否必填 */\n required?: boolean;\n /** 必填验证异常文案 */\n requiredRuleMessage?: string | [string, string];\n /** 范围验证异常文案 */\n rangeRuleMessage?: string | [string, string];\n minInputNumberProps?: Omit<InputNumberProps, 'value'>;\n maxInputNumberProps?: Omit<InputNumberProps, 'value'>;\n /** 最小值与最大值输入是否可以相同 */\n isInputEqual?: boolean;\n};\n/**\n * 数字输入范围组件\n */\nexport const NumberRangeFormItem = (props: NumberRangeFormItemProps) => {\n const {\n minFormItemName,\n maxFormItemName,\n required,\n requiredRuleMessage,\n rangeRuleMessage,\n minInputNumberProps,\n maxInputNumberProps,\n isInputEqual,\n ...otherProps\n } = props;\n\n const rangeRuleMessageList = useMemo(() => {\n if (!rangeRuleMessage) return ['最小值输入不能超过最大值', '最大值输入不能低于最小值'];\n if (isNotEmptyArray(rangeRuleMessage)) {\n return [rangeRuleMessage[0], rangeRuleMessage[1] || rangeRuleMessage[0]];\n }\n return [rangeRuleMessage, rangeRuleMessage] as string[];\n }, [rangeRuleMessage]);\n\n const requiredRuleMessageList = useMemo(() => {\n if (!requiredRuleMessage || isEmptyArray(requiredRuleMessage)) return [];\n if (isNotEmptyArray(requiredRuleMessage)) {\n return [requiredRuleMessage[0], requiredRuleMessage[1] || requiredRuleMessage[0]];\n }\n return [requiredRuleMessage, requiredRuleMessage] as string[];\n }, [requiredRuleMessage]);\n\n const minRules = [\n { required: required, message: requiredRuleMessageList[0] || '' },\n ({ getFieldValue }) => ({\n validator(_, value) {\n if (isUndefinedOrNull(value)) {\n return Promise.resolve();\n }\n const maxValue = getFieldValue(maxFormItemName);\n if (isUndefinedOrNull(maxValue)) {\n return Promise.resolve();\n }\n if (isInputEqual) {\n if (value <= maxValue) {\n return Promise.resolve();\n }\n } else {\n if (value < maxValue) {\n return Promise.resolve();\n }\n }\n return Promise.reject(new Error(rangeRuleMessageList[0]));\n },\n }),\n ];\n\n const maxRules = [\n { required: required, message: requiredRuleMessageList[1] || '' },\n ({ getFieldValue }) => ({\n validator(_, value) {\n if (isUndefinedOrNull(value)) {\n return Promise.resolve();\n }\n const minValue = getFieldValue(minFormItemName);\n if (isUndefinedOrNull(minValue)) {\n return Promise.resolve();\n }\n\n if (isInputEqual) {\n if (value >= minValue) {\n return Promise.resolve();\n }\n } else {\n if (value > minValue) {\n return Promise.resolve();\n }\n }\n return Promise.reject(new Error(rangeRuleMessageList[1]));\n },\n }),\n ];\n\n return (\n <FormItemWrapper {...otherProps} required={required}>\n <FlexLayout fullIndex={[0, 1]} direction=\"horizontal\" gap={10}>\n <FormItemWrapper\n name={minFormItemName}\n dependencies={[maxFormItemName]}\n rules={minRules}\n style={{ margin: 0 }}\n >\n <InputNumber\n placeholder=\"请输入\"\n {...minInputNumberProps}\n style={{ width: '100%', ...minInputNumberProps?.style }}\n />\n </FormItemWrapper>\n <FormItemWrapper\n name={maxFormItemName}\n dependencies={[minFormItemName]}\n rules={maxRules}\n style={{ margin: 0 }}\n >\n <InputNumber\n placeholder=\"请输入\"\n {...maxInputNumberProps}\n style={{ width: '100%', ...maxInputNumberProps?.style }}\n />\n </FormItemWrapper>\n </FlexLayout>\n </FormItemWrapper>\n );\n};\n"],"names":["NumberRangeFormItem","props","minFormItemName","maxFormItemName","required","requiredRuleMessage","rangeRuleMessage","minInputNumberProps","maxInputNumberProps","isInputEqual","otherProps","_objectWithoutPropertiesLoose","_excluded","rangeRuleMessageList","useMemo","isNotEmptyArray","requiredRuleMessageList","isEmptyArray","minRules","message","_ref","getFieldValue","validator","_","value","isUndefinedOrNull","Promise","resolve","maxValue","reject","Error","maxRules","_ref2","minValue","_jsx","FormItemWrapper","_extends","children","_jsxs","FlexLayout","fullIndex","direction","gap","name","dependencies","rules","style","margin","InputNumber","placeholder","width"],"mappings":";8xBA0BaA,EAAsB,SAAtBA,EAAuBC,GAClC,IACEC,EASED,EATFC,gBACAC,EAQEF,EARFE,gBACAC,EAOEH,EAPFG,SACAC,EAMEJ,EANFI,oBACAC,EAKEL,EALFK,iBACAC,EAIEN,EAJFM,oBACAC,EAGEP,EAHFO,oBACAC,EAEER,EAFFQ,aACGC,EAAUC,EACXV,EAAKW,GAET,IAAMC,EAAuBC,EAAQ,WACnC,IAAKR,EAAkB,MAAO,CAAC,eAAgB,gBAC/C,GAAIS,EAAgBT,GAAmB,CACrC,MAAO,CAACA,EAAiB,GAAIA,EAAiB,IAAMA,EAAiB,GACvE,CACA,MAAO,CAACA,EAAkBA,EAC5B,EAAG,CAACA,IAEJ,IAAMU,EAA0BF,EAAQ,WACtC,IAAKT,GAAuBY,EAAaZ,GAAsB,MAAO,GACtE,GAAIU,EAAgBV,GAAsB,CACxC,MAAO,CAACA,EAAoB,GAAIA,EAAoB,IAAMA,EAAoB,GAChF,CACA,MAAO,CAACA,EAAqBA,EAC/B,EAAG,CAACA,IAEJ,IAAMa,EAAW,CACf,CAAEd,SAAUA,EAAUe,QAASH,EAAwB,IAAM,IAC7D,SAAAI,GAAA,IAAGC,EAAaD,EAAbC,cAAa,MAAQ,CACtBC,mBAA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YAGpDZ,EAACC,EAAe,CACdQ,KAAMxC,EACNyC,aAAc,CAAC1C,GACf2C,MAAOd,EACPe,MAAO,CAAEC,OAAQ,GAAIV,SAErBH,EAACc,EAAWZ,EAAA,CACVa,YAAY,OACRzC,EAAmB,CACvBsC,MAAKV,EAAA,CAAIc,MAAO,QAAW1C,GAAmB,UAAA,EAAnBA,EAAqBsC,iBAM5D"}
|
package/esm/pdf/index.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import './../fba-hooks/index.css';
|
|
3
3
|
import './index.css';
|
|
4
4
|
/*! @flatjs/forge MIT @flatbiz/antd */
|
|
5
|
-
import{classNames as r}from"@dimjs/utils/cjs/class-names";import{Result as e,Spin as t}from"antd";import{useState as n}from"react";import{fbaHooks as o}from"../fba-hooks/index.js";import{createCtx as a}from"@wove/react/cjs/create-ctx";import{jsx as i,jsxs as s}from"react/jsx-runtime";import{_ as c}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{hooks as u}from"@wove/react/cjs/hooks";import"@dimjs/lang/cjs/is-array";import"@flatbiz/utils";import"../use-responsive-point-
|
|
5
|
+
import{classNames as r}from"@dimjs/utils/cjs/class-names";import{Result as e,Spin as t}from"antd";import{useState as n}from"react";import{fbaHooks as o}from"../fba-hooks/index.js";import{createCtx as a}from"@wove/react/cjs/create-ctx";import{jsx as i,jsxs as s}from"react/jsx-runtime";import{_ as c}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{hooks as u}from"@wove/react/cjs/hooks";import"@dimjs/lang/cjs/is-array";import"@flatbiz/utils";import"../use-responsive-point-1e6d93d9.js";import"@dimjs/utils/cjs/uuid";var l=a(),d=l[0],m=l[1];var f=function a(s){var c=n(),u=c[0],l=c[1];var d=n(),f=d[0],p=d[1];o.useEffectCustomAsync(function(){return new Promise(function(r,e){var t,n,o,a;t=globalThis,n=t.pdfjsLib;n.GlobalWorkerOptions.workerSrc="//file.40017.cn/tcsk/react/pdf@3.2.146/pdf.worker.min.js";var i=function(){try{return r()}catch(r){return e(r)}};var c=function(r){try{console.error(r);s.onLoadError==null||s.onLoadError(r);p(r);return i()}catch(r){return e(r)}};try{o=n.getDocument({url:s.pdfUrl,cMapUrl:"https://file.40017.cn/tcsk/react/pdf@3.2.146/bcmaps/",cMapPacked:true});return Promise.resolve(o.promise).then(function(r){try{a=r;l(a);s.onLoadSuccess==null||s.onLoadSuccess(a);return i()}catch(r){return c(r)}},c)}catch(r){c(r)}})},[s.pdfUrl]);var v=function r(){return u};if(f){if(s.error){return typeof s.error==="function"?s.error(f):s.error}return i(e,{status:"error",title:"PDF加载异常",subTitle:f==null?void 0:f.message})}if(u){return i(m,{value:{getPdfInstance:v},children:i("div",{className:r("v-pdf-document",s.className),children:s.children})})}return i("div",{className:"v-pdf-document-init-loading",children:i(t,{})})};var p=function e(a){var l=d();var m=l.getPdfInstance();var f=u.useId(undefined,"v-pdf-page-"+a.pageNumber);var p=n(true),v=p[0],h=p[1];var g=m.numPages;o.useEffectCustom(function(){m.getPage(a.pageNumber).then(function(r){var e=a.scale||1;var t=r.getViewport({scale:e});var n=a.width;var o=document.getElementById(f);var i=o.getContext("2d");if(n&&!a.scale){var s=n/t.width;t=r.getViewport({scale:s})}var c=window.devicePixelRatio;c=c<=1?96/72:c;o.width=Math.floor(t.width*c);o.height=Math.floor(t.height*c);o.style.width=t.width+"px";o.style.height=t.height+"px";var u={transform:[c,0,0,c,0,0],canvasContext:i,viewport:t};var l=r.render(u);l.promise.then(function(){a.onRenderSuccess==null||a.onRenderSuccess({width:t.width,height:t.height,scale:e,pageNumber:a.pageNumber,page:r},m);h(false)}).catch(function(r){console.error(r==null?void 0:r.message);a.onRenderError==null||a.onRenderError(r,m);h(false)})})},[m,a.scale,a.pageNumber]);var w=typeof a.gap==="undefined"?10:a.gap;var b=g!==a.pageNumber?{marginBottom:w}:{};return s("div",{className:r("v-pdf-page",a.className),style:c({},b,a.style),onClick:a.onClick,children:[i(t,{spinning:v,children:i("canvas",{id:f})}),a.children]})};var v={Document:f,Page:p};export{v as Pdf};
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/esm/pdf/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["@flatbiz/antd/src/pdf/context.ts","@flatbiz/antd/src/pdf/document.tsx","@flatbiz/antd/src/pdf/page.tsx","@flatbiz/antd/src/pdf/index.ts"],"sourcesContent":["import { createCtx } from '@wove/react';\n\ntype CtxProps = {\n getPdfInstance: () => any;\n};\n\nexport const [getCtx, CtxProvider] = createCtx<CtxProps>();\n","import { classNames } from '@dimjs/utils';\nimport { Result, Spin } from 'antd';\nimport { ReactElement, ReactNode, useState } from 'react';\nimport { fbaHooks } from '../fba-hooks';\nimport { CtxProvider } from './context';\nimport './style.less';\n\ntype PdfProps = {\n pdfUrl: string;\n onLoadError?: (error: any) => void;\n onLoadSuccess?: (pdfInstance: any) => void;\n children: ReactNode;\n error?: ReactElement | ((error) => ReactElement);\n className?: string;\n};\n\nexport const PdfDocument = (props: PdfProps) => {\n const [pdfInstance, setPdfInstance] = useState<any>();\n const [errorInst, setErrorInst] = useState<any>();\n\n fbaHooks.useEffectCustomAsync(async () => {\n const { pdfjsLib } = globalThis as any;\n pdfjsLib.GlobalWorkerOptions.workerSrc = '//file.40017.cn/tcsk/react/pdf@3.2.146/pdf.worker.min.js';\n try {\n const loadingTask = pdfjsLib.getDocument({\n url: props.pdfUrl,\n // 避免服务端动态填充的字体不展示\n cMapUrl: 'https://file.40017.cn/tcsk/react/pdf@3.2.146/bcmaps/',\n cMapPacked: true,\n });\n const pdfInstance = await loadingTask.promise;\n setPdfInstance(pdfInstance);\n props.onLoadSuccess?.(pdfInstance);\n } catch (error: any) {\n console.error(error);\n props.onLoadError?.(error);\n setErrorInst(error);\n }\n }, [props.pdfUrl]);\n\n const getPdfInstance = () => {\n return pdfInstance;\n };\n\n if (errorInst) {\n if (props.error) {\n return typeof props.error === 'function' ? props.error(errorInst) : props.error;\n }\n return <Result status=\"error\" title=\"PDF加载异常\" subTitle={errorInst?.message}></Result>;\n }\n\n if (pdfInstance) {\n return (\n <CtxProvider value={{ getPdfInstance }}>\n <div className={classNames('v-pdf-document', props.className)}>{props.children}</div>\n </CtxProvider>\n );\n }\n\n return (\n <div className=\"v-pdf-document-init-loading\">\n <Spin />\n </div>\n );\n};\n","import { classNames } from '@dimjs/utils';\nimport { hooks } from '@wove/react';\nimport { Spin } from 'antd';\nimport { CSSProperties, ReactNode, useState } from 'react';\nimport { fbaHooks } from '../fba-hooks';\nimport { getCtx } from './context';\nimport './style.less';\n\ntype PdfProps = {\n onRenderSuccess?: (pageInstance: any, pdfInstance: any) => void;\n onRenderError?: (error: any, pdfInstance: any) => void;\n /** pdf page宽度,高度根据比例适配 */\n width?: number;\n /** 缩放比例,默认值:1,配置此参数后 width 属性失效,例如:1、0.6、0.8 */\n scale?: number;\n /** pdf页面上下之间的间隙,默认值10 */\n gap?: number;\n /** 页码 */\n pageNumber: number;\n children?: ReactNode;\n onClick?: (e) => void;\n className?: string;\n style?: CSSProperties;\n};\n\nexport const PdfPage = (props: PdfProps) => {\n const ctx = getCtx();\n const pdfInstance = ctx.getPdfInstance();\n const id = hooks.useId(undefined, `v-pdf-page-${props.pageNumber}`);\n const [spinning, setSpinning] = useState(true);\n\n const numPages = pdfInstance.numPages as number;\n\n fbaHooks.useEffectCustom(() => {\n pdfInstance.getPage(props.pageNumber).then(function (page) {\n const scale = props.scale || 1;\n let viewport = page.getViewport({ scale: scale });\n const customWidth = props.width;\n\n const canvas = document.getElementById(id) as any;\n const context = canvas.getContext('2d');\n\n if (customWidth && !props.scale) {\n const ratio = customWidth / viewport.width;\n viewport = page.getViewport({ scale: ratio });\n }\n let cssUnits = window.devicePixelRatio;\n cssUnits = cssUnits <= 1 ? 96 / 72 : cssUnits;\n canvas.width = Math.floor(viewport.width * cssUnits);\n canvas.height = Math.floor(viewport.height * cssUnits);\n\n canvas.style.width = `${viewport.width}px`;\n canvas.style.height = `${viewport.height}px`;\n\n const renderContext = {\n transform: [cssUnits, 0, 0, cssUnits, 0, 0],\n canvasContext: context,\n viewport: viewport,\n };\n const renderTask = page.render(renderContext);\n renderTask.promise\n .then(function () {\n props.onRenderSuccess?.(\n {\n width: viewport.width,\n height: viewport.height,\n scale: scale,\n pageNumber: props.pageNumber,\n page,\n },\n pdfInstance,\n );\n setSpinning(false);\n })\n .catch((error: any) => {\n console.error(error?.message);\n props.onRenderError?.(error, pdfInstance);\n setSpinning(false);\n });\n });\n }, [pdfInstance, props.scale, props.pageNumber]);\n\n const gap = typeof props.gap === 'undefined' ? 10 : props.gap;\n\n const style = numPages !== props.pageNumber ? { marginBottom: gap } : {};\n\n return (\n <div\n className={classNames('v-pdf-page', props.className)}\n style={{\n ...style,\n ...props.style,\n }}\n onClick={props.onClick}\n >\n <Spin spinning={spinning}>\n <canvas id={id}></canvas>\n </Spin>\n {props.children}\n </div>\n );\n};\n","import { PdfDocument } from './document';\nimport { PdfPage } from './page';\n\n/**\n * pdf预览\n * ```\n * 使用方式:在cdn.ts中引入 '//file.40017.cn/tcsk/react/pdf@3.2.146/pdf.min.js'\n * Git: https://github.com/mozilla/pdfjs-dist/tree/master\n * Demo: https://fex.qa.tcshuke.com/docs/admin/main/file/pdf\n * Demo: https://fex.qa.tcshuke.com/docs/admin/main/file/pdf-seal\n * ```\n */\nexport const Pdf = {\n Document: PdfDocument,\n Page: PdfPage,\n};\n"],"names":["_createCtx","_createCtx2","getCtx","CtxProvider","PdfDocument","props","_useState","useState","pdfInstance","setPdfInstance","_useState2","errorInst","setErrorInst","fbaHooks","useEffectCustomAsync","Promise","$return","$error","_ref","pdfjsLib","loadingTask","_pdfInstance","globalThis","GlobalWorkerOptions","workerSrc","$Try_1_Post","$boundEx","$Try_1_Catch","error","console","onLoadError","getDocument","url","pdfUrl","cMapUrl","cMapPacked","resolve","promise","then","$await_2","onLoadSuccess","getPdfInstance","_jsx","Result","status","title","subTitle","message","value","children","className","_classNames","Spin","PdfPage","ctx","id","_hooks","useId","undefined","pageNumber","spinning","setSpinning","numPages","useEffectCustom","getPage","page","scale","viewport","getViewport","customWidth","width","canvas","document","getElementById","context","getContext","ratio","cssUnits","window","devicePixelRatio","Math","floor","height","style","renderContext","transform","canvasContext","renderTask","render","onRenderSuccess","catch","onRenderError","gap","marginBottom","_jsxs","_extends","onClick","Pdf","Document","Page"],"mappings":";0gBAMO,IAAAA,EAA8BC,IAAvBC,EAAMF,EAAA,GAAEG,EAAWH,EAAA,GCU1B,IAAMI,EAAc,SAAdA,EAAeC,GAC1B,IAAAC,EAAsCC,IAA/BC,EAAWF,EAAA,GAAEG,EAAcH,EAAA,GAClC,IAAAI,EAAkCH,IAA3BI,EAASD,EAAA,GAAEE,EAAYF,EAAA,GAE9BG,EAASC,sBAAqB,WAAA,OAAA,IAAAC,SAAA,SAAAC,EAAAC,GAAA,IAAAC,EAAAC,EAIpBC,EAMAC,EATRH,EAAqBI,WAAbH,EAAQD,EAARC,SACRA,EAASI,oBAAoBC,UAAY,2DAtB7C,IAAIC,aAAJ,IAAI,OAAAT,GAAK,CAAC,MAAAU,GAAW,OAAOT,EAAAS,EAAM,GAAlC,IAAIC,EAAA,SAiCSC,GAjCb,IAkCMC,QAAQD,MAAMA,GACdvB,EAAMyB,aAANzB,MAAAA,EAAMyB,YAAcF,GACpBhB,EAAagB,GApCnB,OAAOH,GAAE,CAAC,MAAAC,GAAW,OAAOT,EAAAS,EAAM,GAuB9B,IACQN,EAAcD,EAASY,YAAY,CACvCC,IAAK3B,EAAM4B,OAEXC,QAAS,uDACTC,WAAY,OAEM,OAAApB,QAAAqB,QAAMhB,EAAYiB,SAAlBC,MAAyB,SAAAC,GA9BnD,IA8BY/B,EAAc+B,EACpB9B,EAAeD,GACfH,EAAMmC,eAANnC,MAAAA,EAAMmC,cAAgBhC,GAhC5B,OAAOiB,GAAE,CAAC,MAAAC,GAAW,OAAOC,EAAAD,EAAM,CAAC,GAAAC,EAiC9B,CAAC,MAAOC,GAAYD,EAAZC,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df/context.ts","@flatbiz/antd/src/pdf/document.tsx","@flatbiz/antd/src/pdf/page.tsx","@flatbiz/antd/src/pdf/index.ts"],"sourcesContent":["import { createCtx } from '@wove/react';\n\ntype CtxProps = {\n getPdfInstance: () => any;\n};\n\nexport const [getCtx, CtxProvider] = createCtx<CtxProps>();\n","import { classNames } from '@dimjs/utils';\nimport { Result, Spin } from 'antd';\nimport { ReactElement, ReactNode, useState } from 'react';\nimport { fbaHooks } from '../fba-hooks';\nimport { CtxProvider } from './context';\nimport './style.less';\n\ntype PdfProps = {\n pdfUrl: string;\n onLoadError?: (error: any) => void;\n onLoadSuccess?: (pdfInstance: any) => void;\n children: ReactNode;\n error?: ReactElement | ((error) => ReactElement);\n className?: string;\n};\n\nexport const PdfDocument = (props: PdfProps) => {\n const [pdfInstance, setPdfInstance] = useState<any>();\n const [errorInst, setErrorInst] = useState<any>();\n\n fbaHooks.useEffectCustomAsync(async () => {\n const { pdfjsLib } = globalThis as any;\n pdfjsLib.GlobalWorkerOptions.workerSrc = '//file.40017.cn/tcsk/react/pdf@3.2.146/pdf.worker.min.js';\n try {\n const loadingTask = pdfjsLib.getDocument({\n url: props.pdfUrl,\n // 避免服务端动态填充的字体不展示\n cMapUrl: 'https://file.40017.cn/tcsk/react/pdf@3.2.146/bcmaps/',\n cMapPacked: true,\n });\n const pdfInstance = await loadingTask.promise;\n setPdfInstance(pdfInstance);\n props.onLoadSuccess?.(pdfInstance);\n } catch (error: any) {\n console.error(error);\n props.onLoadError?.(error);\n setErrorInst(error);\n }\n }, [props.pdfUrl]);\n\n const getPdfInstance = () => {\n return pdfInstance;\n };\n\n if (errorInst) {\n if (props.error) {\n return typeof props.error === 'function' ? props.error(errorInst) : props.error;\n }\n return <Result status=\"error\" title=\"PDF加载异常\" subTitle={errorInst?.message}></Result>;\n }\n\n if (pdfInstance) {\n return (\n <CtxProvider value={{ getPdfInstance }}>\n <div className={classNames('v-pdf-document', props.className)}>{props.children}</div>\n </CtxProvider>\n );\n }\n\n return (\n <div className=\"v-pdf-document-init-loading\">\n <Spin />\n </div>\n );\n};\n","import { classNames } from '@dimjs/utils';\nimport { hooks } from '@wove/react';\nimport { Spin } from 'antd';\nimport { CSSProperties, ReactNode, useState } from 'react';\nimport { fbaHooks } from '../fba-hooks';\nimport { getCtx } from './context';\nimport './style.less';\n\ntype PdfProps = {\n onRenderSuccess?: (pageInstance: any, pdfInstance: any) => void;\n onRenderError?: (error: any, pdfInstance: any) => void;\n /** pdf page宽度,高度根据比例适配 */\n width?: number;\n /** 缩放比例,默认值:1,配置此参数后 width 属性失效,例如:1、0.6、0.8 */\n scale?: number;\n /** pdf页面上下之间的间隙,默认值10 */\n gap?: number;\n /** 页码 */\n pageNumber: number;\n children?: ReactNode;\n onClick?: (e) => void;\n className?: string;\n style?: CSSProperties;\n};\n\nexport const PdfPage = (props: PdfProps) => {\n const ctx = getCtx();\n const pdfInstance = ctx.getPdfInstance();\n const id = hooks.useId(undefined, `v-pdf-page-${props.pageNumber}`);\n const [spinning, setSpinning] = useState(true);\n\n const numPages = pdfInstance.numPages as number;\n\n fbaHooks.useEffectCustom(() => {\n pdfInstance.getPage(props.pageNumber).then(function (page) {\n const scale = props.scale || 1;\n let viewport = page.getViewport({ scale: scale });\n const customWidth = props.width;\n\n const canvas = document.getElementById(id) as any;\n const context = canvas.getContext('2d');\n\n if (customWidth && !props.scale) {\n const ratio = customWidth / viewport.width;\n viewport = page.getViewport({ scale: ratio });\n }\n let cssUnits = window.devicePixelRatio;\n cssUnits = cssUnits <= 1 ? 96 / 72 : cssUnits;\n canvas.width = Math.floor(viewport.width * cssUnits);\n canvas.height = Math.floor(viewport.height * cssUnits);\n\n canvas.style.width = `${viewport.width}px`;\n canvas.style.height = `${viewport.height}px`;\n\n const renderContext = {\n transform: [cssUnits, 0, 0, cssUnits, 0, 0],\n canvasContext: context,\n viewport: viewport,\n };\n const renderTask = page.render(renderContext);\n renderTask.promise\n .then(function () {\n props.onRenderSuccess?.(\n {\n width: viewport.width,\n height: viewport.height,\n scale: scale,\n pageNumber: props.pageNumber,\n page,\n },\n pdfInstance,\n );\n setSpinning(false);\n })\n .catch((error: any) => {\n console.error(error?.message);\n props.onRenderError?.(error, pdfInstance);\n setSpinning(false);\n });\n });\n }, [pdfInstance, props.scale, props.pageNumber]);\n\n const gap = typeof props.gap === 'undefined' ? 10 : props.gap;\n\n const style = numPages !== props.pageNumber ? { marginBottom: gap } : {};\n\n return (\n <div\n className={classNames('v-pdf-page', props.className)}\n style={{\n ...style,\n ...props.style,\n }}\n onClick={props.onClick}\n >\n <Spin spinning={spinning}>\n <canvas id={id}></canvas>\n </Spin>\n {props.children}\n </div>\n );\n};\n","import { PdfDocument } from './document';\nimport { PdfPage } from './page';\n\n/**\n * pdf预览\n * ```\n * 使用方式:在cdn.ts中引入 '//file.40017.cn/tcsk/react/pdf@3.2.146/pdf.min.js'\n * Git: https://github.com/mozilla/pdfjs-dist/tree/master\n * Demo: https://fex.qa.tcshuke.com/docs/admin/main/file/pdf\n * Demo: https://fex.qa.tcshuke.com/docs/admin/main/file/pdf-seal\n * ```\n */\nexport const Pdf = {\n Document: PdfDocument,\n Page: PdfPage,\n};\n"],"names":["_createCtx","_createCtx2","getCtx","CtxProvider","PdfDocument","props","_useState","useState","pdfInstance","setPdfInstance","_useState2","errorInst","setErrorInst","fbaHooks","useEffectCustomAsync","Promise","$return","$error","_ref","pdfjsLib","loadingTask","_pdfInstance","globalThis","GlobalWorkerOptions","workerSrc","$Try_1_Post","$boundEx","$Try_1_Catch","error","console","onLoadError","getDocument","url","pdfUrl","cMapUrl","cMapPacked","resolve","promise","then","$await_2","onLoadSuccess","getPdfInstance","_jsx","Result","status","title","subTitle","message","value","children","className","_classNames","Spin","PdfPage","ctx","id","_hooks","useId","undefined","pageNumber","spinning","setSpinning","numPages","useEffectCustom","getPage","page","scale","viewport","getViewport","customWidth","width","canvas","document","getElementById","context","getContext","ratio","cssUnits","window","devicePixelRatio","Math","floor","height","style","renderContext","transform","canvasContext","renderTask","render","onRenderSuccess","catch","onRenderError","gap","marginBottom","_jsxs","_extends","onClick","Pdf","Document","Page"],"mappings":";0gBAMO,IAAAA,EAA8BC,IAAvBC,EAAMF,EAAA,GAAEG,EAAWH,EAAA,GCU1B,IAAMI,EAAc,SAAdA,EAAeC,GAC1B,IAAAC,EAAsCC,IAA/BC,EAAWF,EAAA,GAAEG,EAAcH,EAAA,GAClC,IAAAI,EAAkCH,IAA3BI,EAASD,EAAA,GAAEE,EAAYF,EAAA,GAE9BG,EAASC,qBAAqB,WAAA,OAAA,IAAAC,QAAA,SAAAC,EAAAC,GAAA,IAAAC,EAAAC,EAIpBC,EAMAC,EATRH,EAAqBI,WAAbH,EAAQD,EAARC,SACRA,EAASI,oBAAoBC,UAAY,2DAtB7C,IAAIC,aAAJ,IAAI,OAAAT,GAAK,CAAC,MAAAU,GAAW,OAAOT,EAAAS,EAAM,GAAlC,IAAIC,EAAA,SAiCSC,GAjCb,IAkCMC,QAAQD,MAAMA,GACdvB,EAAMyB,aAANzB,MAAAA,EAAMyB,YAAcF,GACpBhB,EAAagB,GApCnB,OAAOH,GAAE,CAAC,MAAAC,GAAW,OAAOT,EAAAS,EAAM,GAuB9B,IACQN,EAAcD,EAASY,YAAY,CACvCC,IAAK3B,EAAM4B,OAEXC,QAAS,uDACTC,WAAY,OAEM,OAAApB,QAAAqB,QAAMhB,EAAYiB,SAAlBC,KAAyB,SAAAC,GA9BnD,IA8BY/B,EAAc+B,EACpB9B,EAAeD,GACfH,EAAMmC,eAANnC,MAAAA,EAAMmC,cAAgBhC,GAhC5B,OAAOiB,GAAE,CAAC,MAAAC,GAAW,OAAOC,EAAAD,EAAM,CAAC,EAAAC,EAiC9B,CAAC,MAAOC,GAAYD,EAAZC,EAIT,CAAC,EACF,EAAE,CAACvB,EAAM4B,SAEV,IAAMQ,EAAiB,SAAjBA,IACJ,OAAOjC,GAGT,GAAIG,EAAW,CACb,GAAIN,EAAMuB,MAAO,CACf,cAAcvB,EAAMuB,QAA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MAAWH,EAASG,MAAS,KAC1CC,EAAOY,MAAMD,OAAYf,EAASe,OAAU,KAE5C,IAAME,EAAgB,CACpBC,UAAW,CAACR,EAAU,EAAG,EAAGA,EAAU,EAAG,GACzCS,cAAeZ,EACfP,SAAUA,GAEZ,IAAMoB,EAAatB,EAAKuB,OAAOJ,GAC/BG,EAAWlD,QACRC,KAAK,WACJjC,EAAMoF,iBAAe,MAArBpF,EAAMoF,gBACJ,CACEnB,MAAOH,EAASG,MAChBY,OAAQf,EAASe,OACjBhB,MAAOA,EACPP,WAAYtD,EAAMsD,WAClBM,KAAAA,GAEFzD,GAEFqD,EAAY,MACd,GACC6B,MAAM,SAAC9D,GACNC,QAAQD,MAAMA,eAAAA,EAAOmB,SACrB1C,EAAMsF,eAAa,MAAnBtF,EAAMsF,cAAgB/D,EAAOpB,GAC7BqD,EAAY,MACd,EACJ,EACF,EAAG,CAACrD,EAAaH,EAAM6D,MAAO7D,EAAMsD,aAEpC,IAAMiC,SAAavF,EAAMuF,MAAQ,YAAc,GAAKvF,EAAMuF,IAE1D,IAAMT,EAAQrB,IAAazD,EAAMsD,WAAa,CAAEkC,aAAcD,GAAQ,GAEtE,OACEE,EAAA,MAAA,CACE5C,UAAWC,EAAW,aAAc9C,EAAM6C,WAC1CiC,MAAKY,EACAZ,CAAAA,EAAAA,EACA9E,EAAM8E,OAEXa,QAAS3F,EAAM2F,QAAQ/C,SAAA,CAEvBP,EAACU,EAAI,CAACQ,SAAUA,EAASX,SACvBP,EAAA,SAAA,CAAQa,GAAIA,MAEblD,EAAM4C,WAGb,ECzFO,IAAMgD,EAAM,CACjBC,SAAU9F,EACV+F,KAAM9C"}
|
package/esm/pdf-preview/index.js
CHANGED
|
@@ -4,5 +4,5 @@ import './../fba-hooks/index.css';
|
|
|
4
4
|
import './../roll-location-in-view/index.css';
|
|
5
5
|
import './index.css';
|
|
6
6
|
/*! @flatjs/forge MIT @flatbiz/antd */
|
|
7
|
-
import{classNames as e}from"@dimjs/utils/cjs/class-names";import{hooks as i}from"@wove/react/cjs/hooks";import{generateIntArray as r}from"@flatbiz/utils";import{Result as a}from"antd";import{useState as t,useRef as n,useMemo as o}from"react";import{Pdf as s}from"../pdf/index.js";import{RollLocationInView as c}from"../roll-location-in-view/index.js";import{jsx as l,jsxs as v}from"react/jsx-runtime";import"../fba-hooks/index.js";import"../_rollupPluginBabelHelpers-c0dbec57.js";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-
|
|
7
|
+
import{classNames as e}from"@dimjs/utils/cjs/class-names";import{hooks as i}from"@wove/react/cjs/hooks";import{generateIntArray as r}from"@flatbiz/utils";import{Result as a}from"antd";import{useState as t,useRef as n,useMemo as o}from"react";import{Pdf as s}from"../pdf/index.js";import{RollLocationInView as c}from"../roll-location-in-view/index.js";import{jsx as l,jsxs as v}from"react/jsx-runtime";import"../fba-hooks/index.js";import"../_rollupPluginBabelHelpers-c0dbec57.js";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-1e6d93d9.js";import"@dimjs/utils/cjs/uuid";import"@wove/react/cjs/create-ctx";import"ahooks";var d=function i(a){var t=typeof a.navigationWidth==="undefined"?200:a.navigationWidth;return l(c,{activeKey:""+a.activeNumber,behavior:"auto",style:{width:t},renderList:r(1,a.numPages+1).map(function(i){return{activeKey:""+i,render:v("div",{className:e("v-pdf-preview-navigation-content",{"v-pdf-preview-navigation-active":i===a.activeNumber}),children:[l(s.Page,{pageNumber:i,gap:0,scale:a.scale||.2,className:e("v-pdf-preview-navigation-page"),onClick:function e(){a.onChangeActiveNumber(i);var r=document.querySelector("#"+a.pdfContentNodeId);if(r){if(i===1){r.scrollTo(0,0)}else{var t=a.pdfPageListHeightScope[i-1][0];r.scrollTo(0,t)}}}}),v("div",{className:"v-pdf-preview-navigation-pagination",children:["- ",i," -"]})]},i)}})})};var p=function c(p){var u=t(0),f=u[0],m=u[1];var g=n(null);var h=t(1),N=h[0],j=h[1];var b=t(0),w=b[0],P=b[1];var y=10;var x=i.useCallbackRef(function(e){m(e.numPages)});var C=o(function(){if(!f)return[];var e=[];r(0,f).forEach(function(i){if(i===0){e.push([0,w])}else{var r=w*i+i*y;e.push([r,r+w])}});return e},[f,w]);var S=function e(i){var r;var a=i.target.scrollTop;var t=(r=g.current)==null?void 0:r.clientHeight;for(var n=0;n<C.length;n++){var o=C[n];if(o[1]-a>=t/2){j(n+1);break}}};var k=i.useId(undefined,"pdf-content-node");return v(s.Document,{pdfUrl:p.pdfUrl,onLoadSuccess:x,error:l(a,{status:"500",title:"PDF加载异常",subTitle:"PDF地址:"+p.pdfUrl}),className:e("v-pdf-preview-document",p.className),children:[!p.hiddenNavigation?l("div",{className:"v-pdf-preview-navigation",children:l(d,{numPages:f,activeNumber:N,onChangeActiveNumber:j,scale:p.navigationScale,navigationWidth:p.navigationWidth,pdfPageListHeightScope:C,pdfContentNodeId:k})}):null,l("div",{className:"v-pdf-preview-content",onScroll:S,ref:g,id:k,children:f>0?r(1,f+1).map(function(e){return l(s.Page,{pageNumber:e,scale:p.scale,gap:y,onRenderSuccess:function e(i){var r=Math.floor(i.height);P(r)},style:{display:"flex",justifyContent:"center"}},e)}):null})]})};export{p as PdfPreview};
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["@flatbiz/antd/src/pdf-preview/navigation.tsx","@flatbiz/antd/src/pdf-preview/preview.tsx"],"sourcesContent":["import { classNames } from '@dimjs/utils';\nimport { generateIntArray } from '@flatbiz/utils';\nimport { Pdf } from '../pdf';\nimport { RollLocationInView } from '../roll-location-in-view';\n\ntype NavigationProps = {\n numPages: number;\n activeNumber: number;\n onChangeActiveNumber: (active: number) => void;\n scale?: number;\n navigationWidth?: number;\n pdfPageListHeightScope: number[][];\n pdfContentNodeId: string;\n};\nexport const Navigation = (props: NavigationProps) => {\n const navigationWidth = typeof props.navigationWidth === 'undefined' ? 200 : props.navigationWidth;\n return (\n <RollLocationInView\n activeKey={`${props.activeNumber}`}\n behavior=\"auto\"\n style={{ width: navigationWidth }}\n renderList={generateIntArray(1, props.numPages + 1).map((pageNumer) => {\n return {\n activeKey: `${pageNumer}`,\n render: (\n <div\n key={pageNumer}\n className={classNames('v-pdf-preview-navigation-content', {\n 'v-pdf-preview-navigation-active': pageNumer === props.activeNumber,\n })}\n >\n <Pdf.Page\n pageNumber={pageNumer}\n gap={0}\n scale={props.scale || 0.2}\n className={classNames('v-pdf-preview-navigation-page')}\n onClick={() => {\n props.onChangeActiveNumber(pageNumer);\n const scroll = document.querySelector(`#${props.pdfContentNodeId}`) as HTMLDivElement;\n if (scroll) {\n if (pageNumer === 1) {\n scroll.scrollTo(0, 0);\n } else {\n const top = props.pdfPageListHeightScope[pageNumer - 1][0];\n scroll.scrollTo(0, top);\n }\n }\n }}\n ></Pdf.Page>\n\n <div className=\"v-pdf-preview-navigation-pagination\">- {pageNumer} -</div>\n </div>\n ),\n };\n })}\n />\n );\n};\n","import { classNames } from '@dimjs/utils';\nimport { generateIntArray } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { Result } from 'antd';\nimport { useMemo, useRef, useState } from 'react';\nimport { Pdf } from '../pdf';\nimport { Navigation } from './navigation';\nimport './style.less';\n\nexport type PdfPreviewProps = {\n pdfUrl: string;\n /** 缩放比例,默认值:1 */\n scale?: number;\n className?: string;\n /** 导航pdf,缩放比例,默认值:0.2 */\n navigationScale?: number;\n /** 隐藏导航栏 */\n hiddenNavigation?: boolean;\n /** 导航栏宽度,默认值:200 */\n navigationWidth?: number;\n};\n\n/**\n * pdf预览方式1\n * ```\n * 使用方式:在cdn.ts中引入 '//file.40017.cn/tcsk/react/pdf@3.2.146/pdf.min.js'\n * Git: https://github.com/mozilla/pdfjs-dist/tree/master\n * Demo: https://fex.qa.tcshuke.com/docs/admin/main/file/pdf\n * Demo: https://fex.qa.tcshuke.com/docs/admin/main/file/pdf-seal\n * ```\n */\nexport const PdfPreview = (props: PdfPreviewProps) => {\n const [numPages, setNumPages] = useState(0);\n const dpfDoucmentRef = useRef<HTMLDivElement>(null);\n const [activePagination, setActivePagination] = useState(1);\n const [pdfPageHeight, setPdfPageHeight] = useState(0);\n\n const pageGap = 10;\n\n const onDocumentLoadSuccess = hooks.useCallbackRef((inst) => {\n setNumPages(inst.numPages);\n });\n\n /** 计算 page 在文档流中的高度范围,包含竖直方向间距 */\n const pdfPageListHeightScope = useMemo(() => {\n if (!numPages) return [];\n const pageHeightScopeList: number[][] = [];\n generateIntArray(0, numPages).forEach((item) => {\n if (item === 0) {\n pageHeightScopeList.push([0, pdfPageHeight]);\n } else {\n const x = pdfPageHeight * item + item * pageGap;\n pageHeightScopeList.push([x, x + pdfPageHeight]);\n }\n });\n return pageHeightScopeList;\n }, [numPages, pdfPageHeight]);\n\n const onDocumentCenterScroll = (event) => {\n const scrollTop = event.target.scrollTop;\n const scrollHeight = dpfDoucmentRef.current?.clientHeight as number;\n for (let index = 0; index < pdfPageListHeightScope.length; index++) {\n const element = pdfPageListHeightScope[index];\n if (element[1] - scrollTop >= scrollHeight / 2) {\n setActivePagination(index + 1);\n break;\n }\n }\n };\n\n const pdfContentNodeId = hooks.useId(undefined, 'pdf-content-node');\n\n return (\n <Pdf.Document\n pdfUrl={props.pdfUrl}\n onLoadSuccess={onDocumentLoadSuccess}\n error={<Result status=\"500\" title=\"PDF加载异常\" subTitle={`PDF地址:${props.pdfUrl}`} />}\n className={classNames('v-pdf-preview-document', props.className)}\n >\n {!props.hiddenNavigation ? (\n <div className=\"v-pdf-preview-navigation\">\n <Navigation\n numPages={numPages}\n activeNumber={activePagination}\n onChangeActiveNumber={setActivePagination}\n scale={props.navigationScale}\n navigationWidth={props.navigationWidth}\n pdfPageListHeightScope={pdfPageListHeightScope}\n pdfContentNodeId={pdfContentNodeId}\n />\n </div>\n ) : null}\n\n <div\n className=\"v-pdf-preview-content\"\n onScroll={onDocumentCenterScroll}\n ref={dpfDoucmentRef}\n id={pdfContentNodeId}\n >\n {numPages > 0\n ? generateIntArray(1, numPages + 1).map((item) => {\n return (\n <Pdf.Page\n key={item}\n pageNumber={item}\n scale={props.scale}\n gap={pageGap}\n onRenderSuccess={(node) => {\n const h = Math.floor(node.height);\n setPdfPageHeight(h);\n }}\n style={{ display: 'flex', justifyContent: 'center' }}\n ></Pdf.Page>\n );\n })\n : null}\n </div>\n </Pdf.Document>\n );\n};\n"],"names":["Navigation","props","navigationWidth","_jsx","RollLocationInView","activeKey","activeNumber","behavior","style","width","renderList","generateIntArray","numPages","map","pageNumer","render","_jsxs","className","_classNames","children","Pdf","Page","pageNumber","gap","scale","onClick","onChangeActiveNumber","scroll","document","querySelector","pdfContentNodeId","scrollTo","top","pdfPageListHeightScope","PdfPreview","_useState","useState","setNumPages","dpfDoucmentRef","useRef","_useState2","activePagination","setActivePagination","_useState3","pdfPageHeight","setPdfPageHeight","pageGap","onDocumentLoadSuccess","_hooks","useCallbackRef","inst","useMemo","pageHeightScopeList","forEach","item","push","x","onDocumentCenterScroll","event","_dpfDoucmentRef$curre","scrollTop","target","scrollHeight","current","clientHeight","index","length","element","useId","undefined","Document","pdfUrl","onLoadSuccess","error","Result","status","title","subTitle","hiddenNavigation","navigationScale","onScroll","ref","id","onRenderSuccess","node","h","Math","floor","height","display","justifyContent"],"mappings":";6nBAcO,IAAMA,EAAa,SAAbA,EAAcC,GACzB,IAAMC,SAAyBD,EAAMC,kBAAoB,YAAc,IAAMD,EAAMC,gBACnF,OACEC,EAACC,EAAkB,CACjBC,UAAS,GAAKJ,EAAMK,aACpBC,SAAS,OACTC,MAAO,CAAEC,MAAOP,GAChBQ,WAAYC,EAAiB,EAAGV,EAAMW,SAAW,GAAGC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["@flatbiz/antd/src/pdf-preview/navigation.tsx","@flatbiz/antd/src/pdf-preview/preview.tsx"],"sourcesContent":["import { classNames } from '@dimjs/utils';\nimport { generateIntArray } from '@flatbiz/utils';\nimport { Pdf } from '../pdf';\nimport { RollLocationInView } from '../roll-location-in-view';\n\ntype NavigationProps = {\n numPages: number;\n activeNumber: number;\n onChangeActiveNumber: (active: number) => void;\n scale?: number;\n navigationWidth?: number;\n pdfPageListHeightScope: number[][];\n pdfContentNodeId: string;\n};\nexport const Navigation = (props: NavigationProps) => {\n const navigationWidth = typeof props.navigationWidth === 'undefined' ? 200 : props.navigationWidth;\n return (\n <RollLocationInView\n activeKey={`${props.activeNumber}`}\n behavior=\"auto\"\n style={{ width: navigationWidth }}\n renderList={generateIntArray(1, props.numPages + 1).map((pageNumer) => {\n return {\n activeKey: `${pageNumer}`,\n render: (\n <div\n key={pageNumer}\n className={classNames('v-pdf-preview-navigation-content', {\n 'v-pdf-preview-navigation-active': pageNumer === props.activeNumber,\n })}\n >\n <Pdf.Page\n pageNumber={pageNumer}\n gap={0}\n scale={props.scale || 0.2}\n className={classNames('v-pdf-preview-navigation-page')}\n onClick={() => {\n props.onChangeActiveNumber(pageNumer);\n const scroll = document.querySelector(`#${props.pdfContentNodeId}`) as HTMLDivElement;\n if (scroll) {\n if (pageNumer === 1) {\n scroll.scrollTo(0, 0);\n } else {\n const top = props.pdfPageListHeightScope[pageNumer - 1][0];\n scroll.scrollTo(0, top);\n }\n }\n }}\n ></Pdf.Page>\n\n <div className=\"v-pdf-preview-navigation-pagination\">- {pageNumer} -</div>\n </div>\n ),\n };\n })}\n />\n );\n};\n","import { classNames } from '@dimjs/utils';\nimport { generateIntArray } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { Result } from 'antd';\nimport { useMemo, useRef, useState } from 'react';\nimport { Pdf } from '../pdf';\nimport { Navigation } from './navigation';\nimport './style.less';\n\nexport type PdfPreviewProps = {\n pdfUrl: string;\n /** 缩放比例,默认值:1 */\n scale?: number;\n className?: string;\n /** 导航pdf,缩放比例,默认值:0.2 */\n navigationScale?: number;\n /** 隐藏导航栏 */\n hiddenNavigation?: boolean;\n /** 导航栏宽度,默认值:200 */\n navigationWidth?: number;\n};\n\n/**\n * pdf预览方式1\n * ```\n * 使用方式:在cdn.ts中引入 '//file.40017.cn/tcsk/react/pdf@3.2.146/pdf.min.js'\n * Git: https://github.com/mozilla/pdfjs-dist/tree/master\n * Demo: https://fex.qa.tcshuke.com/docs/admin/main/file/pdf\n * Demo: https://fex.qa.tcshuke.com/docs/admin/main/file/pdf-seal\n * ```\n */\nexport const PdfPreview = (props: PdfPreviewProps) => {\n const [numPages, setNumPages] = useState(0);\n const dpfDoucmentRef = useRef<HTMLDivElement>(null);\n const [activePagination, setActivePagination] = useState(1);\n const [pdfPageHeight, setPdfPageHeight] = useState(0);\n\n const pageGap = 10;\n\n const onDocumentLoadSuccess = hooks.useCallbackRef((inst) => {\n setNumPages(inst.numPages);\n });\n\n /** 计算 page 在文档流中的高度范围,包含竖直方向间距 */\n const pdfPageListHeightScope = useMemo(() => {\n if (!numPages) return [];\n const pageHeightScopeList: number[][] = [];\n generateIntArray(0, numPages).forEach((item) => {\n if (item === 0) {\n pageHeightScopeList.push([0, pdfPageHeight]);\n } else {\n const x = pdfPageHeight * item + item * pageGap;\n pageHeightScopeList.push([x, x + pdfPageHeight]);\n }\n });\n return pageHeightScopeList;\n }, [numPages, pdfPageHeight]);\n\n const onDocumentCenterScroll = (event) => {\n const scrollTop = event.target.scrollTop;\n const scrollHeight = dpfDoucmentRef.current?.clientHeight as number;\n for (let index = 0; index < pdfPageListHeightScope.length; index++) {\n const element = pdfPageListHeightScope[index];\n if (element[1] - scrollTop >= scrollHeight / 2) {\n setActivePagination(index + 1);\n break;\n }\n }\n };\n\n const pdfContentNodeId = hooks.useId(undefined, 'pdf-content-node');\n\n return (\n <Pdf.Document\n pdfUrl={props.pdfUrl}\n onLoadSuccess={onDocumentLoadSuccess}\n error={<Result status=\"500\" title=\"PDF加载异常\" subTitle={`PDF地址:${props.pdfUrl}`} />}\n className={classNames('v-pdf-preview-document', props.className)}\n >\n {!props.hiddenNavigation ? (\n <div className=\"v-pdf-preview-navigation\">\n <Navigation\n numPages={numPages}\n activeNumber={activePagination}\n onChangeActiveNumber={setActivePagination}\n scale={props.navigationScale}\n navigationWidth={props.navigationWidth}\n pdfPageListHeightScope={pdfPageListHeightScope}\n pdfContentNodeId={pdfContentNodeId}\n />\n </div>\n ) : null}\n\n <div\n className=\"v-pdf-preview-content\"\n onScroll={onDocumentCenterScroll}\n ref={dpfDoucmentRef}\n id={pdfContentNodeId}\n >\n {numPages > 0\n ? generateIntArray(1, numPages + 1).map((item) => {\n return (\n <Pdf.Page\n key={item}\n pageNumber={item}\n scale={props.scale}\n gap={pageGap}\n onRenderSuccess={(node) => {\n const h = Math.floor(node.height);\n setPdfPageHeight(h);\n }}\n style={{ display: 'flex', justifyContent: 'center' }}\n ></Pdf.Page>\n );\n })\n : null}\n </div>\n </Pdf.Document>\n );\n};\n"],"names":["Navigation","props","navigationWidth","_jsx","RollLocationInView","activeKey","activeNumber","behavior","style","width","renderList","generateIntArray","numPages","map","pageNumer","render","_jsxs","className","_classNames","children","Pdf","Page","pageNumber","gap","scale","onClick","onChangeActiveNumber","scroll","document","querySelector","pdfContentNodeId","scrollTo","top","pdfPageListHeightScope","PdfPreview","_useState","useState","setNumPages","dpfDoucmentRef","useRef","_useState2","activePagination","setActivePagination","_useState3","pdfPageHeight","setPdfPageHeight","pageGap","onDocumentLoadSuccess","_hooks","useCallbackRef","inst","useMemo","pageHeightScopeList","forEach","item","push","x","onDocumentCenterScroll","event","_dpfDoucmentRef$curre","scrollTop","target","scrollHeight","current","clientHeight","index","length","element","useId","undefined","Document","pdfUrl","onLoadSuccess","error","Result","status","title","subTitle","hiddenNavigation","navigationScale","onScroll","ref","id","onRenderSuccess","node","h","Math","floor","height","display","justifyContent"],"mappings":";6nBAcO,IAAMA,EAAa,SAAbA,EAAcC,GACzB,IAAMC,SAAyBD,EAAMC,kBAAoB,YAAc,IAAMD,EAAMC,gBACnF,OACEC,EAACC,EAAkB,CACjBC,UAAS,GAAKJ,EAAMK,aACpBC,SAAS,OACTC,MAAO,CAAEC,MAAOP,GAChBQ,WAAYC,EAAiB,EAAG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3C,EAAiBwC,EACjB,EACF7E,MAAO,CAAEiF,QAAS,OAAQC,eAAgB,WARrCpC,EAWV,GACD,SAIZ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
import './index.css';
|
|
3
3
|
/*! @flatjs/forge MIT @flatbiz/antd */
|
|
4
|
-
import{valueIsEqual as n}from"@flatbiz/utils";import{Space as e,Radio as r}from"antd";import{jsx as t}from"react/jsx-runtime";var i=function i(a){var u=function n(e){return new Promise(
|
|
4
|
+
import{valueIsEqual as n}from"@flatbiz/utils";import{Space as e,Radio as r}from"antd";import{jsx as t}from"react/jsx-runtime";var i=function i(a){var u=function n(e){return new Promise(function(n,r){var t;t=e.target.value;if(a.onPreChange){return Promise.resolve(a.onPreChange(t)).then(function(n){try{return i.call(this)}catch(n){return r(n)}}.bind(this),r)}function i(){a.onChange==null||a.onChange(t);return n()}return i.call(this)})};var o=function e(r){if(!a.isCancel)return;var t=r.target.value;if(n(a.value,t)){a.onChange==null||a.onChange(undefined)}};return t(e,{size:5,wrap:true,direction:a.direction,children:a.options.map(function(n){return t(r,{value:n.value,onClick:o,checked:a.value===n.value,onChange:u,disabled:a.disabled||n.disabled,children:n.label},String(n.value))})})};export{i as RadioGroupWrapper};
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["@flatbiz/antd/src/radio-group-wrapper/radio-group-wrapper.tsx"],"sourcesContent":["import { valueIsEqual } from '@flatbiz/utils';\nimport { Radio, Space } from 'antd';\nimport { ReactElement } from 'react';\n\nexport type RadioGroupWrapperValue = string | number | boolean;\n\nexport type RadioGroupWrapperOptionItem = {\n label: string | ReactElement;\n value: RadioGroupWrapperValue;\n disabled?: boolean;\n};\n\nexport type CustomRadioGroupProps = {\n value?: RadioGroupWrapperValue;\n onChange?: (value?: RadioGroupWrapperValue) => void;\n onPreChange?: (value?: RadioGroupWrapperValue) => Promise<void>;\n options: RadioGroupWrapperOptionItem[];\n /** 是否可取消选中,默认:false */\n isCancel?: boolean;\n disabled?: boolean;\n /**方向,默认值 horizontal */\n direction?: 'horizontal' | 'vertical';\n};\n\n/**\n * RadioGroupWrapper 为了解决 RadioGroup 组件不能取消选中问题\n * @param props\n * @returns\n */\nexport const RadioGroupWrapper = (props: CustomRadioGroupProps) => {\n const onChange = async (event) => {\n const value = event.target.value;\n if (props.onPreChange) {\n await props.onPreChange(value);\n }\n props.onChange?.(value);\n };\n const onClick = (event) => {\n if (!props.isCancel) return;\n const value = event.target.value;\n if (valueIsEqual(props.value, value)) {\n props.onChange?.(undefined);\n }\n };\n return (\n <Space size={5} wrap={true} direction={props.direction}>\n {props.options.map((item) => {\n return (\n <Radio\n value={item.value}\n onClick={onClick}\n checked={props.value === item.value}\n key={String(item.value)}\n onChange={onChange}\n disabled={props.disabled || item.disabled}\n >\n {item.label}\n </Radio>\n );\n })}\n </Space>\n );\n};\n"],"names":["RadioGroupWrapper","props","onChange","event","Promise","$return","$error","value","target","onPreChange","resolve","then","$await_2","$If_1","call","this","$boundEx","bind","onClick","isCancel","valueIsEqual","undefined","_jsx","Space","size","wrap","direction","children","options","map","item","Radio","checked","disabled","label","String"],"mappings":";kIA6BaA,EAAoB,SAApBA,EAAqBC,GAChC,IAAMC,EAAW,SAAXA,EAAkBC,GAAP,OAAA,IAAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["@flatbiz/antd/src/radio-group-wrapper/radio-group-wrapper.tsx"],"sourcesContent":["import { valueIsEqual } from '@flatbiz/utils';\nimport { Radio, Space } from 'antd';\nimport { ReactElement } from 'react';\n\nexport type RadioGroupWrapperValue = string | number | boolean;\n\nexport type RadioGroupWrapperOptionItem = {\n label: string | ReactElement;\n value: RadioGroupWrapperValue;\n disabled?: boolean;\n};\n\nexport type CustomRadioGroupProps = {\n value?: RadioGroupWrapperValue;\n onChange?: (value?: RadioGroupWrapperValue) => void;\n onPreChange?: (value?: RadioGroupWrapperValue) => Promise<void>;\n options: RadioGroupWrapperOptionItem[];\n /** 是否可取消选中,默认:false */\n isCancel?: boolean;\n disabled?: boolean;\n /**方向,默认值 horizontal */\n direction?: 'horizontal' | 'vertical';\n};\n\n/**\n * RadioGroupWrapper 为了解决 RadioGroup 组件不能取消选中问题\n * @param props\n * @returns\n */\nexport const RadioGroupWrapper = (props: CustomRadioGroupProps) => {\n const onChange = async (event) => {\n const value = event.target.value;\n if (props.onPreChange) {\n await props.onPreChange(value);\n }\n props.onChange?.(value);\n };\n const onClick = (event) => {\n if (!props.isCancel) return;\n const value = event.target.value;\n if (valueIsEqual(props.value, value)) {\n props.onChange?.(undefined);\n }\n };\n return (\n <Space size={5} wrap={true} direction={props.direction}>\n {props.options.map((item) => {\n return (\n <Radio\n value={item.value}\n onClick={onClick}\n checked={props.value === item.value}\n key={String(item.value)}\n onChange={onChange}\n disabled={props.disabled || item.disabled}\n >\n {item.label}\n </Radio>\n );\n })}\n </Space>\n );\n};\n"],"names":["RadioGroupWrapper","props","onChange","event","Promise","$return","$error","value","target","onPreChange","resolve","then","$await_2","$If_1","call","this","$boundEx","bind","onClick","isCancel","valueIsEqual","undefined","_jsx","Space","size","wrap","direction","children","options","map","item","Radio","checked","disabled","label","String"],"mappings":";kIA6BaA,EAAoB,SAApBA,EAAqBC,GAChC,IAAMC,EAAW,SAAXA,EAAkBC,GAAP,OAAA,IAAAC,QAAA,SAAAC,EAAAC,GAAA,IACTC,EAAAA,EAAQJ,EAAMK,OAAOD,MAC3B,GAAIN,EAAMQ,YAAa,CACrB,OAAAL,QAAAM,QAAMT,EAAMQ,YAAYF,IAAxBI,KAjCN,SAAAC,GAAA,IAAI,OAAJC,EAAGC,KAAIC,KAAE,CAAC,MAAAC,GAAW,OAAOV,EAAAU,EAAM,CAAC,EAAhCC,KAAKF,MAAKT,EAkCT,CAAC,SAAAO,IACDZ,EAAMC,UAAND,MAAAA,EAAMC,SAAWK,GAAO,OAAAF,GAAA,CAAA,OAnC5BQ,EAAGC,KAAIC,KAAI,EAoCR,EACD,IAAMG,EAAU,SAAVA,EAAWf,GACf,IAAKF,EAAMkB,SAAU,OACrB,IAAMZ,EAAQJ,EAAMK,OAAOD,MAC3B,GAAIa,EAAanB,EAAMM,MAAOA,GAAQ,CACpCN,EAAMC,UAAND,MAAAA,EAAMC,SAAWmB,UACnB,GAEF,OACEC,EAACC,EAAK,CAACC,KAAM,EAAGC,KAAM,KAAMC,UAAWzB,EAAMyB,UAAUC,SACpD1B,EAAM2B,QAAQC,IAAI,SAACC,GAClB,OACER,EAACS,EAAK,CACJxB,MAAOuB,EAAKvB,MACZW,QAASA,EACTc,QAAS/B,EAAMM,QAAUuB,EAAKvB,MAE9BL,SAAUA,EACV+B,SAAUhC,EAAMgC,UAAYH,EAAKG,SAASN,SAEzCG,EAAKI,OAJDC,OAAOL,EAAKvB,WAU7B"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import './../fba-hooks/index.css';
|
|
3
3
|
import './index.css';
|
|
4
4
|
/*! @flatjs/forge MIT @flatbiz/antd */
|
|
5
|
-
import{hooks as e}from"@wove/react/cjs/hooks";import{_ as n}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{classNames as r}from"@dimjs/utils/cjs/class-names";import{Tag as i,Empty as t,Form as l}from"antd";import{useState as a,createElement as o,Fragment as c}from"react";import{fbaHooks as s}from"../fba-hooks/index.js";import{jsxs as u,jsx as d}from"react/jsx-runtime";import"@dimjs/lang/cjs/is-array";import"@flatbiz/utils";import"../use-responsive-point-
|
|
5
|
+
import{hooks as e}from"@wove/react/cjs/hooks";import{_ as n}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{classNames as r}from"@dimjs/utils/cjs/class-names";import{Tag as i,Empty as t,Form as l}from"antd";import{useState as a,createElement as o,Fragment as c}from"react";import{fbaHooks as s}from"../fba-hooks/index.js";import{jsxs as u,jsx as d}from"react/jsx-runtime";import"@dimjs/lang/cjs/is-array";import"@flatbiz/utils";import"../use-responsive-point-1e6d93d9.js";import"@dimjs/utils/cjs/uuid";var m=function e(n){var t;var l={"--relation-tagline-width":(n.tagLineWidth||40)+"px","--relation-group-indent-width":(n.indentWidth||80)+"px","--relation-tag-width":(n.tagWidth||26)+"px","--relation-line-color":""+(n.lineColor||"#fda148")};var a=r("relation-list",{"relation-list-only-one":n.onlyOne,"relation-list-only-no-main-one":n.onlyOne},n.className);var o=n.solt1,c=n.solt2;return u("div",{className:a,style:l,children:[o?u("div",{className:"relation-list-solt1",children:[d("div",{className:"relation-list-line"}),d("div",{className:"relation-list-label",children:n.label}),n.tagName?d(i,{className:"relation-item-tag",color:n.tagColor||"#fecd96",onClick:(t=n.onTagClick)==null?void 0:t.bind(null,n.tagName),children:n.tagName}):null,o()]}):null,c?d("div",{className:"relation-list-solt2",children:c()}):null]})};var f=function e(n){return d("div",{className:r("relation-group-list",n.className),children:n.children})};var h=function e(n){var i=r("relation-item",{"relation-item-line":true,"relation-item-first":n.isFirst,"relation-item-last":n.isLast,"relation-item-only-one":n.onlyOne});return d("div",{className:i,style:n.style,children:n.children})};var v=function e(n,r){var i;if(n.uid===r){n["_delete"]=true}n==null||(i=n.relationList)==null||i.forEach(function(e){var i,t;if(e.uid===r||((i=e.customData)==null?void 0:i.uid)===r){e["_delete"]=true;if(n.relationList.length===1){n["_delete"]=true}}(t=e.children)==null||t.forEach(function(e){v(e,r)})})};var g=function e(n){n.relationList=n.relationList||[];n.relationList=n.relationList.filter(function(e){return!e["_delete"]});n.relationList.forEach(function(e){e.children=e.children||[];e.children=e.children.filter(function(e){return!e["_delete"]});e.children.forEach(function(e){g(e)})});n.relationList=n.relationList.filter(function(e){if(!e.customData&&!e.children){return false}if(!e.customData&&(!e.children||e.children.length===0)){return false}return true})};var p=function e(n){var i=n.relationItem;var t=n.dataSource;var a=n.index;if(i.customData&&i.children&&i.children.length>0){var o;return u(c,{children:[d(h,{isFirst:a===0,isLast:a===t.relationList.length-1,onlyOne:n.onlyOne,children:n.relationItemRender(i.customData,i.extraData)}),d(f,{children:(o=i.children)==null?void 0:o.map(function(e){return d(C,{dataSource:e,relationItemRender:n.relationItemRender,relationProps:n.relationProps,onTagClick:n.onTagClick,className:n.className},e.uid)})})]},i.uid)}if(i.children&&i.children.length>0){var s;return d("div",{className:r("form-list-no-main-group",{"form-list-no-main-group":a===0}),children:(s=i.children)==null?void 0:s.map(function(e){return d(C,{dataSource:e,relationItemRender:n.relationItemRender,className:r("form-list-no-main",{"form-list-no-main-first":a===0,"form-list-no-main-last":a===t.relationList.length-1}),relationProps:n.relationProps,onTagClick:n.onTagClick},e.uid)})},i.uid)}if(i.customData){return d(h,{isFirst:a===0,isLast:a===t.relationList.length-1,onlyOne:n.onlyOne,children:d(l,{component:false,children:n.relationItemRender(i.customData,i.extraData)})},i.uid)}return null};var C=function e(r){var i=r.dataSource;var t=i.relationList||[];var l=t[t.length-1];var a=t.length>0&&l.customData&&l.children&&l.children.length>0;var s=t.length==1;return o(m,n({},r.relationProps,{tagName:i.tagName,key:i.uid,onlyOne:s,label:i.label,className:r.className,onTagClick:function e(){r.onTagClick==null||r.onTagClick(i.uid,i.extraData)},solt1:function e(){return d(c,{children:t.map(function(e,i){var l=a&&i===t.length-1;return d(p,{dataSource:r.dataSource,relationItemRender:r.relationItemRender,relationProps:r.relationProps,onTagClick:r.onTagClick,relationItem:l?n({},e,{children:undefined}):e,index:i,onlyOne:s},i)})})},solt2:function e(){if(a&&l.children&&l.children.length>0){return d(f,{children:l.children.map(function(e){return d(C,{dataSource:e,relationItemRender:r.relationItemRender,relationProps:r.relationProps,onTagClick:r.onTagClick},e.uid)})},l.uid)}return null}}))};var N=function i(l){var o=a(),c=o[0],u=o[1];s.useEffectCustom(function(){u(l.dataSource)},[l.dataSource]);var m=e.useCallbackRef(function(e,r,i){if(e){e[r]=i;l.onChange==null||l.onChange(n({},c))}});var f=function e(n,r){for(var i=0;i<n.length;i++){var t=n[i];for(var l=0;l<t.relationList.length;l++){var a;var o=t.relationList[l];if(((a=o.customData)==null?void 0:a.uid)===r){return{relationTree:t,index:l,element:o}}else if(o.children){var c=f(o.children,r);if(c){return c}}}}return null};var h=e.useCallbackRef(function(e,n){var r;if(!c)return;var i=f([c],e.uid);if((r=i.relationTree)!=null&&r.relationList){var t;(t=i.relationTree)==null||t.relationList.splice(i.index+1,0,n);l.onChange==null||l.onChange(c)}});var p=e.useCallbackRef(function(e,n){if(!c)return;var r=f([c],e.uid);if(r.element){r.element.children=(r.element.children||[]).concat(n);l.onChange==null||l.onChange(c)}});var N=e.useCallbackRef(function(e){if(!c)return;v(c,e);if(c["_delete"]){l.onChange==null||l.onChange(undefined)}else{g(c);l.onChange==null||l.onChange(c)}});if(!c)return d(t,{description:"暂无数据"});return d("div",{className:r("relation-tree",l.className),children:d(C,{dataSource:c,relationProps:l.relationProps,onTagClick:l.onTagClick,relationItemRender:function e(n,r){return l.children(n,{add:h,addChildren:p,remove:N,onChange:m.bind(null,n)},r)}})})};export{N as RelationTree};
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["@flatbiz/antd/src/relation-tree/compts/relation.tsx","@flatbiz/antd/src/relation-tree/compts/relation-group-list.tsx","@flatbiz/antd/src/relation-tree/compts/relation-item.tsx","@flatbiz/antd/src/relation-tree/utils.ts","@flatbiz/antd/src/relation-tree/relation-tree.tsx"],"sourcesContent":["import { classNames } from '@dimjs/utils';\nimport { Tag } from 'antd';\nimport { CSSProperties } from 'react';\nimport { RelationProps } from '../type';\n\nexport const Relation = (props: RelationProps) => {\n const style = {\n '--relation-tagline-width': `${props.tagLineWidth || 40}px`,\n '--relation-group-indent-width': `${props.indentWidth || 80}px`,\n '--relation-tag-width': `${props.tagWidth || 26}px`,\n '--relation-line-color': `${props.lineColor || '#fda148'}`,\n } as CSSProperties;\n\n const className = classNames(\n 'relation-list',\n { 'relation-list-only-one': props.onlyOne, 'relation-list-only-no-main-one': props.onlyOne },\n props.className,\n );\n const { solt1, solt2 } = props;\n\n return (\n <div className={className} style={style}>\n {solt1 ? (\n <div className=\"relation-list-solt1\">\n <div className=\"relation-list-line\"></div>\n <div className=\"relation-list-label\">{props.label}</div>\n\n {props.tagName ? (\n <Tag\n className=\"relation-item-tag\"\n color={props.tagColor || '#fecd96'}\n onClick={props.onTagClick?.bind(null, props.tagName)}\n >\n {props.tagName}\n </Tag>\n ) : null}\n {solt1()}\n </div>\n ) : null}\n {solt2 ? <div className=\"relation-list-solt2\">{solt2()}</div> : null}\n </div>\n );\n};\n","import { classNames } from '@dimjs/utils';\nimport { ReactElement } from 'react';\n\nexport type RelationGroupListProps = {\n children: ReactElement | ReactElement[] | null;\n className?: string;\n};\n\nexport const RelationGroupList = (props: RelationGroupListProps) => {\n return <div className={classNames('relation-group-list', props.className)}>{props.children}</div>;\n};\n","import { classNames } from '@dimjs/utils';\nimport { CSSProperties, ReactElement } from 'react';\n\nexport type RelationItemProps = {\n children: ReactElement | null | Array<ReactElement | null>;\n className?: string;\n style?: CSSProperties;\n isFirst?: boolean;\n isLast?: boolean;\n onlyOne?: boolean;\n};\n\nexport const RelationItem = (props: RelationItemProps) => {\n const className = classNames('relation-item', {\n 'relation-item-line': true,\n 'relation-item-first': props.isFirst,\n 'relation-item-last': props.isLast,\n 'relation-item-only-one': props.onlyOne,\n });\n\n return (\n <div className={className} style={props.style}>\n {props.children}\n </div>\n );\n};\n","import { TRelationTreeData } from './type';\n\nexport const deleteLoop = (data: TRelationTreeData, uid: string) => {\n if (data.uid === uid) {\n data['_delete'] = true;\n }\n data?.relationList?.forEach((item) => {\n if (item.uid === uid || item.customData?.uid === uid) {\n item['_delete'] = true;\n if (data.relationList.length === 1) {\n data['_delete'] = true;\n }\n }\n\n item.children?.forEach((innerItem) => {\n deleteLoop(innerItem, uid);\n });\n });\n};\n\nexport const filterSurplusData = (data: TRelationTreeData) => {\n data.relationList = data.relationList || [];\n data.relationList = data.relationList.filter((item) => !item['_delete']);\n\n data.relationList.forEach((item) => {\n item.children = item.children || [];\n item.children = item.children.filter((item) => !item['_delete']);\n\n item.children.forEach((innerItem) => {\n filterSurplusData(innerItem);\n });\n });\n\n data.relationList = data.relationList.filter((item) => {\n if (!item.customData && !item.children) {\n return false;\n }\n if (!item.customData && (!item.children || item.children.length === 0)) {\n return false;\n }\n return true;\n });\n};\n","import { classNames } from '@dimjs/utils';\nimport { TPlainObject } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { Empty, Form } from 'antd';\nimport { Fragment, ReactElement, useState } from 'react';\nimport { fbaHooks } from '../fba-hooks';\nimport { Relation } from './compts/relation';\nimport { RelationGroupList } from './compts/relation-group-list';\nimport { RelationItem } from './compts/relation-item';\nimport './style.less';\n\nimport {\n RelationTreeProps,\n TRelationTreeCustomData,\n TRelationTreeData,\n TRelationTreeRelationItem,\n} from './type';\nimport { deleteLoop, filterSurplusData } from './utils';\n\ntype TRelationTreeLoop = {\n dataSource: TRelationTreeData;\n relationItemRender: (data: TRelationTreeCustomData, extraData?: TPlainObject) => ReactElement;\n className?: string;\n relationProps?: RelationTreeProps['relationProps'];\n onTagClick?: RelationTreeProps['onTagClick'];\n};\n\ntype RelationItemRenderProps = TRelationTreeLoop & {\n relationItem: TRelationTreeRelationItem;\n index: number;\n onlyOne?: boolean;\n};\n\nconst RelationItemRender = (props: RelationItemRenderProps) => {\n const relationItem = props.relationItem;\n const dataSource = props.dataSource;\n const index = props.index;\n\n if (relationItem.customData && relationItem.children && relationItem.children.length > 0) {\n return (\n <Fragment key={relationItem.uid}>\n <RelationItem\n isFirst={index === 0}\n isLast={index === dataSource.relationList.length - 1}\n onlyOne={props.onlyOne}\n >\n {props.relationItemRender(relationItem.customData, relationItem.extraData)}\n </RelationItem>\n <RelationGroupList>\n {relationItem.children?.map((innerItem) => {\n return (\n <RelationTreeLoop\n dataSource={innerItem}\n relationItemRender={props.relationItemRender}\n key={innerItem.uid}\n relationProps={props.relationProps}\n onTagClick={props.onTagClick}\n className={props.className}\n />\n );\n })}\n </RelationGroupList>\n </Fragment>\n );\n }\n if (relationItem.children && relationItem.children.length > 0) {\n return (\n <div\n className={classNames('form-list-no-main-group', { 'form-list-no-main-group': index === 0 })}\n key={relationItem.uid}\n >\n {relationItem.children?.map((innerItem) => {\n return (\n <RelationTreeLoop\n dataSource={innerItem}\n relationItemRender={props.relationItemRender}\n key={innerItem.uid}\n className={classNames('form-list-no-main', {\n 'form-list-no-main-first': index === 0,\n 'form-list-no-main-last': index === dataSource.relationList.length - 1,\n })}\n relationProps={props.relationProps}\n onTagClick={props.onTagClick}\n />\n );\n })}\n </div>\n );\n }\n if (relationItem.customData) {\n return (\n <RelationItem\n key={relationItem.uid}\n isFirst={index === 0}\n isLast={index === dataSource.relationList.length - 1}\n onlyOne={props.onlyOne}\n >\n <Form component={false}>\n {props.relationItemRender(relationItem.customData, relationItem.extraData)}\n </Form>\n </RelationItem>\n );\n }\n return null;\n};\n\nconst RelationTreeLoop = (props: TRelationTreeLoop) => {\n const dataSource = props.dataSource;\n const relationList = dataSource.relationList || [];\n\n const lastRelationItem = relationList[relationList.length - 1];\n const hasSolt2 =\n relationList.length > 0 &&\n lastRelationItem.customData &&\n lastRelationItem.children &&\n lastRelationItem.children.length > 0;\n const onlyOne = relationList.length == 1;\n // const onlyNoMainOne =\n // onlyOne && !relationList[0].customData && toArray(relationList[0].children).length === 1;\n return (\n <Relation\n {...props.relationProps}\n tagName={dataSource.tagName}\n key={dataSource.uid}\n onlyOne={onlyOne}\n label={dataSource.label}\n className={props.className}\n onTagClick={() => {\n props.onTagClick?.(dataSource.uid, dataSource.extraData);\n }}\n solt1={() => {\n return (\n <Fragment>\n {relationList.map((relationItem, index) => {\n const flat = hasSolt2 && index === relationList.length - 1;\n return (\n <RelationItemRender\n key={index}\n dataSource={props.dataSource}\n relationItemRender={props.relationItemRender}\n relationProps={props.relationProps}\n onTagClick={props.onTagClick}\n relationItem={\n flat\n ? {\n ...relationItem,\n children: undefined,\n }\n : relationItem\n }\n index={index}\n onlyOne={onlyOne}\n />\n );\n })}\n </Fragment>\n );\n }}\n solt2={() => {\n // 渲染最后一个relation item的children list数据\n if (hasSolt2 && lastRelationItem.children && lastRelationItem.children.length > 0) {\n return (\n <RelationGroupList key={lastRelationItem.uid}>\n {lastRelationItem.children.map((innerItem) => {\n return (\n <RelationTreeLoop\n dataSource={innerItem}\n relationItemRender={props.relationItemRender}\n key={innerItem.uid}\n relationProps={props.relationProps}\n onTagClick={props.onTagClick}\n />\n );\n })}\n </RelationGroupList>\n );\n }\n return null;\n }}\n ></Relation>\n );\n};\n\nexport const RelationTree = (props: RelationTreeProps) => {\n const [dataSource, setDataSource] = useState<TRelationTreeData>();\n\n fbaHooks.useEffectCustom(() => {\n setDataSource(props.dataSource);\n }, [props.dataSource]);\n\n const onRelationItemContentChange = hooks.useCallbackRef((data: TRelationTreeCustomData, name, value) => {\n if (data) {\n data[name] = value;\n props.onChange?.({ ...dataSource } as TRelationTreeData);\n }\n });\n\n const getTargetRelationList = (relationTreeList: TRelationTreeData[], uid: string) => {\n for (let index = 0; index < relationTreeList.length; index++) {\n const relationTree = relationTreeList[index];\n for (let innerIndex = 0; innerIndex < relationTree.relationList.length; innerIndex++) {\n const element = relationTree.relationList[innerIndex];\n if (element.customData?.uid === uid) {\n return {\n relationTree,\n index: innerIndex,\n element: element,\n };\n } else if (element.children) {\n const result = getTargetRelationList(element.children, uid);\n if (result) {\n return result;\n }\n }\n }\n }\n return null;\n };\n\n const onAdd = hooks.useCallbackRef(\n (data: TRelationTreeCustomData, initialData: TRelationTreeRelationItem) => {\n if (!dataSource) return;\n const result = getTargetRelationList([dataSource], data.uid);\n if (result.relationTree?.relationList) {\n result.relationTree?.relationList.splice((result.index as number) + 1, 0, initialData);\n props.onChange?.(dataSource);\n }\n },\n );\n const addChildren = hooks.useCallbackRef(\n (data: TRelationTreeCustomData, initialData: TRelationTreeData) => {\n if (!dataSource) return;\n const result = getTargetRelationList([dataSource], data.uid);\n if (result.element) {\n result.element.children = (result.element.children || []).concat(initialData);\n props.onChange?.(dataSource);\n }\n },\n );\n\n const onRemove = hooks.useCallbackRef((uid: string) => {\n if (!dataSource) return;\n deleteLoop(dataSource, uid);\n if (dataSource['_delete']) {\n props.onChange?.(undefined);\n } else {\n filterSurplusData(dataSource);\n props.onChange?.(dataSource);\n }\n });\n\n if (!dataSource) return <Empty description=\"暂无数据\"></Empty>;\n\n return (\n <div className={classNames('relation-tree', props.className)}>\n <RelationTreeLoop\n dataSource={dataSource}\n relationProps={props.relationProps}\n onTagClick={props.onTagClick}\n relationItemRender={(data, extraData) => {\n return props.children(\n data,\n {\n add: onAdd,\n addChildren: addChildren,\n remove: onRemove,\n onChange: onRelationItemContentChange.bind(null, data),\n },\n extraData,\n );\n }}\n />\n </div>\n );\n};\n"],"names":["Relation","props","_props$onTagClick","style","tagLineWidth","indentWidth","tagWidth","lineColor","className","_classNames","onlyOne","solt1","solt2","_jsxs","children","_jsx","label","tagName","Tag","color","tagColor","onClick","onTagClick","bind","RelationGroupList","RelationItem","isFirst","isLast","deleteLoop","data","uid","_data$relationList","relationList","forEach","item","_item$customData","_item$children","customData","length","innerItem","filterSurplusData","filter","RelationItemRender","relationItem","dataSource","index","_relationItem$childre","Fragment","relationItemRender","extraData","map","_RelationTreeLoop","relationProps","_relationItem$childre2","Form","component","RelationTreeLoop","lastRelationItem","hasSolt2","_createElement","_extends","key","flat","undefined","RelationTree","_useState","useState","setDataSource","fbaHooks","useEffectCustom","onRelationItemContentChange","_hooks","useCallbackRef","name","value","onChange","getTargetRelationList","relationTreeList","relationTree","innerIndex","_element$customData","element","result","onAdd","initialData","_result$relationTree","_result$relationTree2","splice","addChildren","concat","onRemove","Empty","description","add","remove"],"mappings":";4fAKO,IAAMA,EAAW,SAAXA,EAAYC,GAAyB,IAAAC,EAChD,IAAMC,EAAQ,CACZ,4BAA+BF,EAAMG,cAAgB,IAAM,KAC3D,iCAAoCH,EAAMI,aAAe,IAAM,KAC/D,wBAA2BJ,EAAMK,UAAY,IAAM,KACnD,wBAA4BL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,EAAsB,CAAChC,GAAaf,EAAKC,KACxD,GAAIoD,EAAOD,QAAS,CAClBC,EAAOD,QAAQnE,UAAYoE,EAAOD,QAAQnE,UAAY,IAAI2E,OAAOL,GACjEnF,EAAM0E,UAAN1E,MAAAA,EAAM0E,SAAW/B,EACnB,CACF,IAGF,IAAM8C,EAAWnB,EAAMC,gBAAe,SAAC1C,GACrC,IAAKc,EAAY,OACjBhB,EAAWgB,EAAYd,GACvB,GAAIc,EAAW,WAAY,CACzB3C,EAAM0E,UAAN1E,MAAAA,EAAM0E,SAAWZ,UACnB,KAAO,CACLvB,EAAkBI,GAClB3C,EAAM0E,UAAN1E,MAAAA,EAAM0E,SAAW/B,EACnB,CACF,IAEA,IAAKA,EAAY,OAAO7B,EAAC4E,EAAK,CAACC,YAAY,SAE3C,OACE7E,EAAA,MAAA,CAAKP,UAAWC,EAAW,gBAAiBR,EAAMO,WAAWM,SAC3DC,EAACoC,EAAgB,CACfP,WAAYA,EACZQ,cAAenD,EAAMmD,cACrB9B,WAAYrB,EAAMqB,WAClB0B,mBAAoB,SAApBA,EAAqBnB,EAAMoB,GACzB,OAAOhD,EAAMa,SACXe,EACA,CACEgE,IAAKV,EACLK,YAAaA,EACbM,OAAQJ,EACRf,SAAUL,EAA4B/C,KAAK,KAAMM,IAEnDoB,EAEJ,KAIR"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["@flatbiz/antd/src/relation-tree/compts/relation.tsx","@flatbiz/antd/src/relation-tree/compts/relation-group-list.tsx","@flatbiz/antd/src/relation-tree/compts/relation-item.tsx","@flatbiz/antd/src/relation-tree/utils.ts","@flatbiz/antd/src/relation-tree/relation-tree.tsx"],"sourcesContent":["import { classNames } from '@dimjs/utils';\nimport { Tag } from 'antd';\nimport { CSSProperties } from 'react';\nimport { RelationProps } from '../type';\n\nexport const Relation = (props: RelationProps) => {\n const style = {\n '--relation-tagline-width': `${props.tagLineWidth || 40}px`,\n '--relation-group-indent-width': `${props.indentWidth || 80}px`,\n '--relation-tag-width': `${props.tagWidth || 26}px`,\n '--relation-line-color': `${props.lineColor || '#fda148'}`,\n } as CSSProperties;\n\n const className = classNames(\n 'relation-list',\n { 'relation-list-only-one': props.onlyOne, 'relation-list-only-no-main-one': props.onlyOne },\n props.className,\n );\n const { solt1, solt2 } = props;\n\n return (\n <div className={className} style={style}>\n {solt1 ? (\n <div className=\"relation-list-solt1\">\n <div className=\"relation-list-line\"></div>\n <div className=\"relation-list-label\">{props.label}</div>\n\n {props.tagName ? (\n <Tag\n className=\"relation-item-tag\"\n color={props.tagColor || '#fecd96'}\n onClick={props.onTagClick?.bind(null, props.tagName)}\n >\n {props.tagName}\n </Tag>\n ) : null}\n {solt1()}\n </div>\n ) : null}\n {solt2 ? <div className=\"relation-list-solt2\">{solt2()}</div> : null}\n </div>\n );\n};\n","import { classNames } from '@dimjs/utils';\nimport { ReactElement } from 'react';\n\nexport type RelationGroupListProps = {\n children: ReactElement | ReactElement[] | null;\n className?: string;\n};\n\nexport const RelationGroupList = (props: RelationGroupListProps) => {\n return <div className={classNames('relation-group-list', props.className)}>{props.children}</div>;\n};\n","import { classNames } from '@dimjs/utils';\nimport { CSSProperties, ReactElement } from 'react';\n\nexport type RelationItemProps = {\n children: ReactElement | null | Array<ReactElement | null>;\n className?: string;\n style?: CSSProperties;\n isFirst?: boolean;\n isLast?: boolean;\n onlyOne?: boolean;\n};\n\nexport const RelationItem = (props: RelationItemProps) => {\n const className = classNames('relation-item', {\n 'relation-item-line': true,\n 'relation-item-first': props.isFirst,\n 'relation-item-last': props.isLast,\n 'relation-item-only-one': props.onlyOne,\n });\n\n return (\n <div className={className} style={props.style}>\n {props.children}\n </div>\n );\n};\n","import { TRelationTreeData } from './type';\n\nexport const deleteLoop = (data: TRelationTreeData, uid: string) => {\n if (data.uid === uid) {\n data['_delete'] = true;\n }\n data?.relationList?.forEach((item) => {\n if (item.uid === uid || item.customData?.uid === uid) {\n item['_delete'] = true;\n if (data.relationList.length === 1) {\n data['_delete'] = true;\n }\n }\n\n item.children?.forEach((innerItem) => {\n deleteLoop(innerItem, uid);\n });\n });\n};\n\nexport const filterSurplusData = (data: TRelationTreeData) => {\n data.relationList = data.relationList || [];\n data.relationList = data.relationList.filter((item) => !item['_delete']);\n\n data.relationList.forEach((item) => {\n item.children = item.children || [];\n item.children = item.children.filter((item) => !item['_delete']);\n\n item.children.forEach((innerItem) => {\n filterSurplusData(innerItem);\n });\n });\n\n data.relationList = data.relationList.filter((item) => {\n if (!item.customData && !item.children) {\n return false;\n }\n if (!item.customData && (!item.children || item.children.length === 0)) {\n return false;\n }\n return true;\n });\n};\n","import { classNames } from '@dimjs/utils';\nimport { TPlainObject } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { Empty, Form } from 'antd';\nimport { Fragment, ReactElement, useState } from 'react';\nimport { fbaHooks } from '../fba-hooks';\nimport { Relation } from './compts/relation';\nimport { RelationGroupList } from './compts/relation-group-list';\nimport { RelationItem } from './compts/relation-item';\nimport './style.less';\n\nimport {\n RelationTreeProps,\n TRelationTreeCustomData,\n TRelationTreeData,\n TRelationTreeRelationItem,\n} from './type';\nimport { deleteLoop, filterSurplusData } from './utils';\n\ntype TRelationTreeLoop = {\n dataSource: TRelationTreeData;\n relationItemRender: (data: TRelationTreeCustomData, extraData?: TPlainObject) => ReactElement;\n className?: string;\n relationProps?: RelationTreeProps['relationProps'];\n onTagClick?: RelationTreeProps['onTagClick'];\n};\n\ntype RelationItemRenderProps = TRelationTreeLoop & {\n relationItem: TRelationTreeRelationItem;\n index: number;\n onlyOne?: boolean;\n};\n\nconst RelationItemRender = (props: RelationItemRenderProps) => {\n const relationItem = props.relationItem;\n const dataSource = props.dataSource;\n const index = props.index;\n\n if (relationItem.customData && relationItem.children && relationItem.children.length > 0) {\n return (\n <Fragment key={relationItem.uid}>\n <RelationItem\n isFirst={index === 0}\n isLast={index === dataSource.relationList.length - 1}\n onlyOne={props.onlyOne}\n >\n {props.relationItemRender(relationItem.customData, relationItem.extraData)}\n </RelationItem>\n <RelationGroupList>\n {relationItem.children?.map((innerItem) => {\n return (\n <RelationTreeLoop\n dataSource={innerItem}\n relationItemRender={props.relationItemRender}\n key={innerItem.uid}\n relationProps={props.relationProps}\n onTagClick={props.onTagClick}\n className={props.className}\n />\n );\n })}\n </RelationGroupList>\n </Fragment>\n );\n }\n if (relationItem.children && relationItem.children.length > 0) {\n return (\n <div\n className={classNames('form-list-no-main-group', { 'form-list-no-main-group': index === 0 })}\n key={relationItem.uid}\n >\n {relationItem.children?.map((innerItem) => {\n return (\n <RelationTreeLoop\n dataSource={innerItem}\n relationItemRender={props.relationItemRender}\n key={innerItem.uid}\n className={classNames('form-list-no-main', {\n 'form-list-no-main-first': index === 0,\n 'form-list-no-main-last': index === dataSource.relationList.length - 1,\n })}\n relationProps={props.relationProps}\n onTagClick={props.onTagClick}\n />\n );\n })}\n </div>\n );\n }\n if (relationItem.customData) {\n return (\n <RelationItem\n key={relationItem.uid}\n isFirst={index === 0}\n isLast={index === dataSource.relationList.length - 1}\n onlyOne={props.onlyOne}\n >\n <Form component={false}>\n {props.relationItemRender(relationItem.customData, relationItem.extraData)}\n </Form>\n </RelationItem>\n );\n }\n return null;\n};\n\nconst RelationTreeLoop = (props: TRelationTreeLoop) => {\n const dataSource = props.dataSource;\n const relationList = dataSource.relationList || [];\n\n const lastRelationItem = relationList[relationList.length - 1];\n const hasSolt2 =\n relationList.length > 0 &&\n lastRelationItem.customData &&\n lastRelationItem.children &&\n lastRelationItem.children.length > 0;\n const onlyOne = relationList.length == 1;\n // const onlyNoMainOne =\n // onlyOne && !relationList[0].customData && toArray(relationList[0].children).length === 1;\n return (\n <Relation\n {...props.relationProps}\n tagName={dataSource.tagName}\n key={dataSource.uid}\n onlyOne={onlyOne}\n label={dataSource.label}\n className={props.className}\n onTagClick={() => {\n props.onTagClick?.(dataSource.uid, dataSource.extraData);\n }}\n solt1={() => {\n return (\n <Fragment>\n {relationList.map((relationItem, index) => {\n const flat = hasSolt2 && index === relationList.length - 1;\n return (\n <RelationItemRender\n key={index}\n dataSource={props.dataSource}\n relationItemRender={props.relationItemRender}\n relationProps={props.relationProps}\n onTagClick={props.onTagClick}\n relationItem={\n flat\n ? {\n ...relationItem,\n children: undefined,\n }\n : relationItem\n }\n index={index}\n onlyOne={onlyOne}\n />\n );\n })}\n </Fragment>\n );\n }}\n solt2={() => {\n // 渲染最后一个relation item的children list数据\n if (hasSolt2 && lastRelationItem.children && lastRelationItem.children.length > 0) {\n return (\n <RelationGroupList key={lastRelationItem.uid}>\n {lastRelationItem.children.map((innerItem) => {\n return (\n <RelationTreeLoop\n dataSource={innerItem}\n relationItemRender={props.relationItemRender}\n key={innerItem.uid}\n relationProps={props.relationProps}\n onTagClick={props.onTagClick}\n />\n );\n })}\n </RelationGroupList>\n );\n }\n return null;\n }}\n ></Relation>\n );\n};\n\nexport const RelationTree = (props: RelationTreeProps) => {\n const [dataSource, setDataSource] = useState<TRelationTreeData>();\n\n fbaHooks.useEffectCustom(() => {\n setDataSource(props.dataSource);\n }, [props.dataSource]);\n\n const onRelationItemContentChange = hooks.useCallbackRef((data: TRelationTreeCustomData, name, value) => {\n if (data) {\n data[name] = value;\n props.onChange?.({ ...dataSource } as TRelationTreeData);\n }\n });\n\n const getTargetRelationList = (relationTreeList: TRelationTreeData[], uid: string) => {\n for (let index = 0; index < relationTreeList.length; index++) {\n const relationTree = relationTreeList[index];\n for (let innerIndex = 0; innerIndex < relationTree.relationList.length; innerIndex++) {\n const element = relationTree.relationList[innerIndex];\n if (element.customData?.uid === uid) {\n return {\n relationTree,\n index: innerIndex,\n element: element,\n };\n } else if (element.children) {\n const result = getTargetRelationList(element.children, uid);\n if (result) {\n return result;\n }\n }\n }\n }\n return null;\n };\n\n const onAdd = hooks.useCallbackRef(\n (data: TRelationTreeCustomData, initialData: TRelationTreeRelationItem) => {\n if (!dataSource) return;\n const result = getTargetRelationList([dataSource], data.uid);\n if (result.relationTree?.relationList) {\n result.relationTree?.relationList.splice((result.index as number) + 1, 0, initialData);\n props.onChange?.(dataSource);\n }\n },\n );\n const addChildren = hooks.useCallbackRef(\n (data: TRelationTreeCustomData, initialData: TRelationTreeData) => {\n if (!dataSource) return;\n const result = getTargetRelationList([dataSource], data.uid);\n if (result.element) {\n result.element.children = (result.element.children || []).concat(initialData);\n props.onChange?.(dataSource);\n }\n },\n );\n\n const onRemove = hooks.useCallbackRef((uid: string) => {\n if (!dataSource) return;\n deleteLoop(dataSource, uid);\n if (dataSource['_delete']) {\n props.onChange?.(undefined);\n } else {\n filterSurplusData(dataSource);\n props.onChange?.(dataSource);\n }\n });\n\n if (!dataSource) return <Empty description=\"暂无数据\"></Empty>;\n\n return (\n <div className={classNames('relation-tree', props.className)}>\n <RelationTreeLoop\n dataSource={dataSource}\n relationProps={props.relationProps}\n onTagClick={props.onTagClick}\n relationItemRender={(data, extraData) => {\n return props.children(\n data,\n {\n add: onAdd,\n addChildren: addChildren,\n remove: onRemove,\n onChange: onRelationItemContentChange.bind(null, data),\n },\n extraData,\n );\n }}\n />\n </div>\n );\n};\n"],"names":["Relation","props","_props$onTagClick","style","tagLineWidth","indentWidth","tagWidth","lineColor","className","_classNames","onlyOne","solt1","solt2","_jsxs","children","_jsx","label","tagName","Tag","color","tagColor","onClick","onTagClick","bind","RelationGroupList","RelationItem","isFirst","isLast","deleteLoop","data","uid","_data$relationList","relationList","forEach","item","_item$customData","_item$children","customData","length","innerItem","filterSurplusData","filter","RelationItemRender","relationItem","dataSource","index","_relationItem$childre","Fragment","relationItemRender","extraData","map","_RelationTreeLoop","relationProps","_relationItem$childre2","Form","component","RelationTreeLoop","lastRelationItem","hasSolt2","_createElement","_extends","key","flat","undefined","RelationTree","_useState","useState","setDataSource","fbaHooks","useEffectCustom","onRelationItemContentChange","_hooks","useCallbackRef","name","value","onChange","getTargetRelationList","relationTreeList","relationTree","innerIndex","_element$customData","element","result","onAdd","initialData","_result$relationTree","_result$relationTree2","splice","addChildren","concat","onRemove","Empty","description","add","remove"],"mappings":";4fAKO,I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rC,MAAmB,EAAG,EAAGuC,GAC1EnF,EAAM0E,UAAN1E,MAAAA,EAAM0E,SAAW/B,EACnB,CACF,GAEF,IAAM4C,EAAcjB,EAAMC,eACxB,SAAC3C,EAA+BuD,GAC9B,IAAKxC,EAAY,OACjB,IAAMsC,EAASN,EAAsB,CAAChC,GAAaf,EAAKC,KACxD,GAAIoD,EAAOD,QAAS,CAClBC,EAAOD,QAAQnE,UAAYoE,EAAOD,QAAQnE,UAAY,IAAI2E,OAAOL,GACjEnF,EAAM0E,UAAN1E,MAAAA,EAAM0E,SAAW/B,EACnB,CACF,GAGF,IAAM8C,EAAWnB,EAAMC,eAAe,SAAC1C,GACrC,IAAKc,EAAY,OACjBhB,EAAWgB,EAAYd,GACvB,GAAIc,EAAW,WAAY,CACzB3C,EAAM0E,UAAN1E,MAAAA,EAAM0E,SAAWZ,UACnB,KAAO,CACLvB,EAAkBI,GAClB3C,EAAM0E,UAAN1E,MAAAA,EAAM0E,SAAW/B,EACnB,CACF,GAEA,IAAKA,EAAY,OAAO7B,EAAC4E,EAAK,CAACC,YAAY,SAE3C,OACE7E,EAAA,MAAA,CAAKP,UAAWC,EAAW,gBAAiBR,EAAMO,WAAWM,SAC3DC,EAACoC,EAAgB,CACfP,WAAYA,EACZQ,cAAenD,EAAMmD,cACrB9B,WAAYrB,EAAMqB,WAClB0B,mBAAoB,SAApBA,EAAqBnB,EAAMoB,GACzB,OAAOhD,EAAMa,SACXe,EACA,CACEgE,IAAKV,EACLK,YAAaA,EACbM,OAAQJ,EACRf,SAAUL,EAA4B/C,KAAK,KAAMM,IAEnDoB,EAEJ,KAIR"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import './../fba-hooks/index.css';
|
|
3
3
|
import './index.css';
|
|
4
4
|
/*! @flatjs/forge MIT @flatbiz/antd */
|
|
5
|
-
import{extend as r}from"@dimjs/utils/cjs/extend";import{valueIsEqual as s}from"@flatbiz/utils";import{Empty as e,Spin as t}from"antd";import{c as i}from"../index-636a568e.js";import{useMemo as o}from"react";import{TextOverflow as n}from"../text-overflow/index.js";import{jsxs as a,jsx as m}from"react/jsx-runtime";import"../_rollupPluginBabelHelpers-c0dbec57.js";import"@dimjs/lang/cjs/is-string";import"@dimjs/utils/cjs/class-names";import"ahooks";import"../fba-hooks/index.js";import"@dimjs/lang/cjs/is-array";import"@wove/react/cjs/hooks";import"../use-responsive-point-
|
|
5
|
+
import{extend as r}from"@dimjs/utils/cjs/extend";import{valueIsEqual as s}from"@flatbiz/utils";import{Empty as e,Spin as t}from"antd";import{c as i}from"../index-636a568e.js";import{useMemo as o}from"react";import{TextOverflow as n}from"../text-overflow/index.js";import{jsxs as a,jsx as m}from"react/jsx-runtime";import"../_rollupPluginBabelHelpers-c0dbec57.js";import"@dimjs/lang/cjs/is-string";import"@dimjs/utils/cjs/class-names";import"ahooks";import"../fba-hooks/index.js";import"@dimjs/lang/cjs/is-array";import"@wove/react/cjs/hooks";import"../use-responsive-point-1e6d93d9.js";import"@dimjs/utils/cjs/uuid";var u=function u(p){var c=r({"request-success":"暂无数据","request-progress":"数据查询中","request-error":"数据查询异常","request-init":"暂无数据","no-dependencies-params":"未获取到必要的查询条件","request-search-keyword-empty":"请输入搜索关键字"},p.messageConfig);var d=o(function(){if(p.status&&s(p.status,["request-success","request-progress","request-error","no-dependencies-params","request-search-keyword-empty"])){return c[p.status]}return c["request-init"]},[c,p.status]);var l=p.status==="request-error";return a(e,{image:e.PRESENTED_IMAGE_SIMPLE,description:m("div",{style:{width:"100%",overflow:"hidden"},children:m(n,{text:d})}),className:i("v-request-status"),children:[m(t,{spinning:p.loading||false}),l?p.errorButton:null]})};export{u as RequestStatus};
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["@flatbiz/antd/src/request-status/request-status.tsx"],"sourcesContent":["import { extend } from '@dimjs/utils';\nimport { valueIsEqual } from '@flatbiz/utils';\nimport { Empty, Spin } from 'antd';\nimport classNames from 'classnames';\nimport { ReactElement, useMemo } from 'react';\nimport { TextOverflow } from '../text-overflow/text-overflow';\nimport './style.less';\n\nexport type TRequestStatus =\n | 'request-init'\n | 'request-progress'\n | 'request-success'\n | 'request-error'\n | 'request-search-keyword-empty'\n | 'no-dependencies-params';\nexport type TRequestStatusProps = {\n status?: TRequestStatus;\n errorButton?: ReactElement;\n messageConfig?: Partial<Record<TRequestStatus, string>>;\n loading?: boolean;\n};\nexport const RequestStatus = (props: TRequestStatusProps) => {\n const messageConfig = extend(\n {\n 'request-success': '暂无数据',\n 'request-progress': '数据查询中',\n 'request-error': '数据查询异常',\n 'request-init': '暂无数据',\n 'no-dependencies-params': '未获取到必要的查询条件',\n 'request-search-keyword-empty': '请输入搜索关键字',\n },\n props.messageConfig,\n );\n const description = useMemo(() => {\n if (\n props.status &&\n valueIsEqual(props.status, [\n 'request-success',\n 'request-progress',\n 'request-error',\n 'no-dependencies-params',\n 'request-search-keyword-empty',\n ])\n ) {\n return messageConfig[props.status];\n }\n return messageConfig['request-init'];\n }, [messageConfig, props.status]);\n\n const isError = props.status === 'request-error';\n return (\n <Empty\n image={Empty.PRESENTED_IMAGE_SIMPLE}\n description={\n <div style={{ width: '100%', overflow: 'hidden' }}>\n <TextOverflow text={description} />\n </div>\n }\n className={classNames('v-request-status')}\n >\n <Spin spinning={props.loading || false}></Spin>\n {isError ? props.errorButton : null}\n </Empty>\n );\n};\n"],"names":["RequestStatus","props","messageConfig","_extend","description","useMemo","status","valueIsEqual","isError","_jsxs","Empty","image","PRESENTED_IMAGE_SIMPLE","_jsx","style","width","overflow","children","TextOverflow","text","className","classNames","Spin","spinning","loading","errorButton"],"mappings":";4mBAqBaA,EAAgB,SAAhBA,EAAiBC,GAC5B,IAAMC,EAAgBC,EACpB,CACE,kBAAmB,OACnB,mBAAoB,QACpB,gBAAiB,SACjB,eAAgB,OAChB,yBAA0B,cAC1B,+BAAgC,YAElCF,EAAMC,eAER,IAAME,EAAcC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["@flatbiz/antd/src/request-status/request-status.tsx"],"sourcesContent":["import { extend } from '@dimjs/utils';\nimport { valueIsEqual } from '@flatbiz/utils';\nimport { Empty, Spin } from 'antd';\nimport classNames from 'classnames';\nimport { ReactElement, useMemo } from 'react';\nimport { TextOverflow } from '../text-overflow/text-overflow';\nimport './style.less';\n\nexport type TRequestStatus =\n | 'request-init'\n | 'request-progress'\n | 'request-success'\n | 'request-error'\n | 'request-search-keyword-empty'\n | 'no-dependencies-params';\nexport type TRequestStatusProps = {\n status?: TRequestStatus;\n errorButton?: ReactElement;\n messageConfig?: Partial<Record<TRequestStatus, string>>;\n loading?: boolean;\n};\nexport const RequestStatus = (props: TRequestStatusProps) => {\n const messageConfig = extend(\n {\n 'request-success': '暂无数据',\n 'request-progress': '数据查询中',\n 'request-error': '数据查询异常',\n 'request-init': '暂无数据',\n 'no-dependencies-params': '未获取到必要的查询条件',\n 'request-search-keyword-empty': '请输入搜索关键字',\n },\n props.messageConfig,\n );\n const description = useMemo(() => {\n if (\n props.status &&\n valueIsEqual(props.status, [\n 'request-success',\n 'request-progress',\n 'request-error',\n 'no-dependencies-params',\n 'request-search-keyword-empty',\n ])\n ) {\n return messageConfig[props.status];\n }\n return messageConfig['request-init'];\n }, [messageConfig, props.status]);\n\n const isError = props.status === 'request-error';\n return (\n <Empty\n image={Empty.PRESENTED_IMAGE_SIMPLE}\n description={\n <div style={{ width: '100%', overflow: 'hidden' }}>\n <TextOverflow text={description} />\n </div>\n }\n className={classNames('v-request-status')}\n >\n <Spin spinning={props.loading || false}></Spin>\n {isError ? props.errorButton : null}\n </Empty>\n );\n};\n"],"names":["RequestStatus","props","messageConfig","_extend","description","useMemo","status","valueIsEqual","isError","_jsxs","Empty","image","PRESENTED_IMAGE_SIMPLE","_jsx","style","width","overflow","children","TextOverflow","text","className","classNames","Spin","spinning","loading","errorButton"],"mappings":";4mBAqBaA,EAAgB,SAAhBA,EAAiBC,GAC5B,IAAMC,EAAgBC,EACpB,CACE,kBAAmB,OACnB,mBAAoB,QACpB,gBAAiB,SACjB,eAAgB,OAChB,yBAA0B,cAC1B,+BAAgC,YAElCF,EAAMC,eAER,IAAME,EAAcC,EAAQ,WAC1B,GACEJ,EAAMK,QACNC,EAAaN,EAAMK,OAAQ,CACzB,kBACA,mBACA,gBACA,yBACA,iCAEF,CACA,OAAOJ,EAAcD,EAAMK,OAC7B,CACA,OAAOJ,EAAc,eACtB,EAAE,CAACA,EAAeD,EAAMK,SAEzB,IAAME,EAAUP,EAAMK,SAAW,gBACjC,OACEG,EAACC,EAAK,CACJC,MAAOD,EAAME,uBACbR,YACES,EAAA,MAAA,CAAKC,MAAO,CAAEC,MAAO,OAAQC,SAAU,UAAWC,SAChDJ,EAACK,EAAY,CAACC,KAAMf,MAGxBgB,UAAWC,EAAW,oBAAoBJ,SAAA,CAE1CJ,EAACS,EAAI,CAACC,SAAUtB,EAAMuB,SAAW,QAChChB,EAAUP,EAAMwB,YAAc,OAGrC"}
|
|
@@ -6,5 +6,5 @@ import './../types/index.css';
|
|
|
6
6
|
import './../fba-utils/index.css';
|
|
7
7
|
import './index.css';
|
|
8
8
|
/*! @flatjs/forge MIT @flatbiz/antd */
|
|
9
|
-
import e from"@ant-design/icons/es/icons/CloseOutlined";import{_ as r}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{isPromise as i}from"@dimjs/lang/cjs/is-promise";import{hooks as t}from"@wove/react/cjs/hooks";import{Button as o,Space as a}from"antd";import{c as s}from"../index-636a568e.js";import{forwardRef as n,useState as l,useMemo as d}from"react";import{createPortal as c}from"react-dom";import{Resizable as m}from"react-resizable";import{ButtonWrapper as p}from"../button-wrapper/index.js";import{jsx as u,jsxs as f}from"react/jsx-runtime";import"@ant-design/icons/es/icons/LoadingOutlined";import"@dimjs/utils/cjs/class-names";import"@flatbiz/utils";import"../index-
|
|
9
|
+
import e from"@ant-design/icons/es/icons/CloseOutlined";import{_ as r}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{isPromise as i}from"@dimjs/lang/cjs/is-promise";import{hooks as t}from"@wove/react/cjs/hooks";import{Button as o,Space as a}from"antd";import{c as s}from"../index-636a568e.js";import{forwardRef as n,useState as l,useMemo as d}from"react";import{createPortal as c}from"react-dom";import{Resizable as m}from"react-resizable";import{ButtonWrapper as p}from"../button-wrapper/index.js";import{jsx as u,jsxs as f}from"react/jsx-runtime";import"@ant-design/icons/es/icons/LoadingOutlined";import"@dimjs/utils/cjs/class-names";import"@flatbiz/utils";import"../index-853b36e6.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-hooks/index.js";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-1e6d93d9.js";import"@dimjs/utils/cjs/uuid";import"@dimjs/utils/cjs/extend";import"../fba-utils/index.js";import"@dimjs/model";var v=n(function(e,i){return u("div",r({ref:i},e,{className:"resize-border"}))});var y=10;var h=function e(){y++;return y};var j=function n(y){var j=y.open,b=y.onClose,w=y.title,z=w===void 0?"抽屉标题":w,x=y.width,g=x===void 0?600:x,k=y.children,N=y.footer,C=y.maskClosable,P=C===void 0?true:C,E=y.className,R=y.style,S=y.mask,O=S===void 0?true:S,_=y.styles,F=y.headerExtraRender,I=y.zIndex,q=y.onOk,A=y.okText,H=y.cancelText,T=y.hidenFooter;var X=l(g),Y=X[0],B=X[1];var D=function e(r,i){var t=i.size;B(t.width)};var L=function e(r){r.stopPropagation();if(P){b()}};var U=typeof Y==="number"?Y+"px":Y;var G=j?{transform:"translateX(0)",opacity:1}:{transform:"translateX(100%)",opacity:0};var J=j?1:0;var K=d(function(){return I?I:10+h()},[I]);var M=t.useCallbackRef(function(e){if(q){var r=q(e);if(r&&i(r)){return r.then(b)}}return b()});return c(f("div",{className:s("drawer-resizable",{"drawer-resizable-visible":j},E),style:!O?{width:U,zIndex:K}:{left:0,zIndex:K},children:[O?u("div",{className:"drawer-resizable-mask",style:{opacity:J},onClick:L}):null,f("div",{className:"drawer-resizable-content",style:r({width:U},G,R),children:[f("div",{className:"drawer-resizable-header",style:_==null?void 0:_.header,children:[f("div",{className:"drawer-resizable-title",children:[u(o,{type:"text",className:"drawer-resizable-title-close",icon:u(e,{}),onClick:function e(r){r.stopPropagation();b()}}),u("div",{className:"",children:z})]}),F?u("div",{className:"drawer-resizable-title-extra",children:F}):null]}),u("div",{className:"drawer-resizable-body",style:_==null?void 0:_.body,children:u(m,{onResize:D,width:Y,handle:u(v,{}),axis:"x",resizeHandles:["w"],minConstraints:[400,0],maxConstraints:[1200,0],style:{height:"100%"},onResizeStop:function e(r){r.stopPropagation();var i=document.querySelectorAll("iframe");i.forEach(function(e){e.style.pointerEvents=""})},onResizeStart:function e(r){r.stopPropagation();var i=document.querySelectorAll("iframe");i.forEach(function(e){e.style.pointerEvents="none"})},children:k})}),T?null:N?u("div",{className:"drawer-footer",style:_==null?void 0:_.footer,children:N}):u("div",{className:"drawer-footer",style:_==null?void 0:_.footer,children:f(a,{children:[u(p,{onClick:b,children:H||"取消"}),u(p,{onClick:M,type:"primary",loadingPosition:"center",children:A||"确定"})]})})]})]}),document.body)};export{j as ResizableDrawer};
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["@flatbiz/antd/src/resizable-drawer/resize-handle/index.tsx","@flatbiz/antd/src/resizable-drawer/utils.ts","@flatbiz/antd/src/resizable-drawer/drawer.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport './style.less';\nexport const ResizeHandle = forwardRef<HTMLDivElement>((props, ref) => {\n return <div ref={ref} {...props} className=\"resize-border\" />;\n});\n","let zIndex = 10;\n\nexport const getZindex = () => {\n zIndex++;\n return zIndex;\n};\n","import { CloseOutlined } from '@ant-design/icons';\nimport { isPromise } from '@dimjs/lang';\nimport { hooks } from '@wove/react';\nimport { Button, Space } from 'antd';\nimport classNames from 'classnames';\nimport React, { useMemo, useState, type CSSProperties, type ReactElement } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Resizable } from 'react-resizable';\nimport { ButtonWrapper } from '../button-wrapper';\nimport { ResizeHandle } from './resize-handle';\nimport './style.less';\nimport { getZindex } from './utils';\n\ntype ResizableDrawerProps = {\n open?: boolean;\n onClose: () => void;\n title?: React.ReactNode;\n width?: number | string;\n children?: React.ReactNode;\n footer?: React.ReactNode | null;\n hidenFooter?: boolean;\n maskClosable?: boolean;\n mask?: boolean;\n className?: string;\n style?: React.CSSProperties;\n styles?: {\n header?: CSSProperties;\n body?: CSSProperties;\n footer?: CSSProperties;\n };\n headerExtraRender?: ReactElement;\n zIndex?: number;\n cancelText?: string;\n okText?: string;\n onOk?: (e: React.MouseEvent<HTMLElement>) => void | Promise<void>;\n};\n\nexport const ResizableDrawer: React.FC<ResizableDrawerProps> = ({\n open,\n onClose,\n title = '抽屉标题',\n width: initialWidth = 600,\n children,\n footer,\n maskClosable = true,\n className,\n style,\n mask = true,\n styles,\n headerExtraRender,\n zIndex,\n onOk,\n okText,\n cancelText,\n hidenFooter,\n}) => {\n const [width, setWidth] = useState(initialWidth);\n\n const onResize = (_, data) => {\n const { size } = data;\n setWidth(size.width);\n };\n // 遮罩层点击\n const handleMaskClick = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n if (maskClosable) {\n onClose();\n }\n };\n\n // 计算宽度样式\n const widthStyle = typeof width === 'number' ? `${width}px` : width;\n\n const drawerStyle = open\n ? {\n transform: 'translateX(0)',\n opacity: 1,\n }\n : {\n transform: 'translateX(100%)',\n opacity: 0,\n };\n\n const maskOpacity = open ? 1 : 0;\n\n const zIndexInner = useMemo(() => {\n return zIndex ? zIndex : 10 + getZindex();\n }, [zIndex]);\n\n const onOkHandle = hooks.useCallbackRef((e) => {\n if (onOk) {\n const response = onOk(e);\n if (response && isPromise(response)) {\n return response.then(onClose);\n }\n }\n return onClose();\n });\n\n return createPortal(\n <div\n className={classNames('drawer-resizable', { 'drawer-resizable-visible': open }, className)}\n style={!mask ? { width: widthStyle, zIndex: zIndexInner } : { left: 0, zIndex: zIndexInner }}\n >\n {mask ? (\n <div className=\"drawer-resizable-mask\" style={{ opacity: maskOpacity }} onClick={handleMaskClick} />\n ) : null}\n\n <div\n className=\"drawer-resizable-content\"\n style={{\n width: widthStyle,\n ...drawerStyle,\n ...style,\n }}\n >\n {/* 头部 */}\n <div className=\"drawer-resizable-header\" style={styles?.header}>\n <div className=\"drawer-resizable-title\">\n <Button\n type=\"text\"\n className=\"drawer-resizable-title-close\"\n icon={<CloseOutlined />}\n onClick={(event) => {\n event.stopPropagation();\n onClose();\n }}\n ></Button>\n <div className=\"\">{title}</div>\n </div>\n {headerExtraRender ? <div className=\"drawer-resizable-title-extra\">{headerExtraRender}</div> : null}\n </div>\n\n {/* 内容区域 */}\n <div className=\"drawer-resizable-body\" style={styles?.body}>\n <Resizable\n onResize={onResize}\n width={width}\n handle={<ResizeHandle />}\n axis=\"x\"\n resizeHandles={['w']}\n minConstraints={[400, 0]}\n maxConstraints={[1200, 0]}\n style={{ height: '100%' }}\n onResizeStop={(e) => {\n e.stopPropagation();\n const iframeList = document.querySelectorAll('iframe');\n iframeList.forEach((item) => {\n item.style.pointerEvents = '';\n });\n }}\n onResizeStart={(e) => {\n e.stopPropagation();\n const iframeList = document.querySelectorAll('iframe');\n iframeList.forEach((item) => {\n item.style.pointerEvents = 'none';\n });\n }}\n >\n {children}\n </Resizable>\n </div>\n {/* 底部 */}\n {hidenFooter ? null : footer ? (\n <div className=\"drawer-footer\" style={styles?.footer}>\n {footer}\n </div>\n ) : (\n <div className=\"drawer-footer\" style={styles?.footer}>\n <Space>\n <ButtonWrapper onClick={onClose}>{cancelText || '取消'}</ButtonWrapper>\n <ButtonWrapper onClick={onOkHandle} type=\"primary\" loadingPosition=\"center\">\n {okText || '确定'}\n </ButtonWrapper>\n </Space>\n </div>\n )}\n </div>\n </div>,\n document.body,\n );\n};\n"],"names":["ResizeHandle","forwardRef","props","ref","_jsx","_extends","className","zIndex","getZindex","ResizableDrawer","_ref","open","onClose","_ref$title","title","_ref$width","width","initialWidth","children","footer","_ref$maskClosable","maskClosable","style","_ref$mask","mask","styles","headerExtraRender","onOk","okText","cancelText","hidenFooter","_useState","useState","setWidth","onResize","_","data","size","handleMaskClick","e","stopPropagation","widthStyle","drawerStyle","transform","opacity","maskOpacity","zIndexInner","useMemo","onOkHandle","_hooks","useCallbackRef","response","_isPromise","then","createPortal","_jsxs","classNames","left","onClick","header","Button","type","icon","_CloseOutlined","event","body","Resizable","handle","axis","resizeHandles","minConstraints","maxConstraints","height","onResizeStop","iframeList","document","querySelectorAll","forEach","item","pointerEvents","onResizeStart","Space","ButtonWrapper","loadingPosition"],"mappings":";8uCAEO,IAAMA,EAAeC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["@flatbiz/antd/src/resizable-drawer/resize-handle/index.tsx","@flatbiz/antd/src/resizable-drawer/utils.ts","@flatbiz/antd/src/resizable-drawer/drawer.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport './style.less';\nexport const ResizeHandle = forwardRef<HTMLDivElement>((props, ref) => {\n return <div ref={ref} {...props} className=\"resize-border\" />;\n});\n","let zIndex = 10;\n\nexport const getZindex = () => {\n zIndex++;\n return zIndex;\n};\n","import { CloseOutlined } from '@ant-design/icons';\nimport { isPromise } from '@dimjs/lang';\nimport { hooks } from '@wove/react';\nimport { Button, Space } from 'antd';\nimport classNames from 'classnames';\nimport React, { useMemo, useState, type CSSProperties, type ReactElement } from 'react';\nimport { createPortal } from 'react-dom';\nimport { Resizable } from 'react-resizable';\nimport { ButtonWrapper } from '../button-wrapper';\nimport { ResizeHandle } from './resize-handle';\nimport './style.less';\nimport { getZindex } from './utils';\n\ntype ResizableDrawerProps = {\n open?: boolean;\n onClose: () => void;\n title?: React.ReactNode;\n width?: number | string;\n children?: React.ReactNode;\n footer?: React.ReactNode | null;\n hidenFooter?: boolean;\n maskClosable?: boolean;\n mask?: boolean;\n className?: string;\n style?: React.CSSProperties;\n styles?: {\n header?: CSSProperties;\n body?: CSSProperties;\n footer?: CSSProperties;\n };\n headerExtraRender?: ReactElement;\n zIndex?: number;\n cancelText?: string;\n okText?: string;\n onOk?: (e: React.MouseEvent<HTMLElement>) => void | Promise<void>;\n};\n\nexport const ResizableDrawer: React.FC<ResizableDrawerProps> = ({\n open,\n onClose,\n title = '抽屉标题',\n width: initialWidth = 600,\n children,\n footer,\n maskClosable = true,\n className,\n style,\n mask = true,\n styles,\n headerExtraRender,\n zIndex,\n onOk,\n okText,\n cancelText,\n hidenFooter,\n}) => {\n const [width, setWidth] = useState(initialWidth);\n\n const onResize = (_, data) => {\n const { size } = data;\n setWidth(size.width);\n };\n // 遮罩层点击\n const handleMaskClick = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n if (maskClosable) {\n onClose();\n }\n };\n\n // 计算宽度样式\n const widthStyle = typeof width === 'number' ? `${width}px` : width;\n\n const drawerStyle = open\n ? {\n transform: 'translateX(0)',\n opacity: 1,\n }\n : {\n transform: 'translateX(100%)',\n opacity: 0,\n };\n\n const maskOpacity = open ? 1 : 0;\n\n const zIndexInner = useMemo(() => {\n return zIndex ? zIndex : 10 + getZindex();\n }, [zIndex]);\n\n const onOkHandle = hooks.useCallbackRef((e) => {\n if (onOk) {\n const response = onOk(e);\n if (response && isPromise(response)) {\n return response.then(onClose);\n }\n }\n return onClose();\n });\n\n return createPortal(\n <div\n className={classNames('drawer-resizable', { 'drawer-resizable-visible': open }, className)}\n style={!mask ? { width: widthStyle, zIndex: zIndexInner } : { left: 0, zIndex: zIndexInner }}\n >\n {mask ? (\n <div className=\"drawer-resizable-mask\" style={{ opacity: maskOpacity }} onClick={handleMaskClick} />\n ) : null}\n\n <div\n className=\"drawer-resizable-content\"\n style={{\n width: widthStyle,\n ...drawerStyle,\n ...style,\n }}\n >\n {/* 头部 */}\n <div className=\"drawer-resizable-header\" style={styles?.header}>\n <div className=\"drawer-resizable-title\">\n <Button\n type=\"text\"\n className=\"drawer-resizable-title-close\"\n icon={<CloseOutlined />}\n onClick={(event) => {\n event.stopPropagation();\n onClose();\n }}\n ></Button>\n <div className=\"\">{title}</div>\n </div>\n {headerExtraRender ? <div className=\"drawer-resizable-title-extra\">{headerExtraRender}</div> : null}\n </div>\n\n {/* 内容区域 */}\n <div className=\"drawer-resizable-body\" style={styles?.body}>\n <Resizable\n onResize={onResize}\n width={width}\n handle={<ResizeHandle />}\n axis=\"x\"\n resizeHandles={['w']}\n minConstraints={[400, 0]}\n maxConstraints={[1200, 0]}\n style={{ height: '100%' }}\n onResizeStop={(e) => {\n e.stopPropagation();\n const iframeList = document.querySelectorAll('iframe');\n iframeList.forEach((item) => {\n item.style.pointerEvents = '';\n });\n }}\n onResizeStart={(e) => {\n e.stopPropagation();\n const iframeList = document.querySelectorAll('iframe');\n iframeList.forEach((item) => {\n item.style.pointerEvents = 'none';\n });\n }}\n >\n {children}\n </Resizable>\n </div>\n {/* 底部 */}\n {hidenFooter ? null : footer ? (\n <div className=\"drawer-footer\" style={styles?.footer}>\n {footer}\n </div>\n ) : (\n <div className=\"drawer-footer\" style={styles?.footer}>\n <Space>\n <ButtonWrapper onClick={onClose}>{cancelText || '取消'}</ButtonWrapper>\n <ButtonWrapper onClick={onOkHandle} type=\"primary\" loadingPosition=\"center\">\n {okText || '确定'}\n </ButtonWrapper>\n </Space>\n </div>\n )}\n </div>\n </div>,\n document.body,\n );\n};\n"],"names":["ResizeHandle","forwardRef","props","ref","_jsx","_extends","className","zIndex","getZindex","ResizableDrawer","_ref","open","onClose","_ref$title","title","_ref$width","width","initialWidth","children","footer","_ref$maskClosable","maskClosable","style","_ref$mask","mask","styles","headerExtraRender","onOk","okText","cancelText","hidenFooter","_useState","useState","setWidth","onResize","_","data","size","handleMaskClick","e","stopPropagation","widthStyle","drawerStyle","transform","opacity","maskOpacity","zIndexInner","useMemo","onOkHandle","_hooks","useCallbackRef","response","_isPromise","then","createPortal","_jsxs","classNames","left","onClick","header","Button","type","icon","_CloseOutlined","event","body","Resizable","handle","axis","resizeHandles","minConstraints","maxConstraints","height","onResizeStop","iframeList","document","querySelectorAll","forEach","item","pointerEvents","onResizeStart","Space","ButtonWrapper","loadingPosition"],"mappings":";8uCAEO,IAAMA,EAAeC,EAA2B,SAACC,EAAOC,GAC7D,OAAOC,QAAAC,EAAA,CAAKF,IAAKA,GAASD,EAAK,CAAEI,UAAU,kBAC7C,GCJA,IAAIC,EAAS,GAEN,IAAMC,EAAY,SAAZA,IACXD,IACA,OAAOA,CACT,MCgCaE,EAAkD,SAAlDA,EAA+CC,GAkBtD,IAjBJC,EAAID,EAAJC,KACAC,EAAOF,EAAPE,QAAOC,EAAAH,EACPI,MAAAA,EAAKD,SAAG,EAAA,OAAMA,EAAAE,EAAAL,EACdM,MAAOC,EAAYF,SAAG,EAAA,IAAGA,EACzBG,EAAQR,EAARQ,SACAC,EAAMT,EAANS,OAAMC,EAAAV,EACNW,aAAAA,EAAYD,SAAG,EAAA,KAAIA,EACnBd,EAASI,EAATJ,UACAgB,EAAKZ,EAALY,MAAKC,EAAAb,EACLc,KAAAA,EAAID,SAAG,EAAA,KAAIA,EACXE,EAAMf,EAANe,OACAC,EAAiBhB,EAAjBgB,kBACAnB,EAAMG,EAANH,OACAoB,EAAIjB,EAAJiB,KACAC,EAAMlB,EAANkB,OACAC,EAAUnB,EAAVmB,WACAC,EAAWpB,EAAXoB,YAEA,IAAAC,EAA0BC,EAASf,GAA5BD,EAAKe,EAAA,GAAEE,EAAQF,EAAA,GAEtB,IAAMG,EAAW,SAAXA,EAAYC,EAAGC,GACnB,IAAQC,EAASD,EAATC,KACRJ,EAASI,EAAKrB,QAGhB,IAAMsB,EAAkB,SAAlBA,EAAmBC,GACvBA,EAAEC,kBACF,GAAInB,EAAc,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UAAU,wBAAwBgB,MAAOG,GAAAA,UAAAA,EAAAA,EAAQwC,KAAK/C,SACzDd,EAAC8D,EAAS,CACRhC,SAAUA,EACVlB,MAAOA,EACPmD,OAAQ/D,EAACJ,MACToE,KAAK,IACLC,cAAe,CAAC,KAChBC,eAAgB,CAAC,IAAK,GACtBC,eAAgB,CAAC,KAAM,GACvBjD,MAAO,CAAEkD,OAAQ,QACjBC,aAAc,SAAdA,EAAelC,GACbA,EAAEC,kBACF,IAAMkC,EAAaC,SAASC,iBAAiB,UAC7CF,EAAWG,QAAQ,SAACC,GAClBA,EAAKxD,MAAMyD,cAAgB,EAC7B,EACA,EACFC,cAAe,SAAfA,EAAgBzC,GACdA,EAAEC,kBACF,IAAMkC,EAAaC,SAASC,iBAAiB,UAC7CF,EAAWG,QAAQ,SAACC,GAClBA,EAAKxD,MAAMyD,cAAgB,MAC7B,EACA,EAAA7D,SAEDA,MAIJY,EAAc,KAAOX,EACpBf,EAAA,MAAA,CAAKE,UAAU,gBAAgBgB,MAAOG,GAAAA,UAAAA,EAAAA,EAAQN,OAAOD,SAClDC,IAGHf,EAAA,MAAA,CAAKE,UAAU,gBAAgBgB,MAAOG,GAAAA,UAAAA,EAAAA,EAAQN,OAAOD,SACnDqC,EAAC0B,EAAK,CAAA/D,SAAA,CACJd,EAAC8E,EAAa,CAACxB,QAAS9C,EAAQM,SAAEW,GAAc,OAChDzB,EAAC8E,EAAa,CAACxB,QAASV,EAAYa,KAAK,UAAUsB,gBAAgB,SAAQjE,SACxEU,GAAU,kBAOvB+C,SAASV,KAEb"}
|
|
@@ -3,5 +3,5 @@ import './../dynamic-node/index.css';
|
|
|
3
3
|
import './../fba-hooks/index.css';
|
|
4
4
|
import './index.css';
|
|
5
5
|
/*! @flatjs/forge MIT @flatbiz/antd */
|
|
6
|
-
import{a as e,_ as n}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{classNames as t}from"@dimjs/utils/cjs/class-names";import{hooks as r}from"@wove/react/cjs/hooks";import{getStrByteLen as i}from"@flatbiz/utils";import{Editor as o}from"@tinymce/tinymce-react";import{useKeyPress as a}from"ahooks";import{Image as l,message as s}from"antd";import{Fragment as c,useRef as u,useState as m}from"react";import d from"@ant-design/icons/es/icons/PlusCircleOutlined";import{dynamicNode as p}from"../dynamic-node/index.js";import{fbaHooks as f}from"../fba-hooks/index.js";import{jsx as v,Fragment as g,jsxs as h}from"react/jsx-runtime";import"react-dom/client";import"../dom-4d04aa64.js";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-
|
|
6
|
+
import{a as e,_ as n}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{classNames as t}from"@dimjs/utils/cjs/class-names";import{hooks as r}from"@wove/react/cjs/hooks";import{getStrByteLen as i}from"@flatbiz/utils";import{Editor as o}from"@tinymce/tinymce-react";import{useKeyPress as a}from"ahooks";import{Image as l,message as s}from"antd";import{Fragment as c,useRef as u,useState as m}from"react";import d from"@ant-design/icons/es/icons/PlusCircleOutlined";import{dynamicNode as p}from"../dynamic-node/index.js";import{fbaHooks as f}from"../fba-hooks/index.js";import{jsx as v,Fragment as g,jsxs as h}from"react/jsx-runtime";import"react-dom/client";import"../dom-4d04aa64.js";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-1e6d93d9.js";import"@dimjs/utils/cjs/uuid";var y=function e(n){var t=n.visible,r=n.url;f.useEffectCustom(function(){if(t){p.append({content:v(d,{onClick:n.close,className:"preview-image-popup-close",twoToneColor:"#1890ff"})})}else{p.remove()}},[t]);if(!r)return v(g,{});return v(c,{children:v(l,{style:{left:"100px"},preview:{className:"preview-image-popup",maskStyle:{backgroundColor:"rgba(0,0,0,0.85)"},visible:t,src:r,onVisibleChange:function e(){n.close()}}},r)})};var b=["onUploadImage","onChange","height","className"];var C=function l(c){var d,p,f,g;var C=c.onUploadImage,k=c.onChange,x=c.height,_=c.className,w=e(c,b);var j=u(null);var E=m(""),I=E[0],S=E[1];var F=((d=c.init)==null?void 0:d.img_ratio)||[{min:0,max:1e3,ratio:.5},{min:1e3,ratio:.3}];a(function(){return true},function(e){try{if(e.type==="keyup"&&e.key==="Escape"){var n;var t=(n=j.current)==null?void 0:n.editorContainer.classList.contains("tox-fullscreen");if(t){var r;(r=j.current)==null||r.editorCommands.execCommand("mceFullScreen")}}}catch(e){}},{events:["keydown","keyup"]});var N=r.useCallbackRef(function(e,n){try{if(e.keyCode==27){var t;var r=(t=j.current)==null?void 0:t.editorContainer.classList.contains("tox-fullscreen");if(r){var i;(i=j.current)==null||i.editorCommands.execCommand("mceFullScreen")}}}catch(e){}c.onKeyDown==null||c.onKeyDown(e,n)});var P=r.useCallbackRef(function(e,n){j.current=n;n.on("FullscreenStateChanged",function(e){c.onFullScreenChange==null||c.onFullScreenChange(e.state)});try{var t;(t=n.iframeElement)==null||(t=t.contentDocument)==null||t.addEventListener("click",function(e){var n;if(c.imgPreview&&((n=e.target)==null?void 0:n["tagName"])==="IMG"){S(e.target["src"])}},true)}catch(e){}w.onInit==null||w.onInit(e,n)});var z=r.useCallbackRef(function(e,n){j.current=n;w.onEditorChange==null||w.onEditorChange(e,n);k==null||k(e)});var R="https://file.40017.cn/tcsk/tinymce@6.4.1";var D=function e(n){if(F.length===0)return 1;for(var t=0;t<F.length;t++){var r=F[t];if(r.max){if(n>=r.min&&n<=r.max)return r.ratio}else{if(n>=r.min)return r.ratio}}return 1};var K=r.useCallbackRef(function(e,n){try{var t=n.node.children||[];if(t.length===1&&t[0].nodeName==="IMG"){t[0].setAttribute("style","display:none");var r=document.createElement("img");r.src=t[0].getAttribute("src");r.onload=function(){var n=D(r.width);e.execCommand("mceInsertContent",true,'<img src="'+r.src+'" width="'+r.width*n+'" height="'+r.height*n+'" />')}}}catch(e){}});var L=r.useCallbackRef(function(e,n){var t;var r=(t=c.init)==null?void 0:t.paste_text_limit;if(r){var o=i(n.content);if(o>1024*r.limit){void s.error(r.message);n.content=""}}});return h("div",{className:t("v-editor-wrapper",_),children:[v(o,n({tinymceScriptSrc:R+"/tinymce.min.js"},w,{onInit:P,onKeyDown:N,onEditorChange:z,init:n({promotion:false,language:"zh-Hans",height:x,paste_data_images:C?true:false,paste_postprocess:K,paste_preprocess:L,autosave_ask_before_unload:false,base_url:R,autoresize_bottom_margin:0,images_upload_handler:function e(n){return new Promise(function(e,t){var r,i,o;var a=function(n){try{return e(Promise.reject((n==null?void 0:n.message)||"图片上传异常"))}catch(e){return t(e)}};try{r=n.blob();i=new File([r],r["name"],{type:r.type});return Promise.resolve(C==null?void 0:C(i)).then(function(n){try{o=n;return e(Promise.resolve(o))}catch(e){return a(e)}},a)}catch(e){a(e)}})},plugins:"lists link image advlist charmap preview fullscreen code table help codesample "+(((p=c.init)==null?void 0:p.plugins_append)||""),toolbar:"undo redo fullscreen preview | bold italic underline strikethrough |"+"fontsize blocks |"+"forecolor backcolor removeformat |"+"numlist bullist advlist |"+"alignleft aligncenter alignright alignjustify |"+"outdent indent |"+"hr image link code codesample |"+(((f=c.init)==null?void 0:f.toolbar_append)||""),font_size_formats:"8px 10px 12px 14px 16px 18px 24px 36px 48px"},c.init,{content_style:"img {max-width:100%;} table{width:100%} "+((g=c.init)==null?void 0:g.content_style),convert_urls:false})})),v(y,{visible:!!I,url:I,close:function e(){S("")}})]})};export{C as RichTextEditor};
|
|
7
7
|
//# sourceMappingURL=index.js.map
|