zy-react-library 2.1.4 → 2.1.5

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.
@@ -1 +1 @@
1
- import{Modal as e,Form as i,Row as t,Col as a,Select as n,Input as r,Button as l,Spin as o}from"antd";import{useRef as d,useState as s,useEffect as c}from"react";import{dynamicLoadJs as u,dynamicLoadCss as p}from"../../utils/index.js";import w from"./CesiumMap.js";import"./index.less";import{jsxs as m,jsx as h}from"react/jsx-runtime";const g=g=>{const{visible:y,onClose:b,longitude:v,latitude:C,onConfirm:f,area:L="",showArea:M=!1,disable:B=!1,type:k="baidu"}=g,j=d(null),x=d(null),D=d(null),[G,I]=s(!1),[O,A]=s(v||""),[R,z]=s(C||""),[K,P]=s(""),[T,S]=s("");c(()=>{A(v||""),z(C||""),S(L||"")},[v,C,L]);const W=()=>{if(!window?.BMapGL?.Map)return void setTimeout(()=>{W()},50);const e=new window.BMapGL.Map(j.current);if(x.current=e,e.centerAndZoom(new window.BMapGL.Point(v||window.mapLongitude,C||window.mapLatitude),16),e.enableScrollWheelZoom(!0),v&&C){const i=new window.BMapGL.Point(v,C),t=new window.BMapGL.Marker(i);e.addOverlay(t)}B||e.addEventListener("click",i=>{e.clearOverlays();const t=new window.BMapGL.Point(i.latlng.lng,i.latlng.lat),a=new window.BMapGL.Marker(t);e.addOverlay(a),z(i.latlng.lat),A(i.latlng.lng)})},E=()=>{if(I(!0),j.current){if(!x.current){if("baidu"===k)return void W();"cesium"===k&&(()=>{const{init:e,flyTo:i,addMarkPoint:t,getLongitudeAndLatitude:a}=new w,{viewer:n}=e();x.current=n,i({longitude:v||window.mapLongitude,latitude:C||window.mapLatitude,height:9e5}),v&&C&&t({longitude:v,latitude:C}),B||a((e,i)=>{if(e)return;const{longitude:t,latitude:a}=i;z(a),A(t)})})()}I(!1)}},Z=()=>{P(""),x.current&&(x.current.destroy(),x.current=null),b&&b()};c(()=>{let e;return y&&(e=setTimeout(()=>{(()=>{if(window.mapLongitude||window.mapLatitude)return"baidu"===k?window.mapBaiDuKey?void(async()=>{window.BMapGL?E():window?.base?.loadDynamicResource?(await window.base.loadDynamicResource({url:`https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${window.mapBaiDuKey}&callback=initialize`,type:"script",attr:{type:"text/javascript"}}),E()):(await u(`https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${window.mapBaiDuKey}&callback=initialize`),E())})():void console.error("【Map】 请在window设置变量 mapBaiDuKey,以供地图初始化加载使用"):void("cesium"===k&&(async()=>{window.Cesium?E():window?.base?.loadDynamicResource?(await window.base.loadDynamicResource({url:"https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Cesium.js",type:"script",attr:{type:"text/javascript"}}),await window.base.loadDynamicResource({url:"https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Widgets/widgets.css",type:"link",attr:{rel:"stylesheet",type:"text/css"}}),E()):(await u("https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Cesium.js"),await p("https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Widgets/widgets.css"),E())})());console.error("【Map】 请在window设置变量 mapLongitude 和 mapLatitude,以供地图初始化坐标使用")})()},100)),()=>{e&&clearTimeout(e)}},[y]);const $=()=>{if(x.current){try{x.current.clearOverlays(),x.current.destroy(),x.current=null}catch(e){console.warn("Error destroying map on unmount:",e)}x.current=null}};return c(()=>()=>{$()},[]),m(e,{open:y,title:"坐标",onCancel:Z,width:1e3,destroyOnHidden:!1,mask:{closable:!1},afterClose:$,footer:[h(l,{onClick:Z,children:"取消"},"back"),!B&&h(l,{type:"primary",onClick:()=>{f&&f(O,R,{area:T}),Z()},children:"确定"},"submit")],children:[m(i,{labelAlign:"right",labelCol:{span:6},wrapperCol:{span:18},children:[M&&h(t,{gutter:24,children:h(a,{span:12,children:h(i.Item,{label:"所属区域",children:h(n,{value:T,onChange:e=>S(e),allowClear:!0,options:[{value:"1",label:"东港区"},{value:"2",label:"西港区"}]})})})}),!B&&"baidu"===k&&m(t,{gutter:24,children:[h(a,{span:12,children:h(i.Item,{label:"关键字搜索",children:h(r,{value:K,onChange:e=>P(e.target.value),allowClear:!0})})}),h(a,{span:12,children:m(i.Item,{label:" ",colon:!1,style:{textAlign:"right"},children:[h(l,{type:"primary",onClick:()=>{K&&x.current&&(D.current=new window.BMapGL.LocalSearch(x.current,{renderOptions:{map:x.current}}),D.current.search(K))},children:"搜索"}),h(l,{onClick:()=>{P(""),x.current&&D.current.search("")},style:{marginLeft:8},children:"重置"})]})})]}),m(t,{gutter:24,children:[h(a,{span:12,children:h(i.Item,{label:"经度",children:h(r,{disabled:!0,value:O})})}),h(a,{span:12,children:h(i.Item,{label:"纬度",children:h(r,{disabled:!0,value:R})})})]})]}),h("div",{ref:j,id:"map_container",style:{width:"100%",height:"500px",position:"relative"},children:h(o,{size:"large",tip:"地图正在加载中...",spinning:G,children:h("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e3}})})})]})};g.displayName="MapSelector";export{g as default};
1
+ import{Modal as e,Form as i,Row as t,Col as a,Select as n,Input as r,Button as l,Spin as o}from"antd";import{useRef as d,useState as s,useEffect as c}from"react";import{dynamicLoadJs as u,dynamicLoadCss as p}from"../../utils/index.js";import w from"./CesiumMap.js";import"./index.less";import{jsxs as m,jsx as h}from"react/jsx-runtime";const g=g=>{const{visible:y,onClose:b,longitude:v,latitude:C,onConfirm:f,area:L="",showArea:M=!1,disable:B=!1,type:k="baidu"}=g,j=d(null),x=d(null),D=d(null),[G,I]=s(!1),[O,A]=s(v||""),[R,z]=s(C||""),[K,P]=s(""),[T,S]=s("");c(()=>{A(v||""),z(C||""),S(L||"")},[v,C,L]);const W=()=>{if(!window?.BMapGL?.Map)return void setTimeout(()=>{W()},50);const e=new window.BMapGL.Map(j.current);if(x.current=e,e.centerAndZoom(new window.BMapGL.Point(v||window.mapLongitude,C||window.mapLatitude),16),e.enableScrollWheelZoom(!0),v&&C){const i=new window.BMapGL.Point(v,C),t=new window.BMapGL.Marker(i);e.addOverlay(t)}B||e.addEventListener("click",i=>{e.clearOverlays();const t=new window.BMapGL.Point(i.latlng.lng,i.latlng.lat),a=new window.BMapGL.Marker(t);e.addOverlay(a),z(i.latlng.lat),A(i.latlng.lng)})},E=()=>{if(I(!0),j.current){if(!x.current){if("baidu"===k)return void W();"cesium"===k&&(()=>{const{init:e,flyTo:i,addMarkPoint:t,getLongitudeAndLatitude:a}=new w,{viewer:n}=e();x.current=n,i({longitude:v||window.mapLongitude,latitude:C||window.mapLatitude,height:9e5}),v&&C&&t({longitude:v,latitude:C}),B||a((e,i)=>{if(e)return;const{longitude:t,latitude:a}=i;z(a),A(t)})})()}I(!1)}},Z=()=>{P(""),x.current&&(x.current.destroy(),x.current=null),b&&b()};c(()=>{let e;return y&&(e=setTimeout(()=>{(()=>{if(window.mapLongitude||window.mapLatitude)return"baidu"===k?window.mapBaiDuKey?void(async()=>{window.BMapGL?E():window?.base?.loadDynamicResource?(await window.base.loadDynamicResource({url:`https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${window.mapBaiDuKey}&callback=initialize`,type:"script",attr:{type:"text/javascript"}}),E()):(await u(`https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${window.mapBaiDuKey}&callback=initialize`),E())})():void console.error("【Map】 请在window设置变量 mapBaiDuKey,以供地图初始化加载使用"):void("cesium"===k&&(async()=>{window.Cesium?E():window?.base?.loadDynamicResource?(await window.base.loadDynamicResource({url:"https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Cesium.js",type:"script",attr:{type:"text/javascript"}}),await window.base.loadDynamicResource({url:"https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Widgets/widgets.css",type:"link",attr:{rel:"stylesheet",type:"text/css"}}),E()):(await u("https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Cesium.js"),await p("https://cesium.com/downloads/cesiumjs/releases/1.91/Build/Cesium/Widgets/widgets.css"),E())})());console.error("【Map】 请在window设置变量 mapLongitude 和 mapLatitude,以供地图初始化坐标使用")})()},100)),()=>{e&&clearTimeout(e)}},[y]);const $=()=>{if(x.current){try{x.current.clearOverlays(),x.current.destroy(),x.current=null}catch(e){console.warn("Error destroying map on unmount:",e)}x.current=null}};return c(()=>()=>{$()},[]),m(e,{open:y,title:"坐标",onCancel:Z,width:1e3,destroyOnHidden:!1,mask:{closable:!1},afterClose:$,footer:[h(l,{onClick:Z,children:"取消"},"back"),!B&&h(l,{type:"primary",onClick:()=>{f&&f(O,R,{area:T}),Z()},children:"确定"},"submit")],children:[m(i,{labelAlign:"right",labelCol:{span:6},wrapperCol:{span:18},children:[M&&h(t,{gutter:24,children:h(a,{span:12,children:h(i.Item,{label:"所属区域",children:h(n,{value:T,onChange:e=>S(e),allowClear:!0,options:[{value:"1",label:"东港区"},{value:"2",label:"西港区"}]})})})}),!B&&"baidu"===k&&m(t,{gutter:24,children:[h(a,{span:12,children:h(i.Item,{label:"关键字搜索",children:h(r,{value:K,onChange:e=>P(e.target.value),allowClear:!0})})}),h(a,{span:12,children:m(i.Item,{label:" ",colon:!1,style:{textAlign:"right"},children:[h(l,{type:"primary",onClick:()=>{K&&x.current&&(D.current=new window.BMapGL.LocalSearch(x.current,{renderOptions:{map:x.current}}),D.current.search(K))},children:"搜索"}),h(l,{onClick:()=>{P(""),x.current&&D.current.search("")},style:{marginLeft:8},children:"重置"})]})})]}),m(t,{gutter:24,children:[h(a,{span:12,children:h(i.Item,{label:"经度",children:h(r,{disabled:!0,value:O})})}),h(a,{span:12,children:h(i.Item,{label:"纬度",children:h(r,{disabled:!0,value:R})})})]})]}),h("div",{ref:j,id:"map_container",style:{width:"100%",height:"500px",position:"relative"},children:h(o,{size:"large",description:"地图正在加载中...",spinning:G,children:h("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e3}})})})]})};g.displayName="MapSelector";export{g as default};
@@ -21,6 +21,10 @@ export interface BasicSelectProps extends SelectProps {
21
21
  onGetData?: (data: Record<string, any>[]) => void;
22
22
  /** 自定义 label 的渲染函数 */
23
23
  labelRender?: (item: Record<string, any>) => ReactNode;
24
+ /** 排除的项 */
25
+ exclude?: string[];
26
+ /** 包含的项 */
27
+ include?: string[];
24
28
  }
25
29
 
26
30
  /**
@@ -1 +1 @@
1
- import{Select as e}from"antd";import{useEffect as a}from"react";import{jsx as o}from"react/jsx-runtime";function n(n){const{onGetData:t,onChange:r,onGetLabel:l,onGetOption:i,placeholder:s="",data:c=[],nameKey:p="name",idKey:d="id",labelRender:f,...h}=n;return a(()=>{t?.(c)},[c]),o(e,{placeholder:`请选择${s}`,showSearch:{optionFilterProp:"children"},allowClear:!0,onChange:(e,a)=>{if(l||i)if(Array.isArray(e))if(e.length>0){const a=[],o=[];e.forEach(e=>{const n=c.find(a=>a[d]===e);n&&(a.push(n),o.push(n[p]))}),l?.(o),i?.(a)}else l?.([]),i?.([]);else if(e){const a=c.find(a=>a[d]===e);l?.(a[p]),i?.(a)}else l?.(""),i?.({});r?.(e,a)},options:c.map(e=>({value:e[d],label:f?f(e):e[p]})),...h})}n.displayName="BasicSelect";export{n as default};
1
+ import{Select as e}from"antd";import{useMemo as t,useEffect as l}from"react";import{getUnmatchedItems as a,getMatchedItems as n}from"../../../utils/index.js";import{jsx as o}from"react/jsx-runtime";function i(i){const{onGetData:r,onChange:s,onGetLabel:d,onGetOption:c,placeholder:p="",data:f=[],nameKey:h="name",idKey:m="id",labelRender:u,exclude:y=[],include:g=[],...x}=i,K=t(()=>{let e=f;return y.length>0&&(e=a({list:e,value:y,idKey:m})),g.length>0&&(e=n({list:e,value:g,idKey:m})),e},[f,y,g,m]);return l(()=>{r?.(K)},[K]),o(e,{placeholder:`请选择${p}`,showSearch:{optionFilterProp:"children"},allowClear:!0,onChange:(e,t)=>{if(d||c)if(Array.isArray(e))if(e.length>0){const t=[],l=[];e.forEach(e=>{const a=K.find(t=>t[m]===e);a&&(t.push(a),l.push(a[h]))}),d?.(l),c?.(t)}else d?.([]),c?.([]);else if(e){const t=K.find(t=>t[m]===e);d?.(t[h]),c?.(t)}else d?.(""),c?.({});s?.(e,t)},options:K.map(e=>({value:e[m],label:u?u(e):e[h]})),...x})}i.displayName="BasicSelect";export{i as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "2.1.4",
4
+ "version": "2.1.5",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",