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
package/README.md CHANGED
@@ -48,10 +48,11 @@ The project is currently maintained for free by a small number of volunteers. If
48
48
  npm install govuk-react govuk-frontend
49
49
  ```
50
50
 
51
- Load govuk-frontend's CSS once in your app:
51
+ Load govuk-frontend's CSS once in your app, then govuk-react's, which styles what govuk-frontend has no classes for:
52
52
 
53
53
  ```js
54
54
  import 'govuk-frontend/dist/govuk/govuk-frontend.min.css';
55
+ import 'govuk-react/styles.css';
55
56
  ```
56
57
 
57
58
  ```jsx
@@ -96,7 +97,7 @@ const MyComponent = () => (
96
97
 
97
98
  Use of these components assumes the following from the peer project:
98
99
 
99
- - `govuk-frontend` is installed and its CSS (`govuk-frontend/dist/govuk/govuk-frontend.min.css`) is loaded.
100
+ - `govuk-frontend` is installed and its CSS (`govuk-frontend/dist/govuk/govuk-frontend.min.css`) is loaded, followed by `govuk-react/styles.css`.
100
101
  - govuk-frontend's font and image assets are served at `/assets` (see [Fonts and images](#fonts-and-images)).
101
102
  - No other styles affecting generic elements (without classes, IDs etc) are present in the CSS.
102
103
 
@@ -8,7 +8,7 @@ export type RootProps = Omit<Markup.RootProps, 'defaultValue' | 'onChange'> & {
8
8
  /** The sections open at first. */
9
9
  defaultValue?: string[];
10
10
  /** Called with the open sections' values when the user opens or closes a section. */
11
- onValueChange?: (value: string[]) => void;
11
+ onValueChange?: (value: string[], details: Primitives.ChangeDetails) => void;
12
12
  };
13
13
  /**
14
14
  * The accordion component lets users show and hide sections of related content on a page.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/accordion/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,UAAU,MAAM,mCAAmC,CAAC;AAChE,OAAO,KAAK,MAAM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,CACM,CACM;YACvB,UAAU,CAAC,OAAO,CAAC,IAAI,oBAAC,cAAc,IAAC,EAAE,EAAE,GAAG,WAAW,YAAY,KAAK,EAAE,IAAG,OAAO,CAAkB,CACpF;QACvB,oBAAC,cAAc,IAAC,EAAE,EAAE,SAAS,IAAG,QAAQ,CAAkB,CAClD,CACX,CAAC;AACJ,CAAC;AAeD;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAkB;IAC1F,OAAO,CACL,oBAAC,IAAI,IAAC,EAAE,EAAE,EAAE,KAAM,KAAK;QACrB,oBAAC,QAAQ,OAAG;QACX,QAAQ;YACP,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAC/B,oBAAC,gBAAgB,IAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,YAAY,EAAE,YAAY,KAAM,OAAO,GAAI,CAC7G,CAAC;YACJ,CAAC,CAAC,QAAQ,CACP,CACR,CAAC;AACJ,CAAC;AAED,8DAA8D;AAC9D,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 { createContext, useContext } from 'react';\nimport type { ReactNode } from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/accordion';\nimport * as Markup from 'govuk-frontend-react/accordion';\n\n/*\n * govuk-frontend-react's Accordion markup, with the behaviour from @govuk-react/primitives. As in\n * govuk-frontend, every section is open without JavaScript. Each section also renders the button\n * govuk-frontend's script would build, hidden until the element upgrades, so React never has its\n * markup moved.\n */\n\n// Fills in defaults only: in an island without a Root, pass `defaultExpanded` to Section.\nconst AccordionContext = createContext<{ open?: string[] }>({});\n\nexport type RootProps = Omit<Markup.RootProps, 'defaultValue' | 'onChange'> & {\n /** The open sections' values, to control them once hydrated. */\n value?: string[];\n /** The sections open at first. */\n defaultValue?: string[];\n /** Called with the open sections' values when the user opens or closes a section. */\n onValueChange?: (value: string[]) => void;\n};\n\n/**\n * The accordion component lets users show and hide sections of related content on a page.\n *\n * @see https://design-system.service.gov.uk/components/accordion/\n */\nexport function Root({\n value,\n defaultValue,\n onValueChange,\n rememberExpanded,\n hideAllSectionsText,\n hideSectionText,\n hideSectionAriaLabelText,\n showAllSectionsText,\n showSectionText,\n showSectionAriaLabelText,\n ...props\n}: RootProps) {\n return (\n <AccordionContext.Provider value={{ open: value ?? defaultValue }}>\n <Primitives.Root\n value={value}\n defaultValue={defaultValue}\n onValueChange={onValueChange}\n rememberExpanded={rememberExpanded}\n hideAllSectionsText={hideAllSectionsText}\n hideSectionText={hideSectionText}\n hideSectionLabel={hideSectionAriaLabelText}\n showAllSectionsText={showAllSectionsText}\n showSectionText={showSectionText}\n showSectionLabel={showSectionAriaLabelText}\n // govuk-frontend styles the accordion under `govuk-frontend-supported`, which its JavaScript adds to the body.\n upgradedClass=\"govuk-frontend-supported\"\n expandedSectionClass=\"govuk-accordion__section--expanded\"\n collapsedIconClass=\"govuk-accordion-nav__chevron--down\"\n >\n <Markup.Root {...props} />\n </Primitives.Root>\n </AccordionContext.Provider>\n );\n}\n\nexport type ControlsProps = Omit<Primitives.ControlsProps, 'asChild' | 'children'>;\n\n/** The \"Show all sections\" button, at the top of the accordion. Hidden until JavaScript runs. */\nexport function Controls({ className, ...props }: ControlsProps) {\n return (\n <Primitives.Controls className={clsx('govuk-accordion__controls', className)} {...props}>\n <Primitives.ShowAll className=\"govuk-accordion__show-all\" aria-expanded=\"false\">\n <Primitives.Icon className=\"govuk-accordion-nav__chevron govuk-accordion-nav__chevron--down\" />\n <Primitives.ShowAllText className=\"govuk-accordion__show-all-text\">Show all sections</Primitives.ShowAllText>\n </Primitives.ShowAll>\n </Primitives.Controls>\n );\n}\n\nexport type SectionProps = Markup.SectionProps & {\n /** Identifies the section in the accordion's `value`. */\n value: string;\n};\n\nexport function Section({ value, expanded, ...props }: SectionProps) {\n const context = useContext(AccordionContext);\n const isExpanded = expanded ?? context.open?.includes(value) ?? false;\n return (\n <Primitives.Section value={value} defaultExpanded={isExpanded} asChild>\n <Markup.Section expanded={isExpanded} {...props} />\n </Primitives.Section>\n );\n}\n\nexport {\n SectionHeader,\n SectionHeading,\n type SectionHeaderProps,\n type SectionHeadingProps,\n} from 'govuk-frontend-react/accordion';\n\nconst divider = <span className=\"govuk-visually-hidden govuk-accordion__section-heading-divider\">, </span>;\n\nexport type SectionButtonProps = Markup.SectionButtonProps & {\n /** The section's summary line, which the button also shows once JavaScript runs. */\n summary?: ReactNode;\n};\n\n/**\n * The section's heading text. Without JavaScript it's plain text. Once JavaScript runs it's a\n * button that shows and hides the section, holding the heading and `summary`.\n */\nexport function SectionButton({ summary, children, ...props }: SectionButtonProps) {\n return (\n <>\n <Primitives.Fallback asChild>\n <Markup.SectionButton {...props}>{children}</Markup.SectionButton>\n </Primitives.Fallback>\n <Primitives.Trigger className=\"govuk-accordion__section-button\">\n <span className=\"govuk-accordion__section-heading-text\">\n <Primitives.Label className=\"govuk-accordion__section-heading-text-focus\">{children}</Primitives.Label>\n </span>\n {divider}\n {hasContent(summary) && (\n <>\n <span className=\"govuk-accordion__section-summary govuk-body\">\n <Primitives.Label className=\"govuk-accordion__section-summary-focus\">{summary}</Primitives.Label>\n </span>\n {divider}\n </>\n )}\n <span className=\"govuk-accordion__section-toggle\" data-nosnippet=\"\">\n <span className=\"govuk-accordion__section-toggle-focus\">\n <Primitives.Icon className=\"govuk-accordion-nav__chevron govuk-accordion-nav__chevron--down\" />\n <Primitives.ToggleText className=\"govuk-accordion__section-toggle-text\">Show</Primitives.ToggleText>\n </span>\n </span>\n </Primitives.Trigger>\n </>\n );\n}\n\nexport type SectionSummaryProps = Markup.SectionSummaryProps;\n\n/** The section's summary line without JavaScript. Once JavaScript runs, `SectionButton` shows it. */\nexport function SectionSummary(props: SectionSummaryProps) {\n return (\n <Primitives.Fallback asChild>\n <Markup.SectionSummary {...props} />\n </Primitives.Fallback>\n );\n}\n\nexport type SectionContentProps = Markup.SectionContentProps;\n\n/** The section's content. Give it an id, which the button's `aria-controls` names. */\nexport function SectionContent(props: SectionContentProps) {\n return (\n <Primitives.Content asChild>\n <Markup.SectionContent {...props} />\n </Primitives.Content>\n );\n}\n\nexport type SectionCompositeProps = Omit<Markup.SectionCompositeProps, 'expanded'> & {\n /** Identifies the section in the accordion's `value`. Defaults to its content's id. */\n value?: string;\n /** Sets whether the section should be expanded when the page loads for the first time. Defaults to whether the accordion's value includes it. */\n expanded?: boolean;\n};\n\nexport function SectionComposite({\n accordionId,\n index,\n heading,\n summary,\n headingLevel,\n value,\n children,\n ...props\n}: SectionCompositeProps) {\n const contentId = `${accordionId}-content-${index}`;\n return (\n <Section value={value ?? contentId} {...props}>\n <Markup.SectionHeader>\n <Markup.SectionHeading headingLevel={headingLevel}>\n <SectionButton id={`${accordionId}-heading-${index}`} summary={summary}>\n {heading}\n </SectionButton>\n </Markup.SectionHeading>\n {hasContent(summary) && <SectionSummary id={`${accordionId}-summary-${index}`}>{summary}</SectionSummary>}\n </Markup.SectionHeader>\n <SectionContent id={contentId}>{children}</SectionContent>\n </Section>\n );\n}\n\nexport type CompositeProps = Omit<RootProps, 'id' | 'children'> &\n Pick<Markup.SectionHeadingProps, 'headingLevel'> & {\n /** Must be unique across the domain of your service if `rememberExpanded` is `true` (as the expanded state of individual instances of the component persists across page loads using [session storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage)). Used as an `id` in the HTML for the accordion as a whole, and also as a prefix for the `id`s of the section contents and the buttons that open them, so that those `id`s can be the target of `aria-control` attributes. */\n id: string;\n } & (\n | { children?: ReactNode; sections?: never }\n | {\n children?: never;\n /** Prefer children, which memoise and re-render better. */\n sections: Omit<SectionCompositeProps, 'accordionId' | 'index' | 'headingLevel'>[];\n }\n );\n\n/**\n * The accordion component lets users show and hide sections of related content on a page.\n *\n * Children are `SectionComposite`s. With `sections`, it fills in their ids and heading level.\n *\n * @see https://design-system.service.gov.uk/components/accordion/\n */\nexport function Composite({ id, headingLevel, sections, children, ...props }: CompositeProps) {\n return (\n <Root id={id} {...props}>\n <Controls />\n {sections\n ? sections.map((section, index) => (\n <SectionComposite key={index} accordionId={id} index={index + 1} headingLevel={headingLevel} {...section} />\n ))\n : children}\n </Root>\n );\n}\n\n// As govuk-frontend-react decides whether there is a summary.\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/accordion/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,UAAU,MAAM,mCAAmC,CAAC;AAChE,OAAO,KAAK,MAAM,MAAM,gCAAgC,CAAC;AAEzD;;;;;GAKG;AAEH,0FAA0F;AAC1F,MAAM,gBAAgB,GAAG,aAAa,CAAsB,EAAE,CAAC,CAAC;AAWhE;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,EACnB,KAAK,EACL,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EACn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S,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAkB;IAC1F,OAAO,CACL,oBAAC,IAAI,IAAC,EAAE,EAAE,EAAE,KAAM,KAAK;QACrB,oBAAC,QAAQ,OAAG;QACX,QAAQ;YACP,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAC/B,oBAAC,gBAAgB,IAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,YAAY,EAAE,YAAY,KAAM,OAAO,GAAI,CAC7G,CAAC;YACJ,CAAC,CAAC,QAAQ,CACP,CACR,CAAC;AACJ,CAAC;AAED,8DAA8D;AAC9D,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 { createContext, useContext } from 'react';\nimport type { ReactNode } from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/accordion';\nimport * as Markup from 'govuk-frontend-react/accordion';\n\n/*\n * govuk-frontend-react's Accordion markup, with the behaviour from @govuk-react/primitives. As in\n * govuk-frontend, every section is open without JavaScript. Each section also renders the button\n * govuk-frontend's script would build, hidden until the element upgrades, so React never has its\n * markup moved.\n */\n\n// Fills in defaults only: in an island without a Root, pass `defaultExpanded` to Section.\nconst AccordionContext = createContext<{ open?: string[] }>({});\n\nexport type RootProps = Omit<Markup.RootProps, 'defaultValue' | 'onChange'> & {\n /** The open sections' values, to control them once hydrated. */\n value?: string[];\n /** The sections open at first. */\n defaultValue?: string[];\n /** Called with the open sections' values when the user opens or closes a section. */\n onValueChange?: (value: string[], details: Primitives.ChangeDetails) => void;\n};\n\n/**\n * The accordion component lets users show and hide sections of related content on a page.\n *\n * @see https://design-system.service.gov.uk/components/accordion/\n */\nexport function Root({\n value,\n defaultValue,\n onValueChange,\n rememberExpanded,\n hideAllSectionsText,\n hideSectionText,\n hideSectionAriaLabelText,\n showAllSectionsText,\n showSectionText,\n showSectionAriaLabelText,\n ...props\n}: RootProps) {\n return (\n <AccordionContext.Provider value={{ open: value ?? defaultValue }}>\n <Primitives.Root\n value={value}\n defaultValue={defaultValue}\n onValueChange={onValueChange}\n rememberExpanded={rememberExpanded}\n hideAllSectionsText={hideAllSectionsText}\n hideSectionText={hideSectionText}\n hideSectionLabel={hideSectionAriaLabelText}\n showAllSectionsText={showAllSectionsText}\n showSectionText={showSectionText}\n showSectionLabel={showSectionAriaLabelText}\n // govuk-frontend styles the accordion under `govuk-frontend-supported`, which its JavaScript adds to the body.\n upgradedClass=\"govuk-frontend-supported\"\n expandedSectionClass=\"govuk-accordion__section--expanded\"\n collapsedIconClass=\"govuk-accordion-nav__chevron--down\"\n >\n <Markup.Root {...props} />\n </Primitives.Root>\n </AccordionContext.Provider>\n );\n}\n\nexport type ControlsProps = Omit<Primitives.ControlsProps, 'asChild' | 'children'>;\n\n/** The \"Show all sections\" button, at the top of the accordion. Hidden until JavaScript runs. */\nexport function Controls({ className, ...props }: ControlsProps) {\n return (\n <Primitives.Controls className={clsx('govuk-accordion__controls', className)} {...props}>\n <Primitives.ShowAll className=\"govuk-accordion__show-all\" aria-expanded=\"false\">\n <Primitives.Icon className=\"govuk-accordion-nav__chevron govuk-accordion-nav__chevron--down\" />\n <Primitives.ShowAllText className=\"govuk-accordion__show-all-text\">Show all sections</Primitives.ShowAllText>\n </Primitives.ShowAll>\n </Primitives.Controls>\n );\n}\n\nexport type SectionProps = Markup.SectionProps & {\n /** Identifies the section in the accordion's `value`. */\n value: string;\n};\n\nexport function Section({ value, expanded, ...props }: SectionProps) {\n const context = useContext(AccordionContext);\n const isExpanded = expanded ?? context.open?.includes(value) ?? false;\n return (\n <Primitives.Section value={value} defaultExpanded={isExpanded} asChild>\n <Markup.Section expanded={isExpanded} {...props} />\n </Primitives.Section>\n );\n}\n\nexport {\n SectionHeader,\n SectionHeading,\n type SectionHeaderProps,\n type SectionHeadingProps,\n} from 'govuk-frontend-react/accordion';\n\nconst divider = <span className=\"govuk-visually-hidden govuk-accordion__section-heading-divider\">, </span>;\n\nexport type SectionButtonProps = Markup.SectionButtonProps & {\n /** The section's summary line, which the button also shows once JavaScript runs. */\n summary?: ReactNode;\n};\n\n/**\n * The section's heading text. Without JavaScript it's plain text. Once JavaScript runs it's a\n * button that shows and hides the section, holding the heading and `summary`.\n */\nexport function SectionButton({ summary, children, ...props }: SectionButtonProps) {\n return (\n <>\n <Primitives.Fallback asChild>\n <Markup.SectionButton {...props}>{children}</Markup.SectionButton>\n </Primitives.Fallback>\n <Primitives.Trigger className=\"govuk-accordion__section-button\">\n <span className=\"govuk-accordion__section-heading-text\">\n <Primitives.Label className=\"govuk-accordion__section-heading-text-focus\">{children}</Primitives.Label>\n </span>\n {divider}\n {hasContent(summary) && (\n <>\n <span className=\"govuk-accordion__section-summary govuk-body\">\n <Primitives.Label className=\"govuk-accordion__section-summary-focus\">{summary}</Primitives.Label>\n </span>\n {divider}\n </>\n )}\n <span className=\"govuk-accordion__section-toggle\" data-nosnippet=\"\">\n <span className=\"govuk-accordion__section-toggle-focus\">\n <Primitives.Icon className=\"govuk-accordion-nav__chevron govuk-accordion-nav__chevron--down\" />\n <Primitives.ToggleText className=\"govuk-accordion__section-toggle-text\">Show</Primitives.ToggleText>\n </span>\n </span>\n </Primitives.Trigger>\n </>\n );\n}\n\nexport type SectionSummaryProps = Markup.SectionSummaryProps;\n\n/** The section's summary line without JavaScript. Once JavaScript runs, `SectionButton` shows it. */\nexport function SectionSummary(props: SectionSummaryProps) {\n return (\n <Primitives.Fallback asChild>\n <Markup.SectionSummary {...props} />\n </Primitives.Fallback>\n );\n}\n\nexport type SectionContentProps = Markup.SectionContentProps;\n\n/** The section's content. Give it an id, which the button's `aria-controls` names. */\nexport function SectionContent(props: SectionContentProps) {\n return (\n <Primitives.Content asChild>\n <Markup.SectionContent {...props} />\n </Primitives.Content>\n );\n}\n\nexport type SectionCompositeProps = Omit<Markup.SectionCompositeProps, 'expanded'> & {\n /** Identifies the section in the accordion's `value`. Defaults to its content's id. */\n value?: string;\n /** Sets whether the section should be expanded when the page loads for the first time. Defaults to whether the accordion's value includes it. */\n expanded?: boolean;\n};\n\nexport function SectionComposite({\n accordionId,\n index,\n heading,\n summary,\n headingLevel,\n value,\n children,\n ...props\n}: SectionCompositeProps) {\n const contentId = `${accordionId}-content-${index}`;\n return (\n <Section value={value ?? contentId} {...props}>\n <Markup.SectionHeader>\n <Markup.SectionHeading headingLevel={headingLevel}>\n <SectionButton id={`${accordionId}-heading-${index}`} summary={summary}>\n {heading}\n </SectionButton>\n </Markup.SectionHeading>\n {hasContent(summary) && <SectionSummary id={`${accordionId}-summary-${index}`}>{summary}</SectionSummary>}\n </Markup.SectionHeader>\n <SectionContent id={contentId}>{children}</SectionContent>\n </Section>\n );\n}\n\nexport type CompositeProps = Omit<RootProps, 'id' | 'children'> &\n Pick<Markup.SectionHeadingProps, 'headingLevel'> & {\n /** Must be unique across the domain of your service if `rememberExpanded` is `true` (as the expanded state of individual instances of the component persists across page loads using [session storage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage)). Used as an `id` in the HTML for the accordion as a whole, and also as a prefix for the `id`s of the section contents and the buttons that open them, so that those `id`s can be the target of `aria-control` attributes. */\n id: string;\n } & (\n | { children?: ReactNode; sections?: never }\n | {\n children?: never;\n /** Prefer children, which memoise and re-render better. */\n sections: Omit<SectionCompositeProps, 'accordionId' | 'index' | 'headingLevel'>[];\n }\n );\n\n/**\n * The accordion component lets users show and hide sections of related content on a page.\n *\n * Children are `SectionComposite`s. With `sections`, it fills in their ids and heading level.\n *\n * @see https://design-system.service.gov.uk/components/accordion/\n */\nexport function Composite({ id, headingLevel, sections, children, ...props }: CompositeProps) {\n return (\n <Root id={id} {...props}>\n <Controls />\n {sections\n ? sections.map((section, index) => (\n <SectionComposite key={index} accordionId={id} index={index + 1} headingLevel={headingLevel} {...section} />\n ))\n : children}\n </Root>\n );\n}\n\n// As govuk-frontend-react decides whether there is a summary.\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"]}
@@ -27,7 +27,7 @@ export function Root({ maxLength, maxWords, threshold, countType, charactersUnde
27
27
  // As in govuk-frontend, `maxWords` counts words, and `maxLength` wins.
28
28
  , {
29
29
  // As in govuk-frontend, `maxWords` counts words, and `maxLength` wins.
30
- maxLength: maxLength !== null && maxLength !== void 0 ? maxLength : maxWords, countType: countType !== null && countType !== void 0 ? countType : (maxWords && maxLength === undefined ? 'words' : 'length'), threshold: threshold, charactersUnderLimit: charactersUnderLimitText, charactersAtLimit: charactersAtLimitText, charactersOverLimit: charactersOverLimitText, wordsUnderLimit: wordsUnderLimitText, wordsAtLimit: wordsAtLimitText, wordsOverLimit: wordsOverLimitText, hiddenDescriptionClass: "govuk-visually-hidden", withinLimitClass: "govuk-hint", overLimitClass: "govuk-error-message", belowThresholdClass: "govuk-character-count__message--disabled",
30
+ maxLength: maxLength !== null && maxLength !== void 0 ? maxLength : maxWords, countType: countType !== null && countType !== void 0 ? countType : (maxWords && maxLength === undefined ? 'words' : 'length'), threshold: threshold, charactersUnderLimitText: charactersUnderLimitText, charactersAtLimitText: charactersAtLimitText, charactersOverLimitText: charactersOverLimitText, wordsUnderLimitText: wordsUnderLimitText, wordsAtLimitText: wordsAtLimitText, wordsOverLimitText: wordsOverLimitText, hiddenDescriptionClass: "govuk-visually-hidden", withinLimitClass: "govuk-hint", overLimitClass: "govuk-error-message", belowThresholdClass: "govuk-character-count__message--disabled",
31
31
  // An error message already marks the field.
32
32
  inputOverLimitClass: error ? undefined : 'govuk-textarea--error' },
33
33
  React.createElement(Markup.Root, { maxLength: maxLength, maxWords: maxWords, threshold: threshold, countType: countType, error: error, ...text, ...props })));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/character-count/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,yCAAyC,CAAC;AACtE,OAAO,KAAK,MAAM,MAAM,sCAAsC,CAAC;AAC/D,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;AAUlD;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAC,EACnB,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,EACL,GAAG,KAAK,EACE;IACV,MAAM,IAAI,GAAG;QACX,wBAAwB;QACxB,qBAAqB;QACrB,uBAAuB;QACvB,mBAAmB;QACnB,gBAAgB;QAChB,kBAAkB;KACnB,CAAC;IACF,OAAO,CACL,oBAAC,UAAU,CAAC,IAAI;IACd,uEAAuE;;QAAvE,uEAAuE;QACvE,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,QAAQ,EAChC,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,CAAC,QAAQ,IAAI,SAAS,KAAK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OAAG;QACV,oBAAC,kBAAkB,OAAG,CACjB,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/character-count';\nimport * as Markup from 'govuk-frontend-react/character-count';\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 CharacterCount markup, with the count from @govuk-react/primitives.\n * Without JavaScript the field shows its description, such as \"You can enter up to 200\n * characters\", and keeps its `maxlength`, if you give it one.\n */\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Tell users how many characters or words they can enter into a textarea.\n *\n * Wrap `Textarea`, `Message`, `Status` and `ScreenReaderStatus`, with the label, hint and error\n * message.\n *\n * @see https://design-system.service.gov.uk/components/character-count/\n */\nexport function Root({\n maxLength,\n maxWords,\n threshold,\n countType,\n charactersUnderLimitText,\n charactersAtLimitText,\n charactersOverLimitText,\n wordsUnderLimitText,\n wordsAtLimitText,\n wordsOverLimitText,\n error,\n ...props\n}: RootProps) {\n const text = {\n charactersUnderLimitText,\n charactersAtLimitText,\n charactersOverLimitText,\n wordsUnderLimitText,\n wordsAtLimitText,\n wordsOverLimitText,\n };\n return (\n <Primitives.Root\n // As in govuk-frontend, `maxWords` counts words, and `maxLength` wins.\n maxLength={maxLength ?? maxWords}\n countType={countType ?? (maxWords && maxLength === undefined ? 'words' : 'length')}\n threshold={threshold}\n charactersUnderLimit={charactersUnderLimitText}\n charactersAtLimit={charactersAtLimitText}\n charactersOverLimit={charactersOverLimitText}\n wordsUnderLimit={wordsUnderLimitText}\n wordsAtLimit={wordsAtLimitText}\n wordsOverLimit={wordsOverLimitText}\n hiddenDescriptionClass=\"govuk-visually-hidden\"\n withinLimitClass=\"govuk-hint\"\n overLimitClass=\"govuk-error-message\"\n belowThresholdClass=\"govuk-character-count__message--disabled\"\n // An error message already marks the field.\n inputOverLimitClass={error ? undefined : 'govuk-textarea--error'}\n >\n <Markup.Root\n maxLength={maxLength}\n maxWords={maxWords}\n threshold={threshold}\n countType={countType}\n error={error}\n {...text}\n {...props}\n />\n </Primitives.Root>\n );\n}\n\nexport type TextareaProps = Markup.TextareaProps;\n\n/** The field. */\nexport function Textarea(props: TextareaProps) {\n return (\n <Primitives.Input asChild>\n <Markup.Textarea {...props} />\n </Primitives.Input>\n );\n}\n\nexport type MessageProps = Markup.MessageProps;\n\n/**\n * The description, such as \"You can enter up to 200 characters\". Shown without JavaScript, and\n * visually hidden once the count shows. Give it the field's id followed by `-info`, and add that to\n * the field's `aria-describedby`.\n */\nexport function Message(props: MessageProps) {\n return (\n <Primitives.Description asChild>\n <Markup.Message {...props} />\n </Primitives.Description>\n );\n}\n\nexport type StatusProps = Omit<Primitives.StatusProps, 'asChild'>;\n\n/** The visible count, after `Message`. Shown once JavaScript runs. */\nexport function Status({ className, ...props }: StatusProps) {\n return (\n <Primitives.Status\n className={clsx('govuk-hint', 'govuk-character-count__message', 'govuk-character-count__status', className)}\n {...props}\n />\n );\n}\n\nexport type ScreenReaderStatusProps = Omit<Primitives.ScreenReaderStatusProps, 'asChild'>;\n\n/** The count for screen readers, after `Status`, once the user pauses typing. */\nexport function ScreenReaderStatus({ className, ...props }: ScreenReaderStatusProps) {\n return (\n <Primitives.ScreenReaderStatus\n className={clsx('govuk-character-count__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 * Tell users how many characters or words they can enter into a textarea.\n *\n * @see https://design-system.service.gov.uk/components/character-count/\n */\nexport function Field({\n id: idProp,\n name,\n label,\n labelSize,\n labelIsPageHeading,\n hint,\n errorMessage,\n maxLength,\n maxWords,\n threshold,\n countType,\n textareaDescriptionText,\n charactersUnderLimitText,\n charactersAtLimitText,\n charactersOverLimitText,\n wordsUnderLimitText,\n wordsAtLimitText,\n wordsOverLimitText,\n 'aria-describedby': describedBy,\n ...props\n}: FieldProps) {\n const id = idProp || name;\n const infoId = `${id}-info`;\n const hintId = isSet(hint) ? `${id}-hint` : undefined;\n const errorId = isSet(errorMessage) ? `${id}-error` : undefined;\n const limit = maxWords || maxLength;\n const words = (countType ?? (maxWords ? 'words' : undefined)) === 'words';\n const ariaDescribedBy = joinIds(describedBy, infoId, hintId, errorId);\n\n return (\n <Root\n error={Boolean(errorId)}\n maxLength={maxLength}\n maxWords={maxWords}\n threshold={threshold}\n countType={countType}\n textareaDescriptionText={textareaDescriptionText}\n charactersUnderLimitText={charactersUnderLimitText}\n charactersAtLimitText={charactersAtLimitText}\n charactersOverLimitText={charactersOverLimitText}\n wordsUnderLimitText={wordsUnderLimitText}\n wordsAtLimitText={wordsAtLimitText}\n wordsOverLimitText={wordsOverLimitText}\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 <Textarea id={id} name={name} error={Boolean(errorId)} aria-describedby={ariaDescribedBy} {...props} />\n <Message id={infoId}>\n {limit\n ? (textareaDescriptionText || `You can enter up to %{count} ${words ? 'words' : 'characters'}`).replaceAll(\n '%{count}',\n String(limit)\n )\n : null}\n </Message>\n <Status />\n <ScreenReaderStatus />\n </Root>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/character-count/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,yCAAyC,CAAC;AACtE,OAAO,KAAK,MAAM,MAAM,sCAAsC,CAAC;AAC/D,OAAO,EAAE,qBAAqB,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ACxC,gBAAgB,EAAE,gBAAgB,EAClC,kBAAkB,EAAE,kBAAkB;QAEtC,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,QAAQ,IAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,sBAAoB,eAAe,KAAM,KAAK,GAAI;QACvG,oBAAC,OAAO,IAAC,EAAE,EAAE,MAAM,IAChB,KAAK;YACJ,CAAC,CAAC,CAAC,uBAAuB,IAAI,gCAAgC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,UAAU,CACtG,UAAU,EACV,MAAM,CAAC,KAAK,CAAC,CACd;YACH,CAAC,CAAC,IAAI,CACA;QACV,oBAAC,MAAM,OAAG;QACV,oBAAC,kBAAkB,OAAG,CACjB,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/character-count';\nimport * as Markup from 'govuk-frontend-react/character-count';\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 CharacterCount markup, with the count from @govuk-react/primitives.\n * Without JavaScript the field shows its description, such as \"You can enter up to 200\n * characters\", and keeps its `maxlength`, if you give it one.\n */\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Tell users how many characters or words they can enter into a textarea.\n *\n * Wrap `Textarea`, `Message`, `Status` and `ScreenReaderStatus`, with the label, hint and error\n * message.\n *\n * @see https://design-system.service.gov.uk/components/character-count/\n */\nexport function Root({\n maxLength,\n maxWords,\n threshold,\n countType,\n charactersUnderLimitText,\n charactersAtLimitText,\n charactersOverLimitText,\n wordsUnderLimitText,\n wordsAtLimitText,\n wordsOverLimitText,\n error,\n ...props\n}: RootProps) {\n const text = {\n charactersUnderLimitText,\n charactersAtLimitText,\n charactersOverLimitText,\n wordsUnderLimitText,\n wordsAtLimitText,\n wordsOverLimitText,\n };\n return (\n <Primitives.Root\n // As in govuk-frontend, `maxWords` counts words, and `maxLength` wins.\n maxLength={maxLength ?? maxWords}\n countType={countType ?? (maxWords && maxLength === undefined ? 'words' : 'length')}\n threshold={threshold}\n charactersUnderLimitText={charactersUnderLimitText}\n charactersAtLimitText={charactersAtLimitText}\n charactersOverLimitText={charactersOverLimitText}\n wordsUnderLimitText={wordsUnderLimitText}\n wordsAtLimitText={wordsAtLimitText}\n wordsOverLimitText={wordsOverLimitText}\n hiddenDescriptionClass=\"govuk-visually-hidden\"\n withinLimitClass=\"govuk-hint\"\n overLimitClass=\"govuk-error-message\"\n belowThresholdClass=\"govuk-character-count__message--disabled\"\n // An error message already marks the field.\n inputOverLimitClass={error ? undefined : 'govuk-textarea--error'}\n >\n <Markup.Root\n maxLength={maxLength}\n maxWords={maxWords}\n threshold={threshold}\n countType={countType}\n error={error}\n {...text}\n {...props}\n />\n </Primitives.Root>\n );\n}\n\nexport type TextareaProps = Markup.TextareaProps;\n\n/** The field. */\nexport function Textarea(props: TextareaProps) {\n return (\n <Primitives.Input asChild>\n <Markup.Textarea {...props} />\n </Primitives.Input>\n );\n}\n\nexport type MessageProps = Markup.MessageProps;\n\n/**\n * The description, such as \"You can enter up to 200 characters\". Shown without JavaScript, and\n * visually hidden once the count shows. Give it the field's id followed by `-info`, and add that to\n * the field's `aria-describedby`.\n */\nexport function Message(props: MessageProps) {\n return (\n <Primitives.Description asChild>\n <Markup.Message {...props} />\n </Primitives.Description>\n );\n}\n\nexport type StatusProps = Omit<Primitives.StatusProps, 'asChild'>;\n\n/** The visible count, after `Message`. Shown once JavaScript runs. */\nexport function Status({ className, ...props }: StatusProps) {\n return (\n <Primitives.Status\n className={clsx('govuk-hint', 'govuk-character-count__message', 'govuk-character-count__status', className)}\n {...props}\n />\n );\n}\n\nexport type ScreenReaderStatusProps = Omit<Primitives.ScreenReaderStatusProps, 'asChild'>;\n\n/** The count for screen readers, after `Status`, once the user pauses typing. */\nexport function ScreenReaderStatus({ className, ...props }: ScreenReaderStatusProps) {\n return (\n <Primitives.ScreenReaderStatus\n className={clsx('govuk-character-count__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 * Tell users how many characters or words they can enter into a textarea.\n *\n * @see https://design-system.service.gov.uk/components/character-count/\n */\nexport function Field({\n id: idProp,\n name,\n label,\n labelSize,\n labelIsPageHeading,\n hint,\n errorMessage,\n maxLength,\n maxWords,\n threshold,\n countType,\n textareaDescriptionText,\n charactersUnderLimitText,\n charactersAtLimitText,\n charactersOverLimitText,\n wordsUnderLimitText,\n wordsAtLimitText,\n wordsOverLimitText,\n 'aria-describedby': describedBy,\n ...props\n}: FieldProps) {\n const id = idProp || name;\n const infoId = `${id}-info`;\n const hintId = isSet(hint) ? `${id}-hint` : undefined;\n const errorId = isSet(errorMessage) ? `${id}-error` : undefined;\n const limit = maxWords || maxLength;\n const words = (countType ?? (maxWords ? 'words' : undefined)) === 'words';\n const ariaDescribedBy = joinIds(describedBy, infoId, hintId, errorId);\n\n return (\n <Root\n error={Boolean(errorId)}\n maxLength={maxLength}\n maxWords={maxWords}\n threshold={threshold}\n countType={countType}\n textareaDescriptionText={textareaDescriptionText}\n charactersUnderLimitText={charactersUnderLimitText}\n charactersAtLimitText={charactersAtLimitText}\n charactersOverLimitText={charactersOverLimitText}\n wordsUnderLimitText={wordsUnderLimitText}\n wordsAtLimitText={wordsAtLimitText}\n wordsOverLimitText={wordsOverLimitText}\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 <Textarea id={id} name={name} error={Boolean(errorId)} aria-describedby={ariaDescribedBy} {...props} />\n <Message id={infoId}>\n {limit\n ? (textareaDescriptionText || `You can enter up to %{count} ${words ? 'words' : 'characters'}`).replaceAll(\n '%{count}',\n String(limit)\n )\n : null}\n </Message>\n <Status />\n <ScreenReaderStatus />\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/checkboxes';
3
3
  export { Item, Label, Hint, Divider, type ItemProps, type LabelProps, type HintProps, type DividerProps, } from 'govuk-frontend-react/checkboxes';
4
- /** Shows a reveal only while its checkbox is checked, before or without JavaScript. */
5
- export declare const checkboxesCss: string;
6
4
  export type RootProps = Markup.RootProps;
7
5
  /**
8
6
  * Let users select one or more options by using the checkboxes 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/checkboxes';
12
- /** Shows a reveal only while its checkbox is checked, before or without JavaScript. */
13
- export const checkboxesCss = [
14
- // Hides a reveal whose checkbox isn't checked.
15
- '.govuk-checkboxes__item:has(>.govuk-checkboxes__input:not(:checked))+.govuk-checkboxes__conditional{display:none}',
16
- // Shows one whose checkbox is, over govuk-frontend's hidden class, until the element upgrades.
17
- '.govuk-checkboxes__item:has(>.govuk-checkboxes__input:checked)+.govuk-checkboxes__conditional{display:block}',
18
- ].join('');
19
12
  /** The element and styles around the checkboxes, for `Root` and `Field`. */
20
13
  function Behaviour({ children }) {
21
- return (React.createElement(Primitives.Root, { upgradedClass: "govuk-frontend-supported", hiddenConditionalClass: "govuk-checkboxes__conditional--hidden" },
22
- React.createElement("style", { href: "govuk-react-checkboxes", precedence: "default" }, checkboxesCss),
23
- children));
14
+ return (React.createElement(Primitives.Root, { upgradedClass: "govuk-frontend-supported", hiddenConditionalClass: "govuk-checkboxes__conditional--hidden" }, children));
24
15
  }
25
16
  /**
26
17
  * Let users select one or more options by using the checkboxes component.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/checkboxes/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,iCAAiC,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD;;;;GAIG;AAEH,OAAO,EACL,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,OAAO,GAKR,MAAM,iCAAiC,CAAC;AAEzC,uFAAuF;AACvF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,+CAA+C;IAC/C,mHAAmH;IACnH,+FAA+F;IAC/F,8GAA8G;CAC/G,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAEX,4EAA4E;AAC5E,SAAS,SAAS,CAAC,EAAE,QAAQ,EAAiC;IAC5D,OAAO,CACL,oBAAC,UAAU,CAAC,IAAI,IACd,aAAa,EAAC,0BAA0B,EACxC,sBAAsB,EAAC,uCAAuC;QAE9D,+BAAO,IAAI,EAAC,wBAAwB,EAAC,UAAU,EAAC,SAAS,IACtD,aAAa,CACR;QACP,QAAQ,CACO,CACnB,CAAC;AACJ,CAAC;AAID;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,KAAgB;IACnC,OAAO,CACL,oBAAC,SAAS;Q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AAE,QAAQ,EAAE,aAAa,sBAAoB,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,KAAM,KAAK,GAAI;YACrG,oBAAC,MAAM,CAAC,KAAK,IAAC,OAAO,EAAE,EAAE,IAAG,KAAK,CAAgB;YAChD,MAAM,IAAI,oBAAC,MAAM,CAAC,IAAI,IAAC,EAAE,EAAE,MAAM,IAAG,IAAI,CAAe,CAC5C;QACb,aAAa,IAAI,CAChB,oBAAC,WAAW,IAAC,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,MAAA,KAAK,CAAC,OAAO,mCAAI,KAAK,CAAC,cAAc,CAAC,IACpF,WAAW,CACA,CACf,CACA,CACJ,CAAC;AACJ,CAAC;AAYD;;;;;;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/checkboxes';\nimport { joinIds } from '../../utils/join-ids.js';\n\n/*\n * govuk-frontend-react's Checkboxes markup, with conditional reveals from @govuk-react/primitives.\n * Without JavaScript, a reveal shows only while its checkbox 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/checkboxes';\n\n/** Shows a reveal only while its checkbox is checked, before or without JavaScript. */\nexport const checkboxesCss = [\n // Hides a reveal whose checkbox isn't checked.\n '.govuk-checkboxes__item:has(>.govuk-checkboxes__input:not(:checked))+.govuk-checkboxes__conditional{display:none}',\n // Shows one whose checkbox is, over govuk-frontend's hidden class, until the element upgrades.\n '.govuk-checkboxes__item:has(>.govuk-checkboxes__input:checked)+.govuk-checkboxes__conditional{display:block}',\n].join('');\n\n/** The element and styles around the checkboxes, for `Root` and `Field`. */\nfunction Behaviour({ children }: { children: React.ReactNode }) {\n return (\n <Primitives.Root\n upgradedClass=\"govuk-frontend-supported\"\n hiddenConditionalClass=\"govuk-checkboxes__conditional--hidden\"\n >\n <style href=\"govuk-react-checkboxes\" precedence=\"default\">\n {checkboxesCss}\n </style>\n {children}\n </Primitives.Root>\n );\n}\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Let users select one or more options by using the checkboxes 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/checkboxes/\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 checkbox reveals. */\n controls?: string;\n /**\n * For an option such as \"None of these\": once JavaScript runs, checking it unchecks the other\n * checkboxes with its name, and checking one of them unchecks it.\n */\n exclusive?: boolean;\n /** govuk-frontend's way to make it exclusive: \"exclusive\". */\n 'data-behaviour'?: string;\n};\n\nexport function Input({ controls, exclusive, 'data-behaviour': behaviour, ...props }: InputProps) {\n return (\n // govuk-frontend's `data-behaviour=\"exclusive\"` works too. It isn't rendered, so govuk-frontend's\n // own script doesn't handle it as well.\n <Primitives.Input asChild controls={controls} exclusive={exclusive ?? behaviour === 'exclusive'}>\n <Markup.Input {...props} />\n </Primitives.Input>\n );\n}\n\nexport type ConditionalProps = Markup.ConditionalProps;\n\n/** Content revealed while its checkbox is checked, straight after its `Item`. Pass the checkbox'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 & Pick<InputProps, 'exclusive'>;\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 = Omit<Markup.FieldProps, 'items' | 'children'> &\n (\n | { children?: React.ReactNode; items?: never }\n | {\n children?: never;\n /** Prefer children, which memoise and re-render better. */\n items: (ItemCompositeProps | { divider: React.ReactNode })[];\n }\n );\n\n/**\n * Let users select one or more options by using the checkboxes component.\n *\n * Children are `ItemComposite`s and `Divider`s.\n *\n * @see https://design-system.service.gov.uk/components/checkboxes/\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/checkboxes/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,iCAAiC,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD;;;;GAIG;AAEH,OAAO,EACL,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,OAAO,GAKR,MAAM,iCAAiC,CAAC;AAEzC,4EAA4E;AAC5E,SAAS,SAAS,CAAC,EAAE,QAAQ,EAAiC;IAC5D,OAAO,CACL,oBAAC,UAAU,CAAC,IAAI,IACd,aAAa,EAAC,0BAA0B,EACxC,sBAAsB,EAAC,uCAAuC,IAE7D,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;AAcD,MAAM,UAAU,KAAK,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,GAAG,KAAK,EAAc;IAC9F,OAAO;IACL,kGAAkG;IAClG,wCAAwC;IACxC,oBAAC,UAAU,CAAC,KAAK,IAAC,OAAO,QAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,SAAS,KAAK,WAAW;QAC7F,oBAAC,MAAM,CAAC,KAAK,OAAK,KAAK,GAAI,CACV,CACpB,CAAC;AACJ,CAAC;AAID,iJAAiJ;A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;;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/checkboxes';\nimport { joinIds } from '../../utils/join-ids.js';\n\n/*\n * govuk-frontend-react's Checkboxes markup, with conditional reveals from @govuk-react/primitives.\n * Without JavaScript, a reveal shows only while its checkbox 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/checkboxes';\n\n/** The element and styles around the checkboxes, for `Root` and `Field`. */\nfunction Behaviour({ children }: { children: React.ReactNode }) {\n return (\n <Primitives.Root\n upgradedClass=\"govuk-frontend-supported\"\n hiddenConditionalClass=\"govuk-checkboxes__conditional--hidden\"\n >\n {children}\n </Primitives.Root>\n );\n}\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Let users select one or more options by using the checkboxes 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/checkboxes/\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 checkbox reveals. */\n controls?: string;\n /**\n * For an option such as \"None of these\": once JavaScript runs, checking it unchecks the other\n * checkboxes with its name, and checking one of them unchecks it.\n */\n exclusive?: boolean;\n /** govuk-frontend's way to make it exclusive: \"exclusive\". */\n 'data-behaviour'?: string;\n};\n\nexport function Input({ controls, exclusive, 'data-behaviour': behaviour, ...props }: InputProps) {\n return (\n // govuk-frontend's `data-behaviour=\"exclusive\"` works too. It isn't rendered, so govuk-frontend's\n // own script doesn't handle it as well.\n <Primitives.Input asChild controls={controls} exclusive={exclusive ?? behaviour === 'exclusive'}>\n <Markup.Input {...props} />\n </Primitives.Input>\n );\n}\n\nexport type ConditionalProps = Markup.ConditionalProps;\n\n/** Content revealed while its checkbox is checked, straight after its `Item`. Pass the checkbox'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 & Pick<InputProps, 'exclusive'>;\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 = Omit<Markup.FieldProps, 'items' | 'children'> &\n (\n | { children?: React.ReactNode; items?: never }\n | {\n children?: never;\n /** Prefer children, which memoise and re-render better. */\n items: (ItemCompositeProps | { divider: React.ReactNode })[];\n }\n );\n\n/**\n * Let users select one or more options by using the checkboxes component.\n *\n * Children are `ItemComposite`s and `Divider`s.\n *\n * @see https://design-system.service.gov.uk/components/checkboxes/\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"]}
@@ -18,7 +18,7 @@ const defaultHref = 'https://www.bbc.co.uk/weather';
18
18
  * @see https://design-system.service.gov.uk/components/exit-this-page/
19
19
  */
20
20
  export function Root({ children, ...props }) {
21
- return (React.createElement(Primitives.Root, { activatedText: props.activatedText, timedOutText: props.timedOutText, pressTwoMoreTimesText: props.pressTwoMoreTimesText, pressOneMoreTimeText: props.pressOneMoreTimeText, indicatorVisibleClass: "govuk-exit-this-page__indicator--visible", lightOnClass: "govuk-exit-this-page__indicator-light--on", hideContentClass: "govuk-exit-this-page-hide-content", overlayClass: "govuk-exit-this-page-overlay",
21
+ return (React.createElement(Primitives.Root, { activatedAnnouncement: props.activatedText, timedOutAnnouncement: props.timedOutText, pressTwoMoreTimesAnnouncement: props.pressTwoMoreTimesText, pressOneMoreTimeAnnouncement: props.pressOneMoreTimeText, indicatorVisibleClass: "govuk-exit-this-page__indicator--visible", lightOnClass: "govuk-exit-this-page__indicator-light--on", hideContentClass: "govuk-exit-this-page-hide-content", overlayClass: "govuk-exit-this-page-overlay",
22
22
  // Leaves the sticky button's containing block as it is in govuk-frontend.
23
23
  style: { display: 'contents' } },
24
24
  React.createElement(Markup.Root, { ...props },
@@ -27,7 +27,7 @@ export function Root({ children, ...props }) {
27
27
  }
28
28
  /** The link to a safe page. Shows how many times Shift has been pressed. */
29
29
  export function Button({ children, ...props }) {
30
- return (React.createElement(Primitives.Button, { asChild: true },
30
+ return (React.createElement(Primitives.Trigger, { asChild: true },
31
31
  React.createElement(Markup.Button, { ...props },
32
32
  children,
33
33
  React.createElement(Indicator, null))));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/exit-this-page/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,QAAQ,IAAI,cAAc,EAA6C,MAAM,gCAAgC,CAAC;AACvH,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE;;;GAGG;AAEH,MAAM,WAAW,GAAG,+BAA+B,CAAC;AAIpD;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAa;IACpD,OAAO,CACL,oBAAC,UAAU,CAAC,IAAI,IACd,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,EAClD,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,EAChD,qBAAqB,EAAC,0CAA0C,EAChE,YAAY,EAAC,2CAA2C,EACxD,gBAAgB,EAAC,mCAAmC,EACpD,YAAY,EAAC,8BAA8B;QAC3C,0EAA0E;QAC1E,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;QAE9B,oBAAC,MAAM,CAAC,IAAI,OAAK,KAAK;YACnB,QAAQ;YACT,oBAAC,MAAM,OAA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AAK,IAAI,IAAI,QAAQ,KAAK,EAAE,CAAC;IACnF,OAAO,CACL,oBAAC,IAAI,OAAK,KAAK;QACb,oBAAC,MAAM,IAAC,IAAI,EAAE,IAAI,IACf,WAAW,CAAC,CAAC,CAAC,CACb,QAAQ,CACT,CAAC,CAAC,CAAC,CACF;YACE,oBAAC,cAAc,oBAA2B;8BACzC,CACJ,CACM,CACJ,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/exit-this-page';\nimport * as Markup from 'govuk-frontend-react/exit-this-page';\nimport { SkipLink as MarkupSkipLink, type SkipLinkProps as MarkupSkipLinkProps } from 'govuk-frontend-react/skip-link';\nimport { VisuallyHidden } from 'govuk-frontend-react/visually-hidden';\n\n/*\n * govuk-frontend-react's ExitThisPage markup, with the behaviour from @govuk-react/primitives, as\n * govuk-frontend's script has. Without JavaScript the button is a link to a safe page.\n */\n\nconst defaultHref = 'https://www.bbc.co.uk/weather';\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Give users a way to quickly and safely exit a service, website or application.\n *\n * Once JavaScript runs, the button, a `SkipLink`, or pressing Shift 3 times hides the page and\n * goes to the button's `href`, as in govuk-frontend.\n *\n * @see https://design-system.service.gov.uk/components/exit-this-page/\n */\nexport function Root({ children, ...props }: RootProps) {\n return (\n <Primitives.Root\n activatedText={props.activatedText}\n timedOutText={props.timedOutText}\n pressTwoMoreTimesText={props.pressTwoMoreTimesText}\n pressOneMoreTimeText={props.pressOneMoreTimeText}\n indicatorVisibleClass=\"govuk-exit-this-page__indicator--visible\"\n lightOnClass=\"govuk-exit-this-page__indicator-light--on\"\n hideContentClass=\"govuk-exit-this-page-hide-content\"\n overlayClass=\"govuk-exit-this-page-overlay\"\n // Leaves the sticky button's containing block as it is in govuk-frontend.\n style={{ display: 'contents' }}\n >\n <Markup.Root {...props}>\n {children}\n <Status />\n </Markup.Root>\n </Primitives.Root>\n );\n}\n\nexport type ButtonProps = Markup.ButtonProps;\n\n/** The link to a safe page. Shows how many times Shift has been pressed. */\nexport function Button({ children, ...props }: ButtonProps) {\n return (\n <Primitives.Button asChild>\n <Markup.Button {...props}>\n {children}\n <Indicator />\n </Markup.Button>\n </Primitives.Button>\n );\n}\n\n/** Shows how many times Shift has been pressed. Button renders it. */\nexport function Indicator() {\n return (\n <Primitives.Indicator className=\"govuk-exit-this-page__indicator\">\n <Primitives.Light className=\"govuk-exit-this-page__indicator-light\" />\n <Primitives.Light className=\"govuk-exit-this-page__indicator-light\" />\n <Primitives.Light className=\"govuk-exit-this-page__indicator-light\" />\n </Primitives.Indicator>\n );\n}\n\n/** Tells screen readers how many more presses are needed. Root renders it. */\nexport function Status() {\n return <Primitives.Status className=\"govuk-visually-hidden\" />;\n}\n\nexport type SkipLinkProps = MarkupSkipLinkProps;\n\n/** A skip link that exits the page too, for the top of the page. */\nexport function SkipLink({ href, className, ...props }: SkipLinkProps) {\n return (\n <Primitives.SkipLink asChild>\n <MarkupSkipLink\n href={href || defaultHref}\n className={clsx('govuk-js-exit-this-page-skiplink', className)}\n rel=\"nofollow noreferrer\"\n {...props}\n />\n </Primitives.SkipLink>\n );\n}\n\nexport type CompositeProps = Markup.CompositeProps;\n\n/**\n * Give users a way to quickly and safely exit a service, website or application.\n *\n * Once JavaScript runs, the button, a `SkipLink`, or pressing Shift 3 times hides the page and\n * goes to the button's `href`, as in govuk-frontend.\n *\n * @see https://design-system.service.gov.uk/components/exit-this-page/\n */\nexport function Composite({ href, children, ...props }: CompositeProps) {\n const hasChildren = children !== undefined && children !== null && children !== '';\n return (\n <Root {...props}>\n <Button href={href}>\n {hasChildren ? (\n children\n ) : (\n <>\n <VisuallyHidden>Emergency</VisuallyHidden> Exit this page\n </>\n )}\n </Button>\n </Root>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/exit-this-page/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAA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C,SAAS,EAAC,iCAAiC;QAC/D,oBAAC,UAAU,CAAC,KAAK,IAAC,SAAS,EAAC,uCAAuC,GAAG;QACtE,oBAAC,UAAU,CAAC,KAAK,IAAC,SAAS,EAAC,uCAAuC,GAAG;QACtE,oBAAC,UAAU,CAAC,KAAK,IAAC,SAAS,EAAC,uCAAuC,GAAG,CACjD,CACxB,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,MAAM;IACpB,OAAO,oBAAC,UAAU,CAAC,MAAM,IAAC,SAAS,EAAC,uBAAuB,GAAG,CAAC;AACjE,CAAC;AAID,oEAAoE;AACpE,MAAM,UAAU,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,EAAiB;IACnE,OAAO,CACL,oBAAC,UAAU,CAAC,QAAQ,IAAC,OAAO;QAC1B,oBAAC,cAAc,IACb,IAAI,EAAE,IAAI,IAAI,WAAW,EACzB,SAAS,EAAE,IAAI,CAAC,kCAAkC,EAAE,SAAS,CAAC,EAC9D,GAAG,EAAC,qBAAqB,KACrB,KAAK,GACT,CACkB,CACvB,CAAC;AACJ,CAAC;AAID;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAkB;IACpE,MAAM,WAAW,GAAG,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,EAAE,CAAC;IACnF,OAAO,CACL,oBAAC,IAAI,OAAK,KAAK;QACb,oBAAC,MAAM,IAAC,IAAI,EAAE,IAAI,IACf,WAAW,CAAC,CAAC,CAAC,CACb,QAAQ,CACT,CAAC,CAAC,CAAC,CACF;YACE,oBAAC,cAAc,oBAA2B;8BACzC,CACJ,CACM,CACJ,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/exit-this-page';\nimport * as Markup from 'govuk-frontend-react/exit-this-page';\nimport { SkipLink as MarkupSkipLink, type SkipLinkProps as MarkupSkipLinkProps } from 'govuk-frontend-react/skip-link';\nimport { VisuallyHidden } from 'govuk-frontend-react/visually-hidden';\n\n/*\n * govuk-frontend-react's ExitThisPage markup, with the behaviour from @govuk-react/primitives, as\n * govuk-frontend's script has. Without JavaScript the button is a link to a safe page.\n */\n\nconst defaultHref = 'https://www.bbc.co.uk/weather';\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Give users a way to quickly and safely exit a service, website or application.\n *\n * Once JavaScript runs, the button, a `SkipLink`, or pressing Shift 3 times hides the page and\n * goes to the button's `href`, as in govuk-frontend.\n *\n * @see https://design-system.service.gov.uk/components/exit-this-page/\n */\nexport function Root({ children, ...props }: RootProps) {\n return (\n <Primitives.Root\n activatedAnnouncement={props.activatedText}\n timedOutAnnouncement={props.timedOutText}\n pressTwoMoreTimesAnnouncement={props.pressTwoMoreTimesText}\n pressOneMoreTimeAnnouncement={props.pressOneMoreTimeText}\n indicatorVisibleClass=\"govuk-exit-this-page__indicator--visible\"\n lightOnClass=\"govuk-exit-this-page__indicator-light--on\"\n hideContentClass=\"govuk-exit-this-page-hide-content\"\n overlayClass=\"govuk-exit-this-page-overlay\"\n // Leaves the sticky button's containing block as it is in govuk-frontend.\n style={{ display: 'contents' }}\n >\n <Markup.Root {...props}>\n {children}\n <Status />\n </Markup.Root>\n </Primitives.Root>\n );\n}\n\nexport type ButtonProps = Markup.ButtonProps;\n\n/** The link to a safe page. Shows how many times Shift has been pressed. */\nexport function Button({ children, ...props }: ButtonProps) {\n return (\n <Primitives.Trigger asChild>\n <Markup.Button {...props}>\n {children}\n <Indicator />\n </Markup.Button>\n </Primitives.Trigger>\n );\n}\n\n/** Shows how many times Shift has been pressed. Button renders it. */\nexport function Indicator() {\n return (\n <Primitives.Indicator className=\"govuk-exit-this-page__indicator\">\n <Primitives.Light className=\"govuk-exit-this-page__indicator-light\" />\n <Primitives.Light className=\"govuk-exit-this-page__indicator-light\" />\n <Primitives.Light className=\"govuk-exit-this-page__indicator-light\" />\n </Primitives.Indicator>\n );\n}\n\n/** Tells screen readers how many more presses are needed. Root renders it. */\nexport function Status() {\n return <Primitives.Status className=\"govuk-visually-hidden\" />;\n}\n\nexport type SkipLinkProps = MarkupSkipLinkProps;\n\n/** A skip link that exits the page too, for the top of the page. */\nexport function SkipLink({ href, className, ...props }: SkipLinkProps) {\n return (\n <Primitives.SkipLink asChild>\n <MarkupSkipLink\n href={href || defaultHref}\n className={clsx('govuk-js-exit-this-page-skiplink', className)}\n rel=\"nofollow noreferrer\"\n {...props}\n />\n </Primitives.SkipLink>\n );\n}\n\nexport type CompositeProps = Markup.CompositeProps;\n\n/**\n * Give users a way to quickly and safely exit a service, website or application.\n *\n * Once JavaScript runs, the button, a `SkipLink`, or pressing Shift 3 times hides the page and\n * goes to the button's `href`, as in govuk-frontend.\n *\n * @see https://design-system.service.gov.uk/components/exit-this-page/\n */\nexport function Composite({ href, children, ...props }: CompositeProps) {\n const hasChildren = children !== undefined && children !== null && children !== '';\n return (\n <Root {...props}>\n <Button href={href}>\n {hasChildren ? (\n children\n ) : (\n <>\n <VisuallyHidden>Emergency</VisuallyHidden> Exit this page\n </>\n )}\n </Button>\n </Root>\n );\n}\n"]}
@@ -2,13 +2,13 @@ import * as React from 'react';
2
2
  import * as Primitives from '@govuk-react/primitives/file-upload';
3
3
  import * as Markup from 'govuk-frontend-react/file-upload';
4
4
  import { type FileUploadProps, type FileUploadTexts } from './control.js';
5
- export type RootProps = Omit<Primitives.RootProps, 'noFileChosen' | 'multipleFilesChosen' | 'enteredDropZone' | 'leftDropZone' | 'emptyClass' | 'draggingClass' | 'disabledClass'> & Pick<FileUploadTexts, 'noFileChosenText' | 'multipleFilesChosenText' | 'enteredDropZoneText' | 'leftDropZoneText'>;
5
+ export type RootProps = Omit<Primitives.RootProps, 'noFileChosenText' | 'multipleFilesChosenText' | 'enteredDropZoneAnnouncement' | 'leftDropZoneAnnouncement' | 'emptyClass' | 'draggingClass' | 'disabledClass'> & Pick<FileUploadTexts, 'noFileChosenText' | 'multipleFilesChosenText' | 'enteredDropZoneText' | 'leftDropZoneText'>;
6
6
  /** Holds `Wrapper` and `Announcements`, and turns the file input into a button and drop zone once JavaScript runs. */
7
7
  export declare function Root({ noFileChosenText, multipleFilesChosenText, enteredDropZoneText, leftDropZoneText, ...props }: RootProps): React.JSX.Element;
8
8
  export type WrapperProps = Markup.FileUploadWrapperProps;
9
9
  /** The drop zone, holding `Button` and `FileUpload`. */
10
10
  export declare function Wrapper(props: WrapperProps): React.JSX.Element;
11
- export type ButtonProps = Omit<Primitives.ButtonProps, 'asChild'>;
11
+ export type ButtonProps = Omit<Primitives.TriggerProps, 'asChild'>;
12
12
  /** Opens the file picker, and takes dropped files. Shown once JavaScript runs, before `FileUpload`. */
13
13
  export declare function Button({ className, ...props }: ButtonProps): React.JSX.Element;
14
14
  export type StatusProps = Omit<Primitives.StatusProps, 'asChild'>;
@@ -10,7 +10,7 @@ import { FileUpload } from './control.js';
10
10
  import { joinIds } from '../../utils/join-ids.js';
11
11
  /** Holds `Wrapper` and `Announcements`, and turns the file input into a button and drop zone once JavaScript runs. */
12
12
  export function Root({ noFileChosenText, multipleFilesChosenText, enteredDropZoneText, leftDropZoneText, ...props }) {
13
- return (React.createElement(Primitives.Root, { noFileChosen: noFileChosenText, multipleFilesChosen: multipleFilesChosenText, enteredDropZone: enteredDropZoneText, leftDropZone: leftDropZoneText, emptyClass: "govuk-file-upload-button--empty", draggingClass: "govuk-file-upload-button--dragging", disabledClass: "govuk-file-upload-wrapper--disabled", ...props }));
13
+ return (React.createElement(Primitives.Root, { noFileChosenText: noFileChosenText, multipleFilesChosenText: multipleFilesChosenText, enteredDropZoneAnnouncement: enteredDropZoneText, leftDropZoneAnnouncement: leftDropZoneText, emptyClass: "govuk-file-upload-button--empty", draggingClass: "govuk-file-upload-button--dragging", disabledClass: "govuk-file-upload-wrapper--disabled", ...props }));
14
14
  }
15
15
  /** The drop zone, holding `Button` and `FileUpload`. */
16
16
  export function Wrapper(props) {
@@ -19,7 +19,7 @@ export function Wrapper(props) {
19
19
  }
20
20
  /** Opens the file picker, and takes dropped files. Shown once JavaScript runs, before `FileUpload`. */
21
21
  export function Button({ className, ...props }) {
22
- return React.createElement(Primitives.Button, { className: clsx('govuk-file-upload-button', className), ...props });
22
+ return React.createElement(Primitives.Trigger, { className: clsx('govuk-file-upload-button', className), ...props });
23
23
  }
24
24
  /** Which files are chosen, in `Button`. */
25
25
  export function Status({ className, ...props }) {
@@ -1 +1 @@
1
- {"version":3,"file":"enhanced.js","sourceRoot":"","sources":["../../../src/components/file-upload/enhanced.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,UAAU,MAAM,qCAAqC,CAAC;AAClE,OAAO,KAAK,MAAM,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAA8C,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAclD,sHAAsH;AACtH,MAAM,UAAU,IAAI,CAAC,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,GAAG,KAAK,EACE;IACV,OAAO,CACL,oBAAC,UAAU,CAAC,IAAI,IACd,YAAY,EAAE,gBAAgB,EAC9B,mBAAmB,EAAE,uBAAuB,EAC5C,eAAe,EAAE,mBAAmB,EACpC,YAAY,EAAE,gBAAgB,EAC9B,UAAU,EAAC,iCAAiC,EAC5C,aAAa,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AAE,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,IAC/F,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,SAAS,IAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,sBAAoB,eAAe,KAAM,KAAK,GAAI,CAC9F,CACb,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/file-upload';\nimport * as Markup from 'govuk-frontend-react/file-upload';\nimport { ErrorMessageComposite } from 'govuk-frontend-react/error-message';\nimport { FormGroup } from 'govuk-frontend-react/form-group';\nimport { Hint } from 'govuk-frontend-react/hint';\nimport { LabelComposite } from 'govuk-frontend-react/label';\nimport { FileUpload, type FileUploadProps, type FileUploadTexts } from './control.js';\nimport { joinIds } from '../../utils/join-ids.js';\n\nexport type RootProps = Omit<\n Primitives.RootProps,\n | 'noFileChosen'\n | 'multipleFilesChosen'\n | 'enteredDropZone'\n | 'leftDropZone'\n | 'emptyClass'\n | 'draggingClass'\n | 'disabledClass'\n> &\n Pick<FileUploadTexts, 'noFileChosenText' | 'multipleFilesChosenText' | 'enteredDropZoneText' | 'leftDropZoneText'>;\n\n/** Holds `Wrapper` and `Announcements`, and turns the file input into a button and drop zone once JavaScript runs. */\nexport function Root({\n noFileChosenText,\n multipleFilesChosenText,\n enteredDropZoneText,\n leftDropZoneText,\n ...props\n}: RootProps) {\n return (\n <Primitives.Root\n noFileChosen={noFileChosenText}\n multipleFilesChosen={multipleFilesChosenText}\n enteredDropZone={enteredDropZoneText}\n leftDropZone={leftDropZoneText}\n emptyClass=\"govuk-file-upload-button--empty\"\n draggingClass=\"govuk-file-upload-button--dragging\"\n disabledClass=\"govuk-file-upload-wrapper--disabled\"\n {...props}\n />\n );\n}\n\nexport type WrapperProps = Markup.FileUploadWrapperProps;\n\n/** The drop zone, holding `Button` and `FileUpload`. */\nexport function Wrapper(props: WrapperProps) {\n return (\n <Primitives.DropZone asChild>\n <Markup.FileUploadWrapper {...props} />\n </Primitives.DropZone>\n );\n}\n\nexport type ButtonProps = Omit<Primitives.ButtonProps, 'asChild'>;\n\n/** Opens the file picker, and takes dropped files. Shown once JavaScript runs, before `FileUpload`. */\nexport function Button({ className, ...props }: ButtonProps) {\n return <Primitives.Button className={clsx('govuk-file-upload-button', className)} {...props} />;\n}\n\nexport type StatusProps = Omit<Primitives.StatusProps, 'asChild'>;\n\n/** Which files are chosen, in `Button`. */\nexport function Status({ className, ...props }: StatusProps) {\n return <Primitives.Status className={clsx('govuk-body', 'govuk-file-upload-button__status', className)} {...props} />;\n}\n\nexport type CommaProps = Omit<Primitives.SeparatorProps, 'asChild'>;\n\n/** A visually hidden comma between the label and the button's text in its accessible name, after `Status`. */\nexport function Comma({ className, ...props }: CommaProps) {\n return <Primitives.Separator className={clsx('govuk-visually-hidden', className)} {...props} />;\n}\n\nexport type PseudoButtonContainerProps = React.ComponentProps<'span'>;\n\n/** Holds `PseudoButton` and `Instruction`, in `Button`. */\nexport function PseudoButtonContainer({ className, ...props }: PseudoButtonContainerProps) {\n return <span className={clsx('govuk-file-upload-button__pseudo-button-container', className)} {...props} />;\n}\n\nexport type PseudoButtonProps = React.ComponentProps<'span'>;\n\n/** Looks like a secondary button. Defaults to \"Choose file\". */\nexport function PseudoButton({ className, children = 'Choose file', ...props }: PseudoButtonProps) {\n return (\n <span\n className={clsx('govuk-button', 'govuk-button--secondary', 'govuk-file-upload-button__pseudo-button', className)}\n {...props}\n >\n {children}\n </span>\n );\n}\n\nexport type InstructionProps = React.ComponentProps<'span'>;\n\n/** Tells users they can drop files. Defaults to \"or drop file\". */\nexport function Instruction({ className, children = 'or drop file', ...props }: InstructionProps) {\n return (\n <span className={clsx('govuk-body', 'govuk-file-upload-button__instruction', className)} {...props}>\n {children}\n </span>\n );\n}\n\nexport type ButtonCompositeProps = Omit<ButtonProps, 'children'> &\n Pick<FileUploadTexts, 'chooseFilesButtonText' | 'dropInstructionText'>;\n\n/** `Button`, with its status and text. */\nexport function ButtonComposite({ chooseFilesButtonText, dropInstructionText, ...props }: ButtonCompositeProps) {\n return (\n <Button {...props}>\n <Status />\n <Comma />\n <PseudoButtonContainer>\n <PseudoButton>{chooseFilesButtonText}</PseudoButton> <Instruction>{dropInstructionText}</Instruction>\n </PseudoButtonContainer>\n </Button>\n );\n}\n\nexport type AnnouncementsProps = Omit<Primitives.AnnouncementsProps, 'asChild'>;\n\n/** Tells screen reader users when they drag files into or out of the drop zone, after `Wrapper`. */\nexport function Announcements({ className, ...props }: AnnouncementsProps) {\n return (\n <Primitives.Announcements\n className={clsx('govuk-file-upload-announcements', 'govuk-visually-hidden', className)}\n {...props}\n />\n );\n}\n\nexport type CompositeProps = FileUploadProps & FileUploadTexts;\n\n/** `Root`, with the drop zone, button, file input and announcements. Takes the file input's props. */\nexport function Composite({\n chooseFilesButtonText,\n noFileChosenText,\n multipleFilesChosenText,\n dropInstructionText,\n enteredDropZoneText,\n leftDropZoneText,\n ...props\n}: CompositeProps) {\n return (\n <Root\n noFileChosenText={noFileChosenText}\n multipleFilesChosenText={multipleFilesChosenText}\n enteredDropZoneText={enteredDropZoneText}\n leftDropZoneText={leftDropZoneText}\n >\n <Wrapper\n chooseFilesButtonText={chooseFilesButtonText}\n noFileChosenText={noFileChosenText}\n multipleFilesChosenText={multipleFilesChosenText}\n dropInstructionText={dropInstructionText}\n enteredDropZoneText={enteredDropZoneText}\n leftDropZoneText={leftDropZoneText}\n >\n <ButtonComposite chooseFilesButtonText={chooseFilesButtonText} dropInstructionText={dropInstructionText} />\n <FileUpload {...props} />\n </Wrapper>\n <Announcements />\n </Root>\n );\n}\n\nexport type FieldProps = Omit<Markup.FileUploadFieldProps, 'javascript'>;\n\nconst isSet = (node: React.ReactNode) => node !== undefined && node !== null && node !== false && node !== '';\n\n/**\n * Help users select and upload a file, by choosing it or dropping it on the field. This is\n * govuk-frontend's improved file upload. Without JavaScript it's a native file input.\n *\n * @see https://design-system.service.gov.uk/components/file-upload/#using-the-improved-file-upload-component\n */\nexport function Field({\n id: idProp,\n name,\n label,\n labelSize,\n labelIsPageHeading,\n hint,\n errorMessage,\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 <FormGroup error={Boolean(errorId)}>\n {/* The id govuk-frontend gives the label, which names the button. */}\n <LabelComposite id={`${id}-label`} 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 <Composite id={id} name={name} error={Boolean(errorId)} aria-describedby={ariaDescribedBy} {...props} />\n </FormGroup>\n );\n}\n"]}
1
+ {"version":3,"file":"enhanced.js","sourceRoot":"","sources":["../../../src/components/file-upload/enhanced.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,UAAU,MAAM,qCAAqC,CAAC;AAClE,OAAO,KAAK,MAAM,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,E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AC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IACtD,MAAM,OAAO,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAChE,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAE9D,OAAO,CACL,oBAAC,SAAS,IAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;QAEhC,oBAAC,cAAc,IAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,IAC/F,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,SAAS,IAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,sBAAoB,eAAe,KAAM,KAAK,GAAI,CAC9F,CACb,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/file-upload';\nimport * as Markup from 'govuk-frontend-react/file-upload';\nimport { ErrorMessageComposite } from 'govuk-frontend-react/error-message';\nimport { FormGroup } from 'govuk-frontend-react/form-group';\nimport { Hint } from 'govuk-frontend-react/hint';\nimport { LabelComposite } from 'govuk-frontend-react/label';\nimport { FileUpload, type FileUploadProps, type FileUploadTexts } from './control.js';\nimport { joinIds } from '../../utils/join-ids.js';\n\nexport type RootProps = Omit<\n Primitives.RootProps,\n | 'noFileChosenText'\n | 'multipleFilesChosenText'\n | 'enteredDropZoneAnnouncement'\n | 'leftDropZoneAnnouncement'\n | 'emptyClass'\n | 'draggingClass'\n | 'disabledClass'\n> &\n Pick<FileUploadTexts, 'noFileChosenText' | 'multipleFilesChosenText' | 'enteredDropZoneText' | 'leftDropZoneText'>;\n\n/** Holds `Wrapper` and `Announcements`, and turns the file input into a button and drop zone once JavaScript runs. */\nexport function Root({\n noFileChosenText,\n multipleFilesChosenText,\n enteredDropZoneText,\n leftDropZoneText,\n ...props\n}: RootProps) {\n return (\n <Primitives.Root\n noFileChosenText={noFileChosenText}\n multipleFilesChosenText={multipleFilesChosenText}\n enteredDropZoneAnnouncement={enteredDropZoneText}\n leftDropZoneAnnouncement={leftDropZoneText}\n emptyClass=\"govuk-file-upload-button--empty\"\n draggingClass=\"govuk-file-upload-button--dragging\"\n disabledClass=\"govuk-file-upload-wrapper--disabled\"\n {...props}\n />\n );\n}\n\nexport type WrapperProps = Markup.FileUploadWrapperProps;\n\n/** The drop zone, holding `Button` and `FileUpload`. */\nexport function Wrapper(props: WrapperProps) {\n return (\n <Primitives.DropZone asChild>\n <Markup.FileUploadWrapper {...props} />\n </Primitives.DropZone>\n );\n}\n\nexport type ButtonProps = Omit<Primitives.TriggerProps, 'asChild'>;\n\n/** Opens the file picker, and takes dropped files. Shown once JavaScript runs, before `FileUpload`. */\nexport function Button({ className, ...props }: ButtonProps) {\n return <Primitives.Trigger className={clsx('govuk-file-upload-button', className)} {...props} />;\n}\n\nexport type StatusProps = Omit<Primitives.StatusProps, 'asChild'>;\n\n/** Which files are chosen, in `Button`. */\nexport function Status({ className, ...props }: StatusProps) {\n return <Primitives.Status className={clsx('govuk-body', 'govuk-file-upload-button__status', className)} {...props} />;\n}\n\nexport type CommaProps = Omit<Primitives.SeparatorProps, 'asChild'>;\n\n/** A visually hidden comma between the label and the button's text in its accessible name, after `Status`. */\nexport function Comma({ className, ...props }: CommaProps) {\n return <Primitives.Separator className={clsx('govuk-visually-hidden', className)} {...props} />;\n}\n\nexport type PseudoButtonContainerProps = React.ComponentProps<'span'>;\n\n/** Holds `PseudoButton` and `Instruction`, in `Button`. */\nexport function PseudoButtonContainer({ className, ...props }: PseudoButtonContainerProps) {\n return <span className={clsx('govuk-file-upload-button__pseudo-button-container', className)} {...props} />;\n}\n\nexport type PseudoButtonProps = React.ComponentProps<'span'>;\n\n/** Looks like a secondary button. Defaults to \"Choose file\". */\nexport function PseudoButton({ className, children = 'Choose file', ...props }: PseudoButtonProps) {\n return (\n <span\n className={clsx('govuk-button', 'govuk-button--secondary', 'govuk-file-upload-button__pseudo-button', className)}\n {...props}\n >\n {children}\n </span>\n );\n}\n\nexport type InstructionProps = React.ComponentProps<'span'>;\n\n/** Tells users they can drop files. Defaults to \"or drop file\". */\nexport function Instruction({ className, children = 'or drop file', ...props }: InstructionProps) {\n return (\n <span className={clsx('govuk-body', 'govuk-file-upload-button__instruction', className)} {...props}>\n {children}\n </span>\n );\n}\n\nexport type ButtonCompositeProps = Omit<ButtonProps, 'children'> &\n Pick<FileUploadTexts, 'chooseFilesButtonText' | 'dropInstructionText'>;\n\n/** `Button`, with its status and text. */\nexport function ButtonComposite({ chooseFilesButtonText, dropInstructionText, ...props }: ButtonCompositeProps) {\n return (\n <Button {...props}>\n <Status />\n <Comma />\n <PseudoButtonContainer>\n <PseudoButton>{chooseFilesButtonText}</PseudoButton> <Instruction>{dropInstructionText}</Instruction>\n </PseudoButtonContainer>\n </Button>\n );\n}\n\nexport type AnnouncementsProps = Omit<Primitives.AnnouncementsProps, 'asChild'>;\n\n/** Tells screen reader users when they drag files into or out of the drop zone, after `Wrapper`. */\nexport function Announcements({ className, ...props }: AnnouncementsProps) {\n return (\n <Primitives.Announcements\n className={clsx('govuk-file-upload-announcements', 'govuk-visually-hidden', className)}\n {...props}\n />\n );\n}\n\nexport type CompositeProps = FileUploadProps & FileUploadTexts;\n\n/** `Root`, with the drop zone, button, file input and announcements. Takes the file input's props. */\nexport function Composite({\n chooseFilesButtonText,\n noFileChosenText,\n multipleFilesChosenText,\n dropInstructionText,\n enteredDropZoneText,\n leftDropZoneText,\n ...props\n}: CompositeProps) {\n return (\n <Root\n noFileChosenText={noFileChosenText}\n multipleFilesChosenText={multipleFilesChosenText}\n enteredDropZoneText={enteredDropZoneText}\n leftDropZoneText={leftDropZoneText}\n >\n <Wrapper\n chooseFilesButtonText={chooseFilesButtonText}\n noFileChosenText={noFileChosenText}\n multipleFilesChosenText={multipleFilesChosenText}\n dropInstructionText={dropInstructionText}\n enteredDropZoneText={enteredDropZoneText}\n leftDropZoneText={leftDropZoneText}\n >\n <ButtonComposite chooseFilesButtonText={chooseFilesButtonText} dropInstructionText={dropInstructionText} />\n <FileUpload {...props} />\n </Wrapper>\n <Announcements />\n </Root>\n );\n}\n\nexport type FieldProps = Omit<Markup.FileUploadFieldProps, 'javascript'>;\n\nconst isSet = (node: React.ReactNode) => node !== undefined && node !== null && node !== false && node !== '';\n\n/**\n * Help users select and upload a file, by choosing it or dropping it on the field. This is\n * govuk-frontend's improved file upload. Without JavaScript it's a native file input.\n *\n * @see https://design-system.service.gov.uk/components/file-upload/#using-the-improved-file-upload-component\n */\nexport function Field({\n id: idProp,\n name,\n label,\n labelSize,\n labelIsPageHeading,\n hint,\n errorMessage,\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 <FormGroup error={Boolean(errorId)}>\n {/* The id govuk-frontend gives the label, which names the button. */}\n <LabelComposite id={`${id}-label`} 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 <Composite id={id} name={name} error={Boolean(errorId)} aria-describedby={ariaDescribedBy} {...props} />\n </FormGroup>\n );\n}\n"]}
@@ -1,7 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import type { ComponentProps, ReactNode } from 'react';
3
- /** Static styles, hoisted and deduplicated by React. Dynamic values come in through custom properties. */
4
- export declare const loadingBoxCss = "\n.govuk-react-loading-box{position:relative;padding-bottom:2px;min-height:10px}\n.govuk-react-loading-box__overlay{position:absolute;inset:0;z-index:100;display:flex;justify-content:center;visibility:hidden;transition:visibility 0s linear var(--govuk-react-loading-box-time-out)}\n.govuk-react-loading-box__backdrop{position:absolute;inset:0;background-color:var(--govuk-react-loading-box-background-colour);opacity:0;transition:opacity var(--govuk-react-loading-box-time-out) ease-in-out}\n.govuk-react-loading-box__spinner{position:absolute;z-index:1;display:block;width:50px;height:100%;max-height:calc(50vh + 100px);opacity:0;transition:opacity var(--govuk-react-loading-box-time-out) ease-in-out}\n.govuk-react-loading-box__spinner rect{animation:govuk-react-loading-box-fade 1s infinite linear}\n.govuk-react-loading-box--loading>.govuk-react-loading-box__overlay{visibility:visible;transition-delay:0s}\n.govuk-react-loading-box--loading>.govuk-react-loading-box__overlay>.govuk-react-loading-box__backdrop{opacity:var(--govuk-react-loading-box-background-opacity);transition-duration:var(--govuk-react-loading-box-time-in)}\n.govuk-react-loading-box--loading>.govuk-react-loading-box__overlay>.govuk-react-loading-box__spinner{opacity:1;transition-duration:var(--govuk-react-loading-box-time-in);transition-delay:calc(var(--govuk-react-loading-box-time-in) / 2)}\n\n.govuk-react-loading-box__text{display:none;position:absolute;z-index:1;margin:0;padding-top:20px}\n@media (prefers-reduced-motion:reduce){.govuk-react-loading-box__overlay,.govuk-react-loading-box__backdrop,.govuk-react-loading-box__spinner{transition:none}.govuk-react-loading-box__spinner{display:none}.govuk-react-loading-box__text{display:block}}\n@keyframes govuk-react-loading-box-fade{0%{opacity:.250075}.01%{opacity:.25}.03%{opacity:1}100%{opacity:.250075}}\n";
5
3
  export type LoadingBoxProps = Omit<ComponentProps<'div'>, 'title'> & {
6
4
  /** Content that the loading box overlays. */
7
5
  children?: ReactNode;
@@ -1,20 +1,5 @@
1
1
  import * as React from 'react';
2
2
  const name = 'govuk-react-loading-box';
3
- /** Static styles, hoisted and deduplicated by React. Dynamic values come in through custom properties. */
4
- export const loadingBoxCss = `
5
- .${name}{position:relative;padding-bottom:2px;min-height:10px}
6
- .${name}__overlay{position:absolute;inset:0;z-index:100;display:flex;justify-content:center;visibility:hidden;transition:visibility 0s linear var(--${name}-time-out)}
7
- .${name}__backdrop{position:absolute;inset:0;background-color:var(--${name}-background-colour);opacity:0;transition:opacity var(--${name}-time-out) ease-in-out}
8
- .${name}__spinner{position:absolute;z-index:1;display:block;width:50px;height:100%;max-height:calc(50vh + 100px);opacity:0;transition:opacity var(--${name}-time-out) ease-in-out}
9
- .${name}__spinner rect{animation:${name}-fade 1s infinite linear}
10
- .${name}--loading>.${name}__overlay{visibility:visible;transition-delay:0s}
11
- .${name}--loading>.${name}__overlay>.${name}__backdrop{opacity:var(--${name}-background-opacity);transition-duration:var(--${name}-time-in)}
12
- .${name}--loading>.${name}__overlay>.${name}__spinner{opacity:1;transition-duration:var(--${name}-time-in);transition-delay:calc(var(--${name}-time-in) / 2)}
13
-
14
- .${name}__text{display:none;position:absolute;z-index:1;margin:0;padding-top:20px}
15
- @media (prefers-reduced-motion:reduce){.${name}__overlay,.${name}__backdrop,.${name}__spinner{transition:none}.${name}__spinner{display:none}.${name}__text{display:block}}
16
- @keyframes ${name}-fade{0%{opacity:.250075}.01%{opacity:.25}.03%{opacity:1}100%{opacity:.250075}}
17
- `;
18
3
  /**
19
4
  * Wraps content that loads asynchronously. While `loading` is `true`, a spinner and overlay cover the content and `statusText` is announced.
20
5
  *
@@ -34,7 +19,6 @@ export function LoadingBox({ children, loading = false, statusText = 'Loading',
34
19
  ...style,
35
20
  };
36
21
  return (React.createElement("div", { className: [name, loading && `${name}--loading`, className].filter(Boolean).join(' '), style: variables, ...props },
37
- React.createElement("style", { href: name, precedence: "default" }, loadingBoxCss),
38
22
  React.createElement("div", { className: `${name}__overlay`, "aria-hidden": "true" },
39
23
  React.createElement("svg", { className: `${name}__spinner`, viewBox: "-25 -25 50 50", preserveAspectRatio: "xMidYMid meet", fill: spinnerColor, focusable: "false" }, Array.from({ length: 12 }, (_, i) => (React.createElement("rect", { key: i, width: "12", height: "5", rx: "2.5", ry: "2.5", opacity: "0", transform: `rotate(${i * 30}, 0, 2) translate(10 0)`, style: { animationDelay: `${i * 83}ms` } })))),
40
24
  React.createElement("p", { className: `govuk-body govuk-!-font-weight-bold ${name}__text` }, statusText),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/loading-box/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,IAAI,GAAG,yBAAyB,CAAC;AAEvC,0GAA0G;AAC1G,MAAM,CAAC,MAAM,aAAa,GAAG;GAC1B,IAAI;GACJ,IAAI,+IAA+I,IAAI;GACvJ,IAAI,+DAA+D,IAAI,0DAA0D,IAAI;GACrI,IAAI,+IAA+I,IAAI;GACvJ,IAAI,4BAA4B,IAAI;GACpC,IAAI,cAAc,IAAI;GACtB,IAAI,cAAc,IAAI,cAAc,IAAI,4BAA4B,IAAI,kDAAkD,IAAI;GAC9H,IAAI,cAAc,IAAI,cAAc,IAAI,iDAAiD,IAAI,yCAAyC,IAAI;;GAE1I,IAAI;0CACmC,IAAI,cAAc,IAAI,eAAe,IAAI,8BAA8B,IAAI,2BAA2B,IAAI;aACvI,IAAI;CAChB,CAAC;AAuBF;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,QAAQ,EACR,OAAO,GAAG,KAAK,EACf,UAAU,GAAG,SAAS,EACtB,iBAAiB,GAAG,KAAK,EACzB,YAAY,GAAG,mCAAmC,EAClD,eAAe,GAAG,2CAA2C,EAC7D,sBAAsB,GAAG,IAAI,EAC7B,MAAM,GAAG,GAAG,EACZ,OAAO,GAAG,GAAG,EACb,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACQ;IAChB,MAAM,SAAS,G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G,IAAI,YAAY,GAAI,CACnC;QACN,6BAAK,SAAS,EAAC,uBAAuB,EAAC,IAAI,EAAC,QAAQ,IACjD,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CACxB;QACN,0CAAgB,OAAO,EAAE,KAAK,EAAE,iBAAiB,IAAI,OAAO,IACzD,QAAQ,CACL,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { CSSProperties, ComponentProps, ReactNode } from 'react';\n\nconst name = 'govuk-react-loading-box';\n\n/** Static styles, hoisted and deduplicated by React. Dynamic values come in through custom properties. */\nexport const loadingBoxCss = `\n.${name}{position:relative;padding-bottom:2px;min-height:10px}\n.${name}__overlay{position:absolute;inset:0;z-index:100;display:flex;justify-content:center;visibility:hidden;transition:visibility 0s linear var(--${name}-time-out)}\n.${name}__backdrop{position:absolute;inset:0;background-color:var(--${name}-background-colour);opacity:0;transition:opacity var(--${name}-time-out) ease-in-out}\n.${name}__spinner{position:absolute;z-index:1;display:block;width:50px;height:100%;max-height:calc(50vh + 100px);opacity:0;transition:opacity var(--${name}-time-out) ease-in-out}\n.${name}__spinner rect{animation:${name}-fade 1s infinite linear}\n.${name}--loading>.${name}__overlay{visibility:visible;transition-delay:0s}\n.${name}--loading>.${name}__overlay>.${name}__backdrop{opacity:var(--${name}-background-opacity);transition-duration:var(--${name}-time-in)}\n.${name}--loading>.${name}__overlay>.${name}__spinner{opacity:1;transition-duration:var(--${name}-time-in);transition-delay:calc(var(--${name}-time-in) / 2)}\n\n.${name}__text{display:none;position:absolute;z-index:1;margin:0;padding-top:20px}\n@media (prefers-reduced-motion:reduce){.${name}__overlay,.${name}__backdrop,.${name}__spinner{transition:none}.${name}__spinner{display:none}.${name}__text{display:block}}\n@keyframes ${name}-fade{0%{opacity:.250075}.01%{opacity:.25}.03%{opacity:1}100%{opacity:.250075}}\n`;\n\nexport type LoadingBoxProps = Omit<ComponentProps<'div'>, 'title'> & {\n /** Content that the loading box overlays. */\n children?: ReactNode;\n /** Whether the content is loading. Shows the spinner and overlay, announces `statusText`, and sets `aria-busy` on the content. */\n loading?: boolean;\n /** Text announced to screen reader users while loading, and shown instead of the spinner when the user prefers reduced motion. Say what’s happening, such as “Sending your application”. */\n statusText?: ReactNode;\n /** Make the content inert while loading, so users can’t interact with it or move focus into it. Focus inside the content moves to the page body, so move focus yourself when loading ends. */\n inertWhileLoading?: boolean;\n /** Colour of the spinner, as any CSS colour. Defaults to the text colour. */\n spinnerColor?: string;\n /** Colour of the overlay, as any CSS colour. Defaults to the page background colour. */\n backgroundColor?: string;\n /** Opacity of the overlay, from 0 to 1. */\n backgroundColorOpacity?: number;\n /** Length of the fade-in, in milliseconds. */\n timeIn?: number;\n /** Length of the fade-out, in milliseconds. */\n timeOut?: number;\n};\n\n/**\n * Wraps content that loads asynchronously. While `loading` is `true`, a spinner and overlay cover the content and `statusText` is announced.\n *\n * - Say what’s happening in `statusText`, and keep it showing for at least a couple of seconds so it doesn’t flash and screen readers have time to announce it.\n * - Don’t disable buttons while loading: disabled buttons have poor contrast and can confuse some users. Prevent repeat submissions in your submit handler, and on the server.\n * - When loading ends, move focus to the result, or to the error summary if there are errors.\n * - If loading fails or times out, show an error and a way to continue. Don’t leave the spinner running.\n *\n * @see https://github.com/alphagov/govuk-design-system/discussions/6167\n */\nexport function LoadingBox({\n children,\n loading = false,\n statusText = 'Loading',\n inertWhileLoading = false,\n spinnerColor = 'var(--govuk-text-colour, #0b0c0c)',\n backgroundColor = 'var(--govuk-body-background-colour, #fff)',\n backgroundColorOpacity = 0.85,\n timeIn = 800,\n timeOut = 200,\n className,\n style,\n ...props\n}: LoadingBoxProps) {\n const variables: CSSProperties & Record<`--${string}`, string> = {\n [`--${name}-background-colour`]: backgroundColor,\n [`--${name}-background-opacity`]: String(backgroundColorOpacity),\n [`--${name}-time-in`]: `${timeIn}ms`,\n [`--${name}-time-out`]: `${timeOut}ms`,\n ...style,\n };\n return (\n <div\n className={[name, loading && `${name}--loading`, className].filter(Boolean).join(' ')}\n style={variables}\n {...props}\n >\n <style href={name} precedence=\"default\">\n {loadingBoxCss}\n </style>\n <div className={`${name}__overlay`} aria-hidden=\"true\">\n <svg\n className={`${name}__spinner`}\n viewBox=\"-25 -25 50 50\"\n preserveAspectRatio=\"xMidYMid meet\"\n fill={spinnerColor}\n focusable=\"false\"\n >\n {Array.from({ length: 12 }, (_, i) => (\n <rect\n key={i}\n width=\"12\"\n height=\"5\"\n rx=\"2.5\"\n ry=\"2.5\"\n opacity=\"0\"\n transform={`rotate(${i * 30}, 0, 2) translate(10 0)`}\n style={{ animationDelay: `${i * 83}ms` }}\n />\n ))}\n </svg>\n <p className={`govuk-body govuk-!-font-weight-bold ${name}__text`}>{statusText}</p>\n <div className={`${name}__backdrop`} />\n </div>\n <div className=\"govuk-visually-hidden\" role=\"status\">\n {loading ? statusText : null}\n </div>\n <div aria-busy={loading} inert={inertWhileLoading && loading}>\n {children}\n </div>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/loading-box/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,IAAI,GAAG,yBAAyB,CAAC;AAuBvC;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,QAAQ,EACR,OAAO,GAAG,KAAK,EACf,UAAU,GAAG,SAAS,EACtB,iBAAiB,GAAG,KAAK,EACzB,YAAY,GAAG,mCAAmC,EAClD,eAAe,GAAG,2CAA2C,EAC7D,sBAAsB,GAAG,IAAI,EAC7B,MAAM,GAAG,GAAG,EACZ,OAAO,GAAG,GAAG,EACb,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACQ;IAChB,MAAM,SAAS,GAAkD;QAC/D,CAAC,KAAK,IAAI,oBAAoB,CAAC,EAAE,eAAe;QAChD,CAAC,KAAK,IAAI,qBAAqB,CAAC,EAAE,MAAM,CAAC,sBAAsB,CAAC;QACh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AAO,IACzD,QAAQ,CACL,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { CSSProperties, ComponentProps, ReactNode } from 'react';\n\nconst name = 'govuk-react-loading-box';\n\nexport type LoadingBoxProps = Omit<ComponentProps<'div'>, 'title'> & {\n /** Content that the loading box overlays. */\n children?: ReactNode;\n /** Whether the content is loading. Shows the spinner and overlay, announces `statusText`, and sets `aria-busy` on the content. */\n loading?: boolean;\n /** Text announced to screen reader users while loading, and shown instead of the spinner when the user prefers reduced motion. Say what’s happening, such as “Sending your application”. */\n statusText?: ReactNode;\n /** Make the content inert while loading, so users can’t interact with it or move focus into it. Focus inside the content moves to the page body, so move focus yourself when loading ends. */\n inertWhileLoading?: boolean;\n /** Colour of the spinner, as any CSS colour. Defaults to the text colour. */\n spinnerColor?: string;\n /** Colour of the overlay, as any CSS colour. Defaults to the page background colour. */\n backgroundColor?: string;\n /** Opacity of the overlay, from 0 to 1. */\n backgroundColorOpacity?: number;\n /** Length of the fade-in, in milliseconds. */\n timeIn?: number;\n /** Length of the fade-out, in milliseconds. */\n timeOut?: number;\n};\n\n/**\n * Wraps content that loads asynchronously. While `loading` is `true`, a spinner and overlay cover the content and `statusText` is announced.\n *\n * - Say what’s happening in `statusText`, and keep it showing for at least a couple of seconds so it doesn’t flash and screen readers have time to announce it.\n * - Don’t disable buttons while loading: disabled buttons have poor contrast and can confuse some users. Prevent repeat submissions in your submit handler, and on the server.\n * - When loading ends, move focus to the result, or to the error summary if there are errors.\n * - If loading fails or times out, show an error and a way to continue. Don’t leave the spinner running.\n *\n * @see https://github.com/alphagov/govuk-design-system/discussions/6167\n */\nexport function LoadingBox({\n children,\n loading = false,\n statusText = 'Loading',\n inertWhileLoading = false,\n spinnerColor = 'var(--govuk-text-colour, #0b0c0c)',\n backgroundColor = 'var(--govuk-body-background-colour, #fff)',\n backgroundColorOpacity = 0.85,\n timeIn = 800,\n timeOut = 200,\n className,\n style,\n ...props\n}: LoadingBoxProps) {\n const variables: CSSProperties & Record<`--${string}`, string> = {\n [`--${name}-background-colour`]: backgroundColor,\n [`--${name}-background-opacity`]: String(backgroundColorOpacity),\n [`--${name}-time-in`]: `${timeIn}ms`,\n [`--${name}-time-out`]: `${timeOut}ms`,\n ...style,\n };\n return (\n <div\n className={[name, loading && `${name}--loading`, className].filter(Boolean).join(' ')}\n style={variables}\n {...props}\n >\n <div className={`${name}__overlay`} aria-hidden=\"true\">\n <svg\n className={`${name}__spinner`}\n viewBox=\"-25 -25 50 50\"\n preserveAspectRatio=\"xMidYMid meet\"\n fill={spinnerColor}\n focusable=\"false\"\n >\n {Array.from({ length: 12 }, (_, i) => (\n <rect\n key={i}\n width=\"12\"\n height=\"5\"\n rx=\"2.5\"\n ry=\"2.5\"\n opacity=\"0\"\n transform={`rotate(${i * 30}, 0, 2) translate(10 0)`}\n style={{ animationDelay: `${i * 83}ms` }}\n />\n ))}\n </svg>\n <p className={`govuk-body govuk-!-font-weight-bold ${name}__text`}>{statusText}</p>\n <div className={`${name}__backdrop`} />\n </div>\n <div className=\"govuk-visually-hidden\" role=\"status\">\n {loading ? statusText : null}\n </div>\n <div aria-busy={loading} inert={inertWhileLoading && loading}>\n {children}\n </div>\n </div>\n );\n}\n"]}
@@ -2,8 +2,6 @@ import * as React from 'react';
2
2
  import type { ReactNode } from 'react';
3
3
  import * as Primitives from '@govuk-react/primitives/modal';
4
4
  import { type ButtonProps } from 'govuk-frontend-react/button';
5
- /** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */
6
- export declare const modalCss = "\n.govuk-react-modal{box-sizing:border-box;width:calc(100% - 30px);max-width:640px;max-height:calc(100% - 30px);padding:30px;border:5px solid var(--govuk-text-colour,#0b0c0c);background:var(--govuk-body-background-colour,#fff);color:var(--govuk-text-colour,#0b0c0c)}\n.govuk-react-modal:focus{outline:3px solid var(--govuk-focus-colour,#fd0);outline-offset:0}\n.govuk-react-modal::backdrop{background:rgb(11 12 12 / .8)}\n.govuk-react-modal>:last-child{margin-bottom:0}\n@media (max-width:40.0525em){.govuk-react-modal{padding:15px}}\n";
7
5
  export type RootProps = Primitives.RootProps;
8
6
  /** Holds the modal and the buttons that open and close it. */
9
7
  export declare function Root({ children, ...props }: RootProps): React.JSX.Element;
@@ -9,19 +9,9 @@ import { Button } from 'govuk-frontend-react/button';
9
9
  * JavaScript.
10
10
  */
11
11
  const name = 'govuk-react-modal';
12
- /** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */
13
- export const modalCss = `
14
- .${name}{box-sizing:border-box;width:calc(100% - 30px);max-width:640px;max-height:calc(100% - 30px);padding:30px;border:5px solid var(--govuk-text-colour,#0b0c0c);background:var(--govuk-body-background-colour,#fff);color:var(--govuk-text-colour,#0b0c0c)}
15
- .${name}:focus{outline:3px solid var(--govuk-focus-colour,#fd0);outline-offset:0}
16
- .${name}::backdrop{background:rgb(11 12 12 / .8)}
17
- .${name}>:last-child{margin-bottom:0}
18
- @media (max-width:40.0525em){.${name}{padding:15px}}
19
- `;
20
12
  /** Holds the modal and the buttons that open and close it. */
21
13
  export function Root({ children, ...props }) {
22
- return (React.createElement(Primitives.Root, { ...props },
23
- React.createElement("style", { href: name, precedence: "default" }, modalCss),
24
- children));
14
+ return React.createElement(Primitives.Root, { ...props }, children);
25
15
  }
26
16
  /** A button that opens the modal. */
27
17
  export function Trigger({ dialogId, ...props }) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/modal/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,+BAA+B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAoB,MAAM,6BAA6B,CAAC;AAEvE;;;;;GAKG;AAEH,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC,iFAAiF;AACjF,MAAM,CAAC,MAAM,QAAQ,GAAG;GACrB,IA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,CAAC,KAAM,KAAK,GAAI,CAAC;AACxF,CAAC;AAaD,qEAAqE;AACrE,MAAM,UAAU,SAAS,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,GAAG,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAkB;IACjH,OAAO,CACL,oBAAC,IAAI,OAAK,KAAK;QACb,oBAAC,OAAO,QAAE,WAAW,CAAW;QAChC,oBAAC,OAAO;YACN,oBAAC,KAAK,QAAE,KAAK,CAAS;YACrB,QAAQ;YACT,6BAAK,SAAS,EAAC,oBAAoB;gBAChC,OAAO;gBACR,oBAAC,KAAK,QAAE,SAAS,CAAS,CACtB,CACE,CACL,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ReactNode } from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/modal';\nimport { Button, type ButtonProps } from 'govuk-frontend-react/button';\n\n/*\n * A modal dialog on GOV.UK styles, with the behaviour from @govuk-react/primitives. govuk-frontend\n * has no modal, so its look follows the dialogs that GOV.UK services already use, such as the\n * HMRC timeout warning. Where the browser supports invoker commands, it is a true modal without\n * JavaScript.\n */\n\nconst name = 'govuk-react-modal';\n\n/** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */\nexport const modalCss = `\n.${name}{box-sizing:border-box;width:calc(100% - 30px);max-width:640px;max-height:calc(100% - 30px);padding:30px;border:5px solid var(--govuk-text-colour,#0b0c0c);background:var(--govuk-body-background-colour,#fff);color:var(--govuk-text-colour,#0b0c0c)}\n.${name}:focus{outline:3px solid var(--govuk-focus-colour,#fd0);outline-offset:0}\n.${name}::backdrop{background:rgb(11 12 12 / .8)}\n.${name}>:last-child{margin-bottom:0}\n@media (max-width:40.0525em){.${name}{padding:15px}}\n`;\n\nexport type RootProps = Primitives.RootProps;\n\n/** Holds the modal and the buttons that open and close it. */\nexport function Root({ children, ...props }: RootProps) {\n return (\n <Primitives.Root {...props}>\n <style href={name} precedence=\"default\">\n {modalCss}\n </style>\n {children}\n </Primitives.Root>\n );\n}\n\nexport type TriggerProps = Omit<ButtonProps, 'as' | 'href' | 'type'> & Pick<Primitives.TriggerProps, 'dialogId'>;\n\n/** A button that opens the modal. */\nexport function Trigger({ dialogId, ...props }: TriggerProps) {\n return (\n <Primitives.Trigger dialogId={dialogId} asChild>\n <Button type=\"button\" {...props} />\n </Primitives.Trigger>\n );\n}\n\nexport type CloseProps = TriggerProps;\n\n/** A button that closes the modal. A secondary button, unless you pass another `variant`, or `undefined` for a primary one. */\nexport function Close({ dialogId, ...props }: CloseProps) {\n return (\n <Primitives.Close dialogId={dialogId} asChild>\n <Button type=\"button\" variant=\"secondary\" {...props} />\n </Primitives.Close>\n );\n}\n\nexport type ContentProps = Omit<Primitives.ContentProps, 'asChild'>;\n\n/** The modal dialog. Give it a Title. */\nexport function Content({ className, ...props }: ContentProps) {\n return <Primitives.Content className={clsx(name, className)} {...props} />;\n}\n\nexport type TitleProps = Omit<Primitives.TitleProps, 'asChild'>;\n\n/** The modal's heading, which names it. */\nexport function Title({ className, ...props }: TitleProps) {\n return <Primitives.Title className={clsx('govuk-heading-m', className)} {...props} />;\n}\n\nexport type CompositeProps = Omit<RootProps, 'title'> & {\n /** The text of the button that opens the modal. */\n triggerText: ReactNode;\n /** The modal's heading. */\n title: ReactNode;\n /** The text of the button that closes the modal. Defaults to \"Cancel\". */\n closeText?: ReactNode;\n /** Other actions, such as a button that confirms, shown before the close button. */\n actions?: ReactNode;\n};\n\n/** A button that opens a modal with a title, content and actions. */\nexport function Composite({ triggerText, title, closeText = 'Cancel', actions, children, ...props }: CompositeProps) {\n return (\n <Root {...props}>\n <Trigger>{triggerText}</Trigger>\n <Content>\n <Title>{title}</Title>\n {children}\n <div className=\"govuk-button-group\">\n {actions}\n <Close>{closeText}</Close>\n </div>\n </Content>\n </Root>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/modal/index.tsx"],"names":[],"m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E,GAAG,KAAK,EAAc;IACvD,OAAO,oBAAC,UAAU,CAAC,KAAK,IAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,KAAM,KAAK,GAAI,CAAC;AACxF,CAAC;AAaD,qEAAqE;AACrE,MAAM,UAAU,SAAS,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,GAAG,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAkB;IACjH,OAAO,CACL,oBAAC,IAAI,OAAK,KAAK;QACb,oBAAC,OAAO,QAAE,WAAW,CAAW;QAChC,oBAAC,OAAO;YACN,oBAAC,KAAK,QAAE,KAAK,CAAS;YACrB,QAAQ;YACT,6BAAK,SAAS,EAAC,oBAAoB;gBAChC,OAAO;gBACR,oBAAC,KAAK,QAAE,SAAS,CAAS,CACtB,CACE,CACL,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ReactNode } from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/modal';\nimport { Button, type ButtonProps } from 'govuk-frontend-react/button';\n\n/*\n * A modal dialog on GOV.UK styles, with the behaviour from @govuk-react/primitives. govuk-frontend\n * has no modal, so its look follows the dialogs that GOV.UK services already use, such as the\n * HMRC timeout warning. Where the browser supports invoker commands, it is a true modal without\n * JavaScript.\n */\n\nconst name = 'govuk-react-modal';\n\nexport type RootProps = Primitives.RootProps;\n\n/** Holds the modal and the buttons that open and close it. */\nexport function Root({ children, ...props }: RootProps) {\n return <Primitives.Root {...props}>{children}</Primitives.Root>;\n}\n\nexport type TriggerProps = Omit<ButtonProps, 'as' | 'href' | 'type'> & Pick<Primitives.TriggerProps, 'dialogId'>;\n\n/** A button that opens the modal. */\nexport function Trigger({ dialogId, ...props }: TriggerProps) {\n return (\n <Primitives.Trigger dialogId={dialogId} asChild>\n <Button type=\"button\" {...props} />\n </Primitives.Trigger>\n );\n}\n\nexport type CloseProps = TriggerProps;\n\n/** A button that closes the modal. A secondary button, unless you pass another `variant`, or `undefined` for a primary one. */\nexport function Close({ dialogId, ...props }: CloseProps) {\n return (\n <Primitives.Close dialogId={dialogId} asChild>\n <Button type=\"button\" variant=\"secondary\" {...props} />\n </Primitives.Close>\n );\n}\n\nexport type ContentProps = Omit<Primitives.ContentProps, 'asChild'>;\n\n/** The modal dialog. Give it a Title. */\nexport function Content({ className, ...props }: ContentProps) {\n return <Primitives.Content className={clsx(name, className)} {...props} />;\n}\n\nexport type TitleProps = Omit<Primitives.TitleProps, 'asChild'>;\n\n/** The modal's heading, which names it. */\nexport function Title({ className, ...props }: TitleProps) {\n return <Primitives.Title className={clsx('govuk-heading-m', className)} {...props} />;\n}\n\nexport type CompositeProps = Omit<RootProps, 'title'> & {\n /** The text of the button that opens the modal. */\n triggerText: ReactNode;\n /** The modal's heading. */\n title: ReactNode;\n /** The text of the button that closes the modal. Defaults to \"Cancel\". */\n closeText?: ReactNode;\n /** Other actions, such as a button that confirms, shown before the close button. */\n actions?: ReactNode;\n};\n\n/** A button that opens a modal with a title, content and actions. */\nexport function Composite({ triggerText, title, closeText = 'Cancel', actions, children, ...props }: CompositeProps) {\n return (\n <Root {...props}>\n <Trigger>{triggerText}</Trigger>\n <Content>\n <Title>{title}</Title>\n {children}\n <div className=\"govuk-button-group\">\n {actions}\n <Close>{closeText}</Close>\n </div>\n </Content>\n </Root>\n );\n}\n"]}
@@ -30,7 +30,7 @@ export function Input(props) {
30
30
  }
31
31
  /** The show and hide button. Hidden until JavaScript runs. */
32
32
  export function Toggle(props) {
33
- return (React.createElement(Primitives.Toggle, { asChild: true },
33
+ return (React.createElement(Primitives.Trigger, { asChild: true },
34
34
  React.createElement(Markup.Toggle, { ...props })));
35
35
  }
36
36
  /** A visually hidden live region that announces when the password is shown or hidden. */