@bikdotai/bik-component-library 0.0.532-beta.cm-2 → 0.0.532-beta.cm-3
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/cjs/components/accordion/Accordion.d.ts +3 -0
- package/dist/cjs/components/accordion/Accordion.js +1 -1
- package/dist/cjs/components/accordion/Accordion.style.d.ts +2 -0
- package/dist/cjs/components/accordion/Accordion.style.js +3 -2
- package/dist/esm/components/accordion/Accordion.d.ts +3 -0
- package/dist/esm/components/accordion/Accordion.js +1 -1
- package/dist/esm/components/accordion/Accordion.style.d.ts +2 -0
- package/dist/esm/components/accordion/Accordion.style.js +1 -0
- package/package.json +1 -1
|
@@ -14,5 +14,8 @@ export interface AccordionProps {
|
|
|
14
14
|
refresh?: number | boolean;
|
|
15
15
|
autoOpen?: boolean;
|
|
16
16
|
childrenMaxHeight?: number;
|
|
17
|
+
openDirection?: 'DOWN' | 'UP';
|
|
18
|
+
headerStyles?: React.CSSProperties;
|
|
19
|
+
onToggleAccordion?: (state: boolean) => void;
|
|
17
20
|
}
|
|
18
21
|
export declare const BikAccordion: React.FC<AccordionProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../TypographyStyle.js"),n=require("./Accordion.style.js"),i=require("./AccordionArrow.js");exports.BikAccordion=o=>{var s;const[a,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../TypographyStyle.js"),n=require("./Accordion.style.js"),i=require("./AccordionArrow.js");exports.BikAccordion=o=>{var s,c;const[a,l]=r.useState(!1),d=r.useRef(null),u=r.useRef(null);r.useEffect((()=>{o.autoOpen&&h(o.autoOpen,{})}),[o.autoOpen]);const h=(e,r)=>{var t,n;u.current&&d.current&&("keydown"===r.type&&"Enter"!==r.key||(l(e),u.current.style.maxHeight?(u.current.style.maxHeight="",d.current.style.transform="rotate(0deg)",d.current.style.transition="transform 0.25s ease-in-out",u.current.style.transition="padding 0s"):(u.current.style.maxHeight=(null!==(t=o.childrenMaxHeight)&&void 0!==t?t:u.current.scrollHeight)+"px",d.current.style.transform="rotate(180deg)",d.current.style.transition="transform 0.25s ease-in-out",u.current.style.transition="max-height 0.25s ease-in-out"),null===(n=o.onToggleAccordion)||void 0===n||n.call(o,e)))};return r.useEffect((()=>{var e;a&&(null==o?void 0:o.refresh)&&(null===(e=null==u?void 0:u.current)||void 0===e?void 0:e.scrollHeight)&&!o.childrenMaxHeight&&setTimeout((()=>{u.current.style.maxHeight=u.current.scrollHeight+"px"}),100)}),[a,null==o?void 0:o.refresh,null===(s=null==u?void 0:u.current)||void 0===s?void 0:s.scrollHeight]),e.jsxs(n.default,Object.assign({className:"accordion",isActive:a,width:null==o?void 0:o.width,contentMargin:null==o?void 0:o.contentMargin,headerPadding:o.headerPadding,skipHoverState:o.skipHoverHeader,showBorders:o.showBorders,backgroundColor:o.backgroundColor,openDirection:o.openDirection},{children:[e.jsxs("div",Object.assign({className:"accordion__overview "+(a?"active":""),onClick:e=>h(!a,e),onKeyDown:e=>h(!a,e),role:"button",tabIndex:0},{children:[!o.rightActionComponent&&e.jsxs("div",Object.assign({className:"accordion__overview__header",style:null!==(c=o.headerStyles)&&void 0!==c?c:{}},{children:["string"==typeof o.header?e.jsx(t.TitleRegular,{children:null==o?void 0:o.header}):o.header,e.jsx(i.default,{isNewIcon:!0,ref:d})]})),o.rightActionComponent&&e.jsxs("div",Object.assign({className:"accordion__overview__header"},{children:[e.jsxs("div",Object.assign({className:"accordion__overview__title-wrapper"},{children:[e.jsx(i.default,{isNewIcon:!0,ref:d}),"string"==typeof o.header?e.jsx(t.TitleRegular,{children:null==o?void 0:o.header}):o.header]})),e.jsx("div",Object.assign({onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Enter"===e.key&&e.stopPropagation()},role:"button",tabIndex:0},{children:o.rightActionComponent}))]})),(null==o?void 0:o.caption)&&e.jsx("div",Object.assign({className:"accordion__overview__caption"},{children:e.jsx(t.BodySecondary,{children:o.caption})}))]})),e.jsx("div",Object.assign({ref:u,className:"accordion__content"},{children:o.children}))]}))};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AccordionProps } from './Accordion';
|
|
1
2
|
declare const AccordionStyle: import("styled-components").StyledComponent<"div", any, {
|
|
2
3
|
isActive: boolean;
|
|
3
4
|
width?: string | undefined;
|
|
@@ -7,5 +8,6 @@ declare const AccordionStyle: import("styled-components").StyledComponent<"div",
|
|
|
7
8
|
showBorders?: boolean | undefined;
|
|
8
9
|
backgroundColor?: string | undefined;
|
|
9
10
|
hasChildrenMaxHeight?: boolean | undefined;
|
|
11
|
+
openDirection?: AccordionProps['openDirection'];
|
|
10
12
|
}, never>;
|
|
11
13
|
export default AccordionStyle;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),r=require("../../constants/Theme.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),r=require("../../constants/Theme.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const i=o(e).default.div`
|
|
2
2
|
width: ${e=>(null==e?void 0:e.width)||"100%"};
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
${e=>e.isActive?{margin:(null==e?void 0:e.contentMargin)||"0px"}:{}};
|
|
32
32
|
overflow: ${e=>e.hasChildrenMaxHeight?"scroll":"hidden"};
|
|
33
33
|
max-height: 0;
|
|
34
|
+
order: ${e=>"UP"===e.openDirection?-1:0};
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
`;exports.default=
|
|
37
|
+
`;exports.default=i;
|
|
@@ -14,5 +14,8 @@ export interface AccordionProps {
|
|
|
14
14
|
refresh?: number | boolean;
|
|
15
15
|
autoOpen?: boolean;
|
|
16
16
|
childrenMaxHeight?: number;
|
|
17
|
+
openDirection?: 'DOWN' | 'UP';
|
|
18
|
+
headerStyles?: React.CSSProperties;
|
|
19
|
+
onToggleAccordion?: (state: boolean) => void;
|
|
17
20
|
}
|
|
18
21
|
export declare const BikAccordion: React.FC<AccordionProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useState as n,useRef as
|
|
1
|
+
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useState as n,useRef as o,useEffect as t}from"react";import{TitleRegular as i,BodySecondary as c}from"../TypographyStyle.js";import a from"./Accordion.style.js";import l from"./AccordionArrow.js";const s=s=>{var d,h;const[u,v]=n(!1),g=o(null),p=o(null);t((()=>{s.autoOpen&&m(s.autoOpen,{})}),[s.autoOpen]);const m=(e,r)=>{var n,o;p.current&&g.current&&("keydown"===r.type&&"Enter"!==r.key||(v(e),p.current.style.maxHeight?(p.current.style.maxHeight="",g.current.style.transform="rotate(0deg)",g.current.style.transition="transform 0.25s ease-in-out",p.current.style.transition="padding 0s"):(p.current.style.maxHeight=(null!==(n=s.childrenMaxHeight)&&void 0!==n?n:p.current.scrollHeight)+"px",g.current.style.transform="rotate(180deg)",g.current.style.transition="transform 0.25s ease-in-out",p.current.style.transition="max-height 0.25s ease-in-out"),null===(o=s.onToggleAccordion)||void 0===o||o.call(s,e)))};return t((()=>{var e;u&&(null==s?void 0:s.refresh)&&(null===(e=null==p?void 0:p.current)||void 0===e?void 0:e.scrollHeight)&&!s.childrenMaxHeight&&setTimeout((()=>{p.current.style.maxHeight=p.current.scrollHeight+"px"}),100)}),[u,null==s?void 0:s.refresh,null===(d=null==p?void 0:p.current)||void 0===d?void 0:d.scrollHeight]),e(a,Object.assign({className:"accordion",isActive:u,width:null==s?void 0:s.width,contentMargin:null==s?void 0:s.contentMargin,headerPadding:s.headerPadding,skipHoverState:s.skipHoverHeader,showBorders:s.showBorders,backgroundColor:s.backgroundColor,openDirection:s.openDirection},{children:[e("div",Object.assign({className:"accordion__overview "+(u?"active":""),onClick:e=>m(!u,e),onKeyDown:e=>m(!u,e),role:"button",tabIndex:0},{children:[!s.rightActionComponent&&e("div",Object.assign({className:"accordion__overview__header",style:null!==(h=s.headerStyles)&&void 0!==h?h:{}},{children:["string"==typeof s.header?r(i,{children:null==s?void 0:s.header}):s.header,r(l,{isNewIcon:!0,ref:g})]})),s.rightActionComponent&&e("div",Object.assign({className:"accordion__overview__header"},{children:[e("div",Object.assign({className:"accordion__overview__title-wrapper"},{children:[r(l,{isNewIcon:!0,ref:g}),"string"==typeof s.header?r(i,{children:null==s?void 0:s.header}):s.header]})),r("div",Object.assign({onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Enter"===e.key&&e.stopPropagation()},role:"button",tabIndex:0},{children:s.rightActionComponent}))]})),(null==s?void 0:s.caption)&&r("div",Object.assign({className:"accordion__overview__caption"},{children:r(c,{children:s.caption})}))]})),r("div",Object.assign({ref:p,className:"accordion__content"},{children:s.children}))]}))};export{s as BikAccordion};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AccordionProps } from './Accordion';
|
|
1
2
|
declare const AccordionStyle: import("styled-components").StyledComponent<"div", any, {
|
|
2
3
|
isActive: boolean;
|
|
3
4
|
width?: string | undefined;
|
|
@@ -7,5 +8,6 @@ declare const AccordionStyle: import("styled-components").StyledComponent<"div",
|
|
|
7
8
|
showBorders?: boolean | undefined;
|
|
8
9
|
backgroundColor?: string | undefined;
|
|
9
10
|
hasChildrenMaxHeight?: boolean | undefined;
|
|
11
|
+
openDirection?: AccordionProps['openDirection'];
|
|
10
12
|
}, never>;
|
|
11
13
|
export default AccordionStyle;
|
|
@@ -31,6 +31,7 @@ import e from"styled-components";import{COLORS as r}from"../../constants/Theme.j
|
|
|
31
31
|
${e=>e.isActive?{margin:(null==e?void 0:e.contentMargin)||"0px"}:{}};
|
|
32
32
|
overflow: ${e=>e.hasChildrenMaxHeight?"scroll":"hidden"};
|
|
33
33
|
max-height: 0;
|
|
34
|
+
order: ${e=>"UP"===e.openDirection?-1:0};
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
`;export{o as default};
|