@bikdotai/bik-component-library 0.0.685-beta.4 → 0.0.685-beta.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.
- package/dist/cjs/components/accordion/Accordion.d.ts +7 -0
- package/dist/cjs/components/accordion/Accordion.js +1 -1
- package/dist/cjs/components/accordion/Accordion.style.d.ts +1 -0
- package/dist/cjs/components/accordion/Accordion.style.js +8 -1
- package/dist/cjs/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/components/accordion/Accordion.d.ts +7 -0
- package/dist/esm/components/accordion/Accordion.js +1 -1
- package/dist/esm/components/accordion/Accordion.style.d.ts +1 -0
- package/dist/esm/components/accordion/Accordion.style.js +23 -16
- package/dist/esm/components/bik-layout/MockMenus.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
export type HeaderButton = {
|
|
3
|
+
icon: React.FunctionComponent<React.SVGAttributes<SVGElement>>;
|
|
4
|
+
title: string;
|
|
5
|
+
onClick: () => void;
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
};
|
|
2
8
|
export interface AccordionProps {
|
|
3
9
|
header: JSX.Element | string;
|
|
4
10
|
subHeader?: JSX.Element | string;
|
|
@@ -24,5 +30,6 @@ export interface AccordionProps {
|
|
|
24
30
|
captionStyle?: React.CSSProperties;
|
|
25
31
|
borderColor?: string;
|
|
26
32
|
borderRadius?: string;
|
|
33
|
+
headerButtons?: HeaderButton[];
|
|
27
34
|
}
|
|
28
35
|
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"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../TypographyStyle.js"),o=require("../button/Button.js"),n=require("../icon-button/IconButton.js"),i=require("./Accordion.style.js"),s=require("./AccordionArrow.js");exports.BikAccordion=c=>{var l,a,d;const[u,h]=r.useState(!1),v=r.useRef(null),g=r.useRef(null);r.useEffect((()=>{c.autoOpen&&p(c.autoOpen,{})}),[c.autoOpen]),r.useEffect((()=>{void 0!==c.isOpen&&p(c.isOpen,{})}),[c.isOpen]);const p=(e,r)=>{var t,o;g.current&&v.current&&("keydown"===r.type&&"Enter"!==r.key||(e!==u&&h(e),e?(g.current.style.maxHeight=(null!==(t=c.childrenMaxHeight)&&void 0!==t?t:g.current.scrollHeight)+"px",v.current.style.transform="rotate(180deg)",v.current.style.transition="transform 0.25s ease-in-out",g.current.style.transition="max-height 0.25s ease-in-out"):(g.current.style.maxHeight="",v.current.style.transform="rotate(0deg)",v.current.style.transition="transform 0.25s ease-in-out",g.current.style.transition="padding 0s"),null===(o=c.onToggleAccordion)||void 0===o||o.call(c,e)))};return r.useEffect((()=>{const e=new MutationObserver((()=>{u&&g.current&&(g.current.style.maxHeight=g.current.scrollHeight+"px")}));return g.current&&e.observe(g.current,{childList:!0,subtree:!0}),()=>{e.disconnect()}}),[u]),r.useEffect((()=>{var e;u&&(null==c?void 0:c.refresh)&&(null===(e=null==g?void 0:g.current)||void 0===e?void 0:e.scrollHeight)&&!c.childrenMaxHeight&&setTimeout((()=>{g.current.style.maxHeight=g.current.scrollHeight+"px"}),100)}),[u,null==c?void 0:c.refresh,null===(l=null==g?void 0:g.current)||void 0===l?void 0:l.scrollHeight]),e.jsxs(i.default,Object.assign({className:"accordion",isActive:u,width:null==c?void 0:c.width,contentMargin:null==c?void 0:c.contentMargin,headerPadding:c.headerPadding,skipHoverState:c.skipHoverHeader,showBorders:c.showBorders,borderColor:c.borderColor,backgroundColor:c.backgroundColor,openDirection:c.openDirection,borderRadius:c.borderRadius},{children:[e.jsxs("div",Object.assign({className:"accordion__overview "+(u?"active":""),onClick:e=>p(!u,e),onKeyDown:e=>p(!u,e),role:"button",tabIndex:0},{children:[!c.rightActionComponent&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"accordion__overview__header",style:null!==(a=c.headerStyles)&&void 0!==a?a:{}},{children:[e.jsxs(i.AccordionHeaderGroup,{children:["string"==typeof c.header?e.jsx(t.TitleRegular,{children:null==c?void 0:c.header}):c.header,c.buttonLinkText&&e.jsx(o.Button,{buttonText:c.buttonLinkText,buttonType:"text",darkMode:!0,onClick:c.onButtonLinkClick})]}),e.jsxs(i.AccordionHeaderGroup2,{children:[c.headerButtons&&e.jsx("div",Object.assign({className:"accordion__overview__header-buttons"},{children:null===(d=c.headerButtons)||void 0===d?void 0:d.map((r=>e.jsx(n.IconButton,{Icon:r.icon,onClick:e=>{e.stopPropagation(),r.onClick()},width:16,height:16,style:r.style,title:r.title},r.title)))})),e.jsx(s.default,{arrowColor:c.arrowColor,isNewIcon:!0,ref:v})]})]})),(null==c?void 0:c.subHeader)?null==c?void 0:c.subHeader:null]}),c.rightActionComponent&&e.jsxs("div",Object.assign({className:"accordion__overview__header"},{children:[e.jsxs("div",Object.assign({className:"accordion__overview__title-wrapper"},{children:[e.jsx(s.default,{arrowColor:c.arrowColor,isNewIcon:!0,ref:v}),"string"==typeof c.header?e.jsx(t.TitleRegular,{children:null==c?void 0:c.header}):c.header]})),e.jsx("div",Object.assign({onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Enter"===e.key&&e.stopPropagation()},role:"button",tabIndex:0},{children:c.rightActionComponent}))]})),(null==c?void 0:c.caption)&&e.jsx("div",Object.assign({className:"accordion__overview__caption"},{children:e.jsx(t.BodySecondary,{children:e.jsx("div",Object.assign({style:c.captionStyle},{children:c.caption}))})}))]})),e.jsx("div",Object.assign({ref:g,className:"accordion__content"},{children:c.children}))]}))};
|
|
@@ -14,3 +14,4 @@ declare const AccordionStyle: import("styled-components").StyledComponent<"div",
|
|
|
14
14
|
}, never>;
|
|
15
15
|
export default AccordionStyle;
|
|
16
16
|
export declare const AccordionHeaderGroup: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
17
|
+
export declare const AccordionHeaderGroup2: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
align-items: center;
|
|
21
21
|
justify-content: space-between;
|
|
22
22
|
}
|
|
23
|
+
&__header-buttons {
|
|
24
|
+
display: flex;
|
|
25
|
+
gap: 8px;
|
|
26
|
+
}
|
|
23
27
|
&__title-wrapper {
|
|
24
28
|
display: flex;
|
|
25
29
|
gap: 8px;
|
|
@@ -40,4 +44,7 @@
|
|
|
40
44
|
display: flex;
|
|
41
45
|
align-items: center;
|
|
42
46
|
gap: 24px;
|
|
43
|
-
|
|
47
|
+
`,a=d.default.div`
|
|
48
|
+
display: flex;
|
|
49
|
+
gap: 16px;
|
|
50
|
+
`;exports.AccordionHeaderGroup=t,exports.AccordionHeaderGroup2=a,exports.default=i;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
export type HeaderButton = {
|
|
3
|
+
icon: React.FunctionComponent<React.SVGAttributes<SVGElement>>;
|
|
4
|
+
title: string;
|
|
5
|
+
onClick: () => void;
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
};
|
|
2
8
|
export interface AccordionProps {
|
|
3
9
|
header: JSX.Element | string;
|
|
4
10
|
subHeader?: JSX.Element | string;
|
|
@@ -24,5 +30,6 @@ export interface AccordionProps {
|
|
|
24
30
|
captionStyle?: React.CSSProperties;
|
|
25
31
|
borderColor?: string;
|
|
26
32
|
borderRadius?: string;
|
|
33
|
+
headerButtons?: HeaderButton[];
|
|
27
34
|
}
|
|
28
35
|
export declare const BikAccordion: React.FC<AccordionProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,Fragment as r,jsx as o}from"react/jsx-runtime";import{useState as
|
|
1
|
+
import{jsxs as e,Fragment as r,jsx as o}from"react/jsx-runtime";import{useState as t,useRef as n,useEffect as i}from"react";import{TitleRegular as c,BodySecondary as l}from"../TypographyStyle.js";import{Button as s}from"../button/Button.js";import{IconButton as a}from"../icon-button/IconButton.js";import d,{AccordionHeaderGroup as u,AccordionHeaderGroup2 as h}from"./Accordion.style.js";import v from"./AccordionArrow.js";const p=p=>{var g,m,b;const[y,_]=t(!1),w=n(null),f=n(null);i((()=>{p.autoOpen&&x(p.autoOpen,{})}),[p.autoOpen]),i((()=>{void 0!==p.isOpen&&x(p.isOpen,{})}),[p.isOpen]);const x=(e,r)=>{var o,t;f.current&&w.current&&("keydown"===r.type&&"Enter"!==r.key||(e!==y&&_(e),e?(f.current.style.maxHeight=(null!==(o=p.childrenMaxHeight)&&void 0!==o?o:f.current.scrollHeight)+"px",w.current.style.transform="rotate(180deg)",w.current.style.transition="transform 0.25s ease-in-out",f.current.style.transition="max-height 0.25s ease-in-out"):(f.current.style.maxHeight="",w.current.style.transform="rotate(0deg)",w.current.style.transition="transform 0.25s ease-in-out",f.current.style.transition="padding 0s"),null===(t=p.onToggleAccordion)||void 0===t||t.call(p,e)))};return i((()=>{const e=new MutationObserver((()=>{y&&f.current&&(f.current.style.maxHeight=f.current.scrollHeight+"px")}));return f.current&&e.observe(f.current,{childList:!0,subtree:!0}),()=>{e.disconnect()}}),[y]),i((()=>{var e;y&&(null==p?void 0:p.refresh)&&(null===(e=null==f?void 0:f.current)||void 0===e?void 0:e.scrollHeight)&&!p.childrenMaxHeight&&setTimeout((()=>{f.current.style.maxHeight=f.current.scrollHeight+"px"}),100)}),[y,null==p?void 0:p.refresh,null===(g=null==f?void 0:f.current)||void 0===g?void 0:g.scrollHeight]),e(d,Object.assign({className:"accordion",isActive:y,width:null==p?void 0:p.width,contentMargin:null==p?void 0:p.contentMargin,headerPadding:p.headerPadding,skipHoverState:p.skipHoverHeader,showBorders:p.showBorders,borderColor:p.borderColor,backgroundColor:p.backgroundColor,openDirection:p.openDirection,borderRadius:p.borderRadius},{children:[e("div",Object.assign({className:"accordion__overview "+(y?"active":""),onClick:e=>x(!y,e),onKeyDown:e=>x(!y,e),role:"button",tabIndex:0},{children:[!p.rightActionComponent&&e(r,{children:[e("div",Object.assign({className:"accordion__overview__header",style:null!==(m=p.headerStyles)&&void 0!==m?m:{}},{children:[e(u,{children:["string"==typeof p.header?o(c,{children:null==p?void 0:p.header}):p.header,p.buttonLinkText&&o(s,{buttonText:p.buttonLinkText,buttonType:"text",darkMode:!0,onClick:p.onButtonLinkClick})]}),e(h,{children:[p.headerButtons&&o("div",Object.assign({className:"accordion__overview__header-buttons"},{children:null===(b=p.headerButtons)||void 0===b?void 0:b.map((e=>o(a,{Icon:e.icon,onClick:r=>{r.stopPropagation(),e.onClick()},width:16,height:16,style:e.style,title:e.title},e.title)))})),o(v,{arrowColor:p.arrowColor,isNewIcon:!0,ref:w})]})]})),(null==p?void 0:p.subHeader)?null==p?void 0:p.subHeader:null]}),p.rightActionComponent&&e("div",Object.assign({className:"accordion__overview__header"},{children:[e("div",Object.assign({className:"accordion__overview__title-wrapper"},{children:[o(v,{arrowColor:p.arrowColor,isNewIcon:!0,ref:w}),"string"==typeof p.header?o(c,{children:null==p?void 0:p.header}):p.header]})),o("div",Object.assign({onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Enter"===e.key&&e.stopPropagation()},role:"button",tabIndex:0},{children:p.rightActionComponent}))]})),(null==p?void 0:p.caption)&&o("div",Object.assign({className:"accordion__overview__caption"},{children:o(l,{children:o("div",Object.assign({style:p.captionStyle},{children:p.caption}))})}))]})),o("div",Object.assign({ref:f,className:"accordion__content"},{children:p.children}))]}))};export{p as BikAccordion};
|
|
@@ -14,3 +14,4 @@ declare const AccordionStyle: import("styled-components").StyledComponent<"div",
|
|
|
14
14
|
}, never>;
|
|
15
15
|
export default AccordionStyle;
|
|
16
16
|
export declare const AccordionHeaderGroup: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
17
|
+
export declare const AccordionHeaderGroup2: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,43 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
width: ${
|
|
1
|
+
import e from"styled-components";import{COLORS as r}from"../../constants/Theme.js";const o=e.div`
|
|
2
|
+
width: ${e=>(null==e?void 0:e.width)||"100%"};
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
5
|
-
border: ${
|
|
6
|
-
border-color: ${
|
|
7
|
-
border-radius: ${
|
|
8
|
-
background: ${
|
|
5
|
+
border: ${e=>e.showBorders?"1px solid "+r.stroke.primary:""};
|
|
6
|
+
border-color: ${e=>e.borderColor||r.stroke.primary};
|
|
7
|
+
border-radius: ${e=>e.borderRadius?e.borderRadius:e.showBorders?"4px":""};
|
|
8
|
+
background: ${e=>e.backgroundColor||"unset"};
|
|
9
9
|
.accordion {
|
|
10
10
|
&__overview {
|
|
11
11
|
display: flex;
|
|
12
12
|
flex-direction: column;
|
|
13
13
|
gap: 4px;
|
|
14
|
-
padding: ${
|
|
15
|
-
border-bottom: ${
|
|
16
|
-
border-color: ${
|
|
14
|
+
padding: ${e=>e.headerPadding?e.headerPadding:"24px"};
|
|
15
|
+
border-bottom: ${e=>e.showBorders&&e.isActive?"1px solid "+r.stroke.primary:""};
|
|
16
|
+
border-color: ${e=>e.borderColor||r.stroke.primary};
|
|
17
17
|
&__header {
|
|
18
18
|
display: flex;
|
|
19
19
|
flex-direction: row;
|
|
20
20
|
align-items: center;
|
|
21
21
|
justify-content: space-between;
|
|
22
22
|
}
|
|
23
|
+
&__header-buttons {
|
|
24
|
+
display: flex;
|
|
25
|
+
gap: 8px;
|
|
26
|
+
}
|
|
23
27
|
&__title-wrapper {
|
|
24
28
|
display: flex;
|
|
25
29
|
gap: 8px;
|
|
26
30
|
}
|
|
27
31
|
:hover {
|
|
28
|
-
background: ${
|
|
29
|
-
border-radius: ${
|
|
32
|
+
background: ${e=>e.skipHoverState?null:r.surface.subdued};
|
|
33
|
+
border-radius: ${e=>e.skipHoverState?null:"4px"};
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
&__content {
|
|
33
|
-
${
|
|
34
|
-
overflow: ${
|
|
37
|
+
${e=>e.isActive?{margin:(null==e?void 0:e.contentMargin)||"0px"}:{}};
|
|
38
|
+
overflow: ${e=>e.hasChildrenMaxHeight?"scroll":"hidden"};
|
|
35
39
|
max-height: 0;
|
|
36
|
-
order: ${
|
|
40
|
+
order: ${e=>"UP"===e.openDirection?-1:0};
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
|
-
`,d=
|
|
43
|
+
`,d=e.div`
|
|
40
44
|
display: flex;
|
|
41
45
|
align-items: center;
|
|
42
46
|
gap: 24px;
|
|
43
|
-
|
|
47
|
+
`,i=e.div`
|
|
48
|
+
display: flex;
|
|
49
|
+
gap: 16px;
|
|
50
|
+
`;export{d as AccordionHeaderGroup,i as AccordionHeaderGroup2,o as default};
|