govuk-react 0.10.7 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +45 -52
- package/dist/components/accordion/index.d.ts +68 -0
- package/dist/components/accordion/index.js +104 -0
- package/dist/components/accordion/index.js.map +1 -0
- package/dist/components/back-link/index.d.ts +1 -0
- package/dist/components/back-link/index.js +2 -0
- package/dist/components/back-link/index.js.map +1 -0
- package/dist/components/body/index.d.ts +1 -0
- package/dist/components/body/index.js +2 -0
- package/dist/components/body/index.js.map +1 -0
- package/dist/components/breadcrumbs/index.d.ts +1 -0
- package/dist/components/breadcrumbs/index.js +2 -0
- package/dist/components/breadcrumbs/index.js.map +1 -0
- package/dist/components/button/index.d.ts +24 -0
- package/dist/components/button/index.js +17 -0
- package/dist/components/button/index.js.map +1 -0
- package/dist/components/caption/index.d.ts +1 -0
- package/dist/components/caption/index.js +2 -0
- package/dist/components/caption/index.js.map +1 -0
- package/dist/components/character-count/index.d.ts +36 -0
- package/dist/components/character-count/index.js +82 -0
- package/dist/components/character-count/index.js.map +1 -0
- package/dist/components/checkboxes/index.d.ts +49 -0
- package/dist/components/checkboxes/index.js +73 -0
- package/dist/components/checkboxes/index.js.map +1 -0
- package/dist/components/cookie-banner/index.d.ts +1 -0
- package/dist/components/cookie-banner/index.js +2 -0
- package/dist/components/cookie-banner/index.js.map +1 -0
- package/dist/components/date-input/index.d.ts +1 -0
- package/dist/components/date-input/index.js +2 -0
- package/dist/components/date-input/index.js.map +1 -0
- package/dist/components/details/index.d.ts +1 -0
- package/dist/components/details/index.js +2 -0
- package/dist/components/details/index.js.map +1 -0
- package/dist/components/document-footer-metadata/index.d.ts +35 -0
- package/dist/components/document-footer-metadata/index.js +36 -0
- package/dist/components/document-footer-metadata/index.js.map +1 -0
- package/dist/components/error-message/index.d.ts +1 -0
- package/dist/components/error-message/index.js +2 -0
- package/dist/components/error-message/index.js.map +1 -0
- package/dist/components/error-summary/index.d.ts +22 -0
- package/dist/components/error-summary/index.js +49 -0
- package/dist/components/error-summary/index.js.map +1 -0
- package/dist/components/exit-this-page/index.d.ts +33 -0
- package/dist/components/exit-this-page/index.js +66 -0
- package/dist/components/exit-this-page/index.js.map +1 -0
- package/dist/components/feedback/index.d.ts +1 -0
- package/dist/components/feedback/index.js +2 -0
- package/dist/components/feedback/index.js.map +1 -0
- package/dist/components/fieldset/index.d.ts +1 -0
- package/dist/components/fieldset/index.js +2 -0
- package/dist/components/fieldset/index.js.map +1 -0
- package/dist/components/file-upload/control.d.ts +6 -0
- package/dist/components/file-upload/control.js +9 -0
- package/dist/components/file-upload/control.js.map +1 -0
- package/dist/components/file-upload/enhanced.d.ts +45 -0
- package/dist/components/file-upload/enhanced.js +84 -0
- package/dist/components/file-upload/enhanced.js.map +1 -0
- package/dist/components/file-upload/index.d.ts +12 -0
- package/dist/components/file-upload/index.js +18 -0
- package/dist/components/file-upload/index.js.map +1 -0
- package/dist/components/footer/index.d.ts +1 -0
- package/dist/components/footer/index.js +2 -0
- package/dist/components/footer/index.js.map +1 -0
- package/dist/components/form-group/index.d.ts +1 -0
- package/dist/components/form-group/index.js +2 -0
- package/dist/components/form-group/index.js.map +1 -0
- package/dist/components/generic-header/index.d.ts +1 -0
- package/dist/components/generic-header/index.js +2 -0
- package/dist/components/generic-header/index.js.map +1 -0
- package/dist/components/grid-column/index.d.ts +1 -0
- package/dist/components/grid-column/index.js +2 -0
- package/dist/components/grid-column/index.js.map +1 -0
- package/dist/components/grid-row/index.d.ts +1 -0
- package/dist/components/grid-row/index.js +2 -0
- package/dist/components/grid-row/index.js.map +1 -0
- package/dist/components/header/index.d.ts +1 -0
- package/dist/components/header/index.js +2 -0
- package/dist/components/header/index.js.map +1 -0
- package/dist/components/heading/index.d.ts +1 -0
- package/dist/components/heading/index.js +2 -0
- package/dist/components/heading/index.js.map +1 -0
- package/dist/components/hint/index.d.ts +1 -0
- package/dist/components/hint/index.js +2 -0
- package/dist/components/hint/index.js.map +1 -0
- package/dist/components/input/index.d.ts +1 -0
- package/dist/components/input/index.js +2 -0
- package/dist/components/input/index.js.map +1 -0
- package/dist/components/inset-text/index.d.ts +1 -0
- package/dist/components/inset-text/index.js +2 -0
- package/dist/components/inset-text/index.js.map +1 -0
- package/dist/components/label/index.d.ts +1 -0
- package/dist/components/label/index.js +2 -0
- package/dist/components/label/index.js.map +1 -0
- package/dist/components/language-navigation/index.d.ts +1 -0
- package/dist/components/language-navigation/index.js +2 -0
- package/dist/components/language-navigation/index.js.map +1 -0
- package/dist/components/link/index.d.ts +1 -0
- package/dist/components/link/index.js +2 -0
- package/dist/components/link/index.js.map +1 -0
- package/dist/components/list/index.d.ts +1 -0
- package/dist/components/list/index.js +2 -0
- package/dist/components/list/index.js.map +1 -0
- package/dist/components/loading-box/index.d.ts +35 -0
- package/dist/components/loading-box/index.js +45 -0
- package/dist/components/loading-box/index.js.map +1 -0
- package/dist/components/main-wrapper/index.d.ts +1 -0
- package/dist/components/main-wrapper/index.js +2 -0
- package/dist/components/main-wrapper/index.js.map +1 -0
- package/dist/components/modal/index.d.ts +33 -0
- package/dist/components/modal/index.js +55 -0
- package/dist/components/modal/index.js.map +1 -0
- package/dist/components/notification-banner/index.d.ts +17 -0
- package/dist/components/notification-banner/index.js +44 -0
- package/dist/components/notification-banner/index.js.map +1 -0
- package/dist/components/page/index.d.ts +23 -0
- package/dist/components/page/index.js +22 -0
- package/dist/components/page/index.js.map +1 -0
- package/dist/components/pagination/index.d.ts +1 -0
- package/dist/components/pagination/index.js +2 -0
- package/dist/components/pagination/index.js.map +1 -0
- package/dist/components/panel/index.d.ts +1 -0
- package/dist/components/panel/index.js +2 -0
- package/dist/components/panel/index.js.map +1 -0
- package/dist/components/password-input/index.d.ts +26 -0
- package/dist/components/password-input/index.js +60 -0
- package/dist/components/password-input/index.js.map +1 -0
- package/dist/components/phase-banner/index.d.ts +1 -0
- package/dist/components/phase-banner/index.js +2 -0
- package/dist/components/phase-banner/index.js.map +1 -0
- package/dist/components/radios/index.d.ts +33 -0
- package/dist/components/radios/index.js +70 -0
- package/dist/components/radios/index.js.map +1 -0
- package/dist/components/related-items/index.d.ts +33 -0
- package/dist/components/related-items/index.js +45 -0
- package/dist/components/related-items/index.js.map +1 -0
- package/dist/components/search-box/index.d.ts +89 -0
- package/dist/components/search-box/index.js +136 -0
- package/dist/components/search-box/index.js.map +1 -0
- package/dist/components/section-break/index.d.ts +1 -0
- package/dist/components/section-break/index.js +2 -0
- package/dist/components/section-break/index.js.map +1 -0
- package/dist/components/select/index.d.ts +1 -0
- package/dist/components/select/index.js +2 -0
- package/dist/components/select/index.js.map +1 -0
- package/dist/components/service-navigation/index.d.ts +64 -0
- package/dist/components/service-navigation/index.js +131 -0
- package/dist/components/service-navigation/index.js.map +1 -0
- package/dist/components/skip-link/index.d.ts +12 -0
- package/dist/components/skip-link/index.js +16 -0
- package/dist/components/skip-link/index.js.map +1 -0
- package/dist/components/summary-list/index.d.ts +1 -0
- package/dist/components/summary-list/index.js +2 -0
- package/dist/components/summary-list/index.js.map +1 -0
- package/dist/components/table/index.d.ts +1 -0
- package/dist/components/table/index.js +2 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/tabs/index.d.ts +98 -0
- package/dist/components/tabs/index.js +105 -0
- package/dist/components/tabs/index.js.map +1 -0
- package/dist/components/tag/index.d.ts +1 -0
- package/dist/components/tag/index.js +2 -0
- package/dist/components/tag/index.js.map +1 -0
- package/dist/components/task-list/index.d.ts +1 -0
- package/dist/components/task-list/index.js +2 -0
- package/dist/components/task-list/index.js.map +1 -0
- package/dist/components/textarea/index.d.ts +1 -0
- package/dist/components/textarea/index.js +2 -0
- package/dist/components/textarea/index.js.map +1 -0
- package/dist/components/visually-hidden/index.d.ts +1 -0
- package/dist/components/visually-hidden/index.js +2 -0
- package/dist/components/visually-hidden/index.js.map +1 -0
- package/dist/components/warning-text/index.d.ts +1 -0
- package/dist/components/warning-text/index.js +2 -0
- package/dist/components/warning-text/index.js.map +1 -0
- package/dist/components/width-container/index.d.ts +1 -0
- package/dist/components/width-container/index.js +2 -0
- package/dist/components/width-container/index.js.map +1 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/join-ids.d.ts +2 -0
- package/dist/utils/join-ids.js +6 -0
- package/dist/utils/join-ids.js.map +1 -0
- package/package.json +38 -66
- package/dist/declarations/src/index.d.ts +0 -52
- package/dist/govuk-react.cjs.d.ts +0 -2
- package/dist/govuk-react.cjs.dev.js +0 -351
- package/dist/govuk-react.cjs.js +0 -7
- package/dist/govuk-react.cjs.prod.js +0 -351
- package/dist/govuk-react.esm.js +0 -51
- package/src/index.ts +0 -56
- package/src/test.tsx +0 -56
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
3
|
+
import * as Primitives from '@govuk-react/primitives/autocomplete';
|
|
4
|
+
/** Styles govuk-frontend has no class for, hoisted and deduplicated by React. Based on GOV.UK’s search component. */
|
|
5
|
+
export declare const searchBoxCss = "\n.govuk-react-search-box__wrapper{display:flex;background-color:#fff}\n.govuk-react-search-box__input{margin:0;-webkit-appearance:none;appearance:none}\n.govuk-react-search-box__input:focus{z-index:1}\n.govuk-react-search-box__button{position:relative;flex:0 0 auto;width:2.5rem;height:2.5rem;margin:0;padding:0;border:0;border-radius:0;outline:2px solid transparent;outline-offset:0;cursor:pointer;background-color:var(--govuk-brand-colour,#1d70b8);color:#fff}\n.govuk-react-search-box__button:hover{background-color:color-mix(in srgb,var(--govuk-brand-colour,#1d70b8) 75%,#000)}\n.govuk-react-search-box__button:focus{z-index:1;outline:3px solid var(--govuk-focus-colour,#fd0);box-shadow:inset 0 0 0 4px #0b0c0c}\n.govuk-react-search-box__icon{position:absolute;inset:0;width:100%;height:100%;transform:scale(.5);pointer-events:none}\n.govuk-react-search-box:not(.govuk-react-search-box--inverse) .govuk-react-search-box__input{border-right-width:0}\n.govuk-react-search-box:not(.govuk-react-search-box--inverse) .govuk-react-search-box__input:focus{border-right-width:2px}\n.govuk-react-search-box--inverse .govuk-react-search-box__label{color:#fff}\n.govuk-react-search-box--inverse .govuk-react-search-box__input{border-width:0}\n.govuk-react-search-box--inverse .govuk-react-search-box__button{background-color:color-mix(in srgb,var(--govuk-brand-colour,#1d70b8) 20%,#fff);color:var(--govuk-brand-colour,#1d70b8)}\n.govuk-react-search-box--inverse .govuk-react-search-box__button:hover{background-color:color-mix(in srgb,var(--govuk-brand-colour,#1d70b8) 5%,#fff)}\n.govuk-react-search-box--large .govuk-react-search-box__input{height:3.125rem}\n.govuk-react-search-box--large .govuk-react-search-box__button{width:3.125rem;height:3.125rem}\n.govuk-react-search-box--large .govuk-react-search-box__icon{transform:scale(.4)}\n.govuk-react-search-box__autocomplete{display:block;position:relative}\n.govuk-react-search-box__menu{position:absolute;z-index:100;top:100%;left:0;right:0;margin:0;padding:0;list-style:none;overflow-x:hidden;background-color:#fff;border:1px solid #b1b4b6;border-top:0}\n.govuk-react-search-box--inverse .govuk-react-search-box__menu{border-top:1px solid #b1b4b6}\n.govuk-react-search-box__option{cursor:pointer;font-family:\"GDS Transport\",arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:1rem;line-height:1.25;color:#0b0c0c}\n@media (min-width:40.0625em){.govuk-react-search-box__option{font-size:1.1875rem;line-height:1.3157894737}}\n.govuk-react-search-box__option>*{pointer-events:none}\n.govuk-react-search-box__option[data-focused],.govuk-react-search-box__option:hover,.govuk-react-search-box__option:focus-visible{background-color:#f3f3f3;outline:none;text-decoration:underline;text-decoration-thickness:max(3px,.1875rem,.12em);text-underline-offset:.1578em}\n.govuk-react-search-box__option:focus-visible .govuk-react-search-box__suggestion-text{background-color:var(--govuk-focus-colour,#fd0)}\n.govuk-react-search-box__option[hidden]{display:none}\n.govuk-react-search-box__option-wrapper{display:flex;align-items:center;margin:0 15px;padding:5px 0}\n.govuk-react-search-box__option:not([hidden])~.govuk-react-search-box__option:not([hidden]) .govuk-react-search-box__option-wrapper{border-top:1px solid #b1b4b6}\n.govuk-react-search-box__suggestion-icon{flex:none;width:20px;height:2.5rem;margin-right:10px;background-color:#505a5f;-webkit-mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 27 27'%3E%3Ccircle cx='12' cy='11' r='8.5' fill='none' stroke='%23000' stroke-width='3'/%3E%3Cpath d='m17.9 17.4 8.5 8.5' stroke='%23000' stroke-width='3'/%3E%3C/svg%3E\") center/contain no-repeat;mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 27 27'%3E%3Ccircle cx='12' cy='11' r='8.5' fill='none' stroke='%23000' stroke-width='3'/%3E%3Cpath d='m17.9 17.4 8.5 8.5' stroke='%23000' stroke-width='3'/%3E%3C/svg%3E\") center/contain no-repeat}\n.govuk-react-search-box__option[data-focused] .govuk-react-search-box__suggestion-icon,.govuk-react-search-box__option:hover .govuk-react-search-box__suggestion-icon,.govuk-react-search-box__option:focus-visible .govuk-react-search-box__suggestion-icon{background-color:#0b0c0c}\n.govuk-react-search-box__suggestion-text{font-weight:700}\n.govuk-react-search-box__suggestion-highlight{font-weight:400;background:none;color:inherit}\n.govuk-react-search-box--large .govuk-react-search-box__option{min-height:3.125rem}\n@media (forced-colors:active){.govuk-react-search-box__menu{border-color:FieldText}.govuk-react-search-box__option[data-focused],.govuk-react-search-box__option:hover{forced-color-adjust:none;background-color:Highlight;color:HighlightText}.govuk-react-search-box__suggestion-icon{background-color:currentcolor}}\n";
|
|
6
|
+
export type RootProps = ComponentProps<'div'> & {
|
|
7
|
+
/** For use on dark backgrounds, such as a GOV.UK blue homepage banner. */
|
|
8
|
+
inverse?: boolean;
|
|
9
|
+
/** A larger input and button. */
|
|
10
|
+
large?: boolean;
|
|
11
|
+
};
|
|
12
|
+
/** Wraps the search label, input and submit button. */
|
|
13
|
+
export declare function Root({ inverse, large, className, children, ...props }: RootProps): React.JSX.Element;
|
|
14
|
+
export type LabelProps = ComponentProps<'label'> & {
|
|
15
|
+
/** The label size, from govuk-frontend’s label sizes. */
|
|
16
|
+
size?: 's' | 'm' | 'l' | 'xl';
|
|
17
|
+
/** Hide the label visually. It’s still read by screen readers. */
|
|
18
|
+
visuallyHidden?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare function Label({ size, visuallyHidden, className, children, ...props }: LabelProps): React.JSX.Element;
|
|
21
|
+
export type WrapperProps = ComponentProps<'div'>;
|
|
22
|
+
/** Lays out the input and submit button side by side. */
|
|
23
|
+
export declare function Wrapper({ className, ...props }: WrapperProps): React.JSX.Element;
|
|
24
|
+
export type InputProps = ComponentProps<'input'>;
|
|
25
|
+
export declare function Input({ className, type, ...props }: InputProps): React.JSX.Element;
|
|
26
|
+
export type ButtonProps = ComponentProps<'button'>;
|
|
27
|
+
/** The submit button, with a search icon. Children are its accessible name, “Search” by default. */
|
|
28
|
+
export declare function Button({ className, children, ...props }: ButtonProps): React.JSX.Element;
|
|
29
|
+
export type CompositeProps = Omit<InputProps, 'id'> & Pick<RootProps, 'inverse' | 'large'> & {
|
|
30
|
+
/** The input’s id, which the label points to. */
|
|
31
|
+
id: string;
|
|
32
|
+
/** The label text. */
|
|
33
|
+
label?: ReactNode;
|
|
34
|
+
/** The label size, from govuk-frontend’s label sizes. */
|
|
35
|
+
labelSize?: LabelProps['size'];
|
|
36
|
+
/** Hide the label visually. It’s still read by screen readers. */
|
|
37
|
+
labelVisuallyHidden?: boolean;
|
|
38
|
+
/** The submit button’s visually hidden text. */
|
|
39
|
+
buttonText?: ReactNode;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A search input with a label and an attached submit button, based on GOV.UK’s search component. Put it in your own `form`. Other props go on the input.
|
|
43
|
+
*
|
|
44
|
+
* @see https://components.publishing.service.gov.uk/component-guide/search
|
|
45
|
+
*/
|
|
46
|
+
export declare function Composite({ id, label, labelSize, labelVisuallyHidden, buttonText, inverse, large, ...props }: CompositeProps): React.JSX.Element;
|
|
47
|
+
export type AutocompleteProps = Primitives.RootProps;
|
|
48
|
+
/**
|
|
49
|
+
* Suggests searches as the user types, around `Wrapper`, `Listbox`, `Status` and `AssistiveHint`.
|
|
50
|
+
* Without JavaScript the search box works as usual. Based on GOV.UK’s search with autocomplete,
|
|
51
|
+
* with behaviour from accessible-autocomplete.
|
|
52
|
+
*/
|
|
53
|
+
export declare function Autocomplete({ className, ...props }: AutocompleteProps): React.JSX.Element;
|
|
54
|
+
export type AutocompleteInputProps = InputProps;
|
|
55
|
+
/** `Input`, as the autocomplete’s combobox. */
|
|
56
|
+
export declare function AutocompleteInput(props: AutocompleteInputProps): React.JSX.Element;
|
|
57
|
+
export type ListboxProps = Primitives.ListboxProps;
|
|
58
|
+
/** The menu of suggestions, under the search box. Hidden until there are suggestions to show. */
|
|
59
|
+
export declare function Listbox({ className, ...props }: ListboxProps): React.JSX.Element;
|
|
60
|
+
export type OptionProps = Primitives.OptionProps;
|
|
61
|
+
/** A suggestion, in `Listbox`. Children are its text, which can hold `Match`. */
|
|
62
|
+
export declare function Option({ className, children, ...props }: OptionProps): React.JSX.Element;
|
|
63
|
+
export type MatchProps = ComponentProps<'mark'>;
|
|
64
|
+
/** The part of a suggestion that matches the query, in `Option`. */
|
|
65
|
+
export declare function Match({ className, ...props }: MatchProps): React.JSX.Element;
|
|
66
|
+
export type StatusProps = Primitives.StatusProps;
|
|
67
|
+
/** What screen readers hear about the suggestions. Visually hidden. */
|
|
68
|
+
export declare function Status(props: StatusProps): React.JSX.Element;
|
|
69
|
+
export type AssistiveHintProps = Primitives.AssistiveHintProps;
|
|
70
|
+
/** How to use the suggestions, for screen readers. Never shown. */
|
|
71
|
+
export declare function AssistiveHint({ children, ...props }: AssistiveHintProps): React.JSX.Element;
|
|
72
|
+
export type AutocompleteCompositeProps = CompositeProps & Pick<AutocompleteProps, 'minLength' | 'filter' | 'onQueryChange' | 'onConfirm'> & {
|
|
73
|
+
/**
|
|
74
|
+
* The suggestions for the query, such as from `onQueryChange`. Only those containing the query
|
|
75
|
+
* show, unless `filter` is "none", such as for suggestions a server has already matched.
|
|
76
|
+
* Children are an alternative.
|
|
77
|
+
*/
|
|
78
|
+
suggestions?: string[];
|
|
79
|
+
/** `Option`s, rather than `suggestions`, such as to highlight the query with `Match`. */
|
|
80
|
+
children?: ReactNode;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* A search box that suggests searches as the user types, based on GOV.UK’s search with
|
|
84
|
+
* autocomplete. Choosing a suggestion submits the form. Put it in your own `form`. Other props go
|
|
85
|
+
* on the input. Without JavaScript it’s `Composite`.
|
|
86
|
+
*
|
|
87
|
+
* @see https://components.publishing.service.gov.uk/component-guide/search_with_autocomplete
|
|
88
|
+
*/
|
|
89
|
+
export declare function AutocompleteComposite({ id, label, labelSize, labelVisuallyHidden, buttonText, inverse, large, minLength, filter, onQueryChange, onConfirm, suggestions, children, ...props }: AutocompleteCompositeProps): React.JSX.Element;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import * as Primitives from '@govuk-react/primitives/autocomplete';
|
|
4
|
+
const name = 'govuk-react-search-box';
|
|
5
|
+
const brand = 'var(--govuk-brand-colour,#1d70b8)';
|
|
6
|
+
const suggestionIcon = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 27 27'%3E%3Ccircle cx='12' cy='11' r='8.5' fill='none' stroke='%23000' stroke-width='3'/%3E%3Cpath d='m17.9 17.4 8.5 8.5' stroke='%23000' stroke-width='3'/%3E%3C/svg%3E";
|
|
7
|
+
/** Styles govuk-frontend has no class for, hoisted and deduplicated by React. Based on GOV.UK’s search component. */
|
|
8
|
+
export const searchBoxCss = `
|
|
9
|
+
.${name}__wrapper{display:flex;background-color:#fff}
|
|
10
|
+
.${name}__input{margin:0;-webkit-appearance:none;appearance:none}
|
|
11
|
+
.${name}__input:focus{z-index:1}
|
|
12
|
+
.${name}__button{position:relative;flex:0 0 auto;width:2.5rem;height:2.5rem;margin:0;padding:0;border:0;border-radius:0;outline:2px solid transparent;outline-offset:0;cursor:pointer;background-color:${brand};color:#fff}
|
|
13
|
+
.${name}__button:hover{background-color:color-mix(in srgb,${brand} 75%,#000)}
|
|
14
|
+
.${name}__button:focus{z-index:1;outline:3px solid var(--govuk-focus-colour,#fd0);box-shadow:inset 0 0 0 4px #0b0c0c}
|
|
15
|
+
.${name}__icon{position:absolute;inset:0;width:100%;height:100%;transform:scale(.5);pointer-events:none}
|
|
16
|
+
.${name}:not(.${name}--inverse) .${name}__input{border-right-width:0}
|
|
17
|
+
.${name}:not(.${name}--inverse) .${name}__input:focus{border-right-width:2px}
|
|
18
|
+
.${name}--inverse .${name}__label{color:#fff}
|
|
19
|
+
.${name}--inverse .${name}__input{border-width:0}
|
|
20
|
+
.${name}--inverse .${name}__button{background-color:color-mix(in srgb,${brand} 20%,#fff);color:${brand}}
|
|
21
|
+
.${name}--inverse .${name}__button:hover{background-color:color-mix(in srgb,${brand} 5%,#fff)}
|
|
22
|
+
.${name}--large .${name}__input{height:3.125rem}
|
|
23
|
+
.${name}--large .${name}__button{width:3.125rem;height:3.125rem}
|
|
24
|
+
.${name}--large .${name}__icon{transform:scale(.4)}
|
|
25
|
+
.${name}__autocomplete{display:block;position:relative}
|
|
26
|
+
.${name}__menu{position:absolute;z-index:100;top:100%;left:0;right:0;margin:0;padding:0;list-style:none;overflow-x:hidden;background-color:#fff;border:1px solid #b1b4b6;border-top:0}
|
|
27
|
+
.${name}--inverse .${name}__menu{border-top:1px solid #b1b4b6}
|
|
28
|
+
.${name}__option{cursor:pointer;font-family:"GDS Transport",arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:1rem;line-height:1.25;color:#0b0c0c}
|
|
29
|
+
@media (min-width:40.0625em){.${name}__option{font-size:1.1875rem;line-height:1.3157894737}}
|
|
30
|
+
.${name}__option>*{pointer-events:none}
|
|
31
|
+
.${name}__option[data-focused],.${name}__option:hover,.${name}__option:focus-visible{background-color:#f3f3f3;outline:none;text-decoration:underline;text-decoration-thickness:max(3px,.1875rem,.12em);text-underline-offset:.1578em}
|
|
32
|
+
.${name}__option:focus-visible .${name}__suggestion-text{background-color:var(--govuk-focus-colour,#fd0)}
|
|
33
|
+
.${name}__option[hidden]{display:none}
|
|
34
|
+
.${name}__option-wrapper{display:flex;align-items:center;margin:0 15px;padding:5px 0}
|
|
35
|
+
.${name}__option:not([hidden])~.${name}__option:not([hidden]) .${name}__option-wrapper{border-top:1px solid #b1b4b6}
|
|
36
|
+
.${name}__suggestion-icon{flex:none;width:20px;height:2.5rem;margin-right:10px;background-color:#505a5f;-webkit-mask:url("${suggestionIcon}") center/contain no-repeat;mask:url("${suggestionIcon}") center/contain no-repeat}
|
|
37
|
+
.${name}__option[data-focused] .${name}__suggestion-icon,.${name}__option:hover .${name}__suggestion-icon,.${name}__option:focus-visible .${name}__suggestion-icon{background-color:#0b0c0c}
|
|
38
|
+
.${name}__suggestion-text{font-weight:700}
|
|
39
|
+
.${name}__suggestion-highlight{font-weight:400;background:none;color:inherit}
|
|
40
|
+
.${name}--large .${name}__option{min-height:3.125rem}
|
|
41
|
+
@media (forced-colors:active){.${name}__menu{border-color:FieldText}.${name}__option[data-focused],.${name}__option:hover{forced-color-adjust:none;background-color:Highlight;color:HighlightText}.${name}__suggestion-icon{background-color:currentcolor}}
|
|
42
|
+
`;
|
|
43
|
+
/** Wraps the search label, input and submit button. */
|
|
44
|
+
export function Root({ inverse, large, className, children, ...props }) {
|
|
45
|
+
return (React.createElement("div", { className: clsx(name, inverse && `${name}--inverse`, large && `${name}--large`, className), ...props },
|
|
46
|
+
React.createElement("style", { href: name, precedence: "default" }, searchBoxCss),
|
|
47
|
+
children));
|
|
48
|
+
}
|
|
49
|
+
export function Label({ size, visuallyHidden, className, children, ...props }) {
|
|
50
|
+
return (React.createElement("label", { className: clsx(visuallyHidden ? 'govuk-visually-hidden' : ['govuk-label', size && `govuk-label--${size}`], `${name}__label`, className), ...props }, children));
|
|
51
|
+
}
|
|
52
|
+
/** Lays out the input and submit button side by side. */
|
|
53
|
+
export function Wrapper({ className, ...props }) {
|
|
54
|
+
return React.createElement("div", { className: clsx(`${name}__wrapper`, className), ...props });
|
|
55
|
+
}
|
|
56
|
+
export function Input({ className, type = 'search', ...props }) {
|
|
57
|
+
return (React.createElement("input", { type: type, enterKeyHint: "search", className: clsx('govuk-input', `${name}__input`, className), ...props }));
|
|
58
|
+
}
|
|
59
|
+
/** The submit button, with a search icon. Children are its accessible name, “Search” by default. */
|
|
60
|
+
export function Button({ className, children = 'Search', ...props }) {
|
|
61
|
+
return (React.createElement("button", { type: "submit", className: clsx(`${name}__button`, className), ...props },
|
|
62
|
+
React.createElement("svg", { className: `${name}__icon`, width: "27", height: "27", viewBox: "0 0 27 27", fill: "none", "aria-hidden": "true", focusable: "false" },
|
|
63
|
+
React.createElement("circle", { cx: "12.0161", cy: "11.0161", r: "8.51613", stroke: "currentColor", strokeWidth: "3" }),
|
|
64
|
+
React.createElement("line", { x1: "17.8668", y1: "17.3587", x2: "26.4475", y2: "25.9393", stroke: "currentColor", strokeWidth: "3" })),
|
|
65
|
+
React.createElement("span", { className: "govuk-visually-hidden" }, children)));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A search input with a label and an attached submit button, based on GOV.UK’s search component. Put it in your own `form`. Other props go on the input.
|
|
69
|
+
*
|
|
70
|
+
* @see https://components.publishing.service.gov.uk/component-guide/search
|
|
71
|
+
*/
|
|
72
|
+
export function Composite({ id, label = 'Search on GOV.UK', labelSize, labelVisuallyHidden, buttonText, inverse, large, ...props }) {
|
|
73
|
+
return (React.createElement(Root, { inverse: inverse, large: large },
|
|
74
|
+
React.createElement(Label, { htmlFor: id, size: labelSize, visuallyHidden: labelVisuallyHidden }, label),
|
|
75
|
+
React.createElement(Wrapper, null,
|
|
76
|
+
React.createElement(Input, { id: id, ...props }),
|
|
77
|
+
React.createElement(Button, null, buttonText))));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Suggests searches as the user types, around `Wrapper`, `Listbox`, `Status` and `AssistiveHint`.
|
|
81
|
+
* Without JavaScript the search box works as usual. Based on GOV.UK’s search with autocomplete,
|
|
82
|
+
* with behaviour from accessible-autocomplete.
|
|
83
|
+
*/
|
|
84
|
+
export function Autocomplete({ className, ...props }) {
|
|
85
|
+
return React.createElement(Primitives.Root, { className: clsx(`${name}__autocomplete`, className), ...props });
|
|
86
|
+
}
|
|
87
|
+
/** `Input`, as the autocomplete’s combobox. */
|
|
88
|
+
export function AutocompleteInput(props) {
|
|
89
|
+
return (React.createElement(Primitives.Input, { asChild: true },
|
|
90
|
+
React.createElement(Input, { ...props })));
|
|
91
|
+
}
|
|
92
|
+
/** The menu of suggestions, under the search box. Hidden until there are suggestions to show. */
|
|
93
|
+
export function Listbox({ className, ...props }) {
|
|
94
|
+
return React.createElement(Primitives.Listbox, { className: clsx(`${name}__menu`, className), ...props });
|
|
95
|
+
}
|
|
96
|
+
/** A suggestion, in `Listbox`. Children are its text, which can hold `Match`. */
|
|
97
|
+
export function Option({ className, children, ...props }) {
|
|
98
|
+
return (React.createElement(Primitives.Option, { className: clsx(`${name}__option`, className), ...props },
|
|
99
|
+
React.createElement("span", { className: `${name}__option-wrapper` },
|
|
100
|
+
React.createElement("span", { className: `${name}__suggestion-icon`, "aria-hidden": "true" }),
|
|
101
|
+
React.createElement("span", { className: `${name}__suggestion-text` }, children))));
|
|
102
|
+
}
|
|
103
|
+
/** The part of a suggestion that matches the query, in `Option`. */
|
|
104
|
+
export function Match({ className, ...props }) {
|
|
105
|
+
return React.createElement("mark", { className: clsx(`${name}__suggestion-highlight`, className), ...props });
|
|
106
|
+
}
|
|
107
|
+
/** What screen readers hear about the suggestions. Visually hidden. */
|
|
108
|
+
export function Status(props) {
|
|
109
|
+
return React.createElement(Primitives.Status, { ...props });
|
|
110
|
+
}
|
|
111
|
+
/** How to use the suggestions, for screen readers. Never shown. */
|
|
112
|
+
export function AssistiveHint({ children = 'When search suggestions are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.', ...props }) {
|
|
113
|
+
return React.createElement(Primitives.AssistiveHint, { ...props }, children);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* A search box that suggests searches as the user types, based on GOV.UK’s search with
|
|
117
|
+
* autocomplete. Choosing a suggestion submits the form. Put it in your own `form`. Other props go
|
|
118
|
+
* on the input. Without JavaScript it’s `Composite`.
|
|
119
|
+
*
|
|
120
|
+
* @see https://components.publishing.service.gov.uk/component-guide/search_with_autocomplete
|
|
121
|
+
*/
|
|
122
|
+
export function AutocompleteComposite({ id, label = 'Search on GOV.UK', labelSize, labelVisuallyHidden, buttonText, inverse, large, minLength = 3, filter, onQueryChange, onConfirm, suggestions, children, ...props }) {
|
|
123
|
+
return (React.createElement(Root, { inverse: inverse, large: large },
|
|
124
|
+
React.createElement(Label, { htmlFor: id, size: labelSize, visuallyHidden: labelVisuallyHidden }, label),
|
|
125
|
+
React.createElement(Autocomplete, { minLength: minLength, filter: filter, onQueryChange: onQueryChange, onConfirm: onConfirm, confirmOnBlur: false, submitOnConfirm: true, statusNoResults: "No search suggestions found", statusQueryTooShort: "Type in %{count} or more characters for search suggestions", statusResults: {
|
|
126
|
+
one: '%{count} search suggestion is available.',
|
|
127
|
+
other: '%{count} search suggestions are available.',
|
|
128
|
+
} },
|
|
129
|
+
React.createElement(Wrapper, null,
|
|
130
|
+
React.createElement(AutocompleteInput, { id: id, ...props }),
|
|
131
|
+
React.createElement(Button, null, buttonText)),
|
|
132
|
+
React.createElement(Listbox, null, children !== null && children !== void 0 ? children : suggestions === null || suggestions === void 0 ? void 0 : suggestions.map((suggestion) => (React.createElement(Option, { key: suggestion, value: suggestion }, suggestion)))),
|
|
133
|
+
React.createElement(Status, null),
|
|
134
|
+
React.createElement(AssistiveHint, null))));
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/search-box/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,UAAU,MAAM,sCAAsC,CAAC;AAEnE,MAAM,IAAI,GAAG,wBAAwB,CAAC;AACtC,MAAM,KAAK,GAAG,mCAAmC,CAAC;AAClD,MAAM,cAAc,GAClB,oPAAoP,CAAC;AAEvP,qHAAqH;AACrH,MAAM,CAAC,MAAM,YAAY,GAAG;GACzB,IAAI;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI,kMAAkM,KAAK;GAC3M,IAAI,qDAAqD,KAAK;GAC9D,IAAI;GACJ,IAAI;GACJ,IAAI,SAAS,IAAI,eAAe,IAAI;GACpC,IAAI,SAAS,IAAI,eAAe,IAAI;GACpC,IAAI,cAAc,IAAI;GACtB,IAAI,cAAc,IAAI;GACtB,IAAI,cAAc,IAAI,+CAA+C,KAAK,oBAAoB,KAAK;GACnG,IAAI,cAAc,IAAI,qDAAqD,KAAK;GAChF,IAAI,YAAY,IAAI;GACpB,IAAI,YAAY,IAAI;GACpB,IAAI,YAAY,IAAI;GACpB,IAAI;GACJ,IAAI;GACJ,IAAI,cAAc,IAAI;GACtB,IAAI;gCACyB,IAAI;GACjC,IAAI;GACJ,IAAI,2BAA2B,IAAI,mBAAmB,IAAI;GAC1D,IAAI,2BAA2B,IAAI;GACnC,IAAI;GACJ,IAAI;GACJ,IAAI,2BAA2B,IAAI,2BAA2B,IAAI;GAClE,IAAI,qHAAqH,cAAc,yCAAyC,cAAc;GAC9L,IAAI,2BAA2B,IAAI,sBAAsB,IAAI,mBAAmB,IAAI,sBAAsB,IAAI,2BAA2B,IAAI;GAC7I,IA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,EAAE,EAAE,EAAE,KAAM,KAAK,GAAI;gBACxC,oBAAC,MAAM,QAAE,UAAU,CAAU,CACrB;YACV,oBAAC,OAAO,QACL,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GACP,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAC/B,oBAAC,MAAM,IAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,IACvC,UAAU,CACJ,CACV,CAAC,CACI;YACV,oBAAC,MAAM,OAAG;YACV,oBAAC,aAAa,OAAG,CACJ,CACV,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ReactNode } from 'react';\nimport { clsx } from 'clsx';\nimport * as Primitives from '@govuk-react/primitives/autocomplete';\n\nconst name = 'govuk-react-search-box';\nconst brand = 'var(--govuk-brand-colour,#1d70b8)';\nconst suggestionIcon =\n \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 27 27'%3E%3Ccircle cx='12' cy='11' r='8.5' fill='none' stroke='%23000' stroke-width='3'/%3E%3Cpath d='m17.9 17.4 8.5 8.5' stroke='%23000' stroke-width='3'/%3E%3C/svg%3E\";\n\n/** Styles govuk-frontend has no class for, hoisted and deduplicated by React. Based on GOV.UK’s search component. */\nexport const searchBoxCss = `\n.${name}__wrapper{display:flex;background-color:#fff}\n.${name}__input{margin:0;-webkit-appearance:none;appearance:none}\n.${name}__input:focus{z-index:1}\n.${name}__button{position:relative;flex:0 0 auto;width:2.5rem;height:2.5rem;margin:0;padding:0;border:0;border-radius:0;outline:2px solid transparent;outline-offset:0;cursor:pointer;background-color:${brand};color:#fff}\n.${name}__button:hover{background-color:color-mix(in srgb,${brand} 75%,#000)}\n.${name}__button:focus{z-index:1;outline:3px solid var(--govuk-focus-colour,#fd0);box-shadow:inset 0 0 0 4px #0b0c0c}\n.${name}__icon{position:absolute;inset:0;width:100%;height:100%;transform:scale(.5);pointer-events:none}\n.${name}:not(.${name}--inverse) .${name}__input{border-right-width:0}\n.${name}:not(.${name}--inverse) .${name}__input:focus{border-right-width:2px}\n.${name}--inverse .${name}__label{color:#fff}\n.${name}--inverse .${name}__input{border-width:0}\n.${name}--inverse .${name}__button{background-color:color-mix(in srgb,${brand} 20%,#fff);color:${brand}}\n.${name}--inverse .${name}__button:hover{background-color:color-mix(in srgb,${brand} 5%,#fff)}\n.${name}--large .${name}__input{height:3.125rem}\n.${name}--large .${name}__button{width:3.125rem;height:3.125rem}\n.${name}--large .${name}__icon{transform:scale(.4)}\n.${name}__autocomplete{display:block;position:relative}\n.${name}__menu{position:absolute;z-index:100;top:100%;left:0;right:0;margin:0;padding:0;list-style:none;overflow-x:hidden;background-color:#fff;border:1px solid #b1b4b6;border-top:0}\n.${name}--inverse .${name}__menu{border-top:1px solid #b1b4b6}\n.${name}__option{cursor:pointer;font-family:\"GDS Transport\",arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:1rem;line-height:1.25;color:#0b0c0c}\n@media (min-width:40.0625em){.${name}__option{font-size:1.1875rem;line-height:1.3157894737}}\n.${name}__option>*{pointer-events:none}\n.${name}__option[data-focused],.${name}__option:hover,.${name}__option:focus-visible{background-color:#f3f3f3;outline:none;text-decoration:underline;text-decoration-thickness:max(3px,.1875rem,.12em);text-underline-offset:.1578em}\n.${name}__option:focus-visible .${name}__suggestion-text{background-color:var(--govuk-focus-colour,#fd0)}\n.${name}__option[hidden]{display:none}\n.${name}__option-wrapper{display:flex;align-items:center;margin:0 15px;padding:5px 0}\n.${name}__option:not([hidden])~.${name}__option:not([hidden]) .${name}__option-wrapper{border-top:1px solid #b1b4b6}\n.${name}__suggestion-icon{flex:none;width:20px;height:2.5rem;margin-right:10px;background-color:#505a5f;-webkit-mask:url(\"${suggestionIcon}\") center/contain no-repeat;mask:url(\"${suggestionIcon}\") center/contain no-repeat}\n.${name}__option[data-focused] .${name}__suggestion-icon,.${name}__option:hover .${name}__suggestion-icon,.${name}__option:focus-visible .${name}__suggestion-icon{background-color:#0b0c0c}\n.${name}__suggestion-text{font-weight:700}\n.${name}__suggestion-highlight{font-weight:400;background:none;color:inherit}\n.${name}--large .${name}__option{min-height:3.125rem}\n@media (forced-colors:active){.${name}__menu{border-color:FieldText}.${name}__option[data-focused],.${name}__option:hover{forced-color-adjust:none;background-color:Highlight;color:HighlightText}.${name}__suggestion-icon{background-color:currentcolor}}\n`;\n\nexport type RootProps = ComponentProps<'div'> & {\n /** For use on dark backgrounds, such as a GOV.UK blue homepage banner. */\n inverse?: boolean;\n /** A larger input and button. */\n large?: boolean;\n};\n\n/** Wraps the search label, input and submit button. */\nexport function Root({ inverse, large, className, children, ...props }: RootProps) {\n return (\n <div className={clsx(name, inverse && `${name}--inverse`, large && `${name}--large`, className)} {...props}>\n <style href={name} precedence=\"default\">\n {searchBoxCss}\n </style>\n {children}\n </div>\n );\n}\n\nexport type LabelProps = ComponentProps<'label'> & {\n /** The label size, from govuk-frontend’s label sizes. */\n size?: 's' | 'm' | 'l' | 'xl';\n /** Hide the label visually. It’s still read by screen readers. */\n visuallyHidden?: boolean;\n};\n\nexport function Label({ size, visuallyHidden, className, children, ...props }: LabelProps) {\n return (\n <label\n className={clsx(\n visuallyHidden ? 'govuk-visually-hidden' : ['govuk-label', size && `govuk-label--${size}`],\n `${name}__label`,\n className\n )}\n {...props}\n >\n {children}\n </label>\n );\n}\n\nexport type WrapperProps = ComponentProps<'div'>;\n\n/** Lays out the input and submit button side by side. */\nexport function Wrapper({ className, ...props }: WrapperProps) {\n return <div className={clsx(`${name}__wrapper`, className)} {...props} />;\n}\n\nexport type InputProps = ComponentProps<'input'>;\n\nexport function Input({ className, type = 'search', ...props }: InputProps) {\n return (\n <input type={type} enterKeyHint=\"search\" className={clsx('govuk-input', `${name}__input`, className)} {...props} />\n );\n}\n\nexport type ButtonProps = ComponentProps<'button'>;\n\n/** The submit button, with a search icon. Children are its accessible name, “Search” by default. */\nexport function Button({ className, children = 'Search', ...props }: ButtonProps) {\n return (\n <button type=\"submit\" className={clsx(`${name}__button`, className)} {...props}>\n <svg\n className={`${name}__icon`}\n width=\"27\"\n height=\"27\"\n viewBox=\"0 0 27 27\"\n fill=\"none\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <circle cx=\"12.0161\" cy=\"11.0161\" r=\"8.51613\" stroke=\"currentColor\" strokeWidth=\"3\" />\n <line x1=\"17.8668\" y1=\"17.3587\" x2=\"26.4475\" y2=\"25.9393\" stroke=\"currentColor\" strokeWidth=\"3\" />\n </svg>\n <span className=\"govuk-visually-hidden\">{children}</span>\n </button>\n );\n}\n\nexport type CompositeProps = Omit<InputProps, 'id'> &\n Pick<RootProps, 'inverse' | 'large'> & {\n /** The input’s id, which the label points to. */\n id: string;\n /** The label text. */\n label?: ReactNode;\n /** The label size, from govuk-frontend’s label sizes. */\n labelSize?: LabelProps['size'];\n /** Hide the label visually. It’s still read by screen readers. */\n labelVisuallyHidden?: boolean;\n /** The submit button’s visually hidden text. */\n buttonText?: ReactNode;\n };\n\n/**\n * A search input with a label and an attached submit button, based on GOV.UK’s search component. Put it in your own `form`. Other props go on the input.\n *\n * @see https://components.publishing.service.gov.uk/component-guide/search\n */\nexport function Composite({\n id,\n label = 'Search on GOV.UK',\n labelSize,\n labelVisuallyHidden,\n buttonText,\n inverse,\n large,\n ...props\n}: CompositeProps) {\n return (\n <Root inverse={inverse} large={large}>\n <Label htmlFor={id} size={labelSize} visuallyHidden={labelVisuallyHidden}>\n {label}\n </Label>\n <Wrapper>\n <Input id={id} {...props} />\n <Button>{buttonText}</Button>\n </Wrapper>\n </Root>\n );\n}\n\nexport type AutocompleteProps = Primitives.RootProps;\n\n/**\n * Suggests searches as the user types, around `Wrapper`, `Listbox`, `Status` and `AssistiveHint`.\n * Without JavaScript the search box works as usual. Based on GOV.UK’s search with autocomplete,\n * with behaviour from accessible-autocomplete.\n */\nexport function Autocomplete({ className, ...props }: AutocompleteProps) {\n return <Primitives.Root className={clsx(`${name}__autocomplete`, className)} {...props} />;\n}\n\nexport type AutocompleteInputProps = InputProps;\n\n/** `Input`, as the autocomplete’s combobox. */\nexport function AutocompleteInput(props: AutocompleteInputProps) {\n return (\n <Primitives.Input asChild>\n <Input {...props} />\n </Primitives.Input>\n );\n}\n\nexport type ListboxProps = Primitives.ListboxProps;\n\n/** The menu of suggestions, under the search box. Hidden until there are suggestions to show. */\nexport function Listbox({ className, ...props }: ListboxProps) {\n return <Primitives.Listbox className={clsx(`${name}__menu`, className)} {...props} />;\n}\n\nexport type OptionProps = Primitives.OptionProps;\n\n/** A suggestion, in `Listbox`. Children are its text, which can hold `Match`. */\nexport function Option({ className, children, ...props }: OptionProps) {\n return (\n <Primitives.Option className={clsx(`${name}__option`, className)} {...props}>\n <span className={`${name}__option-wrapper`}>\n <span className={`${name}__suggestion-icon`} aria-hidden=\"true\" />\n <span className={`${name}__suggestion-text`}>{children}</span>\n </span>\n </Primitives.Option>\n );\n}\n\nexport type MatchProps = ComponentProps<'mark'>;\n\n/** The part of a suggestion that matches the query, in `Option`. */\nexport function Match({ className, ...props }: MatchProps) {\n return <mark className={clsx(`${name}__suggestion-highlight`, className)} {...props} />;\n}\n\nexport type StatusProps = Primitives.StatusProps;\n\n/** What screen readers hear about the suggestions. Visually hidden. */\nexport function Status(props: StatusProps) {\n return <Primitives.Status {...props} />;\n}\n\nexport type AssistiveHintProps = Primitives.AssistiveHintProps;\n\n/** How to use the suggestions, for screen readers. Never shown. */\nexport function AssistiveHint({\n children = 'When search suggestions are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.',\n ...props\n}: AssistiveHintProps) {\n return <Primitives.AssistiveHint {...props}>{children}</Primitives.AssistiveHint>;\n}\n\nexport type AutocompleteCompositeProps = CompositeProps &\n Pick<AutocompleteProps, 'minLength' | 'filter' | 'onQueryChange' | 'onConfirm'> & {\n /**\n * The suggestions for the query, such as from `onQueryChange`. Only those containing the query\n * show, unless `filter` is \"none\", such as for suggestions a server has already matched.\n * Children are an alternative.\n */\n suggestions?: string[];\n /** `Option`s, rather than `suggestions`, such as to highlight the query with `Match`. */\n children?: ReactNode;\n };\n\n/**\n * A search box that suggests searches as the user types, based on GOV.UK’s search with\n * autocomplete. Choosing a suggestion submits the form. Put it in your own `form`. Other props go\n * on the input. Without JavaScript it’s `Composite`.\n *\n * @see https://components.publishing.service.gov.uk/component-guide/search_with_autocomplete\n */\nexport function AutocompleteComposite({\n id,\n label = 'Search on GOV.UK',\n labelSize,\n labelVisuallyHidden,\n buttonText,\n inverse,\n large,\n minLength = 3,\n filter,\n onQueryChange,\n onConfirm,\n suggestions,\n children,\n ...props\n}: AutocompleteCompositeProps) {\n return (\n <Root inverse={inverse} large={large}>\n <Label htmlFor={id} size={labelSize} visuallyHidden={labelVisuallyHidden}>\n {label}\n </Label>\n <Autocomplete\n minLength={minLength}\n filter={filter}\n onQueryChange={onQueryChange}\n onConfirm={onConfirm}\n confirmOnBlur={false}\n submitOnConfirm\n statusNoResults=\"No search suggestions found\"\n statusQueryTooShort=\"Type in %{count} or more characters for search suggestions\"\n statusResults={{\n one: '%{count} search suggestion is available.',\n other: '%{count} search suggestions are available.',\n }}\n >\n <Wrapper>\n <AutocompleteInput id={id} {...props} />\n <Button>{buttonText}</Button>\n </Wrapper>\n <Listbox>\n {children ??\n suggestions?.map((suggestion) => (\n <Option key={suggestion} value={suggestion}>\n {suggestion}\n </Option>\n ))}\n </Listbox>\n <Status />\n <AssistiveHint />\n </Autocomplete>\n </Root>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SectionBreak, type SectionBreakProps } from 'govuk-frontend-react/section-break';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/section-break/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA0B,MAAM,oCAAoC,CAAC","sourcesContent":["export { SectionBreak, type SectionBreakProps } from 'govuk-frontend-react/section-break';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'govuk-frontend-react/select';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/select/index.tsx"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC","sourcesContent":["export * from 'govuk-frontend-react/select';\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
import * as Primitives from '@govuk-react/primitives/disclosure';
|
|
4
|
+
import * as Markup from 'govuk-frontend-react/service-navigation';
|
|
5
|
+
export { Root, WidthContainer, Container, ServiceName, Link, Text, Item, ActiveFallback, ItemComposite, type RootProps, type WidthContainerProps, type ContainerProps, type ServiceNameProps, type LinkProps, type TextProps, type ItemProps, type ActiveFallbackProps, type ItemCompositeProps, } from 'govuk-frontend-react/service-navigation';
|
|
6
|
+
export { Wrapper, type WrapperProps } from 'govuk-frontend-react/service-navigation';
|
|
7
|
+
type MenuState = {
|
|
8
|
+
/** Whether the menu is open below tablet width, to control it once hydrated, such as to close it after navigating. */
|
|
9
|
+
open?: boolean;
|
|
10
|
+
/** Called when the user opens or closes the menu. */
|
|
11
|
+
onOpenChange?: (open: boolean) => void;
|
|
12
|
+
};
|
|
13
|
+
export type MenuProps = Omit<Primitives.RootProps, 'media' | 'defaultOpen'> & MenuState;
|
|
14
|
+
/**
|
|
15
|
+
* govuk-frontend's menu: inside `Wrapper`, around `Toggle` and `List`. Below tablet width the
|
|
16
|
+
* button shows and hides the list once JavaScript runs. Without JavaScript the list is always
|
|
17
|
+
* shown and the button hidden.
|
|
18
|
+
*/
|
|
19
|
+
export declare function Menu({ style, ...props }: MenuProps): React.JSX.Element;
|
|
20
|
+
export type ToggleProps = Markup.ToggleProps;
|
|
21
|
+
/** The menu button, inside `Menu`. Hidden from tablet width up, and without JavaScript. */
|
|
22
|
+
export declare function Toggle(props: ToggleProps): React.JSX.Element;
|
|
23
|
+
/** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */
|
|
24
|
+
export declare const detailsCss = "\n.govuk-react-service-navigation__details>summary{list-style:none}\n.govuk-react-service-navigation__details>summary::-webkit-details-marker{display:none}\n.govuk-react-service-navigation__details[open]>summary::after{transform:rotate(180deg)}\n@supports selector(::details-content){@media (min-width: 40.0625em){.govuk-react-service-navigation__details>summary{display:none}.govuk-react-service-navigation__details::details-content{content-visibility:visible;display:contents}}}\n";
|
|
25
|
+
export type DetailsMenuProps = Omit<ComponentProps<'details'>, 'open'> & MenuState;
|
|
26
|
+
/**
|
|
27
|
+
* A menu that works without JavaScript: a native `details`, inside `Wrapper`, around `Summary`
|
|
28
|
+
* and `List`. Below tablet width the summary shows and hides the list. From tablet width the list
|
|
29
|
+
* shows where the browser supports `::details-content` (Chrome and Edge 131, Safari 18.4,
|
|
30
|
+
* Firefox 143), and stays behind the menu where it doesn't.
|
|
31
|
+
*
|
|
32
|
+
* Check it with your users' assistive technology before choosing it over `Menu`. GOV.UK's audits
|
|
33
|
+
* of the Details component found VoiceOver doesn't convey a `summary`'s state on iOS before 17,
|
|
34
|
+
* and Dragon voice control can have trouble opening one.
|
|
35
|
+
*
|
|
36
|
+
* @see https://github.com/alphagov/govuk-design-system/issues/4030
|
|
37
|
+
* @see https://github.com/alphagov/govuk-frontend/issues/5310
|
|
38
|
+
*/
|
|
39
|
+
export declare function DetailsMenu({ open, onOpenChange, onToggle, className, children, ...props }: DetailsMenuProps): React.JSX.Element;
|
|
40
|
+
export type SummaryProps = ComponentProps<'summary'>;
|
|
41
|
+
/** The menu button of `DetailsMenu`. Hidden from tablet width up, where the browser can show the list. */
|
|
42
|
+
export declare function Summary({ className, children, ...props }: SummaryProps): React.JSX.Element;
|
|
43
|
+
export type ListProps = Markup.ListProps;
|
|
44
|
+
/** The navigation list, inside `Menu` or `DetailsMenu`, or straight inside `Wrapper` with no menu. */
|
|
45
|
+
export declare function List(props: ListProps): React.JSX.Element;
|
|
46
|
+
export type CompositeProps = Markup.CompositeProps & MenuState;
|
|
47
|
+
/**
|
|
48
|
+
* Service navigation helps users understand that they’re using your service and lets them navigate around your service.
|
|
49
|
+
*
|
|
50
|
+
* Children are `ItemComposite`s. The menu is govuk-frontend's: without JavaScript the
|
|
51
|
+
* navigation is always shown.
|
|
52
|
+
*
|
|
53
|
+
* @see https://design-system.service.gov.uk/components/service-navigation/
|
|
54
|
+
*/
|
|
55
|
+
export declare function Composite(props: CompositeProps): React.JSX.Element;
|
|
56
|
+
/**
|
|
57
|
+
* Service navigation helps users understand that they’re using your service and lets them navigate around your service.
|
|
58
|
+
*
|
|
59
|
+
* Children are `ItemComposite`s. The menu is a `DetailsMenu`, which works without JavaScript but
|
|
60
|
+
* has screen reader and voice control caveats: see `DetailsMenu`.
|
|
61
|
+
*
|
|
62
|
+
* @see https://design-system.service.gov.uk/components/service-navigation/
|
|
63
|
+
*/
|
|
64
|
+
export declare function DetailsComposite(props: CompositeProps): React.JSX.Element;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Children, useEffect, useRef } from 'react';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import * as Primitives from '@govuk-react/primitives/disclosure';
|
|
5
|
+
import * as Markup from 'govuk-frontend-react/service-navigation';
|
|
6
|
+
/*
|
|
7
|
+
* govuk-frontend-react's ServiceNavigation markup, with the menu button from
|
|
8
|
+
* @govuk-react/primitives. As in govuk-frontend, the navigation collapses behind the button
|
|
9
|
+
* below tablet width. Without JavaScript the navigation is always shown and the button hidden,
|
|
10
|
+
* unless you use `DetailsMenu`, which works without JavaScript.
|
|
11
|
+
*/
|
|
12
|
+
export { Root, WidthContainer, Container, ServiceName, Link, Text, Item, ActiveFallback, ItemComposite, } from 'govuk-frontend-react/service-navigation';
|
|
13
|
+
/** govuk-frontend's tablet breakpoint, from which the navigation is always shown. */
|
|
14
|
+
const tablet = '(min-width: 40.0625em)';
|
|
15
|
+
export { Wrapper } from 'govuk-frontend-react/service-navigation';
|
|
16
|
+
/**
|
|
17
|
+
* govuk-frontend's menu: inside `Wrapper`, around `Toggle` and `List`. Below tablet width the
|
|
18
|
+
* button shows and hides the list once JavaScript runs. Without JavaScript the list is always
|
|
19
|
+
* shown and the button hidden.
|
|
20
|
+
*/
|
|
21
|
+
export function Menu({ style, ...props }) {
|
|
22
|
+
// Takes no space, so govuk-frontend's styles still apply to the button and list.
|
|
23
|
+
return React.createElement(Primitives.Root, { media: tablet, style: { display: 'contents', ...style }, ...props });
|
|
24
|
+
}
|
|
25
|
+
/** The menu button, inside `Menu`. Hidden from tablet width up, and without JavaScript. */
|
|
26
|
+
export function Toggle(props) {
|
|
27
|
+
return (React.createElement(Primitives.Toggle, { asChild: true },
|
|
28
|
+
React.createElement(Markup.Toggle, { ...props })));
|
|
29
|
+
}
|
|
30
|
+
const detailsClass = 'govuk-react-service-navigation__details';
|
|
31
|
+
/** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */
|
|
32
|
+
export const detailsCss = `
|
|
33
|
+
.${detailsClass}>summary{list-style:none}
|
|
34
|
+
.${detailsClass}>summary::-webkit-details-marker{display:none}
|
|
35
|
+
.${detailsClass}[open]>summary::after{transform:rotate(180deg)}
|
|
36
|
+
@supports selector(::details-content){@media ${tablet}{.${detailsClass}>summary{display:none}.${detailsClass}::details-content{content-visibility:visible;display:contents}}}
|
|
37
|
+
`;
|
|
38
|
+
/**
|
|
39
|
+
* A menu that works without JavaScript: a native `details`, inside `Wrapper`, around `Summary`
|
|
40
|
+
* and `List`. Below tablet width the summary shows and hides the list. From tablet width the list
|
|
41
|
+
* shows where the browser supports `::details-content` (Chrome and Edge 131, Safari 18.4,
|
|
42
|
+
* Firefox 143), and stays behind the menu where it doesn't.
|
|
43
|
+
*
|
|
44
|
+
* Check it with your users' assistive technology before choosing it over `Menu`. GOV.UK's audits
|
|
45
|
+
* of the Details component found VoiceOver doesn't convey a `summary`'s state on iOS before 17,
|
|
46
|
+
* and Dragon voice control can have trouble opening one.
|
|
47
|
+
*
|
|
48
|
+
* @see https://github.com/alphagov/govuk-design-system/issues/4030
|
|
49
|
+
* @see https://github.com/alphagov/govuk-frontend/issues/5310
|
|
50
|
+
*/
|
|
51
|
+
export function DetailsMenu({ open, onOpenChange, onToggle, className, children, ...props }) {
|
|
52
|
+
const details = useRef(null);
|
|
53
|
+
const onOpenChangeRef = useRef(onOpenChange);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
onOpenChangeRef.current = onOpenChange;
|
|
56
|
+
});
|
|
57
|
+
// A menu opened before hydration is reported, rather than left out of step with `open`.
|
|
58
|
+
const initialOpen = useRef(open);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
var _a;
|
|
61
|
+
const node = details.current;
|
|
62
|
+
if (node && initialOpen.current !== undefined && node.open !== initialOpen.current) {
|
|
63
|
+
(_a = onOpenChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onOpenChangeRef, node.open);
|
|
64
|
+
}
|
|
65
|
+
}, []);
|
|
66
|
+
return (React.createElement("details", { ref: details, className: clsx(detailsClass, className), open: open, onToggle: (event) => {
|
|
67
|
+
onToggle === null || onToggle === void 0 ? void 0 : onToggle(event);
|
|
68
|
+
if (event.currentTarget.open !== open)
|
|
69
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event.currentTarget.open);
|
|
70
|
+
},
|
|
71
|
+
// The user can open it before hydration.
|
|
72
|
+
suppressHydrationWarning: true, ...props },
|
|
73
|
+
React.createElement("style", { href: detailsClass, precedence: "default" }, detailsCss),
|
|
74
|
+
children));
|
|
75
|
+
}
|
|
76
|
+
/** The menu button of `DetailsMenu`. Hidden from tablet width up, where the browser can show the list. */
|
|
77
|
+
export function Summary({ className, children = 'Menu', ...props }) {
|
|
78
|
+
return (React.createElement("summary", { className: clsx('govuk-service-navigation__toggle', className), ...props }, children));
|
|
79
|
+
}
|
|
80
|
+
/** The navigation list, inside `Menu` or `DetailsMenu`, or straight inside `Wrapper` with no menu. */
|
|
81
|
+
export function List(props) {
|
|
82
|
+
return (React.createElement(Primitives.Content, { asChild: true },
|
|
83
|
+
React.createElement(Markup.List, { ...props })));
|
|
84
|
+
}
|
|
85
|
+
function render({ serviceName, serviceHref, navigationLabel, menuButtonText, collapseNavigationOnMobile, open, onOpenChange, as, items, children, ...props }, renderMenu) {
|
|
86
|
+
const list = items
|
|
87
|
+
? items.map((item, index) => React.createElement(Markup.ItemComposite, { key: index, ...item }))
|
|
88
|
+
: Children.toArray(children);
|
|
89
|
+
const collapse = collapseNavigationOnMobile !== null && collapseNavigationOnMobile !== void 0 ? collapseNavigationOnMobile : list.length > 1;
|
|
90
|
+
const hasServiceName = hasContent(serviceName);
|
|
91
|
+
return (React.createElement(Markup.Root, { as: as !== null && as !== void 0 ? as : (hasServiceName ? 'section' : 'div'), ...props },
|
|
92
|
+
React.createElement(Markup.WidthContainer, null,
|
|
93
|
+
React.createElement(Markup.Container, null,
|
|
94
|
+
hasServiceName && (React.createElement(Markup.ServiceName, null, serviceHref ? (React.createElement(Markup.Link, { href: serviceHref }, serviceName)) : (React.createElement(Markup.Text, null, serviceName)))),
|
|
95
|
+
list.length > 0 && (React.createElement(Markup.Wrapper, { "aria-label": navigationLabel || menuButtonText || 'Menu' }, collapse ? (renderMenu({ open, onOpenChange, menuButtonText, children: React.createElement(List, null, list) })) : (React.createElement(List, null, list))))))));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Service navigation helps users understand that they’re using your service and lets them navigate around your service.
|
|
99
|
+
*
|
|
100
|
+
* Children are `ItemComposite`s. The menu is govuk-frontend's: without JavaScript the
|
|
101
|
+
* navigation is always shown.
|
|
102
|
+
*
|
|
103
|
+
* @see https://design-system.service.gov.uk/components/service-navigation/
|
|
104
|
+
*/
|
|
105
|
+
export function Composite(props) {
|
|
106
|
+
return render(props, ({ menuButtonText, children, ...menu }) => (React.createElement(Menu, { ...menu },
|
|
107
|
+
React.createElement(Toggle, null, menuButtonText),
|
|
108
|
+
children)));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Service navigation helps users understand that they’re using your service and lets them navigate around your service.
|
|
112
|
+
*
|
|
113
|
+
* Children are `ItemComposite`s. The menu is a `DetailsMenu`, which works without JavaScript but
|
|
114
|
+
* has screen reader and voice control caveats: see `DetailsMenu`.
|
|
115
|
+
*
|
|
116
|
+
* @see https://design-system.service.gov.uk/components/service-navigation/
|
|
117
|
+
*/
|
|
118
|
+
export function DetailsComposite(props) {
|
|
119
|
+
return render(props, ({ menuButtonText, children, ...menu }) => (React.createElement(DetailsMenu, { ...menu },
|
|
120
|
+
React.createElement(Summary, null, menuButtonText),
|
|
121
|
+
children)));
|
|
122
|
+
}
|
|
123
|
+
// As govuk-frontend-react decides whether there is a service name.
|
|
124
|
+
function hasContent(node) {
|
|
125
|
+
if (node === null || node === undefined || node === false || node === true || node === '')
|
|
126
|
+
return false;
|
|
127
|
+
if (Array.isArray(node))
|
|
128
|
+
return node.some(hasContent);
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/service-navigation/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,UAAU,MAAM,oCAAoC,CAAC;AACjE,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;AAElE;;;;;GAKG;AAEH,OAAO,EACL,IAAI,EACJ,cAAc,EACd,SAAS,EACT,WAAW,EACX,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,cAAc,EACd,aAAa,GAUd,MAAM,yCAAyC,CAAC;A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AAI,QAAE,IAAI,CAAQ,EAAE,CAAC,CAClF,CAAC,CAAC,CAAC,CACF,oBAAC,IAAI,QAAE,IAAI,CAAQ,CACpB,CACc,CAClB,CACgB,CACG,CACZ,CACf,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,KAAqB;IAC7C,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,CAC9D,oBAAC,IAAI,OAAK,IAAI;QACZ,oBAAC,MAAM,QAAE,cAAc,CAAU;QAChC,QAAQ,CACJ,CACR,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAqB;IACpD,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,CAC9D,oBAAC,WAAW,OAAK,IAAI;QACnB,oBAAC,OAAO,QAAE,cAAc,CAAW;QAClC,QAAQ,CACG,CACf,CAAC,CAAC;AACL,CAAC;AAED,mEAAmE;AACnE,SAAS,UAAU,CAAC,IAAe;IACjC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IACxG,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACtD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import * as React from 'react';\nimport { Children, useEffect, useRef } from 'react';\nimport { clsx } from 'clsx';\nimport type { ComponentProps, ReactNode } from 'react';\nimport * as Primitives from '@govuk-react/primitives/disclosure';\nimport * as Markup from 'govuk-frontend-react/service-navigation';\n\n/*\n * govuk-frontend-react's ServiceNavigation markup, with the menu button from\n * @govuk-react/primitives. As in govuk-frontend, the navigation collapses behind the button\n * below tablet width. Without JavaScript the navigation is always shown and the button hidden,\n * unless you use `DetailsMenu`, which works without JavaScript.\n */\n\nexport {\n Root,\n WidthContainer,\n Container,\n ServiceName,\n Link,\n Text,\n Item,\n ActiveFallback,\n ItemComposite,\n type RootProps,\n type WidthContainerProps,\n type ContainerProps,\n type ServiceNameProps,\n type LinkProps,\n type TextProps,\n type ItemProps,\n type ActiveFallbackProps,\n type ItemCompositeProps,\n} from 'govuk-frontend-react/service-navigation';\n\n/** govuk-frontend's tablet breakpoint, from which the navigation is always shown. */\nconst tablet = '(min-width: 40.0625em)';\n\nexport { Wrapper, type WrapperProps } from 'govuk-frontend-react/service-navigation';\n\ntype MenuState = {\n /** Whether the menu is open below tablet width, to control it once hydrated, such as to close it after navigating. */\n open?: boolean;\n /** Called when the user opens or closes the menu. */\n onOpenChange?: (open: boolean) => void;\n};\n\nexport type MenuProps = Omit<Primitives.RootProps, 'media' | 'defaultOpen'> & MenuState;\n\n/**\n * govuk-frontend's menu: inside `Wrapper`, around `Toggle` and `List`. Below tablet width the\n * button shows and hides the list once JavaScript runs. Without JavaScript the list is always\n * shown and the button hidden.\n */\nexport function Menu({ style, ...props }: MenuProps) {\n // Takes no space, so govuk-frontend's styles still apply to the button and list.\n return <Primitives.Root media={tablet} style={{ display: 'contents', ...style }} {...props} />;\n}\n\nexport type ToggleProps = Markup.ToggleProps;\n\n/** The menu button, inside `Menu`. Hidden from tablet width up, and without JavaScript. */\nexport function Toggle(props: ToggleProps) {\n return (\n <Primitives.Toggle asChild>\n <Markup.Toggle {...props} />\n </Primitives.Toggle>\n );\n}\n\nconst detailsClass = 'govuk-react-service-navigation__details';\n\n/** Styles govuk-frontend has no class for, hoisted and deduplicated by React. */\nexport const detailsCss = `\n.${detailsClass}>summary{list-style:none}\n.${detailsClass}>summary::-webkit-details-marker{display:none}\n.${detailsClass}[open]>summary::after{transform:rotate(180deg)}\n@supports selector(::details-content){@media ${tablet}{.${detailsClass}>summary{display:none}.${detailsClass}::details-content{content-visibility:visible;display:contents}}}\n`;\n\nexport type DetailsMenuProps = Omit<ComponentProps<'details'>, 'open'> & MenuState;\n\n/**\n * A menu that works without JavaScript: a native `details`, inside `Wrapper`, around `Summary`\n * and `List`. Below tablet width the summary shows and hides the list. From tablet width the list\n * shows where the browser supports `::details-content` (Chrome and Edge 131, Safari 18.4,\n * Firefox 143), and stays behind the menu where it doesn't.\n *\n * Check it with your users' assistive technology before choosing it over `Menu`. GOV.UK's audits\n * of the Details component found VoiceOver doesn't convey a `summary`'s state on iOS before 17,\n * and Dragon voice control can have trouble opening one.\n *\n * @see https://github.com/alphagov/govuk-design-system/issues/4030\n * @see https://github.com/alphagov/govuk-frontend/issues/5310\n */\nexport function DetailsMenu({ open, onOpenChange, onToggle, className, children, ...props }: DetailsMenuProps) {\n const details = useRef<HTMLDetailsElement>(null);\n const onOpenChangeRef = useRef(onOpenChange);\n useEffect(() => {\n onOpenChangeRef.current = onOpenChange;\n });\n // A menu opened before hydration is reported, rather than left out of step with `open`.\n const initialOpen = useRef(open);\n useEffect(() => {\n const node = details.current;\n if (node && initialOpen.current !== undefined && node.open !== initialOpen.current) {\n onOpenChangeRef.current?.(node.open);\n }\n }, []);\n return (\n <details\n ref={details}\n className={clsx(detailsClass, className)}\n open={open}\n onToggle={(event) => {\n onToggle?.(event);\n if (event.currentTarget.open !== open) onOpenChange?.(event.currentTarget.open);\n }}\n // The user can open it before hydration.\n suppressHydrationWarning\n {...props}\n >\n <style href={detailsClass} precedence=\"default\">\n {detailsCss}\n </style>\n {children}\n </details>\n );\n}\n\nexport type SummaryProps = ComponentProps<'summary'>;\n\n/** The menu button of `DetailsMenu`. Hidden from tablet width up, where the browser can show the list. */\nexport function Summary({ className, children = 'Menu', ...props }: SummaryProps) {\n return (\n <summary className={clsx('govuk-service-navigation__toggle', className)} {...props}>\n {children}\n </summary>\n );\n}\n\nexport type ListProps = Markup.ListProps;\n\n/** The navigation list, inside `Menu` or `DetailsMenu`, or straight inside `Wrapper` with no menu. */\nexport function List(props: ListProps) {\n return (\n <Primitives.Content asChild>\n <Markup.List {...props} />\n </Primitives.Content>\n );\n}\n\nexport type CompositeProps = Markup.CompositeProps & MenuState;\n\ntype MenuRenderer = (props: MenuState & { menuButtonText?: string; children: ReactNode }) => ReactNode;\n\nfunction render(\n {\n serviceName,\n serviceHref,\n navigationLabel,\n menuButtonText,\n collapseNavigationOnMobile,\n open,\n onOpenChange,\n as,\n items,\n children,\n ...props\n }: CompositeProps,\n renderMenu: MenuRenderer\n) {\n const list = items\n ? items.map((item, index) => <Markup.ItemComposite key={index} {...item} />)\n : Children.toArray(children);\n const collapse = collapseNavigationOnMobile ?? list.length > 1;\n const hasServiceName = hasContent(serviceName);\n return (\n <Markup.Root as={as ?? (hasServiceName ? 'section' : 'div')} {...props}>\n <Markup.WidthContainer>\n <Markup.Container>\n {hasServiceName && (\n <Markup.ServiceName>\n {serviceHref ? (\n <Markup.Link href={serviceHref}>{serviceName}</Markup.Link>\n ) : (\n <Markup.Text>{serviceName}</Markup.Text>\n )}\n </Markup.ServiceName>\n )}\n {list.length > 0 && (\n <Markup.Wrapper aria-label={navigationLabel || menuButtonText || 'Menu'}>\n {collapse ? (\n renderMenu({ open, onOpenChange, menuButtonText, children: <List>{list}</List> })\n ) : (\n <List>{list}</List>\n )}\n </Markup.Wrapper>\n )}\n </Markup.Container>\n </Markup.WidthContainer>\n </Markup.Root>\n );\n}\n\n/**\n * Service navigation helps users understand that they’re using your service and lets them navigate around your service.\n *\n * Children are `ItemComposite`s. The menu is govuk-frontend's: without JavaScript the\n * navigation is always shown.\n *\n * @see https://design-system.service.gov.uk/components/service-navigation/\n */\nexport function Composite(props: CompositeProps) {\n return render(props, ({ menuButtonText, children, ...menu }) => (\n <Menu {...menu}>\n <Toggle>{menuButtonText}</Toggle>\n {children}\n </Menu>\n ));\n}\n\n/**\n * Service navigation helps users understand that they’re using your service and lets them navigate around your service.\n *\n * Children are `ItemComposite`s. The menu is a `DetailsMenu`, which works without JavaScript but\n * has screen reader and voice control caveats: see `DetailsMenu`.\n *\n * @see https://design-system.service.gov.uk/components/service-navigation/\n */\nexport function DetailsComposite(props: CompositeProps) {\n return render(props, ({ menuButtonText, children, ...menu }) => (\n <DetailsMenu {...menu}>\n <Summary>{menuButtonText}</Summary>\n {children}\n </DetailsMenu>\n ));\n}\n\n// As govuk-frontend-react decides whether there is a service name.\nfunction hasContent(node: ReactNode): boolean {\n if (node === null || node === undefined || node === false || node === true || node === '') return false;\n if (Array.isArray(node)) return node.some(hasContent);\n return true;\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as Markup from 'govuk-frontend-react/skip-link';
|
|
3
|
+
export type SkipLinkProps = Markup.SkipLinkProps;
|
|
4
|
+
/**
|
|
5
|
+
* Use the skip link component to help keyboard-only users skip to the main content on a page.
|
|
6
|
+
*
|
|
7
|
+
* As in govuk-frontend, once JavaScript runs it moves focus to the main content, which is outlined
|
|
8
|
+
* until focus moves on.
|
|
9
|
+
*
|
|
10
|
+
* @see https://design-system.service.gov.uk/components/skip-link/
|
|
11
|
+
*/
|
|
12
|
+
export declare function SkipLink(props: SkipLinkProps): React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as FocusLinks from '@govuk-react/primitives/focus-links';
|
|
3
|
+
import * as Markup from 'govuk-frontend-react/skip-link';
|
|
4
|
+
/**
|
|
5
|
+
* Use the skip link component to help keyboard-only users skip to the main content on a page.
|
|
6
|
+
*
|
|
7
|
+
* As in govuk-frontend, once JavaScript runs it moves focus to the main content, which is outlined
|
|
8
|
+
* until focus moves on.
|
|
9
|
+
*
|
|
10
|
+
* @see https://design-system.service.gov.uk/components/skip-link/
|
|
11
|
+
*/
|
|
12
|
+
export function SkipLink(props) {
|
|
13
|
+
return (React.createElement(FocusLinks.Root, { focusedClass: "govuk-skip-link-focused-element" },
|
|
14
|
+
React.createElement(Markup.SkipLink, { ...props })));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/skip-link/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,UAAU,MAAM,qCAAqC,CAAC;AAClE,OAAO,KAAK,MAAM,MAAM,gCAAgC,CAAC;AAIzD;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAoB;IAC3C,OAAO,CACL,oBAAC,UAAU,CAAC,IAAI,IAAC,YAAY,EAAC,iCAAiC;QAC7D,oBAAC,MAAM,CAAC,QAAQ,OAAK,KAAK,GAAI,CACd,CACnB,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport * as FocusLinks from '@govuk-react/primitives/focus-links';\nimport * as Markup from 'govuk-frontend-react/skip-link';\n\nexport type SkipLinkProps = Markup.SkipLinkProps;\n\n/**\n * Use the skip link component to help keyboard-only users skip to the main content on a page.\n *\n * As in govuk-frontend, once JavaScript runs it moves focus to the main content, which is outlined\n * until focus moves on.\n *\n * @see https://design-system.service.gov.uk/components/skip-link/\n */\nexport function SkipLink(props: SkipLinkProps) {\n return (\n <FocusLinks.Root focusedClass=\"govuk-skip-link-focused-element\">\n <Markup.SkipLink {...props} />\n </FocusLinks.Root>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'govuk-frontend-react/summary-list';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/summary-list/index.tsx"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC","sourcesContent":["export * from 'govuk-frontend-react/summary-list';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'govuk-frontend-react/table';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/table/index.tsx"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC","sourcesContent":["export * from 'govuk-frontend-react/table';\n"]}
|