diff --git a/packages/duoyun-ui/src/elements/area-chart.ts b/packages/duoyun-ui/src/elements/area-chart.ts index a4e12b4e..2698192a 100644 --- a/packages/duoyun-ui/src/elements/area-chart.ts +++ b/packages/duoyun-ui/src/elements/area-chart.ts @@ -16,14 +16,14 @@ export interface Sequence { values: (number | null)[][]; } -export interface SymbolRenderOption { +export interface SymbolRenderOptions { point: number[]; color: string; isHover: boolean; chart: DuoyunAreaChartElement; } -export function defaultSymbolRender({ point, color, isHover, chart }: SymbolRenderOption) { +export function defaultSymbolRender({ point, color, isHover, chart }: SymbolRenderOptions) { return svg` void }; export class DuoyunAvatarGroupElement extends GemElement { @numattribute max: number; + /**@deprecated */ @property data?: AvatarItem[]; + @property items?: AvatarItem[]; + + get #items() { + return this.items || this.data; + } get #max() { - return this.max || this.data?.length || 0; + return this.max || this.#items?.length || 0; } constructor() { @@ -179,10 +185,10 @@ export class DuoyunAvatarGroupElement extends GemElement { }; render = () => { - if (!this.data) return html``; - const rest = this.data.slice(this.#max); + if (!this.#items) return html``; + const rest = this.#items.slice(this.#max); return html` - ${this.data.slice(0, this.#max).map((avatar) => this.#renderAvatar(avatar))} + ${this.#items.slice(0, this.#max).map((avatar) => this.#renderAvatar(avatar))} ${rest.length ? html` e.alt).join()}> diff --git a/packages/duoyun-ui/src/elements/carousel.ts b/packages/duoyun-ui/src/elements/carousel.ts index b9102943..00fb460b 100644 --- a/packages/duoyun-ui/src/elements/carousel.ts +++ b/packages/duoyun-ui/src/elements/carousel.ts @@ -133,7 +133,7 @@ const style = createCSSSheet(css` } `); -export type Item = { +export type CarouselItem = { img: string; background?: string; onClick?: (evt: PointerEvent) => void; @@ -170,7 +170,13 @@ export class DuoyunCarouselElement extends GemElement { @numattribute interval: number; @emitter change: Emitter; - @property data?: Item[]; + /**@deprecated */ + @property data?: CarouselItem[]; + @property items?: CarouselItem[]; + + get #items() { + return this.items || this.data; + } get #interval() { return this.interval || 3000; @@ -186,7 +192,7 @@ export class DuoyunCarouselElement extends GemElement { }; #add = (direction: 1 | -1) => { - const total = this.data?.length; + const total = this.#items?.length; if (!total) return; this.setState({ currentIndex: (total + this.state.currentIndex + direction) % total, direction }); this.#reset(); @@ -206,11 +212,10 @@ export class DuoyunCarouselElement extends GemElement { }; #oMouseEnter = (evt: Event) => { - this.#waitLeave = new Promise( - (res) => - evt.target?.addEventListener('mouseleave', () => res(), { - once: true, - }), + this.#waitLeave = new Promise((res) => + evt.target?.addEventListener('mouseleave', () => res(), { + once: true, + }), ); }; @@ -241,7 +246,7 @@ export class DuoyunCarouselElement extends GemElement { const { currentIndex, direction } = this.state; return html`
    - ${this.data?.map( + ${this.#items?.map( ({ img, background = 'none', title, description, action, tag, onClick }, index) => html` ${currentIndex === index ? html` @@ -296,7 +301,7 @@ export class DuoyunCarouselElement extends GemElement { )}