@types/govuk-frontend 5.8.0 → 5.11.0
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.
- govuk-frontend/README.md +2 -2
- govuk-frontend/dist/govuk/all.bundle.d.mts +2 -1
- govuk-frontend/dist/govuk/all.bundle.d.ts +3 -1
- govuk-frontend/dist/govuk/common/closest-attribute-value.d.ts +4 -1
- govuk-frontend/dist/govuk/common/configuration.d.ts +45 -26
- govuk-frontend/dist/govuk/common/index.d.ts +19 -20
- govuk-frontend/dist/govuk/component.d.mts +1 -0
- govuk-frontend/dist/govuk/{govuk-frontend-component.d.ts → component.d.ts} +3 -1
- govuk-frontend/dist/govuk/components/accordion/accordion.d.ts +7 -2
- govuk-frontend/dist/govuk/components/button/button.d.ts +3 -1
- govuk-frontend/dist/govuk/components/character-count/character-count.d.ts +17 -6
- govuk-frontend/dist/govuk/components/checkboxes/checkboxes.d.ts +2 -2
- govuk-frontend/dist/govuk/components/error-summary/error-summary.d.ts +8 -3
- govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.d.ts +7 -2
- govuk-frontend/dist/govuk/components/file-upload/file-upload.d.mts +1 -0
- govuk-frontend/dist/govuk/components/file-upload/file-upload.d.ts +95 -0
- govuk-frontend/dist/govuk/components/header/header.d.ts +2 -2
- govuk-frontend/dist/govuk/components/notification-banner/notification-banner.d.ts +7 -2
- govuk-frontend/dist/govuk/components/password-input/password-input.d.ts +8 -2
- govuk-frontend/dist/govuk/components/radios/radios.d.ts +2 -2
- govuk-frontend/dist/govuk/components/service-navigation/service-navigation.d.ts +2 -2
- govuk-frontend/dist/govuk/components/skip-link/skip-link.d.ts +2 -2
- govuk-frontend/dist/govuk/components/tabs/tabs.d.ts +2 -2
- govuk-frontend/dist/govuk/errors/index.d.ts +10 -12
- govuk-frontend/dist/govuk/i18n.d.ts +6 -3
- govuk-frontend/dist/govuk/init.d.ts +60 -21
- govuk-frontend/package.json +8 -3
- govuk-frontend/dist/govuk/govuk-frontend-component.d.mts +0 -1
govuk-frontend/README.md
CHANGED
|
@@ -8,8 +8,8 @@ This package contains type definitions for govuk-frontend (https://github.com/al
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/govuk-frontend.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Fri, 12 Sep 2025 19:02:26 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
|
|
14
14
|
# Credits
|
|
15
|
-
These definitions were written by [Colin Rotherham](https://github.com/colinrotherham), and [Romaric Pascal](https://github.com/romaricpascal).
|
|
15
|
+
These definitions were written by [Colin Rotherham](https://github.com/colinrotherham), [Paul Robert Lloyd](https://github.com/paulrobertlloyd), and [Romaric Pascal](https://github.com/romaricpascal).
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export { ConfigurableComponent } from "./common/configuration.mjs";
|
|
2
2
|
export { version } from "./common/govuk-frontend-version.mjs";
|
|
3
3
|
export { isSupported } from "./common/index.mjs";
|
|
4
|
+
export { Component } from "./component.mjs";
|
|
4
5
|
export { Accordion } from "./components/accordion/accordion.mjs";
|
|
5
6
|
export { Button } from "./components/button/button.mjs";
|
|
6
7
|
export { CharacterCount } from "./components/character-count/character-count.mjs";
|
|
7
8
|
export { Checkboxes } from "./components/checkboxes/checkboxes.mjs";
|
|
8
9
|
export { ErrorSummary } from "./components/error-summary/error-summary.mjs";
|
|
9
10
|
export { ExitThisPage } from "./components/exit-this-page/exit-this-page.mjs";
|
|
11
|
+
export { FileUpload } from "./components/file-upload/file-upload.mjs";
|
|
10
12
|
export { Header } from "./components/header/header.mjs";
|
|
11
13
|
export { NotificationBanner } from "./components/notification-banner/notification-banner.mjs";
|
|
12
14
|
export { PasswordInput } from "./components/password-input/password-input.mjs";
|
|
@@ -14,5 +16,4 @@ export { Radios } from "./components/radios/radios.mjs";
|
|
|
14
16
|
export { ServiceNavigation } from "./components/service-navigation/service-navigation.mjs";
|
|
15
17
|
export { SkipLink } from "./components/skip-link/skip-link.mjs";
|
|
16
18
|
export { Tabs } from "./components/tabs/tabs.mjs";
|
|
17
|
-
export { GOVUKFrontendComponent as Component } from "./govuk-frontend-component.mjs";
|
|
18
19
|
export { type Config, type ConfigKey, createAll, initAll } from "./init.mjs";
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { ConfigurableComponent } from "./common/configuration.js";
|
|
2
2
|
import { version } from "./common/govuk-frontend-version.js";
|
|
3
3
|
import { isSupported } from "./common/index.js";
|
|
4
|
+
import { Component } from "./component.js";
|
|
4
5
|
import { Accordion } from "./components/accordion/accordion.js";
|
|
5
6
|
import { Button } from "./components/button/button.js";
|
|
6
7
|
import { CharacterCount } from "./components/character-count/character-count.js";
|
|
7
8
|
import { Checkboxes } from "./components/checkboxes/checkboxes.js";
|
|
8
9
|
import { ErrorSummary } from "./components/error-summary/error-summary.js";
|
|
9
10
|
import { ExitThisPage } from "./components/exit-this-page/exit-this-page.js";
|
|
11
|
+
import { FileUpload } from "./components/file-upload/file-upload.js";
|
|
10
12
|
import { Header } from "./components/header/header.js";
|
|
11
13
|
import { NotificationBanner } from "./components/notification-banner/notification-banner.js";
|
|
12
14
|
import { PasswordInput } from "./components/password-input/password-input.js";
|
|
@@ -14,7 +16,6 @@ import { Radios } from "./components/radios/radios.js";
|
|
|
14
16
|
import { ServiceNavigation } from "./components/service-navigation/service-navigation.js";
|
|
15
17
|
import { SkipLink } from "./components/skip-link/skip-link.js";
|
|
16
18
|
import { Tabs } from "./components/tabs/tabs.js";
|
|
17
|
-
import { GOVUKFrontendComponent as Component } from "./govuk-frontend-component.js";
|
|
18
19
|
import { type Config as ConfigImport, type ConfigKey as ConfigKeyImport, createAll, initAll } from "./init.js";
|
|
19
20
|
|
|
20
21
|
declare namespace GOVUKFrontend {
|
|
@@ -31,6 +32,7 @@ declare const GOVUKFrontend: {
|
|
|
31
32
|
Checkboxes: typeof Checkboxes;
|
|
32
33
|
ErrorSummary: typeof ErrorSummary;
|
|
33
34
|
ExitThisPage: typeof ExitThisPage;
|
|
35
|
+
FileUpload: typeof FileUpload;
|
|
34
36
|
Header: typeof Header;
|
|
35
37
|
NotificationBanner: typeof NotificationBanner;
|
|
36
38
|
PasswordInput: typeof PasswordInput;
|
|
@@ -6,4 +6,7 @@
|
|
|
6
6
|
* @param {string} attributeName - The name of the attribute
|
|
7
7
|
* @returns {string | null} Attribute value
|
|
8
8
|
*/
|
|
9
|
-
export function closestAttributeValue(
|
|
9
|
+
export function closestAttributeValue(
|
|
10
|
+
$element: Element,
|
|
11
|
+
attributeName: string,
|
|
12
|
+
): string | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component } from "../component.js";
|
|
2
|
+
import { type CompatibleClass, type Config, type CreateAllOptions, type OnErrorCallback } from "../init.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Normalise string
|
|
@@ -28,18 +29,41 @@ export function normaliseString(
|
|
|
28
29
|
* optionally expanding nested `i18n.field`
|
|
29
30
|
*
|
|
30
31
|
* @internal
|
|
31
|
-
* @
|
|
32
|
+
* @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType
|
|
33
|
+
* @template {[keyof ConfigurationType, SchemaProperty | undefined][]} SchemaEntryType
|
|
34
|
+
* @param {{ schema?: Schema<ConfigurationType>, moduleName: string }} Component - Component class
|
|
32
35
|
* @param {DOMStringMap} dataset - HTML element dataset
|
|
33
36
|
* @returns {ObjectNested} Normalised dataset
|
|
34
37
|
*/
|
|
35
|
-
export function normaliseDataset
|
|
38
|
+
export function normaliseDataset<
|
|
39
|
+
ConfigurationType extends Partial<Record<keyof ConfigurationType, unknown>>,
|
|
40
|
+
>(
|
|
36
41
|
Component: {
|
|
37
|
-
schema?: Schema<
|
|
42
|
+
schema?: Schema<ConfigurationType>;
|
|
38
43
|
moduleName: string;
|
|
39
44
|
},
|
|
40
45
|
dataset: DOMStringMap,
|
|
41
46
|
): ObjectNested;
|
|
42
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Normalise options passed to `initAll` or `createAll`
|
|
50
|
+
*
|
|
51
|
+
* @internal
|
|
52
|
+
* @template {CompatibleClass} ComponentClass
|
|
53
|
+
* @param {Config | CreateAllOptions<ComponentClass> | OnErrorCallback<ComponentClass> | Element | Document | null} [scopeOrOptions] - Scope of the document to search within, initialisation options or error callback function
|
|
54
|
+
* @returns {CreateAllOptions<ComponentClass>} Normalised options
|
|
55
|
+
*/
|
|
56
|
+
export function normaliseOptions<
|
|
57
|
+
ComponentClass extends CompatibleClass,
|
|
58
|
+
>(
|
|
59
|
+
scopeOrOptions?:
|
|
60
|
+
| Config
|
|
61
|
+
| CreateAllOptions<ComponentClass>
|
|
62
|
+
| OnErrorCallback<ComponentClass>
|
|
63
|
+
| Element
|
|
64
|
+
| Document
|
|
65
|
+
| null,
|
|
66
|
+
): CreateAllOptions<ComponentClass>;
|
|
43
67
|
/**
|
|
44
68
|
* Config merging function
|
|
45
69
|
*
|
|
@@ -51,9 +75,9 @@ export function normaliseDataset(
|
|
|
51
75
|
* @returns {{ [key: string]: unknown }} A merged config object
|
|
52
76
|
*/
|
|
53
77
|
export function mergeConfigs(
|
|
54
|
-
...configObjects:
|
|
78
|
+
...configObjects: {
|
|
55
79
|
[key: string]: unknown;
|
|
56
|
-
}
|
|
80
|
+
}[]
|
|
57
81
|
): {
|
|
58
82
|
[key: string]: unknown;
|
|
59
83
|
};
|
|
@@ -73,13 +97,8 @@ export function mergeConfigs(
|
|
|
73
97
|
* @returns {string[]} List of validation errors
|
|
74
98
|
*/
|
|
75
99
|
export function validateConfig<
|
|
76
|
-
ConfigurationType extends Partial<
|
|
77
|
-
|
|
78
|
-
>,
|
|
79
|
-
>(
|
|
80
|
-
schema: Schema<ConfigurationType>,
|
|
81
|
-
config: ConfigurationType,
|
|
82
|
-
): string[];
|
|
100
|
+
ConfigurationType extends Partial<Record<keyof ConfigurationType, unknown>>,
|
|
101
|
+
>(schema: Schema<ConfigurationType>, config: ConfigurationType): string[];
|
|
83
102
|
|
|
84
103
|
/**
|
|
85
104
|
* Extracts keys starting with a particular namespace from dataset ('data-*')
|
|
@@ -93,9 +112,7 @@ export function validateConfig<
|
|
|
93
112
|
* @returns {ObjectNested | undefined} Nested object with dot-separated key namespace removed
|
|
94
113
|
*/
|
|
95
114
|
export function extractConfigByNamespace<
|
|
96
|
-
ConfigurationType extends Partial<
|
|
97
|
-
Record<keyof ConfigurationType, unknown>
|
|
98
|
-
>,
|
|
115
|
+
ConfigurationType extends Partial<Record<keyof ConfigurationType, unknown>>,
|
|
99
116
|
>(
|
|
100
117
|
schema: Schema<ConfigurationType>,
|
|
101
118
|
dataset: DOMStringMap,
|
|
@@ -109,8 +126,8 @@ export const configOverride: unique symbol;
|
|
|
109
126
|
*
|
|
110
127
|
* Centralises the behaviours shared by our components
|
|
111
128
|
*
|
|
112
|
-
* @template {Partial<Record<keyof ConfigurationType, unknown>>}
|
|
113
|
-
* @template {Element & { dataset: DOMStringMap }}
|
|
129
|
+
* @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType
|
|
130
|
+
* @template {Element & { dataset: DOMStringMap }} RootElementType
|
|
114
131
|
*/
|
|
115
132
|
export abstract class ConfigurableComponent<
|
|
116
133
|
ConfigurationType extends Partial<
|
|
@@ -119,7 +136,7 @@ export abstract class ConfigurableComponent<
|
|
|
119
136
|
RootElementType extends Element & {
|
|
120
137
|
dataset: DOMStringMap;
|
|
121
138
|
} = HTMLElement,
|
|
122
|
-
> extends
|
|
139
|
+
> extends Component<RootElementType> {
|
|
123
140
|
/**
|
|
124
141
|
* Constructs a new component, validating that GOV.UK Frontend is supported
|
|
125
142
|
*
|
|
@@ -154,7 +171,9 @@ export abstract class ConfigurableComponent<
|
|
|
154
171
|
* @param {Partial<ConfigurationType>} [param] - Configuration object
|
|
155
172
|
* @returns {Partial<ConfigurationType>} return - Configuration object
|
|
156
173
|
*/
|
|
157
|
-
[configOverride](
|
|
174
|
+
[configOverride](
|
|
175
|
+
param?: Partial<ConfigurationType>,
|
|
176
|
+
): Partial<ConfigurationType>;
|
|
158
177
|
}
|
|
159
178
|
|
|
160
179
|
export type NestedKey = keyof ObjectNested;
|
|
@@ -167,9 +186,7 @@ export interface ObjectNested {
|
|
|
167
186
|
* Schema for component config
|
|
168
187
|
*/
|
|
169
188
|
export interface Schema<
|
|
170
|
-
ConfigurationType extends Partial<
|
|
171
|
-
Record<keyof ConfigurationType, unknown>
|
|
172
|
-
>,
|
|
189
|
+
ConfigurationType extends Partial<Record<keyof ConfigurationType, unknown>>,
|
|
173
190
|
> {
|
|
174
191
|
/**
|
|
175
192
|
* - Schema properties
|
|
@@ -179,7 +196,7 @@ export interface Schema<
|
|
|
179
196
|
/**
|
|
180
197
|
* - List of schema conditions
|
|
181
198
|
*/
|
|
182
|
-
anyOf?: SchemaCondition[] | undefined;
|
|
199
|
+
anyOf?: SchemaCondition<ConfigurationType>[] | undefined;
|
|
183
200
|
}
|
|
184
201
|
|
|
185
202
|
/**
|
|
@@ -195,11 +212,13 @@ export interface SchemaProperty {
|
|
|
195
212
|
/**
|
|
196
213
|
* Schema condition for component config
|
|
197
214
|
*/
|
|
198
|
-
export interface SchemaCondition
|
|
215
|
+
export interface SchemaCondition<
|
|
216
|
+
ConfigurationType extends Partial<Record<keyof ConfigurationType, unknown>>,
|
|
217
|
+
> {
|
|
199
218
|
/**
|
|
200
219
|
* - List of required config fields
|
|
201
220
|
*/
|
|
202
|
-
required:
|
|
221
|
+
required: (keyof ConfigurationType)[];
|
|
203
222
|
|
|
204
223
|
/**
|
|
205
224
|
* - Error message when required config fields not provided
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { type ObjectNested } from "./configuration.js";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Common helpers which do not require polyfill.
|
|
5
3
|
*
|
|
@@ -7,18 +5,6 @@ import { type ObjectNested } from "./configuration.js";
|
|
|
7
5
|
* so that the polyfill can be properly tree-shaken and does not burden
|
|
8
6
|
* the components that do not need that helper
|
|
9
7
|
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Get hash fragment from URL
|
|
13
|
-
*
|
|
14
|
-
* Extract the hash fragment (everything after the hash) from a URL,
|
|
15
|
-
* but not including the hash symbol
|
|
16
|
-
*
|
|
17
|
-
* @param {string} url - URL
|
|
18
|
-
* @returns {string | undefined} Fragment from URL, without the hash
|
|
19
|
-
*/
|
|
20
|
-
export function getFragmentFromUrl(url: string): string | undefined;
|
|
21
|
-
|
|
22
8
|
/**
|
|
23
9
|
* Get GOV.UK Frontend breakpoint value from CSS custom property
|
|
24
10
|
*
|
|
@@ -75,15 +61,25 @@ export function isSupported($scope?: HTMLElement | null): boolean;
|
|
|
75
61
|
* Check for an object
|
|
76
62
|
*
|
|
77
63
|
* @internal
|
|
78
|
-
* @template {Partial<Record<keyof ObjectType, unknown>>}
|
|
64
|
+
* @template {Partial<Record<keyof ObjectType, unknown>>} ObjectType
|
|
79
65
|
* @param {unknown | ObjectType} option - Option to check
|
|
80
66
|
* @returns {option is ObjectType} Whether the option is an object
|
|
81
67
|
*/
|
|
82
68
|
export function isObject<
|
|
83
|
-
ObjectType extends Partial<Record<keyof ObjectType, unknown
|
|
84
|
-
>(
|
|
85
|
-
|
|
86
|
-
|
|
69
|
+
ObjectType extends Partial<Record<keyof ObjectType, unknown>>,
|
|
70
|
+
>(option: unknown | ObjectType): option is ObjectType;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Check for valid scope
|
|
74
|
+
*
|
|
75
|
+
* @internal
|
|
76
|
+
* @template {Element | Document} ScopeType
|
|
77
|
+
* @param {unknown | ScopeType} $scope - Scope of the document to search within
|
|
78
|
+
* @returns {$scope is ScopeType} Whether the scope can be queried
|
|
79
|
+
*/
|
|
80
|
+
export function isScope<ScopeType extends Element | Document>(
|
|
81
|
+
$scope: unknown | ScopeType,
|
|
82
|
+
): $scope is ScopeType;
|
|
87
83
|
|
|
88
84
|
/**
|
|
89
85
|
* Format error message
|
|
@@ -93,7 +89,10 @@ export function isObject<
|
|
|
93
89
|
* @param {string} message - Error message
|
|
94
90
|
* @returns {string} - Formatted error message
|
|
95
91
|
*/
|
|
96
|
-
export function formatErrorMessage(
|
|
92
|
+
export function formatErrorMessage(
|
|
93
|
+
Component: ComponentWithModuleName,
|
|
94
|
+
message: string,
|
|
95
|
+
): string;
|
|
97
96
|
|
|
98
97
|
export interface ComponentWithModuleName {
|
|
99
98
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./component.js";
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* Base Component class
|
|
3
3
|
*
|
|
4
4
|
* Centralises the behaviours shared by our components
|
|
5
|
+
*
|
|
6
|
+
* @template {Element} [RootElementType=HTMLElement]
|
|
5
7
|
*/
|
|
6
|
-
export abstract class
|
|
8
|
+
export abstract class Component<RootElementType extends Element = HTMLElement> {
|
|
7
9
|
static elementType: typeof Element;
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -12,7 +12,10 @@ import { ConfigurableComponent } from "../../common/configuration.js";
|
|
|
12
12
|
* The state of each section is saved to the DOM via the `aria-expanded`
|
|
13
13
|
* attribute, which also provides accessibility.
|
|
14
14
|
*/
|
|
15
|
-
export class Accordion extends ConfigurableComponent<
|
|
15
|
+
export class Accordion extends ConfigurableComponent<
|
|
16
|
+
AccordionConfig,
|
|
17
|
+
HTMLElement
|
|
18
|
+
> {
|
|
16
19
|
/**
|
|
17
20
|
* Name for the component used when initialising using data-module attributes.
|
|
18
21
|
*/
|
|
@@ -22,13 +25,15 @@ export class Accordion extends ConfigurableComponent<AccordionConfig, HTMLElemen
|
|
|
22
25
|
* Accordion default config
|
|
23
26
|
*
|
|
24
27
|
* @see {@link AccordionConfig}
|
|
28
|
+
* @constant
|
|
25
29
|
*/
|
|
26
30
|
static defaults: AccordionConfig;
|
|
27
31
|
|
|
28
32
|
/**
|
|
29
33
|
* Accordion config schema
|
|
30
34
|
*
|
|
31
|
-
* @
|
|
35
|
+
* @constant
|
|
36
|
+
* @satisfies {Schema<AccordionConfig>}
|
|
32
37
|
*/
|
|
33
38
|
static schema: Readonly<{
|
|
34
39
|
properties: {
|
|
@@ -13,13 +13,15 @@ export class Button extends ConfigurableComponent<ButtonConfig, HTMLElement> {
|
|
|
13
13
|
* Button default config
|
|
14
14
|
*
|
|
15
15
|
* @see {@link ButtonConfig}
|
|
16
|
+
* @constant
|
|
16
17
|
*/
|
|
17
18
|
static defaults: ButtonConfig;
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Button config schema
|
|
21
22
|
*
|
|
22
|
-
* @
|
|
23
|
+
* @constant
|
|
24
|
+
* @satisfies {Schema<ButtonConfig>}
|
|
23
25
|
*/
|
|
24
26
|
static schema: Readonly<{
|
|
25
27
|
properties: {
|
|
@@ -11,7 +11,10 @@ import { type TranslationPluralForms } from "../../i18n.js";
|
|
|
11
11
|
* You can configure the message to only appear after a certain percentage
|
|
12
12
|
* of the available characters/words has been entered.
|
|
13
13
|
*/
|
|
14
|
-
export class CharacterCount extends ConfigurableComponent<
|
|
14
|
+
export class CharacterCount extends ConfigurableComponent<
|
|
15
|
+
CharacterCountConfig,
|
|
16
|
+
HTMLElement
|
|
17
|
+
> {
|
|
15
18
|
/**
|
|
16
19
|
* Name for the component used when initialising using data-module attributes.
|
|
17
20
|
*/
|
|
@@ -21,13 +24,15 @@ export class CharacterCount extends ConfigurableComponent<CharacterCountConfig,
|
|
|
21
24
|
* Character count default config
|
|
22
25
|
*
|
|
23
26
|
* @see {@link CharacterCountConfig}
|
|
27
|
+
* @constant
|
|
24
28
|
*/
|
|
25
29
|
static defaults: CharacterCountConfig;
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
32
|
* Character count config schema
|
|
29
33
|
*
|
|
30
|
-
* @
|
|
34
|
+
* @constant
|
|
35
|
+
* @satisfies {Schema<CharacterCountConfig>}
|
|
31
36
|
*/
|
|
32
37
|
static schema: Readonly<{
|
|
33
38
|
properties: {
|
|
@@ -44,10 +49,16 @@ export class CharacterCount extends ConfigurableComponent<CharacterCountConfig,
|
|
|
44
49
|
type: "number";
|
|
45
50
|
};
|
|
46
51
|
};
|
|
47
|
-
anyOf:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
anyOf: (
|
|
53
|
+
| {
|
|
54
|
+
required: "maxwords"[];
|
|
55
|
+
errorMessage: string;
|
|
56
|
+
}
|
|
57
|
+
| {
|
|
58
|
+
required: "maxlength"[];
|
|
59
|
+
errorMessage: string;
|
|
60
|
+
}
|
|
61
|
+
)[];
|
|
51
62
|
}>;
|
|
52
63
|
|
|
53
64
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component } from "../../component.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Checkboxes component
|
|
5
5
|
*/
|
|
6
|
-
export class Checkboxes extends
|
|
6
|
+
export class Checkboxes extends Component<HTMLElement> {
|
|
7
7
|
/**
|
|
8
8
|
* Name for the component used when initialising using data-module attributes.
|
|
9
9
|
*/
|
|
@@ -6,7 +6,10 @@ import { ConfigurableComponent } from "../../common/configuration.js";
|
|
|
6
6
|
* Takes focus on initialisation for accessible announcement, unless disabled in
|
|
7
7
|
* configuration.
|
|
8
8
|
*/
|
|
9
|
-
export class ErrorSummary extends ConfigurableComponent<
|
|
9
|
+
export class ErrorSummary extends ConfigurableComponent<
|
|
10
|
+
ErrorSummaryConfig,
|
|
11
|
+
HTMLElement
|
|
12
|
+
> {
|
|
10
13
|
/**
|
|
11
14
|
* Name for the component used when initialising using data-module attributes.
|
|
12
15
|
*/
|
|
@@ -16,13 +19,15 @@ export class ErrorSummary extends ConfigurableComponent<ErrorSummaryConfig, HTML
|
|
|
16
19
|
* Error summary default config
|
|
17
20
|
*
|
|
18
21
|
* @see {@link ErrorSummaryConfig}
|
|
22
|
+
* @constant
|
|
19
23
|
*/
|
|
20
24
|
static defaults: ErrorSummaryConfig;
|
|
21
25
|
|
|
22
26
|
/**
|
|
23
27
|
* Error summary config schema
|
|
24
28
|
*
|
|
25
|
-
* @
|
|
29
|
+
* @constant
|
|
30
|
+
* @satisfies {Schema<ErrorSummaryConfig>}
|
|
26
31
|
*/
|
|
27
32
|
static schema: Readonly<{
|
|
28
33
|
properties: {
|
|
@@ -47,5 +52,5 @@ export interface ErrorSummaryConfig {
|
|
|
47
52
|
* - If set to `true` the error
|
|
48
53
|
* summary will not be focussed when the page loads.
|
|
49
54
|
*/
|
|
50
|
-
disableAutoFocus?: boolean;
|
|
55
|
+
disableAutoFocus?: boolean | undefined;
|
|
51
56
|
}
|
|
@@ -3,7 +3,10 @@ import { ConfigurableComponent } from "../../common/configuration.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Exit this page component
|
|
5
5
|
*/
|
|
6
|
-
export class ExitThisPage extends ConfigurableComponent<
|
|
6
|
+
export class ExitThisPage extends ConfigurableComponent<
|
|
7
|
+
ExitThisPageConfig,
|
|
8
|
+
HTMLElement
|
|
9
|
+
> {
|
|
7
10
|
/**
|
|
8
11
|
* Name for the component used when initialising using data-module attributes.
|
|
9
12
|
*/
|
|
@@ -13,13 +16,15 @@ export class ExitThisPage extends ConfigurableComponent<ExitThisPageConfig, HTML
|
|
|
13
16
|
* Exit this page default config
|
|
14
17
|
*
|
|
15
18
|
* @see {@link ExitThisPageConfig}
|
|
19
|
+
* @constant
|
|
16
20
|
*/
|
|
17
21
|
static defaults: ExitThisPageConfig;
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* Exit this page config schema
|
|
21
25
|
*
|
|
22
|
-
* @
|
|
26
|
+
* @constant
|
|
27
|
+
* @satisfies {Schema<ExitThisPageConfig>}
|
|
23
28
|
*/
|
|
24
29
|
static schema: Readonly<{
|
|
25
30
|
properties: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./file-upload.js";
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ConfigurableComponent } from "../../common/configuration.js";
|
|
2
|
+
import { type TranslationPluralForms } from "../../i18n.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* File upload component
|
|
6
|
+
*/
|
|
7
|
+
export class FileUpload extends ConfigurableComponent<
|
|
8
|
+
FileUploadConfig,
|
|
9
|
+
HTMLElement
|
|
10
|
+
> {
|
|
11
|
+
/**
|
|
12
|
+
* Name for the component used when initialising using data-module attributes.
|
|
13
|
+
*/
|
|
14
|
+
static moduleName: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* File upload default config
|
|
18
|
+
*
|
|
19
|
+
* @see {@link FileUploadConfig}
|
|
20
|
+
* @constant
|
|
21
|
+
*/
|
|
22
|
+
static defaults: FileUploadConfig;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* File upload config schema
|
|
26
|
+
*
|
|
27
|
+
* @constant
|
|
28
|
+
* @satisfies {Schema<FileUploadConfig>}
|
|
29
|
+
*/
|
|
30
|
+
static schema: Readonly<{
|
|
31
|
+
properties: {
|
|
32
|
+
i18n: {
|
|
33
|
+
type: "object";
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param {Element | null} $root - File input element
|
|
40
|
+
* @param {FileUploadConfig} [config] - File Upload config
|
|
41
|
+
*/
|
|
42
|
+
constructor($root: Element | null, config?: FileUploadConfig);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type HTMLFileInputElement = HTMLInputElement & {
|
|
46
|
+
files: FileList;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* File upload config
|
|
51
|
+
*/
|
|
52
|
+
export interface FileUploadConfig {
|
|
53
|
+
/**
|
|
54
|
+
* - File upload translations
|
|
55
|
+
*/
|
|
56
|
+
i18n?: FileUploadTranslations | undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Messages used by the component
|
|
61
|
+
*/
|
|
62
|
+
export interface FileUploadTranslations {
|
|
63
|
+
/**
|
|
64
|
+
* - The text of the button that opens the file picker
|
|
65
|
+
*/
|
|
66
|
+
chooseFile?: string | undefined;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* - The text informing users they can drop files
|
|
70
|
+
*/
|
|
71
|
+
dropInstruction?: string | undefined;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* - The text displayed when multiple files
|
|
75
|
+
* have been chosen by the user
|
|
76
|
+
*/
|
|
77
|
+
multipleFilesChosen?: TranslationPluralForms | undefined;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* - The text to displayed when no file has been chosen by the user
|
|
81
|
+
*/
|
|
82
|
+
noFileChosen?: string | undefined;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* - The text announced by assistive technology
|
|
86
|
+
* when user drags files and enters the drop zone
|
|
87
|
+
*/
|
|
88
|
+
enteredDropZone?: string | undefined;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* - The text announced by assistive technology
|
|
92
|
+
* when user drags files and leaves the drop zone without dropping
|
|
93
|
+
*/
|
|
94
|
+
leftDropZone?: string | undefined;
|
|
95
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component } from "../../component.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Header component
|
|
5
5
|
*/
|
|
6
|
-
export class Header extends
|
|
6
|
+
export class Header extends Component<HTMLElement> {
|
|
7
7
|
/**
|
|
8
8
|
* Name for the component used when initialising using data-module attributes.
|
|
9
9
|
*/
|
|
@@ -3,7 +3,10 @@ import { ConfigurableComponent } from "../../common/configuration.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Notification Banner component
|
|
5
5
|
*/
|
|
6
|
-
export class NotificationBanner extends ConfigurableComponent<
|
|
6
|
+
export class NotificationBanner extends ConfigurableComponent<
|
|
7
|
+
NotificationBannerConfig,
|
|
8
|
+
HTMLElement
|
|
9
|
+
> {
|
|
7
10
|
/**
|
|
8
11
|
* Name for the component used when initialising using data-module attributes.
|
|
9
12
|
*/
|
|
@@ -13,13 +16,15 @@ export class NotificationBanner extends ConfigurableComponent<NotificationBanner
|
|
|
13
16
|
* Notification banner default config
|
|
14
17
|
*
|
|
15
18
|
* @see {@link NotificationBannerConfig}
|
|
19
|
+
* @constant
|
|
16
20
|
*/
|
|
17
21
|
static defaults: NotificationBannerConfig;
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* Notification banner config schema
|
|
21
25
|
*
|
|
22
|
-
* @
|
|
26
|
+
* @constant
|
|
27
|
+
* @satisfies {Schema<NotificationBannerConfig>}
|
|
23
28
|
*/
|
|
24
29
|
static schema: Readonly<{
|
|
25
30
|
properties: {
|
|
@@ -3,7 +3,10 @@ import { ConfigurableComponent } from "../../common/configuration.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Password input component
|
|
5
5
|
*/
|
|
6
|
-
export class PasswordInput extends ConfigurableComponent<
|
|
6
|
+
export class PasswordInput extends ConfigurableComponent<
|
|
7
|
+
PasswordInputConfig,
|
|
8
|
+
HTMLElement
|
|
9
|
+
> {
|
|
7
10
|
/**
|
|
8
11
|
* Name for the component used when initialising using data-module attributes.
|
|
9
12
|
*/
|
|
@@ -13,13 +16,16 @@ export class PasswordInput extends ConfigurableComponent<PasswordInputConfig, HT
|
|
|
13
16
|
* Password input default config
|
|
14
17
|
*
|
|
15
18
|
* @see {@link PasswordInputConfig}
|
|
19
|
+
* @constant
|
|
20
|
+
* @default
|
|
16
21
|
*/
|
|
17
22
|
static defaults: PasswordInputConfig;
|
|
18
23
|
|
|
19
24
|
/**
|
|
20
25
|
* Password input config schema
|
|
21
26
|
*
|
|
22
|
-
* @
|
|
27
|
+
* @constant
|
|
28
|
+
* @satisfies {Schema<PasswordInputConfig>}
|
|
23
29
|
*/
|
|
24
30
|
static schema: Readonly<{
|
|
25
31
|
properties: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component } from "../../component.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Radios component
|
|
5
5
|
*/
|
|
6
|
-
export class Radios extends
|
|
6
|
+
export class Radios extends Component<HTMLElement> {
|
|
7
7
|
/**
|
|
8
8
|
* Name for the component used when initialising using data-module attributes.
|
|
9
9
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component } from "../../component.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Service Navigation component
|
|
5
5
|
*/
|
|
6
|
-
export class ServiceNavigation extends
|
|
6
|
+
export class ServiceNavigation extends Component<HTMLElement> {
|
|
7
7
|
/**
|
|
8
8
|
* Name for the component used when initialising using data-module attributes.
|
|
9
9
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component } from "../../component.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Skip link component
|
|
5
5
|
*/
|
|
6
|
-
export class SkipLink extends
|
|
6
|
+
export class SkipLink extends Component<HTMLAnchorElement> {
|
|
7
7
|
static elementType: {
|
|
8
8
|
new(): HTMLAnchorElement;
|
|
9
9
|
prototype: HTMLAnchorElement;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component } from "../../component.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Tabs component
|
|
5
5
|
*/
|
|
6
|
-
export class Tabs extends
|
|
6
|
+
export class Tabs extends Component<HTMLElement> {
|
|
7
7
|
/**
|
|
8
8
|
* Name for the component used when initialising using data-module attributes.
|
|
9
9
|
*/
|
|
@@ -19,8 +19,7 @@ import { type ComponentWithModuleName } from "../common/index.js";
|
|
|
19
19
|
* }
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
export abstract class GOVUKFrontendError extends Error {
|
|
23
|
-
}
|
|
22
|
+
export abstract class GOVUKFrontendError extends Error {}
|
|
24
23
|
|
|
25
24
|
/**
|
|
26
25
|
* Indicates that GOV.UK Frontend is not supported
|
|
@@ -37,8 +36,7 @@ export class SupportError extends GOVUKFrontendError {
|
|
|
37
36
|
/**
|
|
38
37
|
* Indicates that a component has received an illegal configuration
|
|
39
38
|
*/
|
|
40
|
-
export class ConfigError extends GOVUKFrontendError {
|
|
41
|
-
}
|
|
39
|
+
export class ConfigError extends GOVUKFrontendError {}
|
|
42
40
|
|
|
43
41
|
/**
|
|
44
42
|
* Indicates an issue with an element (possibly `null` or `undefined`)
|
|
@@ -75,22 +73,22 @@ export class InitError extends GOVUKFrontendError {
|
|
|
75
73
|
*/
|
|
76
74
|
export interface ElementErrorOptions {
|
|
77
75
|
/**
|
|
78
|
-
* -
|
|
76
|
+
* - The element in error (optional)
|
|
79
77
|
*/
|
|
80
|
-
|
|
78
|
+
element?: Document | Element | null | undefined;
|
|
81
79
|
|
|
82
80
|
/**
|
|
83
|
-
* -
|
|
81
|
+
* - Component throwing the error (optional)
|
|
84
82
|
*/
|
|
85
|
-
|
|
83
|
+
component?: ComponentWithModuleName | undefined;
|
|
86
84
|
|
|
87
85
|
/**
|
|
88
|
-
* -
|
|
86
|
+
* - An identifier that'll let the user understand which element has an error. This is whatever makes the most sense
|
|
89
87
|
*/
|
|
90
|
-
|
|
88
|
+
identifier: string;
|
|
91
89
|
|
|
92
90
|
/**
|
|
93
|
-
* -
|
|
91
|
+
* - The type that was expected for the identifier (optional)
|
|
94
92
|
*/
|
|
95
|
-
|
|
93
|
+
expectedType?: string | undefined;
|
|
96
94
|
}
|
|
@@ -104,9 +104,12 @@ export class I18n {
|
|
|
104
104
|
* @param {{ [key: string]: unknown }} options - Any options passed with the translation string, e.g: for string interpolation.
|
|
105
105
|
* @returns {string} The translation string to output, with $\{\} placeholders replaced
|
|
106
106
|
*/
|
|
107
|
-
replacePlaceholders(
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
replacePlaceholders(
|
|
108
|
+
translationString: string,
|
|
109
|
+
options: {
|
|
110
|
+
[key: string]: unknown;
|
|
111
|
+
},
|
|
112
|
+
): string;
|
|
110
113
|
|
|
111
114
|
/**
|
|
112
115
|
* Check to see if the browser supports Intl.PluralRules
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { type AccordionConfig } from "./components/accordion/accordion.js";
|
|
2
|
-
import { type ButtonConfig } from "./components/button/button.js";
|
|
3
|
-
import { type CharacterCountConfig } from "./components/character-count/character-count.js";
|
|
4
|
-
import { type ErrorSummaryConfig } from "./components/error-summary/error-summary.js";
|
|
5
|
-
import { type ExitThisPageConfig } from "./components/exit-this-page/exit-this-page.js";
|
|
6
|
-
import { type
|
|
7
|
-
import {
|
|
1
|
+
import { Accordion, type AccordionConfig } from "./components/accordion/accordion.js";
|
|
2
|
+
import { Button, type ButtonConfig } from "./components/button/button.js";
|
|
3
|
+
import { CharacterCount, type CharacterCountConfig } from "./components/character-count/character-count.js";
|
|
4
|
+
import { ErrorSummary, type ErrorSummaryConfig } from "./components/error-summary/error-summary.js";
|
|
5
|
+
import { ExitThisPage, type ExitThisPageConfig } from "./components/exit-this-page/exit-this-page.js";
|
|
6
|
+
import { FileUpload, type FileUploadConfig } from "./components/file-upload/file-upload.js";
|
|
7
|
+
import {
|
|
8
|
+
NotificationBanner,
|
|
9
|
+
type NotificationBannerConfig,
|
|
10
|
+
} from "./components/notification-banner/notification-banner.js";
|
|
11
|
+
import { PasswordInput, type PasswordInputConfig } from "./components/password-input/password-input.js";
|
|
8
12
|
|
|
9
13
|
export interface CompatibleClass {
|
|
10
14
|
new(...args: any[]): any;
|
|
@@ -15,6 +19,28 @@ export interface CompatibleClass {
|
|
|
15
19
|
* Config for all components via `initAll()`
|
|
16
20
|
*/
|
|
17
21
|
export interface Config {
|
|
22
|
+
/**
|
|
23
|
+
* - Scope of the document to search within
|
|
24
|
+
*/
|
|
25
|
+
scope?: Document | Element | null | undefined;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* - Initialisation error callback
|
|
29
|
+
*/
|
|
30
|
+
onError?:
|
|
31
|
+
| OnErrorCallback<
|
|
32
|
+
| typeof Accordion
|
|
33
|
+
| typeof Button
|
|
34
|
+
| typeof CharacterCount
|
|
35
|
+
| typeof ErrorSummary
|
|
36
|
+
| typeof ExitThisPage
|
|
37
|
+
| typeof FileUpload
|
|
38
|
+
| typeof NotificationBanner
|
|
39
|
+
| typeof PasswordInput
|
|
40
|
+
| undefined
|
|
41
|
+
>
|
|
42
|
+
| undefined;
|
|
43
|
+
|
|
18
44
|
/**
|
|
19
45
|
* - Accordion config
|
|
20
46
|
*/
|
|
@@ -40,6 +66,11 @@ export interface Config {
|
|
|
40
66
|
*/
|
|
41
67
|
exitThisPage?: ExitThisPageConfig | undefined;
|
|
42
68
|
|
|
69
|
+
/**
|
|
70
|
+
* - File Upload config
|
|
71
|
+
*/
|
|
72
|
+
fileUpload?: FileUploadConfig | undefined;
|
|
73
|
+
|
|
43
74
|
/**
|
|
44
75
|
* - Notification Banner config
|
|
45
76
|
*/
|
|
@@ -54,15 +85,18 @@ export interface Config {
|
|
|
54
85
|
/**
|
|
55
86
|
* Component config keys, e.g. `accordion` and `characterCount`
|
|
56
87
|
*/
|
|
57
|
-
export type ConfigKey = keyof Config
|
|
88
|
+
export type ConfigKey = keyof Omit<Config, "scope" | "onError">;
|
|
58
89
|
|
|
59
90
|
export type ComponentConfig<ComponentClass extends CompatibleClass> = ConstructorParameters<ComponentClass>[1];
|
|
60
91
|
|
|
61
|
-
export interface ErrorContext<
|
|
92
|
+
export interface ErrorContext<
|
|
93
|
+
ComponentClass extends CompatibleClass | undefined = undefined,
|
|
94
|
+
> {
|
|
62
95
|
/**
|
|
63
96
|
* - Element used for component module initialisation
|
|
64
97
|
*/
|
|
65
|
-
element?:
|
|
98
|
+
element?: ComponentClass extends CompatibleClass ? Element
|
|
99
|
+
: undefined;
|
|
66
100
|
|
|
67
101
|
/**
|
|
68
102
|
* - Class of component
|
|
@@ -70,12 +104,15 @@ export interface ErrorContext<ComponentClass extends CompatibleClass> {
|
|
|
70
104
|
component?: ComponentClass | undefined;
|
|
71
105
|
|
|
72
106
|
/**
|
|
73
|
-
* - Config supplied to
|
|
107
|
+
* - Config supplied to components
|
|
74
108
|
*/
|
|
75
|
-
config
|
|
109
|
+
config?: ComponentClass extends CompatibleClass ? ComponentConfig<ComponentClass>
|
|
110
|
+
: Config;
|
|
76
111
|
}
|
|
77
112
|
|
|
78
|
-
export type OnErrorCallback<
|
|
113
|
+
export type OnErrorCallback<
|
|
114
|
+
ComponentClass extends CompatibleClass | undefined = undefined,
|
|
115
|
+
> = (
|
|
79
116
|
error: unknown,
|
|
80
117
|
context: ErrorContext<ComponentClass>,
|
|
81
118
|
) => any;
|
|
@@ -84,7 +121,7 @@ export interface CreateAllOptions<ComponentClass extends CompatibleClass> {
|
|
|
84
121
|
/**
|
|
85
122
|
* - scope of the document to search within
|
|
86
123
|
*/
|
|
87
|
-
scope?: Document | Element | undefined;
|
|
124
|
+
scope?: Document | Element | null | undefined;
|
|
88
125
|
|
|
89
126
|
/**
|
|
90
127
|
* - callback function if error throw by component on init
|
|
@@ -98,13 +135,10 @@ export interface CreateAllOptions<ComponentClass extends CompatibleClass> {
|
|
|
98
135
|
* Use the `data-module` attributes to find, instantiate and init all of the
|
|
99
136
|
* components provided as part of GOV.UK Frontend.
|
|
100
137
|
*
|
|
101
|
-
* @param {Config
|
|
138
|
+
* @param {Config | Element | Document | null} [scopeOrConfig] - Scope of the document to search within or config for all components (with optional scope)
|
|
102
139
|
*/
|
|
103
140
|
export function initAll(
|
|
104
|
-
|
|
105
|
-
scope?: Element;
|
|
106
|
-
onError?: OnErrorCallback<CompatibleClass>;
|
|
107
|
-
},
|
|
141
|
+
scopeOrConfig?: Config | Element | Document | null,
|
|
108
142
|
): void;
|
|
109
143
|
|
|
110
144
|
/**
|
|
@@ -119,11 +153,16 @@ export function initAll(
|
|
|
119
153
|
* @template {CompatibleClass} ComponentClass
|
|
120
154
|
* @param {ComponentClass} Component - class of the component to create
|
|
121
155
|
* @param {ComponentConfig<ComponentClass>} [config] - Config supplied to component
|
|
122
|
-
* @param {OnErrorCallback<ComponentClass> | Element | Document | CreateAllOptions<ComponentClass>
|
|
156
|
+
* @param {OnErrorCallback<ComponentClass> | Element | Document | null | CreateAllOptions<ComponentClass>} [scopeOrOptions] - options for createAll including scope of the document to search within and callback function if error throw by component on init
|
|
123
157
|
* @returns {Array<InstanceType<ComponentClass>>} - array of instantiated components
|
|
124
158
|
*/
|
|
125
159
|
export function createAll<ComponentClass extends CompatibleClass>(
|
|
126
160
|
Component: ComponentClass,
|
|
127
161
|
config?: ComponentConfig<ComponentClass>,
|
|
128
|
-
|
|
162
|
+
scopeOrOptions?:
|
|
163
|
+
| OnErrorCallback<ComponentClass>
|
|
164
|
+
| Element
|
|
165
|
+
| Document
|
|
166
|
+
| null
|
|
167
|
+
| CreateAllOptions<ComponentClass>,
|
|
129
168
|
): Array<InstanceType<ComponentClass>>;
|
govuk-frontend/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/govuk-frontend",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"description": "TypeScript definitions for govuk-frontend",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/govuk-frontend",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
"githubUsername": "colinrotherham",
|
|
11
11
|
"url": "https://github.com/colinrotherham"
|
|
12
12
|
},
|
|
13
|
+
{
|
|
14
|
+
"name": "Paul Robert Lloyd",
|
|
15
|
+
"githubUsername": "paulrobertlloyd",
|
|
16
|
+
"url": "https://github.com/paulrobertlloyd"
|
|
17
|
+
},
|
|
13
18
|
{
|
|
14
19
|
"name": "Romaric Pascal",
|
|
15
20
|
"githubUsername": "romaricpascal",
|
|
@@ -33,6 +38,6 @@
|
|
|
33
38
|
"scripts": {},
|
|
34
39
|
"dependencies": {},
|
|
35
40
|
"peerDependencies": {},
|
|
36
|
-
"typesPublisherContentHash": "
|
|
37
|
-
"typeScriptVersion": "5.
|
|
41
|
+
"typesPublisherContentHash": "33f390f9de3c3dfe7ef78c5fee7171a541a00aeecaedc5460d56c20acb614a45",
|
|
42
|
+
"typeScriptVersion": "5.2"
|
|
38
43
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./govuk-frontend-component.js";
|