From 13da6a47bfc4749e8b58b43e8b867c7f09a1976e Mon Sep 17 00:00:00 2001 From: mantou132 <709922234@qq.com> Date: Tue, 23 Jan 2024 20:42:04 +0800 Subject: [PATCH] [duoyun-ui] Fixed `` --- packages/duoyun-ui/docs/en/01-guide/README.md | 14 +++++++--- .../docs/en/02-elements/cascader-picker.md | 15 +++++++++-- .../duoyun-ui/docs/en/02-elements/cascader.md | 15 +++-------- .../docs/en/02-elements/color-panel.md | 15 +++-------- .../docs/en/02-elements/color-picker.md | 26 +++++++++++++++++-- .../docs/en/02-elements/date-panel.md | 15 +++-------- .../docs/en/02-elements/date-picker.md | 15 +++++++++-- .../docs/en/02-elements/date-range-panel.md | 15 +++-------- .../docs/en/02-elements/date-range-picker.md | 15 +++++++++-- .../docs/en/02-elements/time-panel.md | 15 +++-------- .../docs/en/02-elements/time-picker.md | 15 +++++++++-- .../docs/zh/02-elements/time-panel.md | 2 +- packages/duoyun-ui/package.json | 2 +- packages/duoyun-ui/src/elements/list.ts | 12 ++++++--- 14 files changed, 112 insertions(+), 79 deletions(-) diff --git a/packages/duoyun-ui/docs/en/01-guide/README.md b/packages/duoyun-ui/docs/en/01-guide/README.md index d4b57221..f246a4eb 100644 --- a/packages/duoyun-ui/docs/en/01-guide/README.md +++ b/packages/duoyun-ui/docs/en/01-guide/README.md @@ -39,15 +39,21 @@ Toast.open('error', 'An error occurred'); DuoyunUI supports an ESM method independently uses an element, such as adding a keyboard access to your website(press f list all focusable elements): ```ts -import('https://esm.sh/duoyun-ui/elements/keyboard-access').then(({ DuoyunKeyboardAccessElement }) => - document.body.append(new DuoyunKeyboardAccessElement()), +import('https://esm.sh/duoyun-ui/elements/keyboard-access').then( + ({ DuoyunKeyboardAccessElement }) => + document.body.append(new DuoyunKeyboardAccessElement()), ); ``` For example, enable input recording mode: ```ts -import('https://esm.sh/duoyun-ui/elements/input-capture').then(({ DuoyunInputCaptureElement }) => - document.body.append(new DuoyunInputCaptureElement()), +import('https://esm.sh/duoyun-ui/elements/input-capture').then( + ({ DuoyunInputCaptureElement }) => + document.body.append(new DuoyunInputCaptureElement()), ); ``` + +## Feedback DuoyunUI + +Please visit [GitHub](https://github.com/mantou132/gem) diff --git a/packages/duoyun-ui/docs/en/02-elements/cascader-picker.md b/packages/duoyun-ui/docs/en/02-elements/cascader-picker.md index 9a38c48e..28bbbf1e 100644 --- a/packages/duoyun-ui/docs/en/02-elements/cascader-picker.md +++ b/packages/duoyun-ui/docs/en/02-elements/cascader-picker.md @@ -1,12 +1,23 @@ # `` -## Example +## `` Example -## API +## `` API + +## `` Example + + + +## `` API + + diff --git a/packages/duoyun-ui/docs/en/02-elements/cascader.md b/packages/duoyun-ui/docs/en/02-elements/cascader.md index 521fee06..1d723071 100644 --- a/packages/duoyun-ui/docs/en/02-elements/cascader.md +++ b/packages/duoyun-ui/docs/en/02-elements/cascader.md @@ -1,12 +1,3 @@ -# `` - -## Example - - - -## API - - +--- +redirect: ./cascader-picker.md +--- diff --git a/packages/duoyun-ui/docs/en/02-elements/color-panel.md b/packages/duoyun-ui/docs/en/02-elements/color-panel.md index faa60512..26cf73d5 100644 --- a/packages/duoyun-ui/docs/en/02-elements/color-panel.md +++ b/packages/duoyun-ui/docs/en/02-elements/color-panel.md @@ -1,12 +1,3 @@ -# `` - -## Example - - - -## API - - +--- +redirect: ./color-picker.md +--- diff --git a/packages/duoyun-ui/docs/en/02-elements/color-picker.md b/packages/duoyun-ui/docs/en/02-elements/color-picker.md index 51f92d59..7a3ec9b1 100644 --- a/packages/duoyun-ui/docs/en/02-elements/color-picker.md +++ b/packages/duoyun-ui/docs/en/02-elements/color-picker.md @@ -1,11 +1,15 @@ # `` -## Example +## `` Example ```json [ + { + "value": "#418eec", + "disabled": true + }, { "alpha": true, "value": "#e5e", @@ -16,6 +20,24 @@ -## API +## `` API + +## `` Example + + + +```json +{ + "alpha": true, + "value": "#e5e", + "@change": "(evt) => evt.target.value = evt.detail" +} +``` + + + +## `` API + + diff --git a/packages/duoyun-ui/docs/en/02-elements/date-panel.md b/packages/duoyun-ui/docs/en/02-elements/date-panel.md index 6db9134f..7f269702 100644 --- a/packages/duoyun-ui/docs/en/02-elements/date-panel.md +++ b/packages/duoyun-ui/docs/en/02-elements/date-panel.md @@ -1,12 +1,3 @@ -# `` - -## Example - - - -## API - - +--- +redirect: ./date-picker.md +--- diff --git a/packages/duoyun-ui/docs/en/02-elements/date-picker.md b/packages/duoyun-ui/docs/en/02-elements/date-picker.md index 948e2c38..314ac87b 100644 --- a/packages/duoyun-ui/docs/en/02-elements/date-picker.md +++ b/packages/duoyun-ui/docs/en/02-elements/date-picker.md @@ -1,6 +1,6 @@ # `` -## Example +## `` Example @@ -25,6 +25,17 @@ -## API +## `` API + +## `` Example + + + +## `` API + + diff --git a/packages/duoyun-ui/docs/en/02-elements/date-range-panel.md b/packages/duoyun-ui/docs/en/02-elements/date-range-panel.md index 19aee9a8..ad1ab169 100644 --- a/packages/duoyun-ui/docs/en/02-elements/date-range-panel.md +++ b/packages/duoyun-ui/docs/en/02-elements/date-range-panel.md @@ -1,12 +1,3 @@ -# `` - -## Example - - - -## API - - +--- +redirect: ./date-range-picker.md +--- diff --git a/packages/duoyun-ui/docs/en/02-elements/date-range-picker.md b/packages/duoyun-ui/docs/en/02-elements/date-range-picker.md index e7a23e29..f0951faa 100644 --- a/packages/duoyun-ui/docs/en/02-elements/date-range-picker.md +++ b/packages/duoyun-ui/docs/en/02-elements/date-range-picker.md @@ -1,6 +1,6 @@ # `` -## Example +## `` Example @@ -21,6 +21,17 @@ -## API +## `` API + +## `` Example + + + +## `` API + + diff --git a/packages/duoyun-ui/docs/en/02-elements/time-panel.md b/packages/duoyun-ui/docs/en/02-elements/time-panel.md index bac4be86..9c5d3737 100644 --- a/packages/duoyun-ui/docs/en/02-elements/time-panel.md +++ b/packages/duoyun-ui/docs/en/02-elements/time-panel.md @@ -1,12 +1,3 @@ -# `` - -## Example - - - -## API - - +--- +redirect: ./time-picker.md +--- diff --git a/packages/duoyun-ui/docs/en/02-elements/time-picker.md b/packages/duoyun-ui/docs/en/02-elements/time-picker.md index 603f86ff..946b4cee 100644 --- a/packages/duoyun-ui/docs/en/02-elements/time-picker.md +++ b/packages/duoyun-ui/docs/en/02-elements/time-picker.md @@ -1,12 +1,23 @@ # `` -## Example +## `` Example -## API +## `` API + +## ``Example + + + +## `` API + + diff --git a/packages/duoyun-ui/docs/zh/02-elements/time-panel.md b/packages/duoyun-ui/docs/zh/02-elements/time-panel.md index a71d8a1a..9c5d3737 100644 --- a/packages/duoyun-ui/docs/zh/02-elements/time-panel.md +++ b/packages/duoyun-ui/docs/zh/02-elements/time-panel.md @@ -1,3 +1,3 @@ --- -redirect: time-picker.md +redirect: ./time-picker.md --- diff --git a/packages/duoyun-ui/package.json b/packages/duoyun-ui/package.json index 16de1af6..6b9a0595 100644 --- a/packages/duoyun-ui/package.json +++ b/packages/duoyun-ui/package.json @@ -1,6 +1,6 @@ { "name": "duoyun-ui", - "version": "1.1.12", + "version": "1.1.13", "description": "A lightweight desktop UI component library, implemented using Gem", "keywords": [ "frontend", diff --git a/packages/duoyun-ui/src/elements/list.ts b/packages/duoyun-ui/src/elements/list.ts index ec3957c5..e8dbb562 100644 --- a/packages/duoyun-ui/src/elements/list.ts +++ b/packages/duoyun-ui/src/elements/list.ts @@ -10,6 +10,7 @@ import { emitter, Emitter, boolattribute, + attribute, } from '@mantou/gem/lib/decorators'; import { GemElement, html, TemplateResult } from '@mantou/gem/lib/element'; import { addListener, createCSSSheet, css, LinkedList, LinkedListItem, styled, styleMap } from '@mantou/gem/lib/utils'; @@ -87,6 +88,7 @@ export class DuoyunListElement extends GemElement { @property key?: any; // 除了 items 提供另外一种方式来更新 @property renderItem?: (item: any) => TemplateResult; @boolattribute debug: boolean; + @attribute itemexportparts: string; /**enable infinite scroll, virtualization render */ @boolattribute infinite: boolean; @@ -274,10 +276,13 @@ export class DuoyunListElement extends GemElement { #appendItems = (items: any[], oldItems?: any[]) => { if (!oldItems) return; + const oldFirst = oldItems.at(0); let beforeHeight = 0; - for (let i = 0; i < items.length; i++) { - if (this.getKey!(items[i]) === this.getKey!(oldItems[0])) break; - if (this.#isLeftItem(i)) beforeHeight += this.#getRowHeight(); + if (oldFirst) { + for (let i = 0; i < items.length; i++) { + if (this.getKey!(items[i]) === this.getKey!(oldFirst)) break; + if (this.#isLeftItem(i)) beforeHeight += this.#getRowHeight(); + } } if (beforeHeight) { // 有向前(上)加载数据,必须是列数的倍数 @@ -398,6 +403,7 @@ export class DuoyunListElement extends GemElement { if (!this.#keyElementMap.has(key)) { const ele = new DuoyunListItemElement(); ele.setAttribute('part', DuoyunListElement.item); + ele.setAttribute('exportparts', this.itemexportparts); ele.addEventListener('resize', this.#onItemResize); ele.addEventListener('show', () => this.itemshow(this.#keyItemMap.get(key))); ele.intersectionRoot = this.scrollContainer;