mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: prettier packages codes
This commit is contained in:
parent
389d68884d
commit
1575bea6f5
@ -6,11 +6,11 @@ import { camelize } from '../../src/utils/format/string';
|
|||||||
import enUS from '../../src/locale/lang/en-US';
|
import enUS from '../../src/locale/lang/en-US';
|
||||||
|
|
||||||
Vue.use(Lazyload, {
|
Vue.use(Lazyload, {
|
||||||
lazyComponent: true
|
lazyComponent: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
Locale.add({
|
Locale.add({
|
||||||
'en-US': enUS
|
'en-US': enUS,
|
||||||
});
|
});
|
||||||
|
|
||||||
// flag for vant-weapp demos
|
// flag for vant-weapp demos
|
||||||
@ -33,7 +33,7 @@ Vue.mixin({
|
|||||||
|
|
||||||
isWeapp() {
|
isWeapp() {
|
||||||
return isWeapp;
|
return isWeapp;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeCreate() {
|
beforeCreate() {
|
||||||
@ -49,7 +49,7 @@ Vue.mixin({
|
|||||||
|
|
||||||
Locale.add(locales);
|
Locale.add(locales);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// switch lang after routing
|
// switch lang after routing
|
||||||
@ -91,7 +91,7 @@ Locale.add({
|
|||||||
advancedUsage: '高级用法',
|
advancedUsage: '高级用法',
|
||||||
loadingStatus: '加载状态',
|
loadingStatus: '加载状态',
|
||||||
usernamePlaceholder: '请输入用户名',
|
usernamePlaceholder: '请输入用户名',
|
||||||
passwordPlaceholder: '请输入密码'
|
passwordPlaceholder: '请输入密码',
|
||||||
},
|
},
|
||||||
'en-US': {
|
'en-US': {
|
||||||
add: 'Add',
|
add: 'Add',
|
||||||
@ -119,6 +119,6 @@ Locale.add({
|
|||||||
basicUsage: 'Basic Usage',
|
basicUsage: 'Basic Usage',
|
||||||
advancedUsage: 'Advanced Usage',
|
advancedUsage: 'Advanced Usage',
|
||||||
usernamePlaceholder: 'Username',
|
usernamePlaceholder: 'Username',
|
||||||
passwordPlaceholder: 'Password'
|
passwordPlaceholder: 'Password',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
@ -36,13 +36,13 @@ function font() {
|
|||||||
targetPath: '../src/index.less',
|
targetPath: '../src/index.less',
|
||||||
normalize: true,
|
normalize: true,
|
||||||
firstGlyph: 0xf000,
|
firstGlyph: 0xf000,
|
||||||
cssClass: fontName // this is a trick to pass fontName to template
|
cssClass: fontName, // this is a trick to pass fontName to template
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.pipe(
|
.pipe(
|
||||||
iconfont({
|
iconfont({
|
||||||
fontName,
|
fontName,
|
||||||
formats
|
formats,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.pipe(dest(srcDir));
|
.pipe(dest(srcDir));
|
||||||
|
@ -4,7 +4,8 @@ const shell = require('shelljs');
|
|||||||
|
|
||||||
const svgDir = path.join(__dirname, '../assets/svg');
|
const svgDir = path.join(__dirname, '../assets/svg');
|
||||||
const sketch = path.join(__dirname, '../assets/icons.sketch');
|
const sketch = path.join(__dirname, '../assets/icons.sketch');
|
||||||
const SKETCH_TOOL_DIR = '/Applications/Sketch.app/Contents/Resources/sketchtool/bin/sketchtool';
|
const SKETCH_TOOL_DIR =
|
||||||
|
'/Applications/Sketch.app/Contents/Resources/sketchtool/bin/sketchtool';
|
||||||
|
|
||||||
fs.removeSync(svgDir);
|
fs.removeSync(svgDir);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ module.exports = {
|
|||||||
'arrow',
|
'arrow',
|
||||||
'arrow-left',
|
'arrow-left',
|
||||||
'arrow-up',
|
'arrow-up',
|
||||||
'arrow-down'
|
'arrow-down',
|
||||||
],
|
],
|
||||||
outline: [
|
outline: [
|
||||||
// has corresponding filled icon
|
// has corresponding filled icon
|
||||||
@ -142,7 +142,7 @@ module.exports = {
|
|||||||
'discount',
|
'discount',
|
||||||
'idcard',
|
'idcard',
|
||||||
'replay',
|
'replay',
|
||||||
'shrink'
|
'shrink',
|
||||||
],
|
],
|
||||||
filled: [
|
filled: [
|
||||||
// has corresponding outline icon
|
// has corresponding outline icon
|
||||||
@ -235,6 +235,6 @@ module.exports = {
|
|||||||
'ascending',
|
'ascending',
|
||||||
'descending',
|
'descending',
|
||||||
'bars',
|
'bars',
|
||||||
'wap-nav'
|
'wap-nav',
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
module.exports = function cardWrapper(html) {
|
module.exports = function cardWrapper(html) {
|
||||||
const group = html.replace(/<h3/g, ':::<h3').replace(/<h2/g, ':::<h2').split(':::');
|
const group = html
|
||||||
|
.replace(/<h3/g, ':::<h3')
|
||||||
|
.replace(/<h2/g, ':::<h2')
|
||||||
|
.split(':::');
|
||||||
|
|
||||||
return group
|
return group
|
||||||
.map(fragment => {
|
.map(fragment => {
|
||||||
|
@ -47,10 +47,10 @@ export default {
|
|||||||
|
|
||||||
const parser = new MarkdownIt({
|
const parser = new MarkdownIt({
|
||||||
html: true,
|
html: true,
|
||||||
highlight
|
highlight,
|
||||||
}).use(markdownItAnchor, {
|
}).use(markdownItAnchor, {
|
||||||
level: 2,
|
level: 2,
|
||||||
slugify
|
slugify,
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = function(source) {
|
module.exports = function(source) {
|
||||||
@ -60,7 +60,7 @@ module.exports = function(source) {
|
|||||||
options = {
|
options = {
|
||||||
wrapper,
|
wrapper,
|
||||||
linkOpen: true,
|
linkOpen: true,
|
||||||
...options
|
...options,
|
||||||
};
|
};
|
||||||
|
|
||||||
let fm;
|
let fm;
|
||||||
|
@ -65,7 +65,7 @@ export function codegen(artical: Artical) {
|
|||||||
const key = camelCaseToKebabCase(match[1] || 'default');
|
const key = camelCaseToKebabCase(match[1] || 'default');
|
||||||
const tag: Tag = tags[key] || {
|
const tag: Tag = tags[key] || {
|
||||||
description: tagDescription,
|
description: tagDescription,
|
||||||
attributes: {}
|
attributes: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
tags[key] = tag;
|
tags[key] = tag;
|
||||||
@ -77,7 +77,7 @@ export function codegen(artical: Artical) {
|
|||||||
|
|
||||||
const attr: Attribute = {
|
const attr: Attribute = {
|
||||||
description: getDescription(td, isProp),
|
description: getDescription(td, isProp),
|
||||||
type: isProp ? td[2].replace(/`/g, '').toLowerCase() : 'event'
|
type: isProp ? td[2].replace(/`/g, '').toLowerCase() : 'event',
|
||||||
};
|
};
|
||||||
|
|
||||||
tag.attributes[name] = attr;
|
tag.attributes[name] = attr;
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
existsSync,
|
existsSync,
|
||||||
readdirSync,
|
readdirSync,
|
||||||
readFileSync,
|
readFileSync,
|
||||||
writeFileSync
|
writeFileSync,
|
||||||
} from 'fs';
|
} from 'fs';
|
||||||
|
|
||||||
export function parseText(input: string) {
|
export function parseText(input: string) {
|
||||||
@ -43,18 +43,18 @@ export type ParseResult = {
|
|||||||
|
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
maxDeep: Infinity,
|
maxDeep: Infinity,
|
||||||
tagPrefix: ''
|
tagPrefix: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
export function parse(options: Options) {
|
export function parse(options: Options) {
|
||||||
options = {
|
options = {
|
||||||
...defaultOptions,
|
...defaultOptions,
|
||||||
...options
|
...options,
|
||||||
};
|
};
|
||||||
|
|
||||||
const result: ParseResult = {
|
const result: ParseResult = {
|
||||||
tags: {},
|
tags: {},
|
||||||
attributes: {}
|
attributes: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
function putResult(componentName: string, component: Tag) {
|
function putResult(componentName: string, component: Tag) {
|
||||||
@ -62,7 +62,7 @@ export function parse(options: Options) {
|
|||||||
const attributes = Object.keys(component.attributes);
|
const attributes = Object.keys(component.attributes);
|
||||||
const tag = {
|
const tag = {
|
||||||
description: component.description,
|
description: component.description,
|
||||||
attributes
|
attributes,
|
||||||
};
|
};
|
||||||
|
|
||||||
result.tags[componentName] = tag;
|
result.tags[componentName] = tag;
|
||||||
@ -85,7 +85,7 @@ export function parse(options: Options) {
|
|||||||
recursiveParse(
|
recursiveParse(
|
||||||
{
|
{
|
||||||
...options,
|
...options,
|
||||||
path: currentPath
|
path: currentPath,
|
||||||
},
|
},
|
||||||
deep
|
deep
|
||||||
);
|
);
|
||||||
@ -123,7 +123,10 @@ export function parseAndWrite(options: Options) {
|
|||||||
mkdirSync(options.outputDir);
|
mkdirSync(options.outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeFileSync(join(options.outputDir, 'tags.json'), JSON.stringify(tags, null, 2));
|
writeFileSync(
|
||||||
|
join(options.outputDir, 'tags.json'),
|
||||||
|
JSON.stringify(tags, null, 2)
|
||||||
|
);
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
join(options.outputDir, 'attributes.json'),
|
join(options.outputDir, 'attributes.json'),
|
||||||
JSON.stringify(attributes, null, 2)
|
JSON.stringify(attributes, null, 2)
|
||||||
@ -133,5 +136,5 @@ export function parseAndWrite(options: Options) {
|
|||||||
export default {
|
export default {
|
||||||
parse,
|
parse,
|
||||||
parseText,
|
parseText,
|
||||||
parseAndWrite
|
parseAndWrite,
|
||||||
};
|
};
|
||||||
|
@ -43,7 +43,7 @@ function tableParse(input: string) {
|
|||||||
const end = input.length;
|
const end = input.length;
|
||||||
const table: TableContent = {
|
const table: TableContent = {
|
||||||
head: [],
|
head: [],
|
||||||
body: []
|
body: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
while (start < end) {
|
while (start < end) {
|
||||||
@ -69,7 +69,7 @@ function tableParse(input: string) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
table,
|
table,
|
||||||
usedLength: start
|
usedLength: start,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ export function mdParser(input: string): Array<SimpleMdAst> {
|
|||||||
artical.push({
|
artical.push({
|
||||||
type: 'title',
|
type: 'title',
|
||||||
content: match[2],
|
content: match[2],
|
||||||
level: match[1].length
|
level: match[1].length,
|
||||||
});
|
});
|
||||||
|
|
||||||
start += match.index + match[0].length;
|
start += match.index + match[0].length;
|
||||||
@ -94,7 +94,7 @@ export function mdParser(input: string): Array<SimpleMdAst> {
|
|||||||
const { table, usedLength } = tableParse(target.substr(match.index));
|
const { table, usedLength } = tableParse(target.substr(match.index));
|
||||||
artical.push({
|
artical.push({
|
||||||
type: 'table',
|
type: 'table',
|
||||||
table
|
table,
|
||||||
});
|
});
|
||||||
|
|
||||||
start += match.index + usedLength;
|
start += match.index + usedLength;
|
||||||
|
@ -6,6 +6,6 @@ module.exports = {
|
|||||||
'number-leading-zero': null,
|
'number-leading-zero': null,
|
||||||
'no-descending-specificity': null,
|
'no-descending-specificity': null,
|
||||||
'declaration-colon-newline-after': null,
|
'declaration-colon-newline-after': null,
|
||||||
'font-family-no-missing-generic-family-keyword': null
|
'font-family-no-missing-generic-family-keyword': null,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
@ -9,16 +9,30 @@ var supportTouch = 'ontouchstart' in window;
|
|||||||
|
|
||||||
// polyfills
|
// polyfills
|
||||||
if (!document.createTouch) {
|
if (!document.createTouch) {
|
||||||
document.createTouch = function(view, target, identifier, pageX, pageY, screenX, screenY) {
|
document.createTouch = function(
|
||||||
|
view,
|
||||||
|
target,
|
||||||
|
identifier,
|
||||||
|
pageX,
|
||||||
|
pageY,
|
||||||
|
screenX,
|
||||||
|
screenY
|
||||||
|
) {
|
||||||
// auto set
|
// auto set
|
||||||
return new Touch(target, identifier, {
|
return new Touch(
|
||||||
|
target,
|
||||||
|
identifier,
|
||||||
|
{
|
||||||
pageX: pageX,
|
pageX: pageX,
|
||||||
pageY: pageY,
|
pageY: pageY,
|
||||||
screenX: screenX,
|
screenX: screenX,
|
||||||
screenY: screenY,
|
screenY: screenY,
|
||||||
clientX: pageX - window.pageXOffset,
|
clientX: pageX - window.pageXOffset,
|
||||||
clientY: pageY - window.pageYOffset
|
clientY: pageY - window.pageYOffset,
|
||||||
}, 0, 0);
|
},
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,15 +92,12 @@ function TouchList() {
|
|||||||
return touchList;
|
return touchList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* only trigger touches when the left mousebutton has been pressed
|
* only trigger touches when the left mousebutton has been pressed
|
||||||
* @param touchType
|
* @param touchType
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
var initiated = false;
|
var initiated = false;
|
||||||
function onMouse(touchType) {
|
function onMouse(touchType) {
|
||||||
return function(ev) {
|
return function(ev) {
|
||||||
@ -101,13 +112,17 @@ function onMouse(touchType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ev.type === 'mousemove' && !initiated) {
|
if (ev.type === 'mousemove' && !initiated) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The EventTarget on which the touch point started when it was first placed on the surface,
|
// The EventTarget on which the touch point started when it was first placed on the surface,
|
||||||
// even if the touch point has since moved outside the interactive area of that element.
|
// even if the touch point has since moved outside the interactive area of that element.
|
||||||
// also, when the target doesnt exist anymore, we update it
|
// also, when the target doesnt exist anymore, we update it
|
||||||
if (ev.type === 'mousedown' || !eventTarget || eventTarget && !eventTarget.dispatchEvent) {
|
if (
|
||||||
|
ev.type === 'mousedown' ||
|
||||||
|
!eventTarget ||
|
||||||
|
(eventTarget && !eventTarget.dispatchEvent)
|
||||||
|
) {
|
||||||
eventTarget = ev.target;
|
eventTarget = ev.target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import {
|
|||||||
getScrollTop,
|
getScrollTop,
|
||||||
getElementTop,
|
getElementTop,
|
||||||
getVisibleHeight,
|
getVisibleHeight,
|
||||||
getScrollEventTarget
|
getScrollEventTarget,
|
||||||
} from './scroll';
|
} from './scroll';
|
||||||
|
|
||||||
const CONTEXT = '@@Waterfall';
|
const CONTEXT = '@@Waterfall';
|
||||||
@ -27,14 +27,18 @@ function handleScrollEvent() {
|
|||||||
// 判断是否到了底
|
// 判断是否到了底
|
||||||
let needLoadMoreToLower = false;
|
let needLoadMoreToLower = false;
|
||||||
if (element === scrollEventTarget) {
|
if (element === scrollEventTarget) {
|
||||||
needLoadMoreToLower = scrollEventTarget.scrollHeight - targetBottom < this.offset;
|
needLoadMoreToLower =
|
||||||
|
scrollEventTarget.scrollHeight - targetBottom < this.offset;
|
||||||
} else {
|
} else {
|
||||||
const elementBottom =
|
const elementBottom =
|
||||||
getElementTop(element) - getElementTop(scrollEventTarget) + getVisibleHeight(element);
|
getElementTop(element) -
|
||||||
|
getElementTop(scrollEventTarget) +
|
||||||
|
getVisibleHeight(element);
|
||||||
needLoadMoreToLower = elementBottom - targetVisibleHeight < this.offset;
|
needLoadMoreToLower = elementBottom - targetVisibleHeight < this.offset;
|
||||||
}
|
}
|
||||||
if (needLoadMoreToLower) {
|
if (needLoadMoreToLower) {
|
||||||
this.cb.lower && this.cb.lower({ target: scrollEventTarget, top: targetScrollTop });
|
this.cb.lower &&
|
||||||
|
this.cb.lower({ target: scrollEventTarget, top: targetScrollTop });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断是否到了顶
|
// 判断是否到了顶
|
||||||
@ -42,11 +46,13 @@ function handleScrollEvent() {
|
|||||||
if (element === scrollEventTarget) {
|
if (element === scrollEventTarget) {
|
||||||
needLoadMoreToUpper = targetScrollTop < this.offset;
|
needLoadMoreToUpper = targetScrollTop < this.offset;
|
||||||
} else {
|
} else {
|
||||||
const elementTop = getElementTop(element) - getElementTop(scrollEventTarget);
|
const elementTop =
|
||||||
|
getElementTop(element) - getElementTop(scrollEventTarget);
|
||||||
needLoadMoreToUpper = elementTop + this.offset > 0;
|
needLoadMoreToUpper = elementTop + this.offset > 0;
|
||||||
}
|
}
|
||||||
if (needLoadMoreToUpper) {
|
if (needLoadMoreToUpper) {
|
||||||
this.cb.upper && this.cb.upper({ target: scrollEventTarget, top: targetScrollTop });
|
this.cb.upper &&
|
||||||
|
this.cb.upper({ target: scrollEventTarget, top: targetScrollTop });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +116,7 @@ export default function (type) {
|
|||||||
el[CONTEXT] = {
|
el[CONTEXT] = {
|
||||||
el,
|
el,
|
||||||
vm: vnode.context,
|
vm: vnode.context,
|
||||||
cb: {}
|
cb: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
el[CONTEXT].cb[type] = binding.value;
|
el[CONTEXT].cb[type] = binding.value;
|
||||||
@ -128,6 +134,6 @@ export default function (type) {
|
|||||||
if (context.scrollEventTarget) {
|
if (context.scrollEventTarget) {
|
||||||
off(context.scrollEventTarget, 'scroll', context.scrollEventListener);
|
off(context.scrollEventTarget, 'scroll', context.scrollEventListener);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ try {
|
|||||||
get() {
|
get() {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
supportsPassive = true;
|
supportsPassive = true;
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
window.addEventListener('test-passive', null, opts);
|
window.addEventListener('test-passive', null, opts);
|
||||||
// eslint-disable-next-line no-empty
|
// eslint-disable-next-line no-empty
|
||||||
|
4
types/image-preview.d.ts
vendored
4
types/image-preview.d.ts
vendored
@ -1,6 +1,8 @@
|
|||||||
import { VanPopupMixin } from './mixins/popup';
|
import { VanPopupMixin } from './mixins/popup';
|
||||||
|
|
||||||
export type ImagePreviewOptions = string[] | {
|
export type ImagePreviewOptions =
|
||||||
|
| string[]
|
||||||
|
| {
|
||||||
loop?: boolean;
|
loop?: boolean;
|
||||||
images: string[];
|
images: string[];
|
||||||
maxZoom?: number;
|
maxZoom?: number;
|
||||||
|
2
types/index.d.ts
vendored
2
types/index.d.ts
vendored
@ -110,5 +110,5 @@ export {
|
|||||||
SwipeCell,
|
SwipeCell,
|
||||||
Tabs,
|
Tabs,
|
||||||
Toast,
|
Toast,
|
||||||
Uploader
|
Uploader,
|
||||||
};
|
};
|
||||||
|
4
types/lazyload.d.ts
vendored
4
types/lazyload.d.ts
vendored
@ -1,7 +1,7 @@
|
|||||||
import Vue, { PluginFunction } from 'vue';
|
import { PluginFunction } from 'vue';
|
||||||
|
|
||||||
export interface Lazyload {
|
export interface Lazyload {
|
||||||
install: PluginFunction<void>
|
install: PluginFunction<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Lazyload: Lazyload;
|
export const Lazyload: Lazyload;
|
||||||
|
5
types/toast.d.ts
vendored
5
types/toast.d.ts
vendored
@ -41,7 +41,10 @@ export interface Toast {
|
|||||||
fail(options?: ToastOptions | ToastMessage): VanToast;
|
fail(options?: ToastOptions | ToastMessage): VanToast;
|
||||||
clear(all?: boolean): void;
|
clear(all?: boolean): void;
|
||||||
install(): void;
|
install(): void;
|
||||||
setDefaultOptions(type: ToastType | ToastOptions, options?: ToastOptions): void;
|
setDefaultOptions(
|
||||||
|
type: ToastType | ToastOptions,
|
||||||
|
options?: ToastOptions
|
||||||
|
): void;
|
||||||
resetDefaultOptions(options?: string): void;
|
resetDefaultOptions(options?: string): void;
|
||||||
allowMultiple(allow: boolean): void;
|
allowMultiple(allow: boolean): void;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user