Coder Social home page Coder Social logo

element-plus / element-plus-vite-starter Goto Github PK

View Code? Open in Web Editor NEW
1.1K 15.0 351.0 117 KB

🌰 A starter kit for Element Plus with Vite

Home Page: https://vite-starter.element-plus.org

HTML 4.97% Vue 60.49% TypeScript 19.58% SCSS 14.96%
element-plus vite

element-plus-vite-starter's Introduction

element-plus-vite-starter

A starter kit for Element Plus with Vite

This is an example of on-demand element-plus with unplugin-vue-components.

If you want to import all, it may be so simple that no examples are needed. Just follow quickstart | Docs and import them.

If you just want an on-demand import example manually, you can check unplugin-element-plus/examples/vite.

Project setup

npm install

Compiles and hot-reloads for development

npm run dev

Compiles and minifies for production

npm run build

Usage

git clone https://github.com/element-plus/element-plus-vite-starter
cd element-plus-vite-starter
npm i
npm run dev

Custom theme

See src/styles/element/index.scss.

element-plus-vite-starter's People

Contributors

daiwanxing avatar iamkun avatar jw-foss avatar sxzz avatar whidy avatar yunyoujun avatar zazzaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

element-plus-vite-starter's Issues

CommandLine has notice : "This is a bug in the "vite:dep-pre-bundle" plugin."

✘ [ERROR] [plugin vite:dep-pre-bundle] Detected inconsistent metadata for the path "node_modules/vue/dist/vue.runtime.esm-bundler.js" when it was imported here:

node_modules/element-plus/es/utils/vue/vnode.mjs:1:103:
  1 │ ...Comment, openBlock, createBlock, createCommentVNode, camelize } from 'vue';
    ╵                                                                         ~~~~~

The original metadata for that path comes from when it was imported here:

dep:vue:2:14:
  2 │ export * from "./node_modules/vue/dist/vue.runtime.esm-bundler.js"
    ╵               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The difference in metadata is displayed below:

{

  • "pluginName": null,
  • "pluginName": "vite:dep-pre-bundle",
    }

This is a bug in the "vite:dep-pre-bundle" plugin. Plugins provide metadata for a
given path in an "onResolve" callback. All metadata provided for the same path must be
consistent to ensure deterministic builds. Due to parallelism, one set of provided
metadata will be randomly chosen for a given path, so providing inconsistent metadata
for the same path can cause non-determinism.

set up error

I git cloned this, and renamed the folder to ui, then:
cd ui
npm install
npm run dev

it come out error:
Failed to resolve entry for package "element-plus". The package may have incorrect main/module/exports specified in its package.json.

ellendeair:ui ellenli$ vue -V
@vue/cli 4.5.10
ellendeair:ui ellenli$ npm -v
6.14.4

any help?

Change font family like Element Plus website

I'm new to the front-end frameworks and I need support on properly declaring font-face for custom fonts. The element-plush UI components do not look perfect with the default font face. I like to add a font that is used in the element-plush documentation page. Could you please help me with that?

启动不起来啊

[plugin:vite:import-analysis] Failed to resolve import "element-plus/theme-chalk/src/message.scss" from "src/main.ts". Does the file exist?

按需引入在jsx语法里不生效么

如题,我在项目中只配置了vue的jsx写法并不让项目支持vue文件写法 导致这种按需引入实际上样式文件一个都不起效果
图片

how to use it in nuxt3

i tried it in nuxt3,and there are some errors, I don’t know how to fix it,please help me
nuxt : 3.0.0-27244261.c49f9ca
node : v16.12.0
npm : 8.1.0
Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use node --trace-warnings ... to show where the warning was created)

there is a Unmet peer dependencies error

node: v16.16.0
pnpm: v7.5.2
description: when i run pnpm install, there is a error

ERR_PNPM_PEER_DEP_ISSUES  Unmet peer dependencies

.
└─┬ vite-ssg
  ├── ✕ missing peer @vueuse/head@"^0.5.0 || ^0.6.0 || ^0.7.0"
  └── ✕ missing peer vue-router@^4.0.1
Peer dependencies that should be installed:
  @vueuse/head@"^0.5.0 || ^0.6.0 || ^0.7.0"  vue-router@^4.0.1

i found add auto-install-peers=true into .npmrc could avoid that

请问有vite-ts模板吗 npm无法打包

自己搭建出来的ts模板无法打包

npm run build

经过尝试确认 yarn build 是没问题的之后npm是出现打包不了的问题

{
"name": "vue3-vite-admin",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"serve": "vite preview"
},
"dependencies": {
"axios": "^0.21.1",
"element-plus": "^1.0.2-beta.35",
"vue": "^3.0.5",
"vue-router": "4.0.5",
"vuex": "4.0.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^1.1.5",
"@vue/compiler-sfc": "^3.0.5",
"node-sass": "^5.0.0",
"sass-loader": "^11.0.1",
"typescript": "^4.1.3",
"vite": "^2.1.0",
"vue-tsc": "^0.0.8"
}
}

HMR not working

Just run this starter code and make a changes in HelloWord.vue component, but the HMR not working, we must refresh manually. And if we remove the element-plus registration, the HMR works. So, I think the problem comes by Element Plus library.

How can we make Element Plus work with HMR?

node version: v15.11.0
npm version: 7.6.0
element-plus: ^1.0.2-beta.45
vue: ^3.0.5
vite: ^2.3.4

Thanks in advance

Error

new dependencies found: elemtn-plus/es,element-plus/es/components/menu/style/index, ...., updating...
Failed to write to output file: open C:\Users\nn\Desktop\element-plus-vite-starter\node_modules.vite\element-plus.js:Access is denied.

运行不了

下载代码后,发现报如下错误
Uncaught SyntaxError: The requested module '/node_modules/.vite/vue.js?v=b456bf5e' does not provide an export named 'createElementBlock'

暗黑模式下,使用popover组件样式有bug

在任意位置加入 popover 组件示例代码

  <el-popover
    placement="bottom"
    title="Title"
    :width="200"
    trigger="click"
    content="this is content, this is content, this is content"
  >
    <template #reference>
      <el-button>Click to activate</el-button>
    </template>
  </el-popover>

暗黑模式下,效果如下,
image

注意到是 .el-popper.is-light.el-popover.el-popper 两组样式优先级的问题,如果是全局引用则正常,前者优先级比后者高;按需自动引入就不行,因为后者优先级会比前者高,导致样式被覆盖,如下图

image

[Request] changing styles on the default theme

can the team show an example on how to change a style of a component correctly ? like table element for example.
it is unclear what is the source of truth - the scss ? the :root css vars ? and how to override correctly without masking style on top of another style.

does not have to be on the main branch - but i think there should be a reference example about the new.
much appreciated. 🙏

win11运行示例报错

日志
 npm run dev

> [email protected] dev
> vite

Pre-bundling dependencies:
  vue
(this will be run only when your dependencies or config have changed)

  vite v2.8.6 dev server running at:

  > Local: http://localhost:3000/
  > Network: use `--host` to expose

  ready in 516ms.

上午11:49:33 [vite] new dependencies found: element-plus/es, updating...
上午11:49:34 [vite] ✨ dependencies updated, reloading page...
上午11:49:35 [vite] Internal server error: Failed to resolve import "element-plus/es/components/menu/style/index" from "src\components\layouts\BaseHeader.vue". Does the file exist?
  Plugin: vite:import-analysis
  File: M:/vue/element-plus-vite-starter/src/components/layouts/BaseHeader.vue
  1  |  /* unplugin-vue-components disabled */import { ElMenu as __unplugin_components_2 } from 'element-plus/es';import 'element-plus/es/components/menu/style/index';
     |                                                                                                                    ^
  2  |  import { ElSubMenu as __unplugin_components_1 } from 'element-plus/es';import 'element-plus/es/components/sub-menu/style/index';
  3  |  import { ElMenuItem as __unplugin_components_0 } from 'element-plus/es';import 'element-plus/es/components/menu-item/style/index';
      at formatError (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:38098:46)
      at TransformContext.error (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:38094:19)
      at normalizeUrl (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:69819:26)
      at async TransformContext.transform (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:69959:57)
      at async Object.transform (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:38334:30)
      at async doTransform (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:53030:29)
上午11:49:35 [vite] Internal server error: Failed to resolve import "element-plus/es/components/menu/style/index" from "src\components\layouts\BaseSide.vue". Does the file exist?
  Plugin: vite:import-analysis
  File: M:/vue/element-plus-vite-starter/src/components/layouts/BaseSide.vue
  1  |  /* unplugin-vue-components disabled */import { ElMenu as __unplugin_components_4 } from 'element-plus/es';import 'element-plus/es/components/menu/style/index';
     |                                                                                                                    ^
  2  |  import { ElSubMenu as __unplugin_components_3 } from 'element-plus/es';import 'element-plus/es/components/sub-menu/style/index';
  3  |  import { ElMenuItemGroup as __unplugin_components_2 } from 'element-plus/es';import 'element-plus/es/components/menu-item-group/style/index';
      at formatError (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:38098:46)
      at TransformContext.error (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:38094:19)
      at normalizeUrl (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:69819:26)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async TransformContext.transform (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:69959:57)
      at async Object.transform (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:38334:30)
      at async doTransform (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:53030:29)
上午11:49:35 [vite] Internal server error: Failed to resolve import "element-plus/es/components/date-picker/style/index" from "src\components\HelloWorld.vue". Does the file exist?
  Plugin: vite:import-analysis
  File: M:/vue/element-plus-vite-starter/src/components/HelloWorld.vue
  1  |  /* unplugin-vue-components disabled */import { ElDatePicker as __unplugin_components_3 } from 'element-plus/es';import 'element-plus/es/components/date-picker/style/index';
     |                                                                                                                          ^
  2  |  import { ElTag as __unplugin_components_2 } from 'element-plus/es';import 'element-plus/es/components/tag/style/index';
  3  |  import { ElInput as __unplugin_components_1 } from 'element-plus/es';import 'element-plus/es/components/input/style/index';
      at formatError (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:38098:46)
      at TransformContext.error (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:38094:19)
      at normalizeUrl (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:69819:26)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async TransformContext.transform (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:69959:57)
      at async Object.transform (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:38334:30)
      at async doTransform (M:\vue\element-plus-vite-starter\node_modules\vite\dist\node\chunks\dep-9c153816.js:53030:29)

build Error: Unexpected token

system: windows10
element-plus version: latest

error log:
"C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" run build --scripts-prepend-node-path=auto

[email protected] build D:\GitHub\element-plus-vite-starter-master
vite build

vite v1.0.0-rc.9

Error: Unexpected token
at error (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:5252:30)
at Module.error (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:9820:16)
at tryParse (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:9701:23)
at Module.setSource (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:10127:19)
at ModuleLoader.addModuleSource (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:18288:20)
at async ModuleLoader.fetchModule (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:18344:9)
at async Promise.all (index 0)
at async ModuleLoader.fetchStaticDependencies (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:18369:34)
at async Promise.all (index 0)
at async ModuleLoader.fetchModule (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:18346:9) {
code: 'PARSE_ERROR',
parserError: SyntaxError: Unexpected token (928:3225)
at Object.pp$4.raise (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:15542:13)
at Object.pp.unexpected (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:13234:8)
at Object.pp.expect (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:13228:26)
at Object.pp$3.parseExprList (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:15433:12)
at Object.pp$3.parseSubscript (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:14799:25)
at Object.parseSubscript (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:19112:37)
at Object.pp$3.parseSubscripts (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:14762:24)
at Object.pp$3.parseExprSubscripts (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:14747:21)
at Object.pp$3.parseMaybeUnary (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:14721:17)
at Object.parseMaybeUnary (D:\GitHub\element-plus-vite-starter-master\node_modules\rollup\dist\shared\rollup.js:19144:29) {
pos: 534953,
loc: Position { line: 928, column: 3225 },
raisedAt: 534961
},
id: 'D:\GitHub\element-plus-vite-starter-master\node_modules\element-plus\lib\index.js',
pos: 534953,
loc: {
file: 'D:\GitHub\element-plus-vite-starter-master\node_modules\element-plus\lib\index.js',
line: 923,
column: 40252
},
frame: '921: \n' +
'922: "use strict";\n' +
'923: eval("webpack_require.r(webpack_exports);\n/* WEBPACK VAR INJECTION /(function(process) {function _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.len
gth; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n
\n return target;\n };\n\n return _extends.apply(this, arguments);\n}\n\nfunction _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.cons
tructor = subClass;\n subClass.proto = superClass;\n}\n\nfunction _getPrototypeOf(o) {\n _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n return o.proto |
| Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}\n\nfunction _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.proto = p;\n retur
n o;\n };\n\n return _setPrototypeOf(o, p);\n}\n\nfunction _isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;
\n if (typeof Proxy === \"function\") return true;\n\n try {\n Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n}\n\nf
unction _construct(Parent, args, Class) {\n if (_isNativeReflectConstruct()) {\n _construct = Reflect.construct;\n } else {\n _construct = function _construct(Parent, args, Class) {\n var a = [null];\n
a.push.apply(a, args);\n var Constructor = Function.bind.apply(Parent, a);\n var instance = new Constructor();\n if (Class) _setPrototypeOf(instance, Class.prototype);\n return instance;\n }
;\n }\n\n return _construct.apply(null, arguments);\n}\n\nfunction _isNativeFunction(fn) {\n return Function.toString.call(fn).indexOf(\"[native code]\") !== -1;\n}\n\nfunction _wrapNativeSuper(Class) {\n
var _cache = typeof Map === \"function\" ? new Map() : undefined;\n\n _wrapNativeSuper = function _wrapNativeSuper(Class) {\n if (Class === null || !_isNativeFunction(Class)) return Class;\n\n if (typeof Clas
s !== \"function\") {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n\n if (typeof _cache !== \"undefined\") {\n if (_cache.has(Class)) return _cache.get(Clas
s);\n\n _cache.set(Class, Wrapper);\n }\n\n function Wrapper() {\n return _construct(Class, arguments, _getPrototypeOf(this).constructor);\n }\n\n Wrapper.prototype = Object.create(Class.prot
otype, {\n constructor: {\n value: Wrapper,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n return _setPrototypeOf(Wrapper, Class);\n };\n\n
return _wrapNativeSuper(Class);\n}\n\n/
eslint no-console:0 /\nvar formatRegExp = /%[sdj%]/g;\nvar warning = function warning() {}; // don't print warning message when in production env or node runtime\n\nif (typ
eof process !== 'undefined' && process.env && \"development\" !== 'production' && typeof window !== 'undefined' && typeof document !== 'undefined') {\n warning = function warning(type, errors) {\n if (typeo
f console !== 'undefined' && console.warn) {\n if (errors.every(function (e) {\n return typeof e === 'string';\n })) {\n console.warn(type, errors);\n }\n }\n };\n}\n\nfunctio
n convertFieldsError(errors) {\n if (!errors || !errors.length) return null;\n var fields = {};\n errors.forEach(function (error) {\n var field = error.field;\n fields[field] = fields[field] || [];\n fiel
ds[field].push(error);\n });\n return fields;\n}\nfunction format() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[key];\n }\n\n va
r i = 1;\n var f = args[0];\n var len = args.length;\n\n if (typeof f === 'function') {\n return f.apply(null, args.slice(1));\n }\n\n if (typeof f === 'string') {\n var str = String(f).replace(form
atRegExp, function (x) {\n if (x === '%%') {\n return '%';\n }\n\n if (i >= len) {\n return x;\n }\n\n switch (x) {\n case '%s':\n return String(args[
i++]);\n\n case '%d':\n return Number(args[i++]);\n\n case '%j':\n try {\n return JSON.stringify(args[i++]);\n } catch (
) {\n return '[Circular]
';\n }\n\n break;\n\n default:\n return x;\n }\n });\n return str;\n }\n\n return f;\n}\n\nfunction isNativeStringType(type) {\n return type === 'string' |
| type === 'url' || type === 'hex' || type === 'email' || type === 'date' || type === 'pattern';\n}\n\nfunction isEmptyValue(value, type) {\n if (value === undefined || value === null) {\n return true;\
n }\n\n if (type === 'array' && Array.isArray(value) && !value.length) {\n return true;\n }\n\n if (isNativeStringType(type) && typeof value === 'string' && !value) {\n return true;\n }\n\n return
false;\n}\n\nfunction asyncParallelArray(arr, func, callback) {\n var results = [];\n var total = 0;\n var arrLength = arr.length;\n\n function count(errors) {\n results.push.apply(results, errors);\n
total++;\n\n if (total === arrLength) {\n callback(results);\n }\n }\n\n arr.forEach(function (a) {\n func(a, count);\n });\n}\n\nfunction asyncSerialArray(arr, func, callback) {\n var index
= 0;\n var arrLength = arr.length;\n\n function next(errors) {\n if (errors && errors.length) {\n callback(errors);\n return;\n }\n\n var original = index;\n index = index + 1;\n\n if
(original < arrLength) {\n func(arr[original], next);\n } else {\n callback([]);\n }\n }\n\n next([]);\n}\n\nfunction flattenObjArr(objArr) {\n var ret = [];\n Object.keys(objArr).forEach(f
unction (k) {\n ret.push.apply(ret, objArr[k]);\n });\n return ret;\n}\n\nvar AsyncValidationError = /
#PURE/function (_Error) {\n _inheritsLoose(AsyncValidationError, _Error);\n\n function AsyncValida
tionError(errors, fields) {\n var _this;\n\n _this = _Error.call(this, 'Async Validation Error') || this;\n _this.errors = errors;\n _this.fields = fields;\n return _this;\n }\n\n return AsyncVa
lidationError;\n}( /
#PURE/_wrapNativeSuper(Error));\nfunction asyncMap(objArr, option, func, callback) {\n if (option.first) {\n var _pending = new Promise(function (resolve, reject) {\n var next = func
tr
);\n asyncSerialArray(flattenArr, func, next);\n });\n\n _pending[\"catch\"](function (e) {\n return e;\n });\n\n return _pending;\n }\n\n var firstFields = option.firstFields || [];\n
\n if (firstFields === true) {\n firstFields = Object.keys(objArr);\n }\n\n var objArrKeys = Object.keys(objArr);\n var objArrLength = objArrKeys.length;\n var total = 0;\n var results = [];\n var pendin
g = new Promise(function (resolve, reject) {\n var next = function next(errors) {\n results.push.apply(results, errors);\n total++;\n\n if (total === objArrLength) {\n callback(results);\n
return results.length ? reject(new AsyncValidationError(results, convertFieldsError(results))) : resolve();\n }\n };\n\n if (!objArrKeys.length) {\n callback(results);\n resolve();\n }
\n\n objArrKeys.forEach(function (key) {\n var arr = objArr[key];\n\n if (firstFields.indexOf(key) !== -1) {\n asyncSerialArray(arr, func, next);\n } else {\n asyncParallelArray(arr,
func, next);\n }\n });\n });\n pending[\"catch\"](function (e) {\n return e;\n });\n return pending;\n}\nfunction complementError(rule) {\n return function (oe) {\n if (oe && oe.message) {\
n oe.field = oe.field || rule.fullField;\n return oe;\n }\n\n return {\n message: typeof oe === 'function' ? oe() : oe,\n field: oe.field || rule.fullField\n };\n };\n}\nfunction d
eepMerge(target, source) {\n if (source) {\n for (var s in source) {\n if (source.hasOwnProperty(s)) {\n var value = source[s];\n\n if (typeof value === 'object' && typeof target[s] === 'obj
ect') {\n target[s] = _extends(_extends({}, target[s]), value);\n } else {\n target[s] = value;\n }\n }\n }\n }\n\n return target;\n}\n\n/\n * Rule for validating
required fields.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param source The source object being validated.\n * @param errors An array of errors tha
t this rule may add\n * validation errors to.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\n\nfunction required(rule, value, source, errors, options, type) {
\n if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type || rule.type))) {\n errors.push(format(options.messages.required, rule.fullField));\n }\n}\n\n/
\n * Rule for validating
whitespace.\n \n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param source The source object being validated.\n * @param errors An array of errors that th
is rule may add\n * validation errors to.\n * @param options The validation options.\n * @param options.messages The validation messages.\n /\n\nfunction whitespace(rule, value, source, errors, options) {\n if
(/^\\s+$/.test(value) || value === '') {\n errors.push(format(options.messages.whitespace, rule.fullField));\n }\n}\n\n/
eslint max-len:0 /\n\nvar pattern = {\n // http://emailregex.com/\\n email: /^(([
^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\\\[\\\\]\\\\\\\\.,;:\\\\s@\\"]+)
)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/,\n url: new R
egExp(\"^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\\\S+(?::\\\\S
)?@)?(?:(?:(?:[1-9]\\\\d?|1\\\\d\\\\d|2[01]\\\\d|22[0-3])(?:\\\\.(?:1?\\\\d{1,2}|2[0-4]\\\\d|25[0-5])){2}(?:\\\\.(
?:[0-9]\\\\d?|1\\\\d\\\\d|2[0-4]\\\\d|25[0-4]))|(?:(?:[a-z\\\\u00a1-\\\\uffff0-9]+-
)[a-z\\\\u00a1-\\\\uffff0-9]+)(?:\\\\.(?:[a-z\\\\u00a1-\\\\uffff0-9]+-)[a-z\\\\u00a1-\
\\\uffff0-9]+)
(?:\\\\.(?:[a-z\\\\u00a1-\\\\uffff]{2,})))|localhost)(?::\\\\d{2,5})?(?:(/|\\\\?|#)[^\\\\\\\\s]*)?$\", 'i'),\n hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i\n};\nvar types = {\n integ
er: function integer(value) {\n return types.number(value) && parseInt(value, 10) === value;\n },\n \"float\": function float(value) {\n return types.number(value) && !types.integer(value);\n },\n array:
function array(value) {\n return Array.isArray(value);\n },\n regexp: function regexp(value) {\n if (value instanceof RegExp) {\n return true;\n }\n\n try {\n return !!new RegExp(value);\n
} catch (e) {\n return false;\n }\n },\n date: function date(value) {\n return typeof value.getTime === 'function' && typeof value.getMonth === 'function' && typeof value.getYear === 'function'
&& !isNaN(value.getTime());\n },\n number: function number(value) {\n if (isNaN(value)) {\n return false;\n }\n\n return typeof value === 'number';\n },\n object: function object(value) {\n
return typeof value === 'object' && !types.array(value);\n },\n method: function method(value) {\n return typeof value === 'function';\n },\n email: function email(value) {\n return typeof value === '
string' && !!value.match(pattern.email) && value.length < 255;\n },\n url: function url(value) {\n return typeof value === 'string' && !!value.match(pattern.url);\n },\n hex: function hex(value) {\n retu
rn typeof value === 'string' && !!value.match(pattern.hex);\n }\n};\n/\n * Rule for validating the type of a value.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the sou
rce object.\n * @param source The source object being validated.\n * @param errors An array of errors that this rule may add\n * validation errors to.\n * @param options The validation options.\n * @param options
.messages The validation messages.\n */\n\nfunction type(rule, value, source, errors, options) {\n if (rule.required && value === undefined) {\n required(rule, value, source, errors, options);\n return;\n }
\n\n var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex'];\n var ruleType = rule.type;\n\n if (custom.indexOf(ruleType) > -1) {\n
if (!typesruleType) {\n errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));\n } // straight typeof check\n\n } else if (ruleType && typeof value !== rule.type) {\n
errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));\n }\n}\n\n/
\n * Rule for validating minimum and maximum allowed values.\n *\n * @param rule The validation rule.\n * @param va
lue The value of the field on the source object.\n * @param source The source object being validated.\n * @param errors An array of errors that this rule may add\n * validation errors to.\n * @param options The val
idation options.\n * @param options.messages The validation messages.\n */\n\nfunction range(rule, value, source, errors, options) {\n var len = typeof rule.len === 'number';\n var min = typeof rule.min === 'nu
mber';\n var max = typeof rule.max === 'number'; // 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane)\n\n var spRegexp = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\n var val = valu
e;\n var key = null;\n var num = typeof value === 'number';\n var str = typeof value === 'string';\n var arr = Array.isArray(value);\n\n if (num) {\n key = 'number';\n } else if (str) {\n key =
'string';\n } else if (arr) {\n key = 'array';\n } // if the value is not of a supported type for range validation\n // the validation rule rule should use the\n // type property to also test for a particula
r type\n\n\n if (!key) {\n return false;\n }\n\n if (arr) {\n val = value.length;\n }\n\n if (str) {\n // 处理码点大于U+010000的文字length属性不准确的bug,如\"���\".lenght !== 3\n val = v
alue.replace(spRegexp, '_').length;\n }\n\n if (len) {\n if (val !== rule.len) {\n errors.push(format(options.messages[key].len, rule.fullField, rule.len));\n }\n } else if (min && !max && val < rule
.min) {\n errors.push(format(options.messages[key].min, rule.fullField, rule.min));\n } else if (max && !min && val > rule.max) {\n errors.push(format(options.messages[key].max, rule.fullField, rule.max));\n }
else if (min && max && (val < rule.min || val > rule.max)) {\n errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max));\n }\n}\n\nvar ENUM = 'enum';\n/\n * Rule for validating a
value exists in an enumerable list.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param source The source object being validated.\n * @param errors An
array of errors that this rule may add\n * validation errors to.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\n\nfunction enumerable(rule, value, source, er
rors, options) {\n rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : [];\n\n if (rule[ENUM].indexOf(value) === -1) {\n errors.push(format(options.messages[ENUM], rule.fullField, rule[ENUM].join(', ')));\n
}\n}\n\n/
\n * Rule for validating a regular expression pattern.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param source The source object being
validated.\n * @param errors An array of errors that this rule may add\n * validation errors to.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\n\nfunction
pattern$1(rule, value, source, errors, options) {\n if (rule.pattern) {\n if (rule.pattern instanceof RegExp) {\n // if a RegExp instance is passed, reset lastIndex in case its global\n // flag is acc
identally set to true, which in a validation scenario\n // is not necessary and the result might be misleading\n rule.pattern.lastIndex = 0;\n\n if (!rule.pattern.test(value)) {\n errors.push(f
ormat(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));\n }\n } else if (typeof rule.pattern === 'string') {\n var _pattern = new RegExp(rule.pattern);\n\n if (!_pattern.tes
t(value)) {\n errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));\n }\n }\n }\n}\n\nvar rules = {\n required: required,\n whitespace: whitespace,\n type
: type,\n range: range,\n \"enum\": enumerable,\n pattern: pattern$1\n};\n\n/\n * Performs validation for string types.\n *\n * @param rule The validation rule.\n * @param value The value of the field o
n the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\
n */\n\nfunction string(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValu
e(value, 'string') && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options, 'string');\n\n if (!isEmptyValue(value, 'string')) {\n rules.type(ru
le, value, source, errors, options);\n rules.range(rule, value, source, errors, options);\n rules.pattern(rule, value, source, errors, options);\n\n if (rule.whitespace === true) {\n rules.whites
pace(rule, value, source, errors, options);\n }\n }\n }\n\n callback(errors);\n}\n\n/
\n * Validates a function.\n *\n * @param rule The validation rule.\n * @param value The value of the field on
the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n
*/\n\nfunction method(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue
(value) && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options);\
n }\n }\n\n callback(errors);\n}\n\n/\n * Validates a number.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback fu
nction.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\n\nfunction number(rule, value, callback, source, o
ptions) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (value === '') {\n value = undefined;\n }\n\n if (isE
mptyValue(value) && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules.type(rule, value, source, errors, op
tions);\n rules.range(rule, value, source, errors, options);\n }\n }\n\n callback(errors);\n}\n\n/
\n * Validates a boolean.\n *\n * @param rule The validation rule.\n * @param value The value of
the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation
messages.\n */\n\nfunction _boolean(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if
(isEmptyValue(value) && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules.type(rule, value, source, error
s, options);\n }\n }\n\n callback(errors);\n}\n\n/\n * Validates the regular expression type.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n *
@param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\n\nfunction regexp
(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value) && !rule.require
d) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (!isEmptyValue(value)) {\n rules.type(rule, value, source, errors, options);\n }\n }\n\n cal
lback(errors);\n}\n\n/
\n * Validates a number is an integer.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\
n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\n\nfunction integer(rule, value, callback, source, options)
{\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return callback();\n }\
n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options);\n rules.range(rule, value, source, errors, options);\n }
\n }\n\n callback(errors);\n}\n\n/\n * Validates a number is a floating point number.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param cal
lback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\n\nfunction floatFn(rule, valu
e, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n
return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options);\n rules.range(rule, value, sou
rce, errors, options);\n }\n }\n\n callback(errors);\n}\n\n/
\n * Validates an array.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param
callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\n\nfunction array(rule, val
ue, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value, 'array') && !rule.requir
ed) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options, 'array');\n\n if (!isEmptyValue(value, 'array')) {\n rules.type(rule, value, source, errors, options);\
n rules.range(rule, value, source, errors, options);\n }\n }\n\n callback(errors);\n}\n\n/\n * Validates an object.\n *\n * @param rule The validation rule.\n * @param value The value of the field
on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.
\n */\n\nfunction object(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyVa
lue(value) && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules.type(rule, value, source, errors, options)
;\n }\n }\n\n callback(errors);\n}\n\nvar ENUM$1 = 'enum';\n/
\n * Validates an enumerable list.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.
\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\n\nfunction e
numerable$1(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value) && !r
ule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (value !== undefined) {\n rules[ENUM$1](rule, value, source, errors, options);\n }\n
}\n\n callback(errors);\n}\n\n/\n * Validates a regular expression pattern.\n *\n * Performs validation when a rule only contains\n * a pattern property but is not declared as a string type.\n *\n * @Par
am rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback The callback function.\n * @param source The source object being validated.\n * @param options The vali
dation options.\n * @param options.messages The validation messages.\n */\n\nfunction pattern$2(rule, value, callback, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && sour
ce.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value, 'string') && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n
if (!isEmptyValue(value, 'string')) {\n rules.pattern(rule, value, source, errors, options);\n }\n }\n\n callback(errors);\n}\n\nfunction date(rule, value, callback, source, options) {\n // console.
log('integer rule called %j', rule);\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); // console.log('validate on %s value', value);\n\n if (validate) {\
n if (isEmptyValue(value, 'date') && !rule.required) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options);\n\n if (!isEmptyValue(value, 'date')) {\n var dateO
bject;\n\n if (value instanceof Date) {\n dateObject = value;\n } else {\n dateObject = new Date(value);\n }\n\n rules.type(rule, dateObject, source, errors, options);\n\n i
f (dateObject) {\n rules.range(rule, dateObject.getTime(), source, errors, options);\n }\n }\n }\n\n callback(errors);\n}\n\nfunction required$1(rule, value, callback, source, options) {\n var e
rrors = [];\n var type = Array.isArray(value) ? 'array' : typeof value;\n rules.required(rule, value, source, errors, options, type);\n callback(errors);\n}\n\nfunction type$1(rule, value, callback, source, opti
ons) {\n var ruleType = rule.type;\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value, ruleType) && !rule.req
uired) {\n return callback();\n }\n\n rules.required(rule, value, source, errors, options, ruleType);\n\n if (!isEmptyValue(value, ruleType)) {\n rules.type(rule, value, source, errors, options);
\n }\n }\n\n callback(errors);\n}\n\n/
\n * Performs validation for any type.\n *\n * @param rule The validation rule.\n * @param value The value of the field on the source object.\n * @param callback
The callback function.\n * @param source The source object being validated.\n * @param options The validation options.\n * @param options.messages The validation messages.\n */\n\nfunction any(rule, value, callbac
k, source, options) {\n var errors = [];\n var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);\n\n if (validate) {\n if (isEmptyValue(value) && !rule.required) {\n return c
allback();\n }\n\n rules.required(rule, value, source, errors, options);\n }\n\n callback(errors);\n}\n\nvar validators = {\n string: string,\n method: method,\n number: number,\n \"boolean\": _b
oolean,\n regexp: regexp,\n integer: integer,\n \"float\": floatFn,\n array: array,\n object: object,\n \"enum\": enumerable$1,\n pattern: pattern$2,\n date: date,\n url: type$1,\n hex: type$1,\n
email: type$1,\n required: required$1,\n any: any\n};\n\nfunction newMessages() {\n return {\n \"default\": 'Validation error on field %s',\n required: '%s is required',\n \"enum\": '%s must b
e one of %s',\n whitespace: '%s cannot be empty',\n date: {\n format: '%s date %s is invalid for format %s',\n parse: '%s date could not be parsed, %s is invalid ',\n invalid: '%s date %s
is invalid'\n },\n types: {\n string: '%s is not a %s',\n method: '%s is not a %s (function)',\n array: '%s is not an %s',\n object: '%s is not an %s',\n number: '%s is not a
%s',\n date: '%s is not a %s',\n \"boolean\": '%s is not a %s',\n integer: '%s is not an %s',\n \"float\": '%s is not a %s',\n regexp: '%s is not a valid %s',\n email: '
%s is not a valid %s',\n url: '%s is not a valid %s',\n hex: '%s is not a valid %s'\n },\n string: {\n len: '%s must be exactly %s characters',\n min: '%s must be at least %s charact
ers',\n max: '%s cannot be longer than %s characters',\n range: '%s must be between %s and %s characters'\n },\n number: {\n len: '%s must equal %s',\n min: '%s cannot be less than %
s',\n max: '%s cannot be greater than %s',\n range: '%s must be between %s and %s'\n },\n array: {\n len: '%s must be exactly %s in length',\n min: '%s cannot be less than %s in leng
th',\n max: '%s cannot be greater than %s in length',\n range: '%s must be between %s and %s in length'\n },\n pattern: {\n mismatch: '%s value %s does not match pattern %s'\n },\n
clone: function clone() {\n var cloned = JSON.parse(JSON.stringify(this));\n cloned.clone = this.clone;\n return cloned;\n }\n };\n}\nvar messages = newMessages();\n\n/**\n * Encapsulates a va
lidation schema.\n *\n * @param descriptor An object declaring validation rules\n * for this schema.\n */\n\nfunction Schema(descriptor) {\n this.rules = null;\n this._messages = messages;\n this.define(descr
iptor);\n}\n\nSchema.prototype = {\n messages: function messages(_messages) {\n if (_messages) {\n this._messages = deepMerge(newMessages(), _messages);\n }\n\n return this.messages;\n },\n def
ine: function define(rules) {\n if (!rules) {\n throw new Error('Cannot configure a schema with no rules');\n }\n\n if (typeof rules !== 'object' || Array.isArray(rules)) {\n throw new Error('
Rules must be an object');\n }\n\n this.rules = {};\n var z;\n var item;\n\n for (z in rules) {\n if (rules.hasOwnProperty(z)) {\n item = rules[z];\n this.rules[z] = Array.isArr
ay(item) ? item : [item];\n }\n }\n },\n validate: function validate(source
, o, oc) {\n var _this = this;\n\n if (o === void 0) {\n o = {};\n }\n\n if (oc === void 0) {\n oc = f

(!this.rules || Object.keys(this.rules).length === 0) {\n if (callback) {\n callback();\n }\n\n return Promise.resolve();\n }\n\n function complete(results) {\n var i;\n var
errors = [];\n var fields = {};\n\n function add(e) {\n if (Array.isArray(e)) {\n var _errors;\n\n errors = (_errors = errors).concat.apply(_errors, e);\n } else {\n
errors.push(e);\n }\n }\n\n for (i = 0; i < results.length; i++) {\n add(results[i]);\n }\n\n if (!errors.length) {\n errors = null;\n fields = null;\n }
else {\n fields = convertFieldsError(errors);\n }\n\n callback(errors, fields);\n }\n\n if (options.messages) {\n var messages$1 = this.messages();\n\n if (messages$1 === messages
) {\n messages$1 = newMessages();\n }\n\n deepMerge(messages$1, options.messages);\n options.messages = messages$1;\n } else {\n options.messages = this.messages();\n }\n\n var
arr;\n var value;\n var series = {};\n var keys = options.keys || Object.keys(this.rules);\n keys.forEach(function (z) {\n arr = this.rules[z];\n value = source[z];\n arr.forEach(functio
n (r) {\n var rule = r;\n\n if (typeof rule.transform === 'function') {\n if (source === source
) {\n source = _extends({}, source);\n }\n\n value = source[z] =
rule.transform(value);\n }\n\n if (typeof rule === 'function') {\n rule = {\n validator: rule\n };\n } else {\n rule = _extends({}, rule);\n }\
n\n rule.validator = _this.getValidationMethod(rule);\n rule.field = z;\n rule.fullField = rule.fullField || z;\n rule.type = _this.getType(rule);\n\n if (!rule.validator) {\n
return;\n }\n\n series[z] = series[z] || [];\n series[z].push({\n rule: rule,\n value: value,\n source: source,\n field: z\n });\n });\n
});\n var errorFields = {};\n return asyncMap(series, options, function (data, doIt) {\n var rule = data.rule;\n var deep = (rule.type === 'object' || rule.type === 'array') && (typeof rule.field
s === 'object' || typeof rule.defaultField === 'object');\n deep = deep && (rule.required || !rule.required && data.value);\n rule.field = data.field;\n\n function addFullfield(key, schema) {\n
return _extends(_extends({}, schema), {}, {\n fullField: rule.fullField + \".\" + key\n });\n }\n\n function cb(e) {\n if (e === void 0) {\n e = [];\n }\n\n
var errors = e;\n\n if (!Array.isArray(errors)) {\n errors = [errors];\n }\n\n if (!options.suppressWarning && errors.length) {\n Schema.warning('async-validator:', err
ors);\n }\n\n if (errors.length && rule.message) {\n errors = [].concat(rule.message);\n }\n\n errors = errors.map(complementError(rule));\n\n if (options.first && error
s.length) {\n errorFields[rule.field] = 1;\n return doIt(errors);\n }\n\n if (!deep) {\n doIt(errors);\n } else {\n // if rule is required but the target obj
ect\n // does not exist fail at the rule level and don't\n // go deeper\n if (rule.required && !data.value) {\n if (rule.message) {\n errors = [].concat(rule.message
).map(complementError(rule));\n } else if (options.error) {\n errors = [options.error(rule, format(options.messages.required, rule.field))];\n }\n\n return doIt(errors);\
n }\n\n var fieldsSchema = {};\n\n if (rule.defaultField) {\n for (var k in data.value) {\n if (data.value.hasOwnProperty(k)) {\n fieldsSchema[k] = r
ule.defaultField;\n }\n }\n }\n\n fieldsSchema = _extends(_extends({}, fieldsSchema), data.rule.fields);\n\n for (var f in fieldsSchema) {\n if (fieldsS
chema.hasOwnProperty(f)) {\n var fieldSchema = Array.isArray(fieldsSchema[f]) ? fieldsSchema[f] : [fieldsSchema[f]];\n fieldsSchema[f] = fieldSchema.map(addFullfield.bind(null, f));\n
}\n }\n\n var schema = new Schema(fieldsSchema);\n schema.messages(options.messages);\n\n if (data.rule.options) {\n data.rule.options.messages = options.messages;\n
data.rule.options.error = options.error;\n }\n\n schema.validate(data.value, data.rule.options || options, function (errs) {\n var finalErrors = [];\n\n if (errors
&& errors.length) {\n finalErrors.push.apply(finalErrors, errors);\n }\n\n if (errs && errs.length) {\n finalErrors.push.apply(finalErrors, errs);\n }\n\n
doIt(finalErrors.length ? finalErrors : null);\n });\n }\n }\n\n var res;\n\n if (rule.asyncValidator) {\n res = rule.asyncValidator(rule, data.value, cb, data.sourc
e, options);\n } else if (rule.validator) {\n res = rule.validator(rule, data.value, cb, data.source, options);\n\n if (res === true) {\n cb();\n } else if (res === false) {\n
cb(rule.message || rule.field + \" fails\");\n } else if (res instanceof Array) {\n cb(res);\n } else if (res instanceof Error) {\n cb(res.message);\n }\n }\n\n
if (res && res.then) {\n res.then(function () {\n return cb();\n }, function (e) {\n return cb(e);\n });\n }\n }, function (results) {\n complete(results);\n
});\n },\n getType: function getType(rule) {\n if (rule.type === undefined && rule.pattern instanceof RegExp) {\n rule.type = 'pattern';\n }\n\n if (typeof rule.validator !== 'function' && rul
e.type && !validators.hasOwnProperty(rule.type)) {\n throw new Error(format('Unknown rule type %s', rule.type));\n }\n\n return rule.type || 'string';\n },\n getValidationMethod: function getValidati
onMethod(rule) {\n if (typeof rule.validator === 'function') {\n return rule.validator;\n }\n\n var keys = Object.keys(rule);\n var messageIndex = keys.indexOf('message');\n\n if (messageInd
ex !== -1) {\n keys.splice(messageIndex, 1);\n }\n\n if (keys.length === 1 && keys[0] === 'required') {\n return validators.required;\n }\n\n return validators[this.getType(rule)] || false;
\n }\n};\n\nSchema.register = function register(type, validator) {\n if (typeof validator !== 'function') {\n throw new Error('Cannot register a validator by type, validator is not a function');\n }\n\n
validators[type] = validator;\n};\n\nSchema.warning = warning;\nSchema.messages = messages;\nSchema.validators = validators;\n\n/* harmony default export / webpack_exports[\"default\"] = (Schema);\n//# sourc
eMappingURL=index.js.map\n\n/
WEBPACK VAR INJECTION /}.call(this, webpack_require(/! ./../../process/browser.js */ \"./node_modules/process/browser.js\")))\n\n//# sourceURL=webpack://ElementPlus/./node_modules
/async-validator/dist-web/index.js?");\n' +
'

                                                                            ^\n' +
'924: \n' +
'925: /***/ }),',

watchFiles: [
'D:\GitHub\element-plus-vite-starter-master\index.html',
'D:\GitHub\element-plus-vite-starter-master\src\main.js',
'D:\GitHub\element-plus-vite-starter-master\node_modules\@VUE\runtime-dom\dist\runtime-dom.esm-bundler.js',
'D:\GitHub\element-plus-vite-starter-master\node_modules\@VUE\runtime-core\dist\runtime-core.esm-bundler.js',
'D:\GitHub\element-plus-vite-starter-master\node_modules\@VUE\shared\dist\shared.esm-bundler.js',
'D:\GitHub\element-plus-vite-starter-master\node_modules\@VUE\reactivity\dist\reactivity.esm-bundler.js',
'D:\GitHub\element-plus-vite-starter-master\src\App.vue',
'D:\GitHub\element-plus-vite-starter-master\src\index.css',
'D:\GitHub\element-plus-vite-starter-master\src\App.vue?vue&type=script&lang.js',
'D:\GitHub\element-plus-vite-starter-master\src\App.vue?vue&type=template&id=7ddbb86d&scoped=true&lang.js',
'D:\GitHub\element-plus-vite-starter-master\src\App.vue?vue&type=style&index=0&id=7ddbb86d&scoped=true&lang.css',
'D:\GitHub\element-plus-vite-starter-master\node_modules\element-plus\lib\index.js',
'D:\GitHub\element-plus-vite-starter-master\node_modules\element-plus\lib\theme-chalk\index.css',
'D:\GitHub\element-plus-vite-starter-master\src\assets\logo.png',
'D:\GitHub\element-plus-vite-starter-master\src\components\HelloWorld.vue',
'D:\GitHub\element-plus-vite-starter-master\src\components\HelloWorld.vue?vue&type=script&lang.js',
'D:\GitHub\element-plus-vite-starter-master\src\components\HelloWorld.vue?vue&type=template&id=bd4c1bf6&lang.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: vite build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\twili\AppData\Roaming\npm-cache_logs\2020-11-17T01_35_38_743Z-debug.log

Process finished with exit code 1

Wrong font on some components

Hi! I just cloned the project but have issues with the fonts. Please see fonts higlighted below:

image

I would have expected that when I cloned the starter, everything should work out of the box - did I miss some instructions?

I also tried the default "getting started" instructions on the element-plus page, but faced similar issues with the font. Am I missing something?

icon

我现在开发时候的icon全部都是 方框,本来项目拉下来第一个安装依赖是有的,第二次第三次第四次拉下来后 icon 全部都是 方框

Change default variables with SCSS and vite

I have setup vite.config.js on this package to work with SCSS by adding it`s module, but when changing element-plus default scss variables, it gets some errors about paths. Maybe you could help me fix this issue!

This is the custom scss I am setting

$--font-path: '~element-plus/packages/theme-chalk/src/fonts';

/**
* I think element-plus default theme color is too light for long-term use.
* So I modified the default color and you can modify it to your liking.
**/

/* theme color */
$--color-primary: #0d6efd;
$--color-success: #1db85d;
$--color-warning: #E6A23C;
$--color-danger: #ff4949;
$--color-info: #1E1E1E;

vite.config.js

import {defineConfig} from 'vite'
import { resolve } from "path";
import vue from '@vitejs/plugin-vue'

export default defineConfig({
    alias: {
        vue: "vue/dist/vue.esm-browser.js",
        "@": resolve(__dirname, "src"),
        "~": resolve(__dirname, "node_modules/"),
    },
    plugins: [vue()],
    build: {
        rollupOptions: {
            external: [
                "vue-class-component", // ignore react stuff
                "vue-draggable-next",
                "vue-grid-layout"
            ],
        },
    },
})

The errors

$ vuedx-typecheck . && vite build
Running for /Users/macbook/Sites/mando/vite

Found 0 errors.building for production...
[vite:css] ENOENT: no such file or directory, open '/sites/app/vite/src/styles/~element-plus/packages/theme-chalk/src/fonts/element-icons.woff'
file: /sites/app//vite/src/styles/style.scss
error during build:

[BUG] el-virtual-list import non-exist path

After updated to latest version for [email protected], vite cannot be launched correctly.

Reason Behind

The file el-virtual-list/index.js is importing a non-exist path ../el-scrollbar/src/util.
el-scrollbar/src/util is not exist after webpack or rollup build as they will be packed to a single file.

Workaround

Hotfix Plugin

import * as fs from 'fs'
import * as path from 'path'
import { Plugin } from 'vite'

export default function(): Plugin {
  const elementPlusRoot = path.resolve('node_modules', 'element-plus')
  const rewrite = [
    {
      path: ['package.json'],
      isJSON: true,
      key: 'module',
      from: 'lib/index.esm.js',
      to: 'es/index.js'
    },
    {
      path: ['es', 'el-virtual-list', 'index.js'],
      isJSON: false,
      key: null,
      from: "import { BAR_MAP } from '../el-scrollbar/src/util';",
      to: 'const BAR_MAP = { vertical: { offset: "offsetHeight", scroll: "scrollTop", scrollSize: "scrollHeight", size: "height", key: "vertical", axis: "Y", client: "clientY", direction: "top" }, horizontal: { offset: "offsetWidth", scroll: "scrollLeft", scrollSize: "scrollWidth", size: "width", key: "horizontal", axis: "X", client: "clientX", direction: "left" } };'
    },
    {
      path: ['lib', 'el-virtual-list', 'index.js'],
      isJSON: false,
      key: null,
      from: "var util$1 = require('../el-scrollbar/src/util');",
      to: 'var util$1 = { BAR_MAP: { vertical: { offset: "offsetHeight", scroll: "scrollTop", scrollSize: "scrollHeight", size: "height", key: "vertical", axis: "Y", client: "clientY", direction: "top" }, horizontal: { offset: "offsetWidth", scroll: "scrollLeft", scrollSize: "scrollWidth", size: "width", key: "horizontal", axis: "X", client: "clientX", direction: "left" } } };'
    }
  ]
  return {
    name: 'element-plus-hotfix',
    async buildStart() {
      const promises = rewrite.map(async function(r) {
        const filePath = path.resolve(elementPlusRoot, ...r.path)
        let buf = await fs.promises.readFile(filePath)
        let str = buf.toString()
        if(r.isJSON && r.key) {
          const json = JSON.parse(str)
          json[r.key] = r.to
          await fs.promises.writeFile(filePath, JSON.stringify(json, null, 2))
        } else {
          str = str.replace(r.from, r.to)
          await fs.promises.writeFile(filePath, str)
        }
      })
      await Promise.all(promises)
    },
    async buildEnd() {
      const promises = rewrite.map(async function(r) {
        const filePath = path.resolve(elementPlusRoot, ...r.path)
        let buf = await fs.promises.readFile(filePath)
        let str = buf.toString()
        if(r.isJSON && r.key) {
          const json = JSON.parse(str)
          json[r.key] = r.from
          await fs.promises.writeFile(filePath, JSON.stringify(json, null, 2))
        } else {
          str = str.replace(r.to, r.from)
          await fs.promises.writeFile(filePath, str)
        }
      })
      await Promise.all(promises)
    }
  }
}

Vite Config

import vue from '@vitejs/plugin-vue'
import hotfix from 'hotfix.ts'
export default {
  plugins: [hotfix(), vue()]
}

webpack

有无webpack的版本呢大佬

npm run dev失败

Build failed with 3 errors:
node_modules/_element-plus@1.0.2-beta.35@element-plus/lib/index.esm.js:1:885: error: No matching export in "node_modules/_vue@3.0.8@vue/dist/vue.runtime.esm-bundler.js" for import "pushScopeId"
node_modules/_element-plus@1.0.2-beta.35@element-plus/lib/index.esm.js:1:903: error: No matching export in "node_modules/_vue@3.0.8@vue/dist/vue.runtime.esm-bundler.js" for import "popScopeId"
node_modules/_element-plus@1.0.2-beta.35@element-plus/lib/index.esm.js:1:920: error: No matching export in "node_modules/_vue@3.0.8@vue/dist/vue.runtime.esm-bundler.js" for import "withScopeId"

error

npm run dev error
error when starting dev server:
Error: Cannot find module 'unplugin-vue-components/vite'

ElMessage, ElMessageBox no style

import {ElMessage, ElMessageBox } from 'element-plus'
export default {
setup() {
ElMessage.error('123')
ElMessageBox.confirm("111", "222", {
confirmButtonText: "11221",
cancelButtonText: "123",
})
.then(() => {})
.catch(() => {});
},
};

ElMessage and ElMessageBox
image

ElMessage not style

用了unplugin-vue-components 插件我在request.js 中
import {ElMessage} from 'element-plus'

ElMessage.error() 是没有样式的,这样如何处理

暗黑模式下,会生成重复的样式

例子就是本仓库在线地址,可以看到在暗黑模式下时,单个 el-button 组件就会生成多个重复的 css ,但在默认模式下是正常的,感觉应该是个 bug

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.