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 {string} [name]
* @param {?} oldValue * @param {unknown} [oldValue]
* @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldValue) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldValue); super.requestUpdate(name, oldValue, options);
if (name === undefined) {
return;
}
const map = { const map = {
disableDates: () => this.__disableDatesChanged(), disableDates: () => this.__disableDatesChanged(),

View file

@ -378,11 +378,13 @@ export class LionCombobox extends OverlayMixin(LionListbox) {
} }
/** /**
* @param {'disabled'|'modelValue'|'readOnly'|'focused'} name * @param {string} [name]
* @param {unknown} oldValue * @param {unknown} [oldValue]
* @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldValue) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldValue); super.requestUpdate(name, oldValue, options);
if (name === 'disabled' || name === 'readOnly') { if (name === 'disabled' || name === 'readOnly') {
this.__setComboboxDisabledAndReadOnly(); this.__setComboboxDisabledAndReadOnly();
} }

View file

@ -58,11 +58,13 @@ const DisabledMixinImplementation = superclass =>
} }
/** /**
* @param {PropertyKey} name * @param {string} [name]
* @param {?} oldValue * @param {unknown} [oldValue]
* @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldValue) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldValue); super.requestUpdate(name, oldValue, options);
if (name === 'disabled') { if (name === 'disabled') {
if (this.__isUserSettingDisabled) { if (this.__isUserSettingDisabled) {
this.__restoreDisabledTo = this.disabled; this.__restoreDisabledTo = this.disabled;

View file

@ -60,11 +60,13 @@ const DisabledWithTabIndexMixinImplementation = superclass =>
} }
/** /**
* @param {PropertyKey} name * @param {string} [name]
* @param {?} oldValue * @param {unknown} [oldValue]
* @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldValue) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldValue); super.requestUpdate(name, oldValue, options);
if (name === 'disabled') { if (name === 'disabled') {
if (this.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, superclass: T,
): T & ): T &
Constructor<SlotHost> & Constructor<SlotHost> &

View file

@ -70,19 +70,21 @@ const FormatMixinImplementation = superclass =>
} }
/** /**
* @param {string} name * @param {string} [name]
* @param {any} oldVal * @param {unknown} [oldValue]
* @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldVal) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldVal); super.requestUpdate(name, oldValue, options);
if (name === 'modelValue' && this.modelValue !== oldVal) { if (name === 'modelValue' && this.modelValue !== oldValue) {
this._onModelValueChanged({ modelValue: this.modelValue }, { modelValue: oldVal }); this._onModelValueChanged({ modelValue: this.modelValue }, { modelValue: oldValue });
} }
if (name === 'serializedValue' && this.serializedValue !== oldVal) { if (name === 'serializedValue' && this.serializedValue !== oldValue) {
this._calculateValues({ source: 'serialized' }); this._calculateValues({ source: 'serialized' });
} }
if (name === 'formattedValue' && this.formattedValue !== oldVal) { if (name === 'formattedValue' && this.formattedValue !== oldValue) {
this._calculateValues({ source: 'formatted' }); this._calculateValues({ source: 'formatted' });
} }
} }

View file

@ -33,12 +33,14 @@ const InteractionStateMixinImplementation = superclass =>
} }
/** /**
* @param {PropertyKey} name * @param {string} [name]
* @param {*} oldVal * @param {unknown} [oldValue]
* @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldVal) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldVal); super.requestUpdate(name, oldValue, options);
if (name === 'touched' && this.touched !== oldVal) { if (name === 'touched' && this.touched !== oldValue) {
this._onTouchedChanged(); this._onTouchedChanged();
} }
@ -48,7 +50,7 @@ const InteractionStateMixinImplementation = superclass =>
this.filled = !this._isEmpty(); this.filled = !this._isEmpty();
} }
if (name === 'dirty' && this.dirty !== oldVal) { if (name === 'dirty' && this.dirty !== oldValue) {
this._onDirtyChanged(); this._onDirtyChanged();
} }
} }

View file

@ -52,11 +52,13 @@ const ChoiceInputMixinImplementation = superclass =>
} }
/** /**
* @param {string} name * @param {string} [name]
* @param {any} oldValue * @param {unknown} [oldValue]
* @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldValue) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldValue); super.requestUpdate(name, oldValue, options);
if (name === 'modelValue') { if (name === 'modelValue') {
if (this.modelValue.checked !== this.checked) { if (this.modelValue.checked !== this.checked) {

View file

@ -93,11 +93,16 @@ const SyncUpdatableMixinImplementation = superclass =>
} }
/** /**
* @param {string} name * @param {string} [name]
* @param {*} oldValue * @param {unknown} [oldValue]
* @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldValue) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldValue); super.requestUpdate(name, oldValue, options);
if (name === undefined) {
return;
}
this.__SyncUpdatableNamespace = this.__SyncUpdatableNamespace || {}; this.__SyncUpdatableNamespace = this.__SyncUpdatableNamespace || {};
const ns = this.__SyncUpdatableNamespace; const ns = this.__SyncUpdatableNamespace;

View file

@ -147,11 +147,13 @@ describe('SyncUpdatableMixin', () => {
} }
/** /**
* @param {string} name * @param {string} [name]
* @param {*} oldValue * @param {unknown} [oldValue]
* @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldValue) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldValue); super.requestUpdate(name, oldValue, options);
if (name === 'prop') { if (name === 'prop') {
propChangedCount += 1; propChangedCount += 1;
} }

View file

@ -211,11 +211,13 @@ export class LionInputDatepicker extends ScopedElementsMixin(
} }
/** /**
* @param {PropertyKey} name * @param {string} [name]
* @param {?} oldValue * @param {unknown} [oldValue]
* @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldValue) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldValue); super.requestUpdate(name, oldValue, options);
if (name === 'disabled' || name === 'readOnly') { if (name === 'disabled' || name === 'readOnly') {
this.__toggleInvokerDisabled(); this.__toggleInvokerDisabled();

View file

@ -64,11 +64,13 @@ export class LionInput extends NativeTextFieldMixin(LionField) {
} }
/** /**
* @param {PropertyKey} [name] * @param {string} [name]
* @param {?} [oldValue] * @param {unknown} [oldValue]
* @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldValue) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldValue); super.requestUpdate(name, oldValue, options);
if (name === 'readOnly') { if (name === 'readOnly') {
this.__delegateReadOnly(); this.__delegateReadOnly();
} }

View file

@ -78,11 +78,13 @@ export class LionOption extends DisabledMixin(
} }
/** /**
* @param {string} name * @param {string} [name]
* @param {unknown} oldValue * @param {unknown} [oldValue]
* @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldValue) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldValue); super.requestUpdate(name, oldValue, options);
if (name === 'active' && this.active !== oldValue) { if (name === 'active' && this.active !== oldValue) {
this.dispatchEvent(new Event('active-changed', { bubbles: true })); this.dispatchEvent(new Event('active-changed', { bubbles: true }));

View file

@ -58,12 +58,13 @@ export const OverlayMixinImplementation = superclass =>
} }
/** /**
* @override * @param {string} [name]
* @param {string} name * @param {unknown} [oldValue]
* @param {any} oldValue * @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldValue) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldValue); super.requestUpdate(name, oldValue, options);
if (name === 'opened' && this.opened !== oldValue) { if (name === 'opened' && this.opened !== oldValue) {
this.dispatchEvent(new Event('opened-changed')); this.dispatchEvent(new Event('opened-changed'));
} }

View file

@ -156,11 +156,13 @@ export class LionSelectRich extends SlotMixin(ScopedElementsMixin(OverlayMixin(L
} }
/** /**
* @param {string} name * @param {string} [name]
* @param {unknown} oldValue * @param {unknown} [oldValue]
* @param {import('lit').PropertyDeclaration} [options]
* @returns {void}
*/ */
requestUpdate(name, oldValue) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldValue); super.requestUpdate(name, oldValue, options);
if (name === 'interactionMode') { if (name === 'interactionMode') {
if (this.interactionMode === 'auto') { if (this.interactionMode === 'auto') {
this.interactionMode = detectInteractionMode(); 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 {string} [name]
* * @param {unknown} [oldValue]
* @param {PropertyKey} name * @param {import('lit').PropertyDeclaration} [options]
* @param {?} oldValue * @returns {void}
* @override
*/ */
requestUpdate(name, oldValue) { requestUpdate(name, oldValue, options) {
super.requestUpdate(name, oldValue); super.requestUpdate(name, oldValue, options);
if (this.isConnected && name === 'checked' && this.checked !== oldValue && !this.disabled) { if (this.isConnected && name === 'checked' && this.checked !== oldValue && !this.disabled) {
this.__checkedStateChange(); this.__checkedStateChange();
} }