@bikdotai/bik-component-library 0.0.685-beta.2 → 0.0.685-beta.4
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 +1 -0
- package/dist/cjs/components/accordion/Accordion.js +1 -1
- package/dist/cjs/components/code-block/CodeBlock.d.ts +3 -0
- package/dist/cjs/components/code-block/CodeBlock.stories.d.ts +8 -0
- package/dist/cjs/components/code-block/CodeBlock.styled.d.ts +30 -0
- package/dist/cjs/components/code-block/CodeBlockHelper.d.ts +1 -0
- package/dist/cjs/components/code-block/index.d.ts +1 -0
- package/dist/cjs/components/code-block/languageSpecificFormatting/html.d.ts +1 -0
- package/dist/cjs/components/code-block/types.d.ts +17 -0
- package/dist/esm/components/accordion/Accordion.d.ts +1 -0
- package/dist/esm/components/accordion/Accordion.js +1 -1
- package/dist/esm/components/code-block/CodeBlock.d.ts +3 -0
- package/dist/esm/components/code-block/CodeBlock.stories.d.ts +8 -0
- package/dist/esm/components/code-block/CodeBlock.styled.d.ts +30 -0
- package/dist/esm/components/code-block/CodeBlockHelper.d.ts +1 -0
- package/dist/esm/components/code-block/index.d.ts +1 -0
- package/dist/esm/components/code-block/languageSpecificFormatting/html.d.ts +1 -0
- package/dist/esm/components/code-block/types.d.ts +17 -0
- package/package.json +1 -1
|
@@ -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"),i=require("./AccordionArrow.js");exports.BikAccordion=s=>{var c,
|
|
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"),i=require("./AccordionArrow.js");exports.BikAccordion=s=>{var c,l;const[a,d]=r.useState(!1),u=r.useRef(null),h=r.useRef(null);r.useEffect((()=>{s.autoOpen&&v(s.autoOpen,{})}),[s.autoOpen]),r.useEffect((()=>{void 0!==s.isOpen&&v(s.isOpen,{})}),[s.isOpen]);const v=(e,r)=>{var t,n;h.current&&u.current&&("keydown"===r.type&&"Enter"!==r.key||(e!==a&&d(e),e?(h.current.style.maxHeight=(null!==(t=s.childrenMaxHeight)&&void 0!==t?t:h.current.scrollHeight)+"px",u.current.style.transform="rotate(180deg)",u.current.style.transition="transform 0.25s ease-in-out",h.current.style.transition="max-height 0.25s ease-in-out"):(h.current.style.maxHeight="",u.current.style.transform="rotate(0deg)",u.current.style.transition="transform 0.25s ease-in-out",h.current.style.transition="padding 0s"),null===(n=s.onToggleAccordion)||void 0===n||n.call(s,e)))};return r.useEffect((()=>{const e=new MutationObserver((()=>{a&&h.current&&(h.current.style.maxHeight=h.current.scrollHeight+"px")}));return h.current&&e.observe(h.current,{childList:!0,subtree:!0}),()=>{e.disconnect()}}),[a]),r.useEffect((()=>{var e;a&&(null==s?void 0:s.refresh)&&(null===(e=null==h?void 0:h.current)||void 0===e?void 0:e.scrollHeight)&&!s.childrenMaxHeight&&setTimeout((()=>{h.current.style.maxHeight=h.current.scrollHeight+"px"}),100)}),[a,null==s?void 0:s.refresh,null===(c=null==h?void 0:h.current)||void 0===c?void 0:c.scrollHeight]),e.jsxs(o.default,Object.assign({className:"accordion",isActive:a,width:null==s?void 0:s.width,contentMargin:null==s?void 0:s.contentMargin,headerPadding:s.headerPadding,skipHoverState:s.skipHoverHeader,showBorders:s.showBorders,borderColor:s.borderColor,backgroundColor:s.backgroundColor,openDirection:s.openDirection,borderRadius:s.borderRadius},{children:[e.jsxs("div",Object.assign({className:"accordion__overview "+(a?"active":""),onClick:e=>v(!a,e),onKeyDown:e=>v(!a,e),role:"button",tabIndex:0},{children:[!s.rightActionComponent&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"accordion__overview__header",style:null!==(l=s.headerStyles)&&void 0!==l?l:{}},{children:[e.jsxs(o.AccordionHeaderGroup,{children:["string"==typeof s.header?e.jsx(t.TitleRegular,{children:null==s?void 0:s.header}):s.header,s.buttonLinkText&&e.jsx(n.Button,{buttonText:s.buttonLinkText,buttonType:"text",darkMode:!0,onClick:s.onButtonLinkClick})]}),e.jsx(i.default,{arrowColor:s.arrowColor,isNewIcon:!0,ref:u})]})),(null==s?void 0:s.subHeader)?null==s?void 0:s.subHeader:null]}),s.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,{arrowColor:s.arrowColor,isNewIcon:!0,ref:u}),"string"==typeof s.header?e.jsx(t.TitleRegular,{children:null==s?void 0:s.header}):s.header]})),e.jsx("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)&&e.jsx("div",Object.assign({className:"accordion__overview__caption"},{children:e.jsx(t.BodySecondary,{children:e.jsx("div",Object.assign({style:s.captionStyle},{children:s.caption}))})}))]})),e.jsx("div",Object.assign({ref:h,className:"accordion__content"},{children:s.children}))]}))};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
2
|
+
declare const _default: ComponentMeta<({ code, language, title, showTitle, showLineNumbers, maxHeight, theme, }: import("./types").CodeBlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
3
|
+
export default _default;
|
|
4
|
+
export declare const JSDark: ComponentStory<({ code, language, title, showTitle, showLineNumbers, maxHeight, theme, }: import("./types").CodeBlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
5
|
+
export declare const LightWithoutTitle: ComponentStory<({ code, language, title, showTitle, showLineNumbers, maxHeight, theme, }: import("./types").CodeBlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
|
+
export declare const Python: ComponentStory<({ code, language, title, showTitle, showLineNumbers, maxHeight, theme, }: import("./types").CodeBlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
7
|
+
export declare const HTMLNoLineNumbers: ComponentStory<({ code, language, title, showTitle, showLineNumbers, maxHeight, theme, }: import("./types").CodeBlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
8
|
+
export declare const Css: ComponentStory<({ code, language, title, showTitle, showLineNumbers, maxHeight, theme, }: import("./types").CodeBlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const Container: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
themeMode: 'dark' | 'light';
|
|
3
|
+
}, never>;
|
|
4
|
+
export declare const Header: import("styled-components").StyledComponent<"div", any, {
|
|
5
|
+
themeMode: 'dark' | 'light';
|
|
6
|
+
}, never>;
|
|
7
|
+
export declare const WindowControls: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const Dot: import("styled-components").StyledComponent<"div", any, {
|
|
9
|
+
color: string;
|
|
10
|
+
}, never>;
|
|
11
|
+
export declare const TitleSection: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
|
+
export declare const Title: import("styled-components").StyledComponent<"span", any, {
|
|
13
|
+
themeMode: 'dark' | 'light';
|
|
14
|
+
}, never>;
|
|
15
|
+
export declare const LanguageBadge: import("styled-components").StyledComponent<"div", any, {
|
|
16
|
+
bg: string;
|
|
17
|
+
color?: string | undefined;
|
|
18
|
+
}, never>;
|
|
19
|
+
export declare const CopyButton: import("styled-components").StyledComponent<"button", any, {
|
|
20
|
+
themeMode: 'dark' | 'light';
|
|
21
|
+
}, never>;
|
|
22
|
+
export declare const CodeContainer: import("styled-components").StyledComponent<"div", any, {
|
|
23
|
+
maxHeight: string;
|
|
24
|
+
}, never>;
|
|
25
|
+
export declare const LineNumbers: import("styled-components").StyledComponent<"div", any, {
|
|
26
|
+
themeMode: 'dark' | 'light';
|
|
27
|
+
}, never>;
|
|
28
|
+
export declare const Code: import("styled-components").StyledComponent<"pre", any, {
|
|
29
|
+
themeMode: 'dark' | 'light';
|
|
30
|
+
}, never>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const highlightCode: (code: string, lang: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CodeBlock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function format(code: string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare enum CodeLanguage {
|
|
2
|
+
JAVASCRIPT = "javascript",
|
|
3
|
+
PYTHON = "python",
|
|
4
|
+
JAVA = "java",
|
|
5
|
+
CSS = "css",
|
|
6
|
+
HTML = "html",
|
|
7
|
+
JSON = "json"
|
|
8
|
+
}
|
|
9
|
+
export interface CodeBlockProps {
|
|
10
|
+
code?: string;
|
|
11
|
+
language?: CodeLanguage;
|
|
12
|
+
title?: string;
|
|
13
|
+
showTitle?: boolean;
|
|
14
|
+
showLineNumbers?: boolean;
|
|
15
|
+
maxHeight?: string;
|
|
16
|
+
theme?: 'dark' | 'light';
|
|
17
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as
|
|
1
|
+
import{jsxs as e,Fragment as r,jsx as o}from"react/jsx-runtime";import{useState as n,useRef as t,useEffect as i}from"react";import{TitleRegular as c,BodySecondary as l}from"../TypographyStyle.js";import{Button as s}from"../button/Button.js";import a,{AccordionHeaderGroup as d}from"./Accordion.style.js";import u from"./AccordionArrow.js";const h=h=>{var v,g;const[p,m]=n(!1),b=t(null),y=t(null);i((()=>{h.autoOpen&&w(h.autoOpen,{})}),[h.autoOpen]),i((()=>{void 0!==h.isOpen&&w(h.isOpen,{})}),[h.isOpen]);const w=(e,r)=>{var o,n;y.current&&b.current&&("keydown"===r.type&&"Enter"!==r.key||(e!==p&&m(e),e?(y.current.style.maxHeight=(null!==(o=h.childrenMaxHeight)&&void 0!==o?o:y.current.scrollHeight)+"px",b.current.style.transform="rotate(180deg)",b.current.style.transition="transform 0.25s ease-in-out",y.current.style.transition="max-height 0.25s ease-in-out"):(y.current.style.maxHeight="",b.current.style.transform="rotate(0deg)",b.current.style.transition="transform 0.25s ease-in-out",y.current.style.transition="padding 0s"),null===(n=h.onToggleAccordion)||void 0===n||n.call(h,e)))};return i((()=>{const e=new MutationObserver((()=>{p&&y.current&&(y.current.style.maxHeight=y.current.scrollHeight+"px")}));return y.current&&e.observe(y.current,{childList:!0,subtree:!0}),()=>{e.disconnect()}}),[p]),i((()=>{var e;p&&(null==h?void 0:h.refresh)&&(null===(e=null==y?void 0:y.current)||void 0===e?void 0:e.scrollHeight)&&!h.childrenMaxHeight&&setTimeout((()=>{y.current.style.maxHeight=y.current.scrollHeight+"px"}),100)}),[p,null==h?void 0:h.refresh,null===(v=null==y?void 0:y.current)||void 0===v?void 0:v.scrollHeight]),e(a,Object.assign({className:"accordion",isActive:p,width:null==h?void 0:h.width,contentMargin:null==h?void 0:h.contentMargin,headerPadding:h.headerPadding,skipHoverState:h.skipHoverHeader,showBorders:h.showBorders,borderColor:h.borderColor,backgroundColor:h.backgroundColor,openDirection:h.openDirection,borderRadius:h.borderRadius},{children:[e("div",Object.assign({className:"accordion__overview "+(p?"active":""),onClick:e=>w(!p,e),onKeyDown:e=>w(!p,e),role:"button",tabIndex:0},{children:[!h.rightActionComponent&&e(r,{children:[e("div",Object.assign({className:"accordion__overview__header",style:null!==(g=h.headerStyles)&&void 0!==g?g:{}},{children:[e(d,{children:["string"==typeof h.header?o(c,{children:null==h?void 0:h.header}):h.header,h.buttonLinkText&&o(s,{buttonText:h.buttonLinkText,buttonType:"text",darkMode:!0,onClick:h.onButtonLinkClick})]}),o(u,{arrowColor:h.arrowColor,isNewIcon:!0,ref:b})]})),(null==h?void 0:h.subHeader)?null==h?void 0:h.subHeader:null]}),h.rightActionComponent&&e("div",Object.assign({className:"accordion__overview__header"},{children:[e("div",Object.assign({className:"accordion__overview__title-wrapper"},{children:[o(u,{arrowColor:h.arrowColor,isNewIcon:!0,ref:b}),"string"==typeof h.header?o(c,{children:null==h?void 0:h.header}):h.header]})),o("div",Object.assign({onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Enter"===e.key&&e.stopPropagation()},role:"button",tabIndex:0},{children:h.rightActionComponent}))]})),(null==h?void 0:h.caption)&&o("div",Object.assign({className:"accordion__overview__caption"},{children:o(l,{children:o("div",Object.assign({style:h.captionStyle},{children:h.caption}))})}))]})),o("div",Object.assign({ref:y,className:"accordion__content"},{children:h.children}))]}))};export{h as BikAccordion};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
2
|
+
declare const _default: ComponentMeta<({ code, language, title, showTitle, showLineNumbers, maxHeight, theme, }: import("./types").CodeBlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
3
|
+
export default _default;
|
|
4
|
+
export declare const JSDark: ComponentStory<({ code, language, title, showTitle, showLineNumbers, maxHeight, theme, }: import("./types").CodeBlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
5
|
+
export declare const LightWithoutTitle: ComponentStory<({ code, language, title, showTitle, showLineNumbers, maxHeight, theme, }: import("./types").CodeBlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
|
+
export declare const Python: ComponentStory<({ code, language, title, showTitle, showLineNumbers, maxHeight, theme, }: import("./types").CodeBlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
7
|
+
export declare const HTMLNoLineNumbers: ComponentStory<({ code, language, title, showTitle, showLineNumbers, maxHeight, theme, }: import("./types").CodeBlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
8
|
+
export declare const Css: ComponentStory<({ code, language, title, showTitle, showLineNumbers, maxHeight, theme, }: import("./types").CodeBlockProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const Container: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
themeMode: 'dark' | 'light';
|
|
3
|
+
}, never>;
|
|
4
|
+
export declare const Header: import("styled-components").StyledComponent<"div", any, {
|
|
5
|
+
themeMode: 'dark' | 'light';
|
|
6
|
+
}, never>;
|
|
7
|
+
export declare const WindowControls: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const Dot: import("styled-components").StyledComponent<"div", any, {
|
|
9
|
+
color: string;
|
|
10
|
+
}, never>;
|
|
11
|
+
export declare const TitleSection: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
|
+
export declare const Title: import("styled-components").StyledComponent<"span", any, {
|
|
13
|
+
themeMode: 'dark' | 'light';
|
|
14
|
+
}, never>;
|
|
15
|
+
export declare const LanguageBadge: import("styled-components").StyledComponent<"div", any, {
|
|
16
|
+
bg: string;
|
|
17
|
+
color?: string | undefined;
|
|
18
|
+
}, never>;
|
|
19
|
+
export declare const CopyButton: import("styled-components").StyledComponent<"button", any, {
|
|
20
|
+
themeMode: 'dark' | 'light';
|
|
21
|
+
}, never>;
|
|
22
|
+
export declare const CodeContainer: import("styled-components").StyledComponent<"div", any, {
|
|
23
|
+
maxHeight: string;
|
|
24
|
+
}, never>;
|
|
25
|
+
export declare const LineNumbers: import("styled-components").StyledComponent<"div", any, {
|
|
26
|
+
themeMode: 'dark' | 'light';
|
|
27
|
+
}, never>;
|
|
28
|
+
export declare const Code: import("styled-components").StyledComponent<"pre", any, {
|
|
29
|
+
themeMode: 'dark' | 'light';
|
|
30
|
+
}, never>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const highlightCode: (code: string, lang: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CodeBlock';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function format(code: string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare enum CodeLanguage {
|
|
2
|
+
JAVASCRIPT = "javascript",
|
|
3
|
+
PYTHON = "python",
|
|
4
|
+
JAVA = "java",
|
|
5
|
+
CSS = "css",
|
|
6
|
+
HTML = "html",
|
|
7
|
+
JSON = "json"
|
|
8
|
+
}
|
|
9
|
+
export interface CodeBlockProps {
|
|
10
|
+
code?: string;
|
|
11
|
+
language?: CodeLanguage;
|
|
12
|
+
title?: string;
|
|
13
|
+
showTitle?: boolean;
|
|
14
|
+
showLineNumbers?: boolean;
|
|
15
|
+
maxHeight?: string;
|
|
16
|
+
theme?: 'dark' | 'light';
|
|
17
|
+
}
|