forked from jd-opensource/nutui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nutui.js
296 lines (281 loc) · 9.39 KB
/
nutui.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
import { version } from '../package.json';
import { packages as pkgList } from './config.json';
import { locale } from './locales';
import Cell from './packages/cell/index.js';
import './packages/cell/cell.scss';
import Dialog from './packages/dialog/index.js';
import './packages/dialog/dialog.scss';
import Icon from './packages/icon/index.js';
import './packages/icon/icon.scss';
import Toast from './packages/toast/index.js';
import './packages/toast/toast.scss';
import ActionSheet from './packages/actionsheet/index.js';
import './packages/actionsheet/actionsheet.scss';
import Tab from './packages/tab/index.js';
import './packages/tab/tab.scss';
import TabPanel from './packages/tabpanel/index.js';
import './packages/tabpanel/tabpanel.scss';
import TabBar from './packages/tabbar/index.js';
import './packages/tabbar/tabbar.scss';
import Calendar from './packages/calendar/index.js';
import './packages/calendar/calendar.scss';
import DatePicker from './packages/datepicker/index.js';
import './packages/datepicker/datepicker.scss';
import NavBar from './packages/navbar/index.js';
import './packages/navbar/navbar.scss';
import NoticeBar from './packages/noticebar/index.js';
import './packages/noticebar/noticebar.scss';
import Switch from './packages/switch/index.js';
import './packages/switch/switch.scss';
import Slider from './packages/slider/index.js';
import './packages/slider/slider.scss';
import Range from './packages/range/index.js';
import './packages/range/range.scss';
import Picker from './packages/picker/index.js';
import './packages/picker/picker.scss';
import Progress from './packages/progress/index.js';
import './packages/progress/progress.scss';
import Price from './packages/price/index.js';
import './packages/price/price.scss';
import Flex from './packages/flex/index.js';
import './packages/flex/flex.scss';
import Col from './packages/col/index.js';
import './packages/col/col.scss';
import Row from './packages/row/index.js';
import './packages/row/row.scss';
import Steps from './packages/steps/index.js';
import './packages/steps/steps.scss';
import Button from './packages/button/index.js';
import './packages/button/button.scss';
import Badge from './packages/badge/index.js';
import './packages/badge/badge.scss';
import Rate from './packages/rate/index.js';
import './packages/rate/rate.scss';
import Swiper from './packages/swiper/index.js';
import './packages/swiper/swiper.scss';
import Menu from './packages/menu/index.js';
import './packages/menu/menu.scss';
import Stepper from './packages/stepper/index.js';
import './packages/stepper/stepper.scss';
import ButtonGroup from './packages/buttongroup/index.js';
import './packages/buttongroup/buttongroup.scss';
import SearchBar from './packages/searchbar/index.js';
import './packages/searchbar/searchbar.scss';
import ImagePicker from './packages/imagepicker/index.js';
import './packages/imagepicker/imagepicker.scss';
import Radio from './packages/radio/index.js';
import './packages/radio/radio.scss';
import RadioGroup from './packages/radiogroup/index.js';
import './packages/radiogroup/radiogroup.scss';
import CheckBox from './packages/checkbox/index.js';
import './packages/checkbox/checkbox.scss';
import CheckBoxGroup from './packages/checkboxgroup/index.js';
import './packages/checkboxgroup/checkboxgroup.scss';
import ShortPassword from './packages/shortpassword/index.js';
import './packages/shortpassword/shortpassword.scss';
import Skeleton from './packages/skeleton/index.js';
import './packages/skeleton/skeleton.scss';
import Scroller from './packages/scroller/index.js';
import './packages/scroller/scroller.scss';
import BackTop from './packages/backtop/index.js';
import './packages/backtop/backtop.scss';
import CountDown from './packages/countdown/index.js';
import './packages/countdown/countdown.scss';
import InfiniteLoading from './packages/infiniteloading/index.js';
import './packages/infiniteloading/infiniteloading.scss';
import Uploader from './packages/uploader/index.js';
import './packages/uploader/uploader.scss';
import TextInput from './packages/textinput/index.js';
import './packages/textinput/textinput.scss';
import Avatar from './packages/avatar/index.js';
import './packages/avatar/avatar.scss';
import Lazyload from './packages/lazyload/index.js';
import './packages/textbox/textbox.scss';
import TextBox from './packages/textbox/index.js';
import Elevator from './packages/elevator/index.js';
import './packages/elevator/elevator.scss';
import Popup from './packages/popup/index.js';
import LeftSlip from './packages/leftslip/index.js';
import './packages/leftslip/leftslip.scss';
import TabSelect from './packages/tabselect/index.js';
import './packages/tabselect/tabselect.scss';
import './packages/popup/popup.scss';
import LuckDraw from './packages/luckdraw/index.js';
import './packages/luckdraw/luckdraw.scss';
import Video from './packages/video/index.js';
import './packages/video/video.scss';
import Signature from './packages/signature/index.js';
import './packages/signature/signature.scss';
import CircleProgress from './packages/circleprogress/index.js';
import './packages/circleprogress/circleprogress.scss';
import TimeLine from './packages/timeline/index.js';
import './packages/timeline/timeline.scss';
import TimeLineItem from './packages/timelineitem/index.js';
import './packages/timelineitem/timelineitem.scss';
import SideNavBar from './packages/sidenavbar/index.js';
import './packages/sidenavbar/sidenavbar.scss';
import SubSideNavBar from './packages/subsidenavbar/index.js';
import './packages/subsidenavbar/subsidenavbar.scss';
import SideNavBarItem from './packages/sidenavbaritem/index.js';
import './packages/sidenavbaritem/sidenavbaritem.scss';
import Drag from './packages/drag/index.js';
import './packages/drag/drag.scss'; // import VueQr from "./packages/qart/index.js";
// import "./packages/qart/qart.scss";
import Address from './packages/address/index.js';
import './packages/address/address.scss';
import Notify from './packages/notify/index.js';
import './packages/notify/notify.scss';
import CountUp from './packages/countup/index.js';
import './packages/countup/countup.scss';
import FixedNav from './packages/fixednav/index.js';
import './packages/fixednav/fixednav.scss'; // import Gesture from './packages/gesture/index.js';
// import './packages/gesture/gesture.scss';
import Collapse from './packages/collapse/index.js';
import './packages/collapse/collapse.scss';
import Luckycard from './packages/luckycard/index.js';
import './packages/luckycard/luckycard.scss';
import NumberKeyboard from './packages/numberkeyboard/index.js';
import './packages/numberkeyboard/numberkeyboard.scss';
import CollapseItem from './packages/collapseitem/index.js';
import './packages/collapseitem/collapseitem.scss';
const packages = {
Cell,
Dialog,
Icon,
Toast,
ActionSheet,
Tab,
TabPanel,
TabBar,
Calendar,
DatePicker,
NavBar,
NoticeBar,
Switch,
Slider,
Range,
Picker,
Progress,
Price,
Flex,
Col,
Row,
Steps,
Button,
Badge,
Rate,
Swiper,
Menu,
Stepper,
ButtonGroup,
SearchBar,
ImagePicker,
Radio,
RadioGroup,
CheckBox,
CheckBoxGroup,
ShortPassword,
Skeleton,
Scroller,
BackTop,
CountDown,
InfiniteLoading,
Uploader,
TextInput,
TextBox,
Avatar,
Elevator,
Popup,
LeftSlip,
TabSelect,
LuckDraw,
Video,
Signature,
CircleProgress,
TimeLine,
TimeLineItem,
SideNavBar,
SubSideNavBar,
SideNavBarItem,
Drag,
Address,
Notify,
CountUp,
FixedNav,
// Gesture: Gesture
Collapse: Collapse,
Luckycard: Luckycard,
NumberKeyboard: NumberKeyboard,
CollapseItem: CollapseItem
};
const components = {};
const methods = {};
const filters = {};
const directives = {};
pkgList.map(item => {
const pkg = packages[item.name];
if (!pkg) return;
if (item.type == 'component') {
if (pkg.name) {
components[pkg.name] = pkg;
} else {
for (let n in pkg) {
components[n] = pkg[n];
}
}
} else if (item.type == 'method') {
methods[item.name] = pkg;
} else if (item.type == 'filter') {
filters[item.name] = pkg;
} else if (item.type == 'directive') {
directives[item.name] = pkg;
}
});
const install = function(Vue, opts = {}) {
if (install.installed) return;
if (opts.locale) {
Vue.config.lang = opts.locale;
}
if (opts.lang) locale(Vue.config.lang, opts.lang);
for (let cptName in methods) {
if (Array.isArray(methods[cptName])) {
Vue.prototype['$' + cptName.toLowerCase()] = methods[cptName][0];
Vue.component(methods[cptName][1].name, methods[cptName][1]);
} else {
Vue.prototype['$' + cptName.toLowerCase()] = methods[cptName];
}
}
for (let cptName in components) {
if (components[cptName] && components[cptName].name) {
Vue.component(components[cptName].name, components[cptName]);
}
}
for (let cptName in filters) {
if (filters[cptName] && filters[cptName].name) {
Vue.filter(cptName, filters[cptName]);
}
}
for (let cptName in directives) {
if (directives[cptName] && directives[cptName].name) {
Vue.directive(directives[cptName].name, directives[cptName]);
}
}
Vue.use(Lazyload, {
lazyComponent: true,
loading: '//img12.360buyimg.com/imagetools/jfs/t1/73967/28/14561/916/5dc142e4E0666555b/bf33454553c6035e.png'
});
};
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue);
}
export default {
version,
locale,
install,
Lazyload,
// VueQr,
...components,
...filters,
...directives,
...methods
};