rox-react-components 0.0.31 → 0.0.32
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.d.ts +7 -4
- package/dist/es/Menu/Menu.js +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/lib/Menu/Menu.d.ts +7 -4
- package/dist/lib/Menu/Menu.js +1 -1
- package/package.json +1 -1
package/dist/es/Menu/Menu.d.ts
CHANGED
|
@@ -11,14 +11,17 @@ interface IconProps {
|
|
|
11
11
|
iconStrokeWidth?: string;
|
|
12
12
|
iconColor?: string;
|
|
13
13
|
}
|
|
14
|
+
interface ExposeDataType<T> {
|
|
15
|
+
item: (T & {
|
|
16
|
+
__index__: string;
|
|
17
|
+
}) | null;
|
|
18
|
+
active: string;
|
|
19
|
+
}
|
|
14
20
|
interface MenuProps<T> extends IconProps {
|
|
15
21
|
data: T[];
|
|
16
22
|
renderItem: (item: T, index: string) => ReactNode;
|
|
17
|
-
onChange?: (data:
|
|
18
|
-
item: T | null;
|
|
19
|
-
}) => void;
|
|
23
|
+
onChange?: (data: ExposeDataType<T>['item']) => void;
|
|
20
24
|
active?: string;
|
|
21
|
-
activeField?: string;
|
|
22
25
|
childrenField?: string;
|
|
23
26
|
icon?: ReactNode;
|
|
24
27
|
activeIcon?: ReactNode;
|
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 n,{createContext as a,useMemo as i,useState as r,useCallback as c,useEffect as
|
|
1
|
+
import{__assign as e}from"tslib";import{css as t}from"aphrodite/no-important";import n,{createContext as a,useMemo as i,useState as r,useCallback as c,useEffect as o,useContext as l}from"react";import m from"../Card/Card.js";import u from"./styles.js";var d={data:[],renderItem:function(){return null},onChange:function(){return null},active:"",childrenField:"children",iconSize:"10px",iconColor:"#333",iconStrokeWidth:"2px",itemClassName:"",itemLabelClassName:"",activeItemClassName:"",activeItemLabelClassName:""},s=a({active:"",changeData:function(){return null}});function f(e){var a=e.iconSize,i=e.iconStrokeWidth,r=e.iconColor,c=e.down;return n.createElement("div",{style:{"--size":a,"--strokeWidth":i,"--color":r},className:"".concat(t(u.arrow_right)," ").concat(c?t(u.arrow_down):"")})}function v(a){var d=r(!1),h=d[0],_=d[1],p=a.item,C=a.index,x=a.childrenField,E=a.renderItem,N=a.activeIcon,g=a.icon,b=a.itemClassName,w=a.itemLabelClassName,I=a.activeItemClassName,k=a.activeItemLabelClassName,y=a.active,F=l(s),S=F.changeData;F.active;var L=C.split("-").length,z=Array.isArray(p[x])&&p[x].length?p[x]:null,D=i((function(){return p&&!z&&y===p.__index__}),[p,y,z]),W=c((function(e){e.stopPropagation(),z||S({item:p}),_((function(e){return!e}))}),[z,S,p]);return o((function(){D&&S({item:p})}),[D,p]),o((function(){(null==y?void 0:y.includes(C))&&_(!0)}),[y,C]),n.createElement("div",{className:t(u.w_full,u.border_box),onClick:W},n.createElement("div",{className:"".concat(t(u.item)," item-").concat(L," ").concat(b," ").concat(D?I:"")},n.createElement("div",{className:"".concat(t(u.flex_1)," ").concat(w," ").concat(D?k:"")},E(p,C)),n.createElement(n.Fragment,null,z?h?N||n.createElement(f,e({},a,{down:!0})):g||n.createElement(f,e({},a)):null)),z?z.map((function(i,r){return n.createElement("div",{key:r,className:"".concat(t(u.w_full,u.border_box)," sub-item-").concat(L)},n.createElement(m,{expand:h},n.createElement(v,e({},a,{index:C+"-"+r,item:i}))))})):null)}function h(t){var a=i((function(){return function e(n,a){n.forEach((function(n,i){n.__index__=void 0!==a?a+"-"+i:i.toString(),n[t.childrenField]&&e(n[t.childrenField],n.__index__)}))}(t.data),t.data}),[t.data,t.childrenField]),l=i((function(){return e(e(e({},d),t),{data:a})}),[t,a]),m=r({active:"",item:null}),u=m[0],f=m[1],h=c((function(t){return f((function(n){return e(e({},n),t)}))}),[]);return o((function(){var e;u.item&&(null===(e=l.onChange)||void 0===e||e.call(l,u.item))}),[u.active]),n.createElement(s.Provider,{value:{active:u.active,changeData:h}},l.data.map((function(t,a){return n.createElement(v,e({key:a},l,{index:a.toString(),item:t}))})))}export{h as default};
|
package/dist/index.d.ts
CHANGED
|
@@ -81,14 +81,17 @@ interface IconProps {
|
|
|
81
81
|
iconStrokeWidth?: string;
|
|
82
82
|
iconColor?: string;
|
|
83
83
|
}
|
|
84
|
+
interface ExposeDataType<T> {
|
|
85
|
+
item: (T & {
|
|
86
|
+
__index__: string;
|
|
87
|
+
}) | null;
|
|
88
|
+
active: string;
|
|
89
|
+
}
|
|
84
90
|
interface MenuProps<T> extends IconProps {
|
|
85
91
|
data: T[];
|
|
86
92
|
renderItem: (item: T, index: string) => ReactNode;
|
|
87
|
-
onChange?: (data:
|
|
88
|
-
item: T | null;
|
|
89
|
-
}) => void;
|
|
93
|
+
onChange?: (data: ExposeDataType<T>['item']) => void;
|
|
90
94
|
active?: string;
|
|
91
|
-
activeField?: string;
|
|
92
95
|
childrenField?: string;
|
|
93
96
|
icon?: ReactNode;
|
|
94
97
|
activeIcon?: ReactNode;
|
package/dist/lib/Menu/Menu.d.ts
CHANGED
|
@@ -11,14 +11,17 @@ interface IconProps {
|
|
|
11
11
|
iconStrokeWidth?: string;
|
|
12
12
|
iconColor?: string;
|
|
13
13
|
}
|
|
14
|
+
interface ExposeDataType<T> {
|
|
15
|
+
item: (T & {
|
|
16
|
+
__index__: string;
|
|
17
|
+
}) | null;
|
|
18
|
+
active: string;
|
|
19
|
+
}
|
|
14
20
|
interface MenuProps<T> extends IconProps {
|
|
15
21
|
data: T[];
|
|
16
22
|
renderItem: (item: T, index: string) => ReactNode;
|
|
17
|
-
onChange?: (data:
|
|
18
|
-
item: T | null;
|
|
19
|
-
}) => void;
|
|
23
|
+
onChange?: (data: ExposeDataType<T>['item']) => void;
|
|
20
24
|
active?: string;
|
|
21
|
-
activeField?: string;
|
|
22
25
|
childrenField?: string;
|
|
23
26
|
icon?: ReactNode;
|
|
24
27
|
activeIcon?: ReactNode;
|
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"),a=require("../Card/Card.js"),i=require("./styles.js"),c={data:[],renderItem:function(){return null},onChange:function(){return null},active:"",
|
|
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"),i=require("./styles.js"),c={data:[],renderItem:function(){return null},onChange:function(){return null},active:"",childrenField:"children",iconSize:"10px",iconColor:"#333",iconStrokeWidth:"2px",itemClassName:"",itemLabelClassName:"",activeItemClassName:"",activeItemLabelClassName:""},r=n.createContext({active:"",changeData:function(){return null}});function l(e){var a=e.iconSize,c=e.iconStrokeWidth,r=e.iconColor,l=e.down;return n.createElement("div",{style:{"--size":a,"--strokeWidth":c,"--color":r},className:"".concat(t.css(i.default.arrow_right)," ").concat(l?t.css(i.default.arrow_down):"")})}function s(c){var o=n.useState(!1),u=o[0],d=o[1],m=c.item,f=c.index,_=c.childrenField,v=c.renderItem,g=c.activeIcon,h=c.icon,C=c.itemClassName,x=c.itemLabelClassName,E=c.activeItemClassName,b=c.activeItemLabelClassName,p=c.active,N=n.useContext(r),k=N.changeData;N.active;var S=f.split("-").length,w=Array.isArray(m[_])&&m[_].length?m[_]:null,y=n.useMemo((function(){return m&&!w&&p===m.__index__}),[m,p,w]),I=n.useCallback((function(e){e.stopPropagation(),w||k({item:m}),d((function(e){return!e}))}),[w,k,m]);return n.useEffect((function(){y&&k({item:m})}),[y,m]),n.useEffect((function(){(null==p?void 0:p.includes(f))&&d(!0)}),[p,f]),n.createElement("div",{className:t.css(i.default.w_full,i.default.border_box),onClick:I},n.createElement("div",{className:"".concat(t.css(i.default.item)," item-").concat(S," ").concat(C," ").concat(y?E:"")},n.createElement("div",{className:"".concat(t.css(i.default.flex_1)," ").concat(x," ").concat(y?b:"")},v(m,f)),n.createElement(n.Fragment,null,w?u?g||n.createElement(l,e.__assign({},c,{down:!0})):h||n.createElement(l,e.__assign({},c)):null)),w?w.map((function(r,l){return n.createElement("div",{key:l,className:"".concat(t.css(i.default.w_full,i.default.border_box)," sub-item-").concat(S)},n.createElement(a.default,{expand:u},n.createElement(s,e.__assign({},c,{index:f+"-"+l,item:r}))))})):null)}exports.default=function(t){var a=n.useMemo((function(){return function e(n,a){n.forEach((function(n,i){n.__index__=void 0!==a?a+"-"+i:i.toString(),n[t.childrenField]&&e(n[t.childrenField],n.__index__)}))}(t.data),t.data}),[t.data,t.childrenField]),i=n.useMemo((function(){return e.__assign(e.__assign(e.__assign({},c),t),{data:a})}),[t,a]),l=n.useState({active:"",item:null}),o=l[0],u=l[1],d=n.useCallback((function(t){return u((function(n){return e.__assign(e.__assign({},n),t)}))}),[]);return n.useEffect((function(){var e;o.item&&(null===(e=i.onChange)||void 0===e||e.call(i,o.item))}),[o.active]),n.createElement(r.Provider,{value:{active:o.active,changeData:d}},i.data.map((function(t,a){return n.createElement(s,e.__assign({key:a},i,{index:a.toString(),item:t}))})))};
|