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,82 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import * as Primitives from '@govuk-react/primitives/character-count';
|
|
4
|
+
import * as Markup from 'govuk-frontend-react/character-count';
|
|
5
|
+
import { ErrorMessageComposite } from 'govuk-frontend-react/error-message';
|
|
6
|
+
import { Hint } from 'govuk-frontend-react/hint';
|
|
7
|
+
import { LabelComposite } from 'govuk-frontend-react/label';
|
|
8
|
+
import { joinIds } from '../../utils/join-ids.js';
|
|
9
|
+
/**
|
|
10
|
+
* Tell users how many characters or words they can enter into a textarea.
|
|
11
|
+
*
|
|
12
|
+
* Wrap `Textarea`, `Message`, `Status` and `ScreenReaderStatus`, with the label, hint and error
|
|
13
|
+
* message.
|
|
14
|
+
*
|
|
15
|
+
* @see https://design-system.service.gov.uk/components/character-count/
|
|
16
|
+
*/
|
|
17
|
+
export function Root({ maxLength, maxWords, threshold, countType, charactersUnderLimitText, charactersAtLimitText, charactersOverLimitText, wordsUnderLimitText, wordsAtLimitText, wordsOverLimitText, error, ...props }) {
|
|
18
|
+
const text = {
|
|
19
|
+
charactersUnderLimitText,
|
|
20
|
+
charactersAtLimitText,
|
|
21
|
+
charactersOverLimitText,
|
|
22
|
+
wordsUnderLimitText,
|
|
23
|
+
wordsAtLimitText,
|
|
24
|
+
wordsOverLimitText,
|
|
25
|
+
};
|
|
26
|
+
return (React.createElement(Primitives.Root
|
|
27
|
+
// As in govuk-frontend, `maxWords` counts words, and `maxLength` wins.
|
|
28
|
+
, {
|
|
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",
|
|
31
|
+
// An error message already marks the field.
|
|
32
|
+
inputOverLimitClass: error ? undefined : 'govuk-textarea--error' },
|
|
33
|
+
React.createElement(Markup.Root, { maxLength: maxLength, maxWords: maxWords, threshold: threshold, countType: countType, error: error, ...text, ...props })));
|
|
34
|
+
}
|
|
35
|
+
/** The field. */
|
|
36
|
+
export function Textarea(props) {
|
|
37
|
+
return (React.createElement(Primitives.Input, { asChild: true },
|
|
38
|
+
React.createElement(Markup.Textarea, { ...props })));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The description, such as "You can enter up to 200 characters". Shown without JavaScript, and
|
|
42
|
+
* visually hidden once the count shows. Give it the field's id followed by `-info`, and add that to
|
|
43
|
+
* the field's `aria-describedby`.
|
|
44
|
+
*/
|
|
45
|
+
export function Message(props) {
|
|
46
|
+
return (React.createElement(Primitives.Description, { asChild: true },
|
|
47
|
+
React.createElement(Markup.Message, { ...props })));
|
|
48
|
+
}
|
|
49
|
+
/** The visible count, after `Message`. Shown once JavaScript runs. */
|
|
50
|
+
export function Status({ className, ...props }) {
|
|
51
|
+
return (React.createElement(Primitives.Status, { className: clsx('govuk-hint', 'govuk-character-count__message', 'govuk-character-count__status', className), ...props }));
|
|
52
|
+
}
|
|
53
|
+
/** The count for screen readers, after `Status`, once the user pauses typing. */
|
|
54
|
+
export function ScreenReaderStatus({ className, ...props }) {
|
|
55
|
+
return (React.createElement(Primitives.ScreenReaderStatus, { className: clsx('govuk-character-count__sr-status', 'govuk-visually-hidden', className), ...props }));
|
|
56
|
+
}
|
|
57
|
+
const isSet = (node) => node !== undefined && node !== null && node !== false && node !== '';
|
|
58
|
+
/**
|
|
59
|
+
* Tell users how many characters or words they can enter into a textarea.
|
|
60
|
+
*
|
|
61
|
+
* @see https://design-system.service.gov.uk/components/character-count/
|
|
62
|
+
*/
|
|
63
|
+
export function Field({ id: idProp, name, label, labelSize, labelIsPageHeading, hint, errorMessage, maxLength, maxWords, threshold, countType, textareaDescriptionText, charactersUnderLimitText, charactersAtLimitText, charactersOverLimitText, wordsUnderLimitText, wordsAtLimitText, wordsOverLimitText, 'aria-describedby': describedBy, ...props }) {
|
|
64
|
+
const id = idProp || name;
|
|
65
|
+
const infoId = `${id}-info`;
|
|
66
|
+
const hintId = isSet(hint) ? `${id}-hint` : undefined;
|
|
67
|
+
const errorId = isSet(errorMessage) ? `${id}-error` : undefined;
|
|
68
|
+
const limit = maxWords || maxLength;
|
|
69
|
+
const words = (countType !== null && countType !== void 0 ? countType : (maxWords ? 'words' : undefined)) === 'words';
|
|
70
|
+
const ariaDescribedBy = joinIds(describedBy, infoId, hintId, errorId);
|
|
71
|
+
return (React.createElement(Root, { error: Boolean(errorId), maxLength: maxLength, maxWords: maxWords, threshold: threshold, countType: countType, textareaDescriptionText: textareaDescriptionText, charactersUnderLimitText: charactersUnderLimitText, charactersAtLimitText: charactersAtLimitText, charactersOverLimitText: charactersOverLimitText, wordsUnderLimitText: wordsUnderLimitText, wordsAtLimitText: wordsAtLimitText, wordsOverLimitText: wordsOverLimitText },
|
|
72
|
+
React.createElement(LabelComposite, { htmlFor: id, size: labelSize, isPageHeading: labelIsPageHeading }, label),
|
|
73
|
+
hintId && React.createElement(Hint, { id: hintId }, hint),
|
|
74
|
+
errorId && React.createElement(ErrorMessageComposite, { id: errorId }, errorMessage),
|
|
75
|
+
React.createElement(Textarea, { id: id, name: name, error: Boolean(errorId), "aria-describedby": ariaDescribedBy, ...props }),
|
|
76
|
+
React.createElement(Message, { id: infoId }, limit
|
|
77
|
+
? (textareaDescriptionText || `You can enter up to %{count} ${words ? 'words' : 'characters'}`).replaceAll('%{count}', String(limit))
|
|
78
|
+
: null),
|
|
79
|
+
React.createElement(Status, null),
|
|
80
|
+
React.createElement(ScreenReaderStatus, null)));
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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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AAE,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 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"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as Markup from 'govuk-frontend-react/checkboxes';
|
|
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
|
+
export type RootProps = Markup.RootProps;
|
|
7
|
+
/**
|
|
8
|
+
* Let users select one or more options by using the checkboxes component.
|
|
9
|
+
*
|
|
10
|
+
* Children are `Item`s, each with an `Input`, followed by a `Conditional` where it reveals one.
|
|
11
|
+
*
|
|
12
|
+
* @see https://design-system.service.gov.uk/components/checkboxes/
|
|
13
|
+
*/
|
|
14
|
+
export declare function Root(props: RootProps): React.JSX.Element;
|
|
15
|
+
export type InputProps = Markup.InputProps & {
|
|
16
|
+
/** The id of the `Conditional` this checkbox reveals. */
|
|
17
|
+
controls?: string;
|
|
18
|
+
/**
|
|
19
|
+
* For an option such as "None of these": once JavaScript runs, checking it unchecks the other
|
|
20
|
+
* checkboxes with its name, and checking one of them unchecks it.
|
|
21
|
+
*/
|
|
22
|
+
exclusive?: boolean;
|
|
23
|
+
/** govuk-frontend's way to make it exclusive: "exclusive". */
|
|
24
|
+
'data-behaviour'?: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function Input({ controls, exclusive, 'data-behaviour': behaviour, ...props }: InputProps): React.JSX.Element;
|
|
27
|
+
export type ConditionalProps = Markup.ConditionalProps;
|
|
28
|
+
/** Content revealed while its checkbox is checked, straight after its `Item`. Pass the checkbox's `checked` or `defaultChecked` as `checked`. */
|
|
29
|
+
export declare function Conditional(props: ConditionalProps): React.JSX.Element;
|
|
30
|
+
export type ItemCompositeProps = Markup.ItemCompositeProps & Pick<InputProps, 'exclusive'>;
|
|
31
|
+
export declare function ItemComposite({ id, label, hint, conditional, 'aria-describedby': describedBy, ...props }: ItemCompositeProps): React.JSX.Element;
|
|
32
|
+
export type FieldProps = Omit<Markup.FieldProps, 'items' | 'children'> & ({
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
items?: never;
|
|
35
|
+
} | {
|
|
36
|
+
children?: never;
|
|
37
|
+
/** Prefer children, which memoise and re-render better. */
|
|
38
|
+
items: (ItemCompositeProps | {
|
|
39
|
+
divider: React.ReactNode;
|
|
40
|
+
})[];
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* Let users select one or more options by using the checkboxes component.
|
|
44
|
+
*
|
|
45
|
+
* Children are `ItemComposite`s and `Divider`s.
|
|
46
|
+
*
|
|
47
|
+
* @see https://design-system.service.gov.uk/components/checkboxes/
|
|
48
|
+
*/
|
|
49
|
+
export declare function Field({ items, children, ...props }: FieldProps): React.JSX.Element;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Children } from 'react';
|
|
3
|
+
import * as Primitives from '@govuk-react/primitives/choices';
|
|
4
|
+
import * as Markup from 'govuk-frontend-react/checkboxes';
|
|
5
|
+
import { joinIds } from '../../utils/join-ids.js';
|
|
6
|
+
/*
|
|
7
|
+
* govuk-frontend-react's Checkboxes markup, with conditional reveals from @govuk-react/primitives.
|
|
8
|
+
* Without JavaScript, a reveal shows only while its checkbox is checked, where the browser supports
|
|
9
|
+
* `:has()`, and always where it doesn't, as in govuk-frontend.
|
|
10
|
+
*/
|
|
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
|
+
/** The element and styles around the checkboxes, for `Root` and `Field`. */
|
|
20
|
+
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));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Let users select one or more options by using the checkboxes component.
|
|
27
|
+
*
|
|
28
|
+
* Children are `Item`s, each with an `Input`, followed by a `Conditional` where it reveals one.
|
|
29
|
+
*
|
|
30
|
+
* @see https://design-system.service.gov.uk/components/checkboxes/
|
|
31
|
+
*/
|
|
32
|
+
export function Root(props) {
|
|
33
|
+
return (React.createElement(Behaviour, null,
|
|
34
|
+
React.createElement(Markup.Root, { ...props })));
|
|
35
|
+
}
|
|
36
|
+
export function Input({ controls, exclusive, 'data-behaviour': behaviour, ...props }) {
|
|
37
|
+
return (
|
|
38
|
+
// govuk-frontend's `data-behaviour="exclusive"` works too. It isn't rendered, so govuk-frontend's
|
|
39
|
+
// own script doesn't handle it as well.
|
|
40
|
+
React.createElement(Primitives.Input, { asChild: true, controls: controls, exclusive: exclusive !== null && exclusive !== void 0 ? exclusive : behaviour === 'exclusive' },
|
|
41
|
+
React.createElement(Markup.Input, { ...props })));
|
|
42
|
+
}
|
|
43
|
+
/** Content revealed while its checkbox is checked, straight after its `Item`. Pass the checkbox's `checked` or `defaultChecked` as `checked`. */
|
|
44
|
+
export function Conditional(props) {
|
|
45
|
+
return (React.createElement(Primitives.Conditional, { asChild: true },
|
|
46
|
+
React.createElement(Markup.Conditional, { ...props })));
|
|
47
|
+
}
|
|
48
|
+
const isSet = (node) => node !== undefined && node !== null && node !== false && node !== '';
|
|
49
|
+
export function ItemComposite({ id, label, hint, conditional, 'aria-describedby': describedBy, ...props }) {
|
|
50
|
+
var _a;
|
|
51
|
+
const hintId = isSet(hint) ? `${id}-item-hint` : undefined;
|
|
52
|
+
const conditionalId = isSet(conditional) ? `conditional-${id}` : undefined;
|
|
53
|
+
return (React.createElement(React.Fragment, null,
|
|
54
|
+
React.createElement(Markup.Item, null,
|
|
55
|
+
React.createElement(Input, { id: id, controls: conditionalId, "aria-describedby": joinIds(describedBy, hintId), ...props }),
|
|
56
|
+
React.createElement(Markup.Label, { htmlFor: id }, label),
|
|
57
|
+
hintId && React.createElement(Markup.Hint, { id: hintId }, hint)),
|
|
58
|
+
conditionalId && (React.createElement(Conditional, { id: conditionalId, checked: Boolean((_a = props.checked) !== null && _a !== void 0 ? _a : props.defaultChecked) }, conditional))));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Let users select one or more options by using the checkboxes component.
|
|
62
|
+
*
|
|
63
|
+
* Children are `ItemComposite`s and `Divider`s.
|
|
64
|
+
*
|
|
65
|
+
* @see https://design-system.service.gov.uk/components/checkboxes/
|
|
66
|
+
*/
|
|
67
|
+
export function Field({ items, children, ...props }) {
|
|
68
|
+
return (React.createElement(Behaviour, null,
|
|
69
|
+
React.createElement(Markup.Field, { ...props }, items
|
|
70
|
+
? items.map((item, index) => 'divider' in item ? (React.createElement(Markup.Divider, { key: index }, item.divider)) : (React.createElement(ItemComposite, { key: index, ...item })))
|
|
71
|
+
: Children.toArray(children))));
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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;A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,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'govuk-frontend-react/cookie-banner';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/cookie-banner/index.tsx"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC","sourcesContent":["export * from 'govuk-frontend-react/cookie-banner';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'govuk-frontend-react/date-input';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/date-input/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC","sourcesContent":["export * from 'govuk-frontend-react/date-input';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'govuk-frontend-react/details';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/details/index.tsx"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC","sourcesContent":["export * from 'govuk-frontend-react/details';\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
3
|
+
export type RootProps = ComponentProps<'dl'>;
|
|
4
|
+
/** A list of metadata about a document, such as who it’s from and what it’s part of. */
|
|
5
|
+
export declare function Root({ className, ...props }: RootProps): React.JSX.Element;
|
|
6
|
+
export type TermProps = ComponentProps<'dt'>;
|
|
7
|
+
export declare function Term({ className, ...props }: TermProps): React.JSX.Element;
|
|
8
|
+
export type DefinitionProps = ComponentProps<'dd'>;
|
|
9
|
+
export declare function Definition({ className, ...props }: DefinitionProps): React.JSX.Element;
|
|
10
|
+
export type ItemCompositeProps = {
|
|
11
|
+
/** The label, such as “From”. A colon is added after it. */
|
|
12
|
+
term: ReactNode;
|
|
13
|
+
/** The values. Each renders as its own definition. */
|
|
14
|
+
definitions: ReactNode[];
|
|
15
|
+
};
|
|
16
|
+
/** A term and its values. */
|
|
17
|
+
export declare function ItemComposite({ term, definitions }: ItemCompositeProps): React.JSX.Element;
|
|
18
|
+
export type CompositeProps = RootProps & {
|
|
19
|
+
/** Values for “From”, such as organisation links. */
|
|
20
|
+
from?: ReactNode[];
|
|
21
|
+
/** Values for “Part of”, such as topic links. */
|
|
22
|
+
partOf?: ReactNode[];
|
|
23
|
+
/** Other items. Prefer `ItemComposite` children. */
|
|
24
|
+
other?: {
|
|
25
|
+
id?: string | number;
|
|
26
|
+
title: ReactNode;
|
|
27
|
+
content: ReactNode;
|
|
28
|
+
}[];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Metadata about a document. Children are `ItemComposite`s, rendered after `from`, `partOf` and `other`.
|
|
32
|
+
*
|
|
33
|
+
* @see https://components.publishing.service.gov.uk/component-guide/metadata
|
|
34
|
+
*/
|
|
35
|
+
export declare function Composite({ from, partOf, other, children, ...props }: CompositeProps): React.JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
/** A list of metadata about a document, such as who it’s from and what it’s part of. */
|
|
4
|
+
export function Root({ className, ...props }) {
|
|
5
|
+
return React.createElement("dl", { className: clsx('govuk-body', className), ...props });
|
|
6
|
+
}
|
|
7
|
+
export function Term({ className, ...props }) {
|
|
8
|
+
return React.createElement("dt", { className: clsx('govuk-!-margin-bottom-1', className), ...props });
|
|
9
|
+
}
|
|
10
|
+
export function Definition({ className, ...props }) {
|
|
11
|
+
return (React.createElement("dd", { className: clsx('govuk-!-font-weight-bold', 'govuk-!-margin-left-0', 'govuk-!-margin-bottom-2', className), ...props }));
|
|
12
|
+
}
|
|
13
|
+
/** A term and its values. */
|
|
14
|
+
export function ItemComposite({ term, definitions }) {
|
|
15
|
+
return (React.createElement(React.Fragment, null,
|
|
16
|
+
React.createElement(Term, null,
|
|
17
|
+
term,
|
|
18
|
+
":"),
|
|
19
|
+
definitions.map((definition, index) => (React.createElement(Definition, { key: index }, definition)))));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Metadata about a document. Children are `ItemComposite`s, rendered after `from`, `partOf` and `other`.
|
|
23
|
+
*
|
|
24
|
+
* @see https://components.publishing.service.gov.uk/component-guide/metadata
|
|
25
|
+
*/
|
|
26
|
+
export function Composite({ from, partOf, other, children, ...props }) {
|
|
27
|
+
return (React.createElement(Root, { ...props },
|
|
28
|
+
from && from.length > 0 && React.createElement(ItemComposite, { term: "From", definitions: from }),
|
|
29
|
+
partOf && partOf.length > 0 && React.createElement(ItemComposite, { term: "Part of", definitions: partOf }), other === null || other === void 0 ? void 0 :
|
|
30
|
+
other.map((item, index) => {
|
|
31
|
+
var _a;
|
|
32
|
+
return (React.createElement(ItemComposite, { key: (_a = item.id) !== null && _a !== void 0 ? _a : index, term: item.title, definitions: [item.content] }));
|
|
33
|
+
}),
|
|
34
|
+
children));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/document-footer-metadata/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,wFAAwF;AACxF,MAAM,UAAU,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAa;IACrD,OAAO,4BAAI,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,KAAM,KAAK,GAAI,CAAC;AACrE,CAAC;AAID,MAAM,UAAU,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAa;IACrD,OAAO,4BAAI,SAAS,EAAE,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAC,KAAM,KAAK,GAAI,CAAC;AAClF,CAAC;AAID,MAAM,UAAU,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAmB;IACjE,OAAO,CACL,4BACE,SAAS,EAAE,IAAI,CAAC,0BAA0B,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,SAAS,CAAC,KACtG,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AASD,6BAA6B;AAC7B,MAAM,UAAU,aAAa,CAAC,EAAE,IAAI,EAAE,WAAW,EAAsB;IACrE,OAAO,CACL;QACE,oBAAC,IAAI;YAAE,IAAI;gBAAS;QACnB,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC,CACtC,oBAAC,UAAU,IAAC,GAAG,EAAE,KAAK,IAAG,UAAU,CAAc,CAClD,CAAC,CACD,CACJ,CAAC;AACJ,CAAC;AAWD;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAkB;IACnF,OAAO,CACL,oBAAC,IAAI,OAAK,KAAK;QACZ,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,oBAAC,aAAa,IAAC,IAAI,EAAC,MAAM,EAAC,WAAW,EAAE,IAAI,GAAI;QAC3E,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,oBAAC,aAAa,IAAC,IAAI,EAAC,SAAS,EAAC,WAAW,EAAE,MAAM,GAAI,EACpF,KAAK,aAAL,KAAK;QAAL,KAAK,CAAE,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;;YAAC,OAAA,CAC3B,oBAAC,aAAa,IAAC,GAAG,EAAE,MAAA,IAAI,CAAC,EAAE,mCAAI,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAI,CACxF,CAAA;SAAA,CAAC;QACD,QAAQ,CACJ,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ReactNode } from 'react';\nimport { clsx } from 'clsx';\n\nexport type RootProps = ComponentProps<'dl'>;\n\n/** A list of metadata about a document, such as who it’s from and what it’s part of. */\nexport function Root({ className, ...props }: RootProps) {\n return <dl className={clsx('govuk-body', className)} {...props} />;\n}\n\nexport type TermProps = ComponentProps<'dt'>;\n\nexport function Term({ className, ...props }: TermProps) {\n return <dt className={clsx('govuk-!-margin-bottom-1', className)} {...props} />;\n}\n\nexport type DefinitionProps = ComponentProps<'dd'>;\n\nexport function Definition({ className, ...props }: DefinitionProps) {\n return (\n <dd\n className={clsx('govuk-!-font-weight-bold', 'govuk-!-margin-left-0', 'govuk-!-margin-bottom-2', className)}\n {...props}\n />\n );\n}\n\nexport type ItemCompositeProps = {\n /** The label, such as “From”. A colon is added after it. */\n term: ReactNode;\n /** The values. Each renders as its own definition. */\n definitions: ReactNode[];\n};\n\n/** A term and its values. */\nexport function ItemComposite({ term, definitions }: ItemCompositeProps) {\n return (\n <>\n <Term>{term}:</Term>\n {definitions.map((definition, index) => (\n <Definition key={index}>{definition}</Definition>\n ))}\n </>\n );\n}\n\nexport type CompositeProps = RootProps & {\n /** Values for “From”, such as organisation links. */\n from?: ReactNode[];\n /** Values for “Part of”, such as topic links. */\n partOf?: ReactNode[];\n /** Other items. Prefer `ItemComposite` children. */\n other?: { id?: string | number; title: ReactNode; content: ReactNode }[];\n};\n\n/**\n * Metadata about a document. Children are `ItemComposite`s, rendered after `from`, `partOf` and `other`.\n *\n * @see https://components.publishing.service.gov.uk/component-guide/metadata\n */\nexport function Composite({ from, partOf, other, children, ...props }: CompositeProps) {\n return (\n <Root {...props}>\n {from && from.length > 0 && <ItemComposite term=\"From\" definitions={from} />}\n {partOf && partOf.length > 0 && <ItemComposite term=\"Part of\" definitions={partOf} />}\n {other?.map((item, index) => (\n <ItemComposite key={item.id ?? index} term={item.title} definitions={[item.content]} />\n ))}\n {children}\n </Root>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ErrorMessage, ErrorMessageComposite, type ErrorMessageProps, type ErrorMessageCompositeProps, } from 'govuk-frontend-react/error-message';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/error-message/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,qBAAqB,GAGtB,MAAM,oCAAoC,CAAC","sourcesContent":["export {\n ErrorMessage,\n ErrorMessageComposite,\n type ErrorMessageProps,\n type ErrorMessageCompositeProps,\n} from 'govuk-frontend-react/error-message';\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as Markup from 'govuk-frontend-react/error-summary';
|
|
3
|
+
export { Alert, Title, Body, Description, List, ListItem, ListItemLink, ListItemComposite, type AlertProps, type TitleProps, type BodyProps, type DescriptionProps, type ListProps, type ListItemProps, type ListItemCompositeProps, } from 'govuk-frontend-react/error-summary';
|
|
4
|
+
export type RootProps = Markup.RootProps;
|
|
5
|
+
/**
|
|
6
|
+
* Use an error summary when there is a validation error.
|
|
7
|
+
*
|
|
8
|
+
* It takes focus when it appears. To move focus to it again, such as after another invalid submit,
|
|
9
|
+
* give it a new `key`.
|
|
10
|
+
*
|
|
11
|
+
* @see https://design-system.service.gov.uk/components/error-summary/
|
|
12
|
+
*/
|
|
13
|
+
export declare function Root({ disableAutoFocus, ...props }: RootProps): React.JSX.Element;
|
|
14
|
+
export type CompositeProps = Markup.CompositeProps;
|
|
15
|
+
/**
|
|
16
|
+
* Use an error summary when there is a validation error.
|
|
17
|
+
*
|
|
18
|
+
* Children are `ListItemComposite`s.
|
|
19
|
+
*
|
|
20
|
+
* @see https://design-system.service.gov.uk/components/error-summary/
|
|
21
|
+
*/
|
|
22
|
+
export declare function Composite({ title, description, errors, children, ...props }: CompositeProps): React.JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as AutoFocus from '@govuk-react/primitives/auto-focus';
|
|
3
|
+
import * as FocusLinks from '@govuk-react/primitives/focus-links';
|
|
4
|
+
import * as Markup from 'govuk-frontend-react/error-summary';
|
|
5
|
+
/*
|
|
6
|
+
* govuk-frontend-react's ErrorSummary markup, with govuk-frontend's focus behaviour from
|
|
7
|
+
* @govuk-react/primitives. The summary takes focus when it appears, and is rendered with
|
|
8
|
+
* `autofocus`, so it takes focus when the page loads even without JavaScript. Its links move focus
|
|
9
|
+
* to the field, with its label or legend in view.
|
|
10
|
+
*/
|
|
11
|
+
export { Alert, Title, Body, Description, List, ListItem, ListItemLink, ListItemComposite, } from 'govuk-frontend-react/error-summary';
|
|
12
|
+
/**
|
|
13
|
+
* Use an error summary when there is a validation error.
|
|
14
|
+
*
|
|
15
|
+
* It takes focus when it appears. To move focus to it again, such as after another invalid submit,
|
|
16
|
+
* give it a new `key`.
|
|
17
|
+
*
|
|
18
|
+
* @see https://design-system.service.gov.uk/components/error-summary/
|
|
19
|
+
*/
|
|
20
|
+
export function Root({ disableAutoFocus, ...props }) {
|
|
21
|
+
return (React.createElement(FocusLinks.Root, null,
|
|
22
|
+
React.createElement(AutoFocus.Root, { disabled: disableAutoFocus },
|
|
23
|
+
React.createElement(AutoFocus.Target, { asChild: true, disabled: disableAutoFocus },
|
|
24
|
+
React.createElement(Markup.Root, { disableAutoFocus: disableAutoFocus, ...props })))));
|
|
25
|
+
}
|
|
26
|
+
const hasContent = (node) => {
|
|
27
|
+
if (node === null || node === undefined || node === false || node === true || node === '')
|
|
28
|
+
return false;
|
|
29
|
+
if (Array.isArray(node))
|
|
30
|
+
return node.some(hasContent);
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Use an error summary when there is a validation error.
|
|
35
|
+
*
|
|
36
|
+
* Children are `ListItemComposite`s.
|
|
37
|
+
*
|
|
38
|
+
* @see https://design-system.service.gov.uk/components/error-summary/
|
|
39
|
+
*/
|
|
40
|
+
export function Composite({ title, description, errors, children, ...props }) {
|
|
41
|
+
const list = errors ? errors.map((item, index) => React.createElement(Markup.ListItemComposite, { key: index, ...item })) : children;
|
|
42
|
+
return (React.createElement(Root, { ...props },
|
|
43
|
+
React.createElement(Markup.Alert, null,
|
|
44
|
+
React.createElement(Markup.Title, null, title),
|
|
45
|
+
React.createElement(Markup.Body, null,
|
|
46
|
+
hasContent(description) && React.createElement(Markup.Description, null, description),
|
|
47
|
+
hasContent(list) && React.createElement(Markup.List, null, list)))));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRo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IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,oBAAC,MAAM,CAAC,iBAAiB,IAAC,GAAG,EAAE,KAAK,KAAM,IAAI,GAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACjH,OAAO,CACL,oBAAC,IAAI,OAAK,KAAK;QACb,oBAAC,MAAM,CAAC,KAAK;YACX,oBAAC,MAAM,CAAC,KAAK,QAAE,KAAK,CAAgB;YACpC,oBAAC,MAAM,CAAC,IAAI;gBACT,UAAU,CAAC,WAAW,CAAC,IAAI,oBAAC,MAAM,CAAC,WAAW,QAAE,WAAW,CAAsB;gBACjF,UAAU,CAAC,IAAI,CAAC,IAAI,oBAAC,MAAM,CAAC,IAAI,QAAE,IAAI,CAAe,CAC1C,CACD,CACV,CACR,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport * as AutoFocus from '@govuk-react/primitives/auto-focus';\nimport * as FocusLinks from '@govuk-react/primitives/focus-links';\nimport * as Markup from 'govuk-frontend-react/error-summary';\n\n/*\n * govuk-frontend-react's ErrorSummary markup, with govuk-frontend's focus behaviour from\n * @govuk-react/primitives. The summary takes focus when it appears, and is rendered with\n * `autofocus`, so it takes focus when the page loads even without JavaScript. Its links move focus\n * to the field, with its label or legend in view.\n */\n\nexport {\n Alert,\n Title,\n Body,\n Description,\n List,\n ListItem,\n ListItemLink,\n ListItemComposite,\n type AlertProps,\n type TitleProps,\n type BodyProps,\n type DescriptionProps,\n type ListProps,\n type ListItemProps,\n type ListItemCompositeProps,\n} from 'govuk-frontend-react/error-summary';\n\nexport type RootProps = Markup.RootProps;\n\n/**\n * Use an error summary when there is a validation error.\n *\n * It takes focus when it appears. To move focus to it again, such as after another invalid submit,\n * give it a new `key`.\n *\n * @see https://design-system.service.gov.uk/components/error-summary/\n */\nexport function Root({ disableAutoFocus, ...props }: RootProps) {\n return (\n <FocusLinks.Root>\n <AutoFocus.Root disabled={disableAutoFocus}>\n <AutoFocus.Target asChild disabled={disableAutoFocus}>\n <Markup.Root disableAutoFocus={disableAutoFocus} {...props} />\n </AutoFocus.Target>\n </AutoFocus.Root>\n </FocusLinks.Root>\n );\n}\n\nexport type CompositeProps = Markup.CompositeProps;\n\nconst hasContent = (node: React.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\n/**\n * Use an error summary when there is a validation error.\n *\n * Children are `ListItemComposite`s.\n *\n * @see https://design-system.service.gov.uk/components/error-summary/\n */\nexport function Composite({ title, description, errors, children, ...props }: CompositeProps) {\n const list = errors ? errors.map((item, index) => <Markup.ListItemComposite key={index} {...item} />) : children;\n return (\n <Root {...props}>\n <Markup.Alert>\n <Markup.Title>{title}</Markup.Title>\n <Markup.Body>\n {hasContent(description) && <Markup.Description>{description}</Markup.Description>}\n {hasContent(list) && <Markup.List>{list}</Markup.List>}\n </Markup.Body>\n </Markup.Alert>\n </Root>\n );\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as Markup from 'govuk-frontend-react/exit-this-page';
|
|
3
|
+
import { type SkipLinkProps as MarkupSkipLinkProps } from 'govuk-frontend-react/skip-link';
|
|
4
|
+
export type RootProps = Markup.RootProps;
|
|
5
|
+
/**
|
|
6
|
+
* Give users a way to quickly and safely exit a service, website or application.
|
|
7
|
+
*
|
|
8
|
+
* Once JavaScript runs, the button, a `SkipLink`, or pressing Shift 3 times hides the page and
|
|
9
|
+
* goes to the button's `href`, as in govuk-frontend.
|
|
10
|
+
*
|
|
11
|
+
* @see https://design-system.service.gov.uk/components/exit-this-page/
|
|
12
|
+
*/
|
|
13
|
+
export declare function Root({ children, ...props }: RootProps): React.JSX.Element;
|
|
14
|
+
export type ButtonProps = Markup.ButtonProps;
|
|
15
|
+
/** The link to a safe page. Shows how many times Shift has been pressed. */
|
|
16
|
+
export declare function Button({ children, ...props }: ButtonProps): React.JSX.Element;
|
|
17
|
+
/** Shows how many times Shift has been pressed. Button renders it. */
|
|
18
|
+
export declare function Indicator(): React.JSX.Element;
|
|
19
|
+
/** Tells screen readers how many more presses are needed. Root renders it. */
|
|
20
|
+
export declare function Status(): React.JSX.Element;
|
|
21
|
+
export type SkipLinkProps = MarkupSkipLinkProps;
|
|
22
|
+
/** A skip link that exits the page too, for the top of the page. */
|
|
23
|
+
export declare function SkipLink({ href, className, ...props }: SkipLinkProps): React.JSX.Element;
|
|
24
|
+
export type CompositeProps = Markup.CompositeProps;
|
|
25
|
+
/**
|
|
26
|
+
* Give users a way to quickly and safely exit a service, website or application.
|
|
27
|
+
*
|
|
28
|
+
* Once JavaScript runs, the button, a `SkipLink`, or pressing Shift 3 times hides the page and
|
|
29
|
+
* goes to the button's `href`, as in govuk-frontend.
|
|
30
|
+
*
|
|
31
|
+
* @see https://design-system.service.gov.uk/components/exit-this-page/
|
|
32
|
+
*/
|
|
33
|
+
export declare function Composite({ href, children, ...props }: CompositeProps): React.JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import * as Primitives from '@govuk-react/primitives/exit-this-page';
|
|
4
|
+
import * as Markup from 'govuk-frontend-react/exit-this-page';
|
|
5
|
+
import { SkipLink as MarkupSkipLink } from 'govuk-frontend-react/skip-link';
|
|
6
|
+
import { VisuallyHidden } from 'govuk-frontend-react/visually-hidden';
|
|
7
|
+
/*
|
|
8
|
+
* govuk-frontend-react's ExitThisPage markup, with the behaviour from @govuk-react/primitives, as
|
|
9
|
+
* govuk-frontend's script has. Without JavaScript the button is a link to a safe page.
|
|
10
|
+
*/
|
|
11
|
+
const defaultHref = 'https://www.bbc.co.uk/weather';
|
|
12
|
+
/**
|
|
13
|
+
* Give users a way to quickly and safely exit a service, website or application.
|
|
14
|
+
*
|
|
15
|
+
* Once JavaScript runs, the button, a `SkipLink`, or pressing Shift 3 times hides the page and
|
|
16
|
+
* goes to the button's `href`, as in govuk-frontend.
|
|
17
|
+
*
|
|
18
|
+
* @see https://design-system.service.gov.uk/components/exit-this-page/
|
|
19
|
+
*/
|
|
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",
|
|
22
|
+
// Leaves the sticky button's containing block as it is in govuk-frontend.
|
|
23
|
+
style: { display: 'contents' } },
|
|
24
|
+
React.createElement(Markup.Root, { ...props },
|
|
25
|
+
children,
|
|
26
|
+
React.createElement(Status, null))));
|
|
27
|
+
}
|
|
28
|
+
/** The link to a safe page. Shows how many times Shift has been pressed. */
|
|
29
|
+
export function Button({ children, ...props }) {
|
|
30
|
+
return (React.createElement(Primitives.Button, { asChild: true },
|
|
31
|
+
React.createElement(Markup.Button, { ...props },
|
|
32
|
+
children,
|
|
33
|
+
React.createElement(Indicator, null))));
|
|
34
|
+
}
|
|
35
|
+
/** Shows how many times Shift has been pressed. Button renders it. */
|
|
36
|
+
export function Indicator() {
|
|
37
|
+
return (React.createElement(Primitives.Indicator, { className: "govuk-exit-this-page__indicator" },
|
|
38
|
+
React.createElement(Primitives.Light, { className: "govuk-exit-this-page__indicator-light" }),
|
|
39
|
+
React.createElement(Primitives.Light, { className: "govuk-exit-this-page__indicator-light" }),
|
|
40
|
+
React.createElement(Primitives.Light, { className: "govuk-exit-this-page__indicator-light" })));
|
|
41
|
+
}
|
|
42
|
+
/** Tells screen readers how many more presses are needed. Root renders it. */
|
|
43
|
+
export function Status() {
|
|
44
|
+
return React.createElement(Primitives.Status, { className: "govuk-visually-hidden" });
|
|
45
|
+
}
|
|
46
|
+
/** A skip link that exits the page too, for the top of the page. */
|
|
47
|
+
export function SkipLink({ href, className, ...props }) {
|
|
48
|
+
return (React.createElement(Primitives.SkipLink, { asChild: true },
|
|
49
|
+
React.createElement(MarkupSkipLink, { href: href || defaultHref, className: clsx('govuk-js-exit-this-page-skiplink', className), rel: "nofollow noreferrer", ...props })));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Give users a way to quickly and safely exit a service, website or application.
|
|
53
|
+
*
|
|
54
|
+
* Once JavaScript runs, the button, a `SkipLink`, or pressing Shift 3 times hides the page and
|
|
55
|
+
* goes to the button's `href`, as in govuk-frontend.
|
|
56
|
+
*
|
|
57
|
+
* @see https://design-system.service.gov.uk/components/exit-this-page/
|
|
58
|
+
*/
|
|
59
|
+
export function Composite({ href, children, ...props }) {
|
|
60
|
+
const hasChildren = children !== undefined && children !== null && children !== '';
|
|
61
|
+
return (React.createElement(Root, { ...props },
|
|
62
|
+
React.createElement(Button, { href: href }, hasChildren ? (children) : (React.createElement(React.Fragment, null,
|
|
63
|
+
React.createElement(VisuallyHidden, null, "Emergency"),
|
|
64
|
+
" Exit this page")))));
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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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C,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 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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'govuk-frontend-react/feedback';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/feedback/index.tsx"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC","sourcesContent":["export * from 'govuk-frontend-react/feedback';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'govuk-frontend-react/fieldset';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/fieldset/index.tsx"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC","sourcesContent":["export * from 'govuk-frontend-react/fieldset';\n"]}
|