front-ui-product
Version:
Front UI
565 lines (516 loc) • 19.6 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["front-ui-product"] = factory();
else
root["front-ui-product"] = factory();
})((typeof self !== 'undefined' ? self : this), function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "fb15");
/******/ })
/************************************************************************/
/******/ ({
/***/ "102b":
/***/ (function(module, exports, __webpack_require__) {
// extracted by mini-css-extract-plugin
/***/ }),
/***/ "3f47":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_vue_cli_service_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_index_vue_vue_type_style_index_0_id_74c3ca6d_prod_scoped_true_lang_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("102b");
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_vue_cli_service_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_index_vue_vue_type_style_index_0_id_74c3ca6d_prod_scoped_true_lang_scss__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_vue_cli_service_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_index_vue_vue_type_style_index_0_id_74c3ca6d_prod_scoped_true_lang_scss__WEBPACK_IMPORTED_MODULE_0__);
/* unused harmony reexport * */
/***/ }),
/***/ "fb15":
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, "PMobileInput", function() { return /* reexport */ p_mobile_input; });
// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js
// This file is imported into lib/wc client bundles.
if (typeof window !== 'undefined') {
var currentScript = window.document.currentScript
if (false) { var getCurrentScript; }
var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/)
if (src) {
__webpack_require__.p = src[1] // eslint-disable-line
}
}
// Indicate to webpack that this file can be concatenated
/* harmony default export */ var setPublicPath = (null);
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"7fe5194a-vue-loader-template"}!./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/package-product/p-mobile-input/index.vue?vue&type=template&id=74c3ca6d&scoped=true
var render = function render() {
var _vm = this,
_c = _vm._self._c;
return _c('div', {
staticClass: "p-mobile-input"
}, [_c('div', {
staticClass: "content",
style: _vm.classStyle
}, [_vm.$slots.label ? _c('div', {
style: _vm.labelStyle
}, [_vm._t("label")], 2) : _vm._e(), _c('div', {
key: _vm.inputKey,
staticClass: "input-wrp",
class: {
error: _vm.hasErrors,
showBorders: _vm.showBorder
},
style: _vm.containerStyle
}, [_c('input', {
directives: [{
name: "model",
rawName: "v-model",
value: _vm.inputValue,
expression: "inputValue"
}],
key: _vm.inputKey,
ref: "newInput",
staticClass: "p-input",
staticStyle: {
"padding": "0 !important",
"border": "none !important",
"outline": "none !important",
"-webkit-appearance": "none !important",
"-moz-appearance": "none !important",
"appearance": "none !important"
},
style: _vm.inputStyle,
attrs: {
"inputmode": "decimal",
"maxlength": _vm.formatMaxlength,
"placeholder": _vm.placeholder
},
domProps: {
"value": _vm.inputValue
},
on: {
"input": [function ($event) {
if ($event.target.composing) return;
_vm.inputValue = $event.target.value;
}, _vm.inputHandler],
"focus": function ($event) {
_vm.hasErrors = false;
},
"blur": _vm.handleBlur,
"compositionstart": function ($event) {
_vm.isComposing = true;
},
"compositionend": _vm.onCompositionEnd
}
}), _vm.$slots.prefix ? _c('div', {
style: _vm.prefixStyle
}, [_vm._t("prefix")], 2) : _vm._e()])]), _vm.hasErrors ? _c('div', {
style: _vm.warningStyle
}, [_vm._t("error")], 2) : _vm._e()]);
};
var staticRenderFns = [];
// CONCATENATED MODULE: ./src/package-product/p-mobile-input/index.vue?vue&type=template&id=74c3ca6d&scoped=true
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/package-product/p-mobile-input/index.vue?vue&type=script&lang=js
/* harmony default export */ var p_mobile_inputvue_type_script_lang_js = ({
name: "p-mobile-input",
//组件名
data() {
return {
inputValue: "",
selectionStart: -1,
selectionEnd: -1,
oldValue: "",
type: null,
hasErrors: false,
inputKey: "inputKey",
isComposing: false
};
},
watch: {
defaultValue: {
handler(newVal) {
if (this.inputValue) {
return;
}
if (newVal) {
this.inputValue = newVal;
this.$nextTick(() => {
this.inputHandler(null, true);
});
}
},
immediate: true
},
inputValue: {
handler(newVal) {
this.$emit("input", newVal.replace(/^\+1\s*/, "").replace(/\D/g, ""));
},
immediate: true
}
},
props: {
maxlength: {
type: Number,
default: 10
},
classStyle: {
type: Object,
default: () => {}
},
placeholder: {
type: String,
default: ""
},
labelStyle: {
type: Object,
default: () => {}
},
prefixStyle: {
type: Object,
default: () => {}
},
defaultValue: {
type: String,
default: ""
},
warningStyle: {
type: Object,
default: () => {}
},
containerStyle: {
type: Object,
default: () => {}
},
showBorder: {
type: Boolean,
default: false
},
inputStyle: {
type: Object,
default: () => {}
}
},
computed: {
formatMaxlength() {
return this.maxlength + 7;
}
},
methods: {
formatInput(newValue) {
let formatValue = "";
if (newValue > 0) {
let formattedNumber = "";
if (newValue.length <= 3) {
formattedNumber = `(${newValue}`;
} else if (newValue.length <= 6) {
formattedNumber = `(${newValue.slice(0, 3)}) ${newValue.slice(3)}`;
} else {
formattedNumber = `(${newValue.slice(0, 3)}) ${newValue.slice(3, 6)}-${newValue.slice(6, 10)}`;
}
// 如果当前值不包含前缀,添加前缀
if (!newValue.startsWith("+1")) {
formatValue = `+1 ${formattedNumber}`;
} else {
// 如果已经有前缀,只更新数字部分
const prefix = "+1 ";
formatValue = prefix + formattedNumber;
}
} else {
formatValue = "";
}
return formatValue;
},
onCompositionEnd(e) {
this.isComposing = false;
this.inputHandler(e);
},
inputHandler(e, first) {
if (this.isComposing) return;
let newValue = first ? this.defaultValue : this.inputValue.replace(/^\+1\s*/, "").replace(/\D/g, "");
if (!newValue.length) {
this.$refs.newInput.value = "";
this.inputValue = "";
this.oldValue = "";
this.$emit("input", "");
return;
}
const oldValueFormat = this.oldValue.replace(/^\+1\s*/, "").replace(/\D/g, "");
this.type = oldValueFormat == newValue ? "char" : oldValueFormat && newValue && oldValueFormat.length - newValue.length == 1 ? "delete" : "add";
this.oldValue = this.inputValue;
this.selectionStart = this.$refs.newInput.selectionStart;
this.selectionEnd = this.$refs.newInput.selectionEnd;
console.log("type", this.type, this.inputValue, oldValueFormat, newValue);
this.$nextTick(() => {
if (this.type == "delete") {
let formatValue = this.formatInput(newValue);
this.$refs.newInput.value = formatValue;
this.$refs.newInput.setSelectionRange(this.selectionStart, this.selectionEnd);
} else if (this.type == "add") {
let formatValue = this.formatInput(newValue);
this.$refs.newInput.value = formatValue;
const index = {
1: 5,
4: 10,
7: 15
};
const newValueForIndex = {
1: 1,
2: 6,
3: 7,
4: 8,
5: 11,
6: 12,
7: 13,
8: 15,
9: 16,
10: 17
};
const selection = () => {
if (newValueForIndex[newValue.length] == this.selectionStart) {
return [1, 4, 7].includes(newValue.length) ? index[newValue.length] : this.selectionStart;
} else {
return this.selectionStart;
}
};
this.$refs.newInput.setSelectionRange(selection(), selection());
} else {
const func = {
7: () => {
const value = this.formatInput(newValue.slice(0, 2) + newValue.slice(3));
this.$refs.newInput.value = value;
this.$refs.newInput.setSelectionRange(7, 7);
},
8: () => {
const value = this.formatInput(newValue.slice(0, 2) + newValue.slice(3));
this.$refs.newInput.value = value;
this.$refs.newInput.setSelectionRange(7, 7);
},
12: () => {
const value = this.formatInput(newValue.slice(0, 5) + newValue.slice(6));
this.$refs.newInput.value = value;
this.$refs.newInput.setSelectionRange(12, 12);
}
};
if ([7, 8, 12].includes(this.selectionStart)) {
func[this.selectionStart]();
} else {
let formatValue = this.formatInput(newValue);
this.$refs.newInput.value = formatValue;
}
}
});
},
handleBlur() {
const phoneNumber = this.inputValue.replace(/^\+1\s*/, "").replace(/\D/g, "");
console.log("blur");
this.hasErrors = phoneNumber.length == 0;
}
}
});
// CONCATENATED MODULE: ./src/package-product/p-mobile-input/index.vue?vue&type=script&lang=js
/* harmony default export */ var package_product_p_mobile_inputvue_type_script_lang_js = (p_mobile_inputvue_type_script_lang_js);
// EXTERNAL MODULE: ./src/package-product/p-mobile-input/index.vue?vue&type=style&index=0&id=74c3ca6d&prod&scoped=true&lang=scss
var p_mobile_inputvue_type_style_index_0_id_74c3ca6d_prod_scoped_true_lang_scss = __webpack_require__("3f47");
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
/* globals __VUE_SSR_CONTEXT__ */
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
// This module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle.
function normalizeComponent(
scriptExports,
render,
staticRenderFns,
functionalTemplate,
injectStyles,
scopeId,
moduleIdentifier /* server only */,
shadowMode /* vue-cli only */
) {
// Vue.extend constructor export interop
var options =
typeof scriptExports === 'function' ? scriptExports.options : scriptExports
// render functions
if (render) {
options.render = render
options.staticRenderFns = staticRenderFns
options._compiled = true
}
// functional template
if (functionalTemplate) {
options.functional = true
}
// scopedId
if (scopeId) {
options._scopeId = 'data-v-' + scopeId
}
var hook
if (moduleIdentifier) {
// server build
hook = function (context) {
// 2.3 injection
context =
context || // cached call
(this.$vnode && this.$vnode.ssrContext) || // stateful
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
// 2.2 with runInNewContext: true
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
context = __VUE_SSR_CONTEXT__
}
// inject component styles
if (injectStyles) {
injectStyles.call(this, context)
}
// register component module identifier for async chunk inferrence
if (context && context._registeredComponents) {
context._registeredComponents.add(moduleIdentifier)
}
}
// used by ssr in case component is cached and beforeCreate
// never gets called
options._ssrRegister = hook
} else if (injectStyles) {
hook = shadowMode
? function () {
injectStyles.call(
this,
(options.functional ? this.parent : this).$root.$options.shadowRoot
)
}
: injectStyles
}
if (hook) {
if (options.functional) {
// for template-only hot-reload because in that case the render fn doesn't
// go through the normalizer
options._injectStyles = hook
// register for functional component in vue file
var originalRender = options.render
options.render = function renderWithStyleInjection(h, context) {
hook.call(context)
return originalRender(h, context)
}
} else {
// inject component registration as beforeCreate hook
var existing = options.beforeCreate
options.beforeCreate = existing ? [].concat(existing, hook) : [hook]
}
}
return {
exports: scriptExports,
options: options
}
}
// CONCATENATED MODULE: ./src/package-product/p-mobile-input/index.vue
/* normalize component */
var component = normalizeComponent(
package_product_p_mobile_inputvue_type_script_lang_js,
render,
staticRenderFns,
false,
null,
"74c3ca6d",
null
)
/* harmony default export */ var p_mobile_input = (component.exports);
// CONCATENATED MODULE: ./src/package-product/index.js
//package/index.js
// 所有组件
const components = [p_mobile_input];
// install 方法
const install = function (Vue) {
components.forEach(com => {
Vue.component(com.name, com);
});
};
// 支持按需引入
// 支持全局引入
/* harmony default export */ var package_product = (install);
// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js
/* harmony default export */ var entry_lib = __webpack_exports__["default"] = (package_product);
/***/ })
/******/ });
});
//# sourceMappingURL=front-ui-product.umd.js.map