fix(ui): type requestUpdate

This commit is contained in:
Thomas Allmer 2022-11-18 15:17:11 +01:00 committed by Thijs Louisse
parent aee0621c54
commit dec62b3b0d
16 changed files with 104 additions and 71 deletions

View file

@ -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(),

View file

@ -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();
}

View file

@ -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;

View file

@ -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) {

View file

@ -60,7 +60,7 @@ export declare class SlotHost {
* };
* }
*/
export declare function SlotMixinImplementation<T extends Constructor<LitElement>>(
declare function SlotMixinImplementation<T extends Constructor<LitElement>>(
superclass: T,
): T &
Constructor<SlotHost> &

View file

@ -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' });
}
}

View file

@ -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();
}
}

View file

@ -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) {

View file

@ -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;

View file

@ -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;
}

View file

@ -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();

View file

@ -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();
}

View file

@ -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 }));

View file

@ -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'));
}

View file

@ -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();

View file

@ -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();
}