Skip to content

Commit 04cddfc

Browse files
authored
修复部分组件ESLint问题 (DevCloudFE#365)
* chore(ripple): 修复ripple组件的eslint问题 * chore(loading): 修复loading组件的eslint问题 * chore(result): 修复result组件的eslint问题 * chore(auto-complete): 修复auto-complete组件部分eslint问题 * chore(checkbox): 修复checkbox组件的eslint问题 * chore(input): 修复input组件的eslint问题 * chore(editable-select): 修复editable-select组件的eslint问题 * chore(switch): 修复switch组件的eslint问题 * chore(textarea): 修复textarea组件的eslint问题 * chore(avatar): 修复avatar/tag-input组件部分eslint问题 * chore(countdown): 修复countdown组件的eslint问题 * chore(progress): 修复progress组件部分eslint问题 * chore(rate): 修复rate组件部分eslint问题 * chore(splitter): 修复部分组件eslint问题
1 parent 7d3e959 commit 04cddfc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+465
-603
lines changed
Lines changed: 50 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import { defineComponent, provide, Transition,toRefs, ref, SetupContext, Teleport } from 'vue'
2-
import { autoCompleteProps, AutoCompleteProps, DropdownPropsKey } from './auto-complete-types'
3-
import useCustomTemplate from './composables/use-custom-template'
4-
import useSearchFn from './composables/use-searchfn'
5-
import useInputHandle from './composables/use-input-handle'
6-
import useSelectHandle from './composables/use-select-handle'
7-
import useLazyHandle from './composables/use-lazy-handle'
8-
import useKeyBoardHandle from './composables/use-keyboard-select'
9-
import './auto-complete.scss'
10-
import DAutoCompleteDropdown from './components/dropdown'
11-
import ClickOutside from '../../shared/devui-directive/clickoutside'
12-
import {FlexibleOverlay} from '../../overlay/src/flexible-overlay'
1+
import { defineComponent, provide, Transition, toRefs, ref, SetupContext, Teleport } from 'vue';
2+
import { autoCompleteProps, AutoCompleteProps, DropdownPropsKey } from './auto-complete-types';
3+
import useCustomTemplate from './composables/use-custom-template';
4+
import useSearchFn from './composables/use-searchfn';
5+
import useInputHandle from './composables/use-input-handle';
6+
import useSelectHandle from './composables/use-select-handle';
7+
import useLazyHandle from './composables/use-lazy-handle';
8+
import useKeyBoardHandle from './composables/use-keyboard-select';
9+
import './auto-complete.scss';
10+
import DAutoCompleteDropdown from './components/dropdown';
11+
import ClickOutside from '../../shared/devui-directive/clickoutside';
12+
import { FlexibleOverlay } from '../../overlay/src/flexible-overlay';
1313

1414
export default defineComponent({
1515
name: 'DAutoComplete',
1616
directives: { ClickOutside },
1717
props: autoCompleteProps,
1818
emits: ['update:modelValue'],
19-
setup(props: AutoCompleteProps, ctx:SetupContext) {
19+
setup(props: AutoCompleteProps, ctx: SetupContext) {
2020
const {
2121
disabled,
2222
modelValue,
@@ -30,30 +30,17 @@ export default defineComponent({
3030
searchFn,
3131
position,
3232
latestSource,
33-
showAnimation
34-
} = toRefs(props)
33+
showAnimation,
34+
} = toRefs(props);
3535

36-
const {
37-
handleSearch,
38-
searchList,
39-
showNoResultItemTemplate,
40-
recentlyFocus
41-
} = useSearchFn(
36+
const { handleSearch, searchList, showNoResultItemTemplate, recentlyFocus } = useSearchFn(
4237
ctx,
4338
allowEmptyValueSearch,
4439
source,
4540
searchFn,
4641
formatter
47-
)
48-
const {
49-
onInput,
50-
onFocus,
51-
inputRef,
52-
visible,
53-
searchStatus,
54-
handleClose,
55-
toggleMenu
56-
} = useInputHandle(
42+
);
43+
const { onInput, onFocus, inputRef, visible, searchStatus, handleClose, toggleMenu } = useInputHandle(
5744
ctx,
5845
searchList,
5946
showNoResultItemTemplate,
@@ -64,37 +51,11 @@ export default defineComponent({
6451
transInputFocusEmit,
6552
recentlyFocus,
6653
latestSource
67-
)
68-
const {
69-
selectedIndex,
70-
selectOptionClick
71-
} = useSelectHandle(
72-
ctx,
73-
searchList,
74-
selectValue,
75-
handleSearch,
76-
formatter,
77-
handleClose
78-
)
79-
const {
80-
showLoading,
81-
dropDownRef,
82-
loadMore
83-
} = useLazyHandle(
84-
props,
85-
ctx,
86-
handleSearch
87-
)
88-
const {
89-
customRenderSolts
90-
} = useCustomTemplate(
91-
ctx,
92-
modelValue
93-
)
94-
const {
95-
hoverIndex,
96-
handlekeyDown
97-
} = useKeyBoardHandle(
54+
);
55+
const { selectedIndex, selectOptionClick } = useSelectHandle(ctx, searchList, selectValue, handleSearch, formatter, handleClose);
56+
const { showLoading, dropDownRef, loadMore } = useLazyHandle(props, ctx, handleSearch);
57+
const { customRenderSolts } = useCustomTemplate(ctx, modelValue);
58+
const { hoverIndex, handlekeyDown } = useKeyBoardHandle(
9859
dropDownRef,
9960
visible,
10061
searchList,
@@ -103,12 +64,12 @@ export default defineComponent({
10364
showNoResultItemTemplate,
10465
selectOptionClick,
10566
handleClose
106-
)
67+
);
10768
provide(DropdownPropsKey, {
10869
props,
10970
visible,
11071
term: '',
111-
searchList:searchList,
72+
searchList: searchList,
11273
selectedIndex,
11374
searchStatus,
11475
selectOptionClick,
@@ -117,63 +78,54 @@ export default defineComponent({
11778
loadMore,
11879
latestSource,
11980
modelValue,
120-
showNoResultItemTemplate:showNoResultItemTemplate,
121-
hoverIndex:hoverIndex
122-
})
123-
const origin = ref<HTMLElement>()
124-
81+
showNoResultItemTemplate: showNoResultItemTemplate,
82+
hoverIndex: hoverIndex,
83+
});
84+
const origin = ref<HTMLElement>();
85+
12586
const renderDropdown = () => {
12687
return (
127-
<Teleport to='body'>
128-
<Transition name={showAnimation?'fade':''}>
129-
<FlexibleOverlay
130-
origin={origin.value}
131-
position={position.value}
132-
v-model={visible.value}
133-
>
88+
<Teleport to="body">
89+
<Transition name={showAnimation ? 'fade' : ''}>
90+
<FlexibleOverlay origin={origin.value} position={position.value} v-model={visible.value}>
13491
<div
135-
class='devui-auto-complete-menu'
92+
class="devui-auto-complete-menu"
13693
style={{
13794
width: `
138-
${width.value+'px'}
139-
`
140-
}}
141-
>
142-
<DAutoCompleteDropdown>
143-
{customRenderSolts()}
144-
</DAutoCompleteDropdown>
95+
${width.value + 'px'}
96+
`,
97+
}}>
98+
<DAutoCompleteDropdown>{customRenderSolts()}</DAutoCompleteDropdown>
14599
</div>
146100
</FlexibleOverlay>
147101
</Transition>
148-
</Teleport>
149-
)
150-
151-
}
102+
</Teleport>
103+
);
104+
};
152105
return () => {
153106
return (
154107
<div
155-
class={['devui-auto-complete','devui-form-group','devui-has-feedback',visible.value&&'devui-select-open']}
108+
class={['devui-auto-complete', 'devui-form-group', 'devui-has-feedback', visible.value && 'devui-select-open']}
156109
ref={origin}
157110
v-click-outside={handleClose}
158111
style={{
159-
width: `${width.value+'px'}`
160-
}}
161-
>
112+
width: `${width.value + 'px'}`,
113+
}}>
162114
<input
163115
disabled={disabled.value}
164116
type="text"
165117
onClick={toggleMenu}
166-
class={['devui-form-control','devui-dropdown-origin','devui-dropdown-origin-open',disabled.value&&'disabled']}
118+
class={['devui-form-control', 'devui-dropdown-origin', 'devui-dropdown-origin-open', disabled.value && 'disabled']}
167119
placeholder="Search"
168120
onInput={onInput}
169121
onFocus={onFocus}
170122
value={modelValue.value}
171-
ref = {inputRef}
123+
ref={inputRef}
172124
onKeydown={handlekeyDown}
173125
/>
174126
{renderDropdown()}
175127
</div>
176-
)
177-
}
178-
}
179-
})
128+
);
129+
};
130+
},
131+
});
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import type { App } from 'vue';
22
import Avatar from './src/avatar';
33

4-
Avatar.install = function (app: App) {
5-
app.component(Avatar.name, Avatar);
6-
};
4+
export * from './src/avatar-types';
75

86
export { Avatar };
97

@@ -12,6 +10,6 @@ export default {
1210
category: '数据展示',
1311
status: '100%',
1412
install(app: App): void {
15-
app.use(Avatar as any);
13+
app.component(Avatar.name, Avatar);
1614
},
1715
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { ExtractPropTypes } from "vue";
2+
3+
export const avatarProps = {
4+
name: {
5+
type: String,
6+
default: null,
7+
},
8+
gender: {
9+
type: String as () => 'male' | 'female' | string,
10+
default: null,
11+
},
12+
width: {
13+
type: Number,
14+
default: 36,
15+
},
16+
height: {
17+
type: Number,
18+
default: 36,
19+
},
20+
isRound: {
21+
type: Boolean,
22+
default: true,
23+
},
24+
imgSrc: {
25+
type: String,
26+
default: '',
27+
},
28+
customText: {
29+
type: String,
30+
default: null,
31+
},
32+
};
33+
34+
export type AvatarProps = ExtractPropTypes<typeof avatarProps>;

packages/devui-vue/devui/avatar/src/avatar.tsx

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,14 @@ import { defineComponent, watch, toRefs, ref } from 'vue';
22

33
import AvatarBodyIcon from './avatar-body-icon';
44
import AvatarNoBodyIcon from './avatar-nobody-icon';
5+
import { AvatarProps, avatarProps } from './avatar-types';
56

67
import './avatar.scss';
78

89
export default defineComponent({
910
name: 'DAvatar',
10-
props: {
11-
name: {
12-
type: String,
13-
default: null,
14-
},
15-
gender: {
16-
type: String as () => 'male' | 'female' | string,
17-
default: null,
18-
},
19-
width: {
20-
type: Number,
21-
default: 36,
22-
},
23-
height: {
24-
type: Number,
25-
default: 36,
26-
},
27-
isRound: {
28-
type: Boolean,
29-
default: true,
30-
},
31-
imgSrc: {
32-
type: String,
33-
default: '',
34-
},
35-
customText: {
36-
type: String,
37-
default: null,
38-
},
39-
},
40-
setup(props) {
11+
props: avatarProps,
12+
setup(props: AvatarProps) {
4113
const { name, width, height, customText, gender, imgSrc, isRound } =
4214
toRefs(props);
4315
const isNobody = ref<boolean>(true);
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import type { App } from 'vue';
22
import Card from './src/card';
33

4-
Card.install = function(app: App) {
5-
app.component(Card.name, Card);
6-
};
4+
export * from './src/card-types';
75

86
export { Card };
97

@@ -12,6 +10,6 @@ export default {
1210
category: '数据展示',
1311
status: '100%',
1412
install(app: App): void {
15-
app.use(Card as any);
13+
app.component(Card.name, Card);
1614
}
1715
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { ExtractPropTypes, PropType } from 'vue';
2+
3+
export const cardProps = {
4+
align: {
5+
type: String as PropType<'start' | 'end' | 'spaceBetween'>,
6+
default: 'start'
7+
},
8+
src: {
9+
type: String,
10+
default: ''
11+
}
12+
} as const;
13+
14+
export type CardProps = ExtractPropTypes<typeof cardProps>;

packages/devui-vue/devui/card/src/card.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
import { defineComponent, PropType } from 'vue';
1+
import { defineComponent } from 'vue';
2+
import { cardProps } from './card-types';
23
import './card.scss';
34

4-
const cardProps = {
5-
align: {
6-
type: String as PropType<'start' | 'end' | 'spaceBetween'>,
7-
default: 'start'
8-
},
9-
src: {
10-
type: String,
11-
default: ''
12-
}
13-
} as const;
14-
155
export default defineComponent({
166
name: 'DCard',
177
props: cardProps,

packages/devui-vue/devui/checkbox/index.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ import type { App } from 'vue';
22
import Checkbox from './src/checkbox';
33
import CheckboxGroup from './src/checkbox-group';
44

5-
Checkbox.install = function (app: App) {
6-
app.component(Checkbox.name, Checkbox);
7-
};
8-
9-
CheckboxGroup.install = function (app: App) {
10-
app.component(CheckboxGroup.name, CheckboxGroup);
11-
};
5+
export * from './src/checkbox-types';
126

137
export { Checkbox };
148

@@ -17,7 +11,7 @@ export default {
1711
category: '数据录入',
1812
status: '100%',
1913
install(app: App): void {
20-
app.use(Checkbox as any);
21-
app.use(CheckboxGroup as any);
14+
app.component(Checkbox.name, Checkbox);
15+
app.component(CheckboxGroup.name, CheckboxGroup);
2216
}
2317
};

0 commit comments

Comments
 (0)