rox-react-components 0.0.10 → 0.0.12
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/dist/es/Menu/Menu.js +1 -1
- package/dist/lib/Menu/Menu.js +1 -1
- package/package.json +1 -1
package/dist/es/Menu/Menu.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{css as t}from"aphrodite/no-important";import r,{createContext as n,useState as i,useEffect as a,useContext as c,useCallback as o}from"react";import l from"../Card/Card.js";import d from"./styles.js";var u={data:[],renderItem:function(){return null},onChange:function(){return null},subItemStyle:{paddingLeft:"25px"},activeStyle:{color:"skyblue"},active:"
|
|
1
|
+
import{__assign as e}from"tslib";import{css as t}from"aphrodite/no-important";import r,{createContext as n,useState as i,useEffect as a,useContext as c,useCallback as o}from"react";import l from"../Card/Card.js";import d from"./styles.js";var u={data:[],renderItem:function(){return null},onChange:function(){return null},subItemStyle:{paddingLeft:"25px"},activeStyle:{color:"skyblue"},active:"",isMultipleExpand:!1,iconSize:"10px",iconStrokeWidth:"2px",iconColor:"#333"};function s(n){var i=e(e({},u),n),a=i.iconSize,c=i.iconStrokeWidth,o=i.iconColor,l=i.down;return r.createElement("div",{style:{"--size":a,"--strokeWidth":c,"--color":o},className:"".concat(t(d.arrow_right)," ").concat(l?t(d.arrow_down):"")})}var m=n({active:"0",changeActive:function(){return null}}),v=function(n){var h=e(e({},u),n),f=h.renderItem,p=h.item,y=h.subItemStyle,g=h.activeStyle,E=h.index,x=h.isMultipleExpand,A=h.icon,b=h.activeIcon,S=i(!1),C=S[0],k=S[1],w=c(m),I=w.active,W=w.changeActive,_=o((function(e){e.stopPropagation(),W(E),h.onChange(p,E),p.children&&Array.isArray(p.children)&&k((function(e){return!e}))}),[W,E,p]);return a((function(){if(void 0!==I){var e=I.split("-"),t=E.split("-");I.startsWith(E)&&e.length>t.length&&E.length<I.length?k(!0):I.startsWith(E)&&E.startsWith(I)||x||k(!1)}}),[I,E]),r.createElement("div",{className:t(d.w_full,d.border_box),onClick:_},r.createElement("div",{className:t(d.item),style:I===E?g:{}},f(p)," ",Array.isArray(p.children)&&p.children.length?C?b||r.createElement(s,e({},h,{down:!0})):A||r.createElement(s,e({},h)):null),Array.isArray(p.children)?p.children.map((function(n,i){return r.createElement("div",{key:i,className:t(d.w_full,d.border_box),style:e(e({},u.subItemStyle),y)},r.createElement(l,{expand:C},r.createElement(v,e({},h,{index:E+"-"+i,item:n}))))})):null)},h=function(t){var n=e(e({},u),t),c=i(n.active),o=c[0],l=c[1];return a((function(){if(n.data.length&&void 0!==n.active){var e=n.active.split("-").map((function(e){return Number(e)})),t=n.data,r={};e.forEach((function(e){Array.isArray(t)&&(r=t[e]||{},t=r.children)})),n.onChange(r,n.active)}l(n.active)}),[n.active,n.data]),r.createElement(m.Provider,{value:{active:o,changeActive:l}},n.data.map((function(t,i){return r.createElement(v,e({key:i,index:i.toString()},n,{item:t}))})))};export{h as default};
|
package/dist/lib/Menu/Menu.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("aphrodite/no-important"),n=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("aphrodite/no-important"),n=require("react"),a=require("../Card/Card.js"),r=require("./styles.js"),i={data:[],renderItem:function(){return null},onChange:function(){return null},subItemStyle:{paddingLeft:"25px"},activeStyle:{color:"skyblue"},active:"",isMultipleExpand:!1,iconSize:"10px",iconStrokeWidth:"2px",iconColor:"#333"};function s(a){var s=e.__assign(e.__assign({},i),a),c=s.iconSize,l=s.iconStrokeWidth,o=s.iconColor,u=s.down;return n.createElement("div",{style:{"--size":c,"--strokeWidth":l,"--color":o},className:"".concat(t.css(r.default.arrow_right)," ").concat(u?t.css(r.default.arrow_down):"")})}var c=n.createContext({active:"0",changeActive:function(){return null}}),l=function(o){var u=e.__assign(e.__assign({},i),o),d=u.renderItem,f=u.item,v=u.subItemStyle,_=u.activeStyle,g=u.index,h=u.isMultipleExpand,m=u.icon,p=u.activeIcon,y=n.useState(!1),x=y[0],E=y[1],b=n.useContext(c),S=b.active,A=b.changeActive,C=n.useCallback((function(e){e.stopPropagation(),A(g),u.onChange(f,g),f.children&&Array.isArray(f.children)&&E((function(e){return!e}))}),[A,g,f]);return n.useEffect((function(){if(void 0!==S){var e=S.split("-"),t=g.split("-");S.startsWith(g)&&e.length>t.length&&g.length<S.length?E(!0):S.startsWith(g)&&g.startsWith(S)||h||E(!1)}}),[S,g]),n.createElement("div",{className:t.css(r.default.w_full,r.default.border_box),onClick:C},n.createElement("div",{className:t.css(r.default.item),style:S===g?_:{}},d(f)," ",Array.isArray(f.children)&&f.children.length?x?p||n.createElement(s,e.__assign({},u,{down:!0})):m||n.createElement(s,e.__assign({},u)):null),Array.isArray(f.children)?f.children.map((function(s,c){return n.createElement("div",{key:c,className:t.css(r.default.w_full,r.default.border_box),style:e.__assign(e.__assign({},i.subItemStyle),v)},n.createElement(a.default,{expand:x},n.createElement(l,e.__assign({},u,{index:g+"-"+c,item:s}))))})):null)};exports.default=function(t){var a=e.__assign(e.__assign({},i),t),r=n.useState(a.active),s=r[0],o=r[1];return n.useEffect((function(){if(a.data.length&&void 0!==a.active){var e=a.active.split("-").map((function(e){return Number(e)})),t=a.data,n={};e.forEach((function(e){Array.isArray(t)&&(n=t[e]||{},t=n.children)})),a.onChange(n,a.active)}o(a.active)}),[a.active,a.data]),n.createElement(c.Provider,{value:{active:s,changeActive:o}},a.data.map((function(t,r){return n.createElement(l,e.__assign({key:r,index:r.toString()},a,{item:t}))})))};
|