@nocobase/plugin-field-china-region 2.1.0-beta.30 → 2.1.0-beta.33

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/client-v2.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/client-v2';
2
+ export { default } from './dist/client-v2';
package/client-v2.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client-v2/index.js');
@@ -15,14 +15,7 @@ export declare class ChinaRegionFieldInterface extends CollectionFieldInterface
15
15
  title: string;
16
16
  isAssociation: boolean;
17
17
  default: {
18
- interface: string;
19
- type: string;
20
- target: string;
21
- targetKey: string;
22
- sortBy: string;
23
18
  uiSchema: {
24
- type: string;
25
- 'x-component': string;
26
19
  'x-component-props': {
27
20
  useDataSource: string;
28
21
  useLoadData: string;
@@ -35,7 +28,14 @@ export declare class ChinaRegionFieldInterface extends CollectionFieldInterface
35
28
  children: string;
36
29
  };
37
30
  };
31
+ type: string;
32
+ 'x-component': string;
38
33
  };
34
+ interface: string;
35
+ type: string;
36
+ target: string;
37
+ targetKey: string;
38
+ sortBy: string;
39
39
  };
40
40
  availableTypes: string[];
41
41
  initialize(values: any): void;
@@ -82,8 +82,6 @@ export declare class ChinaRegionFieldInterface extends CollectionFieldInterface
82
82
  };
83
83
  filterable: {
84
84
  children: {
85
- name: string;
86
- title: string;
87
85
  operators: ({
88
86
  label: string;
89
87
  value: string;
@@ -100,6 +98,8 @@ export declare class ChinaRegionFieldInterface extends CollectionFieldInterface
100
98
  noValue: boolean;
101
99
  selected?: undefined;
102
100
  })[];
101
+ name: string;
102
+ title: string;
103
103
  schema: {
104
104
  title: string;
105
105
  type: string;
@@ -10,4 +10,5 @@ import { Plugin } from '@nocobase/client';
10
10
  export declare class PluginFieldChinaRegionClient extends Plugin {
11
11
  load(): Promise<void>;
12
12
  }
13
+ export { ChinaRegionFieldModel, DisplayChinaRegionFieldModel } from '../client-v2/models';
13
14
  export default PluginFieldChinaRegionClient;
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/flow-engine"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-china-region",["@formily/shared","react","antd","@nocobase/client","@formily/react","@nocobase/flow-engine","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-field-china-region"]=t(require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/flow-engine"),require("lodash")):e["@nocobase/plugin-field-china-region"]=t(e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e["@formily/react"],e["@nocobase/flow-engine"],e.lodash)}(self,function(e,t,r,n,o,i,a){return function(){"use strict";var c={230:function(e){e.exports=o},166:function(t){t.exports=e},342:function(e){e.exports=n},694:function(e){e.exports=i},59:function(e){e.exports=r},773:function(e){e.exports=a},155:function(e){e.exports=t}},l={};function u(e){var t=l[e];if(void 0!==t)return t.exports;var r=l[e]={exports:{}};return c[e](r,r.exports,u),r.exports}u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},u.d=function(e,t){for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.g.importScripts&&(f=u.g.location+"");var f,s=u.g.document;if(!f&&s&&(s.currentScript&&"SCRIPT"===s.currentScript.tagName.toUpperCase()&&(f=s.currentScript.src),!f)){var p=s.getElementsByTagName("script");if(p.length)for(var y=p.length-1;y>-1&&(!f||!/^http(s?):/.test(f));)f=p[y--].src}if(!f)throw Error("Automatic publicPath is not supported in this browser");u.p=f.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var b={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-field-china-region/dist/client/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var n=window.location.pathname||"/",o=n.indexOf("/v2/");e=o>=0?n.slice(0,o+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-field-china-region/dist/client/"}u.p=e}(),!function(){u.r(b),u.d(b,{PluginFieldChinaRegionClient:function(){return K},default:function(){return $}});var e=u(342),t=u(230);function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var n=function(r){var n,o,i=(0,t.useField)().componentProps.maxLevel;return(0,e.useRequest)({resource:"chinaRegions",action:"list",params:{sort:"code",paginate:!1,filter:{level:1}}},(n=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},r),o=o={onSuccess:function(e){var t;null==r||r.onSuccess({data:(null==e||null==(t=e.data)?void 0:t.map(function(e){return 1!==i&&(e.isLeaf=!1),e}))||[]})},manual:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(o)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}),n))},o=function(){var n=(0,e.useAPIClient)(),o=(0,t.useField)(),i=o.componentProps.maxLevel;return function(e){var t,a=e[e.length-1];(null==a||null==(t=a.children)?void 0:t.length)>0||(a.loading=!0,n.resource("chinaRegions").list({sort:"code",paginate:!1,filter:{parentCode:a.code}}).then(function(e){var t,n,c=e.data;a.loading=!1,a.children=(null==c||null==(n=c.data)?void 0:n.map(function(e){return i>e.level&&(e.isLeaf=!1),e}))||[],o.dataSource=function(e){if(Array.isArray(e))return r(e)}(t=o.dataSource)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e){if(e){if("string"==typeof e)return r(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return r(e,void 0)}}(t)||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)}))}},i=u(166);function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}var s=function(t){var r;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function n(){var t,r,o,i,l;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return r=n,o=arguments,r=c(r),a(t=function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,f()?Reflect.construct(r,o||[],c(this).constructor):r.apply(this,o)),"name","chinaRegion"),a(t,"type","object"),a(t,"group","choices"),a(t,"order",7),a(t,"title",'{{t("China region")}}'),a(t,"isAssociation",!0),a(t,"default",{interface:"chinaRegion",type:"belongsToMany",target:"chinaRegions",targetKey:"code",sortBy:"level",uiSchema:{type:"array","x-component":"Cascader","x-component-props":{useDataSource:"{{ useChinaRegionDataSource }}",useLoadData:"{{ useChinaRegionLoadData }}",changeOnSelectLast:!1,labelInValue:!0,maxLevel:3,fieldNames:{label:"name",value:"code",children:"children"}}}}),a(t,"availableTypes",["belongsToMany"]),a(t,"properties",(i=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){a(e,t,r[t])})}return e}({},e.defaultProps),l=l={"uiSchema.x-component-props.maxLevel":{type:"number","x-component":"Radio.Group","x-decorator":"FormItem",title:'{{t("Select level")}}',default:3,enum:[{value:1,label:'{{t("Province")}}'},{value:2,label:'{{t("City")}}'},{value:3,label:'{{t("Area")}}'},{value:4,label:'{{t("Street")}}',disabled:!0},{value:5,label:'{{t("Village")}}',disabled:!0}]},"uiSchema.x-component-props.changeOnSelectLast":{type:"boolean","x-component":"Checkbox","x-content":'{{t("Must select to the last level")}}',"x-decorator":"FormItem"}},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(l)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(l)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(l,e))}),i)),a(t,"filterable",{children:[{name:"name",title:'{{t("Province/city/area name")}}',operators:e.operators.string,schema:{title:'{{t("Province/city/area name")}}',type:"string","x-component":"Input"}}]}),t}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&l(n,t),r=[{key:"initialize",value:function(e){e.through||(e.through="t_".concat((0,i.uid)())),e.foreignKey||(e.foreignKey="f_".concat((0,i.uid)())),e.otherKey||(e.otherKey="f_".concat((0,i.uid)())),e.sourceKey||(e.sourceKey="id"),e.targetKey||(e.targetKey="id")}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(n.prototype,r),n}(e.CollectionFieldInterface),p=u(155),y=u.n(p),d=u(59),h=u(773),v=u(694);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function g(e){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function j(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function S(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function P(e,t){if(e){if("string"==typeof e)return m(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return m(e,t)}}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_=function(){return!!e})()}var x=function(t){var r,n=t.value,o=t.onChange,i=t.maxLevel,a=void 0===i?3:i,c=t.changeOnSelectLast,l=t.labelInValue,u=t.fieldNames,f=void 0===u?{label:"name",value:"code",children:"children"}:u,s=(t.multiple,function(e,t){if(null==e)return{};var r,n,o,i={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,r=Reflect.ownKeys(Object(e));o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}if(i=function(e,t){if(null==e)return{};var r,n,o={},i=Object.getOwnPropertyNames(e);for(n=0;n<i.length;n++)r=i[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}(t,["value","onChange","maxLevel","changeOnSelectLast","labelInValue","fieldNames","multiple"])),p=(0,e.useAPIClient)(),b=(0,e.useRequest)({resource:"chinaRegions",action:"list",params:{sort:"code",paginate:!1,filter:{level:1}}},{manual:!0}),v=b.data,g=b.loading,w=b.run,_=function(e){if(Array.isArray(e))return e}(r=y().useState([]))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,a=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(a)throw r}}return o}}(r)||P(r,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),x=_[0],R=_[1];y().useEffect(function(){(null==v?void 0:v.data)&&R(v.data.map(function(e){return j(O({},e),{isLeaf:1===a})}))},[v,a]);var A=y().useCallback(function(e){e&&0===x.length&&w()},[x.length,w]),C=y().useCallback(function(e){var t,r=e[e.length-1];(null==r||null==(t=r.children)?void 0:t.length)>0||(r.loading=!0,p.resource("chinaRegions").list({sort:"code",paginate:!1,filter:{parentCode:r.code}}).then(function(e){var t,n=e.data;r.loading=!1,r.children=(null==n||null==(t=n.data)?void 0:t.map(function(e){return j(O({},e),{isLeaf:a<=e.level})}))||[],R(function(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||P(e)||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),r.loading=!1}))},[p,a]),E=y().useCallback(function(){if(n)return(Array.isArray(n)?n:[n]).map(function(e){return(void 0===e?"undefined":S(e))==="object"?e[f.value]:e})},[n,f.value]),I=y().useCallback(function(e,t){if(!n)return e.join(" / ");var r=(Array.isArray(n)?n:[n]).filter(function(e){return(void 0===e?"undefined":S(e))==="object"}).sort(function(e,t){return(e.level||0)-(t.level||0)});return e.map(function(e,n){return t[n]?t[n][f.label]:r[n]&&r[n][f.label]?r[n][f.label]:e}).join(" / ")},[n,f.label]),k=y().useCallback(function(e,t){e&&l?null==o||o(t.map(function(e){return(0,h.omit)(e,[f.children])})||null):null==o||o(e||null)},[o,l,f.children]);return y().createElement(d.Cascader,j(O({},s),{loading:g,options:x,value:E(),loadData:C,fieldNames:f,displayRender:I,multiple:!1,changeOnSelect:(0,h.isBoolean)(c)?!c:s.changeOnSelect,onDropdownVisibleChange:A,onChange:k}))},R=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=g(e),function(e,t){if(t&&("object"===S(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,_()?Reflect.construct(e,t||[],g(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&w(r,e),t=[{key:"render",value:function(){return y().createElement(x,this.props)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(e.FieldModel);function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}v.EditableItemModel.bindModelToInterface("ChinaRegionFieldModel",["chinaRegion"],{isDefault:!0});function C(e){return(C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function I(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function k(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(k=function(){return!!e})()}var D=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=C(e),function(e,t){if(t&&("object"===I(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,k()?Reflect.construct(e,t||[],C(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&E(r,e),t=[{key:"render",value:function(){var e=this.props.value;if(!e||Array.isArray(e)&&0===e.length)return null;if(Array.isArray(e)){var t=((function(e){if(Array.isArray(e))return A(e)})(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return A(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return A(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).sort(function(e,t){return e.level!==t.level?e.level-t.level:(e.sort||0)-(t.sort||0)}).map(function(e){return e.name||e.label||e}).filter(Boolean);return y().createElement("span",null,t.join("/"))}return(void 0===e?"undefined":I(e))==="object"&&e.name?y().createElement("span",null,e.name):y().createElement("span",null,String(e))}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(e.FieldModel);function T(e,t,r,n,o,i,a){try{var c=e[i](a),l=c.value}catch(e){r(e);return}c.done?t(l):Promise.resolve(l).then(n,o)}function M(e,t,r){return(M=B()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&q(o,r.prototype),o}).apply(null,arguments)}v.DisplayItemModel.bindModelToInterface("DisplayChinaRegionFieldModel",["chinaRegion"],{isDefault:!0});function L(e){return(L=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function F(e){var t="function"==typeof Map?new Map:void 0;return(F=function(e){if(null===e||-1===Function.toString.call(e).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 M(e,arguments,L(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),q(r,e)})(e)}function B(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(B=function(){return!!e})()}var K=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=L(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,B()?Reflect.construct(e,t||[],L(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&q(r,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return this.app.addScopes({useChinaRegionDataSource:n,useChinaRegionLoadData:o}),this.app.dataSourceManager.addFieldInterfaces([s]),this.flowEngine.registerModels({ChinaRegionFieldModel:R,DisplayChinaRegionFieldModel:D}),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){T(i,n,o,a,c,"next",e)}function c(e){T(i,n,o,a,c,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(F(e.Plugin)),$=K}(),b}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("@nocobase/client-v2"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/flow-engine"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-china-region",["ahooks","@nocobase/client-v2","@formily/shared","react","antd","@nocobase/client","@formily/react","@nocobase/flow-engine","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-field-china-region"]=t(require("ahooks"),require("@nocobase/client-v2"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/flow-engine"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-field-china-region"]=t(e.ahooks,e["@nocobase/client-v2"],e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e["@formily/react"],e["@nocobase/flow-engine"],e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,r,n,o,i,a,c,l,u){return function(){"use strict";var f={230:function(e){e.exports=a},166:function(e){e.exports=r},342:function(e){e.exports=i},485:function(e){e.exports=t},694:function(e){e.exports=c},768:function(e){e.exports=l},625:function(t){t.exports=e},59:function(e){e.exports=o},773:function(e){e.exports=u},155:function(e){e.exports=n}},s={};function p(e){var t=s[e];if(void 0!==t)return t.exports;var r=s[e]={exports:{}};return f[e](r,r.exports,p),r.exports}p.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(t,{a:t}),t},p.d=function(e,t){for(var r in t)p.o(t,r)&&!p.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},p.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},p.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},p.g.importScripts&&(b=p.g.location+"");var b,y=p.g.document;if(!b&&y&&(y.currentScript&&"SCRIPT"===y.currentScript.tagName.toUpperCase()&&(b=y.currentScript.src),!b)){var d=y.getElementsByTagName("script");if(d.length)for(var h=d.length-1;h>-1&&(!b||!/^http(s?):/.test(b));)b=d[h--].src}if(!b)throw Error("Automatic publicPath is not supported in this browser");p.p=b.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var v={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-field-china-region/dist/client/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var n=window.location.pathname||"/",o=n.indexOf("/v2/");e=o>=0?n.slice(0,o+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-field-china-region/dist/client/"}p.p=e}(),!function(){p.r(v),p.d(v,{PluginFieldChinaRegionClient:function(){return en},DisplayChinaRegionFieldModel:function(){return W},default:function(){return eo},ChinaRegionFieldModel:function(){return V}});var e=p(342),t=p(230);function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var n=function(r){var n,o,i=(0,t.useField)().componentProps.maxLevel;return(0,e.useRequest)({resource:"chinaRegions",action:"list",params:{sort:"code",paginate:!1,filter:{level:1}}},(n=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},r),o=o={onSuccess:function(e){var t;null==r||r.onSuccess({data:(null==e||null==(t=e.data)?void 0:t.map(function(e){return 1!==i&&(e.isLeaf=!1),e}))||[]})},manual:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(o)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}),n))},o=function(){var n=(0,e.useAPIClient)(),o=(0,t.useField)(),i=o.componentProps.maxLevel;return function(e){var t,a=e[e.length-1];(null==a||null==(t=a.children)?void 0:t.length)>0||(a.loading=!0,n.resource("chinaRegions").list({sort:"code",paginate:!1,filter:{parentCode:a.code}}).then(function(e){var t,n,c=e.data;a.loading=!1,a.children=(null==c||null==(n=c.data)?void 0:n.map(function(e){return i>e.level&&(e.isLeaf=!1),e}))||[],o.dataSource=function(e){if(Array.isArray(e))return r(e)}(t=o.dataSource)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e){if(e){if("string"==typeof e)return r(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return r(e,void 0)}}(t)||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)}))}},i=p(166),a="chinaRegion",c="chinaRegions",l={label:"name",value:"code",children:"children"},u=[{value:1,label:'{{t("Province")}}'},{value:2,label:'{{t("City")}}'},{value:3,label:'{{t("Area")}}'},{value:4,label:'{{t("Street")}}',disabled:!0},{value:5,label:'{{t("Village")}}',disabled:!0}],f={changeOnSelectLast:!1,labelInValue:!0,maxLevel:3,fieldNames:l},s={interface:a,type:"belongsToMany",target:c,targetKey:"code",sortBy:"level",uiSchema:{type:"array","x-component":"Cascader"}},b={name:"name",title:'{{t("Province/city/area name")}}',schema:{title:'{{t("Province/city/area name")}}',type:"string","x-component":"Input"}};function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){y(e,t,r[t])})}return e}function m(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(O=function(){return!!e})()}var j=function(t){var r;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function n(){var t,r,o;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return r=n,o=arguments,r=d(r),y(t=function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,O()?Reflect.construct(r,o||[],d(this).constructor):r.apply(this,o)),"name",a),y(t,"type","object"),y(t,"group","choices"),y(t,"order",7),y(t,"title",'{{t("China region")}}'),y(t,"isAssociation",!0),y(t,"default",m(h({},s),{uiSchema:m(h({},s.uiSchema),{"x-component-props":m(h({},f),{useDataSource:"{{ useChinaRegionDataSource }}",useLoadData:"{{ useChinaRegionLoadData }}"})})})),y(t,"availableTypes",["belongsToMany"]),y(t,"properties",m(h({},e.defaultProps),{"uiSchema.x-component-props.maxLevel":{type:"number","x-component":"Radio.Group","x-decorator":"FormItem",title:'{{t("Select level")}}',default:3,enum:u},"uiSchema.x-component-props.changeOnSelectLast":{type:"boolean","x-component":"Checkbox","x-content":'{{t("Must select to the last level")}}',"x-decorator":"FormItem"}})),y(t,"filterable",{children:[m(h({},b),{operators:e.operators.string})]}),t}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&g(n,t),r=[{key:"initialize",value:function(e){e.through||(e.through="t_".concat((0,i.uid)())),e.foreignKey||(e.foreignKey="f_".concat((0,i.uid)())),e.otherKey||(e.otherKey="f_".concat((0,i.uid)())),e.sourceKey||(e.sourceKey="id"),e.targetKey||(e.targetKey="id")}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(n.prototype,r),n}(e.CollectionFieldInterface),w=p(59),S=p(625),P=p(773),x=p(155),_=p.n(x),C=p(485),E=p(694),R=p(768),A=JSON.parse('{"UU":"@nocobase/plugin-field-china-region"}');function k(e){return(0,E.tExpr)(e,{ns:[A.UU,"client"]})}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function D(e,t,r,n,o,i,a){try{var c=e[i](a),l=c.value}catch(e){r(e);return}c.done?t(l):Promise.resolve(l).then(n,o)}function M(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){D(i,n,o,a,c,"next",e)}function c(e){D(i,n,o,a,c,"throw",e)}a(void 0)})}}function T(e){return(T=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function F(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function L(e,t){return(L=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function B(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function K(e,t){if(e){if("string"==typeof e)return I(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return I(e,t)}}function $(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return($=function(){return!!e})()}function N(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var U=function(e){var t,r=e.value,n=e.onChange,o=e.maxLevel,i=void 0===o?3:o,a=e.changeOnSelectLast,u=e.labelInValue,f=e.fieldNames,s=void 0===f?l:f,p=(e.multiple,function(e,t){if(null==e)return{};var r,n,o,i={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,r=Reflect.ownKeys(Object(e));o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}if(i=function(e,t){if(null==e)return{};var r,n,o={},i=Object.getOwnPropertyNames(e);for(n=0;n<i.length;n++)r=i[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}(e,["value","onChange","maxLevel","changeOnSelectLast","labelInValue","fieldNames","multiple"])),b=(0,E.useFlowContext)().api,y=function(e){if(Array.isArray(e))return e}(t=_().useState([]))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,a=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(a)throw r}}return o}}(t)||K(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),d=y[0],h=y[1],v=(0,S.useRequest)(function(){return M(function(){var e,t;return N(this,function(r){switch(r.label){case 0:return[4,b.resource(c).list({sort:"code",paginate:!1,filter:{level:1}})];case 1:return[2,(null==(t=r.sent())||null==(e=t.data)?void 0:e.data)||[]]}})})()},{manual:!0,onSuccess:function(e){h(e.map(function(e){return F(q({},e),{isLeaf:1===i})}))}}),m=v.data,g=v.loading,O=v.run;_().useEffect(function(){m&&h(m.map(function(e){return F(q({},e),{isLeaf:1===i})}))},[m,i]);var j=_().useCallback(function(e){e&&0===d.length&&O()},[d.length,O]),x=_().useCallback(function(e){return M(function(){var t,r,n,o,a,l;return N(this,function(u){switch(u.label){case 0:if(!(r=e[e.length-1])||(null==r||null==(t=r.children)?void 0:t.length)>0)return[2];r.loading=!0,u.label=1;case 1:return u.trys.push([1,3,4,5]),[4,b.resource(c).list({sort:"code",paginate:!1,filter:{parentCode:r.code}})];case 2:return a=u.sent(),r.children=(null==a||null==(o=a.data)||null==(n=o.data)?void 0:n.map(function(e){return F(q({},e),{isLeaf:i<=e.level})}))||[],[3,5];case 3:return l=u.sent(),(0,R.error)(l),[3,5];case 4:return r.loading=!1,h(function(e){return function(e){if(Array.isArray(e))return I(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||K(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}),[7];case 5:return[2]}})})()},[b,i]),C=_().useMemo(function(){if(r)return(Array.isArray(r)?r:[r]).map(function(e){return(void 0===e?"undefined":B(e))==="object"?e[s.value]:e})},[s.value,r]),A=_().useCallback(function(e,t){if(!r)return e.join(" / ");var n=(Array.isArray(r)?r:[r]).filter(function(e){return(void 0===e?"undefined":B(e))==="object"}).sort(function(e,t){return(e.level||0)-(t.level||0)});return e.map(function(e,r){var o;return t[r]?t[r][s.label]:(null==(o=n[r])?void 0:o[s.label])?n[r][s.label]:e}).join(" / ")},[s.label,r]),k=_().useCallback(function(e,t){if(e&&u){null==n||n(t.map(function(e){return(0,P.omit)(e,[s.children])})||null);return}null==n||n(e||null)},[s.children,u,n]);return _().createElement(w.Cascader,F(q({},p),{loading:g,options:d,value:C,loadData:x,fieldNames:s,displayRender:A,multiple:!1,changeOnSelect:(0,P.isBoolean)(a)?!a:p.changeOnSelect,onDropdownVisibleChange:j,onChange:k}))},V=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=T(e),function(e,t){if(t&&("object"===B(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,$()?Reflect.construct(e,t||[],T(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&L(r,e),t=[{key:"render",value:function(){return _().createElement(U,this.props)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(C.FieldModel);function G(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}V.define({label:k("China region")}),E.EditableItemModel.bindModelToInterface("ChinaRegionFieldModel",["chinaRegion"],{isDefault:!0});function z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function J(e,t){return(J=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function H(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function Q(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Q=function(){return!!e})()}var W=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=z(e),function(e,t){if(t&&("object"===H(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,Q()?Reflect.construct(e,t||[],z(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&J(r,e),t=[{key:"render",value:function(){var e=this.props.value;if(!e||Array.isArray(e)&&0===e.length)return null;if(Array.isArray(e)){var t=((function(e){if(Array.isArray(e))return G(e)})(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return G(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return G(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).sort(function(e,t){return e.level!==t.level?e.level-t.level:(e.sort||0)-(t.sort||0)}).map(function(e){return e.name||e.label||e}).filter(Boolean);return _().createElement("span",null,t.join("/"))}return(void 0===e?"undefined":H(e))==="object"&&e.name?_().createElement("span",null,e.name):_().createElement("span",null,String(e))}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(C.FieldModel);function X(e,t,r,n,o,i,a){try{var c=e[i](a),l=c.value}catch(e){r(e);return}c.done?t(l):Promise.resolve(l).then(n,o)}function Y(e,t,r){return(Y=er()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&ee(o,r.prototype),o}).apply(null,arguments)}W.define({label:k("China region")}),E.DisplayItemModel.bindModelToInterface("DisplayChinaRegionFieldModel",["chinaRegion"],{isDefault:!0});function Z(e){return(Z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ee(e,t){return(ee=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function et(e){var t="function"==typeof Map?new Map:void 0;return(et=function(e){if(null===e||-1===Function.toString.call(e).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 Y(e,arguments,Z(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ee(r,e)})(e)}function er(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(er=function(){return!!e})()}var en=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=Z(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,er()?Reflect.construct(e,t||[],Z(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&ee(r,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return this.app.addScopes({useChinaRegionDataSource:n,useChinaRegionLoadData:o}),this.app.dataSourceManager.addFieldInterfaces([j]),this.flowEngine.registerModels({ChinaRegionFieldModel:V,DisplayChinaRegionFieldModel:W}),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){X(i,n,o,a,c,"next",e)}function c(e){X(i,n,o,a,c,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(et(e.Plugin)),eo=en}(),v}()});
@@ -0,0 +1,91 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { CollectionFieldInterface } from '@nocobase/client-v2';
10
+ export declare class ChinaRegionFieldInterface extends CollectionFieldInterface {
11
+ name: string;
12
+ type: string;
13
+ group: string;
14
+ order: number;
15
+ title: string;
16
+ isAssociation: boolean;
17
+ default: {
18
+ uiSchema: {
19
+ 'x-component-props': {
20
+ changeOnSelectLast: boolean;
21
+ labelInValue: boolean;
22
+ maxLevel: number;
23
+ fieldNames: {
24
+ label: string;
25
+ value: string;
26
+ children: string;
27
+ };
28
+ };
29
+ type: string;
30
+ 'x-component': string;
31
+ };
32
+ interface: string;
33
+ type: string;
34
+ target: string;
35
+ targetKey: string;
36
+ sortBy: string;
37
+ };
38
+ availableTypes: string[];
39
+ initialize(values: any): void;
40
+ properties: {
41
+ 'uiSchema.x-component-props.maxLevel': {
42
+ type: string;
43
+ 'x-component': string;
44
+ 'x-decorator': string;
45
+ title: string;
46
+ default: number;
47
+ enum: ({
48
+ value: number;
49
+ label: string;
50
+ disabled?: undefined;
51
+ } | {
52
+ value: number;
53
+ label: string;
54
+ disabled: boolean;
55
+ })[];
56
+ };
57
+ 'uiSchema.x-component-props.changeOnSelectLast': {
58
+ type: string;
59
+ 'x-component': string;
60
+ 'x-content': string;
61
+ 'x-decorator': string;
62
+ };
63
+ };
64
+ filterable: {
65
+ children: {
66
+ operators: ({
67
+ label: string;
68
+ value: string;
69
+ selected: boolean;
70
+ noValue?: undefined;
71
+ } | {
72
+ label: string;
73
+ value: string;
74
+ selected?: undefined;
75
+ noValue?: undefined;
76
+ } | {
77
+ label: string;
78
+ value: string;
79
+ noValue: boolean;
80
+ selected?: undefined;
81
+ })[];
82
+ name: string;
83
+ title: string;
84
+ schema: {
85
+ title: string;
86
+ type: string;
87
+ 'x-component': string;
88
+ };
89
+ }[];
90
+ };
91
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export declare const CHINA_REGION_INTERFACE_NAME = "chinaRegion";
10
+ export declare const CHINA_REGION_TARGET = "chinaRegions";
11
+ export declare const CHINA_REGION_FIELD_NAMES: {
12
+ label: string;
13
+ value: string;
14
+ children: string;
15
+ };
16
+ export declare const CHINA_REGION_LEVEL_OPTIONS: ({
17
+ value: number;
18
+ label: string;
19
+ disabled?: undefined;
20
+ } | {
21
+ value: number;
22
+ label: string;
23
+ disabled: boolean;
24
+ })[];
25
+ export declare const CHINA_REGION_BASE_COMPONENT_PROPS: {
26
+ changeOnSelectLast: boolean;
27
+ labelInValue: boolean;
28
+ maxLevel: number;
29
+ fieldNames: {
30
+ label: string;
31
+ value: string;
32
+ children: string;
33
+ };
34
+ };
35
+ export declare const CHINA_REGION_BASE_DEFAULT: {
36
+ interface: string;
37
+ type: string;
38
+ target: string;
39
+ targetKey: string;
40
+ sortBy: string;
41
+ uiSchema: {
42
+ type: string;
43
+ 'x-component': string;
44
+ };
45
+ };
46
+ export declare const CHINA_REGION_FILTERABLE_CHILD_BASE: {
47
+ name: string;
48
+ title: string;
49
+ schema: {
50
+ title: string;
51
+ type: string;
52
+ 'x-component': string;
53
+ };
54
+ };
55
+ export declare function initializeChinaRegionValues(values: any): void;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export { ChinaRegionFieldInterface } from './chinaRegion';
10
+ export * from './models';
11
+ export { default } from './plugin';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("@nocobase/client-v2"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/flow-engine"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-field-china-region/client-v2",["ahooks","@nocobase/client-v2","@formily/shared","react","antd","@nocobase/flow-engine","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-field-china-region/client-v2"]=t(require("ahooks"),require("@nocobase/client-v2"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/flow-engine"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-field-china-region/client-v2"]=t(e.ahooks,e["@nocobase/client-v2"],e["@formily/shared"],e.react,e.antd,e["@nocobase/flow-engine"],e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,n,r,o,i,a,l){return function(){"use strict";var u={211:function(e,t,n){n.r(t),n.d(t,{ChinaRegionFieldModel:function(){return _}});var r=n(59),o=n(625),i=n(773),a=n(155),l=n.n(a),u=n(485),c=n(694),f=n(768),s=n(143),p=n(466);function b(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}function y(e,t,n,r,o,i,a){try{var l=e[i](a),u=l.value}catch(e){n(e);return}l.done?t(u):Promise.resolve(u).then(r,o)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){y(i,r,o,a,l,"next",e)}function l(e){y(i,r,o,a,l,"throw",e)}a(void 0)})}}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function v(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;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function m(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function w(e,t){if(e){if("string"==typeof e)return b(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 b(e,t)}}function j(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(j=function(){return!!e})()}function S(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:u(0)}),l(a,"throw",{value:u(1)}),l(a,"return",{value:u(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function u(l){return function(u){var c=[l,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var P=function(e){var t,n=e.value,a=e.onChange,u=e.maxLevel,s=void 0===u?3:u,y=e.changeOnSelectLast,h=e.labelInValue,g=e.fieldNames,j=void 0===g?p.Dx:g,P=(e.multiple,function(e,t){if(null==e)return{};var n,r,o,i={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,n=Reflect.ownKeys(Object(e));o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r]);return i}if(i=function(e,t){if(null==e)return{};var n,r,o={},i=Object.getOwnPropertyNames(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r]);return i}(e,["value","onChange","maxLevel","changeOnSelectLast","labelInValue","fieldNames","multiple"])),_=(0,c.useFlowContext)().api,x=function(e){if(Array.isArray(e))return e}(t=l().useState([]))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||w(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),C=x[0],E=x[1],R=(0,o.useRequest)(function(){return d(function(){var e,t;return S(this,function(n){switch(n.label){case 0:return[4,_.resource(p.f0).list({sort:"code",paginate:!1,filter:{level:1}})];case 1:return[2,(null==(t=n.sent())||null==(e=t.data)?void 0:e.data)||[]]}})})()},{manual:!0,onSuccess:function(e){E(e.map(function(e){return m(v({},e),{isLeaf:1===s})}))}}),k=R.data,I=R.loading,M=R.run;l().useEffect(function(){k&&E(k.map(function(e){return m(v({},e),{isLeaf:1===s})}))},[k,s]);var A=l().useCallback(function(e){e&&0===C.length&&M()},[C.length,M]),F=l().useCallback(function(e){return d(function(){var t,n,r,o,i,a;return S(this,function(l){switch(l.label){case 0:if(!(n=e[e.length-1])||(null==n||null==(t=n.children)?void 0:t.length)>0)return[2];n.loading=!0,l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,_.resource(p.f0).list({sort:"code",paginate:!1,filter:{parentCode:n.code}})];case 2:return i=l.sent(),n.children=(null==i||null==(o=i.data)||null==(r=o.data)?void 0:r.map(function(e){return m(v({},e),{isLeaf:s<=e.level})}))||[],[3,5];case 3:return a=l.sent(),(0,f.error)(a),[3,5];case 4:return n.loading=!1,E(function(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||w(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}),[7];case 5:return[2]}})})()},[_,s]),T=l().useMemo(function(){if(n)return(Array.isArray(n)?n:[n]).map(function(e){return(void 0===e?"undefined":O(e))==="object"?e[j.value]:e})},[j.value,n]),D=l().useCallback(function(e,t){if(!n)return e.join(" / ");var r=(Array.isArray(n)?n:[n]).filter(function(e){return(void 0===e?"undefined":O(e))==="object"}).sort(function(e,t){return(e.level||0)-(t.level||0)});return e.map(function(e,n){var o;return t[n]?t[n][j.label]:(null==(o=r[n])?void 0:o[j.label])?r[n][j.label]:e}).join(" / ")},[j.label,n]),q=l().useCallback(function(e,t){if(e&&h){null==a||a(t.map(function(e){return(0,i.omit)(e,[j.children])})||null);return}null==a||a(e||null)},[j.children,h,a]);return l().createElement(r.Cascader,m(v({},P),{loading:I,options:C,value:T,loadData:F,fieldNames:j,displayRender:D,multiple:!1,changeOnSelect:(0,i.isBoolean)(y)?!y:P.changeOnSelect,onDropdownVisibleChange:A,onChange:q}))},_=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=h(e),function(e,t){if(t&&("object"===O(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,j()?Reflect.construct(e,t||[],h(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&g(n,e),t=[{key:"render",value:function(){return l().createElement(P,this.props)}}],function(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)}}(n.prototype,t),n}(u.FieldModel);_.define({label:(0,s.M)("China region")}),c.EditableItemModel.bindModelToInterface("ChinaRegionFieldModel",["chinaRegion"],{isDefault:!0})},241:function(e,t,n){n.r(t),n.d(t,{DisplayChinaRegionFieldModel:function(){return b}});var r=n(155),o=n.n(r),i=n(485),a=n(694),l=n(143);function u(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}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}var b=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=c(e),function(e,t){if(t&&("object"===s(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,p()?Reflect.construct(e,t||[],c(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&f(n,e),t=[{key:"render",value:function(){var e=this.props.value;if(!e||Array.isArray(e)&&0===e.length)return null;if(Array.isArray(e)){var t=((function(e){if(Array.isArray(e))return u(e)})(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return u(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return u(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).sort(function(e,t){return e.level!==t.level?e.level-t.level:(e.sort||0)-(t.sort||0)}).map(function(e){return e.name||e.label||e}).filter(Boolean);return o().createElement("span",null,t.join("/"))}return(void 0===e?"undefined":s(e))==="object"&&e.name?o().createElement("span",null,e.name):o().createElement("span",null,String(e))}}],function(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)}}(n.prototype,t),n}(i.FieldModel);b.define({label:(0,l.M)("China region")}),a.DisplayItemModel.bindModelToInterface("DisplayChinaRegionFieldModel",["chinaRegion"],{isDefault:!0})},466:function(e,t,n){n.d(t,{Be:function(){return l},DF:function(){return o},Dx:function(){return a},OI:function(){return s},VF:function(){return f},bF:function(){return c},f0:function(){return i},ko:function(){return u}});var r=n(166),o="chinaRegion",i="chinaRegions",a={label:"name",value:"code",children:"children"},l=[{value:1,label:'{{t("Province")}}'},{value:2,label:'{{t("City")}}'},{value:3,label:'{{t("Area")}}'},{value:4,label:'{{t("Street")}}',disabled:!0},{value:5,label:'{{t("Village")}}',disabled:!0}],u={changeOnSelectLast:!1,labelInValue:!0,maxLevel:3,fieldNames:a},c={interface:o,type:"belongsToMany",target:i,targetKey:"code",sortBy:"level",uiSchema:{type:"array","x-component":"Cascader"}},f={name:"name",title:'{{t("Province/city/area name")}}',schema:{title:'{{t("Province/city/area name")}}',type:"string","x-component":"Input"}};function s(e){e.through||(e.through="t_".concat((0,r.uid)())),e.foreignKey||(e.foreignKey="f_".concat((0,r.uid)())),e.otherKey||(e.otherKey="f_".concat((0,r.uid)())),e.sourceKey||(e.sourceKey="id"),e.targetKey||(e.targetKey="id")}},143:function(e,t,n){n.d(t,{M:function(){return i}});var r=n(694),o=JSON.parse('{"UU":"@nocobase/plugin-field-china-region"}');function i(e){return(0,r.tExpr)(e,{ns:[o.UU,"client"]})}},166:function(e){e.exports=n},485:function(e){e.exports=t},694:function(e){e.exports=i},768:function(e){e.exports=a},625:function(t){t.exports=e},59:function(e){e.exports=o},773:function(e){e.exports=l},155:function(e){e.exports=r}},c={};function f(e){var t=c[e];if(void 0!==t)return t.exports;var n=c[e]={exports:{}};return u[e](n,n.exports,f),n.exports}f.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(t,{a:t}),t},f.d=function(e,t){for(var n in t)f.o(t,n)&&!f.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},f.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),f.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.g.importScripts&&(s=f.g.location+"");var s,p=f.g.document;if(!s&&p&&(p.currentScript&&"SCRIPT"===p.currentScript.tagName.toUpperCase()&&(s=p.currentScript.src),!s)){var b=p.getElementsByTagName("script");if(b.length)for(var y=b.length-1;y>-1&&(!s||!/^http(s?):/.test(s));)s=b[y--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");f.p=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var d={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-field-china-region/dist/client-v2/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var r=window.location.pathname||"/",o=r.indexOf("/v2/");e=o>=0?r.slice(0,o+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-field-china-region/dist/client-v2/"}f.p=e}(),!function(){f.r(d),f.d(d,{ChinaRegionFieldInterface:function(){return c},DisplayChinaRegionFieldModel:function(){return p.DisplayChinaRegionFieldModel},default:function(){return O},ChinaRegionFieldModel:function(){return s.ChinaRegionFieldModel}});var e=f(485),t=f(466);function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){n(e,t,r[t])})}return e}function i(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}var u=[{label:'{{t("contains")}}',value:"$includes",selected:!0},{label:'{{t("does not contain")}}',value:"$notIncludes"},{label:'{{t("is")}}',value:"$eq"},{label:'{{t("is not")}}',value:"$ne"},{label:'{{t("is empty")}}',value:"$empty",noValue:!0},{label:'{{t("is not empty")}}',value:"$notEmpty",noValue:!0}],c=function(e){var c;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function f(){var e,a,c;if(!(this instanceof f))throw TypeError("Cannot call a class as a function");return a=f,c=arguments,a=r(a),n(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,l()?Reflect.construct(a,c||[],r(this).constructor):a.apply(this,c)),"name",t.DF),n(e,"type","object"),n(e,"group","choices"),n(e,"order",7),n(e,"title",'{{t("China region")}}'),n(e,"isAssociation",!0),n(e,"default",i(o({},t.bF),{uiSchema:i(o({},t.bF.uiSchema),{"x-component-props":o({},t.ko)})})),n(e,"availableTypes",["belongsToMany"]),n(e,"properties",{"uiSchema.x-component-props.maxLevel":{type:"number","x-component":"Radio.Group","x-decorator":"FormItem",title:'{{t("Select level")}}',default:3,enum:t.Be},"uiSchema.x-component-props.changeOnSelectLast":{type:"boolean","x-component":"Checkbox","x-content":'{{t("Must select to the last level")}}',"x-decorator":"FormItem"}}),n(e,"filterable",{children:[i(o({},t.VF),{operators:u})]}),e}return f.prototype=Object.create(e&&e.prototype,{constructor:{value:f,writable:!0,configurable:!0}}),e&&a(f,e),c=[{key:"initialize",value:function(e){(0,t.OI)(e)}}],function(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)}}(f.prototype,c),f}(e.CollectionFieldInterface),s=f(211),p=f(241);function b(e,t,n,r,o,i,a){try{var l=e[i](a),u=l.value}catch(e){n(e);return}l.done?t(u):Promise.resolve(u).then(r,o)}function y(e,t,n){return(y=g()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&v(o,n.prototype),o}).apply(null,arguments)}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function v(e,t){return(v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(e){var t="function"==typeof Map?new Map:void 0;return(m=function(e){if(null===e||-1===Function.toString.call(e).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,n)}function n(){return y(e,arguments,h(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,e)})(e)}function g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(g=function(){return!!e})()}var O=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=h(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,g()?Reflect.construct(e,t||[],h(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&v(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:u(0)}),l(a,"throw",{value:u(1)}),l(a,"return",{value:u(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function u(l){return function(u){var c=[l,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(e){return this.app.addFieldInterfaces([c]),this.flowEngine.registerModelLoaders({ChinaRegionFieldModel:{loader:function(){return Promise.resolve().then(f.bind(f,211))}},DisplayChinaRegionFieldModel:{loader:function(){return Promise.resolve().then(f.bind(f,241))}}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){b(i,r,o,a,l,"next",e)}function l(e){b(i,r,o,a,l,"throw",e)}a(void 0)})}).call(this)}}],function(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)}}(n.prototype,t),n}(m(e.Plugin))}(),d}()});
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export declare function useT(): (str: string) => string;
10
+ export declare function tExpr(key: string): string;
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import React from 'react';
10
- import { FieldModel } from '@nocobase/client';
10
+ import { FieldModel } from '@nocobase/client-v2';
11
11
  export declare class ChinaRegionFieldModel extends FieldModel {
12
12
  render(): React.JSX.Element;
13
13
  }
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import React from 'react';
10
- import { FieldModel } from '@nocobase/client';
10
+ import { FieldModel } from '@nocobase/client-v2';
11
11
  export declare class DisplayChinaRegionFieldModel extends FieldModel {
12
12
  render(): React.JSX.Element;
13
13
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Application, Plugin } from '@nocobase/client-v2';
10
+ export declare class PluginFieldChinaRegionClient extends Plugin<any, Application> {
11
+ load(): Promise<void>;
12
+ }
13
+ export default PluginFieldChinaRegionClient;
@@ -10,13 +10,16 @@
10
10
  module.exports = {
11
11
  "@formily/core": "2.3.7",
12
12
  "@formily/react": "2.3.7",
13
- "@nocobase/client": "2.1.0-beta.30",
13
+ "@nocobase/client": "2.1.0-beta.33",
14
+ "@nocobase/client-v2": "2.1.0-beta.33",
14
15
  "@formily/shared": "2.3.7",
15
- "@nocobase/server": "2.1.0-beta.30",
16
+ "@nocobase/flow-engine": "2.1.0-beta.33",
17
+ "@nocobase/server": "2.1.0-beta.33",
16
18
  "china-division": "2.7.0",
17
- "react": "18.2.0",
18
19
  "antd": "5.24.2",
20
+ "ahooks": "3.7.8",
19
21
  "lodash": "4.18.1",
20
- "@nocobase/flow-engine": "2.1.0-beta.30",
21
- "@nocobase/database": "2.1.0-beta.30"
22
+ "react": "18.2.0",
23
+ "@nocobase/utils": "2.1.0-beta.33",
24
+ "@nocobase/database": "2.1.0-beta.33"
22
25
  };
@@ -0,0 +1,11 @@
1
+ {
2
+ "China region": "China region",
3
+ "Select level": "Select level",
4
+ "Province": "Province",
5
+ "City": "City",
6
+ "Area": "Area",
7
+ "Street": "Street",
8
+ "Village": "Village",
9
+ "Must select to the last level": "Must select to the last level",
10
+ "Province/city/area name": "Province/city/area name"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "China region": "中国行政区划",
3
+ "Select level": "选择级别",
4
+ "Province": "省",
5
+ "City": "市",
6
+ "Area": "区",
7
+ "Street": "街道",
8
+ "Village": "村",
9
+ "Must select to the last level": "必须选择到最后一级",
10
+ "Province/city/area name": "省/市/区名称"
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-field-china-region",
3
- "version": "2.1.0-beta.30",
3
+ "version": "2.1.0-beta.33",
4
4
  "displayName": "Collection field: administrative divisions of China",
5
5
  "displayName.zh-CN": "数据表字段:中国行政区划",
6
6
  "displayName.ru-RU": "Поле коллекции: административное деление Китая",
@@ -21,11 +21,12 @@
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@nocobase/client": "2.x",
24
+ "@nocobase/client-v2": "2.x",
24
25
  "@nocobase/database": "2.x",
25
26
  "@nocobase/server": "2.x",
26
27
  "@nocobase/test": "2.x"
27
28
  },
28
- "gitHead": "1a493069cd0d8a4f403668bfe592879678c894b2",
29
+ "gitHead": "4815c394e80a264fa8ed619246280923c47aeb72",
29
30
  "keywords": [
30
31
  "Collection fields"
31
32
  ]
File without changes