@nocobase/plugin-field-china-region 1.4.0-alpha.8 → 1.4.0-beta.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.
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- (function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@formily/react")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@formily/react"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-field-china-region"]={},n["@nocobase/client"],n["@formily/react"]))})(this,function(n,e,i){"use strict";var y=Object.defineProperty,L=Object.defineProperties;var P=Object.getOwnPropertyDescriptors;var p=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var m=(n,e,i)=>e in n?y(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,v=(n,e)=>{for(var i in e||(e={}))R.call(e,i)&&m(n,i,e[i]);if(p)for(var i of p(e))x.call(e,i)&&m(n,i,e[i]);return n},C=(n,e)=>L(n,P(e));var S=(n,e,i)=>new Promise((d,u)=>{var f=o=>{try{a(i.next(o))}catch(s){u(s)}},r=o=>{try{a(i.throw(o))}catch(s){u(s)}},a=o=>o.done?d(o.value):Promise.resolve(o.value).then(f,r);a((i=i.apply(n,e)).next())});const d=r=>{const o=i.useField().componentProps.maxLevel;return e.useRequest({resource:"chinaRegions",action:"list",params:{sort:"code",paginate:!1,filter:{level:1}}},C(v({},r),{onSuccess(s){var l;r==null||r.onSuccess({data:((l=s==null?void 0:s.data)==null?void 0:l.map(c=>(o!==1&&(c.isLeaf=!1),c)))||[]})},manual:!0}))},u=()=>{const r=e.useAPIClient(),a=i.useField(),o=a.componentProps.maxLevel;return s=>{var c;const l=s[s.length-1];((c=l==null?void 0:l.children)==null?void 0:c.length)>0||(l.loading=!0,r.resource("chinaRegions").list({sort:"code",paginate:!1,filter:{parentCode:l.code}}).then(({data:t})=>{var g;l.loading=!1,l.children=((g=t==null?void 0:t.data)==null?void 0:g.map(h=>(o>h.level&&(h.isLeaf=!1),h)))||[],a.dataSource=[...a.dataSource]}).catch(t=>{console.error(t)}))}};class f extends e.Plugin{load(){return S(this,null,function*(){this.app.addScopes({useChinaRegionDataSource:d,useChinaRegionLoadData:u})})}}n.PluginFieldChinaRegionClient=f,n.default=f,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client"),require("@formily/react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-china-region",["@nocobase/client","@formily/react"],t):"object"==typeof exports?exports["@nocobase/plugin-field-china-region"]=t(require("@nocobase/client"),require("@formily/react")):e["@nocobase/plugin-field-china-region"]=t(e["@nocobase/client"],e["@formily/react"])}(self,function(e,t){return function(){"use strict";var n={505:function(e){e.exports=t},772:function(t){t.exports=e}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[e](i,i.exports,o),i.exports}o.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};o.r(i),o.d(i,{PluginFieldChinaRegionClient:function(){return g},default:function(){return m}});var u=o("772"),c=o("505");function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var l=function(e){var t,n,r=(0,c.useField)().componentProps.maxLevel;return(0,u.useRequest)({resource:"chinaRegions",action:"list",params:{sort:"code",paginate:!1,filter:{level:1}}},(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},e),n=(n={onSuccess:function(t){var n;null==e||e.onSuccess({data:(null==t?void 0:null===(n=t.data)||void 0===n?void 0:n.map(function(e){return 1!==r&&(e.isLeaf=!1),e}))||[]})},manual:!0},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))},f=function(){var e=(0,u.useAPIClient)(),t=(0,c.useField)(),n=t.componentProps.maxLevel;return function(r){var o,i=r[r.length-1];if(!((null==i?void 0:null===(o=i.children)||void 0===o?void 0:o.length)>0))i.loading=!0,e.resource("chinaRegions").list({sort:"code",paginate:!1,filter:{parentCode:i.code}}).then(function(e){var r,o,u=e.data;i.loading=!1,i.children=(null==u?void 0:null===(o=u.data)||void 0===o?void 0:o.map(function(e){return n>e.level&&(e.isLeaf=!1),e}))||[],t.dataSource=function(e){if(Array.isArray(e))return a(e)}(r=t.dataSource)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}}(r)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}).catch(function(e){console.error(e)})}};function s(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function p(e,t,n){return(p=h()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&d(o,n.prototype),o}).apply(null,arguments)}function y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(e,t){return(d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function v(e){var t="function"==typeof Map?new Map:void 0;return(v=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return p(e,arguments,b(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)})(e)}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}var g=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=b(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,h()?Reflect.construct(t,n||[],b(e).constructor):t.apply(e,n))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&d(e,t)}(o,e),t=o,n=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(e){return t.app.addScopes({useChinaRegionDataSource:l,useChinaRegionLoadData:f}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){s(i,r,o,u,c,"next",e)}function c(e){s(i,r,o,u,c,"throw",e)}u(void 0)})})()}}],y(t.prototype,n),o}(v(u.Plugin)),m=g;return i}()});
@@ -10,8 +10,8 @@
10
10
  module.exports = {
11
11
  "@formily/core": "2.3.0",
12
12
  "@formily/react": "2.3.0",
13
- "@nocobase/client": "1.4.0-alpha.8",
14
- "@nocobase/server": "1.4.0-alpha.8",
13
+ "@nocobase/client": "1.4.0-beta.1",
14
+ "@nocobase/server": "1.4.0-beta.1",
15
15
  "china-division": "2.7.0",
16
- "@nocobase/database": "1.4.0-alpha.8"
16
+ "@nocobase/database": "1.4.0-beta.1"
17
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-field-china-region",
3
- "version": "1.4.0-alpha.8",
3
+ "version": "1.4.0-beta.1",
4
4
  "displayName": "Administrative divisions of China",
5
5
  "displayName.zh-CN": "中国行政区划",
6
6
  "description": "Provides data and field type for administrative divisions of China.",
@@ -22,7 +22,7 @@
22
22
  "@nocobase/server": "1.x",
23
23
  "@nocobase/test": "1.x"
24
24
  },
25
- "gitHead": "aa36bd20b2028c5e133a59e922c2f1ab22c86dde",
25
+ "gitHead": "1ece4e558ba445088dbb658bd458eb0004295326",
26
26
  "keywords": [
27
27
  "Fields"
28
28
  ]