@postenbring/hedwig-react 1.5.0 → 2.1.0
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/button/button.d.ts +13 -7
- package/dist/button/button.d.ts.map +1 -1
- package/dist/button/button.js +5 -3
- package/dist/button/button.js.map +1 -1
- package/dist/button/button.mjs +1 -1
- package/dist/button/index.js +5 -3
- package/dist/button/index.js.map +1 -1
- package/dist/button/index.mjs +1 -1
- package/dist/button-list/button-list.d.ts +19 -0
- package/dist/button-list/button-list.d.ts.map +1 -0
- package/dist/button-list/button-list.js +78 -0
- package/dist/button-list/button-list.js.map +1 -0
- package/dist/button-list/button-list.mjs +8 -0
- package/dist/button-list/button-list.mjs.map +1 -0
- package/dist/button-list/index.d.ts +3 -0
- package/dist/button-list/index.d.ts.map +1 -0
- package/dist/button-list/index.js +80 -0
- package/dist/button-list/index.js.map +1 -0
- package/dist/button-list/index.mjs +9 -0
- package/dist/button-list/index.mjs.map +1 -0
- package/dist/card/card.d.ts +10 -0
- package/dist/card/card.d.ts.map +1 -1
- package/dist/card/card.js +6 -2
- package/dist/card/card.js.map +1 -1
- package/dist/card/card.mjs +1 -1
- package/dist/card/index.js +6 -2
- package/dist/card/index.js.map +1 -1
- package/dist/card/index.mjs +1 -1
- package/dist/{chunk-6DWIJEHQ.mjs → chunk-444SCBJD.mjs} +3 -3
- package/dist/chunk-444SCBJD.mjs.map +1 -0
- package/dist/{chunk-FUIKSOJF.mjs → chunk-6SVLMQUW.mjs} +4 -4
- package/dist/{chunk-BQR4ZRFT.mjs → chunk-CFAPQFEC.mjs} +5 -5
- package/dist/{chunk-6VKQ6IRG.mjs → chunk-GXIKHXWC.mjs} +1 -1
- package/dist/chunk-GXIKHXWC.mjs.map +1 -0
- package/dist/{chunk-NE6PE5W7.mjs → chunk-LDZIJR2D.mjs} +7 -3
- package/dist/chunk-LDZIJR2D.mjs.map +1 -0
- package/dist/chunk-ME746XCZ.mjs +31 -0
- package/dist/chunk-ME746XCZ.mjs.map +1 -0
- package/dist/{chunk-V5X3ZS23.mjs → chunk-OHDHIRAW.mjs} +5 -3
- package/dist/chunk-OHDHIRAW.mjs.map +1 -0
- package/dist/{chunk-AYCHNAU7.mjs → chunk-TYCGAA35.mjs} +6 -4
- package/dist/chunk-TYCGAA35.mjs.map +1 -0
- package/dist/chunk-Y6NOEN7R.mjs +1 -0
- package/dist/chunk-Y6NOEN7R.mjs.map +1 -0
- package/dist/{chunk-TC5PD4TA.mjs → chunk-YQMTDQSQ.mjs} +4 -4
- package/dist/footer/footer.js +6 -4
- package/dist/footer/footer.js.map +1 -1
- package/dist/footer/footer.mjs +2 -2
- package/dist/footer/index.js +6 -4
- package/dist/footer/index.js.map +1 -1
- package/dist/footer/index.mjs +2 -2
- package/dist/form/error-summary/error-summary.js +4 -2
- package/dist/form/error-summary/error-summary.js.map +1 -1
- package/dist/form/error-summary/error-summary.mjs +4 -4
- package/dist/form/error-summary/index.js +4 -2
- package/dist/form/error-summary/index.js.map +1 -1
- package/dist/form/error-summary/index.mjs +4 -4
- package/dist/form/index.js +4 -2
- package/dist/form/index.js.map +1 -1
- package/dist/form/index.mjs +18 -18
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +475 -444
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -59
- package/dist/layout/grid/grid.mjs +2 -2
- package/dist/layout/grid/index.mjs +2 -2
- package/dist/layout/index.mjs +3 -3
- package/dist/layout/stack/index.mjs +2 -2
- package/dist/layout/stack/stack.mjs +2 -2
- package/dist/link/index.js +4 -2
- package/dist/link/index.js.map +1 -1
- package/dist/link/index.mjs +1 -1
- package/dist/link/link.d.ts +9 -3
- package/dist/link/link.d.ts.map +1 -1
- package/dist/link/link.js +4 -2
- package/dist/link/link.js.map +1 -1
- package/dist/link/link.mjs +1 -1
- package/dist/modal/index.js.map +1 -1
- package/dist/modal/index.mjs +1 -1
- package/dist/modal/modal.d.ts +1 -1
- package/dist/modal/modal.js.map +1 -1
- package/dist/modal/modal.mjs +1 -1
- package/package.json +6 -6
- package/src/button/button.tsx +19 -10
- package/src/button-list/button-list.stories.tsx +27 -0
- package/src/button-list/button-list.tsx +37 -0
- package/src/button-list/index.tsx +3 -0
- package/src/card/card.tsx +16 -2
- package/src/footer/footer.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/link/link.tsx +18 -5
- package/src/modal/modal.stories.tsx +1 -1
- package/src/modal/modal.tsx +1 -1
- package/dist/chunk-6DWIJEHQ.mjs.map +0 -1
- package/dist/chunk-6VKQ6IRG.mjs.map +0 -1
- package/dist/chunk-AYCHNAU7.mjs.map +0 -1
- package/dist/chunk-NE6PE5W7.mjs.map +0 -1
- package/dist/chunk-V5X3ZS23.mjs.map +0 -1
- /package/dist/{chunk-FUIKSOJF.mjs.map → chunk-6SVLMQUW.mjs.map} +0 -0
- /package/dist/{chunk-BQR4ZRFT.mjs.map → chunk-CFAPQFEC.mjs.map} +0 -0
- /package/dist/{chunk-TC5PD4TA.mjs.map → chunk-YQMTDQSQ.mjs.map} +0 -0
package/dist/footer/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/footer/index.tsx","../../src/footer/footer.tsx","../../src/accordion/accordion.tsx","../../src/accordion/accordion-item.tsx","../../src/accordion/context.ts","../../src/accordion/accordion-header.tsx","../../src/accordion/accordion-content.tsx","../../src/list/link-list.tsx","../../src/list/list.tsx","../../src/button/button.tsx"],"sourcesContent":["export {\n Footer,\n FooterLogo,\n FooterButtonLink,\n FooterLinkSections,\n FooterLinkSection,\n} from \"./footer\";\n\nexport type * from \"./footer\";\n","import { forwardRef, type HTMLAttributes, type ReactElement } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Accordion } from \"../accordion\";\nimport { LinkList } from \"../list/link-list\";\nimport { Button } from \"../button\";\n\ninterface FooterLogoProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * A fixed Posten or Bring logo.\n *\n * The logo follows the brand theme, so if the class `hds-theme-bring` is set the Bring logo will be shown instead of the Posten logo\n */\nexport const FooterLogo = forwardRef<HTMLDivElement, FooterLogoProps>(\n ({ children, className, asChild, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component className={clsx(`hds-footer__logo`, className as undefined)} ref={ref} {...rest}>\n {children}\n </Component>\n );\n },\n);\nFooterLogo.displayName = \"Footer.Logo\";\n\nexport interface FooterButtonLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n */\nexport const FooterButtonLink = forwardRef<HTMLAnchorElement, FooterButtonLinkProps>(\n ({ children, className, asChild, ...rest }, ref) => {\n const Component = asChild ? Slot : \"a\";\n return (\n <Button asChild variant=\"primary-outline\" className={clsx(className as undefined)}>\n <Component ref={ref} {...rest}>\n {children}\n </Component>\n </Button>\n );\n },\n);\nFooterButtonLink.displayName = \"FooterButton\";\n\ninterface FooterLinkSectionsProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<FooterLinkSectionProps> | ReactElement<FooterLinkSectionProps>[];\n}\n\n/**\n * Responsive sections of links. Will become an accordion on mobile.\n *\n * Use with {@link FooterLinkSection} for each section.\n */\nexport const FooterLinkSections = forwardRef<HTMLDivElement, FooterLinkSectionsProps>(\n ({ children, className, ...rest }, ref) => {\n return (\n <>\n {/* Mobile and Desktop. The accordion styling gets removed on desktop */}\n <Accordion\n className={clsx(\"hds-footer__link-sections\", className as undefined)}\n ref={ref}\n {...rest}\n >\n {/* @ts-expect-error -- It's ok */}\n {children}\n </Accordion>\n </>\n );\n },\n);\nFooterLinkSections.displayName = \"Footer.LinkSections\";\n\ninterface FooterLinkSectionProps extends HTMLAttributes<HTMLDivElement> {\n heading: React.ReactNode;\n children: React.ReactNode;\n}\n\nexport const FooterLinkSection = forwardRef<HTMLDivElement, FooterLinkSectionProps>(\n ({ heading, children, className, ...rest }, ref) => {\n // @ts-expect-error -- It's ok\n const linkListChildren = <LinkList>{children}</LinkList>;\n return (\n <>\n {/* Mobile */}\n <Accordion.Item\n className={clsx(`hds-footer__link-section`, className as undefined)}\n ref={ref}\n {...rest}\n >\n <Accordion.Header>{heading}</Accordion.Header>\n <Accordion.Content>{linkListChildren}</Accordion.Content>\n </Accordion.Item>\n\n {/* Desktop */}\n <div className={clsx(`hds-footer__link-section`, className as undefined)}>\n <h2>{heading}</h2>\n {linkListChildren}\n </div>\n </>\n );\n },\n);\nFooterLinkSection.displayName = \"Footer.LinkSection\";\n\nexport interface FooterProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Footer variant\n *\n * @default \"default\"\n */\n variant?: \"default\" | \"slim\";\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n */\nexport const Footer = forwardRef<HTMLDivElement, FooterProps>(\n ({ children, className, variant, asChild, ...rest }, ref) => {\n const Component = asChild ? Slot : \"footer\";\n return (\n <Component\n className={clsx(\n `hds-footer`,\n variant === \"slim\" && \"hds-footer--slim\",\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n) as FooterType;\nFooter.displayName = \"Footer\";\n\ntype FooterType = ReturnType<typeof forwardRef<HTMLDivElement, FooterProps>> & {\n Logo: typeof FooterLogo;\n ButtonLink: typeof FooterButtonLink;\n LinkSections: typeof FooterLinkSections;\n LinkSection: typeof FooterLinkSection;\n};\n\nFooter.Logo = FooterLogo;\nFooter.ButtonLink = FooterButtonLink;\nFooter.LinkSections = FooterLinkSections;\nFooter.LinkSection = FooterLinkSection;\n","import type { ReactElement } from \"react\";\nimport { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { AccordionItem, type AccordionItemProps } from \"./accordion-item\";\nimport { AccordionHeader } from \"./accordion-header\";\nimport { AccordionContent } from \"./accordion-content\";\n\nexport interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Accepts type of <AccordionItem/>\n */\n children: ReactElement<AccordionItemProps> | ReactElement<AccordionItemProps>[];\n\n /**\n * Adds padding to the left of the accordion\n */\n indent?: boolean;\n}\n\n/**\n * Displays collapsible content sections\n *\n * @example\n * ```tsx\n * <Accordion>\n * <Accordion.Item defaultOpen>\n * <Accordion.Header>Item one</Accordion.Header>\n * <Accordion.Content>\n * Some content\n * </Accordion.Content>\n * </Accordion.Item>\n * <Accordion.Item>\n * <Accordion.Header>Item two</Accordion.Header>\n * <Accordion.Content>\n * Some more content\n * </Accordion.Content>\n * </Accordion.Item>\n * </Accordion>\n * ```\n */\nexport const Accordion = forwardRef<HTMLDivElement, AccordionProps>(\n ({ children, className, indent = true, ...rest }, ref) => {\n return (\n <div\n {...rest}\n className={clsx(\n \"hds-accordion\",\n !indent && \"hds-accordion--no-indent\",\n className as undefined,\n )}\n ref={ref}\n >\n {children}\n </div>\n );\n },\n) as AccordionType;\nAccordion.displayName = \"Accordion\";\n\nAccordion.Item = AccordionItem;\nAccordion.Header = AccordionHeader;\nAccordion.Content = AccordionContent;\n\ntype AccordionType = ReturnType<typeof forwardRef<HTMLDivElement, AccordionProps>> & {\n Item: typeof AccordionItem;\n Header: typeof AccordionHeader;\n Content: typeof AccordionContent;\n};\n","import type { ReactElement } from \"react\";\nimport { forwardRef, useId, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { AccordionItemContext } from \"./context\";\nimport type { AccordionHeaderProps } from \"./accordion-header\";\nimport type { AccordionContentProps } from \"./accordion-content\";\n\nexport type AccordionItemChildrenType =\n | ReactElement<AccordionHeaderProps>\n | ReactElement<AccordionContentProps>;\n\nexport interface AccordionItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Control the open state of the accordion manually\n */\n open?: boolean;\n\n /**\n * Use with open to control the open state of the accordion manually\n */\n onOpenChange?: (open: boolean) => void;\n\n /**\n * If the accordion should be open by default\n */\n defaultOpen?: boolean;\n\n /**\n * Accepts type of Accordion.Content and Accordion.Header\n */\n children: AccordionItemChildrenType[];\n}\n\nexport const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(\n ({ children, defaultOpen, open: outerOpen, onOpenChange, className, ...rest }, ref) => {\n const contentId = useId();\n const [innerOpen, setInnerOpen] = useState(defaultOpen ?? false);\n const open = outerOpen ?? innerOpen;\n\n const handleOpen = () => {\n if (outerOpen !== undefined) {\n onOpenChange && onOpenChange(!open);\n } else {\n setInnerOpen(!open);\n }\n };\n\n return (\n <div\n {...rest}\n data-state={open ? \"open\" : \"closed\"}\n className={clsx(\"hds-accordion-item\", className as undefined)}\n ref={ref}\n >\n <AccordionItemContext.Provider value={{ contentId, open, setOpen: handleOpen }}>\n {children}\n </AccordionItemContext.Provider>\n </div>\n );\n },\n);\n\nAccordionItem.displayName = \"Accordion.Item\";\n","import { createContext } from \"react\";\n\nexport interface AccordionItemContextProps {\n open: boolean;\n setOpen: (open: boolean) => void;\n contentId: string;\n}\n\nexport const AccordionItemContext = createContext<AccordionItemContextProps | null>(null);\n","import type { MouseEvent, ReactNode } from \"react\";\nimport { forwardRef, useContext } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { AccordionItemContext } from \"./context\";\n\nexport interface AccordionHeaderProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n children: ReactNode;\n}\n\nexport const AccordionHeader = forwardRef<HTMLButtonElement, AccordionHeaderProps>(\n ({ children, className, onClick, ...rest }, ref) => {\n const context = useContext(AccordionItemContext);\n if (context === null) {\n return null;\n }\n const expandOrCollapse = (e: MouseEvent<HTMLButtonElement>) => {\n context.setOpen(!context.open);\n onClick?.(e);\n };\n return (\n <button\n {...rest}\n aria-expanded={context.open}\n aria-controls={context.contentId}\n data-state={context.open ? \"open\" : \"closed\"}\n className={clsx(\"hds-accordion-item-header\", className as undefined)}\n onClick={expandOrCollapse}\n ref={ref}\n type=\"button\"\n >\n <span>{children}</span>\n </button>\n );\n },\n);\n\nAccordionHeader.displayName = \"Accordion.Header\";\n","import type { ReactNode } from \"react\";\nimport { forwardRef, useContext } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { AccordionItemContext } from \"./context\";\n\nexport interface AccordionContentProps extends React.HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n}\n\nexport const AccordionContent = forwardRef<HTMLDivElement, AccordionContentProps>(\n ({ children, className, ...rest }, ref) => {\n const context = useContext(AccordionItemContext);\n if (context === null) {\n return null;\n }\n return (\n <div\n id={context.contentId}\n data-state={context.open ? \"open\" : \"closed\"}\n {...{ inert: context.open ? undefined : \"true\" }}\n className={clsx(\"hds-accordion-item-content\", className as undefined)}\n ref={ref}\n {...rest}\n >\n <div className={clsx(\"hds-accordion-item-content-inner\")}>{children}</div>\n </div>\n );\n },\n);\n\nAccordionContent.displayName = \"Accordion.Content\";\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport type { ListProps } from \"./list\";\nimport { UnorderedList } from \"./list\";\n\nexport interface LinkListProps extends Omit<ListProps, \"listStyle\"> {\n children?: React.ReactElement<HTMLLIElement> | React.ReactElement<HTMLLIElement>[];\n}\n\n/**\n * Show a list of links\n *\n * For other list types use `UnorderedList` and `OrderedList`, or use your own list component using the semantic `ul` and `ol` tags.\n */\nexport const LinkList = forwardRef<HTMLUListElement, LinkListProps>(\n ({ className, ...rest }, ref) => {\n return (\n <UnorderedList\n ref={ref}\n className={clsx(\"hds-list--link-list\", className as undefined)}\n {...rest}\n />\n );\n },\n);\nLinkList.displayName = \"LinkList\";\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\nexport interface ListProps extends HTMLAttributes<HTMLOListElement | HTMLUListElement> {\n /**\n * Sets the size of the items (font)\n *\n * @default \"medium\"\n */\n size?: \"small\" | \"medium\" | \"large\";\n}\n\n/**\n * An unordered list of simple items, often text. You can nest other lists inside this component.\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <UnorderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </UnorderedList>\n * ```\n */\nexport const UnorderedList = forwardRef<HTMLUListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ul\n ref={ref}\n className={clsx(\"hds-list\", `hds-list--${size}`, className as undefined)}\n {...rest}\n />\n );\n },\n);\nUnorderedList.displayName = \"UnorderedList\";\n\n/**\n * An ordered list of simple items\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <OrderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </OrderedList>\n * ```\n */\nexport const OrderedList = forwardRef<HTMLOListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ol\n ref={ref}\n className={clsx(\"hds-list\", `hds-list--${size}`, className as undefined)}\n {...rest}\n />\n );\n },\n);\nOrderedList.displayName = \"OrderedList\";\n","import { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * The height, font size and padding of the button\n */\n size?: \"small\" | \"medium\" | \"large\";\n\n /**\n * The background and fill of the button\n *\n * @default \"primary\"\n */\n variant?: \"primary\" | \"secondary\" | \"primary-outline\" | \"secondary-outline\";\n\n /**\n * Make the button use 100% width available.\n * Using the \"mobile\" it only stretch to full width on smaller screens\n */\n fullWidth?: boolean | \"mobile\";\n\n /**\n * Use the button as an icon button\n *\n * Render the icon in `children`\n */\n icon?: boolean;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * Button component\n *\n * @example\n * <Button variant=\"primary\">Primary</Button>\n * <Button variant=\"secondary\" size=\"large\">Secondary</Button>\n * <Button variant=\"primary-outline\">Primary Outline</Button>\n * <Button variant=\"secondary-outline\" fullWidth=\"mobile\">Secondary Outline</Button>\n *\n * @example\n * // If used for navigation use the `asChild` prop with a anchor element as a child.\n * <Button asChild><a href=\"/home\">Home</a></Button>\n */\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n asChild,\n children,\n variant = \"primary\",\n size = \"medium\",\n fullWidth = false,\n icon,\n className,\n ...rest\n },\n ref,\n ) => {\n const Component = asChild ? Slot : \"button\";\n return (\n <Component\n className={clsx(\n \"hds-button\",\n `hds-button--${size}`,\n `hds-button--${variant}`,\n {\n \"hds-button--full\": fullWidth === true,\n \"hds-button--mobile-full\": fullWidth === \"mobile\",\n \"hds-button--icon-only\": icon,\n },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nButton.displayName = \"Button\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAmE;AACnE,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;;;ACDrB,IAAAC,gBAA2B;AAC3B,IAAAC,0BAAqB;;;ACDrB,IAAAC,gBAA4C;AAC5C,6BAAqB;;;ACFrB,mBAA8B;AAQvB,IAAM,2BAAuB,4BAAgD,IAAI;;;AD8ChF;AArBD,IAAM,oBAAgB;AAAA,EAC3B,CAAC,IAA8E,QAAQ;AAAtF,iBAAE,YAAU,aAAa,MAAM,WAAW,cAAc,UAlC3D,IA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AAQ;AAAnD,iBAAE,WAAS,UAAU,UA7FxB,IA6FG,IAAmC,iBAAnC,IAAmC,CAAjC,WAAS,YAAU;AAEpB,UAAM,mBAAmB,6CAAC,YAAU,UAAS;AAC7C,WACE,8EAEE;AAAA;AAAA,QAAC,UAAU;AAAA,QAAV;AAAA,UACC,eAAW,8BAAK,4BAA4B,SAAsB;AAAA,UAClE;AAAA,WACI,OAHL;AAAA,UAKC;AAAA,yDAAC,UAAU,QAAV,EAAkB,mBAAQ;AAAA,YAC3B,6CAAC,UAAU,SAAV,EAAmB,4BAAiB;AAAA;AAAA;AAAA,MACvC;AAAA,MAGA,8CAAC,SAAI,eAAW,8BAAK,4BAA4B,SAAsB,GACrE;AAAA,qDAAC,QAAI,mBAAQ;AAAA,QACZ;AAAA,SACH;AAAA,OACF;AAAA,EAEJ;AACF;AACA,kBAAkB,cAAc;AAqBzB,IAAM,aAAS;AAAA,EACpB,CAAC,IAAoD,QAAQ;AAA5D,iBAAE,YAAU,WAAW,SAAS,QA3InC,IA2IG,IAA4C,iBAA5C,IAA4C,CAA1C,YAAU,aAAW,WAAS;AAC/B,UAAM,YAAY,UAAU,0BAAO;AACnC,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW;AAAA,UACT;AAAA,UACA,YAAY,UAAU;AAAA,UACtB;AAAA,QACF;AAAA,QACA;AAAA,SACI,OAPL;AAAA,QASE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,OAAO,cAAc;AASrB,OAAO,OAAO;AACd,OAAO,aAAa;AACpB,OAAO,eAAe;AACtB,OAAO,cAAc;","names":["import_react","import_typed_classname","import_react_slot","import_react","import_typed_classname","import_react","import_react","import_typed_classname","import_jsx_runtime","import_react","import_typed_classname","import_jsx_runtime","import_jsx_runtime","import_typed_classname","import_react","import_react","import_typed_classname","import_jsx_runtime","import_jsx_runtime","import_react","import_typed_classname","import_jsx_runtime","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../src/footer/index.tsx","../../src/footer/footer.tsx","../../src/accordion/accordion.tsx","../../src/accordion/accordion-item.tsx","../../src/accordion/context.ts","../../src/accordion/accordion-header.tsx","../../src/accordion/accordion-content.tsx","../../src/list/link-list.tsx","../../src/list/list.tsx","../../src/button/button.tsx"],"sourcesContent":["export {\n Footer,\n FooterLogo,\n FooterButtonLink,\n FooterLinkSections,\n FooterLinkSection,\n} from \"./footer\";\n\nexport type * from \"./footer\";\n","import { forwardRef, type HTMLAttributes, type ReactElement } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Accordion } from \"../accordion\";\nimport { LinkList } from \"../list/link-list\";\nimport { Button } from \"../button\";\n\ninterface FooterLogoProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * A fixed Posten or Bring logo.\n *\n * The logo follows the brand theme, so if the class `hds-theme-bring` is set the Bring logo will be shown instead of the Posten logo\n */\nexport const FooterLogo = forwardRef<HTMLDivElement, FooterLogoProps>(\n ({ children, className, asChild, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component className={clsx(`hds-footer__logo`, className as undefined)} ref={ref} {...rest}>\n {children}\n </Component>\n );\n },\n);\nFooterLogo.displayName = \"Footer.Logo\";\n\nexport interface FooterButtonLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n */\nexport const FooterButtonLink = forwardRef<HTMLAnchorElement, FooterButtonLinkProps>(\n ({ children, className, asChild, ...rest }, ref) => {\n const Component = asChild ? Slot : \"a\";\n return (\n <Button asChild variant=\"inverted\" className={clsx(className as undefined)}>\n <Component ref={ref} {...rest}>\n {children}\n </Component>\n </Button>\n );\n },\n);\nFooterButtonLink.displayName = \"FooterButton\";\n\ninterface FooterLinkSectionsProps extends HTMLAttributes<HTMLDivElement> {\n children: ReactElement<FooterLinkSectionProps> | ReactElement<FooterLinkSectionProps>[];\n}\n\n/**\n * Responsive sections of links. Will become an accordion on mobile.\n *\n * Use with {@link FooterLinkSection} for each section.\n */\nexport const FooterLinkSections = forwardRef<HTMLDivElement, FooterLinkSectionsProps>(\n ({ children, className, ...rest }, ref) => {\n return (\n <>\n {/* Mobile and Desktop. The accordion styling gets removed on desktop */}\n <Accordion\n className={clsx(\"hds-footer__link-sections\", className as undefined)}\n ref={ref}\n {...rest}\n >\n {/* @ts-expect-error -- It's ok */}\n {children}\n </Accordion>\n </>\n );\n },\n);\nFooterLinkSections.displayName = \"Footer.LinkSections\";\n\ninterface FooterLinkSectionProps extends HTMLAttributes<HTMLDivElement> {\n heading: React.ReactNode;\n children: React.ReactNode;\n}\n\nexport const FooterLinkSection = forwardRef<HTMLDivElement, FooterLinkSectionProps>(\n ({ heading, children, className, ...rest }, ref) => {\n // @ts-expect-error -- It's ok\n const linkListChildren = <LinkList>{children}</LinkList>;\n return (\n <>\n {/* Mobile */}\n <Accordion.Item\n className={clsx(`hds-footer__link-section`, className as undefined)}\n ref={ref}\n {...rest}\n >\n <Accordion.Header>{heading}</Accordion.Header>\n <Accordion.Content>{linkListChildren}</Accordion.Content>\n </Accordion.Item>\n\n {/* Desktop */}\n <div className={clsx(`hds-footer__link-section`, className as undefined)}>\n <h2>{heading}</h2>\n {linkListChildren}\n </div>\n </>\n );\n },\n);\nFooterLinkSection.displayName = \"Footer.LinkSection\";\n\nexport interface FooterProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Footer variant\n *\n * @default \"default\"\n */\n variant?: \"default\" | \"slim\";\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * 🚨 WORK IN PROGRESS 🚨\n */\nexport const Footer = forwardRef<HTMLDivElement, FooterProps>(\n ({ children, className, variant, asChild, ...rest }, ref) => {\n const Component = asChild ? Slot : \"footer\";\n return (\n <Component\n className={clsx(\n `hds-footer`,\n variant === \"slim\" && \"hds-footer--slim\",\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n) as FooterType;\nFooter.displayName = \"Footer\";\n\ntype FooterType = ReturnType<typeof forwardRef<HTMLDivElement, FooterProps>> & {\n Logo: typeof FooterLogo;\n ButtonLink: typeof FooterButtonLink;\n LinkSections: typeof FooterLinkSections;\n LinkSection: typeof FooterLinkSection;\n};\n\nFooter.Logo = FooterLogo;\nFooter.ButtonLink = FooterButtonLink;\nFooter.LinkSections = FooterLinkSections;\nFooter.LinkSection = FooterLinkSection;\n","import type { ReactElement } from \"react\";\nimport { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { AccordionItem, type AccordionItemProps } from \"./accordion-item\";\nimport { AccordionHeader } from \"./accordion-header\";\nimport { AccordionContent } from \"./accordion-content\";\n\nexport interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Accepts type of <AccordionItem/>\n */\n children: ReactElement<AccordionItemProps> | ReactElement<AccordionItemProps>[];\n\n /**\n * Adds padding to the left of the accordion\n */\n indent?: boolean;\n}\n\n/**\n * Displays collapsible content sections\n *\n * @example\n * ```tsx\n * <Accordion>\n * <Accordion.Item defaultOpen>\n * <Accordion.Header>Item one</Accordion.Header>\n * <Accordion.Content>\n * Some content\n * </Accordion.Content>\n * </Accordion.Item>\n * <Accordion.Item>\n * <Accordion.Header>Item two</Accordion.Header>\n * <Accordion.Content>\n * Some more content\n * </Accordion.Content>\n * </Accordion.Item>\n * </Accordion>\n * ```\n */\nexport const Accordion = forwardRef<HTMLDivElement, AccordionProps>(\n ({ children, className, indent = true, ...rest }, ref) => {\n return (\n <div\n {...rest}\n className={clsx(\n \"hds-accordion\",\n !indent && \"hds-accordion--no-indent\",\n className as undefined,\n )}\n ref={ref}\n >\n {children}\n </div>\n );\n },\n) as AccordionType;\nAccordion.displayName = \"Accordion\";\n\nAccordion.Item = AccordionItem;\nAccordion.Header = AccordionHeader;\nAccordion.Content = AccordionContent;\n\ntype AccordionType = ReturnType<typeof forwardRef<HTMLDivElement, AccordionProps>> & {\n Item: typeof AccordionItem;\n Header: typeof AccordionHeader;\n Content: typeof AccordionContent;\n};\n","import type { ReactElement } from \"react\";\nimport { forwardRef, useId, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { AccordionItemContext } from \"./context\";\nimport type { AccordionHeaderProps } from \"./accordion-header\";\nimport type { AccordionContentProps } from \"./accordion-content\";\n\nexport type AccordionItemChildrenType =\n | ReactElement<AccordionHeaderProps>\n | ReactElement<AccordionContentProps>;\n\nexport interface AccordionItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Control the open state of the accordion manually\n */\n open?: boolean;\n\n /**\n * Use with open to control the open state of the accordion manually\n */\n onOpenChange?: (open: boolean) => void;\n\n /**\n * If the accordion should be open by default\n */\n defaultOpen?: boolean;\n\n /**\n * Accepts type of Accordion.Content and Accordion.Header\n */\n children: AccordionItemChildrenType[];\n}\n\nexport const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(\n ({ children, defaultOpen, open: outerOpen, onOpenChange, className, ...rest }, ref) => {\n const contentId = useId();\n const [innerOpen, setInnerOpen] = useState(defaultOpen ?? false);\n const open = outerOpen ?? innerOpen;\n\n const handleOpen = () => {\n if (outerOpen !== undefined) {\n onOpenChange && onOpenChange(!open);\n } else {\n setInnerOpen(!open);\n }\n };\n\n return (\n <div\n {...rest}\n data-state={open ? \"open\" : \"closed\"}\n className={clsx(\"hds-accordion-item\", className as undefined)}\n ref={ref}\n >\n <AccordionItemContext.Provider value={{ contentId, open, setOpen: handleOpen }}>\n {children}\n </AccordionItemContext.Provider>\n </div>\n );\n },\n);\n\nAccordionItem.displayName = \"Accordion.Item\";\n","import { createContext } from \"react\";\n\nexport interface AccordionItemContextProps {\n open: boolean;\n setOpen: (open: boolean) => void;\n contentId: string;\n}\n\nexport const AccordionItemContext = createContext<AccordionItemContextProps | null>(null);\n","import type { MouseEvent, ReactNode } from \"react\";\nimport { forwardRef, useContext } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { AccordionItemContext } from \"./context\";\n\nexport interface AccordionHeaderProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n children: ReactNode;\n}\n\nexport const AccordionHeader = forwardRef<HTMLButtonElement, AccordionHeaderProps>(\n ({ children, className, onClick, ...rest }, ref) => {\n const context = useContext(AccordionItemContext);\n if (context === null) {\n return null;\n }\n const expandOrCollapse = (e: MouseEvent<HTMLButtonElement>) => {\n context.setOpen(!context.open);\n onClick?.(e);\n };\n return (\n <button\n {...rest}\n aria-expanded={context.open}\n aria-controls={context.contentId}\n data-state={context.open ? \"open\" : \"closed\"}\n className={clsx(\"hds-accordion-item-header\", className as undefined)}\n onClick={expandOrCollapse}\n ref={ref}\n type=\"button\"\n >\n <span>{children}</span>\n </button>\n );\n },\n);\n\nAccordionHeader.displayName = \"Accordion.Header\";\n","import type { ReactNode } from \"react\";\nimport { forwardRef, useContext } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { AccordionItemContext } from \"./context\";\n\nexport interface AccordionContentProps extends React.HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n}\n\nexport const AccordionContent = forwardRef<HTMLDivElement, AccordionContentProps>(\n ({ children, className, ...rest }, ref) => {\n const context = useContext(AccordionItemContext);\n if (context === null) {\n return null;\n }\n return (\n <div\n id={context.contentId}\n data-state={context.open ? \"open\" : \"closed\"}\n {...{ inert: context.open ? undefined : \"true\" }}\n className={clsx(\"hds-accordion-item-content\", className as undefined)}\n ref={ref}\n {...rest}\n >\n <div className={clsx(\"hds-accordion-item-content-inner\")}>{children}</div>\n </div>\n );\n },\n);\n\nAccordionContent.displayName = \"Accordion.Content\";\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport type { ListProps } from \"./list\";\nimport { UnorderedList } from \"./list\";\n\nexport interface LinkListProps extends Omit<ListProps, \"listStyle\"> {\n children?: React.ReactElement<HTMLLIElement> | React.ReactElement<HTMLLIElement>[];\n}\n\n/**\n * Show a list of links\n *\n * For other list types use `UnorderedList` and `OrderedList`, or use your own list component using the semantic `ul` and `ol` tags.\n */\nexport const LinkList = forwardRef<HTMLUListElement, LinkListProps>(\n ({ className, ...rest }, ref) => {\n return (\n <UnorderedList\n ref={ref}\n className={clsx(\"hds-list--link-list\", className as undefined)}\n {...rest}\n />\n );\n },\n);\nLinkList.displayName = \"LinkList\";\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\nexport interface ListProps extends HTMLAttributes<HTMLOListElement | HTMLUListElement> {\n /**\n * Sets the size of the items (font)\n *\n * @default \"medium\"\n */\n size?: \"small\" | \"medium\" | \"large\";\n}\n\n/**\n * An unordered list of simple items, often text. You can nest other lists inside this component.\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <UnorderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </UnorderedList>\n * ```\n */\nexport const UnorderedList = forwardRef<HTMLUListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ul\n ref={ref}\n className={clsx(\"hds-list\", `hds-list--${size}`, className as undefined)}\n {...rest}\n />\n );\n },\n);\nUnorderedList.displayName = \"UnorderedList\";\n\n/**\n * An ordered list of simple items\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <OrderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </OrderedList>\n * ```\n */\nexport const OrderedList = forwardRef<HTMLOListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ol\n ref={ref}\n className={clsx(\"hds-list\", `hds-list--${size}`, className as undefined)}\n {...rest}\n />\n );\n },\n);\nOrderedList.displayName = \"OrderedList\";\n","import { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * The height, font size and padding of the button\n *\n * @default \"large\"\n */\n size?: \"small\" | \"large\";\n\n /**\n * The background and fill of the button\n *\n * @default \"primary\"\n */\n variant?: \"primary\" | \"secondary\" | \"tertiary\" | \"inverted\";\n\n /**\n * Make the button use 100% width available.\n * Using the \"mobile\" it only stretch to full width on smaller screens\n */\n fullWidth?: boolean | \"mobile\";\n\n /**\n * Specify that there is an icon in the button.\n * `icon`: There is only an icon in the button.\n * `icon=\"leading\"`: There is an icon before the text.\n * `icon=\"trailing\"`: There is an icon after the text.\n *\n * @default false\n */\n icon?: boolean | \"leading\" | \"trailing\";\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\n/**\n * Button component\n *\n * @example\n * <Button variant=\"primary\">Primary</Button>\n * <Button variant=\"secondary\" size=\"large\">Secondary</Button>\n * <Button variant=\"inverted\">Inverted</Button>\n * <Button variant=\"tertiary\" fullWidth=\"mobile\">Tertiary</Button>\n * <Button icon=\"leading\"><LeadingIcon />Leading icon</Button>\n *\n * @example\n * // If used for navigation use the `asChild` prop with a anchor element as a child.\n * <Button asChild><a href=\"/home\">Home</a></Button>\n */\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n (\n {\n asChild,\n children,\n variant = \"primary\",\n size = \"large\",\n fullWidth = false,\n icon = false,\n className,\n ...rest\n },\n ref,\n ) => {\n const Component = asChild ? Slot : \"button\";\n\n return (\n <Component\n className={clsx(\n \"hds-button\",\n `hds-button--${size}`,\n `hds-button--${variant}`,\n {\n \"hds-button--full\": fullWidth === true,\n \"hds-button--mobile-full\": fullWidth === \"mobile\",\n \"hds-button--only-icon\": icon === true,\n \"hds-button--leading-icon\": icon === \"leading\",\n \"hds-button--trailing-icon\": icon === \"trailing\",\n },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nButton.displayName = \"Button\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAmE;AACnE,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;;;ACDrB,IAAAC,gBAA2B;AAC3B,IAAAC,0BAAqB;;;ACDrB,IAAAC,gBAA4C;AAC5C,6BAAqB;;;ACFrB,mBAA8B;AAQvB,IAAM,2BAAuB,4BAAgD,IAAI;;;AD8ChF;AArBD,IAAM,oBAAgB;AAAA,EAC3B,CAAC,IAA8E,QAAQ;AAAtF,iBAAE,YAAU,aAAa,MAAM,WAAW,cAAc,UAlC3D,IAkCG,IAAsE,iBAAtE,IAAsE,CAApE,YAAU,eAAa,QAAiB,gBAAc;AACvD,UAAM,gBAAY,qBAAM;AACxB,UAAM,CAAC,WAAW,YAAY,QAAI,wBAAS,oCAAe,KAAK;AAC/D,UAAM,OAAO,gCAAa;AAE1B,UAAM,aAAa,MAAM;AACvB,UAAI,cAAc,QAAW;AAC3B,wBAAgB,aAAa,CAAC,IAAI;AAAA,MACpC,OAAO;AACL,qBAAa,CAAC,IAAI;AAAA,MACpB;AAAA,IACF;AAEA,WACE;AAAA,MAAC;AAAA,uCACK,OADL;AAAA,QAEC,cAAY,OAAO,SAAS;AAAA,QAC5B,eAAW,6BAAK,sBAAsB,SAAsB;AAAA,QAC5D;AAAA,QAEA,sDAAC,qBAAqB,UAArB,EAA8B,OAAO,EAAE,WAAW,MAAM,SAAS,WAAW,GAC1E,UACH;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA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AEJ;AACF;AACA,kBAAkB,cAAc;AAqBzB,IAAM,aAAS;AAAA,EACpB,CAAC,IAAoD,QAAQ;AAA5D,iBAAE,YAAU,WAAW,SAAS,QA3InC,IA2IG,IAA4C,iBAA5C,IAA4C,CAA1C,YAAU,aAAW,WAAS;AAC/B,UAAM,YAAY,UAAU,0BAAO;AACnC,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW;AAAA,UACT;AAAA,UACA,YAAY,UAAU;AAAA,UACtB;AAAA,QACF;AAAA,QACA;AAAA,SACI,OAPL;AAAA,QASE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,OAAO,cAAc;AASrB,OAAO,OAAO;AACd,OAAO,aAAa;AACpB,OAAO,eAAe;AACtB,OAAO,cAAc;","names":["import_react","import_typed_classname","import_react_slot","import_react","import_typed_classname","import_react","import_react","import_typed_classname","import_jsx_runtime","import_react","import_typed_classname","import_jsx_runtime","import_jsx_runtime","import_typed_classname","import_react","import_react","import_typed_classname","import_jsx_runtime","import_jsx_runtime","import_react","import_typed_classname","import_jsx_runtime","import_jsx_runtime"]}
|
package/dist/footer/index.mjs
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
FooterLinkSection,
|
|
6
6
|
FooterLinkSections,
|
|
7
7
|
FooterLogo
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-444SCBJD.mjs";
|
|
9
9
|
import "../chunk-Z2ZCM4BE.mjs";
|
|
10
10
|
import "../chunk-LGEGXOPU.mjs";
|
|
11
11
|
import "../chunk-HT2EIJAD.mjs";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-TYCGAA35.mjs";
|
|
13
13
|
import "../chunk-ZKMFJZSH.mjs";
|
|
14
14
|
import "../chunk-CKG2XRMX.mjs";
|
|
15
15
|
import "../chunk-5FWY7FIX.mjs";
|
|
@@ -237,7 +237,7 @@ var import_react_slot3 = require("@radix-ui/react-slot");
|
|
|
237
237
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
238
238
|
var Link = (0, import_react4.forwardRef)(
|
|
239
239
|
(_a, ref) => {
|
|
240
|
-
var _b = _a, { asChild, children, variant = "underline", size = "default", className } = _b, rest = __objRest(_b, ["asChild", "children", "variant", "size", "className"]);
|
|
240
|
+
var _b = _a, { asChild, children, variant = "underline", size = "default", icon, className } = _b, rest = __objRest(_b, ["asChild", "children", "variant", "size", "icon", "className"]);
|
|
241
241
|
const Component = asChild ? import_react_slot3.Slot : "a";
|
|
242
242
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
243
243
|
Component,
|
|
@@ -245,7 +245,9 @@ var Link = (0, import_react4.forwardRef)(
|
|
|
245
245
|
className: (0, import_typed_classname4.clsx)(
|
|
246
246
|
"hds-link",
|
|
247
247
|
variant !== "underline" && `hds-link--${variant}`,
|
|
248
|
-
size !== "default" &&
|
|
248
|
+
size !== "default" && `hds-link--${size}`,
|
|
249
|
+
{ "hds-link--trailing-icon": icon === "trailing" },
|
|
250
|
+
{ "hds-link--leading-icon": icon === "leading" },
|
|
249
251
|
className
|
|
250
252
|
),
|
|
251
253
|
ref
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/form/error-summary/error-summary.tsx","../../../src/message/message.tsx","../../../src/box/box.tsx","../../../src/list/list.tsx","../../../src/link/link.tsx","../../../src/utils/utils.ts","../../../src/form/error-summary/focus.ts"],"sourcesContent":["import { forwardRef, useEffect, useRef } from \"react\";\nimport { Message, type MessageProps, type MessageTitleProps } from \"../../message\";\nimport { UnorderedList, type ListProps } from \"../../list\";\nimport { Link } from \"../../link\";\nimport { useMergeRefs } from \"../../utils\";\nimport { focusWithLegendOrLabelInViewport } from \"./focus\";\n\ninterface ErrorSummaryHeadingPropsAutoFocus {\n /**\n * The heading will be focused when the component mounts\n *\n * On following errornous form submissions you should manually focus the heading\n * e.g. by passing a ref and calling `ref.current.focus()`\n *\n * @default true\n */\n autoFocus?: boolean;\n}\n\ninterface ErrorSummaryHeadingPropsAs {\n /**\n * A heading level must be selected, or optionally opting out for a different element\n *\n * Use {@link ErrorSummaryHeadingPropsAsChild.asChild} if you need more control of the rendered element.\n */\n as: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"span\" | \"div\" | \"label\" | \"p\";\n asChild?: never;\n}\n\ninterface ErrorSummaryHeadingPropsAsChild {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild: true;\n as?: never;\n}\n\nexport type ErrorSummaryHeadingProps = MessageTitleProps &\n ErrorSummaryHeadingPropsAutoFocus &\n (ErrorSummaryHeadingPropsAs | ErrorSummaryHeadingPropsAsChild);\n\nexport const ErrorSummaryHeading = forwardRef<\n HTMLParagraphElement,\n ErrorSummaryHeadingProps & (ErrorSummaryHeadingPropsAs | ErrorSummaryHeadingPropsAsChild)\n>(({ children, as: Tag, autoFocus = true, ...rest }, ref) => {\n const focusRef = useRef<HTMLElement>(null);\n const mergedRef = useMergeRefs([focusRef, ref]);\n\n useEffect(() => {\n /**\n * Hack: Safari 18 on mac at the time of writing\n * does not correctly focus it with VoiceOver without the timeout\n */\n setTimeout(() => {\n if (focusRef.current && autoFocus) {\n focusRef.current.focus();\n }\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps -- Only on initial render\n }, []);\n\n return (\n <Message.Title ref={mergedRef} tabIndex={-1} asChild {...rest}>\n {Tag ? <Tag>{children}</Tag> : children}\n </Message.Title>\n );\n});\nErrorSummaryHeading.displayName = \"ErrorSummary.Heading\";\n\nexport interface ErrorSummaryListProps extends ListProps {\n /**\n * Sets the size of the items (font)\n *\n * @default \"small\"\n */\n size?: ListProps[\"size\"];\n}\nexport const ErrorSummaryList = forwardRef<HTMLUListElement, ErrorSummaryListProps>(\n ({ children, style: _style, size = \"small\", ...rest }, ref) => {\n const style = {\n // Match the link `solid` style, which black underline\n \"--_hds-list-marker-color\": \"var(--hds-ui-colors-black)\",\n ..._style,\n };\n return (\n <Message.Description asChild>\n <UnorderedList size={size} ref={ref} style={style} {...rest}>\n {children}\n </UnorderedList>\n </Message.Description>\n );\n },\n);\nErrorSummaryList.displayName = \"ErrorSummary.List\";\n\nexport interface ErrorSummaryItemProps extends React.HTMLAttributes<HTMLLIElement> {\n /**\n * A hash link to the element that the error message refers to\n *\n * Must start with \"#\" as it's passed to the `href` attribute of an anchor element\n *\n * @example \"#email\"\n */\n href: `#${string}`;\n\n /**\n * Extra props to pass to the link element\n */\n linkProps?: React.AnchorHTMLAttributes<HTMLAnchorElement>;\n}\nexport const ErrorSummaryItem = forwardRef<HTMLLIElement, ErrorSummaryItemProps>(\n ({ children, href, linkProps, ...rest }, ref) => {\n function onClick(e: React.MouseEvent<HTMLAnchorElement>) {\n linkProps?.onClick?.(e);\n if (focusWithLegendOrLabelInViewport(href.replace(\"#\", \"\"))) {\n e.preventDefault();\n }\n }\n\n return (\n <li ref={ref} {...rest}>\n <Link size=\"small\" href={href} variant=\"solid\" {...linkProps} onClick={onClick}>\n {children}\n </Link>\n </li>\n );\n },\n);\nErrorSummaryItem.displayName = \"ErrorSummary.Item\";\n\nexport type ErrorSummaryProps = Omit<MessageProps, \"variant\" | \"icon\" | \"iconClassName\">;\n\nexport const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(\n ({ children, ...rest }, ref) => {\n return (\n <Message variant=\"warning\" ref={ref} {...rest}>\n {children}\n </Message>\n );\n },\n) as ErrorSummaryType;\nErrorSummary.displayName = \"ErrorSummary\";\n\ntype ErrorSummaryType = ReturnType<typeof forwardRef<HTMLDivElement, ErrorSummaryProps>> & {\n Heading: typeof ErrorSummaryHeading;\n List: typeof ErrorSummaryList;\n Item: typeof ErrorSummaryItem;\n};\nErrorSummary.Heading = ErrorSummaryHeading;\nErrorSummary.List = ErrorSummaryList;\nErrorSummary.Item = ErrorSummaryItem;\n","import { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Box, type BoxProps } from \"../box/box\";\n\nexport interface MessageTitleProps extends React.HTMLAttributes<HTMLParagraphElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const MessageTitle = forwardRef<HTMLParagraphElement, MessageTitleProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-message__title\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nMessageTitle.displayName = \"Message.Title\";\n\nexport interface MessageDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const MessageDescription = forwardRef<HTMLParagraphElement, MessageDescriptionProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-message__description\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nMessageDescription.displayName = \"Message.Description\";\n\nexport type MessageProps = (\n | {\n variant?: \"success\" | \"attention\" | \"warning\" | \"info\";\n icon?: never;\n iconClassName?: never;\n }\n | {\n variant: \"neutral\";\n icon?: React.ReactNode;\n iconClassName?: string;\n }\n) &\n Omit<BoxProps, \"variant\" | \"asChild\">;\n\nexport const Message = forwardRef<HTMLDivElement, MessageProps>(\n ({ children, className, variant = \"success\", icon, iconClassName, ...rest }, ref) => {\n return (\n <Box\n className={clsx(`hds-message`, `hds-message--${variant}`, className as undefined)}\n ref={ref}\n {...rest}\n >\n {variant === \"neutral\" && (\n <div className={clsx(\"hds-message--neutral__icon\", iconClassName as undefined)}>\n {icon}\n </div>\n )}\n {children}\n </Box>\n );\n },\n) as MessageType;\nMessage.displayName = \"Message\";\n\ntype MessageType = ReturnType<typeof forwardRef<HTMLDivElement, MessageProps>> & {\n Title: typeof MessageTitle;\n Description: typeof MessageDescription;\n};\nMessage.Title = MessageTitle;\nMessage.Description = MessageDescription;\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\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\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Color variant of the box\n *\n * @default \"light-grey\"\n */\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\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 * @default false\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 /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n asChild,\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 const Component = asChild ? Slot : \"div\";\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 <Slottable>{children}</Slottable>\n </Component>\n );\n },\n) as BoxType;\nBox.displayName = \"Box\";\n\nBox.CloseButton = BoxCloseButton;\n\ntype BoxType = ReturnType<typeof forwardRef<HTMLDivElement, BoxProps>> & {\n CloseButton: typeof BoxCloseButton;\n};\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\nexport interface ListProps extends HTMLAttributes<HTMLOListElement | HTMLUListElement> {\n /**\n * Sets the size of the items (font)\n *\n * @default \"medium\"\n */\n size?: \"small\" | \"medium\" | \"large\";\n}\n\n/**\n * An unordered list of simple items, often text. You can nest other lists inside this component.\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <UnorderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </UnorderedList>\n * ```\n */\nexport const UnorderedList = forwardRef<HTMLUListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ul\n ref={ref}\n className={clsx(\"hds-list\", `hds-list--${size}`, className as undefined)}\n {...rest}\n />\n );\n },\n);\nUnorderedList.displayName = \"UnorderedList\";\n\n/**\n * An ordered list of simple items\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <OrderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </OrderedList>\n * ```\n */\nexport const OrderedList = forwardRef<HTMLOListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ol\n ref={ref}\n className={clsx(\"hds-list\", `hds-list--${size}`, className as undefined)}\n {...rest}\n />\n );\n },\n);\nOrderedList.displayName = \"OrderedList\";\n","import * as React from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nexport interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n /**\n * The visual style of the link\n */\n variant?: \"underline\" | \"solid\" | \"inverted\" | \"no-underline\";\n\n /**\n * Font size of the link\n *\n * Note: `medium` is deprecated, use `default` instead of `medium`\n */\n size?: \"default\" | \"small\" | \"large\" | \"technical\" | \"medium\";\n\n children: React.ReactNode;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Link = forwardRef<HTMLAnchorElement, LinkProps>(\n ({ asChild, children, variant = \"underline\", size = \"default\", className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"a\";\n return (\n <Component\n className={clsx(\n \"hds-link\",\n variant !== \"underline\" && `hds-link--${variant}`,\n size !== \"default\" && size !== \"medium\" && `hds-link--${size}`,\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nLink.displayName = \"Link\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n","/**\n * Focus a form field while showing the associated legend or label in the viewport.\n *\n * Gives the user a better context of what field they are focusing on.\n *\n * Copied from https://github.com/alphagov/govuk-frontend/blob/cbf4ef1e329711be5b78a92bda6ba84a7db9ca40/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs#L60-L108\n */\nexport function focusWithLegendOrLabelInViewport(id: string) {\n const input = document.getElementById(id);\n if (!input) {\n return false;\n }\n\n const legendOrLabel = maybeLegendForInput(input) ?? labelForInput(input);\n if (!legendOrLabel) {\n return false;\n }\n\n legendOrLabel.scrollIntoView();\n input.focus({ preventScroll: true });\n\n return true;\n}\n\nfunction maybeLegendForInput(input: HTMLElement) {\n const fieldset = input.closest(\"fieldset\");\n if (!fieldset) {\n return null;\n }\n\n const legend = fieldset.querySelector(\"legend\");\n if (!legend) {\n return null;\n }\n\n // If the input type is radio or checkbox, always use the legend if\n // there is one.\n if (input instanceof HTMLInputElement && (input.type === \"checkbox\" || input.type === \"radio\")) {\n return legend;\n }\n\n // For other input types, only scroll to the fieldset’s legend (instead\n // of the label associated with the input) if the input would end up in\n // the top half of the screen.\n //\n // This should avoid situations where the input either ends up off the\n // screen, or obscured by a software keyboard.\n const legendTop = legend.getBoundingClientRect().top;\n const inputRect = input.getBoundingClientRect();\n\n // If the browser doesn't support Element.getBoundingClientRect().height\n // or window.innerHeight (like IE8), bail and just link to the label.\n if (inputRect.height && window.innerHeight) {\n const inputBottom = inputRect.top + inputRect.height;\n\n if (inputBottom - legendTop < window.innerHeight / 2) {\n return legend;\n }\n }\n}\n\nfunction labelForInput(input: HTMLElement) {\n return (\n document.querySelector(`label[for='${input.getAttribute(\"id\")}']`) ?? input.closest(\"label\")\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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,QAAM;AACjB,aAAS,QAAQ,GAAwC;AAhH7D,UAAAC;AAiHM,OAAAA,MAAA,uCAAW,YAAX,gBAAAA,IAAA,gBAAqB;AACrB,UAAI,iCAAiC,KAAK,QAAQ,KAAK,EAAE,CAAC,GAAG;AAC3D,UAAE,eAAe;AAAA,MACnB;AAAA,IACF;AAEA,WACE,6CAAC,qCAAG,OAAc,OAAjB,EACC,uDAAC,qCAAK,MAAK,SAAQ,MAAY,SAAQ,WAAY,YAAlD,EAA6D,SAC3D,WACH,IACF;AAAA,EAEJ;AACF;AACA,iBAAiB,cAAc;AAIxB,IAAM,mBAAe;AAAA,EAC1B,CAAC,IAAuB,QAAQ;AAA/B,iBAAE,WArIL,IAqIG,IAAe,iBAAf,IAAe,CAAb;AACD,WACE,6CAAC,wCAAQ,SAAQ,WAAU,OAAc,OAAxC,EACE,WACH;AAAA,EAEJ;AACF;AACA,aAAa,cAAc;AAO3B,aAAa,UAAU;AACvB,aAAa,OAAO;AACpB,aAAa,OAAO;","names":["import_react","import_react","import_typed_classname","import_react_slot","import_jsx_runtime","import_react","import_typed_classname","import_jsx_runtime","import_typed_classname","import_react","import_react_slot","import_jsx_runtime","React","import_react","import_jsx_runtime","_a"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/form/error-summary/error-summary.tsx","../../../src/message/message.tsx","../../../src/box/box.tsx","../../../src/list/list.tsx","../../../src/link/link.tsx","../../../src/utils/utils.ts","../../../src/form/error-summary/focus.ts"],"sourcesContent":["import { forwardRef, useEffect, useRef } from \"react\";\nimport { Message, type MessageProps, type MessageTitleProps } from \"../../message\";\nimport { UnorderedList, type ListProps } from \"../../list\";\nimport { Link } from \"../../link\";\nimport { useMergeRefs } from \"../../utils\";\nimport { focusWithLegendOrLabelInViewport } from \"./focus\";\n\ninterface ErrorSummaryHeadingPropsAutoFocus {\n /**\n * The heading will be focused when the component mounts\n *\n * On following errornous form submissions you should manually focus the heading\n * e.g. by passing a ref and calling `ref.current.focus()`\n *\n * @default true\n */\n autoFocus?: boolean;\n}\n\ninterface ErrorSummaryHeadingPropsAs {\n /**\n * A heading level must be selected, or optionally opting out for a different element\n *\n * Use {@link ErrorSummaryHeadingPropsAsChild.asChild} if you need more control of the rendered element.\n */\n as: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"span\" | \"div\" | \"label\" | \"p\";\n asChild?: never;\n}\n\ninterface ErrorSummaryHeadingPropsAsChild {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild: true;\n as?: never;\n}\n\nexport type ErrorSummaryHeadingProps = MessageTitleProps &\n ErrorSummaryHeadingPropsAutoFocus &\n (ErrorSummaryHeadingPropsAs | ErrorSummaryHeadingPropsAsChild);\n\nexport const ErrorSummaryHeading = forwardRef<\n HTMLParagraphElement,\n ErrorSummaryHeadingProps & (ErrorSummaryHeadingPropsAs | ErrorSummaryHeadingPropsAsChild)\n>(({ children, as: Tag, autoFocus = true, ...rest }, ref) => {\n const focusRef = useRef<HTMLElement>(null);\n const mergedRef = useMergeRefs([focusRef, ref]);\n\n useEffect(() => {\n /**\n * Hack: Safari 18 on mac at the time of writing\n * does not correctly focus it with VoiceOver without the timeout\n */\n setTimeout(() => {\n if (focusRef.current && autoFocus) {\n focusRef.current.focus();\n }\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps -- Only on initial render\n }, []);\n\n return (\n <Message.Title ref={mergedRef} tabIndex={-1} asChild {...rest}>\n {Tag ? <Tag>{children}</Tag> : children}\n </Message.Title>\n );\n});\nErrorSummaryHeading.displayName = \"ErrorSummary.Heading\";\n\nexport interface ErrorSummaryListProps extends ListProps {\n /**\n * Sets the size of the items (font)\n *\n * @default \"small\"\n */\n size?: ListProps[\"size\"];\n}\nexport const ErrorSummaryList = forwardRef<HTMLUListElement, ErrorSummaryListProps>(\n ({ children, style: _style, size = \"small\", ...rest }, ref) => {\n const style = {\n // Match the link `solid` style, which black underline\n \"--_hds-list-marker-color\": \"var(--hds-ui-colors-black)\",\n ..._style,\n };\n return (\n <Message.Description asChild>\n <UnorderedList size={size} ref={ref} style={style} {...rest}>\n {children}\n </UnorderedList>\n </Message.Description>\n );\n },\n);\nErrorSummaryList.displayName = \"ErrorSummary.List\";\n\nexport interface ErrorSummaryItemProps extends React.HTMLAttributes<HTMLLIElement> {\n /**\n * A hash link to the element that the error message refers to\n *\n * Must start with \"#\" as it's passed to the `href` attribute of an anchor element\n *\n * @example \"#email\"\n */\n href: `#${string}`;\n\n /**\n * Extra props to pass to the link element\n */\n linkProps?: React.AnchorHTMLAttributes<HTMLAnchorElement>;\n}\nexport const ErrorSummaryItem = forwardRef<HTMLLIElement, ErrorSummaryItemProps>(\n ({ children, href, linkProps, ...rest }, ref) => {\n function onClick(e: React.MouseEvent<HTMLAnchorElement>) {\n linkProps?.onClick?.(e);\n if (focusWithLegendOrLabelInViewport(href.replace(\"#\", \"\"))) {\n e.preventDefault();\n }\n }\n\n return (\n <li ref={ref} {...rest}>\n <Link size=\"small\" href={href} variant=\"solid\" {...linkProps} onClick={onClick}>\n {children}\n </Link>\n </li>\n );\n },\n);\nErrorSummaryItem.displayName = \"ErrorSummary.Item\";\n\nexport type ErrorSummaryProps = Omit<MessageProps, \"variant\" | \"icon\" | \"iconClassName\">;\n\nexport const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(\n ({ children, ...rest }, ref) => {\n return (\n <Message variant=\"warning\" ref={ref} {...rest}>\n {children}\n </Message>\n );\n },\n) as ErrorSummaryType;\nErrorSummary.displayName = \"ErrorSummary\";\n\ntype ErrorSummaryType = ReturnType<typeof forwardRef<HTMLDivElement, ErrorSummaryProps>> & {\n Heading: typeof ErrorSummaryHeading;\n List: typeof ErrorSummaryList;\n Item: typeof ErrorSummaryItem;\n};\nErrorSummary.Heading = ErrorSummaryHeading;\nErrorSummary.List = ErrorSummaryList;\nErrorSummary.Item = ErrorSummaryItem;\n","import { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Box, type BoxProps } from \"../box/box\";\n\nexport interface MessageTitleProps extends React.HTMLAttributes<HTMLParagraphElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const MessageTitle = forwardRef<HTMLParagraphElement, MessageTitleProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-message__title\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nMessageTitle.displayName = \"Message.Title\";\n\nexport interface MessageDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const MessageDescription = forwardRef<HTMLParagraphElement, MessageDescriptionProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-message__description\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nMessageDescription.displayName = \"Message.Description\";\n\nexport type MessageProps = (\n | {\n variant?: \"success\" | \"attention\" | \"warning\" | \"info\";\n icon?: never;\n iconClassName?: never;\n }\n | {\n variant: \"neutral\";\n icon?: React.ReactNode;\n iconClassName?: string;\n }\n) &\n Omit<BoxProps, \"variant\" | \"asChild\">;\n\nexport const Message = forwardRef<HTMLDivElement, MessageProps>(\n ({ children, className, variant = \"success\", icon, iconClassName, ...rest }, ref) => {\n return (\n <Box\n className={clsx(`hds-message`, `hds-message--${variant}`, className as undefined)}\n ref={ref}\n {...rest}\n >\n {variant === \"neutral\" && (\n <div className={clsx(\"hds-message--neutral__icon\", iconClassName as undefined)}>\n {icon}\n </div>\n )}\n {children}\n </Box>\n );\n },\n) as MessageType;\nMessage.displayName = \"Message\";\n\ntype MessageType = ReturnType<typeof forwardRef<HTMLDivElement, MessageProps>> & {\n Title: typeof MessageTitle;\n Description: typeof MessageDescription;\n};\nMessage.Title = MessageTitle;\nMessage.Description = MessageDescription;\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\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\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Color variant of the box\n *\n * @default \"light-grey\"\n */\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\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 * @default false\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 /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n asChild,\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 const Component = asChild ? Slot : \"div\";\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 <Slottable>{children}</Slottable>\n </Component>\n );\n },\n) as BoxType;\nBox.displayName = \"Box\";\n\nBox.CloseButton = BoxCloseButton;\n\ntype BoxType = ReturnType<typeof forwardRef<HTMLDivElement, BoxProps>> & {\n CloseButton: typeof BoxCloseButton;\n};\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\nexport interface ListProps extends HTMLAttributes<HTMLOListElement | HTMLUListElement> {\n /**\n * Sets the size of the items (font)\n *\n * @default \"medium\"\n */\n size?: \"small\" | \"medium\" | \"large\";\n}\n\n/**\n * An unordered list of simple items, often text. You can nest other lists inside this component.\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <UnorderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </UnorderedList>\n * ```\n */\nexport const UnorderedList = forwardRef<HTMLUListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ul\n ref={ref}\n className={clsx(\"hds-list\", `hds-list--${size}`, className as undefined)}\n {...rest}\n />\n );\n },\n);\nUnorderedList.displayName = \"UnorderedList\";\n\n/**\n * An ordered list of simple items\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <OrderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </OrderedList>\n * ```\n */\nexport const OrderedList = forwardRef<HTMLOListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ol\n ref={ref}\n className={clsx(\"hds-list\", `hds-list--${size}`, className as undefined)}\n {...rest}\n />\n );\n },\n);\nOrderedList.displayName = \"OrderedList\";\n","import * as React from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nexport interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n /**\n * The visual style of the link\n */\n variant?: \"underline\" | \"solid\" | \"inverted\" | \"no-underline\" | \"inverted-no-underline\";\n\n /**\n * Font size of the link\n * @default \"default\"\n */\n size?: \"default\" | \"small\" | \"large\" | \"technical\";\n\n /**\n * Specify that there is an icon in the link.\n * `icon=\"leading\"`: There is an icon before the text.\n * `icon=\"trailing\"`: There is an icon after the text.\n *\n */\n icon?: \"leading\" | \"trailing\";\n\n children: React.ReactNode;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Link = forwardRef<HTMLAnchorElement, LinkProps>(\n (\n { asChild, children, variant = \"underline\", size = \"default\", icon, className, ...rest },\n ref,\n ) => {\n const Component = asChild ? Slot : \"a\";\n\n return (\n <Component\n className={clsx(\n \"hds-link\",\n variant !== \"underline\" && `hds-link--${variant}`,\n size !== \"default\" && `hds-link--${size}`,\n { \"hds-link--trailing-icon\": icon === \"trailing\" },\n { \"hds-link--leading-icon\": icon === \"leading\" },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nLink.displayName = \"Link\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n","/**\n * Focus a form field while showing the associated legend or label in the viewport.\n *\n * Gives the user a better context of what field they are focusing on.\n *\n * Copied from https://github.com/alphagov/govuk-frontend/blob/cbf4ef1e329711be5b78a92bda6ba84a7db9ca40/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs#L60-L108\n */\nexport function focusWithLegendOrLabelInViewport(id: string) {\n const input = document.getElementById(id);\n if (!input) {\n return false;\n }\n\n const legendOrLabel = maybeLegendForInput(input) ?? labelForInput(input);\n if (!legendOrLabel) {\n return false;\n }\n\n legendOrLabel.scrollIntoView();\n input.focus({ preventScroll: true });\n\n return true;\n}\n\nfunction maybeLegendForInput(input: HTMLElement) {\n const fieldset = input.closest(\"fieldset\");\n if (!fieldset) {\n return null;\n }\n\n const legend = fieldset.querySelector(\"legend\");\n if (!legend) {\n return null;\n }\n\n // If the input type is radio or checkbox, always use the legend if\n // there is one.\n if (input instanceof HTMLInputElement && (input.type === \"checkbox\" || input.type === \"radio\")) {\n return legend;\n }\n\n // For other input types, only scroll to the fieldset’s legend (instead\n // of the label associated with the input) if the input would end up in\n // the top half of the screen.\n //\n // This should avoid situations where the input either ends up off the\n // screen, or obscured by a software keyboard.\n const legendTop = legend.getBoundingClientRect().top;\n const inputRect = input.getBoundingClientRect();\n\n // If the browser doesn't support Element.getBoundingClientRect().height\n // or window.innerHeight (like IE8), bail and just link to the label.\n if (inputRect.height && window.innerHeight) {\n const inputBottom = inputRect.top + inputRect.height;\n\n if (inputBottom - legendTop < window.innerHeight / 2) {\n return legend;\n }\n }\n}\n\nfunction labelForInput(input: HTMLElement) {\n return (\n document.querySelector(`label[for='${input.getAttribute(\"id\")}']`) ?? input.closest(\"label\")\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA8C;;;ACA9C,IAAAC,gBAA2B;AAC3B,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AACrB,wBAAgC;AAM1B;AAHC,IAAM,qBAAiB;AAAA,EAC5B,CAAC,IAAwB,QAAQ;AAAhC,iBAAE,YANL,IAMG,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;AAmDtB,IAAM,UAAM;AAAA,EACjB,CACE,IAWA,QACG;AAZH,iBACE;AAAA;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IA9EN,IAsEI,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,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6CAAC,QAAQ,aAAR,EAAoB,SAAO,MAC1B,uDAAC,8CAAc,MAAY,KAAU,SAAkB,OAAtD,EACE,WACH,GACF;AAAA,EAEJ;AACF;AACA,iBAAiB,cAAc;AAiBxB,IAAM,uBAAmB;AAAA,EAC9B,CAAC,IAAwC,QAAQ;AAAhD,iBAAE,YAAU,MAAM,UA/GrB,IA+GG,IAAgC,iBAAhC,IAAgC,CAA9B,YAAU,QAAM;AACjB,aAAS,QAAQ,GAAwC;AAhH7D,UAAAC;AAiHM,OAAAA,MAAA,uCAAW,YAAX,gBAAAA,IAAA,gBAAqB;AACrB,UAAI,iCAAiC,KAAK,QAAQ,KAAK,EAAE,CAAC,GAAG;AAC3D,UAAE,eAAe;AAAA,MACnB;AAAA,IACF;AAEA,WACE,6CAAC,qCAAG,OAAc,OAAjB,EACC,uDAAC,qCAAK,MAAK,SAAQ,MAAY,SAAQ,WAAY,YAAlD,EAA6D,SAC3D,WACH,IACF;AAAA,EAEJ;AACF;AACA,iBAAiB,cAAc;AAIxB,IAAM,mBAAe;AAAA,EAC1B,CAAC,IAAuB,QAAQ;AAA/B,iBAAE,WArIL,IAqIG,IAAe,iBAAf,IAAe,CAAb;AACD,WACE,6CAAC,wCAAQ,SAAQ,WAAU,OAAc,OAAxC,EACE,WACH;AAAA,EAEJ;AACF;AACA,aAAa,cAAc;AAO3B,aAAa,UAAU;AACvB,aAAa,OAAO;AACpB,aAAa,OAAO;","names":["import_react","import_react","import_typed_classname","import_react_slot","import_jsx_runtime","import_react","import_typed_classname","import_jsx_runtime","import_typed_classname","import_react","import_react_slot","import_jsx_runtime","React","import_react","import_jsx_runtime","_a"]}
|
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
ErrorSummaryHeading,
|
|
4
4
|
ErrorSummaryItem,
|
|
5
5
|
ErrorSummaryList
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-CFAPQFEC.mjs";
|
|
7
7
|
import "../../chunk-CKAL5ZJZ.mjs";
|
|
8
8
|
import "../../chunk-CYDWEPFL.mjs";
|
|
9
9
|
import "../../chunk-KCEWKQ4W.mjs";
|
|
10
|
+
import "../../chunk-ILFK3VKS.mjs";
|
|
11
|
+
import "../../chunk-XLLYMQLW.mjs";
|
|
12
|
+
import "../../chunk-OHDHIRAW.mjs";
|
|
10
13
|
import "../../chunk-6QV3OV66.mjs";
|
|
11
14
|
import "../../chunk-RC76SXBP.mjs";
|
|
12
15
|
import "../../chunk-BYFBK3J7.mjs";
|
|
13
|
-
import "../../chunk-ILFK3VKS.mjs";
|
|
14
|
-
import "../../chunk-XLLYMQLW.mjs";
|
|
15
|
-
import "../../chunk-V5X3ZS23.mjs";
|
|
16
16
|
import "../../chunk-Z2ZCM4BE.mjs";
|
|
17
17
|
import "../../chunk-LGEGXOPU.mjs";
|
|
18
18
|
import "../../chunk-3OGHJOJF.mjs";
|
|
@@ -236,7 +236,7 @@ var import_react_slot3 = require("@radix-ui/react-slot");
|
|
|
236
236
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
237
237
|
var Link = (0, import_react4.forwardRef)(
|
|
238
238
|
(_a, ref) => {
|
|
239
|
-
var _b = _a, { asChild, children, variant = "underline", size = "default", className } = _b, rest = __objRest(_b, ["asChild", "children", "variant", "size", "className"]);
|
|
239
|
+
var _b = _a, { asChild, children, variant = "underline", size = "default", icon, className } = _b, rest = __objRest(_b, ["asChild", "children", "variant", "size", "icon", "className"]);
|
|
240
240
|
const Component = asChild ? import_react_slot3.Slot : "a";
|
|
241
241
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
242
242
|
Component,
|
|
@@ -244,7 +244,9 @@ var Link = (0, import_react4.forwardRef)(
|
|
|
244
244
|
className: (0, import_typed_classname4.clsx)(
|
|
245
245
|
"hds-link",
|
|
246
246
|
variant !== "underline" && `hds-link--${variant}`,
|
|
247
|
-
size !== "default" &&
|
|
247
|
+
size !== "default" && `hds-link--${size}`,
|
|
248
|
+
{ "hds-link--trailing-icon": icon === "trailing" },
|
|
249
|
+
{ "hds-link--leading-icon": icon === "leading" },
|
|
248
250
|
className
|
|
249
251
|
),
|
|
250
252
|
ref
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/form/error-summary/index.tsx","../../../src/form/error-summary/error-summary.tsx","../../../src/message/message.tsx","../../../src/box/box.tsx","../../../src/list/list.tsx","../../../src/link/link.tsx","../../../src/utils/utils.ts","../../../src/form/error-summary/focus.ts"],"sourcesContent":["export { ErrorSummary } from \"./error-summary\";\nexport type * from \"./error-summary\";\n","import { forwardRef, useEffect, useRef } from \"react\";\nimport { Message, type MessageProps, type MessageTitleProps } from \"../../message\";\nimport { UnorderedList, type ListProps } from \"../../list\";\nimport { Link } from \"../../link\";\nimport { useMergeRefs } from \"../../utils\";\nimport { focusWithLegendOrLabelInViewport } from \"./focus\";\n\ninterface ErrorSummaryHeadingPropsAutoFocus {\n /**\n * The heading will be focused when the component mounts\n *\n * On following errornous form submissions you should manually focus the heading\n * e.g. by passing a ref and calling `ref.current.focus()`\n *\n * @default true\n */\n autoFocus?: boolean;\n}\n\ninterface ErrorSummaryHeadingPropsAs {\n /**\n * A heading level must be selected, or optionally opting out for a different element\n *\n * Use {@link ErrorSummaryHeadingPropsAsChild.asChild} if you need more control of the rendered element.\n */\n as: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"span\" | \"div\" | \"label\" | \"p\";\n asChild?: never;\n}\n\ninterface ErrorSummaryHeadingPropsAsChild {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild: true;\n as?: never;\n}\n\nexport type ErrorSummaryHeadingProps = MessageTitleProps &\n ErrorSummaryHeadingPropsAutoFocus &\n (ErrorSummaryHeadingPropsAs | ErrorSummaryHeadingPropsAsChild);\n\nexport const ErrorSummaryHeading = forwardRef<\n HTMLParagraphElement,\n ErrorSummaryHeadingProps & (ErrorSummaryHeadingPropsAs | ErrorSummaryHeadingPropsAsChild)\n>(({ children, as: Tag, autoFocus = true, ...rest }, ref) => {\n const focusRef = useRef<HTMLElement>(null);\n const mergedRef = useMergeRefs([focusRef, ref]);\n\n useEffect(() => {\n /**\n * Hack: Safari 18 on mac at the time of writing\n * does not correctly focus it with VoiceOver without the timeout\n */\n setTimeout(() => {\n if (focusRef.current && autoFocus) {\n focusRef.current.focus();\n }\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps -- Only on initial render\n }, []);\n\n return (\n <Message.Title ref={mergedRef} tabIndex={-1} asChild {...rest}>\n {Tag ? <Tag>{children}</Tag> : children}\n </Message.Title>\n );\n});\nErrorSummaryHeading.displayName = \"ErrorSummary.Heading\";\n\nexport interface ErrorSummaryListProps extends ListProps {\n /**\n * Sets the size of the items (font)\n *\n * @default \"small\"\n */\n size?: ListProps[\"size\"];\n}\nexport const ErrorSummaryList = forwardRef<HTMLUListElement, ErrorSummaryListProps>(\n ({ children, style: _style, size = \"small\", ...rest }, ref) => {\n const style = {\n // Match the link `solid` style, which black underline\n \"--_hds-list-marker-color\": \"var(--hds-ui-colors-black)\",\n ..._style,\n };\n return (\n <Message.Description asChild>\n <UnorderedList size={size} ref={ref} style={style} {...rest}>\n {children}\n </UnorderedList>\n </Message.Description>\n );\n },\n);\nErrorSummaryList.displayName = \"ErrorSummary.List\";\n\nexport interface ErrorSummaryItemProps extends React.HTMLAttributes<HTMLLIElement> {\n /**\n * A hash link to the element that the error message refers to\n *\n * Must start with \"#\" as it's passed to the `href` attribute of an anchor element\n *\n * @example \"#email\"\n */\n href: `#${string}`;\n\n /**\n * Extra props to pass to the link element\n */\n linkProps?: React.AnchorHTMLAttributes<HTMLAnchorElement>;\n}\nexport const ErrorSummaryItem = forwardRef<HTMLLIElement, ErrorSummaryItemProps>(\n ({ children, href, linkProps, ...rest }, ref) => {\n function onClick(e: React.MouseEvent<HTMLAnchorElement>) {\n linkProps?.onClick?.(e);\n if (focusWithLegendOrLabelInViewport(href.replace(\"#\", \"\"))) {\n e.preventDefault();\n }\n }\n\n return (\n <li ref={ref} {...rest}>\n <Link size=\"small\" href={href} variant=\"solid\" {...linkProps} onClick={onClick}>\n {children}\n </Link>\n </li>\n );\n },\n);\nErrorSummaryItem.displayName = \"ErrorSummary.Item\";\n\nexport type ErrorSummaryProps = Omit<MessageProps, \"variant\" | \"icon\" | \"iconClassName\">;\n\nexport const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(\n ({ children, ...rest }, ref) => {\n return (\n <Message variant=\"warning\" ref={ref} {...rest}>\n {children}\n </Message>\n );\n },\n) as ErrorSummaryType;\nErrorSummary.displayName = \"ErrorSummary\";\n\ntype ErrorSummaryType = ReturnType<typeof forwardRef<HTMLDivElement, ErrorSummaryProps>> & {\n Heading: typeof ErrorSummaryHeading;\n List: typeof ErrorSummaryList;\n Item: typeof ErrorSummaryItem;\n};\nErrorSummary.Heading = ErrorSummaryHeading;\nErrorSummary.List = ErrorSummaryList;\nErrorSummary.Item = ErrorSummaryItem;\n","import { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Box, type BoxProps } from \"../box/box\";\n\nexport interface MessageTitleProps extends React.HTMLAttributes<HTMLParagraphElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const MessageTitle = forwardRef<HTMLParagraphElement, MessageTitleProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-message__title\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nMessageTitle.displayName = \"Message.Title\";\n\nexport interface MessageDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const MessageDescription = forwardRef<HTMLParagraphElement, MessageDescriptionProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-message__description\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nMessageDescription.displayName = \"Message.Description\";\n\nexport type MessageProps = (\n | {\n variant?: \"success\" | \"attention\" | \"warning\" | \"info\";\n icon?: never;\n iconClassName?: never;\n }\n | {\n variant: \"neutral\";\n icon?: React.ReactNode;\n iconClassName?: string;\n }\n) &\n Omit<BoxProps, \"variant\" | \"asChild\">;\n\nexport const Message = forwardRef<HTMLDivElement, MessageProps>(\n ({ children, className, variant = \"success\", icon, iconClassName, ...rest }, ref) => {\n return (\n <Box\n className={clsx(`hds-message`, `hds-message--${variant}`, className as undefined)}\n ref={ref}\n {...rest}\n >\n {variant === \"neutral\" && (\n <div className={clsx(\"hds-message--neutral__icon\", iconClassName as undefined)}>\n {icon}\n </div>\n )}\n {children}\n </Box>\n );\n },\n) as MessageType;\nMessage.displayName = \"Message\";\n\ntype MessageType = ReturnType<typeof forwardRef<HTMLDivElement, MessageProps>> & {\n Title: typeof MessageTitle;\n Description: typeof MessageDescription;\n};\nMessage.Title = MessageTitle;\nMessage.Description = MessageDescription;\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\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\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Color variant of the box\n *\n * @default \"light-grey\"\n */\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\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 * @default false\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 /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n asChild,\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 const Component = asChild ? Slot : \"div\";\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 <Slottable>{children}</Slottable>\n </Component>\n );\n },\n) as BoxType;\nBox.displayName = \"Box\";\n\nBox.CloseButton = BoxCloseButton;\n\ntype BoxType = ReturnType<typeof forwardRef<HTMLDivElement, BoxProps>> & {\n CloseButton: typeof BoxCloseButton;\n};\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\nexport interface ListProps extends HTMLAttributes<HTMLOListElement | HTMLUListElement> {\n /**\n * Sets the size of the items (font)\n *\n * @default \"medium\"\n */\n size?: \"small\" | \"medium\" | \"large\";\n}\n\n/**\n * An unordered list of simple items, often text. You can nest other lists inside this component.\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <UnorderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </UnorderedList>\n * ```\n */\nexport const UnorderedList = forwardRef<HTMLUListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ul\n ref={ref}\n className={clsx(\"hds-list\", `hds-list--${size}`, className as undefined)}\n {...rest}\n />\n );\n },\n);\nUnorderedList.displayName = \"UnorderedList\";\n\n/**\n * An ordered list of simple items\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <OrderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </OrderedList>\n * ```\n */\nexport const OrderedList = forwardRef<HTMLOListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ol\n ref={ref}\n className={clsx(\"hds-list\", `hds-list--${size}`, className as undefined)}\n {...rest}\n />\n );\n },\n);\nOrderedList.displayName = \"OrderedList\";\n","import * as React from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nexport interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n /**\n * The visual style of the link\n */\n variant?: \"underline\" | \"solid\" | \"inverted\" | \"no-underline\";\n\n /**\n * Font size of the link\n *\n * Note: `medium` is deprecated, use `default` instead of `medium`\n */\n size?: \"default\" | \"small\" | \"large\" | \"technical\" | \"medium\";\n\n children: React.ReactNode;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Link = forwardRef<HTMLAnchorElement, LinkProps>(\n ({ asChild, children, variant = \"underline\", size = \"default\", className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"a\";\n return (\n <Component\n className={clsx(\n \"hds-link\",\n variant !== \"underline\" && `hds-link--${variant}`,\n size !== \"default\" && size !== \"medium\" && `hds-link--${size}`,\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nLink.displayName = \"Link\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n","/**\n * Focus a form field while showing the associated legend or label in the viewport.\n *\n * Gives the user a better context of what field they are focusing on.\n *\n * Copied from https://github.com/alphagov/govuk-frontend/blob/cbf4ef1e329711be5b78a92bda6ba84a7db9ca40/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs#L60-L108\n */\nexport function focusWithLegendOrLabelInViewport(id: string) {\n const input = document.getElementById(id);\n if (!input) {\n return false;\n }\n\n const legendOrLabel = maybeLegendForInput(input) ?? labelForInput(input);\n if (!legendOrLabel) {\n return false;\n }\n\n legendOrLabel.scrollIntoView();\n input.focus({ preventScroll: true });\n\n return true;\n}\n\nfunction maybeLegendForInput(input: HTMLElement) {\n const fieldset = input.closest(\"fieldset\");\n if (!fieldset) {\n return null;\n }\n\n const legend = fieldset.querySelector(\"legend\");\n if (!legend) {\n return null;\n }\n\n // If the input type is radio or checkbox, always use the legend if\n // there is one.\n if (input instanceof HTMLInputElement && (input.type === \"checkbox\" || input.type === \"radio\")) {\n return legend;\n }\n\n // For other input types, only scroll to the fieldset’s legend (instead\n // of the label associated with the input) if the input would end up in\n // the top half of the screen.\n //\n // This should avoid situations where the input either ends up off the\n // screen, or obscured by a software keyboard.\n const legendTop = legend.getBoundingClientRect().top;\n const inputRect = input.getBoundingClientRect();\n\n // If the browser doesn't support Element.getBoundingClientRect().height\n // or window.innerHeight (like IE8), bail and just link to the label.\n if (inputRect.height && window.innerHeight) {\n const inputBottom = inputRect.top + inputRect.height;\n\n if (inputBottom - legendTop < window.innerHeight / 2) {\n return legend;\n }\n }\n}\n\nfunction labelForInput(input: HTMLElement) {\n return (\n document.querySelector(`label[for='${input.getAttribute(\"id\")}']`) ?? input.closest(\"label\")\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA8C;;;ACA9C,IAAAC,gBAA2B;AAC3B,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AACrB,wBAAgC;AAM1B;AAHC,IAAM,qBAAiB;AAAA,EAC5B,CAAC,IAAwB,QAAQ;AAAhC,iBAAE,YANL,IAMG,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;AAmDtB,IAAM,UAAM;AAAA,EACjB,CACE,IAWA,QACG;AAZ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AACA,aAAa,cAAc;AAO3B,aAAa,UAAU;AACvB,aAAa,OAAO;AACpB,aAAa,OAAO;","names":["import_react","import_react","import_typed_classname","import_react_slot","import_jsx_runtime","import_react","import_typed_classname","import_jsx_runtime","import_typed_classname","import_react","import_react_slot","import_jsx_runtime","React","import_react","import_jsx_runtime","_a"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/form/error-summary/index.tsx","../../../src/form/error-summary/error-summary.tsx","../../../src/message/message.tsx","../../../src/box/box.tsx","../../../src/list/list.tsx","../../../src/link/link.tsx","../../../src/utils/utils.ts","../../../src/form/error-summary/focus.ts"],"sourcesContent":["export { ErrorSummary } from \"./error-summary\";\nexport type * from \"./error-summary\";\n","import { forwardRef, useEffect, useRef } from \"react\";\nimport { Message, type MessageProps, type MessageTitleProps } from \"../../message\";\nimport { UnorderedList, type ListProps } from \"../../list\";\nimport { Link } from \"../../link\";\nimport { useMergeRefs } from \"../../utils\";\nimport { focusWithLegendOrLabelInViewport } from \"./focus\";\n\ninterface ErrorSummaryHeadingPropsAutoFocus {\n /**\n * The heading will be focused when the component mounts\n *\n * On following errornous form submissions you should manually focus the heading\n * e.g. by passing a ref and calling `ref.current.focus()`\n *\n * @default true\n */\n autoFocus?: boolean;\n}\n\ninterface ErrorSummaryHeadingPropsAs {\n /**\n * A heading level must be selected, or optionally opting out for a different element\n *\n * Use {@link ErrorSummaryHeadingPropsAsChild.asChild} if you need more control of the rendered element.\n */\n as: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"span\" | \"div\" | \"label\" | \"p\";\n asChild?: never;\n}\n\ninterface ErrorSummaryHeadingPropsAsChild {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild: true;\n as?: never;\n}\n\nexport type ErrorSummaryHeadingProps = MessageTitleProps &\n ErrorSummaryHeadingPropsAutoFocus &\n (ErrorSummaryHeadingPropsAs | ErrorSummaryHeadingPropsAsChild);\n\nexport const ErrorSummaryHeading = forwardRef<\n HTMLParagraphElement,\n ErrorSummaryHeadingProps & (ErrorSummaryHeadingPropsAs | ErrorSummaryHeadingPropsAsChild)\n>(({ children, as: Tag, autoFocus = true, ...rest }, ref) => {\n const focusRef = useRef<HTMLElement>(null);\n const mergedRef = useMergeRefs([focusRef, ref]);\n\n useEffect(() => {\n /**\n * Hack: Safari 18 on mac at the time of writing\n * does not correctly focus it with VoiceOver without the timeout\n */\n setTimeout(() => {\n if (focusRef.current && autoFocus) {\n focusRef.current.focus();\n }\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps -- Only on initial render\n }, []);\n\n return (\n <Message.Title ref={mergedRef} tabIndex={-1} asChild {...rest}>\n {Tag ? <Tag>{children}</Tag> : children}\n </Message.Title>\n );\n});\nErrorSummaryHeading.displayName = \"ErrorSummary.Heading\";\n\nexport interface ErrorSummaryListProps extends ListProps {\n /**\n * Sets the size of the items (font)\n *\n * @default \"small\"\n */\n size?: ListProps[\"size\"];\n}\nexport const ErrorSummaryList = forwardRef<HTMLUListElement, ErrorSummaryListProps>(\n ({ children, style: _style, size = \"small\", ...rest }, ref) => {\n const style = {\n // Match the link `solid` style, which black underline\n \"--_hds-list-marker-color\": \"var(--hds-ui-colors-black)\",\n ..._style,\n };\n return (\n <Message.Description asChild>\n <UnorderedList size={size} ref={ref} style={style} {...rest}>\n {children}\n </UnorderedList>\n </Message.Description>\n );\n },\n);\nErrorSummaryList.displayName = \"ErrorSummary.List\";\n\nexport interface ErrorSummaryItemProps extends React.HTMLAttributes<HTMLLIElement> {\n /**\n * A hash link to the element that the error message refers to\n *\n * Must start with \"#\" as it's passed to the `href` attribute of an anchor element\n *\n * @example \"#email\"\n */\n href: `#${string}`;\n\n /**\n * Extra props to pass to the link element\n */\n linkProps?: React.AnchorHTMLAttributes<HTMLAnchorElement>;\n}\nexport const ErrorSummaryItem = forwardRef<HTMLLIElement, ErrorSummaryItemProps>(\n ({ children, href, linkProps, ...rest }, ref) => {\n function onClick(e: React.MouseEvent<HTMLAnchorElement>) {\n linkProps?.onClick?.(e);\n if (focusWithLegendOrLabelInViewport(href.replace(\"#\", \"\"))) {\n e.preventDefault();\n }\n }\n\n return (\n <li ref={ref} {...rest}>\n <Link size=\"small\" href={href} variant=\"solid\" {...linkProps} onClick={onClick}>\n {children}\n </Link>\n </li>\n );\n },\n);\nErrorSummaryItem.displayName = \"ErrorSummary.Item\";\n\nexport type ErrorSummaryProps = Omit<MessageProps, \"variant\" | \"icon\" | \"iconClassName\">;\n\nexport const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(\n ({ children, ...rest }, ref) => {\n return (\n <Message variant=\"warning\" ref={ref} {...rest}>\n {children}\n </Message>\n );\n },\n) as ErrorSummaryType;\nErrorSummary.displayName = \"ErrorSummary\";\n\ntype ErrorSummaryType = ReturnType<typeof forwardRef<HTMLDivElement, ErrorSummaryProps>> & {\n Heading: typeof ErrorSummaryHeading;\n List: typeof ErrorSummaryList;\n Item: typeof ErrorSummaryItem;\n};\nErrorSummary.Heading = ErrorSummaryHeading;\nErrorSummary.List = ErrorSummaryList;\nErrorSummary.Item = ErrorSummaryItem;\n","import { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Box, type BoxProps } from \"../box/box\";\n\nexport interface MessageTitleProps extends React.HTMLAttributes<HTMLParagraphElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const MessageTitle = forwardRef<HTMLParagraphElement, MessageTitleProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-message__title\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nMessageTitle.displayName = \"Message.Title\";\n\nexport interface MessageDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const MessageDescription = forwardRef<HTMLParagraphElement, MessageDescriptionProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-message__description\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nMessageDescription.displayName = \"Message.Description\";\n\nexport type MessageProps = (\n | {\n variant?: \"success\" | \"attention\" | \"warning\" | \"info\";\n icon?: never;\n iconClassName?: never;\n }\n | {\n variant: \"neutral\";\n icon?: React.ReactNode;\n iconClassName?: string;\n }\n) &\n Omit<BoxProps, \"variant\" | \"asChild\">;\n\nexport const Message = forwardRef<HTMLDivElement, MessageProps>(\n ({ children, className, variant = \"success\", icon, iconClassName, ...rest }, ref) => {\n return (\n <Box\n className={clsx(`hds-message`, `hds-message--${variant}`, className as undefined)}\n ref={ref}\n {...rest}\n >\n {variant === \"neutral\" && (\n <div className={clsx(\"hds-message--neutral__icon\", iconClassName as undefined)}>\n {icon}\n </div>\n )}\n {children}\n </Box>\n );\n },\n) as MessageType;\nMessage.displayName = \"Message\";\n\ntype MessageType = ReturnType<typeof forwardRef<HTMLDivElement, MessageProps>> & {\n Title: typeof MessageTitle;\n Description: typeof MessageDescription;\n};\nMessage.Title = MessageTitle;\nMessage.Description = MessageDescription;\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\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\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Color variant of the box\n *\n * @default \"light-grey\"\n */\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\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 * @default false\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 /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n asChild,\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 const Component = asChild ? Slot : \"div\";\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 <Slottable>{children}</Slottable>\n </Component>\n );\n },\n) as BoxType;\nBox.displayName = \"Box\";\n\nBox.CloseButton = BoxCloseButton;\n\ntype BoxType = ReturnType<typeof forwardRef<HTMLDivElement, BoxProps>> & {\n CloseButton: typeof BoxCloseButton;\n};\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\nexport interface ListProps extends HTMLAttributes<HTMLOListElement | HTMLUListElement> {\n /**\n * Sets the size of the items (font)\n *\n * @default \"medium\"\n */\n size?: \"small\" | \"medium\" | \"large\";\n}\n\n/**\n * An unordered list of simple items, often text. You can nest other lists inside this component.\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <UnorderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </UnorderedList>\n * ```\n */\nexport const UnorderedList = forwardRef<HTMLUListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ul\n ref={ref}\n className={clsx(\"hds-list\", `hds-list--${size}`, className as undefined)}\n {...rest}\n />\n );\n },\n);\nUnorderedList.displayName = \"UnorderedList\";\n\n/**\n * An ordered list of simple items\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <OrderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </OrderedList>\n * ```\n */\nexport const OrderedList = forwardRef<HTMLOListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ol\n ref={ref}\n className={clsx(\"hds-list\", `hds-list--${size}`, className as undefined)}\n {...rest}\n />\n );\n },\n);\nOrderedList.displayName = \"OrderedList\";\n","import * as React from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nexport interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n /**\n * The visual style of the link\n */\n variant?: \"underline\" | \"solid\" | \"inverted\" | \"no-underline\" | \"inverted-no-underline\";\n\n /**\n * Font size of the link\n * @default \"default\"\n */\n size?: \"default\" | \"small\" | \"large\" | \"technical\";\n\n /**\n * Specify that there is an icon in the link.\n * `icon=\"leading\"`: There is an icon before the text.\n * `icon=\"trailing\"`: There is an icon after the text.\n *\n */\n icon?: \"leading\" | \"trailing\";\n\n children: React.ReactNode;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Link = forwardRef<HTMLAnchorElement, LinkProps>(\n (\n { asChild, children, variant = \"underline\", size = \"default\", icon, className, ...rest },\n ref,\n ) => {\n const Component = asChild ? Slot : \"a\";\n\n return (\n <Component\n className={clsx(\n \"hds-link\",\n variant !== \"underline\" && `hds-link--${variant}`,\n size !== \"default\" && `hds-link--${size}`,\n { \"hds-link--trailing-icon\": icon === \"trailing\" },\n { \"hds-link--leading-icon\": icon === \"leading\" },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nLink.displayName = \"Link\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n","/**\n * Focus a form field while showing the associated legend or label in the viewport.\n *\n * Gives the user a better context of what field they are focusing on.\n *\n * Copied from https://github.com/alphagov/govuk-frontend/blob/cbf4ef1e329711be5b78a92bda6ba84a7db9ca40/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs#L60-L108\n */\nexport function focusWithLegendOrLabelInViewport(id: string) {\n const input = document.getElementById(id);\n if (!input) {\n return false;\n }\n\n const legendOrLabel = maybeLegendForInput(input) ?? labelForInput(input);\n if (!legendOrLabel) {\n return false;\n }\n\n legendOrLabel.scrollIntoView();\n input.focus({ preventScroll: true });\n\n return true;\n}\n\nfunction maybeLegendForInput(input: HTMLElement) {\n const fieldset = input.closest(\"fieldset\");\n if (!fieldset) {\n return null;\n }\n\n const legend = fieldset.querySelector(\"legend\");\n if (!legend) {\n return null;\n }\n\n // If the input type is radio or checkbox, always use the legend if\n // there is one.\n if (input instanceof HTMLInputElement && (input.type === \"checkbox\" || input.type === \"radio\")) {\n return legend;\n }\n\n // For other input types, only scroll to the fieldset’s legend (instead\n // of the label associated with the input) if the input would end up in\n // the top half of the screen.\n //\n // This should avoid situations where the input either ends up off the\n // screen, or obscured by a software keyboard.\n const legendTop = legend.getBoundingClientRect().top;\n const inputRect = input.getBoundingClientRect();\n\n // If the browser doesn't support Element.getBoundingClientRect().height\n // or window.innerHeight (like IE8), bail and just link to the label.\n if (inputRect.height && window.innerHeight) {\n const inputBottom = inputRect.top + inputRect.height;\n\n if (inputBottom - legendTop < window.innerHeight / 2) {\n return legend;\n }\n }\n}\n\nfunction labelForInput(input: HTMLElement) {\n return (\n document.querySelector(`label[for='${input.getAttribute(\"id\")}']`) ?? input.closest(\"label\")\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA8C;;;ACA9C,IAAAC,gBAA2B;AAC3B,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AACrB,wBAAgC;AAM1B;AAHC,IAAM,qBAAiB;AAAA,EAC5B,CAAC,IAAwB,QAAQ;AAAhC,i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OAAc,OAAjB,EACC,uDAAC,qCAAK,MAAK,SAAQ,MAAY,SAAQ,WAAY,YAAlD,EAA6D,SAC3D,WACH,IACF;AAAA,EAEJ;AACF;AACA,iBAAiB,cAAc;AAIxB,IAAM,mBAAe;AAAA,EAC1B,CAAC,IAAuB,QAAQ;AAA/B,iBAAE,WArIL,IAqIG,IAAe,iBAAf,IAAe,CAAb;AACD,WACE,6CAAC,wCAAQ,SAAQ,WAAU,OAAc,OAAxC,EACE,WACH;AAAA,EAEJ;AACF;AACA,aAAa,cAAc;AAO3B,aAAa,UAAU;AACvB,aAAa,OAAO;AACpB,aAAa,OAAO;","names":["import_react","import_react","import_typed_classname","import_react_slot","import_jsx_runtime","import_react","import_typed_classname","import_jsx_runtime","import_typed_classname","import_react","import_react_slot","import_jsx_runtime","React","import_react","import_jsx_runtime","_a"]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import "../../chunk-KPPLVGZ3.mjs";
|
|
2
2
|
import {
|
|
3
3
|
ErrorSummary
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-CFAPQFEC.mjs";
|
|
5
5
|
import "../../chunk-CKAL5ZJZ.mjs";
|
|
6
6
|
import "../../chunk-CYDWEPFL.mjs";
|
|
7
7
|
import "../../chunk-KCEWKQ4W.mjs";
|
|
8
|
+
import "../../chunk-ILFK3VKS.mjs";
|
|
9
|
+
import "../../chunk-XLLYMQLW.mjs";
|
|
10
|
+
import "../../chunk-OHDHIRAW.mjs";
|
|
8
11
|
import "../../chunk-6QV3OV66.mjs";
|
|
9
12
|
import "../../chunk-RC76SXBP.mjs";
|
|
10
13
|
import "../../chunk-BYFBK3J7.mjs";
|
|
11
|
-
import "../../chunk-ILFK3VKS.mjs";
|
|
12
|
-
import "../../chunk-XLLYMQLW.mjs";
|
|
13
|
-
import "../../chunk-V5X3ZS23.mjs";
|
|
14
14
|
import "../../chunk-Z2ZCM4BE.mjs";
|
|
15
15
|
import "../../chunk-LGEGXOPU.mjs";
|
|
16
16
|
import "../../chunk-3OGHJOJF.mjs";
|
package/dist/form/index.js
CHANGED
|
@@ -571,7 +571,7 @@ var import_react_slot3 = require("@radix-ui/react-slot");
|
|
|
571
571
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
572
572
|
var Link = (0, import_react10.forwardRef)(
|
|
573
573
|
(_a, ref) => {
|
|
574
|
-
var _b = _a, { asChild, children, variant = "underline", size = "default", className } = _b, rest = __objRest(_b, ["asChild", "children", "variant", "size", "className"]);
|
|
574
|
+
var _b = _a, { asChild, children, variant = "underline", size = "default", icon, className } = _b, rest = __objRest(_b, ["asChild", "children", "variant", "size", "icon", "className"]);
|
|
575
575
|
const Component = asChild ? import_react_slot3.Slot : "a";
|
|
576
576
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
577
577
|
Component,
|
|
@@ -579,7 +579,9 @@ var Link = (0, import_react10.forwardRef)(
|
|
|
579
579
|
className: (0, import_typed_classname9.clsx)(
|
|
580
580
|
"hds-link",
|
|
581
581
|
variant !== "underline" && `hds-link--${variant}`,
|
|
582
|
-
size !== "default" &&
|
|
582
|
+
size !== "default" && `hds-link--${size}`,
|
|
583
|
+
{ "hds-link--trailing-icon": icon === "trailing" },
|
|
584
|
+
{ "hds-link--leading-icon": icon === "leading" },
|
|
583
585
|
className
|
|
584
586
|
),
|
|
585
587
|
ref
|