chore: type enhancements SlotMixin, LocalizeMixin, SelectRichInvoker
This commit is contained in:
parent
51732b0e4f
commit
20ba0ca8c0
5 changed files with 25 additions and 8 deletions
11
.changeset/large-walls-dance.md
Normal file
11
.changeset/large-walls-dance.md
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
'@lion/core': patch
|
||||||
|
'@lion/localize': patch
|
||||||
|
'@lion/select-rich': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Type enhancements
|
||||||
|
|
||||||
|
- LocalizeMixinTypes.d.ts extend from LitElement
|
||||||
|
- Make `slots` a getter in SlotMixin types
|
||||||
|
- selectedElement of type 'LionOption' in SelectRichInvoker
|
||||||
2
packages/core/types/SlotMixinTypes.d.ts
vendored
2
packages/core/types/SlotMixinTypes.d.ts
vendored
|
|
@ -10,7 +10,7 @@ export declare class SlotHost {
|
||||||
/**
|
/**
|
||||||
* Obtains all the slots to create
|
* Obtains all the slots to create
|
||||||
*/
|
*/
|
||||||
slots: SlotsMap;
|
get slots(): SlotsMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the creation of slots
|
* Starts the creation of slots
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { Constructor } from '@open-wc/dedupe-mixin';
|
import { Constructor } from '@open-wc/dedupe-mixin';
|
||||||
|
import { LitElement } from '@lion/core';
|
||||||
|
|
||||||
export interface FormatNumberPart {
|
export interface FormatNumberPart {
|
||||||
type: string;
|
type: string;
|
||||||
|
|
@ -68,7 +69,7 @@ declare class LocalizeMixinHost {
|
||||||
private __localizeOnLocaleChanged(event: CustomEvent): void;
|
private __localizeOnLocaleChanged(event: CustomEvent): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare function LocalizeMixinImplementation<T extends Constructor<HTMLElement>>(
|
declare function LocalizeMixinImplementation<T extends Constructor<LitElement>>(
|
||||||
superclass: T,
|
superclass: T,
|
||||||
): T & Constructor<LocalizeMixinHost> & typeof LocalizeMixinHost;
|
): T & Constructor<LocalizeMixinHost> & typeof LocalizeMixinHost;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { css, html } from '@lion/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import('@lion/core').CSSResult} CSSResult
|
* @typedef {import('@lion/core').CSSResult} CSSResult
|
||||||
|
* @typedef {import('@lion/listbox').LionOption} LionOption
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -66,8 +67,8 @@ export class LionSelectInvoker extends LionButton {
|
||||||
*/
|
*/
|
||||||
this.readOnly = false;
|
this.readOnly = false;
|
||||||
/**
|
/**
|
||||||
* The option Element that is currently selected
|
* The option element that is currently selected
|
||||||
* @type {HTMLElement | null}
|
* @type {LionOption | null}
|
||||||
*/
|
*/
|
||||||
this.selectedElement = null;
|
this.selectedElement = null;
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@ import { defineCE, expect, fixture, html } from '@open-wc/testing';
|
||||||
import '../lion-select-invoker.js';
|
import '../lion-select-invoker.js';
|
||||||
import { LionSelectInvoker } from '../src/LionSelectInvoker.js';
|
import { LionSelectInvoker } from '../src/LionSelectInvoker.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import('@lion/listbox').LionOption} LionOption
|
||||||
|
*/
|
||||||
|
|
||||||
describe('lion-select-invoker', () => {
|
describe('lion-select-invoker', () => {
|
||||||
it('should behave as a button', async () => {
|
it('should behave as a button', async () => {
|
||||||
const el = await fixture(html`<lion-select-invoker></lion-select-invoker>`);
|
const el = await fixture(html`<lion-select-invoker></lion-select-invoker>`);
|
||||||
|
|
@ -13,7 +17,7 @@ describe('lion-select-invoker', () => {
|
||||||
const el = /** @type {LionSelectInvoker} */ (await fixture(
|
const el = /** @type {LionSelectInvoker} */ (await fixture(
|
||||||
html`<lion-select-invoker></lion-select-invoker>`,
|
html`<lion-select-invoker></lion-select-invoker>`,
|
||||||
));
|
));
|
||||||
el.selectedElement = /** @type {HTMLElement} */ (await fixture(
|
el.selectedElement = /** @type {LionOption} */ (await fixture(
|
||||||
`<div class="option">Textnode<h2>I am</h2><p>2 lines</p></div>`,
|
`<div class="option">Textnode<h2>I am</h2><p>2 lines</p></div>`,
|
||||||
));
|
));
|
||||||
await el.updateComplete;
|
await el.updateComplete;
|
||||||
|
|
@ -34,7 +38,7 @@ describe('lion-select-invoker', () => {
|
||||||
const el = /** @type {LionSelectInvoker} */ (await fixture(
|
const el = /** @type {LionSelectInvoker} */ (await fixture(
|
||||||
html`<lion-select-invoker></lion-select-invoker>`,
|
html`<lion-select-invoker></lion-select-invoker>`,
|
||||||
));
|
));
|
||||||
el.selectedElement = /** @type {HTMLElement} */ (await fixture(
|
el.selectedElement = /** @type {LionOption} */ (await fixture(
|
||||||
`<div class="option">just textContent</div>`,
|
`<div class="option">just textContent</div>`,
|
||||||
));
|
));
|
||||||
await el.updateComplete;
|
await el.updateComplete;
|
||||||
|
|
@ -81,13 +85,13 @@ describe('lion-select-invoker', () => {
|
||||||
);
|
);
|
||||||
const el = /** @type {LionSelectInvoker} */ (await fixture(`<${myTag}></${myTag}>`));
|
const el = /** @type {LionSelectInvoker} */ (await fixture(`<${myTag}></${myTag}>`));
|
||||||
|
|
||||||
el.selectedElement = /** @type {HTMLElement} */ (await fixture(
|
el.selectedElement = /** @type {LionOption} */ (await fixture(
|
||||||
`<div class="option">cat</div>`,
|
`<div class="option">cat</div>`,
|
||||||
));
|
));
|
||||||
await el.updateComplete;
|
await el.updateComplete;
|
||||||
expect(el._contentWrapperNode).lightDom.to.equal('cat selected');
|
expect(el._contentWrapperNode).lightDom.to.equal('cat selected');
|
||||||
|
|
||||||
el.selectedElement = /** @type {HTMLElement} */ (await fixture(
|
el.selectedElement = /** @type {LionOption} */ (await fixture(
|
||||||
`<div class="option">dog</div>`,
|
`<div class="option">dog</div>`,
|
||||||
));
|
));
|
||||||
await el.updateComplete;
|
await el.updateComplete;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue