From 23249dc4e98a7f0bc612b3f59bae1f20a0c6f3b1 Mon Sep 17 00:00:00 2001 From: konnorrogers Date: Wed, 8 May 2024 16:16:14 -0400 Subject: [PATCH] prettier --- src/components/button/button.ts | 32 ++++++++++----------- src/components/input/input.ts | 1 - src/components/radio-button/radio-button.ts | 8 +----- src/internal/webawesome-element.ts | 12 ++++---- 4 files changed, 21 insertions(+), 32 deletions(-) diff --git a/src/components/button/button.ts b/src/components/button/button.ts index b0dd63a15..815e095cc 100644 --- a/src/components/button/button.ts +++ b/src/components/button/button.ts @@ -1,12 +1,12 @@ import '../icon/icon.js'; import '../spinner/spinner.js'; import { classMap } from 'lit/directives/class-map.js'; +import { customElement, property, query, state } from 'lit/decorators.js'; import { HasSlotController } from '../../internal/slot.js'; import { html, literal } from 'lit/static-html.js'; import { ifDefined } from 'lit/directives/if-defined.js'; import { LocalizeController } from '../../utilities/localize.js'; import { MirrorValidator } from '../../internal/validators/mirror-validator.js'; -import { customElement, property, query, state } from 'lit/decorators.js'; import { watch } from '../../internal/watch.js'; import { WebAwesomeFormAssociated } from '../../internal/webawesome-element.js'; import componentStyles from '../../styles/component.styles.js'; @@ -52,17 +52,15 @@ import type { CSSResultGroup } from 'lit'; * @cssproperty --label-color-active - The color of the button's label when active. * @cssproperty --label-color-hover - The color of the button's label on hover. */ -@customElement("wa-button") +@customElement('wa-button') export default class WaButton extends WebAwesomeFormAssociated { static styles: CSSResultGroup = [componentStyles, styles]; - static get validators () { - return [ - MirrorValidator() - ] + static get validators() { + return [MirrorValidator()]; } - assumeInteractionOn = ["click"] + assumeInteractionOn = ['click']; private readonly hasSlotController = new HasSlotController(this, '[default]', 'prefix', 'suffix'); private readonly localize = new LocalizeController(this); @@ -132,7 +130,7 @@ export default class WaButton extends WebAwesomeFormAssociated { * The "form owner" to associate the button with. If omitted, the closest containing form will be used instead. The * value of this attribute must be an id of a form in the same document or shadow root as the button. */ - @property({ reflect: true }) form: string | null = null + @property({ reflect: true }) form: string | null = null; /** Used to override the form owner's `action` attribute. */ @property({ attribute: 'formaction' }) formAction: string; @@ -161,19 +159,19 @@ export default class WaButton extends WebAwesomeFormAssociated { } private handleClick() { - const form = this.getForm() + const form = this.getForm(); - if (!form) return + if (!form) return; - const lightDOMButton = this.constructLightDOMButton() + const lightDOMButton = this.constructLightDOMButton(); // form.append(lightDOMButton); - this.parentElement?.append(lightDOMButton) + this.parentElement?.append(lightDOMButton); lightDOMButton.click(); lightDOMButton.remove(); } - private constructLightDOMButton () { + private constructLightDOMButton() { const button = document.createElement('button'); button.type = this.type; button.style.position = 'absolute'; @@ -191,11 +189,11 @@ export default class WaButton extends WebAwesomeFormAssociated { } }); - return button + return button; } private handleInvalid() { - this.emit("wa-invalid"); + this.emit('wa-invalid'); } private isButton() { @@ -208,11 +206,11 @@ export default class WaButton extends WebAwesomeFormAssociated { @watch('disabled', { waitUntilFirstUpdate: true }) handleDisabledChange() { - this.updateValidity() + this.updateValidity(); } // eslint-disable-next-line - setValue (..._args: Parameters) { + setValue(..._args: Parameters) { // This is just a stub. We dont ever actually want to set a value on the form. That happens when the button is clicked and added // via the light dom button. } diff --git a/src/components/input/input.ts b/src/components/input/input.ts index 6a897b23c..8df05dccf 100644 --- a/src/components/input/input.ts +++ b/src/components/input/input.ts @@ -72,7 +72,6 @@ export default class WaInput extends WebAwesomeFormAssociated { @state() private hasFocus = false; @property() title = ''; // make reactive to pass through - /** * The type of input. Works the same as a native `` element, but only a subset of types are supported. Defaults * to `text`. diff --git a/src/components/radio-button/radio-button.ts b/src/components/radio-button/radio-button.ts index 8f0a1cfb4..57cd3f9c7 100644 --- a/src/components/radio-button/radio-button.ts +++ b/src/components/radio-button/radio-button.ts @@ -8,7 +8,7 @@ import { watch } from '../../internal/watch.js'; import { WebAwesomeFormAssociated } from '../../internal/webawesome-element.js'; import componentStyles from '../../styles/component.styles.js'; import styles from './radio-button.styles.js'; -import type { CSSResultGroup, PropertyValues } from 'lit'; +import type { CSSResultGroup } from 'lit'; /** * @summary Radios buttons allow the user to select a single option from a group using a button-like control. @@ -95,12 +95,6 @@ export default class WaRadioButton extends WebAwesomeFormAssociated { this.emit('wa-focus'); } - // protected willUpdate(changedProperties: PropertyValues): void { - // if (this.disabled && changedProperties.has("checked")) { - // this.checked = Boolean(changedProperties.get("checked")) - // } - // } - @watch('disabled', { waitUntilFirstUpdate: true }) handleDisabledChange() { this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false'); diff --git a/src/internal/webawesome-element.ts b/src/internal/webawesome-element.ts index 60e62905e..3e27d193e 100644 --- a/src/internal/webawesome-element.ts +++ b/src/internal/webawesome-element.ts @@ -244,21 +244,19 @@ export class WebAwesomeFormAssociated } } - if ( - changedProperties.has('value') || - changedProperties.has("disabled") - ) { - + if (changedProperties.has('value') || changedProperties.has('disabled')) { // this is a hack because of how "disabled" attribute can be set by static HTML, but then changed via property, but we don't // want to use reflection because of a bug in "formDisabledCallback" - if (!this.disabled) { this.removeAttribute("disabled") } + if (!this.disabled) { + this.removeAttribute('disabled'); + } if (this.hasInteracted && this.value !== this.defaultValue) { this.valueHasChanged = true; } if (this.input) { - this.input.value = this.value + this.input.value = this.value; } const value = this.value;