govuk-react 1.0.0-alpha.1 → 1.0.0-alpha.2

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.
Files changed (38) hide show
  1. package/README.md +3 -2
  2. package/dist/components/accordion/index.d.ts +1 -1
  3. package/dist/components/accordion/index.js.map +1 -1
  4. package/dist/components/character-count/index.js +1 -1
  5. package/dist/components/character-count/index.js.map +1 -1
  6. package/dist/components/checkboxes/index.d.ts +0 -2
  7. package/dist/components/checkboxes/index.js +1 -10
  8. package/dist/components/checkboxes/index.js.map +1 -1
  9. package/dist/components/exit-this-page/index.js +2 -2
  10. package/dist/components/exit-this-page/index.js.map +1 -1
  11. package/dist/components/file-upload/enhanced.d.ts +2 -2
  12. package/dist/components/file-upload/enhanced.js +2 -2
  13. package/dist/components/file-upload/enhanced.js.map +1 -1
  14. package/dist/components/loading-box/index.d.ts +0 -2
  15. package/dist/components/loading-box/index.js +0 -16
  16. package/dist/components/loading-box/index.js.map +1 -1
  17. package/dist/components/modal/index.d.ts +0 -2
  18. package/dist/components/modal/index.js +1 -11
  19. package/dist/components/modal/index.js.map +1 -1
  20. package/dist/components/password-input/index.js +1 -1
  21. package/dist/components/password-input/index.js.map +1 -1
  22. package/dist/components/radios/index.d.ts +0 -2
  23. package/dist/components/radios/index.js +1 -10
  24. package/dist/components/radios/index.js.map +1 -1
  25. package/dist/components/related-items/index.d.ts +0 -2
  26. package/dist/components/related-items/index.js +1 -5
  27. package/dist/components/related-items/index.js.map +1 -1
  28. package/dist/components/search-box/index.d.ts +1 -3
  29. package/dist/components/search-box/index.js +4 -44
  30. package/dist/components/search-box/index.js.map +1 -1
  31. package/dist/components/service-navigation/index.d.ts +1 -3
  32. package/dist/components/service-navigation/index.js +4 -13
  33. package/dist/components/service-navigation/index.js.map +1 -1
  34. package/dist/components/tabs/index.d.ts +4 -8
  35. package/dist/components/tabs/index.js +6 -6
  36. package/dist/components/tabs/index.js.map +1 -1
  37. package/dist/styles.css +350 -0
  38. package/package.json +7 -4
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/password-input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,UAAU,MAAM,wCAAwC,CAAC;AACrE,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AASlD;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,8BAA8B,EAC9B,GAAG,KAAK,EACE;IACV,MAAM,IAAI,GAAG;QACX,gBAAgB;QAChB,gBAAgB;QAChB,yBAAyB;QACzB,yBAAyB;QACzB,6BAA6B;QAC7B,8BAA8B;KAC/B,CAAC;IACF,OAAO,CACL,oBAAC,UAAU,CAAC,IAAI,IACd,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,yBAAyB,EACpC,SAAS,EAAE,yBAAyB,EACpC,iBAAiB,EAAE,6BAA6B,EAChD,kBAAkB,EAAE,8BAA8B;QAElD,oBAAC,MAAM,CAAC,IAAI,OAAK,IAAI,KAAM,KAAK,GAAI,CACpB,CACnB,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,OAAO,EAAqB,MAAM,qCAAqC,CAAC;AAIjF,MAAM,UAAU,KAAK,CAAC,KAAiB;IACrC,OAAO,CACL,oBAAC,UAAU,CAAC,KAAK,IAAC,OAAO;QACvB,oB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AAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAE9D,OAAO,CACL,oBAAC,IAAI,IACH,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,EACvB,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,yBAAyB,EAAE,yBAAyB,EACpD,yBAAyB,EAAE,yBAAyB,EACpD,6BAA6B,EAAE,6BAA6B,EAC5D,8BAA8B,EAAE,8BAA8B;QAE9D,oBAAC,cAAc,IAAC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,IAC5E,KAAK,CACS;QAChB,MAAM,IAAI,oBAAC,IAAI,IAAC,EAAE,EAAE,MAAM,IAAG,IAAI,CAAQ;QACzC,OAAO,IAAI,oBAAC,qBAAqB,IAAC,EAAE,EAAE,OAAO,IAAG,YAAY,CAAyB;QACtF,oBAAC,MAAM,CAAC,OAAO;YACb,oBAAC,KAAK,IAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,sBAAoB,eAAe,KAAM,KAAK,GAAI;YACpG,oBAAC,MAAM,OAAG;YACV,oBAAC,MAAM,qBAAgB,EAAE,gBAAc,yBAAyB,IAC7D,gBAAgB,CACV,CACM,CACZ,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/password-input';\nimport * as Markup from 'govuk-frontend-react/password-input';\nimport { ErrorMessageComposite } from 'govuk-frontend-react/error-message';\nimport { Hint } from 'govuk-frontend-react/hint';\nimport { LabelComposite } from 'govuk-frontend-react/label';\nimport { joinIds } from '../../utils/join-ids.js';\n\n/*\n * govuk-frontend-react's PasswordInput markup, with the show and hide button from\n * @govuk-react/primitives. Without JavaScript it is a password field with no button.\n */\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Help users accessibly enter passwords.\n *\n * @see https://design-system.service.gov.uk/components/password-input/\n */\nexport function Root({\n showPasswordText,\n hidePasswordText,\n showPasswordAriaLabelText,\n hidePasswordAriaLabelText,\n passwordShownAnnouncementText,\n passwordHiddenAnnouncementText,\n ...props\n}: RootProps) {\n const text = {\n showPasswordText,\n hidePasswordText,\n showPasswordAriaLabelText,\n hidePasswordAriaLabelText,\n passwordShownAnnouncementText,\n passwordHiddenAnnouncementText,\n };\n return (\n <Primitives.Root\n showText={showPasswordText}\n hideText={hidePasswordText}\n showLabel={showPasswordAriaLabelText}\n hideLabel={hidePasswordAriaLabelText}\n shownAnnouncement={passwordShownAnnouncementText}\n hiddenAnnouncement={passwordHiddenAnnouncementText}\n >\n <Markup.Root {...text} {...props} />\n </Primitives.Root>\n );\n}\n\nexport { Wrapper, type WrapperProps } from 'govuk-frontend-react/password-input';\n\nexport type InputProps = Markup.InputProps;\n\nexport function Input(props: InputProps) {\n return (\n <Primitives.Input asChild>\n <Markup.Input {...props} />\n </Primitives.Input>\n );\n}\n\nexport type ToggleProps = Markup.ToggleProps;\n\n/** The show and hide button. Hidden until JavaScript runs. */\nexport function Toggle(props: ToggleProps) {\n return (\n <Primitives.Toggle asChild>\n <Markup.Toggle {...props} />\n </Primitives.Toggle>\n );\n}\n\nexport type StatusProps = Omit<Primitives.StatusProps, 'asChild'>;\n\n/** A visually hidden live region that announces when the password is shown or hidden. */\nexport function Status({ className, ...props }: StatusProps) {\n return (\n <Primitives.Status\n className={clsx('govuk-password-input__sr-status', 'govuk-visually-hidden', className)}\n {...props}\n />\n );\n}\n\nexport type FieldProps = Markup.FieldProps;\n\nconst isSet = (node: React.ReactNode) => node !== undefined && node !== null && node !== false && node !== '';\n\n/**\n * Help users accessibly enter passwords.\n *\n * @see https://design-system.service.gov.uk/components/password-input/\n */\nexport function Field({\n id: idProp,\n name,\n label,\n labelSize,\n labelIsPageHeading,\n hint,\n errorMessage,\n showPasswordText,\n hidePasswordText,\n showPasswordAriaLabelText,\n hidePasswordAriaLabelText,\n passwordShownAnnouncementText,\n passwordHiddenAnnouncementText,\n 'aria-describedby': describedBy,\n ...props\n}: FieldProps) {\n const id = idProp || name;\n const hintId = isSet(hint) ? `${id}-hint` : undefined;\n const errorId = isSet(errorMessage) ? `${id}-error` : undefined;\n const ariaDescribedBy = joinIds(describedBy, hintId, errorId);\n\n return (\n <Root\n error={Boolean(errorId)}\n showPasswordText={showPasswordText}\n hidePasswordText={hidePasswordText}\n showPasswordAriaLabelText={showPasswordAriaLabelText}\n hidePasswordAriaLabelText={hidePasswordAriaLabelText}\n passwordShownAnnouncementText={passwordShownAnnouncementText}\n passwordHiddenAnnouncementText={passwordHiddenAnnouncementText}\n >\n <LabelComposite htmlFor={id} size={labelSize} isPageHeading={labelIsPageHeading}>\n {label}\n </LabelComposite>\n {hintId && <Hint id={hintId}>{hint}</Hint>}\n {errorId && <ErrorMessageComposite id={errorId}>{errorMessage}</ErrorMessageComposite>}\n <Markup.Wrapper>\n <Input id={id} name={name} error={Boolean(errorId)} aria-describedby={ariaDescribedBy} {...props} />\n <Status />\n <Toggle aria-controls={id} aria-label={showPasswordAriaLabelText}>\n {showPasswordText}\n </Toggle>\n </Markup.Wrapper>\n </Root>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/password-input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,UAAU,MAAM,wCAAwC,CAAC;AACrE,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AASlD;;;;GAIG;AACH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EAAE,OAAO,IAAG,YAAY,CAAyB;QACtF,oBAAC,MAAM,CAAC,OAAO;YACb,oBAAC,KAAK,IAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,sBAAoB,eAAe,KAAM,KAAK,GAAI;YACpG,oBAAC,MAAM,OAAG;YACV,oBAAC,MAAM,qBAAgB,EAAE,gBAAc,yBAAyB,IAC7D,gBAAgB,CACV,CACM,CACZ,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/password-input';\nimport * as Markup from 'govuk-frontend-react/password-input';\nimport { ErrorMessageComposite } from 'govuk-frontend-react/error-message';\nimport { Hint } from 'govuk-frontend-react/hint';\nimport { LabelComposite } from 'govuk-frontend-react/label';\nimport { joinIds } from '../../utils/join-ids.js';\n\n/*\n * govuk-frontend-react's PasswordInput markup, with the show and hide button from\n * @govuk-react/primitives. Without JavaScript it is a password field with no button.\n */\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Help users accessibly enter passwords.\n *\n * @see https://design-system.service.gov.uk/components/password-input/\n */\nexport function Root({\n showPasswordText,\n hidePasswordText,\n showPasswordAriaLabelText,\n hidePasswordAriaLabelText,\n passwordShownAnnouncementText,\n passwordHiddenAnnouncementText,\n ...props\n}: RootProps) {\n const text = {\n showPasswordText,\n hidePasswordText,\n showPasswordAriaLabelText,\n hidePasswordAriaLabelText,\n passwordShownAnnouncementText,\n passwordHiddenAnnouncementText,\n };\n return (\n <Primitives.Root\n showText={showPasswordText}\n hideText={hidePasswordText}\n showLabel={showPasswordAriaLabelText}\n hideLabel={hidePasswordAriaLabelText}\n shownAnnouncement={passwordShownAnnouncementText}\n hiddenAnnouncement={passwordHiddenAnnouncementText}\n >\n <Markup.Root {...text} {...props} />\n </Primitives.Root>\n );\n}\n\nexport { Wrapper, type WrapperProps } from 'govuk-frontend-react/password-input';\n\nexport type InputProps = Markup.InputProps;\n\nexport function Input(props: InputProps) {\n return (\n <Primitives.Input asChild>\n <Markup.Input {...props} />\n </Primitives.Input>\n );\n}\n\nexport type ToggleProps = Markup.ToggleProps;\n\n/** The show and hide button. Hidden until JavaScript runs. */\nexport function Toggle(props: ToggleProps) {\n return (\n <Primitives.Trigger asChild>\n <Markup.Toggle {...props} />\n </Primitives.Trigger>\n );\n}\n\nexport type StatusProps = Omit<Primitives.StatusProps, 'asChild'>;\n\n/** A visually hidden live region that announces when the password is shown or hidden. */\nexport function Status({ className, ...props }: StatusProps) {\n return (\n <Primitives.Status\n className={clsx('govuk-password-input__sr-status', 'govuk-visually-hidden', className)}\n {...props}\n />\n );\n}\n\nexport type FieldProps = Markup.FieldProps;\n\nconst isSet = (node: React.ReactNode) => node !== undefined && node !== null && node !== false && node !== '';\n\n/**\n * Help users accessibly enter passwords.\n *\n * @see https://design-system.service.gov.uk/components/password-input/\n */\nexport function Field({\n id: idProp,\n name,\n label,\n labelSize,\n labelIsPageHeading,\n hint,\n errorMessage,\n showPasswordText,\n hidePasswordText,\n showPasswordAriaLabelText,\n hidePasswordAriaLabelText,\n passwordShownAnnouncementText,\n passwordHiddenAnnouncementText,\n 'aria-describedby': describedBy,\n ...props\n}: FieldProps) {\n const id = idProp || name;\n const hintId = isSet(hint) ? `${id}-hint` : undefined;\n const errorId = isSet(errorMessage) ? `${id}-error` : undefined;\n const ariaDescribedBy = joinIds(describedBy, hintId, errorId);\n\n return (\n <Root\n error={Boolean(errorId)}\n showPasswordText={showPasswordText}\n hidePasswordText={hidePasswordText}\n showPasswordAriaLabelText={showPasswordAriaLabelText}\n hidePasswordAriaLabelText={hidePasswordAriaLabelText}\n passwordShownAnnouncementText={passwordShownAnnouncementText}\n passwordHiddenAnnouncementText={passwordHiddenAnnouncementText}\n >\n <LabelComposite htmlFor={id} size={labelSize} isPageHeading={labelIsPageHeading}>\n {label}\n </LabelComposite>\n {hintId && <Hint id={hintId}>{hint}</Hint>}\n {errorId && <ErrorMessageComposite id={errorId}>{errorMessage}</ErrorMessageComposite>}\n <Markup.Wrapper>\n <Input id={id} name={name} error={Boolean(errorId)} aria-describedby={ariaDescribedBy} {...props} />\n <Status />\n <Toggle aria-controls={id} aria-label={showPasswordAriaLabelText}>\n {showPasswordText}\n </Toggle>\n </Markup.Wrapper>\n </Root>\n );\n}\n"]}
@@ -1,8 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import * as Markup from 'govuk-frontend-react/radios';
3
3
  export { Item, Label, Hint, Divider, type ItemProps, type LabelProps, type HintProps, type DividerProps, } from 'govuk-frontend-react/radios';
4
- /** Shows a reveal only while its radio is checked, before or without JavaScript. */
5
- export declare const radiosCss: string;
6
4
  export type RootProps = Markup.RootProps;
7
5
  /**
8
6
  * Let users select a single option from a list using the radios component.
@@ -9,18 +9,9 @@ import { joinIds } from '../../utils/join-ids.js';
9
9
  * `:has()`, and always where it doesn't, as in govuk-frontend.
10
10
  */
11
11
  export { Item, Label, Hint, Divider, } from 'govuk-frontend-react/radios';
12
- /** Shows a reveal only while its radio is checked, before or without JavaScript. */
13
- export const radiosCss = [
14
- // Hides a reveal whose radio isn't checked.
15
- '.govuk-radios__item:has(>.govuk-radios__input:not(:checked))+.govuk-radios__conditional{display:none}',
16
- // Shows one whose radio is, over govuk-frontend's hidden class, until the element upgrades.
17
- '.govuk-radios__item:has(>.govuk-radios__input:checked)+.govuk-radios__conditional{display:block}',
18
- ].join('');
19
12
  /** The element and styles around the radios, for `Root` and `Field`. */
20
13
  function Behaviour({ children }) {
21
- return (React.createElement(Primitives.Root, { upgradedClass: "govuk-frontend-supported", hiddenConditionalClass: "govuk-radios__conditional--hidden" },
22
- React.createElement("style", { href: "govuk-react-radios", precedence: "default" }, radiosCss),
23
- children));
14
+ return (React.createElement(Primitives.Root, { upgradedClass: "govuk-frontend-supported", hiddenConditionalClass: "govuk-radios__conditional--hidden" }, children));
24
15
  }
25
16
  /**
26
17
  * Let users select a single option from a list using the radios component.
@@ -1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AID;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAc;IAC7D,OAAO,CACL,oBAAC,SAAS;QACR,oBAAC,MAAM,CAAC,KAAK,OAAK,KAAK,IACpB,KAAK;YACJ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACxB,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,CAClB,oBAAC,MAAM,CAAC,OAAO,IAAC,GAAG,EAAE,KAAK,IAAG,IAAI,CAAC,OAAO,CAAkB,CAC5D,CAAC,CAAC,CAAC,CACF,oBAAC,aAAa,IAAC,GAAG,EAAE,KAAK,KAAM,IAAI,GAAI,CACxC,CACF;YACH,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CACjB,CACL,CACb,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { Children } from 'react';\nimport * as Primitives from '@govuk-react/primitives/choices';\nimport * as Markup from 'govuk-frontend-react/radios';\nimport { joinIds } from '../../utils/join-ids.js';\n\n/*\n * govuk-frontend-react's Radios markup, with conditional reveals from @govuk-react/primitives.\n * Without JavaScript, a reveal shows only while its radio is checked, where the browser supports\n * `:has()`, and always where it doesn't, as in govuk-frontend.\n */\n\nexport {\n Item,\n Label,\n Hint,\n Divider,\n type ItemProps,\n type LabelProps,\n type HintProps,\n type DividerProps,\n} from 'govuk-frontend-react/radios';\n\n/** Shows a reveal only while its radio is checked, before or without JavaScript. */\nexport const radiosCss = [\n // Hides a reveal whose radio isn't checked.\n '.govuk-radios__item:has(>.govuk-radios__input:not(:checked))+.govuk-radios__conditional{display:none}',\n // Shows one whose radio is, over govuk-frontend's hidden class, until the element upgrades.\n '.govuk-radios__item:has(>.govuk-radios__input:checked)+.govuk-radios__conditional{display:block}',\n].join('');\n\n/** The element and styles around the radios, for `Root` and `Field`. */\nfunction Behaviour({ children }: { children: React.ReactNode }) {\n return (\n <Primitives.Root\n upgradedClass=\"govuk-frontend-supported\"\n hiddenConditionalClass=\"govuk-radios__conditional--hidden\"\n >\n <style href=\"govuk-react-radios\" precedence=\"default\">\n {radiosCss}\n </style>\n {children}\n </Primitives.Root>\n );\n}\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Let users select a single option from a list using the radios component.\n *\n * Children are `Item`s, each with an `Input`, followed by a `Conditional` where it reveals one.\n *\n * @see https://design-system.service.gov.uk/components/radios/\n */\nexport function Root(props: RootProps) {\n return (\n <Behaviour>\n <Markup.Root {...props} />\n </Behaviour>\n );\n}\n\nexport type InputProps = Markup.InputProps & {\n /** The id of the `Conditional` this radio reveals. */\n controls?: string;\n};\n\nexport function Input({ controls, ...props }: InputProps) {\n return (\n <Primitives.Input asChild controls={controls}>\n <Markup.Input {...props} />\n </Primitives.Input>\n );\n}\n\nexport type ConditionalProps = Markup.ConditionalProps;\n\n/** Content revealed while its radio is checked, straight after its `Item`. Pass the radio's `checked` or `defaultChecked` as `checked`. */\nexport function Conditional(props: ConditionalProps) {\n return (\n <Primitives.Conditional asChild>\n <Markup.Conditional {...props} />\n </Primitives.Conditional>\n );\n}\n\nexport type ItemCompositeProps = Markup.ItemCompositeProps;\n\nconst isSet = (node: React.ReactNode) => node !== undefined && node !== null && node !== false && node !== '';\n\nexport function ItemComposite({\n id,\n label,\n hint,\n conditional,\n 'aria-describedby': describedBy,\n ...props\n}: ItemCompositeProps) {\n const hintId = isSet(hint) ? `${id}-item-hint` : undefined;\n const conditionalId = isSet(conditional) ? `conditional-${id}` : undefined;\n return (\n <>\n <Markup.Item>\n <Input id={id} controls={conditionalId} aria-describedby={joinIds(describedBy, hintId)} {...props} />\n <Markup.Label htmlFor={id}>{label}</Markup.Label>\n {hintId && <Markup.Hint id={hintId}>{hint}</Markup.Hint>}\n </Markup.Item>\n {conditionalId && (\n <Conditional id={conditionalId} checked={Boolean(props.checked ?? props.defaultChecked)}>\n {conditional}\n </Conditional>\n )}\n </>\n );\n}\n\nexport type FieldProps = Markup.FieldProps;\n\n/**\n * Let users select a single option from a list using the radios component.\n *\n * Children are `ItemComposite`s and `Divider`s.\n *\n * @see https://design-system.service.gov.uk/components/radios/\n */\nexport function Field({ items, children, ...props }: FieldProps) {\n return (\n <Behaviour>\n <Markup.Field {...props}>\n {items\n ? items.map((item, index) =>\n 'divider' in item ? (\n <Markup.Divider key={index}>{item.divider}</Markup.Divider>\n ) : (\n <ItemComposite key={index} {...item} />\n )\n )\n : Children.toArray(children)}\n </Markup.Field>\n </Behaviour>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/radios/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD;;;;GAIG;AAEH,OAAO,EACL,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,OAAO,GAKR,MAAM,6BAA6B,CAAC;AAErC,wEAAwE;AACxE,SAAS,SAAS,CAAC,EAAE,QAAQ,EAAiC;IAC5D,OAAO,CACL,oBAAC,UAAU,CAAC,IAAI,IACd,aAAa,EAAC,0BAA0B,EACxC,sBAAsB,EAAC,mCAAmC,IAEzD,QAAQ,CACO,CACnB,CAAC;AACJ,CAAC;AAID;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,KAAgB;IACnC,OAAO,CACL,oBAAC,SAAS;QACR,oBAAC,MAAM,CAAC,IAAI,OAAK,KAAK,GAAI,CAChB,CACb,CAAC;AACJ,CAAC;AAOD,MAAM,UAAU,KAAK,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAc;IACtD,OAAO,CACL,oBAAC,UAAU,CAAC,KAAK,I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AE,OAAO,CAAC,MAAA,KAAK,CAAC,OAAO,mCAAI,KAAK,CAAC,cAAc,CAAC,IACpF,WAAW,CACA,CACf,CACA,CACJ,CAAC;AACJ,CAAC;AAID;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAc;IAC7D,OAAO,CACL,oBAAC,SAAS;QACR,oBAAC,MAAM,CAAC,KAAK,OAAK,KAAK,IACpB,KAAK;YACJ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACxB,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,CAClB,oBAAC,MAAM,CAAC,OAAO,IAAC,GAAG,EAAE,KAAK,IAAG,IAAI,CAAC,OAAO,CAAkB,CAC5D,CAAC,CAAC,CAAC,CACF,oBAAC,aAAa,IAAC,GAAG,EAAE,KAAK,KAAM,IAAI,GAAI,CACxC,CACF;YACH,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CACjB,CACL,CACb,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { Children } from 'react';\nimport * as Primitives from '@govuk-react/primitives/choices';\nimport * as Markup from 'govuk-frontend-react/radios';\nimport { joinIds } from '../../utils/join-ids.js';\n\n/*\n * govuk-frontend-react's Radios markup, with conditional reveals from @govuk-react/primitives.\n * Without JavaScript, a reveal shows only while its radio is checked, where the browser supports\n * `:has()`, and always where it doesn't, as in govuk-frontend.\n */\n\nexport {\n Item,\n Label,\n Hint,\n Divider,\n type ItemProps,\n type LabelProps,\n type HintProps,\n type DividerProps,\n} from 'govuk-frontend-react/radios';\n\n/** The element and styles around the radios, for `Root` and `Field`. */\nfunction Behaviour({ children }: { children: React.ReactNode }) {\n return (\n <Primitives.Root\n upgradedClass=\"govuk-frontend-supported\"\n hiddenConditionalClass=\"govuk-radios__conditional--hidden\"\n >\n {children}\n </Primitives.Root>\n );\n}\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Let users select a single option from a list using the radios component.\n *\n * Children are `Item`s, each with an `Input`, followed by a `Conditional` where it reveals one.\n *\n * @see https://design-system.service.gov.uk/components/radios/\n */\nexport function Root(props: RootProps) {\n return (\n <Behaviour>\n <Markup.Root {...props} />\n </Behaviour>\n );\n}\n\nexport type InputProps = Markup.InputProps & {\n /** The id of the `Conditional` this radio reveals. */\n controls?: string;\n};\n\nexport function Input({ controls, ...props }: InputProps) {\n return (\n <Primitives.Input asChild controls={controls}>\n <Markup.Input {...props} />\n </Primitives.Input>\n );\n}\n\nexport type ConditionalProps = Markup.ConditionalProps;\n\n/** Content revealed while its radio is checked, straight after its `Item`. Pass the radio's `checked` or `defaultChecked` as `checked`. */\nexport function Conditional(props: ConditionalProps) {\n return (\n <Primitives.Conditional asChild>\n <Markup.Conditional {...props} />\n </Primitives.Conditional>\n );\n}\n\nexport type ItemCompositeProps = Markup.ItemCompositeProps;\n\nconst isSet = (node: React.ReactNode) => node !== undefined && node !== null && node !== false && node !== '';\n\nexport function ItemComposite({\n id,\n label,\n hint,\n conditional,\n 'aria-describedby': describedBy,\n ...props\n}: ItemCompositeProps) {\n const hintId = isSet(hint) ? `${id}-item-hint` : undefined;\n const conditionalId = isSet(conditional) ? `conditional-${id}` : undefined;\n return (\n <>\n <Markup.Item>\n <Input id={id} controls={conditionalId} aria-describedby={joinIds(describedBy, hintId)} {...props} />\n <Markup.Label htmlFor={id}>{label}</Markup.Label>\n {hintId && <Markup.Hint id={hintId}>{hint}</Markup.Hint>}\n </Markup.Item>\n {conditionalId && (\n <Conditional id={conditionalId} checked={Boolean(props.checked ?? props.defaultChecked)}>\n {conditional}\n </Conditional>\n )}\n </>\n );\n}\n\nexport type FieldProps = Markup.FieldProps;\n\n/**\n * Let users select a single option from a list using the radios component.\n *\n * Children are `ItemComposite`s and `Divider`s.\n *\n * @see https://design-system.service.gov.uk/components/radios/\n */\nexport function Field({ items, children, ...props }: FieldProps) {\n return (\n <Behaviour>\n <Markup.Field {...props}>\n {items\n ? items.map((item, index) =>\n 'divider' in item ? (\n <Markup.Divider key={index}>{item.divider}</Markup.Divider>\n ) : (\n <ItemComposite key={index} {...item} />\n )\n )\n : Children.toArray(children)}\n </Markup.Field>\n </Behaviour>\n );\n}\n"]}
@@ -1,7 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import type { ComponentProps, ReactNode } from 'react';
3
- /** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */
4
- export declare const relatedItemsCss = ".govuk-react-related-items{border-top:2px solid var(--govuk-brand-colour,#1d70b8);padding-top:10px}";
5
3
  export type RootProps = ComponentProps<'div'>;
6
4
  /** Related content, such as topics, guidance and collections. */
7
5
  export declare function Root({ className, children, ...props }: RootProps): React.JSX.Element;
@@ -2,13 +2,9 @@ import * as React from 'react';
2
2
  import { useId } from 'react';
3
3
  import { clsx } from 'clsx';
4
4
  const name = 'govuk-react-related-items';
5
- /** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */
6
- export const relatedItemsCss = `.${name}{border-top:2px solid var(--govuk-brand-colour,#1d70b8);padding-top:10px}`;
7
5
  /** Related content, such as topics, guidance and collections. */
8
6
  export function Root({ className, children, ...props }) {
9
- return (React.createElement("div", { className: clsx(name, className), ...props },
10
- React.createElement("style", { href: name, precedence: "default" }, relatedItemsCss),
11
- children));
7
+ return (React.createElement("div", { className: clsx(name, className), ...props }, children));
12
8
  }
13
9
  export function Heading({ className, children, ...props }) {
14
10
  return (React.createElement("h2", { className: clsx('govuk-heading-s', className), ...props }, children));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/related-items/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,IAAI,GAAG,2BAA2B,CAAC;AAE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Q,EAAE,GAAG,KAAK,EAAyB;IACnF,MAAM,SAAS,GAAG,KAAK,EAAE,CAAC;IAC1B,OAAO,CACL,oBAAC,OAAO,uBAAkB,SAAS,KAAM,KAAK;QAC5C,oBAAC,cAAc,IAAC,EAAE,EAAE,SAAS,IAAG,KAAK,CAAkB;QACvD,oBAAC,IAAI,QAAE,QAAQ,CAAQ,CACf,CACX,CAAC;AACJ,CAAC;AAOD;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,EAAE,KAAK,GAAG,iBAAiB,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAkB;IACzF,OAAO,CACL,oBAAC,IAAI,OAAK,KAAK;QACb,oBAAC,OAAO,QAAE,KAAK,CAAW;QACzB,QAAQ,CACJ,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useId } from 'react';\nimport { clsx } from 'clsx';\n\nconst name = 'govuk-react-related-items';\n\n/** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */\nexport const relatedItemsCss = `.${name}{border-top:2px solid var(--govuk-brand-colour,#1d70b8);padding-top:10px}`;\n\nexport type RootProps = ComponentProps<'div'>;\n\n/** Related content, such as topics, guidance and collections. */\nexport function Root({ className, children, ...props }: RootProps) {\n return (\n <div className={clsx(name, className)} {...props}>\n <style href={name} precedence=\"default\">\n {relatedItemsCss}\n </style>\n {children}\n </div>\n );\n}\n\nexport type HeadingProps = ComponentProps<'h2'>;\n\nexport function Heading({ className, children, ...props }: HeadingProps) {\n return (\n <h2 className={clsx('govuk-heading-s', className)} {...props}>\n {children}\n </h2>\n );\n}\n\nexport type SectionProps = ComponentProps<'nav'>;\n\nexport function Section(props: SectionProps) {\n return <nav {...props} />;\n}\n\nexport type SectionHeadingProps = ComponentProps<'h3'>;\n\nexport function SectionHeading({ className, children, ...props }: SectionHeadingProps) {\n return (\n <h3 className={clsx('govuk-body-s', 'govuk-!-font-weight-bold', 'govuk-!-margin-bottom-2', className)} {...props}>\n {children}\n </h3>\n );\n}\n\nexport type ListProps = ComponentProps<'ul'>;\n\nexport function List({ className, ...props }: ListProps) {\n return <ul className={clsx('govuk-list', 'govuk-body-s', className)} {...props} />;\n}\n\nexport type ItemProps = ComponentProps<'li'>;\n\nexport function Item(props: ItemProps) {\n return <li {...props} />;\n}\n\nexport type SectionCompositeProps = Omit<SectionProps, 'title'> & {\n /** The section heading, such as “Travel abroad”. Also labels the navigation landmark. */\n title: ReactNode;\n};\n\n/** A labelled navigation section with a heading and a list. Children are `Item`s. */\nexport function SectionComposite({ title, children, ...props }: SectionCompositeProps) {\n const headingId = useId();\n return (\n <Section aria-labelledby={headingId} {...props}>\n <SectionHeading id={headingId}>{title}</SectionHeading>\n <List>{children}</List>\n </Section>\n );\n}\n\nexport type CompositeProps = Omit<RootProps, 'title'> & {\n /** The main heading. */\n title?: ReactNode;\n};\n\n/**\n * Related content, including topics, guidance and collections. Children are `SectionComposite`s.\n *\n * @see https://components.publishing.service.gov.uk/component-guide/related_navigation\n */\nexport function Composite({ title = 'Related content', children, ...props }: CompositeProps) {\n return (\n <Root {...props}>\n <Heading>{title}</Heading>\n {children}\n </Root>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/related-items/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,IAAI,GAAG,2BAA2B,CAAC;AAIzC,iEAAiE;AACjE,MAAM,UAAU,IAAI,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAa;IAC/D,OAAO,CACL,6BAAK,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,KAAM,KAAK,IAC7C,QAAQ,CACL,CACP,CAAC;AACJ,CAAC;AAID,MAAM,UAAU,O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,oBAAC,IAAI,OAAK,KAAK;QACb,oBAAC,OAAO,QAAE,KAAK,CAAW;QACzB,QAAQ,CACJ,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useId } from 'react';\nimport { clsx } from 'clsx';\n\nconst name = 'govuk-react-related-items';\n\nexport type RootProps = ComponentProps<'div'>;\n\n/** Related content, such as topics, guidance and collections. */\nexport function Root({ className, children, ...props }: RootProps) {\n return (\n <div className={clsx(name, className)} {...props}>\n {children}\n </div>\n );\n}\n\nexport type HeadingProps = ComponentProps<'h2'>;\n\nexport function Heading({ className, children, ...props }: HeadingProps) {\n return (\n <h2 className={clsx('govuk-heading-s', className)} {...props}>\n {children}\n </h2>\n );\n}\n\nexport type SectionProps = ComponentProps<'nav'>;\n\nexport function Section(props: SectionProps) {\n return <nav {...props} />;\n}\n\nexport type SectionHeadingProps = ComponentProps<'h3'>;\n\nexport function SectionHeading({ className, children, ...props }: SectionHeadingProps) {\n return (\n <h3 className={clsx('govuk-body-s', 'govuk-!-font-weight-bold', 'govuk-!-margin-bottom-2', className)} {...props}>\n {children}\n </h3>\n );\n}\n\nexport type ListProps = ComponentProps<'ul'>;\n\nexport function List({ className, ...props }: ListProps) {\n return <ul className={clsx('govuk-list', 'govuk-body-s', className)} {...props} />;\n}\n\nexport type ItemProps = ComponentProps<'li'>;\n\nexport function Item(props: ItemProps) {\n return <li {...props} />;\n}\n\nexport type SectionCompositeProps = Omit<SectionProps, 'title'> & {\n /** The section heading, such as “Travel abroad”. Also labels the navigation landmark. */\n title: ReactNode;\n};\n\n/** A labelled navigation section with a heading and a list. Children are `Item`s. */\nexport function SectionComposite({ title, children, ...props }: SectionCompositeProps) {\n const headingId = useId();\n return (\n <Section aria-labelledby={headingId} {...props}>\n <SectionHeading id={headingId}>{title}</SectionHeading>\n <List>{children}</List>\n </Section>\n );\n}\n\nexport type CompositeProps = Omit<RootProps, 'title'> & {\n /** The main heading. */\n title?: ReactNode;\n};\n\n/**\n * Related content, including topics, guidance and collections. Children are `SectionComposite`s.\n *\n * @see https://components.publishing.service.gov.uk/component-guide/related_navigation\n */\nexport function Composite({ title = 'Related content', children, ...props }: CompositeProps) {\n return (\n <Root {...props}>\n <Heading>{title}</Heading>\n {children}\n </Root>\n );\n}\n"]}
@@ -1,8 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import type { ComponentProps, ReactNode } from 'react';
3
3
  import * as Primitives from '@govuk-react/primitives/autocomplete';
4
- /** Styles govuk-frontend has no class for, hoisted and deduplicated by React. Based on GOV.UK’s search component. */
5
- export declare const searchBoxCss = "\n.govuk-react-search-box__wrapper{display:flex;background-color:#fff}\n.govuk-react-search-box__input{margin:0;-webkit-appearance:none;appearance:none}\n.govuk-react-search-box__input:focus{z-index:1}\n.govuk-react-search-box__button{position:relative;flex:0 0 auto;width:2.5rem;height:2.5rem;margin:0;padding:0;border:0;border-radius:0;outline:2px solid transparent;outline-offset:0;cursor:pointer;background-color:var(--govuk-brand-colour,#1d70b8);color:#fff}\n.govuk-react-search-box__button:hover{background-color:color-mix(in srgb,var(--govuk-brand-colour,#1d70b8) 75%,#000)}\n.govuk-react-search-box__button:focus{z-index:1;outline:3px solid var(--govuk-focus-colour,#fd0);box-shadow:inset 0 0 0 4px #0b0c0c}\n.govuk-react-search-box__icon{position:absolute;inset:0;width:100%;height:100%;transform:scale(.5);pointer-events:none}\n.govuk-react-search-box:not(.govuk-react-search-box--inverse) .govuk-react-search-box__input{border-right-width:0}\n.govuk-react-search-box:not(.govuk-react-search-box--inverse) .govuk-react-search-box__input:focus{border-right-width:2px}\n.govuk-react-search-box--inverse .govuk-react-search-box__label{color:#fff}\n.govuk-react-search-box--inverse .govuk-react-search-box__input{border-width:0}\n.govuk-react-search-box--inverse .govuk-react-search-box__button{background-color:color-mix(in srgb,var(--govuk-brand-colour,#1d70b8) 20%,#fff);color:var(--govuk-brand-colour,#1d70b8)}\n.govuk-react-search-box--inverse .govuk-react-search-box__button:hover{background-color:color-mix(in srgb,var(--govuk-brand-colour,#1d70b8) 5%,#fff)}\n.govuk-react-search-box--large .govuk-react-search-box__input{height:3.125rem}\n.govuk-react-search-box--large .govuk-react-search-box__button{width:3.125rem;height:3.125rem}\n.govuk-react-search-box--large .govuk-react-search-box__icon{transform:scale(.4)}\n.govuk-react-search-box__autocomplete{display:block;position:relative}\n.govuk-react-search-box__menu{position:absolute;z-index:100;top:100%;left:0;right:0;margin:0;padding:0;list-style:none;overflow-x:hidden;background-color:#fff;border:1px solid #b1b4b6;border-top:0}\n.govuk-react-search-box--inverse .govuk-react-search-box__menu{border-top:1px solid #b1b4b6}\n.govuk-react-search-box__option{cursor:pointer;font-family:\"GDS Transport\",arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:1rem;line-height:1.25;color:#0b0c0c}\n@media (min-width:40.0625em){.govuk-react-search-box__option{font-size:1.1875rem;line-height:1.3157894737}}\n.govuk-react-search-box__option>*{pointer-events:none}\n.govuk-react-search-box__option[data-focused],.govuk-react-search-box__option:hover,.govuk-react-search-box__option:focus-visible{background-color:#f3f3f3;outline:none;text-decoration:underline;text-decoration-thickness:max(3px,.1875rem,.12em);text-underline-offset:.1578em}\n.govuk-react-search-box__option:focus-visible .govuk-react-search-box__suggestion-text{background-color:var(--govuk-focus-colour,#fd0)}\n.govuk-react-search-box__option[hidden]{display:none}\n.govuk-react-search-box__option-wrapper{display:flex;align-items:center;margin:0 15px;padding:5px 0}\n.govuk-react-search-box__option:not([hidden])~.govuk-react-search-box__option:not([hidden]) .govuk-react-search-box__option-wrapper{border-top:1px solid #b1b4b6}\n.govuk-react-search-box__suggestion-icon{flex:none;width:20px;height:2.5rem;margin-right:10px;background-color:#505a5f;-webkit-mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 27 27'%3E%3Ccircle cx='12' cy='11' r='8.5' fill='none' stroke='%23000' stroke-width='3'/%3E%3Cpath d='m17.9 17.4 8.5 8.5' stroke='%23000' stroke-width='3'/%3E%3C/svg%3E\") center/contain no-repeat;mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 27 27'%3E%3Ccircle cx='12' cy='11' r='8.5' fill='none' stroke='%23000' stroke-width='3'/%3E%3Cpath d='m17.9 17.4 8.5 8.5' stroke='%23000' stroke-width='3'/%3E%3C/svg%3E\") center/contain no-repeat}\n.govuk-react-search-box__option[data-focused] .govuk-react-search-box__suggestion-icon,.govuk-react-search-box__option:hover .govuk-react-search-box__suggestion-icon,.govuk-react-search-box__option:focus-visible .govuk-react-search-box__suggestion-icon{background-color:#0b0c0c}\n.govuk-react-search-box__suggestion-text{font-weight:700}\n.govuk-react-search-box__suggestion-highlight{font-weight:400;background:none;color:inherit}\n.govuk-react-search-box--large .govuk-react-search-box__option{min-height:3.125rem}\n@media (forced-colors:active){.govuk-react-search-box__menu{border-color:FieldText}.govuk-react-search-box__option[data-focused],.govuk-react-search-box__option:hover{forced-color-adjust:none;background-color:Highlight;color:HighlightText}.govuk-react-search-box__suggestion-icon{background-color:currentcolor}}\n";
6
4
  export type RootProps = ComponentProps<'div'> & {
7
5
  /** For use on dark backgrounds, such as a GOV.UK blue homepage banner. */
8
6
  inverse?: boolean;
@@ -65,7 +63,7 @@ export type MatchProps = ComponentProps<'mark'>;
65
63
  export declare function Match({ className, ...props }: MatchProps): React.JSX.Element;
66
64
  export type StatusProps = Primitives.StatusProps;
67
65
  /** What screen readers hear about the suggestions. Visually hidden. */
68
- export declare function Status(props: StatusProps): React.JSX.Element;
66
+ export declare function Status({ className, ...props }: StatusProps): React.JSX.Element;
69
67
  export type AssistiveHintProps = Primitives.AssistiveHintProps;
70
68
  /** How to use the suggestions, for screen readers. Never shown. */
71
69
  export declare function AssistiveHint({ children, ...props }: AssistiveHintProps): React.JSX.Element;
@@ -2,49 +2,9 @@ import * as React from 'react';
2
2
  import { clsx } from 'clsx';
3
3
  import * as Primitives from '@govuk-react/primitives/autocomplete';
4
4
  const name = 'govuk-react-search-box';
5
- const brand = 'var(--govuk-brand-colour,#1d70b8)';
6
- const suggestionIcon = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 27 27'%3E%3Ccircle cx='12' cy='11' r='8.5' fill='none' stroke='%23000' stroke-width='3'/%3E%3Cpath d='m17.9 17.4 8.5 8.5' stroke='%23000' stroke-width='3'/%3E%3C/svg%3E";
7
- /** Styles govuk-frontend has no class for, hoisted and deduplicated by React. Based on GOV.UK’s search component. */
8
- export const searchBoxCss = `
9
- .${name}__wrapper{display:flex;background-color:#fff}
10
- .${name}__input{margin:0;-webkit-appearance:none;appearance:none}
11
- .${name}__input:focus{z-index:1}
12
- .${name}__button{position:relative;flex:0 0 auto;width:2.5rem;height:2.5rem;margin:0;padding:0;border:0;border-radius:0;outline:2px solid transparent;outline-offset:0;cursor:pointer;background-color:${brand};color:#fff}
13
- .${name}__button:hover{background-color:color-mix(in srgb,${brand} 75%,#000)}
14
- .${name}__button:focus{z-index:1;outline:3px solid var(--govuk-focus-colour,#fd0);box-shadow:inset 0 0 0 4px #0b0c0c}
15
- .${name}__icon{position:absolute;inset:0;width:100%;height:100%;transform:scale(.5);pointer-events:none}
16
- .${name}:not(.${name}--inverse) .${name}__input{border-right-width:0}
17
- .${name}:not(.${name}--inverse) .${name}__input:focus{border-right-width:2px}
18
- .${name}--inverse .${name}__label{color:#fff}
19
- .${name}--inverse .${name}__input{border-width:0}
20
- .${name}--inverse .${name}__button{background-color:color-mix(in srgb,${brand} 20%,#fff);color:${brand}}
21
- .${name}--inverse .${name}__button:hover{background-color:color-mix(in srgb,${brand} 5%,#fff)}
22
- .${name}--large .${name}__input{height:3.125rem}
23
- .${name}--large .${name}__button{width:3.125rem;height:3.125rem}
24
- .${name}--large .${name}__icon{transform:scale(.4)}
25
- .${name}__autocomplete{display:block;position:relative}
26
- .${name}__menu{position:absolute;z-index:100;top:100%;left:0;right:0;margin:0;padding:0;list-style:none;overflow-x:hidden;background-color:#fff;border:1px solid #b1b4b6;border-top:0}
27
- .${name}--inverse .${name}__menu{border-top:1px solid #b1b4b6}
28
- .${name}__option{cursor:pointer;font-family:"GDS Transport",arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:1rem;line-height:1.25;color:#0b0c0c}
29
- @media (min-width:40.0625em){.${name}__option{font-size:1.1875rem;line-height:1.3157894737}}
30
- .${name}__option>*{pointer-events:none}
31
- .${name}__option[data-focused],.${name}__option:hover,.${name}__option:focus-visible{background-color:#f3f3f3;outline:none;text-decoration:underline;text-decoration-thickness:max(3px,.1875rem,.12em);text-underline-offset:.1578em}
32
- .${name}__option:focus-visible .${name}__suggestion-text{background-color:var(--govuk-focus-colour,#fd0)}
33
- .${name}__option[hidden]{display:none}
34
- .${name}__option-wrapper{display:flex;align-items:center;margin:0 15px;padding:5px 0}
35
- .${name}__option:not([hidden])~.${name}__option:not([hidden]) .${name}__option-wrapper{border-top:1px solid #b1b4b6}
36
- .${name}__suggestion-icon{flex:none;width:20px;height:2.5rem;margin-right:10px;background-color:#505a5f;-webkit-mask:url("${suggestionIcon}") center/contain no-repeat;mask:url("${suggestionIcon}") center/contain no-repeat}
37
- .${name}__option[data-focused] .${name}__suggestion-icon,.${name}__option:hover .${name}__suggestion-icon,.${name}__option:focus-visible .${name}__suggestion-icon{background-color:#0b0c0c}
38
- .${name}__suggestion-text{font-weight:700}
39
- .${name}__suggestion-highlight{font-weight:400;background:none;color:inherit}
40
- .${name}--large .${name}__option{min-height:3.125rem}
41
- @media (forced-colors:active){.${name}__menu{border-color:FieldText}.${name}__option[data-focused],.${name}__option:hover{forced-color-adjust:none;background-color:Highlight;color:HighlightText}.${name}__suggestion-icon{background-color:currentcolor}}
42
- `;
43
5
  /** Wraps the search label, input and submit button. */
44
6
  export function Root({ inverse, large, className, children, ...props }) {
45
- return (React.createElement("div", { className: clsx(name, inverse && `${name}--inverse`, large && `${name}--large`, className), ...props },
46
- React.createElement("style", { href: name, precedence: "default" }, searchBoxCss),
47
- children));
7
+ return (React.createElement("div", { className: clsx(name, inverse && `${name}--inverse`, large && `${name}--large`, className), ...props }, children));
48
8
  }
49
9
  export function Label({ size, visuallyHidden, className, children, ...props }) {
50
10
  return (React.createElement("label", { className: clsx(visuallyHidden ? 'govuk-visually-hidden' : ['govuk-label', size && `govuk-label--${size}`], `${name}__label`, className), ...props }, children));
@@ -105,8 +65,8 @@ export function Match({ className, ...props }) {
105
65
  return React.createElement("mark", { className: clsx(`${name}__suggestion-highlight`, className), ...props });
106
66
  }
107
67
  /** What screen readers hear about the suggestions. Visually hidden. */
108
- export function Status(props) {
109
- return React.createElement(Primitives.Status, { ...props });
68
+ export function Status({ className, ...props }) {
69
+ return React.createElement(Primitives.Status, { className: clsx('govuk-visually-hidden', className), ...props });
110
70
  }
111
71
  /** How to use the suggestions, for screen readers. Never shown. */
112
72
  export function AssistiveHint({ children = 'When search suggestions are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.', ...props }) {
@@ -122,7 +82,7 @@ export function AssistiveHint({ children = 'When search suggestions are availabl
122
82
  export function AutocompleteComposite({ id, label = 'Search on GOV.UK', labelSize, labelVisuallyHidden, buttonText, inverse, large, minLength = 3, filter, onQueryChange, onConfirm, suggestions, children, ...props }) {
123
83
  return (React.createElement(Root, { inverse: inverse, large: large },
124
84
  React.createElement(Label, { htmlFor: id, size: labelSize, visuallyHidden: labelVisuallyHidden }, label),
125
- React.createElement(Autocomplete, { minLength: minLength, filter: filter, onQueryChange: onQueryChange, onConfirm: onConfirm, confirmOnBlur: false, submitOnConfirm: true, statusNoResults: "No search suggestions found", statusQueryTooShort: "Type in %{count} or more characters for search suggestions", statusResults: {
85
+ React.createElement(Autocomplete, { minLength: minLength, filter: filter, onQueryChange: onQueryChange, onConfirm: onConfirm, confirmOnBlur: false, submitOnConfirm: true, noResultsAnnouncement: "No search suggestions found", queryTooShortAnnouncement: "Type in %{count} or more characters for search suggestions", resultsAnnouncement: {
126
86
  one: '%{count} search suggestion is available.',
127
87
  other: '%{count} search suggestions are available.',
128
88
  } },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/search-box/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,UAAU,MAAM,sCAAsC,CAAC;AAEnE,MAAM,IAAI,GAAG,wBAAwB,CAAC;AACtC,MAAM,KAAK,GAAG,mCAAmC,CAAC;AAClD,MAAM,cAAc,GAClB,oPAAoP,CAAC;AAEvP,qHAAqH;AACrH,MAAM,CAAC,MAAM,YAAY,GAAG;GACzB,IAAI;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI,kMAAkM,KAAK;GAC3M,IAAI,qDAAqD,KAAK;GAC9D,IAAI;GACJ,IAAI;GACJ,IAAI,SAAS,IAAI,eAAe,IAAI;GACpC,IAAI,SAAS,IAAI,eAAe,IAAI;GACpC,IAAI,cAAc,IAAI;GACtB,IAAI,cAAc,IAAI;GACtB,IAAI,cAAc,IAAI,+CAA+C,KAAK,oBAAoB,KAAK;GACnG,IAAI,cAAc,IAAI,qDAAqD,KAAK;GAChF,IAAI,YAAY,IAAI;GACpB,IAAI,YAAY,IAAI;GACpB,IAAI,YAAY,IAAI;GACpB,IAAI;GACJ,IAAI;GACJ,IAAI,cAAc,IAAI;GACtB,IAAI;gCACyB,IAAI;GACjC,IAAI;GACJ,IAAI,2BAA2B,IAAI,mBAAmB,IAAI;GAC1D,IAAI,2BAA2B,IAAI;GACnC,IAAI;GACJ,IAAI;GACJ,IAAI,2BAA2B,IAAI,2BAA2B,IAAI;GAClE,IAAI,qHAAqH,cAAc,yCAAyC,cAAc;GAC9L,IAAI,2BAA2B,IAAI,sBAAsB,IAAI,mBAAmB,IAAI,sBAAsB,IAAI,2BAA2B,IAAI;GAC7I,IAAI;GACJ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EAAE,EAAE,KAAM,KAAK,GAAI;gBACxC,oBAAC,MAAM,QAAE,UAAU,CAAU,CACrB;YACV,oBAAC,OAAO,QACL,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GACP,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAC/B,oBAAC,MAAM,IAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,IACvC,UAAU,CACJ,CACV,CAAC,CACI;YACV,oBAAC,MAAM,OAAG;YACV,oBAAC,aAAa,OAAG,CACJ,CACV,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ReactNode } from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/autocomplete';\n\nconst name = 'govuk-react-search-box';\nconst brand = 'var(--govuk-brand-colour,#1d70b8)';\nconst suggestionIcon =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 27 27'%3E%3Ccircle cx='12' cy='11' r='8.5' fill='none' stroke='%23000' stroke-width='3'/%3E%3Cpath d='m17.9 17.4 8.5 8.5' stroke='%23000' stroke-width='3'/%3E%3C/svg%3E\";\n\n/** Styles govuk-frontend has no class for, hoisted and deduplicated by React. Based on GOV.UK’s search component. */\nexport const searchBoxCss = `\n.${name}__wrapper{display:flex;background-color:#fff}\n.${name}__input{margin:0;-webkit-appearance:none;appearance:none}\n.${name}__input:focus{z-index:1}\n.${name}__button{position:relative;flex:0 0 auto;width:2.5rem;height:2.5rem;margin:0;padding:0;border:0;border-radius:0;outline:2px solid transparent;outline-offset:0;cursor:pointer;background-color:${brand};color:#fff}\n.${name}__button:hover{background-color:color-mix(in srgb,${brand} 75%,#000)}\n.${name}__button:focus{z-index:1;outline:3px solid var(--govuk-focus-colour,#fd0);box-shadow:inset 0 0 0 4px #0b0c0c}\n.${name}__icon{position:absolute;inset:0;width:100%;height:100%;transform:scale(.5);pointer-events:none}\n.${name}:not(.${name}--inverse) .${name}__input{border-right-width:0}\n.${name}:not(.${name}--inverse) .${name}__input:focus{border-right-width:2px}\n.${name}--inverse .${name}__label{color:#fff}\n.${name}--inverse .${name}__input{border-width:0}\n.${name}--inverse .${name}__button{background-color:color-mix(in srgb,${brand} 20%,#fff);color:${brand}}\n.${name}--inverse .${name}__button:hover{background-color:color-mix(in srgb,${brand} 5%,#fff)}\n.${name}--large .${name}__input{height:3.125rem}\n.${name}--large .${name}__button{width:3.125rem;height:3.125rem}\n.${name}--large .${name}__icon{transform:scale(.4)}\n.${name}__autocomplete{display:block;position:relative}\n.${name}__menu{position:absolute;z-index:100;top:100%;left:0;right:0;margin:0;padding:0;list-style:none;overflow-x:hidden;background-color:#fff;border:1px solid #b1b4b6;border-top:0}\n.${name}--inverse .${name}__menu{border-top:1px solid #b1b4b6}\n.${name}__option{cursor:pointer;font-family:\"GDS Transport\",arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:1rem;line-height:1.25;color:#0b0c0c}\n@media (min-width:40.0625em){.${name}__option{font-size:1.1875rem;line-height:1.3157894737}}\n.${name}__option>*{pointer-events:none}\n.${name}__option[data-focused],.${name}__option:hover,.${name}__option:focus-visible{background-color:#f3f3f3;outline:none;text-decoration:underline;text-decoration-thickness:max(3px,.1875rem,.12em);text-underline-offset:.1578em}\n.${name}__option:focus-visible .${name}__suggestion-text{background-color:var(--govuk-focus-colour,#fd0)}\n.${name}__option[hidden]{display:none}\n.${name}__option-wrapper{display:flex;align-items:center;margin:0 15px;padding:5px 0}\n.${name}__option:not([hidden])~.${name}__option:not([hidden]) .${name}__option-wrapper{border-top:1px solid #b1b4b6}\n.${name}__suggestion-icon{flex:none;width:20px;height:2.5rem;margin-right:10px;background-color:#505a5f;-webkit-mask:url(\"${suggestionIcon}\") center/contain no-repeat;mask:url(\"${suggestionIcon}\") center/contain no-repeat}\n.${name}__option[data-focused] .${name}__suggestion-icon,.${name}__option:hover .${name}__suggestion-icon,.${name}__option:focus-visible .${name}__suggestion-icon{background-color:#0b0c0c}\n.${name}__suggestion-text{font-weight:700}\n.${name}__suggestion-highlight{font-weight:400;background:none;color:inherit}\n.${name}--large .${name}__option{min-height:3.125rem}\n@media (forced-colors:active){.${name}__menu{border-color:FieldText}.${name}__option[data-focused],.${name}__option:hover{forced-color-adjust:none;background-color:Highlight;color:HighlightText}.${name}__suggestion-icon{background-color:currentcolor}}\n`;\n\nexport type RootProps = ComponentProps<'div'> & {\n /** For use on dark backgrounds, such as a GOV.UK blue homepage banner. */\n inverse?: boolean;\n /** A larger input and button. */\n large?: boolean;\n};\n\n/** Wraps the search label, input and submit button. */\nexport function Root({ inverse, large, className, children, ...props }: RootProps) {\n return (\n <div className={clsx(name, inverse && `${name}--inverse`, large && `${name}--large`, className)} {...props}>\n <style href={name} precedence=\"default\">\n {searchBoxCss}\n </style>\n {children}\n </div>\n );\n}\n\nexport type LabelProps = ComponentProps<'label'> & {\n /** The label size, from govuk-frontend’s label sizes. */\n size?: 's' | 'm' | 'l' | 'xl';\n /** Hide the label visually. It’s still read by screen readers. */\n visuallyHidden?: boolean;\n};\n\nexport function Label({ size, visuallyHidden, className, children, ...props }: LabelProps) {\n return (\n <label\n className={clsx(\n visuallyHidden ? 'govuk-visually-hidden' : ['govuk-label', size && `govuk-label--${size}`],\n `${name}__label`,\n className\n )}\n {...props}\n >\n {children}\n </label>\n );\n}\n\nexport type WrapperProps = ComponentProps<'div'>;\n\n/** Lays out the input and submit button side by side. */\nexport function Wrapper({ className, ...props }: WrapperProps) {\n return <div className={clsx(`${name}__wrapper`, className)} {...props} />;\n}\n\nexport type InputProps = ComponentProps<'input'>;\n\nexport function Input({ className, type = 'search', ...props }: InputProps) {\n return (\n <input type={type} enterKeyHint=\"search\" className={clsx('govuk-input', `${name}__input`, className)} {...props} />\n );\n}\n\nexport type ButtonProps = ComponentProps<'button'>;\n\n/** The submit button, with a search icon. Children are its accessible name, “Search” by default. */\nexport function Button({ className, children = 'Search', ...props }: ButtonProps) {\n return (\n <button type=\"submit\" className={clsx(`${name}__button`, className)} {...props}>\n <svg\n className={`${name}__icon`}\n width=\"27\"\n height=\"27\"\n viewBox=\"0 0 27 27\"\n fill=\"none\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <circle cx=\"12.0161\" cy=\"11.0161\" r=\"8.51613\" stroke=\"currentColor\" strokeWidth=\"3\" />\n <line x1=\"17.8668\" y1=\"17.3587\" x2=\"26.4475\" y2=\"25.9393\" stroke=\"currentColor\" strokeWidth=\"3\" />\n </svg>\n <span className=\"govuk-visually-hidden\">{children}</span>\n </button>\n );\n}\n\nexport type CompositeProps = Omit<InputProps, 'id'> &\n Pick<RootProps, 'inverse' | 'large'> & {\n /** The input’s id, which the label points to. */\n id: string;\n /** The label text. */\n label?: ReactNode;\n /** The label size, from govuk-frontend’s label sizes. */\n labelSize?: LabelProps['size'];\n /** Hide the label visually. It’s still read by screen readers. */\n labelVisuallyHidden?: boolean;\n /** The submit button’s visually hidden text. */\n buttonText?: ReactNode;\n };\n\n/**\n * A search input with a label and an attached submit button, based on GOV.UK’s search component. Put it in your own `form`. Other props go on the input.\n *\n * @see https://components.publishing.service.gov.uk/component-guide/search\n */\nexport function Composite({\n id,\n label = 'Search on GOV.UK',\n labelSize,\n labelVisuallyHidden,\n buttonText,\n inverse,\n large,\n ...props\n}: CompositeProps) {\n return (\n <Root inverse={inverse} large={large}>\n <Label htmlFor={id} size={labelSize} visuallyHidden={labelVisuallyHidden}>\n {label}\n </Label>\n <Wrapper>\n <Input id={id} {...props} />\n <Button>{buttonText}</Button>\n </Wrapper>\n </Root>\n );\n}\n\nexport type AutocompleteProps = Primitives.RootProps;\n\n/**\n * Suggests searches as the user types, around `Wrapper`, `Listbox`, `Status` and `AssistiveHint`.\n * Without JavaScript the search box works as usual. Based on GOV.UK’s search with autocomplete,\n * with behaviour from accessible-autocomplete.\n */\nexport function Autocomplete({ className, ...props }: AutocompleteProps) {\n return <Primitives.Root className={clsx(`${name}__autocomplete`, className)} {...props} />;\n}\n\nexport type AutocompleteInputProps = InputProps;\n\n/** `Input`, as the autocomplete’s combobox. */\nexport function AutocompleteInput(props: AutocompleteInputProps) {\n return (\n <Primitives.Input asChild>\n <Input {...props} />\n </Primitives.Input>\n );\n}\n\nexport type ListboxProps = Primitives.ListboxProps;\n\n/** The menu of suggestions, under the search box. Hidden until there are suggestions to show. */\nexport function Listbox({ className, ...props }: ListboxProps) {\n return <Primitives.Listbox className={clsx(`${name}__menu`, className)} {...props} />;\n}\n\nexport type OptionProps = Primitives.OptionProps;\n\n/** A suggestion, in `Listbox`. Children are its text, which can hold `Match`. */\nexport function Option({ className, children, ...props }: OptionProps) {\n return (\n <Primitives.Option className={clsx(`${name}__option`, className)} {...props}>\n <span className={`${name}__option-wrapper`}>\n <span className={`${name}__suggestion-icon`} aria-hidden=\"true\" />\n <span className={`${name}__suggestion-text`}>{children}</span>\n </span>\n </Primitives.Option>\n );\n}\n\nexport type MatchProps = ComponentProps<'mark'>;\n\n/** The part of a suggestion that matches the query, in `Option`. */\nexport function Match({ className, ...props }: MatchProps) {\n return <mark className={clsx(`${name}__suggestion-highlight`, className)} {...props} />;\n}\n\nexport type StatusProps = Primitives.StatusProps;\n\n/** What screen readers hear about the suggestions. Visually hidden. */\nexport function Status(props: StatusProps) {\n return <Primitives.Status {...props} />;\n}\n\nexport type AssistiveHintProps = Primitives.AssistiveHintProps;\n\n/** How to use the suggestions, for screen readers. Never shown. */\nexport function AssistiveHint({\n children = 'When search suggestions are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.',\n ...props\n}: AssistiveHintProps) {\n return <Primitives.AssistiveHint {...props}>{children}</Primitives.AssistiveHint>;\n}\n\nexport type AutocompleteCompositeProps = CompositeProps &\n Pick<AutocompleteProps, 'minLength' | 'filter' | 'onQueryChange' | 'onConfirm'> & {\n /**\n * The suggestions for the query, such as from `onQueryChange`. Only those containing the query\n * show, unless `filter` is \"none\", such as for suggestions a server has already matched.\n * Children are an alternative.\n */\n suggestions?: string[];\n /** `Option`s, rather than `suggestions`, such as to highlight the query with `Match`. */\n children?: ReactNode;\n };\n\n/**\n * A search box that suggests searches as the user types, based on GOV.UK’s search with\n * autocomplete. Choosing a suggestion submits the form. Put it in your own `form`. Other props go\n * on the input. Without JavaScript it’s `Composite`.\n *\n * @see https://components.publishing.service.gov.uk/component-guide/search_with_autocomplete\n */\nexport function AutocompleteComposite({\n id,\n label = 'Search on GOV.UK',\n labelSize,\n labelVisuallyHidden,\n buttonText,\n inverse,\n large,\n minLength = 3,\n filter,\n onQueryChange,\n onConfirm,\n suggestions,\n children,\n ...props\n}: AutocompleteCompositeProps) {\n return (\n <Root inverse={inverse} large={large}>\n <Label htmlFor={id} size={labelSize} visuallyHidden={labelVisuallyHidden}>\n {label}\n </Label>\n <Autocomplete\n minLength={minLength}\n filter={filter}\n onQueryChange={onQueryChange}\n onConfirm={onConfirm}\n confirmOnBlur={false}\n submitOnConfirm\n statusNoResults=\"No search suggestions found\"\n statusQueryTooShort=\"Type in %{count} or more characters for search suggestions\"\n statusResults={{\n one: '%{count} search suggestion is available.',\n other: '%{count} search suggestions are available.',\n }}\n >\n <Wrapper>\n <AutocompleteInput id={id} {...props} />\n <Button>{buttonText}</Button>\n </Wrapper>\n <Listbox>\n {children ??\n suggestions?.map((suggestion) => (\n <Option key={suggestion} value={suggestion}>\n {suggestion}\n </Option>\n ))}\n </Listbox>\n <Status />\n <AssistiveHint />\n </Autocomplete>\n </Root>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/search-box/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,UAAU,MAAM,sCAAsC,CAAC;AAEnE,MAAM,IAAI,GAAG,wBAAwB,CAAC;AAQtC,uDAAuD;AACvD,MAAM,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AAR,QAAQ,cAAR,QAAQ,GACP,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAC/B,oBAAC,MAAM,IAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,IACvC,UAAU,CACJ,CACV,CAAC,CACI;YACV,oBAAC,MAAM,OAAG;YACV,oBAAC,aAAa,OAAG,CACJ,CACV,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ReactNode } from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/autocomplete';\n\nconst name = 'govuk-react-search-box';\nexport type RootProps = ComponentProps<'div'> & {\n /** For use on dark backgrounds, such as a GOV.UK blue homepage banner. */\n inverse?: boolean;\n /** A larger input and button. */\n large?: boolean;\n};\n\n/** Wraps the search label, input and submit button. */\nexport function Root({ inverse, large, className, children, ...props }: RootProps) {\n return (\n <div className={clsx(name, inverse && `${name}--inverse`, large && `${name}--large`, className)} {...props}>\n {children}\n </div>\n );\n}\n\nexport type LabelProps = ComponentProps<'label'> & {\n /** The label size, from govuk-frontend’s label sizes. */\n size?: 's' | 'm' | 'l' | 'xl';\n /** Hide the label visually. It’s still read by screen readers. */\n visuallyHidden?: boolean;\n};\n\nexport function Label({ size, visuallyHidden, className, children, ...props }: LabelProps) {\n return (\n <label\n className={clsx(\n visuallyHidden ? 'govuk-visually-hidden' : ['govuk-label', size && `govuk-label--${size}`],\n `${name}__label`,\n className\n )}\n {...props}\n >\n {children}\n </label>\n );\n}\n\nexport type WrapperProps = ComponentProps<'div'>;\n\n/** Lays out the input and submit button side by side. */\nexport function Wrapper({ className, ...props }: WrapperProps) {\n return <div className={clsx(`${name}__wrapper`, className)} {...props} />;\n}\n\nexport type InputProps = ComponentProps<'input'>;\n\nexport function Input({ className, type = 'search', ...props }: InputProps) {\n return (\n <input type={type} enterKeyHint=\"search\" className={clsx('govuk-input', `${name}__input`, className)} {...props} />\n );\n}\n\nexport type ButtonProps = ComponentProps<'button'>;\n\n/** The submit button, with a search icon. Children are its accessible name, “Search” by default. */\nexport function Button({ className, children = 'Search', ...props }: ButtonProps) {\n return (\n <button type=\"submit\" className={clsx(`${name}__button`, className)} {...props}>\n <svg\n className={`${name}__icon`}\n width=\"27\"\n height=\"27\"\n viewBox=\"0 0 27 27\"\n fill=\"none\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <circle cx=\"12.0161\" cy=\"11.0161\" r=\"8.51613\" stroke=\"currentColor\" strokeWidth=\"3\" />\n <line x1=\"17.8668\" y1=\"17.3587\" x2=\"26.4475\" y2=\"25.9393\" stroke=\"currentColor\" strokeWidth=\"3\" />\n </svg>\n <span className=\"govuk-visually-hidden\">{children}</span>\n </button>\n );\n}\n\nexport type CompositeProps = Omit<InputProps, 'id'> &\n Pick<RootProps, 'inverse' | 'large'> & {\n /** The input’s id, which the label points to. */\n id: string;\n /** The label text. */\n label?: ReactNode;\n /** The label size, from govuk-frontend’s label sizes. */\n labelSize?: LabelProps['size'];\n /** Hide the label visually. It’s still read by screen readers. */\n labelVisuallyHidden?: boolean;\n /** The submit button’s visually hidden text. */\n buttonText?: ReactNode;\n };\n\n/**\n * A search input with a label and an attached submit button, based on GOV.UK’s search component. Put it in your own `form`. Other props go on the input.\n *\n * @see https://components.publishing.service.gov.uk/component-guide/search\n */\nexport function Composite({\n id,\n label = 'Search on GOV.UK',\n labelSize,\n labelVisuallyHidden,\n buttonText,\n inverse,\n large,\n ...props\n}: CompositeProps) {\n return (\n <Root inverse={inverse} large={large}>\n <Label htmlFor={id} size={labelSize} visuallyHidden={labelVisuallyHidden}>\n {label}\n </Label>\n <Wrapper>\n <Input id={id} {...props} />\n <Button>{buttonText}</Button>\n </Wrapper>\n </Root>\n );\n}\n\nexport type AutocompleteProps = Primitives.RootProps;\n\n/**\n * Suggests searches as the user types, around `Wrapper`, `Listbox`, `Status` and `AssistiveHint`.\n * Without JavaScript the search box works as usual. Based on GOV.UK’s search with autocomplete,\n * with behaviour from accessible-autocomplete.\n */\nexport function Autocomplete({ className, ...props }: AutocompleteProps) {\n return <Primitives.Root className={clsx(`${name}__autocomplete`, className)} {...props} />;\n}\n\nexport type AutocompleteInputProps = InputProps;\n\n/** `Input`, as the autocomplete’s combobox. */\nexport function AutocompleteInput(props: AutocompleteInputProps) {\n return (\n <Primitives.Input asChild>\n <Input {...props} />\n </Primitives.Input>\n );\n}\n\nexport type ListboxProps = Primitives.ListboxProps;\n\n/** The menu of suggestions, under the search box. Hidden until there are suggestions to show. */\nexport function Listbox({ className, ...props }: ListboxProps) {\n return <Primitives.Listbox className={clsx(`${name}__menu`, className)} {...props} />;\n}\n\nexport type OptionProps = Primitives.OptionProps;\n\n/** A suggestion, in `Listbox`. Children are its text, which can hold `Match`. */\nexport function Option({ className, children, ...props }: OptionProps) {\n return (\n <Primitives.Option className={clsx(`${name}__option`, className)} {...props}>\n <span className={`${name}__option-wrapper`}>\n <span className={`${name}__suggestion-icon`} aria-hidden=\"true\" />\n <span className={`${name}__suggestion-text`}>{children}</span>\n </span>\n </Primitives.Option>\n );\n}\n\nexport type MatchProps = ComponentProps<'mark'>;\n\n/** The part of a suggestion that matches the query, in `Option`. */\nexport function Match({ className, ...props }: MatchProps) {\n return <mark className={clsx(`${name}__suggestion-highlight`, className)} {...props} />;\n}\n\nexport type StatusProps = Primitives.StatusProps;\n\n/** What screen readers hear about the suggestions. Visually hidden. */\nexport function Status({ className, ...props }: StatusProps) {\n return <Primitives.Status className={clsx('govuk-visually-hidden', className)} {...props} />;\n}\n\nexport type AssistiveHintProps = Primitives.AssistiveHintProps;\n\n/** How to use the suggestions, for screen readers. Never shown. */\nexport function AssistiveHint({\n children = 'When search suggestions are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.',\n ...props\n}: AssistiveHintProps) {\n return <Primitives.AssistiveHint {...props}>{children}</Primitives.AssistiveHint>;\n}\n\nexport type AutocompleteCompositeProps = CompositeProps &\n Pick<AutocompleteProps, 'minLength' | 'filter' | 'onQueryChange' | 'onConfirm'> & {\n /**\n * The suggestions for the query, such as from `onQueryChange`. Only those containing the query\n * show, unless `filter` is \"none\", such as for suggestions a server has already matched.\n * Children are an alternative.\n */\n suggestions?: string[];\n /** `Option`s, rather than `suggestions`, such as to highlight the query with `Match`. */\n children?: ReactNode;\n };\n\n/**\n * A search box that suggests searches as the user types, based on GOV.UK’s search with\n * autocomplete. Choosing a suggestion submits the form. Put it in your own `form`. Other props go\n * on the input. Without JavaScript it’s `Composite`.\n *\n * @see https://components.publishing.service.gov.uk/component-guide/search_with_autocomplete\n */\nexport function AutocompleteComposite({\n id,\n label = 'Search on GOV.UK',\n labelSize,\n labelVisuallyHidden,\n buttonText,\n inverse,\n large,\n minLength = 3,\n filter,\n onQueryChange,\n onConfirm,\n suggestions,\n children,\n ...props\n}: AutocompleteCompositeProps) {\n return (\n <Root inverse={inverse} large={large}>\n <Label htmlFor={id} size={labelSize} visuallyHidden={labelVisuallyHidden}>\n {label}\n </Label>\n <Autocomplete\n minLength={minLength}\n filter={filter}\n onQueryChange={onQueryChange}\n onConfirm={onConfirm}\n confirmOnBlur={false}\n submitOnConfirm\n noResultsAnnouncement=\"No search suggestions found\"\n queryTooShortAnnouncement=\"Type in %{count} or more characters for search suggestions\"\n resultsAnnouncement={{\n one: '%{count} search suggestion is available.',\n other: '%{count} search suggestions are available.',\n }}\n >\n <Wrapper>\n <AutocompleteInput id={id} {...props} />\n <Button>{buttonText}</Button>\n </Wrapper>\n <Listbox>\n {children ??\n suggestions?.map((suggestion) => (\n <Option key={suggestion} value={suggestion}>\n {suggestion}\n </Option>\n ))}\n </Listbox>\n <Status />\n <AssistiveHint />\n </Autocomplete>\n </Root>\n );\n}\n"]}
@@ -8,7 +8,7 @@ type MenuState = {
8
8
  /** Whether the menu is open below tablet width, to control it once hydrated, such as to close it after navigating. */
9
9
  open?: boolean;
10
10
  /** Called when the user opens or closes the menu. */
11
- onOpenChange?: (open: boolean) => void;
11
+ onOpenChange?: (open: boolean, details: Primitives.ChangeDetails) => void;
12
12
  };
13
13
  export type MenuProps = Omit<Primitives.RootProps, 'media' | 'defaultOpen'> & MenuState;
14
14
  /**
@@ -20,8 +20,6 @@ export declare function Menu({ style, ...props }: MenuProps): React.JSX.Element;
20
20
  export type ToggleProps = Markup.ToggleProps;
21
21
  /** The menu button, inside `Menu`. Hidden from tablet width up, and without JavaScript. */
22
22
  export declare function Toggle(props: ToggleProps): React.JSX.Element;
23
- /** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */
24
- export declare const detailsCss = "\n.govuk-react-service-navigation__details>summary{list-style:none}\n.govuk-react-service-navigation__details>summary::-webkit-details-marker{display:none}\n.govuk-react-service-navigation__details[open]>summary::after{transform:rotate(180deg)}\n@supports selector(::details-content){@media (min-width: 40.0625em){.govuk-react-service-navigation__details>summary{display:none}.govuk-react-service-navigation__details::details-content{content-visibility:visible;display:contents}}}\n";
25
23
  export type DetailsMenuProps = Omit<ComponentProps<'details'>, 'open'> & MenuState;
26
24
  /**
27
25
  * A menu that works without JavaScript: a native `details`, inside `Wrapper`, around `Summary`
@@ -24,17 +24,10 @@ export function Menu({ style, ...props }) {
24
24
  }
25
25
  /** The menu button, inside `Menu`. Hidden from tablet width up, and without JavaScript. */
26
26
  export function Toggle(props) {
27
- return (React.createElement(Primitives.Toggle, { asChild: true },
27
+ return (React.createElement(Primitives.Trigger, { asChild: true },
28
28
  React.createElement(Markup.Toggle, { ...props })));
29
29
  }
30
30
  const detailsClass = 'govuk-react-service-navigation__details';
31
- /** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */
32
- export const detailsCss = `
33
- .${detailsClass}>summary{list-style:none}
34
- .${detailsClass}>summary::-webkit-details-marker{display:none}
35
- .${detailsClass}[open]>summary::after{transform:rotate(180deg)}
36
- @supports selector(::details-content){@media ${tablet}{.${detailsClass}>summary{display:none}.${detailsClass}::details-content{content-visibility:visible;display:contents}}}
37
- `;
38
31
  /**
39
32
  * A menu that works without JavaScript: a native `details`, inside `Wrapper`, around `Summary`
40
33
  * and `List`. Below tablet width the summary shows and hides the list. From tablet width the list
@@ -60,18 +53,16 @@ export function DetailsMenu({ open, onOpenChange, onToggle, className, children,
60
53
  var _a;
61
54
  const node = details.current;
62
55
  if (node && initialOpen.current !== undefined && node.open !== initialOpen.current) {
63
- (_a = onOpenChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onOpenChangeRef, node.open);
56
+ (_a = onOpenChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onOpenChangeRef, node.open, { beforeHydration: true });
64
57
  }
65
58
  }, []);
66
59
  return (React.createElement("details", { ref: details, className: clsx(detailsClass, className), open: open, onToggle: (event) => {
67
60
  onToggle === null || onToggle === void 0 ? void 0 : onToggle(event);
68
61
  if (event.currentTarget.open !== open)
69
- onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event.currentTarget.open);
62
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event.currentTarget.open, { beforeHydration: false });
70
63
  },
71
64
  // The user can open it before hydration.
72
- suppressHydrationWarning: true, ...props },
73
- React.createElement("style", { href: detailsClass, precedence: "default" }, detailsCss),
74
- children));
65
+ suppressHydrationWarning: true, ...props }, children));
75
66
  }
76
67
  /** The menu button of `DetailsMenu`. Hidden from tablet width up, where the browser can show the list. */
77
68
  export function Summary({ className, children = 'Menu', ...props }) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/service-navigation/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,UAAU,MAAM,oCAAoC,CAAC;AACjE,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;AAElE;;;;;GAKG;AA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react';\nimport { clsx } from 'clsx';\nimport type { ComponentProps, ReactNode } from 'react';\nimport * as Primitives from '@govuk-react/primitives/disclosure';\nimport * as Markup from 'govuk-frontend-react/service-navigation';\n\n/*\n * govuk-frontend-react's ServiceNavigation markup, with the menu button from\n * @govuk-react/primitives. As in govuk-frontend, the navigation collapses behind the button\n * below tablet width. Without JavaScript the navigation is always shown and the button hidden,\n * unless you use `DetailsMenu`, which works without JavaScript.\n */\n\nexport {\n Root,\n WidthContainer,\n Container,\n ServiceName,\n Link,\n Text,\n Item,\n ActiveFallback,\n ItemComposite,\n type RootProps,\n type WidthContainerProps,\n type ContainerProps,\n type ServiceNameProps,\n type LinkProps,\n type TextProps,\n type ItemProps,\n type ActiveFallbackProps,\n type ItemCompositeProps,\n} from 'govuk-frontend-react/service-navigation';\n\n/** govuk-frontend's tablet breakpoint, from which the navigation is always shown. */\nconst tablet = '(min-width: 40.0625em)';\n\nexport { Wrapper, type WrapperProps } from 'govuk-frontend-react/service-navigation';\n\ntype MenuState = {\n /** Whether the menu is open below tablet width, to control it once hydrated, such as to close it after navigating. */\n open?: boolean;\n /** Called when the user opens or closes the menu. */\n onOpenChange?: (open: boolean) => void;\n};\n\nexport type MenuProps = Omit<Primitives.RootProps, 'media' | 'defaultOpen'> & MenuState;\n\n/**\n * govuk-frontend's menu: inside `Wrapper`, around `Toggle` and `List`. Below tablet width the\n * button shows and hides the list once JavaScript runs. Without JavaScript the list is always\n * shown and the button hidden.\n */\nexport function Menu({ style, ...props }: MenuProps) {\n // Takes no space, so govuk-frontend's styles still apply to the button and list.\n return <Primitives.Root media={tablet} style={{ display: 'contents', ...style }} {...props} />;\n}\n\nexport type ToggleProps = Markup.ToggleProps;\n\n/** The menu button, inside `Menu`. Hidden from tablet width up, and without JavaScript. */\nexport function Toggle(props: ToggleProps) {\n return (\n <Primitives.Toggle asChild>\n <Markup.Toggle {...props} />\n </Primitives.Toggle>\n );\n}\n\nconst detailsClass = 'govuk-react-service-navigation__details';\n\n/** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */\nexport const detailsCss = `\n.${detailsClass}>summary{list-style:none}\n.${detailsClass}>summary::-webkit-details-marker{display:none}\n.${detailsClass}[open]>summary::after{transform:rotate(180deg)}\n@supports selector(::details-content){@media ${tablet}{.${detailsClass}>summary{display:none}.${detailsClass}::details-content{content-visibility:visible;display:contents}}}\n`;\n\nexport type DetailsMenuProps = Omit<ComponentProps<'details'>, 'open'> & MenuState;\n\n/**\n * A menu that works without JavaScript: a native `details`, inside `Wrapper`, around `Summary`\n * and `List`. Below tablet width the summary shows and hides the list. From tablet width the list\n * shows where the browser supports `::details-content` (Chrome and Edge 131, Safari 18.4,\n * Firefox 143), and stays behind the menu where it doesn't.\n *\n * Check it with your users' assistive technology before choosing it over `Menu`. GOV.UK's audits\n * of the Details component found VoiceOver doesn't convey a `summary`'s state on iOS before 17,\n * and Dragon voice control can have trouble opening one.\n *\n * @see https://github.com/alphagov/govuk-design-system/issues/4030\n * @see https://github.com/alphagov/govuk-frontend/issues/5310\n */\nexport function DetailsMenu({ open, onOpenChange, onToggle, className, children, ...props }: DetailsMenuProps) {\n const details = useRef<HTMLDetailsElement>(null);\n const onOpenChangeRef = useRef(onOpenChange);\n useEffect(() => {\n onOpenChangeRef.current = onOpenChange;\n });\n // A menu opened before hydration is reported, rather than left out of step with `open`.\n const initialOpen = useRef(open);\n useEffect(() => {\n const node = details.current;\n if (node && initialOpen.current !== undefined && node.open !== initialOpen.current) {\n onOpenChangeRef.current?.(node.open);\n }\n }, []);\n return (\n <details\n ref={details}\n className={clsx(detailsClass, className)}\n open={open}\n onToggle={(event) => {\n onToggle?.(event);\n if (event.currentTarget.open !== open) onOpenChange?.(event.currentTarget.open);\n }}\n // The user can open it before hydration.\n suppressHydrationWarning\n {...props}\n >\n <style href={detailsClass} precedence=\"default\">\n {detailsCss}\n </style>\n {children}\n </details>\n );\n}\n\nexport type SummaryProps = ComponentProps<'summary'>;\n\n/** The menu button of `DetailsMenu`. Hidden from tablet width up, where the browser can show the list. */\nexport function Summary({ className, children = 'Menu', ...props }: SummaryProps) {\n return (\n <summary className={clsx('govuk-service-navigation__toggle', className)} {...props}>\n {children}\n </summary>\n );\n}\n\nexport type ListProps = Markup.ListProps;\n\n/** The navigation list, inside `Menu` or `DetailsMenu`, or straight inside `Wrapper` with no menu. */\nexport function List(props: ListProps) {\n return (\n <Primitives.Content asChild>\n <Markup.List {...props} />\n </Primitives.Content>\n );\n}\n\nexport type CompositeProps = Markup.CompositeProps & MenuState;\n\ntype MenuRenderer = (props: MenuState & { menuButtonText?: string; children: ReactNode }) => ReactNode;\n\nfunction render(\n {\n serviceName,\n serviceHref,\n navigationLabel,\n menuButtonText,\n collapseNavigationOnMobile,\n open,\n onOpenChange,\n as,\n items,\n children,\n ...props\n }: CompositeProps,\n renderMenu: MenuRenderer\n) {\n const list = items\n ? items.map((item, index) => <Markup.ItemComposite key={index} {...item} />)\n : Children.toArray(children);\n const collapse = collapseNavigationOnMobile ?? list.length > 1;\n const hasServiceName = hasContent(serviceName);\n return (\n <Markup.Root as={as ?? (hasServiceName ? 'section' : 'div')} {...props}>\n <Markup.WidthContainer>\n <Markup.Container>\n {hasServiceName && (\n <Markup.ServiceName>\n {serviceHref ? (\n <Markup.Link href={serviceHref}>{serviceName}</Markup.Link>\n ) : (\n <Markup.Text>{serviceName}</Markup.Text>\n )}\n </Markup.ServiceName>\n )}\n {list.length > 0 && (\n <Markup.Wrapper aria-label={navigationLabel || menuButtonText || 'Menu'}>\n {collapse ? (\n renderMenu({ open, onOpenChange, menuButtonText, children: <List>{list}</List> })\n ) : (\n <List>{list}</List>\n )}\n </Markup.Wrapper>\n )}\n </Markup.Container>\n </Markup.WidthContainer>\n </Markup.Root>\n );\n}\n\n/**\n * Service navigation helps users understand that they’re using your service and lets them navigate around your service.\n *\n * Children are `ItemComposite`s. The menu is govuk-frontend's: without JavaScript the\n * navigation is always shown.\n *\n * @see https://design-system.service.gov.uk/components/service-navigation/\n */\nexport function Composite(props: CompositeProps) {\n return render(props, ({ menuButtonText, children, ...menu }) => (\n <Menu {...menu}>\n <Toggle>{menuButtonText}</Toggle>\n {children}\n </Menu>\n ));\n}\n\n/**\n * Service navigation helps users understand that they’re using your service and lets them navigate around your service.\n *\n * Children are `ItemComposite`s. The menu is a `DetailsMenu`, which works without JavaScript but\n * has screen reader and voice control caveats: see `DetailsMenu`.\n *\n * @see https://design-system.service.gov.uk/components/service-navigation/\n */\nexport function DetailsComposite(props: CompositeProps) {\n return render(props, ({ menuButtonText, children, ...menu }) => (\n <DetailsMenu {...menu}>\n <Summary>{menuButtonText}</Summary>\n {children}\n </DetailsMenu>\n ));\n}\n\n// As govuk-frontend-react decides whether there is a service name.\nfunction hasContent(node: ReactNode): boolean {\n if (node === null || node === undefined || node === false || node === true || node === '') return false;\n if (Array.isArray(node)) return node.some(hasContent);\n return true;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/service-navigation/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,UAAU,MAAM,oCAAoC,CAAC;AACjE,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;AAElE;;;;;GAKG;AAEH,OAAO,EACL,IAAI,EACJ,cAAc,EACd,SAAS,EACT,WAAW,EACX,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,cAAc,EACd,aAAa,GAUd,MAAM,yCAAyC,CAAC;AAEjD,qFAAqF;AACrF,MAAM,MAAM,GAAG,wBAAwB,CAAC;AAExC,OAAO,EAAE,OAAO,EAAqB,MAAM,yCAAyC,CAAC;AAWrF;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,EAAa;IACjD,iFAAiF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,OAAK,IAAI;QACZ,oBAAC,MAAM,QAAE,cAAc,CAAU;QAChC,QAAQ,CACJ,CACR,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAqB;IACpD,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,CAC9D,oBAAC,WAAW,OAAK,IAAI;QACnB,oBAAC,OAAO,QAAE,cAAc,CAAW;QAClC,QAAQ,CACG,CACf,CAAC,CAAC;AACL,CAAC;AAED,mEAAmE;AACnE,SAAS,UAAU,CAAC,IAAe;IACjC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IACxG,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACtD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import * as React from 'react';\nimport { Children, useEffect, useRef } from 'react';\nimport { clsx } from 'clsx';\nimport type { ComponentProps, ReactNode } from 'react';\nimport * as Primitives from '@govuk-react/primitives/disclosure';\nimport * as Markup from 'govuk-frontend-react/service-navigation';\n\n/*\n * govuk-frontend-react's ServiceNavigation markup, with the menu button from\n * @govuk-react/primitives. As in govuk-frontend, the navigation collapses behind the button\n * below tablet width. Without JavaScript the navigation is always shown and the button hidden,\n * unless you use `DetailsMenu`, which works without JavaScript.\n */\n\nexport {\n Root,\n WidthContainer,\n Container,\n ServiceName,\n Link,\n Text,\n Item,\n ActiveFallback,\n ItemComposite,\n type RootProps,\n type WidthContainerProps,\n type ContainerProps,\n type ServiceNameProps,\n type LinkProps,\n type TextProps,\n type ItemProps,\n type ActiveFallbackProps,\n type ItemCompositeProps,\n} from 'govuk-frontend-react/service-navigation';\n\n/** govuk-frontend's tablet breakpoint, from which the navigation is always shown. */\nconst tablet = '(min-width: 40.0625em)';\n\nexport { Wrapper, type WrapperProps } from 'govuk-frontend-react/service-navigation';\n\ntype MenuState = {\n /** Whether the menu is open below tablet width, to control it once hydrated, such as to close it after navigating. */\n open?: boolean;\n /** Called when the user opens or closes the menu. */\n onOpenChange?: (open: boolean, details: Primitives.ChangeDetails) => void;\n};\n\nexport type MenuProps = Omit<Primitives.RootProps, 'media' | 'defaultOpen'> & MenuState;\n\n/**\n * govuk-frontend's menu: inside `Wrapper`, around `Toggle` and `List`. Below tablet width the\n * button shows and hides the list once JavaScript runs. Without JavaScript the list is always\n * shown and the button hidden.\n */\nexport function Menu({ style, ...props }: MenuProps) {\n // Takes no space, so govuk-frontend's styles still apply to the button and list.\n return <Primitives.Root media={tablet} style={{ display: 'contents', ...style }} {...props} />;\n}\n\nexport type ToggleProps = Markup.ToggleProps;\n\n/** The menu button, inside `Menu`. Hidden from tablet width up, and without JavaScript. */\nexport function Toggle(props: ToggleProps) {\n return (\n <Primitives.Trigger asChild>\n <Markup.Toggle {...props} />\n </Primitives.Trigger>\n );\n}\n\nconst detailsClass = 'govuk-react-service-navigation__details';\n\nexport type DetailsMenuProps = Omit<ComponentProps<'details'>, 'open'> & MenuState;\n\n/**\n * A menu that works without JavaScript: a native `details`, inside `Wrapper`, around `Summary`\n * and `List`. Below tablet width the summary shows and hides the list. From tablet width the list\n * shows where the browser supports `::details-content` (Chrome and Edge 131, Safari 18.4,\n * Firefox 143), and stays behind the menu where it doesn't.\n *\n * Check it with your users' assistive technology before choosing it over `Menu`. GOV.UK's audits\n * of the Details component found VoiceOver doesn't convey a `summary`'s state on iOS before 17,\n * and Dragon voice control can have trouble opening one.\n *\n * @see https://github.com/alphagov/govuk-design-system/issues/4030\n * @see https://github.com/alphagov/govuk-frontend/issues/5310\n */\nexport function DetailsMenu({ open, onOpenChange, onToggle, className, children, ...props }: DetailsMenuProps) {\n const details = useRef<HTMLDetailsElement>(null);\n const onOpenChangeRef = useRef(onOpenChange);\n useEffect(() => {\n onOpenChangeRef.current = onOpenChange;\n });\n // A menu opened before hydration is reported, rather than left out of step with `open`.\n const initialOpen = useRef(open);\n useEffect(() => {\n const node = details.current;\n if (node && initialOpen.current !== undefined && node.open !== initialOpen.current) {\n onOpenChangeRef.current?.(node.open, { beforeHydration: true });\n }\n }, []);\n return (\n <details\n ref={details}\n className={clsx(detailsClass, className)}\n open={open}\n onToggle={(event) => {\n onToggle?.(event);\n if (event.currentTarget.open !== open) onOpenChange?.(event.currentTarget.open, { beforeHydration: false });\n }}\n // The user can open it before hydration.\n suppressHydrationWarning\n {...props}\n >\n {children}\n </details>\n );\n}\n\nexport type SummaryProps = ComponentProps<'summary'>;\n\n/** The menu button of `DetailsMenu`. Hidden from tablet width up, where the browser can show the list. */\nexport function Summary({ className, children = 'Menu', ...props }: SummaryProps) {\n return (\n <summary className={clsx('govuk-service-navigation__toggle', className)} {...props}>\n {children}\n </summary>\n );\n}\n\nexport type ListProps = Markup.ListProps;\n\n/** The navigation list, inside `Menu` or `DetailsMenu`, or straight inside `Wrapper` with no menu. */\nexport function List(props: ListProps) {\n return (\n <Primitives.Content asChild>\n <Markup.List {...props} />\n </Primitives.Content>\n );\n}\n\nexport type CompositeProps = Markup.CompositeProps & MenuState;\n\ntype MenuRenderer = (props: MenuState & { menuButtonText?: string; children: ReactNode }) => ReactNode;\n\nfunction render(\n {\n serviceName,\n serviceHref,\n navigationLabel,\n menuButtonText,\n collapseNavigationOnMobile,\n open,\n onOpenChange,\n as,\n items,\n children,\n ...props\n }: CompositeProps,\n renderMenu: MenuRenderer\n) {\n const list = items\n ? items.map((item, index) => <Markup.ItemComposite key={index} {...item} />)\n : Children.toArray(children);\n const collapse = collapseNavigationOnMobile ?? list.length > 1;\n const hasServiceName = hasContent(serviceName);\n return (\n <Markup.Root as={as ?? (hasServiceName ? 'section' : 'div')} {...props}>\n <Markup.WidthContainer>\n <Markup.Container>\n {hasServiceName && (\n <Markup.ServiceName>\n {serviceHref ? (\n <Markup.Link href={serviceHref}>{serviceName}</Markup.Link>\n ) : (\n <Markup.Text>{serviceName}</Markup.Text>\n )}\n </Markup.ServiceName>\n )}\n {list.length > 0 && (\n <Markup.Wrapper aria-label={navigationLabel || menuButtonText || 'Menu'}>\n {collapse ? (\n renderMenu({ open, onOpenChange, menuButtonText, children: <List>{list}</List> })\n ) : (\n <List>{list}</List>\n )}\n </Markup.Wrapper>\n )}\n </Markup.Container>\n </Markup.WidthContainer>\n </Markup.Root>\n );\n}\n\n/**\n * Service navigation helps users understand that they’re using your service and lets them navigate around your service.\n *\n * Children are `ItemComposite`s. The menu is govuk-frontend's: without JavaScript the\n * navigation is always shown.\n *\n * @see https://design-system.service.gov.uk/components/service-navigation/\n */\nexport function Composite(props: CompositeProps) {\n return render(props, ({ menuButtonText, children, ...menu }) => (\n <Menu {...menu}>\n <Toggle>{menuButtonText}</Toggle>\n {children}\n </Menu>\n ));\n}\n\n/**\n * Service navigation helps users understand that they’re using your service and lets them navigate around your service.\n *\n * Children are `ItemComposite`s. The menu is a `DetailsMenu`, which works without JavaScript but\n * has screen reader and voice control caveats: see `DetailsMenu`.\n *\n * @see https://design-system.service.gov.uk/components/service-navigation/\n */\nexport function DetailsComposite(props: CompositeProps) {\n return render(props, ({ menuButtonText, children, ...menu }) => (\n <DetailsMenu {...menu}>\n <Summary>{menuButtonText}</Summary>\n {children}\n </DetailsMenu>\n ));\n}\n\n// As govuk-frontend-react decides whether there is a service name.\nfunction hasContent(node: ReactNode): boolean {\n if (node === null || node === undefined || node === false || node === true || node === '') return false;\n if (Array.isArray(node)) return node.some(hasContent);\n return true;\n}\n"]}
@@ -1,14 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import type { ReactNode } from 'react';
3
+ import * as Primitives from '@govuk-react/primitives/tabs';
3
4
  import * as Markup from 'govuk-frontend-react/tabs';
4
5
  type BaseRootProps = Omit<Markup.RootProps, 'defaultValue' | 'onChange'> & {
5
6
  /** Called when the user selects a tab. */
6
- onValueChange?: (value: string) => void;
7
- /**
8
- * When controlled, what happens to a tab the user picked before hydration: "ignore" keeps
9
- * `value`, "report" calls `onValueChange` with the pick so you can adopt it.
10
- */
11
- preHydration?: 'ignore' | 'report';
7
+ onValueChange?: (value: string, details: Primitives.ChangeDetails) => void;
12
8
  /** The panels' radio group name. Defaults to a generated one. */
13
9
  name?: string;
14
10
  };
@@ -26,7 +22,7 @@ export type RootProps = BaseRootProps & {
26
22
  *
27
23
  * @see https://design-system.service.gov.uk/components/tabs/
28
24
  */
29
- export declare function Root({ value, defaultValue, onValueChange, preHydration, name, ...props }: RootProps): React.JSX.Element;
25
+ export declare function Root({ value, defaultValue, onValueChange, name, ...props }: RootProps): React.JSX.Element;
30
26
  export type RadiosRootProps = BaseRootProps & ({
31
27
  value: string;
32
28
  defaultValue?: string;
@@ -40,7 +36,7 @@ export type RadiosRootProps = BaseRootProps & ({
40
36
  *
41
37
  * @see https://design-system.service.gov.uk/components/tabs/
42
38
  */
43
- export declare function RadiosRoot({ value, defaultValue, onValueChange, preHydration, name, ...props }: RadiosRootProps): React.JSX.Element;
39
+ export declare function RadiosRoot({ value, defaultValue, onValueChange, name, ...props }: RadiosRootProps): React.JSX.Element;
44
40
  export { Title, type TitleProps } from 'govuk-frontend-react/tabs';
45
41
  export type ListProps = Markup.ListProps;
46
42
  export declare function List(props: ListProps): React.JSX.Element;
@@ -27,9 +27,9 @@ const classes = {
27
27
  *
28
28
  * @see https://design-system.service.gov.uk/components/tabs/
29
29
  */
30
- export function Root({ value, defaultValue, onValueChange, preHydration, name, ...props }) {
30
+ export function Root({ value, defaultValue, onValueChange, name, ...props }) {
31
31
  return (React.createElement(TabsContext.Provider, { value: { selected: value !== null && value !== void 0 ? value : defaultValue } },
32
- React.createElement(Primitives.Root, { value: value, defaultValue: defaultValue, onValueChange: onValueChange, preHydration: preHydration, name: name, ...classes },
32
+ React.createElement(Primitives.Root, { value: value, defaultValue: defaultValue, onValueChange: onValueChange, name: name, ...classes },
33
33
  React.createElement(Markup.Root, { ...props }))));
34
34
  }
35
35
  /**
@@ -38,10 +38,10 @@ export function Root({ value, defaultValue, onValueChange, preHydration, name, .
38
38
  *
39
39
  * @see https://design-system.service.gov.uk/components/tabs/
40
40
  */
41
- export function RadiosRoot({ value, defaultValue, onValueChange, preHydration, name, ...props }) {
41
+ export function RadiosRoot({ value, defaultValue, onValueChange, name, ...props }) {
42
42
  const selection = value !== undefined ? { value, defaultValue } : { defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : '' };
43
43
  return (React.createElement(TabsContext.Provider, { value: { selected: value !== null && value !== void 0 ? value : defaultValue } },
44
- React.createElement(Primitives.RadiosRoot, { ...selection, onValueChange: onValueChange, preHydration: preHydration, name: name, ...classes },
44
+ React.createElement(Primitives.RadiosRoot, { ...selection, onValueChange: onValueChange, name: name, ...classes },
45
45
  React.createElement(Markup.Root, { ...props }))));
46
46
  }
47
47
  export { Title } from 'govuk-frontend-react/tabs';
@@ -65,7 +65,7 @@ export function Tab({ value, children, ...props }) {
65
65
  }
66
66
  /** A tab in a `RadiosRoot`: a label for its panel's radio. */
67
67
  export function RadioTab({ value, name, children, ...props }) {
68
- return (React.createElement(Primitives.RadioTrigger, { value: value, name: name, asChild: true },
68
+ return (React.createElement(Primitives.RadiosTrigger, { value: value, name: name, asChild: true },
69
69
  React.createElement(Markup.Tab, { asChild: true, ...props },
70
70
  React.createElement("label", null, children))));
71
71
  }
@@ -78,7 +78,7 @@ export function Panel({ value, selected, name, ...props }) {
78
78
  /** A panel in a `RadiosRoot`, shown without JavaScript only while its tab is chosen. */
79
79
  export function RadioPanel({ value, selected, name, ...props }) {
80
80
  const isSelected = useSelected(value, selected);
81
- return (React.createElement(Primitives.RadioContent, { value: value, name: name, defaultSelected: isSelected, asChild: true },
81
+ return (React.createElement(Primitives.RadiosContent, { value: value, name: name, defaultSelected: isSelected, asChild: true },
82
82
  React.createElement(Markup.Panel, { selected: isSelected, ...props })));
83
83
  }
84
84
  /** The tabs, with a tab and panel for each item. Without JavaScript, a list of links to every panel. */