@bikdotai/bik-component-library 0.0.685-beta.4 → 0.0.685-beta.5
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 +8 -0
- package/dist/cjs/components/accordion/Accordion.js +1 -1
- package/dist/cjs/components/accordion/Accordion.style.js +4 -0
- package/dist/cjs/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/components/accordion/Accordion.d.ts +8 -0
- package/dist/esm/components/accordion/Accordion.js +1 -1
- package/dist/esm/components/accordion/Accordion.style.js +4 -0
- 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
|
+
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,7 @@ 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>;
|
|
36
|
+
export {};
|
|
@@ -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("../button/Button.js"),o=require("./Accordion.style.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../TypographyStyle.js"),n=require("../button/Button.js"),o=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,n;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===(n=c.onToggleAccordion)||void 0===n||n.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(n.Button,{buttonText:c.buttonLinkText,buttonType:"text",darkMode:!0,onClick:c.onButtonLinkClick}),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(o.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}))]}))};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
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,7 @@ 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>;
|
|
36
|
+
export {};
|
|
@@ -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}from"./Accordion.style.js";import h from"./AccordionArrow.js";const v=v=>{var p,g,m;const[b,y]=t(!1),_=n(null),w=n(null);i((()=>{v.autoOpen&&f(v.autoOpen,{})}),[v.autoOpen]),i((()=>{void 0!==v.isOpen&&f(v.isOpen,{})}),[v.isOpen]);const f=(e,r)=>{var o,t;w.current&&_.current&&("keydown"===r.type&&"Enter"!==r.key||(e!==b&&y(e),e?(w.current.style.maxHeight=(null!==(o=v.childrenMaxHeight)&&void 0!==o?o:w.current.scrollHeight)+"px",_.current.style.transform="rotate(180deg)",_.current.style.transition="transform 0.25s ease-in-out",w.current.style.transition="max-height 0.25s ease-in-out"):(w.current.style.maxHeight="",_.current.style.transform="rotate(0deg)",_.current.style.transition="transform 0.25s ease-in-out",w.current.style.transition="padding 0s"),null===(t=v.onToggleAccordion)||void 0===t||t.call(v,e)))};return i((()=>{const e=new MutationObserver((()=>{b&&w.current&&(w.current.style.maxHeight=w.current.scrollHeight+"px")}));return w.current&&e.observe(w.current,{childList:!0,subtree:!0}),()=>{e.disconnect()}}),[b]),i((()=>{var e;b&&(null==v?void 0:v.refresh)&&(null===(e=null==w?void 0:w.current)||void 0===e?void 0:e.scrollHeight)&&!v.childrenMaxHeight&&setTimeout((()=>{w.current.style.maxHeight=w.current.scrollHeight+"px"}),100)}),[b,null==v?void 0:v.refresh,null===(p=null==w?void 0:w.current)||void 0===p?void 0:p.scrollHeight]),e(d,Object.assign({className:"accordion",isActive:b,width:null==v?void 0:v.width,contentMargin:null==v?void 0:v.contentMargin,headerPadding:v.headerPadding,skipHoverState:v.skipHoverHeader,showBorders:v.showBorders,borderColor:v.borderColor,backgroundColor:v.backgroundColor,openDirection:v.openDirection,borderRadius:v.borderRadius},{children:[e("div",Object.assign({className:"accordion__overview "+(b?"active":""),onClick:e=>f(!b,e),onKeyDown:e=>f(!b,e),role:"button",tabIndex:0},{children:[!v.rightActionComponent&&e(r,{children:[e("div",Object.assign({className:"accordion__overview__header",style:null!==(g=v.headerStyles)&&void 0!==g?g:{}},{children:[e(u,{children:["string"==typeof v.header?o(c,{children:null==v?void 0:v.header}):v.header,v.buttonLinkText&&o(s,{buttonText:v.buttonLinkText,buttonType:"text",darkMode:!0,onClick:v.onButtonLinkClick}),v.headerButtons&&o("div",Object.assign({className:"accordion__overview__header-buttons"},{children:null===(m=v.headerButtons)||void 0===m?void 0:m.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(h,{arrowColor:v.arrowColor,isNewIcon:!0,ref:_})]})),(null==v?void 0:v.subHeader)?null==v?void 0:v.subHeader:null]}),v.rightActionComponent&&e("div",Object.assign({className:"accordion__overview__header"},{children:[e("div",Object.assign({className:"accordion__overview__title-wrapper"},{children:[o(h,{arrowColor:v.arrowColor,isNewIcon:!0,ref:_}),"string"==typeof v.header?o(c,{children:null==v?void 0:v.header}):v.header]})),o("div",Object.assign({onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Enter"===e.key&&e.stopPropagation()},role:"button",tabIndex:0},{children:v.rightActionComponent}))]})),(null==v?void 0:v.caption)&&o("div",Object.assign({className:"accordion__overview__caption"},{children:o(l,{children:o("div",Object.assign({style:v.captionStyle},{children:v.caption}))})}))]})),o("div",Object.assign({ref:w,className:"accordion__content"},{children:v.children}))]}))};export{v as BikAccordion};
|
|
@@ -20,6 +20,10 @@ import r from"styled-components";import{COLORS as e}from"../../constants/Theme.j
|
|
|
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;
|