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