@postenbring/hedwig-react 0.0.72 → 0.0.73

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.
@@ -1046,7 +1046,17 @@ declare interface HeadingProps {
1046
1046
  /**
1047
1047
  * Show a help text for a word or phrase when clicked
1048
1048
  *
1049
- * Useful for providing explanations for domain-specific terms or acronyms
1049
+ * Useful for providing explanations for domain-specific terms, acronyms or phrases that could do with further elaboration
1050
+ *
1051
+ * **Usage**
1052
+ * ```tsx
1053
+ * <p>
1054
+ * En annen avgjørende faktor for avgifter er om nettbutikken er registrert i{" "}
1055
+ * <HelpText helpText={`VOEC er en forkortelse for "VAT on E-commerce" (mva. på e-handel).`}>
1056
+ * VOEC
1057
+ * </HelpText>
1058
+ * </p>
1059
+ * ```
1050
1060
  */
1051
1061
  declare const HelpText: ForwardRefExoticComponent<HelpTextProps & RefAttributes<HTMLButtonElement>>;
1052
1062
  export { HelpText }
@@ -1057,13 +1067,13 @@ export { HelpText as HelpText_alias_3 }
1057
1067
  declare interface HelpTextProps extends React.HTMLAttributes<HTMLButtonElement> {
1058
1068
  className?: string;
1059
1069
  /**
1060
- * The content of the help text
1070
+ * The content of the help text, often a word or phrase that could use some explanation
1061
1071
  */
1062
1072
  children: React.ReactNode;
1063
1073
  /**
1064
- * The word that should be clickable to show the help text
1074
+ * The help text that will be shown when the user clicks the trigger
1065
1075
  */
1066
- word?: React.ReactNode;
1076
+ helpText: React.ReactNode;
1067
1077
  /**
1068
1078
  * The title of the help text. Used by screen readers and if the user hover over the help text
1069
1079
  */
@@ -1046,7 +1046,17 @@ declare interface HeadingProps {
1046
1046
  /**
1047
1047
  * Show a help text for a word or phrase when clicked
1048
1048
  *
1049
- * Useful for providing explanations for domain-specific terms or acronyms
1049
+ * Useful for providing explanations for domain-specific terms, acronyms or phrases that could do with further elaboration
1050
+ *
1051
+ * **Usage**
1052
+ * ```tsx
1053
+ * <p>
1054
+ * En annen avgjørende faktor for avgifter er om nettbutikken er registrert i{" "}
1055
+ * <HelpText helpText={`VOEC er en forkortelse for "VAT on E-commerce" (mva. på e-handel).`}>
1056
+ * VOEC
1057
+ * </HelpText>
1058
+ * </p>
1059
+ * ```
1050
1060
  */
1051
1061
  declare const HelpText: ForwardRefExoticComponent<HelpTextProps & RefAttributes<HTMLButtonElement>>;
1052
1062
  export { HelpText }
@@ -1057,13 +1067,13 @@ export { HelpText as HelpText_alias_3 }
1057
1067
  declare interface HelpTextProps extends React.HTMLAttributes<HTMLButtonElement> {
1058
1068
  className?: string;
1059
1069
  /**
1060
- * The content of the help text
1070
+ * The content of the help text, often a word or phrase that could use some explanation
1061
1071
  */
1062
1072
  children: React.ReactNode;
1063
1073
  /**
1064
- * The word that should be clickable to show the help text
1074
+ * The help text that will be shown when the user clicks the trigger
1065
1075
  */
1066
- word?: React.ReactNode;
1076
+ helpText: React.ReactNode;
1067
1077
  /**
1068
1078
  * The title of the help text. Used by screen readers and if the user hover over the help text
1069
1079
  */
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  AccordionComponent
3
- } from "../chunk-3FRCJ3RH.mjs";
4
- import {
5
- AccordionItem
6
- } from "../chunk-62F4I3MQ.mjs";
7
- import "../chunk-VRIY65P5.mjs";
3
+ } from "../chunk-XYIY6FHW.mjs";
8
4
  import {
9
5
  AccordionContent
10
6
  } from "../chunk-GUB3UCXO.mjs";
11
7
  import {
12
8
  AccordionHeader
13
9
  } from "../chunk-YXHXRUFX.mjs";
10
+ import {
11
+ AccordionItem
12
+ } from "../chunk-62F4I3MQ.mjs";
13
+ import "../chunk-VRIY65P5.mjs";
14
14
  import "../chunk-V3PAFMK5.mjs";
15
15
  import "../chunk-R4SQKVDQ.mjs";
16
16
  export {
@@ -4,7 +4,7 @@ import {
4
4
  FooterLinkSection,
5
5
  FooterLinkSections,
6
6
  FooterLogo
7
- } from "./chunk-BFNITN5E.mjs";
7
+ } from "./chunk-S3BGPCLK.mjs";
8
8
 
9
9
  // src/footer/index.tsx
10
10
  var FooterComponent = Footer;
@@ -16,4 +16,4 @@ FooterComponent.LinkSection = FooterLinkSection;
16
16
  export {
17
17
  FooterComponent
18
18
  };
19
- //# sourceMappingURL=chunk-CU56G5WS.mjs.map
19
+ //# sourceMappingURL=chunk-CSAEHQ4R.mjs.map
@@ -14,7 +14,7 @@ import { forwardRef } from "react";
14
14
  import { jsx, jsxs } from "react/jsx-runtime";
15
15
  var HelpText = forwardRef(
16
16
  (_a, ref) => {
17
- var _b = _a, { children, className, word, title, side = "top", align = "start", boxProps } = _b, rest = __objRest(_b, ["children", "className", "word", "title", "side", "align", "boxProps"]);
17
+ var _b = _a, { children, className, helpText, title, side = "top", align = "start", boxProps } = _b, rest = __objRest(_b, ["children", "className", "helpText", "title", "side", "align", "boxProps"]);
18
18
  return (
19
19
  // NOTE: Using radix's [Popover component](https://www.radix-ui.com/primitives/docs/components/popover)
20
20
  // In the future we can use the native popover api, but as of writing, though all browsers support it
@@ -29,7 +29,7 @@ var HelpText = forwardRef(
29
29
  title,
30
30
  type: "button"
31
31
  }, rest), {
32
- children: word
32
+ children
33
33
  })
34
34
  ) }),
35
35
  /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Content, { asChild: true, side, align, children: /* @__PURE__ */ jsxs(
@@ -38,7 +38,7 @@ var HelpText = forwardRef(
38
38
  className: clsx("hds-help-text-box", boxProps == null ? void 0 : boxProps.className),
39
39
  children: [
40
40
  /* @__PURE__ */ jsx(Popover.Close, { asChild: true, children: /* @__PURE__ */ jsx(BoxComponent.CloseButton, {}) }),
41
- children
41
+ helpText
42
42
  ]
43
43
  })
44
44
  ) }) })
@@ -51,4 +51,4 @@ HelpText.displayName = "HelpText";
51
51
  export {
52
52
  HelpText
53
53
  };
54
- //# sourceMappingURL=chunk-E5O6ID3L.mjs.map
54
+ //# sourceMappingURL=chunk-E2RTLHMZ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/help-text/help-text.tsx"],"sourcesContent":["import * as Popover from \"@radix-ui/react-popover\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Box } from \"../box\";\n\ninterface HelpTextProps extends React.HTMLAttributes<HTMLButtonElement> {\n className?: string;\n\n /**\n * The content of the help text, often a word or phrase that could use some explanation\n */\n children: React.ReactNode;\n\n /**\n * The help text that will be shown when the user clicks the trigger\n */\n helpText: React.ReactNode;\n\n /**\n * The title of the help text. Used by screen readers and if the user hover over the help text\n */\n title?: string;\n\n /**\n * Props for the `Box` that contains the help text\n */\n boxProps?: React.ComponentProps<typeof Box>;\n\n /**\n * The side of the trigger the popover should be attached to\n *\n * default is `top`\n */\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n\n /**\n * The alignment of the popover content\n *\n * default is `start`\n */\n align?: \"center\" | \"end\" | \"start\";\n}\n\n/**\n * Show a help text for a word or phrase when clicked\n *\n * Useful for providing explanations for domain-specific terms, acronyms or phrases that could do with further elaboration\n *\n * **Usage**\n * ```tsx\n * <p>\n * En annen avgjørende faktor for avgifter er om nettbutikken er registrert i{\" \"}\n * <HelpText helpText={`VOEC er en forkortelse for \"VAT on E-commerce\" (mva. på e-handel).`}>\n * VOEC\n * </HelpText>\n * </p>\n * ```\n */\nexport const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(\n (\n { children, className, helpText, title, side = \"top\", align = \"start\", boxProps, ...rest },\n ref,\n ) => {\n return (\n // NOTE: Using radix's [Popover component](https://www.radix-ui.com/primitives/docs/components/popover)\n // In the future we can use the native popover api, but as of writing, though all browsers support it\n // it's not far enough back to be used in production\n // https://caniuse.com/mdn-html_elements_input_popovertarget\n <Popover.Root>\n <Popover.Trigger asChild>\n <button\n ref={ref}\n className={clsx(\"hds-help-text-button\", className as undefined)}\n title={title}\n type=\"button\"\n {...rest}\n >\n {children}\n </button>\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Content asChild side={side} align={align}>\n <Box\n {...boxProps}\n className={clsx(\"hds-help-text-box\", boxProps?.className as undefined)}\n >\n <Popover.Close asChild>\n <Box.CloseButton />\n </Popover.Close>\n {helpText}\n </Box>\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n },\n);\nHelpText.displayName = \"HelpText\";\n"],"mappings":";;;;;;;;;;AAAA,YAAY,aAAa;AACzB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAoEjB,cAYE,YAZF;AAZH,IAAM,WAAW;AAAA,EACtB,CACE,IACA,QACG;AAFH,iBAAE,YAAU,WAAW,UAAU,OAAO,OAAO,OAAO,QAAQ,SAAS,SA5D3E,IA4DI,IAAoF,iBAApF,IAAoF,CAAlF,YAAU,aAAW,YAAU,SAAO,QAAc,SAAiB;AAGvE;AAAA;AAAA;AAAA;AAAA;AAAA,MAKE,qBAAS,cAAR,EACC;AAAA,4BAAS,iBAAR,EAAgB,SAAO,MACtB;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,WAAW,KAAK,wBAAwB,SAAsB;AAAA,YAC9D;AAAA,YACA,MAAK;AAAA,aACD,OALL;AAAA,YAOE;AAAA;AAAA,QACH,GACF;AAAA,QACA,oBAAS,gBAAR,EACC,8BAAS,iBAAR,EAAgB,SAAO,MAAC,MAAY,OACnC;AAAA,UAAC;AAAA,2CACK,WADL;AAAA,YAEC,WAAW,KAAK,qBAAqB,qCAAU,SAAsB;AAAA,YAErE;AAAA,kCAAS,eAAR,EAAc,SAAO,MACpB,8BAAC,aAAI,aAAJ,EAAgB,GACnB;AAAA,cACC;AAAA;AAAA;AAAA,QACH,GACF,GACF;AAAA,SACF;AAAA;AAAA,EAEJ;AACF;AACA,SAAS,cAAc;","names":[]}
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-BWFFP6BB.mjs";
7
7
  import {
8
8
  AccordionComponent
9
- } from "./chunk-3FRCJ3RH.mjs";
9
+ } from "./chunk-XYIY6FHW.mjs";
10
10
  import {
11
11
  __objRest,
12
12
  __spreadProps,
@@ -115,4 +115,4 @@ export {
115
115
  FooterLinkSections,
116
116
  FooterLinkSection
117
117
  };
118
- //# sourceMappingURL=chunk-BFNITN5E.mjs.map
118
+ //# sourceMappingURL=chunk-S3BGPCLK.mjs.map
@@ -1,15 +1,15 @@
1
- import {
2
- AccordionItem
3
- } from "./chunk-62F4I3MQ.mjs";
4
- import {
5
- Accordion
6
- } from "./chunk-VRIY65P5.mjs";
7
1
  import {
8
2
  AccordionContent
9
3
  } from "./chunk-GUB3UCXO.mjs";
10
4
  import {
11
5
  AccordionHeader
12
6
  } from "./chunk-YXHXRUFX.mjs";
7
+ import {
8
+ AccordionItem
9
+ } from "./chunk-62F4I3MQ.mjs";
10
+ import {
11
+ Accordion
12
+ } from "./chunk-VRIY65P5.mjs";
13
13
 
14
14
  // src/accordion/index.tsx
15
15
  var AccordionComponent = Accordion;
@@ -20,4 +20,4 @@ AccordionComponent.Content = AccordionContent;
20
20
  export {
21
21
  AccordionComponent
22
22
  };
23
- //# sourceMappingURL=chunk-3FRCJ3RH.mjs.map
23
+ //# sourceMappingURL=chunk-XYIY6FHW.mjs.map
@@ -4,16 +4,16 @@ import {
4
4
  FooterLinkSection,
5
5
  FooterLinkSections,
6
6
  FooterLogo
7
- } from "../chunk-BFNITN5E.mjs";
7
+ } from "../chunk-S3BGPCLK.mjs";
8
8
  import "../chunk-GJDRW6PA.mjs";
9
9
  import "../chunk-PMLDK3VC.mjs";
10
10
  import "../chunk-HT2EIJAD.mjs";
11
11
  import "../chunk-BWFFP6BB.mjs";
12
- import "../chunk-3FRCJ3RH.mjs";
13
- import "../chunk-62F4I3MQ.mjs";
14
- import "../chunk-VRIY65P5.mjs";
12
+ import "../chunk-XYIY6FHW.mjs";
15
13
  import "../chunk-GUB3UCXO.mjs";
16
14
  import "../chunk-YXHXRUFX.mjs";
15
+ import "../chunk-62F4I3MQ.mjs";
16
+ import "../chunk-VRIY65P5.mjs";
17
17
  import "../chunk-V3PAFMK5.mjs";
18
18
  import "../chunk-R4SQKVDQ.mjs";
19
19
  export {
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  FooterComponent
3
- } from "../chunk-CU56G5WS.mjs";
3
+ } from "../chunk-CSAEHQ4R.mjs";
4
4
  import {
5
5
  FooterButtonLink,
6
6
  FooterLinkSection,
7
7
  FooterLinkSections,
8
8
  FooterLogo
9
- } from "../chunk-BFNITN5E.mjs";
9
+ } from "../chunk-S3BGPCLK.mjs";
10
10
  import "../chunk-GJDRW6PA.mjs";
11
11
  import "../chunk-PMLDK3VC.mjs";
12
12
  import "../chunk-HT2EIJAD.mjs";
13
13
  import "../chunk-BWFFP6BB.mjs";
14
- import "../chunk-3FRCJ3RH.mjs";
15
- import "../chunk-62F4I3MQ.mjs";
16
- import "../chunk-VRIY65P5.mjs";
14
+ import "../chunk-XYIY6FHW.mjs";
17
15
  import "../chunk-GUB3UCXO.mjs";
18
16
  import "../chunk-YXHXRUFX.mjs";
17
+ import "../chunk-62F4I3MQ.mjs";
18
+ import "../chunk-VRIY65P5.mjs";
19
19
  import "../chunk-V3PAFMK5.mjs";
20
20
  import "../chunk-R4SQKVDQ.mjs";
21
21
  export {
@@ -146,7 +146,7 @@ BoxComponent.CloseButton = BoxCloseButton;
146
146
  var import_jsx_runtime2 = require("react/jsx-runtime");
147
147
  var HelpText = (0, import_react2.forwardRef)(
148
148
  (_a, ref) => {
149
- var _b = _a, { children, className, word, title, side = "top", align = "start", boxProps } = _b, rest = __objRest(_b, ["children", "className", "word", "title", "side", "align", "boxProps"]);
149
+ var _b = _a, { children, className, helpText, title, side = "top", align = "start", boxProps } = _b, rest = __objRest(_b, ["children", "className", "helpText", "title", "side", "align", "boxProps"]);
150
150
  return (
151
151
  // NOTE: Using radix's [Popover component](https://www.radix-ui.com/primitives/docs/components/popover)
152
152
  // In the future we can use the native popover api, but as of writing, though all browsers support it
@@ -161,7 +161,7 @@ var HelpText = (0, import_react2.forwardRef)(
161
161
  title,
162
162
  type: "button"
163
163
  }, rest), {
164
- children: word
164
+ children
165
165
  })
166
166
  ) }),
167
167
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Popover.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Popover.Content, { asChild: true, side, align, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
@@ -170,7 +170,7 @@ var HelpText = (0, import_react2.forwardRef)(
170
170
  className: (0, import_typed_classname2.clsx)("hds-help-text-box", boxProps == null ? void 0 : boxProps.className),
171
171
  children: [
172
172
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Popover.Close, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BoxComponent.CloseButton, {}) }),
173
- children
173
+ helpText
174
174
  ]
175
175
  })
176
176
  ) }) })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/help-text/help-text.tsx","../../src/box/box.tsx","../../src/box/index.tsx"],"sourcesContent":["import * as Popover from \"@radix-ui/react-popover\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Box } from \"../box\";\n\ninterface HelpTextProps extends React.HTMLAttributes<HTMLButtonElement> {\n className?: string;\n\n /**\n * The content of the help text\n */\n children: React.ReactNode;\n\n /**\n * The word that should be clickable to show the help text\n */\n word?: React.ReactNode;\n\n /**\n * The title of the help text. Used by screen readers and if the user hover over the help text\n */\n title?: string;\n\n /**\n * Props for the `Box` that contains the help text\n */\n boxProps?: React.ComponentProps<typeof Box>;\n\n /**\n * The side of the trigger the popover should be attached to\n *\n * default is `top`\n */\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n\n /**\n * The alignment of the popover content\n *\n * default is `start`\n */\n align?: \"center\" | \"end\" | \"start\";\n}\n\n/**\n * Show a help text for a word or phrase when clicked\n *\n * Useful for providing explanations for domain-specific terms or acronyms\n */\nexport const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(\n ({ children, className, word, title, side = \"top\", align = \"start\", boxProps, ...rest }, ref) => {\n return (\n // NOTE: Using radix's [Popover component](https://www.radix-ui.com/primitives/docs/components/popover)\n // In the future we can use the native popover api, but as of writing, though all browsers support it\n // it's not far enough back to be used in production\n // https://caniuse.com/mdn-html_elements_input_popovertarget\n <Popover.Root>\n <Popover.Trigger asChild>\n <button\n ref={ref}\n className={clsx(\"hds-help-text-button\", className as undefined)}\n title={title}\n type=\"button\"\n {...rest}\n >\n {word}\n </button>\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Content asChild side={side} align={align}>\n <Box\n {...boxProps}\n className={clsx(\"hds-help-text-box\", boxProps?.className as undefined)}\n >\n <Popover.Close asChild>\n <Box.CloseButton />\n </Popover.Close>\n {children}\n </Box>\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n },\n);\nHelpText.displayName = \"HelpText\";\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\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, BoxCloseButton };\n\nexport type * from \"./box\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAAyB;AACzB,IAAAA,0BAAqB;AACrB,IAAAC,gBAA2B;;;ACF3B,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,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AAiB;AAClE;AAAA;AAAA;AAAA;AAAA;AAAA,MAKE,8CAAS,cAAR,EACC;AAAA,qDAAS,iBAAR,EAAgB,SAAO,MACtB;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,eAAW,8BAAK,wBAAwB,SAAsB;AAAA,YAC9D;AAAA,YACA,MAAK;AAAA,aACD,OALL;AAAA,YAOE;AAAA;AAAA,QACH,GACF;AAAA,QACA,6CAAS,gBAAR,EACC,uDAAS,iBAAR,EAAgB,SAAO,MAAC,MAAY,OACnC;AAAA,UAAC;AAAA,2CACK,WADL;AAAA,YAEC,eAAW,8BAAK,qBAAqB,qCAAU,SAAsB;AAAA,YAErE;AAAA,2DAAS,eAAR,EAAc,SAAO,MACpB,uDAAC,aAAI,aAAJ,EAAgB,GACnB;AAAA,cACC;AAAA;AAAA;AAAA,QACH,GACF,GACF;AAAA,SACF;AAAA;AAAA,EAEJ;AACF;AACA,SAAS,cAAc;","names":["import_typed_classname","import_react","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../src/help-text/help-text.tsx","../../src/box/box.tsx","../../src/box/index.tsx"],"sourcesContent":["import * as Popover from \"@radix-ui/react-popover\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Box } from \"../box\";\n\ninterface HelpTextProps extends React.HTMLAttributes<HTMLButtonElement> {\n className?: string;\n\n /**\n * The content of the help text, often a word or phrase that could use some explanation\n */\n children: React.ReactNode;\n\n /**\n * The help text that will be shown when the user clicks the trigger\n */\n helpText: React.ReactNode;\n\n /**\n * The title of the help text. Used by screen readers and if the user hover over the help text\n */\n title?: string;\n\n /**\n * Props for the `Box` that contains the help text\n */\n boxProps?: React.ComponentProps<typeof Box>;\n\n /**\n * The side of the trigger the popover should be attached to\n *\n * default is `top`\n */\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n\n /**\n * The alignment of the popover content\n *\n * default is `start`\n */\n align?: \"center\" | \"end\" | \"start\";\n}\n\n/**\n * Show a help text for a word or phrase when clicked\n *\n * Useful for providing explanations for domain-specific terms, acronyms or phrases that could do with further elaboration\n *\n * **Usage**\n * ```tsx\n * <p>\n * En annen avgjørende faktor for avgifter er om nettbutikken er registrert i{\" \"}\n * <HelpText helpText={`VOEC er en forkortelse for \"VAT on E-commerce\" (mva. på e-handel).`}>\n * VOEC\n * </HelpText>\n * </p>\n * ```\n */\nexport const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(\n (\n { children, className, helpText, title, side = \"top\", align = \"start\", boxProps, ...rest },\n ref,\n ) => {\n return (\n // NOTE: Using radix's [Popover component](https://www.radix-ui.com/primitives/docs/components/popover)\n // In the future we can use the native popover api, but as of writing, though all browsers support it\n // it's not far enough back to be used in production\n // https://caniuse.com/mdn-html_elements_input_popovertarget\n <Popover.Root>\n <Popover.Trigger asChild>\n <button\n ref={ref}\n className={clsx(\"hds-help-text-button\", className as undefined)}\n title={title}\n type=\"button\"\n {...rest}\n >\n {children}\n </button>\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Content asChild side={side} align={align}>\n <Box\n {...boxProps}\n className={clsx(\"hds-help-text-box\", boxProps?.className as undefined)}\n >\n <Popover.Close asChild>\n <Box.CloseButton />\n </Popover.Close>\n {helpText}\n </Box>\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n },\n);\nHelpText.displayName = \"HelpText\";\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\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, BoxCloseButton };\n\nexport type * from \"./box\";\n"],"mapp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AA,QACC,eAAW,6BAAK,yBAAyB,SAAsB;AAAA,QAC/D;AAAA,QACA,MAAK;AAAA,SACD;AAAA,IACN;AAAA,EAEJ;AACF;AACA,eAAe,cAAc;;;ACjG7B,IAAM,eAAe;AAGrB,aAAa,cAAc;;;AFiEjB,IAAAC,sBAAA;AAZH,IAAM,eAAW;AAAA,EACtB,CACE,IACA,QACG;AAFH,iBAAE,YAAU,WAAW,UAAU,OAAO,OAAO,OAAO,QAAQ,SAAS,SA5D3E,IA4DI,IAAoF,iBAApF,IAAoF,CAAlF,YAAU,aAAW,YAAU,SAAO,QAAc,SAAiB;AAGvE;AAAA;AAAA;AAAA;AAAA;AAAA,MAKE,8CAAS,cAAR,EACC;AAAA,qDAAS,iBAAR,EAAgB,SAAO,MACtB;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,eAAW,8BAAK,wBAAwB,SAAsB;AAAA,YAC9D;AAAA,YACA,MAAK;AAAA,aACD,OALL;AAAA,YAOE;AAAA;AAAA,QACH,GACF;AAAA,QACA,6CAAS,gBAAR,EACC,uDAAS,iBAAR,EAAgB,SAAO,MAAC,MAAY,OACnC;AAAA,UAAC;AAAA,2CACK,WADL;AAAA,YAEC,eAAW,8BAAK,qBAAqB,qCAAU,SAAsB;AAAA,YAErE;AAAA,2DAAS,eAAR,EAAc,SAAO,MACpB,uDAAC,aAAI,aAAJ,EAAgB,GACnB;AAAA,cACC;AAAA;AAAA;AAAA,QACH,GACF,GACF;AAAA,SACF;AAAA;AAAA,EAEJ;AACF;AACA,SAAS,cAAc;","names":["import_typed_classname","import_react","import_jsx_runtime"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  HelpText
3
- } from "../chunk-E5O6ID3L.mjs";
3
+ } from "../chunk-E2RTLHMZ.mjs";
4
4
  import "../chunk-NMMFIRLZ.mjs";
5
5
  import "../chunk-EGXM575K.mjs";
6
6
  import "../chunk-R4SQKVDQ.mjs";
@@ -148,7 +148,7 @@ BoxComponent.CloseButton = BoxCloseButton;
148
148
  var import_jsx_runtime2 = require("react/jsx-runtime");
149
149
  var HelpText = (0, import_react2.forwardRef)(
150
150
  (_a, ref) => {
151
- var _b = _a, { children, className, word, title, side = "top", align = "start", boxProps } = _b, rest = __objRest(_b, ["children", "className", "word", "title", "side", "align", "boxProps"]);
151
+ var _b = _a, { children, className, helpText, title, side = "top", align = "start", boxProps } = _b, rest = __objRest(_b, ["children", "className", "helpText", "title", "side", "align", "boxProps"]);
152
152
  return (
153
153
  // NOTE: Using radix's [Popover component](https://www.radix-ui.com/primitives/docs/components/popover)
154
154
  // In the future we can use the native popover api, but as of writing, though all browsers support it
@@ -163,7 +163,7 @@ var HelpText = (0, import_react2.forwardRef)(
163
163
  title,
164
164
  type: "button"
165
165
  }, rest), {
166
- children: word
166
+ children
167
167
  })
168
168
  ) }),
169
169
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Popover.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Popover.Content, { asChild: true, side, align, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
@@ -172,7 +172,7 @@ var HelpText = (0, import_react2.forwardRef)(
172
172
  className: (0, import_typed_classname2.clsx)("hds-help-text-box", boxProps == null ? void 0 : boxProps.className),
173
173
  children: [
174
174
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Popover.Close, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BoxComponent.CloseButton, {}) }),
175
- children
175
+ helpText
176
176
  ]
177
177
  })
178
178
  ) }) })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/help-text/index.ts","../../src/help-text/help-text.tsx","../../src/box/box.tsx","../../src/box/index.tsx"],"sourcesContent":["export { HelpText } from \"./help-text\";\nexport type * from \"./help-text\";\n","import * as Popover from \"@radix-ui/react-popover\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Box } from \"../box\";\n\ninterface HelpTextProps extends React.HTMLAttributes<HTMLButtonElement> {\n className?: string;\n\n /**\n * The content of the help text\n */\n children: React.ReactNode;\n\n /**\n * The word that should be clickable to show the help text\n */\n word?: React.ReactNode;\n\n /**\n * The title of the help text. Used by screen readers and if the user hover over the help text\n */\n title?: string;\n\n /**\n * Props for the `Box` that contains the help text\n */\n boxProps?: React.ComponentProps<typeof Box>;\n\n /**\n * The side of the trigger the popover should be attached to\n *\n * default is `top`\n */\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n\n /**\n * The alignment of the popover content\n *\n * default is `start`\n */\n align?: \"center\" | \"end\" | \"start\";\n}\n\n/**\n * Show a help text for a word or phrase when clicked\n *\n * Useful for providing explanations for domain-specific terms or acronyms\n */\nexport const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(\n ({ children, className, word, title, side = \"top\", align = \"start\", boxProps, ...rest }, ref) => {\n return (\n // NOTE: Using radix's [Popover component](https://www.radix-ui.com/primitives/docs/components/popover)\n // In the future we can use the native popover api, but as of writing, though all browsers support it\n // it's not far enough back to be used in production\n // https://caniuse.com/mdn-html_elements_input_popovertarget\n <Popover.Root>\n <Popover.Trigger asChild>\n <button\n ref={ref}\n className={clsx(\"hds-help-text-button\", className as undefined)}\n title={title}\n type=\"button\"\n {...rest}\n >\n {word}\n </button>\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Content asChild side={side} align={align}>\n <Box\n {...boxProps}\n className={clsx(\"hds-help-text-box\", boxProps?.className as undefined)}\n >\n <Popover.Close asChild>\n <Box.CloseButton />\n </Popover.Close>\n {children}\n </Box>\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n },\n);\nHelpText.displayName = \"HelpText\";\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\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, BoxCloseButton };\n\nexport type * from \"./box\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,cAAyB;AACzB,IAAAA,0BAAqB;AACrB,IAAAC,gBAA2B;;;ACF3B,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,CAAC,CAAC;AACL,UAAM,SAAS,kCAAc;AAE7B,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW;AAAA,UACT;AAAA,UACA,WAAW,YAAY,OAAO;AAAA,UAC9B,EAAE,mBAAmB,OAAO;AAAA,UAC5B;AAAA,QACF;AAAA,QACA;AAAA,SACI,OARL;AAAA,QAUE;AAAA,sBAAY,4CAAC,iCAAe,SAAS,WAAa,iBAAkB,IAAK;AAAA,UACzE;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,IAAI,cAAc;AAGX,IAAM,qBAAiB;AAAA,EAC5B,CAAC,IAAwB,QAAQ;AAAhC,iBAAE,YAxFL,IAwFG,IAAgB,iBAAhB,IAAgB,CAAd;AACD,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,6BAAK,yBAAyB,SAAsB;AAAA,QAC/D;AAAA,QACA,MAAK;AAAA,SACD;AAAA,IACN;AAAA,EAEJ;AACF;AACA,eAAe,cAAc;;;ACjG7B,IAAM,eAAe;AAGrB,aAAa,cAAc;;;AFoDjB,IAAAC,sBAAA;AATH,IAAM,eAAW;AAAA,EACtB,CAAC,IAAwF,QAAQ;AAAhG,iBAAE,YAAU,WAAW,MAAM,OAAO,OAAO,OAAO,QAAQ,SAAS,SAjDtE,IAiDG,IAAgF,iBAAhF,IAAgF,CAA9E,YAAU,aAAW,QAAM,SAAO,QAAc,SAAiB;AAClE;AAAA;AAAA;AAAA;AAAA;AAAA,MAKE,8CAAS,cAAR,EACC;AAAA,qDAAS,iBAAR,EAAgB,SAAO,MACtB;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,eAAW,8BAAK,wBAAwB,SAAsB;AAAA,YAC9D;AAAA,YACA,MAAK;AAAA,aACD,OALL;AAAA,YAOE;AAAA;AAAA,QACH,GACF;AAAA,QACA,6CAAS,gBAAR,EACC,uDAAS,iBAAR,EAAgB,SAAO,MAAC,MAAY,OACnC;AAAA,UAAC;AAAA,2CACK,WADL;AAAA,YAEC,eAAW,8BAAK,qBAAqB,qCAAU,SAAsB;AAAA,YAErE;AAAA,2DAAS,eAAR,EAAc,SAAO,MACpB,uDAAC,aAAI,aAAJ,EAAgB,GACnB;AAAA,cACC;AAAA;AAAA;AAAA,QACH,GACF,GACF;AAAA,SACF;AAAA;AAAA,EAEJ;AACF;AACA,SAAS,cAAc;","names":["import_typed_classname","import_react","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../src/help-text/index.ts","../../src/help-text/help-text.tsx","../../src/box/box.tsx","../../src/box/index.tsx"],"sourcesContent":["export { HelpText } from \"./help-text\";\nexport type * from \"./help-text\";\n","import * as Popover from \"@radix-ui/react-popover\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Box } from \"../box\";\n\ninterface HelpTextProps extends React.HTMLAttributes<HTMLButtonElement> {\n className?: string;\n\n /**\n * The content of the help text, often a word or phrase that could use some explanation\n */\n children: React.ReactNode;\n\n /**\n * The help text that will be shown when the user clicks the trigger\n */\n helpText: React.ReactNode;\n\n /**\n * The title of the help text. Used by screen readers and if the user hover over the help text\n */\n title?: string;\n\n /**\n * Props for the `Box` that contains the help text\n */\n boxProps?: React.ComponentProps<typeof Box>;\n\n /**\n * The side of the trigger the popover should be attached to\n *\n * default is `top`\n */\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n\n /**\n * The alignment of the popover content\n *\n * default is `start`\n */\n align?: \"center\" | \"end\" | \"start\";\n}\n\n/**\n * Show a help text for a word or phrase when clicked\n *\n * Useful for providing explanations for domain-specific terms, acronyms or phrases that could do with further elaboration\n *\n * **Usage**\n * ```tsx\n * <p>\n * En annen avgjørende faktor for avgifter er om nettbutikken er registrert i{\" \"}\n * <HelpText helpText={`VOEC er en forkortelse for \"VAT on E-commerce\" (mva. på e-handel).`}>\n * VOEC\n * </HelpText>\n * </p>\n * ```\n */\nexport const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(\n (\n { children, className, helpText, title, side = \"top\", align = \"start\", boxProps, ...rest },\n ref,\n ) => {\n return (\n // NOTE: Using radix's [Popover component](https://www.radix-ui.com/primitives/docs/components/popover)\n // In the future we can use the native popover api, but as of writing, though all browsers support it\n // it's not far enough back to be used in production\n // https://caniuse.com/mdn-html_elements_input_popovertarget\n <Popover.Root>\n <Popover.Trigger asChild>\n <button\n ref={ref}\n className={clsx(\"hds-help-text-button\", className as undefined)}\n title={title}\n type=\"button\"\n {...rest}\n >\n {children}\n </button>\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Content asChild side={side} align={align}>\n <Box\n {...boxProps}\n className={clsx(\"hds-help-text-box\", boxProps?.className as undefined)}\n >\n <Popover.Close asChild>\n <Box.CloseButton />\n </Popover.Close>\n {helpText}\n </Box>\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n },\n);\nHelpText.displayName = \"HelpText\";\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\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, BoxCloseButton };\n\nexport type * from \"./box\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,cAAyB;AACzB,IAAAA,0BAAqB;AACrB,IAAAC,gBAA2B;;;ACF3B,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,c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AAA;AAAA,QACH,GACF;AAAA,QACA,6CAAS,gBAAR,EACC,uDAAS,iBAAR,EAAgB,SAAO,MAAC,MAAY,OACnC;AAAA,UAAC;AAAA,2CACK,WADL;AAAA,YAEC,eAAW,8BAAK,qBAAqB,qCAAU,SAAsB;AAAA,YAErE;AAAA,2DAAS,eAAR,EAAc,SAAO,MACpB,uDAAC,aAAI,aAAJ,EAAgB,GACnB;AAAA,cACC;AAAA;AAAA;AAAA,QACH,GACF,GACF;AAAA,SACF;AAAA;AAAA,EAEJ;AACF;AACA,SAAS,cAAc;","names":["import_typed_classname","import_react","import_jsx_runtime"]}
@@ -1,7 +1,7 @@
1
1
  import "../chunk-CFAH2LID.mjs";
2
2
  import {
3
3
  HelpText
4
- } from "../chunk-E5O6ID3L.mjs";
4
+ } from "../chunk-E2RTLHMZ.mjs";
5
5
  import "../chunk-NMMFIRLZ.mjs";
6
6
  import "../chunk-EGXM575K.mjs";
7
7
  import "../chunk-R4SQKVDQ.mjs";
@@ -1293,7 +1293,7 @@ var import_react22 = require("react");
1293
1293
  var import_jsx_runtime24 = require("react/jsx-runtime");
1294
1294
  var HelpText = (0, import_react22.forwardRef)(
1295
1295
  (_a, ref) => {
1296
- var _b = _a, { children, className, word, title, side = "top", align = "start", boxProps } = _b, rest = __objRest(_b, ["children", "className", "word", "title", "side", "align", "boxProps"]);
1296
+ var _b = _a, { children, className, helpText, title, side = "top", align = "start", boxProps } = _b, rest = __objRest(_b, ["children", "className", "helpText", "title", "side", "align", "boxProps"]);
1297
1297
  return (
1298
1298
  // NOTE: Using radix's [Popover component](https://www.radix-ui.com/primitives/docs/components/popover)
1299
1299
  // In the future we can use the native popover api, but as of writing, though all browsers support it
@@ -1308,7 +1308,7 @@ var HelpText = (0, import_react22.forwardRef)(
1308
1308
  title,
1309
1309
  type: "button"
1310
1310
  }, rest), {
1311
- children: word
1311
+ children
1312
1312
  })
1313
1313
  ) }),
1314
1314
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Popover.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Popover.Content, { asChild: true, side, align, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
@@ -1317,7 +1317,7 @@ var HelpText = (0, import_react22.forwardRef)(
1317
1317
  className: (0, import_typed_classname23.clsx)("hds-help-text-box", boxProps == null ? void 0 : boxProps.className),
1318
1318
  children: [
1319
1319
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Popover.Close, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(BoxComponent.CloseButton, {}) }),
1320
- children
1320
+ helpText
1321
1321
  ]
1322
1322
  })
1323
1323
  ) }) })