@fle-ui/plus-address-selection 1.0.8 → 1.0.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/README.md CHANGED
@@ -1,17 +1,17 @@
1
- # @fle-ui/plus-address-selection
2
-
3
- > @fle-ui/plus-address-selection
4
-
5
- ## Install
6
-
7
- Using npm:
8
-
9
- ```bash
10
- $ npm install --save @fle-ui/plus-address-selection
11
- ```
12
-
13
- or using yarn:
14
-
15
- ```bash
16
- $ yarn add @fle-ui/plus-address-selection
17
- ```
1
+ # @fle-ui/plus-address-selection
2
+
3
+ > @fle-ui/plus-address-selection
4
+
5
+ ## Install
6
+
7
+ Using npm:
8
+
9
+ ```bash
10
+ $ npm install --save @fle-ui/plus-address-selection
11
+ ```
12
+
13
+ or using yarn:
14
+
15
+ ```bash
16
+ $ yarn add @fle-ui/plus-address-selection
17
+ ```
package/es/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { CascaderProps } from 'antd';
3
+ import { Env } from './utils/api';
3
4
  export declare type CascaderValueType = string | Array<string | number>;
4
5
  export interface CascaderOptionType {
5
6
  value?: string | number;
@@ -29,12 +30,7 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
29
30
  */
30
31
  valueDivision?: string;
31
32
  /**
32
- * @description 接口地址 全地址哦
33
- * @default
34
- */
35
- apiUrl?: string;
36
- /**
37
- * @description 地址层级 默认四级
33
+ * @description 地址层级 默认四级 --
38
34
  * @default 4
39
35
  */
40
36
  level?: number;
@@ -48,6 +44,7 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
48
44
  * @default []
49
45
  */
50
46
  options?: CascaderOptionType[];
47
+ env?: Env;
51
48
  }
52
49
  declare const AddressSelection: React.FC<SiteSelectProps>;
53
50
  export default AddressSelection;
package/es/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
2
  import "antd/es/cascader/style";
3
3
  import _Cascader from "antd/es/cascader";
4
- var _excluded = ["level", "value", "onChange", "valueDivision", "apiUrl"];
4
+ var _excluded = ["env", "level", "value", "onChange", "valueDivision"];
5
5
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
6
6
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7
7
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
8
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
9
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
10
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
11
11
  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); } }
12
12
  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); }); }; }
13
13
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -16,18 +16,32 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
16
16
  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; }
17
17
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
18
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
21
+ 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; }
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
23
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
24
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
20
25
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
21
26
  import React, { useEffect, useState } from 'react';
22
27
  import _ from 'lodash';
23
- import { httpClient } from './utils';
28
+ import { apiCreate } from './utils/api';
29
+ var defaultProps = {
30
+ level: 4,
31
+ valueDivision: '',
32
+ value: [],
33
+ onChange: function onChange() {}
34
+ };
24
35
  var AddressSelection = function AddressSelection(props) {
25
- var level = props.level,
26
- value = props.value,
27
- onChange = props.onChange,
28
- valueDivision = props.valueDivision,
29
- apiUrl = props.apiUrl,
30
- otherProps = _objectWithoutProperties(props, _excluded);
36
+ var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
37
+ env = _defaultProps$props.env,
38
+ level = _defaultProps$props.level,
39
+ value = _defaultProps$props.value,
40
+ onChange = _defaultProps$props.onChange,
41
+ valueDivision = _defaultProps$props.valueDivision,
42
+ otherProps = _objectWithoutProperties(_defaultProps$props, _excluded);
43
+ var _apiCreate = apiCreate(env),
44
+ getAddress = _apiCreate.getAddress;
31
45
  var _useState = useState([]),
32
46
  _useState2 = _slicedToArray(_useState, 2),
33
47
  addressList = _useState2[0],
@@ -52,7 +66,7 @@ var AddressSelection = function AddressSelection(props) {
52
66
  while (1) switch (_context.prev = _context.next) {
53
67
  case 0:
54
68
  _context.next = 2;
55
- return getAddressAPI({
69
+ return getAddress({
56
70
  parentCode: 0
57
71
  });
58
72
  case 2:
@@ -105,57 +119,31 @@ var AddressSelection = function AddressSelection(props) {
105
119
  };
106
120
  });
107
121
  };
108
- var getAddressAPI = /*#__PURE__*/function () {
109
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
110
- var params,
111
- _yield$httpClient$pos,
112
- data,
113
- _args2 = arguments;
114
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
115
- while (1) switch (_context2.prev = _context2.next) {
116
- case 0:
117
- params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
118
- _context2.next = 3;
119
- return httpClient.post(apiUrl || '/basic/area/areas', params);
120
- case 3:
121
- _yield$httpClient$pos = _context2.sent;
122
- data = _yield$httpClient$pos.data;
123
- return _context2.abrupt("return", data);
124
- case 6:
125
- case "end":
126
- return _context2.stop();
127
- }
128
- }, _callee2);
129
- }));
130
- return function getAddressAPI() {
131
- return _ref.apply(this, arguments);
132
- };
133
- }();
134
122
  var initAddress = /*#__PURE__*/function () {
135
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(defaultValue, parentCode) {
123
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(defaultValue, parentCode) {
136
124
  var provinceList, len, thisAddress, _loop, i;
137
- return _regeneratorRuntime().wrap(function _callee3$(_context4) {
138
- while (1) switch (_context4.prev = _context4.next) {
125
+ return _regeneratorRuntime().wrap(function _callee2$(_context3) {
126
+ while (1) switch (_context3.prev = _context3.next) {
139
127
  case 0:
140
128
  provinceList = _.cloneDeep(addressList);
141
129
  len = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length;
142
130
  if (!len) {
143
- _context4.next = 11;
131
+ _context3.next = 11;
144
132
  break;
145
133
  }
146
134
  thisAddress = provinceList;
147
135
  _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(i) {
148
136
  var _thisAddress;
149
137
  var levelData, thisIndex;
150
- return _regeneratorRuntime().wrap(function _loop$(_context3) {
151
- while (1) switch (_context3.prev = _context3.next) {
138
+ return _regeneratorRuntime().wrap(function _loop$(_context2) {
139
+ while (1) switch (_context2.prev = _context2.next) {
152
140
  case 0:
153
- _context3.next = 2;
154
- return getAddressAPI({
141
+ _context2.next = 2;
142
+ return getAddress({
155
143
  parentCode: defaultValue[i]
156
144
  });
157
145
  case 2:
158
- levelData = _context3.sent;
146
+ levelData = _context2.sent;
159
147
  thisIndex = -1;
160
148
  (_thisAddress = thisAddress) === null || _thisAddress === void 0 ? void 0 : _thisAddress.forEach(function (item, index) {
161
149
  if (item.value === defaultValue[i]) {
@@ -171,53 +159,53 @@ var AddressSelection = function AddressSelection(props) {
171
159
  }
172
160
  case 7:
173
161
  case "end":
174
- return _context3.stop();
162
+ return _context2.stop();
175
163
  }
176
164
  }, _loop);
177
165
  });
178
166
  i = 0;
179
167
  case 6:
180
168
  if (!(i < len - 1)) {
181
- _context4.next = 11;
169
+ _context3.next = 11;
182
170
  break;
183
171
  }
184
- return _context4.delegateYield(_loop(i), "t0", 8);
172
+ return _context3.delegateYield(_loop(i), "t0", 8);
185
173
  case 8:
186
174
  i++;
187
- _context4.next = 6;
175
+ _context3.next = 6;
188
176
  break;
189
177
  case 11:
190
178
  setAddressList(provinceList);
191
179
  case 12:
192
180
  case "end":
193
- return _context4.stop();
181
+ return _context3.stop();
194
182
  }
195
- }, _callee3);
183
+ }, _callee2);
196
184
  }));
197
185
  return function initAddress(_x, _x2) {
198
- return _ref2.apply(this, arguments);
186
+ return _ref.apply(this, arguments);
199
187
  };
200
188
  }();
201
189
  var loadData = /*#__PURE__*/function () {
202
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(selectedOptions) {
190
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(selectedOptions) {
203
191
  var targetOption, data;
204
- return _regeneratorRuntime().wrap(function _callee4$(_context5) {
205
- while (1) switch (_context5.prev = _context5.next) {
192
+ return _regeneratorRuntime().wrap(function _callee3$(_context4) {
193
+ while (1) switch (_context4.prev = _context4.next) {
206
194
  case 0:
207
195
  targetOption = selectedOptions[selectedOptions.length - 1];
208
196
  if (!(stateValue === null || stateValue === void 0 ? void 0 : stateValue.includes(targetOption.value))) {
209
- _context5.next = 3;
197
+ _context4.next = 3;
210
198
  break;
211
199
  }
212
- return _context5.abrupt("return");
200
+ return _context4.abrupt("return");
213
201
  case 3:
214
202
  targetOption.loading = true;
215
- _context5.next = 6;
216
- return getAddressAPI({
203
+ _context4.next = 6;
204
+ return getAddress({
217
205
  parentCode: targetOption.value
218
206
  });
219
207
  case 6:
220
- data = _context5.sent;
208
+ data = _context4.sent;
221
209
  targetOption.loading = false;
222
210
  if (data.length) {
223
211
  targetOption.children = formatArea(data, targetOption.level + 1 === level);
@@ -228,16 +216,16 @@ var AddressSelection = function AddressSelection(props) {
228
216
  setAddressList(_toConsumableArray(addressList));
229
217
  case 11:
230
218
  case "end":
231
- return _context5.stop();
219
+ return _context4.stop();
232
220
  }
233
- }, _callee4);
221
+ }, _callee3);
234
222
  }));
235
223
  return function loadData(_x3) {
236
- return _ref3.apply(this, arguments);
224
+ return _ref2.apply(this, arguments);
237
225
  };
238
226
  }();
239
227
  var handleChange = function handleChange(info, selectedOptions) {
240
- var cascaderValue = info;
228
+ var cascaderValue = info || [];
241
229
  if (valueDivision) {
242
230
  cascaderValue = cascaderValue.join(valueDivision);
243
231
  }
@@ -249,14 +237,7 @@ var AddressSelection = function AddressSelection(props) {
249
237
  loadData: loadData,
250
238
  options: addressList,
251
239
  onChange: handleChange,
252
- value: formatValue(value).length === 0 ? stateValue : formatValue(value)
240
+ value: props.value ? value : stateValue
253
241
  }));
254
242
  };
255
- AddressSelection.defaultProps = {
256
- level: 4,
257
- valueDivision: '',
258
- value: [],
259
- onChange: function onChange() {},
260
- apiUrl: ''
261
- };
262
243
  export default AddressSelection;
@@ -0,0 +1,10 @@
1
+ declare const baseURLMap: {
2
+ dev: string;
3
+ qa: string;
4
+ prod: string;
5
+ };
6
+ export type Env = keyof typeof baseURLMap;
7
+ export declare const apiCreate: (env?: Env) => {
8
+ getAddress(data: any): Promise<any>;
9
+ };
10
+ export {};
@@ -0,0 +1,24 @@
1
+ import axios from 'axios';
2
+ var baseURLMap = {
3
+ dev: 'https://dev-gateway.fxqifu.net/pangu',
4
+ qa: 'https://qa-gateway.fxqifu.net/pangu',
5
+ prod: 'https://gateway.fxqifu.net/pangu'
6
+ };
7
+ export var apiCreate = function apiCreate(env) {
8
+ var envGet = env || localStorage.getItem('env') || 'prod';
9
+ var baseURL = baseURLMap[envGet];
10
+ return {
11
+ getAddress: function getAddress(data) {
12
+ return new Promise(function (resolve, reject) {
13
+ axios.post("".concat(baseURL, "/basic/area/areas"), data).then(function (res) {
14
+ var _res$data;
15
+ if (Array.isArray((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.data)) {
16
+ resolve(res.data.data);
17
+ } else {
18
+ resolve([]);
19
+ }
20
+ }).catch(reject);
21
+ });
22
+ }
23
+ };
24
+ };
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { CascaderProps } from 'antd';
3
+ import { Env } from './utils/api';
3
4
  export declare type CascaderValueType = string | Array<string | number>;
4
5
  export interface CascaderOptionType {
5
6
  value?: string | number;
@@ -29,12 +30,7 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
29
30
  */
30
31
  valueDivision?: string;
31
32
  /**
32
- * @description 接口地址 全地址哦
33
- * @default
34
- */
35
- apiUrl?: string;
36
- /**
37
- * @description 地址层级 默认四级
33
+ * @description 地址层级 默认四级 --
38
34
  * @default 4
39
35
  */
40
36
  level?: number;
@@ -48,6 +44,7 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
48
44
  * @default []
49
45
  */
50
46
  options?: CascaderOptionType[];
47
+ env?: Env;
51
48
  }
52
49
  declare const AddressSelection: React.FC<SiteSelectProps>;
53
50
  export default AddressSelection;
package/lib/index.js CHANGED
@@ -8,17 +8,17 @@ exports.default = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _antd = require("antd");
10
10
  var _lodash = _interopRequireDefault(require("lodash"));
11
- var _utils = require("./utils");
12
- var _excluded = ["level", "value", "onChange", "valueDivision", "apiUrl"];
11
+ var _api = require("./utils/api");
12
+ var _excluded = ["env", "level", "value", "onChange", "valueDivision"];
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
16
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
17
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
18
18
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
19
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
20
20
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
21
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
21
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
22
22
  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); } }
23
23
  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); }); }; }
24
24
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -27,15 +27,29 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
27
27
  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; }
28
28
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
29
29
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
30
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
31
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
32
+ 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; }
33
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
34
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
30
35
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
31
36
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
37
+ var defaultProps = {
38
+ level: 4,
39
+ valueDivision: '',
40
+ value: [],
41
+ onChange: function onChange() {}
42
+ };
32
43
  var AddressSelection = function AddressSelection(props) {
33
- var level = props.level,
34
- value = props.value,
35
- onChange = props.onChange,
36
- valueDivision = props.valueDivision,
37
- apiUrl = props.apiUrl,
38
- otherProps = _objectWithoutProperties(props, _excluded);
44
+ var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
45
+ env = _defaultProps$props.env,
46
+ level = _defaultProps$props.level,
47
+ value = _defaultProps$props.value,
48
+ onChange = _defaultProps$props.onChange,
49
+ valueDivision = _defaultProps$props.valueDivision,
50
+ otherProps = _objectWithoutProperties(_defaultProps$props, _excluded);
51
+ var _apiCreate = (0, _api.apiCreate)(env),
52
+ getAddress = _apiCreate.getAddress;
39
53
  var _useState = (0, _react.useState)([]),
40
54
  _useState2 = _slicedToArray(_useState, 2),
41
55
  addressList = _useState2[0],
@@ -60,7 +74,7 @@ var AddressSelection = function AddressSelection(props) {
60
74
  while (1) switch (_context.prev = _context.next) {
61
75
  case 0:
62
76
  _context.next = 2;
63
- return getAddressAPI({
77
+ return getAddress({
64
78
  parentCode: 0
65
79
  });
66
80
  case 2:
@@ -113,57 +127,31 @@ var AddressSelection = function AddressSelection(props) {
113
127
  };
114
128
  });
115
129
  };
116
- var getAddressAPI = /*#__PURE__*/function () {
117
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
118
- var params,
119
- _yield$httpClient$pos,
120
- data,
121
- _args2 = arguments;
122
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
123
- while (1) switch (_context2.prev = _context2.next) {
124
- case 0:
125
- params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
126
- _context2.next = 3;
127
- return _utils.httpClient.post(apiUrl || '/basic/area/areas', params);
128
- case 3:
129
- _yield$httpClient$pos = _context2.sent;
130
- data = _yield$httpClient$pos.data;
131
- return _context2.abrupt("return", data);
132
- case 6:
133
- case "end":
134
- return _context2.stop();
135
- }
136
- }, _callee2);
137
- }));
138
- return function getAddressAPI() {
139
- return _ref.apply(this, arguments);
140
- };
141
- }();
142
130
  var initAddress = /*#__PURE__*/function () {
143
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(defaultValue, parentCode) {
131
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(defaultValue, parentCode) {
144
132
  var provinceList, len, thisAddress, _loop, i;
145
- return _regeneratorRuntime().wrap(function _callee3$(_context4) {
146
- while (1) switch (_context4.prev = _context4.next) {
133
+ return _regeneratorRuntime().wrap(function _callee2$(_context3) {
134
+ while (1) switch (_context3.prev = _context3.next) {
147
135
  case 0:
148
136
  provinceList = _lodash.default.cloneDeep(addressList);
149
137
  len = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length;
150
138
  if (!len) {
151
- _context4.next = 11;
139
+ _context3.next = 11;
152
140
  break;
153
141
  }
154
142
  thisAddress = provinceList;
155
143
  _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(i) {
156
144
  var _thisAddress;
157
145
  var levelData, thisIndex;
158
- return _regeneratorRuntime().wrap(function _loop$(_context3) {
159
- while (1) switch (_context3.prev = _context3.next) {
146
+ return _regeneratorRuntime().wrap(function _loop$(_context2) {
147
+ while (1) switch (_context2.prev = _context2.next) {
160
148
  case 0:
161
- _context3.next = 2;
162
- return getAddressAPI({
149
+ _context2.next = 2;
150
+ return getAddress({
163
151
  parentCode: defaultValue[i]
164
152
  });
165
153
  case 2:
166
- levelData = _context3.sent;
154
+ levelData = _context2.sent;
167
155
  thisIndex = -1;
168
156
  (_thisAddress = thisAddress) === null || _thisAddress === void 0 ? void 0 : _thisAddress.forEach(function (item, index) {
169
157
  if (item.value === defaultValue[i]) {
@@ -179,53 +167,53 @@ var AddressSelection = function AddressSelection(props) {
179
167
  }
180
168
  case 7:
181
169
  case "end":
182
- return _context3.stop();
170
+ return _context2.stop();
183
171
  }
184
172
  }, _loop);
185
173
  });
186
174
  i = 0;
187
175
  case 6:
188
176
  if (!(i < len - 1)) {
189
- _context4.next = 11;
177
+ _context3.next = 11;
190
178
  break;
191
179
  }
192
- return _context4.delegateYield(_loop(i), "t0", 8);
180
+ return _context3.delegateYield(_loop(i), "t0", 8);
193
181
  case 8:
194
182
  i++;
195
- _context4.next = 6;
183
+ _context3.next = 6;
196
184
  break;
197
185
  case 11:
198
186
  setAddressList(provinceList);
199
187
  case 12:
200
188
  case "end":
201
- return _context4.stop();
189
+ return _context3.stop();
202
190
  }
203
- }, _callee3);
191
+ }, _callee2);
204
192
  }));
205
193
  return function initAddress(_x, _x2) {
206
- return _ref2.apply(this, arguments);
194
+ return _ref.apply(this, arguments);
207
195
  };
208
196
  }();
209
197
  var loadData = /*#__PURE__*/function () {
210
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(selectedOptions) {
198
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(selectedOptions) {
211
199
  var targetOption, data;
212
- return _regeneratorRuntime().wrap(function _callee4$(_context5) {
213
- while (1) switch (_context5.prev = _context5.next) {
200
+ return _regeneratorRuntime().wrap(function _callee3$(_context4) {
201
+ while (1) switch (_context4.prev = _context4.next) {
214
202
  case 0:
215
203
  targetOption = selectedOptions[selectedOptions.length - 1];
216
204
  if (!(stateValue === null || stateValue === void 0 ? void 0 : stateValue.includes(targetOption.value))) {
217
- _context5.next = 3;
205
+ _context4.next = 3;
218
206
  break;
219
207
  }
220
- return _context5.abrupt("return");
208
+ return _context4.abrupt("return");
221
209
  case 3:
222
210
  targetOption.loading = true;
223
- _context5.next = 6;
224
- return getAddressAPI({
211
+ _context4.next = 6;
212
+ return getAddress({
225
213
  parentCode: targetOption.value
226
214
  });
227
215
  case 6:
228
- data = _context5.sent;
216
+ data = _context4.sent;
229
217
  targetOption.loading = false;
230
218
  if (data.length) {
231
219
  targetOption.children = formatArea(data, targetOption.level + 1 === level);
@@ -236,16 +224,16 @@ var AddressSelection = function AddressSelection(props) {
236
224
  setAddressList(_toConsumableArray(addressList));
237
225
  case 11:
238
226
  case "end":
239
- return _context5.stop();
227
+ return _context4.stop();
240
228
  }
241
- }, _callee4);
229
+ }, _callee3);
242
230
  }));
243
231
  return function loadData(_x3) {
244
- return _ref3.apply(this, arguments);
232
+ return _ref2.apply(this, arguments);
245
233
  };
246
234
  }();
247
235
  var handleChange = function handleChange(info, selectedOptions) {
248
- var cascaderValue = info;
236
+ var cascaderValue = info || [];
249
237
  if (valueDivision) {
250
238
  cascaderValue = cascaderValue.join(valueDivision);
251
239
  }
@@ -257,14 +245,7 @@ var AddressSelection = function AddressSelection(props) {
257
245
  loadData: loadData,
258
246
  options: addressList,
259
247
  onChange: handleChange,
260
- value: formatValue(value).length === 0 ? stateValue : formatValue(value)
248
+ value: props.value ? value : stateValue
261
249
  }));
262
250
  };
263
- AddressSelection.defaultProps = {
264
- level: 4,
265
- valueDivision: '',
266
- value: [],
267
- onChange: function onChange() {},
268
- apiUrl: ''
269
- };
270
251
  var _default = exports.default = AddressSelection;
@@ -0,0 +1,10 @@
1
+ declare const baseURLMap: {
2
+ dev: string;
3
+ qa: string;
4
+ prod: string;
5
+ };
6
+ export type Env = keyof typeof baseURLMap;
7
+ export declare const apiCreate: (env?: Env) => {
8
+ getAddress(data: any): Promise<any>;
9
+ };
10
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.apiCreate = void 0;
7
+ var _axios = _interopRequireDefault(require("axios"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ var baseURLMap = {
10
+ dev: 'https://dev-gateway.fxqifu.net/pangu',
11
+ qa: 'https://qa-gateway.fxqifu.net/pangu',
12
+ prod: 'https://gateway.fxqifu.net/pangu'
13
+ };
14
+ var apiCreate = exports.apiCreate = function apiCreate(env) {
15
+ var envGet = env || localStorage.getItem('env') || 'prod';
16
+ var baseURL = baseURLMap[envGet];
17
+ return {
18
+ getAddress: function getAddress(data) {
19
+ return new Promise(function (resolve, reject) {
20
+ _axios.default.post("".concat(baseURL, "/basic/area/areas"), data).then(function (res) {
21
+ var _res$data;
22
+ if (Array.isArray((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.data)) {
23
+ resolve(res.data.data);
24
+ } else {
25
+ resolve([]);
26
+ }
27
+ }).catch(reject);
28
+ });
29
+ }
30
+ };
31
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fle-ui/plus-address-selection",
3
- "version": "1.0.8",
3
+ "version": "1.0.11",
4
4
  "description": "@fle-ui/plus-address-selection",
5
5
  "private": false,
6
6
  "main": "lib/index.js",
@@ -41,5 +41,5 @@
41
41
  "devDependencies": {
42
42
  "@types/js-cookie": "^3.0.0"
43
43
  },
44
- "gitHead": "b7b23a456b7fbe96c8d518351092e6ae4905e153"
44
+ "gitHead": "89623cde9674f6e35e70f4678f856578d60019f9"
45
45
  }
@@ -1,13 +0,0 @@
1
- export interface Response {
2
- status: number;
3
- data: any;
4
- statusText: string;
5
- }
6
- export interface AxiosRequestConfig {
7
- baseURL?: string;
8
- timeout: number;
9
- headers?: any;
10
- url?: string;
11
- }
12
- declare const httpClient: import("axios").AxiosInstance;
13
- export default httpClient;
@@ -1,76 +0,0 @@
1
- import "antd/es/notification/style";
2
- import _notification from "antd/es/notification";
3
- import axios from 'axios';
4
- import Cookies from 'js-cookie';
5
- var axiosConfig = {
6
- baseURL: 'https://gateway.fxqifu.net/pangu',
7
- timeout: 60000
8
- };
9
- var httpClient = axios.create(axiosConfig);
10
- // 登陆页面接口列表,不需要带token
11
- var loginMap = [''];
12
- httpClient.interceptors.request.use(function (config) {
13
- config.headers['Content-Type'] = 'application/json;charset=UTF-8';
14
- if (loginMap.find(function (item) {
15
- return config.url.endsWith(item);
16
- })) {
17
- delete config.headers['authority_token'];
18
- } else {
19
- var tokenFrom = config['tokenFrom'];
20
- var token = '';
21
- switch (tokenFrom) {
22
- case 'cookie':
23
- token = Cookies.get('token');
24
- break;
25
- case 'localstorage':
26
- token = localStorage.getItem('token');
27
- break;
28
- default:
29
- token = Cookies.get('token') || localStorage.getItem('token');
30
- }
31
- config.headers['authority_token'] = token;
32
- }
33
- return config;
34
- }, function (err) {
35
- _notification.error({
36
- message: '发送请求失败',
37
- // @ts-ignore
38
- description: err
39
- });
40
- return false;
41
- });
42
- httpClient.interceptors.response.use(function (res) {
43
- var status = res.status,
44
- data = res.data,
45
- statusText = res.statusText;
46
- return new Promise(function (resolve, reject) {
47
- if (status < 200 || status > 300) {
48
- _notification.error({
49
- message: "\u8BF7\u6C42\u9519\u8BEF: ".concat(status),
50
- description: statusText
51
- });
52
- } else if (!data.success) {
53
- if (data.code === '915003') {
54
- return reject(data);
55
- }
56
- if (data.code === '100003') {
57
- return reject(data);
58
- }
59
- _notification.error({
60
- message: '提示',
61
- description: data.message
62
- });
63
- return reject(data);
64
- } else {
65
- return resolve(data || true);
66
- }
67
- return reject();
68
- });
69
- }, function () {
70
- _notification.error({
71
- message: '提示',
72
- description: '系统错误'
73
- });
74
- return false;
75
- });
76
- export default httpClient;
@@ -1,2 +0,0 @@
1
- import httpClient from './httpClient';
2
- export { httpClient };
package/es/utils/index.js DELETED
@@ -1,2 +0,0 @@
1
- import httpClient from './httpClient';
2
- export { httpClient };
@@ -1,13 +0,0 @@
1
- export interface Response {
2
- status: number;
3
- data: any;
4
- statusText: string;
5
- }
6
- export interface AxiosRequestConfig {
7
- baseURL?: string;
8
- timeout: number;
9
- headers?: any;
10
- url?: string;
11
- }
12
- declare const httpClient: import("axios").AxiosInstance;
13
- export default httpClient;
@@ -1,82 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _axios = _interopRequireDefault(require("axios"));
8
- var _antd = require("antd");
9
- var _jsCookie = _interopRequireDefault(require("js-cookie"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- var axiosConfig = {
12
- baseURL: 'https://gateway.fxqifu.net/pangu',
13
- timeout: 60000
14
- };
15
- var httpClient = _axios.default.create(axiosConfig);
16
- // 登陆页面接口列表,不需要带token
17
- var loginMap = [''];
18
- httpClient.interceptors.request.use(function (config) {
19
- config.headers['Content-Type'] = 'application/json;charset=UTF-8';
20
- if (loginMap.find(function (item) {
21
- return config.url.endsWith(item);
22
- })) {
23
- delete config.headers['authority_token'];
24
- } else {
25
- var tokenFrom = config['tokenFrom'];
26
- var token = '';
27
- switch (tokenFrom) {
28
- case 'cookie':
29
- token = _jsCookie.default.get('token');
30
- break;
31
- case 'localstorage':
32
- token = localStorage.getItem('token');
33
- break;
34
- default:
35
- token = _jsCookie.default.get('token') || localStorage.getItem('token');
36
- }
37
- config.headers['authority_token'] = token;
38
- }
39
- return config;
40
- }, function (err) {
41
- _antd.notification.error({
42
- message: '发送请求失败',
43
- // @ts-ignore
44
- description: err
45
- });
46
- return false;
47
- });
48
- httpClient.interceptors.response.use(function (res) {
49
- var status = res.status,
50
- data = res.data,
51
- statusText = res.statusText;
52
- return new Promise(function (resolve, reject) {
53
- if (status < 200 || status > 300) {
54
- _antd.notification.error({
55
- message: "\u8BF7\u6C42\u9519\u8BEF: ".concat(status),
56
- description: statusText
57
- });
58
- } else if (!data.success) {
59
- if (data.code === '915003') {
60
- return reject(data);
61
- }
62
- if (data.code === '100003') {
63
- return reject(data);
64
- }
65
- _antd.notification.error({
66
- message: '提示',
67
- description: data.message
68
- });
69
- return reject(data);
70
- } else {
71
- return resolve(data || true);
72
- }
73
- return reject();
74
- });
75
- }, function () {
76
- _antd.notification.error({
77
- message: '提示',
78
- description: '系统错误'
79
- });
80
- return false;
81
- });
82
- var _default = exports.default = httpClient;
@@ -1,2 +0,0 @@
1
- import httpClient from './httpClient';
2
- export { httpClient };
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "httpClient", {
7
- enumerable: true,
8
- get: function get() {
9
- return _httpClient.default;
10
- }
11
- });
12
- var _httpClient = _interopRequireDefault(require("./httpClient"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }