From 675b7fb1d77e4c8056c3816f07df90ab1585824c Mon Sep 17 00:00:00 2001 From: Patrick Cartlidge Date: Mon, 18 Nov 2024 15:10:06 +0000 Subject: [PATCH] update config --- .../src/govuk/common/configuration.mjs | 8 ++--- ...tend-component-configurable.jsdom.test.mjs | 33 +++++++++---------- .../govuk/components/accordion/accordion.mjs | 6 ++-- .../src/govuk/components/button/button.mjs | 6 ++-- .../character-count/character-count.mjs | 6 ++-- .../error-summary/error-summary.mjs | 6 ++-- .../exit-this-page/exit-this-page.mjs | 6 ++-- .../notification-banner.mjs | 6 ++-- .../password-input/password-input.mjs | 6 ++-- 9 files changed, 40 insertions(+), 43 deletions(-) diff --git a/packages/govuk-frontend/src/govuk/common/configuration.mjs b/packages/govuk-frontend/src/govuk/common/configuration.mjs index 78595cffaf..63947cd1f6 100644 --- a/packages/govuk-frontend/src/govuk/common/configuration.mjs +++ b/packages/govuk-frontend/src/govuk/common/configuration.mjs @@ -1,5 +1,5 @@ +import { Component } from '../component.mjs' import { ConfigError } from '../errors/index.mjs' -import { GOVUKFrontendComponent } from '../govuk-frontend-component.mjs' import { isObject, formatErrorMessage } from './index.mjs' @@ -13,9 +13,9 @@ export const configOverride = Symbol.for('configOverride') * @virtual * @template {ObjectNested} [ConfigurationType={}] * @template {Element & { dataset: DOMStringMap }} [RootElementType=HTMLElement] - * @augments GOVUKFrontendComponent + * @augments Component */ -export class GOVUKFrontendComponentConfigurable extends GOVUKFrontendComponent { +export class ConfigurableComponent extends Component { /** * configOverride * @@ -354,5 +354,5 @@ export function extractConfigByNamespace(schema, dataset, namespace) { /** * @template {ObjectNested} [ConfigurationType={}] - * @typedef {typeof GOVUKFrontendComponent & ChildClass} ChildClassConstructor + * @typedef {typeof Component & ChildClass} ChildClassConstructor */ diff --git a/packages/govuk-frontend/src/govuk/common/configuration/govuk-frontend-component-configurable.jsdom.test.mjs b/packages/govuk-frontend/src/govuk/common/configuration/govuk-frontend-component-configurable.jsdom.test.mjs index 5e1f4831c3..83326e32cc 100644 --- a/packages/govuk-frontend/src/govuk/common/configuration/govuk-frontend-component-configurable.jsdom.test.mjs +++ b/packages/govuk-frontend/src/govuk/common/configuration/govuk-frontend-component-configurable.jsdom.test.mjs @@ -1,8 +1,5 @@ import { ConfigError } from '../../errors/index.mjs' -import { - GOVUKFrontendComponentConfigurable, - configOverride -} from '../configuration.mjs' +import { ConfigurableComponent, configOverride } from '../configuration.mjs' describe('GOVUKFrontendComponentConfigurable', () => { beforeEach(() => { @@ -18,7 +15,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { describe('throws error', () => { it('if no schema defined', () => { - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { static moduleName = 'config-component' static defaults = { @@ -26,7 +23,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { } } - expect(() => new ConfigurableComponent(document.body)).toThrow( + expect(() => new MockConfigurableComponent(document.body)).toThrow( new ConfigError( 'config-component: Config passed as parameter into constructor but no schema defined' ) @@ -34,7 +31,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { }) it('if no defaults defined', () => { - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { static moduleName = 'config-component' static schema = { @@ -44,7 +41,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { } } - expect(() => new ConfigurableComponent(document.body)).toThrow( + expect(() => new MockConfigurableComponent(document.body)).toThrow( new ConfigError( 'config-component: Config passed as parameter into constructor but no defaults defined' ) @@ -58,7 +55,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
` - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { static moduleName = 'config-component' static schema = { @@ -74,7 +71,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { const testComponent = document.querySelector('#test-component') - const configComponent = new ConfigurableComponent(testComponent) + const configComponent = new MockConfigurableComponent(testComponent) expect(configComponent._config).toMatchObject({ randomAttribute: 0 }) }) @@ -84,7 +81,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
` - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { static moduleName = 'config-component' static schema = { @@ -100,7 +97,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { const testComponent = document.querySelector('#test-component') - const configComponent = new ConfigurableComponent(testComponent) + const configComponent = new MockConfigurableComponent(testComponent) expect(configComponent._config).toMatchObject({ randomAttribute: 42 }) }) @@ -110,7 +107,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
` - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { static moduleName = 'config-component' static schema = { @@ -126,7 +123,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { const testComponent = document.querySelector('#test-component') - const configComponent = new ConfigurableComponent(testComponent, { + const configComponent = new MockConfigurableComponent(testComponent, { randomAttribute: 100 }) @@ -138,7 +135,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
` - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { static moduleName = 'config-component' static schema = { @@ -154,7 +151,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { const testComponent = document.querySelector('#test-component') - const configComponent = new ConfigurableComponent(testComponent, { + const configComponent = new MockConfigurableComponent(testComponent, { randomAttribute: 100 }) @@ -170,7 +167,7 @@ describe('GOVUKFrontendComponentConfigurable', () => {
` - class ConfigurableComponent extends GOVUKFrontendComponentConfigurable { + class MockConfigurableComponent extends ConfigurableComponent { [configOverride](config) { return configOverrideFunction(config) } @@ -190,7 +187,7 @@ describe('GOVUKFrontendComponentConfigurable', () => { const testComponent = document.querySelector('#test-component') - const configComponent = new ConfigurableComponent(testComponent, { + const configComponent = new MockConfigurableComponent(testComponent, { randomAttribute: '14' }) diff --git a/packages/govuk-frontend/src/govuk/components/accordion/accordion.mjs b/packages/govuk-frontend/src/govuk/components/accordion/accordion.mjs index bc6e592cf3..97d52624b6 100644 --- a/packages/govuk-frontend/src/govuk/components/accordion/accordion.mjs +++ b/packages/govuk-frontend/src/govuk/components/accordion/accordion.mjs @@ -1,4 +1,4 @@ -import { GOVUKFrontendComponentConfigurable } from '../../common/configuration.mjs' +import { ConfigurableComponent } from '../../common/configuration.mjs' import { ElementError } from '../../errors/index.mjs' import { I18n } from '../../i18n.mjs' @@ -15,9 +15,9 @@ import { I18n } from '../../i18n.mjs' * attribute, which also provides accessibility. * * @preserve - * @augments GOVUKFrontendComponentConfigurable + * @augments ConfigurableComponent */ -export class Accordion extends GOVUKFrontendComponentConfigurable { +export class Accordion extends ConfigurableComponent { /** @private */ i18n diff --git a/packages/govuk-frontend/src/govuk/components/button/button.mjs b/packages/govuk-frontend/src/govuk/components/button/button.mjs index 5f0c8e8d42..b081708286 100644 --- a/packages/govuk-frontend/src/govuk/components/button/button.mjs +++ b/packages/govuk-frontend/src/govuk/components/button/button.mjs @@ -1,4 +1,4 @@ -import { GOVUKFrontendComponentConfigurable } from '../../common/configuration.mjs' +import { ConfigurableComponent } from '../../common/configuration.mjs' const DEBOUNCE_TIMEOUT_IN_SECONDS = 1 @@ -6,9 +6,9 @@ const DEBOUNCE_TIMEOUT_IN_SECONDS = 1 * JavaScript enhancements for the Button component * * @preserve - * @augments GOVUKFrontendComponentConfigurable + * @augments ConfigurableComponent */ -export class Button extends GOVUKFrontendComponentConfigurable { +export class Button extends ConfigurableComponent { /** * @private * @type {number | null} diff --git a/packages/govuk-frontend/src/govuk/components/character-count/character-count.mjs b/packages/govuk-frontend/src/govuk/components/character-count/character-count.mjs index dd0c276b5c..57b8268d9c 100644 --- a/packages/govuk-frontend/src/govuk/components/character-count/character-count.mjs +++ b/packages/govuk-frontend/src/govuk/components/character-count/character-count.mjs @@ -1,7 +1,7 @@ import { closestAttributeValue } from '../../common/closest-attribute-value.mjs' import { validateConfig, - GOVUKFrontendComponentConfigurable, + ConfigurableComponent, configOverride } from '../../common/configuration.mjs' import { formatErrorMessage } from '../../common/index.mjs' @@ -19,9 +19,9 @@ import { I18n } from '../../i18n.mjs' * of the available characters/words has been entered. * * @preserve - * @augments GOVUKFrontendComponentConfigurable + * @augments ConfigurableComponent */ -export class CharacterCount extends GOVUKFrontendComponentConfigurable { +export class CharacterCount extends ConfigurableComponent { /** @private */ $textarea diff --git a/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs b/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs index 5d34dd7785..57e4681923 100644 --- a/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs +++ b/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs @@ -1,4 +1,4 @@ -import { GOVUKFrontendComponentConfigurable } from '../../common/configuration.mjs' +import { ConfigurableComponent } from '../../common/configuration.mjs' import { getFragmentFromUrl, setFocus } from '../../common/index.mjs' /** @@ -8,9 +8,9 @@ import { getFragmentFromUrl, setFocus } from '../../common/index.mjs' * configuration. * * @preserve - * @augments GOVUKFrontendComponentConfigurable + * @augments ConfigurableComponent */ -export class ErrorSummary extends GOVUKFrontendComponentConfigurable { +export class ErrorSummary extends ConfigurableComponent { /** * @param {Element | null} $root - HTML element to use for error summary * @param {ErrorSummaryConfig} [config] - Error summary config diff --git a/packages/govuk-frontend/src/govuk/components/exit-this-page/exit-this-page.mjs b/packages/govuk-frontend/src/govuk/components/exit-this-page/exit-this-page.mjs index 71fcedb19b..891fc3f2f2 100644 --- a/packages/govuk-frontend/src/govuk/components/exit-this-page/exit-this-page.mjs +++ b/packages/govuk-frontend/src/govuk/components/exit-this-page/exit-this-page.mjs @@ -1,4 +1,4 @@ -import { GOVUKFrontendComponentConfigurable } from '../../common/configuration.mjs' +import { ConfigurableComponent } from '../../common/configuration.mjs' import { ElementError } from '../../errors/index.mjs' import { I18n } from '../../i18n.mjs' @@ -6,9 +6,9 @@ import { I18n } from '../../i18n.mjs' * Exit this page component * * @preserve - * @augments GOVUKFrontendComponentConfigurable + * @augments ConfigurableComponent */ -export class ExitThisPage extends GOVUKFrontendComponentConfigurable { +export class ExitThisPage extends ConfigurableComponent { /** @private */ i18n diff --git a/packages/govuk-frontend/src/govuk/components/notification-banner/notification-banner.mjs b/packages/govuk-frontend/src/govuk/components/notification-banner/notification-banner.mjs index c4f175e9fd..32caded5be 100644 --- a/packages/govuk-frontend/src/govuk/components/notification-banner/notification-banner.mjs +++ b/packages/govuk-frontend/src/govuk/components/notification-banner/notification-banner.mjs @@ -1,13 +1,13 @@ -import { GOVUKFrontendComponentConfigurable } from '../../common/configuration.mjs' +import { ConfigurableComponent } from '../../common/configuration.mjs' import { setFocus } from '../../common/index.mjs' /** * Notification Banner component * * @preserve - * @augments GOVUKFrontendComponentConfigurable + * @augments ConfigurableComponent */ -export class NotificationBanner extends GOVUKFrontendComponentConfigurable { +export class NotificationBanner extends ConfigurableComponent { /** * @param {Element | null} $root - HTML element to use for notification banner * @param {NotificationBannerConfig} [config] - Notification banner config diff --git a/packages/govuk-frontend/src/govuk/components/password-input/password-input.mjs b/packages/govuk-frontend/src/govuk/components/password-input/password-input.mjs index 36d716a50e..f031f9cd5e 100644 --- a/packages/govuk-frontend/src/govuk/components/password-input/password-input.mjs +++ b/packages/govuk-frontend/src/govuk/components/password-input/password-input.mjs @@ -1,5 +1,5 @@ import { closestAttributeValue } from '../../common/closest-attribute-value.mjs' -import { GOVUKFrontendComponentConfigurable } from '../../common/configuration.mjs' +import { ConfigurableComponent } from '../../common/configuration.mjs' import { ElementError } from '../../errors/index.mjs' import { I18n } from '../../i18n.mjs' @@ -7,9 +7,9 @@ import { I18n } from '../../i18n.mjs' * Password input component * * @preserve - * @augments GOVUKFrontendComponentConfigurable + * @augments ConfigurableComponent */ -export class PasswordInput extends GOVUKFrontendComponentConfigurable { +export class PasswordInput extends ConfigurableComponent { /** @private */ i18n