@10yun/cv-pc-ui 0.2.7 → 0.2.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@10yun/cv-pc-ui",
3
- "version": "0.2.7",
3
+ "version": "0.2.11",
4
4
  "description": "cvjs-pc-ui组件",
5
5
  "author": "10yun",
6
6
  "private": false,
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "async-validator": "^4.0.7",
34
34
  "axios": "^0.24.0",
35
- "core-js": "^3.19.3",
35
+ "core-js": "^3.20.2",
36
36
  "element-ui": "^2.15.6",
37
37
  "vue": "^2.6.14",
38
38
  "vue-router": "^3.5.3"
@@ -43,7 +43,7 @@
43
43
  "@vue/cli-service": "~4.5.15",
44
44
  "babel-eslint": "^10.1.0",
45
45
  "babel-plugin-transform-remove-console": "^6.9.4",
46
- "eslint": "^8.4.1",
46
+ "eslint": "^8.6.0",
47
47
  "eslint-plugin-vue": "^8.2.0",
48
48
  "vue-template-compiler": "^2.6.14"
49
49
  }
@@ -37,6 +37,13 @@ export default {
37
37
  localVal() {
38
38
  this.handleChange();
39
39
  },
40
+ dataLists: {
41
+ handler() {
42
+ this._parseLocalOpt()
43
+ },
44
+ immediate: true,
45
+ deep: true
46
+ },
40
47
  },
41
48
  data() {
42
49
  return {
@@ -0,0 +1,33 @@
1
+ function broadcast(componentName, eventName, params) {
2
+ this.$children.forEach(child => {
3
+ var name = child.$options.componentName;
4
+
5
+ if (name === componentName) {
6
+ child.$emit.apply(child, [eventName].concat(params));
7
+ } else {
8
+ broadcast.apply(child, [componentName, eventName].concat([params]));
9
+ }
10
+ });
11
+ }
12
+ export default {
13
+ methods: {
14
+ dispatch(componentName, eventName, params) {
15
+ var parent = this.$parent || this.$root;
16
+ var name = parent.$options.componentName;
17
+
18
+ while (parent && (!name || name !== componentName)) {
19
+ parent = parent.$parent;
20
+
21
+ if (parent) {
22
+ name = parent.$options.componentName;
23
+ }
24
+ }
25
+ if (parent) {
26
+ parent.$emit.apply(parent, [eventName].concat(params));
27
+ }
28
+ },
29
+ broadcast(componentName, eventName, params) {
30
+ broadcast.call(this, componentName, eventName, params);
31
+ }
32
+ }
33
+ };
@@ -1,5 +1,6 @@
1
1
  import { Input } from "element-ui";
2
2
  export default {
3
+ extends: Input,
3
4
  props: {
4
5
  ...Input.props,
5
6
  // 提示文本
@@ -0,0 +1,54 @@
1
+ import { kebabCase } from '../utils/util';
2
+ /**
3
+ * Show migrating guide in browser console.
4
+ *
5
+ * Usage:
6
+ * import Migrating from 'element-ui/src/mixins/migrating';
7
+ *
8
+ * mixins: [Migrating]
9
+ *
10
+ * add getMigratingConfig method for your component.
11
+ * getMigratingConfig() {
12
+ * return {
13
+ * props: {
14
+ * 'allow-no-selection': 'allow-no-selection is removed.',
15
+ * 'selection-mode': 'selection-mode is removed.'
16
+ * },
17
+ * events: {
18
+ * selectionchange: 'selectionchange is renamed to selection-change.'
19
+ * }
20
+ * };
21
+ * },
22
+ */
23
+ export default {
24
+ mounted() {
25
+ if (process.env.NODE_ENV === 'production') return;
26
+ if (!this.$vnode) return;
27
+ const { props = {}, events = {} } = this.getMigratingConfig();
28
+ const { data, componentOptions } = this.$vnode;
29
+ const definedProps = data.attrs || {};
30
+ const definedEvents = componentOptions.listeners || {};
31
+
32
+ for (let propName in definedProps) {
33
+ propName = kebabCase(propName); // compatible with camel case
34
+ if (props[propName]) {
35
+ console.warn(`[Element Migrating][${this.$options.name}][Attribute]: ${props[propName]}`);
36
+ }
37
+ }
38
+
39
+ for (let eventName in definedEvents) {
40
+ eventName = kebabCase(eventName); // compatible with camel case
41
+ if (events[eventName]) {
42
+ console.warn(`[Element Migrating][${this.$options.name}][Event]: ${events[eventName]}`);
43
+ }
44
+ }
45
+ },
46
+ methods: {
47
+ getMigratingConfig() {
48
+ return {
49
+ props: {},
50
+ events: {}
51
+ };
52
+ }
53
+ }
54
+ };
@@ -33,7 +33,14 @@ export default {
33
33
  },
34
34
  localVal() {
35
35
  this.handleChange()
36
- }
36
+ },
37
+ dataLists: {
38
+ handler() {
39
+ this._parseLocalOpt()
40
+ },
41
+ immediate: true,
42
+ deep: true
43
+ },
37
44
  },
38
45
  data() {
39
46
  return {
@@ -0,0 +1,227 @@
1
+ /* istanbul ignore next */
2
+
3
+ import Vue from 'vue';
4
+
5
+ const isServer = Vue.prototype.$isServer;
6
+ const SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g;
7
+ const MOZ_HACK_REGEXP = /^moz([A-Z])/;
8
+ const ieVersion = isServer ? 0 : Number(document.documentMode);
9
+
10
+ /* istanbul ignore next */
11
+ const trim = function(string) {
12
+ return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');
13
+ };
14
+ /* istanbul ignore next */
15
+ const camelCase = function(name) {
16
+ return name.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {
17
+ return offset ? letter.toUpperCase() : letter;
18
+ }).replace(MOZ_HACK_REGEXP, 'Moz$1');
19
+ };
20
+
21
+ /* istanbul ignore next */
22
+ export const on = (function() {
23
+ if (!isServer && document.addEventListener) {
24
+ return function(element, event, handler) {
25
+ if (element && event && handler) {
26
+ element.addEventListener(event, handler, false);
27
+ }
28
+ };
29
+ } else {
30
+ return function(element, event, handler) {
31
+ if (element && event && handler) {
32
+ element.attachEvent('on' + event, handler);
33
+ }
34
+ };
35
+ }
36
+ })();
37
+
38
+ /* istanbul ignore next */
39
+ export const off = (function() {
40
+ if (!isServer && document.removeEventListener) {
41
+ return function(element, event, handler) {
42
+ if (element && event) {
43
+ element.removeEventListener(event, handler, false);
44
+ }
45
+ };
46
+ } else {
47
+ return function(element, event, handler) {
48
+ if (element && event) {
49
+ element.detachEvent('on' + event, handler);
50
+ }
51
+ };
52
+ }
53
+ })();
54
+
55
+ /* istanbul ignore next */
56
+ export const once = function(el, event, fn) {
57
+ var listener = function() {
58
+ if (fn) {
59
+ fn.apply(this, arguments);
60
+ }
61
+ off(el, event, listener);
62
+ };
63
+ on(el, event, listener);
64
+ };
65
+
66
+ /* istanbul ignore next */
67
+ export function hasClass(el, cls) {
68
+ if (!el || !cls) return false;
69
+ if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.');
70
+ if (el.classList) {
71
+ return el.classList.contains(cls);
72
+ } else {
73
+ return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1;
74
+ }
75
+ };
76
+
77
+ /* istanbul ignore next */
78
+ export function addClass(el, cls) {
79
+ if (!el) return;
80
+ var curClass = el.className;
81
+ var classes = (cls || '').split(' ');
82
+
83
+ for (var i = 0, j = classes.length; i < j; i++) {
84
+ var clsName = classes[i];
85
+ if (!clsName) continue;
86
+
87
+ if (el.classList) {
88
+ el.classList.add(clsName);
89
+ } else if (!hasClass(el, clsName)) {
90
+ curClass += ' ' + clsName;
91
+ }
92
+ }
93
+ if (!el.classList) {
94
+ el.setAttribute('class', curClass);
95
+ }
96
+ };
97
+
98
+ /* istanbul ignore next */
99
+ export function removeClass(el, cls) {
100
+ if (!el || !cls) return;
101
+ var classes = cls.split(' ');
102
+ var curClass = ' ' + el.className + ' ';
103
+
104
+ for (var i = 0, j = classes.length; i < j; i++) {
105
+ var clsName = classes[i];
106
+ if (!clsName) continue;
107
+
108
+ if (el.classList) {
109
+ el.classList.remove(clsName);
110
+ } else if (hasClass(el, clsName)) {
111
+ curClass = curClass.replace(' ' + clsName + ' ', ' ');
112
+ }
113
+ }
114
+ if (!el.classList) {
115
+ el.setAttribute('class', trim(curClass));
116
+ }
117
+ };
118
+
119
+ /* istanbul ignore next */
120
+ export const getStyle = ieVersion < 9 ? function(element, styleName) {
121
+ if (isServer) return;
122
+ if (!element || !styleName) return null;
123
+ styleName = camelCase(styleName);
124
+ if (styleName === 'float') {
125
+ styleName = 'styleFloat';
126
+ }
127
+ try {
128
+ switch (styleName) {
129
+ case 'opacity':
130
+ try {
131
+ return element.filters.item('alpha').opacity / 100;
132
+ } catch (e) {
133
+ return 1.0;
134
+ }
135
+ default:
136
+ return (element.style[styleName] || element.currentStyle ? element.currentStyle[styleName] : null);
137
+ }
138
+ } catch (e) {
139
+ return element.style[styleName];
140
+ }
141
+ } : function(element, styleName) {
142
+ if (isServer) return;
143
+ if (!element || !styleName) return null;
144
+ styleName = camelCase(styleName);
145
+ if (styleName === 'float') {
146
+ styleName = 'cssFloat';
147
+ }
148
+ try {
149
+ var computed = document.defaultView.getComputedStyle(element, '');
150
+ return element.style[styleName] || computed ? computed[styleName] : null;
151
+ } catch (e) {
152
+ return element.style[styleName];
153
+ }
154
+ };
155
+
156
+ /* istanbul ignore next */
157
+ export function setStyle(element, styleName, value) {
158
+ if (!element || !styleName) return;
159
+
160
+ if (typeof styleName === 'object') {
161
+ for (var prop in styleName) {
162
+ if (styleName.hasOwnProperty(prop)) {
163
+ setStyle(element, prop, styleName[prop]);
164
+ }
165
+ }
166
+ } else {
167
+ styleName = camelCase(styleName);
168
+ if (styleName === 'opacity' && ieVersion < 9) {
169
+ element.style.filter = isNaN(value) ? '' : 'alpha(opacity=' + value * 100 + ')';
170
+ } else {
171
+ element.style[styleName] = value;
172
+ }
173
+ }
174
+ };
175
+
176
+ export const isScroll = (el, vertical) => {
177
+ if (isServer) return;
178
+
179
+ const determinedDirection = vertical !== null && vertical !== undefined;
180
+ const overflow = determinedDirection
181
+ ? vertical
182
+ ? getStyle(el, 'overflow-y')
183
+ : getStyle(el, 'overflow-x')
184
+ : getStyle(el, 'overflow');
185
+
186
+ return overflow.match(/(scroll|auto|overlay)/);
187
+ };
188
+
189
+ export const getScrollContainer = (el, vertical) => {
190
+ if (isServer) return;
191
+
192
+ let parent = el;
193
+ while (parent) {
194
+ if ([window, document, document.documentElement].includes(parent)) {
195
+ return window;
196
+ }
197
+ if (isScroll(parent, vertical)) {
198
+ return parent;
199
+ }
200
+ parent = parent.parentNode;
201
+ }
202
+
203
+ return parent;
204
+ };
205
+
206
+ export const isInContainer = (el, container) => {
207
+ if (isServer || !el || !container) return false;
208
+
209
+ const elRect = el.getBoundingClientRect();
210
+ let containerRect;
211
+
212
+ if ([window, document, document.documentElement, null, undefined].includes(container)) {
213
+ containerRect = {
214
+ top: 0,
215
+ right: window.innerWidth,
216
+ bottom: window.innerHeight,
217
+ left: 0
218
+ };
219
+ } else {
220
+ containerRect = container.getBoundingClientRect();
221
+ }
222
+
223
+ return elRect.top < containerRect.bottom &&
224
+ elRect.bottom > containerRect.top &&
225
+ elRect.right > containerRect.left &&
226
+ elRect.left < containerRect.right;
227
+ };
@@ -0,0 +1,15 @@
1
+ export default function(target) {
2
+ for (let i = 1, j = arguments.length; i < j; i++) {
3
+ let source = arguments[i] || {};
4
+ for (let prop in source) {
5
+ if (source.hasOwnProperty(prop)) {
6
+ let value = source[prop];
7
+ if (value !== undefined) {
8
+ target[prop] = value;
9
+ }
10
+ }
11
+ }
12
+ }
13
+
14
+ return target;
15
+ };
@@ -0,0 +1,29 @@
1
+ import Vue from 'vue';
2
+
3
+ let scrollBarWidth;
4
+
5
+ export default function() {
6
+ if (Vue.prototype.$isServer) return 0;
7
+ if (scrollBarWidth !== undefined) return scrollBarWidth;
8
+
9
+ const outer = document.createElement('div');
10
+ outer.className = 'el-scrollbar__wrap';
11
+ outer.style.visibility = 'hidden';
12
+ outer.style.width = '100px';
13
+ outer.style.position = 'absolute';
14
+ outer.style.top = '-9999px';
15
+ document.body.appendChild(outer);
16
+
17
+ const widthNoScroll = outer.offsetWidth;
18
+ outer.style.overflow = 'scroll';
19
+
20
+ const inner = document.createElement('div');
21
+ inner.style.width = '100%';
22
+ outer.appendChild(inner);
23
+
24
+ const widthWithScroll = inner.offsetWidth;
25
+ outer.parentNode.removeChild(outer);
26
+ scrollBarWidth = widthNoScroll - widthWithScroll;
27
+
28
+ return scrollBarWidth;
29
+ };
@@ -0,0 +1,40 @@
1
+ import Vue from 'vue';
2
+
3
+ export function isString(obj) {
4
+ return Object.prototype.toString.call(obj) === '[object String]';
5
+ }
6
+
7
+ export function isObject(obj) {
8
+ return Object.prototype.toString.call(obj) === '[object Object]';
9
+ }
10
+
11
+ export function isHtmlElement(node) {
12
+ return node && node.nodeType === Node.ELEMENT_NODE;
13
+ }
14
+
15
+ /**
16
+ * - Inspired:
17
+ * https://github.com/jashkenas/underscore/blob/master/modules/isFunction.js
18
+ */
19
+ let isFunction = (functionToCheck) => {
20
+ var getType = {};
21
+ return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
22
+ };
23
+
24
+ if (typeof /./ !== 'function' && typeof Int8Array !== 'object' && (Vue.prototype.$isServer || typeof document.childNodes !== 'function')) {
25
+ isFunction = function (obj) {
26
+ return typeof obj === 'function' || false;
27
+ };
28
+ }
29
+
30
+ export {
31
+ isFunction
32
+ };
33
+
34
+ export const isUndefined = (val) => {
35
+ return val === void 0;
36
+ };
37
+
38
+ export const isDefined = (val) => {
39
+ return val !== undefined && val !== null;
40
+ };
@@ -0,0 +1,241 @@
1
+ import Vue from 'vue';
2
+ import { isString, isObject } from './types';
3
+
4
+ const hasOwnProperty = Object.prototype.hasOwnProperty;
5
+
6
+ export function noop() { };
7
+
8
+ export function hasOwn(obj, key) {
9
+ return hasOwnProperty.call(obj, key);
10
+ };
11
+
12
+ function extend(to, _from) {
13
+ for (let key in _from) {
14
+ to[key] = _from[key];
15
+ }
16
+ return to;
17
+ };
18
+
19
+ export function toObject(arr) {
20
+ var res = {};
21
+ for (let i = 0; i < arr.length; i++) {
22
+ if (arr[i]) {
23
+ extend(res, arr[i]);
24
+ }
25
+ }
26
+ return res;
27
+ };
28
+
29
+ export const getValueByPath = function (object, prop) {
30
+ prop = prop || '';
31
+ const paths = prop.split('.');
32
+ let current = object;
33
+ let result = null;
34
+ for (let i = 0, j = paths.length; i < j; i++) {
35
+ const path = paths[i];
36
+ if (!current) break;
37
+
38
+ if (i === j - 1) {
39
+ result = current[path];
40
+ break;
41
+ }
42
+ current = current[path];
43
+ }
44
+ return result;
45
+ };
46
+
47
+ export function getPropByPath(obj, path, strict) {
48
+ let tempObj = obj;
49
+ path = path.replace(/\[(\w+)\]/g, '.$1');
50
+ path = path.replace(/^\./, '');
51
+
52
+ let keyArr = path.split('.');
53
+ let i = 0;
54
+ for (let len = keyArr.length; i < len - 1; ++i) {
55
+ if (!tempObj && !strict) break;
56
+ let key = keyArr[i];
57
+ if (key in tempObj) {
58
+ tempObj = tempObj[key];
59
+ } else {
60
+ if (strict) {
61
+ throw new Error('please transfer a valid prop path to form item!');
62
+ }
63
+ break;
64
+ }
65
+ }
66
+ return {
67
+ o: tempObj,
68
+ k: keyArr[i],
69
+ v: tempObj ? tempObj[keyArr[i]] : null
70
+ };
71
+ };
72
+
73
+ export const generateId = function () {
74
+ return Math.floor(Math.random() * 10000);
75
+ };
76
+
77
+ export const valueEquals = (a, b) => {
78
+ // see: https://stackoverflow.com/questions/3115982/how-to-check-if-two-arrays-are-equal-with-javascript
79
+ if (a === b) return true;
80
+ if (!(a instanceof Array)) return false;
81
+ if (!(b instanceof Array)) return false;
82
+ if (a.length !== b.length) return false;
83
+ for (let i = 0; i !== a.length; ++i) {
84
+ if (a[i] !== b[i]) return false;
85
+ }
86
+ return true;
87
+ };
88
+
89
+ export const escapeRegexpString = (value = '') => String(value).replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
90
+
91
+ // TODO: use native Array.find, Array.findIndex when IE support is dropped
92
+ export const arrayFindIndex = function (arr, pred) {
93
+ for (let i = 0; i !== arr.length; ++i) {
94
+ if (pred(arr[i])) {
95
+ return i;
96
+ }
97
+ }
98
+ return -1;
99
+ };
100
+
101
+ export const arrayFind = function (arr, pred) {
102
+ const idx = arrayFindIndex(arr, pred);
103
+ return idx !== -1 ? arr[idx] : undefined;
104
+ };
105
+
106
+ // coerce truthy value to array
107
+ export const coerceTruthyValueToArray = function (val) {
108
+ if (Array.isArray(val)) {
109
+ return val;
110
+ } else if (val) {
111
+ return [val];
112
+ } else {
113
+ return [];
114
+ }
115
+ };
116
+
117
+ export const isIE = function () {
118
+ return !Vue.prototype.$isServer && !isNaN(Number(document.documentMode));
119
+ };
120
+
121
+ export const isEdge = function () {
122
+ return !Vue.prototype.$isServer && navigator.userAgent.indexOf('Edge') > -1;
123
+ };
124
+
125
+ export const isFirefox = function () {
126
+ return !Vue.prototype.$isServer && !!window.navigator.userAgent.match(/firefox/i);
127
+ };
128
+
129
+ export const autoprefixer = function (style) {
130
+ if (typeof style !== 'object') return style;
131
+ const rules = ['transform', 'transition', 'animation'];
132
+ const prefixes = ['ms-', 'webkit-'];
133
+ rules.forEach(rule => {
134
+ const value = style[rule];
135
+ if (rule && value) {
136
+ prefixes.forEach(prefix => {
137
+ style[prefix + rule] = value;
138
+ });
139
+ }
140
+ });
141
+ return style;
142
+ };
143
+
144
+ export const kebabCase = function (str) {
145
+ const hyphenateRE = /([^-])([A-Z])/g;
146
+ return str
147
+ .replace(hyphenateRE, '$1-$2')
148
+ .replace(hyphenateRE, '$1-$2')
149
+ .toLowerCase();
150
+ };
151
+
152
+ export const capitalize = function (str) {
153
+ if (!isString(str)) return str;
154
+ return str.charAt(0).toUpperCase() + str.slice(1);
155
+ };
156
+
157
+ export const looseEqual = function (a, b) {
158
+ const isObjectA = isObject(a);
159
+ const isObjectB = isObject(b);
160
+ if (isObjectA && isObjectB) {
161
+ return JSON.stringify(a) === JSON.stringify(b);
162
+ } else if (!isObjectA && !isObjectB) {
163
+ return String(a) === String(b);
164
+ } else {
165
+ return false;
166
+ }
167
+ };
168
+
169
+ export const arrayEquals = function (arrayA, arrayB) {
170
+ arrayA = arrayA || [];
171
+ arrayB = arrayB || [];
172
+
173
+ if (arrayA.length !== arrayB.length) {
174
+ return false;
175
+ }
176
+
177
+ for (let i = 0; i < arrayA.length; i++) {
178
+ if (!looseEqual(arrayA[i], arrayB[i])) {
179
+ return false;
180
+ }
181
+ }
182
+
183
+ return true;
184
+ };
185
+
186
+ export const isEqual = function (value1, value2) {
187
+ if (Array.isArray(value1) && Array.isArray(value2)) {
188
+ return arrayEquals(value1, value2);
189
+ }
190
+ return looseEqual(value1, value2);
191
+ };
192
+
193
+ export const isEmpty = function (val) {
194
+ // null or undefined
195
+ if (val == null) return true;
196
+
197
+ if (typeof val === 'boolean') return false;
198
+
199
+ if (typeof val === 'number') return !val;
200
+
201
+ if (val instanceof Error) return val.message === '';
202
+
203
+ switch (Object.prototype.toString.call(val)) {
204
+ // String or Array
205
+ case '[object String]':
206
+ case '[object Array]':
207
+ return !val.length;
208
+
209
+ // Map or Set or File
210
+ case '[object File]':
211
+ case '[object Map]':
212
+ case '[object Set]': {
213
+ return !val.size;
214
+ }
215
+ // Plain Object
216
+ case '[object Object]': {
217
+ return !Object.keys(val).length;
218
+ }
219
+ }
220
+
221
+ return false;
222
+ };
223
+
224
+ export function rafThrottle(fn) {
225
+ let locked = false;
226
+ return function (...args) {
227
+ if (locked) return;
228
+ locked = true;
229
+ window.requestAnimationFrame(_ => {
230
+ fn.apply(this, args);
231
+ locked = false;
232
+ });
233
+ };
234
+ }
235
+
236
+ export function objToArray(obj) {
237
+ if (Array.isArray(obj)) {
238
+ return obj;
239
+ }
240
+ return isEmpty(obj) ? [] : [obj];
241
+ }