@kvdbil/components 9.5.0 → 9.6.0
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,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("./Tab.js"),r=require("styled-components"),l=require("../../shared/media-queries.js"),i=require("react-collapse");function n(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("./Tab.js"),r=require("styled-components"),l=require("../../shared/media-queries.js"),i=require("react-collapse");function n(b){return b&&typeof b=="object"&&"default"in b?b:{default:b}}require("../Button/index.js"),require("../../theme.js"),require("../Spinner/index.js"),require("../../typography/ButtonText/index.js"),require("../Button/styles.js"),require("../../utils/utils.js");var a=n(e),o=n(r);const s=o.default.div`
|
|
2
2
|
.ReactCollapse--collapse {
|
|
3
3
|
transition: height 300ms;
|
|
4
4
|
}
|
|
5
|
-
`,d=
|
|
5
|
+
`,d=o.default.ul`
|
|
6
6
|
width: 100%;
|
|
7
7
|
padding: 0;
|
|
8
8
|
margin: 0.5rem 0;
|
|
@@ -10,12 +10,15 @@
|
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
align-items: center;
|
|
12
12
|
flex-wrap: wrap;
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
${({theme:b,fullWidthBorder:g})=>g?`border-bottom: 3px solid ${b.colors.gray.light6};`:`& > li {
|
|
15
|
+
border-bottom: 3px solid ${b.colors.gray.light6};
|
|
16
|
+
}`}
|
|
14
17
|
|
|
15
18
|
${l.mq("mobileM")} {
|
|
16
19
|
flex-direction: row;
|
|
17
|
-
justify-content: ${({justify:
|
|
20
|
+
justify-content: ${({justify:b})=>b};
|
|
18
21
|
}
|
|
19
|
-
`,u=
|
|
22
|
+
`,u=o.default.div`
|
|
20
23
|
padding: 0.5rem 0;
|
|
21
|
-
`,p=
|
|
24
|
+
`,p=o.default.div``,c=({activeColor:b="secondary",justify:g="end",initalActive:D,children:T=[],kbNavAutoOpen:q=!0,onTabClick:O=()=>{},fullWidthBorder:W=!0})=>{var E,$;const v=e.Children.map(T,f=>f),[x,k]=e.useState(()=>D!=null?D:v.findIndex(f=>!f.props.isDisabled)),A=e.useRef([]),I=Boolean(($=(E=v[x])==null?void 0:E.props)==null?void 0:$.children),M=(f,m)=>{if(f.preventDefault(),f.key!=="Enter"||q||k(m),f.key==="ArrowLeft"||f.key==="ArrowRight"){const y=q?x:m,h=f.key==="ArrowRight",w=h?y+1:0,B=h?v.length:y,R=v.slice(w,B);h||R.reverse();const C=R.findIndex(j=>!j.props.isDisabled);if(C!==-1){const j=h?y+(C+1):y-(C+1);q&&k(j),A.current[j].focus()}}};return a.default.createElement(s,null,a.default.createElement(i.UnmountClosed,{isOpened:!0},a.default.createElement(d,{fullWidthBorder:W,justify:g,role:"tablist"},v.map((f,m)=>f?a.default.createElement(t.default,{key:m,label:f.props.label,isDisabled:f.props.isDisabled,index:m,id:m,isActive:x===m,activeColor:b,onClick:(y,h)=>{f.props.isDisabled||(O(y,h),((w,B)=>{w.preventDefault(),k(B)})(y,h))},onKeyUp:M,ref:y=>A.current[m]=y}):null)),I&&a.default.createElement(u,null,v.map((f,m)=>{const y=f.props.children&&x===m;return a.default.createElement(p,{key:m,id:`tabpanel-${m}`,role:"tabpanel","aria-labelledby":`tab-${m}`,"aria-hidden":y?"false":"true"},y&&f.props.children)}))))};exports.Tabs=c,exports.default=c;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import i,{Children as
|
|
1
|
+
import i,{Children as $,useState as k,useRef as I}from"react";import B from"./Tab.js";import c from"styled-components";import{mq as _}from"../../shared/media-queries.js";import{UnmountClosed as A}from"react-collapse";import"../Button/index.js";import"../../theme.js";import"../Spinner/index.js";import"../../typography/ButtonText/index.js";import"../Button/styles.js";import"../../utils/utils.js";const P=c.div`
|
|
2
2
|
.ReactCollapse--collapse {
|
|
3
3
|
transition: height 300ms;
|
|
4
4
|
}
|
|
5
|
-
`,
|
|
5
|
+
`,S=c.ul`
|
|
6
6
|
width: 100%;
|
|
7
7
|
padding: 0;
|
|
8
8
|
margin: 0.5rem 0;
|
|
@@ -10,12 +10,15 @@ import i,{Children as R,useState as k,useRef as I}from"react";import $ from"./Ta
|
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
align-items: center;
|
|
12
12
|
flex-wrap: wrap;
|
|
13
|
-
border-bottom: 3px solid ${({theme:o})=>o.colors.gray.light6};
|
|
14
13
|
|
|
15
|
-
${
|
|
14
|
+
${({theme:o,fullWidthBorder:d})=>d?`border-bottom: 3px solid ${o.colors.gray.light6};`:`& > li {
|
|
15
|
+
border-bottom: 3px solid ${o.colors.gray.light6};
|
|
16
|
+
}`}
|
|
17
|
+
|
|
18
|
+
${_("mobileM")} {
|
|
16
19
|
flex-direction: row;
|
|
17
20
|
justify-content: ${({justify:o})=>o};
|
|
18
21
|
}
|
|
19
|
-
`,
|
|
22
|
+
`,U=c.div`
|
|
20
23
|
padding: 0.5rem 0;
|
|
21
|
-
`,
|
|
24
|
+
`,q=c.div``,T=({activeColor:o="secondary",justify:d="end",initalActive:f,children:v=[],kbNavAutoOpen:p=!0,onTabClick:j=()=>{},fullWidthBorder:C=!0})=>{var b,h;const s=$.map(v,e=>e),[l,m]=k(()=>f!=null?f:s.findIndex(e=>!e.props.isDisabled)),y=I([]),E=Boolean((h=(b=s[l])==null?void 0:b.props)==null?void 0:h.children),x=(e,t)=>{e.preventDefault(),m(t)},D=(e,t)=>{if(e.preventDefault(),e.key==="Enter"&&!p&&m(t),e.key==="ArrowLeft"||e.key==="ArrowRight"){const r=p?l:t,n=e.key==="ArrowRight",w=n?r+1:0,R=n?s.length:r,g=s.slice(w,R);n||g.reverse();const u=g.findIndex(a=>!a.props.isDisabled);if(u!==-1){const a=n?r+(u+1):r-(u+1);p&&m(a),y.current[a].focus()}}};return i.createElement(P,null,i.createElement(A,{isOpened:!0},i.createElement(S,{fullWidthBorder:C,justify:d,role:"tablist"},s.map((e,t)=>e?i.createElement(B,{key:t,label:e.props.label,isDisabled:e.props.isDisabled,index:t,id:t,isActive:l===t,activeColor:o,onClick:(r,n)=>{e.props.isDisabled||(j(r,n),x(r,n))},onKeyUp:D,ref:r=>y.current[t]=r}):null)),E&&i.createElement(U,null,s.map((e,t)=>{const r=e.props.children&&l===t;return i.createElement(q,{key:t,id:`tabpanel-${t}`,role:"tabpanel","aria-labelledby":`tab-${t}`,"aria-hidden":r?"false":"true"},r&&e.props.children)}))))};export{T as Tabs,T as default};
|
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ export interface TabsProps {
|
|
|
11
11
|
children: TabElement | TabElement[];
|
|
12
12
|
kbNavAutoOpen?: boolean;
|
|
13
13
|
onTabClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>, index: number) => void;
|
|
14
|
+
fullWidthBorder?: boolean;
|
|
14
15
|
}
|
|
15
|
-
export declare const Tabs: ({ activeColor, justify, initalActive, children, kbNavAutoOpen, onTabClick, }: TabsProps) => JSX.Element;
|
|
16
|
+
export declare const Tabs: ({ activeColor, justify, initalActive, children, kbNavAutoOpen, onTabClick, fullWidthBorder, }: TabsProps) => JSX.Element;
|
|
16
17
|
export default Tabs;
|