@moduk/frontend 1.6.0 → 1.7.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/dist/nunjucks/moduk/components/character-count/__examples__/with-custom-messages.njk +25 -0
- package/dist/nunjucks/moduk/components/character-count/__examples__/with-word-count-custom-messages.njk +25 -0
- package/dist/nunjucks/moduk/components/fieldset/__examples__/not-as-page-heading.njk +44 -0
- package/dist/nunjucks/moduk/components/notification-banner/__examples__/with-custom-title.njk +6 -0
- package/dist/nunjucks/moduk/components/notification-banner/__examples__/with-disable-auto-focus.njk +6 -0
- package/nunjucks/moduk/components/character-count/__examples__/with-custom-messages.njk +25 -0
- package/nunjucks/moduk/components/character-count/__examples__/with-word-count-custom-messages.njk +25 -0
- package/nunjucks/moduk/components/fieldset/__examples__/not-as-page-heading.njk +44 -0
- package/nunjucks/moduk/components/notification-banner/__examples__/with-custom-title.njk +6 -0
- package/nunjucks/moduk/components/notification-banner/__examples__/with-disable-auto-focus.njk +6 -0
- package/package.json +7 -7
- package/react/MODUKBody/MODUKBody.d.ts +7 -0
- package/react/MODUKBody/MODUKBody.d.ts.map +1 -1
- package/react/accordion/Accordion.d.ts +65 -0
- package/react/accordion/Accordion.d.ts.map +1 -1
- package/react/accordion/AccordionItem.d.ts +14 -0
- package/react/accordion/AccordionItem.d.ts.map +1 -1
- package/react/back-link/BackLink.d.ts +8 -0
- package/react/back-link/BackLink.d.ts.map +1 -1
- package/react/character-count/CharacterCount.d.ts +115 -0
- package/react/character-count/CharacterCount.d.ts.map +1 -0
- package/react/character-count/index.d.ts +3 -0
- package/react/character-count/index.d.ts.map +1 -0
- package/react/character-count/useThrottledValue.d.ts +6 -0
- package/react/character-count/useThrottledValue.d.ts.map +1 -0
- package/react/details/Details.d.ts +23 -0
- package/react/details/Details.d.ts.map +1 -0
- package/react/details/index.d.ts +2 -0
- package/react/details/index.d.ts.map +1 -0
- package/react/esm/accordion/Accordion.js +4 -3
- package/react/esm/character-count/CharacterCount.js +158 -0
- package/react/esm/character-count/index.js +2 -0
- package/react/esm/character-count/useThrottledValue.js +28 -0
- package/react/esm/details/Details.js +35 -0
- package/react/esm/details/index.js +1 -0
- package/react/esm/fieldset/Fieldset.js +24 -0
- package/react/esm/fieldset/FieldsetLegend.js +29 -0
- package/react/esm/fieldset/index.js +2 -0
- package/react/esm/index.js +3 -0
- package/react/esm/notification-banner/NotificationBanner.js +87 -0
- package/react/esm/notification-banner/index.js +1 -0
- package/react/esm/textarea/Textarea.js +3 -2
- package/react/fieldset/Fieldset.d.ts +46 -0
- package/react/fieldset/Fieldset.d.ts.map +1 -0
- package/react/fieldset/FieldsetLegend.d.ts +18 -0
- package/react/fieldset/FieldsetLegend.d.ts.map +1 -0
- package/react/fieldset/index.d.ts +3 -0
- package/react/fieldset/index.d.ts.map +1 -0
- package/react/header/Header.d.ts +53 -0
- package/react/header/Header.d.ts.map +1 -1
- package/react/header/HeaderNavigationItem.d.ts +8 -0
- package/react/header/HeaderNavigationItem.d.ts.map +1 -1
- package/react/header/HeaderNavigationLink.d.ts +2 -0
- package/react/header/HeaderNavigationLink.d.ts.map +1 -1
- package/react/index.d.ts +3 -0
- package/react/index.d.ts.map +1 -1
- package/react/index.js +1 -1
- package/react/index.js.map +1 -1
- package/react/internal/Link/Link.d.ts +6 -0
- package/react/internal/Link/Link.d.ts.map +1 -1
- package/react/notification-banner/NotificationBanner.d.ts +71 -0
- package/react/notification-banner/NotificationBanner.d.ts.map +1 -0
- package/react/notification-banner/index.d.ts +2 -0
- package/react/notification-banner/index.d.ts.map +1 -0
- package/react/textarea/Textarea.d.ts +6 -1
- package/react/textarea/Textarea.d.ts.map +1 -1
- package/src/react/character-count/__examples__/default.tsx +14 -0
- package/src/react/character-count/__examples__/not-as-page-heading.tsx +13 -0
- package/src/react/character-count/__examples__/with-custom-messages.tsx +24 -0
- package/src/react/character-count/__examples__/with-error-message.tsx +16 -0
- package/src/react/character-count/__examples__/with-threshold.tsx +15 -0
- package/src/react/character-count/__examples__/with-word-count-custom-messages.tsx +18 -0
- package/src/react/character-count/__examples__/word-count.tsx +13 -0
- package/src/react/details/__examples__/default.tsx +7 -0
- package/src/react/details/__examples__/open.tsx +7 -0
- package/src/react/fieldset/__examples__/default.tsx +31 -0
- package/src/react/fieldset/__examples__/not-as-page-heading.tsx +31 -0
- package/src/react/notification-banner/__examples__/default.tsx +7 -0
- package/src/react/notification-banner/__examples__/success.tsx +13 -0
- package/src/react/notification-banner/__examples__/with-custom-title.tsx +7 -0
- package/src/react/notification-banner/__examples__/with-disable-auto-focus.tsx +7 -0
- package/src/react/notification-banner/__examples__/with-html.tsx +10 -0
- package/client/index.d.ts +0 -2
- package/client/index.d.ts.map +0 -1
- package/dist/client/index.d.ts +0 -2
- package/dist/client/index.d.ts.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{% from "moduk/components/character-count/macro.njk" import modukCharacterCount -%}
|
|
2
|
+
|
|
3
|
+
{{ modukCharacterCount({
|
|
4
|
+
name: "with-hint",
|
|
5
|
+
id: "with-hint",
|
|
6
|
+
maxlength: 200,
|
|
7
|
+
label: {
|
|
8
|
+
text: "Can you provide more detail?",
|
|
9
|
+
classes: "govuk-label--l",
|
|
10
|
+
isPageHeading: true
|
|
11
|
+
},
|
|
12
|
+
hint: {
|
|
13
|
+
text: "Do not include personal information like your service number."
|
|
14
|
+
},
|
|
15
|
+
charactersAtLimitText: "characters at limit",
|
|
16
|
+
charactersOverLimitText: {
|
|
17
|
+
one: "characters over limit, one, %{count}",
|
|
18
|
+
other: "characters over limit, other, %{count}"
|
|
19
|
+
},
|
|
20
|
+
charactersUnderLimitText: {
|
|
21
|
+
one: "characters under limit, one, %{count}",
|
|
22
|
+
other: "characters under limit, other, %{count}"
|
|
23
|
+
},
|
|
24
|
+
textareaDescriptionText: "description text, %{count}"
|
|
25
|
+
}) -}}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{% from "moduk/components/character-count/macro.njk" import modukCharacterCount -%}
|
|
2
|
+
|
|
3
|
+
{{ modukCharacterCount({
|
|
4
|
+
name: "with-hint",
|
|
5
|
+
id: "with-hint",
|
|
6
|
+
maxwords: 5,
|
|
7
|
+
label: {
|
|
8
|
+
text: "Can you provide more detail?",
|
|
9
|
+
classes: "govuk-label--l",
|
|
10
|
+
isPageHeading: true
|
|
11
|
+
},
|
|
12
|
+
hint: {
|
|
13
|
+
text: "Do not include personal information like your service number."
|
|
14
|
+
},
|
|
15
|
+
wordsAtLimitText: "words at limit",
|
|
16
|
+
wordsOverLimitText: {
|
|
17
|
+
one: "words over limit, one, %{count}",
|
|
18
|
+
other: "words over limit, other, %{count}"
|
|
19
|
+
},
|
|
20
|
+
wordsUnderLimitText: {
|
|
21
|
+
one: "words under limit, one, %{count}",
|
|
22
|
+
other: "words under limit, other, %{count}"
|
|
23
|
+
},
|
|
24
|
+
textareaDescriptionText: "description text, %{count}"
|
|
25
|
+
}) -}}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{% from "moduk/components/input/macro.njk" import modukInput -%}
|
|
2
|
+
{% from "moduk/components/fieldset/macro.njk" import modukFieldset -%}
|
|
3
|
+
|
|
4
|
+
{% call modukFieldset({
|
|
5
|
+
legend: {
|
|
6
|
+
text: "What is your address?",
|
|
7
|
+
classes: "govuk-fieldset__legend--s"
|
|
8
|
+
}
|
|
9
|
+
}) -%}
|
|
10
|
+
{{ modukInput({
|
|
11
|
+
label: {
|
|
12
|
+
text: 'Address line 1'
|
|
13
|
+
},
|
|
14
|
+
id: "address-line-1",
|
|
15
|
+
name: "address-line-1",
|
|
16
|
+
autocomplete: "address-line1"
|
|
17
|
+
}) -}}
|
|
18
|
+
{{ modukInput({
|
|
19
|
+
label: {
|
|
20
|
+
text: 'Address line 2 (optional)'
|
|
21
|
+
},
|
|
22
|
+
id: "address-line-2",
|
|
23
|
+
name: "address-line-2",
|
|
24
|
+
autocomplete: "address-line2"
|
|
25
|
+
}) -}}
|
|
26
|
+
{{ modukInput({
|
|
27
|
+
label: {
|
|
28
|
+
text: "Town or city"
|
|
29
|
+
},
|
|
30
|
+
classes: "govuk-!-width-two-thirds",
|
|
31
|
+
id: "address-town",
|
|
32
|
+
name: "address-town",
|
|
33
|
+
autocomplete: "address-level2"
|
|
34
|
+
}) -}}
|
|
35
|
+
{{ modukInput({
|
|
36
|
+
label: {
|
|
37
|
+
text: "Postcode"
|
|
38
|
+
},
|
|
39
|
+
classes: "govuk-input--width-10",
|
|
40
|
+
id: "address-postcode",
|
|
41
|
+
name: "address-postcode",
|
|
42
|
+
autocomplete: "postal-code"
|
|
43
|
+
}) -}}
|
|
44
|
+
{% endcall -%}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{% from "moduk/components/character-count/macro.njk" import modukCharacterCount -%}
|
|
2
|
+
|
|
3
|
+
{{ modukCharacterCount({
|
|
4
|
+
name: "with-hint",
|
|
5
|
+
id: "with-hint",
|
|
6
|
+
maxlength: 200,
|
|
7
|
+
label: {
|
|
8
|
+
text: "Can you provide more detail?",
|
|
9
|
+
classes: "govuk-label--l",
|
|
10
|
+
isPageHeading: true
|
|
11
|
+
},
|
|
12
|
+
hint: {
|
|
13
|
+
text: "Do not include personal information like your service number."
|
|
14
|
+
},
|
|
15
|
+
charactersAtLimitText: "characters at limit",
|
|
16
|
+
charactersOverLimitText: {
|
|
17
|
+
one: "characters over limit, one, %{count}",
|
|
18
|
+
other: "characters over limit, other, %{count}"
|
|
19
|
+
},
|
|
20
|
+
charactersUnderLimitText: {
|
|
21
|
+
one: "characters under limit, one, %{count}",
|
|
22
|
+
other: "characters under limit, other, %{count}"
|
|
23
|
+
},
|
|
24
|
+
textareaDescriptionText: "description text, %{count}"
|
|
25
|
+
}) -}}
|
package/nunjucks/moduk/components/character-count/__examples__/with-word-count-custom-messages.njk
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{% from "moduk/components/character-count/macro.njk" import modukCharacterCount -%}
|
|
2
|
+
|
|
3
|
+
{{ modukCharacterCount({
|
|
4
|
+
name: "with-hint",
|
|
5
|
+
id: "with-hint",
|
|
6
|
+
maxwords: 5,
|
|
7
|
+
label: {
|
|
8
|
+
text: "Can you provide more detail?",
|
|
9
|
+
classes: "govuk-label--l",
|
|
10
|
+
isPageHeading: true
|
|
11
|
+
},
|
|
12
|
+
hint: {
|
|
13
|
+
text: "Do not include personal information like your service number."
|
|
14
|
+
},
|
|
15
|
+
wordsAtLimitText: "words at limit",
|
|
16
|
+
wordsOverLimitText: {
|
|
17
|
+
one: "words over limit, one, %{count}",
|
|
18
|
+
other: "words over limit, other, %{count}"
|
|
19
|
+
},
|
|
20
|
+
wordsUnderLimitText: {
|
|
21
|
+
one: "words under limit, one, %{count}",
|
|
22
|
+
other: "words under limit, other, %{count}"
|
|
23
|
+
},
|
|
24
|
+
textareaDescriptionText: "description text, %{count}"
|
|
25
|
+
}) -}}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{% from "moduk/components/input/macro.njk" import modukInput -%}
|
|
2
|
+
{% from "moduk/components/fieldset/macro.njk" import modukFieldset -%}
|
|
3
|
+
|
|
4
|
+
{% call modukFieldset({
|
|
5
|
+
legend: {
|
|
6
|
+
text: "What is your address?",
|
|
7
|
+
classes: "govuk-fieldset__legend--s"
|
|
8
|
+
}
|
|
9
|
+
}) -%}
|
|
10
|
+
{{ modukInput({
|
|
11
|
+
label: {
|
|
12
|
+
text: 'Address line 1'
|
|
13
|
+
},
|
|
14
|
+
id: "address-line-1",
|
|
15
|
+
name: "address-line-1",
|
|
16
|
+
autocomplete: "address-line1"
|
|
17
|
+
}) -}}
|
|
18
|
+
{{ modukInput({
|
|
19
|
+
label: {
|
|
20
|
+
text: 'Address line 2 (optional)'
|
|
21
|
+
},
|
|
22
|
+
id: "address-line-2",
|
|
23
|
+
name: "address-line-2",
|
|
24
|
+
autocomplete: "address-line2"
|
|
25
|
+
}) -}}
|
|
26
|
+
{{ modukInput({
|
|
27
|
+
label: {
|
|
28
|
+
text: "Town or city"
|
|
29
|
+
},
|
|
30
|
+
classes: "govuk-!-width-two-thirds",
|
|
31
|
+
id: "address-town",
|
|
32
|
+
name: "address-town",
|
|
33
|
+
autocomplete: "address-level2"
|
|
34
|
+
}) -}}
|
|
35
|
+
{{ modukInput({
|
|
36
|
+
label: {
|
|
37
|
+
text: "Postcode"
|
|
38
|
+
},
|
|
39
|
+
classes: "govuk-input--width-10",
|
|
40
|
+
id: "address-postcode",
|
|
41
|
+
name: "address-postcode",
|
|
42
|
+
autocomplete: "postal-code"
|
|
43
|
+
}) -}}
|
|
44
|
+
{% endcall -%}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moduk/frontend",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "The MOD.UK Frontend contains the code you need to start building a user interface for Ministry of Defence platforms and services.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sass": "src/css/index.scss",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"build:assets": "ts-node scripts/copy-govuk-static-assets.ts && npm run build:assets:svg",
|
|
39
39
|
"build:assets:svg": "shx mkdir -p assets/svg && cp src/assets/svg/* assets/svg",
|
|
40
40
|
"prebuild:client": "shx rm -rf client",
|
|
41
|
-
"build:client": "npm run build:client:umd && npm run build:client:es && npm run build:client:react
|
|
41
|
+
"build:client": "npm run build:client:umd && npm run build:client:es && npm run build:client:react",
|
|
42
42
|
"build:client:umd": "webpack --config webpack.config.ts",
|
|
43
43
|
"build:client:es": "babel src/client/index.ts --extensions .ts,.tsx --out-file client/moduk-frontend.mjs",
|
|
44
44
|
"prebuild:client:react": "shx rm -rf react",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"@axe-core/playwright": "^4.7.3",
|
|
102
102
|
"@babel/cli": "^7.22.10",
|
|
103
103
|
"@babel/core": "^7.22.11",
|
|
104
|
-
"@babel/preset-env": "^7.22.
|
|
104
|
+
"@babel/preset-env": "^7.22.14",
|
|
105
105
|
"@babel/preset-react": "^7.22.5",
|
|
106
106
|
"@babel/preset-typescript": "^7.22.11",
|
|
107
107
|
"@babel/register": "^7.22.5",
|
|
@@ -130,16 +130,16 @@
|
|
|
130
130
|
"eslint-import-resolver-typescript": "^3.5.5",
|
|
131
131
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
132
132
|
"eslint-plugin-import": "^2.28.1",
|
|
133
|
-
"eslint-plugin-react": "^7.33.
|
|
133
|
+
"eslint-plugin-react": "^7.33.2",
|
|
134
134
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
135
135
|
"eslint-plugin-unicorn": "^48.0.1",
|
|
136
136
|
"glob": "^10.2.2",
|
|
137
|
-
"happy-dom": "^10.
|
|
137
|
+
"happy-dom": "^10.11.2",
|
|
138
138
|
"husky": "^8.0.3",
|
|
139
|
-
"lint-staged": "^
|
|
139
|
+
"lint-staged": "^14.0.1",
|
|
140
140
|
"postcss-cli": "^10.1.0",
|
|
141
141
|
"postcss-fail-on-warn": "^0.2.1",
|
|
142
|
-
"postcss-preset-env": "^
|
|
142
|
+
"postcss-preset-env": "^9.1.2",
|
|
143
143
|
"react-merge-refs": "^2.0.2",
|
|
144
144
|
"release-it": "^16.1.5",
|
|
145
145
|
"sass": "^1.63.4",
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { type ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
/**
|
|
3
|
+
* Replacement for <body> tag when using React to render the
|
|
4
|
+
* entire page.
|
|
5
|
+
*
|
|
6
|
+
* This handles adding the `js-enabled` CSS class to the body
|
|
7
|
+
* element when JavaScript is available, ensuring interactive
|
|
8
|
+
* components are styled correctly.
|
|
9
|
+
*
|
|
3
10
|
* @experimental React components are in alpha and subject to change.
|
|
4
11
|
*/
|
|
5
12
|
export declare const MODUKBody: ({ children, className, ...rest }: ComponentPropsWithoutRef<'body'>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MODUKBody.d.ts","sourceRoot":"","sources":["../../../src/react/MODUKBody/MODUKBody.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,wBAAwB,EAAuB,MAAM,OAAO,CAAA;AAE1E
|
|
1
|
+
{"version":3,"file":"MODUKBody.d.ts","sourceRoot":"","sources":["../../../src/react/MODUKBody/MODUKBody.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,wBAAwB,EAAuB,MAAM,OAAO,CAAA;AAE1E;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,qCAAsC,yBAAyB,MAAM,CAAC,4CAO3F,CAAA"}
|
|
@@ -3,19 +3,84 @@ import type { PermissiveChild } from '../internal/PermissiveChild';
|
|
|
3
3
|
import type { AccordionHeadingTag } from './AccordionHeadingTag';
|
|
4
4
|
import type { AccordionItemProps } from './AccordionItem';
|
|
5
5
|
export interface AccordionProps extends ComponentPropsWithoutRef<'div'> {
|
|
6
|
+
/**
|
|
7
|
+
* Instances of AccordionItem.
|
|
8
|
+
*/
|
|
6
9
|
children: PermissiveChild<AccordionItemProps>;
|
|
10
|
+
/**
|
|
11
|
+
* HTML tag to use for item headings.
|
|
12
|
+
*/
|
|
7
13
|
headingTag?: AccordionHeadingTag;
|
|
14
|
+
/**
|
|
15
|
+
* The text content of the 'Hide all sections' button at
|
|
16
|
+
* the top of the accordion when all sections are expanded.
|
|
17
|
+
*/
|
|
8
18
|
hideAllSectionsText?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The text content of the 'Hide' button within each section
|
|
21
|
+
* of the accordion, which is visible when the section is
|
|
22
|
+
* expanded.
|
|
23
|
+
*/
|
|
9
24
|
hideSectionText?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Text made available to assistive technologies, like
|
|
27
|
+
* screen readers, as the final part of the toggle's
|
|
28
|
+
* accessible name when the section is expanded. Defaults
|
|
29
|
+
* to 'Hide this section'.
|
|
30
|
+
*/
|
|
10
31
|
hideSectionAriaLabelText?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Unique identifier for the accordion.
|
|
34
|
+
*
|
|
35
|
+
* Must be unique across the domain of your service if
|
|
36
|
+
* rememberExpanded is set.
|
|
37
|
+
*/
|
|
11
38
|
id: string;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the expanded/collapsed state of the accordion
|
|
41
|
+
* should be saved when a user leaves the page and restored
|
|
42
|
+
* when they return. Default is true.
|
|
43
|
+
*/
|
|
12
44
|
rememberExpanded?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The text content of the 'Show all sections' button at the
|
|
47
|
+
* top of the accordion when at least one section is collapsed.
|
|
48
|
+
*/
|
|
13
49
|
showAllSectionsText?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Text made available to assistive technologies, like screen
|
|
52
|
+
* readers, as the final part of the toggle's accessible name
|
|
53
|
+
* when the section is collapsed. Defaults to 'Show this
|
|
54
|
+
* section'.
|
|
55
|
+
*/
|
|
14
56
|
showSectionAriaLabelText?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The text content of the 'Show' button within each section
|
|
59
|
+
* of the accordion, which is visible when the section is
|
|
60
|
+
* collapsed.
|
|
61
|
+
*/
|
|
15
62
|
showSectionText?: string;
|
|
16
63
|
}
|
|
17
64
|
/**
|
|
65
|
+
* Accordion.
|
|
66
|
+
*
|
|
18
67
|
* @experimental React components are in alpha and subject to change.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* <Accordion id='example-accordion'>
|
|
71
|
+
* <AccordionItem heading='Writing well for the web'>
|
|
72
|
+
* <p className='govuk-body'>This is the content for Writing well for the web.</p>
|
|
73
|
+
* </AccordionItem>
|
|
74
|
+
* <AccordionItem heading='Writing well for specialists'>
|
|
75
|
+
* <p className='govuk-body'>This is the content for Writing well for specialists.</p>
|
|
76
|
+
* </AccordionItem>
|
|
77
|
+
* <AccordionItem heading='Know your audience'>
|
|
78
|
+
* <p className='govuk-body'>This is the content for Know your audience.</p>
|
|
79
|
+
* </AccordionItem>
|
|
80
|
+
* <AccordionItem heading='How people read'>
|
|
81
|
+
* <p className='govuk-body'>This is the content for How people read.</p>
|
|
82
|
+
* </AccordionItem>
|
|
83
|
+
* </Accordion>
|
|
19
84
|
*/
|
|
20
85
|
export declare const Accordion: import("react").ForwardRefExoticComponent<AccordionProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
21
86
|
//# sourceMappingURL=Accordion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../../src/react/accordion/Accordion.tsx"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../../src/react/accordion/Accordion.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,wBAAwB,EAA+C,MAAM,OAAO,CAAA;AAMlG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAElE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGzD,MAAM,WAAW,cAAe,SAAQ,wBAAwB,CAAC,KAAK,CAAC;IACrE;;OAEG;IACH,QAAQ,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAA;IAC7C;;OAEG;IACH,UAAU,CAAC,EAAE,mBAAmB,CAAA;IAChC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC;;;;;OAKG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAoBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,SAAS,2GA8DrB,CAAA"}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import { type ReactNode, type ReactPortal } from 'react';
|
|
2
2
|
export interface AccordionItemProps {
|
|
3
|
+
/**
|
|
4
|
+
* Content for the section.
|
|
5
|
+
*/
|
|
3
6
|
children: Exclude<ReactNode, ReactPortal | null | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Whether this section is expanded.
|
|
9
|
+
*/
|
|
4
10
|
expanded?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Heading for the section.
|
|
13
|
+
*/
|
|
5
14
|
heading: Exclude<ReactNode, ReactPortal | null | undefined>;
|
|
15
|
+
/**
|
|
16
|
+
* Summary line content.
|
|
17
|
+
*/
|
|
6
18
|
summary?: Exclude<ReactNode, ReactPortal>;
|
|
7
19
|
}
|
|
8
20
|
/**
|
|
21
|
+
* An accordion section.
|
|
22
|
+
*
|
|
9
23
|
* @experimental React components are in alpha and subject to change.
|
|
10
24
|
*/
|
|
11
25
|
export declare function AccordionItem({ children, expanded, heading, summary, }: AccordionItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionItem.d.ts","sourceRoot":"","sources":["../../../src/react/accordion/AccordionItem.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAc,MAAM,OAAO,CAAA;AAIpE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,OAAO,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;IAC3D,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;CAC1C;AAED
|
|
1
|
+
{"version":3,"file":"AccordionItem.d.ts","sourceRoot":"","sources":["../../../src/react/accordion/AccordionItem.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAc,MAAM,OAAO,CAAA;AAIpE,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;IAC5D;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;IAC3D;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;CAC1C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,OAAO,GACR,EAAE,kBAAkB,2CAiCpB"}
|
|
@@ -5,7 +5,15 @@ interface BackLinkProps {
|
|
|
5
5
|
className?: string;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
+
* A back link.
|
|
9
|
+
*
|
|
8
10
|
* @experimental React components are in alpha and subject to change.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <BackLink href='/previous-page'>Back</BackLink>
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* <BackLink component={Link} to='/previous-page'>Back</BackLink>
|
|
9
17
|
*/
|
|
10
18
|
export declare const BackLink: LinkComponent<BackLinkProps>;
|
|
11
19
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackLink.d.ts","sourceRoot":"","sources":["../../../src/react/back-link/BackLink.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAElE,UAAU,aAAa;IACrB,QAAQ,EAAE,eAAe,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED
|
|
1
|
+
{"version":3,"file":"BackLink.d.ts","sourceRoot":"","sources":["../../../src/react/back-link/BackLink.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAElE,UAAU,aAAa;IACrB,QAAQ,EAAE,eAAe,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,EAAE,aAAa,CAAC,aAAa,CAGgE,CAAA"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { type TextareaProps } from '../textarea';
|
|
2
|
+
interface CharacterCountPluralMessage {
|
|
3
|
+
/**
|
|
4
|
+
* Message for when the count is exactly 1.
|
|
5
|
+
*/
|
|
6
|
+
one: string;
|
|
7
|
+
/**
|
|
8
|
+
* Message for when the count is not 1.
|
|
9
|
+
*/
|
|
10
|
+
other: string;
|
|
11
|
+
}
|
|
12
|
+
interface CharacterCountMessageConfig {
|
|
13
|
+
/**
|
|
14
|
+
* Message made available to assistive technologies to describe
|
|
15
|
+
* that the component accepts only a limited amount of content.
|
|
16
|
+
* It is visible on the page when JavaScript is unavailable. The
|
|
17
|
+
* component will replace the `%{count}` placeholder with the
|
|
18
|
+
* value of the `maxLength` or `maxWords` prop.
|
|
19
|
+
*/
|
|
20
|
+
textareaDescriptionText?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Message displayed when the number of characters is under the
|
|
23
|
+
* configured maximum, `maxLength`. This message is displayed
|
|
24
|
+
* visually and through assistive technologies. The component
|
|
25
|
+
* will replace the `%{count}` placeholder with the number of
|
|
26
|
+
* remaining characters.
|
|
27
|
+
*/
|
|
28
|
+
charactersUnderLimitText?: Partial<CharacterCountPluralMessage>;
|
|
29
|
+
/**
|
|
30
|
+
* Message displayed when the number of characters reaches the
|
|
31
|
+
* configured maximum, `maxLength`. This message is displayed
|
|
32
|
+
* visually and through assistive technologies.
|
|
33
|
+
*/
|
|
34
|
+
charactersAtLimitText?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Message displayed when the number of characters is over the
|
|
37
|
+
* configured maximum, `maxLength`. This message is displayed
|
|
38
|
+
* visually and through assistive technologies. The component
|
|
39
|
+
* will replace the `%{count}` placeholder with the number of
|
|
40
|
+
* characters above the maximum.
|
|
41
|
+
*/
|
|
42
|
+
charactersOverLimitText?: Partial<CharacterCountPluralMessage>;
|
|
43
|
+
/**
|
|
44
|
+
* Message displayed when the number of words is under the
|
|
45
|
+
* configured maximum, `maxWords`. This message is displayed
|
|
46
|
+
* visually and through assistive technologies. The component
|
|
47
|
+
* will replace the `%{count}` placeholder with the number of
|
|
48
|
+
* remaining words.
|
|
49
|
+
*/
|
|
50
|
+
wordsUnderLimitText?: Partial<CharacterCountPluralMessage>;
|
|
51
|
+
/**
|
|
52
|
+
* Message displayed when the number of words reaches the
|
|
53
|
+
* configured maximum, `maxWords`. This message is displayed
|
|
54
|
+
* visually and through assistive technologies.
|
|
55
|
+
*/
|
|
56
|
+
wordsAtLimitText?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Message displayed when the number of words is over the
|
|
59
|
+
* configured maximum, `maxWords`. This message is displayed
|
|
60
|
+
* visually and through assistive technologies. The component
|
|
61
|
+
* will replace the `%{count}` placeholder with the number of
|
|
62
|
+
* characters above the maximum.
|
|
63
|
+
*/
|
|
64
|
+
wordsOverLimitText?: Partial<CharacterCountPluralMessage>;
|
|
65
|
+
}
|
|
66
|
+
interface BaseCharacterCountProps extends TextareaProps, CharacterCountMessageConfig {
|
|
67
|
+
/**
|
|
68
|
+
* Defines a threshold that must be reached before the
|
|
69
|
+
* character count message is displayed.
|
|
70
|
+
* This is a value between 0 and 1, representing a percentage
|
|
71
|
+
* of `maxLength` or `maxWords`.
|
|
72
|
+
*/
|
|
73
|
+
threshold?: number;
|
|
74
|
+
/**
|
|
75
|
+
* CSS classes to add to the count message.
|
|
76
|
+
*/
|
|
77
|
+
countMessageClassname?: string;
|
|
78
|
+
}
|
|
79
|
+
interface LengthCharacterCountProps extends BaseCharacterCountProps {
|
|
80
|
+
/**
|
|
81
|
+
* The maximum number of characters. Required if `maxWords`
|
|
82
|
+
* is not set. Cannot be set if `maxWords` is set.
|
|
83
|
+
*/
|
|
84
|
+
maxLength: number;
|
|
85
|
+
maxWords?: never;
|
|
86
|
+
}
|
|
87
|
+
interface WordCharacterCountProps extends BaseCharacterCountProps {
|
|
88
|
+
maxLength?: never;
|
|
89
|
+
/**
|
|
90
|
+
* The maximum number of words. Required if `maxLength`
|
|
91
|
+
* is not set. Cannot be set if `maxLength` is set.
|
|
92
|
+
*/
|
|
93
|
+
maxWords: number;
|
|
94
|
+
}
|
|
95
|
+
export type CharacterCountProps = LengthCharacterCountProps | WordCharacterCountProps;
|
|
96
|
+
/**
|
|
97
|
+
* Character count.
|
|
98
|
+
*
|
|
99
|
+
* @experimental React components are in alpha and subject to change.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* <CharacterCount
|
|
103
|
+
* label={
|
|
104
|
+
* <Label className='govuk-label--l' isPageHeading>
|
|
105
|
+
* Can you provide more detail?
|
|
106
|
+
* </Label>
|
|
107
|
+
* }
|
|
108
|
+
* hint={<Hint>Do not include personal information like your service number.</Hint>}
|
|
109
|
+
* maxLength={200}
|
|
110
|
+
* name='with-hint'
|
|
111
|
+
* />
|
|
112
|
+
*/
|
|
113
|
+
export declare const CharacterCount: import("react").ForwardRefExoticComponent<CharacterCountProps & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
114
|
+
export {};
|
|
115
|
+
//# sourceMappingURL=CharacterCount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CharacterCount.d.ts","sourceRoot":"","sources":["../../../src/react/character-count/CharacterCount.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AA0B1D,UAAU,2BAA2B;IACnC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,2BAA2B;IACnC;;;;;;OAMG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC;;;;;;OAMG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAA;IAC/D;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B;;;;;;OAMG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAA;IAC9D;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAA;IAC1D;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAA;CAC1D;AAED,UAAU,uBAAwB,SAAQ,aAAa,EAAE,2BAA2B;IAClF;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED,UAAU,yBAA0B,SAAQ,uBAAuB;IACjE;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAA;CACjB;AAED,UAAU,uBAAwB,SAAQ,uBAAuB;IAC/D,SAAS,CAAC,EAAE,KAAK,CAAA;IACjB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,MAAM,mBAAmB,GAAG,yBAAyB,GAAG,uBAAuB,CAAA;AAqDrF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,qHAoH1B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/character-count/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThrottledValue.d.ts","sourceRoot":"","sources":["../../../src/react/character-count/useThrottledValue.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB;;sBAKM,MAAM;;EAM5C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
|
|
2
|
+
export interface DetailsProps extends ComponentPropsWithoutRef<'details'> {
|
|
3
|
+
/**
|
|
4
|
+
* Content to be displayed when the details element is expanded.
|
|
5
|
+
*/
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Content for the summary element.
|
|
9
|
+
*/
|
|
10
|
+
summary: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Details component.
|
|
14
|
+
*
|
|
15
|
+
* @experimental React components are in alpha and subject to change.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* <Details summary='Help with organisation'>
|
|
19
|
+
* We need to know the organisation you work for so we can forward your request to the correct team.
|
|
20
|
+
* </Details>
|
|
21
|
+
*/
|
|
22
|
+
export declare const Details: import("react").ForwardRefExoticComponent<DetailsProps & import("react").RefAttributes<HTMLDetailsElement>>;
|
|
23
|
+
//# sourceMappingURL=Details.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Details.d.ts","sourceRoot":"","sources":["../../../src/react/details/Details.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,wBAAwB,EAAc,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjF,MAAM,WAAW,YAAa,SAAQ,wBAAwB,CAAC,SAAS,CAAC;IACvE;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAA;IACnB;;OAEG;IACH,OAAO,EAAE,SAAS,CAAA;CACnB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,6GAanB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/details/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -11,7 +11,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
11
11
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
12
|
import clsx from 'clsx';
|
|
13
13
|
import { isEqual, pick } from 'lodash';
|
|
14
|
-
import {
|
|
14
|
+
import { forwardRef, isValidElement, useMemo, useRef } from 'react';
|
|
15
15
|
import flattenChildren from 'react-keyed-flatten-children';
|
|
16
16
|
import { mergeRefs } from 'react-merge-refs';
|
|
17
17
|
import { useMODUKComponent } from '../internal/hooks/useMODUKComponent';
|
|
@@ -62,6 +62,7 @@ export var Accordion = forwardRef(function (props, forwardedRef) {
|
|
|
62
62
|
'data-i18n.show-section': showSectionText,
|
|
63
63
|
'data-i18n.show-section-aria-label': showSectionAriaLabelText
|
|
64
64
|
};
|
|
65
|
+
var flattenedChildren = flattenChildren(children).filter(isValidElement);
|
|
65
66
|
return _jsx(AccordionContext.Provider, {
|
|
66
67
|
value: contextValue,
|
|
67
68
|
children: _jsx("div", _objectSpread(_objectSpread(_objectSpread({
|
|
@@ -72,11 +73,11 @@ export var Accordion = forwardRef(function (props, forwardedRef) {
|
|
|
72
73
|
"data-remember-expanded": rememberExpanded,
|
|
73
74
|
id: id
|
|
74
75
|
}, i18nAttributes), {}, {
|
|
75
|
-
children:
|
|
76
|
+
children: flattenedChildren.map(function (child, index) {
|
|
76
77
|
return _jsx(AccordionItemIndexContext.Provider, {
|
|
77
78
|
value: index,
|
|
78
79
|
children: child
|
|
79
|
-
});
|
|
80
|
+
}, child.key);
|
|
80
81
|
})
|
|
81
82
|
}), key.current)
|
|
82
83
|
});
|