zy-react-library 1.1.43 → 1.1.44

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{Cascader as e}from"antd";import{useEffect as a}from"react";import{processTreeDataByLevel as t}from"../../../utils/index.js";import{jsx as n}from"react/jsx-runtime";function r(r){const{onGetData:l,onChange:o,onGetNodePaths:d,onGetNodePathsIsIncludeOneself:i=!0,placeholder:c="",data:s=[],nameKey:m="name",idKey:h="id",childrenKey:p="children",level:u,...f}=r,y=u?t({data:s,level:u,childrenKey:p,currentLevel:1}):s;return a(()=>{l?.(s,y)},[s,y]),n(e,{options:y,placeholder:`请选择${c}`,onChange:(e,a)=>{const t=(e=>{let a=e;return!i&&e&&(a=e.slice(0,-1)),a||[]})(a);d?.(t),o?.(e,a)},fieldNames:{label:m,value:h,children:p},...f})}r.displayName="BasicCascader";export{r as default};
1
+ import{Cascader as e}from"antd";import{useMemo as a,useEffect as t}from"react";import{processTreeDataByLevel as n}from"../../../utils/index.js";import{jsx as r}from"react/jsx-runtime";function l(l){const{onGetData:o,onChange:i,onGetNodePaths:d,onGetNodePathsIsIncludeOneself:c=!0,placeholder:s="",data:m=[],nameKey:h="name",idKey:f="id",childrenKey:p="children",level:u,...y}=l,v=a(()=>u?n({data:m,level:u,childrenKey:p,currentLevel:1}):m,[m,u,p]);return t(()=>{o?.(m,v)},[m,v]),r(e,{options:v,placeholder:`请选择${s}`,onChange:(e,a)=>{if(a&&d){const e=(e=>{let a=e;return!c&&e&&(a=e.slice(0,-1)),a||[]})(a);d?.(e)}i?.(e,a)},fieldNames:{label:h,value:f,children:p},...y})}l.displayName="BasicCascader";export{l as default};
@@ -1 +1 @@
1
- import{Input as e,Tree as t}from"antd";import{useState as n,useEffect as r}from"react";import{getTreeNodePaths as s}from"../../../utils/index.js";import{jsxs as d,jsx as i}from"react/jsx-runtime";const{Search:a}=e,o=e=>{const{onGetData:o,onSelect:c,onGetNodePaths:l,onGetNodePathsIsIncludeOneself:h=!0,expandedKeys:u,treeData:m=[],nameKey:f="name",idKey:p="id",childrenKey:y="children",...g}=e,[x,K]=n([]),[v,I]=n(""),[N,S]=n(!0);r(()=>{K(u)},[u]);const D=(e,t,n=[])=>(e.forEach(e=>{e[y]&&((e[f].includes(t)||e[y].some(e=>e[f].includes(t)))&&n.push(e[p]),D(e[y],t,n))}),n),E=(e,t)=>t?e.reduce((e,n)=>{const r=n[f].includes(t),s=n[y]?E(n[y],t):[];return(r||s.length>0)&&e.push({...n,[y]:s.length>0?s:void 0}),e},[]):e,G=e=>{if(!v)return e;const t=e.indexOf(v);if(-1===t)return e;const n=e.substring(0,t),r=e.substring(t+v.length);return d("span",{children:[n,i("span",{style:{color:"#f50"},children:v}),r]})},O=e=>e.map(e=>({...e,[f]:G(e[f]),[y]:e[y]?O(e[y]):void 0})),P=E(m,v),b=O(P);return r(()=>{o?.(m)},[m]),d("div",{style:{width:300},children:[i(a,{style:{marginBottom:8},placeholder:"输入关键字进行过滤",onSearch:async e=>{e!==v&&(e=>{if(I(e),S(!0),!e)return void K([]);const t=D(m,e);K(t)})(e)}}),i(t,{onExpand:e=>{K(e),S(!1)},onSelect:(e,t)=>{if(e.length>0){const t=e[0],n=s({data:m,targetId:t,idKey:p,childrenKey:y,isIncludeOneself:h});l?.(n)}c?.(e,t)},autoExpandParent:N,expandedKeys:x,treeData:b,fieldNames:{title:f,key:p,children:y},...g})]})};o.displayName="BasicLeftTree";export{o as default};
1
+ import{Input as e,Tree as t}from"antd";import{useState as n,useEffect as r}from"react";import{getTreeNodePaths as s}from"../../../utils/index.js";import{jsxs as d,jsx as i}from"react/jsx-runtime";const{Search:a}=e,o=e=>{const{onGetData:o,onSelect:c,onGetNodePaths:l,onGetNodePathsIsIncludeOneself:h=!0,expandedKeys:u,treeData:m=[],nameKey:f="name",idKey:p="id",childrenKey:y="children",...g}=e,[x,K]=n([]),[v,I]=n(""),[N,S]=n(!0);r(()=>{K(u)},[u]);const D=(e,t,n=[])=>(e.forEach(e=>{e[y]&&((e[f].includes(t)||e[y].some(e=>e[f].includes(t)))&&n.push(e[p]),D(e[y],t,n))}),n),E=(e,t)=>t?e.reduce((e,n)=>{const r=n[f].includes(t),s=n[y]?E(n[y],t):[];return(r||s.length>0)&&e.push({...n,[y]:s.length>0?s:void 0}),e},[]):e,G=e=>{if(!v)return e;const t=e.indexOf(v);if(-1===t)return e;const n=e.substring(0,t),r=e.substring(t+v.length);return d("span",{children:[n,i("span",{style:{color:"#f50"},children:v}),r]})},O=e=>e.map(e=>({...e,[f]:G(e[f]),[y]:e[y]?O(e[y]):void 0})),P=E(m,v),b=O(P);return r(()=>{o?.(m)},[m]),d("div",{style:{width:300},children:[i(a,{style:{marginBottom:8},placeholder:"输入关键字进行过滤",onSearch:async e=>{e!==v&&(e=>{if(I(e),S(!0),!e)return void K([]);const t=D(m,e);K(t)})(e)}}),i(t,{onExpand:e=>{K(e),S(!1)},onSelect:(e,t)=>{if(e.length>0&&l){const t=e[0],n=s({data:m,targetId:t,idKey:p,childrenKey:y,isIncludeOneself:h});l?.(n)}c?.(e,t)},autoExpandParent:N,expandedKeys:x,treeData:b,fieldNames:{title:f,key:p,children:y},...g})]})};o.displayName="BasicLeftTree";export{o as default};
@@ -1 +1 @@
1
- import{Select as e}from"antd";import{useEffect as n}from"react";import{jsx as r}from"react/jsx-runtime";function a(a){const{onGetData:o,onChange:t,onGetLabel:i,onGetOption:l,placeholder:c="",data:s=[],nameKey:d="name",idKey:p="id",labelRender:h,...f}=a;return n(()=>{o?.(s)},[s]),r(e,{placeholder:`请选择${c}`,showSearch:!0,allowClear:!0,optionFilterProp:"children",onChange:(e,n)=>{if(Array.isArray(e))if(e.length>0){const n=[],r=[];e.forEach(e=>{const a=s.find(n=>n[p]===e);a&&(n.push(a),r.push(a[d]))}),i?.(r),l?.(n)}else i?.([]),l?.([]);else if(e){const n=s.find(n=>n[p]===e);i?.(n[d]),l?.(n)}else i?.(""),l?.({});t?.(e,n)},...f,children:s.map(n=>{const a=n[p],o=h?h(n):n[d];return r(e.Option,{value:a,children:o},a)})})}a.displayName="BasicSelect";export{a as default};
1
+ import{Select as e}from"antd";import{useEffect as n}from"react";import{jsx as r}from"react/jsx-runtime";function a(a){const{onGetData:o,onChange:t,onGetLabel:i,onGetOption:l,placeholder:c="",data:s=[],nameKey:d="name",idKey:p="id",labelRender:h,...f}=a;return n(()=>{o?.(s)},[s]),r(e,{placeholder:`请选择${c}`,showSearch:!0,allowClear:!0,optionFilterProp:"children",onChange:(e,n)=>{if(i||l)if(Array.isArray(e))if(e.length>0){const n=[],r=[];e.forEach(e=>{const a=s.find(n=>n[p]===e);a&&(n.push(a),r.push(a[d]))}),i?.(r),l?.(n)}else i?.([]),l?.([]);else if(e){const n=s.find(n=>n[p]===e);i?.(n[d]),l?.(n)}else i?.(""),l?.({});t?.(e,n)},...f,children:s.map(n=>{const a=n[p],o=h?h(n):n[d];return r(e.Option,{value:a,children:o},a)})})}a.displayName="BasicSelect";export{a as default};
@@ -1 +1 @@
1
- import{TreeSelect as e}from"antd";import{useEffect as l}from"react";import{processTreeDataByLevel as t,processTreeDataForOnlyLastLevel as a,getDataType as r,getTreeNodePaths as n,arrayObjectDeduplication as o}from"../../../utils/index.js";import{jsx as c}from"react/jsx-runtime";function i(i){const{onGetData:d,onChange:s,onGetLabel:h,onGetNodePaths:u,onGetNodePathsIsIncludeOneself:y=!0,placeholder:m="",treeData:p=[],nameKey:f="name",idKey:v="id",childrenKey:I="children",level:K,onlyLastLevel:g=!1,...C}=i;let L=K?t({data:p,level:K,childrenKey:I,currentLevel:1}):p;return L=a({data:L,childrenKey:I,onlyLastLevel:g}),l(()=>{d?.(p,L)},[p,L]),c(e,{showSearch:!0,style:{width:"100%"},styles:{popup:{root:{maxHeight:400,overflow:"auto"}}},placeholder:`请选择${m}`,onChange:(e,l,t)=>{if(e)if("Array"===r(e)){const t=[];for(let l=0;l<e.length;l++){const a=C.labelInValue||C.treeCheckStrictly?e[l].value:e[l],r=n({data:p,targetId:a,idKey:v,childrenKey:I,isIncludeOneself:y});t.push(...r)}const a=o(t,v);u?.(a),h?.(C.labelInValue||C.treeCheckStrictly?e.map(e=>e.label):l)}else{const l=C.labelInValue||C.treeCheckStrictly?e.value:e,t=n({data:p,targetId:l,idKey:v,childrenKey:I,isIncludeOneself:y});u?.(t),h?.(t[t.length-1][f])}else u?.([]),h?.("");s?.(C.labelInValue||C.treeCheckStrictly?e.map(e=>e.value):e,l,t)},allowClear:!0,treeData:L,fieldNames:{label:f,value:v,children:I},treeNodeFilterProp:f,showCheckedStrategy:e.SHOW_ALL,...C})}i.displayName="BasicSelectTree";export{i as default};
1
+ import{TreeSelect as e}from"antd";import{useMemo as l,useEffect as t}from"react";import{processTreeDataByLevel as a,processTreeDataForOnlyLastLevel as r,getDataType as n,getTreeNodePaths as o,arrayObjectDeduplication as i}from"../../../utils/index.js";import{jsx as c}from"react/jsx-runtime";function d(d){const{onGetData:s,onChange:h,onGetLabel:u,onGetNodePaths:y,onGetNodePathsIsIncludeOneself:f=!0,placeholder:m="",treeData:p=[],nameKey:v="name",idKey:I="id",childrenKey:K="children",level:g,onlyLastLevel:C=!1,...L}=d,S=l(()=>{let e=g?a({data:p,level:g,childrenKey:K,currentLevel:1}):p;return e=r({data:e,childrenKey:K,onlyLastLevel:C}),e},[p,g,K,C]);return t(()=>{s?.(p,S)},[p,S]),c(e,{showSearch:!0,style:{width:"100%"},styles:{popup:{root:{maxHeight:400,overflow:"auto"}}},placeholder:`请选择${m}`,onChange:(e,l,t)=>{if(e){if("Array"===n(e)){if(y){const l=[];for(let t=0;t<e.length;t++){const a=L.labelInValue||L.treeCheckStrictly?e[t].value:e[t],r=o({data:p,targetId:a,idKey:I,childrenKey:K,isIncludeOneself:f});l.push(...r)}const t=i(l,I);y?.(t)}u?.(L.labelInValue||L.treeCheckStrictly?e.map(e=>e.label):l)}else if(y||u){const l=L.labelInValue||L.treeCheckStrictly?e.value:e,t=o({data:p,targetId:l,idKey:I,childrenKey:K,isIncludeOneself:f});y?.(t),u?.(t[t.length-1][v])}}else y?.([]),u?.("");h?.(L.labelInValue||L.treeCheckStrictly?e.map(e=>e.value):e,l,t)},allowClear:!0,treeData:S,fieldNames:{label:v,value:I,children:K},treeNodeFilterProp:v,showCheckedStrategy:e.SHOW_ALL,...L})}d.displayName="BasicSelectTree";export{d as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "1.1.43",
4
+ "version": "1.1.44",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",