@kmkf-fe-packages/kmkf-utils 1.24.0 → 1.25.1
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/README.md +1 -1
- package/dist/esm/addressData/index.d.ts +1 -0
- package/dist/esm/addressData/index.js +30 -0
- package/dist/esm/bsAddressData/index.d.ts +1 -0
- package/dist/esm/bsAddressData/index.js +30 -0
- package/dist/esm/wdtAddressData/index.d.ts +1 -0
- package/dist/esm/wdtAddressData/index.js +30 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
111226333
|
|
@@ -25,6 +25,7 @@ export default class AddressData {
|
|
|
25
25
|
value: string;
|
|
26
26
|
}[];
|
|
27
27
|
getProCodeByName: (proName: string) => number | undefined;
|
|
28
|
+
getCodesByNames: (names: Array<string>) => (string | undefined)[];
|
|
28
29
|
getNameByCode: (code: string | number) => string;
|
|
29
30
|
static getInstance(): AddressData;
|
|
30
31
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
2
5
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
6
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
7
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
8
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
9
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
10
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
11
|
+
import { isEmpty } from 'lodash';
|
|
8
12
|
var AddressData = /*#__PURE__*/function () {
|
|
9
13
|
function AddressData() {
|
|
10
14
|
var _this = this;
|
|
@@ -45,6 +49,32 @@ var AddressData = /*#__PURE__*/function () {
|
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
});
|
|
52
|
+
_defineProperty(this, "getCodesByNames", function (names) {
|
|
53
|
+
var codes = [];
|
|
54
|
+
var currentData = _this.addressOptions;
|
|
55
|
+
var _iterator = _createForOfIteratorHelper(names),
|
|
56
|
+
_step;
|
|
57
|
+
try {
|
|
58
|
+
var _loop = function _loop() {
|
|
59
|
+
var name = _step.value;
|
|
60
|
+
var foundChild = currentData.find(function (item) {
|
|
61
|
+
return item.label === name;
|
|
62
|
+
});
|
|
63
|
+
codes.push(foundChild === null || foundChild === void 0 ? void 0 : foundChild.value); // 添加找到的 code
|
|
64
|
+
if (!isEmpty(foundChild === null || foundChild === void 0 ? void 0 : foundChild.children)) {
|
|
65
|
+
currentData = (foundChild === null || foundChild === void 0 ? void 0 : foundChild.children) || []; // 更新当前数据为找到的子节点
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
69
|
+
_loop();
|
|
70
|
+
}
|
|
71
|
+
} catch (err) {
|
|
72
|
+
_iterator.e(err);
|
|
73
|
+
} finally {
|
|
74
|
+
_iterator.f();
|
|
75
|
+
}
|
|
76
|
+
return codes; // 返回所有找到的 codes
|
|
77
|
+
});
|
|
48
78
|
_defineProperty(this, "getNameByCode", function (code) {
|
|
49
79
|
var _ref;
|
|
50
80
|
return (_ref = (_this.addrData || {})[code] || []) === null || _ref === void 0 ? void 0 : _ref[0];
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
2
5
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
6
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
7
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
8
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
9
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
10
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
11
|
+
import { isEmpty } from 'lodash';
|
|
8
12
|
var BsAddressData = /*#__PURE__*/function () {
|
|
9
13
|
function BsAddressData() {
|
|
10
14
|
var _this = this;
|
|
@@ -29,6 +33,32 @@ var BsAddressData = /*#__PURE__*/function () {
|
|
|
29
33
|
}
|
|
30
34
|
return arr;
|
|
31
35
|
});
|
|
36
|
+
_defineProperty(this, "getCodesByNames", function (names) {
|
|
37
|
+
var codes = [];
|
|
38
|
+
var currentData = _this.addressOptions;
|
|
39
|
+
var _iterator = _createForOfIteratorHelper(names),
|
|
40
|
+
_step;
|
|
41
|
+
try {
|
|
42
|
+
var _loop = function _loop() {
|
|
43
|
+
var name = _step.value;
|
|
44
|
+
var foundChild = currentData.find(function (item) {
|
|
45
|
+
return item.label === name;
|
|
46
|
+
});
|
|
47
|
+
codes.push(foundChild === null || foundChild === void 0 ? void 0 : foundChild.value); // 添加找到的 code
|
|
48
|
+
if (!isEmpty(foundChild === null || foundChild === void 0 ? void 0 : foundChild.children)) {
|
|
49
|
+
currentData = (foundChild === null || foundChild === void 0 ? void 0 : foundChild.children) || []; // 更新当前数据为找到的子节点
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
53
|
+
_loop();
|
|
54
|
+
}
|
|
55
|
+
} catch (err) {
|
|
56
|
+
_iterator.e(err);
|
|
57
|
+
} finally {
|
|
58
|
+
_iterator.f();
|
|
59
|
+
}
|
|
60
|
+
return codes; // 返回所有找到的 codes
|
|
61
|
+
});
|
|
32
62
|
_defineProperty(this, "getProvinceByCode", function (countryIndex) {
|
|
33
63
|
return _this.parseData(countryIndex);
|
|
34
64
|
});
|
|
@@ -26,6 +26,7 @@ export default class WdtAddressData {
|
|
|
26
26
|
value: string;
|
|
27
27
|
}[];
|
|
28
28
|
getProCodeByName: (proName: string) => number | undefined;
|
|
29
|
+
getCodesByNames: (names: Array<string>) => (string | undefined)[];
|
|
29
30
|
getNameByCode: (code: string | number) => string;
|
|
30
31
|
static initData: () => Promise<WdtAddressData>;
|
|
31
32
|
static getAddressOptions: () => Promise<TreeOption[]>;
|
|
@@ -2,12 +2,16 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
2
2
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
3
3
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
4
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
5
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
6
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
8
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
9
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
7
10
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
11
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
12
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
13
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
|
+
import { isEmpty } from 'lodash';
|
|
11
15
|
import { queryWdtAddressData } from "../servers";
|
|
12
16
|
var WdtAddressData = /*#__PURE__*/function () {
|
|
13
17
|
function WdtAddressData() {
|
|
@@ -49,6 +53,32 @@ var WdtAddressData = /*#__PURE__*/function () {
|
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
});
|
|
56
|
+
_defineProperty(this, "getCodesByNames", function (names) {
|
|
57
|
+
var codes = [];
|
|
58
|
+
var currentData = _this.addressOptions;
|
|
59
|
+
var _iterator = _createForOfIteratorHelper(names),
|
|
60
|
+
_step;
|
|
61
|
+
try {
|
|
62
|
+
var _loop = function _loop() {
|
|
63
|
+
var name = _step.value;
|
|
64
|
+
var foundChild = currentData.find(function (item) {
|
|
65
|
+
return item.label === name;
|
|
66
|
+
});
|
|
67
|
+
codes.push(foundChild === null || foundChild === void 0 ? void 0 : foundChild.value); // 添加找到的 code
|
|
68
|
+
if (!isEmpty(foundChild === null || foundChild === void 0 ? void 0 : foundChild.children)) {
|
|
69
|
+
currentData = (foundChild === null || foundChild === void 0 ? void 0 : foundChild.children) || []; // 更新当前数据为找到的子节点
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
73
|
+
_loop();
|
|
74
|
+
}
|
|
75
|
+
} catch (err) {
|
|
76
|
+
_iterator.e(err);
|
|
77
|
+
} finally {
|
|
78
|
+
_iterator.f();
|
|
79
|
+
}
|
|
80
|
+
return codes; // 返回所有找到的 codes
|
|
81
|
+
});
|
|
52
82
|
_defineProperty(this, "getNameByCode", function (code) {
|
|
53
83
|
var _ref;
|
|
54
84
|
return (_ref = (_this.addrData || {})[code] || []) === null || _ref === void 0 ? void 0 : _ref[0];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kmkf-fe-packages/kmkf-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.1",
|
|
4
4
|
"module": "dist/esm/index.js",
|
|
5
5
|
"typings": "dist/esm/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "fe8404f42c30b927e372cba3eac352b365da758a",
|
|
45
45
|
"gitHooks": {
|
|
46
46
|
"pre-commit": "lint-staged"
|
|
47
47
|
}
|