@postenbring/hedwig-react 0.0.54 → 0.0.56
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/_tsup-dts-rollup.d.mts +162 -190
- package/dist/_tsup-dts-rollup.d.ts +162 -190
- package/dist/accordion/index.mjs +2 -2
- package/dist/button/button.js +1 -1
- package/dist/button/button.js.map +1 -1
- package/dist/button/button.mjs +1 -1
- package/dist/button/index.js +1 -1
- package/dist/button/index.js.map +1 -1
- package/dist/button/index.mjs +1 -1
- package/dist/{chunk-2XSEQBJ5.mjs → chunk-5IIBIO3Y.mjs} +1 -1
- package/dist/chunk-5IIBIO3Y.mjs.map +1 -0
- package/dist/{chunk-MJ4LA23N.mjs → chunk-BDA6STW2.mjs} +2 -2
- package/dist/{chunk-52ULSP6E.mjs → chunk-GAKMKOPK.mjs} +3 -16
- package/dist/chunk-GAKMKOPK.mjs.map +1 -0
- package/dist/{chunk-5T3VUFL4.mjs → chunk-GVSLN5KE.mjs} +1 -1
- package/dist/chunk-GVSLN5KE.mjs.map +1 -0
- package/dist/{chunk-FL4LCX4F.mjs → chunk-IWV5GK63.mjs} +4 -4
- package/dist/{chunk-UVUIY2WB.mjs → chunk-J6ES2LO5.mjs} +2 -2
- package/dist/{chunk-UVUIY2WB.mjs.map → chunk-J6ES2LO5.mjs.map} +1 -1
- package/dist/{chunk-5GRZROYQ.mjs → chunk-LYRXA4WS.mjs} +8 -8
- package/dist/chunk-LYRXA4WS.mjs.map +1 -0
- package/dist/{chunk-KOO4VQ2N.mjs → chunk-OJ42PRYY.mjs} +2 -2
- package/dist/chunk-OJ42PRYY.mjs.map +1 -0
- package/dist/{chunk-T3EC54VN.mjs → chunk-PUFFEK6I.mjs} +2 -2
- package/dist/chunk-V4NGQVBQ.mjs +61 -0
- package/dist/chunk-V4NGQVBQ.mjs.map +1 -0
- package/dist/{chunk-LK62DXGG.mjs → chunk-ZSLWZUBI.mjs} +10 -3
- package/dist/chunk-ZSLWZUBI.mjs.map +1 -0
- package/dist/index-no-css.d.mts +1 -28
- package/dist/index-no-css.d.ts +1 -28
- package/dist/index-no-css.js +53 -132
- package/dist/index-no-css.js.map +1 -1
- package/dist/index-no-css.mjs +23 -77
- package/dist/index.d.mts +1 -28
- package/dist/index.d.ts +1 -28
- package/dist/index.js +54 -133
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -78
- package/dist/index.mjs.map +1 -1
- package/dist/modal/index.js.map +1 -1
- package/dist/modal/index.mjs +2 -2
- package/dist/modal/modal.js.map +1 -1
- package/dist/modal/modal.mjs +1 -1
- package/dist/navbar/index.js +9 -2
- package/dist/navbar/index.js.map +1 -1
- package/dist/navbar/index.mjs +2 -2
- package/dist/navbar/navbar-expandable-menu.js +9 -2
- package/dist/navbar/navbar-expandable-menu.js.map +1 -1
- package/dist/navbar/navbar-expandable-menu.mjs +1 -1
- package/dist/show-more/index.js.map +1 -1
- package/dist/show-more/index.mjs +1 -1
- package/dist/show-more/show-more.js.map +1 -1
- package/dist/show-more/show-more.mjs +1 -1
- package/dist/styled-html/index.js +1 -1
- package/dist/styled-html/index.js.map +1 -1
- package/dist/styled-html/index.mjs +1 -1
- package/dist/styled-html/styled-html.js +1 -1
- package/dist/styled-html/styled-html.js.map +1 -1
- package/dist/styled-html/styled-html.mjs +1 -1
- package/dist/text/index.d.mts +15 -0
- package/dist/text/index.d.ts +15 -0
- package/dist/text/index.js +179 -0
- package/dist/text/index.js.map +1 -0
- package/dist/text/index.mjs +36 -0
- package/dist/text/text.d.mts +2 -0
- package/dist/text/text.d.ts +2 -0
- package/dist/{typography/typography.js → text/text.js} +12 -12
- package/dist/text/text.js.map +1 -0
- package/dist/text/text.mjs +8 -0
- package/dist/warning-banner/index.js +2 -15
- package/dist/warning-banner/index.js.map +1 -1
- package/dist/warning-banner/index.mjs +1 -1
- package/dist/warning-banner/warning-banner.js +2 -15
- package/dist/warning-banner/warning-banner.js.map +1 -1
- package/dist/warning-banner/warning-banner.mjs +1 -1
- package/package.json +5 -5
- package/dist/chunk-2XSEQBJ5.mjs.map +0 -1
- package/dist/chunk-52ULSP6E.mjs.map +0 -1
- package/dist/chunk-5GRZROYQ.mjs.map +0 -1
- package/dist/chunk-5T3VUFL4.mjs.map +0 -1
- package/dist/chunk-KOO4VQ2N.mjs.map +0 -1
- package/dist/chunk-LK62DXGG.mjs.map +0 -1
- package/dist/chunk-NCYRNCGJ.mjs +0 -107
- package/dist/chunk-NCYRNCGJ.mjs.map +0 -1
- package/dist/typography/index.d.mts +0 -42
- package/dist/typography/index.d.ts +0 -42
- package/dist/typography/index.js +0 -252
- package/dist/typography/index.js.map +0 -1
- package/dist/typography/index.mjs +0 -90
- package/dist/typography/typography.d.mts +0 -2
- package/dist/typography/typography.d.ts +0 -2
- package/dist/typography/typography.js.map +0 -1
- package/dist/typography/typography.mjs +0 -8
- /package/dist/{chunk-MJ4LA23N.mjs.map → chunk-BDA6STW2.mjs.map} +0 -0
- /package/dist/{chunk-FL4LCX4F.mjs.map → chunk-IWV5GK63.mjs.map} +0 -0
- /package/dist/{chunk-T3EC54VN.mjs.map → chunk-PUFFEK6I.mjs.map} +0 -0
- /package/dist/{typography → text}/index.mjs.map +0 -0
- /package/dist/{typography/typography.mjs.map → text/text.mjs.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/show-more/show-more.tsx"],"sourcesContent":["import { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\n\ntype Variant =\n | {\n variant?: \"show-more\";\n expanded?: never;\n }\n | {\n variant: \"show-more-show-less\";\n expanded: boolean;\n };\n\nexport type ShowMoreProps = React.HTMLAttributes<HTMLButtonElement> & {\n text: React.ReactNode;\n} & Variant;\n\n/**\n * Simple button for triggering more content.\n *\n * You have to add the logic for what happens when the button is clicked yourself.\n *\n * **Example**\n *\n * ```tsx\n * function Content() {\n * const [items, fetchMoreItems, moreItemsAvailable] = useYourData();\n * function onShowMoreItems() {\n * fetchMoreItems();\n * }\n * return (\n * <>\n * <ul>\n * {items.map((item) => (\n * <li key={item.id}>{item.text}</li>\n * ))}\n * </ul>\n * {moreItemsAvailable ?\n * <ShowMoreButton className=\"mt-
|
|
1
|
+
{"version":3,"sources":["../../src/show-more/show-more.tsx"],"sourcesContent":["import { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\n\ntype Variant =\n | {\n variant?: \"show-more\";\n expanded?: never;\n }\n | {\n variant: \"show-more-show-less\";\n expanded: boolean;\n };\n\nexport type ShowMoreProps = React.HTMLAttributes<HTMLButtonElement> & {\n text: React.ReactNode;\n} & Variant;\n\n/**\n * Simple button for triggering more content.\n *\n * You have to add the logic for what happens when the button is clicked yourself.\n *\n * **Example**\n *\n * ```tsx\n * function Content() {\n * const [items, fetchMoreItems, moreItemsAvailable] = useYourData();\n * function onShowMoreItems() {\n * fetchMoreItems();\n * }\n * return (\n * <>\n * <ul>\n * {items.map((item) => (\n * <li key={item.id}>{item.text}</li>\n * ))}\n * </ul>\n * {moreItemsAvailable ?\n * <ShowMoreButton className=\"mt-8\" onClick={onShowMoreItems} lang=\"en\" /> :\n * null\n * }\n * </>\n * )\n * }\n * ```\n */\nexport function ShowMoreButton({ text, variant, expanded, className, ...rest }: ShowMoreProps) {\n return (\n <button\n className={clsx(\n \"hds-show-more\",\n variant === \"show-more-show-less\" && \"hds-show-more--show-less\",\n className as undefined,\n )}\n data-state={expanded ? \"expanded\" : undefined}\n type=\"button\"\n {...rest}\n >\n {text}\n <span className={clsx(\"hds-show-more__icon\")} />\n </button>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAqB;AA+CjB;AAFG,SAAS,eAAe,IAAgE;AAAhE,eAAE,QAAM,SAAS,UAAU,UA7C1D,IA6C+B,IAAyC,iBAAzC,IAAyC,CAAvC,QAAM,WAAS,YAAU;AACxD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAW;AAAA,QACT;AAAA,QACA,YAAY,yBAAyB;AAAA,QACrC;AAAA,MACF;AAAA,MACA,cAAY,WAAW,aAAa;AAAA,MACpC,MAAK;AAAA,OACD,OARL;AAAA,MAUE;AAAA;AAAA,QACD,4CAAC,UAAK,eAAW,6BAAK,qBAAqB,GAAG;AAAA;AAAA;AAAA,EAChD;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/styled-html/index.ts","../../src/styled-html/styled-html.tsx"],"sourcesContent":["export { StyledHtml } from \"./styled-html\";\nexport type * from \"./styled-html\";\n","import React, { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\nimport type { OverridableComponent } from \"../utils\";\n\nexport interface StyledHtmlProps {\n children?: React.ReactNode;\n size?: \"default\" | \"small\";\n darkmode?: boolean;\n}\n\n/**\n * A component for displaying dynamic content that you want to apply hedwig styling to.\n * the styling depends on the semantic html elements you use inside the component.\n *\n * Useful when you have dynamic content that you want styled with hedwig, like content from a CMS.\n *\n * Previously known as `hw-wysiwyg` in hedwig legacy. In tailwind this kind of component it is known as `prose`.\n *\n * ```tsx\n * <StyledHtml>\n * <h1>Heading 1</h1>\n * <h2>Heading 2</h2>\n * <a href=\"https://www.postenbring.no\">Postenbring</a>\n * <ul>\n * <li>Hei</li>\n * <li>Hallo</li>\n * <li>Hello</li>\n * </ul>\n * </StyledHtml>\n * ```\n */\nexport const StyledHtml: OverridableComponent<StyledHtmlProps, HTMLDivElement> = forwardRef(\n ({ as: Component = \"div\", children, size, darkmode = false, className, ...rest }, ref) => {\n return (\n <Component\n className={clsx(\n `hds-styled-html`,\n size === \"small\" && \"hds-styled-html--small\",\n darkmode && \"hds-styled-html--darkmode\",\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nStyledHtml.displayName = \"
|
|
1
|
+
{"version":3,"sources":["../../src/styled-html/index.ts","../../src/styled-html/styled-html.tsx"],"sourcesContent":["export { StyledHtml } from \"./styled-html\";\nexport type * from \"./styled-html\";\n","import React, { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\nimport type { OverridableComponent } from \"../utils\";\n\nexport interface StyledHtmlProps {\n children?: React.ReactNode;\n size?: \"default\" | \"small\";\n darkmode?: boolean;\n}\n\n/**\n * A component for displaying dynamic content that you want to apply hedwig styling to.\n * the styling depends on the semantic html elements you use inside the component.\n *\n * Useful when you have dynamic content that you want styled with hedwig, like content from a CMS.\n *\n * Previously known as `hw-wysiwyg` in hedwig legacy. In tailwind this kind of component it is known as `prose`.\n *\n * ```tsx\n * <StyledHtml>\n * <h1>Heading 1</h1>\n * <h2>Heading 2</h2>\n * <a href=\"https://www.postenbring.no\">Postenbring</a>\n * <ul>\n * <li>Hei</li>\n * <li>Hallo</li>\n * <li>Hello</li>\n * </ul>\n * </StyledHtml>\n * ```\n */\nexport const StyledHtml: OverridableComponent<StyledHtmlProps, HTMLDivElement> = forwardRef(\n ({ as: Component = \"div\", children, size, darkmode = false, className, ...rest }, ref) => {\n return (\n <Component\n className={clsx(\n `hds-styled-html`,\n size === \"small\" && \"hds-styled-html--small\",\n darkmode && \"hds-styled-html--darkmode\",\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nStyledHtml.displayName = \"StyledHtml\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkC;AAClC,6BAAqB;AAiCf;AAHC,IAAM,iBAAoE;AAAA,EAC/E,CAAC,IAAiF,QAAQ;AAAzF,iBAAE,MAAI,YAAY,OAAO,UAAU,MAAM,WAAW,OAAO,UAhC9D,IAgCG,IAAyE,iBAAzE,IAAyE,CAAvE,MAAuB,YAAU,QAAM,YAAkB;AAC1D,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW;AAAA,UACT;AAAA,UACA,SAAS,WAAW;AAAA,UACpB,YAAY;AAAA,UACZ;AAAA,QACF;AAAA,QACA;AAAA,SACI,OARL;AAAA,QAUE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,WAAW,cAAc;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/styled-html/styled-html.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\nimport type { OverridableComponent } from \"../utils\";\n\nexport interface StyledHtmlProps {\n children?: React.ReactNode;\n size?: \"default\" | \"small\";\n darkmode?: boolean;\n}\n\n/**\n * A component for displaying dynamic content that you want to apply hedwig styling to.\n * the styling depends on the semantic html elements you use inside the component.\n *\n * Useful when you have dynamic content that you want styled with hedwig, like content from a CMS.\n *\n * Previously known as `hw-wysiwyg` in hedwig legacy. In tailwind this kind of component it is known as `prose`.\n *\n * ```tsx\n * <StyledHtml>\n * <h1>Heading 1</h1>\n * <h2>Heading 2</h2>\n * <a href=\"https://www.postenbring.no\">Postenbring</a>\n * <ul>\n * <li>Hei</li>\n * <li>Hallo</li>\n * <li>Hello</li>\n * </ul>\n * </StyledHtml>\n * ```\n */\nexport const StyledHtml: OverridableComponent<StyledHtmlProps, HTMLDivElement> = forwardRef(\n ({ as: Component = \"div\", children, size, darkmode = false, className, ...rest }, ref) => {\n return (\n <Component\n className={clsx(\n `hds-styled-html`,\n size === \"small\" && \"hds-styled-html--small\",\n darkmode && \"hds-styled-html--darkmode\",\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nStyledHtml.displayName = \"
|
|
1
|
+
{"version":3,"sources":["../../src/styled-html/styled-html.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\nimport type { OverridableComponent } from \"../utils\";\n\nexport interface StyledHtmlProps {\n children?: React.ReactNode;\n size?: \"default\" | \"small\";\n darkmode?: boolean;\n}\n\n/**\n * A component for displaying dynamic content that you want to apply hedwig styling to.\n * the styling depends on the semantic html elements you use inside the component.\n *\n * Useful when you have dynamic content that you want styled with hedwig, like content from a CMS.\n *\n * Previously known as `hw-wysiwyg` in hedwig legacy. In tailwind this kind of component it is known as `prose`.\n *\n * ```tsx\n * <StyledHtml>\n * <h1>Heading 1</h1>\n * <h2>Heading 2</h2>\n * <a href=\"https://www.postenbring.no\">Postenbring</a>\n * <ul>\n * <li>Hei</li>\n * <li>Hallo</li>\n * <li>Hello</li>\n * </ul>\n * </StyledHtml>\n * ```\n */\nexport const StyledHtml: OverridableComponent<StyledHtmlProps, HTMLDivElement> = forwardRef(\n ({ as: Component = \"div\", children, size, darkmode = false, className, ...rest }, ref) => {\n return (\n <Component\n className={clsx(\n `hds-styled-html`,\n size === \"small\" && \"hds-styled-html--small\",\n darkmode && \"hds-styled-html--darkmode\",\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nStyledHtml.displayName = \"StyledHtml\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkC;AAClC,6BAAqB;AAiCf;AAHC,IAAM,iBAAoE;AAAA,EAC/E,CAAC,IAAiF,QAAQ;AAAzF,iBAAE,MAAI,YAAY,OAAO,UAAU,MAAM,WAAW,OAAO,UAhC9D,IAgCG,IAAyE,iBAAzE,IAAyE,CAAvE,MAAuB,YAAU,QAAM,YAAkB;AAC1D,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW;AAAA,UACT;AAAA,UACA,SAAS,WAAW;AAAA,UACpB,YAAY;AAAA,UACZ;AAAA,QACF;AAAA,QACA;AAAA,SACI,OARL;AAAA,QAUE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,WAAW,cAAc;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { Text_alias_2 as Text } from '../_tsup-dts-rollup';
|
|
2
|
+
export { TextH1Display_alias_2 as TextH1Display } from '../_tsup-dts-rollup';
|
|
3
|
+
export { TextH1_alias_2 as TextH1 } from '../_tsup-dts-rollup';
|
|
4
|
+
export { TextH2_alias_2 as TextH2 } from '../_tsup-dts-rollup';
|
|
5
|
+
export { TextH3_alias_2 as TextH3 } from '../_tsup-dts-rollup';
|
|
6
|
+
export { TextH3Title_alias_2 as TextH3Title } from '../_tsup-dts-rollup';
|
|
7
|
+
export { TextBody_alias_2 as TextBody } from '../_tsup-dts-rollup';
|
|
8
|
+
export { TextBodyTitle_alias_2 as TextBodyTitle } from '../_tsup-dts-rollup';
|
|
9
|
+
export { TextBodySmall_alias_2 as TextBodySmall } from '../_tsup-dts-rollup';
|
|
10
|
+
export { TextBodySmallTitle_alias_2 as TextBodySmallTitle } from '../_tsup-dts-rollup';
|
|
11
|
+
export { TextTechnical_alias_2 as TextTechnical } from '../_tsup-dts-rollup';
|
|
12
|
+
export { TextTechnicalTitle_alias_2 as TextTechnicalTitle } from '../_tsup-dts-rollup';
|
|
13
|
+
export { TextCaption_alias_2 as TextCaption } from '../_tsup-dts-rollup';
|
|
14
|
+
export { TextCaptionTitle_alias_2 as TextCaptionTitle } from '../_tsup-dts-rollup';
|
|
15
|
+
export { TextProps_alias_2 as TextProps } from '../_tsup-dts-rollup';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { Text_alias_2 as Text } from '../_tsup-dts-rollup';
|
|
2
|
+
export { TextH1Display_alias_2 as TextH1Display } from '../_tsup-dts-rollup';
|
|
3
|
+
export { TextH1_alias_2 as TextH1 } from '../_tsup-dts-rollup';
|
|
4
|
+
export { TextH2_alias_2 as TextH2 } from '../_tsup-dts-rollup';
|
|
5
|
+
export { TextH3_alias_2 as TextH3 } from '../_tsup-dts-rollup';
|
|
6
|
+
export { TextH3Title_alias_2 as TextH3Title } from '../_tsup-dts-rollup';
|
|
7
|
+
export { TextBody_alias_2 as TextBody } from '../_tsup-dts-rollup';
|
|
8
|
+
export { TextBodyTitle_alias_2 as TextBodyTitle } from '../_tsup-dts-rollup';
|
|
9
|
+
export { TextBodySmall_alias_2 as TextBodySmall } from '../_tsup-dts-rollup';
|
|
10
|
+
export { TextBodySmallTitle_alias_2 as TextBodySmallTitle } from '../_tsup-dts-rollup';
|
|
11
|
+
export { TextTechnical_alias_2 as TextTechnical } from '../_tsup-dts-rollup';
|
|
12
|
+
export { TextTechnicalTitle_alias_2 as TextTechnicalTitle } from '../_tsup-dts-rollup';
|
|
13
|
+
export { TextCaption_alias_2 as TextCaption } from '../_tsup-dts-rollup';
|
|
14
|
+
export { TextCaptionTitle_alias_2 as TextCaptionTitle } from '../_tsup-dts-rollup';
|
|
15
|
+
export { TextProps_alias_2 as TextProps } from '../_tsup-dts-rollup';
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __objRest = (source, exclude) => {
|
|
24
|
+
var target = {};
|
|
25
|
+
for (var prop in source)
|
|
26
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
+
target[prop] = source[prop];
|
|
28
|
+
if (source != null && __getOwnPropSymbols)
|
|
29
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
35
|
+
var __export = (target, all) => {
|
|
36
|
+
for (var name in all)
|
|
37
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
38
|
+
};
|
|
39
|
+
var __copyProps = (to, from, except, desc) => {
|
|
40
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
41
|
+
for (let key of __getOwnPropNames(from))
|
|
42
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
43
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
44
|
+
}
|
|
45
|
+
return to;
|
|
46
|
+
};
|
|
47
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
48
|
+
|
|
49
|
+
// src/text/index.tsx
|
|
50
|
+
var text_exports = {};
|
|
51
|
+
__export(text_exports, {
|
|
52
|
+
Text: () => Text,
|
|
53
|
+
TextBody: () => TextBody,
|
|
54
|
+
TextBodySmall: () => TextBodySmall,
|
|
55
|
+
TextBodySmallTitle: () => TextBodySmallTitle,
|
|
56
|
+
TextBodyTitle: () => TextBodyTitle,
|
|
57
|
+
TextCaption: () => TextCaption,
|
|
58
|
+
TextCaptionTitle: () => TextCaptionTitle,
|
|
59
|
+
TextH1: () => TextH1,
|
|
60
|
+
TextH1Display: () => TextH1Display,
|
|
61
|
+
TextH2: () => TextH2,
|
|
62
|
+
TextH3: () => TextH3,
|
|
63
|
+
TextH3Title: () => TextH3Title,
|
|
64
|
+
TextTechnical: () => TextTechnical,
|
|
65
|
+
TextTechnicalTitle: () => TextTechnicalTitle
|
|
66
|
+
});
|
|
67
|
+
module.exports = __toCommonJS(text_exports);
|
|
68
|
+
|
|
69
|
+
// src/text/text.tsx
|
|
70
|
+
var import_react = require("react");
|
|
71
|
+
var import_typed_classname = require("@postenbring/hedwig-css/typed-classname/index.mjs");
|
|
72
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
73
|
+
var defaultHTMLTag = {
|
|
74
|
+
"h1-display": "h1",
|
|
75
|
+
h1: "h1",
|
|
76
|
+
h2: "h2",
|
|
77
|
+
h3: "h3",
|
|
78
|
+
"h3-title": "h3",
|
|
79
|
+
body: "p",
|
|
80
|
+
"body-title": "p",
|
|
81
|
+
"body-small": "p",
|
|
82
|
+
"body-small-title": "p",
|
|
83
|
+
technical: "p",
|
|
84
|
+
"technical-title": "p",
|
|
85
|
+
caption: "p",
|
|
86
|
+
"caption-title": "p"
|
|
87
|
+
};
|
|
88
|
+
var Text = (0, import_react.forwardRef)(
|
|
89
|
+
(_a, ref) => {
|
|
90
|
+
var _b = _a, {
|
|
91
|
+
as,
|
|
92
|
+
variant = "body",
|
|
93
|
+
size = "fluid",
|
|
94
|
+
_unstableSpacing: spacing,
|
|
95
|
+
children,
|
|
96
|
+
className
|
|
97
|
+
} = _b, rest = __objRest(_b, [
|
|
98
|
+
"as",
|
|
99
|
+
"variant",
|
|
100
|
+
"size",
|
|
101
|
+
"_unstableSpacing",
|
|
102
|
+
"children",
|
|
103
|
+
"className"
|
|
104
|
+
]);
|
|
105
|
+
const Component = as != null ? as : defaultHTMLTag[variant];
|
|
106
|
+
const sizeModifier = size !== "fluid" && variant !== "caption" && variant !== "caption-title" && size;
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
108
|
+
Component,
|
|
109
|
+
__spreadProps(__spreadValues({
|
|
110
|
+
className: (0, import_typed_classname.clsx)(
|
|
111
|
+
`hds-text-${variant}`,
|
|
112
|
+
sizeModifier && `hds-text--${sizeModifier}`,
|
|
113
|
+
spacing && "hds-text--spacing",
|
|
114
|
+
className
|
|
115
|
+
),
|
|
116
|
+
ref
|
|
117
|
+
}, rest), {
|
|
118
|
+
children
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
Text.displayName = "Text";
|
|
124
|
+
|
|
125
|
+
// src/text/index.tsx
|
|
126
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
127
|
+
var TextH1Display = textVariant("h1-display", "TextH1Display");
|
|
128
|
+
var TextH1 = textVariant("h1", "TextH1");
|
|
129
|
+
var TextH2 = textVariant("h2", "TextH2");
|
|
130
|
+
var TextH3 = textVariant("h3", "TextH3");
|
|
131
|
+
var TextH3Title = textVariant("h3-title", "TextH3Title");
|
|
132
|
+
var TextBody = textVariant("body", "TextBody");
|
|
133
|
+
var TextBodyTitle = textVariant("body-title", "TextBodyTitle");
|
|
134
|
+
var TextBodySmall = textVariant("body-small", "TextBodySmall");
|
|
135
|
+
var TextBodySmallTitle = textVariant("body-small-title", "TextBodySmallTitle");
|
|
136
|
+
var TextTechnical = textVariant("technical", "TextTechnical");
|
|
137
|
+
var TextTechnicalTitle = textVariant("technical-title", "TextTechnicalTitle");
|
|
138
|
+
var TextCaption = textVariant("caption", "TextCaption");
|
|
139
|
+
var TextCaptionTitle = textVariant("caption-title", "TextCaptionTitle");
|
|
140
|
+
var variantToHtmlTag = {
|
|
141
|
+
"h1-display": "h1",
|
|
142
|
+
h1: "h1",
|
|
143
|
+
h2: "h2",
|
|
144
|
+
h3: "h3",
|
|
145
|
+
"h3-title": "h3",
|
|
146
|
+
body: "p",
|
|
147
|
+
"body-title": "p",
|
|
148
|
+
"body-small": "p",
|
|
149
|
+
"body-small-title": "p",
|
|
150
|
+
technical: "p",
|
|
151
|
+
"technical-title": "p",
|
|
152
|
+
caption: "p",
|
|
153
|
+
"caption-title": "p"
|
|
154
|
+
};
|
|
155
|
+
function textVariant(variant, displayName) {
|
|
156
|
+
function WrappedText(props) {
|
|
157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, __spreadValues({ variant, as: variantToHtmlTag[variant != null ? variant : "body"] }, props));
|
|
158
|
+
}
|
|
159
|
+
WrappedText.displayName = displayName;
|
|
160
|
+
return WrappedText;
|
|
161
|
+
}
|
|
162
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
163
|
+
0 && (module.exports = {
|
|
164
|
+
Text,
|
|
165
|
+
TextBody,
|
|
166
|
+
TextBodySmall,
|
|
167
|
+
TextBodySmallTitle,
|
|
168
|
+
TextBodyTitle,
|
|
169
|
+
TextCaption,
|
|
170
|
+
TextCaptionTitle,
|
|
171
|
+
TextH1,
|
|
172
|
+
TextH1Display,
|
|
173
|
+
TextH2,
|
|
174
|
+
TextH3,
|
|
175
|
+
TextH3Title,
|
|
176
|
+
TextTechnical,
|
|
177
|
+
TextTechnicalTitle
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/text/index.tsx","../../src/text/text.tsx"],"sourcesContent":["import type { TextProps } from \"./text\";\nimport { Text } from \"./text\";\n\nexport { Text };\nexport type * from \"./text\";\n\n/**\n * # 🚨 Unstable alternative\n *\n * named as the different typography levels with Text prefix\n *\n * ## Alias to @see Text\n */\nexport const TextH1Display = textVariant(\"h1-display\", \"TextH1Display\");\n/**\n * # 🚨 Unstable alternative\n *\n * named as the different typography levels with Text prefix\n *\n * ## Alias to @see Text\n */\nexport const TextH1 = textVariant(\"h1\", \"TextH1\");\n/**\n * # 🚨 Unstable alternative\n *\n * named as the different typography levels with Text prefix\n *\n * ## Alias to @see Text\n */\nexport const TextH2 = textVariant(\"h2\", \"TextH2\");\n/**\n * # 🚨 Unstable alternative\n *\n * named as the different typography levels with Text prefix\n *\n * ## Alias to @see Text\n */\nexport const TextH3 = textVariant(\"h3\", \"TextH3\");\n/**\n * # 🚨 Unstable alternative\n *\n * named as the different typography levels with Text prefix\n *\n * ## Alias to @see Text\n */\nexport const TextH3Title = textVariant(\"h3-title\", \"TextH3Title\");\n/**\n * # 🚨 Unstable alternative\n *\n * named as the different typography levels with Text prefix\n *\n * ## Alias to @see Text\n */\nexport const TextBody = textVariant(\"body\", \"TextBody\"); // Less weird\n/**\n * # 🚨 Unstable alternative\n *\n * named as the different typography levels with Text prefix\n *\n * ## Alias to @see Text\n */\nexport const TextBodyTitle = textVariant(\"body-title\", \"TextBodyTitle\");\n/**\n * # 🚨 Unstable alternative\n *\n * named as the different typography levels with Text prefix\n *\n * ## Alias to @see Text\n */\nexport const TextBodySmall = textVariant(\"body-small\", \"TextBodySmall\");\n/**\n * # 🚨 Unstable alternative\n *\n * named as the different typography levels with Text prefix\n *\n * ## Alias to @see Text\n */\nexport const TextBodySmallTitle = textVariant(\"body-small-title\", \"TextBodySmallTitle\");\n/**\n * 🚨 Unstable alterentative: Named as the different typography levels with Text prefix\n *\n * ## Alias to @see Text\n */\nexport const TextTechnical = textVariant(\"technical\", \"TextTechnical\");\n/**\n * 🚨 Unstable alterentative: Named as the different typography levels with Text prefix\n *\n * ## Alias to @see Text\n */\nexport const TextTechnicalTitle = textVariant(\"technical-title\", \"TextTechnicalTitle\");\n/**\n * 🚨 Unstable alterentative: Named as the different typography levels with Text prefix\n *\n * ## Alias to @see Text\n */\nexport const TextCaption = textVariant(\"caption\", \"TextCaption\");\n/**\n * 🚨 Unstable alterentative: Named as the different typography levels with Text prefix\n *\n * ## Alias to @see Text\n */\nexport const TextCaptionTitle = textVariant(\"caption-title\", \"TextCaptionTitle\");\n\nconst variantToHtmlTag = {\n \"h1-display\": \"h1\",\n h1: \"h1\",\n h2: \"h2\",\n h3: \"h3\",\n \"h3-title\": \"h3\",\n body: \"p\",\n \"body-title\": \"p\",\n \"body-small\": \"p\",\n \"body-small-title\": \"p\",\n technical: \"p\",\n \"technical-title\": \"p\",\n caption: \"p\",\n \"caption-title\": \"p\",\n} as const;\n\nfunction textVariant(\n variant: TextProps[\"variant\"],\n displayName: string,\n): React.FunctionComponent<Omit<TextProps, \"variant\">> {\n function WrappedText(props: Omit<TextProps, \"variant\">) {\n return <Text variant={variant} as={variantToHtmlTag[variant ?? \"body\"]} {...props} />;\n }\n WrappedText.displayName = displayName;\n\n return WrappedText;\n}\n","import React, { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\nimport type { OverridableComponent } from \"../utils\";\n\ninterface HeadingProps {\n variant: \"h1-display\" | \"h1\" | \"h2\" | \"h3\" | \"h3-title\";\n as: React.ElementType;\n}\ninterface ParagraphProps {\n variant?:\n | \"body\"\n | \"body-title\"\n | \"body-small\"\n | \"body-small-title\"\n | \"technical\"\n | \"technical-title\"\n | \"caption\"\n | \"caption-title\";\n}\n\nexport type TextProps = (HeadingProps | ParagraphProps) & {\n children: React.ReactNode;\n\n /**\n * The font-size of the component. By default it's `fluid` which means it's smaller on mobile and larger on desktop.\n *\n * But you can lock it to either the min or the max size.\n */\n size?: \"min\" | \"max\" | \"fluid\";\n\n /**\n * 🚧 Experimental spacing\n */\n _unstableSpacing?: boolean;\n};\n\nconst defaultHTMLTag: Record<NonNullable<TextProps[\"variant\"]>, `h${1 | 2 | 3}` | \"p\"> = {\n \"h1-display\": \"h1\",\n h1: \"h1\",\n h2: \"h2\",\n h3: \"h3\",\n \"h3-title\": \"h3\",\n body: \"p\",\n \"body-title\": \"p\",\n \"body-small\": \"p\",\n \"body-small-title\": \"p\",\n technical: \"p\",\n \"technical-title\": \"p\",\n caption: \"p\",\n \"caption-title\": \"p\",\n};\n\n/**\n * Text component\n *\n * If the variant is `h1-display`, `h1`, `h2`, `h3`, or `h3-title` the `as` prop is required.\n *\n * This to force the consumer to consider which semantic html element to use. E.g. `<h1>` or `<h2>`\n *\n * @example\n * ```tsx\n * <Text variant=\"h1-display\" as=\"h1\">Hello world</Text>\n * <Text variant=\"body\">\n * This is a body text\n * </Text>\n * ```\n */\nexport const Text: OverridableComponent<TextProps, HTMLDivElement> = forwardRef(\n (\n {\n as,\n variant = \"body\",\n size = \"fluid\",\n _unstableSpacing: spacing,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const Component = as ?? defaultHTMLTag[variant];\n const sizeModifier =\n size !== \"fluid\" && variant !== \"caption\" && variant !== \"caption-title\" && size;\n return (\n <Component\n className={clsx(\n `hds-text-${variant}`,\n sizeModifier && `hds-text--${sizeModifier}`,\n spacing && \"hds-text--spacing\",\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nText.displayName = \"Text\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAkC;AAClC,6BAAqB;AAmFf;AAhDN,IAAM,iBAAmF;AAAA,EACvF,cAAc;AAAA,EACd,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,cAAc;AAAA,EACd,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,mBAAmB;AAAA,EACnB,SAAS;AAAA,EACT,iBAAiB;AACnB;AAiBO,IAAM,WAAwD;AAAA,EACnE,CACE,IASA,QACG;AAVH,iBACE;AAAA;AAAA,MACA,UAAU;AAAA,MACV,OAAO;AAAA,MACP,kBAAkB;AAAA,M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nB,SAAS;AAAA,EACT,iBAAiB;AACnB;AAEA,SAAS,YACP,SACA,aACqD;AACrD,WAAS,YAAY,OAAmC;AACtD,WAAO,6CAAC,uBAAK,SAAkB,IAAI,iBAAiB,4BAAW,MAAM,KAAO,MAAO;AAAA,EACrF;AACA,cAAY,cAAc;AAE1B,SAAO;AACT;","names":["import_jsx_runtime"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TextBody,
|
|
3
|
+
TextBodySmall,
|
|
4
|
+
TextBodySmallTitle,
|
|
5
|
+
TextBodyTitle,
|
|
6
|
+
TextCaption,
|
|
7
|
+
TextCaptionTitle,
|
|
8
|
+
TextH1,
|
|
9
|
+
TextH1Display,
|
|
10
|
+
TextH2,
|
|
11
|
+
TextH3,
|
|
12
|
+
TextH3Title,
|
|
13
|
+
TextTechnical,
|
|
14
|
+
TextTechnicalTitle
|
|
15
|
+
} from "../chunk-V4NGQVBQ.mjs";
|
|
16
|
+
import {
|
|
17
|
+
Text
|
|
18
|
+
} from "../chunk-LYRXA4WS.mjs";
|
|
19
|
+
import "../chunk-R4SQKVDQ.mjs";
|
|
20
|
+
export {
|
|
21
|
+
Text,
|
|
22
|
+
TextBody,
|
|
23
|
+
TextBodySmall,
|
|
24
|
+
TextBodySmallTitle,
|
|
25
|
+
TextBodyTitle,
|
|
26
|
+
TextCaption,
|
|
27
|
+
TextCaptionTitle,
|
|
28
|
+
TextH1,
|
|
29
|
+
TextH1Display,
|
|
30
|
+
TextH2,
|
|
31
|
+
TextH3,
|
|
32
|
+
TextH3Title,
|
|
33
|
+
TextTechnical,
|
|
34
|
+
TextTechnicalTitle
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -46,12 +46,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
46
46
|
};
|
|
47
47
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
48
48
|
|
|
49
|
-
// src/
|
|
50
|
-
var
|
|
51
|
-
__export(
|
|
52
|
-
|
|
49
|
+
// src/text/text.tsx
|
|
50
|
+
var text_exports = {};
|
|
51
|
+
__export(text_exports, {
|
|
52
|
+
Text: () => Text
|
|
53
53
|
});
|
|
54
|
-
module.exports = __toCommonJS(
|
|
54
|
+
module.exports = __toCommonJS(text_exports);
|
|
55
55
|
var import_react = require("react");
|
|
56
56
|
var import_typed_classname = require("@postenbring/hedwig-css/typed-classname/index.mjs");
|
|
57
57
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -70,7 +70,7 @@ var defaultHTMLTag = {
|
|
|
70
70
|
caption: "p",
|
|
71
71
|
"caption-title": "p"
|
|
72
72
|
};
|
|
73
|
-
var
|
|
73
|
+
var Text = (0, import_react.forwardRef)(
|
|
74
74
|
(_a, ref) => {
|
|
75
75
|
var _b = _a, {
|
|
76
76
|
as,
|
|
@@ -93,9 +93,9 @@ var Typography = (0, import_react.forwardRef)(
|
|
|
93
93
|
Component,
|
|
94
94
|
__spreadProps(__spreadValues({
|
|
95
95
|
className: (0, import_typed_classname.clsx)(
|
|
96
|
-
`hds-
|
|
97
|
-
sizeModifier && `hds-
|
|
98
|
-
spacing && "hds-
|
|
96
|
+
`hds-text-${variant}`,
|
|
97
|
+
sizeModifier && `hds-text--${sizeModifier}`,
|
|
98
|
+
spacing && "hds-text--spacing",
|
|
99
99
|
className
|
|
100
100
|
),
|
|
101
101
|
ref
|
|
@@ -105,9 +105,9 @@ var Typography = (0, import_react.forwardRef)(
|
|
|
105
105
|
);
|
|
106
106
|
}
|
|
107
107
|
);
|
|
108
|
-
|
|
108
|
+
Text.displayName = "Text";
|
|
109
109
|
// Annotate the CommonJS export names for ESM import in node:
|
|
110
110
|
0 && (module.exports = {
|
|
111
|
-
|
|
111
|
+
Text
|
|
112
112
|
});
|
|
113
|
-
//# sourceMappingURL=
|
|
113
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/text/text.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\nimport type { OverridableComponent } from \"../utils\";\n\ninterface HeadingProps {\n variant: \"h1-display\" | \"h1\" | \"h2\" | \"h3\" | \"h3-title\";\n as: React.ElementType;\n}\ninterface ParagraphProps {\n variant?:\n | \"body\"\n | \"body-title\"\n | \"body-small\"\n | \"body-small-title\"\n | \"technical\"\n | \"technical-title\"\n | \"caption\"\n | \"caption-title\";\n}\n\nexport type TextProps = (HeadingProps | ParagraphProps) & {\n children: React.ReactNode;\n\n /**\n * The font-size of the component. By default it's `fluid` which means it's smaller on mobile and larger on desktop.\n *\n * But you can lock it to either the min or the max size.\n */\n size?: \"min\" | \"max\" | \"fluid\";\n\n /**\n * 🚧 Experimental spacing\n */\n _unstableSpacing?: boolean;\n};\n\nconst defaultHTMLTag: Record<NonNullable<TextProps[\"variant\"]>, `h${1 | 2 | 3}` | \"p\"> = {\n \"h1-display\": \"h1\",\n h1: \"h1\",\n h2: \"h2\",\n h3: \"h3\",\n \"h3-title\": \"h3\",\n body: \"p\",\n \"body-title\": \"p\",\n \"body-small\": \"p\",\n \"body-small-title\": \"p\",\n technical: \"p\",\n \"technical-title\": \"p\",\n caption: \"p\",\n \"caption-title\": \"p\",\n};\n\n/**\n * Text component\n *\n * If the variant is `h1-display`, `h1`, `h2`, `h3`, or `h3-title` the `as` prop is required.\n *\n * This to force the consumer to consider which semantic html element to use. E.g. `<h1>` or `<h2>`\n *\n * @example\n * ```tsx\n * <Text variant=\"h1-display\" as=\"h1\">Hello world</Text>\n * <Text variant=\"body\">\n * This is a body text\n * </Text>\n * ```\n */\nexport const Text: OverridableComponent<TextProps, HTMLDivElement> = forwardRef(\n (\n {\n as,\n variant = \"body\",\n size = \"fluid\",\n _unstableSpacing: spacing,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const Component = as ?? defaultHTMLTag[variant];\n const sizeModifier =\n size !== \"fluid\" && variant !== \"caption\" && variant !== \"caption-title\" && size;\n return (\n <Component\n className={clsx(\n `hds-text-${variant}`,\n sizeModifier && `hds-text--${sizeModifier}`,\n spacing && \"hds-text--spacing\",\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nText.displayName = \"Text\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkC;AAClC,6BAAqB;AAmFf;AAhDN,IAAM,iBAAmF;AAAA,EACvF,cAAc;AAAA,EACd,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,cAAc;AAAA,EACd,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,mBAAmB;AAAA,EACnB,SAAS;AAAA,EACT,iBAAiB;AACnB;AAiBO,IAAM,WAAwD;AAAA,EACnE,CACE,IASA,QACG;AAVH,iBACE;AAAA;AAAA,MACA,UAAU;AAAA,MACV,OAAO;AAAA,MACP,kBAAkB;AAAA,MAClB;AAAA,MACA;AAAA,IA3EN,IAqEI,IAOK,iBAPL,IAOK;AAAA,MANH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,YAAY,kBAAM,eAAe,OAAO;AAC9C,UAAM,eACJ,SAAS,WAAW,YAAY,aAAa,YAAY,mBAAmB;AAC9E,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW;AAAA,UACT,YAAY,OAAO;AAAA,UACnB,gBAAgB,aAAa,YAAY;AAAA,UACzC,WAAW;AAAA,UACX;AAAA,QACF;AAAA,QACA;AAAA,SACI,OARL;AAAA,QAUE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,KAAK,cAAc;","names":[]}
|
|
@@ -161,7 +161,7 @@ var WarningBannerTitle = (0, import_react2.forwardRef)(
|
|
|
161
161
|
]);
|
|
162
162
|
const [open, setOpen] = (0, import_react2.useState)(false);
|
|
163
163
|
if (variant === "expandable") {
|
|
164
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.
|
|
164
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
165
165
|
Component,
|
|
166
166
|
__spreadProps(__spreadValues({
|
|
167
167
|
className: (0, import_typed_classname2.clsx)(
|
|
@@ -176,20 +176,7 @@ var WarningBannerTitle = (0, import_react2.forwardRef)(
|
|
|
176
176
|
ref,
|
|
177
177
|
type: "button"
|
|
178
178
|
}, rest), {
|
|
179
|
-
children:
|
|
180
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children }),
|
|
181
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: (0, import_typed_classname2.clsx)("hds-warning-banner__title-trigger--icon"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
182
|
-
"svg",
|
|
183
|
-
{
|
|
184
|
-
fill: "none",
|
|
185
|
-
height: "24",
|
|
186
|
-
viewBox: "0 0 24 24",
|
|
187
|
-
width: "24",
|
|
188
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
189
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("g", { className: "hds-warning-banner__title-trigger--icon-chevron", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M19.6289 9.15625L18.9609 8.45312C18.7852 8.27734 18.5039 8.27734 18.3633 8.45312L12 14.8164L5.60156 8.45312C5.46094 8.27734 5.17969 8.27734 5.00391 8.45312L4.33594 9.15625C4.16016 9.29688 4.16016 9.57812 4.33594 9.75391L11.6836 17.1016C11.8594 17.2773 12.1055 17.2773 12.2812 17.1016L19.6289 9.75391C19.8047 9.57812 19.8047 9.29688 19.6289 9.15625Z" }) })
|
|
190
|
-
}
|
|
191
|
-
) })
|
|
192
|
-
]
|
|
179
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children })
|
|
193
180
|
})
|
|
194
181
|
);
|
|
195
182
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/warning-banner/index.tsx","../../src/warning-banner/warning-banner.tsx","../../src/box/box.tsx","../../src/box/index.tsx"],"sourcesContent":["export { WarningBanner } from \"./warning-banner\";\nexport type * from \"./warning-banner\";\n","import type { ReactNode } from \"react\";\nimport { forwardRef, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\nimport type { OverridableComponent } from \"../utils\";\nimport { Box } from \"../box\";\n\nexport interface WarningBannerProps {\n title: ReactNode;\n description?: ReactNode;\n}\n\nexport const WarningBanner: OverridableComponent<WarningBannerProps, HTMLDivElement> = forwardRef(\n ({ title, description, className, ...rest }, ref) => {\n const expandable = !!description;\n return (\n <Box {...rest} className={clsx(\"hds-warning-banner\", className as undefined)} ref={ref}>\n <WarningBannerTitle variant={expandable ? \"expandable\" : \"default\"}>\n {title}\n </WarningBannerTitle>\n {expandable ? <WarningBannerDescription>{description}</WarningBannerDescription> : null}\n </Box>\n );\n },\n);\nWarningBanner.displayName = \"WarningBanner\";\n\ninterface WarningBannerTitleProps {\n variant: \"expandable\" | \"default\";\n children: ReactNode;\n}\n\nconst WarningBannerTitle: OverridableComponent<WarningBannerTitleProps, HTMLDivElement> =\n forwardRef(\n (\n {\n variant,\n as: Component = variant === \"expandable\" ? \"button\" : \"p\",\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [open, setOpen] = useState<boolean>(false);\n if (variant === \"expandable\") {\n return (\n <Component\n className={clsx(\n \"hds-warning-banner__title\",\n \"hds-warning-banner__title-trigger\",\n { \"hds-warning-banner--closed\": !open },\n className as undefined,\n )}\n onClick={() => {\n setOpen(!open);\n }}\n ref={ref}\n type=\"button\"\n {...rest}\n >\n <span>{children}</span>\n
|
|
1
|
+
{"version":3,"sources":["../../src/warning-banner/index.tsx","../../src/warning-banner/warning-banner.tsx","../../src/box/box.tsx","../../src/box/index.tsx"],"sourcesContent":["export { WarningBanner } from \"./warning-banner\";\nexport type * from \"./warning-banner\";\n","import type { ReactNode } from \"react\";\nimport { forwardRef, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\nimport type { OverridableComponent } from \"../utils\";\nimport { Box } from \"../box\";\n\nexport interface WarningBannerProps {\n title: ReactNode;\n description?: ReactNode;\n}\n\nexport const WarningBanner: OverridableComponent<WarningBannerProps, HTMLDivElement> = forwardRef(\n ({ title, description, className, ...rest }, ref) => {\n const expandable = !!description;\n return (\n <Box {...rest} className={clsx(\"hds-warning-banner\", className as undefined)} ref={ref}>\n <WarningBannerTitle variant={expandable ? \"expandable\" : \"default\"}>\n {title}\n </WarningBannerTitle>\n {expandable ? <WarningBannerDescription>{description}</WarningBannerDescription> : null}\n </Box>\n );\n },\n);\nWarningBanner.displayName = \"WarningBanner\";\n\ninterface WarningBannerTitleProps {\n variant: \"expandable\" | \"default\";\n children: ReactNode;\n}\n\nconst WarningBannerTitle: OverridableComponent<WarningBannerTitleProps, HTMLDivElement> =\n forwardRef(\n (\n {\n variant,\n as: Component = variant === \"expandable\" ? \"button\" : \"p\",\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [open, setOpen] = useState<boolean>(false);\n if (variant === \"expandable\") {\n return (\n <Component\n className={clsx(\n \"hds-warning-banner__title\",\n \"hds-warning-banner__title-trigger\",\n { \"hds-warning-banner--closed\": !open },\n className as undefined,\n )}\n onClick={() => {\n setOpen(!open);\n }}\n ref={ref}\n type=\"button\"\n {...rest}\n >\n <span>{children}</span>\n </Component>\n );\n }\n return (\n <Component\n className={clsx(\"hds-warning-banner__title\", className as undefined)}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n );\nWarningBannerTitle.displayName = \"WarningBannerTitle\";\n\nconst WarningBannerDescription: OverridableComponent<object, HTMLParagraphElement> = forwardRef(\n ({ as: Component = \"p\", className, ...rest }, ref) => {\n return (\n <Component\n className={clsx(\"hds-warning-banner__description\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nWarningBannerDescription.displayName = \"WarningBannerDescription\";\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\nimport type { OverridableComponent } from \"../utils\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\n children?: React.ReactNode;\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n}\n\nexport const Box: OverridableComponent<BoxProps, HTMLDivElement> = forwardRef(\n (\n {\n as: Component = \"div\",\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n\n return (\n <Component\n className={clsx(\n \"hds-box\",\n variant && `hds-box--${variant}`,\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n {children}\n </Component>\n );\n },\n);\nBox.displayName = \"Box\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n","import { Box, BoxCloseButton } from \"./box\";\n\nconst BoxComponent = Box as typeof Box & {\n CloseButton: typeof BoxCloseButton;\n};\nBoxComponent.CloseButton = BoxCloseButton;\n\nexport { BoxComponent as Box };\n\nexport type * from \"./box\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAAA,gBAAqC;AACrC,IAAAC,0BAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AAmEf;AA9BC,IAAM,UAAsD;AAAA,EACjE,CACE,IAWA,QACG;AAZH,iBACE;AAAA,UAAI,YAAY;AAAA,MAChB;AAAA,MACA,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IAhDN,IAwCI,IASK,iBATL,IASK;AAAA,MARH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,KAAK;AACpD,UAAM,cAAU,0BAAY,MAAM;AAChC,UAAI,aAAa;AACf,cAAM,SAAS,YAAY;AAC3B,YAAI,WAAW,MAAM;AACnB,yBAAe,IAAI;AAAA,QACrB;AAAA,MACF,OAAO;AACL,uBAAe,IAAI;AAAA,MACrB;AAAA,IAEF,GAAG,CA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,MAJH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,CAAC,MAAM,OAAO,QAAI,wBAAkB,KAAK;AAC/C,QAAI,YAAY,cAAc;AAC5B,aACE;AAAA,QAAC;AAAA;AAAA,UACC,eAAW;AAAA,YACT;AAAA,YACA;AAAA,YACA,EAAE,8BAA8B,CAAC,KAAK;AAAA,YACtC;AAAA,UACF;AAAA,UACA,SAAS,MAAM;AACb,oBAAQ,CAAC,IAAI;AAAA,UACf;AAAA,UACA;AAAA,UACA,MAAK;AAAA,WACD,OAZL;AAAA,UAcC,uDAAC,UAAM,UAAS;AAAA;AAAA,MAClB;AAAA,IAEJ;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,8BAAK,6BAA6B,SAAsB;AAAA,QACnE;AAAA,SACI,OAHL;AAAA,QAKE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACF,mBAAmB,cAAc;AAEjC,IAAM,+BAA+E;AAAA,EACnF,CAAC,IAA6C,QAAQ;AAArD,iBAAE,MAAI,YAAY,KAAK,UA9E1B,IA8EG,IAAqC,iBAArC,IAAqC,CAAnC,MAAqB;AACtB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,8BAAK,mCAAmC,SAAsB;AAAA,QACzE;AAAA,SACI;AAAA,IACN;AAAA,EAEJ;AACF;AACA,yBAAyB,cAAc;","names":["import_react","import_typed_classname","import_jsx_runtime"]}
|
|
@@ -159,7 +159,7 @@ var WarningBannerTitle = (0, import_react2.forwardRef)(
|
|
|
159
159
|
]);
|
|
160
160
|
const [open, setOpen] = (0, import_react2.useState)(false);
|
|
161
161
|
if (variant === "expandable") {
|
|
162
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.
|
|
162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
163
163
|
Component,
|
|
164
164
|
__spreadProps(__spreadValues({
|
|
165
165
|
className: (0, import_typed_classname2.clsx)(
|
|
@@ -174,20 +174,7 @@ var WarningBannerTitle = (0, import_react2.forwardRef)(
|
|
|
174
174
|
ref,
|
|
175
175
|
type: "button"
|
|
176
176
|
}, rest), {
|
|
177
|
-
children:
|
|
178
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children }),
|
|
179
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: (0, import_typed_classname2.clsx)("hds-warning-banner__title-trigger--icon"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
180
|
-
"svg",
|
|
181
|
-
{
|
|
182
|
-
fill: "none",
|
|
183
|
-
height: "24",
|
|
184
|
-
viewBox: "0 0 24 24",
|
|
185
|
-
width: "24",
|
|
186
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
187
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("g", { className: "hds-warning-banner__title-trigger--icon-chevron", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M19.6289 9.15625L18.9609 8.45312C18.7852 8.27734 18.5039 8.27734 18.3633 8.45312L12 14.8164L5.60156 8.45312C5.46094 8.27734 5.17969 8.27734 5.00391 8.45312L4.33594 9.15625C4.16016 9.29688 4.16016 9.57812 4.33594 9.75391L11.6836 17.1016C11.8594 17.2773 12.1055 17.2773 12.2812 17.1016L19.6289 9.75391C19.8047 9.57812 19.8047 9.29688 19.6289 9.15625Z" }) })
|
|
188
|
-
}
|
|
189
|
-
) })
|
|
190
|
-
]
|
|
177
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children })
|
|
191
178
|
})
|
|
192
179
|
);
|
|
193
180
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/warning-banner/warning-banner.tsx","../../src/box/box.tsx","../../src/box/index.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { forwardRef, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\nimport type { OverridableComponent } from \"../utils\";\nimport { Box } from \"../box\";\n\nexport interface WarningBannerProps {\n title: ReactNode;\n description?: ReactNode;\n}\n\nexport const WarningBanner: OverridableComponent<WarningBannerProps, HTMLDivElement> = forwardRef(\n ({ title, description, className, ...rest }, ref) => {\n const expandable = !!description;\n return (\n <Box {...rest} className={clsx(\"hds-warning-banner\", className as undefined)} ref={ref}>\n <WarningBannerTitle variant={expandable ? \"expandable\" : \"default\"}>\n {title}\n </WarningBannerTitle>\n {expandable ? <WarningBannerDescription>{description}</WarningBannerDescription> : null}\n </Box>\n );\n },\n);\nWarningBanner.displayName = \"WarningBanner\";\n\ninterface WarningBannerTitleProps {\n variant: \"expandable\" | \"default\";\n children: ReactNode;\n}\n\nconst WarningBannerTitle: OverridableComponent<WarningBannerTitleProps, HTMLDivElement> =\n forwardRef(\n (\n {\n variant,\n as: Component = variant === \"expandable\" ? \"button\" : \"p\",\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [open, setOpen] = useState<boolean>(false);\n if (variant === \"expandable\") {\n return (\n <Component\n className={clsx(\n \"hds-warning-banner__title\",\n \"hds-warning-banner__title-trigger\",\n { \"hds-warning-banner--closed\": !open },\n className as undefined,\n )}\n onClick={() => {\n setOpen(!open);\n }}\n ref={ref}\n type=\"button\"\n {...rest}\n >\n <span>{children}</span>\n
|
|
1
|
+
{"version":3,"sources":["../../src/warning-banner/warning-banner.tsx","../../src/box/box.tsx","../../src/box/index.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { forwardRef, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\nimport type { OverridableComponent } from \"../utils\";\nimport { Box } from \"../box\";\n\nexport interface WarningBannerProps {\n title: ReactNode;\n description?: ReactNode;\n}\n\nexport const WarningBanner: OverridableComponent<WarningBannerProps, HTMLDivElement> = forwardRef(\n ({ title, description, className, ...rest }, ref) => {\n const expandable = !!description;\n return (\n <Box {...rest} className={clsx(\"hds-warning-banner\", className as undefined)} ref={ref}>\n <WarningBannerTitle variant={expandable ? \"expandable\" : \"default\"}>\n {title}\n </WarningBannerTitle>\n {expandable ? <WarningBannerDescription>{description}</WarningBannerDescription> : null}\n </Box>\n );\n },\n);\nWarningBanner.displayName = \"WarningBanner\";\n\ninterface WarningBannerTitleProps {\n variant: \"expandable\" | \"default\";\n children: ReactNode;\n}\n\nconst WarningBannerTitle: OverridableComponent<WarningBannerTitleProps, HTMLDivElement> =\n forwardRef(\n (\n {\n variant,\n as: Component = variant === \"expandable\" ? \"button\" : \"p\",\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [open, setOpen] = useState<boolean>(false);\n if (variant === \"expandable\") {\n return (\n <Component\n className={clsx(\n \"hds-warning-banner__title\",\n \"hds-warning-banner__title-trigger\",\n { \"hds-warning-banner--closed\": !open },\n className as undefined,\n )}\n onClick={() => {\n setOpen(!open);\n }}\n ref={ref}\n type=\"button\"\n {...rest}\n >\n <span>{children}</span>\n </Component>\n );\n }\n return (\n <Component\n className={clsx(\"hds-warning-banner__title\", className as undefined)}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n );\nWarningBannerTitle.displayName = \"WarningBannerTitle\";\n\nconst WarningBannerDescription: OverridableComponent<object, HTMLParagraphElement> = forwardRef(\n ({ as: Component = \"p\", className, ...rest }, ref) => {\n return (\n <Component\n className={clsx(\"hds-warning-banner__description\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nWarningBannerDescription.displayName = \"WarningBannerDescription\";\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname/index.mjs\";\nimport type { OverridableComponent } from \"../utils\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\n children?: React.ReactNode;\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n}\n\nexport const Box: OverridableComponent<BoxProps, HTMLDivElement> = forwardRef(\n (\n {\n as: Component = \"div\",\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n\n return (\n <Component\n className={clsx(\n \"hds-box\",\n variant && `hds-box--${variant}`,\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n {children}\n </Component>\n );\n },\n);\nBox.displayName = \"Box\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n","import { Box, BoxCloseButton } from \"./box\";\n\nconst BoxComponent = Box as typeof Box & {\n CloseButton: typeof BoxCloseButton;\n};\nBoxCompon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