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