From 32f24a881e546c553df39d2b92346664b59cdd39 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Wed, 17 Aug 2022 11:37:37 -0400 Subject: [PATCH] make dir/lang reactive everywhere --- docs/resources/changelog.md | 1 + scripts/plop/templates/component/component.hbs | 8 ++++++-- src/components/alert/alert.ts | 5 +++-- src/components/animated-image/animated-image.ts | 5 +++-- src/components/animation/animation.ts | 5 +++-- src/components/avatar/avatar.ts | 5 +++-- src/components/badge/badge.ts | 5 +++-- src/components/breadcrumb-item/breadcrumb-item.ts | 5 +++-- src/components/breadcrumb/breadcrumb.ts | 5 +++-- src/components/button-group/button-group.ts | 5 +++-- src/components/button/button.ts | 4 ++-- src/components/card/card.ts | 5 +++-- src/components/checkbox/checkbox.ts | 5 +++-- src/components/color-picker/color-picker.ts | 8 +++----- src/components/details/details.ts | 5 +++-- src/components/dialog/dialog.ts | 5 +++-- src/components/divider/divider.ts | 4 ++-- src/components/drawer/drawer.ts | 7 ++++--- src/components/dropdown/dropdown.ts | 5 +++-- src/components/format-bytes/format-bytes.ts | 7 ++----- src/components/format-date/format-date.ts | 8 +++----- src/components/format-number/format-number.ts | 7 ++----- src/components/icon-button/icon-button.ts | 4 ++-- src/components/icon/icon.ts | 5 +++-- src/components/image-comparer/image-comparer.ts | 5 +++-- src/components/include/include.ts | 5 +++-- src/components/input/input.ts | 5 +++-- src/components/menu-item/menu-item.ts | 5 +++-- src/components/menu-label/menu-label.ts | 5 +++-- src/components/menu/menu.ts | 5 +++-- src/components/mutation-observer/mutation-observer.ts | 5 +++-- src/components/popup/popup.ts | 5 +++-- src/components/progress-bar/progress-bar.ts | 8 +++----- src/components/progress-ring/progress-ring.ts | 8 +++----- src/components/qr-code/qr-code.ts | 5 +++-- src/components/radio-button/radio-button.ts | 4 ++-- src/components/radio-group/radio-group.ts | 5 +++-- src/components/radio/radio.ts | 5 +++-- src/components/range/range.ts | 5 +++-- src/components/rating/rating.ts | 5 +++-- src/components/relative-time/relative-time.ts | 8 +++----- src/components/resize-observer/resize-observer.ts | 5 +++-- src/components/responsive-media/responsive-media.ts | 5 +++-- src/components/select/select.ts | 5 +++-- src/components/skeleton/skeleton.ts | 5 +++-- src/components/spinner/spinner.ts | 5 +++-- src/components/split-panel/split-panel.ts | 5 +++-- src/components/switch/switch.ts | 5 +++-- src/components/tab-group/tab-group.ts | 8 +++----- src/components/tab-panel/tab-panel.ts | 5 +++-- src/components/tab/tab.ts | 8 +++----- src/components/tag/tag.ts | 5 +++-- src/components/textarea/textarea.ts | 8 ++++---- src/components/tooltip/tooltip.ts | 5 +++-- src/components/tree-item/tree-item.ts | 5 +++-- src/components/tree/tree.ts | 5 +++-- src/components/visually-hidden/visually-hidden.ts | 5 +++-- src/internal/shoelace-element.ts | 8 ++++++++ 58 files changed, 176 insertions(+), 142 deletions(-) create mode 100644 src/internal/shoelace-element.ts diff --git a/docs/resources/changelog.md b/docs/resources/changelog.md index 8eca210c..2c3346bf 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 d734f227..401bfc2b 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 dd007226..19ffd414 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 df3134de..c556ce5f 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 72a91aa7..49788993 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 43f43971..56ebb650 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 115a8489..3b7d522b 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 5dbae30f..e009a48b 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 042a09c1..91e92fe2 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 250b529c..2a9037b1 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 4bb2eed7..3c3baf37 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 24367e71..f9b76a32 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 75757f22..bc30a3c5 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 634ceeea..2900e474 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 8b6dc859..b9cb6155 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 26e43470..9dcdbd71 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 f7e7729e..e64475df 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 fa3bb7c7..f4d555d0 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 cdd644ac..70486f46 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 42393bc9..d30af6c2 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 b70dcf82..da7b0941 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 91dbda0d..77079577 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 4830fe1d..b10c01e1 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 b7bb9dcd..a89765ff 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 f0770605..ceec129c 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 2076456f..c8c83919 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 26b50092..7727b9a3 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 ``, `