@zhaoyifannan/tvue 3.9.7 → 3.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/tvue.js +9453 -2344
- package/dist/tvue.js.map +1 -1
- package/dist/tvue.min.js +3 -3
- package/es/_virtual/_commonjs-dynamic-modules.mjs +1 -1
- package/es/_virtual/_commonjsHelpers.mjs +1 -1
- package/es/_virtual/axios.mjs +1 -1
- package/es/_virtual/axios2.mjs +1 -1
- package/es/_virtual/countUp.min.mjs +1 -1
- package/es/_virtual/countUp2.min.mjs +1 -1
- package/es/_virtual/dayjs.min.mjs +1 -1
- package/es/_virtual/dayjs2.min.mjs +1 -1
- package/es/index.css +1 -1
- package/es/locale/browser/en.mjs +7 -1
- package/es/locale/browser/zh-cn.mjs +7 -1
- package/es/locale/browser/zh.mjs +7 -1
- package/es/node_modules/.pnpm/async-validator@4.2.5/node_modules/async-validator/dist-web/index.mjs +1329 -0
- package/es/node_modules/.pnpm/countup.js@1.9.3/node_modules/countup.js/dist/countUp.min.mjs +1 -1
- package/es/node_modules/.pnpm/dayjs@1.11.23/node_modules/dayjs/dayjs.min.mjs +1 -1
- package/es/node_modules/.pnpm/qrcode-generator@2.0.4/node_modules/qrcode-generator/dist/qrcode.mjs +1 -1
- package/es/node_modules/axios/dist/axios.mjs +1 -1
- package/es/packages/core/common/event.mjs +54 -7
- package/es/packages/core/common/init.mjs +203 -44
- package/es/packages/core/common/props.mjs +11 -4
- package/es/packages/core/components/dialog-form/index.mjs +1 -1
- package/es/packages/core/components/dialog-form/index2.mjs +1 -1
- package/es/packages/core/components/dialog-form/index3.mjs +1 -1
- package/es/packages/core/components/dialog-form/index4.mjs +1 -1
- package/es/packages/core/components/form/custom.mjs +1 -1
- package/es/packages/core/components/form/index.mjs +1 -1
- package/es/packages/core/components/form/index2.mjs +1 -1
- package/es/packages/core/components/form/index3.mjs +1 -1
- package/es/packages/core/components/icon/index.mjs +1 -1
- package/es/packages/core/components/icon/index2.mjs +1 -1
- package/es/packages/core/components/icon/index3.mjs +1 -1
- package/es/packages/core/components/image-preview/index.mjs +1 -1
- package/es/packages/core/components/image-preview/index2.mjs +1 -1
- package/es/packages/core/components/image-preview/index3.mjs +1 -2
- package/es/packages/core/components/image-preview/index4.mjs +1 -1
- package/es/packages/core/components/print-preview/index.mjs +8 -0
- package/es/packages/core/components/print-preview/index2.mjs +123 -0
- package/es/packages/core/components/print-preview/index3.mjs +309 -0
- package/es/packages/core/directive/contextmenu.mjs +1 -1
- package/es/packages/core/directive/permission.mjs +1 -1
- package/es/packages/data/box/index.mjs +1 -1
- package/es/packages/data/box/index2.mjs +1 -1
- package/es/packages/data/box/index3.mjs +1 -1
- package/es/packages/data/card/index.mjs +1 -1
- package/es/packages/data/card/index2.mjs +1 -1
- package/es/packages/data/card/index3.mjs +1 -1
- package/es/packages/data/cardText/index.mjs +1 -1
- package/es/packages/data/cardText/index2.mjs +1 -1
- package/es/packages/data/cardText/index3.mjs +1 -1
- package/es/packages/data/countdown/index.mjs +1 -1
- package/es/packages/data/countdown/index2.mjs +1 -1
- package/es/packages/data/countdown/index3.mjs +1 -1
- package/es/packages/data/dashboard/index.mjs +1 -1
- package/es/packages/data/dashboard/index2.mjs +1 -1
- package/es/packages/data/dashboard/index3.mjs +1 -1
- package/es/packages/data/display/index.mjs +1 -1
- package/es/packages/data/display/index2.mjs +1 -1
- package/es/packages/data/display/index3.mjs +1 -1
- package/es/packages/data/icons/index.mjs +1 -1
- package/es/packages/data/icons/index2.mjs +1 -1
- package/es/packages/data/icons/index3.mjs +1 -1
- package/es/packages/data/imgText/index.mjs +1 -1
- package/es/packages/data/imgText/index2.mjs +1 -1
- package/es/packages/data/imgText/index3.mjs +1 -1
- package/es/packages/data/list/index.mjs +1 -1
- package/es/packages/data/list/index2.mjs +1 -1
- package/es/packages/data/list/index3.mjs +1 -1
- package/es/packages/data/notice/index.mjs +1 -1
- package/es/packages/data/notice/index2.mjs +1 -1
- package/es/packages/data/notice/index3.mjs +1 -1
- package/es/packages/data/operaText/index.mjs +1 -1
- package/es/packages/data/operaText/index2.mjs +1 -1
- package/es/packages/data/operaText/index3.mjs +1 -1
- package/es/packages/data/panel/index.mjs +1 -1
- package/es/packages/data/panel/index2.mjs +1 -1
- package/es/packages/data/panel/index3.mjs +1 -1
- package/es/packages/data/pay/index.mjs +1 -1
- package/es/packages/data/pay/index2.mjs +1 -1
- package/es/packages/data/pay/index3.mjs +1 -1
- package/es/packages/data/price/index.mjs +1 -1
- package/es/packages/data/price/index2.mjs +1 -1
- package/es/packages/data/price/index3.mjs +1 -1
- package/es/packages/data/product/index.mjs +1 -1
- package/es/packages/data/product/index2.mjs +1 -1
- package/es/packages/data/product/index3.mjs +1 -1
- package/es/packages/data/profile/index.mjs +1 -1
- package/es/packages/data/profile/index2.mjs +1 -1
- package/es/packages/data/profile/index3.mjs +1 -1
- package/es/packages/data/progress/index.mjs +1 -1
- package/es/packages/data/progress/index2.mjs +1 -1
- package/es/packages/data/progress/index3.mjs +1 -1
- package/es/packages/data/rank/index.mjs +1 -1
- package/es/packages/data/rank/index2.mjs +1 -1
- package/es/packages/data/rank/index3.mjs +1 -1
- package/es/packages/data/rotate/index.mjs +1 -1
- package/es/packages/data/rotate/index2.mjs +1 -1
- package/es/packages/data/rotate/index3.mjs +1 -1
- package/es/packages/data/statistic/index.mjs +1 -1
- package/es/packages/data/statistic/index2.mjs +1 -1
- package/es/packages/data/statistic/index3.mjs +1 -1
- package/es/packages/data/tabs/index.mjs +1 -1
- package/es/packages/data/tabs/index2.mjs +1 -1
- package/es/packages/data/tabs/index3.mjs +1 -1
- package/es/packages/data/task/index.mjs +1 -1
- package/es/packages/data/task/index2.mjs +1 -1
- package/es/packages/data/task/index3.mjs +1 -1
- package/es/packages/data/weather/index.mjs +1 -1
- package/es/packages/data/weather/index2.mjs +1 -1
- package/es/packages/data/weather/index3.mjs +1 -1
- package/es/packages/element-plus/array/index.mjs +1 -1
- package/es/packages/element-plus/array/index2.mjs +1 -1
- package/es/packages/element-plus/array/index3.mjs +1 -1
- package/es/packages/element-plus/article/index.mjs +1 -1
- package/es/packages/element-plus/article/index2.mjs +1 -1
- package/es/packages/element-plus/article/index3.mjs +1 -1
- package/es/packages/element-plus/captcha/index.mjs +1 -1
- package/es/packages/element-plus/captcha/index2.mjs +1 -1
- package/es/packages/element-plus/captcha/index3.mjs +1 -1
- package/es/packages/element-plus/cascader/index.mjs +1 -1
- package/es/packages/element-plus/cascader/index2.mjs +38 -20
- package/es/packages/element-plus/cascader/index3.mjs +3 -4
- package/es/packages/element-plus/chat/index.mjs +1 -1
- package/es/packages/element-plus/chat/index2.mjs +1 -1
- package/es/packages/element-plus/chat/index3.mjs +1 -1
- package/es/packages/element-plus/checkbox/index.mjs +1 -1
- package/es/packages/element-plus/checkbox/index2.mjs +27 -11
- package/es/packages/element-plus/checkbox/index3.mjs +1 -1
- package/es/packages/element-plus/comment/index.mjs +1 -1
- package/es/packages/element-plus/comment/index2.mjs +1 -1
- package/es/packages/element-plus/comment/index3.mjs +1 -1
- package/es/packages/element-plus/count-up/index.mjs +1 -1
- package/es/packages/element-plus/count-up/index2.mjs +1 -1
- package/es/packages/element-plus/count-up/index3.mjs +1 -1
- package/es/packages/element-plus/crud/column/column-default.mjs +1 -1
- package/es/packages/element-plus/crud/column/column-default2.mjs +1 -1
- package/es/packages/element-plus/crud/column/column-default3.mjs +1 -1
- package/es/packages/element-plus/crud/column/column-dynamic.mjs +1 -1
- package/es/packages/element-plus/crud/column/column-dynamic2.mjs +1 -1
- package/es/packages/element-plus/crud/column/column-dynamic3.mjs +1 -1
- package/es/packages/element-plus/crud/column/column-menu.mjs +1 -1
- package/es/packages/element-plus/crud/column/column-menu2.mjs +1 -1
- package/es/packages/element-plus/crud/column/column-menu3.mjs +1 -1
- package/es/packages/element-plus/crud/column/column-slot.mjs +1 -1
- package/es/packages/element-plus/crud/column/column-slot2.mjs +1 -1
- package/es/packages/element-plus/crud/column/column-slot3.mjs +1 -1
- package/es/packages/element-plus/crud/column/column.mjs +1 -1
- package/es/packages/element-plus/crud/column/column2.mjs +1 -1
- package/es/packages/element-plus/crud/column/column3.mjs +1 -1
- package/es/packages/element-plus/crud/column/menu.mjs +1 -1
- package/es/packages/element-plus/crud/column/menu2.mjs +1 -1
- package/es/packages/element-plus/crud/column/menu3.mjs +1 -1
- package/es/packages/element-plus/crud/config.mjs +6 -1
- package/es/packages/element-plus/crud/dialog/dialog-column.mjs +1 -1
- package/es/packages/element-plus/crud/dialog/dialog-column2.mjs +1 -1
- package/es/packages/element-plus/crud/dialog/dialog-column3.mjs +1 -1
- package/es/packages/element-plus/crud/dialog/dialog-excel.mjs +1 -1
- package/es/packages/element-plus/crud/dialog/dialog-excel2.mjs +9 -10
- package/es/packages/element-plus/crud/dialog/dialog-excel3.mjs +1 -1
- package/es/packages/element-plus/crud/dialog/dialog-filter.mjs +1 -1
- package/es/packages/element-plus/crud/dialog/dialog-filter2.mjs +1 -1
- package/es/packages/element-plus/crud/dialog/dialog-filter3.mjs +1 -1
- package/es/packages/element-plus/crud/dialog/dialog-form.mjs +1 -1
- package/es/packages/element-plus/crud/dialog/dialog-form2.mjs +14 -10
- package/es/packages/element-plus/crud/dialog/dialog-form3.mjs +6 -6
- package/es/packages/element-plus/crud/dialog/dialog-import.mjs +8 -0
- package/es/packages/element-plus/crud/dialog/dialog-import2.mjs +312 -0
- package/es/packages/element-plus/crud/dialog/dialog-import3.mjs +316 -0
- package/es/packages/element-plus/crud/grid/index.mjs +1 -1
- package/es/packages/element-plus/crud/grid/index2.mjs +1 -1
- package/es/packages/element-plus/crud/grid/index3.mjs +1 -1
- package/es/packages/element-plus/crud/grid/item.mjs +1 -1
- package/es/packages/element-plus/crud/grid/item2.mjs +1 -1
- package/es/packages/element-plus/crud/grid/item3.mjs +1 -1
- package/es/packages/element-plus/crud/index.mjs +1 -1
- package/es/packages/element-plus/crud/index2.mjs +74 -36
- package/es/packages/element-plus/crud/index3.mjs +9 -2
- package/es/packages/element-plus/crud/menu/header-menu.mjs +1 -1
- package/es/packages/element-plus/crud/menu/header-menu2.mjs +18 -4
- package/es/packages/element-plus/crud/menu/header-menu3.mjs +35 -9
- package/es/packages/element-plus/crud/menu/header-search.mjs +1 -1
- package/es/packages/element-plus/crud/menu/header-search2.mjs +1 -1
- package/es/packages/element-plus/crud/menu/header-search3.mjs +1 -1
- package/es/packages/element-plus/crud/menu/query-views.mjs +8 -0
- package/es/packages/element-plus/crud/menu/query-views2.mjs +24 -0
- package/es/packages/element-plus/crud/menu/query-views3.mjs +156 -0
- package/es/packages/element-plus/crud/menu/table-page.mjs +1 -1
- package/es/packages/element-plus/crud/menu/table-page2.mjs +1 -1
- package/es/packages/element-plus/crud/menu/table-page3.mjs +1 -1
- package/es/packages/element-plus/crud/query-view.mjs +364 -0
- package/es/packages/element-plus/date/index.mjs +1 -1
- package/es/packages/element-plus/date/index2.mjs +1 -1
- package/es/packages/element-plus/date/index3.mjs +1 -1
- package/es/packages/element-plus/draggable/index.mjs +1 -1
- package/es/packages/element-plus/draggable/index2.mjs +1 -1
- package/es/packages/element-plus/draggable/index3.mjs +1 -1
- package/es/packages/element-plus/dynamic/index.mjs +1 -1
- package/es/packages/element-plus/dynamic/index2.mjs +50 -7
- package/es/packages/element-plus/dynamic/index3.mjs +6 -6
- package/es/packages/element-plus/file-manager/index.mjs +1 -1
- package/es/packages/element-plus/file-manager/index2.mjs +56 -9
- package/es/packages/element-plus/file-manager/index3.mjs +1 -1
- package/es/packages/element-plus/filter-builder/index.mjs +1 -1
- package/es/packages/element-plus/filter-builder/index2.mjs +1 -1
- package/es/packages/element-plus/filter-builder/index3.mjs +1 -1
- package/es/packages/element-plus/flow/index.mjs +1 -1
- package/es/packages/element-plus/flow/index2.mjs +1 -1
- package/es/packages/element-plus/flow/index3.mjs +1 -1
- package/es/packages/element-plus/flow/node.mjs +1 -1
- package/es/packages/element-plus/flow/node2.mjs +1 -1
- package/es/packages/element-plus/flow/node3.mjs +1 -1
- package/es/packages/element-plus/form/config.mjs +1 -1
- package/es/packages/element-plus/form/index.mjs +1 -1
- package/es/packages/element-plus/form/index2.mjs +308 -224
- package/es/packages/element-plus/form/index3.mjs +4 -4
- package/es/packages/element-plus/form/menu.mjs +1 -1
- package/es/packages/element-plus/form/menu2.mjs +1 -1
- package/es/packages/element-plus/form/menu3.mjs +1 -1
- package/es/packages/element-plus/group/index.mjs +1 -1
- package/es/packages/element-plus/group/index2.mjs +1 -1
- package/es/packages/element-plus/group/index3.mjs +1 -1
- package/es/packages/element-plus/iframe/index.mjs +1 -1
- package/es/packages/element-plus/iframe/index2.mjs +1 -1
- package/es/packages/element-plus/iframe/index3.mjs +1 -1
- package/es/packages/element-plus/input/index.mjs +1 -1
- package/es/packages/element-plus/input/index2.mjs +1 -1
- package/es/packages/element-plus/input/index3.mjs +1 -1
- package/es/packages/element-plus/input-color/index.mjs +1 -1
- package/es/packages/element-plus/input-color/index2.mjs +1 -1
- package/es/packages/element-plus/input-color/index3.mjs +1 -1
- package/es/packages/element-plus/input-cron/index.mjs +1 -1
- package/es/packages/element-plus/input-cron/index2.mjs +1 -1
- package/es/packages/element-plus/input-cron/index3.mjs +1 -1
- package/es/packages/element-plus/input-icon/index.mjs +1 -1
- package/es/packages/element-plus/input-icon/index2.mjs +1 -1
- package/es/packages/element-plus/input-icon/index3.mjs +1 -1
- package/es/packages/element-plus/input-map/index.mjs +1 -1
- package/es/packages/element-plus/input-map/index2.mjs +93 -28
- package/es/packages/element-plus/input-map/index3.mjs +11 -9
- package/es/packages/element-plus/input-number/index.mjs +1 -1
- package/es/packages/element-plus/input-number/index2.mjs +1 -1
- package/es/packages/element-plus/input-number/index3.mjs +1 -1
- package/es/packages/element-plus/input-otp/index.mjs +1 -1
- package/es/packages/element-plus/input-otp/index2.mjs +2 -2
- package/es/packages/element-plus/input-otp/index3.mjs +1 -1
- package/es/packages/element-plus/input-table/index.mjs +1 -1
- package/es/packages/element-plus/input-table/index2.mjs +100 -38
- package/es/packages/element-plus/input-table/index3.mjs +1 -1
- package/es/packages/element-plus/input-tag/index.mjs +1 -1
- package/es/packages/element-plus/input-tag/index2.mjs +1 -10
- package/es/packages/element-plus/input-tag/index3.mjs +2 -3
- package/es/packages/element-plus/input-tree/index.mjs +1 -1
- package/es/packages/element-plus/input-tree/index2.mjs +41 -39
- package/es/packages/element-plus/input-tree/index3.mjs +1 -1
- package/es/packages/element-plus/license/index.mjs +1 -1
- package/es/packages/element-plus/license/index2.mjs +1 -1
- package/es/packages/element-plus/license/index3.mjs +1 -1
- package/es/packages/element-plus/login/index.mjs +1 -1
- package/es/packages/element-plus/login/index2.mjs +31 -9
- package/es/packages/element-plus/login/index3.mjs +1 -1
- package/es/packages/element-plus/mention/index.mjs +1 -1
- package/es/packages/element-plus/mention/index2.mjs +1 -1
- package/es/packages/element-plus/mention/index3.mjs +1 -1
- package/es/packages/element-plus/qrcode/index.mjs +1 -1
- package/es/packages/element-plus/qrcode/index2.mjs +1 -1
- package/es/packages/element-plus/qrcode/index3.mjs +1 -1
- package/es/packages/element-plus/radio/index.mjs +1 -1
- package/es/packages/element-plus/radio/index2.mjs +1 -1
- package/es/packages/element-plus/radio/index3.mjs +1 -1
- package/es/packages/element-plus/rate/index.mjs +1 -1
- package/es/packages/element-plus/rate/index2.mjs +1 -1
- package/es/packages/element-plus/rate/index3.mjs +1 -1
- package/es/packages/element-plus/search/index.mjs +1 -1
- package/es/packages/element-plus/search/index2.mjs +1 -1
- package/es/packages/element-plus/search/index3.mjs +1 -1
- package/es/packages/element-plus/select/index.mjs +1 -1
- package/es/packages/element-plus/select/index2.mjs +55 -21
- package/es/packages/element-plus/select/index3.mjs +55 -56
- package/es/packages/element-plus/sign/index.mjs +1 -1
- package/es/packages/element-plus/sign/index2.mjs +1 -1
- package/es/packages/element-plus/sign/index3.mjs +1 -1
- package/es/packages/element-plus/slider/index.mjs +1 -1
- package/es/packages/element-plus/slider/index2.mjs +1 -1
- package/es/packages/element-plus/slider/index3.mjs +1 -1
- package/es/packages/element-plus/switch/index.mjs +1 -1
- package/es/packages/element-plus/switch/index2.mjs +1 -1
- package/es/packages/element-plus/switch/index3.mjs +1 -1
- package/es/packages/element-plus/tabs/index.mjs +1 -1
- package/es/packages/element-plus/tabs/index2.mjs +1 -1
- package/es/packages/element-plus/tabs/index3.mjs +1 -1
- package/es/packages/element-plus/text-ellipsis/index.mjs +1 -1
- package/es/packages/element-plus/text-ellipsis/index2.mjs +1 -1
- package/es/packages/element-plus/text-ellipsis/index3.mjs +1 -1
- package/es/packages/element-plus/time/index.mjs +1 -1
- package/es/packages/element-plus/time/index2.mjs +1 -1
- package/es/packages/element-plus/time/index3.mjs +1 -1
- package/es/packages/element-plus/title/index.mjs +1 -1
- package/es/packages/element-plus/title/index2.mjs +1 -1
- package/es/packages/element-plus/title/index3.mjs +1 -1
- package/es/packages/element-plus/tree/index.mjs +1 -1
- package/es/packages/element-plus/tree/index2.mjs +1 -1
- package/es/packages/element-plus/tree/index3.mjs +1 -1
- package/es/packages/element-plus/upload/index.mjs +1 -1
- package/es/packages/element-plus/upload/index2.mjs +160 -53
- package/es/packages/element-plus/upload/index3.mjs +1 -1
- package/es/packages/element-plus/video/index.mjs +1 -1
- package/es/packages/element-plus/video/index2.mjs +1 -1
- package/es/packages/element-plus/video/index3.mjs +1 -1
- package/es/src/core/column-state.mjs +16 -7
- package/es/src/core/create.mjs +1 -1
- package/es/src/core/crud-import.mjs +306 -0
- package/es/src/core/crud-validation.mjs +80 -0
- package/es/src/core/dataformat.mjs +6 -6
- package/es/src/core/detail.mjs +2 -4
- package/es/src/core/dic.mjs +52 -35
- package/es/src/core/locale.mjs +1 -1
- package/es/src/core/model.mjs +23 -0
- package/es/src/core/option.mjs +5 -5
- package/es/src/core/packages.mjs +1 -1
- package/es/src/core/query-view.mjs +304 -0
- package/es/src/core/slot.mjs +1 -1
- package/es/src/core/viewport.mjs +50 -0
- package/es/src/global/variable.mjs +1 -1
- package/es/src/icon.mjs +1 -1
- package/es/src/index.mjs +3 -2
- package/es/src/locale/index.mjs +1 -1
- package/es/src/locale/lang/en.mjs +8 -1
- package/es/src/locale/lang/zh-cn.mjs +8 -1
- package/es/src/locale/lang/zh.mjs +8 -1
- package/es/src/locale/messages/crud-import.mjs +75 -0
- package/es/src/locale/messages/print-preview.mjs +65 -0
- package/es/src/locale/messages/query-view.mjs +38 -0
- package/es/src/plugin/ali/index.mjs +1 -1
- package/es/src/plugin/clipboard/index.mjs +1 -1
- package/es/src/plugin/export/_blob.mjs +1 -1
- package/es/src/plugin/export/_export2Excel.mjs +1 -1
- package/es/src/plugin/export/index.mjs +1 -1
- package/es/src/plugin/logs/index.mjs +1 -1
- package/es/src/plugin/print/index.mjs +280 -173
- package/es/src/plugin/print/preview.mjs +74 -0
- package/es/src/plugin/qiniu/index.mjs +1 -1
- package/es/src/plugin/screenshot/index.mjs +1 -1
- package/es/src/plugin/video/index.mjs +1 -1
- package/es/src/plugin/watermark/index.mjs +1 -1
- package/es/src/plugin/watermark/watermark.mjs +1 -1
- package/es/src/ui/data/index.mjs +1 -1
- package/es/src/ui/element-plus/index.mjs +1 -1
- package/es/src/ui/index.mjs +1 -1
- package/es/src/utils/bem.mjs +1 -1
- package/es/src/utils/load-script.mjs +102 -0
- package/es/src/utils/mock.mjs +1 -1
- package/es/src/utils/print.mjs +83 -19
- package/es/src/utils/util.mjs +7 -37
- package/es/src/utils/validate.mjs +1 -1
- package/es/src/version.mjs +2 -2
- package/lib/_virtual/_commonjsHelpers.js +1 -1
- package/lib/_virtual/dayjs.min.js +1 -1
- package/lib/_virtual/dayjs2.min.js +1 -1
- package/lib/index.css +1 -1
- package/lib/locale/browser/en.js +7 -1
- package/lib/locale/browser/zh-cn.js +7 -1
- package/lib/locale/browser/zh.js +7 -1
- package/lib/node_modules/.pnpm/async-validator@4.2.5/node_modules/async-validator/dist-web/index.js +1333 -0
- package/lib/node_modules/.pnpm/dayjs@1.11.23/node_modules/dayjs/dayjs.min.js +1 -1
- package/lib/node_modules/.pnpm/qrcode-generator@2.0.4/node_modules/qrcode-generator/dist/qrcode.js +1 -1
- package/lib/packages/core/common/event.js +54 -7
- package/lib/packages/core/common/init.js +206 -43
- package/lib/packages/core/common/props.js +11 -4
- package/lib/packages/core/components/dialog-form/index.js +1 -1
- package/lib/packages/core/components/dialog-form/index2.js +1 -1
- package/lib/packages/core/components/dialog-form/index3.js +1 -1
- package/lib/packages/core/components/dialog-form/index4.js +1 -1
- package/lib/packages/core/components/form/custom.js +1 -1
- package/lib/packages/core/components/form/index.js +1 -1
- package/lib/packages/core/components/form/index2.js +1 -1
- package/lib/packages/core/components/form/index3.js +1 -1
- package/lib/packages/core/components/icon/index.js +1 -1
- package/lib/packages/core/components/icon/index2.js +1 -1
- package/lib/packages/core/components/icon/index3.js +1 -1
- package/lib/packages/core/components/image-preview/index.js +1 -1
- package/lib/packages/core/components/image-preview/index2.js +1 -1
- package/lib/packages/core/components/image-preview/index3.js +1 -2
- package/lib/packages/core/components/image-preview/index4.js +1 -1
- package/lib/packages/core/components/print-preview/index.js +12 -0
- package/lib/packages/core/components/print-preview/index2.js +127 -0
- package/lib/packages/core/components/print-preview/index3.js +311 -0
- package/lib/packages/core/directive/contextmenu.js +1 -1
- package/lib/packages/core/directive/permission.js +1 -1
- package/lib/packages/data/box/index.js +1 -1
- package/lib/packages/data/box/index2.js +1 -1
- package/lib/packages/data/box/index3.js +1 -1
- package/lib/packages/data/card/index.js +1 -1
- package/lib/packages/data/card/index2.js +1 -1
- package/lib/packages/data/card/index3.js +1 -1
- package/lib/packages/data/cardText/index.js +1 -1
- package/lib/packages/data/cardText/index2.js +1 -1
- package/lib/packages/data/cardText/index3.js +1 -1
- package/lib/packages/data/countdown/index.js +1 -1
- package/lib/packages/data/countdown/index2.js +1 -1
- package/lib/packages/data/countdown/index3.js +1 -1
- package/lib/packages/data/dashboard/index.js +1 -1
- package/lib/packages/data/dashboard/index2.js +1 -1
- package/lib/packages/data/dashboard/index3.js +1 -1
- package/lib/packages/data/display/index.js +1 -1
- package/lib/packages/data/display/index2.js +1 -1
- package/lib/packages/data/display/index3.js +1 -1
- package/lib/packages/data/icons/index.js +1 -1
- package/lib/packages/data/icons/index2.js +1 -1
- package/lib/packages/data/icons/index3.js +1 -1
- package/lib/packages/data/imgText/index.js +1 -1
- package/lib/packages/data/imgText/index2.js +1 -1
- package/lib/packages/data/imgText/index3.js +1 -1
- package/lib/packages/data/list/index.js +1 -1
- package/lib/packages/data/list/index2.js +1 -1
- package/lib/packages/data/list/index3.js +1 -1
- package/lib/packages/data/notice/index.js +1 -1
- package/lib/packages/data/notice/index2.js +1 -1
- package/lib/packages/data/notice/index3.js +1 -1
- package/lib/packages/data/operaText/index.js +1 -1
- package/lib/packages/data/operaText/index2.js +1 -1
- package/lib/packages/data/operaText/index3.js +1 -1
- package/lib/packages/data/panel/index.js +1 -1
- package/lib/packages/data/panel/index2.js +1 -1
- package/lib/packages/data/panel/index3.js +1 -1
- package/lib/packages/data/pay/index.js +1 -1
- package/lib/packages/data/pay/index2.js +1 -1
- package/lib/packages/data/pay/index3.js +1 -1
- package/lib/packages/data/price/index.js +1 -1
- package/lib/packages/data/price/index2.js +1 -1
- package/lib/packages/data/price/index3.js +1 -1
- package/lib/packages/data/product/index.js +1 -1
- package/lib/packages/data/product/index2.js +1 -1
- package/lib/packages/data/product/index3.js +1 -1
- package/lib/packages/data/profile/index.js +1 -1
- package/lib/packages/data/profile/index2.js +1 -1
- package/lib/packages/data/profile/index3.js +1 -1
- package/lib/packages/data/progress/index.js +1 -1
- package/lib/packages/data/progress/index2.js +1 -1
- package/lib/packages/data/progress/index3.js +1 -1
- package/lib/packages/data/rank/index.js +1 -1
- package/lib/packages/data/rank/index2.js +1 -1
- package/lib/packages/data/rank/index3.js +1 -1
- package/lib/packages/data/rotate/index.js +1 -1
- package/lib/packages/data/rotate/index2.js +1 -1
- package/lib/packages/data/rotate/index3.js +1 -1
- package/lib/packages/data/statistic/index.js +1 -1
- package/lib/packages/data/statistic/index2.js +1 -1
- package/lib/packages/data/statistic/index3.js +1 -1
- package/lib/packages/data/tabs/index.js +1 -1
- package/lib/packages/data/tabs/index2.js +1 -1
- package/lib/packages/data/tabs/index3.js +1 -1
- package/lib/packages/data/task/index.js +1 -1
- package/lib/packages/data/task/index2.js +1 -1
- package/lib/packages/data/task/index3.js +1 -1
- package/lib/packages/data/weather/index.js +1 -1
- package/lib/packages/data/weather/index2.js +1 -1
- package/lib/packages/data/weather/index3.js +1 -1
- package/lib/packages/element-plus/array/index.js +1 -1
- package/lib/packages/element-plus/array/index2.js +1 -1
- package/lib/packages/element-plus/array/index3.js +1 -1
- package/lib/packages/element-plus/article/index.js +1 -1
- package/lib/packages/element-plus/article/index2.js +1 -1
- package/lib/packages/element-plus/article/index3.js +1 -1
- package/lib/packages/element-plus/captcha/index.js +1 -1
- package/lib/packages/element-plus/captcha/index2.js +1 -1
- package/lib/packages/element-plus/captcha/index3.js +1 -1
- package/lib/packages/element-plus/cascader/index.js +1 -1
- package/lib/packages/element-plus/cascader/index2.js +38 -20
- package/lib/packages/element-plus/cascader/index3.js +3 -4
- package/lib/packages/element-plus/chat/index.js +1 -1
- package/lib/packages/element-plus/chat/index2.js +1 -1
- package/lib/packages/element-plus/chat/index3.js +1 -1
- package/lib/packages/element-plus/checkbox/index.js +1 -1
- package/lib/packages/element-plus/checkbox/index2.js +27 -11
- package/lib/packages/element-plus/checkbox/index3.js +1 -1
- package/lib/packages/element-plus/comment/index.js +1 -1
- package/lib/packages/element-plus/comment/index2.js +1 -1
- package/lib/packages/element-plus/comment/index3.js +1 -1
- package/lib/packages/element-plus/count-up/index.js +1 -1
- package/lib/packages/element-plus/count-up/index2.js +1 -1
- package/lib/packages/element-plus/count-up/index3.js +1 -1
- package/lib/packages/element-plus/crud/column/column-default.js +1 -1
- package/lib/packages/element-plus/crud/column/column-default2.js +1 -1
- package/lib/packages/element-plus/crud/column/column-default3.js +1 -1
- package/lib/packages/element-plus/crud/column/column-dynamic.js +1 -1
- package/lib/packages/element-plus/crud/column/column-dynamic2.js +1 -1
- package/lib/packages/element-plus/crud/column/column-dynamic3.js +1 -1
- package/lib/packages/element-plus/crud/column/column-menu.js +1 -1
- package/lib/packages/element-plus/crud/column/column-menu2.js +1 -1
- package/lib/packages/element-plus/crud/column/column-menu3.js +1 -1
- package/lib/packages/element-plus/crud/column/column-slot.js +1 -1
- package/lib/packages/element-plus/crud/column/column-slot2.js +1 -1
- package/lib/packages/element-plus/crud/column/column-slot3.js +1 -1
- package/lib/packages/element-plus/crud/column/column.js +1 -1
- package/lib/packages/element-plus/crud/column/column2.js +1 -1
- package/lib/packages/element-plus/crud/column/column3.js +1 -1
- package/lib/packages/element-plus/crud/column/menu.js +1 -1
- package/lib/packages/element-plus/crud/column/menu2.js +1 -1
- package/lib/packages/element-plus/crud/column/menu3.js +1 -1
- package/lib/packages/element-plus/crud/config.js +6 -1
- package/lib/packages/element-plus/crud/dialog/dialog-column.js +1 -1
- package/lib/packages/element-plus/crud/dialog/dialog-column2.js +1 -1
- package/lib/packages/element-plus/crud/dialog/dialog-column3.js +1 -1
- package/lib/packages/element-plus/crud/dialog/dialog-excel.js +1 -1
- package/lib/packages/element-plus/crud/dialog/dialog-excel2.js +9 -10
- package/lib/packages/element-plus/crud/dialog/dialog-excel3.js +1 -1
- package/lib/packages/element-plus/crud/dialog/dialog-filter.js +1 -1
- package/lib/packages/element-plus/crud/dialog/dialog-filter2.js +1 -1
- package/lib/packages/element-plus/crud/dialog/dialog-filter3.js +1 -1
- package/lib/packages/element-plus/crud/dialog/dialog-form.js +1 -1
- package/lib/packages/element-plus/crud/dialog/dialog-form2.js +14 -10
- package/lib/packages/element-plus/crud/dialog/dialog-form3.js +6 -6
- package/lib/packages/element-plus/crud/dialog/dialog-import.js +12 -0
- package/lib/packages/element-plus/crud/dialog/dialog-import2.js +316 -0
- package/lib/packages/element-plus/crud/dialog/dialog-import3.js +318 -0
- package/lib/packages/element-plus/crud/grid/index.js +1 -1
- package/lib/packages/element-plus/crud/grid/index2.js +1 -1
- package/lib/packages/element-plus/crud/grid/index3.js +1 -1
- package/lib/packages/element-plus/crud/grid/item.js +1 -1
- package/lib/packages/element-plus/crud/grid/item2.js +1 -1
- package/lib/packages/element-plus/crud/grid/item3.js +1 -1
- package/lib/packages/element-plus/crud/index.js +1 -1
- package/lib/packages/element-plus/crud/index2.js +50 -12
- package/lib/packages/element-plus/crud/index3.js +9 -2
- package/lib/packages/element-plus/crud/menu/header-menu.js +1 -1
- package/lib/packages/element-plus/crud/menu/header-menu2.js +18 -4
- package/lib/packages/element-plus/crud/menu/header-menu3.js +35 -9
- package/lib/packages/element-plus/crud/menu/header-search.js +1 -1
- package/lib/packages/element-plus/crud/menu/header-search2.js +1 -1
- package/lib/packages/element-plus/crud/menu/header-search3.js +1 -1
- package/lib/packages/element-plus/crud/menu/query-views.js +12 -0
- package/lib/packages/element-plus/crud/menu/query-views2.js +28 -0
- package/lib/packages/element-plus/crud/menu/query-views3.js +158 -0
- package/lib/packages/element-plus/crud/menu/table-page.js +1 -1
- package/lib/packages/element-plus/crud/menu/table-page2.js +1 -1
- package/lib/packages/element-plus/crud/menu/table-page3.js +1 -1
- package/lib/packages/element-plus/crud/query-view.js +368 -0
- package/lib/packages/element-plus/date/index.js +1 -1
- package/lib/packages/element-plus/date/index2.js +1 -1
- package/lib/packages/element-plus/date/index3.js +1 -1
- package/lib/packages/element-plus/draggable/index.js +1 -1
- package/lib/packages/element-plus/draggable/index2.js +1 -1
- package/lib/packages/element-plus/draggable/index3.js +1 -1
- package/lib/packages/element-plus/dynamic/index.js +1 -1
- package/lib/packages/element-plus/dynamic/index2.js +50 -7
- package/lib/packages/element-plus/dynamic/index3.js +6 -6
- package/lib/packages/element-plus/file-manager/index.js +1 -1
- package/lib/packages/element-plus/file-manager/index2.js +56 -9
- package/lib/packages/element-plus/file-manager/index3.js +1 -1
- package/lib/packages/element-plus/filter-builder/index.js +1 -1
- package/lib/packages/element-plus/filter-builder/index2.js +1 -1
- package/lib/packages/element-plus/filter-builder/index3.js +1 -1
- package/lib/packages/element-plus/flow/index.js +1 -1
- package/lib/packages/element-plus/flow/index2.js +1 -1
- package/lib/packages/element-plus/flow/index3.js +1 -1
- package/lib/packages/element-plus/flow/node.js +1 -1
- package/lib/packages/element-plus/flow/node2.js +1 -1
- package/lib/packages/element-plus/flow/node3.js +1 -1
- package/lib/packages/element-plus/form/config.js +1 -1
- package/lib/packages/element-plus/form/index.js +1 -1
- package/lib/packages/element-plus/form/index2.js +313 -223
- package/lib/packages/element-plus/form/index3.js +4 -4
- package/lib/packages/element-plus/form/menu.js +1 -1
- package/lib/packages/element-plus/form/menu2.js +1 -1
- package/lib/packages/element-plus/form/menu3.js +1 -1
- package/lib/packages/element-plus/group/index.js +1 -1
- package/lib/packages/element-plus/group/index2.js +1 -1
- package/lib/packages/element-plus/group/index3.js +1 -1
- package/lib/packages/element-plus/iframe/index.js +1 -1
- package/lib/packages/element-plus/iframe/index2.js +1 -1
- package/lib/packages/element-plus/iframe/index3.js +1 -1
- package/lib/packages/element-plus/input/index.js +1 -1
- package/lib/packages/element-plus/input/index2.js +1 -1
- package/lib/packages/element-plus/input/index3.js +1 -1
- package/lib/packages/element-plus/input-color/index.js +1 -1
- package/lib/packages/element-plus/input-color/index2.js +1 -1
- package/lib/packages/element-plus/input-color/index3.js +1 -1
- package/lib/packages/element-plus/input-cron/index.js +1 -1
- package/lib/packages/element-plus/input-cron/index2.js +1 -1
- package/lib/packages/element-plus/input-cron/index3.js +1 -1
- package/lib/packages/element-plus/input-icon/index.js +1 -1
- package/lib/packages/element-plus/input-icon/index2.js +1 -1
- package/lib/packages/element-plus/input-icon/index3.js +1 -1
- package/lib/packages/element-plus/input-map/index.js +1 -1
- package/lib/packages/element-plus/input-map/index2.js +93 -28
- package/lib/packages/element-plus/input-map/index3.js +11 -9
- package/lib/packages/element-plus/input-number/index.js +1 -1
- package/lib/packages/element-plus/input-number/index2.js +1 -1
- package/lib/packages/element-plus/input-number/index3.js +1 -1
- package/lib/packages/element-plus/input-otp/index.js +1 -1
- package/lib/packages/element-plus/input-otp/index2.js +2 -2
- package/lib/packages/element-plus/input-otp/index3.js +1 -1
- package/lib/packages/element-plus/input-table/index.js +1 -1
- package/lib/packages/element-plus/input-table/index2.js +100 -38
- package/lib/packages/element-plus/input-table/index3.js +1 -1
- package/lib/packages/element-plus/input-tag/index.js +1 -1
- package/lib/packages/element-plus/input-tag/index2.js +1 -10
- package/lib/packages/element-plus/input-tag/index3.js +2 -3
- package/lib/packages/element-plus/input-tree/index.js +1 -1
- package/lib/packages/element-plus/input-tree/index2.js +41 -39
- package/lib/packages/element-plus/input-tree/index3.js +1 -1
- package/lib/packages/element-plus/license/index.js +1 -1
- package/lib/packages/element-plus/license/index2.js +1 -1
- package/lib/packages/element-plus/license/index3.js +1 -1
- package/lib/packages/element-plus/login/index.js +1 -1
- package/lib/packages/element-plus/login/index2.js +31 -9
- package/lib/packages/element-plus/login/index3.js +1 -1
- package/lib/packages/element-plus/mention/index.js +1 -1
- package/lib/packages/element-plus/mention/index2.js +1 -1
- package/lib/packages/element-plus/mention/index3.js +1 -1
- package/lib/packages/element-plus/qrcode/index.js +1 -1
- package/lib/packages/element-plus/qrcode/index2.js +1 -1
- package/lib/packages/element-plus/qrcode/index3.js +1 -1
- package/lib/packages/element-plus/radio/index.js +1 -1
- package/lib/packages/element-plus/radio/index2.js +1 -1
- package/lib/packages/element-plus/radio/index3.js +1 -1
- package/lib/packages/element-plus/rate/index.js +1 -1
- package/lib/packages/element-plus/rate/index2.js +1 -1
- package/lib/packages/element-plus/rate/index3.js +1 -1
- package/lib/packages/element-plus/search/index.js +1 -1
- package/lib/packages/element-plus/search/index2.js +1 -1
- package/lib/packages/element-plus/search/index3.js +1 -1
- package/lib/packages/element-plus/select/index.js +1 -1
- package/lib/packages/element-plus/select/index2.js +55 -21
- package/lib/packages/element-plus/select/index3.js +54 -55
- package/lib/packages/element-plus/sign/index.js +1 -1
- package/lib/packages/element-plus/sign/index2.js +1 -1
- package/lib/packages/element-plus/sign/index3.js +1 -1
- package/lib/packages/element-plus/slider/index.js +1 -1
- package/lib/packages/element-plus/slider/index2.js +1 -1
- package/lib/packages/element-plus/slider/index3.js +1 -1
- package/lib/packages/element-plus/switch/index.js +1 -1
- package/lib/packages/element-plus/switch/index2.js +1 -1
- package/lib/packages/element-plus/switch/index3.js +1 -1
- package/lib/packages/element-plus/tabs/index.js +1 -1
- package/lib/packages/element-plus/tabs/index2.js +1 -1
- package/lib/packages/element-plus/tabs/index3.js +1 -1
- package/lib/packages/element-plus/text-ellipsis/index.js +1 -1
- package/lib/packages/element-plus/text-ellipsis/index2.js +1 -1
- package/lib/packages/element-plus/text-ellipsis/index3.js +1 -1
- package/lib/packages/element-plus/time/index.js +1 -1
- package/lib/packages/element-plus/time/index2.js +1 -1
- package/lib/packages/element-plus/time/index3.js +1 -1
- package/lib/packages/element-plus/title/index.js +1 -1
- package/lib/packages/element-plus/title/index2.js +1 -1
- package/lib/packages/element-plus/title/index3.js +1 -1
- package/lib/packages/element-plus/tree/index.js +1 -1
- package/lib/packages/element-plus/tree/index2.js +1 -1
- package/lib/packages/element-plus/tree/index3.js +1 -1
- package/lib/packages/element-plus/upload/index.js +1 -1
- package/lib/packages/element-plus/upload/index2.js +160 -53
- package/lib/packages/element-plus/upload/index3.js +1 -1
- package/lib/packages/element-plus/video/index.js +1 -1
- package/lib/packages/element-plus/video/index2.js +1 -1
- package/lib/packages/element-plus/video/index3.js +1 -1
- package/lib/src/core/column-state.js +16 -7
- package/lib/src/core/create.js +1 -1
- package/lib/src/core/crud-import.js +321 -0
- package/lib/src/core/crud-validation.js +89 -0
- package/lib/src/core/dataformat.js +5 -5
- package/lib/src/core/detail.js +2 -4
- package/lib/src/core/dic.js +51 -33
- package/lib/src/core/locale.js +1 -1
- package/lib/src/core/model.js +32 -0
- package/lib/src/core/option.js +5 -5
- package/lib/src/core/packages.js +1 -1
- package/lib/src/core/query-view.js +320 -0
- package/lib/src/core/slot.js +1 -1
- package/lib/src/core/viewport.js +53 -0
- package/lib/src/global/variable.js +1 -1
- package/lib/src/icon.js +1 -1
- package/lib/src/index.js +4 -3
- package/lib/src/locale/index.js +1 -1
- package/lib/src/locale/lang/en.js +8 -1
- package/lib/src/locale/lang/zh-cn.js +8 -1
- package/lib/src/locale/lang/zh.js +8 -1
- package/lib/src/locale/messages/crud-import.js +79 -0
- package/lib/src/locale/messages/print-preview.js +69 -0
- package/lib/src/locale/messages/query-view.js +42 -0
- package/lib/src/plugin/ali/index.js +1 -1
- package/lib/src/plugin/clipboard/index.js +1 -1
- package/lib/src/plugin/export/_blob.js +1 -1
- package/lib/src/plugin/export/_export2Excel.js +1 -1
- package/lib/src/plugin/export/index.js +1 -1
- package/lib/src/plugin/logs/index.js +1 -1
- package/lib/src/plugin/print/index.js +279 -172
- package/lib/src/plugin/print/preview.js +76 -0
- package/lib/src/plugin/qiniu/index.js +1 -1
- package/lib/src/plugin/screenshot/index.js +1 -1
- package/lib/src/plugin/video/index.js +1 -1
- package/lib/src/plugin/watermark/index.js +1 -1
- package/lib/src/plugin/watermark/watermark.js +1 -1
- package/lib/src/ui/data/index.js +1 -1
- package/lib/src/ui/element-plus/index.js +1 -1
- package/lib/src/ui/index.js +1 -1
- package/lib/src/utils/bem.js +1 -1
- package/lib/src/utils/load-script.js +104 -0
- package/lib/src/utils/mock.js +1 -1
- package/lib/src/utils/print.js +86 -18
- package/lib/src/utils/util.js +8 -38
- package/lib/src/utils/validate.js +1 -1
- package/lib/src/version.js +2 -2
- package/package.json +2 -1
- package/types/index.d.ts +108 -4
package/es/node_modules/.pnpm/async-validator@4.2.5/node_modules/async-validator/dist-web/index.mjs
ADDED
|
@@ -0,0 +1,1329 @@
|
|
|
1
|
+
/*! Tvue.js v3.9.8 | (c) 2024-2026 MORISHIMA | Released under the MIT License. */
|
|
2
|
+
function _extends() {
|
|
3
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
4
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
5
|
+
var source = arguments[i];
|
|
6
|
+
|
|
7
|
+
for (var key in source) {
|
|
8
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
9
|
+
target[key] = source[key];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
return _extends.apply(this, arguments);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function _inheritsLoose(subClass, superClass) {
|
|
20
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
21
|
+
subClass.prototype.constructor = subClass;
|
|
22
|
+
|
|
23
|
+
_setPrototypeOf(subClass, superClass);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function _getPrototypeOf(o) {
|
|
27
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
28
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
29
|
+
};
|
|
30
|
+
return _getPrototypeOf(o);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _setPrototypeOf(o, p) {
|
|
34
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
35
|
+
o.__proto__ = p;
|
|
36
|
+
return o;
|
|
37
|
+
};
|
|
38
|
+
return _setPrototypeOf(o, p);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _isNativeReflectConstruct() {
|
|
42
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
43
|
+
if (Reflect.construct.sham) return false;
|
|
44
|
+
if (typeof Proxy === "function") return true;
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
48
|
+
return true;
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function _construct(Parent, args, Class) {
|
|
55
|
+
if (_isNativeReflectConstruct()) {
|
|
56
|
+
_construct = Reflect.construct.bind();
|
|
57
|
+
} else {
|
|
58
|
+
_construct = function _construct(Parent, args, Class) {
|
|
59
|
+
var a = [null];
|
|
60
|
+
a.push.apply(a, args);
|
|
61
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
62
|
+
var instance = new Constructor();
|
|
63
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
64
|
+
return instance;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return _construct.apply(null, arguments);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function _isNativeFunction(fn) {
|
|
72
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function _wrapNativeSuper(Class) {
|
|
76
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
77
|
+
|
|
78
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
79
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
80
|
+
|
|
81
|
+
if (typeof Class !== "function") {
|
|
82
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (typeof _cache !== "undefined") {
|
|
86
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
87
|
+
|
|
88
|
+
_cache.set(Class, Wrapper);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function Wrapper() {
|
|
92
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
96
|
+
constructor: {
|
|
97
|
+
value: Wrapper,
|
|
98
|
+
enumerable: false,
|
|
99
|
+
writable: true,
|
|
100
|
+
configurable: true
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return _wrapNativeSuper(Class);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* eslint no-console:0 */
|
|
110
|
+
var formatRegExp = /%[sdj%]/g;
|
|
111
|
+
var warning = function warning() {}; // don't print warning message when in production env or node runtime
|
|
112
|
+
|
|
113
|
+
if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV !== 'production' && typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
114
|
+
warning = function warning(type, errors) {
|
|
115
|
+
if (typeof console !== 'undefined' && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING === 'undefined') {
|
|
116
|
+
if (errors.every(function (e) {
|
|
117
|
+
return typeof e === 'string';
|
|
118
|
+
})) {
|
|
119
|
+
console.warn(type, errors);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function convertFieldsError(errors) {
|
|
126
|
+
if (!errors || !errors.length) return null;
|
|
127
|
+
var fields = {};
|
|
128
|
+
errors.forEach(function (error) {
|
|
129
|
+
var field = error.field;
|
|
130
|
+
fields[field] = fields[field] || [];
|
|
131
|
+
fields[field].push(error);
|
|
132
|
+
});
|
|
133
|
+
return fields;
|
|
134
|
+
}
|
|
135
|
+
function format(template) {
|
|
136
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
137
|
+
args[_key - 1] = arguments[_key];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
var i = 0;
|
|
141
|
+
var len = args.length;
|
|
142
|
+
|
|
143
|
+
if (typeof template === 'function') {
|
|
144
|
+
return template.apply(null, args);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (typeof template === 'string') {
|
|
148
|
+
var str = template.replace(formatRegExp, function (x) {
|
|
149
|
+
if (x === '%%') {
|
|
150
|
+
return '%';
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (i >= len) {
|
|
154
|
+
return x;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
switch (x) {
|
|
158
|
+
case '%s':
|
|
159
|
+
return String(args[i++]);
|
|
160
|
+
|
|
161
|
+
case '%d':
|
|
162
|
+
return Number(args[i++]);
|
|
163
|
+
|
|
164
|
+
case '%j':
|
|
165
|
+
try {
|
|
166
|
+
return JSON.stringify(args[i++]);
|
|
167
|
+
} catch (_) {
|
|
168
|
+
return '[Circular]';
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
break;
|
|
172
|
+
|
|
173
|
+
default:
|
|
174
|
+
return x;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
return str;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return template;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function isNativeStringType(type) {
|
|
184
|
+
return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'date' || type === 'pattern';
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function isEmptyValue(value, type) {
|
|
188
|
+
if (value === undefined || value === null) {
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (type === 'array' && Array.isArray(value) && !value.length) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (isNativeStringType(type) && typeof value === 'string' && !value) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function asyncParallelArray(arr, func, callback) {
|
|
204
|
+
var results = [];
|
|
205
|
+
var total = 0;
|
|
206
|
+
var arrLength = arr.length;
|
|
207
|
+
|
|
208
|
+
function count(errors) {
|
|
209
|
+
results.push.apply(results, errors || []);
|
|
210
|
+
total++;
|
|
211
|
+
|
|
212
|
+
if (total === arrLength) {
|
|
213
|
+
callback(results);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
arr.forEach(function (a) {
|
|
218
|
+
func(a, count);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function asyncSerialArray(arr, func, callback) {
|
|
223
|
+
var index = 0;
|
|
224
|
+
var arrLength = arr.length;
|
|
225
|
+
|
|
226
|
+
function next(errors) {
|
|
227
|
+
if (errors && errors.length) {
|
|
228
|
+
callback(errors);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
var original = index;
|
|
233
|
+
index = index + 1;
|
|
234
|
+
|
|
235
|
+
if (original < arrLength) {
|
|
236
|
+
func(arr[original], next);
|
|
237
|
+
} else {
|
|
238
|
+
callback([]);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
next([]);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function flattenObjArr(objArr) {
|
|
246
|
+
var ret = [];
|
|
247
|
+
Object.keys(objArr).forEach(function (k) {
|
|
248
|
+
ret.push.apply(ret, objArr[k] || []);
|
|
249
|
+
});
|
|
250
|
+
return ret;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
var AsyncValidationError = /*#__PURE__*/function (_Error) {
|
|
254
|
+
_inheritsLoose(AsyncValidationError, _Error);
|
|
255
|
+
|
|
256
|
+
function AsyncValidationError(errors, fields) {
|
|
257
|
+
var _this;
|
|
258
|
+
|
|
259
|
+
_this = _Error.call(this, 'Async Validation Error') || this;
|
|
260
|
+
_this.errors = errors;
|
|
261
|
+
_this.fields = fields;
|
|
262
|
+
return _this;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return AsyncValidationError;
|
|
266
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
267
|
+
function asyncMap(objArr, option, func, callback, source) {
|
|
268
|
+
if (option.first) {
|
|
269
|
+
var _pending = new Promise(function (resolve, reject) {
|
|
270
|
+
var next = function next(errors) {
|
|
271
|
+
callback(errors);
|
|
272
|
+
return errors.length ? reject(new AsyncValidationError(errors, convertFieldsError(errors))) : resolve(source);
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
var flattenArr = flattenObjArr(objArr);
|
|
276
|
+
asyncSerialArray(flattenArr, func, next);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
_pending["catch"](function (e) {
|
|
280
|
+
return e;
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
return _pending;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
var firstFields = option.firstFields === true ? Object.keys(objArr) : option.firstFields || [];
|
|
287
|
+
var objArrKeys = Object.keys(objArr);
|
|
288
|
+
var objArrLength = objArrKeys.length;
|
|
289
|
+
var total = 0;
|
|
290
|
+
var results = [];
|
|
291
|
+
var pending = new Promise(function (resolve, reject) {
|
|
292
|
+
var next = function next(errors) {
|
|
293
|
+
results.push.apply(results, errors);
|
|
294
|
+
total++;
|
|
295
|
+
|
|
296
|
+
if (total === objArrLength) {
|
|
297
|
+
callback(results);
|
|
298
|
+
return results.length ? reject(new AsyncValidationError(results, convertFieldsError(results))) : resolve(source);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
if (!objArrKeys.length) {
|
|
303
|
+
callback(results);
|
|
304
|
+
resolve(source);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
objArrKeys.forEach(function (key) {
|
|
308
|
+
var arr = objArr[key];
|
|
309
|
+
|
|
310
|
+
if (firstFields.indexOf(key) !== -1) {
|
|
311
|
+
asyncSerialArray(arr, func, next);
|
|
312
|
+
} else {
|
|
313
|
+
asyncParallelArray(arr, func, next);
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
pending["catch"](function (e) {
|
|
318
|
+
return e;
|
|
319
|
+
});
|
|
320
|
+
return pending;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function isErrorObj(obj) {
|
|
324
|
+
return !!(obj && obj.message !== undefined);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function getValue(value, path) {
|
|
328
|
+
var v = value;
|
|
329
|
+
|
|
330
|
+
for (var i = 0; i < path.length; i++) {
|
|
331
|
+
if (v == undefined) {
|
|
332
|
+
return v;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
v = v[path[i]];
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return v;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function complementError(rule, source) {
|
|
342
|
+
return function (oe) {
|
|
343
|
+
var fieldValue;
|
|
344
|
+
|
|
345
|
+
if (rule.fullFields) {
|
|
346
|
+
fieldValue = getValue(source, rule.fullFields);
|
|
347
|
+
} else {
|
|
348
|
+
fieldValue = source[oe.field || rule.fullField];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (isErrorObj(oe)) {
|
|
352
|
+
oe.field = oe.field || rule.fullField;
|
|
353
|
+
oe.fieldValue = fieldValue;
|
|
354
|
+
return oe;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return {
|
|
358
|
+
message: typeof oe === 'function' ? oe() : oe,
|
|
359
|
+
fieldValue: fieldValue,
|
|
360
|
+
field: oe.field || rule.fullField
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
function deepMerge(target, source) {
|
|
365
|
+
if (source) {
|
|
366
|
+
for (var s in source) {
|
|
367
|
+
if (source.hasOwnProperty(s)) {
|
|
368
|
+
var value = source[s];
|
|
369
|
+
|
|
370
|
+
if (typeof value === 'object' && typeof target[s] === 'object') {
|
|
371
|
+
target[s] = _extends({}, target[s], value);
|
|
372
|
+
} else {
|
|
373
|
+
target[s] = value;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return target;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
var required$1 = function required(rule, value, source, errors, options, type) {
|
|
383
|
+
if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type || rule.type))) {
|
|
384
|
+
errors.push(format(options.messages.required, rule.fullField));
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Rule for validating whitespace.
|
|
390
|
+
*
|
|
391
|
+
* @param rule The validation rule.
|
|
392
|
+
* @param value The value of the field on the source object.
|
|
393
|
+
* @param source The source object being validated.
|
|
394
|
+
* @param errors An array of errors that this rule may add
|
|
395
|
+
* validation errors to.
|
|
396
|
+
* @param options The validation options.
|
|
397
|
+
* @param options.messages The validation messages.
|
|
398
|
+
*/
|
|
399
|
+
|
|
400
|
+
var whitespace = function whitespace(rule, value, source, errors, options) {
|
|
401
|
+
if (/^\s+$/.test(value) || value === '') {
|
|
402
|
+
errors.push(format(options.messages.whitespace, rule.fullField));
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
// https://github.com/kevva/url-regex/blob/master/index.js
|
|
407
|
+
var urlReg;
|
|
408
|
+
var getUrlRegex = (function () {
|
|
409
|
+
if (urlReg) {
|
|
410
|
+
return urlReg;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
var word = '[a-fA-F\\d:]';
|
|
414
|
+
|
|
415
|
+
var b = function b(options) {
|
|
416
|
+
return options && options.includeBoundaries ? "(?:(?<=\\s|^)(?=" + word + ")|(?<=" + word + ")(?=\\s|$))" : '';
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
var v4 = '(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}';
|
|
420
|
+
var v6seg = '[a-fA-F\\d]{1,4}';
|
|
421
|
+
var v6 = ("\n(?:\n(?:" + v6seg + ":){7}(?:" + v6seg + "|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:" + v6seg + ":){6}(?:" + v4 + "|:" + v6seg + "|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:" + v6seg + ":){5}(?::" + v4 + "|(?::" + v6seg + "){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:" + v6seg + ":){4}(?:(?::" + v6seg + "){0,1}:" + v4 + "|(?::" + v6seg + "){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:" + v6seg + ":){3}(?:(?::" + v6seg + "){0,2}:" + v4 + "|(?::" + v6seg + "){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:" + v6seg + ":){2}(?:(?::" + v6seg + "){0,3}:" + v4 + "|(?::" + v6seg + "){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:" + v6seg + ":){1}(?:(?::" + v6seg + "){0,4}:" + v4 + "|(?::" + v6seg + "){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::" + v6seg + "){0,5}:" + v4 + "|(?::" + v6seg + "){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n").replace(/\s*\/\/.*$/gm, '').replace(/\n/g, '').trim(); // Pre-compile only the exact regexes because adding a global flag make regexes stateful
|
|
422
|
+
|
|
423
|
+
var v46Exact = new RegExp("(?:^" + v4 + "$)|(?:^" + v6 + "$)");
|
|
424
|
+
var v4exact = new RegExp("^" + v4 + "$");
|
|
425
|
+
var v6exact = new RegExp("^" + v6 + "$");
|
|
426
|
+
|
|
427
|
+
var ip = function ip(options) {
|
|
428
|
+
return options && options.exact ? v46Exact : new RegExp("(?:" + b(options) + v4 + b(options) + ")|(?:" + b(options) + v6 + b(options) + ")", 'g');
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
ip.v4 = function (options) {
|
|
432
|
+
return options && options.exact ? v4exact : new RegExp("" + b(options) + v4 + b(options), 'g');
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
ip.v6 = function (options) {
|
|
436
|
+
return options && options.exact ? v6exact : new RegExp("" + b(options) + v6 + b(options), 'g');
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
var protocol = "(?:(?:[a-z]+:)?//)";
|
|
440
|
+
var auth = '(?:\\S+(?::\\S*)?@)?';
|
|
441
|
+
var ipv4 = ip.v4().source;
|
|
442
|
+
var ipv6 = ip.v6().source;
|
|
443
|
+
var host = "(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)";
|
|
444
|
+
var domain = "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*";
|
|
445
|
+
var tld = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";
|
|
446
|
+
var port = '(?::\\d{2,5})?';
|
|
447
|
+
var path = '(?:[/?#][^\\s"]*)?';
|
|
448
|
+
var regex = "(?:" + protocol + "|www\\.)" + auth + "(?:localhost|" + ipv4 + "|" + ipv6 + "|" + host + domain + tld + ")" + port + path;
|
|
449
|
+
urlReg = new RegExp("(?:^" + regex + "$)", 'i');
|
|
450
|
+
return urlReg;
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
/* eslint max-len:0 */
|
|
454
|
+
|
|
455
|
+
var pattern$2 = {
|
|
456
|
+
// http://emailregex.com/
|
|
457
|
+
email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
|
|
458
|
+
// url: new RegExp(
|
|
459
|
+
// '^(?!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]*)?$',
|
|
460
|
+
// 'i',
|
|
461
|
+
// ),
|
|
462
|
+
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
|
|
463
|
+
};
|
|
464
|
+
var types = {
|
|
465
|
+
integer: function integer(value) {
|
|
466
|
+
return types.number(value) && parseInt(value, 10) === value;
|
|
467
|
+
},
|
|
468
|
+
"float": function float(value) {
|
|
469
|
+
return types.number(value) && !types.integer(value);
|
|
470
|
+
},
|
|
471
|
+
array: function array(value) {
|
|
472
|
+
return Array.isArray(value);
|
|
473
|
+
},
|
|
474
|
+
regexp: function regexp(value) {
|
|
475
|
+
if (value instanceof RegExp) {
|
|
476
|
+
return true;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
try {
|
|
480
|
+
return !!new RegExp(value);
|
|
481
|
+
} catch (e) {
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
date: function date(value) {
|
|
486
|
+
return typeof value.getTime === 'function' && typeof value.getMonth === 'function' && typeof value.getYear === 'function' && !isNaN(value.getTime());
|
|
487
|
+
},
|
|
488
|
+
number: function number(value) {
|
|
489
|
+
if (isNaN(value)) {
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
return typeof value === 'number';
|
|
494
|
+
},
|
|
495
|
+
object: function object(value) {
|
|
496
|
+
return typeof value === 'object' && !types.array(value);
|
|
497
|
+
},
|
|
498
|
+
method: function method(value) {
|
|
499
|
+
return typeof value === 'function';
|
|
500
|
+
},
|
|
501
|
+
email: function email(value) {
|
|
502
|
+
return typeof value === 'string' && value.length <= 320 && !!value.match(pattern$2.email);
|
|
503
|
+
},
|
|
504
|
+
url: function url(value) {
|
|
505
|
+
return typeof value === 'string' && value.length <= 2048 && !!value.match(getUrlRegex());
|
|
506
|
+
},
|
|
507
|
+
hex: function hex(value) {
|
|
508
|
+
return typeof value === 'string' && !!value.match(pattern$2.hex);
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
var type$1 = function type(rule, value, source, errors, options) {
|
|
513
|
+
if (rule.required && value === undefined) {
|
|
514
|
+
required$1(rule, value, source, errors, options);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex'];
|
|
519
|
+
var ruleType = rule.type;
|
|
520
|
+
|
|
521
|
+
if (custom.indexOf(ruleType) > -1) {
|
|
522
|
+
if (!types[ruleType](value)) {
|
|
523
|
+
errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
|
|
524
|
+
} // straight typeof check
|
|
525
|
+
|
|
526
|
+
} else if (ruleType && typeof value !== rule.type) {
|
|
527
|
+
errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
var range = function range(rule, value, source, errors, options) {
|
|
532
|
+
var len = typeof rule.len === 'number';
|
|
533
|
+
var min = typeof rule.min === 'number';
|
|
534
|
+
var max = typeof rule.max === 'number'; // 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane)
|
|
535
|
+
|
|
536
|
+
var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
537
|
+
var val = value;
|
|
538
|
+
var key = null;
|
|
539
|
+
var num = typeof value === 'number';
|
|
540
|
+
var str = typeof value === 'string';
|
|
541
|
+
var arr = Array.isArray(value);
|
|
542
|
+
|
|
543
|
+
if (num) {
|
|
544
|
+
key = 'number';
|
|
545
|
+
} else if (str) {
|
|
546
|
+
key = 'string';
|
|
547
|
+
} else if (arr) {
|
|
548
|
+
key = 'array';
|
|
549
|
+
} // if the value is not of a supported type for range validation
|
|
550
|
+
// the validation rule rule should use the
|
|
551
|
+
// type property to also test for a particular type
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
if (!key) {
|
|
555
|
+
return false;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
if (arr) {
|
|
559
|
+
val = value.length;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
if (str) {
|
|
563
|
+
// 处理码点大于U+010000的文字length属性不准确的bug,如"𠮷𠮷𠮷".lenght !== 3
|
|
564
|
+
val = value.replace(spRegexp, '_').length;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (len) {
|
|
568
|
+
if (val !== rule.len) {
|
|
569
|
+
errors.push(format(options.messages[key].len, rule.fullField, rule.len));
|
|
570
|
+
}
|
|
571
|
+
} else if (min && !max && val < rule.min) {
|
|
572
|
+
errors.push(format(options.messages[key].min, rule.fullField, rule.min));
|
|
573
|
+
} else if (max && !min && val > rule.max) {
|
|
574
|
+
errors.push(format(options.messages[key].max, rule.fullField, rule.max));
|
|
575
|
+
} else if (min && max && (val < rule.min || val > rule.max)) {
|
|
576
|
+
errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max));
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
var ENUM$1 = 'enum';
|
|
581
|
+
|
|
582
|
+
var enumerable$1 = function enumerable(rule, value, source, errors, options) {
|
|
583
|
+
rule[ENUM$1] = Array.isArray(rule[ENUM$1]) ? rule[ENUM$1] : [];
|
|
584
|
+
|
|
585
|
+
if (rule[ENUM$1].indexOf(value) === -1) {
|
|
586
|
+
errors.push(format(options.messages[ENUM$1], rule.fullField, rule[ENUM$1].join(', ')));
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
var pattern$1 = function pattern(rule, value, source, errors, options) {
|
|
591
|
+
if (rule.pattern) {
|
|
592
|
+
if (rule.pattern instanceof RegExp) {
|
|
593
|
+
// if a RegExp instance is passed, reset `lastIndex` in case its `global`
|
|
594
|
+
// flag is accidentally set to `true`, which in a validation scenario
|
|
595
|
+
// is not necessary and the result might be misleading
|
|
596
|
+
rule.pattern.lastIndex = 0;
|
|
597
|
+
|
|
598
|
+
if (!rule.pattern.test(value)) {
|
|
599
|
+
errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
|
|
600
|
+
}
|
|
601
|
+
} else if (typeof rule.pattern === 'string') {
|
|
602
|
+
var _pattern = new RegExp(rule.pattern);
|
|
603
|
+
|
|
604
|
+
if (!_pattern.test(value)) {
|
|
605
|
+
errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
var rules = {
|
|
612
|
+
required: required$1,
|
|
613
|
+
whitespace: whitespace,
|
|
614
|
+
type: type$1,
|
|
615
|
+
range: range,
|
|
616
|
+
"enum": enumerable$1,
|
|
617
|
+
pattern: pattern$1
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
var string = function string(rule, value, callback, source, options) {
|
|
621
|
+
var errors = [];
|
|
622
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
623
|
+
|
|
624
|
+
if (validate) {
|
|
625
|
+
if (isEmptyValue(value, 'string') && !rule.required) {
|
|
626
|
+
return callback();
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
rules.required(rule, value, source, errors, options, 'string');
|
|
630
|
+
|
|
631
|
+
if (!isEmptyValue(value, 'string')) {
|
|
632
|
+
rules.type(rule, value, source, errors, options);
|
|
633
|
+
rules.range(rule, value, source, errors, options);
|
|
634
|
+
rules.pattern(rule, value, source, errors, options);
|
|
635
|
+
|
|
636
|
+
if (rule.whitespace === true) {
|
|
637
|
+
rules.whitespace(rule, value, source, errors, options);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
callback(errors);
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
var method = function method(rule, value, callback, source, options) {
|
|
646
|
+
var errors = [];
|
|
647
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
648
|
+
|
|
649
|
+
if (validate) {
|
|
650
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
651
|
+
return callback();
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
rules.required(rule, value, source, errors, options);
|
|
655
|
+
|
|
656
|
+
if (value !== undefined) {
|
|
657
|
+
rules.type(rule, value, source, errors, options);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
callback(errors);
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
var number = function number(rule, value, callback, source, options) {
|
|
665
|
+
var errors = [];
|
|
666
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
667
|
+
|
|
668
|
+
if (validate) {
|
|
669
|
+
if (value === '') {
|
|
670
|
+
value = undefined;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
674
|
+
return callback();
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
rules.required(rule, value, source, errors, options);
|
|
678
|
+
|
|
679
|
+
if (value !== undefined) {
|
|
680
|
+
rules.type(rule, value, source, errors, options);
|
|
681
|
+
rules.range(rule, value, source, errors, options);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
callback(errors);
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
var _boolean = function _boolean(rule, value, callback, source, options) {
|
|
689
|
+
var errors = [];
|
|
690
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
691
|
+
|
|
692
|
+
if (validate) {
|
|
693
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
694
|
+
return callback();
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
rules.required(rule, value, source, errors, options);
|
|
698
|
+
|
|
699
|
+
if (value !== undefined) {
|
|
700
|
+
rules.type(rule, value, source, errors, options);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
callback(errors);
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
var regexp = function regexp(rule, value, callback, source, options) {
|
|
708
|
+
var errors = [];
|
|
709
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
710
|
+
|
|
711
|
+
if (validate) {
|
|
712
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
713
|
+
return callback();
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
rules.required(rule, value, source, errors, options);
|
|
717
|
+
|
|
718
|
+
if (!isEmptyValue(value)) {
|
|
719
|
+
rules.type(rule, value, source, errors, options);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
callback(errors);
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
var integer = function integer(rule, value, callback, source, options) {
|
|
727
|
+
var errors = [];
|
|
728
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
729
|
+
|
|
730
|
+
if (validate) {
|
|
731
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
732
|
+
return callback();
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
rules.required(rule, value, source, errors, options);
|
|
736
|
+
|
|
737
|
+
if (value !== undefined) {
|
|
738
|
+
rules.type(rule, value, source, errors, options);
|
|
739
|
+
rules.range(rule, value, source, errors, options);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
callback(errors);
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
var floatFn = function floatFn(rule, value, callback, source, options) {
|
|
747
|
+
var errors = [];
|
|
748
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
749
|
+
|
|
750
|
+
if (validate) {
|
|
751
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
752
|
+
return callback();
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
rules.required(rule, value, source, errors, options);
|
|
756
|
+
|
|
757
|
+
if (value !== undefined) {
|
|
758
|
+
rules.type(rule, value, source, errors, options);
|
|
759
|
+
rules.range(rule, value, source, errors, options);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
callback(errors);
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
var array = function array(rule, value, callback, source, options) {
|
|
767
|
+
var errors = [];
|
|
768
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
769
|
+
|
|
770
|
+
if (validate) {
|
|
771
|
+
if ((value === undefined || value === null) && !rule.required) {
|
|
772
|
+
return callback();
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
rules.required(rule, value, source, errors, options, 'array');
|
|
776
|
+
|
|
777
|
+
if (value !== undefined && value !== null) {
|
|
778
|
+
rules.type(rule, value, source, errors, options);
|
|
779
|
+
rules.range(rule, value, source, errors, options);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
callback(errors);
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
var object = function object(rule, value, callback, source, options) {
|
|
787
|
+
var errors = [];
|
|
788
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
789
|
+
|
|
790
|
+
if (validate) {
|
|
791
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
792
|
+
return callback();
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
rules.required(rule, value, source, errors, options);
|
|
796
|
+
|
|
797
|
+
if (value !== undefined) {
|
|
798
|
+
rules.type(rule, value, source, errors, options);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
callback(errors);
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
var ENUM = 'enum';
|
|
806
|
+
|
|
807
|
+
var enumerable = function enumerable(rule, value, callback, source, options) {
|
|
808
|
+
var errors = [];
|
|
809
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
810
|
+
|
|
811
|
+
if (validate) {
|
|
812
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
813
|
+
return callback();
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
rules.required(rule, value, source, errors, options);
|
|
817
|
+
|
|
818
|
+
if (value !== undefined) {
|
|
819
|
+
rules[ENUM](rule, value, source, errors, options);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
callback(errors);
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
var pattern = function pattern(rule, value, callback, source, options) {
|
|
827
|
+
var errors = [];
|
|
828
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
829
|
+
|
|
830
|
+
if (validate) {
|
|
831
|
+
if (isEmptyValue(value, 'string') && !rule.required) {
|
|
832
|
+
return callback();
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
rules.required(rule, value, source, errors, options);
|
|
836
|
+
|
|
837
|
+
if (!isEmptyValue(value, 'string')) {
|
|
838
|
+
rules.pattern(rule, value, source, errors, options);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
callback(errors);
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
var date = function date(rule, value, callback, source, options) {
|
|
846
|
+
// console.log('integer rule called %j', rule);
|
|
847
|
+
var errors = [];
|
|
848
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); // console.log('validate on %s value', value);
|
|
849
|
+
|
|
850
|
+
if (validate) {
|
|
851
|
+
if (isEmptyValue(value, 'date') && !rule.required) {
|
|
852
|
+
return callback();
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
rules.required(rule, value, source, errors, options);
|
|
856
|
+
|
|
857
|
+
if (!isEmptyValue(value, 'date')) {
|
|
858
|
+
var dateObject;
|
|
859
|
+
|
|
860
|
+
if (value instanceof Date) {
|
|
861
|
+
dateObject = value;
|
|
862
|
+
} else {
|
|
863
|
+
dateObject = new Date(value);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
rules.type(rule, dateObject, source, errors, options);
|
|
867
|
+
|
|
868
|
+
if (dateObject) {
|
|
869
|
+
rules.range(rule, dateObject.getTime(), source, errors, options);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
callback(errors);
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
var required = function required(rule, value, callback, source, options) {
|
|
878
|
+
var errors = [];
|
|
879
|
+
var type = Array.isArray(value) ? 'array' : typeof value;
|
|
880
|
+
rules.required(rule, value, source, errors, options, type);
|
|
881
|
+
callback(errors);
|
|
882
|
+
};
|
|
883
|
+
|
|
884
|
+
var type = function type(rule, value, callback, source, options) {
|
|
885
|
+
var ruleType = rule.type;
|
|
886
|
+
var errors = [];
|
|
887
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
888
|
+
|
|
889
|
+
if (validate) {
|
|
890
|
+
if (isEmptyValue(value, ruleType) && !rule.required) {
|
|
891
|
+
return callback();
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
rules.required(rule, value, source, errors, options, ruleType);
|
|
895
|
+
|
|
896
|
+
if (!isEmptyValue(value, ruleType)) {
|
|
897
|
+
rules.type(rule, value, source, errors, options);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
callback(errors);
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
var any = function any(rule, value, callback, source, options) {
|
|
905
|
+
var errors = [];
|
|
906
|
+
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
|
|
907
|
+
|
|
908
|
+
if (validate) {
|
|
909
|
+
if (isEmptyValue(value) && !rule.required) {
|
|
910
|
+
return callback();
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
rules.required(rule, value, source, errors, options);
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
callback(errors);
|
|
917
|
+
};
|
|
918
|
+
|
|
919
|
+
var validators = {
|
|
920
|
+
string: string,
|
|
921
|
+
method: method,
|
|
922
|
+
number: number,
|
|
923
|
+
"boolean": _boolean,
|
|
924
|
+
regexp: regexp,
|
|
925
|
+
integer: integer,
|
|
926
|
+
"float": floatFn,
|
|
927
|
+
array: array,
|
|
928
|
+
object: object,
|
|
929
|
+
"enum": enumerable,
|
|
930
|
+
pattern: pattern,
|
|
931
|
+
date: date,
|
|
932
|
+
url: type,
|
|
933
|
+
hex: type,
|
|
934
|
+
email: type,
|
|
935
|
+
required: required,
|
|
936
|
+
any: any
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
function newMessages() {
|
|
940
|
+
return {
|
|
941
|
+
"default": 'Validation error on field %s',
|
|
942
|
+
required: '%s is required',
|
|
943
|
+
"enum": '%s must be one of %s',
|
|
944
|
+
whitespace: '%s cannot be empty',
|
|
945
|
+
date: {
|
|
946
|
+
format: '%s date %s is invalid for format %s',
|
|
947
|
+
parse: '%s date could not be parsed, %s is invalid ',
|
|
948
|
+
invalid: '%s date %s is invalid'
|
|
949
|
+
},
|
|
950
|
+
types: {
|
|
951
|
+
string: '%s is not a %s',
|
|
952
|
+
method: '%s is not a %s (function)',
|
|
953
|
+
array: '%s is not an %s',
|
|
954
|
+
object: '%s is not an %s',
|
|
955
|
+
number: '%s is not a %s',
|
|
956
|
+
date: '%s is not a %s',
|
|
957
|
+
"boolean": '%s is not a %s',
|
|
958
|
+
integer: '%s is not an %s',
|
|
959
|
+
"float": '%s is not a %s',
|
|
960
|
+
regexp: '%s is not a valid %s',
|
|
961
|
+
email: '%s is not a valid %s',
|
|
962
|
+
url: '%s is not a valid %s',
|
|
963
|
+
hex: '%s is not a valid %s'
|
|
964
|
+
},
|
|
965
|
+
string: {
|
|
966
|
+
len: '%s must be exactly %s characters',
|
|
967
|
+
min: '%s must be at least %s characters',
|
|
968
|
+
max: '%s cannot be longer than %s characters',
|
|
969
|
+
range: '%s must be between %s and %s characters'
|
|
970
|
+
},
|
|
971
|
+
number: {
|
|
972
|
+
len: '%s must equal %s',
|
|
973
|
+
min: '%s cannot be less than %s',
|
|
974
|
+
max: '%s cannot be greater than %s',
|
|
975
|
+
range: '%s must be between %s and %s'
|
|
976
|
+
},
|
|
977
|
+
array: {
|
|
978
|
+
len: '%s must be exactly %s in length',
|
|
979
|
+
min: '%s cannot be less than %s in length',
|
|
980
|
+
max: '%s cannot be greater than %s in length',
|
|
981
|
+
range: '%s must be between %s and %s in length'
|
|
982
|
+
},
|
|
983
|
+
pattern: {
|
|
984
|
+
mismatch: '%s value %s does not match pattern %s'
|
|
985
|
+
},
|
|
986
|
+
clone: function clone() {
|
|
987
|
+
var cloned = JSON.parse(JSON.stringify(this));
|
|
988
|
+
cloned.clone = this.clone;
|
|
989
|
+
return cloned;
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
var messages = newMessages();
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* Encapsulates a validation schema.
|
|
997
|
+
*
|
|
998
|
+
* @param descriptor An object declaring validation rules
|
|
999
|
+
* for this schema.
|
|
1000
|
+
*/
|
|
1001
|
+
|
|
1002
|
+
var Schema = /*#__PURE__*/function () {
|
|
1003
|
+
// ========================= Static =========================
|
|
1004
|
+
// ======================== Instance ========================
|
|
1005
|
+
function Schema(descriptor) {
|
|
1006
|
+
this.rules = null;
|
|
1007
|
+
this._messages = messages;
|
|
1008
|
+
this.define(descriptor);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
var _proto = Schema.prototype;
|
|
1012
|
+
|
|
1013
|
+
_proto.define = function define(rules) {
|
|
1014
|
+
var _this = this;
|
|
1015
|
+
|
|
1016
|
+
if (!rules) {
|
|
1017
|
+
throw new Error('Cannot configure a schema with no rules');
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
if (typeof rules !== 'object' || Array.isArray(rules)) {
|
|
1021
|
+
throw new Error('Rules must be an object');
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
this.rules = {};
|
|
1025
|
+
Object.keys(rules).forEach(function (name) {
|
|
1026
|
+
var item = rules[name];
|
|
1027
|
+
_this.rules[name] = Array.isArray(item) ? item : [item];
|
|
1028
|
+
});
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1031
|
+
_proto.messages = function messages(_messages) {
|
|
1032
|
+
if (_messages) {
|
|
1033
|
+
this._messages = deepMerge(newMessages(), _messages);
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
return this._messages;
|
|
1037
|
+
};
|
|
1038
|
+
|
|
1039
|
+
_proto.validate = function validate(source_, o, oc) {
|
|
1040
|
+
var _this2 = this;
|
|
1041
|
+
|
|
1042
|
+
if (o === void 0) {
|
|
1043
|
+
o = {};
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
if (oc === void 0) {
|
|
1047
|
+
oc = function oc() {};
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
var source = source_;
|
|
1051
|
+
var options = o;
|
|
1052
|
+
var callback = oc;
|
|
1053
|
+
|
|
1054
|
+
if (typeof options === 'function') {
|
|
1055
|
+
callback = options;
|
|
1056
|
+
options = {};
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
if (!this.rules || Object.keys(this.rules).length === 0) {
|
|
1060
|
+
if (callback) {
|
|
1061
|
+
callback(null, source);
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
return Promise.resolve(source);
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
function complete(results) {
|
|
1068
|
+
var errors = [];
|
|
1069
|
+
var fields = {};
|
|
1070
|
+
|
|
1071
|
+
function add(e) {
|
|
1072
|
+
if (Array.isArray(e)) {
|
|
1073
|
+
var _errors;
|
|
1074
|
+
|
|
1075
|
+
errors = (_errors = errors).concat.apply(_errors, e);
|
|
1076
|
+
} else {
|
|
1077
|
+
errors.push(e);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
for (var i = 0; i < results.length; i++) {
|
|
1082
|
+
add(results[i]);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
if (!errors.length) {
|
|
1086
|
+
callback(null, source);
|
|
1087
|
+
} else {
|
|
1088
|
+
fields = convertFieldsError(errors);
|
|
1089
|
+
callback(errors, fields);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
if (options.messages) {
|
|
1094
|
+
var messages$1 = this.messages();
|
|
1095
|
+
|
|
1096
|
+
if (messages$1 === messages) {
|
|
1097
|
+
messages$1 = newMessages();
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
deepMerge(messages$1, options.messages);
|
|
1101
|
+
options.messages = messages$1;
|
|
1102
|
+
} else {
|
|
1103
|
+
options.messages = this.messages();
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
var series = {};
|
|
1107
|
+
var keys = options.keys || Object.keys(this.rules);
|
|
1108
|
+
keys.forEach(function (z) {
|
|
1109
|
+
var arr = _this2.rules[z];
|
|
1110
|
+
var value = source[z];
|
|
1111
|
+
arr.forEach(function (r) {
|
|
1112
|
+
var rule = r;
|
|
1113
|
+
|
|
1114
|
+
if (typeof rule.transform === 'function') {
|
|
1115
|
+
if (source === source_) {
|
|
1116
|
+
source = _extends({}, source);
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
value = source[z] = rule.transform(value);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
if (typeof rule === 'function') {
|
|
1123
|
+
rule = {
|
|
1124
|
+
validator: rule
|
|
1125
|
+
};
|
|
1126
|
+
} else {
|
|
1127
|
+
rule = _extends({}, rule);
|
|
1128
|
+
} // Fill validator. Skip if nothing need to validate
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
rule.validator = _this2.getValidationMethod(rule);
|
|
1132
|
+
|
|
1133
|
+
if (!rule.validator) {
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
rule.field = z;
|
|
1138
|
+
rule.fullField = rule.fullField || z;
|
|
1139
|
+
rule.type = _this2.getType(rule);
|
|
1140
|
+
series[z] = series[z] || [];
|
|
1141
|
+
series[z].push({
|
|
1142
|
+
rule: rule,
|
|
1143
|
+
value: value,
|
|
1144
|
+
source: source,
|
|
1145
|
+
field: z
|
|
1146
|
+
});
|
|
1147
|
+
});
|
|
1148
|
+
});
|
|
1149
|
+
var errorFields = {};
|
|
1150
|
+
return asyncMap(series, options, function (data, doIt) {
|
|
1151
|
+
var rule = data.rule;
|
|
1152
|
+
var deep = (rule.type === 'object' || rule.type === 'array') && (typeof rule.fields === 'object' || typeof rule.defaultField === 'object');
|
|
1153
|
+
deep = deep && (rule.required || !rule.required && data.value);
|
|
1154
|
+
rule.field = data.field;
|
|
1155
|
+
|
|
1156
|
+
function addFullField(key, schema) {
|
|
1157
|
+
return _extends({}, schema, {
|
|
1158
|
+
fullField: rule.fullField + "." + key,
|
|
1159
|
+
fullFields: rule.fullFields ? [].concat(rule.fullFields, [key]) : [key]
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
function cb(e) {
|
|
1164
|
+
if (e === void 0) {
|
|
1165
|
+
e = [];
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
var errorList = Array.isArray(e) ? e : [e];
|
|
1169
|
+
|
|
1170
|
+
if (!options.suppressWarning && errorList.length) {
|
|
1171
|
+
Schema.warning('async-validator:', errorList);
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
if (errorList.length && rule.message !== undefined) {
|
|
1175
|
+
errorList = [].concat(rule.message);
|
|
1176
|
+
} // Fill error info
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
var filledErrors = errorList.map(complementError(rule, source));
|
|
1180
|
+
|
|
1181
|
+
if (options.first && filledErrors.length) {
|
|
1182
|
+
errorFields[rule.field] = 1;
|
|
1183
|
+
return doIt(filledErrors);
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
if (!deep) {
|
|
1187
|
+
doIt(filledErrors);
|
|
1188
|
+
} else {
|
|
1189
|
+
// if rule is required but the target object
|
|
1190
|
+
// does not exist fail at the rule level and don't
|
|
1191
|
+
// go deeper
|
|
1192
|
+
if (rule.required && !data.value) {
|
|
1193
|
+
if (rule.message !== undefined) {
|
|
1194
|
+
filledErrors = [].concat(rule.message).map(complementError(rule, source));
|
|
1195
|
+
} else if (options.error) {
|
|
1196
|
+
filledErrors = [options.error(rule, format(options.messages.required, rule.field))];
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
return doIt(filledErrors);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
var fieldsSchema = {};
|
|
1203
|
+
|
|
1204
|
+
if (rule.defaultField) {
|
|
1205
|
+
Object.keys(data.value).map(function (key) {
|
|
1206
|
+
fieldsSchema[key] = rule.defaultField;
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
fieldsSchema = _extends({}, fieldsSchema, data.rule.fields);
|
|
1211
|
+
var paredFieldsSchema = {};
|
|
1212
|
+
Object.keys(fieldsSchema).forEach(function (field) {
|
|
1213
|
+
var fieldSchema = fieldsSchema[field];
|
|
1214
|
+
var fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema];
|
|
1215
|
+
paredFieldsSchema[field] = fieldSchemaList.map(addFullField.bind(null, field));
|
|
1216
|
+
});
|
|
1217
|
+
var schema = new Schema(paredFieldsSchema);
|
|
1218
|
+
schema.messages(options.messages);
|
|
1219
|
+
|
|
1220
|
+
if (data.rule.options) {
|
|
1221
|
+
data.rule.options.messages = options.messages;
|
|
1222
|
+
data.rule.options.error = options.error;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
schema.validate(data.value, data.rule.options || options, function (errs) {
|
|
1226
|
+
var finalErrors = [];
|
|
1227
|
+
|
|
1228
|
+
if (filledErrors && filledErrors.length) {
|
|
1229
|
+
finalErrors.push.apply(finalErrors, filledErrors);
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
if (errs && errs.length) {
|
|
1233
|
+
finalErrors.push.apply(finalErrors, errs);
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
doIt(finalErrors.length ? finalErrors : null);
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
var res;
|
|
1242
|
+
|
|
1243
|
+
if (rule.asyncValidator) {
|
|
1244
|
+
res = rule.asyncValidator(rule, data.value, cb, data.source, options);
|
|
1245
|
+
} else if (rule.validator) {
|
|
1246
|
+
try {
|
|
1247
|
+
res = rule.validator(rule, data.value, cb, data.source, options);
|
|
1248
|
+
} catch (error) {
|
|
1249
|
+
console.error == null ? void 0 : console.error(error); // rethrow to report error
|
|
1250
|
+
|
|
1251
|
+
if (!options.suppressValidatorError) {
|
|
1252
|
+
setTimeout(function () {
|
|
1253
|
+
throw error;
|
|
1254
|
+
}, 0);
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
cb(error.message);
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
if (res === true) {
|
|
1261
|
+
cb();
|
|
1262
|
+
} else if (res === false) {
|
|
1263
|
+
cb(typeof rule.message === 'function' ? rule.message(rule.fullField || rule.field) : rule.message || (rule.fullField || rule.field) + " fails");
|
|
1264
|
+
} else if (res instanceof Array) {
|
|
1265
|
+
cb(res);
|
|
1266
|
+
} else if (res instanceof Error) {
|
|
1267
|
+
cb(res.message);
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
if (res && res.then) {
|
|
1272
|
+
res.then(function () {
|
|
1273
|
+
return cb();
|
|
1274
|
+
}, function (e) {
|
|
1275
|
+
return cb(e);
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
}, function (results) {
|
|
1279
|
+
complete(results);
|
|
1280
|
+
}, source);
|
|
1281
|
+
};
|
|
1282
|
+
|
|
1283
|
+
_proto.getType = function getType(rule) {
|
|
1284
|
+
if (rule.type === undefined && rule.pattern instanceof RegExp) {
|
|
1285
|
+
rule.type = 'pattern';
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
if (typeof rule.validator !== 'function' && rule.type && !validators.hasOwnProperty(rule.type)) {
|
|
1289
|
+
throw new Error(format('Unknown rule type %s', rule.type));
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
return rule.type || 'string';
|
|
1293
|
+
};
|
|
1294
|
+
|
|
1295
|
+
_proto.getValidationMethod = function getValidationMethod(rule) {
|
|
1296
|
+
if (typeof rule.validator === 'function') {
|
|
1297
|
+
return rule.validator;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
var keys = Object.keys(rule);
|
|
1301
|
+
var messageIndex = keys.indexOf('message');
|
|
1302
|
+
|
|
1303
|
+
if (messageIndex !== -1) {
|
|
1304
|
+
keys.splice(messageIndex, 1);
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
if (keys.length === 1 && keys[0] === 'required') {
|
|
1308
|
+
return validators.required;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
return validators[this.getType(rule)] || undefined;
|
|
1312
|
+
};
|
|
1313
|
+
|
|
1314
|
+
return Schema;
|
|
1315
|
+
}();
|
|
1316
|
+
|
|
1317
|
+
Schema.register = function register(type, validator) {
|
|
1318
|
+
if (typeof validator !== 'function') {
|
|
1319
|
+
throw new Error('Cannot register a validator by type, validator is not a function');
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
validators[type] = validator;
|
|
1323
|
+
};
|
|
1324
|
+
|
|
1325
|
+
Schema.warning = warning;
|
|
1326
|
+
Schema.messages = messages;
|
|
1327
|
+
Schema.validators = validators;
|
|
1328
|
+
|
|
1329
|
+
export { Schema as default };
|