浏览代码

Merge branch 'v2' of https://github.com/jdf2e/nutui into v2

Frans 7 年之前
父节点
当前提交
3ff3c7efd4

+ 105 - 0
src/packages/button/__test__/button.spec.js

@@ -0,0 +1,105 @@
+import { shallowMount, mount } from '@vue/test-utils'
+import Button from '../button.vue';
+import Vue from 'vue';
+
+describe('Button.vue', () => {
+    it('设置type', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '去结算'
+            },
+            propsData:{
+                type: 'light'
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.attributes('class')).toContain('light');
+        })
+    });
+    it('设置slot', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '去结算'
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.text()).toBe('去结算');
+        })
+    });
+    it('设置disabled', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '去结算'
+            },
+            propsData:{
+                disabled: true
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.text()).toBe('去结算');
+            expect(wrapper.attributes('disabled')).toContain('disabled');
+        })
+    });
+    it('设置shape', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '去结算'
+            },
+            propsData:{
+                shape: 'circle'
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.text()).toBe('去结算');
+            expect(wrapper.attributes('class')).toContain('circle');
+        })
+    });
+    it('设置small', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '去结算'
+            },
+            propsData:{
+                small: true
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.text()).toBe('去结算');
+            expect(wrapper.attributes('class')).toContain('small');
+        })
+    });
+    it('设置icon', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '全部100万'
+            },
+            propsData:{
+                type: 'actived',
+                icon: 'tick'
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.text()).toBe('全部100万');
+            expect(wrapper.contains('.txt-icon')).toBe(true);
+            expect(wrapper.find('.txt-icon').attributes('type')).toBe('tick');            
+            expect(wrapper.find('span').text()).toBe('全部100万');
+        })
+    });
+    it('设置color', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '去结算'
+            },
+            propsData:{
+                icon: 'tick',
+                color: '#fff'
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.text()).toBe('去结算');
+            expect(wrapper.find('span').attributes('style')).toBe('color: rgb(255, 255, 255);');
+            expect(wrapper.find('.txt-icon').attributes('color')).toBe('#fff');
+        })
+    });
+
+});

+ 6 - 6
src/packages/buttongroup/demo.vue

@@ -1,23 +1,23 @@
 <template>
 <template>
     <div>
     <div>
       <h4>常规按钮组</h4>
       <h4>常规按钮组</h4>
-      <nut-button-group>
+      <nut-buttongroup>
         <nut-button type="light">重置</nut-button>
         <nut-button type="light">重置</nut-button>
         <nut-button>确定</nut-button>
         <nut-button>确定</nut-button>
-      </nut-button-group>
+      </nut-buttongroup>
     <h4>圆角按钮组</h4>
     <h4>圆角按钮组</h4>
-    <nut-button-group shape="circle">
+    <nut-buttongroup shape="circle">
       <nut-button type="light">重置</nut-button>
       <nut-button type="light">重置</nut-button>
       <nut-button>确定</nut-button>
       <nut-button>确定</nut-button>
-    </nut-button-group>
+    </nut-buttongroup>
     <h4>页面底部功能,配合Badge使用</h4>
     <h4>页面底部功能,配合Badge使用</h4>
-      <nut-button-group type="menu">
+      <nut-buttongroup type="menu">
         <nut-button type="light" icon="action" color="#000">关于</nut-button>
         <nut-button type="light" icon="action" color="#000">关于</nut-button>
         <nut-button type="light" icon="more" color="#000">更多</nut-button>
         <nut-button type="light" icon="more" color="#000">更多</nut-button>
         <nut-button type="light" icon="search" color="#000">关闭</nut-button>
         <nut-button type="light" icon="search" color="#000">关闭</nut-button>
         <nut-badge value="2" top="0.5rem" right="2rem"><nut-button type="light" icon="trolley" color="#f00">购物车</nut-button></nut-badge>      
         <nut-badge value="2" top="0.5rem" right="2rem"><nut-button type="light" icon="trolley" color="#f00">购物车</nut-button></nut-badge>      
         <nut-button type="light" icon="tick" color="#000">成功</nut-button>
         <nut-button type="light" icon="tick" color="#000">成功</nut-button>
-      </nut-button-group>
+      </nut-buttongroup>
     </div>
     </div>
 </template>
 </template>
 
 

+ 2 - 2
src/packages/calendar/calendar.scss

@@ -36,10 +36,10 @@
         line-height: 40px;
         line-height: 40px;
     }
     }
     .nut-calendar-confirm-btn{
     .nut-calendar-confirm-btn{
-        left: 0;
+        right: 0;
     }
     }
     .nut-calendar-cancel-btn{
     .nut-calendar-cancel-btn{
-        right: 0;
+        left: 0;
     }
     }
     .nut-calendar-title{
     .nut-calendar-title{
         margin: 0 60px;
         margin: 0 60px;

+ 4 - 2
src/packages/checkbox/__test__/checkbox.spec.js

@@ -5,9 +5,11 @@ import Vue from 'vue';
 
 
 describe('Checkbox.vue', () => {
 describe('Checkbox.vue', () => {
     const wrapper = shallowMount(Checkbox, {
     const wrapper = shallowMount(Checkbox, {
-
+        propsData:{
+            value:true
+        }
     });
     });
-
+    
     it('尺寸设置为base', () => {
     it('尺寸设置为base', () => {
         wrapper.setProps({ size: 'base' });
         wrapper.setProps({ size: 'base' });
 
 

+ 2 - 2
src/packages/picker/picker.vue

@@ -2,9 +2,9 @@
     <nut-actionsheet :is-visible="isVisible" @close="closeActionSheet">
     <nut-actionsheet :is-visible="isVisible" @close="closeActionSheet">
         <div class="nut-picker" slot="custom" :class="customClassName ? customClassName : null">
         <div class="nut-picker" slot="custom" :class="customClassName ? customClassName : null">
             <div class="nut-picker-control">
             <div class="nut-picker-control">
-                <span class="nut-picker-confirm-btn"  @click="closeActionSheet">{{nutTranslate('lang.okBtnTxt')}}</span>
+                <span class="nut-picker-confirm-btn"  @click="closeActionSheet">{{nutTranslate('lang.cancelText')}}</span>
                 <div class="nut-picker-title">{{title ? title : ''}}</div>
                 <div class="nut-picker-title">{{title ? title : ''}}</div>
-                <span class="nut-picker-cancel-btn" @click="confirm">{{nutTranslate('lang.cancelText')}}</span>
+                <span class="nut-picker-cancel-btn" @click="confirm">{{nutTranslate('lang.okBtnTxt')}}</span>
             </div>
             </div>
             <div class="nut-picker-panel">
             <div class="nut-picker-panel">
                 <template v-for="(item, index) of listData" >
                 <template v-for="(item, index) of listData" >

+ 1 - 5
types/index.d.ts

@@ -1,7 +1,3 @@
 import * as NutUI from './nutui'
 import * as NutUI from './nutui'
 export default NutUI
 export default NutUI
-
-
-
-
-
+export * from './nutui'

+ 48 - 1
types/nutui.d.ts

@@ -1,4 +1,50 @@
 import Vue  from 'vue';
 import Vue  from 'vue';
+
+declare class UIComponent extends Vue {
+    static install (vue: typeof Vue): void
+}
+
+export declare class ActionSheet extends UIComponent {}
+export declare class Badge extends UIComponent {}
+export declare class Button extends UIComponent {}
+export declare class ButtonGroup extends UIComponent {}
+export declare class Calendar extends UIComponent {}
+export declare class Cell extends UIComponent {}
+export declare class CheckBox extends UIComponent {}
+export declare class CheckBoxGroup extends UIComponent {}
+export declare class Col extends UIComponent {}
+export declare class DatePicker extends UIComponent {}
+export declare class Dialog extends UIComponent {}
+export declare class Flex extends UIComponent {}
+export declare class Grid extends UIComponent {}
+export declare class GridCol extends UIComponent {}
+export declare class GridRow extends UIComponent {}
+export declare class Icon extends UIComponent {}
+export declare class ImagePicker extends UIComponent {}
+export declare class Menu extends UIComponent {}
+export declare class Navbar extends UIComponent {}
+export declare class NoticeBar extends UIComponent {}
+export declare class Picker extends UIComponent {}
+export declare class Price extends UIComponent {}
+export declare class Progress extends UIComponent {}
+export declare class Radio extends UIComponent {}
+export declare class RadioGroup extends UIComponent {}
+export declare class Range extends UIComponent {}
+export declare class Rating extends UIComponent {}
+export declare class Row extends UIComponent {}
+export declare class SearchBar extends UIComponent {}
+export declare class ShortPassword extends UIComponent {}
+export declare class Skeleton extends UIComponent {}
+export declare class Slider extends UIComponent {}
+export declare class Stepper extends UIComponent {}
+export declare class Steps extends UIComponent {}
+export declare class Swiper extends UIComponent {}
+export declare class Switch extends UIComponent {}
+export declare class Tab extends UIComponent {}
+export declare class Tabbar extends UIComponent {}
+export declare class TabPanel extends UIComponent {}
+export declare class Toast extends UIComponent {}
+
 export interface InstallationOptions {
 export interface InstallationOptions {
     locale?: any
     locale?: any
     lang?: any
     lang?: any
@@ -8,4 +54,5 @@ export const version: string
 
 
 export const locale: (l:any) => void
 export const locale: (l:any) => void
 
 
-export function install (vue: typeof Vue, options: InstallationOptions): void
+export function install (vue: typeof Vue, options: InstallationOptions): void
+