From 4d9351c0f4a1c3238a044e5d12ee9ddf1be02e7e Mon Sep 17 00:00:00 2001 From: mantou132 <709922234@qq.com> Date: Mon, 8 Jul 2024 02:35:19 +0800 Subject: [PATCH] [gem] Use decorator metadata Closed #156 --- package.json | 4 +- packages/duoyun-ui/package.json | 2 +- .../duoyun-ui/src/elements/action-text.ts | 7 +- packages/duoyun-ui/src/elements/alert.ts | 8 +- packages/duoyun-ui/src/elements/area-chart.ts | 2 +- packages/duoyun-ui/src/elements/avatar.ts | 7 +- packages/duoyun-ui/src/elements/banner.ts | 9 +- packages/duoyun-ui/src/elements/base/chart.ts | 10 +- .../duoyun-ui/src/elements/base/loadable.ts | 6 +- .../duoyun-ui/src/elements/base/resize.ts | 9 +- .../duoyun-ui/src/elements/base/visible.ts | 6 +- .../duoyun-ui/src/elements/base/wake-lock.ts | 5 +- .../duoyun-ui/src/elements/breadcrumbs.ts | 8 +- packages/duoyun-ui/src/elements/button.ts | 4 +- packages/duoyun-ui/src/elements/calendar.ts | 4 +- packages/duoyun-ui/src/elements/card.ts | 9 +- packages/duoyun-ui/src/elements/carousel.ts | 6 +- .../duoyun-ui/src/elements/cascader-picker.ts | 9 +- packages/duoyun-ui/src/elements/chart-zoom.ts | 1 + packages/duoyun-ui/src/elements/checkbox.ts | 12 +- packages/duoyun-ui/src/elements/collapse.ts | 15 +- .../duoyun-ui/src/elements/color-panel.ts | 7 +- .../duoyun-ui/src/elements/color-picker.ts | 6 +- .../duoyun-ui/src/elements/contextmenu.ts | 7 +- packages/duoyun-ui/src/elements/copy.ts | 6 +- packages/duoyun-ui/src/elements/date-panel.ts | 9 +- .../duoyun-ui/src/elements/date-picker.ts | 7 +- .../src/elements/date-range-panel.ts | 8 +- .../src/elements/date-range-picker.ts | 7 +- packages/duoyun-ui/src/elements/divider.ts | 4 +- packages/duoyun-ui/src/elements/drop-area.ts | 3 +- .../duoyun-ui/src/elements/file-picker.ts | 6 +- packages/duoyun-ui/src/elements/form.ts | 14 +- .../duoyun-ui/src/elements/image-preview.ts | 7 +- packages/duoyun-ui/src/elements/input.ts | 16 +- packages/duoyun-ui/src/elements/legend.ts | 4 +- packages/duoyun-ui/src/elements/list.ts | 14 +- packages/duoyun-ui/src/elements/map.ts | 8 +- packages/duoyun-ui/src/elements/meter.ts | 4 +- packages/duoyun-ui/src/elements/modal.ts | 4 +- packages/duoyun-ui/src/elements/more.ts | 9 +- packages/duoyun-ui/src/elements/options.ts | 17 +- .../duoyun-ui/src/elements/page-loadbar.ts | 8 +- packages/duoyun-ui/src/elements/pagination.ts | 10 +- packages/duoyun-ui/src/elements/paragraph.ts | 9 +- packages/duoyun-ui/src/elements/picker.ts | 7 +- .../duoyun-ui/src/elements/placeholder.ts | 17 +- packages/duoyun-ui/src/elements/popover.ts | 4 +- packages/duoyun-ui/src/elements/progress.ts | 4 +- packages/duoyun-ui/src/elements/radio.ts | 12 +- packages/duoyun-ui/src/elements/rate.ts | 7 +- packages/duoyun-ui/src/elements/segmented.ts | 9 +- packages/duoyun-ui/src/elements/select.ts | 4 +- .../duoyun-ui/src/elements/shortcut-record.ts | 7 +- .../duoyun-ui/src/elements/side-navigation.ts | 19 +- packages/duoyun-ui/src/elements/slider.ts | 7 +- packages/duoyun-ui/src/elements/space.ts | 7 +- packages/duoyun-ui/src/elements/statistic.ts | 7 +- .../duoyun-ui/src/elements/status-light.ts | 8 +- packages/duoyun-ui/src/elements/switch.ts | 4 +- packages/duoyun-ui/src/elements/table.ts | 6 +- packages/duoyun-ui/src/elements/tabs.ts | 11 +- packages/duoyun-ui/src/elements/tag.ts | 9 +- packages/duoyun-ui/src/elements/time-panel.ts | 6 +- .../duoyun-ui/src/elements/time-picker.ts | 7 +- packages/duoyun-ui/src/elements/timeline.ts | 8 +- packages/duoyun-ui/src/elements/toast.ts | 5 +- packages/duoyun-ui/src/elements/tree.ts | 17 +- packages/duoyun-ui/src/elements/wait.ts | 5 +- packages/duoyun-ui/src/lib/element.ts | 4 +- packages/duoyun-ui/src/patterns/console.ts | 7 +- packages/duoyun-ui/src/patterns/footer.ts | 7 +- packages/duoyun-ui/src/patterns/nav.ts | 13 +- packages/gem-analyzer/package.json | 2 +- packages/gem-book/package.json | 2 +- .../gem-book/src/element/elements/loadbar.ts | 10 +- packages/gem-book/src/plugins/api.ts | 5 +- packages/gem-book/src/plugins/include.ts | 5 +- packages/gem-book/src/plugins/trans-status.ts | 7 +- packages/gem-devtools/src/scripts/get-gem.ts | 37 +-- packages/gem-devtools/src/scripts/preload.ts | 2 +- packages/gem-examples/src/async/index.ts | 16 +- packages/gem-examples/src/homepage/index.ts | 7 +- packages/gem-examples/src/light-dom/index.ts | 5 +- packages/gem-examples/src/perf-demo/index.ts | 5 +- packages/gem-examples/src/scope/index.ts | 6 +- packages/gem-port/package.json | 2 +- .../gem/docs/en/003-api/001-gem-element.md | 12 +- packages/gem/docs/en/003-api/007-decorator.md | 6 + .../004-blog/001-create-standard-element.md | 20 +- .../gem/docs/zh/003-api/001-gem-element.md | 12 +- packages/gem/docs/zh/003-api/007-decorator.md | 6 + .../004-blog/001-create-standard-element.md | 20 +- packages/gem/package.json | 2 +- packages/gem/src/elements/base/dialog.ts | 15 +- packages/gem/src/elements/base/link.ts | 5 +- .../gem/src/elements/base/modal-factory.ts | 9 +- packages/gem/src/elements/base/reflect.ts | 5 +- packages/gem/src/elements/base/route.ts | 14 +- packages/gem/src/helper/i18n.ts | 4 +- packages/gem/src/lib/decorators.ts | 148 +++++---- packages/gem/src/lib/element.ts | 122 ++++---- packages/gem/src/lib/utils.ts | 1 - .../gem/src/test/gem-element/advance.test.ts | 15 +- .../src/test/gem-element/decorators.test.ts | 23 +- yarn.lock | 296 +++++++++--------- 106 files changed, 701 insertions(+), 710 deletions(-) diff --git a/package.json b/package.json index 5fdce33d..06491751 100644 --- a/package.json +++ b/package.json @@ -26,10 +26,10 @@ "lerna": "^8.0.0", "lint-staged": "^15.1.0", "prettier": "^3.1.0", - "typescript": "^5.4.3" + "typescript": "^5.5.3" }, "resolutions": { - "**/esbuild": "^0.21.2" + "**/esbuild": "^0.23.0" }, "lint-staged": { "*.ts": "eslint --fix" diff --git a/packages/duoyun-ui/package.json b/packages/duoyun-ui/package.json index fc4dd3ed..d7349ba2 100644 --- a/packages/duoyun-ui/package.json +++ b/packages/duoyun-ui/package.json @@ -62,7 +62,7 @@ "@web/dev-server-esbuild": "^1.0.2", "@web/test-runner": "^0.18.1", "rimraf": "^3.0.2", - "typescript": "^5.4.3", + "typescript": "^5.5.3", "webpack-merge": "^5.7.3" }, "author": "mantou132", diff --git a/packages/duoyun-ui/src/elements/action-text.ts b/packages/duoyun-ui/src/elements/action-text.ts index 473dbfc7..6d2813ef 100644 --- a/packages/duoyun-ui/src/elements/action-text.ts +++ b/packages/duoyun-ui/src/elements/action-text.ts @@ -1,5 +1,5 @@ import { GemElement, html } from '@mantou/gem/lib/element'; -import { adoptedStyle, customElement, attribute, state, slot } from '@mantou/gem/lib/decorators'; +import { adoptedStyle, customElement, attribute, state, slot, focusable, aria } from '@mantou/gem/lib/decorators'; import { createCSSSheet, css } from '@mantou/gem/lib/utils'; import { theme, getSemanticColor } from '../lib/theme'; @@ -34,6 +34,8 @@ const style = createCSSSheet(css` @customElement('dy-action-text') @adoptedStyle(style) @adoptedStyle(focusStyle) +@focusable() +@aria({ role: 'button' }) export class DuoyunActionTextElement extends GemElement { @slot static unnamed: string; @@ -42,8 +44,7 @@ export class DuoyunActionTextElement extends GemElement { @state active: boolean; constructor() { - super({ focusable: true }); - this.internals.role = 'button'; + super(); this.addEventListener('keydown', commonHandle); } diff --git a/packages/duoyun-ui/src/elements/alert.ts b/packages/duoyun-ui/src/elements/alert.ts index 2b953c99..5bb84298 100644 --- a/packages/duoyun-ui/src/elements/alert.ts +++ b/packages/duoyun-ui/src/elements/alert.ts @@ -1,5 +1,5 @@ // https://spectrum.adobe.com/page/in-line-alert/ -import { adoptedStyle, customElement, attribute, property, slot } from '@mantou/gem/lib/decorators'; +import { adoptedStyle, customElement, attribute, property, slot, aria } from '@mantou/gem/lib/decorators'; import { GemElement, html } from '@mantou/gem/lib/element'; import { createCSSSheet, css } from '@mantou/gem/lib/utils'; @@ -49,6 +49,7 @@ type Status = 'positive' | 'notice' | 'negative' | 'informative' | 'default'; */ @customElement('dy-alert') @adoptedStyle(style) +@aria({ role: 'alert' }) export class DuoyunAlertElement extends GemElement { @slot static unnamed: string; @@ -74,11 +75,6 @@ export class DuoyunAlertElement extends GemElement { return getSemanticColor(this.status) || theme.neutralColor; } - constructor() { - super(); - this.internals.role = 'alert'; - } - render = () => { const icon = this.#icon; return html` diff --git a/packages/duoyun-ui/src/elements/area-chart.ts b/packages/duoyun-ui/src/elements/area-chart.ts index 7feadf33..cc916dd4 100644 --- a/packages/duoyun-ui/src/elements/area-chart.ts +++ b/packages/duoyun-ui/src/elements/area-chart.ts @@ -80,7 +80,7 @@ export class DuoyunAreaChartElement extends DuoyunChartBaseElement { } constructor() { - super({ isLight: false }); + super(); this.addEventListener('pointermove', this.#onPointerMove); this.addEventListener('pointerout', this.#onPointerOut); this.addEventListener('pointercancel', this.#onPointerOut); diff --git a/packages/duoyun-ui/src/elements/avatar.ts b/packages/duoyun-ui/src/elements/avatar.ts index 0a14ca0c..00f1197d 100644 --- a/packages/duoyun-ui/src/elements/avatar.ts +++ b/packages/duoyun-ui/src/elements/avatar.ts @@ -6,6 +6,7 @@ import { boolattribute, numattribute, part, + aria, } from '@mantou/gem/lib/decorators'; import { GemElement, html } from '@mantou/gem/lib/element'; import { createCSSSheet, css, exportPartsMap } from '@mantou/gem/lib/utils'; @@ -161,6 +162,7 @@ export type AvatarItem = { */ @customElement('dy-avatar-group') @adoptedStyle(groupStyle) +@aria({ role: 'list' }) export class DuoyunAvatarGroupElement extends GemElement { @part static avatar: string; @@ -180,11 +182,6 @@ export class DuoyunAvatarGroupElement extends GemElement { return this.max || this.#items?.length || 0; } - constructor() { - super(); - this.internals.role = 'list'; - } - #parts = exportPartsMap({ [DuoyunAvatarElement.avatar]: DuoyunAvatarGroupElement.avatar }); #renderAvatar = ({ src = '', tooltip = '', alt = '', status, onClick }: AvatarItem) => { diff --git a/packages/duoyun-ui/src/elements/banner.ts b/packages/duoyun-ui/src/elements/banner.ts index 6420593f..a7bdb879 100644 --- a/packages/duoyun-ui/src/elements/banner.ts +++ b/packages/duoyun-ui/src/elements/banner.ts @@ -8,6 +8,8 @@ import { property, boolattribute, slot, + shadow, + aria, } from '@mantou/gem/lib/decorators'; import { GemElement, html } from '@mantou/gem/lib/element'; import { createCSSSheet, css } from '@mantou/gem/lib/utils'; @@ -82,6 +84,8 @@ type Status = 'positive' | 'notice' | 'negative' | 'default'; */ @customElement('dy-banner') @adoptedStyle(style) +@shadow() +@aria({ role: 'banner' }) export class DuoyunBannerElement extends GemElement { @slot static unnamed: string; @@ -103,11 +107,6 @@ export class DuoyunBannerElement extends GemElement { } } - constructor() { - super({ delegatesFocus: true }); - this.internals.role = 'banner'; - } - render = () => { const icon = this.#icon; return html` diff --git a/packages/duoyun-ui/src/elements/base/chart.ts b/packages/duoyun-ui/src/elements/base/chart.ts index 84963aab..93b41940 100644 --- a/packages/duoyun-ui/src/elements/base/chart.ts +++ b/packages/duoyun-ui/src/elements/base/chart.ts @@ -1,5 +1,5 @@ -import { adoptedStyle, emitter, Emitter, property, state, part } from '@mantou/gem/lib/decorators'; -import { html, svg, TemplateResult, GemElementOptions } from '@mantou/gem/lib/element'; +import { adoptedStyle, emitter, Emitter, property, state, part, aria } from '@mantou/gem/lib/decorators'; +import { html, svg, TemplateResult } from '@mantou/gem/lib/element'; import { createCSSSheet, css, randomStr } from '@mantou/gem/lib/utils'; import { theme } from '../../lib/theme'; @@ -53,6 +53,7 @@ const style = createCSSSheet(css` `); @adoptedStyle(style) +@aria({ role: 'img' }) export class DuoyunChartBaseElement<_T = Record> extends DuoyunResizeBaseElement { @part static chart: string; @@ -79,9 +80,8 @@ export class DuoyunChartBaseElement<_T = Record> extends Duoyun return this.aspectRatio || 2; } - constructor(options?: GemElementOptions) { - super(options); - this.internals.role = 'img'; + constructor() { + super(); this.memo( () => (this.filtersSet = new Set(this.filters)), () => [this.filters], diff --git a/packages/duoyun-ui/src/elements/base/loadable.ts b/packages/duoyun-ui/src/elements/base/loadable.ts index 63a9e2f9..233b0de7 100644 --- a/packages/duoyun-ui/src/elements/base/loadable.ts +++ b/packages/duoyun-ui/src/elements/base/loadable.ts @@ -1,5 +1,5 @@ import { adoptedStyle, customElement, boolattribute } from '@mantou/gem/lib/decorators'; -import { GemElement, html, GemElementOptions } from '@mantou/gem/lib/element'; +import { GemElement, html } from '@mantou/gem/lib/element'; import { createCSSSheet, css } from '@mantou/gem/lib/utils'; import { theme } from '../../lib/theme'; @@ -53,8 +53,8 @@ const style = createCSSSheet(css` export class DuoyunLoadableBaseElement> extends GemElement { @boolattribute loading: boolean; - constructor(options?: GemElementOptions) { - super(options); + constructor() { + super(); const mask = new DuoyunLoadableMaskElement(); this.effect(() => { this.internals.ariaBusy = String(this.loading); diff --git a/packages/duoyun-ui/src/elements/base/resize.ts b/packages/duoyun-ui/src/elements/base/resize.ts index 851ca880..d75a7fc0 100644 --- a/packages/duoyun-ui/src/elements/base/resize.ts +++ b/packages/duoyun-ui/src/elements/base/resize.ts @@ -1,5 +1,5 @@ import { emitter, Emitter } from '@mantou/gem/lib/decorators'; -import { GemElement, GemElementOptions } from '@mantou/gem/lib/element'; +import { GemElement } from '@mantou/gem/lib/element'; import { throttle } from '../../lib/timer'; @@ -8,7 +8,9 @@ export type ResizeDetail = { borderBoxSize: DuoyunResizeBaseElement['borderBoxSize']; }; -export function resizeObserver(ele: DuoyunResizeBaseElement, options: { throttle?: boolean } = {}) { +export type DuoyunResizeBaseElementOptions = { throttle?: boolean }; + +export function resizeObserver(ele: DuoyunResizeBaseElement, options: DuoyunResizeBaseElementOptions = {}) { const { throttle: needThrottle = true } = options; const callback = (entryList: ResizeObserverEntry[]) => { entryList.forEach((entry) => { @@ -29,12 +31,11 @@ export function resizeObserver(ele: DuoyunResizeBaseElement, options: { throttle return () => ro.disconnect(); } -export type DuoyunResizeBaseElementOptions = GemElementOptions & { throttle?: boolean }; export class DuoyunResizeBaseElement<_T = Record> extends GemElement { @emitter resize: Emitter; constructor(options: DuoyunResizeBaseElementOptions = {}) { - super(options); + super(); this.effect( () => resizeObserver(this, options), () => [], diff --git a/packages/duoyun-ui/src/elements/base/visible.ts b/packages/duoyun-ui/src/elements/base/visible.ts index ad6c8b25..ebd068b0 100644 --- a/packages/duoyun-ui/src/elements/base/visible.ts +++ b/packages/duoyun-ui/src/elements/base/visible.ts @@ -1,5 +1,5 @@ import { emitter, Emitter, property, state } from '@mantou/gem/lib/decorators'; -import { GemElement, GemElementOptions } from '@mantou/gem/lib/element'; +import { GemElement } from '@mantou/gem/lib/element'; export function visibilityObserver(ele: DuoyunVisibleBaseElement) { const io = new IntersectionObserver( @@ -36,8 +36,8 @@ export class DuoyunVisibleBaseElement<_T = Record> extends GemE @property intersectionRoot?: Element | Document; @property intersectionRootMargin?: string; - constructor(options?: GemElementOptions) { - super(options); + constructor() { + super(); this.effect( () => visibilityObserver(this), () => [this.intersectionRoot], diff --git a/packages/duoyun-ui/src/elements/base/wake-lock.ts b/packages/duoyun-ui/src/elements/base/wake-lock.ts index c48cb466..c9c55cec 100644 --- a/packages/duoyun-ui/src/elements/base/wake-lock.ts +++ b/packages/duoyun-ui/src/elements/base/wake-lock.ts @@ -1,6 +1,5 @@ /**只要元素显示在屏幕内,屏幕就不会自动熄灭 */ -import { GemElementOptions } from '@mantou/gem/lib/element'; import { logger } from '@mantou/gem/helper/logger'; import { addListener } from '@mantou/gem/lib/utils'; @@ -39,8 +38,8 @@ export function wakeLock(ele: DuoyunWakeLockBaseElement) { } export class DuoyunWakeLockBaseElement<_T = Record> extends DuoyunVisibleBaseElement { - constructor(options?: GemElementOptions) { - super(options); + constructor() { + super(); this.effect( () => wakeLock(this), () => [], diff --git a/packages/duoyun-ui/src/elements/breadcrumbs.ts b/packages/duoyun-ui/src/elements/breadcrumbs.ts index 25cf1a61..dec8ee5a 100644 --- a/packages/duoyun-ui/src/elements/breadcrumbs.ts +++ b/packages/duoyun-ui/src/elements/breadcrumbs.ts @@ -1,5 +1,5 @@ // https://spectrum.adobe.com/page/breadcrumbs/ -import { adoptedStyle, customElement, property, boolattribute, part } from '@mantou/gem/lib/decorators'; +import { adoptedStyle, customElement, property, boolattribute, part, aria } from '@mantou/gem/lib/decorators'; import { GemElement, html } from '@mantou/gem/lib/element'; import { createCSSSheet, css, classMap } from '@mantou/gem/lib/utils'; @@ -55,6 +55,7 @@ export type BreadcrumbsItem = { */ @customElement('dy-breadcrumbs') @adoptedStyle(style) +@aria({ ariaLabel: 'breadcrumbs' }) export class DuoyunBreadcrumbsElement extends GemElement { @part static item: string; @@ -68,11 +69,6 @@ export class DuoyunBreadcrumbsElement extends GemElement { return this.items || this.list; } - constructor() { - super(); - this.internals.ariaLabel = 'breadcrumbs'; - } - render = () => { return html` ${this.#items?.map( diff --git a/packages/duoyun-ui/src/elements/button.ts b/packages/duoyun-ui/src/elements/button.ts index 93e3bc5c..c4e70b5a 100644 --- a/packages/duoyun-ui/src/elements/button.ts +++ b/packages/duoyun-ui/src/elements/button.ts @@ -10,6 +10,7 @@ import { state, part, slot, + shadow, } from '@mantou/gem/lib/decorators'; import { GemElement, html } from '@mantou/gem/lib/element'; import { history } from '@mantou/gem/lib/history'; @@ -139,6 +140,7 @@ const style = createCSSSheet(css` @adoptedStyle(style) @adoptedStyle(focusStyle) @connectStore(icons) +@shadow() export class DuoyunButtonElement extends GemElement { @slot static unnamed: string; @@ -167,7 +169,7 @@ export class DuoyunButtonElement extends GemElement { } constructor() { - super({ delegatesFocus: true }); + super(); this.addEventListener('click', () => { if (this.disabled) return; if (this.route) { diff --git a/packages/duoyun-ui/src/elements/calendar.ts b/packages/duoyun-ui/src/elements/calendar.ts index fa23cceb..ee782659 100644 --- a/packages/duoyun-ui/src/elements/calendar.ts +++ b/packages/duoyun-ui/src/elements/calendar.ts @@ -6,6 +6,7 @@ import { property, boolattribute, part, + shadow, } from '@mantou/gem/lib/decorators'; import { GemElement, html, TemplateResult } from '@mantou/gem/lib/element'; import { createCSSSheet, css, classMap, partMap } from '@mantou/gem/lib/utils'; @@ -112,6 +113,7 @@ interface Day { @customElement('dy-calendar') @adoptedStyle(style) @adoptedStyle(focusStyle) +@shadow() export class DuoyunCalendarElement extends GemElement { @part static headerRow: string; @part static headerLeftCell: string; @@ -140,7 +142,7 @@ export class DuoyunCalendarElement extends GemElement { @property renderDate?: (date: Time) => TemplateResult; constructor() { - super({ delegatesFocus: true }); + super(); } #isHighlightRange = (date: Time) => { diff --git a/packages/duoyun-ui/src/elements/card.ts b/packages/duoyun-ui/src/elements/card.ts index 5c2a9ab3..743e0c69 100644 --- a/packages/duoyun-ui/src/elements/card.ts +++ b/packages/duoyun-ui/src/elements/card.ts @@ -1,5 +1,5 @@ // https://spectrum.adobe.com/page/cards/ -import { adoptedStyle, customElement, attribute, property, part, slot } from '@mantou/gem/lib/decorators'; +import { adoptedStyle, customElement, attribute, property, part, slot, shadow, aria } from '@mantou/gem/lib/decorators'; import { html, TemplateResult } from '@mantou/gem/lib/element'; import { createCSSSheet, css } from '@mantou/gem/lib/utils'; @@ -99,6 +99,8 @@ export type ActionItem = Omit & { handle: (rest: HTML @customElement('dy-card') @adoptedStyle(style) @adoptedStyle(focusStyle) +@shadow() +@aria({ role: 'group' }) export class DuoyunCardElement extends DuoyunLoadableBaseElement { @part static preview: string; @part static avatar: string; @@ -116,11 +118,6 @@ export class DuoyunCardElement extends DuoyunLoadableBaseElement { @property actions?: ActionItem[]; @attribute crossorigin: 'anonymous' | 'use-credentials'; - constructor() { - super({ delegatesFocus: true }); - this.internals.role = 'group'; - } - #onOpenMenu = (evt: MouseEvent) => { const target = evt.target as HTMLElement; ContextMenu.open( diff --git a/packages/duoyun-ui/src/elements/carousel.ts b/packages/duoyun-ui/src/elements/carousel.ts index 0abe8ff3..1b752151 100644 --- a/packages/duoyun-ui/src/elements/carousel.ts +++ b/packages/duoyun-ui/src/elements/carousel.ts @@ -8,6 +8,7 @@ import { part, emitter, Emitter, + shadow, } from '@mantou/gem/lib/decorators'; import { createCSSSheet, css, styleMap, classMap, addListener } from '@mantou/gem/lib/utils'; @@ -150,6 +151,7 @@ type State = { @customElement('dy-carousel') @adoptedStyle(style) @adoptedStyle(focusStyle) +@shadow() export class DuoyunCarouselElement extends GemElement { @part static img: string; @part static title: string; @@ -175,10 +177,6 @@ export class DuoyunCarouselElement extends GemElement { return this.interval || 3000; } - constructor() { - super({ delegatesFocus: true }); - } - state: State = { currentIndex: 0, direction: 1, diff --git a/packages/duoyun-ui/src/elements/cascader-picker.ts b/packages/duoyun-ui/src/elements/cascader-picker.ts index b6688555..87c8ab4a 100644 --- a/packages/duoyun-ui/src/elements/cascader-picker.ts +++ b/packages/duoyun-ui/src/elements/cascader-picker.ts @@ -8,6 +8,9 @@ import { boolattribute, state, emitter, + shadow, + focusable, + aria, } from '@mantou/gem/lib/decorators'; import { GemElement, html } from '@mantou/gem/lib/element'; import { createCSSSheet, css } from '@mantou/gem/lib/utils'; @@ -61,6 +64,9 @@ const style = createCSSSheet(css` @adoptedStyle(style) @adoptedStyle(pickerStyle) @adoptedStyle(focusStyle) +@shadow() +@focusable() +@aria({ role: 'combobox' }) export class DuoyunCascaderPickerElement extends GemElement implements BasePickerElement { @attribute placeholder: string; @boolattribute fit: boolean; @@ -75,10 +81,9 @@ export class DuoyunCascaderPickerElement extends GemElement implements BasePicke @emitter expand: Emitter