diff --git a/docs/resources/changelog.md b/docs/resources/changelog.md index 8eca210cd..2c3346bf5 100644 --- a/docs/resources/changelog.md +++ b/docs/resources/changelog.md @@ -11,6 +11,7 @@ _During the beta period, these restrictions may be relaxed in the event of a mis ## Next - Improved RTL support for `` +- Refactored components to extend from `ShoelaceElement` to make `dir` and `lang` reactive properties in all components ## 2.0.0-beta.81 diff --git a/scripts/plop/templates/component/component.hbs b/scripts/plop/templates/component/component.hbs index d734f2270..401bfc2b6 100644 --- a/scripts/plop/templates/component/component.hbs +++ b/scripts/plop/templates/component/component.hbs @@ -1,7 +1,9 @@ -import { LitElement, html } from 'lit'; +import { html } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { emit } from '../../internal/event'; +import ShoelaceElement from '../../internal/shoelace-element'; import { watch } from '../../internal/watch'; +import { LocalizeController } from '../../utilities/localize'; import styles from './{{ tagWithoutPrefix tag }}.styles'; import type { CSSResultGroup } from 'lit'; @@ -21,9 +23,11 @@ import type { CSSResultGroup } from 'lit'; * @cssproperty --example - An example CSS custom property. */ @customElement('{{ tag }}') -export default class {{ properCase tag }} extends LitElement { +export default class {{ properCase tag }} extends ShoelaceElement { static styles: CSSResultGroup = styles; + private readonly localize = new LocalizeController(this); + /** An example property. */ @property() prop = 'example'; diff --git a/src/components/alert/alert.ts b/src/components/alert/alert.ts index dd007226b..19ffd414b 100644 --- a/src/components/alert/alert.ts +++ b/src/components/alert/alert.ts @@ -1,8 +1,9 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, query } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { animateTo, stopAnimations } from '../../internal/animate'; import { emit, waitForEvent } from '../../internal/event'; +import ShoelaceElement from '../../internal/shoelace-element'; import { HasSlotController } from '../../internal/slot'; import { watch } from '../../internal/watch'; import { getAnimation, setDefaultAnimation } from '../../utilities/animation-registry'; @@ -40,7 +41,7 @@ const toastStack = Object.assign(document.createElement('div'), { className: 'sl */ @customElement('sl-alert') -export default class SlAlert extends LitElement { +export default class SlAlert extends ShoelaceElement { static styles: CSSResultGroup = styles; private autoHideTimeout: number; diff --git a/src/components/animated-image/animated-image.ts b/src/components/animated-image/animated-image.ts index df3134de5..c556ce5f8 100644 --- a/src/components/animated-image/animated-image.ts +++ b/src/components/animated-image/animated-image.ts @@ -1,6 +1,7 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, query, state } from 'lit/decorators.js'; import { emit } from '../../internal/event'; +import ShoelaceElement from '../../internal/shoelace-element'; import { watch } from '../../internal/watch'; import '../icon/icon'; import styles from './animated-image.styles'; @@ -23,7 +24,7 @@ import type { CSSResultGroup } from 'lit'; * @cssproperty --icon-size - The size of the play/pause icons. */ @customElement('sl-animated-image') -export default class SlAnimatedImage extends LitElement { +export default class SlAnimatedImage extends ShoelaceElement { static styles: CSSResultGroup = styles; @state() frozenFrame: string; diff --git a/src/components/animation/animation.ts b/src/components/animation/animation.ts index 72a91aa71..497889938 100644 --- a/src/components/animation/animation.ts +++ b/src/components/animation/animation.ts @@ -1,6 +1,7 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, queryAsync } from 'lit/decorators.js'; import { emit } from '../../internal/event'; +import ShoelaceElement from '../../internal/shoelace-element'; import { watch } from '../../internal/watch'; import styles from './animation.styles'; import { animations } from './animations'; @@ -18,7 +19,7 @@ import type { CSSResultGroup } from 'lit'; * multiple animation elements. */ @customElement('sl-animation') -export default class SlAnimation extends LitElement { +export default class SlAnimation extends ShoelaceElement { static styles: CSSResultGroup = styles; private animation?: Animation; diff --git a/src/components/avatar/avatar.ts b/src/components/avatar/avatar.ts index 43f439714..56ebb6501 100644 --- a/src/components/avatar/avatar.ts +++ b/src/components/avatar/avatar.ts @@ -1,6 +1,7 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; +import ShoelaceElement from '../../internal/shoelace-element'; import { watch } from '../../internal/watch'; import '../icon/icon'; import styles from './avatar.styles'; @@ -22,7 +23,7 @@ import type { CSSResultGroup } from 'lit'; * @cssproperty --size - The size of the avatar. */ @customElement('sl-avatar') -export default class SlAvatar extends LitElement { +export default class SlAvatar extends ShoelaceElement { static styles: CSSResultGroup = styles; @state() private hasError = false; diff --git a/src/components/badge/badge.ts b/src/components/badge/badge.ts index 115a84892..3b7d522b2 100644 --- a/src/components/badge/badge.ts +++ b/src/components/badge/badge.ts @@ -1,6 +1,7 @@ -import { LitElement, html } from 'lit'; +import { html } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; +import ShoelaceElement from '../../internal/shoelace-element'; import styles from './badge.styles'; import type { CSSResultGroup } from 'lit'; @@ -13,7 +14,7 @@ import type { CSSResultGroup } from 'lit'; * @csspart base - The component's internal wrapper. */ @customElement('sl-badge') -export default class SlBadge extends LitElement { +export default class SlBadge extends ShoelaceElement { static styles: CSSResultGroup = styles; /** The badge's variant. */ diff --git a/src/components/breadcrumb-item/breadcrumb-item.ts b/src/components/breadcrumb-item/breadcrumb-item.ts index 5dbae30f8..e009a48ba 100644 --- a/src/components/breadcrumb-item/breadcrumb-item.ts +++ b/src/components/breadcrumb-item/breadcrumb-item.ts @@ -1,7 +1,8 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { ifDefined } from 'lit/directives/if-defined.js'; +import ShoelaceElement from '../../internal/shoelace-element'; import { HasSlotController } from '../../internal/slot'; import styles from './breadcrumb-item.styles'; import type { CSSResultGroup } from 'lit'; @@ -23,7 +24,7 @@ import type { CSSResultGroup } from 'lit'; * @csspart separator - The container that wraps the separator slot. */ @customElement('sl-breadcrumb-item') -export default class SlBreadcrumbItem extends LitElement { +export default class SlBreadcrumbItem extends ShoelaceElement { static styles: CSSResultGroup = styles; private readonly hasSlotController = new HasSlotController(this, 'prefix', 'suffix'); diff --git a/src/components/breadcrumb/breadcrumb.ts b/src/components/breadcrumb/breadcrumb.ts index 042a09c14..91e92fe29 100644 --- a/src/components/breadcrumb/breadcrumb.ts +++ b/src/components/breadcrumb/breadcrumb.ts @@ -1,5 +1,6 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, query } from 'lit/decorators.js'; +import ShoelaceElement from '../../internal/shoelace-element'; import { LocalizeController } from '../../utilities/localize'; import '../icon/icon'; import styles from './breadcrumb.styles'; @@ -18,7 +19,7 @@ import type { CSSResultGroup } from 'lit'; * @csspart base - The component's internal wrapper. */ @customElement('sl-breadcrumb') -export default class SlBreadcrumb extends LitElement { +export default class SlBreadcrumb extends ShoelaceElement { static styles: CSSResultGroup = styles; @query('slot') defaultSlot: HTMLSlotElement; diff --git a/src/components/button-group/button-group.ts b/src/components/button-group/button-group.ts index 250b529c5..2a9037b19 100644 --- a/src/components/button-group/button-group.ts +++ b/src/components/button-group/button-group.ts @@ -1,5 +1,6 @@ -import { LitElement, html } from 'lit'; +import { html } from 'lit'; import { customElement, property, query, state } from 'lit/decorators.js'; +import ShoelaceElement from '../../internal/shoelace-element'; import styles from './button-group.styles'; import type { CSSResultGroup } from 'lit'; @@ -12,7 +13,7 @@ import type { CSSResultGroup } from 'lit'; * @csspart base - The component's internal wrapper. */ @customElement('sl-button-group') -export default class SlButtonGroup extends LitElement { +export default class SlButtonGroup extends ShoelaceElement { static styles: CSSResultGroup = styles; @query('slot') defaultSlot: HTMLSlotElement; diff --git a/src/components/button/button.ts b/src/components/button/button.ts index 4bb2eed79..3c3baf377 100644 --- a/src/components/button/button.ts +++ b/src/components/button/button.ts @@ -1,10 +1,10 @@ -import { LitElement } from 'lit'; import { customElement, property, query, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { ifDefined } from 'lit/directives/if-defined.js'; import { html, literal } from 'lit/static-html.js'; import { emit } from '../../internal/event'; import { FormSubmitController } from '../../internal/form'; +import ShoelaceElement from '../../internal/shoelace-element'; import { HasSlotController } from '../../internal/slot'; import { LocalizeController } from '../../utilities/localize'; import '../spinner/spinner'; @@ -31,7 +31,7 @@ import type { CSSResultGroup } from 'lit'; * @csspart caret - The button's caret. */ @customElement('sl-button') -export default class SlButton extends LitElement { +export default class SlButton extends ShoelaceElement { static styles: CSSResultGroup = styles; @query('.button') button: HTMLButtonElement | HTMLLinkElement; diff --git a/src/components/card/card.ts b/src/components/card/card.ts index 24367e715..f9b76a326 100644 --- a/src/components/card/card.ts +++ b/src/components/card/card.ts @@ -1,6 +1,7 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; +import ShoelaceElement from '../../internal/shoelace-element'; import { HasSlotController } from '../../internal/slot'; import styles from './card.styles'; import type { CSSResultGroup } from 'lit'; @@ -26,7 +27,7 @@ import type { CSSResultGroup } from 'lit'; * @cssproperty --padding - The padding to use for card sections.* */ @customElement('sl-card') -export default class SlCard extends LitElement { +export default class SlCard extends ShoelaceElement { static styles: CSSResultGroup = styles; private readonly hasSlotController = new HasSlotController(this, 'footer', 'header', 'image'); diff --git a/src/components/checkbox/checkbox.ts b/src/components/checkbox/checkbox.ts index 75757f22c..bc30a3c5b 100644 --- a/src/components/checkbox/checkbox.ts +++ b/src/components/checkbox/checkbox.ts @@ -1,4 +1,4 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, query, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { ifDefined } from 'lit/directives/if-defined.js'; @@ -6,6 +6,7 @@ import { live } from 'lit/directives/live.js'; import { defaultValue } from '../../internal/default-value'; import { emit } from '../../internal/event'; import { FormSubmitController } from '../../internal/form'; +import ShoelaceElement from '../../internal/shoelace-element'; import { watch } from '../../internal/watch'; import styles from './checkbox.styles'; import type { CSSResultGroup } from 'lit'; @@ -27,7 +28,7 @@ import type { CSSResultGroup } from 'lit'; * @csspart label - The checkbox label. */ @customElement('sl-checkbox') -export default class SlCheckbox extends LitElement { +export default class SlCheckbox extends ShoelaceElement { static styles: CSSResultGroup = styles; @query('input[type="checkbox"]') input: HTMLInputElement; diff --git a/src/components/color-picker/color-picker.ts b/src/components/color-picker/color-picker.ts index 634ceeea3..2900e474c 100644 --- a/src/components/color-picker/color-picker.ts +++ b/src/components/color-picker/color-picker.ts @@ -1,5 +1,5 @@ import Color from 'color'; -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, query, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { ifDefined } from 'lit/directives/if-defined.js'; @@ -10,6 +10,7 @@ import { drag } from '../../internal/drag'; import { emit } from '../../internal/event'; import { FormSubmitController } from '../../internal/form'; import { clamp } from '../../internal/math'; +import ShoelaceElement from '../../internal/shoelace-element'; import { watch } from '../../internal/watch'; import { LocalizeController } from '../../utilities/localize'; import '../button-group/button-group'; @@ -82,7 +83,7 @@ declare const EyeDropper: EyeDropperConstructor; * @cssproperty --swatch-size - The size of each predefined color swatch. */ @customElement('sl-color-picker') -export default class SlColorPicker extends LitElement { +export default class SlColorPicker extends ShoelaceElement { static styles: CSSResultGroup = styles; @query('[part="input"]') input: SlInput; @@ -180,9 +181,6 @@ export default class SlColorPicker extends LitElement { '#fff' ]; - /** The locale to render the component in. */ - @property() lang: string; - connectedCallback() { super.connectedCallback(); diff --git a/src/components/details/details.ts b/src/components/details/details.ts index 8b6dc8595..b9cb61557 100644 --- a/src/components/details/details.ts +++ b/src/components/details/details.ts @@ -1,8 +1,9 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, query } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { animateTo, shimKeyframesHeightAuto, stopAnimations } from '../../internal/animate'; import { emit, waitForEvent } from '../../internal/event'; +import ShoelaceElement from '../../internal/shoelace-element'; import { watch } from '../../internal/watch'; import { getAnimation, setDefaultAnimation } from '../../utilities/animation-registry'; import { LocalizeController } from '../../utilities/localize'; @@ -34,7 +35,7 @@ import type { CSSResultGroup } from 'lit'; * @animation details.hide - The animation to use when hiding details. You can use `height: auto` with this animation. */ @customElement('sl-details') -export default class SlDetails extends LitElement { +export default class SlDetails extends ShoelaceElement { static styles: CSSResultGroup = styles; @query('.details') details: HTMLElement; diff --git a/src/components/dialog/dialog.ts b/src/components/dialog/dialog.ts index 26e43470b..9dcdbd71b 100644 --- a/src/components/dialog/dialog.ts +++ b/src/components/dialog/dialog.ts @@ -1,4 +1,4 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, query } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { ifDefined } from 'lit/directives/if-defined.js'; @@ -6,6 +6,7 @@ import { animateTo, stopAnimations } from '../../internal/animate'; import { emit, waitForEvent } from '../../internal/event'; import Modal from '../../internal/modal'; import { lockBodyScrolling, unlockBodyScrolling } from '../../internal/scroll'; +import ShoelaceElement from '../../internal/shoelace-element'; import { HasSlotController } from '../../internal/slot'; import { watch } from '../../internal/watch'; import { getAnimation, setDefaultAnimation } from '../../utilities/animation-registry'; @@ -57,7 +58,7 @@ import type { CSSResultGroup } from 'lit'; * @animation dialog.overlay.hide - The animation to use when hiding the dialog's overlay. */ @customElement('sl-dialog') -export default class SlDialog extends LitElement { +export default class SlDialog extends ShoelaceElement { static styles: CSSResultGroup = styles; @query('.dialog') dialog: HTMLElement; diff --git a/src/components/divider/divider.ts b/src/components/divider/divider.ts index f7e7729e3..e64475dfc 100644 --- a/src/components/divider/divider.ts +++ b/src/components/divider/divider.ts @@ -1,5 +1,5 @@ -import { LitElement } from 'lit'; import { customElement, property } from 'lit/decorators.js'; +import ShoelaceElement from '../../internal/shoelace-element'; import { watch } from '../../internal/watch'; import styles from './divider.styles'; import type { CSSResultGroup } from 'lit'; @@ -13,7 +13,7 @@ import type { CSSResultGroup } from 'lit'; * @cssproperty --spacing - The spacing of the divider. */ @customElement('sl-divider') -export default class SlDivider extends LitElement { +export default class SlDivider extends ShoelaceElement { static styles: CSSResultGroup = styles; /** Draws the divider in a vertical orientation. */ diff --git a/src/components/drawer/drawer.ts b/src/components/drawer/drawer.ts index fa3bb7c74..f4d555d06 100644 --- a/src/components/drawer/drawer.ts +++ b/src/components/drawer/drawer.ts @@ -1,4 +1,4 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, query } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { ifDefined } from 'lit/directives/if-defined.js'; @@ -6,6 +6,7 @@ import { animateTo, stopAnimations } from '../../internal/animate'; import { emit, waitForEvent } from '../../internal/event'; import Modal from '../../internal/modal'; import { lockBodyScrolling, unlockBodyScrolling } from '../../internal/scroll'; +import ShoelaceElement from '../../internal/shoelace-element'; import { HasSlotController } from '../../internal/slot'; import { uppercaseFirstLetter } from '../../internal/string'; import { watch } from '../../internal/watch'; @@ -65,7 +66,7 @@ import type { CSSResultGroup } from 'lit'; * @animation drawer.overlay.hide - The animation to use when hiding the drawer's overlay. */ @customElement('sl-drawer') -export default class SlDrawer extends LitElement { +export default class SlDrawer extends ShoelaceElement { static styles: CSSResultGroup = styles; @query('.drawer') drawer: HTMLElement; @@ -247,8 +248,8 @@ export default class SlDrawer extends LitElement { } } + /* eslint-disable lit-a11y/click-events-have-key-events */ render() { - /* eslint-disable lit-a11y/click-events-have-key-events */ return html`
) { super.updated(changedProps); diff --git a/src/components/qr-code/qr-code.ts b/src/components/qr-code/qr-code.ts index cdd644aca..70486f46e 100644 --- a/src/components/qr-code/qr-code.ts +++ b/src/components/qr-code/qr-code.ts @@ -1,7 +1,8 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, query } from 'lit/decorators.js'; import { styleMap } from 'lit/directives/style-map.js'; import QrCreator from 'qr-creator'; +import ShoelaceElement from '../../internal/shoelace-element'; import { watch } from '../../internal/watch'; import styles from './qr-code.styles'; import type { CSSResultGroup } from 'lit'; @@ -13,7 +14,7 @@ import type { CSSResultGroup } from 'lit'; * @csspart base - The component's internal wrapper. */ @customElement('sl-qr-code') -export default class SlQrCode extends LitElement { +export default class SlQrCode extends ShoelaceElement { static styles: CSSResultGroup = styles; @query('canvas') canvas: HTMLElement; diff --git a/src/components/radio-button/radio-button.ts b/src/components/radio-button/radio-button.ts index 42393bc91..d30af6c2a 100644 --- a/src/components/radio-button/radio-button.ts +++ b/src/components/radio-button/radio-button.ts @@ -1,9 +1,9 @@ -import { LitElement } from 'lit'; import { customElement, property, query, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { ifDefined } from 'lit/directives/if-defined.js'; import { html } from 'lit/static-html.js'; import { emit } from '../../internal/event'; +import ShoelaceElement from '../../internal/shoelace-element'; import { HasSlotController } from '../../internal/slot'; import { watch } from '../../internal/watch'; import styles from './radio-button.styles'; @@ -27,7 +27,7 @@ import type { CSSResultGroup } from 'lit'; * @csspart suffix - The suffix slot's container. */ @customElement('sl-radio-button') -export default class SlRadioButton extends LitElement { +export default class SlRadioButton extends ShoelaceElement { static styles: CSSResultGroup = styles; @query('.button') input: HTMLInputElement; diff --git a/src/components/radio-group/radio-group.ts b/src/components/radio-group/radio-group.ts index b70dcf826..da7b0941a 100644 --- a/src/components/radio-group/radio-group.ts +++ b/src/components/radio-group/radio-group.ts @@ -1,9 +1,10 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, query, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { emit } from 'src/internal/event'; import { FormSubmitController } from 'src/internal/form'; import { watch } from 'src/internal/watch'; +import ShoelaceElement from '../../internal/shoelace-element'; import '../button-group/button-group'; import styles from './radio-group.styles'; import type SlRadioButton from '../radio-button/radio-button'; @@ -27,7 +28,7 @@ import type { CSSResultGroup } from 'lit'; * @csspart button-group__base - The button group's `base` part. */ @customElement('sl-radio-group') -export default class SlRadioGroup extends LitElement { +export default class SlRadioGroup extends ShoelaceElement { static styles: CSSResultGroup = styles; protected readonly formSubmitController = new FormSubmitController(this, { diff --git a/src/components/radio/radio.ts b/src/components/radio/radio.ts index 91dbda0d0..770795775 100644 --- a/src/components/radio/radio.ts +++ b/src/components/radio/radio.ts @@ -1,7 +1,8 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { emit } from 'src/internal/event'; +import ShoelaceElement from '../../internal/shoelace-element'; import { watch } from '../../internal/watch'; import styles from './radio.styles'; import type { CSSResultGroup } from 'lit'; @@ -21,7 +22,7 @@ import type { CSSResultGroup } from 'lit'; * @csspart label - The radio label. */ @customElement('sl-radio') -export default class SlRadio extends LitElement { +export default class SlRadio extends ShoelaceElement { static styles: CSSResultGroup = styles; @state() checked = false; diff --git a/src/components/range/range.ts b/src/components/range/range.ts index 4830fe1d3..b10c01e13 100644 --- a/src/components/range/range.ts +++ b/src/components/range/range.ts @@ -1,4 +1,4 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, query, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { ifDefined } from 'lit/directives/if-defined.js'; @@ -6,6 +6,7 @@ import { live } from 'lit/directives/live.js'; import { defaultValue } from '../../internal/default-value'; import { emit } from '../../internal/event'; import { FormSubmitController } from '../../internal/form'; +import ShoelaceElement from '../../internal/shoelace-element'; import { HasSlotController } from '../../internal/slot'; import { watch } from '../../internal/watch'; import { LocalizeController } from '../../utilities/localize'; @@ -39,7 +40,7 @@ import type { CSSResultGroup } from 'lit'; * @cssproperty --track-active-offset - The point of origin of the active track. */ @customElement('sl-range') -export default class SlRange extends LitElement { +export default class SlRange extends ShoelaceElement { static styles: CSSResultGroup = styles; @query('.range__control') input: HTMLInputElement; diff --git a/src/components/rating/rating.ts b/src/components/rating/rating.ts index b7bb9dcde..a89765ffb 100644 --- a/src/components/rating/rating.ts +++ b/src/components/rating/rating.ts @@ -1,10 +1,11 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, query, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { styleMap } from 'lit/directives/style-map.js'; import { unsafeHTML } from 'lit/directives/unsafe-html.js'; import { emit } from '../../internal/event'; import { clamp } from '../../internal/math'; +import ShoelaceElement from '../../internal/shoelace-element'; import { watch } from '../../internal/watch'; import { LocalizeController } from '../../utilities/localize'; import '../icon/icon'; @@ -27,7 +28,7 @@ import type { CSSResultGroup } from 'lit'; * @cssproperty --symbol-spacing - The spacing to use around symbols. */ @customElement('sl-rating') -export default class SlRating extends LitElement { +export default class SlRating extends ShoelaceElement { static styles: CSSResultGroup = styles; @query('.rating') rating: HTMLElement; diff --git a/src/components/relative-time/relative-time.ts b/src/components/relative-time/relative-time.ts index f07706056..ceec129c3 100644 --- a/src/components/relative-time/relative-time.ts +++ b/src/components/relative-time/relative-time.ts @@ -1,5 +1,6 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; +import ShoelaceElement from '../../internal/shoelace-element'; import { LocalizeController } from '../../utilities/localize'; interface UnitConfig { @@ -22,7 +23,7 @@ const availableUnits: UnitConfig[] = [ * @status stable */ @customElement('sl-relative-time') -export default class SlRelativeTime extends LitElement { +export default class SlRelativeTime extends ShoelaceElement { private readonly localize = new LocalizeController(this); private updateTimeout: number; @@ -33,9 +34,6 @@ export default class SlRelativeTime extends LitElement { /** The date from which to calculate time from. */ @property() date: Date | string; - /** The locale to use when formatting the number. */ - @property() lang: string; - /** The formatting style to use. */ @property() format: 'long' | 'short' | 'narrow' = 'long'; diff --git a/src/components/resize-observer/resize-observer.ts b/src/components/resize-observer/resize-observer.ts index 2076456f3..c8c839197 100644 --- a/src/components/resize-observer/resize-observer.ts +++ b/src/components/resize-observer/resize-observer.ts @@ -1,6 +1,7 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { emit } from '../../internal/event'; +import ShoelaceElement from '../../internal/shoelace-element'; import { watch } from '../../internal/watch'; import styles from './resize-observer.styles'; import type { CSSResultGroup } from 'lit'; @@ -14,7 +15,7 @@ import type { CSSResultGroup } from 'lit'; * @event {{ entries: ResizeObserverEntry[] }} sl-resize - Emitted when the element is resized. */ @customElement('sl-resize-observer') -export default class SlResizeObserver extends LitElement { +export default class SlResizeObserver extends ShoelaceElement { static styles: CSSResultGroup = styles; private resizeObserver: ResizeObserver; diff --git a/src/components/responsive-media/responsive-media.ts b/src/components/responsive-media/responsive-media.ts index 26b500928..7727b9a3f 100644 --- a/src/components/responsive-media/responsive-media.ts +++ b/src/components/responsive-media/responsive-media.ts @@ -1,6 +1,7 @@ -import { LitElement, html } from 'lit'; +import { html } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; +import ShoelaceElement from '../../internal/shoelace-element'; import styles from './responsive-media.styles'; import type { CSSResultGroup } from 'lit'; @@ -11,7 +12,7 @@ import type { CSSResultGroup } from 'lit'; * @slot - The element to receive the aspect ratio. Should be a replaced element, such as ``, `