From dec62b3b0d23ab373be4ff757d20352ae658e8ee Mon Sep 17 00:00:00 2001 From: Thomas Allmer Date: Fri, 18 Nov 2022 15:17:11 +0100 Subject: [PATCH] fix(ui): type requestUpdate --- .../ui/components/calendar/src/LionCalendar.js | 14 ++++++++++---- .../ui/components/combobox/src/LionCombobox.js | 10 ++++++---- .../ui/components/core/src/DisabledMixin.js | 10 ++++++---- .../core/src/DisabledWithTabIndexMixin.js | 10 ++++++---- .../ui/components/core/types/SlotMixinTypes.ts | 2 +- .../ui/components/form-core/src/FormatMixin.js | 18 ++++++++++-------- .../form-core/src/InteractionStateMixin.js | 14 ++++++++------ .../src/choice-group/ChoiceInputMixin.js | 10 ++++++---- .../form-core/src/utils/SyncUpdatableMixin.js | 13 +++++++++---- .../test/utils/SyncUpdatableMixin.test.js | 10 ++++++---- .../src/LionInputDatepicker.js | 10 ++++++---- packages/ui/components/input/src/LionInput.js | 10 ++++++---- .../ui/components/listbox/src/LionOption.js | 10 ++++++---- .../ui/components/overlays/src/OverlayMixin.js | 11 ++++++----- .../select-rich/src/LionSelectRich.js | 10 ++++++---- .../components/switch/src/LionSwitchButton.js | 13 ++++++------- 16 files changed, 104 insertions(+), 71 deletions(-) diff --git a/packages/ui/components/calendar/src/LionCalendar.js b/packages/ui/components/calendar/src/LionCalendar.js index 44b27cf2d..400fd58af 100644 --- a/packages/ui/components/calendar/src/LionCalendar.js +++ b/packages/ui/components/calendar/src/LionCalendar.js @@ -317,11 +317,17 @@ export class LionCalendar extends LocalizeMixin(LitElement) { } /** - * @param {string} name - * @param {?} oldValue + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldValue) { - super.requestUpdate(name, oldValue); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); + + if (name === undefined) { + return; + } const map = { disableDates: () => this.__disableDatesChanged(), diff --git a/packages/ui/components/combobox/src/LionCombobox.js b/packages/ui/components/combobox/src/LionCombobox.js index ae7f5264f..8f8f436fa 100644 --- a/packages/ui/components/combobox/src/LionCombobox.js +++ b/packages/ui/components/combobox/src/LionCombobox.js @@ -378,11 +378,13 @@ export class LionCombobox extends OverlayMixin(LionListbox) { } /** - * @param {'disabled'|'modelValue'|'readOnly'|'focused'} name - * @param {unknown} oldValue + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldValue) { - super.requestUpdate(name, oldValue); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); if (name === 'disabled' || name === 'readOnly') { this.__setComboboxDisabledAndReadOnly(); } diff --git a/packages/ui/components/core/src/DisabledMixin.js b/packages/ui/components/core/src/DisabledMixin.js index dc22553d8..3c83134bd 100644 --- a/packages/ui/components/core/src/DisabledMixin.js +++ b/packages/ui/components/core/src/DisabledMixin.js @@ -58,11 +58,13 @@ const DisabledMixinImplementation = superclass => } /** - * @param {PropertyKey} name - * @param {?} oldValue + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldValue) { - super.requestUpdate(name, oldValue); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); if (name === 'disabled') { if (this.__isUserSettingDisabled) { this.__restoreDisabledTo = this.disabled; diff --git a/packages/ui/components/core/src/DisabledWithTabIndexMixin.js b/packages/ui/components/core/src/DisabledWithTabIndexMixin.js index 66bbdd884..01e04ee6d 100644 --- a/packages/ui/components/core/src/DisabledWithTabIndexMixin.js +++ b/packages/ui/components/core/src/DisabledWithTabIndexMixin.js @@ -60,11 +60,13 @@ const DisabledWithTabIndexMixinImplementation = superclass => } /** - * @param {PropertyKey} name - * @param {?} oldValue + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldValue) { - super.requestUpdate(name, oldValue); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); if (name === 'disabled') { if (this.disabled) { diff --git a/packages/ui/components/core/types/SlotMixinTypes.ts b/packages/ui/components/core/types/SlotMixinTypes.ts index ee8a1e47c..8f16a25a6 100644 --- a/packages/ui/components/core/types/SlotMixinTypes.ts +++ b/packages/ui/components/core/types/SlotMixinTypes.ts @@ -60,7 +60,7 @@ export declare class SlotHost { * }; * } */ -export declare function SlotMixinImplementation>( +declare function SlotMixinImplementation>( superclass: T, ): T & Constructor & diff --git a/packages/ui/components/form-core/src/FormatMixin.js b/packages/ui/components/form-core/src/FormatMixin.js index 3b21ff976..d80636db0 100644 --- a/packages/ui/components/form-core/src/FormatMixin.js +++ b/packages/ui/components/form-core/src/FormatMixin.js @@ -70,19 +70,21 @@ const FormatMixinImplementation = superclass => } /** - * @param {string} name - * @param {any} oldVal + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldVal) { - super.requestUpdate(name, oldVal); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); - if (name === 'modelValue' && this.modelValue !== oldVal) { - this._onModelValueChanged({ modelValue: this.modelValue }, { modelValue: oldVal }); + if (name === 'modelValue' && this.modelValue !== oldValue) { + this._onModelValueChanged({ modelValue: this.modelValue }, { modelValue: oldValue }); } - if (name === 'serializedValue' && this.serializedValue !== oldVal) { + if (name === 'serializedValue' && this.serializedValue !== oldValue) { this._calculateValues({ source: 'serialized' }); } - if (name === 'formattedValue' && this.formattedValue !== oldVal) { + if (name === 'formattedValue' && this.formattedValue !== oldValue) { this._calculateValues({ source: 'formatted' }); } } diff --git a/packages/ui/components/form-core/src/InteractionStateMixin.js b/packages/ui/components/form-core/src/InteractionStateMixin.js index 87e745331..d4c3f51fa 100644 --- a/packages/ui/components/form-core/src/InteractionStateMixin.js +++ b/packages/ui/components/form-core/src/InteractionStateMixin.js @@ -33,12 +33,14 @@ const InteractionStateMixinImplementation = superclass => } /** - * @param {PropertyKey} name - * @param {*} oldVal + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldVal) { - super.requestUpdate(name, oldVal); - if (name === 'touched' && this.touched !== oldVal) { + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); + if (name === 'touched' && this.touched !== oldValue) { this._onTouchedChanged(); } @@ -48,7 +50,7 @@ const InteractionStateMixinImplementation = superclass => this.filled = !this._isEmpty(); } - if (name === 'dirty' && this.dirty !== oldVal) { + if (name === 'dirty' && this.dirty !== oldValue) { this._onDirtyChanged(); } } diff --git a/packages/ui/components/form-core/src/choice-group/ChoiceInputMixin.js b/packages/ui/components/form-core/src/choice-group/ChoiceInputMixin.js index f48ca8a33..4a673476a 100644 --- a/packages/ui/components/form-core/src/choice-group/ChoiceInputMixin.js +++ b/packages/ui/components/form-core/src/choice-group/ChoiceInputMixin.js @@ -52,11 +52,13 @@ const ChoiceInputMixinImplementation = superclass => } /** - * @param {string} name - * @param {any} oldValue + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldValue) { - super.requestUpdate(name, oldValue); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); if (name === 'modelValue') { if (this.modelValue.checked !== this.checked) { diff --git a/packages/ui/components/form-core/src/utils/SyncUpdatableMixin.js b/packages/ui/components/form-core/src/utils/SyncUpdatableMixin.js index 6662e3fd5..4e0dd096f 100644 --- a/packages/ui/components/form-core/src/utils/SyncUpdatableMixin.js +++ b/packages/ui/components/form-core/src/utils/SyncUpdatableMixin.js @@ -93,11 +93,16 @@ const SyncUpdatableMixinImplementation = superclass => } /** - * @param {string} name - * @param {*} oldValue + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldValue) { - super.requestUpdate(name, oldValue); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); + if (name === undefined) { + return; + } this.__SyncUpdatableNamespace = this.__SyncUpdatableNamespace || {}; const ns = this.__SyncUpdatableNamespace; diff --git a/packages/ui/components/form-core/test/utils/SyncUpdatableMixin.test.js b/packages/ui/components/form-core/test/utils/SyncUpdatableMixin.test.js index aa740713a..8092ed8aa 100644 --- a/packages/ui/components/form-core/test/utils/SyncUpdatableMixin.test.js +++ b/packages/ui/components/form-core/test/utils/SyncUpdatableMixin.test.js @@ -147,11 +147,13 @@ describe('SyncUpdatableMixin', () => { } /** - * @param {string} name - * @param {*} oldValue + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldValue) { - super.requestUpdate(name, oldValue); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); if (name === 'prop') { propChangedCount += 1; } diff --git a/packages/ui/components/input-datepicker/src/LionInputDatepicker.js b/packages/ui/components/input-datepicker/src/LionInputDatepicker.js index 4bed43349..0af4adf2e 100644 --- a/packages/ui/components/input-datepicker/src/LionInputDatepicker.js +++ b/packages/ui/components/input-datepicker/src/LionInputDatepicker.js @@ -211,11 +211,13 @@ export class LionInputDatepicker extends ScopedElementsMixin( } /** - * @param {PropertyKey} name - * @param {?} oldValue + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldValue) { - super.requestUpdate(name, oldValue); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); if (name === 'disabled' || name === 'readOnly') { this.__toggleInvokerDisabled(); diff --git a/packages/ui/components/input/src/LionInput.js b/packages/ui/components/input/src/LionInput.js index b2bf8307f..4d84d007a 100644 --- a/packages/ui/components/input/src/LionInput.js +++ b/packages/ui/components/input/src/LionInput.js @@ -64,11 +64,13 @@ export class LionInput extends NativeTextFieldMixin(LionField) { } /** - * @param {PropertyKey} [name] - * @param {?} [oldValue] + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldValue) { - super.requestUpdate(name, oldValue); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); if (name === 'readOnly') { this.__delegateReadOnly(); } diff --git a/packages/ui/components/listbox/src/LionOption.js b/packages/ui/components/listbox/src/LionOption.js index 23474aa16..eacd63496 100644 --- a/packages/ui/components/listbox/src/LionOption.js +++ b/packages/ui/components/listbox/src/LionOption.js @@ -78,11 +78,13 @@ export class LionOption extends DisabledMixin( } /** - * @param {string} name - * @param {unknown} oldValue + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldValue) { - super.requestUpdate(name, oldValue); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); if (name === 'active' && this.active !== oldValue) { this.dispatchEvent(new Event('active-changed', { bubbles: true })); diff --git a/packages/ui/components/overlays/src/OverlayMixin.js b/packages/ui/components/overlays/src/OverlayMixin.js index a371a917b..6aa6dc7e5 100644 --- a/packages/ui/components/overlays/src/OverlayMixin.js +++ b/packages/ui/components/overlays/src/OverlayMixin.js @@ -58,12 +58,13 @@ export const OverlayMixinImplementation = superclass => } /** - * @override - * @param {string} name - * @param {any} oldValue + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldValue) { - super.requestUpdate(name, oldValue); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); if (name === 'opened' && this.opened !== oldValue) { this.dispatchEvent(new Event('opened-changed')); } diff --git a/packages/ui/components/select-rich/src/LionSelectRich.js b/packages/ui/components/select-rich/src/LionSelectRich.js index 7be84509c..9d830468f 100644 --- a/packages/ui/components/select-rich/src/LionSelectRich.js +++ b/packages/ui/components/select-rich/src/LionSelectRich.js @@ -156,11 +156,13 @@ export class LionSelectRich extends SlotMixin(ScopedElementsMixin(OverlayMixin(L } /** - * @param {string} name - * @param {unknown} oldValue + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldValue) { - super.requestUpdate(name, oldValue); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); if (name === 'interactionMode') { if (this.interactionMode === 'auto') { this.interactionMode = detectInteractionMode(); diff --git a/packages/ui/components/switch/src/LionSwitchButton.js b/packages/ui/components/switch/src/LionSwitchButton.js index d6e3761ad..a323d9846 100644 --- a/packages/ui/components/switch/src/LionSwitchButton.js +++ b/packages/ui/components/switch/src/LionSwitchButton.js @@ -151,14 +151,13 @@ export class LionSwitchButton extends DisabledWithTabIndexMixin(LitElement) { } /** - * We synchronously update aria-checked to support voice over on safari. - * - * @param {PropertyKey} name - * @param {?} oldValue - * @override + * @param {string} [name] + * @param {unknown} [oldValue] + * @param {import('lit').PropertyDeclaration} [options] + * @returns {void} */ - requestUpdate(name, oldValue) { - super.requestUpdate(name, oldValue); + requestUpdate(name, oldValue, options) { + super.requestUpdate(name, oldValue, options); if (this.isConnected && name === 'checked' && this.checked !== oldValue && !this.disabled) { this.__checkedStateChange(); }