Browse Source

fix: 组件dts修改

yangxiaolu3 3 years ago
parent
commit
d52f1222c3

+ 4 - 3
src/packages/__VUE/audio/index.vue

@@ -14,7 +14,7 @@
           inactive-color="#cccccc"
           active-color="#fa2c19"
         >
-          <template #button>
+          <template v-slot:button>
             <div class="nut-audio__button--custom"></div>
           </template>
         </nut-range>
@@ -112,7 +112,7 @@ export default create({
   },
   emits: ['fastBack', 'play', 'forward', 'ended', 'changeProgress', 'mute', 'can-play'],
 
-  setup(props, { emit }) {
+  setup(props, { emit, slots }) {
     const audioRef = ref(null);
 
     const audioData = reactive({
@@ -277,7 +277,8 @@ export default create({
       audioEnd,
       onTimeupdate,
       handleMute,
-      onCanplay
+      onCanplay,
+      slots
     };
   }
 });

+ 8 - 1
src/packages/__VUE/audiooperate/index.vue

@@ -43,7 +43,14 @@ export default create({
 
   setup(props, { emit }) {
     const audio: any = inject('audioParent');
-    const parent: any = reactive(audio);
+    const parent: {
+      children: [];
+      audioData: any;
+      handleMute: ((payload: MouseEvent) => void) | undefined;
+      forward: ((payload: MouseEvent) => void) | undefined;
+      fastBack: ((payload: MouseEvent) => void) | undefined;
+      changeStatus: ((payload: MouseEvent) => void) | undefined;
+    } = reactive(audio);
     const customSlot = ref(useSlots().default);
 
     return { ...toRefs(props), ...toRefs(parent), customSlot, translate };

+ 4 - 18
src/packages/__VUE/backtop/index.vue

@@ -10,6 +10,7 @@
 import { computed, onMounted, onUnmounted, onActivated, onDeactivated, reactive } from 'vue';
 import { createComponent } from '@/packages/utils/create';
 const { componentName, create } = createComponent('backtop');
+import requestAniFrame, { cancelRaf } from '@/packages/utils/raf';
 import { Top } from '@nutui/icons-vue';
 export default create({
   components: {
@@ -88,13 +89,13 @@ export default create({
     }
 
     function scrollAnimation() {
-      let cid = requestAniFrame()(function fn() {
+      let cid = requestAniFrame(function fn() {
         var t = props.duration - Math.max(0, state.startTime - +new Date() + props.duration);
         var y = (t * -state.scrollTop) / props.duration + state.scrollTop;
         scroll(y);
-        cid = requestAniFrame()(fn);
+        cid = requestAniFrame(fn);
         if (t == props.duration || y == 0) {
-          window.cancelAnimationFrame(cid);
+          cancelRaf(cid);
         }
       });
     }
@@ -109,20 +110,6 @@ export default create({
       state.scrollEl.removeEventListener('resize', scrollListener, false);
     }
 
-    function initCancelAniFrame() {
-      window.cancelAnimationFrame = window.webkitCancelAnimationFrame;
-    }
-
-    function requestAniFrame() {
-      return (
-        window.requestAnimationFrame ||
-        window.webkitRequestAnimationFrame ||
-        function (callback) {
-          window.setTimeout(callback, 1000 / 60);
-        }
-      );
-    }
-
     function click(e: MouseEvent) {
       state.startTime = +new Date();
       props.isAnimation && props.duration > 0 ? scrollAnimation() : scroll();
@@ -135,7 +122,6 @@ export default create({
       }
 
       addEventListener();
-      initCancelAniFrame();
     }
 
     onMounted(() => {

+ 2 - 2
src/packages/__VUE/dialog/index.ts

@@ -1,5 +1,5 @@
 import Dialog from './index.vue';
-import { h, VNode, CSSProperties } from 'vue';
+import { h, VNode, CSSProperties, Component } from 'vue';
 import Popup from '../popup/index.vue';
 import Icon from '../icon/index.vue';
 import Button from '../button/index.vue';
@@ -58,7 +58,7 @@ class DialogFunction {
             }
             options.teleport = `#${root.id}`;
             return () => {
-              return h(Dialog, options);
+              return h(Dialog as Component, options);
             };
           }
         };

+ 2 - 2
src/packages/__VUE/imagepreview/index.ts

@@ -1,5 +1,5 @@
 import ImagePreview from './index.vue';
-import { h } from 'vue';
+import { Component, h } from 'vue';
 import { ImageInterface } from './types';
 import { CreateComponent } from '@/packages/utils/create';
 import { Interceptor } from '@/packages/utils/util';
@@ -48,7 +48,7 @@ class ImagePreviewFunction {
               options.onClose = () => {
                 unmount();
               };
-              return h(ImagePreview, options);
+              return h(ImagePreview as Component, options);
             };
           }
         };

+ 3 - 3
src/packages/__VUE/invoice/index.vue

@@ -32,7 +32,7 @@
       </nut-form-item>
     </nut-form>
     <div v-if="submit" class="nut-invoice__submit">
-      <nut-button type="primary" block @click="submit">提交审批</nut-button>
+      <nut-button type="primary" block @click="submitFun">提交审批</nut-button>
     </div>
   </view>
 </template>
@@ -93,7 +93,7 @@ export default create({
       list.value = props.data;
     };
 
-    const submit = () => {
+    const submitFun = () => {
       formRef.value.validate().then(({ valid, errors }: any) => {
         emit('onSubmit', valid, errors);
       });
@@ -110,7 +110,7 @@ export default create({
       classes,
       formRef,
       list,
-      submit
+      submitFun
     };
   }
 });

+ 1 - 1
src/packages/__VUE/picker/Column.vue

@@ -134,7 +134,7 @@ export default create({
         let dom = roller.value as any;
         const { transform } = window.getComputedStyle(dom);
         if (props.threeDimensional) {
-          const circle = Math.floor(parseFloat(touchDeg.value) / 360);
+          const circle = Math.floor(touchDeg.value / 360);
           const cos = +transform.split(', ')[5];
           const sin = +transform.split(', ')[6] < 0 ? 180 : 0;
           const endDeg = circle * 360 + (Math.acos(cos) / Math.PI) * 180 + sin;

+ 4 - 4
src/packages/__VUE/popover/index.vue

@@ -24,7 +24,7 @@
           :class="[item.className, item.disabled && 'nut-popover-menu-disabled', 'nut-popover-menu-item']"
           @click.stop="chooseItem(item, index)"
         >
-          <component :is="renderIcon(item.icon)" class="nut-popover-item-img"></component>
+          <component v-if="item.icon" :is="renderIcon(item.icon)" class="nut-popover-item-img"></component>
 
           <view class="nut-popover-menu-item-name">{{ item.name }}</view>
         </view>
@@ -87,7 +87,7 @@ export default create({
       const base = 16;
 
       if (bgColor) {
-        styles[`border${upperCaseFirst(direction)}Color`] = bgColor;
+        styles[`border${upperCaseFirst(direction)}Color` as any] = bgColor;
       }
 
       if (props.arrowOffset != 0) {
@@ -187,7 +187,7 @@ export default create({
     const getContentWidth = () => {
       let rect = useRect(popoverRef.value);
       if (props.targetId) {
-        rect = useRect(document.querySelector(`#${props.targetId}`));
+        rect = useRect(document.querySelector(`#${props.targetId}`) as Element);
       }
       rootRect.value = rect;
       setTimeout(() => {
@@ -241,7 +241,7 @@ export default create({
       let el = element && !element.contains(event.target);
 
       if (props.targetId) {
-        const dom = document.querySelector(`#${props.targetId}`);
+        const dom: any = document.querySelector(`#${props.targetId}`);
         el = dom && !dom.contains(event.target);
       }
       if (el && elContent && !elContent.contains(event.target) && props.closeOnClickOutside) {

+ 3 - 1
src/packages/__VUE/popover/type.ts

@@ -1,3 +1,5 @@
+import { Component } from 'vue';
+
 export type PopoverTheme = 'light' | 'dark';
 
 export type PopoverLocation =
@@ -16,7 +18,7 @@ export type PopoverLocation =
 
 export type PopoverList = {
   name: string;
-  icon?: string;
+  icon?: Component;
   disabled?: boolean;
   className?: any;
   [key: PropertyKey]: any;

+ 6 - 3
src/packages/__VUE/tour/index.vue

@@ -149,9 +149,12 @@ export default create({
       active: 0
     });
 
-    const maskRect = ref<{
-      [props: string]: number;
-    }>({});
+    const maskRect = ref<
+      | DOMRect
+      | {
+          [props: string]: number;
+        }
+    >({});
 
     const classes = computed(() => {
       const prefixCls = 'nut-tour';

+ 11 - 0
src/packages/utils/raf.ts

@@ -1,4 +1,7 @@
 const _window = window as any;
+
+export const inBrowser = typeof window !== 'undefined';
+
 function requestAniFrame() {
   if (typeof _window !== 'undefined') {
     return (
@@ -15,4 +18,12 @@ function requestAniFrame() {
   }
 }
 
+export function cancelRaf(id: number) {
+  if (inBrowser) {
+    cancelAnimationFrame(id);
+  } else {
+    clearTimeout(id);
+  }
+}
+
 export default requestAniFrame();