UNPKG

tdesign-vue-next

Version:
1 lines 5.88 kB
{"version":3,"file":"adapt.mjs","sources":["../../../components/tree/adapt.ts"],"sourcesContent":["// 在这个文件,解决 vue2/vue3 tree 组件依赖的差异问题\n// 除此文件之外的其他组件文件,可从 vue2 项目直接复制到 vue3 项目进行维护\nimport * as Vue from 'vue';\nimport { Ref, SetupContext, ToRefs, VNode, PropType, ComponentPublicInstance, UnwrapNestedRefs } from 'vue';\nimport { CheckboxProps } from '../checkbox';\nimport { ClassName, TScroll, Styles, TNode, TreeOptionData, TNodeReturnValue } from '../common';\nimport { TypeTreeEventState as TreeEventState } from '@tdesign/common-js/tree/types';\nimport { TdTreeProps, TreeInstanceFunctions } from './type';\nimport { VirtualScrollConfig } from '../hooks/useVirtualScrollNew';\nimport tdWithInstall from '../utils/withInstall';\nimport tdUseVModel from '../hooks/useVModel';\nimport tdUseDefaultValue from '../hooks/useDefaultValue';\nimport { TreeStore } from '@tdesign/common-js/tree/tree-store';\n\nexport { ref, reactive, computed, watch, onMounted, toRefs, defineComponent, TransitionGroup } from 'vue';\nexport { CaretRightSmallIcon as TdCaretRightSmallIcon } from 'tdesign-icons-vue-next';\nexport { Checkbox as TCheckBox } from '../checkbox';\nexport { Loading as TLoading } from '../loading';\nexport { useConfig, usePrefixClass } from '../hooks/useConfig';\nexport { useGlobalIcon } from '../hooks/useGlobalIcon';\nexport { default as useLazyLoad } from '../hooks/useLazyLoad';\nexport { default as useVirtualScroll } from '../hooks/useVirtualScrollNew';\nexport { TreeNode, privateKey } from '@tdesign/common-js/tree/tree-node';\nexport type TypeVModel = ReturnType<typeof tdUseVModel>;\n\nexport type TypeRef<T> = Ref<T>;\nexport type TypeSetupContext = SetupContext;\nexport type TypeCreateElement = typeof Vue.h;\nexport type TypeVNode = VNode;\nexport type TypePropType<T> = PropType<T>;\nexport type TypeCheckboxProps = CheckboxProps;\nexport type TypeClassName = ClassName;\nexport type TypeScroll = TScroll;\nexport type TypeStyles = Styles;\nexport type TypeTNode<T> = TNode<T>;\nexport type TypeTNodeReturnValue = TNodeReturnValue;\nexport type TypeTreeOptionData = TreeOptionData;\nexport type TypeTreeEventState = TreeEventState;\nexport type TypeVirtualScrollConfig = VirtualScrollConfig;\nexport type TypeToRefs<T> = ToRefs<T>;\nexport type TypeUnwrapNestedRefs<T> = UnwrapNestedRefs<T>;\nexport interface TypeTreeInstance extends ComponentPublicInstance, TreeInstanceFunctions {}\n\nexport type TreeProps<T extends TypeTreeOptionData = TypeTreeOptionData> = TdTreeProps<T> & {\n treeStore?: TreeStore;\n};\n\nexport interface TypeOnDrag {\n default?: unknown;\n}\n\nconst onDrag: TypeOnDrag = {\n default: undefined,\n};\n\nexport const isVueNext = true;\n\nexport const TreeItemDefinition = {\n name: 'TTreeNode',\n inject: {\n onDrag,\n },\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useRipple(el: unknown) {}\n\nexport function withInstall<T>(construct: T) {\n return tdWithInstall(construct);\n}\n\nexport interface UseVModelParams<T> {\n value: Ref<T>;\n eventName?: string;\n propName?: string;\n}\n\nexport function getCreateElement(h?: TypeCreateElement) {\n if (h) {\n // do nothing, just for adapt\n }\n return Vue.h;\n}\n\nexport function getScopedSlots(instance: ComponentPublicInstance) {\n return instance.$slots;\n}\n\nexport function useVModel(\n props: TreeProps & Record<string, any>,\n refsProps: ToRefs<TreeProps> & Record<string, any>,\n propName = 'value',\n defaultPropName = 'defaultValue',\n eventPropName = 'onChange',\n eventName = 'change',\n) {\n if (eventName) {\n // do nothing,just for adapt\n }\n const { modelValue } = refsProps;\n let vm;\n if (propName === 'value') {\n vm = tdUseVModel(refsProps[propName], modelValue, props[defaultPropName], props[eventPropName], propName);\n } else {\n vm = tdUseDefaultValue(refsProps[propName], props[defaultPropName], props[eventPropName], propName);\n }\n return vm;\n}\n"],"names":["onDrag","isVueNext","TreeItemDefinition","name","inject","useRipple","el","withInstall","construct","tdWithInstall","getCreateElement","h","Vue","getScopedSlots","instance","$slots","useVModel","props","refsProps","propName","arguments","length","undefined","defaultPropName","eventPropName","eventName","modelValue","vm","tdUseVModel","tdUseDefaultValue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAMA,MAAqB,GAAA;AACzB,EAAA,SAAA,EAAS,KAAA,CAAA;AACX,CAAA,CAAA;AAEO,IAAMC,SAAY,GAAA,KAAA;AAElB,IAAMC,kBAAqB,GAAA;AAChCC,EAAAA,IAAM,EAAA,WAAA;AACNC,EAAAA,MAAQ,EAAA;AACNJ,IAAAA,MAAA,EAAAA,MAAAA;AACF,GAAA;AACF,EAAA;AAGO,SAASK,UAAUC,EAAa,EAAA,EAAC;AAEjC,SAASC,YAAeC,SAAc,EAAA;EAC3C,OAAOC,cAAcD,SAAS,CAAA,CAAA;AAChC,CAAA;AAQO,SAASE,iBAAiBC,CAAuB,EAAA;EACtD,IAAIA,CAAG,EAAA,EAEP;EACA,OAAOC,GAAI,CAAAD,CAAA,CAAA;AACb,CAAA;AAEO,SAASE,eAAeC,QAAmC,EAAA;EAChE,OAAOA,QAAS,CAAAC,MAAA,CAAA;AAClB,CAAA;AAEgB,SAAAC,SAAAA,CACdC,KACA,EAAAC,SAAA,EAKA;AAAA,EAAA,IAJAC,QAAW,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAA,OAAA,CAAA;AAAA,EAAA,IACXG,sFAAkB,cAClB,CAAA;AAAA,EAAA,IAAAC,aAAA,GAAAJ,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAgB,UAChB,CAAA;AAAA,EAAA,IAAAK,SAAA,GAAAL,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA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