From 8789555c8c028e95753f6b404b7b47fa029d5cbd Mon Sep 17 00:00:00 2001 From: lwl <1181102955@qq.com> Date: Thu, 14 Oct 2021 22:12:47 +0800 Subject: [PATCH 01/59] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0click=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=A4=84=E7=90=86=EF=BC=8C=E5=8C=BA=E5=88=86hover?= =?UTF-8?q?=E4=B8=8Eclick?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cascader/components/cascader-item/index.tsx | 16 ++++++++++------ .../cascader-list/cascader-list-types.ts | 8 ++++++-- .../cascader/components/cascader-list/index.tsx | 4 ++-- devui/cascader/hooks/use-cascader-item.ts | 9 +++++++++ devui/cascader/src/cascader-types.ts | 8 +++++++- devui/cascader/src/cascader.tsx | 8 +++++--- docs/components/cascader/index.md | 1 + 7 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 devui/cascader/hooks/use-cascader-item.ts diff --git a/devui/cascader/components/cascader-item/index.tsx b/devui/cascader/components/cascader-item/index.tsx index 5182dd22..59cdebde 100644 --- a/devui/cascader/components/cascader-item/index.tsx +++ b/devui/cascader/components/cascader-item/index.tsx @@ -2,19 +2,23 @@ import { getRootClass } from './use-class' import { optionsHandles } from '../../hooks/use-cascader-options' import './index.scss' export const DCascaderItem = (props) => { - const { cascaderli, ulIndex } = props + // console.log(props) + const { cascaderItem, ulIndex } = props const { changeCascaderIndexs } = optionsHandles() const rootClasses = getRootClass() - const mouseHover = () => { - changeCascaderIndexs(cascaderli, ulIndex) + const mouseEvent = () => { + changeCascaderIndexs(cascaderItem, ulIndex) } + const onMouseEvent = { + [props.cascaderItemNeedProps.trigger === 'hover' ? 'onMouseenter' : 'onClick']: mouseEvent + } return ( -
  • +
  • { - cascaderli?.children?.length > 0 && + cascaderItem?.children?.length > 0 && }
  • ) diff --git a/devui/cascader/components/cascader-list/cascader-list-types.ts b/devui/cascader/components/cascader-list/cascader-list-types.ts index 85e2152d..f1fd8fed 100644 --- a/devui/cascader/components/cascader-list/cascader-list-types.ts +++ b/devui/cascader/components/cascader-list/cascader-list-types.ts @@ -1,12 +1,12 @@ import type { PropType, ExtractPropTypes } from 'vue' -import { CascaderItem } from '../../src/cascader-types' +import { CascaderItem, PickCascader } from '../../src/cascader-types' export const cascaderulProps = { /** * 每个ul中的li * @type {CascaderItem[]} * @default [] */ - cascaderlis: { + cascaderItems: { type: Array as PropType, default: [], }, @@ -18,6 +18,10 @@ export const cascaderulProps = { ulIndex: { type: Number, default: 0 + }, + cascaderItemNeedProps: { + type: Object as PropType, + default: {} } } export type CascaderulProps = ExtractPropTypes diff --git a/devui/cascader/components/cascader-list/index.tsx b/devui/cascader/components/cascader-list/index.tsx index 4fa19244..562bd5c3 100644 --- a/devui/cascader/components/cascader-list/index.tsx +++ b/devui/cascader/components/cascader-list/index.tsx @@ -10,8 +10,8 @@ export default defineComponent({ const rootClasses = getRootClass() return () => (
      - {props.cascaderlis.map((item, index) => { - return + {props.cascaderItems.map((item, index) => { + return })}
    ) diff --git a/devui/cascader/hooks/use-cascader-item.ts b/devui/cascader/hooks/use-cascader-item.ts new file mode 100644 index 00000000..b8b688ee --- /dev/null +++ b/devui/cascader/hooks/use-cascader-item.ts @@ -0,0 +1,9 @@ +import { CascaderProps, UseCascaderItemCallback } from '../src/cascader-types' +export const userCascaderItem = (props: CascaderProps): UseCascaderItemCallback => { + const cascaderItemNeedProps = { + trigger: props.trigger + } + return { + cascaderItemNeedProps + } +} \ No newline at end of file diff --git a/devui/cascader/src/cascader-types.ts b/devui/cascader/src/cascader-types.ts index 13abc1af..6d287bab 100644 --- a/devui/cascader/src/cascader-types.ts +++ b/devui/cascader/src/cascader-types.ts @@ -67,4 +67,10 @@ export interface PopupTypes { export interface OptionsCallback { cascaderOptions: never | UnwrapNestedRefs<[CascaderItem[]]> changeCascaderIndexs: (optionItem: CascaderItem, ulIndex: number) => void -} \ No newline at end of file +} + +type cascaderItemExtendsProps = 'trigger' +export type PickCascader = Pick +export interface UseCascaderItemCallback { + cascaderItemNeedProps: PickCascader +} diff --git a/devui/cascader/src/cascader.tsx b/devui/cascader/src/cascader.tsx index d0565e61..bf0523d6 100644 --- a/devui/cascader/src/cascader.tsx +++ b/devui/cascader/src/cascader.tsx @@ -6,7 +6,7 @@ import { getRootClass } from '../hooks/use-cascader-class' import { popupHandles } from '../hooks/use-cascader-popup' import DCascaderList from '../components/cascader-list' import { optionsHandles } from '../hooks/use-cascader-options' - +import { userCascaderItem } from '../hooks/use-cascader-item' export default defineComponent({ name: 'DCascader', @@ -25,9 +25,11 @@ export default defineComponent({ const rootClasses = getRootClass(props, menuShow) // 级联菜单操作,变换ul、li等 const { cascaderOptions } = optionsHandles(props.options) + // 传递给cascaderItem的props + const { cascaderItemNeedProps } = userCascaderItem(props) return () => ( <> -
    +
    {cascaderOptions.map((item, index) => { - return + return })}
    diff --git a/docs/components/cascader/index.md b/docs/components/cascader/index.md index 88e98169..cb35e239 100644 --- a/docs/components/cascader/index.md +++ b/docs/components/cascader/index.md @@ -7,6 +7,7 @@ ```vue +``` + +::: + diff --git a/docs/en-US/components/button/index.md b/docs/en-US/components/button/index.md new file mode 100644 index 00000000..4870da3b --- /dev/null +++ b/docs/en-US/components/button/index.md @@ -0,0 +1,27 @@ +# Button + +The button is used to start an instant operation。 + +### When to use + +An operation command (or a group of encapsulation) is marked, and the corresponding business logic is triggered in response to the user's click behavior。 + +### Main button + +Primary +Disabled + +```html +Primary +Disabled +``` + +### Secondary button + +Common +Disabled + +```html +Common +Disabled +``` \ No newline at end of file diff --git a/docs/en-US/components/card/index.md b/docs/en-US/components/card/index.md new file mode 100644 index 00000000..d81ada82 --- /dev/null +++ b/docs/en-US/components/card/index.md @@ -0,0 +1,220 @@ +# Card + +Universal card container。 + +### When to use + +Basic card container, which can contain text, lists, pictures, paragraphs, used for overview display。 + + +### Basic usage + + + + + + + + + +```html + + + + + + + +``` + +### Use image + +The alignment of the d-card-actions operation area can be set through align: initial alignment, tail alignment, stretch alignment。 + + + + + + + + + +```html + + + + + + + +``` + +### Custom Area + + +
    + +
    +
    + + +
    + +```html + +
    + +
    +
    + + +
    +``` + \ No newline at end of file diff --git a/docs/en-US/components/carousel/index.md b/docs/en-US/components/carousel/index.md new file mode 100644 index 00000000..4fad5733 --- /dev/null +++ b/docs/en-US/components/carousel/index.md @@ -0,0 +1,162 @@ +# Carousel + +A set of carousel areas。 + +### When to use + +1. Used to display pictures or cards。 + +### Basic usage + + {{ item }} + + +```html + + {{ item }} + +``` +```css +.d-carousel-item { + text-align: center; + line-height: 200px; + background: var(--devui-global-bg, #f3f6f8); +} +``` +### 指示器&切换箭头 +arrowTrigger设为always可以使箭头永久显示,dotTrigger设为hover可以使hover到点上就切换。 + + + {{ item }} + + +```html + + {{ item }} + +``` +### Automatic carousel + + {{ item }} + + +```html + + {{ item }} + +``` +### Custom action + + {{ item }} + + + +```html + + {{ item }} + + +``` +```css +.carousel-demo-operate{ + margin-top: 10px; + + display: flex; + align-items: center; + + > * { + margin-right: 20px; + } +} +``` + +### API +#### parameter + +| parameter | type | default | description | jump Demo | +| :----------: | :--------------------------: | :------: | :---------------------------------------------- | ------------------------------------------------ | +| arrowTrigger | `'hover'\|'never'\|'always'` | 'hover' | Optional, specify the switching arrow display mode | [Indicator-switch-arrow](#Indicator-switch-arrow) | +| autoplay | `boolean` | false | Optional, whether to rotate automatically | [Automatic-carousel](#Automatic-carousel) | +| autoplaySpeed | `number` | 3000 | Optional, used with `autoplay`, automatic rotation speed, unit: ms | [Automatic-carousel](#Automatic-carousel) | +| height | `string` | '100%' | Optional, carousel container height | [Basic-usage](#Basic-usage) | +| showDots | `boolean` | true | Optional, whether to display the panel indicator | [Automatic-carousel](#Automatic-carousel) | +| dotPosition | `'top'\|'bottom'` | 'bottom' | Optional, panel indicator position | [Indicator-switch-arrow](#Indicator-switch-arrow) | +| dotTrigger | `'click'\|'hover'` | 'click' | Optional, indicator triggers carousel mode | [Indicator-switch-arrow](#Indicator-switch-arrow) | +| activeIndex | `number` | 0 | Optional, initialize the active card index, starting from 0, supporting `[(activeIndex)]` two-way binding | [Basic-usage](#Basic-usage) | + +#### Event + +| event | type | description | jump Demo | +| :----------------: | :---------------------: | :-----------------------------------------: | ------------------------------------------------- | +| activeIndexChange | `EventEmitter` | When the card is switched, return to the index of the current card, starting from 0 | [Basic-usage](#Basic-usage) | + +#### methods + +| methods | description | jump Demo | +| :---------: | :---------------------------------- | :----------------------------- | +| prev() | Switch to the previous card | [Custom-action](#Custom-action) | +| next() | Switch to the next card | [Custom-action](#Custom-action) | +| goTo(index) | Switch to the card with the specified index, the index starts from 0 | [Custom-action](#Custom-action) | + + + + \ No newline at end of file diff --git a/docs/en-US/components/checkbox/index.md b/docs/en-US/components/checkbox/index.md new file mode 100644 index 00000000..1cd4822d --- /dev/null +++ b/docs/en-US/components/checkbox/index.md @@ -0,0 +1,42 @@ +# CheckBox + +CheckBox。 + +### When to use + +1. Make multiple choices in a set of options; +2. Used alone can indicate switching between the two states, and can be combined with the submit operation。 + +### Basic usage + + + + +```html + + +``` + +#### use CheckboxGroup + + + + +
    {{ checkedValues.reduce((prev, current) => `${current} ${prev}`, '') }}
    + + \ No newline at end of file diff --git a/docs/en-US/components/date-picker/index.md b/docs/en-US/components/date-picker/index.md new file mode 100644 index 00000000..6ec80542 --- /dev/null +++ b/docs/en-US/components/date-picker/index.md @@ -0,0 +1,121 @@ + + +# DatePicker + +Date and time visual input。 + +## Attributes auto-close + +|project|description| +|----|----| +|name|auto-close / autoClose| +|type|boolean| +|mustSelect|false| +|default|false| +|description|After selecting the date, whether to automatically close the date panel| + +```vue + + + + + + + +``` + + + + +## Attributes range + +|project|description| +|----|----| +|name|range| +|type|boolean| +|mustSelect|false| +|default|false| +|description|Whether to open interval selection| + +```vue + + + + + + + +``` + + + +## Attributes format + +|project|type| +|----|----| +|name|format| +|type|string| +|mustSelect|false| +|default|y/MM/dd| +|description|Date value format| + + + + +```vue + + +``` + +**Date formatting characters** + +|character|description|rule| +|----|----|----| +|y, yy, yyyy|year|When using `yy`, only the last 2 digits are displayed, otherwise 4 digits are displayed。for example:`yy/MM/dd -> 21/01/02`, `y/MM/dd -> 2021/01/02`| +|M,MM|month|When using `MM`, the left side of a one-digit number will automatically add `0`。for example: `y/MM/dd -> 2021/01/02`,`y/M/d -> 2021/1/2`| +|d,dd|date|rule reference`M`| +|h,hh|hour|rule reference`M`;Use 24-hour representation。| +|m,mm|minute|rule reference`M`| +|s,ss|second|rule reference`M`| + +## Attributes range-spliter + +|project|type| +|----|----| +|name|range-spliter / rangeSpliter| +|type|string| +|mustSelect|false| +|default|-| +|description|In interval selection mode, the character that separates the start and end time。| + +```vue + +``` + + + +## Event selectedDateChange + +```vue + + +``` + + + \ No newline at end of file diff --git a/docs/en-US/components/icon/index.md b/docs/en-US/components/icon/index.md new file mode 100644 index 00000000..45ba44f2 --- /dev/null +++ b/docs/en-US/components/icon/index.md @@ -0,0 +1,71 @@ +# Icon 图标 + +用于显示图标。 + +### 何时使用 + +需要显示图标时。 + +所有内置的图标可在DevUI官网进行查看: + +[https://devui.design/icon/ruleResource](https://devui.design/icon/ruleResource) + +### 基本用法 + + + + + + +```html + + + + +``` + +### 自定义字体图标 + +Icon 组件默认引用 DevUI 图标库的图标,如果需要在现有 Icon 的基础上使用更多图标,可以引入第三方 iconfont 对应的字体文件和 CSS 文件,之后就可以在 Icon 组件中直接使用。 + +```css +@font-face { + font-family: "my-icon"; + src: url("./my-icon.ttf") format("truetype"); +} + +.my-icon { + font-family: "my-icon"; +} + +.my-icon-right::before { + content: "\E03F"; +} +``` + +引入字体图标的 css + +```css +@import "my-icon.css"; +``` + +or + +```js +import "my-icon.css"; +``` + +使用 + +```html + +``` + +### API + +| 参数 | 类型 | 默认 | 说明 | 跳转 Demo | +| :---------: | :------: | :-------: | :----------------------- | --------------------------------- | +| name | `String` | -- | 必选,Icon 名称 | [基本用法](#基本用法) | +| size | `String` | '16px' | 可选,图标大小 | [基本用法](#基本用法) | +| color | `String` | '#252b3a' | 可选,图标颜色 | [基本用法](#基本用法) | +| classPrefix | `String` | 'icon' | 可选,自定义字体图标前缀 | [自定义字体图标](#自定义字体图标) | diff --git a/docs/en-US/components/image-preview/index.md b/docs/en-US/components/image-preview/index.md new file mode 100644 index 00000000..481641d3 --- /dev/null +++ b/docs/en-US/components/image-preview/index.md @@ -0,0 +1,137 @@ +# ImagePreview + +Preview the components of one or more pictures。 + +### When to use + +When you need to preview the image or preview the image in the container according to the user input。 + +### Basic usage + +Use the v-d-image-preview command to preview the image in the container。 + +
    + +
    + +```html +
    + +
    + + +``` + +### Custom open preview window + +Pass in the custom parameter, the command will be automatically injected into the open method, and the preview window will be opened through custom.open + +
    + +
    +自定义 + +```html +
    + +
    +自定义 + + +``` + +### Set zIndex + +Set zIndex to control the level of the pop-up effect, and set backDropZIndex to control the level of the background of the pop-up layer。 +You can see that when zIndex is set to be less than backDropZIndex, imagePreview will be displayed below the background。 +You can close imagePreview by Esc。 + +``` +// 待嵌入 modal 组件即可 +``` + +### API + +| parameter | type | default | description | +| :------------: | :-------: | :---: | :------------------------------------------------------------ | +| custom | `Object` | -- | Optional, the command will be automatically injected into the open method, and the preview window will be opened through custom.open | +| disableDefault | `Boolean` | false | Optional, turn off the default click trigger image preview mode | +| zIndex | `Number` | 1050 | Optional, optional, set the z-index value of the picture when previewing | +| backDropZIndex | `Number` | 1040 | Optional, set the z-index value of the image background during preview | + + + + diff --git a/docs/en-US/components/input/index.md b/docs/en-US/components/input/index.md new file mode 100644 index 00000000..edc7f8fa --- /dev/null +++ b/docs/en-US/components/input/index.md @@ -0,0 +1,96 @@ +# Input + +Text input。 + +### When to use + +You need to manually enter text to use。 + +### Basic usage + +:::demo + +```vue + + +``` + +::: + +### Size + +:::demo + +```vue + +``` + +::: + + +### Password + +:::demo + +```vue + + +``` + +::: + +### API + +| parameter | type | default | description | jump Demo | +| :---------: | :------: | :-------: | :-----------------------: | :---------------------------------: | +| id | `string` | -- | Optional, text box id | [Basic-usage](#Basic-usage) | +| placeholder | `string` | -- | Optional,textarea placeholder | [Basic-usage](#Basic-usage) | +| maxLength | `number` | Number.MAX_SAFE_INTEGER | Optional, the max-length of the input box | | +| disabled | `boolean` | false | Optional,Whether the text box is disabled | [Basic-usage](#Basic-usage) | +| error | `boolean` | false | Optional,Whether there is an input error in the text box | [Basic-usage](#Basic-usage) | +| size | `'sm'\|''\|'lg'` | '' | Optional,There are three options for the size of the text box`'lg'`,`''`,`'sm'` | [Size](#Size) | +| cssClass | `string` | '' | Optional,Support to pass in the class name to the input box | | +| showPassword | `boolean` | false | Optional,password | [Password](#Password) | +| autoFocus | `boolean` | false | Optional,Whether the input box is auto-focused | [Basic-usage](#Basic-usage) | + diff --git a/docs/en-US/components/loading/index.md b/docs/en-US/components/loading/index.md new file mode 100644 index 00000000..5c0a61f5 --- /dev/null +++ b/docs/en-US/components/loading/index.md @@ -0,0 +1,298 @@ +# Loading + +Prompt the user that the page is executing instructions and needs to wait。 + +### When to use + +When the execution time is long (it takes more than a few seconds), show the user the status of execution。 + + +### Basic usage +Show the basic usage in the scene of loading table data。 +:::demo + +```vue + + + +``` +::: + + +### many promise +support many promise。 +:::demo + +```vue + + + +``` +::: + +### Custom Css Style +Customize loading style through templateRef。 +:::demo + +```vue + + + + + +``` +::: + +### Service method call +Use the service method to load the loading component in full screen or load the loading component on the specified host。 +:::demo + +```vue + + + +``` +::: + +### parameter +The parameter of dLoading + +| **parameter** | **type** | **default** | **description** | **jump Demo** | +| ------------------ | ------------------------------------------------------------ | ------------------------- | ------------------------------------------------------------ | ---------------------------- | +| v-dLoading | `Promise \| Array> \| Boolean \| undefined` | -- | Optional, command mode, control loading status | [Basic-usage](#Basic-usage) | +| target | `element` | document.body | Optional, service mode, DOM nodes that need to be covered by Loading | [Service-method-call](#Service-method-call) | +| message | `string` | -- | Optional, prompt message during loading | [many-promise](#many-promise) | +| loadingTemplateRef | `VNode` | -- | Optional, custom loading template | [Custom-css-style](#Custom-css-style) | +| backdrop | `boolean` | true | Optional, whether to show the mask during loading | [Basic-usage](#Basic-usage) | +| positionType | `string` | relative | Optional, specify the positioning type of the `dLoading` host element, the value is consistent with the css position attribute。 | [Basic-usage](#Basic-usage) | +| view | `{top?:string,left?:string} ` | {top: '50%', left: '50%'} | Optional, adjust the display position of loading, relative to the top and left distances of the host element | [Basic-usage](#Basic-usage) | +| zIndex | `number` | -- | Optional, z-index value of loading prompt | [Basic-usage](#Basic-usage) | + diff --git a/docs/en-US/components/overlay/index.md b/docs/en-US/components/overlay/index.md new file mode 100644 index 00000000..6a7399ba --- /dev/null +++ b/docs/en-US/components/overlay/index.md @@ -0,0 +1,198 @@ +## overlay +The mask layer is a basic component and is used to build components independent of the current page layout。 +### When to use +You can use this component when you need a global pop-up window, or when you need an element-following function。 +### Fixed overlay + +:::demo Use `sm`, `''`, `lg` to define the basic type of `Search` + +```vue + + +``` +::: + + +### Elastic overlay + +:::demo +```vue + + +``` + +::: + + + + +### API +The parameter of d-fixed-overlay + +| parameter | type | default | description | +| :--------------: | :------------------------: | :---: | :-------------------------------------------------------------------- | +| visible | `boolean` | false | Optional, whether the mask layer is visible | +| onUpdate:visible | `(value: boolean) => void` | -- | Optional, the mask layer cancels the visible event | +| backgroundBlock | `boolean` | false | Optional, if true, the background cannot be scrolled | +| backgroundClass | `string` | -- | Optional, the style class of the background | +| hasBackdrop | `boolean` | true | Optional, if false, the content behind the background will be triggered | +| backdropClick | `() => void` | -- | Optional, click on the event triggered by the background | +| backdropClose | `boolean` | false | Optional, if true, clicking on the background will trigger `onUpdate:visible`, the default parameter is false | +| overlayStyle | `CSSProperties` | -- | Optional, the style of the mask layer | + +The parameter of d-flexible-overlay + +| 参数 | 类型 | 默认 | 说明 | +| :--------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---: | :---------------------------------------------------------------- | +| visible | `boolean` | false | 可选,遮罩层是否可见 | +| onUpdate:visible | `(value: boolean) => void` | -- | 可选,遮罩层取消可见事件 | +| backgroundBlock | `boolean` | false | 可选,如果为 true,背景不能滚动 | +| backgroundClass | `string` | -- | 可选,背景的样式类 | +| hasBackdrop | `boolean` | true | 可选,如果为false,背景后下的内容将可以触发 | +| backdropClick | `() => void` | -- | 可选,点击背景触发的事件 | +| backdropClose | `boolean` | false | 可选,如果为true,点击背景将触发 `onUpdate:visible`,参数是 false | +| origin | `Element \| ComponentPublicInstance \| { x: number, y: number, width?: number, height?: number }` | false | 必选,你必须指定起点元素才能让遮罩层与该元素连接在一起 | +| position | `{originX: HorizontalPos, originY: VerticalPos, overlayX: HorizontalPos, overlayY: VerticalPos } (type HorizontalPos = 'left' \| 'center' \| 'right') ( type VerticalPos = 'top' \| 'center' \| 'bottom')` | false | 可选,指定遮罩层与原点的连接点 | diff --git a/docs/en-US/components/pagination/index.md b/docs/en-US/components/pagination/index.md new file mode 100644 index 00000000..6e85d151 --- /dev/null +++ b/docs/en-US/components/pagination/index.md @@ -0,0 +1,473 @@ +# Pagination + +Pagination。 + +### When to use + +When loading/rendering all the data will take a lot of time, you can switch the page number to browse the data。 + + +### Basic usage + +:::demo + +```vue + + +``` +::: + + +### Minimalist mode +Minimalist mode is suitable for some pages with a lot of information, which can simplify the complexity of the page。 +:::demo + + +```vue + + + + +``` +::: + +### Multiple configurations +Support setting input jump, display jump button; setting pageSize and other functions。 +:::demo + +```vue + + +``` +::: + +### Special cases +The display of the pager in a special scene。 +:::demo + + +```vue + + +``` +::: + +### 参数 + +d-pagination 参数 + +| parameter | type | default | description | jump Demo | +| ----------------- | ------------------------------------------------------------ | -------------------------- | ------------------------------------------------------------ | --------------------- | +| pageSize | `number` | 10 | Optional, display the maximum number of entries per page | [Basic-usage](#Basic-usage) | +| total | `number` | 0 | Optional, total number of entries displayed | [Basic-usage](#Basic-usage) | +| pageSizeOptions | `number[] ` | 10 | Optional, the data source of the drop-down box for the maximum number of entries per page for pagination, there are four options by default 5, 10, 20, 50 | [Multiple-configurations](#Multiple-configurations) | +| pageSizeDirection | `Array<`[`AppendToBodyDirection`](#appendtobodydirection) `\|` [`ConnectedPosition`](#connectedposition)`>` | ['centerDown', 'centerUp'] | Optional, set the display direction of the drop-down box of each page entry | [Multiple-configurations](#Multiple-configurations) | +| pageIndex | `number` | 1 | Optional, initialize page number | [Basic-usage](#Basic-usage) | +| maxItems | `number` | 10 | Optional, display a few buttons at most for pagination | [Basic-usage](#Basic-usage) | +| preLink | `string` | -- | Optional, the previous page button displays the icon, the default setting is the left arrow icon | [Basic-usage](#Basic-usage) | +| nextLink | `string` | -- | Optional, the next page button displays the icon, the default setting is the right arrow icon | [Basic-usage](#Basic-usage) | +| size | `number` | '' | 可Selection, paging component size, there are three options lg,``,sm, respectively representing large, medium and small | [Basic-usage](#Basic-usage) | +| canJumpPage | `boolean` | false | Optional, whether to display the page input jump | [Basic-usage](#Basic-usage) | +| canChangePageSize | `boolean` | false |Optional, whether to display the drop-down box for selecting the maximum number of entries per page for changing the pagination | [Basic-usage](#Basic-usage) | +| canViewTotal | `boolean` | false | Optional, whether to display total entries | [Basic-usage](#Basic-usage) | +| totalItemText | `string` | 'All entries' | Optional, total entry text | [Minimalist-mode](#Minimalist-mode) | +| goToText | `string` | 'jump to' | Optional, total entry text | [Basic-usage](#Basic-usage) | +| showJumpButton | `boolean` | false | Optional, whether to show the jump button | [Multiple-configurations](#Multiple-configurations) | +| showTruePageIndex | `boolean` | false | Optional, the switch to display the current page number when the page number exceeds the paging range | [Multiple-configurations](#Multiple-configurations) | +| lite | `boolean` | false | Optional, whether to switch to Minimalist-mode | [Minimalist-mode](#Minimalist-mode) | +| showPageSelector | `boolean` | true | Optional, whether to show page number drop-down under `Minimalist-mode` | [Minimalist-mode](#Minimalist-mode) | +| haveConfigMenu | `boolean` | false | Optional, whether to display the configuration under `Minimalist-mode` | [Minimalist-mode](#Minimalist-mode) | +| autoFixPageIndex | `boolean` | true | Optional, whether to automatically correct the page number when changing the pageSize. If the `pageIndex` is handled in the `pageSizeChange` event, it is recommended to set it to `false` | [Minimalist-mode](#Minimalist-mode) | +| autoHide | `boolean` | false | Optional, whether to hide automatically, autoHide is true and the minimum value of pageSizeOptions> total does not show pagination | [Minimalist-mode](#Minimalist-mode) | + +d-pagination Event + +| parameter | type | default | jump Demo | +| --------------- | -------------------- | ---------------------------------------------------------- | --------------------- | +| pageIndexChange | `EventEmitter` | Optional, callback of page number change, return current page number value | [Multiple-configurations](#Multiple-configurations) | +| pageSizeChange | `EventEmitter` | Optional, callback when the maximum number of items per page is changed, return the current number of items displayed on each page | [Multiple-configurations](#Multiple-configurations) | + +**Tnterface & TypeDefine** + +##### AppendToBodyDirection + +```ts +export type AppendToBodyDirection = 'rightDown' | 'rightUp' | 'leftUp' | 'leftDown' | 'centerDown' | 'centerUp'; +``` + +##### ConnectedPosition + +```ts +export interface ConnectedPosition { + originX: 'start' | 'center' | 'end'; + originY: 'top' | 'center' | 'bottom'; + + overlayX: 'start' | 'center' | 'end'; + overlayY: 'top' | 'center' | 'bottom'; + + weight?: number; + offsetX?: number; + offsetY?: number; + panelClass?: string | string[]; +} +``` + diff --git a/docs/en-US/components/panel/index.md b/docs/en-US/components/panel/index.md new file mode 100644 index 00000000..da8c4438 --- /dev/null +++ b/docs/en-US/components/panel/index.md @@ -0,0 +1,74 @@ +# Panel + +Content panel for content grouping。 + +### When to use + +Used when the page content needs to be displayed in groups, generally including three parts: header, content area, and bottom。 + +### Basic usage + +
    + + + Panel with foldable + + + This is body + +

    + + + Panel has no left padding + + + This is body + +

    + + Panel with header and footer + This is body + This is footer + +
    + + +```html +
    + + + Panel with foldable + + + This is body + +

    + + + Panel has no left padding + + + This is body + +

    + + Panel with header and footer + This is body + This is footer + +
    +``` + + diff --git a/docs/en-US/components/popover/index.md b/docs/en-US/components/popover/index.md new file mode 100644 index 00000000..522495c9 --- /dev/null +++ b/docs/en-US/components/popover/index.md @@ -0,0 +1,386 @@ +# Popover +Simple text prompt bubble box。 + +### When to use +Used to notify users of non-critical issues or to prompt a control in a special situation。 + +### Basic usage +When Popover pops up, it will be positioned based on the content of the `reference` slot。 + +
    + + + + + + + + + + + + + + + + + + +
    + + +```html + + + + + + + + + + + + + + + + + + + + + + +``` + +### Custom content +Customize the content of the `reference` slot and the content of the pop-up prompt。 + +
    + + + +
    + +```html +
    + + + +
    +``` + +### Pop-up position +A total of 12 pop-up positions are supported。 + +
    + + + + + + + + + + + + +
    + +
    + + + + + + + + + + + + +
    + +
    + + + + + + + + + + + + +
    + +
    + + + + + + + + + + + + +
    + +```html +
    + + + + + + + + + + + + +
    + +
    + + + + + + + + + + + + +
    + +
    + + + + + + + + + + + + +
    + +
    + + + + + + + + + + + + +
    +``` + +### Delay trigger +Only when the trigger is hover, the mouse moves in for more than [mouseEnterDelay] milliseconds to trigger to prevent flashing caused by the user inadvertently swiping. The default value is 150 milliseconds; after the mouse is moved out, it will be triggered after [mouseLeaveDelay] milliseconds. , The Popover component will be hidden, the default value is 100 milliseconds。 + +
    + + + + + + + + +
    + +```html + + + + + + + + +``` + +### dPopover parameter + +| parameter | type | default | description | jump Demo | +| ---- | ---- | ---- | ---- | ---- | +| content | `string` | defalut |Optional, the display content of the pop-up box | [Custom-content](#Custom-content) | +| visible | `boolean` | false | Optional, the initial pop-up state of the bullet box | [Basic-usage](#Basic-usage) | +| trigger | `string` | click | Optional, trigger mode of the bullet frame | [Basic-usage](#Basic-usage) | +| popType | `string` | default | Optional, pop-up box type, different styles | [Basic-usage](#Basic-usage) | +| zIndex | `number` | 1060 | Optional, z-index value is used to manually control the layer height | [Basic-usage](#Basic-usage) | +| positionType | `string` | bottom | Optionally, control the direction in which the bullet frame appears | [Pop-up-position](#Pop-up-position) | +| showAnimation | `boolean` | true | Optional, whether to show animation | [Basic-usage](#Basic-usage) | +| mouseEnterDelay | `number` | 150 | Optional, only when the trigger is hover, set the delay after the mouse moves in to display Popover, the unit is `ms`| [Delay-trigger](#Delay-trigger) | +| mouseLeaveDelay | `number` | 100 | Optional, only need to set the delay after the mouse is moved out to hide the popover only when the trigger is hover, the unit is `ms` | [Delay-trigger](#Delay-trigger) | + diff --git a/docs/en-US/components/progress/index.md b/docs/en-US/components/progress/index.md new file mode 100644 index 00000000..402090d5 --- /dev/null +++ b/docs/en-US/components/progress/index.md @@ -0,0 +1,142 @@ +# Progress + +progress bar。 + +### When to use +1. When the operation takes a long time, show the user the progress of the operation。 +2. When the operation needs to interrupt the existing interface or background operation, it takes a long time。 +3. When it is necessary to display the percentage of an operation completed or the completed steps/total steps。 + +### Basic usage +Basic progress and text configuration。 + +
    +
    + +
    +
    + +
    +
    + + +```html +
    + +
    +
    + +
    +``` + +```css +.progress-container { + margin-bottom: 20px; +} +``` + +### Ring usage +Basic progress and text configuration。 + +
    +
    + +
    +
    + + +
    +
    + + + +
    +
    + + +```html +
    + +
    +
    + +
    +
    + + + +
    +``` + +```css +.progress-container-circle { + height: 130px; + width: 130px; + font-size: 20px; + display: inline-block; + margin-right: 10px; +} + +.icon-position { + position: absolute; + top: 50%; + left: 50%; + width: 100%; + margin: 0; + padding: 0; + line-height: 1; + white-space: normal; + text-align: center; + transform: translate(-50%, -50%); + color: #50d4ab; + font-size: 24px; +} +``` + +### API +#### d-progress parameter +| parameter | type | default | description | jump Demo | +| :---: | :---: | :---: | :---: | :---: | +| percentage | `number` | 0 | Optional, the maximum value of the progress bar is 100 | [基本用法](#基本用法) | +| percentageText | `string` | -- | Optional, the text description of the current value of the progress bar, such as: '30%' \| '4/5' | [基本用法](#基本用法) | +| barBgColor | `string` | #5170ff | Optional, the color of the progress bar is displayed, the default is sky blue | [基本用法](#基本用法) | +| height | `string` | 20px | Optional, the height of the progress bar, the default value is 20px | [基本用法](#基本用法) | +| isCircle | `boolean` | false | Optional, show whether the progress bar is a circle | [圆环用法](#圆环用法) | +| strokeWidth | `number` | 6 | Optional, set the width of the circular progress bar, the unit is the percentage of the width of the progress bar and the canvas | [圆环用法](#圆环用法) | +| showContent | `boolean` | true | Optional, set whether to display content in the circle-shaped progress bar | [圆环用法](#圆环用法) | + + + diff --git a/docs/en-US/components/quadrant-diagram/index.md b/docs/en-US/components/quadrant-diagram/index.md new file mode 100644 index 00000000..e212464c --- /dev/null +++ b/docs/en-US/components/quadrant-diagram/index.md @@ -0,0 +1,44 @@ +# ProQuadrantDiagramgress + +Quadrant diagram。 + +### When to use + +Regional division and value sorting of affairs according to needs, which can be used to manage the priority of affairs。 + +### Basic usage + +

    Basic Usage

    + +:::demo + +```vue + + + + +``` + +::: diff --git a/docs/en-US/components/radio/index.md b/docs/en-US/components/radio/index.md new file mode 100644 index 00000000..3ab37dd6 --- /dev/null +++ b/docs/en-US/components/radio/index.md @@ -0,0 +1,307 @@ +# Radio 单选框 + +单选框。 + +### 何时使用 + +用户要从一个数据集中选择单个选项,且能并排查看所有可选项,选项数量在 2~7 之间时,建议使用单选按钮。 + +### 相互独立的单选项 + +:::demo + +```vue + + + +``` + +::: + +### radio 根据条件终止切换操作 + +:::demo 根据条件判断,第二项禁止跳转。 + +```vue + + + +``` + +::: + +### radio-group 根据条件终止切换操作 + +:::demo + +```vue + + + +``` + +::: + +### 禁用 + +:::demo + +```vue + + + +``` + +::: + +### 横向排列 + +:::demo + +```vue + + + +``` + +::: + +### 竖向排列 + +:::demo + +```vue + + + +``` + +::: + +### 自定义单选项 + +:::demo 数组源可为普通数组、对象数组等。 + +```vue + + + +``` + +::: + +### API + +d-radio 参数 + +| 参数 | 类型 | 默认 | 说明 | 跳转 Demo | +| :----------: | :------------------: | :---: | :------------------------------------------------------------------------------ | --------------------------------------- | +| name | `string` | -- | 可选,单选项名称 | [互相独立的单选项](#相互独立的单选项) | +| value | `string` | -- | 必选,单选项值 | [互相独立的单选项](#相互独立的单选项) | +| disabled | `boolean` | false | 可选,是否禁用该单选项 | [禁用](#禁用) | +| beforeChange | `Function / Promise` | -- | 可选,radio 切换前的回调函数,返回 boolean 类型,返回 false 可以阻止 radio 切换 | [回调切换](#radio-根据条件终止切换操作) | + +d-radio 事件 + +| 参数 | 类型 | 说明 | 跳转 Demo | +| :----: | :--------------------: | :------------------------------- | ------------------------------------- | +| change | `EventEmitter` | 单选项值改变时触发,返回选中的值 | [互相独立的单选项](#相互独立的单选项) | + +d-radio-group 参数 + +| 参数 | 类型 | 默认 | 说明 | 跳转 Demo | +| :----------: | :------------------: | :------: | :-------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | +| name | `string` | -- | 可选,单选框的名称 | [竖向排列](#竖向排列) | +| values | `array` | -- | 可选,单选数据组 | [竖向排列](#竖向排列) | +| disabled | `boolean` | false | 可选,是否禁用该选项组 | [radio-group 根据条件终止切换操作](#radio-group-根据条件终止切换操作) | +| cssStyle | `'row' / 'column'` | 'column' | 可选,设置横向或纵向排列 | [横向排列](#横向排列) | +| beforeChange | `Function / Promise` | -- | 可选,radio-group 切换前的回调函数,返回 boolean 类型,返回 false 可以阻止 radio-group 的切换 | [回调切换](#radio-group-根据条件终止切换操作) | + +d-radio-group 事件 + +| 参数 | 类型 | 说明 | 跳转 Demo | +| :----: | :--------------------: | :------------------------------- | --------------------- | +| change | `EventEmitter` | 单选项值改变时触发,返回选中的值 | [竖向排列](#竖向排列) | diff --git a/docs/en-US/components/rate/index.md b/docs/en-US/components/rate/index.md new file mode 100644 index 00000000..4ffde650 --- /dev/null +++ b/docs/en-US/components/rate/index.md @@ -0,0 +1,138 @@ +# Rate + +Grade evaluation。 + +When to sue +It can be used when users rate a product。 + +### Demo + +### Read-only mode + +:::demo + +```vue + + +``` + +::: + +### Dynamic mode + +:::demo + +```vue + + +``` + +::: + +### Dynamic mode-custom + +:::demo + +```vue + + +``` + +::: + +### Use the type parameter + +:::demo + +```vue + + +``` + +::: + +### API + +d-rate parameter + +| parameter | type | default | description | jump Demo | +| :-------: | :-----------------------------: | :----: | :------------------------------------------------------- | ----------------------------------- | +| read | `boolean` | false | Optional, set whether to read-only mode, read-only mode cannot be interactive | [只读模式](#只读模式) | +| count | `number` | 5 | Optional, set the total number of levels | [只读模式](#只读模式) | +| type | `'success'\|'warning'\|'error'` | -- | Optional, set the current rating type, different types correspond to different colors | [使用 type 参数](#使用-type-参数) | +| color | `string` | -- | Optional, star color | [动态模式-自定义](#动态模式-自定义) | +| icon | `string` | -- | Optional, the style of the rating icon, only supports all icons in the devUI icon library | [动态模式](#动态模式) | +| character | `string` | -- | Optional, the style of the rating icon, only one of icon and character can be set | [动态模式-自定义](#动态模式-自定义) | diff --git a/docs/en-US/components/search/index.md b/docs/en-US/components/search/index.md new file mode 100644 index 00000000..a47a8355 --- /dev/null +++ b/docs/en-US/components/search/index.md @@ -0,0 +1,95 @@ +# Search 搜索框 + +### 基本用法 + +:::demo 使用`sm`,`''`,`lg`来定义`Search`基本类型 + +```vue + +``` +::: + +### 搜索图标左置 + +:::demo 使用`left`,`right`来定义`Search`搜索图标位置, 默认`right` + +```vue + +``` +::: + +### 无边框 + +:::demo 使用`noBorder`来定义`Search`无边框 + +```vue + +``` +::: + +### 双向绑定 + +:::demo 使用`v-model`双向绑定 + +```vue + + + + +``` + +::: + +### API + +| 参数 | 类型 | 默认 | 说明 | 跳转 Demo | 全局配置项 | +| :---------: | :------: | :-------: | :----------------------- | --------------------------------- | --------- | +| size | `'sm'\|''\|'lg'` | '' | 可选,搜索框尺寸,有三种选择 lg、''、sm | [基本用法](#基本用法) || +| placeholder | `string` | -- | 可选,输入框 placeholder | [搜索图标左置](#搜索图标左置) || +| maxLength | `number` | -- | 可选,输入框的 max-length | [双向绑定](#双向绑定) || +| delay | `number` | 300 | 可选,debounceTime 的延迟 | [基本用法](#基本用法) || +| disabled | `boolean` | false | 可选,输入框是否被禁用 | [基本用法](#基本用法) || +| autoFocus | `boolean` | false | 可选,输入框是否自动对焦 | [基本用法](#基本用法) || +| isKeyupSearch | `boolean` | false | 可选,是否支持输入值立即触发 searchFn | [基本用法](#基本用法) || +| iconPosition | `string` | 'right' | 可选,搜索图标位置,有两种选择'left' / 'right' | [搜索图标左置](#搜索图标左置) || +| noBorder | `boolean` | false | 可选,是否显示边框 | [无边框](#无边框) || +| cssClass | `string` | '' | 可选,支持传入类名到输入框上 | [双向绑定](#双向绑定) || + +### d-search 事件 + +| 事件 | 类型 | 说明 | 跳转 Demo | +| :---------: | :------: | :--------------------: | :---------: | +| searchFn | `string` | 回车或点击搜索按钮触发的回调函数,返回文本框输入的值 | [基本用法](#基本用法) | + diff --git a/docs/en-US/components/select/index.md b/docs/en-US/components/select/index.md new file mode 100644 index 00000000..5440b1c7 --- /dev/null +++ b/docs/en-US/components/select/index.md @@ -0,0 +1,175 @@ +# Select 下拉选择框 + +用于从列表中选择单个或者多个数据 + +### 基本用法 + +:::demo 通过`size`:`sm`,`md(默认)`,`lg`来设置`Select`大小,通过`overview`:`underlined`设置只有下边框样式 + +```vue + + + +``` +::: + +#### 多选 + +:::demo 通过`multiple`:`true`来开启多选 + +```vue + + + +``` +::: + +#### 禁用 + +:::demo 通过`disabled`:`true`来禁用`Select`,通过`option-disabled-key`来设置单个选项禁用,比如设置`disabled`字段,则对象上disabled为`true`时不可选择 + +```vue + + + + +``` +::: + +#### 可清空 + +:::demo 通过`allow-clear`:`true`来设置`Select`可清空 + +```vue + + + + +``` +::: diff --git a/docs/en-US/components/slider/index.md b/docs/en-US/components/slider/index.md new file mode 100644 index 00000000..171e2e5b --- /dev/null +++ b/docs/en-US/components/slider/index.md @@ -0,0 +1,128 @@ +# Slider 滑动输入条 + +滑动输入条 + +### 何时使用 + +当用户需要在数值区间内进行选择时使用 + +### 基本用法 + +
    + +
    + +### 带有输入框的滑动组件 + +
    + +
    + +### 可设置 Step 的滑动组件 +
    + + +
    + +```html + + +``` + +### 禁止输入态 + +
    + +
    + +```html + + +``` + + + +### API + +d-slider 参数 + +| 参数 | 类型 | 默认 | 说明 | 跳转 | +| --------- | ------- | ----- | ------------------------------------------------------------------- | ---- | +| max | number | 100 | 可选,滑动输入条的最大值 |[基本用法](#基本用法) | +| min | number | 0 | 可选,滑动输入条的最小值 |[基本用法](#基本用法) | +| step | number | 1 | 可选,滑动输入条的步长,取值必须大于等于1,且必须可被(max-min)整除 |[基本用法](#可设置Step的滑动组件) | +| disabled | boolean | false | 可选,值为 true 时禁止用户输入 |[基本用法](#禁止输入态) | +| showInput | boolean | false | 可选,值为 true 显示输入框 |[基本用法](#带有输入框的滑动组件) | + diff --git a/docs/en-US/components/status/index.md b/docs/en-US/components/status/index.md new file mode 100644 index 00000000..4f0996af --- /dev/null +++ b/docs/en-US/components/status/index.md @@ -0,0 +1,26 @@ +# Status 状态 + +传达交互结果的组件。 + +### 何时使用 + +表示一个任务的执行结果时使用。 + +### 基本用法 +Success +Error +Warning +Initial +Waiting +Running +Invalid + +```html +Success +Error +Warning +Initial +Waiting +Running +Invalid +``` \ No newline at end of file diff --git a/docs/en-US/components/sticky/index.md b/docs/en-US/components/sticky/index.md new file mode 100644 index 00000000..e3acf7c0 --- /dev/null +++ b/docs/en-US/components/sticky/index.md @@ -0,0 +1,139 @@ +# sticky 便贴 + +### 何时使用 +当用户在滚动屏幕时,需要某个区域内容在段落或者浏览器可视区域可见时。 + +### 基本用法 + +:::demo 默认容器为父元素 + +```vue + + + + +``` +::: + +### 指定容器 + +:::demo + +```vue + + + +``` +::: + + +### 指定滚动容器 + +:::demo + +```vue + + + + +``` +::: + + +### API + +| 参数 | 类型 | 默认 | 说明 | 跳转 Demo | 全局配置项 | +| :---------: | :------: | :-------: | :----------------------- | --------------------------------- | --------- | +| zIndex | `number` | -- | 可选,指定包裹层的 z-index,用于浮动的时候控制 z 轴的叠放 | [基本用法](#基本用法) || +| container | `Element` | 父容器 | 可选,触发的容器,可不同于父容器 | [指定容器](#指定容器) || +| view | `{top?:number,bottom?:number}` | {top:0,bottom:0} | 可选,用于可视区域的调整,比如顶部有固定位置的头部等,数值对应被遮挡的顶部或底部的高度 | [基本用法](#基本用法) || +| scrollTarget | `Element` | document.documentElement | 可选,设置要发生滚动的容器,一般为滚动条所在容器,为主页面的滚动条时候可以不设置 | [指定滚动容器](#指定滚动容器) || + + +### d-sticky 事件 + +| 事件 | 类型 | 说明 | 跳转 Demo | +| :---------: | :------: | :--------------------: | :---------: | +| statusChange | `string` | 可选,状态变化的时候触发,值为变化后的状态值 | [基本用法](#基本用法) | + diff --git a/docs/en-US/components/switch/index.md b/docs/en-US/components/switch/index.md new file mode 100644 index 00000000..5845385f --- /dev/null +++ b/docs/en-US/components/switch/index.md @@ -0,0 +1,66 @@ +# Switch 开关 + +开/关切换组件。 + +### 何时使用 + +当两种状态需要来回切换控制时,比如启用/禁用。 + +### 基本用法 + +
    + +#### Small + +
    + + + +
    +
    + +#### Middle + +
    + + + +
    + + + +
    +
    + +#### Large + +
    + + + +```html + + + + +``` + + diff --git a/docs/en-US/components/tabs/index.md b/docs/en-US/components/tabs/index.md new file mode 100644 index 00000000..1fe14767 --- /dev/null +++ b/docs/en-US/components/tabs/index.md @@ -0,0 +1,7 @@ +# Tabs 选项卡切换 + +选项卡切换组件。 + +### 何时使用 + +用户需要通过平级的区域将大块内容进行收纳和展现,保持界面整洁。 diff --git a/docs/en-US/components/tag-input/index.md b/docs/en-US/components/tag-input/index.md new file mode 100644 index 00000000..80bd047c --- /dev/null +++ b/docs/en-US/components/tag-input/index.md @@ -0,0 +1,44 @@ +# TagInput 标签输入框 + +输入标签组件。 + +### 何时使用 + +当用户需要输入多个标签时。 + +### 基本用法 + + + +```html + +``` + + \ No newline at end of file diff --git a/docs/en-US/components/toast/index.md b/docs/en-US/components/toast/index.md new file mode 100644 index 00000000..2218666a --- /dev/null +++ b/docs/en-US/components/toast/index.md @@ -0,0 +1,611 @@ +# Toast 全局通知 + +全局信息提示组件。 + +### 何时使用 + +当需要向用户全局展示提示信息时使用,显示数秒后消失。 + +### 基本用法 + +common 时不展示图标。 + +
    + + + + Success + Warn + Error + Multiple + link + pure text + common + no title +
    + +```html +
    + + + + Success + Warn + Error + Multiple + link + pure text + common + no title +
    +``` + +```ts +import { defineComponent, ref } from 'vue' + +export default defineComponent({ + setup() { + const msgs = ref([]) + + function showToast(type: any) { + switch (type) { + case 'link': + msgs.value = [ + { severity: 'info', summary: 'Relative', detail: `Back to Home Page` }, + { severity: 'info', summary: 'Absolute', content: 'slot:customTemplate', myInfo: 'Devui' } + ] + break + case 'multiple': + msgs.value = [ + { + severity: 'info', + summary: 'Summary', + content: 'This is a test text. This is a test text. This is a test text.' + }, + { + severity: 'info', + summary: 'Summary', + content: 'This is a test text. This is a test text. This is a test text.' + } + ] + break + case 'noTitle': + msgs.value = [{ severity: 'warn', content: 'This is a test text. This is a test text. This is a test text.' }] + break + case 'plainText': + msgs.value = [{ severity: 'info', content: 'data:' }] + break + default: + msgs.value = [ + { + severity: type, + summary: 'Summary', + content: 'This is a test text. This is a test text. This is a test text.' + } + ] + } + } + + return { + msgs, + showToast + } + } +}) +``` + +### 超时时间 + +当设置超时时间、没有标题时,则不展示标题和关闭按钮。 + +
    + + Success + Warn + Error + common +
    + +```html +
    + + Success + Warn + Error + common +
    +``` + +```ts +import { defineComponent, ref } from 'vue' + +export default defineComponent({ + setup() { + const msgs = ref([]) + + function showToast(type: any) { + switch (type) { + case 'error': + msgs.value = [{ severity: type, content: 'This is a test text. This is a test text. This is a test text.' }] + break + case 'common': + msgs.value = [{ severity: type, content: 'This is a test text. This is a test text. This is a test text.' }] + break + default: + msgs.value = [ + { + severity: type, + summary: 'Summary', + content: 'This is a test text. This is a test text. This is a test text.' + } + ] + } + } + + return { + msgs, + showToast + } + } +}) +``` + +### 自定义样式 + +
    + +
    + + Custom Style +
    + +```html +
    + + Custom Style +
    +``` + +```scss +.custom-class { + .devui-toast-item-container { + color: #252b3a; + background-color: #ffffff; + + .devui-toast-icon-close { + top: 10px; + right: 13px; + + & i.icon { + color: #252b3a !important; + } + } + + .devui-toast-image { + top: 15px; + } + + .devui-toast-message { + line-height: 23px; + + .devui-toast-title { + font-size: 16px; + } + + p { + font-size: 14px; + } + } + } +} +``` + +```ts +import { defineComponent, ref } from 'vue' + +export default defineComponent({ + setup() { + const msgs = ref([]) + + function showToast() { + msgs.value = [ + { + severity: 'success', + summary: 'Success', + content: 'This is a test text. This is a test text. This is a test text.' + } + ] + } + + return { + msgs, + showToast + } + } +}) +``` + +### 每个消息使用单独的超时时间 + +当设置超时时间模式为 single 时,每个消息使用自身的 life 作为超时时间,如果未设置则按 severity 判断,severity 也未设置时默认超时时间为 5000 毫秒。 + +
    + + Single +
    + +```html +
    + + Single +
    +``` + +```ts +import { defineComponent, ref } from 'vue' + +export default defineComponent({ + setup() { + const msgs = ref([]) + + function showToast() { + msgs.value = [ + { life: 3000, summary: 'Summary', content: 'This is a test text. This is a test text. This is a test text.' }, + { + life: 6000, + severity: 'info', + summary: 'Summary', + content: 'This is a test text. This is a test text. This is a test text.' + }, + { + severity: 'success', + summary: 'Success', + content: 'This is a test text. This is a test text. This is a test text.' + }, + { severity: 'warn', summary: 'Warn', content: 'This is a test text. This is a test text. This is a test text.' } + ] + } + + return { + msgs, + showToast + } + } +}) +``` + +### 服务方式调用 + +使用服务的方式创建 toast 全局通知。 + +click me show simplest toast! +click me show customer toast! +click me close customer toast! +only close first customer toast! + +```html +click me show simplest toast! +click me show customer toast! +click me close customer toast! +only close first customer toast! +``` + +```ts +import { defineComponent, ref } from 'vue' +import { ToastService } from 'devui/toast' + +export default defineComponent({ + setup() { + const results = ref() + + function openToast2() { + results.value = ToastService.open({ + value: [ + { severity: 'info', summary: 'summary', content: '1. I am content' }, + { severity: 'error', summary: 'summary', content: '2. I am content' }, + { severity: 'error', summary: 'summary', content: '3. I am content' } + ], + sticky: true, + style: { width: '600px', color: 'red' }, + styleClass: 'myCustom-toast', + life: 5000, + lifeMode: 'global', + /* + 接收发射过来的数据 + */ + onCloseEvent(value: any) { + console.log('closeEvent', value) + }, + onValueChange(value: any) { + console.log('valueChange', value) + } + }) + + console.log('results', results.value) + + isShow.value = true + } + + function closeToast2() { + results.value.toastInstance.close() + isShow.value = false + } + + function closeToast3() { + /* + 1.可以根据指定下标关闭 results.value.toastInstance.close(0); + 2.可以根据value对象去关闭,作用跟1是等同的,如下所示: + */ + results.value.toastInstance.close({ severity: 'info', summary: 'summary', content: '1. I am content' }) + } + + return { + isShow, + openToast, + openToast2, + closeToast2, + closeToast3 + } + } +}) +``` + +### Toast Api + + + +### Toast Event + + + +### 接口 & 类型定义 + +Message + +```ts +export interface Message { + severity?: string // 预设值有 common、success、error、warn、info,超时时间参见 life 说明,未设置或非预设值时超时时间为 5000 毫秒,warn 和 error 为 10000 毫秒 + summary?: string // 消息标题。当设置超时时间,未设置标题时,不展示标题和关闭按钮 + detail?: string // 消息内容,推荐使用content替换 + content?: string | `slot:${string}` | (message: Message) => ReturnType // 消息内容,支持纯文本和插槽,推荐使用 + life?: number // 单个消息超时时间,需设置 lifeMode 为 single 。每个消息使用自己的超时时间,开启该模式却未设置时按 severity 判断超时时间 + id?: any // 消息ID +} +``` + +### Service 引入方式 + +```ts +import { ToastService } from 'devui' +``` + +### Service 使用 + +```ts +// 方式 1,局部引入 ToastService +ToastService.open({ xxx }) + +// 方式2,全局属性 +app.config.globalProperties.$toastService.open({ xxx }) +``` + +### Service Api + + + + + + diff --git a/docs/en-US/components/tooltip/index.md b/docs/en-US/components/tooltip/index.md new file mode 100644 index 00000000..3faa69f2 --- /dev/null +++ b/docs/en-US/components/tooltip/index.md @@ -0,0 +1,100 @@ +# Tooltip + +Text prompt component。 + +### When to use + +The user moves the mouse to the text, and it is used when further prompts are needed。 + +### Basic usage + +:::demo We can control the display position of the tooltip by controlling the attribute `position`. There are 4 values for `position`, which are `top`, `right`, `bottom`, and `left`. Control the content of the tooltip prompt box through the attribute `content`。 + + + + + + + + + +```vue + +``` + +```css +.example { + height: 50px; + width: 60px; + background: cornflowerblue; + margin-top: 30px; +} +``` +::: + +### Delay trigger + +The mouse will be triggered after moving in for more than [mouseEnterDelay] milliseconds to prevent flashing caused by the user accidentally swiping. The default value is 150 milliseconds; after the mouse is moved out, the toolTip component will be hidden after [mouseLeaveDelay] milliseconds. The default value Is 100 milliseconds。 + +:::demo Use the `mouseEnterDelay` property to control the `delay display` of the tooltip prompt box (the default is 100ms), and the `mouseLeaveDelay` property to control the `delay disappearing` of the tooltip prompt box (the default is 150ms) +
    MouseEnter delay 500ms
    + +
    MouseLeave delay 1000ms
    +```vue + +``` + +```css +.customCss { + width: fit-content; + height: 30px; + padding: 10px; + display: flex; + justify-content: center; + align-items: center; + color: #fff; + background: cornflowerblue; +} +.customCss-leave { + width: fit-content; + height: 30px; + padding: 10px; + display: flex; + justify-content: center; + align-items: center; + color: #252b3a; + background: #fff; +} +``` +::: + +### Tooltip Api + +| parameter | type | default | description | jump Demo | Global configuration items | +| :---------: | :------: | :-------: | :----------------------- | --------------------------------- | --------- | +| content | `string|DOMString` | -- | Required, tooltip displays content | [基本用法](#基本用法) || +| position | `PositionType | PositionType[]` | ['top', 'right', 'bottom', 'left'] | Optional, tooltip display position | [基本用法](#基本用法) || +| showAnimation | `boolean` | true | Optional, whether to show the wipe out animation | |✔| +| mouseEnterDelay | `number` | 150 | Optional, how long is the delay before the Tooltip is displayed after the mouse moves in, the unit is ms | [基本用法](#延时触发) || +| mouseLeaveDelay | `number` | 100 | Optional, after the mouse is moved out, how long is the delay before the Tooltip is hidden, the unit is ms | [基本用法](#延时触发) || diff --git a/docs/en-US/components/transfer/index.md b/docs/en-US/components/transfer/index.md new file mode 100644 index 00000000..988204fe --- /dev/null +++ b/docs/en-US/components/transfer/index.md @@ -0,0 +1,224 @@ +# Transfer 穿梭框 + +双栏穿梭选择框。 + +### 何时使用 + +需要在多个可选项中进行多选时。穿梭选择框可用只管的方式在两栏中移动数据,完成选择行为。其中左边一栏为source,右边一栏为target。最终返回两栏的数据,提供给开发者使用。 + +### 基本用法 + +穿梭框基本用法。 + +
    + + +
    + + + +```html + + +``` + +```ts +import {defineComponent, reactive} from 'vue' + type TData = { + id: number + age: number + value: string + disabled?: boolean + } + export default defineComponent({ + setup() { + const options = reactive({ + titles: ['sourceHeader', 'targetHeader'], + source: [ + { + key: '北京', + value: '北京', + disabled: false + }, + { + key: '上海', + value: '上海', + disabled: true + }, + { + key: '广州', + value: '广州', + disabled: false + }, + { + key: '深圳', + value: '深圳', + disabled: false + }, + { + key: '成都', + value: '成都', + disabled: false + }, + { + key: '武汉', + value: '武汉', + disabled: false + }, + { + key: '西安', + value: '西安', + disabled: false + }, + { + key: '福建', + value: '福建', + disabled: false + }, + { + key: '大连', + value: '大连', + disabled: false + }, + { + key: '重庆', + value: '重庆', + disabled: false + } + ], + target: [ + { + key: '南充', + value: '南充', + disabled: false + }, + { + key: '广元', + value: '广元', + disabled: true + }, + { + key: '绵阳', + value: '绵阳', + disabled: false + } + ], + isSearch: true, + modelValues: ['深圳', '成都', '绵阳'] + }) + return { + options + } + } + }) +``` + +### 参数 + +| **参数** | **类型** | **默认** | **说明** | **跳转 Demo** | +| ------------------ | ------------------------------------------------------------ | ------------------------- | ------------------------------------------------------------ | ---------------------------- | +| sourceOption | Array | [] | 可选参数,穿梭框源数据 | [基本用法](#基本用法) | +| targetOption | Array | [] | 可选参数,穿梭框目标数据 | [基本用法](#基本用法) | +| titles | Array | [] | 可选参数,穿梭框标题 | [基本用法](#基本用法) | +| height | string | 320px | 可选参数,穿梭框高度 | [基本用法](#基本用法) | +| isSearch | boolean | true | 可选参数,是否可以搜索 | [基本用法](#基本用法) | +| disabled | boolean | false | 可选参数 穿梭框禁止使用 | [基本用法](#基本用法) | diff --git a/docs/en-US/components/upload/index.md b/docs/en-US/components/upload/index.md new file mode 100644 index 00000000..b2f8d8c2 --- /dev/null +++ b/docs/en-US/components/upload/index.md @@ -0,0 +1,1297 @@ +# Upload + +File upload component。 + +### When to use + +When you need to upload files to the back-end server。 + +### Basic usage + +Single file upload, drag file upload, prohibit upload。 + +

    Basic Usage

    + +:::demo + +```vue + + +``` + +::: + +

    Dragdrop

    + +:::demo + +```vue + + +``` + +::: + +

    Disabled

    + +:::demo + +```vue + + +``` + +::: + +### Multiple file upload + +Multi-file upload, support drag file upload, prohibit upload。 + +

    Basic Usage

    + +:::demo + +```vue + + +``` + +::: + +

    Upload Directory

    + +:::demo + +```vue + + +``` + +::: + +

    Dragdrop

    + +:::demo + +```vue + + +``` + +::: + +

    Disabled

    + +:::demo + +```vue + + +``` + +::: + +### Auto upload + +Set up automatic upload via autoUpload。 + +:::demo + +```vue + + +``` + +::: + +### customize + +Customize the upload button, set the selected file list template through slot preloadFiles, and set the uploaded file list template through slot uploadedFiles。 + +:::demo + +```vue + + + +``` + +::: + +### Dynamic upload parameters + +Users can dynamically modify upload parameters through beforeUpload。 + +:::demo + +```vue + + +``` + +::: + +### Upload from any area + +Users can upload files in any area through the default slot。 +:::demo + +```vue + + +``` + +::: + +自定义默认 slot,初始显示已上传文件。 + +:::demo + +```vue + + + +``` + +::: + +### API + +d-single-upload 参数 + +| **参数** | **类型** | **默认** | 说明 | **跳转 Demo** | +| ---------------------- | --------------------------------- | ---------- | ---------------------------------------------------------------------------------------- | --------------------- | +| fileOptions | [IFileOptions](#ifileoptions) | -- | 必选,待上传文件配置 | [基本用法](#基本用法) | +| filePath | `string` | -- | 文件路径 | [基本用法](#基本用法) | +| uploadOptions | [IUploadOptions](#iuploadoptions) | \-- | 必选,上传配置 | [基本用法](#基本用法) | +| autoUpload | `boolean` | false | 可选,是否自动上传 | [基本用法](#基本用法) | +| placeholderText | `string` | '选择文件' | 可选,上传输入框中的 Placeholder 文字 | [基本用法](#基本用法) | +| uploadText | `string` | '上传' | 可选,上传按钮文字 | [基本用法](#基本用法) | +| uploadedFiles | `Array` | [] | 可选,获取已上传的文件列表 | [基本用法](#基本用法) | +| withoutBtn | `boolean` | false | 可选,是否舍弃按钮 | [基本用法](#基本用法) | +| enableDrop | `boolean` | false | 可选,是否支持拖拽 | [基本用法](#基本用法) | +| beforeUpload | `boolean Promise ` | \-- | 可选,上传前的回调,通过返回`true` or `false` ,控制文件是否上传,参数为文件信息及上传配置 | [基本用法](#基本用法) | +| dynamicUploadOptionsFn | [IUploadOptions](#iuploadoptions) | \-- | 为文件动态设置自定义的上传参数, 参数为当前选中文件及`uploadOptions`的值 | [基本用法](#基本用法) | +| disabled | `boolean` | false | 可选,是否禁用上传组件 | [基本用法](#基本用法) | +| showTip | `boolean` | false | 可选,是否显示上传提示信息 | [自动上传](#自动上传) | + +d-single-upload 事件 + +| 参数 | 类型 | 说明 | 跳转 Demo | +| ----------------------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | --------------------- | +| fileOver | `EventEmitter` | 支持拖拽上传时,文件移动到可拖放区域触发事件,可拖动的元素移出放置目标时返回`false`,元素正在拖动到放置目标时返回`true` | [基本用法](#基本用法) | +| fileDrop | `EventEmitter` | 支持拖拽上传时,当前拖拽的文件列表回调,单文件上传默认返回第一个文件 | [基本用法](#基本用法) | +| successEvent | `EventEmitter>` | 上传成功时的回调函数,返回文件及 xhr 的响应信息 | [基本用法](#基本用法) | +| errorEvent | `EventEmitter<{file: File; response: any}>` | 上传错误时的回调函数,返回上传失败的错误信息 | [基本用法](#基本用法) | +| deleteUploadedFileEvent | `EventEmitter` | 删除上传文件的回调函数,返回删除文件的路径信息 | [基本用法](#基本用法) | +| fileSelect | `EventEmitter` | 文件选择后的回调函数,返回已选择文件信息 | [基本用法](#基本用法) | + +d-multiple-upload 参数 + +| **参数** | **类型** | **默认** | 说明 | **跳转 Demo** | +| ---------------------- | --------------------------------- | -------------- | ---------------------------------------------------------------------------------------- | ------------------------- | +| fileOptions | [IFileOptions](#ifileoptions) | -- | 必选,待上传文件配置 | [多文件上传](#多文件上传) | +| filePath | `string` | -- | 文件路径 | [多文件上传](#多文件上传) | +| uploadOptions | [IUploadOptions](#iuploadoptions) | \-- | 必选,上传配置 | [多文件上传](#多文件上传) | +| autoUpload | `boolean` | false | 可选,是否自动上传 | [自动上传](#自动上传) | +| placeholderText | `string` | '选择多个文件' | 可选,上传输入框中的 Placeholder 文字 | [基本用法](#基本用法) | +| uploadText | `string` | '上传' | 可选,上传按钮文字 | [基本用法](#基本用法) | +| uploadedFiles | `Array` | [] | 可选,获取已上传的文件列表 | [多文件上传](#多文件上传) | +| withoutBtn | `boolean` | false | 可选,是否舍弃按钮 | [自定义](#自定义) | +| enableDrop | `boolean` | false | 可选,是否支持拖拽 | [多文件上传](#多文件上传) | +| beforeUpload | `boolean Promise` | \-- | 可选,上传前的回调,通过返回`true` or `false` ,控制文件是否上传,参数为文件信息及上传配置 | [多文件上传](#多文件上传) | +| dynamicUploadOptionsFn | [IUploadOptions](#iuploadoptions) | \-- | 为文件动态设置自定义的上传参数, 参数为当前选中文件及`uploadOptions`的值 | [多文件上传](#多文件上传) | +| disabled | `boolean` | false | 可选,是否禁用上传组件 | [多文件上传](#多文件上传) | +| showTip | `boolean` | false | 可选,是否显示上传提示信息 | [多文件上传](#多文件上传) | +| setCustomUploadOptions | [IUploadOptions](#iuploadoptions) | -- | 为每个文件设置自定义的上传参数, 参数为当前选中文件及`uploadOptions`的值 | [自定义](#自定义) | + +d-multiple-upload 事件 + +| 参数 | 类型 | 说明 | 跳转 Demo | +| ----------------------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------- | +| fileOver | `EventEmitter` | 支持拖拽上传时,文件移动到可拖放区域触发事件,可拖动的元素移出放置目标时返回`false`,元素正在拖动到放置目标时返回`true` | [多文件上传](#多文件上传) | +| fileDrop | `EventEmitter` | 支持拖拽上传时,当前拖拽的文件列表回调,单文件上传默认返回第一个文件 | [多文件上传](#多文件上传) | +| successEvent | `EventEmitter>` | 上传成功时的回调函数,返回文件及 xhr 的响应信息 | [多文件上传](#多文件上传) | +| errorEvent | `EventEmitter<{file: File; response: any}>` | 上传错误时的回调函数,返回上传失败的错误信息 | [多文件上传](#多文件上传) | +| deleteUploadedFileEvent | `EventEmitter` | 删除上传文件的回调函数,返回删除文件的路径信息 | [多文件上传](#多文件上传) | +| fileSelect | `EventEmitter` | 文件选择后的回调函数,返回已选择文件信息 | [多文件上传](#多文件上传) | + +### slot + +| name | 默认 | 说明 | 跳转 Demo | +| ------------- | ---- | ----------------------------------------------------------------------------- | ----------------- | +| preloadFiles | -- | 可选,用于创建自定义 已选择文件列表模板,参数为 `{fileUploaders, deleteFile}` | [自定义](#自定义) | +| uploadedFiles | -- | 可选,用于创建自定义 已上传文件列表模板,参数为 `{uploadedFiles, deleteFile}` | [自定义](#自定义) | + +### 接口 & 类型定义 + +### IUploadOptions + +```typescript +export class IUploadOptions { + // 上传接口地址 + uri: string + // http 请求方法 + method?: string + // 上传文件大小限制 + maximumSize?: number + // 自定义请求headers + headers?: { [key: string]: any } + // 认证token + authToken?: string + // 认证token header标示 + authTokenHeader?: string + // 上传额外自定义参数 + additionalParameter?: { [key: string]: any } + // 上传文件字段名称,默认file + fileFieldName?: string + // 多文件上传,是否检查文件重名,设置为true,重名文件不会覆盖,否则会覆盖上传 + checkSameName?: boolean + // 指示了是否该使用类似cookies,authorization headers(头部授权)或者TLS客户端证书这一类资格证书来创建一个跨站点访问控制(cross-site Access-Control)请求 + withCredentials?: boolean + // 手动设置返回数据类型 + responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' +} +``` + +### IFileOptions + +```typescript +export class IFileOptions { + // 规定能够通过文件上传进行提交的文件类型,例如 accept: '.xls,.xlsx,.pages,.mp3,.png' + accept?: string + // 输入字段可选择多个值 + multiple?: boolean + // 是否允许用户选择文件目录,而不是文件 + webkitdirectory?: boolean +} +``` diff --git a/docs/en-US/design.md b/docs/en-US/design.md new file mode 100644 index 00000000..f936956a --- /dev/null +++ b/docs/en-US/design.md @@ -0,0 +1 @@ +# Design \ No newline at end of file diff --git a/docs/en-US/index.md b/docs/en-US/index.md new file mode 100644 index 00000000..4194e11d --- /dev/null +++ b/docs/en-US/index.md @@ -0,0 +1,43 @@ +# Quick Start + +Guide you how to use DevUI in your project + +### Vue version + +Vue version currently supported ^3.0.0 + +### 1. Create a project + +It is recommended to use @vite/cli to create your project + +```shell +yarn create vite my-vue-app --template vue-ts +``` + +### 2. Install + +Go to your project folder and use yarn to install DevUI + +```shell +yarn add vue-devui + +# 可选,字体图标库, 部分Demo依赖此字体库 +# yarn add @devui-design/icons +``` + +### 3. Introduce modules and styles + +main.ts + +```js +import DevUI from 'vue-devui' +import 'vue-devui/style.css' + +createApp(App).use(DevUI).mount('#app') +``` + +### 4. Start development and debugging + +```shell +yarn dev +``` \ No newline at end of file diff --git a/docs/en-US/theme.md b/docs/en-US/theme.md new file mode 100644 index 00000000..b29f0a86 --- /dev/null +++ b/docs/en-US/theme.md @@ -0,0 +1 @@ +# Theme \ No newline at end of file diff --git a/docs/en-US/version.md b/docs/en-US/version.md new file mode 100644 index 00000000..e04a043b --- /dev/null +++ b/docs/en-US/version.md @@ -0,0 +1 @@ +# Version \ No newline at end of file -- Gitee From 6b107a1abe137848658d3a408142c38eb921c4b2 Mon Sep 17 00:00:00 2001 From: lwl <1181102955@qq.com> Date: Sun, 31 Oct 2021 21:44:12 +0800 Subject: [PATCH 08/59] feat: add character --- .../components/cascader-item/index.tsx | 27 +++-- .../components/cascader-item/use-class.ts | 22 ++-- .../cascader-list/cascader-list-types.ts | 6 +- .../devui/cascader/hooks/use-cascader-item.ts | 9 +- .../cascader/hooks/use-cascader-popup.ts | 8 ++ .../devui/cascader/src/cascader-types.ts | 12 ++- .../devui-vue/devui/cascader/src/cascader.tsx | 101 ++++++++++++++---- .../docs/components/cascader/index.md | 13 ++- 8 files changed, 149 insertions(+), 49 deletions(-) diff --git a/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx b/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx index ceb5d690..9203b7b4 100644 --- a/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx +++ b/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx @@ -1,22 +1,27 @@ -import { getRootClass } from './use-class' +import { useClassName } from './use-class' import { CascaderItemPropsType } from '../cascader-list/cascader-list-types' -import { computed } from 'vue' +import { computed, ref } from 'vue' +import { cloneDeep } from 'lodash-es' + import './index.scss' export const DCascaderItem = (props: CascaderItemPropsType) => { - console.log('item index',props) + // console.log('item index',props) const { cascaderItem, ulIndex, liIndex, cascaderItemNeedProps } = props - const { multiple, value } = cascaderItemNeedProps + const { multiple, stopDefault } = cascaderItemNeedProps const disbaled = computed(() => cascaderItem?.disabled) // 当前项是否被禁用 + const { getRootClass } = useClassName() const rootClasses = getRootClass(props) const triggerHover = cascaderItemNeedProps.trigger === 'hover' // 触发联动更新 const updateValues = () => { + if (stopDefault.value) return if (!multiple) { - // 单选模式 + // 单选模式: // 删除当前联动级之后的所有级 cascaderItemNeedProps.value.splice(ulIndex, cascaderItemNeedProps.value.length - ulIndex) // 更新当前active的value数组 - cascaderItemNeedProps.value[ulIndex] = liIndex + cascaderItemNeedProps.value[ulIndex] = cascaderItem?.value as number + // console.log(cascaderItemNeedProps.value) } else { // 多选模式 console.log(cascaderItemNeedProps.value) @@ -28,7 +33,7 @@ export const DCascaderItem = (props: CascaderItemPropsType) => { updateValues() } const mouseenter = { - [ triggerHover && 'onMouseenter']: mouseEnter + [ triggerHover && 'onMouseenter' ]: mouseEnter } // 鼠标click const mouseClick = () => { @@ -40,9 +45,11 @@ export const DCascaderItem = (props: CascaderItemPropsType) => { } return (
  • -
    - -
    + { multiple && +
    + +
    + } { cascaderItem.icon &&
    diff --git a/packages/devui-vue/devui/cascader/components/cascader-item/use-class.ts b/packages/devui-vue/devui/cascader/components/cascader-item/use-class.ts index 2e950499..b66972c8 100644 --- a/packages/devui-vue/devui/cascader/components/cascader-item/use-class.ts +++ b/packages/devui-vue/devui/cascader/components/cascader-item/use-class.ts @@ -4,13 +4,19 @@ import { computed, ComputedRef } from 'vue'; import { CascaderItemPropsType } from '../cascader-list/cascader-list-types' - export const getRootClass = (props: CascaderItemPropsType): ComputedRef => { - const activeFlg = props?.cascaderItemNeedProps?.value[props.ulIndex] === props.liIndex - const disabledFlg = props.cascaderItem?.disabled - return computed(() => ({ - 'devui-cascader-li devui-dropdown-item': true, - 'devui-leaf-active': activeFlg, - 'disabled': disabledFlg - })) + export const useClassName= () => { + const getRootClass = (props: CascaderItemPropsType): ComputedRef => { + const itemProps = props?.cascaderItemNeedProps + const activeFlg = itemProps?.value[props.ulIndex] === props.cascaderItem?.value + const disabledFlg = props.cascaderItem?.disabled + return computed(() => ({ + 'devui-cascader-li devui-dropdown-item': true, + 'devui-leaf-active': activeFlg, + 'disabled': disabledFlg + })) + } + return { + getRootClass + } } \ No newline at end of file diff --git a/packages/devui-vue/devui/cascader/components/cascader-list/cascader-list-types.ts b/packages/devui-vue/devui/cascader/components/cascader-list/cascader-list-types.ts index 019d452f..95fb3c98 100644 --- a/packages/devui-vue/devui/cascader/components/cascader-list/cascader-list-types.ts +++ b/packages/devui-vue/devui/cascader/components/cascader-list/cascader-list-types.ts @@ -1,4 +1,4 @@ -import type { PropType, ExtractPropTypes } from 'vue' +import type { PropType, ExtractPropTypes, Ref } from 'vue' import { CascaderItem, CascaderItemNeedType } from '../../src/cascader-types' export const cascaderulProps = { /** @@ -23,6 +23,10 @@ export const cascaderulProps = { type: Object as PropType, default: {} }, + stopDefault: { + type: Boolean, + default: false + }, cascaderOptions: { type: Array as unknown as PropType<[CascaderItem[]]>, default: [] diff --git a/packages/devui-vue/devui/cascader/hooks/use-cascader-item.ts b/packages/devui-vue/devui/cascader/hooks/use-cascader-item.ts index dbe1603d..b1cea7c3 100644 --- a/packages/devui-vue/devui/cascader/hooks/use-cascader-item.ts +++ b/packages/devui-vue/devui/cascader/hooks/use-cascader-item.ts @@ -2,14 +2,17 @@ * 处理cascader-item中需要的参数 */ import { CascaderProps, UseCascaderItemCallback } from '../src/cascader-types' -import { ref, reactive } from 'vue' -export const useCascaderItem = (props: CascaderProps): UseCascaderItemCallback => { +import { ref, reactive, Ref } from 'vue' +import { cloneDeep } from 'lodash-es' + +export const useCascaderItem = (props: CascaderProps, stopDefault: Ref): UseCascaderItemCallback => { const cascaderItemNeedProps = { trigger: props.trigger, inputValueCache: ref(''), confirmInputValueFlg: ref(false), // 用于监听点击确定时输出选择内容 - value: reactive(props.value), + value: reactive(cloneDeep(props.value)), // 每级的value multiple: props.multiple, + stopDefault, } return { cascaderItemNeedProps diff --git a/packages/devui-vue/devui/cascader/hooks/use-cascader-popup.ts b/packages/devui-vue/devui/cascader/hooks/use-cascader-popup.ts index 64ecefff..8e1b4e25 100644 --- a/packages/devui-vue/devui/cascader/hooks/use-cascader-popup.ts +++ b/packages/devui-vue/devui/cascader/hooks/use-cascader-popup.ts @@ -8,9 +8,15 @@ export const popupHandles = (props: CascaderProps): PopupTypes => { const menuShow = ref(false) const menuOpenClass = ref('') const disabled = computed(() => props.disabled) // select是否被禁用 + const stopDefault = ref(false) + const updateStopDefaultType = () => { + stopDefault.value = !menuShow.value + } + const openPopup = () => { if (disabled.value) return menuShow.value = !menuShow.value + updateStopDefaultType() } watch(menuShow, (status) => { @@ -19,7 +25,9 @@ export const popupHandles = (props: CascaderProps): PopupTypes => { return { menuShow, + stopDefault, menuOpenClass, + updateStopDefaultType, openPopup, } } diff --git a/packages/devui-vue/devui/cascader/src/cascader-types.ts b/packages/devui-vue/devui/cascader/src/cascader-types.ts index 663cd1c0..bd099bb4 100644 --- a/packages/devui-vue/devui/cascader/src/cascader-types.ts +++ b/packages/devui-vue/devui/cascader/src/cascader-types.ts @@ -47,7 +47,14 @@ export const cascaderProps = { default: false }, /** - * 可选,级联器选中的数组下标value + * 可选,级联器选中项是否显示路径,仅单选模式下生效 + */ + showPath: { + type: Boolean, + default: false + }, + /** + * 可选,需要选中项的value集合 * @type {CascaderValueType} * @default [] */ @@ -81,7 +88,9 @@ export type CascaderProps = ExtractPropTypes export interface PopupTypes { menuShow: Ref menuOpenClass: Ref + stopDefault: Ref openPopup: (e?: MouseEvent) => void + updateStopDefaultType: () => void } export type CaascaderOptionsType = UnwrapNestedRefs<[CascaderItem[]]> @@ -97,6 +106,7 @@ export interface CascaderItemNeedType extends PickCascader { inputValueCache: Ref confirmInputValueFlg: Ref multiple: boolean + stopDefault: Ref } export interface UseCascaderItemCallback { cascaderItemNeedProps: CascaderItemNeedType diff --git a/packages/devui-vue/devui/cascader/src/cascader.tsx b/packages/devui-vue/devui/cascader/src/cascader.tsx index 59566546..a648e44d 100644 --- a/packages/devui-vue/devui/cascader/src/cascader.tsx +++ b/packages/devui-vue/devui/cascader/src/cascader.tsx @@ -5,17 +5,19 @@ import { popupHandles } from '../hooks/use-cascader-popup' import DCascaderList from '../components/cascader-list' // import { optionsHandles } from '../hooks/use-cascader-options' import { useCascaderItem } from '../hooks/use-cascader-item' +import { cloneDeep } from 'lodash-es' import './cascader.scss' // import { UnwrapNestedRefs } from '@vue/reactivity' -// type ValueType = UnwrapNestedRefs +// type OptionsType = UnwrapNestedRefs<[CascaderItem[]]> export default defineComponent({ name: 'DCascader', props: cascaderProps, setup(props: CascaderProps, ctx) { const origin = ref(null) - const cascaderOptions = reactive<[CascaderItem[]]>([ props?.options ]) + const cascaderOptions = reactive<[CascaderItem[]]>(cloneDeep([ props?.options ])) const multiple = toRef(props, 'multiple') const inputValue = ref('') + let initIptValue = props.value.length > 0 ? true : false const position = reactive({ originX: 'left', originY: 'bottom', @@ -23,43 +25,104 @@ export default defineComponent({ overlayY: 'top' } as const) // popup弹出层 - const { menuShow, menuOpenClass, openPopup } = popupHandles(props) + const { menuShow, menuOpenClass, openPopup, stopDefault, updateStopDefaultType } = popupHandles(props) // 配置class const rootClasses = getRootClass(props, menuShow) // 传递给cascaderItem的props - const { cascaderItemNeedProps } = useCascaderItem(props) + const { cascaderItemNeedProps } = useCascaderItem(props, stopDefault) /** * * @param value value数组 - * @param index 起始项 + * @param currentOption 选中的某项 + * @param index 数组项 */ const getCascaderLoop = (value: CascaderValueType, currentOption: CascaderItem[], index: number) => { - if (index === value.length) return // 区分单选多选模式 if (!multiple.value) { - const i = value[index] - getInputValue(currentOption[i as number]?.label, currentOption[i as number]?.children) - if (currentOption[i as number]?.children?.length > 0) { + if (index === value.length) return + const i = value[index] as number + // 当前的子级 + const current = getCurrentOption(currentOption, i) + const children = current?.children + getInputValue(current.label, children) + if (children?.length > 0) { // 为下一级增添数据 - cascaderOptions[index + 1] = currentOption[i as number].children + cascaderOptions[index + 1] = children // 递归添加 - getCascaderLoop(value, currentOption[i as number].children, index + 1) + getCascaderLoop(value, children, index + 1) } else { // 当最新的ul(级)没有下一级时删除之前选中ul的数据 cascaderOptions.splice(index + 1, cascaderOptions.length - 1) } } else { // 多选模式 + // console.log('currentOption', currentOption) + value.forEach(singleValues => { + console.log('singleValues', singleValues) + getMultipleCascaderItem(currentOption, singleValues, index) + }) } } /** * - * @param value 当前value数组 + * 筛选每列中选中的value + */ + const getCurrentOption = (currentOption: CascaderItem[], i: number) => { + return currentOption.filter(item => item?.value === i)[0] + } + /** + * 需要判断是否是多选 + * 需要判断单选模式下是否showPath + * @param label 当前current的内容 + * @param arr 当前选中项current的children数组 */ const getInputValue = (label: string, arr?: CascaderItem[]) => { - cascaderItemNeedProps.inputValueCache.value += (label + (arr?.length > 0 ? ' / ' : '')) + if (!props.showPath) { + cascaderItemNeedProps.inputValueCache.value = label + } else { + cascaderItemNeedProps.inputValueCache.value += (label + (arr?.length > 0 ? ' / ' : '')) + } + } + const getMultipleIptValue = () => { + + } + /** + * @param currentOption 选中的某项 + * @param cascaderUlValues 多选集合中的某一个集合 + * @param index cascaderUlValues数组的起始项,最开始为0 + */ + const getMultipleCascaderItem = (currentOption: CascaderItem[], cascaderUlValues: number[], index: number) => { + console.log('currentOption', currentOption, cascaderUlValues[index], index) + let nextOption = null + for (let i = 0; i < currentOption.length; i++) { + if (currentOption[i]?.value === cascaderUlValues[index]) { + nextOption = currentOption[i] + break + } + } + console.log(nextOption?.label) + if (nextOption?.children?.length > 0) { + index += 1 + getMultipleCascaderItem(nextOption.children, cascaderUlValues, index) + } } + // const initMultipleActiveItem = () + /** + * 触发input内容输出监听 + */ + const triggerUpdateIptValue = () => { + cascaderItemNeedProps.confirmInputValueFlg.value = !cascaderItemNeedProps.confirmInputValueFlg.value + } + /** + * 监听点击最终的节点输出内容 + */ + watch(() => cascaderItemNeedProps.confirmInputValueFlg.value, () => { + inputValue.value = cascaderItemNeedProps.inputValueCache.value + menuShow.value = false + // 点击确定过后禁止再次选中 + updateStopDefaultType() + }) /** * 监听value值的改变 * 改变cascaderOptions弹窗内容 @@ -67,19 +130,15 @@ export default defineComponent({ */ watch(cascaderItemNeedProps.value, (val) => { cascaderItemNeedProps.inputValueCache.value = '' - if (!multiple.value) { - getCascaderLoop(val, props?.options, 0) - } else { - console.log(val) + getCascaderLoop(val, props?.options, 0) + if (initIptValue) { // 因为初始化了value,所以默认输出值 + triggerUpdateIptValue() + initIptValue = false // 只需要初始化一次,之后不再执行 } }, { immediate: true }) - watch(() => cascaderItemNeedProps.confirmInputValueFlg.value, () => { - inputValue.value = cascaderItemNeedProps.inputValueCache.value - menuShow.value = false - }) return () => ( <>
    diff --git a/packages/devui-vue/docs/components/cascader/index.md b/packages/devui-vue/docs/components/cascader/index.md index f5ed5782..e900d06f 100644 --- a/packages/devui-vue/docs/components/cascader/index.md +++ b/packages/devui-vue/docs/components/cascader/index.md @@ -1,15 +1,12 @@ # Cascader 级联菜单 下拉级联菜单。 -<<<<<<< HEAD:docs/components/cascader/index.md -======= ### 何时使用 1. 需要从一组相关联的数据集合进行选择,例如省市区,公司层级,事物分类等。 2. 从一个较大的数据集合中进行选择时,用多级分类进行分隔,方便选择。 ->>>>>>> dev:packages/devui-vue/docs/components/cascader/index.md ### 基本用法 :::demo @@ -19,7 +16,7 @@

    hover mode

    click mode

    - +

    data empty

    disabled

    @@ -222,9 +219,11 @@ export default defineComponent({ disabled: true } ]) + const value = [1, 4, 9, 81] return { options, - options2 + options2, + value } }, }) @@ -388,6 +387,10 @@ export default defineComponent({ | options | [`CascaderItem[]`](#CascaderItem) | [] | 必选,级联器的菜单信息 | [基本用法](#基本用法) | | | placeholder | `string` | '' | 可选,没有选择时的输入框展示信息 | [基本用法](#基本用法) | | | disabled | `boolean` | false | 可选,级联器是否禁用 | [基本用法](#基本用法) | | +| value | `number[] \| [number[]]` | [] | 可选,单选时为`number[]`,多选时为`[number[]]`,选中项的value值集合 | [基本用法](#基本用法) | | +| multiple | `boolean` | false | 可选,级联器是否开启多选模式,开启后为 checkbox 选择 | [基本用法](#多选模式) | | +| disabled | `boolean` | false | 可选,级联器是否禁用 | [基本用法](#基本用法) | | + ### 接口 & 类型定义 -- Gitee From bc8681fabf8815d4e19ff91d0c941577f070c9a7 Mon Sep 17 00:00:00 2001 From: lwl <1181102955@qq.com> Date: Mon, 1 Nov 2021 17:22:45 +0800 Subject: [PATCH 09/59] refactor: refactor some code --- .../components/cascader-item/index.tsx | 22 ++- .../components/cascader-item/use-class.ts | 3 +- .../components/cascader-multiple/index.scss | 29 ++++ .../components/cascader-multiple/index.tsx | 21 +++ .../components/cascader-multiple/use-type.ts | 6 + .../components/cascader-tag/index.scss | 39 +++++ .../components/cascader-tag/index.tsx | 20 +++ .../devui/cascader/hooks/use-cascader-item.ts | 2 + .../devui/cascader/src/cascader-types.ts | 9 +- .../devui-vue/devui/cascader/src/cascader.tsx | 152 ++++++++++++------ .../devui-vue/devui/cascader/src/readme.md | 13 ++ 11 files changed, 254 insertions(+), 62 deletions(-) create mode 100644 packages/devui-vue/devui/cascader/components/cascader-multiple/index.scss create mode 100644 packages/devui-vue/devui/cascader/components/cascader-multiple/index.tsx create mode 100644 packages/devui-vue/devui/cascader/components/cascader-multiple/use-type.ts create mode 100644 packages/devui-vue/devui/cascader/components/cascader-tag/index.scss create mode 100644 packages/devui-vue/devui/cascader/components/cascader-tag/index.tsx create mode 100644 packages/devui-vue/devui/cascader/src/readme.md diff --git a/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx b/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx index 9203b7b4..461e4e1a 100644 --- a/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx +++ b/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx @@ -1,13 +1,12 @@ import { useClassName } from './use-class' import { CascaderItemPropsType } from '../cascader-list/cascader-list-types' import { computed, ref } from 'vue' -import { cloneDeep } from 'lodash-es' import './index.scss' export const DCascaderItem = (props: CascaderItemPropsType) => { // console.log('item index',props) const { cascaderItem, ulIndex, liIndex, cascaderItemNeedProps } = props - const { multiple, stopDefault } = cascaderItemNeedProps + const { multiple, stopDefault, valueCache, activeIndexs } = cascaderItemNeedProps const disbaled = computed(() => cascaderItem?.disabled) // 当前项是否被禁用 const { getRootClass } = useClassName() const rootClasses = getRootClass(props) @@ -15,17 +14,14 @@ export const DCascaderItem = (props: CascaderItemPropsType) => { // 触发联动更新 const updateValues = () => { if (stopDefault.value) return - if (!multiple) { - // 单选模式: - // 删除当前联动级之后的所有级 - cascaderItemNeedProps.value.splice(ulIndex, cascaderItemNeedProps.value.length - ulIndex) - // 更新当前active的value数组 - cascaderItemNeedProps.value[ulIndex] = cascaderItem?.value as number - // console.log(cascaderItemNeedProps.value) - } else { - // 多选模式 - console.log(cascaderItemNeedProps.value) - } + // 删除当前联动级之后的所有级 + activeIndexs.splice(ulIndex, activeIndexs.length - ulIndex) + // 更新当前渲染视图的下标数组 + activeIndexs[ulIndex] = liIndex + // 删除当前联动级之后的所有级 + valueCache.splice(ulIndex, valueCache.length - ulIndex) + // 更新当前active的value数组 + valueCache[ulIndex] = cascaderItem?.value as number } // 鼠标hover(多选模式下只能点击操作触发) const mouseEnter = () => { diff --git a/packages/devui-vue/devui/cascader/components/cascader-item/use-class.ts b/packages/devui-vue/devui/cascader/components/cascader-item/use-class.ts index b66972c8..374bfbe6 100644 --- a/packages/devui-vue/devui/cascader/components/cascader-item/use-class.ts +++ b/packages/devui-vue/devui/cascader/components/cascader-item/use-class.ts @@ -7,7 +7,8 @@ export const useClassName= () => { const getRootClass = (props: CascaderItemPropsType): ComputedRef => { const itemProps = props?.cascaderItemNeedProps - const activeFlg = itemProps?.value[props.ulIndex] === props.cascaderItem?.value + console.log(itemProps.valueCache) + const activeFlg = itemProps?.valueCache[props.ulIndex] === props.cascaderItem?.value const disabledFlg = props.cascaderItem?.disabled return computed(() => ({ 'devui-cascader-li devui-dropdown-item': true, diff --git a/packages/devui-vue/devui/cascader/components/cascader-multiple/index.scss b/packages/devui-vue/devui/cascader/components/cascader-multiple/index.scss new file mode 100644 index 00000000..848f54b3 --- /dev/null +++ b/packages/devui-vue/devui/cascader/components/cascader-multiple/index.scss @@ -0,0 +1,29 @@ +@import '../../../style/theme/color'; +@import '../../../style/theme/corner'; +@import '../../../style/core/font'; +.devui-tags { + &-input { + flex: 1; + padding: 1px 20px 1px 4px; + border: 1px solid $devui-form-control-line; + border-radius: $devui-border-radius; + outline: none; + background-color: $devui-base-bg; + transition: border-color 300ms cubic-bezier(0.645, 0.045, 0.355, 1); + } + &-box { + width: 100%; + overflow: auto; + min-height: 28px; + max-height: 56px; + display: flex; + align-items: center; + flex-wrap: wrap; + } + &-placeholder { + font-size: $devui-font-size; + line-height: 22px; + margin-left: 6px; + color: $devui-placeholder; + } +} \ No newline at end of file diff --git a/packages/devui-vue/devui/cascader/components/cascader-multiple/index.tsx b/packages/devui-vue/devui/cascader/components/cascader-multiple/index.tsx new file mode 100644 index 00000000..6dcd30f1 --- /dev/null +++ b/packages/devui-vue/devui/cascader/components/cascader-multiple/index.tsx @@ -0,0 +1,21 @@ +/** + * 多选模式下的内容框 + */ +import { DTag } from '../cascader-tag/' +import { MultiplePropsType } from './use-type' +import './index.scss' +export const DMultipleBox = (props: MultiplePropsType) => { + console.log(props) + return ( +
    +
    + { props.activeOptions.length > 0 + ? props.activeOptions.map(item => { + return + }) + :
    { props.placeholder }
    + } +
    +
    + ) +} \ No newline at end of file diff --git a/packages/devui-vue/devui/cascader/components/cascader-multiple/use-type.ts b/packages/devui-vue/devui/cascader/components/cascader-multiple/use-type.ts new file mode 100644 index 00000000..b734aab1 --- /dev/null +++ b/packages/devui-vue/devui/cascader/components/cascader-multiple/use-type.ts @@ -0,0 +1,6 @@ +import { CascaderItem } from '../../src/cascader-types' + +export interface MultiplePropsType { + activeOptions: CascaderItem[] + placeholder: string +} \ No newline at end of file diff --git a/packages/devui-vue/devui/cascader/components/cascader-tag/index.scss b/packages/devui-vue/devui/cascader/components/cascader-tag/index.scss new file mode 100644 index 00000000..2e57f9bc --- /dev/null +++ b/packages/devui-vue/devui/cascader/components/cascader-tag/index.scss @@ -0,0 +1,39 @@ +@import '../../../style/theme/color'; +@import '../../../style/theme/corner'; +@import '../../../style/core/font'; +.devui-tag { + margin: 2px 4px 2px 0; + display: inline-block; + position: relative; + display: flex; + align-items: center; + padding: 0 8px 0 8px; + background-color: $devui-label-bg; + border-radius: $devui-border-radius; + border-color: inherit; + border: 0 solid; + span { + min-height: 20px; + line-height: 20px; + font-size: $devui-font-size; + color: $devui-text; + position: relative; + cursor: default; + } + &__close { + margin-left: 12px; + font-size: $devui-font-size; + cursor: pointer; + color: #fff; + width: 14px; + height: 14px; + line-height: 14px; + background-color: $devui-line; + border-radius: 50%; + display: inline-block; + text-align: center; + &:hover { + background-color: $devui-brand; + } + } +} \ No newline at end of file diff --git a/packages/devui-vue/devui/cascader/components/cascader-tag/index.tsx b/packages/devui-vue/devui/cascader/components/cascader-tag/index.tsx new file mode 100644 index 00000000..47c26b0b --- /dev/null +++ b/packages/devui-vue/devui/cascader/components/cascader-tag/index.tsx @@ -0,0 +1,20 @@ +/** + * 多选模式下的内容框中的选中tag + * tag组件还未开发完成,所以暂时使用自定义组件 + */ +import { CascaderItem } from '../../src/cascader-types' +import './index.scss' +interface PropsType { + item: CascaderItem +} +export const DTag = (props: PropsType) => { + const { item } = props + return ( +
    + { item?.label } +
    + +
    +
    + ) +} \ No newline at end of file diff --git a/packages/devui-vue/devui/cascader/hooks/use-cascader-item.ts b/packages/devui-vue/devui/cascader/hooks/use-cascader-item.ts index b1cea7c3..9bdaa540 100644 --- a/packages/devui-vue/devui/cascader/hooks/use-cascader-item.ts +++ b/packages/devui-vue/devui/cascader/hooks/use-cascader-item.ts @@ -10,8 +10,10 @@ export const useCascaderItem = (props: CascaderProps, stopDefault: Ref) trigger: props.trigger, inputValueCache: ref(''), confirmInputValueFlg: ref(false), // 用于监听点击确定时输出选择内容 + valueCache: reactive(cloneDeep(props.value)), // 操作时缓存选中的值 value: reactive(cloneDeep(props.value)), // 每级的value multiple: props.multiple, + activeIndexs: reactive([]), // 维护用于视图更新的选中下标 stopDefault, } return { diff --git a/packages/devui-vue/devui/cascader/src/cascader-types.ts b/packages/devui-vue/devui/cascader/src/cascader-types.ts index bd099bb4..dbca0481 100644 --- a/packages/devui-vue/devui/cascader/src/cascader-types.ts +++ b/packages/devui-vue/devui/cascader/src/cascader-types.ts @@ -79,8 +79,11 @@ export const cascaderProps = { placeholder: { type: String, default: '' - } - + }, + change: { + type: Function as PropType<(v: CascaderValueType, k: CascaderItem[]) => void>, + default: undefined + }, } as const export type CascaderProps = ExtractPropTypes @@ -102,11 +105,13 @@ export interface OptionsCallback { type cascaderItemExtendsProps = 'trigger' export type PickCascader = Pick export interface CascaderItemNeedType extends PickCascader { + valueCache: CascaderValueType value: CascaderValueType inputValueCache: Ref confirmInputValueFlg: Ref multiple: boolean stopDefault: Ref + activeIndexs: number[] } export interface UseCascaderItemCallback { cascaderItemNeedProps: CascaderItemNeedType diff --git a/packages/devui-vue/devui/cascader/src/cascader.tsx b/packages/devui-vue/devui/cascader/src/cascader.tsx index a648e44d..35af1259 100644 --- a/packages/devui-vue/devui/cascader/src/cascader.tsx +++ b/packages/devui-vue/devui/cascader/src/cascader.tsx @@ -1,10 +1,11 @@ -import { defineComponent, ref, reactive, watch, toRef } from 'vue' +import { defineComponent, ref, reactive, watch, toRef, Ref } from 'vue' import { cascaderProps, CascaderItem, CascaderProps, CascaderValueType } from './cascader-types' import { getRootClass } from '../hooks/use-cascader-class' import { popupHandles } from '../hooks/use-cascader-popup' import DCascaderList from '../components/cascader-list' // import { optionsHandles } from '../hooks/use-cascader-options' import { useCascaderItem } from '../hooks/use-cascader-item' +import { DMultipleBox } from '../components/cascader-multiple/index' import { cloneDeep } from 'lodash-es' import './cascader.scss' // import { UnwrapNestedRefs } from '@vue/reactivity' @@ -17,11 +18,12 @@ export default defineComponent({ const cascaderOptions = reactive<[CascaderItem[]]>(cloneDeep([ props?.options ])) const multiple = toRef(props, 'multiple') const inputValue = ref('') - let initIptValue = props.value.length > 0 ? true : false + const multipleActiveArr = reactive([]) // 多选模式下选中的值数组,用于生成tag + // let initIptValue = props.value.length > 0 ? true : false // 有value默认值时,初始化输出内容 const position = reactive({ - originX: 'left', - originY: 'bottom', - overlayX: 'left', + originX: 'left', + originY: 'bottom', + overlayX: 'left', overlayY: 'top' } as const) // popup弹出层 @@ -31,14 +33,39 @@ export default defineComponent({ // 传递给cascaderItem的props const { cascaderItemNeedProps } = useCascaderItem(props, stopDefault) /** - * - * @param value value数组 + * 控制视图更新 + * 注意视图更新不区分单选或者多选 + * @param activeIndexs 视图展示下标集合 * @param currentOption 选中的某项 - * @param index 数组项 + * @param index value的下标,起始为0 + */ + const updateCascaderView = (value: CascaderValueType, currentOption: CascaderItem[], index: number) => { + if (index === value.length) return + const i = value[index] as number + // 当前的子级 + const current = currentOption[i] + const children = current?.children + // getInputValue(current.label, children) + if (children?.length > 0) { + // 为下一级增添数据 + cascaderOptions[index + 1] = children + // 递归添加 + updateCascaderView(value, children, index + 1) + } else { + // 当最新的ul(级)没有下一级时删除之前选中ul的数据 + cascaderOptions.splice(index + 1, cascaderOptions.length - 1) + } + } + /** + * 选中项输出 + * 需要区分单选或多选模式 + * @param value 选中值集合 + * @param currentOption 激活的某项 + * @param index value的下标,起始为0 */ - const getCascaderLoop = (value: CascaderValueType, currentOption: CascaderItem[], index: number) => { - // 区分单选多选模式 + const updateCascaderValue = (value: CascaderValueType, currentOption: CascaderItem[], index: number) => { if (!multiple.value) { + // 单选模式 if (index === value.length) return const i = value[index] as number // 当前的子级 @@ -46,32 +73,23 @@ export default defineComponent({ const children = current?.children getInputValue(current.label, children) if (children?.length > 0) { - // 为下一级增添数据 - cascaderOptions[index + 1] = children - // 递归添加 - getCascaderLoop(value, children, index + 1) - } else { - // 当最新的ul(级)没有下一级时删除之前选中ul的数据 - cascaderOptions.splice(index + 1, cascaderOptions.length - 1) + updateCascaderValue(value, children, index + 1) } } else { // 多选模式 - // console.log('currentOption', currentOption) value.forEach(singleValues => { - console.log('singleValues', singleValues) getMultipleCascaderItem(currentOption, singleValues, index) }) } } - /** - * - * 筛选每列中选中的value + * 根据value筛选每列中选中item */ const getCurrentOption = (currentOption: CascaderItem[], i: number) => { return currentOption.filter(item => item?.value === i)[0] } /** + * 下拉框中输出内容 * 需要判断是否是多选 * 需要判断单选模式下是否showPath * @param label 当前current的内容 @@ -84,8 +102,30 @@ export default defineComponent({ cascaderItemNeedProps.inputValueCache.value += (label + (arr?.length > 0 ? ' / ' : '')) } } - const getMultipleIptValue = () => { + /** + * 多选模式下 + * 添加选中项 + * @param arr 当前选中的数组集合 + * @param singleItem 当前选中项 + * + */ + const addMultipleIptValue = (arr: CascaderItem[], singleItem: CascaderItem) => { + arr.push(singleItem) + } + /** + * 多选模式下 + * 初始化选中项,将选中的数组集合置为空 + * @param arr 当前选中的数组集合 + */ + const initMultipleIptValue = (arr: CascaderItem[]) => { + arr.splice(0, arr.length) + } + /** + * 单选模式初始化 + */ + const initSingleIptValue = (inputValueCache: Ref) => { + inputValueCache.value = '' } /** * @param currentOption 选中的某项 @@ -93,60 +133,80 @@ export default defineComponent({ * @param index cascaderUlValues数组的起始项,最开始为0 */ const getMultipleCascaderItem = (currentOption: CascaderItem[], cascaderUlValues: number[], index: number) => { - console.log('currentOption', currentOption, cascaderUlValues[index], index) let nextOption = null + // 根据value筛选出当前children中被选中的项 for (let i = 0; i < currentOption.length; i++) { if (currentOption[i]?.value === cascaderUlValues[index]) { nextOption = currentOption[i] break } } - console.log(nextOption?.label) if (nextOption?.children?.length > 0) { + // 递归获取选中节点 index += 1 getMultipleCascaderItem(nextOption.children, cascaderUlValues, index) + } else { + // 没有子节点了则说明已经是最终节点 + addMultipleIptValue(multipleActiveArr, nextOption) } } - // const initMultipleActiveItem = () /** * 触发input内容输出监听 */ - const triggerUpdateIptValue = () => { - cascaderItemNeedProps.confirmInputValueFlg.value = !cascaderItemNeedProps.confirmInputValueFlg.value - } + // const triggerUpdateIptValue = () => { + // cascaderItemNeedProps.confirmInputValueFlg.value = !cascaderItemNeedProps.confirmInputValueFlg.value + // } /** * 监听点击最终的节点输出内容 */ watch(() => cascaderItemNeedProps.confirmInputValueFlg.value, () => { - inputValue.value = cascaderItemNeedProps.inputValueCache.value + // 单选和多选模式初始化 + multiple.value + ? initMultipleIptValue(multipleActiveArr) + : initSingleIptValue(cascaderItemNeedProps.inputValueCache) + // 输出确认的选中值 + cascaderItemNeedProps.value = reactive(cloneDeep(cascaderItemNeedProps.valueCache)) menuShow.value = false // 点击确定过后禁止再次选中 updateStopDefaultType() + // 更新值 + updateCascaderValue(cascaderItemNeedProps.value, props?.options, 0) + inputValue.value = cascaderItemNeedProps.inputValueCache.value + }, { + immediate: true + }) + /** + * 监听视图更新 + */ + watch(cascaderItemNeedProps.activeIndexs, val => { + updateCascaderView(val, props?.options, 0) }) /** * 监听value值的改变 - * 改变cascaderOptions弹窗内容 + * 改变cascaderOptions弹出层内容 * 改变展示值 */ - watch(cascaderItemNeedProps.value, (val) => { - cascaderItemNeedProps.inputValueCache.value = '' - getCascaderLoop(val, props?.options, 0) - if (initIptValue) { // 因为初始化了value,所以默认输出值 - triggerUpdateIptValue() - initIptValue = false // 只需要初始化一次,之后不再执行 - } - }, { - immediate: true - }) + // watch(cascaderItemNeedProps.value, (val) => { + // // cascaderItemNeedProps.inputValueCache.value = '' + // // if (initIptValue) { // 因为初始化了value,所以默认输出值 + // // triggerUpdateIptValue() + // // initIptValue = false // 只需要初始化一次,之后不再执行 + // // } + // }, { + // immediate: true + // }) return () => ( <>
    - + { multiple.value + ? + : + }
    diff --git a/packages/devui-vue/devui/cascader/src/readme.md b/packages/devui-vue/devui/cascader/src/readme.md new file mode 100644 index 00000000..70b71288 --- /dev/null +++ b/packages/devui-vue/devui/cascader/src/readme.md @@ -0,0 +1,13 @@ +# 组件组成 +cacader组件分为: +- `cascader.tsx`主要文件,渲染主视图 +- `cascader-multiple.tsx`多选模式下的内容展示container,单选模式为input组件 +- `cascader-list.tsx`渲染列 +- `cascader-item.tsx`渲染列中的项 + +# 组件设计 +以下属性在`hooks/use-cascader-item.ts`中 +- `activeIndexs`:每列中的选中下标,负责弹窗交互视图更新 +- `value`:选中的项的value值集合,也可以通过props方式传入 + +**activeIndex** 负责视图更新,也就是hover或者click每项时的交互行为,**value**负责输出选中值。通过`watch`监听这两个值的改变驱动视图和值输出 -- Gitee From c62e41a1ea89174c691386b1a2468ae3f606f3bf Mon Sep 17 00:00:00 2001 From: lwl <1181102955@qq.com> Date: Mon, 1 Nov 2021 21:58:22 +0800 Subject: [PATCH 10/59] refactor: refactor some code --- .../cascader-item/cascader-item-types.ts | 8 +- .../components/cascader-item/use-class.ts | 20 +++-- .../components/cascader-multiple/index.tsx | 1 - .../cascader/hooks/use-cascader-multiple.ts | 77 +++++++++++++++++++ .../cascader/hooks/use-cascader-single.ts | 0 .../devui/cascader/src/cascader-types.ts | 8 ++ .../devui-vue/devui/cascader/src/cascader.tsx | 76 +++--------------- 7 files changed, 110 insertions(+), 80 deletions(-) create mode 100644 packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts create mode 100644 packages/devui-vue/devui/cascader/hooks/use-cascader-single.ts diff --git a/packages/devui-vue/devui/cascader/components/cascader-item/cascader-item-types.ts b/packages/devui-vue/devui/cascader/components/cascader-item/cascader-item-types.ts index 96d19f97..8688dab6 100644 --- a/packages/devui-vue/devui/cascader/components/cascader-item/cascader-item-types.ts +++ b/packages/devui-vue/devui/cascader/components/cascader-item/cascader-item-types.ts @@ -1,3 +1,5 @@ -export const cascaderItemProps = { - -} \ No newline at end of file +import { ComputedRef } from 'vue' +import { CascaderItemPropsType } from '../cascader-list/cascader-list-types' +export interface UseClassNameType { + getRootClass: (j: CascaderItemPropsType) => ComputedRef +} diff --git a/packages/devui-vue/devui/cascader/components/cascader-item/use-class.ts b/packages/devui-vue/devui/cascader/components/cascader-item/use-class.ts index 374bfbe6..6aa44a57 100644 --- a/packages/devui-vue/devui/cascader/components/cascader-item/use-class.ts +++ b/packages/devui-vue/devui/cascader/components/cascader-item/use-class.ts @@ -1,13 +1,12 @@ /** * 定义组件class */ - import { computed, ComputedRef } from 'vue'; - import { CascaderItemPropsType } from '../cascader-list/cascader-list-types' - - export const useClassName= () => { - const getRootClass = (props: CascaderItemPropsType): ComputedRef => { +import { computed, ComputedRef } from 'vue'; +import { CascaderItemPropsType } from '../cascader-list/cascader-list-types' +import { UseClassNameType } from './cascader-item-types' +export const useClassName = (): UseClassNameType => { + const getRootClass = (props: CascaderItemPropsType): ComputedRef => { const itemProps = props?.cascaderItemNeedProps - console.log(itemProps.valueCache) const activeFlg = itemProps?.valueCache[props.ulIndex] === props.cascaderItem?.value const disabledFlg = props.cascaderItem?.disabled return computed(() => ({ @@ -15,9 +14,8 @@ 'devui-leaf-active': activeFlg, 'disabled': disabledFlg })) - } - return { + } + return { getRootClass - } - } - \ No newline at end of file + } +} diff --git a/packages/devui-vue/devui/cascader/components/cascader-multiple/index.tsx b/packages/devui-vue/devui/cascader/components/cascader-multiple/index.tsx index 6dcd30f1..51d053d9 100644 --- a/packages/devui-vue/devui/cascader/components/cascader-multiple/index.tsx +++ b/packages/devui-vue/devui/cascader/components/cascader-multiple/index.tsx @@ -5,7 +5,6 @@ import { DTag } from '../cascader-tag/' import { MultiplePropsType } from './use-type' import './index.scss' export const DMultipleBox = (props: MultiplePropsType) => { - console.log(props) return (
    diff --git a/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts b/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts new file mode 100644 index 00000000..64d75986 --- /dev/null +++ b/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts @@ -0,0 +1,77 @@ +/** + * 多选模式下的一些函数 + */ +import { CascaderItem, CascaderValueType, UseCascaderMultipleCallback } from '../src/cascader-types' +import { reactive } from 'vue' +const multipleActiveArr = reactive([]) // 多选模式下选中的值数组,用于生成tag +export const useMultiple = (): UseCascaderMultipleCallback => { + /** + * 添加选中项 + * @param arr 当前选中的数组集合 + * @param singleItem 当前选中项 + * + */ + const addMultipleIptValue = (arr: CascaderItem[], singleItem: CascaderItem) => { + arr.push(singleItem) + } + /** + * 初始化选中项,将选中的数组集合置为空 + * @param arr 当前选中的数组集合 + */ + const initMultipleIptValue = (arr: CascaderItem[]) => { + arr.splice(0, arr.length) + } + /** + * 多选模式下获取选中的节点 + * @param currentOption 选中的某项 + * @param cascaderUlValues 多选集合中的某一个集合 + * @param index cascaderUlValues数组的起始项,最开始为0 + */ + const getMultipleCascaderItem = (currentOption: CascaderItem[], cascaderUlValues: number[], index: number) => { + let nextOption = null + // 根据value筛选出当前children中被选中的项 + for (let i = 0; i < currentOption.length; i++) { + if (currentOption[i]?.value === cascaderUlValues[index]) { + nextOption = currentOption[i] + break + } + } + if (nextOption?.children?.length > 0) { + // 递归获取选中节点 + index += 1 + getMultipleCascaderItem(nextOption.children, cascaderUlValues, index) + } else { + // 没有子节点了则说明已经是最终节点 + addMultipleIptValue(multipleActiveArr, nextOption) + } + } + /** + * 多选模式下当有默认选中值时,初始化视图选中状态 + * 通过value集合获取下标集合 + * @param values 默认选中的value集合 + * @param currentOption 当前列 + * @param index values数组的起始项,最开始为0 + * @param activeIndexs 渲染视图所需要的下标集合 + */ + const initActiveIndexs = (values: CascaderValueType, currentOption: CascaderItem[], index: number, activeIndexs: number[]) => { + let nextOption = null + for (let i = 0; i < currentOption.length; i++) { + if (currentOption[i]?.value === values[index]) { + nextOption = currentOption[i]?.children + activeIndexs[index] = i + break + } + } + if (index < values.length - 1 && nextOption) { + index += 1 + initActiveIndexs(values, nextOption, index, activeIndexs) + } + } + return { + multipleActiveArr, + addMultipleIptValue, + initMultipleIptValue, + getMultipleCascaderItem, + initActiveIndexs + } +} diff --git a/packages/devui-vue/devui/cascader/hooks/use-cascader-single.ts b/packages/devui-vue/devui/cascader/hooks/use-cascader-single.ts new file mode 100644 index 00000000..e69de29b diff --git a/packages/devui-vue/devui/cascader/src/cascader-types.ts b/packages/devui-vue/devui/cascader/src/cascader-types.ts index dbca0481..b57cc01d 100644 --- a/packages/devui-vue/devui/cascader/src/cascader-types.ts +++ b/packages/devui-vue/devui/cascader/src/cascader-types.ts @@ -116,3 +116,11 @@ export interface CascaderItemNeedType extends PickCascader { export interface UseCascaderItemCallback { cascaderItemNeedProps: CascaderItemNeedType } + +export interface UseCascaderMultipleCallback { + multipleActiveArr: UnwrapNestedRefs + addMultipleIptValue: (a: CascaderItem[], b: CascaderItem) => void + initMultipleIptValue: (a: CascaderItem[]) => void + getMultipleCascaderItem: (a: CascaderItem[], b: number[], c: number) => void + initActiveIndexs: (a: CascaderValueType, b: CascaderItem[], c: number, d: number[]) => void +} \ No newline at end of file diff --git a/packages/devui-vue/devui/cascader/src/cascader.tsx b/packages/devui-vue/devui/cascader/src/cascader.tsx index 35af1259..1e7c476a 100644 --- a/packages/devui-vue/devui/cascader/src/cascader.tsx +++ b/packages/devui-vue/devui/cascader/src/cascader.tsx @@ -6,6 +6,7 @@ import DCascaderList from '../components/cascader-list' // import { optionsHandles } from '../hooks/use-cascader-options' import { useCascaderItem } from '../hooks/use-cascader-item' import { DMultipleBox } from '../components/cascader-multiple/index' +import { useMultiple } from '../hooks/use-cascader-multiple' import { cloneDeep } from 'lodash-es' import './cascader.scss' // import { UnwrapNestedRefs } from '@vue/reactivity' @@ -18,8 +19,9 @@ export default defineComponent({ const cascaderOptions = reactive<[CascaderItem[]]>(cloneDeep([ props?.options ])) const multiple = toRef(props, 'multiple') const inputValue = ref('') - const multipleActiveArr = reactive([]) // 多选模式下选中的值数组,用于生成tag - // let initIptValue = props.value.length > 0 ? true : false // 有value默认值时,初始化输出内容 + const { multipleActiveArr, initMultipleIptValue, getMultipleCascaderItem, initActiveIndexs } = useMultiple() + // const multipleActiveArr = reactive([]) // 多选模式下选中的值数组,用于生成tag + let initIptValue = props.value.length > 0 ? true : false // 有value默认值时,初始化输出内容 const position = reactive({ originX: 'left', originY: 'bottom', @@ -45,7 +47,6 @@ export default defineComponent({ // 当前的子级 const current = currentOption[i] const children = current?.children - // getInputValue(current.label, children) if (children?.length > 0) { // 为下一级增添数据 cascaderOptions[index + 1] = children @@ -102,60 +103,13 @@ export default defineComponent({ cascaderItemNeedProps.inputValueCache.value += (label + (arr?.length > 0 ? ' / ' : '')) } } - - /** - * 多选模式下 - * 添加选中项 - * @param arr 当前选中的数组集合 - * @param singleItem 当前选中项 - * - */ - const addMultipleIptValue = (arr: CascaderItem[], singleItem: CascaderItem) => { - arr.push(singleItem) - } - /** - * 多选模式下 - * 初始化选中项,将选中的数组集合置为空 - * @param arr 当前选中的数组集合 - */ - const initMultipleIptValue = (arr: CascaderItem[]) => { - arr.splice(0, arr.length) - } + /** * 单选模式初始化 */ const initSingleIptValue = (inputValueCache: Ref) => { inputValueCache.value = '' } - /** - * @param currentOption 选中的某项 - * @param cascaderUlValues 多选集合中的某一个集合 - * @param index cascaderUlValues数组的起始项,最开始为0 - */ - const getMultipleCascaderItem = (currentOption: CascaderItem[], cascaderUlValues: number[], index: number) => { - let nextOption = null - // 根据value筛选出当前children中被选中的项 - for (let i = 0; i < currentOption.length; i++) { - if (currentOption[i]?.value === cascaderUlValues[index]) { - nextOption = currentOption[i] - break - } - } - if (nextOption?.children?.length > 0) { - // 递归获取选中节点 - index += 1 - getMultipleCascaderItem(nextOption.children, cascaderUlValues, index) - } else { - // 没有子节点了则说明已经是最终节点 - addMultipleIptValue(multipleActiveArr, nextOption) - } - } - /** - * 触发input内容输出监听 - */ - // const triggerUpdateIptValue = () => { - // cascaderItemNeedProps.confirmInputValueFlg.value = !cascaderItemNeedProps.confirmInputValueFlg.value - // } /** * 监听点击最终的节点输出内容 */ @@ -172,6 +126,10 @@ export default defineComponent({ // 更新值 updateCascaderValue(cascaderItemNeedProps.value, props?.options, 0) inputValue.value = cascaderItemNeedProps.inputValueCache.value + if (initIptValue) { // 因为初始化了value,所以默认回显视图的选中态 + initActiveIndexs(props.value, props?.options, 0, cascaderItemNeedProps.activeIndexs) + initIptValue = false // 只需要初始化一次,之后不再执行 + } }, { immediate: true }) @@ -180,21 +138,9 @@ export default defineComponent({ */ watch(cascaderItemNeedProps.activeIndexs, val => { updateCascaderView(val, props?.options, 0) + }, { + immediate: true }) - /** - * 监听value值的改变 - * 改变cascaderOptions弹出层内容 - * 改变展示值 - */ - // watch(cascaderItemNeedProps.value, (val) => { - // // cascaderItemNeedProps.inputValueCache.value = '' - // // if (initIptValue) { // 因为初始化了value,所以默认输出值 - // // triggerUpdateIptValue() - // // initIptValue = false // 只需要初始化一次,之后不再执行 - // // } - // }, { - // immediate: true - // }) return () => ( <> -- Gitee From 2a5a7cf9e0bb62e0d01b2bf6839be3c8d475c1ae Mon Sep 17 00:00:00 2001 From: lwl <1181102955@qq.com> Date: Tue, 2 Nov 2021 17:31:58 +0800 Subject: [PATCH 11/59] feat: add character --- .../components/cascader-item/index.tsx | 28 +++++++++----- .../devui/cascader/hooks/use-cascader-item.ts | 22 ++++++++++- .../cascader/hooks/use-cascader-multiple.ts | 13 ++++++- .../cascader/hooks/use-cascader-single.ts | 24 ++++++++++++ .../devui/cascader/src/cascader-types.ts | 6 +++ .../devui-vue/devui/cascader/src/cascader.tsx | 37 ++++--------------- 6 files changed, 88 insertions(+), 42 deletions(-) diff --git a/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx b/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx index 461e4e1a..771f590e 100644 --- a/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx +++ b/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx @@ -1,16 +1,20 @@ import { useClassName } from './use-class' import { CascaderItemPropsType } from '../cascader-list/cascader-list-types' import { computed, ref } from 'vue' - +import { useSingle } from '../../hooks/use-cascader-single' +import { useMultiple } from '../../hooks/use-cascader-multiple' import './index.scss' +import checkbox from '../../../checkbox/src/checkbox' export const DCascaderItem = (props: CascaderItemPropsType) => { // console.log('item index',props) const { cascaderItem, ulIndex, liIndex, cascaderItemNeedProps } = props - const { multiple, stopDefault, valueCache, activeIndexs } = cascaderItemNeedProps - const disbaled = computed(() => cascaderItem?.disabled) // 当前项是否被禁用 + const { multiple, stopDefault, valueCache, activeIndexs, trigger, confirmInputValueFlg } = cascaderItemNeedProps + const triggerHover = trigger === 'hover' + const { singleChoose } = useSingle() + const { clickCheckbox } = useMultiple() const { getRootClass } = useClassName() + const disbaled = computed(() => cascaderItem?.disabled) // 当前项是否被禁用 const rootClasses = getRootClass(props) - const triggerHover = cascaderItemNeedProps.trigger === 'hover' // 触发联动更新 const updateValues = () => { if (stopDefault.value) return @@ -18,10 +22,11 @@ export const DCascaderItem = (props: CascaderItemPropsType) => { activeIndexs.splice(ulIndex, activeIndexs.length - ulIndex) // 更新当前渲染视图的下标数组 activeIndexs[ulIndex] = liIndex - // 删除当前联动级之后的所有级 - valueCache.splice(ulIndex, valueCache.length - ulIndex) - // 更新当前active的value数组 - valueCache[ulIndex] = cascaderItem?.value as number + if (multiple) { + // clickCheckbox() + } else { + singleChoose(ulIndex, valueCache, cascaderItem) + } } // 鼠标hover(多选模式下只能点击操作触发) const mouseEnter = () => { @@ -36,14 +41,17 @@ export const DCascaderItem = (props: CascaderItemPropsType) => { if (disbaled.value) return updateValues() if (!cascaderItem.children || cascaderItem?.children?.length === 0) { - cascaderItemNeedProps.confirmInputValueFlg.value = !cascaderItemNeedProps.confirmInputValueFlg.value + confirmInputValueFlg.value = !confirmInputValueFlg.value } } + const checkboxChange = (e) => { + console.log(123) + } return (
  • { multiple &&
    - +
    } { cascaderItem.icon && diff --git a/packages/devui-vue/devui/cascader/hooks/use-cascader-item.ts b/packages/devui-vue/devui/cascader/hooks/use-cascader-item.ts index 9bdaa540..ff32d704 100644 --- a/packages/devui-vue/devui/cascader/hooks/use-cascader-item.ts +++ b/packages/devui-vue/devui/cascader/hooks/use-cascader-item.ts @@ -1,11 +1,14 @@ /** * 处理cascader-item中需要的参数 */ -import { CascaderProps, UseCascaderItemCallback } from '../src/cascader-types' +import { CascaderProps, UseCascaderItemCallback, CascaderItem } from '../src/cascader-types' import { ref, reactive, Ref } from 'vue' import { cloneDeep } from 'lodash-es' export const useCascaderItem = (props: CascaderProps, stopDefault: Ref): UseCascaderItemCallback => { + /** + * 传递给cascader-item/index.ts组件的数据 + */ const cascaderItemNeedProps = { trigger: props.trigger, inputValueCache: ref(''), @@ -16,7 +19,22 @@ export const useCascaderItem = (props: CascaderProps, stopDefault: Ref) activeIndexs: reactive([]), // 维护用于视图更新的选中下标 stopDefault, } + /** + * 下拉框中输出内容 + * 需要判断是否是多选 + * 需要判断单选模式下是否showPath + * @param label 当前current的内容 + * @param arr 当前选中项current的children数组 + */ + const getInputValue = (label: string, arr?: CascaderItem[]) => { + if (!props.showPath) { + cascaderItemNeedProps.inputValueCache.value = label + } else { + cascaderItemNeedProps.inputValueCache.value += (label + (arr?.length > 0 ? ' / ' : '')) + } + } return { - cascaderItemNeedProps + cascaderItemNeedProps, + getInputValue } } \ No newline at end of file diff --git a/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts b/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts index 64d75986..f01ab02b 100644 --- a/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts +++ b/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts @@ -2,7 +2,7 @@ * 多选模式下的一些函数 */ import { CascaderItem, CascaderValueType, UseCascaderMultipleCallback } from '../src/cascader-types' -import { reactive } from 'vue' +import { reactive, nextTick } from 'vue' const multipleActiveArr = reactive([]) // 多选模式下选中的值数组,用于生成tag export const useMultiple = (): UseCascaderMultipleCallback => { /** @@ -36,6 +36,8 @@ export const useMultiple = (): UseCascaderMultipleCallback => { break } } + nextOption.checked = true + console.log(nextOption, 'nextOption') if (nextOption?.children?.length > 0) { // 递归获取选中节点 index += 1 @@ -67,10 +69,19 @@ export const useMultiple = (): UseCascaderMultipleCallback => { initActiveIndexs(values, nextOption, index, activeIndexs) } } + + /** + * 多选模式点击checkbox + */ + const clickCheckbox = (event: Event): void => { + // 如果是半选状态,更新为false,其他状态则更新为与checked相反 + + } return { multipleActiveArr, addMultipleIptValue, initMultipleIptValue, + clickCheckbox, getMultipleCascaderItem, initActiveIndexs } diff --git a/packages/devui-vue/devui/cascader/hooks/use-cascader-single.ts b/packages/devui-vue/devui/cascader/hooks/use-cascader-single.ts index e69de29b..8039ca69 100644 --- a/packages/devui-vue/devui/cascader/hooks/use-cascader-single.ts +++ b/packages/devui-vue/devui/cascader/hooks/use-cascader-single.ts @@ -0,0 +1,24 @@ +import { Ref } from 'vue' +import { CascaderValueType, CascaderItem } from '../src/cascader-types' +export const useSingle = () => { + /** + * 单选模式初始化 + */ + const initSingleIptValue = (inputValueCache: Ref) => { + inputValueCache.value = '' + } + + /** + * 单选模式选中 + */ + const singleChoose = (ulIndex: number, valueCache: CascaderValueType, cascaderItem: CascaderItem) => { + // 删除当前联动级之后的所有级 + valueCache.splice(ulIndex, valueCache.length - ulIndex) + // 更新当前active的value数组 + valueCache[ulIndex] = cascaderItem?.value as number + } + return { + initSingleIptValue, + singleChoose + } +} \ No newline at end of file diff --git a/packages/devui-vue/devui/cascader/src/cascader-types.ts b/packages/devui-vue/devui/cascader/src/cascader-types.ts index b57cc01d..969b3a98 100644 --- a/packages/devui-vue/devui/cascader/src/cascader-types.ts +++ b/packages/devui-vue/devui/cascader/src/cascader-types.ts @@ -8,7 +8,11 @@ export interface CascaderItem { value: number | string isLeaf?: boolean children?: CascaderItem[] + checked?: boolean + halfChecked?: boolean disabled?: boolean + active?: boolean + _loading?: boolean icon?: string // 用户可以传入自定义属性,并在dropDownItemTemplate中使用 [prop: string]: any @@ -115,6 +119,7 @@ export interface CascaderItemNeedType extends PickCascader { } export interface UseCascaderItemCallback { cascaderItemNeedProps: CascaderItemNeedType + getInputValue: (a: string, b?: CascaderItem[]) => void } export interface UseCascaderMultipleCallback { @@ -122,5 +127,6 @@ export interface UseCascaderMultipleCallback { addMultipleIptValue: (a: CascaderItem[], b: CascaderItem) => void initMultipleIptValue: (a: CascaderItem[]) => void getMultipleCascaderItem: (a: CascaderItem[], b: number[], c: number) => void + clickCheckbox: () => void initActiveIndexs: (a: CascaderValueType, b: CascaderItem[], c: number, d: number[]) => void } \ No newline at end of file diff --git a/packages/devui-vue/devui/cascader/src/cascader.tsx b/packages/devui-vue/devui/cascader/src/cascader.tsx index 1e7c476a..8eecf21f 100644 --- a/packages/devui-vue/devui/cascader/src/cascader.tsx +++ b/packages/devui-vue/devui/cascader/src/cascader.tsx @@ -7,6 +7,7 @@ import DCascaderList from '../components/cascader-list' import { useCascaderItem } from '../hooks/use-cascader-item' import { DMultipleBox } from '../components/cascader-multiple/index' import { useMultiple } from '../hooks/use-cascader-multiple' +import { useSingle } from '../hooks/use-cascader-single' import { cloneDeep } from 'lodash-es' import './cascader.scss' // import { UnwrapNestedRefs } from '@vue/reactivity' @@ -20,6 +21,7 @@ export default defineComponent({ const multiple = toRef(props, 'multiple') const inputValue = ref('') const { multipleActiveArr, initMultipleIptValue, getMultipleCascaderItem, initActiveIndexs } = useMultiple() + const { initSingleIptValue } = useSingle() // const multipleActiveArr = reactive([]) // 多选模式下选中的值数组,用于生成tag let initIptValue = props.value.length > 0 ? true : false // 有value默认值时,初始化输出内容 const position = reactive({ @@ -33,7 +35,7 @@ export default defineComponent({ // 配置class const rootClasses = getRootClass(props, menuShow) // 传递给cascaderItem的props - const { cascaderItemNeedProps } = useCascaderItem(props, stopDefault) + const { cascaderItemNeedProps, getInputValue } = useCascaderItem(props, stopDefault) /** * 控制视图更新 * 注意视图更新不区分单选或者多选 @@ -90,30 +92,15 @@ export default defineComponent({ return currentOption.filter(item => item?.value === i)[0] } /** - * 下拉框中输出内容 - * 需要判断是否是多选 - * 需要判断单选模式下是否showPath - * @param label 当前current的内容 - * @param arr 当前选中项current的children数组 - */ - const getInputValue = (label: string, arr?: CascaderItem[]) => { - if (!props.showPath) { - cascaderItemNeedProps.inputValueCache.value = label - } else { - cascaderItemNeedProps.inputValueCache.value += (label + (arr?.length > 0 ? ' / ' : '')) - } - } - - /** - * 单选模式初始化 + * 监听视图更新 */ - const initSingleIptValue = (inputValueCache: Ref) => { - inputValueCache.value = '' - } + watch(cascaderItemNeedProps.activeIndexs, val => { + updateCascaderView(val, props?.options, 0) + }) /** * 监听点击最终的节点输出内容 */ - watch(() => cascaderItemNeedProps.confirmInputValueFlg.value, () => { + watch(() => cascaderItemNeedProps.confirmInputValueFlg.value, () => { // 单选和多选模式初始化 multiple.value ? initMultipleIptValue(multipleActiveArr) @@ -133,14 +120,6 @@ export default defineComponent({ }, { immediate: true }) - /** - * 监听视图更新 - */ - watch(cascaderItemNeedProps.activeIndexs, val => { - updateCascaderView(val, props?.options, 0) - }, { - immediate: true - }) return () => ( <> -- Gitee From 821394711c989ba76e0409986cdea9ee6b594f6b Mon Sep 17 00:00:00 2001 From: lwl <1181102955@qq.com> Date: Wed, 3 Nov 2021 17:18:47 +0800 Subject: [PATCH 12/59] feat: add character --- .../components/cascader-item/index.scss | 9 +- .../components/cascader-item/index.tsx | 44 +++--- .../components/cascader-tag/index.tsx | 9 +- .../cascader/hooks/use-cascader-multiple.ts | 146 ++++++++++++++---- .../devui/cascader/src/cascader-types.ts | 17 +- .../devui-vue/devui/cascader/src/cascader.tsx | 25 +-- 6 files changed, 186 insertions(+), 64 deletions(-) diff --git a/packages/devui-vue/devui/cascader/components/cascader-item/index.scss b/packages/devui-vue/devui/cascader/components/cascader-item/index.scss index 04f5f97b..f3368ead 100644 --- a/packages/devui-vue/devui/cascader/components/cascader-item/index.scss +++ b/packages/devui-vue/devui/cascader/components/cascader-item/index.scss @@ -9,13 +9,15 @@ color: $devui-text; cursor: pointer; @include flex(flex-start); - -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } - + .cascader-li__wraper { + flex: 1; + @include flex(flex-start); + } .dropdown-item-label { display: inline-block; flex: 1; @@ -47,6 +49,9 @@ margin-right: 4px; font-size: $devui-font-size-icon; color: $devui-text; + &.disabled { + color: $devui-disabled-text !important; + } } } } diff --git a/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx b/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx index 771f590e..6eac8002 100644 --- a/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx +++ b/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx @@ -4,14 +4,13 @@ import { computed, ref } from 'vue' import { useSingle } from '../../hooks/use-cascader-single' import { useMultiple } from '../../hooks/use-cascader-multiple' import './index.scss' -import checkbox from '../../../checkbox/src/checkbox' export const DCascaderItem = (props: CascaderItemPropsType) => { // console.log('item index',props) - const { cascaderItem, ulIndex, liIndex, cascaderItemNeedProps } = props + const { cascaderItem, ulIndex, liIndex, cascaderItemNeedProps, cascaderOptions } = props const { multiple, stopDefault, valueCache, activeIndexs, trigger, confirmInputValueFlg } = cascaderItemNeedProps const triggerHover = trigger === 'hover' const { singleChoose } = useSingle() - const { clickCheckbox } = useMultiple() + const { updateCheckOptionStatus, getParentNode, updateParentNodeStatus } = useMultiple() const { getRootClass } = useClassName() const disbaled = computed(() => cascaderItem?.disabled) // 当前项是否被禁用 const rootClasses = getRootClass(props) @@ -22,9 +21,7 @@ export const DCascaderItem = (props: CascaderItemPropsType) => { activeIndexs.splice(ulIndex, activeIndexs.length - ulIndex) // 更新当前渲染视图的下标数组 activeIndexs[ulIndex] = liIndex - if (multiple) { - // clickCheckbox() - } else { + if (!multiple) { // 单选点击选项就更新,多选是通过点击checkbox触发数据更新 singleChoose(ulIndex, valueCache, cascaderItem) } } @@ -40,31 +37,38 @@ export const DCascaderItem = (props: CascaderItemPropsType) => { const mouseClick = () => { if (disbaled.value) return updateValues() - if (!cascaderItem.children || cascaderItem?.children?.length === 0) { + if (!multiple && (!cascaderItem.children || cascaderItem?.children?.length === 0)) { confirmInputValueFlg.value = !confirmInputValueFlg.value } } - const checkboxChange = (e) => { - console.log(123) + const checkboxChange = () => { + updateCheckOptionStatus(cascaderItem, cascaderOptions, ulIndex) + // const parentNode = getParentNode(cascaderItem.value, cascaderOptions, ulIndex - 1) + // updateParentNodeStatus(parentNode, cascaderOptions, ulIndex - 1) + // if (!cascaderItem.children || cascaderItem?.children?.length === 0) { + // confirmInputValueFlg.value = !confirmInputValueFlg.value + // } } return ( -
  • +
  • { multiple &&
    - +
    } - { cascaderItem.icon && -
    - +
    + { cascaderItem.icon && +
    + +
    + } + - } - - { - cascaderItem?.children?.length > 0 && - }
  • ) } diff --git a/packages/devui-vue/devui/cascader/components/cascader-tag/index.tsx b/packages/devui-vue/devui/cascader/components/cascader-tag/index.tsx index 47c26b0b..c60211a8 100644 --- a/packages/devui-vue/devui/cascader/components/cascader-tag/index.tsx +++ b/packages/devui-vue/devui/cascader/components/cascader-tag/index.tsx @@ -3,16 +3,23 @@ * tag组件还未开发完成,所以暂时使用自定义组件 */ import { CascaderItem } from '../../src/cascader-types' +import { useMultiple } from '../../hooks/use-cascader-multiple' import './index.scss' interface PropsType { item: CascaderItem } export const DTag = (props: PropsType) => { const { item } = props + const { tagList, deleteTagList } = useMultiple() + const deleteCurrentTag = (e: Event) => { + console.log(11) + e.stopPropagation() + deleteTagList(tagList, item) + } return (
    { item?.label } -
    +
    diff --git a/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts b/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts index f01ab02b..02e07862 100644 --- a/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts +++ b/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts @@ -1,9 +1,9 @@ /** * 多选模式下的一些函数 */ -import { CascaderItem, CascaderValueType, UseCascaderMultipleCallback } from '../src/cascader-types' -import { reactive, nextTick } from 'vue' -const multipleActiveArr = reactive([]) // 多选模式下选中的值数组,用于生成tag +import { CascaderItem, CascaderValueType, CaascaderOptionsType, UseCascaderMultipleCallback, CheckedType } from '../src/cascader-types' +import { reactive } from 'vue' +const tagList = reactive([]) // 多选模式下选中的值数组,用于生成tag export const useMultiple = (): UseCascaderMultipleCallback => { /** * 添加选中项 @@ -11,40 +11,47 @@ export const useMultiple = (): UseCascaderMultipleCallback => { * @param singleItem 当前选中项 * */ - const addMultipleIptValue = (arr: CascaderItem[], singleItem: CascaderItem) => { + const addTagList = (arr: CascaderItem[], singleItem: CascaderItem) => { arr.push(singleItem) } + /** + * 删除选中项 + * @param arr 当前选中的数组集合 + * @param singleItem 当前选中项 + * + */ + const deleteTagList = (arr: CascaderItem[], singleItem: CascaderItem) => { + const i = arr.findIndex(item => item.value === singleItem.value) + arr.splice(i, 1) + } /** * 初始化选中项,将选中的数组集合置为空 * @param arr 当前选中的数组集合 */ - const initMultipleIptValue = (arr: CascaderItem[]) => { + const initTagList = (arr: CascaderItem[]) => { arr.splice(0, arr.length) } /** - * 多选模式下获取选中的节点 + * 获取选中的节点 * @param currentOption 选中的某项 * @param cascaderUlValues 多选集合中的某一个集合 * @param index cascaderUlValues数组的起始项,最开始为0 */ - const getMultipleCascaderItem = (currentOption: CascaderItem[], cascaderUlValues: number[], index: number) => { - let nextOption = null - // 根据value筛选出当前children中被选中的项 - for (let i = 0; i < currentOption.length; i++) { - if (currentOption[i]?.value === cascaderUlValues[index]) { - nextOption = currentOption[i] - break - } - } - nextOption.checked = true - console.log(nextOption, 'nextOption') - if (nextOption?.children?.length > 0) { + const getMultipleCascaderItem = (currentOption: CascaderItem[], cascaderUlValues: number[], index: number, cascaderOptions) => { + const node = currentOption.find(item => item.value === cascaderUlValues[index]) + // node.checked = true + // console.log(ulIndex) + if (node?.children?.length > 0) { // 递归获取选中节点 index += 1 - getMultipleCascaderItem(nextOption.children, cascaderUlValues, index) + getMultipleCascaderItem(node.children, cascaderUlValues, index, cascaderOptions) } else { // 没有子节点了则说明已经是最终节点 - addMultipleIptValue(multipleActiveArr, nextOption) + // console.log('node', node, cascaderOptions, index) + const ulIndex = cascaderUlValues.findIndex(item => item === node.value) + console.log('node', node, ulIndex) + updateCheckOptionStatus(node, cascaderOptions, ulIndex) + // addTagList(tagList, node) } } /** @@ -73,16 +80,103 @@ export const useMultiple = (): UseCascaderMultipleCallback => { /** * 多选模式点击checkbox */ - const clickCheckbox = (event: Event): void => { + const updateCheckOptionStatus = (node: CascaderItem, options: CaascaderOptionsType, ulIndex: number): void => { // 如果是半选状态,更新为false,其他状态则更新为与checked相反 + // console.log(node, options, ulIndex) + if (node?.halfChecked) { // 更新半选状态 + node.halfChecked = false + node.checked = false + updateCheckStatusLoop(node, 'halfChecked') + } else { + node.checked = !node.checked + // 更新是否选中状态 + updateCheckStatusLoop(node, 'checked', node.checked) + } + ulIndex -= 1 + const parentNode = getParentNode(node.value, options, ulIndex) + updateParentNodeStatus(parentNode, options, ulIndex) + } + /** + * 父节点改变子节点check状态 + * @param node 节点 + */ + const updateCheckStatusLoop = (node: CascaderItem, type: CheckedType, status?: boolean) => { + // console.log(node) + if (node.children) { + node.children.forEach(item => { + // 当需要改变checked时 + // halfChecked一定是false + if (item.disabled) return // 禁用不可更改状态 + if (type === 'checked') { + item[type] = status + item['halfChecked'] = false + updateCheckStatusLoop(item, type, status) + } else if (type === 'halfChecked') { + /** + * halfChecked为false时,取消子节点所有选中 + */ + item['halfChecked'] = false + item['checked'] = false + !status && updateCheckStatusLoop(item, type) + } + }) + } else { + // 更新tagList + !node.checked + ? deleteTagList(tagList, node) + : addTagList(tagList, node) + } + } + /** + * 子节点获取父节点 + */ + const getParentNode = (childValue: string | number, options: CaascaderOptionsType, ulIndex: number): CascaderItem => { + if (ulIndex < 0) return + const queue = [...options[ulIndex]] + let cur: CascaderItem + while(queue.length) { + cur = queue.shift() + if (cur.children && cur.children.find(t => t.value === childValue)) { + break + } else if (cur.children) { + queue.push(...cur.children) + } + } + return cur + } + /** + * 更新父节点 + */ + const updateParentNodeStatus = (node: CascaderItem, options: CaascaderOptionsType, ulIndex: number) => { + if (ulIndex < 0) return + const checkedChild = node?.children?.find(t => t['checked']) + const halfcheckedChild = node?.children?.find(t => t['halfChecked']) + const uncheckedChild = node?.children?.find(t => !t['halfChecked'] && !t['checked']) + if (halfcheckedChild || (checkedChild && uncheckedChild)) { + node['checked'] = false + node['halfChecked'] = true + } else if (!checkedChild && !halfcheckedChild) { + node['checked'] = false + node['halfChecked'] = false + } else { + node['checked'] = true + node['halfChecked'] = false + } + ulIndex -= 1 + const parentNode = getParentNode(node.value, options, ulIndex) + updateParentNodeStatus(parentNode, options, ulIndex) } return { - multipleActiveArr, - addMultipleIptValue, - initMultipleIptValue, - clickCheckbox, + tagList, + addTagList, + deleteTagList, + initTagList, + updateCheckOptionStatus, getMultipleCascaderItem, - initActiveIndexs + initActiveIndexs, + updateCheckStatusLoop, + updateParentNodeStatus, + getParentNode, } } diff --git a/packages/devui-vue/devui/cascader/src/cascader-types.ts b/packages/devui-vue/devui/cascader/src/cascader-types.ts index 969b3a98..f2d175b6 100644 --- a/packages/devui-vue/devui/cascader/src/cascader-types.ts +++ b/packages/devui-vue/devui/cascader/src/cascader-types.ts @@ -122,11 +122,16 @@ export interface UseCascaderItemCallback { getInputValue: (a: string, b?: CascaderItem[]) => void } +export type CheckedType = 'checked' | 'halfChecked' export interface UseCascaderMultipleCallback { - multipleActiveArr: UnwrapNestedRefs - addMultipleIptValue: (a: CascaderItem[], b: CascaderItem) => void - initMultipleIptValue: (a: CascaderItem[]) => void - getMultipleCascaderItem: (a: CascaderItem[], b: number[], c: number) => void - clickCheckbox: () => void + tagList: UnwrapNestedRefs + addTagList: (a: CascaderItem[], b: CascaderItem) => void + deleteTagList: (a: CascaderItem[], b: CascaderItem) => void + initTagList: (a: CascaderItem[]) => void + getMultipleCascaderItem: (a: CascaderItem[], b: number[], c: number, d: any) => void + updateCheckOptionStatus: (a: CascaderItem, options: CaascaderOptionsType, ulIndex: number) => void initActiveIndexs: (a: CascaderValueType, b: CascaderItem[], c: number, d: number[]) => void -} \ No newline at end of file + updateCheckStatusLoop: (a: CascaderItem, b: CheckedType, c?: boolean) => void + getParentNode: (a: string | number, b: [CascaderItem[]], c: number) => CascaderItem + updateParentNodeStatus: (a: CascaderItem, b: CaascaderOptionsType, c: number) => void +} diff --git a/packages/devui-vue/devui/cascader/src/cascader.tsx b/packages/devui-vue/devui/cascader/src/cascader.tsx index 8eecf21f..2e65a3df 100644 --- a/packages/devui-vue/devui/cascader/src/cascader.tsx +++ b/packages/devui-vue/devui/cascader/src/cascader.tsx @@ -12,6 +12,8 @@ import { cloneDeep } from 'lodash-es' import './cascader.scss' // import { UnwrapNestedRefs } from '@vue/reactivity' // type OptionsType = UnwrapNestedRefs<[CascaderItem[]]> +let cascaderOptionsCache = reactive({}) + export default defineComponent({ name: 'DCascader', props: cascaderProps, @@ -20,9 +22,9 @@ export default defineComponent({ const cascaderOptions = reactive<[CascaderItem[]]>(cloneDeep([ props?.options ])) const multiple = toRef(props, 'multiple') const inputValue = ref('') - const { multipleActiveArr, initMultipleIptValue, getMultipleCascaderItem, initActiveIndexs } = useMultiple() + const { tagList, updateCheckOptionStatus, initTagList, getMultipleCascaderItem, initActiveIndexs } = useMultiple() const { initSingleIptValue } = useSingle() - // const multipleActiveArr = reactive([]) // 多选模式下选中的值数组,用于生成tag + // const tagList = reactive([]) // 多选模式下选中的值数组,用于生成tag let initIptValue = props.value.length > 0 ? true : false // 有value默认值时,初始化输出内容 const position = reactive({ originX: 'left', @@ -58,6 +60,8 @@ export default defineComponent({ // 当最新的ul(级)没有下一级时删除之前选中ul的数据 cascaderOptions.splice(index + 1, cascaderOptions.length - 1) } + cascaderOptionsCache = cascaderOptions + // console.log('cascaderOptions1', cascaderOptionsCache) } /** * 选中项输出 @@ -80,8 +84,10 @@ export default defineComponent({ } } else { // 多选模式 - value.forEach(singleValues => { - getMultipleCascaderItem(currentOption, singleValues, index) + // console.log('cascaderOptions2', cascaderOptionsCache) + value.forEach((singleValues) => { + console.log(singleValues) + getMultipleCascaderItem(currentOption, singleValues, index, cascaderOptionsCache) }) } } @@ -95,7 +101,8 @@ export default defineComponent({ * 监听视图更新 */ watch(cascaderItemNeedProps.activeIndexs, val => { - updateCascaderView(val, props?.options, 0) + // cascaderOptions.splice(0, cascaderOptions.length) + updateCascaderView(val, cascaderOptions[0], 0) }) /** * 监听点击最终的节点输出内容 @@ -103,7 +110,7 @@ export default defineComponent({ watch(() => cascaderItemNeedProps.confirmInputValueFlg.value, () => { // 单选和多选模式初始化 multiple.value - ? initMultipleIptValue(multipleActiveArr) + ? initTagList(tagList) : initSingleIptValue(cascaderItemNeedProps.inputValueCache) // 输出确认的选中值 cascaderItemNeedProps.value = reactive(cloneDeep(cascaderItemNeedProps.valueCache)) @@ -111,10 +118,10 @@ export default defineComponent({ // 点击确定过后禁止再次选中 updateStopDefaultType() // 更新值 - updateCascaderValue(cascaderItemNeedProps.value, props?.options, 0) + updateCascaderValue(cascaderItemNeedProps.value, cascaderOptions[0], 0) inputValue.value = cascaderItemNeedProps.inputValueCache.value if (initIptValue) { // 因为初始化了value,所以默认回显视图的选中态 - initActiveIndexs(props.value, props?.options, 0, cascaderItemNeedProps.activeIndexs) + initActiveIndexs(props.value, cascaderOptions[0], 0, cascaderItemNeedProps.activeIndexs) initIptValue = false // 只需要初始化一次,之后不再执行 } }, { @@ -125,7 +132,7 @@ export default defineComponent({ <>
    { multiple.value - ? + ? : Date: Thu, 4 Nov 2021 16:55:02 +0800 Subject: [PATCH 13/59] feat: add character --- .../components/cascader-item/index.tsx | 1 + .../cascader/hooks/use-cascader-multiple.ts | 59 +++++++++++++++---- .../devui-vue/devui/cascader/src/cascader.tsx | 17 +++--- .../docs/components/cascader/index.md | 3 +- 4 files changed, 61 insertions(+), 19 deletions(-) diff --git a/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx b/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx index 6eac8002..163961eb 100644 --- a/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx +++ b/packages/devui-vue/devui/cascader/components/cascader-item/index.tsx @@ -21,6 +21,7 @@ export const DCascaderItem = (props: CascaderItemPropsType) => { activeIndexs.splice(ulIndex, activeIndexs.length - ulIndex) // 更新当前渲染视图的下标数组 activeIndexs[ulIndex] = liIndex + console.log('activeIndexs更新', activeIndexs) if (!multiple) { // 单选点击选项就更新,多选是通过点击checkbox触发数据更新 singleChoose(ulIndex, valueCache, cascaderItem) } diff --git a/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts b/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts index 02e07862..b86dbf10 100644 --- a/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts +++ b/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts @@ -39,7 +39,7 @@ export const useMultiple = (): UseCascaderMultipleCallback => { */ const getMultipleCascaderItem = (currentOption: CascaderItem[], cascaderUlValues: number[], index: number, cascaderOptions) => { const node = currentOption.find(item => item.value === cascaderUlValues[index]) - // node.checked = true + // console.log(ulIndex) if (node?.children?.length > 0) { // 递归获取选中节点 @@ -47,13 +47,24 @@ export const useMultiple = (): UseCascaderMultipleCallback => { getMultipleCascaderItem(node.children, cascaderUlValues, index, cascaderOptions) } else { // 没有子节点了则说明已经是最终节点 - // console.log('node', node, cascaderOptions, index) + // 从最终子节点往上开始查找父节点状态 + node['checked'] = true + node['halfChecked'] = false const ulIndex = cascaderUlValues.findIndex(item => item === node.value) - console.log('node', node, ulIndex) - updateCheckOptionStatus(node, cascaderOptions, ulIndex) + // console.log('node', node, cascaderOptions, cascaderUlValues) + const parentNode = getParentNode2(node.value, cascaderOptions) + // const parentNode = getParentNode(node.value, cascaderOptions, ulIndex - 1) + console.log('父节点', parentNode) + + // updateParentNodeStatus(node, cascaderOptions, ulIndex) + // updateCheckOptionStatus(node, cascaderOptions, ulIndex) // addTagList(tagList, node) } } + + // const updateOptionCheckedStatus = (options, targetValue: string | number, checked: boolean) => { + // } + /** * 多选模式下当有默认选中值时,初始化视图选中状态 * 通过value集合获取下标集合 @@ -84,11 +95,11 @@ export const useMultiple = (): UseCascaderMultipleCallback => { // 如果是半选状态,更新为false,其他状态则更新为与checked相反 // console.log(node, options, ulIndex) if (node?.halfChecked) { // 更新半选状态 - node.halfChecked = false - node.checked = false + node['halfChecked'] = false + node['checked'] = false updateCheckStatusLoop(node, 'halfChecked') } else { - node.checked = !node.checked + node['checked'] = !node.checked // 更新是否选中状态 updateCheckStatusLoop(node, 'checked', node.checked) } @@ -101,8 +112,7 @@ export const useMultiple = (): UseCascaderMultipleCallback => { * @param node 节点 */ const updateCheckStatusLoop = (node: CascaderItem, type: CheckedType, status?: boolean) => { - // console.log(node) - if (node.children) { + if (node?.children?.length > 0) { node.children.forEach(item => { // 当需要改变checked时 // halfChecked一定是false @@ -122,6 +132,7 @@ export const useMultiple = (): UseCascaderMultipleCallback => { }) } else { // 更新tagList + // console.log('add node', node) !node.checked ? deleteTagList(tagList, node) : addTagList(tagList, node) @@ -131,8 +142,10 @@ export const useMultiple = (): UseCascaderMultipleCallback => { * 子节点获取父节点 */ const getParentNode = (childValue: string | number, options: CaascaderOptionsType, ulIndex: number): CascaderItem => { + // console.log('getParentNode', options) if (ulIndex < 0) return const queue = [...options[ulIndex]] + // console.log(queue) let cur: CascaderItem while(queue.length) { cur = queue.shift() @@ -144,7 +157,31 @@ export const useMultiple = (): UseCascaderMultipleCallback => { } return cur } - + const getParentNode2 = (childValue: string | number, options: any): CascaderItem => { + // console.log('childValue', childValue, options) + let cur: CascaderItem + for (let i = 0; i < options.length; i++) { + const queue = [...options[i]?.children] + if (childValue === options[i].value) break + while(queue.length) { + cur = queue.shift() + if (cur.value === childValue) { + cur = options[i] + break + } + if (cur?.children && cur?.children.find(t => t.value === childValue)) { + break + } else if (cur?.children) { + queue.push(...cur?.children) + } + cur = null + } + if (cur) { + break + } + } + return cur + } /** * 更新父节点 */ @@ -163,8 +200,10 @@ export const useMultiple = (): UseCascaderMultipleCallback => { node['checked'] = true node['halfChecked'] = false } + console.log('childNode', node, ulIndex) ulIndex -= 1 const parentNode = getParentNode(node.value, options, ulIndex) + // console.log('parentNode', parentNode, ulIndex) updateParentNodeStatus(parentNode, options, ulIndex) } return { diff --git a/packages/devui-vue/devui/cascader/src/cascader.tsx b/packages/devui-vue/devui/cascader/src/cascader.tsx index 2e65a3df..6635bee5 100644 --- a/packages/devui-vue/devui/cascader/src/cascader.tsx +++ b/packages/devui-vue/devui/cascader/src/cascader.tsx @@ -12,7 +12,6 @@ import { cloneDeep } from 'lodash-es' import './cascader.scss' // import { UnwrapNestedRefs } from '@vue/reactivity' // type OptionsType = UnwrapNestedRefs<[CascaderItem[]]> -let cascaderOptionsCache = reactive({}) export default defineComponent({ name: 'DCascader', @@ -26,6 +25,7 @@ export default defineComponent({ const { initSingleIptValue } = useSingle() // const tagList = reactive([]) // 多选模式下选中的值数组,用于生成tag let initIptValue = props.value.length > 0 ? true : false // 有value默认值时,初始化输出内容 + // console.log('init', props.value) const position = reactive({ originX: 'left', originY: 'bottom', @@ -59,9 +59,8 @@ export default defineComponent({ } else { // 当最新的ul(级)没有下一级时删除之前选中ul的数据 cascaderOptions.splice(index + 1, cascaderOptions.length - 1) + console.log('删除', cascaderOptions) } - cascaderOptionsCache = cascaderOptions - // console.log('cascaderOptions1', cascaderOptionsCache) } /** * 选中项输出 @@ -84,10 +83,9 @@ export default defineComponent({ } } else { // 多选模式 - // console.log('cascaderOptions2', cascaderOptionsCache) + console.log('cascaderOptions2', [ ...props?.options ]) value.forEach((singleValues) => { - console.log(singleValues) - getMultipleCascaderItem(currentOption, singleValues, index, cascaderOptionsCache) + getMultipleCascaderItem(currentOption, singleValues, index, [ ...props?.options ]) }) } } @@ -101,7 +99,8 @@ export default defineComponent({ * 监听视图更新 */ watch(cascaderItemNeedProps.activeIndexs, val => { - // cascaderOptions.splice(0, cascaderOptions.length) + // TODO 多选模式下优化切换选择后的视图切换 + cascaderOptions.splice(val.length, cascaderOptions.length - 1) updateCascaderView(val, cascaderOptions[0], 0) }) /** @@ -120,7 +119,9 @@ export default defineComponent({ // 更新值 updateCascaderValue(cascaderItemNeedProps.value, cascaderOptions[0], 0) inputValue.value = cascaderItemNeedProps.inputValueCache.value - if (initIptValue) { // 因为初始化了value,所以默认回显视图的选中态 + // 因为初始化了value,所以默认回显视图的选中态 + // 多选模式不默认视图打开状态,因为选中了太多个,无法确定展示哪一种选中态 + if (initIptValue && !multiple.value) { initActiveIndexs(props.value, cascaderOptions[0], 0, cascaderItemNeedProps.activeIndexs) initIptValue = false // 只需要初始化一次,之后不再执行 } diff --git a/packages/devui-vue/docs/components/cascader/index.md b/packages/devui-vue/docs/components/cascader/index.md index e900d06f..44e84a4a 100644 --- a/packages/devui-vue/docs/components/cascader/index.md +++ b/packages/devui-vue/docs/components/cascader/index.md @@ -354,7 +354,8 @@ export default defineComponent({ icon: 'folder' } ]) - const value1 = [[1, 4, 8], [1, 4, 9, 81], [1, 41]] + // const value1 = [[1, 4, 8], [1, 4, 9, 81], [1, 41]] + const value1 = [] const onToggleChange = (event) => { console.log(event) } -- Gitee From 3cb21f31e8abbcbf77b22b8dbe36c36534dc14c6 Mon Sep 17 00:00:00 2001 From: lwl <1181102955@qq.com> Date: Fri, 5 Nov 2021 17:45:28 +0800 Subject: [PATCH 14/59] feat: add character --- .../cascader/hooks/use-cascader-multiple.ts | 72 ++++++++++++------- .../devui/cascader/src/cascader-types.ts | 2 +- .../devui-vue/devui/cascader/src/cascader.tsx | 7 +- .../docs/components/cascader/index.md | 4 +- 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts b/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts index b86dbf10..0e37dbcd 100644 --- a/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts +++ b/packages/devui-vue/devui/cascader/hooks/use-cascader-multiple.ts @@ -33,33 +33,46 @@ export const useMultiple = (): UseCascaderMultipleCallback => { } /** * 获取选中的节点 - * @param currentOption 选中的某项 - * @param cascaderUlValues 多选集合中的某一个集合 - * @param index cascaderUlValues数组的起始项,最开始为0 */ - const getMultipleCascaderItem = (currentOption: CascaderItem[], cascaderUlValues: number[], index: number, cascaderOptions) => { - const node = currentOption.find(item => item.value === cascaderUlValues[index]) + const getMultipleCascaderItem = (targetValues: number[], cascaderOptions: CascaderItem[]) => { + console.log('init', targetValues, cascaderOptions) + // const node = currentOption.find(item => item.value === cascaderUlValues[index]) + // 找出 - // console.log(ulIndex) - if (node?.children?.length > 0) { - // 递归获取选中节点 - index += 1 - getMultipleCascaderItem(node.children, cascaderUlValues, index, cascaderOptions) - } else { - // 没有子节点了则说明已经是最终节点 - // 从最终子节点往上开始查找父节点状态 - node['checked'] = true - node['halfChecked'] = false - const ulIndex = cascaderUlValues.findIndex(item => item === node.value) - // console.log('node', node, cascaderOptions, cascaderUlValues) - const parentNode = getParentNode2(node.value, cascaderOptions) - // const parentNode = getParentNode(node.value, cascaderOptions, ulIndex - 1) - console.log('父节点', parentNode) - - // updateParentNodeStatus(node, cascaderOptions, ulIndex) - // updateCheckOptionStatus(node, cascaderOptions, ulIndex) - // addTagList(tagList, node) + const findNextColumn = (targetValues, options, index) => { + + const targetNode = options.find(t => t.value === targetValues[index]) + console.log('target', targetNode) + // if (targetNode?.halfChecked) { // 更新半选状态 + // targetNode['halfChecked'] = false + // targetNode['checked'] = false + // } else { + // targetNode['checked'] = !targetNode.checked + // // 更新是否选中状态 + // } + if (targetNode?.children?.length > 0) { + index += 1 + findChildrenCheckedStatusToUpdateParent(targetNode) + findNextColumn(targetValues, targetNode.children, index) + } else { + targetNode['checked'] = true + } } + findNextColumn(targetValues, cascaderOptions, 0) + // console.log(ulIndex) + // if (node?.children?.length > 0) { + // // 递归获取选中节点 + // index += 1 + // getMultipleCascaderItem(node.children, cascaderUlValues, index, cascaderOptions) + // } else { + // // 没有子节点了则说明已经是最终节点 + // // 从最终子节点往上开始查找父节点状态 + // node['checked'] = true + // node['halfChecked'] = false + // const ulIndex = cascaderUlValues.findIndex(item => item === node.value) + // const parentNode = getParentNode2(node.value, cascaderOptions) + // console.log('父节点', parentNode) + // } } // const updateOptionCheckedStatus = (options, targetValue: string | number, checked: boolean) => { @@ -185,21 +198,28 @@ export const useMultiple = (): UseCascaderMultipleCallback => { /** * 更新父节点 */ - const updateParentNodeStatus = (node: CascaderItem, options: CaascaderOptionsType, ulIndex: number) => { - if (ulIndex < 0) return + const findChildrenCheckedStatusToUpdateParent = (node) => { const checkedChild = node?.children?.find(t => t['checked']) const halfcheckedChild = node?.children?.find(t => t['halfChecked']) const uncheckedChild = node?.children?.find(t => !t['halfChecked'] && !t['checked']) + console.log('check', node, checkedChild, halfcheckedChild, uncheckedChild) if (halfcheckedChild || (checkedChild && uncheckedChild)) { + console.log('半选') node['checked'] = false node['halfChecked'] = true } else if (!checkedChild && !halfcheckedChild) { + console.log('空') node['checked'] = false node['halfChecked'] = false } else { + console.log('选中') node['checked'] = true node['halfChecked'] = false } + } + const updateParentNodeStatus = (node: CascaderItem, options: CaascaderOptionsType, ulIndex: number) => { + if (ulIndex < 0) return + findChildrenCheckedStatusToUpdateParent(node) console.log('childNode', node, ulIndex) ulIndex -= 1 const parentNode = getParentNode(node.value, options, ulIndex) diff --git a/packages/devui-vue/devui/cascader/src/cascader-types.ts b/packages/devui-vue/devui/cascader/src/cascader-types.ts index f2d175b6..e228c615 100644 --- a/packages/devui-vue/devui/cascader/src/cascader-types.ts +++ b/packages/devui-vue/devui/cascader/src/cascader-types.ts @@ -128,7 +128,7 @@ export interface UseCascaderMultipleCallback { addTagList: (a: CascaderItem[], b: CascaderItem) => void deleteTagList: (a: CascaderItem[], b: CascaderItem) => void initTagList: (a: CascaderItem[]) => void - getMultipleCascaderItem: (a: CascaderItem[], b: number[], c: number, d: any) => void + getMultipleCascaderItem: (a: number[], b: CascaderItem[]) => void updateCheckOptionStatus: (a: CascaderItem, options: CaascaderOptionsType, ulIndex: number) => void initActiveIndexs: (a: CascaderValueType, b: CascaderItem[], c: number, d: number[]) => void updateCheckStatusLoop: (a: CascaderItem, b: CheckedType, c?: boolean) => void diff --git a/packages/devui-vue/devui/cascader/src/cascader.tsx b/packages/devui-vue/devui/cascader/src/cascader.tsx index 6635bee5..9ab2bf63 100644 --- a/packages/devui-vue/devui/cascader/src/cascader.tsx +++ b/packages/devui-vue/devui/cascader/src/cascader.tsx @@ -59,7 +59,6 @@ export default defineComponent({ } else { // 当最新的ul(级)没有下一级时删除之前选中ul的数据 cascaderOptions.splice(index + 1, cascaderOptions.length - 1) - console.log('删除', cascaderOptions) } } /** @@ -84,8 +83,8 @@ export default defineComponent({ } else { // 多选模式 console.log('cascaderOptions2', [ ...props?.options ]) - value.forEach((singleValues) => { - getMultipleCascaderItem(currentOption, singleValues, index, [ ...props?.options ]) + value.forEach((targetValue) => { + getMultipleCascaderItem(targetValue, cascaderOptions[0]) }) } } @@ -116,7 +115,7 @@ export default defineComponent({ menuShow.value = false // 点击确定过后禁止再次选中 updateStopDefaultType() - // 更新值 + // 更新值 updateCascaderValue(cascaderItemNeedProps.value, cascaderOptions[0], 0) inputValue.value = cascaderItemNeedProps.inputValueCache.value // 因为初始化了value,所以默认回显视图的选中态 diff --git a/packages/devui-vue/docs/components/cascader/index.md b/packages/devui-vue/docs/components/cascader/index.md index 44e84a4a..b4509c6c 100644 --- a/packages/devui-vue/docs/components/cascader/index.md +++ b/packages/devui-vue/docs/components/cascader/index.md @@ -354,8 +354,8 @@ export default defineComponent({ icon: 'folder' } ]) - // const value1 = [[1, 4, 8], [1, 4, 9, 81], [1, 41]] - const value1 = [] + const value1 = [[1, 4, 8], [1, 4, 9, 81], [1, 41]] + // const value1 = [] const onToggleChange = (event) => { console.log(event) } -- Gitee From 65c412dffa532790dbfa4d7d37d9701e673f2b1e Mon Sep 17 00:00:00 2001 From: xiaojiujiu <3507440900@qq.com> Date: Mon, 8 Nov 2021 00:03:58 +0800 Subject: [PATCH 15/59] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E8=8B=B1=E6=96=87=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../en-US/components/accordion/accordion.md | 189 ++++++++++++++++++ .../docs/en-US/components/alert/alert.md | 38 ++++ .../docs/en-US/components/anchor/anchor.md | 126 ++++++++++++ .../docs/en-US/components/avatar/avatar.md | 42 ++++ .../docs/en-US/components/button/button.md | 82 ++++++++ 5 files changed, 477 insertions(+) create mode 100644 packages/devui-vue/docs/en-US/components/accordion/accordion.md create mode 100644 packages/devui-vue/docs/en-US/components/alert/alert.md create mode 100644 packages/devui-vue/docs/en-US/components/anchor/anchor.md create mode 100644 packages/devui-vue/docs/en-US/components/avatar/avatar.md create mode 100644 packages/devui-vue/docs/en-US/components/button/button.md diff --git a/packages/devui-vue/docs/en-US/components/accordion/accordion.md b/packages/devui-vue/docs/en-US/components/accordion/accordion.md new file mode 100644 index 00000000..dba8ce67 --- /dev/null +++ b/packages/devui-vue/docs/en-US/components/accordion/accordion.md @@ -0,0 +1,189 @@ +# How to use + +Import into module: + +```typescript +import { AccordionModule } from ' ng-devui/accordion'; +``` + +On the page: + +```html + +``` + +## Accordion + +### d-accordion parameter + +| Parameter | Type | Default | Description | Jump to Demo |Global Config| +| :----------------: | :----------------: | :----------------------------------------------------: | :--------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | -------------------------------------------------------------------------- | +| data | `Array \| AccordionMenuType` | -- | Required. Data source. You can customize an array or use the preset `AccordionMenuType` | [Basic usage](demo#basic-usage) | +| titleKey | `string` | 'title' | Optional. Title attribute name. The type of item[titleKey] is `string`, indicating the title content. | [Change key value](demo#change-values) | +| loadingKey | `string` | 'loading' | Optional. attribute name for determining whether a submenu is loaded. The type of item[loadingKey] is `boolean` | [Change key value](demo#change-values) | +| childrenKey | `string` | 'children' | Optional. Submenu attribute name. The type of item[childrenKey] is `Array` | [Change key value](demo#change-values) | +| disabledKey | `string` | 'disabled' | Optional. indicating whether to disable the attribute. The type of item[disabledKey] is `boolean` | [Change key value](demo#change-values) | +| activeKey | `string` | 'active' | Optional. indicating whether a submenu is activated. The type of item[activeKey] is `boolean` | [Change key value](demo#change-values) | +| openKey | `string` | 'open' | Optional. indicating whether a menu is expanded. The type of item[openKey] is `boolean` | [Change key value](demo#change-values) | +| restrictOneOpen | `boolean` | false | Optional. Only one level-1 menu can be opened at a time. By default, there is no restriction. | [Basic usage](demo#basic-usage) | +| menuItemTemplate | `TemplateRef` | Built-in | Optional. It can expand the menu content bar template. The available variable values are as follows. | [Using a Template](demo#using-templates) | +| itemTemplate | `TemplateRef` | Built-in | Optional. The menu content bar template can be clicked. The available variable values are as follows: | [Using a Template](demo#using-templates) | +| noContentTemplate | `TemplateRef` | Built-in | Optional. If there is no content, use a customized template. The available variable values are as follows: | [Using a Template](demo#using-templates) | +| loadingTemplate | `TemplateRef` | Built-in | Optional. A customized template is used for loading. The available variable values are as follows | [Using a Template](demo#using-templates) | +| innerListTemplate | `TemplateRef` | Built-in | Optional. The sublist content is customized and used as a folding panel. The available variable values are as follows. | [Using a Template](demo#using-templates) | +| linkType | `'routerLink'\|'hrefLink'\|'dependOnLinkTypeKey'\|'''` | '' | Optional. `routerLink'` indicates the routing scenario. `hrefLink'` indicates the external link scenario. `dependOnLinkTypeKey'` indicates the dynamic routing or external link scenario. `''` is the default non-link type (you cannot right-click to open a new tab page) | [Built-in route and link type](demo#use-built-in-routing-and-link-types) | +| linkTypeKey | `string` | 'linkType' | Optional. Key value of the link type, which is used to specify the object link type attribute name when linkType is set to `'dependOnLinkTypeKey'`. The value of item[linkTypeKey] is `'routerLink'\|'hrefLink'\| string`, in the preceding information, `routerLink'` indicates a route link, `hrefLink'` indicates an external link, and other values are default non-link types. | +| linkKey | `string` | 'link' | Optional. Key of the link content, which is used to set the value of the link value when linkType is not set to ````. item[linkKey] indicates the route address or hyperlink address. | +| linkTargetKey | `string` | 'target' | Optional. Key of the target window to be linked, which is used for the link type. item[linkTargetKey] indicates the target window of a single link. | +| linkDefaultTarget | `string` | '\_self' | Optional. If target is not set, the default value of target is `'\_self'`, which is used for the link type and its value is the same as that of target attribute of link a. | [Built-in route and link type](demo#use-built-in-routing-and-link-types) | +| autoOpenActiveMenu | `boolean` | false | Optional. Whether to automatically expand menus with active subitems | [Composite Hierarchy and Auto Expand](demo#compound-level-and-auto-expand) | +| accordionType | `normal ' \| 'embed'` | 'normal' | Optional. The menu format is common (with shadow) or embedded (without shadow). | [Basic usage](demo#basic-usage) | +| showAnimation | `boolean` | true | Optional. Indicating whether to display animations. | [Built-in route and link type](demo#use-built-in-routing-and-link-types) | ✔ | + +### d-accordion event + +| Event | Type | Description | Jump to Demo | +| :--------------: | :-----------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | ------------------------------- | +| menuToggle | `EventEmitter<`[`AccordionMenuToggleEvent`](#accordionmenutoggleevent)`>` | Optional. The menu can be expanded. In the returned object, the attribute item is the object data clicked. If open is true, the object will be expanded. If open is false, the object will be closed. If parent is the parent object data. Event is the native event of the click event. | [Basic usage](demo#basic-usage) | +| itemClick | `EventEmitter<`[`AccordionItemClickEvent`](#accordionitemclickevent)`>` | Optional. It can click a menu event. In the returned object, the attribute item is the object data of the clicked object, the preActive object is the object expanded last time, the parent object is the data of the parent object, and the event is the native event of the click event. | [Basic usage](demo#basic-usage) | +| activeItemChange | `EventEmitter` | Optional. Data of the newly activated sub-item is sent when the sub-item is switched. | [Basic usage](demo#basic-usage) | + +### AccordionMenuType Definition + +```typescript +/* Basic data type */ +type AccordionMenuItemLinkType = 'routerLink' | 'hrefLink' | string; +export interface AccordionBase { + title: string; + disabled?: boolean; + [prop: string]: any; +} +interface IAccordionActiveable { + active?: boolean; +} +interface IAccordionFoldable { + open?: boolean; + loading?: boolean; + children?: Array; +} +interface IAccordionLinkable { + link?: string; + target?: boolean; + linkType?: AccordionMenuItemLinkType; +} +export interface AccordionBaseItem extends AccordionBase, IAccordionActiveable {} +export interface AccordionBaseMenu extends AccordionBase, IAccordionFoldable {} +export interface AccordionLinkableItem extends AccordionBase, IAccordionActiveable, IAccordionLinkable {} +export interface AccordionMenuItem extends AccordionBase, IAccordionActiveable, IAccordionFoldable, IAccordionLinkable {} +export type AccordionMenuType = Array; + +/* Common configuration data type */ +interface AccordionMenuKeyGroup { + titleKey?: string; + activeKey?: string; + disabledKey?: string; + openKey?: string; + loadingKey?: string; + childrenKey?: string; + linkKey?: string; + linkTargetKey?: string; + linkTypeKey?: string; +} +type AccordionTemplateRefArray = 'itemTemplate' | 'menuItemTemplate' | 'noContentTemplate' | 'loadingTemplate' | 'innerListTemplate'; +type AccordionTemplateRefGroup = { + [p in AccordionTemplateRefArray]: TemplateRef; +}; +interface AccordionConfigOptions { + restrictOneOpen?: boolean; + autoOpenActiveMenu?: boolean; + showNoContent?: boolean; + linkDefaultTarget?: string; + i18nText: any; + linkType: 'routerLink' | 'hrefLink' | 'dependOnLinkTypeKey' | ''; +} +export interface AccordionOptions extends AccordionConfigOptions, AccordionMenuKeyGroup, AccordionTemplateRefGroup {} +``` + +## AccordionMenuToggleEvent + +```typescript +export type AccordionMenuToggleEvent = { + item: any; + open: boolean; + parent: any; + event: MouseEvent; +}; +``` + +## AccordionItemClickEvent + +```typescript +export type AccordionItemClickEvent = { + item: any; + prevActiveItem?: any; + parent: any; + event: MouseEvent; +}; +``` + +### Templates can use variable values. + +#### Variable Usage + +```html +{{myitem}} +``` + +#### menuItemTemplate Available variable values + +| Variable | Type | Variable Description | +| :----------------: | :--------: | :------------------------------------------------------------------------------------------: | +| item | `any` | Expandable menu data | +| deepth | `number` | Indicates the nested structure level. | +| parent | `any` | Parent menu data | +| ~~~titleKey~~~ | `string` | Deprecated.~~~ The titleKey value of the component. ~~~ | +| ~~~disabledKey~~~ | `string` | Deprecated. ~~~ The value of the disabledKey of the component. ~~~ | +| ~~~openKey~~~ | `string` | Deprecated. ~~~ The openKey value of the component. ~~~ | +| ~~~menuToggleFn~~~ | `Function` | Deprecated.~~~ The parameter should be item, indicating that the level-1 menu is clicked.~~~ | + +#### itemTemplate Available variable values + +| Variable | Type | Variable Description | +| :---------------: | :--------: | :------------------------------------------------------------------------------------------: | +| item | `any` | Clickable menu data | +| deepth | `number` | The value indicates the nested structure level. | +| parent | `any` | Parent menu data | +| ~~~titleKey~~~ | `string` | Deprecated.~~~ The titleKey value of the component ~~~ | +| ~~~disabledKey~~~ | `string` | Deprecated.~~~ The value of the disabledKey of the component ~~~ | +| ~~~activeKey~~~ | `string` | Deprecated.~~~ The activeKey value of the component ~~~ | +| ~~~itemClickFn~~~ | `Function` | Deprecated. ~~~The parameter should be item, indicating that the level-2 menu is clicked.~~~ | + +#### noContentTemplate Available variable value + +| Variable | Type | Variable Description | +| :------: | :------: | :---------------------------------------------: | +| item | `any` | Parent menu single data | +| deepth | `number` | The value indicates the nested structure level. | + +#### loadingTemplate Available variable values + +| Variable | Type | Variable Description | +| :---------------------: | :--------------: | :---------------------------------------------: | +| item | `any` | Parent menu single data | +| deepth | `number` | The value indicates the nested structure level. | +| LoadingKey value of the | ~~~loadingKey~~~ | `string` | ~~~ component ~~~ | + +#### InnerListTemplate Available Variable Values + +| Variable | Type | Variable Description | +| :---------------: | :--------: | :------------------------------------------------------------------------------------------------------------------------------------------------------: | +| item | `any` | Parent menu single data | +| deepth | `number` | The value indicates the nested structure level. | +| ~~~titleKey~~~ | `string` | Deprecated.~~~The titleKey value of the component ~~~ | +| ~~~loadingKey~~~ | `string` | Deprecated.~~~ The loading key value of the component ~~~ | +| ~~~childrenKey~~~ | `string` | Deprecated.~~~ The value of childrenKey of the component ~~~ | +| ~~~disabledKey~~~ | `string` | Deprecated.~~~ The value of the disabledKey of the component ~~~ | +| ~~~openKey~~~ | `string` | Deprecated.~~~ The openKey value of the component ~~~ | +| ~~~activeKey~~~ | `string` | Deprecated. ~~~ The activeKey value of the component Use the level-2 menu ~~~ | +| menuToggleFn | `Function` | The parameter should be item, indicating that the menu is expanded. The optional parameter event, original event, is used. | +| itemClickFn | `Function` | The parameter must be an item of a menu that can be clicked, indicating that the menu is clicked. The optional parameter event, original event, is used. | diff --git a/packages/devui-vue/docs/en-US/components/alert/alert.md b/packages/devui-vue/docs/en-US/components/alert/alert.md new file mode 100644 index 00000000..a3af2132 --- /dev/null +++ b/packages/devui-vue/docs/en-US/components/alert/alert.md @@ -0,0 +1,38 @@ +# How to use + +Import into module: + +```ts +import { AlertModule } from 'ng-devui/alert'; +``` + +In the page: + +```xml + +``` +# d-alert +## d-alert Parameter + +| Attributes | Type | Default | Description | Jump to Demo |Global Config| +| :----------------: | :---------: | :--------------------------------------: | :----: | :---------------------------------------- | ------------------------------------------ | +| type | [`AlertType`](#alerttype) | 'info' | Required. Specify the style of the warning prompt | [Basic Usage](demo#basic-usage) | +| cssClass | `string` | -- | Optional. Customize className | +| closeable | `boolean` | true | Optional. The close button is displayed by default | [Basic Usage](demo#tips-to-close) | +| dismissTime | `number` | -- | Optional. Toggle off the delay time of Alert(`ms`) | +| showIcon | `boolean` | true | Optional. Whether to use the default type icon | [Without Icon](demo#without-icon) | + +## d-alert Event + +| Attributes | Type | Description | Jump to Demo | +| :--------: | :-----------------: | :------------------------- | -------------------------------------------- | +| closeEvent | `EventEmitter` | Optional. Callback when alert is closed | [Closable Prompt](demo#tips-to-close) | + +# Interface & Type Definition +### AlertType + +The default value is 'info', which specifies the type of alert warning. + +```ts +export type AlertType = 'success' | 'danger' | 'warning' | 'info' | 'simple'; +``` diff --git a/packages/devui-vue/docs/en-US/components/anchor/anchor.md b/packages/devui-vue/docs/en-US/components/anchor/anchor.md new file mode 100644 index 00000000..fd1bd914 --- /dev/null +++ b/packages/devui-vue/docs/en-US/components/anchor/anchor.md @@ -0,0 +1,126 @@ +# How to use + +Import into module: + +```ts +import { AnchorModule } from 'ng-devui'; +``` + +In the page: + +```html +
    +
      +
    • anchorlink-one
    • +
    • anchorlink-two
    • +
    • anchorlink-three
    • +
    • anchorlink-four
    • +
    +
    +
    + anchorlink-one +
    +
    + anchorlink-two +
    +
    + anchorlink-three +
    +
    + anchorlink-four +
    +
    +
    +``` + +```ts +// using router (cross-route), anchorName means your own anchor +this.router.navigateByUrl('../xx/xxx#anchorName'); +this.router.navigate(['/xxx'], { fragment: 'anchorName' }); + +// using router (at the same level), anchorName means your own anchor +this.router.navigateByUrl('#anchorName'); +this.router.navigate([], { fragment: 'anchorName' }); +``` + +# dAnchor + +Define an anchor point + +## dAnchor Parameters + +| Parameter | Type | Default | Description | Jump to Demo |Global Config| +| :----------------: | :----------: | :------: | :-----: | :---------------------------------------------------------------------------------------------------: | -------------------------------------------------- | +| dAnchor | `string` | -- | Required. Sets an anchor name. | [Basic Usage](demo#basic-usage) | +| anchorActive | `string` | -- | Optional. When the anchor is activated, the corresponding CSS class name takes effect for the module. | [Basic Usage](demo#basic-usage) | + +## dAnchor Anchor Activation Event + +The following classes are automatically added to the anchor to correspond to different activated objects: + +| css class name | Meaning | +| :---------------------------: | :-------------------------------------------------------: | +| anchor-active-by-anchor-link | Click the anchor link to activate it. | +| anchor-active-by-scroll | The container scrolls to the anchor point for activation. | +| anchor-active-by-click-inside | Click the anchor content to activate it. | +| anchor-active-by-initial | Initialize the scroll bar position. | + +# dAnchorLink + +Define a link of an anchor point. Click the link to slide to the anchor point. When the anchor point is at the top of the page, the link class is activated. + +## dAnchorLink Parameters + +| Parameter | Type | Default | Description | Jump to Demo | +| :----------: | :------: | :-----: | :------------------------------------------------------------------------------------------------: | -------------------------------------------------- | +| dAnchorLink | `string` | -- | Required. Name of the target anchor point for sliding. | [Basic Usage](demo#basic-usage) | +| anchorActive | `string` | -- | Optional. CSS class name corresponding to the link that takes effect when the anchor is activated. | [Basic Usage](demo#basic-usage) | + +# dAnchorBox + +There must be one container. Otherwise, the function cannot be used. + +Defines a container for scanning anchor points, placed on the common parent node of dAnchor and dAnchorLink, for communication between anchor points and links. + +## dAnchorBox Parameters + +| Parameter | Type | Default | Description | Jump to Demo | +| :-----------: | :----------------------------: | :-------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | --------------------------------------------------------------------- | +| view | `{top?:number,bottom?:number}` | {top:0,bottom:0} | Optional. It is used to adjust the visible region, for example, the head with a fixed position on the top. The value corresponds to the height of the blocked top or bottom. | [Basic Usage](demo#basic-usage) | +| defaultAnchor | `string` | -- | Optional. An anchor link that is activated by default after a page is displayed. Generally, the first anchor link is set to the first anchor link. If this parameter is not set, the first anchor link can be activated only when the first anchor is moved to the top position. | [Basic Usage](demo#basic-usage) | +| scrollTarget | `HTMLElement` | document.documentElement(document.body) | Optional. Sets the container where the scroll bar is located. This parameter is optional when the scroll bar is on the home page. | [Replace Rolling Container](demo#scroll-target) | + +# dAnchorHashSupport + +dAnchorBox support instruction + +## dAnchorHashSupport Parameters + +The following parameters are advanced configuration parameters and are not required. You only need to use dAnchorHashSupport. + +| Parameter | Type | Default | Description | Jump to Demo | +| :--------------------------: | :-------: | :-----: | :-----------------------------------------------------------------------------------------------------------------------------------------------------: | ------------------------------------------------------------------ | +| updateUrlWhenAnchorActive | `boolean` | true | Optional. The URL is updated when the anchor is activated. The default value is true. | [URL Hash Anchor](demo#support-hash) | +| scrollToAnchorByHashOnlyInit | `boolean` | false | Optional. True indicates that the fragment field changes from routes are received only during initialization. This field is used for complex scenarios. | [URL Hash Anchor](demo#support-hash) | + +The dAnchorHashSupport command is used together with the dAnchorBox command to bind the hash fragment of a route. For example, xxx.xxx/xxx#foo, where the foo field is a hash field. +The hop hash field can be the anchor component, route navigate, and routerLink fragment field. + +# Note + +Note that this parameter cannot be used together with the RouterScoller of the routing module of ng6.1 or later. The routerlScroller will scroll to the traditional ID anchor point. +Using RouterScroller alone, you can configure the routing module. + +```ts +@NgModule({ + //...... + imports: [ + //...... + RouterModule.forRoot(routes, { + anchorScrolling: 'enabled', // This policy conflicts with the dAnchorHashSupport instruction of the anchor component. + }), + ], + //...... +}) +export class DemoModule {} +``` diff --git a/packages/devui-vue/docs/en-US/components/avatar/avatar.md b/packages/devui-vue/docs/en-US/components/avatar/avatar.md new file mode 100644 index 00000000..f057f819 --- /dev/null +++ b/packages/devui-vue/docs/en-US/components/avatar/avatar.md @@ -0,0 +1,42 @@ +# How to use + +Import into module: + +```ts +import { AvatarModule } from 'ng-devui/avatar'; +``` + +In the page: + +```xml + +``` +# d-avatar +## d-avatar Parameter + +| Parameter | Type | Default | Description | Jump to Demo |Global Config| +| :----------------: | :--------: | :--------------------: | :--: | :-------------------------------------------------------------------------- | ------------------------------------------------------------- | +| name | `string` | -- | Required. The input character string is used to create a profile picture. | [Basic Rules](demo#basic-rules) | +| gender | `string \| male \| female` | -- | Optional. The profile picture color is differentiated by gender. The input string can be in the format of `female \| male`. | [Basic Rules](demo#basic-rules) | +| width | `number` | 40 | Optional. Width of the avatar(`px`) | [Basic Configuration](demo#basic-configuration) | +| height | `number` | 40 | Optional. Set the height of the avatar(`px`) | [Basic Configuration](demo#basic-configuration) | +| isRound | `boolean` | true | Optional. Indicating whether to display a circular avatar | [Basic Configuration](demo#basic-configuration) | +| imgSrc | `string` | -- | Optional. Import a customized image as the avatar | [Basic Configuration](demo#basic-configuration) | +| customText | `string` | -- | Optional. Input the customized display text | [Basic Configuration](demo#basic-configuration) | + + +### Basic Profile Picture Display Rules + +- `Begin with Chinese `: Use the last two characters. +- `Begin with English `: Use the first two characters. +- `Use multiple English names together`: Use the first two letters of the first English name. +- `Not starting with Chinese or English `: Use the first two characters. + +### Special avatar display rules + +- If `name`, `customText`, and `imgSrc` are not transferred, the user who uses the avatar does not exist. +- If the values of `name`, `customText`, and `imgSrc` are empty, the user who uses the avatar does not have a nickname and the default avatar is used. + +### Display Priority + +imgSrc > customText > name diff --git a/packages/devui-vue/docs/en-US/components/button/button.md b/packages/devui-vue/docs/en-US/components/button/button.md new file mode 100644 index 00000000..b626daa9 --- /dev/null +++ b/packages/devui-vue/docs/en-US/components/button/button.md @@ -0,0 +1,82 @@ +# How to use + +Import into module: + +```ts +import { ButtonModule } from 'ng-devui/button'; +``` + +In the page: + +```xml + +``` +# d-button +## d-button Parameter + +| Parameter | Type | Default | Description | Jump to Demo |Global Config| +| :----------------: | :---------: | :------------: | :-----: | :--------------------------------------------------------------------------- | | +| id | `string` | -- | Optional. ID of the button. | [Primary Buttons](demo#button-primary)| +| type | [`IButtonType`](#ibuttontype) | 'button' | Optional. The type is `'button' \| 'submit' \| 'reset'` |[Danger Buttons](demo#button-danger) | +| bsStyle | [`IButtonStyle`](#ibuttonstyle) | 'primary' | Optional. The style is `'primary' \| 'common' \| 'text' \| 'text-dark' \| 'danger'` | [Common Buttons](demo#button-common) | +| bsSize | [`IButtonSize`](#ibuttonsize) | 'md' | Optional. The size is `'lg' \| 'md' \| 'sm' \| 'xs'` | [Button Size](demo#button-size) | +| bsPosition |[`IButtonPosition`](#ibuttonposition) |'default'| Optional. The button position is `'default' \| 'left' \| 'right'` | [Left & Right Buttons](demo#button-left-right) | +| bordered | `boolean` | false | Optional. Indicating whether a border exists | [Auto-focus Buttons](demo#button-auto-focus)| +| icon | `string` | -- | Optional. Customized button icon | [Icon Buttons](demo#button-icon) | +| showLoading | `boolean` | false | Optional. Indicating whether to display the loading prompt | [Loading Buttons](demo#button-loading) | +| width | `string` | -- | Optional. Button width |[Combinations of Primary & Common Buttons](demo#button-primary-and-common) | +| disabled | `boolean` | false | Optional. Indicating whether to disable the button | [Primary Buttons](demo#button-primary) | +| autofocus | `boolean` | false | Optional. Indicating whether to automatically obtain the focus during button loading | [Auto-focus Buttons](demo#button-auto-focus) | + +## d-button Event + +| Parameter | Type | Description | Jump to Demo | +| :------: | :-----------------: | :-------------------------------------------------------------------------------------- | ---------------------------------------------- | +| btnClick | `EventEmitter` | Optional. Solve the click event is triggered when button is disabled. After the mouse is clicked, the mouse event object is returned | [Loading Buttons](demo#button-loading)| + +# d-button-group + +## d-button-group parameter + +| Parameter | Type | Default | Description | Jump to Demo |Global Config| +| :----------------: | :---------: | :------------: | :-----: | :--------------------------------------------------------------------------- | | +| size | [`IButtonGroupSize`](#ibuttongroupsize) | 'md' | Optional. The size is `'lg' \| 'md' \| 'sm' \| 'xs'` | [Button Group](demo#button-groups) | + +# Interface & Type Definition +### IButtonType + +The default value is 'button', indicating the button type. + +```ts +export type IButtonType = 'button' | 'submit' | 'reset'; +``` + +### IButtonStyle + +The default value is 'primary', indicating the button style. + +```ts +export type IButtonStyle = 'common' | 'primary' | 'text' | 'text-dark' | 'danger'; +``` + +### IButtonPosition + +The default value is 'default', indicating the button position. + +```ts +export type IButtonPosition = 'left' | 'right' | 'default'; +``` + +### IButtonSize +The default value is 'md', indicating the button size. + +```ts +export type IButtonSize = 'lg' | 'md' | 'sm' | 'xs'; +``` + +### IButtonGroupSize +The default value is 'md', indicating the button-group size. + +```ts +export type IButtonGroupSize = 'lg' | 'md' | 'sm' | 'xs'; +``` -- Gitee From 8adf612d5b771a479a99e3ca204ab086adf88f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=BF=9C=E6=88=90?= Date: Mon, 8 Nov 2021 20:48:37 +0800 Subject: [PATCH 16/59] init --- .../devui/accordion/src/accordion-list.tsx | 33 ++++-- .../devui/accordion/src/accordion-menu.tsx | 55 ++++++++- .../devui/accordion/src/accordion-types.ts | 63 ++++++++++ .../devui/accordion/src/accordion.scss | 40 +++++-- .../devui/accordion/src/accordion.tsx | 61 +--------- .../devui/dropdown/src/dropdown.scss | 2 +- .../docs/components/accordion/index.md | 108 +++++++++++++++++- 7 files changed, 280 insertions(+), 82 deletions(-) create mode 100644 packages/devui-vue/devui/accordion/src/accordion-types.ts diff --git a/packages/devui-vue/devui/accordion/src/accordion-list.tsx b/packages/devui-vue/devui/accordion/src/accordion-list.tsx index 362cae3e..0213622b 100644 --- a/packages/devui-vue/devui/accordion/src/accordion-list.tsx +++ b/packages/devui-vue/devui/accordion/src/accordion-list.tsx @@ -1,11 +1,16 @@ -import { defineComponent } from 'vue' -import { AccordionMenuItem } from './accordion.type' +import { defineComponent, toRefs } from 'vue' +import type { AccordionMenuItem } from './accordion.type' +import DAccordionMenu from './accordion-menu' +import { accordionProps } from './accordion-types' export default defineComponent({ name: 'DAccordionList', inheritAttrs: false, + components: { + DAccordionMenu + }, props: { - data: { + data: { type: Array as () => Array, default: null }, @@ -13,28 +18,32 @@ export default defineComponent({ type: Number, default: 0 }, - parent: { + parent: { type: Object as () => AccordionMenuItem, default: null }, innerListTemplate: Boolean, + ...accordionProps, }, setup(props, ctx) { + console.log('list', props) + const { + childrenKey + } = toRefs(props) return () => { return (!props.innerListTemplate || props.deepth === 0) &&
      - { props.data.map(item => { + {props.data.map(item => { return
    • - { - // TODO 菜单类型 d-accordion-menu - } -
      + {/* // TODO 菜单类型 d-accordion-menu */} + {childrenKey !== undefined && } + {/*
      { item.title }
      { // TODO 子菜单 d-accordion-list }
        - { item.children.map(component => { + { item.children?.map(component => { return
      • { // TODO 路由链接 d-accordion-item-routerlink @@ -50,9 +59,9 @@ export default defineComponent({ })}
      -
      +
      */}
    • - }) } + })}
    } } diff --git a/packages/devui-vue/devui/accordion/src/accordion-menu.tsx b/packages/devui-vue/devui/accordion/src/accordion-menu.tsx index c5280a3b..e79c63d0 100644 --- a/packages/devui-vue/devui/accordion/src/accordion-menu.tsx +++ b/packages/devui-vue/devui/accordion/src/accordion-menu.tsx @@ -1,13 +1,58 @@ -import { defineComponent } from 'vue' +import { computed, defineComponent, toRefs } from 'vue' +import { AccordionMenuItem } from './accordion.type' +import DAccordionList from './accordion-list' +import { accordionProps } from './accordion-types' export default defineComponent({ name: 'DAccordionMenu', props: { - + item: Object as () => AccordionMenuItem, + deepth: { + type: Number, + default: 0 + }, + parent: { + type: Object as () => AccordionMenuItem, + default: null + }, + ...accordionProps }, - setup() { - return () => { - return
  • d-accordion-menu
  • + setup(props) { + const { item, deepth } = toRefs(props) + + + const menuItemClasses = computed(() => { + return (keyOpen === undefined && props.autoOpenActiveMenu) + ? childActived + : keyOpen + }) + + const keyOpen = computed(() => { + return item?.value[props.openKey]; + }) + const childActived = computed(() => { + // return props.routerLinkActived || props.hasActiveChildren + }) + + return () => { + return ( + <> +
    + {item.value.title} +
    + + + + ) } } }) \ No newline at end of file diff --git a/packages/devui-vue/devui/accordion/src/accordion-types.ts b/packages/devui-vue/devui/accordion/src/accordion-types.ts new file mode 100644 index 00000000..b64c0445 --- /dev/null +++ b/packages/devui-vue/devui/accordion/src/accordion-types.ts @@ -0,0 +1,63 @@ +import { ExtractPropTypes } from "vue"; +import { AccordionMenuType } from "./accordion.type"; + +export const accordionProps = { + data: { + type: Array as () => Array | AccordionMenuType, + default: null, + }, + /* Key值定义, 用于自定义数据结构 */ + titleKey: { type: String, default: "title" }, // 标题的key,item[titleKey]类型为string,为标题显示内容 + loadingKey: { type: String, default: "loading" }, // 子菜单动态加载item[loadingKey]类型为boolean + childrenKey: { type: String, default: "children" }, // 子菜单Key + disabledKey: { type: String, default: "disabled" }, // 是否禁用Key + activeKey: { type: String, default: "active" }, // 菜单是否激活/选中 + openKey: { type: String, default: "open" }, // 菜单是否打开 + + /* 菜单模板 */ + menuItemTemplate: { type: String, default: "" }, // 可展开菜单内容条模板 + itemTemplate: { type: String, default: "" }, // 可点击菜单内容条模板 + + menuToggle: { + type: Function as unknown as () => (event: MouseEvent) => void, + default: null, + }, // 可展开菜单展开事件 + itemClick: { + type: Function as unknown as () => (event: MouseEvent) => void, + default: null, + }, // 可点击菜单点击事件 + activeItemChange: { + type: Function as unknown as () => (event: MouseEvent) => void, + default: null, + }, + + /** 高级选项和模板 */ + restrictOneOpen: { type: Boolean, default: false }, // 限制一级菜单同时只能打开一个 + autoOpenActiveMenu: { type: Boolean, default: false }, // 自动展开活跃菜单 + showNoContent: { type: Boolean, default: true }, // 没有内容的时候是否显示没有数据 + noContentTemplate: { type: String, default: "" }, // 没有内容的时候使用自定义模板 + loadingTemplate: { type: String, default: "" }, // 加载中使用自定义模板 + innerListTemplate: { type: String, default: "" }, // 可折叠菜单内容完全自定义,用做折叠面板 + + /* 内置路由/链接/动态判断路由或链接类型 */ + linkType: { + type: String as () => + | "routerLink" + | "hrefLink" + | "dependOnLinkTypeKey" + | "" + | string, + default: "", + }, + linkTypeKey: { type: String, default: "linkType" }, // linkType为'dependOnLinkTypeKey'时指定对象linkType定义区 + linkKey: { type: String, default: "link" }, // 链接内容的key + linkTargetKey: { type: String, default: "target" }, // 链接目标窗口的key + linkDefaultTarget: { type: String, default: "_self" }, // 不设置target的时候target默认值 + + accordionType: { + type: String as () => "normal" | "embed", + default: "normal", + }, +} as const; + +export type AccordionProps = ExtractPropTypes; diff --git a/packages/devui-vue/devui/accordion/src/accordion.scss b/packages/devui-vue/devui/accordion/src/accordion.scss index a6f4317d..6aa628b2 100644 --- a/packages/devui-vue/devui/accordion/src/accordion.scss +++ b/packages/devui-vue/devui/accordion/src/accordion.scss @@ -3,6 +3,7 @@ @import '../../style/theme/font'; @import '../../style/theme/shadow'; @import '../../style/theme/corner'; +@import '../../style/core/animation'; :host { display: block; @@ -188,17 +189,40 @@ d-accordion-item-routerlink { } } + .devui-accordion-splitter::before { + content: ''; + display: block; + width: 2px; + height: 18px; + background: $devui-form-control-line-active; + position: absolute; + top: 11px; + left: 0; + opacity: 0; + } + &.devui-router-active, &.active { &:not(.open) .devui-accordion-splitter::before { - content: ''; - display: block; - width: 2px; - height: 18px; - background: $devui-form-control-line-active; - position: absolute; - top: 11px; - left: 0; + opacity: 1; + } + } +} + +.devui-accordion-show-animate .devui-accordion-item-title { + transition: + font-weight $devui-animation-duration-fast $devui-animation-ease-in-out-smooth, + background-color $devui-animation-duration-fast $devui-animation-ease-in-out-smooth; + + .devui-accordion-splitter::before { + transform: scaleY(0); + transition: transform $devui-animation-duration-slow $devui-animation-ease-in-out-smooth; + } + + &.devui-router-active, + &.active { + &:not(.open) .devui-accordion-splitter::before { + transform: scaleY(1); } } } diff --git a/packages/devui-vue/devui/accordion/src/accordion.tsx b/packages/devui-vue/devui/accordion/src/accordion.tsx index 9935f71d..d46165a0 100644 --- a/packages/devui-vue/devui/accordion/src/accordion.tsx +++ b/packages/devui-vue/devui/accordion/src/accordion.tsx @@ -1,65 +1,16 @@ -import { defineComponent, reactive } from 'vue' +import { defineComponent, toRefs } from 'vue' import AccordionList from './accordion-list' -import { AccordionMenuType } from './accordion.type' +import { accordionProps } from './accordion-types' import './accordion.scss' export default defineComponent({ name: 'DAccordion', - props: { - data: { - type: Array as () => Array | AccordionMenuType, - default: null - }, - /* Key值定义, 用于自定义数据结构 */ - titleKey: { type : String, default: 'title' }, // 标题的key,item[titleKey]类型为string,为标题显示内容 - loadingKey: { type : String, default: 'loading' }, // 子菜单动态加载item[loadingKey]类型为boolean - childrenKey: { type : String, default: 'children' }, // 子菜单Key - disabledKey: { type : String, default: 'disabled' }, // 是否禁用Key - activeKey: { type : String, default: 'active' }, // 菜单是否激活/选中 - openKey: { type : String, default: 'open' }, // 菜单是否打开 - - /* 菜单模板 */ - menuItemTemplate: { type: String, default: '' }, // 可展开菜单内容条模板 - itemTemplate: { type: String, default: '' }, // 可点击菜单内容条模板 - - menuToggle: { - type: Function as unknown as () => ((event: MouseEvent) => void), - default: null - }, // 可展开菜单展开事件 - itemClick: { - type: Function as unknown as () => ((event: MouseEvent) => void), - default: null - }, // 可点击菜单点击事件 - activeItemChange: { - type: Function as unknown as () => ((event: MouseEvent) => void), - default: null - }, - - /** 高级选项和模板 */ - restrictOneOpen: { type: Boolean, default: false }, // 限制一级菜单同时只能打开一个 - autoOpenActiveMenu: { type: Boolean, default: false }, // 自动展开活跃菜单 - showNoContent: { type: Boolean, default: true }, // 没有内容的时候是否显示没有数据 - noContentTemplate: { type: String, default: '' }, // 没有内容的时候使用自定义模板 - loadingTemplate: { type: String, default: '' }, // 加载中使用自定义模板 - innerListTemplate: { type: String, default: '' }, // 可折叠菜单内容完全自定义,用做折叠面板 - - /* 内置路由/链接/动态判断路由或链接类型 */ - linkType: { - type: String as () => 'routerLink' | 'hrefLink' | 'dependOnLinkTypeKey' | '' | string, - default: '' - }, - linkTypeKey: { type: String, default: 'linkType' }, // linkType为'dependOnLinkTypeKey'时指定对象linkType定义区 - linkKey: { type: String, default: 'link' }, // 链接内容的key - linkTargetKey: { type: String, default: 'target' }, // 链接目标窗口的key - linkDefaultTarget: { type: String, default: '_self' }, // 不设置target的时候target默认值 - - accordionType: { type: String as () => 'normal' | 'embed', default: 'normal' }, - }, + props: accordionProps, setup(props) { - const { data, accordionType } = reactive(props) - + const { data, accordionType } = toRefs(props) + console.log(111, toRefs(props)) return () => { - return
    + return
    + + +
    + Only one level-1 menu can be expanded. +
    +
    Embedded menu (no shadow)
    + + + +``` \ No newline at end of file -- Gitee From 418e9e73121aaabe1001cbffd623445533a8c429 Mon Sep 17 00:00:00 2001 From: xiaojiujiu <3507440900@qq.com> Date: Mon, 8 Nov 2021 23:59:50 +0800 Subject: [PATCH 17/59] fixed #I4H6K3 --- .../docs/.vitepress/config/enSidebar.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/devui-vue/docs/.vitepress/config/enSidebar.ts b/packages/devui-vue/docs/.vitepress/config/enSidebar.ts index 00c33617..4f814fef 100644 --- a/packages/devui-vue/docs/.vitepress/config/enSidebar.ts +++ b/packages/devui-vue/docs/.vitepress/config/enSidebar.ts @@ -33,15 +33,15 @@ const enSidebar = { { text: 'Feedback', children: [ - { text: 'Alert', link: '/components/alert/', status: 'completed' }, - { text: 'Drawer', link: '/components/drawer/' }, - { text: 'Loading', link: '/components/loading/', status: 'completed' }, - { text: 'Mention', link: '/components/mention/' }, - { text: 'Modal', link: '/components/modal/' }, - { text: 'Popover', link: '/components/popover/', status: "progress" }, - { text: 'ReadTip', link: '/components/read-tip/' }, - { text: 'Toast', link: '/components/toast/', status: 'completed' }, - { text: 'Tooltip', link: '/components/tooltip/', status: 'completed' }, + { text: 'Alert', link: '/en-US/components/alert/', status: 'completed' }, + { text: 'Drawer', link: '/en-US/components/drawer/' }, + { text: 'Loading', link: '/en-US/components/loading/', status: 'completed' }, + { text: 'Mention', link: '/en-US/components/mention/' }, + { text: 'Modal', link: '/en-US/components/modal/' }, + { text: 'Popover', link: '/en-US/components/popover/', status: "progress" }, + { text: 'ReadTip', link: '/en-US/components/read-tip/' }, + { text: 'Toast', link: '/en-US/components/toast/', status: 'completed' }, + { text: 'Tooltip', link: '/en-US/components/tooltip/', status: 'completed' }, ] }, { -- Gitee From 66eaa765aea73d30caa96cc175cbe8844c6238cb Mon Sep 17 00:00:00 2001 From: xiaojiujiu <3507440900@qq.com> Date: Tue, 9 Nov 2021 21:40:42 +0800 Subject: [PATCH 18/59] =?UTF-8?q?docs:=20=E5=88=A0=E9=99=A4=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E5=9B=BD=E9=99=85=E5=8C=96=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../en-US/components/accordion/accordion.md | 189 --- .../docs/en-US/components/accordion/index.md | 4 - .../docs/en-US/components/alert/alert.md | 38 - .../docs/en-US/components/alert/index.md | 23 - .../docs/en-US/components/anchor/anchor.md | 126 -- .../docs/en-US/components/anchor/demo.tsx | 35 - .../docs/en-US/components/anchor/index.md | 80 - .../docs/en-US/components/avatar/avatar.md | 42 - .../docs/en-US/components/avatar/index.md | 23 - .../docs/en-US/components/badge/index.md | 178 --- .../docs/en-US/components/button/button.md | 82 -- .../docs/en-US/components/button/index.md | 27 - .../docs/en-US/components/card/index.md | 220 --- .../docs/en-US/components/carousel/index.md | 162 -- .../docs/en-US/components/checkbox/index.md | 42 - .../en-US/components/date-picker/index.md | 121 -- .../docs/en-US/components/icon/index.md | 71 - .../en-US/components/image-preview/index.md | 137 -- .../docs/en-US/components/input/index.md | 96 -- .../docs/en-US/components/loading/index.md | 298 ---- .../docs/en-US/components/overlay/index.md | 198 --- .../docs/en-US/components/pagination/index.md | 473 ------ .../docs/en-US/components/panel/index.md | 74 - .../docs/en-US/components/popover/index.md | 386 ----- .../docs/en-US/components/progress/index.md | 142 -- .../components/quadrant-diagram/index.md | 44 - .../docs/en-US/components/radio/index.md | 307 ---- .../docs/en-US/components/rate/index.md | 138 -- .../docs/en-US/components/search/index.md | 95 -- .../docs/en-US/components/select/index.md | 175 --- .../docs/en-US/components/slider/index.md | 128 -- .../docs/en-US/components/status/index.md | 26 - .../docs/en-US/components/sticky/index.md | 139 -- .../docs/en-US/components/switch/index.md | 66 - .../docs/en-US/components/tabs/index.md | 7 - .../docs/en-US/components/tag-input/index.md | 44 - .../docs/en-US/components/toast/index.md | 611 -------- .../docs/en-US/components/transfer/index.md | 224 --- .../docs/en-US/components/upload/index.md | 1297 ----------------- packages/devui-vue/docs/en-US/design.md | 1 - packages/devui-vue/docs/en-US/theme.md | 1 - packages/devui-vue/docs/en-US/version.md | 1 - 42 files changed, 6571 deletions(-) delete mode 100644 packages/devui-vue/docs/en-US/components/accordion/accordion.md delete mode 100644 packages/devui-vue/docs/en-US/components/accordion/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/alert/alert.md delete mode 100644 packages/devui-vue/docs/en-US/components/alert/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/anchor/anchor.md delete mode 100644 packages/devui-vue/docs/en-US/components/anchor/demo.tsx delete mode 100644 packages/devui-vue/docs/en-US/components/anchor/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/avatar/avatar.md delete mode 100644 packages/devui-vue/docs/en-US/components/avatar/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/badge/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/button/button.md delete mode 100644 packages/devui-vue/docs/en-US/components/button/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/card/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/carousel/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/checkbox/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/date-picker/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/icon/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/image-preview/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/input/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/loading/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/overlay/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/pagination/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/panel/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/popover/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/progress/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/quadrant-diagram/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/radio/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/rate/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/search/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/select/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/slider/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/status/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/sticky/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/switch/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/tabs/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/tag-input/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/toast/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/transfer/index.md delete mode 100644 packages/devui-vue/docs/en-US/components/upload/index.md delete mode 100644 packages/devui-vue/docs/en-US/design.md delete mode 100644 packages/devui-vue/docs/en-US/theme.md delete mode 100644 packages/devui-vue/docs/en-US/version.md diff --git a/packages/devui-vue/docs/en-US/components/accordion/accordion.md b/packages/devui-vue/docs/en-US/components/accordion/accordion.md deleted file mode 100644 index dba8ce67..00000000 --- a/packages/devui-vue/docs/en-US/components/accordion/accordion.md +++ /dev/null @@ -1,189 +0,0 @@ -# How to use - -Import into module: - -```typescript -import { AccordionModule } from ' ng-devui/accordion'; -``` - -On the page: - -```html - -``` - -## Accordion - -### d-accordion parameter - -| Parameter | Type | Default | Description | Jump to Demo |Global Config| -| :----------------: | :----------------: | :----------------------------------------------------: | :--------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | -------------------------------------------------------------------------- | -| data | `Array \| AccordionMenuType` | -- | Required. Data source. You can customize an array or use the preset `AccordionMenuType` | [Basic usage](demo#basic-usage) | -| titleKey | `string` | 'title' | Optional. Title attribute name. The type of item[titleKey] is `string`, indicating the title content. | [Change key value](demo#change-values) | -| loadingKey | `string` | 'loading' | Optional. attribute name for determining whether a submenu is loaded. The type of item[loadingKey] is `boolean` | [Change key value](demo#change-values) | -| childrenKey | `string` | 'children' | Optional. Submenu attribute name. The type of item[childrenKey] is `Array` | [Change key value](demo#change-values) | -| disabledKey | `string` | 'disabled' | Optional. indicating whether to disable the attribute. The type of item[disabledKey] is `boolean` | [Change key value](demo#change-values) | -| activeKey | `string` | 'active' | Optional. indicating whether a submenu is activated. The type of item[activeKey] is `boolean` | [Change key value](demo#change-values) | -| openKey | `string` | 'open' | Optional. indicating whether a menu is expanded. The type of item[openKey] is `boolean` | [Change key value](demo#change-values) | -| restrictOneOpen | `boolean` | false | Optional. Only one level-1 menu can be opened at a time. By default, there is no restriction. | [Basic usage](demo#basic-usage) | -| menuItemTemplate | `TemplateRef` | Built-in | Optional. It can expand the menu content bar template. The available variable values are as follows. | [Using a Template](demo#using-templates) | -| itemTemplate | `TemplateRef` | Built-in | Optional. The menu content bar template can be clicked. The available variable values are as follows: | [Using a Template](demo#using-templates) | -| noContentTemplate | `TemplateRef` | Built-in | Optional. If there is no content, use a customized template. The available variable values are as follows: | [Using a Template](demo#using-templates) | -| loadingTemplate | `TemplateRef` | Built-in | Optional. A customized template is used for loading. The available variable values are as follows | [Using a Template](demo#using-templates) | -| innerListTemplate | `TemplateRef` | Built-in | Optional. The sublist content is customized and used as a folding panel. The available variable values are as follows. | [Using a Template](demo#using-templates) | -| linkType | `'routerLink'\|'hrefLink'\|'dependOnLinkTypeKey'\|'''` | '' | Optional. `routerLink'` indicates the routing scenario. `hrefLink'` indicates the external link scenario. `dependOnLinkTypeKey'` indicates the dynamic routing or external link scenario. `''` is the default non-link type (you cannot right-click to open a new tab page) | [Built-in route and link type](demo#use-built-in-routing-and-link-types) | -| linkTypeKey | `string` | 'linkType' | Optional. Key value of the link type, which is used to specify the object link type attribute name when linkType is set to `'dependOnLinkTypeKey'`. The value of item[linkTypeKey] is `'routerLink'\|'hrefLink'\| string`, in the preceding information, `routerLink'` indicates a route link, `hrefLink'` indicates an external link, and other values are default non-link types. | -| linkKey | `string` | 'link' | Optional. Key of the link content, which is used to set the value of the link value when linkType is not set to ````. item[linkKey] indicates the route address or hyperlink address. | -| linkTargetKey | `string` | 'target' | Optional. Key of the target window to be linked, which is used for the link type. item[linkTargetKey] indicates the target window of a single link. | -| linkDefaultTarget | `string` | '\_self' | Optional. If target is not set, the default value of target is `'\_self'`, which is used for the link type and its value is the same as that of target attribute of link a. | [Built-in route and link type](demo#use-built-in-routing-and-link-types) | -| autoOpenActiveMenu | `boolean` | false | Optional. Whether to automatically expand menus with active subitems | [Composite Hierarchy and Auto Expand](demo#compound-level-and-auto-expand) | -| accordionType | `normal ' \| 'embed'` | 'normal' | Optional. The menu format is common (with shadow) or embedded (without shadow). | [Basic usage](demo#basic-usage) | -| showAnimation | `boolean` | true | Optional. Indicating whether to display animations. | [Built-in route and link type](demo#use-built-in-routing-and-link-types) | ✔ | - -### d-accordion event - -| Event | Type | Description | Jump to Demo | -| :--------------: | :-----------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | ------------------------------- | -| menuToggle | `EventEmitter<`[`AccordionMenuToggleEvent`](#accordionmenutoggleevent)`>` | Optional. The menu can be expanded. In the returned object, the attribute item is the object data clicked. If open is true, the object will be expanded. If open is false, the object will be closed. If parent is the parent object data. Event is the native event of the click event. | [Basic usage](demo#basic-usage) | -| itemClick | `EventEmitter<`[`AccordionItemClickEvent`](#accordionitemclickevent)`>` | Optional. It can click a menu event. In the returned object, the attribute item is the object data of the clicked object, the preActive object is the object expanded last time, the parent object is the data of the parent object, and the event is the native event of the click event. | [Basic usage](demo#basic-usage) | -| activeItemChange | `EventEmitter` | Optional. Data of the newly activated sub-item is sent when the sub-item is switched. | [Basic usage](demo#basic-usage) | - -### AccordionMenuType Definition - -```typescript -/* Basic data type */ -type AccordionMenuItemLinkType = 'routerLink' | 'hrefLink' | string; -export interface AccordionBase { - title: string; - disabled?: boolean; - [prop: string]: any; -} -interface IAccordionActiveable { - active?: boolean; -} -interface IAccordionFoldable { - open?: boolean; - loading?: boolean; - children?: Array; -} -interface IAccordionLinkable { - link?: string; - target?: boolean; - linkType?: AccordionMenuItemLinkType; -} -export interface AccordionBaseItem extends AccordionBase, IAccordionActiveable {} -export interface AccordionBaseMenu extends AccordionBase, IAccordionFoldable {} -export interface AccordionLinkableItem extends AccordionBase, IAccordionActiveable, IAccordionLinkable {} -export interface AccordionMenuItem extends AccordionBase, IAccordionActiveable, IAccordionFoldable, IAccordionLinkable {} -export type AccordionMenuType = Array; - -/* Common configuration data type */ -interface AccordionMenuKeyGroup { - titleKey?: string; - activeKey?: string; - disabledKey?: string; - openKey?: string; - loadingKey?: string; - childrenKey?: string; - linkKey?: string; - linkTargetKey?: string; - linkTypeKey?: string; -} -type AccordionTemplateRefArray = 'itemTemplate' | 'menuItemTemplate' | 'noContentTemplate' | 'loadingTemplate' | 'innerListTemplate'; -type AccordionTemplateRefGroup = { - [p in AccordionTemplateRefArray]: TemplateRef; -}; -interface AccordionConfigOptions { - restrictOneOpen?: boolean; - autoOpenActiveMenu?: boolean; - showNoContent?: boolean; - linkDefaultTarget?: string; - i18nText: any; - linkType: 'routerLink' | 'hrefLink' | 'dependOnLinkTypeKey' | ''; -} -export interface AccordionOptions extends AccordionConfigOptions, AccordionMenuKeyGroup, AccordionTemplateRefGroup {} -``` - -## AccordionMenuToggleEvent - -```typescript -export type AccordionMenuToggleEvent = { - item: any; - open: boolean; - parent: any; - event: MouseEvent; -}; -``` - -## AccordionItemClickEvent - -```typescript -export type AccordionItemClickEvent = { - item: any; - prevActiveItem?: any; - parent: any; - event: MouseEvent; -}; -``` - -### Templates can use variable values. - -#### Variable Usage - -```html -{{myitem}} -``` - -#### menuItemTemplate Available variable values - -| Variable | Type | Variable Description | -| :----------------: | :--------: | :------------------------------------------------------------------------------------------: | -| item | `any` | Expandable menu data | -| deepth | `number` | Indicates the nested structure level. | -| parent | `any` | Parent menu data | -| ~~~titleKey~~~ | `string` | Deprecated.~~~ The titleKey value of the component. ~~~ | -| ~~~disabledKey~~~ | `string` | Deprecated. ~~~ The value of the disabledKey of the component. ~~~ | -| ~~~openKey~~~ | `string` | Deprecated. ~~~ The openKey value of the component. ~~~ | -| ~~~menuToggleFn~~~ | `Function` | Deprecated.~~~ The parameter should be item, indicating that the level-1 menu is clicked.~~~ | - -#### itemTemplate Available variable values - -| Variable | Type | Variable Description | -| :---------------: | :--------: | :------------------------------------------------------------------------------------------: | -| item | `any` | Clickable menu data | -| deepth | `number` | The value indicates the nested structure level. | -| parent | `any` | Parent menu data | -| ~~~titleKey~~~ | `string` | Deprecated.~~~ The titleKey value of the component ~~~ | -| ~~~disabledKey~~~ | `string` | Deprecated.~~~ The value of the disabledKey of the component ~~~ | -| ~~~activeKey~~~ | `string` | Deprecated.~~~ The activeKey value of the component ~~~ | -| ~~~itemClickFn~~~ | `Function` | Deprecated. ~~~The parameter should be item, indicating that the level-2 menu is clicked.~~~ | - -#### noContentTemplate Available variable value - -| Variable | Type | Variable Description | -| :------: | :------: | :---------------------------------------------: | -| item | `any` | Parent menu single data | -| deepth | `number` | The value indicates the nested structure level. | - -#### loadingTemplate Available variable values - -| Variable | Type | Variable Description | -| :---------------------: | :--------------: | :---------------------------------------------: | -| item | `any` | Parent menu single data | -| deepth | `number` | The value indicates the nested structure level. | -| LoadingKey value of the | ~~~loadingKey~~~ | `string` | ~~~ component ~~~ | - -#### InnerListTemplate Available Variable Values - -| Variable | Type | Variable Description | -| :---------------: | :--------: | :------------------------------------------------------------------------------------------------------------------------------------------------------: | -| item | `any` | Parent menu single data | -| deepth | `number` | The value indicates the nested structure level. | -| ~~~titleKey~~~ | `string` | Deprecated.~~~The titleKey value of the component ~~~ | -| ~~~loadingKey~~~ | `string` | Deprecated.~~~ The loading key value of the component ~~~ | -| ~~~childrenKey~~~ | `string` | Deprecated.~~~ The value of childrenKey of the component ~~~ | -| ~~~disabledKey~~~ | `string` | Deprecated.~~~ The value of the disabledKey of the component ~~~ | -| ~~~openKey~~~ | `string` | Deprecated.~~~ The openKey value of the component ~~~ | -| ~~~activeKey~~~ | `string` | Deprecated. ~~~ The activeKey value of the component Use the level-2 menu ~~~ | -| menuToggleFn | `Function` | The parameter should be item, indicating that the menu is expanded. The optional parameter event, original event, is used. | -| itemClickFn | `Function` | The parameter must be an item of a menu that can be clicked, indicating that the menu is clicked. The optional parameter event, original event, is used. | diff --git a/packages/devui-vue/docs/en-US/components/accordion/index.md b/packages/devui-vue/docs/en-US/components/accordion/index.md deleted file mode 100644 index 5b42b165..00000000 --- a/packages/devui-vue/docs/en-US/components/accordion/index.md +++ /dev/null @@ -1,4 +0,0 @@ -# Accordion -A component that provides navigation for a page. -### When to use -Use when you need to organize the menu in groups. \ No newline at end of file diff --git a/packages/devui-vue/docs/en-US/components/alert/alert.md b/packages/devui-vue/docs/en-US/components/alert/alert.md deleted file mode 100644 index a3af2132..00000000 --- a/packages/devui-vue/docs/en-US/components/alert/alert.md +++ /dev/null @@ -1,38 +0,0 @@ -# How to use - -Import into module: - -```ts -import { AlertModule } from 'ng-devui/alert'; -``` - -In the page: - -```xml - -``` -# d-alert -## d-alert Parameter - -| Attributes | Type | Default | Description | Jump to Demo |Global Config| -| :----------------: | :---------: | :--------------------------------------: | :----: | :---------------------------------------- | ------------------------------------------ | -| type | [`AlertType`](#alerttype) | 'info' | Required. Specify the style of the warning prompt | [Basic Usage](demo#basic-usage) | -| cssClass | `string` | -- | Optional. Customize className | -| closeable | `boolean` | true | Optional. The close button is displayed by default | [Basic Usage](demo#tips-to-close) | -| dismissTime | `number` | -- | Optional. Toggle off the delay time of Alert(`ms`) | -| showIcon | `boolean` | true | Optional. Whether to use the default type icon | [Without Icon](demo#without-icon) | - -## d-alert Event - -| Attributes | Type | Description | Jump to Demo | -| :--------: | :-----------------: | :------------------------- | -------------------------------------------- | -| closeEvent | `EventEmitter` | Optional. Callback when alert is closed | [Closable Prompt](demo#tips-to-close) | - -# Interface & Type Definition -### AlertType - -The default value is 'info', which specifies the type of alert warning. - -```ts -export type AlertType = 'success' | 'danger' | 'warning' | 'info' | 'simple'; -``` diff --git a/packages/devui-vue/docs/en-US/components/alert/index.md b/packages/devui-vue/docs/en-US/components/alert/index.md deleted file mode 100644 index 089868ec..00000000 --- a/packages/devui-vue/docs/en-US/components/alert/index.md +++ /dev/null @@ -1,23 +0,0 @@ -# Alert - -A component that displays warning information, information that needs the user's attention。 - -### When to use - -When the page needs to send a warning message to the user。 - -### 基本用法 - - success - danger - warning - info - simple - -```html - success - danger - warning - info - simple -``` \ No newline at end of file diff --git a/packages/devui-vue/docs/en-US/components/anchor/anchor.md b/packages/devui-vue/docs/en-US/components/anchor/anchor.md deleted file mode 100644 index fd1bd914..00000000 --- a/packages/devui-vue/docs/en-US/components/anchor/anchor.md +++ /dev/null @@ -1,126 +0,0 @@ -# How to use - -Import into module: - -```ts -import { AnchorModule } from 'ng-devui'; -``` - -In the page: - -```html -
    -
      -
    • anchorlink-one
    • -
    • anchorlink-two
    • -
    • anchorlink-three
    • -
    • anchorlink-four
    • -
    -
    -
    - anchorlink-one -
    -
    - anchorlink-two -
    -
    - anchorlink-three -
    -
    - anchorlink-four -
    -
    -
    -``` - -```ts -// using router (cross-route), anchorName means your own anchor -this.router.navigateByUrl('../xx/xxx#anchorName'); -this.router.navigate(['/xxx'], { fragment: 'anchorName' }); - -// using router (at the same level), anchorName means your own anchor -this.router.navigateByUrl('#anchorName'); -this.router.navigate([], { fragment: 'anchorName' }); -``` - -# dAnchor - -Define an anchor point - -## dAnchor Parameters - -| Parameter | Type | Default | Description | Jump to Demo |Global Config| -| :----------------: | :----------: | :------: | :-----: | :---------------------------------------------------------------------------------------------------: | -------------------------------------------------- | -| dAnchor | `string` | -- | Required. Sets an anchor name. | [Basic Usage](demo#basic-usage) | -| anchorActive | `string` | -- | Optional. When the anchor is activated, the corresponding CSS class name takes effect for the module. | [Basic Usage](demo#basic-usage) | - -## dAnchor Anchor Activation Event - -The following classes are automatically added to the anchor to correspond to different activated objects: - -| css class name | Meaning | -| :---------------------------: | :-------------------------------------------------------: | -| anchor-active-by-anchor-link | Click the anchor link to activate it. | -| anchor-active-by-scroll | The container scrolls to the anchor point for activation. | -| anchor-active-by-click-inside | Click the anchor content to activate it. | -| anchor-active-by-initial | Initialize the scroll bar position. | - -# dAnchorLink - -Define a link of an anchor point. Click the link to slide to the anchor point. When the anchor point is at the top of the page, the link class is activated. - -## dAnchorLink Parameters - -| Parameter | Type | Default | Description | Jump to Demo | -| :----------: | :------: | :-----: | :------------------------------------------------------------------------------------------------: | -------------------------------------------------- | -| dAnchorLink | `string` | -- | Required. Name of the target anchor point for sliding. | [Basic Usage](demo#basic-usage) | -| anchorActive | `string` | -- | Optional. CSS class name corresponding to the link that takes effect when the anchor is activated. | [Basic Usage](demo#basic-usage) | - -# dAnchorBox - -There must be one container. Otherwise, the function cannot be used. - -Defines a container for scanning anchor points, placed on the common parent node of dAnchor and dAnchorLink, for communication between anchor points and links. - -## dAnchorBox Parameters - -| Parameter | Type | Default | Description | Jump to Demo | -| :-----------: | :----------------------------: | :-------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | --------------------------------------------------------------------- | -| view | `{top?:number,bottom?:number}` | {top:0,bottom:0} | Optional. It is used to adjust the visible region, for example, the head with a fixed position on the top. The value corresponds to the height of the blocked top or bottom. | [Basic Usage](demo#basic-usage) | -| defaultAnchor | `string` | -- | Optional. An anchor link that is activated by default after a page is displayed. Generally, the first anchor link is set to the first anchor link. If this parameter is not set, the first anchor link can be activated only when the first anchor is moved to the top position. | [Basic Usage](demo#basic-usage) | -| scrollTarget | `HTMLElement` | document.documentElement(document.body) | Optional. Sets the container where the scroll bar is located. This parameter is optional when the scroll bar is on the home page. | [Replace Rolling Container](demo#scroll-target) | - -# dAnchorHashSupport - -dAnchorBox support instruction - -## dAnchorHashSupport Parameters - -The following parameters are advanced configuration parameters and are not required. You only need to use dAnchorHashSupport. - -| Parameter | Type | Default | Description | Jump to Demo | -| :--------------------------: | :-------: | :-----: | :-----------------------------------------------------------------------------------------------------------------------------------------------------: | ------------------------------------------------------------------ | -| updateUrlWhenAnchorActive | `boolean` | true | Optional. The URL is updated when the anchor is activated. The default value is true. | [URL Hash Anchor](demo#support-hash) | -| scrollToAnchorByHashOnlyInit | `boolean` | false | Optional. True indicates that the fragment field changes from routes are received only during initialization. This field is used for complex scenarios. | [URL Hash Anchor](demo#support-hash) | - -The dAnchorHashSupport command is used together with the dAnchorBox command to bind the hash fragment of a route. For example, xxx.xxx/xxx#foo, where the foo field is a hash field. -The hop hash field can be the anchor component, route navigate, and routerLink fragment field. - -# Note - -Note that this parameter cannot be used together with the RouterScoller of the routing module of ng6.1 or later. The routerlScroller will scroll to the traditional ID anchor point. -Using RouterScroller alone, you can configure the routing module. - -```ts -@NgModule({ - //...... - imports: [ - //...... - RouterModule.forRoot(routes, { - anchorScrolling: 'enabled', // This policy conflicts with the dAnchorHashSupport instruction of the anchor component. - }), - ], - //...... -}) -export class DemoModule {} -``` diff --git a/packages/devui-vue/docs/en-US/components/anchor/demo.tsx b/packages/devui-vue/docs/en-US/components/anchor/demo.tsx deleted file mode 100644 index d87cc00c..00000000 --- a/packages/devui-vue/docs/en-US/components/anchor/demo.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { defineComponent } from 'vue' - -export default defineComponent({ - name: 'DAnchor', - props: { - }, - setup() { - return () => { - return ( -
    -
      -
    • anchorlink-one
    • -
    • anchorlink-two
    • -
    • anchorlink-three
    • -
    • anchorlink-four
    • -
    -
    -
    - anchorlink-one -
    -
    - anchorlink-two -
    -
    - anchorlink-three -
    -
    - anchorlink-four -
    -
    -
    - ) - } - } -}) \ No newline at end of file diff --git a/packages/devui-vue/docs/en-US/components/anchor/index.md b/packages/devui-vue/docs/en-US/components/anchor/index.md deleted file mode 100644 index 08f7664b..00000000 --- a/packages/devui-vue/docs/en-US/components/anchor/index.md +++ /dev/null @@ -1,80 +0,0 @@ -# anchor - - - -# When to use - - -Use in the page: - -```html - -
    -
      -
    • anchorlink-one
    • -
    • anchorlink-two
    • -
    • anchorlink-three
    • -
    • anchorlink-four
    • -
    -
    -
    - anchorlink-one1 -
    -
    - anchorlink-two -
    -
    - anchorlink-three -
    -
    - anchorlink-four -
    -
    -
    -``` - -# dAnchor - -Define an anchor point。 -### dAnchor parameter - -| parameter | type | default | illustrate | jump Demo |config| -| :----------------: | :----------: | :------: | :--: | :---------------------------------------------------: | ---------------------------- | -| dAnchor | `string` | -- | required, set an anchor name | [basic usage](demo#basic-usage) | -| anchorActive | `string` | -- | Optional, when the anchor point is activated, the corresponding css class name for the module to take effect | [basic usage](demo#basic-usage) | - -### dAnchor activation event - -The following classes are automatically added to the anchor points to correspond to different activated objects。 - -| css classname | Representative meaning | -| :---------------------------: | :--------------------: | -| anchor-active-by-anchor-link | Click on the anchor link to activate | -| anchor-active-by-scroll | The container is scrolled to the anchor point to activate | -| anchor-active-by-click-inside | Click on the content inside the anchor to activate | -| anchor-active-by-initial | Initialize scroll bar position activation | - -# dAnchorLink - -Define a link with an anchor point. Clicking on the link will slide to the anchor point. When the anchor point is at the top of the page, the link class will be activated。 - -### dAnchorLink parameter - -| parameter | type | default | illustrate | jump Demo |config| -| :----------------: | :----------: | :------: | :--: | :---------------------------------------------------: | ---------------------------- | -| dAnchorLink | `string` | -- | required, click the name of the target anchor point to slide | [basic usage](demo#basic-usage) | -| anchorActive | `string` | -- | optional, when the anchor point is active, the css class name corresponding to the effective link | [basic usage](demo#basic-usage) | - -# dAnchorBox - -There must be a container, otherwise the function cannot be used。 - -Define a container for scanning anchor points and place it on the common parent node of dAnchor and dAnchorLink for communication between anchor points and links。 diff --git a/packages/devui-vue/docs/en-US/components/avatar/avatar.md b/packages/devui-vue/docs/en-US/components/avatar/avatar.md deleted file mode 100644 index f057f819..00000000 --- a/packages/devui-vue/docs/en-US/components/avatar/avatar.md +++ /dev/null @@ -1,42 +0,0 @@ -# How to use - -Import into module: - -```ts -import { AvatarModule } from 'ng-devui/avatar'; -``` - -In the page: - -```xml - -``` -# d-avatar -## d-avatar Parameter - -| Parameter | Type | Default | Description | Jump to Demo |Global Config| -| :----------------: | :--------: | :--------------------: | :--: | :-------------------------------------------------------------------------- | ------------------------------------------------------------- | -| name | `string` | -- | Required. The input character string is used to create a profile picture. | [Basic Rules](demo#basic-rules) | -| gender | `string \| male \| female` | -- | Optional. The profile picture color is differentiated by gender. The input string can be in the format of `female \| male`. | [Basic Rules](demo#basic-rules) | -| width | `number` | 40 | Optional. Width of the avatar(`px`) | [Basic Configuration](demo#basic-configuration) | -| height | `number` | 40 | Optional. Set the height of the avatar(`px`) | [Basic Configuration](demo#basic-configuration) | -| isRound | `boolean` | true | Optional. Indicating whether to display a circular avatar | [Basic Configuration](demo#basic-configuration) | -| imgSrc | `string` | -- | Optional. Import a customized image as the avatar | [Basic Configuration](demo#basic-configuration) | -| customText | `string` | -- | Optional. Input the customized display text | [Basic Configuration](demo#basic-configuration) | - - -### Basic Profile Picture Display Rules - -- `Begin with Chinese `: Use the last two characters. -- `Begin with English `: Use the first two characters. -- `Use multiple English names together`: Use the first two letters of the first English name. -- `Not starting with Chinese or English `: Use the first two characters. - -### Special avatar display rules - -- If `name`, `customText`, and `imgSrc` are not transferred, the user who uses the avatar does not exist. -- If the values of `name`, `customText`, and `imgSrc` are empty, the user who uses the avatar does not have a nickname and the default avatar is used. - -### Display Priority - -imgSrc > customText > name diff --git a/packages/devui-vue/docs/en-US/components/avatar/index.md b/packages/devui-vue/docs/en-US/components/avatar/index.md deleted file mode 100644 index 3ca64429..00000000 --- a/packages/devui-vue/docs/en-US/components/avatar/index.md +++ /dev/null @@ -1,23 +0,0 @@ -# Avatar - -The component that displays the user's avatar。 - -### When to use - -当需要显示用户头像时。 - -### Basic rules of avatar display - -When the 'name' attribute is passed to the avatar component, the avatar field will be displayed according to certain rules. Please refer to the API for specific rules。 - - - - - - -```html - - - - -``` \ No newline at end of file diff --git a/packages/devui-vue/docs/en-US/components/badge/index.md b/packages/devui-vue/docs/en-US/components/badge/index.md deleted file mode 100644 index 2eb62674..00000000 --- a/packages/devui-vue/docs/en-US/components/badge/index.md +++ /dev/null @@ -1,178 +0,0 @@ -# Badge - -The round logo number in the upper right corner of the icon。 - -### When to use - -Appears in the upper right corner of the icon or to the right of the list item, and prompts the user when there is a message to be processed through different status colors and numbers。 - -### Basic Badge - -The basic badge type. When there is a package element, the badge and number will be displayed in the upper right corner。 - -Unread message -Unread message -Unread message -Unread message - -```html -Unread message -Unread message -Unread message -Unread message -``` - -### Dot Badge - -Dot badge type. When there is a package element and the showDot parameter is true, it is a dot badge. By default, small dots are displayed in the upper right corner and the number is not displayed。 - -Unread message -Unread message - - - - - - - -```html -Unread message -Unread message - - - - - - -``` - -### Count Badge - -When the badge is used independently and does not wrap any elements, only the badge status color and number are displayed。 - -
      -
    • - Unread message - -
    • -
    • - Personal message - -
    • -
    - -```html -
      -
    • - System message - -
    • -
    • - Personal message - -
    • -
    -``` - -### Status Badge - -When the badge is used independently, does not wrap any elements, and the showDot parameter is true, it is a state badge, and different states show different color points。 - -  danger
    -  warning
    -  waiting
    -  info
    -  success
    - -```html -  danger
    -  warning
    -  waiting
    -  info
    -  success
    -``` - -### Badge Position - -Set the badge position through the badgePos parameter。 - -Unread message -Unread message - - - - - - -```html -Unread message -Unread message - - - - - - -``` - -### Define - -The badge display status color is set through the bgColor parameter (the badge status color set by the status parameter is invalid at this time), and the badge offset relative to the badgePos can be set through the offsetXY parameter. Customize text and background color through textColor and bgColor。 - - - - - - - -Unread message -Unread message - - -```html - - - - - - -Unread message -Unread message - -``` - -### API - -| parameter | type | default | illustrate | -| :-------: | :-----------------: | :---------: | :--------------------------------------------------------------------------------------------------------------------------- | -| count | `Number` | -- | Optionally, set the number displayed in the basic badge and count badge | -| maxCount | `Number` | 99 | Optional, set the maximum number of basic badges and count badges that can be displayed, and display maxCount+ when count> maxCount | -| showDot | `Boolean` | false | Optional, when true, it is a dot badge (with package) or status badge (without package); when it is false, it is a basic badge (with package) or counting badge (without package) | -| status | `BadgeStatusType` | -- | Optional, status color danger\| warning \| waiting \| success \| info | -| badgePos | `BadgePositionType` | 'top-right' | Optional, logo position top-left\| top-right \| bottom-left \| bottom-right | -| bgColor | `String` | -- | Optional, customize the logo color, at this time the badge status color set by the status parameter is invalid | -| textColor | `String` | -- | Optional, logo text color can be customized | -| offsetXY | `[number, number] ` | -- | Optional, optional, the logo position offset when there is a package, the format is [x,y], and the unit is px. x is the offset relative to right or left, and y is the offset relative to top or bottom | - - diff --git a/packages/devui-vue/docs/en-US/components/button/button.md b/packages/devui-vue/docs/en-US/components/button/button.md deleted file mode 100644 index b626daa9..00000000 --- a/packages/devui-vue/docs/en-US/components/button/button.md +++ /dev/null @@ -1,82 +0,0 @@ -# How to use - -Import into module: - -```ts -import { ButtonModule } from 'ng-devui/button'; -``` - -In the page: - -```xml - -``` -# d-button -## d-button Parameter - -| Parameter | Type | Default | Description | Jump to Demo |Global Config| -| :----------------: | :---------: | :------------: | :-----: | :--------------------------------------------------------------------------- | | -| id | `string` | -- | Optional. ID of the button. | [Primary Buttons](demo#button-primary)| -| type | [`IButtonType`](#ibuttontype) | 'button' | Optional. The type is `'button' \| 'submit' \| 'reset'` |[Danger Buttons](demo#button-danger) | -| bsStyle | [`IButtonStyle`](#ibuttonstyle) | 'primary' | Optional. The style is `'primary' \| 'common' \| 'text' \| 'text-dark' \| 'danger'` | [Common Buttons](demo#button-common) | -| bsSize | [`IButtonSize`](#ibuttonsize) | 'md' | Optional. The size is `'lg' \| 'md' \| 'sm' \| 'xs'` | [Button Size](demo#button-size) | -| bsPosition |[`IButtonPosition`](#ibuttonposition) |'default'| Optional. The button position is `'default' \| 'left' \| 'right'` | [Left & Right Buttons](demo#button-left-right) | -| bordered | `boolean` | false | Optional. Indicating whether a border exists | [Auto-focus Buttons](demo#button-auto-focus)| -| icon | `string` | -- | Optional. Customized button icon | [Icon Buttons](demo#button-icon) | -| showLoading | `boolean` | false | Optional. Indicating whether to display the loading prompt | [Loading Buttons](demo#button-loading) | -| width | `string` | -- | Optional. Button width |[Combinations of Primary & Common Buttons](demo#button-primary-and-common) | -| disabled | `boolean` | false | Optional. Indicating whether to disable the button | [Primary Buttons](demo#button-primary) | -| autofocus | `boolean` | false | Optional. Indicating whether to automatically obtain the focus during button loading | [Auto-focus Buttons](demo#button-auto-focus) | - -## d-button Event - -| Parameter | Type | Description | Jump to Demo | -| :------: | :-----------------: | :-------------------------------------------------------------------------------------- | ---------------------------------------------- | -| btnClick | `EventEmitter` | Optional. Solve the click event is triggered when button is disabled. After the mouse is clicked, the mouse event object is returned | [Loading Buttons](demo#button-loading)| - -# d-button-group - -## d-button-group parameter - -| Parameter | Type | Default | Description | Jump to Demo |Global Config| -| :----------------: | :---------: | :------------: | :-----: | :--------------------------------------------------------------------------- | | -| size | [`IButtonGroupSize`](#ibuttongroupsize) | 'md' | Optional. The size is `'lg' \| 'md' \| 'sm' \| 'xs'` | [Button Group](demo#button-groups) | - -# Interface & Type Definition -### IButtonType - -The default value is 'button', indicating the button type. - -```ts -export type IButtonType = 'button' | 'submit' | 'reset'; -``` - -### IButtonStyle - -The default value is 'primary', indicating the button style. - -```ts -export type IButtonStyle = 'common' | 'primary' | 'text' | 'text-dark' | 'danger'; -``` - -### IButtonPosition - -The default value is 'default', indicating the button position. - -```ts -export type IButtonPosition = 'left' | 'right' | 'default'; -``` - -### IButtonSize -The default value is 'md', indicating the button size. - -```ts -export type IButtonSize = 'lg' | 'md' | 'sm' | 'xs'; -``` - -### IButtonGroupSize -The default value is 'md', indicating the button-group size. - -```ts -export type IButtonGroupSize = 'lg' | 'md' | 'sm' | 'xs'; -``` diff --git a/packages/devui-vue/docs/en-US/components/button/index.md b/packages/devui-vue/docs/en-US/components/button/index.md deleted file mode 100644 index 4870da3b..00000000 --- a/packages/devui-vue/docs/en-US/components/button/index.md +++ /dev/null @@ -1,27 +0,0 @@ -# Button - -The button is used to start an instant operation。 - -### When to use - -An operation command (or a group of encapsulation) is marked, and the corresponding business logic is triggered in response to the user's click behavior。 - -### Main button - -Primary -Disabled - -```html -Primary -Disabled -``` - -### Secondary button - -Common -Disabled - -```html -Common -Disabled -``` \ No newline at end of file diff --git a/packages/devui-vue/docs/en-US/components/card/index.md b/packages/devui-vue/docs/en-US/components/card/index.md deleted file mode 100644 index d81ada82..00000000 --- a/packages/devui-vue/docs/en-US/components/card/index.md +++ /dev/null @@ -1,220 +0,0 @@ -# Card - -Universal card container。 - -### When to use - -Basic card container, which can contain text, lists, pictures, paragraphs, used for overview display。 - - -### Basic usage - - - - - - - - - -```html - - - - - - - -``` - -### Use image - -The alignment of the d-card-actions operation area can be set through align: initial alignment, tail alignment, stretch alignment。 - - - - - - - - - -```html - - - - - - - -``` - -### Custom Area - - -
    - -
    -
    - - -
    - -```html - -
    - -
    -
    - - -
    -``` - \ No newline at end of file diff --git a/packages/devui-vue/docs/en-US/components/carousel/index.md b/packages/devui-vue/docs/en-US/components/carousel/index.md deleted file mode 100644 index 4fad5733..00000000 --- a/packages/devui-vue/docs/en-US/components/carousel/index.md +++ /dev/null @@ -1,162 +0,0 @@ -# Carousel - -A set of carousel areas。 - -### When to use - -1. Used to display pictures or cards。 - -### Basic usage - - {{ item }} - - -```html - - {{ item }} - -``` -```css -.d-carousel-item { - text-align: center; - line-height: 200px; - background: var(--devui-global-bg, #f3f6f8); -} -``` -### 指示器&切换箭头 -arrowTrigger设为always可以使箭头永久显示,dotTrigger设为hover可以使hover到点上就切换。 - - - {{ item }} - - -```html - - {{ item }} - -``` -### Automatic carousel - - {{ item }} - - -```html - - {{ item }} - -``` -### Custom action - - {{ item }} - - - -```html - - {{ item }} - - -``` -```css -.carousel-demo-operate{ - margin-top: 10px; - - display: flex; - align-items: center; - - > * { - margin-right: 20px; - } -} -``` - -### API -#### parameter - -| parameter | type | default | description | jump Demo | -| :----------: | :--------------------------: | :------: | :---------------------------------------------- | ------------------------------------------------ | -| arrowTrigger | `'hover'\|'never'\|'always'` | 'hover' | Optional, specify the switching arrow display mode | [Indicator-switch-arrow](#Indicator-switch-arrow) | -| autoplay | `boolean` | false | Optional, whether to rotate automatically | [Automatic-carousel](#Automatic-carousel) | -| autoplaySpeed | `number` | 3000 | Optional, used with `autoplay`, automatic rotation speed, unit: ms | [Automatic-carousel](#Automatic-carousel) | -| height | `string` | '100%' | Optional, carousel container height | [Basic-usage](#Basic-usage) | -| showDots | `boolean` | true | Optional, whether to display the panel indicator | [Automatic-carousel](#Automatic-carousel) | -| dotPosition | `'top'\|'bottom'` | 'bottom' | Optional, panel indicator position | [Indicator-switch-arrow](#Indicator-switch-arrow) | -| dotTrigger | `'click'\|'hover'` | 'click' | Optional, indicator triggers carousel mode | [Indicator-switch-arrow](#Indicator-switch-arrow) | -| activeIndex | `number` | 0 | Optional, initialize the active card index, starting from 0, supporting `[(activeIndex)]` two-way binding | [Basic-usage](#Basic-usage) | - -#### Event - -| event | type | description | jump Demo | -| :----------------: | :---------------------: | :-----------------------------------------: | ------------------------------------------------- | -| activeIndexChange | `EventEmitter` | When the card is switched, return to the index of the current card, starting from 0 | [Basic-usage](#Basic-usage) | - -#### methods - -| methods | description | jump Demo | -| :---------: | :---------------------------------- | :----------------------------- | -| prev() | Switch to the previous card | [Custom-action](#Custom-action) | -| next() | Switch to the next card | [Custom-action](#Custom-action) | -| goTo(index) | Switch to the card with the specified index, the index starts from 0 | [Custom-action](#Custom-action) | - - - - \ No newline at end of file diff --git a/packages/devui-vue/docs/en-US/components/checkbox/index.md b/packages/devui-vue/docs/en-US/components/checkbox/index.md deleted file mode 100644 index 1cd4822d..00000000 --- a/packages/devui-vue/docs/en-US/components/checkbox/index.md +++ /dev/null @@ -1,42 +0,0 @@ -# CheckBox - -CheckBox。 - -### When to use - -1. Make multiple choices in a set of options; -2. Used alone can indicate switching between the two states, and can be combined with the submit operation。 - -### Basic usage - - - - -```html - - -``` - -#### use CheckboxGroup - - - - -
    {{ checkedValues.reduce((prev, current) => `${current} ${prev}`, '') }}
    - - \ No newline at end of file diff --git a/packages/devui-vue/docs/en-US/components/date-picker/index.md b/packages/devui-vue/docs/en-US/components/date-picker/index.md deleted file mode 100644 index 6ec80542..00000000 --- a/packages/devui-vue/docs/en-US/components/date-picker/index.md +++ /dev/null @@ -1,121 +0,0 @@ - - -# DatePicker - -Date and time visual input。 - -## Attributes auto-close - -|project|description| -|----|----| -|name|auto-close / autoClose| -|type|boolean| -|mustSelect|false| -|default|false| -|description|After selecting the date, whether to automatically close the date panel| - -```vue - - - - - - - -``` - - - - -## Attributes range - -|project|description| -|----|----| -|name|range| -|type|boolean| -|mustSelect|false| -|default|false| -|description|Whether to open interval selection| - -```vue - - - - - - - -``` - - - -## Attributes format - -|project|type| -|----|----| -|name|format| -|type|string| -|mustSelect|false| -|default|y/MM/dd| -|description|Date value format| - - - - -```vue - - -``` - -**Date formatting characters** - -|character|description|rule| -|----|----|----| -|y, yy, yyyy|year|When using `yy`, only the last 2 digits are displayed, otherwise 4 digits are displayed。for example:`yy/MM/dd -> 21/01/02`, `y/MM/dd -> 2021/01/02`| -|M,MM|month|When using `MM`, the left side of a one-digit number will automatically add `0`。for example: `y/MM/dd -> 2021/01/02`,`y/M/d -> 2021/1/2`| -|d,dd|date|rule reference`M`| -|h,hh|hour|rule reference`M`;Use 24-hour representation。| -|m,mm|minute|rule reference`M`| -|s,ss|second|rule reference`M`| - -## Attributes range-spliter - -|project|type| -|----|----| -|name|range-spliter / rangeSpliter| -|type|string| -|mustSelect|false| -|default|-| -|description|In interval selection mode, the character that separates the start and end time。| - -```vue - -``` - - - -## Event selectedDateChange - -```vue - - -``` - - - \ No newline at end of file diff --git a/packages/devui-vue/docs/en-US/components/icon/index.md b/packages/devui-vue/docs/en-US/components/icon/index.md deleted file mode 100644 index 45ba44f2..00000000 --- a/packages/devui-vue/docs/en-US/components/icon/index.md +++ /dev/null @@ -1,71 +0,0 @@ -# Icon 图标 - -用于显示图标。 - -### 何时使用 - -需要显示图标时。 - -所有内置的图标可在DevUI官网进行查看: - -[https://devui.design/icon/ruleResource](https://devui.design/icon/ruleResource) - -### 基本用法 - - - - - - -```html - - - - -``` - -### 自定义字体图标 - -Icon 组件默认引用 DevUI 图标库的图标,如果需要在现有 Icon 的基础上使用更多图标,可以引入第三方 iconfont 对应的字体文件和 CSS 文件,之后就可以在 Icon 组件中直接使用。 - -```css -@font-face { - font-family: "my-icon"; - src: url("./my-icon.ttf") format("truetype"); -} - -.my-icon { - font-family: "my-icon"; -} - -.my-icon-right::before { - content: "\E03F"; -} -``` - -引入字体图标的 css - -```css -@import "my-icon.css"; -``` - -or - -```js -import "my-icon.css"; -``` - -使用 - -```html - -``` - -### API - -| 参数 | 类型 | 默认 | 说明 | 跳转 Demo | -| :---------: | :------: | :-------: | :----------------------- | --------------------------------- | -| name | `String` | -- | 必选,Icon 名称 | [基本用法](#基本用法) | -| size | `String` | '16px' | 可选,图标大小 | [基本用法](#基本用法) | -| color | `String` | '#252b3a' | 可选,图标颜色 | [基本用法](#基本用法) | -| classPrefix | `String` | 'icon' | 可选,自定义字体图标前缀 | [自定义字体图标](#自定义字体图标) | diff --git a/packages/devui-vue/docs/en-US/components/image-preview/index.md b/packages/devui-vue/docs/en-US/components/image-preview/index.md deleted file mode 100644 index 481641d3..00000000 --- a/packages/devui-vue/docs/en-US/components/image-preview/index.md +++ /dev/null @@ -1,137 +0,0 @@ -# ImagePreview - -Preview the components of one or more pictures。 - -### When to use - -When you need to preview the image or preview the image in the container according to the user input。 - -### Basic usage - -Use the v-d-image-preview command to preview the image in the container。 - -
    - -
    - -```html -
    - -
    - - -``` - -### Custom open preview window - -Pass in the custom parameter, the command will be automatically injected into the open method, and the preview window will be opened through custom.open - -
    - -
    -自定义 - -```html -
    - -
    -自定义 - - -``` - -### Set zIndex - -Set zIndex to control the level of the pop-up effect, and set backDropZIndex to control the level of the background of the pop-up layer。 -You can see that when zIndex is set to be less than backDropZIndex, imagePreview will be displayed below the background。 -You can close imagePreview by Esc。 - -``` -// 待嵌入 modal 组件即可 -``` - -### API - -| parameter | type | default | description | -| :------------: | :-------: | :---: | :------------------------------------------------------------ | -| custom | `Object` | -- | Optional, the command will be automatically injected into the open method, and the preview window will be opened through custom.open | -| disableDefault | `Boolean` | false | Optional, turn off the default click trigger image preview mode | -| zIndex | `Number` | 1050 | Optional, optional, set the z-index value of the picture when previewing | -| backDropZIndex | `Number` | 1040 | Optional, set the z-index value of the image background during preview | - - - - diff --git a/packages/devui-vue/docs/en-US/components/input/index.md b/packages/devui-vue/docs/en-US/components/input/index.md deleted file mode 100644 index edc7f8fa..00000000 --- a/packages/devui-vue/docs/en-US/components/input/index.md +++ /dev/null @@ -1,96 +0,0 @@ -# Input - -Text input。 - -### When to use - -You need to manually enter text to use。 - -### Basic usage - -:::demo - -```vue - - -``` - -::: - -### Size - -:::demo - -```vue - -``` - -::: - - -### Password - -:::demo - -```vue - - -``` - -::: - -### API - -| parameter | type | default | description | jump Demo | -| :---------: | :------: | :-------: | :-----------------------: | :---------------------------------: | -| id | `string` | -- | Optional, text box id | [Basic-usage](#Basic-usage) | -| placeholder | `string` | -- | Optional,textarea placeholder | [Basic-usage](#Basic-usage) | -| maxLength | `number` | Number.MAX_SAFE_INTEGER | Optional, the max-length of the input box | | -| disabled | `boolean` | false | Optional,Whether the text box is disabled | [Basic-usage](#Basic-usage) | -| error | `boolean` | false | Optional,Whether there is an input error in the text box | [Basic-usage](#Basic-usage) | -| size | `'sm'\|''\|'lg'` | '' | Optional,There are three options for the size of the text box`'lg'`,`''`,`'sm'` | [Size](#Size) | -| cssClass | `string` | '' | Optional,Support to pass in the class name to the input box | | -| showPassword | `boolean` | false | Optional,password | [Password](#Password) | -| autoFocus | `boolean` | false | Optional,Whether the input box is auto-focused | [Basic-usage](#Basic-usage) | - diff --git a/packages/devui-vue/docs/en-US/components/loading/index.md b/packages/devui-vue/docs/en-US/components/loading/index.md deleted file mode 100644 index 5c0a61f5..00000000 --- a/packages/devui-vue/docs/en-US/components/loading/index.md +++ /dev/null @@ -1,298 +0,0 @@ -# Loading - -Prompt the user that the page is executing instructions and needs to wait。 - -### When to use - -When the execution time is long (it takes more than a few seconds), show the user the status of execution。 - - -### Basic usage -Show the basic usage in the scene of loading table data。 -:::demo - -```vue - - - -``` -::: - - -### many promise -support many promise。 -:::demo - -```vue - - - -``` -::: - -### Custom Css Style -Customize loading style through templateRef。 -:::demo - -```vue - - - - - -``` -::: - -### Service method call -Use the service method to load the loading component in full screen or load the loading component on the specified host。 -:::demo - -```vue - - - -``` -::: - -### parameter -The parameter of dLoading - -| **parameter** | **type** | **default** | **description** | **jump Demo** | -| ------------------ | ------------------------------------------------------------ | ------------------------- | ------------------------------------------------------------ | ---------------------------- | -| v-dLoading | `Promise \| Array> \| Boolean \| undefined` | -- | Optional, command mode, control loading status | [Basic-usage](#Basic-usage) | -| target | `element` | document.body | Optional, service mode, DOM nodes that need to be covered by Loading | [Service-method-call](#Service-method-call) | -| message | `string` | -- | Optional, prompt message during loading | [many-promise](#many-promise) | -| loadingTemplateRef | `VNode` | -- | Optional, custom loading template | [Custom-css-style](#Custom-css-style) | -| backdrop | `boolean` | true | Optional, whether to show the mask during loading | [Basic-usage](#Basic-usage) | -| positionType | `string` | relative | Optional, specify the positioning type of the `dLoading` host element, the value is consistent with the css position attribute。 | [Basic-usage](#Basic-usage) | -| view | `{top?:string,left?:string} ` | {top: '50%', left: '50%'} | Optional, adjust the display position of loading, relative to the top and left distances of the host element | [Basic-usage](#Basic-usage) | -| zIndex | `number` | -- | Optional, z-index value of loading prompt | [Basic-usage](#Basic-usage) | - diff --git a/packages/devui-vue/docs/en-US/components/overlay/index.md b/packages/devui-vue/docs/en-US/components/overlay/index.md deleted file mode 100644 index 6a7399ba..00000000 --- a/packages/devui-vue/docs/en-US/components/overlay/index.md +++ /dev/null @@ -1,198 +0,0 @@ -## overlay -The mask layer is a basic component and is used to build components independent of the current page layout。 -### When to use -You can use this component when you need a global pop-up window, or when you need an element-following function。 -### Fixed overlay - -:::demo Use `sm`, `''`, `lg` to define the basic type of `Search` - -```vue - - -``` -::: - - -### Elastic overlay - -:::demo -```vue - - -``` - -::: - - - - -### API -The parameter of d-fixed-overlay - -| parameter | type | default | description | -| :--------------: | :------------------------: | :---: | :-------------------------------------------------------------------- | -| visible | `boolean` | false | Optional, whether the mask layer is visible | -| onUpdate:visible | `(value: boolean) => void` | -- | Optional, the mask layer cancels the visible event | -| backgroundBlock | `boolean` | false | Optional, if true, the background cannot be scrolled | -| backgroundClass | `string` | -- | Optional, the style class of the background | -| hasBackdrop | `boolean` | true | Optional, if false, the content behind the background will be triggered | -| backdropClick | `() => void` | -- | Optional, click on the event triggered by the background | -| backdropClose | `boolean` | false | Optional, if true, clicking on the background will trigger `onUpdate:visible`, the default parameter is false | -| overlayStyle | `CSSProperties` | -- | Optional, the style of the mask layer | - -The parameter of d-flexible-overlay - -| 参数 | 类型 | 默认 | 说明 | -| :--------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---: | :---------------------------------------------------------------- | -| visible | `boolean` | false | 可选,遮罩层是否可见 | -| onUpdate:visible | `(value: boolean) => void` | -- | 可选,遮罩层取消可见事件 | -| backgroundBlock | `boolean` | false | 可选,如果为 true,背景不能滚动 | -| backgroundClass | `string` | -- | 可选,背景的样式类 | -| hasBackdrop | `boolean` | true | 可选,如果为false,背景后下的内容将可以触发 | -| backdropClick | `() => void` | -- | 可选,点击背景触发的事件 | -| backdropClose | `boolean` | false | 可选,如果为true,点击背景将触发 `onUpdate:visible`,参数是 false | -| origin | `Element \| ComponentPublicInstance \| { x: number, y: number, width?: number, height?: number }` | false | 必选,你必须指定起点元素才能让遮罩层与该元素连接在一起 | -| position | `{originX: HorizontalPos, originY: VerticalPos, overlayX: HorizontalPos, overlayY: VerticalPos } (type HorizontalPos = 'left' \| 'center' \| 'right') ( type VerticalPos = 'top' \| 'center' \| 'bottom')` | false | 可选,指定遮罩层与原点的连接点 | diff --git a/packages/devui-vue/docs/en-US/components/pagination/index.md b/packages/devui-vue/docs/en-US/components/pagination/index.md deleted file mode 100644 index 6e85d151..00000000 --- a/packages/devui-vue/docs/en-US/components/pagination/index.md +++ /dev/null @@ -1,473 +0,0 @@ -# Pagination - -Pagination。 - -### When to use - -When loading/rendering all the data will take a lot of time, you can switch the page number to browse the data。 - - -### Basic usage - -:::demo - -```vue - - -``` -::: - - -### Minimalist mode -Minimalist mode is suitable for some pages with a lot of information, which can simplify the complexity of the page。 -:::demo - - -```vue - - - - -``` -::: - -### Multiple configurations -Support setting input jump, display jump button; setting pageSize and other functions。 -:::demo - -```vue - - -``` -::: - -### Special cases -The display of the pager in a special scene。 -:::demo - - -```vue - - -``` -::: - -### 参数 - -d-pagination 参数 - -| parameter | type | default | description | jump Demo | -| ----------------- | ------------------------------------------------------------ | -------------------------- | ------------------------------------------------------------ | --------------------- | -| pageSize | `number` | 10 | Optional, display the maximum number of entries per page | [Basic-usage](#Basic-usage) | -| total | `number` | 0 | Optional, total number of entries displayed | [Basic-usage](#Basic-usage) | -| pageSizeOptions | `number[] ` | 10 | Optional, the data source of the drop-down box for the maximum number of entries per page for pagination, there are four options by default 5, 10, 20, 50 | [Multiple-configurations](#Multiple-configurations) | -| pageSizeDirection | `Array<`[`AppendToBodyDirection`](#appendtobodydirection) `\|` [`ConnectedPosition`](#connectedposition)`>` | ['centerDown', 'centerUp'] | Optional, set the display direction of the drop-down box of each page entry | [Multiple-configurations](#Multiple-configurations) | -| pageIndex | `number` | 1 | Optional, initialize page number | [Basic-usage](#Basic-usage) | -| maxItems | `number` | 10 | Optional, display a few buttons at most for pagination | [Basic-usage](#Basic-usage) | -| preLink | `string` | -- | Optional, the previous page button displays the icon, the default setting is the left arrow icon | [Basic-usage](#Basic-usage) | -| nextLink | `string` | -- | Optional, the next page button displays the icon, the default setting is the right arrow icon | [Basic-usage](#Basic-usage) | -| size | `number` | '' | 可Selection, paging component size, there are three options lg,``,sm, respectively representing large, medium and small | [Basic-usage](#Basic-usage) | -| canJumpPage | `boolean` | false | Optional, whether to display the page input jump | [Basic-usage](#Basic-usage) | -| canChangePageSize | `boolean` | false |Optional, whether to display the drop-down box for selecting the maximum number of entries per page for changing the pagination | [Basic-usage](#Basic-usage) | -| canViewTotal | `boolean` | false | Optional, whether to display total entries | [Basic-usage](#Basic-usage) | -| totalItemText | `string` | 'All entries' | Optional, total entry text | [Minimalist-mode](#Minimalist-mode) | -| goToText | `string` | 'jump to' | Optional, total entry text | [Basic-usage](#Basic-usage) | -| showJumpButton | `boolean` | false | Optional, whether to show the jump button | [Multiple-configurations](#Multiple-configurations) | -| showTruePageIndex | `boolean` | false | Optional, the switch to display the current page number when the page number exceeds the paging range | [Multiple-configurations](#Multiple-configurations) | -| lite | `boolean` | false | Optional, whether to switch to Minimalist-mode | [Minimalist-mode](#Minimalist-mode) | -| showPageSelector | `boolean` | true | Optional, whether to show page number drop-down under `Minimalist-mode` | [Minimalist-mode](#Minimalist-mode) | -| haveConfigMenu | `boolean` | false | Optional, whether to display the configuration under `Minimalist-mode` | [Minimalist-mode](#Minimalist-mode) | -| autoFixPageIndex | `boolean` | true | Optional, whether to automatically correct the page number when changing the pageSize. If the `pageIndex` is handled in the `pageSizeChange` event, it is recommended to set it to `false` | [Minimalist-mode](#Minimalist-mode) | -| autoHide | `boolean` | false | Optional, whether to hide automatically, autoHide is true and the minimum value of pageSizeOptions> total does not show pagination | [Minimalist-mode](#Minimalist-mode) | - -d-pagination Event - -| parameter | type | default | jump Demo | -| --------------- | -------------------- | ---------------------------------------------------------- | --------------------- | -| pageIndexChange | `EventEmitter` | Optional, callback of page number change, return current page number value | [Multiple-configurations](#Multiple-configurations) | -| pageSizeChange | `EventEmitter` | Optional, callback when the maximum number of items per page is changed, return the current number of items displayed on each page | [Multiple-configurations](#Multiple-configurations) | - -**Tnterface & TypeDefine** - -##### AppendToBodyDirection - -```ts -export type AppendToBodyDirection = 'rightDown' | 'rightUp' | 'leftUp' | 'leftDown' | 'centerDown' | 'centerUp'; -``` - -##### ConnectedPosition - -```ts -export interface ConnectedPosition { - originX: 'start' | 'center' | 'end'; - originY: 'top' | 'center' | 'bottom'; - - overlayX: 'start' | 'center' | 'end'; - overlayY: 'top' | 'center' | 'bottom'; - - weight?: number; - offsetX?: number; - offsetY?: number; - panelClass?: string | string[]; -} -``` - diff --git a/packages/devui-vue/docs/en-US/components/panel/index.md b/packages/devui-vue/docs/en-US/components/panel/index.md deleted file mode 100644 index da8c4438..00000000 --- a/packages/devui-vue/docs/en-US/components/panel/index.md +++ /dev/null @@ -1,74 +0,0 @@ -# Panel - -Content panel for content grouping。 - -### When to use - -Used when the page content needs to be displayed in groups, generally including three parts: header, content area, and bottom。 - -### Basic usage - -
    - - - Panel with foldable - - - This is body - -

    - - - Panel has no left padding - - - This is body - -

    - - Panel with header and footer - This is body - This is footer - -
    - - -```html -
    - - - Panel with foldable - - - This is body - -

    - - - Panel has no left padding - - - This is body - -

    - - Panel with header and footer - This is body - This is footer - -
    -``` - - diff --git a/packages/devui-vue/docs/en-US/components/popover/index.md b/packages/devui-vue/docs/en-US/components/popover/index.md deleted file mode 100644 index 522495c9..00000000 --- a/packages/devui-vue/docs/en-US/components/popover/index.md +++ /dev/null @@ -1,386 +0,0 @@ -# Popover -Simple text prompt bubble box。 - -### When to use -Used to notify users of non-critical issues or to prompt a control in a special situation。 - -### Basic usage -When Popover pops up, it will be positioned based on the content of the `reference` slot。 - -
    - - - - - - - - - - - - - - - - - - -
    - - -```html - - - - - - - - - - - - - - - - - - - - - - -``` - -### Custom content -Customize the content of the `reference` slot and the content of the pop-up prompt。 - -
    - - - -
    - -```html -
    - - - -
    -``` - -### Pop-up position -A total of 12 pop-up positions are supported。 - -
    - - - - - - - - - - - - -
    - -
    - - - - - - - - - - - - -
    - -
    - - - - - - - - - - - - -
    - -
    - - - - - - - - - - - - -
    - -```html -
    - - - - - - - - - - - - -
    - -
    - - - - - - - - - - - - -
    - -
    - - - - - - - - - - - - -
    - -
    - - - - - - - - - - - - -
    -``` - -### Delay trigger -Only when the trigger is hover, the mouse moves in for more than [mouseEnterDelay] milliseconds to trigger to prevent flashing caused by the user inadvertently swiping. The default value is 150 milliseconds; after the mouse is moved out, it will be triggered after [mouseLeaveDelay] milliseconds. , The Popover component will be hidden, the default value is 100 milliseconds。 - -
    - - - - - - - - -
    - -```html - - - - - - - - -``` - -### dPopover parameter - -| parameter | type | default | description | jump Demo | -| ---- | ---- | ---- | ---- | ---- | -| content | `string` | defalut |Optional, the display content of the pop-up box | [Custom-content](#Custom-content) | -| visible | `boolean` | false | Optional, the initial pop-up state of the bullet box | [Basic-usage](#Basic-usage) | -| trigger | `string` | click | Optional, trigger mode of the bullet frame | [Basic-usage](#Basic-usage) | -| popType | `string` | default | Optional, pop-up box type, different styles | [Basic-usage](#Basic-usage) | -| zIndex | `number` | 1060 | Optional, z-index value is used to manually control the layer height | [Basic-usage](#Basic-usage) | -| positionType | `string` | bottom | Optionally, control the direction in which the bullet frame appears | [Pop-up-position](#Pop-up-position) | -| showAnimation | `boolean` | true | Optional, whether to show animation | [Basic-usage](#Basic-usage) | -| mouseEnterDelay | `number` | 150 | Optional, only when the trigger is hover, set the delay after the mouse moves in to display Popover, the unit is `ms`| [Delay-trigger](#Delay-trigger) | -| mouseLeaveDelay | `number` | 100 | Optional, only need to set the delay after the mouse is moved out to hide the popover only when the trigger is hover, the unit is `ms` | [Delay-trigger](#Delay-trigger) | - diff --git a/packages/devui-vue/docs/en-US/components/progress/index.md b/packages/devui-vue/docs/en-US/components/progress/index.md deleted file mode 100644 index 402090d5..00000000 --- a/packages/devui-vue/docs/en-US/components/progress/index.md +++ /dev/null @@ -1,142 +0,0 @@ -# Progress - -progress bar。 - -### When to use -1. When the operation takes a long time, show the user the progress of the operation。 -2. When the operation needs to interrupt the existing interface or background operation, it takes a long time。 -3. When it is necessary to display the percentage of an operation completed or the completed steps/total steps。 - -### Basic usage -Basic progress and text configuration。 - -
    -
    - -
    -
    - -
    -
    - - -```html -
    - -
    -
    - -
    -``` - -```css -.progress-container { - margin-bottom: 20px; -} -``` - -### Ring usage -Basic progress and text configuration。 - -
    -
    - -
    -
    - - -
    -
    - - - -
    -
    - - -```html -
    - -
    -
    - -
    -
    - - - -
    -``` - -```css -.progress-container-circle { - height: 130px; - width: 130px; - font-size: 20px; - display: inline-block; - margin-right: 10px; -} - -.icon-position { - position: absolute; - top: 50%; - left: 50%; - width: 100%; - margin: 0; - padding: 0; - line-height: 1; - white-space: normal; - text-align: center; - transform: translate(-50%, -50%); - color: #50d4ab; - font-size: 24px; -} -``` - -### API -#### d-progress parameter -| parameter | type | default | description | jump Demo | -| :---: | :---: | :---: | :---: | :---: | -| percentage | `number` | 0 | Optional, the maximum value of the progress bar is 100 | [基本用法](#基本用法) | -| percentageText | `string` | -- | Optional, the text description of the current value of the progress bar, such as: '30%' \| '4/5' | [基本用法](#基本用法) | -| barBgColor | `string` | #5170ff | Optional, the color of the progress bar is displayed, the default is sky blue | [基本用法](#基本用法) | -| height | `string` | 20px | Optional, the height of the progress bar, the default value is 20px | [基本用法](#基本用法) | -| isCircle | `boolean` | false | Optional, show whether the progress bar is a circle | [圆环用法](#圆环用法) | -| strokeWidth | `number` | 6 | Optional, set the width of the circular progress bar, the unit is the percentage of the width of the progress bar and the canvas | [圆环用法](#圆环用法) | -| showContent | `boolean` | true | Optional, set whether to display content in the circle-shaped progress bar | [圆环用法](#圆环用法) | - - - diff --git a/packages/devui-vue/docs/en-US/components/quadrant-diagram/index.md b/packages/devui-vue/docs/en-US/components/quadrant-diagram/index.md deleted file mode 100644 index e212464c..00000000 --- a/packages/devui-vue/docs/en-US/components/quadrant-diagram/index.md +++ /dev/null @@ -1,44 +0,0 @@ -# ProQuadrantDiagramgress - -Quadrant diagram。 - -### When to use - -Regional division and value sorting of affairs according to needs, which can be used to manage the priority of affairs。 - -### Basic usage - -

    Basic Usage

    - -:::demo - -```vue - - - - -``` - -::: diff --git a/packages/devui-vue/docs/en-US/components/radio/index.md b/packages/devui-vue/docs/en-US/components/radio/index.md deleted file mode 100644 index 3ab37dd6..00000000 --- a/packages/devui-vue/docs/en-US/components/radio/index.md +++ /dev/null @@ -1,307 +0,0 @@ -# Radio 单选框 - -单选框。 - -### 何时使用 - -用户要从一个数据集中选择单个选项,且能并排查看所有可选项,选项数量在 2~7 之间时,建议使用单选按钮。 - -### 相互独立的单选项 - -:::demo - -```vue - - - -``` - -::: - -### radio 根据条件终止切换操作 - -:::demo 根据条件判断,第二项禁止跳转。 - -```vue - - - -``` - -::: - -### radio-group 根据条件终止切换操作 - -:::demo - -```vue - - - -``` - -::: - -### 禁用 - -:::demo - -```vue - - - -``` - -::: - -### 横向排列 - -:::demo - -```vue - - - -``` - -::: - -### 竖向排列 - -:::demo - -```vue - - - -``` - -::: - -### 自定义单选项 - -:::demo 数组源可为普通数组、对象数组等。 - -```vue - - - -``` - -::: - -### API - -d-radio 参数 - -| 参数 | 类型 | 默认 | 说明 | 跳转 Demo | -| :----------: | :------------------: | :---: | :------------------------------------------------------------------------------ | --------------------------------------- | -| name | `string` | -- | 可选,单选项名称 | [互相独立的单选项](#相互独立的单选项) | -| value | `string` | -- | 必选,单选项值 | [互相独立的单选项](#相互独立的单选项) | -| disabled | `boolean` | false | 可选,是否禁用该单选项 | [禁用](#禁用) | -| beforeChange | `Function / Promise` | -- | 可选,radio 切换前的回调函数,返回 boolean 类型,返回 false 可以阻止 radio 切换 | [回调切换](#radio-根据条件终止切换操作) | - -d-radio 事件 - -| 参数 | 类型 | 说明 | 跳转 Demo | -| :----: | :--------------------: | :------------------------------- | ------------------------------------- | -| change | `EventEmitter` | 单选项值改变时触发,返回选中的值 | [互相独立的单选项](#相互独立的单选项) | - -d-radio-group 参数 - -| 参数 | 类型 | 默认 | 说明 | 跳转 Demo | -| :----------: | :------------------: | :------: | :-------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | -| name | `string` | -- | 可选,单选框的名称 | [竖向排列](#竖向排列) | -| values | `array` | -- | 可选,单选数据组 | [竖向排列](#竖向排列) | -| disabled | `boolean` | false | 可选,是否禁用该选项组 | [radio-group 根据条件终止切换操作](#radio-group-根据条件终止切换操作) | -| cssStyle | `'row' / 'column'` | 'column' | 可选,设置横向或纵向排列 | [横向排列](#横向排列) | -| beforeChange | `Function / Promise` | -- | 可选,radio-group 切换前的回调函数,返回 boolean 类型,返回 false 可以阻止 radio-group 的切换 | [回调切换](#radio-group-根据条件终止切换操作) | - -d-radio-group 事件 - -| 参数 | 类型 | 说明 | 跳转 Demo | -| :----: | :--------------------: | :------------------------------- | --------------------- | -| change | `EventEmitter` | 单选项值改变时触发,返回选中的值 | [竖向排列](#竖向排列) | diff --git a/packages/devui-vue/docs/en-US/components/rate/index.md b/packages/devui-vue/docs/en-US/components/rate/index.md deleted file mode 100644 index 4ffde650..00000000 --- a/packages/devui-vue/docs/en-US/components/rate/index.md +++ /dev/null @@ -1,138 +0,0 @@ -# Rate - -Grade evaluation。 - -When to sue -It can be used when users rate a product。 - -### Demo - -### Read-only mode - -:::demo - -```vue - - -``` - -::: - -### Dynamic mode - -:::demo - -```vue - - -``` - -::: - -### Dynamic mode-custom - -:::demo - -```vue - - -``` - -::: - -### Use the type parameter - -:::demo - -```vue - - -``` - -::: - -### API - -d-rate parameter - -| parameter | type | default | description | jump Demo | -| :-------: | :-----------------------------: | :----: | :------------------------------------------------------- | ----------------------------------- | -| read | `boolean` | false | Optional, set whether to read-only mode, read-only mode cannot be interactive | [只读模式](#只读模式) | -| count | `number` | 5 | Optional, set the total number of levels | [只读模式](#只读模式) | -| type | `'success'\|'warning'\|'error'` | -- | Optional, set the current rating type, different types correspond to different colors | [使用 type 参数](#使用-type-参数) | -| color | `string` | -- | Optional, star color | [动态模式-自定义](#动态模式-自定义) | -| icon | `string` | -- | Optional, the style of the rating icon, only supports all icons in the devUI icon library | [动态模式](#动态模式) | -| character | `string` | -- | Optional, the style of the rating icon, only one of icon and character can be set | [动态模式-自定义](#动态模式-自定义) | diff --git a/packages/devui-vue/docs/en-US/components/search/index.md b/packages/devui-vue/docs/en-US/components/search/index.md deleted file mode 100644 index a47a8355..00000000 --- a/packages/devui-vue/docs/en-US/components/search/index.md +++ /dev/null @@ -1,95 +0,0 @@ -# Search 搜索框 - -### 基本用法 - -:::demo 使用`sm`,`''`,`lg`来定义`Search`基本类型 - -```vue - -``` -::: - -### 搜索图标左置 - -:::demo 使用`left`,`right`来定义`Search`搜索图标位置, 默认`right` - -```vue - -``` -::: - -### 无边框 - -:::demo 使用`noBorder`来定义`Search`无边框 - -```vue - -``` -::: - -### 双向绑定 - -:::demo 使用`v-model`双向绑定 - -```vue - - - - -``` - -::: - -### API - -| 参数 | 类型 | 默认 | 说明 | 跳转 Demo | 全局配置项 | -| :---------: | :------: | :-------: | :----------------------- | --------------------------------- | --------- | -| size | `'sm'\|''\|'lg'` | '' | 可选,搜索框尺寸,有三种选择 lg、''、sm | [基本用法](#基本用法) || -| placeholder | `string` | -- | 可选,输入框 placeholder | [搜索图标左置](#搜索图标左置) || -| maxLength | `number` | -- | 可选,输入框的 max-length | [双向绑定](#双向绑定) || -| delay | `number` | 300 | 可选,debounceTime 的延迟 | [基本用法](#基本用法) || -| disabled | `boolean` | false | 可选,输入框是否被禁用 | [基本用法](#基本用法) || -| autoFocus | `boolean` | false | 可选,输入框是否自动对焦 | [基本用法](#基本用法) || -| isKeyupSearch | `boolean` | false | 可选,是否支持输入值立即触发 searchFn | [基本用法](#基本用法) || -| iconPosition | `string` | 'right' | 可选,搜索图标位置,有两种选择'left' / 'right' | [搜索图标左置](#搜索图标左置) || -| noBorder | `boolean` | false | 可选,是否显示边框 | [无边框](#无边框) || -| cssClass | `string` | '' | 可选,支持传入类名到输入框上 | [双向绑定](#双向绑定) || - -### d-search 事件 - -| 事件 | 类型 | 说明 | 跳转 Demo | -| :---------: | :------: | :--------------------: | :---------: | -| searchFn | `string` | 回车或点击搜索按钮触发的回调函数,返回文本框输入的值 | [基本用法](#基本用法) | - diff --git a/packages/devui-vue/docs/en-US/components/select/index.md b/packages/devui-vue/docs/en-US/components/select/index.md deleted file mode 100644 index 5440b1c7..00000000 --- a/packages/devui-vue/docs/en-US/components/select/index.md +++ /dev/null @@ -1,175 +0,0 @@ -# Select 下拉选择框 - -用于从列表中选择单个或者多个数据 - -### 基本用法 - -:::demo 通过`size`:`sm`,`md(默认)`,`lg`来设置`Select`大小,通过`overview`:`underlined`设置只有下边框样式 - -```vue - - - -``` -::: - -#### 多选 - -:::demo 通过`multiple`:`true`来开启多选 - -```vue - - - -``` -::: - -#### 禁用 - -:::demo 通过`disabled`:`true`来禁用`Select`,通过`option-disabled-key`来设置单个选项禁用,比如设置`disabled`字段,则对象上disabled为`true`时不可选择 - -```vue - - - - -``` -::: - -#### 可清空 - -:::demo 通过`allow-clear`:`true`来设置`Select`可清空 - -```vue - - - - -``` -::: diff --git a/packages/devui-vue/docs/en-US/components/slider/index.md b/packages/devui-vue/docs/en-US/components/slider/index.md deleted file mode 100644 index 171e2e5b..00000000 --- a/packages/devui-vue/docs/en-US/components/slider/index.md +++ /dev/null @@ -1,128 +0,0 @@ -# Slider 滑动输入条 - -滑动输入条 - -### 何时使用 - -当用户需要在数值区间内进行选择时使用 - -### 基本用法 - -
    - -
    - -### 带有输入框的滑动组件 - -
    - -
    - -### 可设置 Step 的滑动组件 -
    - - -
    - -```html - - -``` - -### 禁止输入态 - -
    - -
    - -```html - - -``` - - - -### API - -d-slider 参数 - -| 参数 | 类型 | 默认 | 说明 | 跳转 | -| --------- | ------- | ----- | ------------------------------------------------------------------- | ---- | -| max | number | 100 | 可选,滑动输入条的最大值 |[基本用法](#基本用法) | -| min | number | 0 | 可选,滑动输入条的最小值 |[基本用法](#基本用法) | -| step | number | 1 | 可选,滑动输入条的步长,取值必须大于等于1,且必须可被(max-min)整除 |[基本用法](#可设置Step的滑动组件) | -| disabled | boolean | false | 可选,值为 true 时禁止用户输入 |[基本用法](#禁止输入态) | -| showInput | boolean | false | 可选,值为 true 显示输入框 |[基本用法](#带有输入框的滑动组件) | - diff --git a/packages/devui-vue/docs/en-US/components/status/index.md b/packages/devui-vue/docs/en-US/components/status/index.md deleted file mode 100644 index 4f0996af..00000000 --- a/packages/devui-vue/docs/en-US/components/status/index.md +++ /dev/null @@ -1,26 +0,0 @@ -# Status 状态 - -传达交互结果的组件。 - -### 何时使用 - -表示一个任务的执行结果时使用。 - -### 基本用法 -Success -Error -Warning -Initial -Waiting -Running -Invalid - -```html -Success -Error -Warning -Initial -Waiting -Running -Invalid -``` \ No newline at end of file diff --git a/packages/devui-vue/docs/en-US/components/sticky/index.md b/packages/devui-vue/docs/en-US/components/sticky/index.md deleted file mode 100644 index e3acf7c0..00000000 --- a/packages/devui-vue/docs/en-US/components/sticky/index.md +++ /dev/null @@ -1,139 +0,0 @@ -# sticky 便贴 - -### 何时使用 -当用户在滚动屏幕时,需要某个区域内容在段落或者浏览器可视区域可见时。 - -### 基本用法 - -:::demo 默认容器为父元素 - -```vue - - - - -``` -::: - -### 指定容器 - -:::demo - -```vue - - - -``` -::: - - -### 指定滚动容器 - -:::demo - -```vue - - - - -``` -::: - - -### API - -| 参数 | 类型 | 默认 | 说明 | 跳转 Demo | 全局配置项 | -| :---------: | :------: | :-------: | :----------------------- | --------------------------------- | --------- | -| zIndex | `number` | -- | 可选,指定包裹层的 z-index,用于浮动的时候控制 z 轴的叠放 | [基本用法](#基本用法) || -| container | `Element` | 父容器 | 可选,触发的容器,可不同于父容器 | [指定容器](#指定容器) || -| view | `{top?:number,bottom?:number}` | {top:0,bottom:0} | 可选,用于可视区域的调整,比如顶部有固定位置的头部等,数值对应被遮挡的顶部或底部的高度 | [基本用法](#基本用法) || -| scrollTarget | `Element` | document.documentElement | 可选,设置要发生滚动的容器,一般为滚动条所在容器,为主页面的滚动条时候可以不设置 | [指定滚动容器](#指定滚动容器) || - - -### d-sticky 事件 - -| 事件 | 类型 | 说明 | 跳转 Demo | -| :---------: | :------: | :--------------------: | :---------: | -| statusChange | `string` | 可选,状态变化的时候触发,值为变化后的状态值 | [基本用法](#基本用法) | - diff --git a/packages/devui-vue/docs/en-US/components/switch/index.md b/packages/devui-vue/docs/en-US/components/switch/index.md deleted file mode 100644 index 5845385f..00000000 --- a/packages/devui-vue/docs/en-US/components/switch/index.md +++ /dev/null @@ -1,66 +0,0 @@ -# Switch 开关 - -开/关切换组件。 - -### 何时使用 - -当两种状态需要来回切换控制时,比如启用/禁用。 - -### 基本用法 - -
    - -#### Small - -
    - - - -
    -
    - -#### Middle - -
    - - - -
    - - - -
    -
    - -#### Large - -
    - - - -```html - - - - -``` - - diff --git a/packages/devui-vue/docs/en-US/components/tabs/index.md b/packages/devui-vue/docs/en-US/components/tabs/index.md deleted file mode 100644 index 1fe14767..00000000 --- a/packages/devui-vue/docs/en-US/components/tabs/index.md +++ /dev/null @@ -1,7 +0,0 @@ -# Tabs 选项卡切换 - -选项卡切换组件。 - -### 何时使用 - -用户需要通过平级的区域将大块内容进行收纳和展现,保持界面整洁。 diff --git a/packages/devui-vue/docs/en-US/components/tag-input/index.md b/packages/devui-vue/docs/en-US/components/tag-input/index.md deleted file mode 100644 index 80bd047c..00000000 --- a/packages/devui-vue/docs/en-US/components/tag-input/index.md +++ /dev/null @@ -1,44 +0,0 @@ -# TagInput 标签输入框 - -输入标签组件。 - -### 何时使用 - -当用户需要输入多个标签时。 - -### 基本用法 - - - -```html - -``` - - \ No newline at end of file diff --git a/packages/devui-vue/docs/en-US/components/toast/index.md b/packages/devui-vue/docs/en-US/components/toast/index.md deleted file mode 100644 index 2218666a..00000000 --- a/packages/devui-vue/docs/en-US/components/toast/index.md +++ /dev/null @@ -1,611 +0,0 @@ -# Toast 全局通知 - -全局信息提示组件。 - -### 何时使用 - -当需要向用户全局展示提示信息时使用,显示数秒后消失。 - -### 基本用法 - -common 时不展示图标。 - -
    - - - - Success - Warn - Error - Multiple - link - pure text - common - no title -
    - -```html -
    - - - - Success - Warn - Error - Multiple - link - pure text - common - no title -
    -``` - -```ts -import { defineComponent, ref } from 'vue' - -export default defineComponent({ - setup() { - const msgs = ref([]) - - function showToast(type: any) { - switch (type) { - case 'link': - msgs.value = [ - { severity: 'info', summary: 'Relative', detail: `Back to Home Page` }, - { severity: 'info', summary: 'Absolute', content: 'slot:customTemplate', myInfo: 'Devui' } - ] - break - case 'multiple': - msgs.value = [ - { - severity: 'info', - summary: 'Summary', - content: 'This is a test text. This is a test text. This is a test text.' - }, - { - severity: 'info', - summary: 'Summary', - content: 'This is a test text. This is a test text. This is a test text.' - } - ] - break - case 'noTitle': - msgs.value = [{ severity: 'warn', content: 'This is a test text. This is a test text. This is a test text.' }] - break - case 'plainText': - msgs.value = [{ severity: 'info', content: 'data:' }] - break - default: - msgs.value = [ - { - severity: type, - summary: 'Summary', - content: 'This is a test text. This is a test text. This is a test text.' - } - ] - } - } - - return { - msgs, - showToast - } - } -}) -``` - -### 超时时间 - -当设置超时时间、没有标题时,则不展示标题和关闭按钮。 - -
    - - Success - Warn - Error - common -
    - -```html -
    - - Success - Warn - Error - common -
    -``` - -```ts -import { defineComponent, ref } from 'vue' - -export default defineComponent({ - setup() { - const msgs = ref([]) - - function showToast(type: any) { - switch (type) { - case 'error': - msgs.value = [{ severity: type, content: 'This is a test text. This is a test text. This is a test text.' }] - break - case 'common': - msgs.value = [{ severity: type, content: 'This is a test text. This is a test text. This is a test text.' }] - break - default: - msgs.value = [ - { - severity: type, - summary: 'Summary', - content: 'This is a test text. This is a test text. This is a test text.' - } - ] - } - } - - return { - msgs, - showToast - } - } -}) -``` - -### 自定义样式 - -
    - -
    - - Custom Style -
    - -```html -
    - - Custom Style -
    -``` - -```scss -.custom-class { - .devui-toast-item-container { - color: #252b3a; - background-color: #ffffff; - - .devui-toast-icon-close { - top: 10px; - right: 13px; - - & i.icon { - color: #252b3a !important; - } - } - - .devui-toast-image { - top: 15px; - } - - .devui-toast-message { - line-height: 23px; - - .devui-toast-title { - font-size: 16px; - } - - p { - font-size: 14px; - } - } - } -} -``` - -```ts -import { defineComponent, ref } from 'vue' - -export default defineComponent({ - setup() { - const msgs = ref([]) - - function showToast() { - msgs.value = [ - { - severity: 'success', - summary: 'Success', - content: 'This is a test text. This is a test text. This is a test text.' - } - ] - } - - return { - msgs, - showToast - } - } -}) -``` - -### 每个消息使用单独的超时时间 - -当设置超时时间模式为 single 时,每个消息使用自身的 life 作为超时时间,如果未设置则按 severity 判断,severity 也未设置时默认超时时间为 5000 毫秒。 - -
    - - Single -
    - -```html -
    - - Single -
    -``` - -```ts -import { defineComponent, ref } from 'vue' - -export default defineComponent({ - setup() { - const msgs = ref([]) - - function showToast() { - msgs.value = [ - { life: 3000, summary: 'Summary', content: 'This is a test text. This is a test text. This is a test text.' }, - { - life: 6000, - severity: 'info', - summary: 'Summary', - content: 'This is a test text. This is a test text. This is a test text.' - }, - { - severity: 'success', - summary: 'Success', - content: 'This is a test text. This is a test text. This is a test text.' - }, - { severity: 'warn', summary: 'Warn', content: 'This is a test text. This is a test text. This is a test text.' } - ] - } - - return { - msgs, - showToast - } - } -}) -``` - -### 服务方式调用 - -使用服务的方式创建 toast 全局通知。 - -click me show simplest toast! -click me show customer toast! -click me close customer toast! -only close first customer toast! - -```html -click me show simplest toast! -click me show customer toast! -click me close customer toast! -only close first customer toast! -``` - -```ts -import { defineComponent, ref } from 'vue' -import { ToastService } from 'devui/toast' - -export default defineComponent({ - setup() { - const results = ref() - - function openToast2() { - results.value = ToastService.open({ - value: [ - { severity: 'info', summary: 'summary', content: '1. I am content' }, - { severity: 'error', summary: 'summary', content: '2. I am content' }, - { severity: 'error', summary: 'summary', content: '3. I am content' } - ], - sticky: true, - style: { width: '600px', color: 'red' }, - styleClass: 'myCustom-toast', - life: 5000, - lifeMode: 'global', - /* - 接收发射过来的数据 - */ - onCloseEvent(value: any) { - console.log('closeEvent', value) - }, - onValueChange(value: any) { - console.log('valueChange', value) - } - }) - - console.log('results', results.value) - - isShow.value = true - } - - function closeToast2() { - results.value.toastInstance.close() - isShow.value = false - } - - function closeToast3() { - /* - 1.可以根据指定下标关闭 results.value.toastInstance.close(0); - 2.可以根据value对象去关闭,作用跟1是等同的,如下所示: - */ - results.value.toastInstance.close({ severity: 'info', summary: 'summary', content: '1. I am content' }) - } - - return { - isShow, - openToast, - openToast2, - closeToast2, - closeToast3 - } - } -}) -``` - -### Toast Api - - - -### Toast Event - - - -### 接口 & 类型定义 - -Message - -```ts -export interface Message { - severity?: string // 预设值有 common、success、error、warn、info,超时时间参见 life 说明,未设置或非预设值时超时时间为 5000 毫秒,warn 和 error 为 10000 毫秒 - summary?: string // 消息标题。当设置超时时间,未设置标题时,不展示标题和关闭按钮 - detail?: string // 消息内容,推荐使用content替换 - content?: string | `slot:${string}` | (message: Message) => ReturnType // 消息内容,支持纯文本和插槽,推荐使用 - life?: number // 单个消息超时时间,需设置 lifeMode 为 single 。每个消息使用自己的超时时间,开启该模式却未设置时按 severity 判断超时时间 - id?: any // 消息ID -} -``` - -### Service 引入方式 - -```ts -import { ToastService } from 'devui' -``` - -### Service 使用 - -```ts -// 方式 1,局部引入 ToastService -ToastService.open({ xxx }) - -// 方式2,全局属性 -app.config.globalProperties.$toastService.open({ xxx }) -``` - -### Service Api - - - - - - diff --git a/packages/devui-vue/docs/en-US/components/transfer/index.md b/packages/devui-vue/docs/en-US/components/transfer/index.md deleted file mode 100644 index 988204fe..00000000 --- a/packages/devui-vue/docs/en-US/components/transfer/index.md +++ /dev/null @@ -1,224 +0,0 @@ -# Transfer 穿梭框 - -双栏穿梭选择框。 - -### 何时使用 - -需要在多个可选项中进行多选时。穿梭选择框可用只管的方式在两栏中移动数据,完成选择行为。其中左边一栏为source,右边一栏为target。最终返回两栏的数据,提供给开发者使用。 - -### 基本用法 - -穿梭框基本用法。 - -
    - - -
    - - - -```html - - -``` - -```ts -import {defineComponent, reactive} from 'vue' - type TData = { - id: number - age: number - value: string - disabled?: boolean - } - export default defineComponent({ - setup() { - const options = reactive({ - titles: ['sourceHeader', 'targetHeader'], - source: [ - { - key: '北京', - value: '北京', - disabled: false - }, - { - key: '上海', - value: '上海', - disabled: true - }, - { - key: '广州', - value: '广州', - disabled: false - }, - { - key: '深圳', - value: '深圳', - disabled: false - }, - { - key: '成都', - value: '成都', - disabled: false - }, - { - key: '武汉', - value: '武汉', - disabled: false - }, - { - key: '西安', - value: '西安', - disabled: false - }, - { - key: '福建', - value: '福建', - disabled: false - }, - { - key: '大连', - value: '大连', - disabled: false - }, - { - key: '重庆', - value: '重庆', - disabled: false - } - ], - target: [ - { - key: '南充', - value: '南充', - disabled: false - }, - { - key: '广元', - value: '广元', - disabled: true - }, - { - key: '绵阳', - value: '绵阳', - disabled: false - } - ], - isSearch: true, - modelValues: ['深圳', '成都', '绵阳'] - }) - return { - options - } - } - }) -``` - -### 参数 - -| **参数** | **类型** | **默认** | **说明** | **跳转 Demo** | -| ------------------ | ------------------------------------------------------------ | ------------------------- | ------------------------------------------------------------ | ---------------------------- | -| sourceOption | Array | [] | 可选参数,穿梭框源数据 | [基本用法](#基本用法) | -| targetOption | Array | [] | 可选参数,穿梭框目标数据 | [基本用法](#基本用法) | -| titles | Array | [] | 可选参数,穿梭框标题 | [基本用法](#基本用法) | -| height | string | 320px | 可选参数,穿梭框高度 | [基本用法](#基本用法) | -| isSearch | boolean | true | 可选参数,是否可以搜索 | [基本用法](#基本用法) | -| disabled | boolean | false | 可选参数 穿梭框禁止使用 | [基本用法](#基本用法) | diff --git a/packages/devui-vue/docs/en-US/components/upload/index.md b/packages/devui-vue/docs/en-US/components/upload/index.md deleted file mode 100644 index b2f8d8c2..00000000 --- a/packages/devui-vue/docs/en-US/components/upload/index.md +++ /dev/null @@ -1,1297 +0,0 @@ -# Upload - -File upload component。 - -### When to use - -When you need to upload files to the back-end server。 - -### Basic usage - -Single file upload, drag file upload, prohibit upload。 - -

    Basic Usage

    - -:::demo - -```vue - - -``` - -::: - -

    Dragdrop

    - -:::demo - -```vue - - -``` - -::: - -

    Disabled

    - -:::demo - -```vue - - -``` - -::: - -### Multiple file upload - -Multi-file upload, support drag file upload, prohibit upload。 - -

    Basic Usage

    - -:::demo - -```vue - - -``` - -::: - -

    Upload Directory

    - -:::demo - -```vue - - -``` - -::: - -

    Dragdrop

    - -:::demo - -```vue - - -``` - -::: - -

    Disabled

    - -:::demo - -```vue - - -``` - -::: - -### Auto upload - -Set up automatic upload via autoUpload。 - -:::demo - -```vue - - -``` - -::: - -### customize - -Customize the upload button, set the selected file list template through slot preloadFiles, and set the uploaded file list template through slot uploadedFiles。 - -:::demo - -```vue - - - -``` - -::: - -### Dynamic upload parameters - -Users can dynamically modify upload parameters through beforeUpload。 - -:::demo - -```vue - - -``` - -::: - -### Upload from any area - -Users can upload files in any area through the default slot。 -:::demo - -```vue - - -``` - -::: - -自定义默认 slot,初始显示已上传文件。 - -:::demo - -```vue - - - -``` - -::: - -### API - -d-single-upload 参数 - -| **参数** | **类型** | **默认** | 说明 | **跳转 Demo** | -| ---------------------- | --------------------------------- | ---------- | ---------------------------------------------------------------------------------------- | --------------------- | -| fileOptions | [IFileOptions](#ifileoptions) | -- | 必选,待上传文件配置 | [基本用法](#基本用法) | -| filePath | `string` | -- | 文件路径 | [基本用法](#基本用法) | -| uploadOptions | [IUploadOptions](#iuploadoptions) | \-- | 必选,上传配置 | [基本用法](#基本用法) | -| autoUpload | `boolean` | false | 可选,是否自动上传 | [基本用法](#基本用法) | -| placeholderText | `string` | '选择文件' | 可选,上传输入框中的 Placeholder 文字 | [基本用法](#基本用法) | -| uploadText | `string` | '上传' | 可选,上传按钮文字 | [基本用法](#基本用法) | -| uploadedFiles | `Array` | [] | 可选,获取已上传的文件列表 | [基本用法](#基本用法) | -| withoutBtn | `boolean` | false | 可选,是否舍弃按钮 | [基本用法](#基本用法) | -| enableDrop | `boolean` | false | 可选,是否支持拖拽 | [基本用法](#基本用法) | -| beforeUpload | `boolean Promise ` | \-- | 可选,上传前的回调,通过返回`true` or `false` ,控制文件是否上传,参数为文件信息及上传配置 | [基本用法](#基本用法) | -| dynamicUploadOptionsFn | [IUploadOptions](#iuploadoptions) | \-- | 为文件动态设置自定义的上传参数, 参数为当前选中文件及`uploadOptions`的值 | [基本用法](#基本用法) | -| disabled | `boolean` | false | 可选,是否禁用上传组件 | [基本用法](#基本用法) | -| showTip | `boolean` | false | 可选,是否显示上传提示信息 | [自动上传](#自动上传) | - -d-single-upload 事件 - -| 参数 | 类型 | 说明 | 跳转 Demo | -| ----------------------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | --------------------- | -| fileOver | `EventEmitter` | 支持拖拽上传时,文件移动到可拖放区域触发事件,可拖动的元素移出放置目标时返回`false`,元素正在拖动到放置目标时返回`true` | [基本用法](#基本用法) | -| fileDrop | `EventEmitter` | 支持拖拽上传时,当前拖拽的文件列表回调,单文件上传默认返回第一个文件 | [基本用法](#基本用法) | -| successEvent | `EventEmitter>` | 上传成功时的回调函数,返回文件及 xhr 的响应信息 | [基本用法](#基本用法) | -| errorEvent | `EventEmitter<{file: File; response: any}>` | 上传错误时的回调函数,返回上传失败的错误信息 | [基本用法](#基本用法) | -| deleteUploadedFileEvent | `EventEmitter` | 删除上传文件的回调函数,返回删除文件的路径信息 | [基本用法](#基本用法) | -| fileSelect | `EventEmitter` | 文件选择后的回调函数,返回已选择文件信息 | [基本用法](#基本用法) | - -d-multiple-upload 参数 - -| **参数** | **类型** | **默认** | 说明 | **跳转 Demo** | -| ---------------------- | --------------------------------- | -------------- | ---------------------------------------------------------------------------------------- | ------------------------- | -| fileOptions | [IFileOptions](#ifileoptions) | -- | 必选,待上传文件配置 | [多文件上传](#多文件上传) | -| filePath | `string` | -- | 文件路径 | [多文件上传](#多文件上传) | -| uploadOptions | [IUploadOptions](#iuploadoptions) | \-- | 必选,上传配置 | [多文件上传](#多文件上传) | -| autoUpload | `boolean` | false | 可选,是否自动上传 | [自动上传](#自动上传) | -| placeholderText | `string` | '选择多个文件' | 可选,上传输入框中的 Placeholder 文字 | [基本用法](#基本用法) | -| uploadText | `string` | '上传' | 可选,上传按钮文字 | [基本用法](#基本用法) | -| uploadedFiles | `Array` | [] | 可选,获取已上传的文件列表 | [多文件上传](#多文件上传) | -| withoutBtn | `boolean` | false | 可选,是否舍弃按钮 | [自定义](#自定义) | -| enableDrop | `boolean` | false | 可选,是否支持拖拽 | [多文件上传](#多文件上传) | -| beforeUpload | `boolean Promise` | \-- | 可选,上传前的回调,通过返回`true` or `false` ,控制文件是否上传,参数为文件信息及上传配置 | [多文件上传](#多文件上传) | -| dynamicUploadOptionsFn | [IUploadOptions](#iuploadoptions) | \-- | 为文件动态设置自定义的上传参数, 参数为当前选中文件及`uploadOptions`的值 | [多文件上传](#多文件上传) | -| disabled | `boolean` | false | 可选,是否禁用上传组件 | [多文件上传](#多文件上传) | -| showTip | `boolean` | false | 可选,是否显示上传提示信息 | [多文件上传](#多文件上传) | -| setCustomUploadOptions | [IUploadOptions](#iuploadoptions) | -- | 为每个文件设置自定义的上传参数, 参数为当前选中文件及`uploadOptions`的值 | [自定义](#自定义) | - -d-multiple-upload 事件 - -| 参数 | 类型 | 说明 | 跳转 Demo | -| ----------------------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------------------- | -| fileOver | `EventEmitter` | 支持拖拽上传时,文件移动到可拖放区域触发事件,可拖动的元素移出放置目标时返回`false`,元素正在拖动到放置目标时返回`true` | [多文件上传](#多文件上传) | -| fileDrop | `EventEmitter` | 支持拖拽上传时,当前拖拽的文件列表回调,单文件上传默认返回第一个文件 | [多文件上传](#多文件上传) | -| successEvent | `EventEmitter>` | 上传成功时的回调函数,返回文件及 xhr 的响应信息 | [多文件上传](#多文件上传) | -| errorEvent | `EventEmitter<{file: File; response: any}>` | 上传错误时的回调函数,返回上传失败的错误信息 | [多文件上传](#多文件上传) | -| deleteUploadedFileEvent | `EventEmitter` | 删除上传文件的回调函数,返回删除文件的路径信息 | [多文件上传](#多文件上传) | -| fileSelect | `EventEmitter` | 文件选择后的回调函数,返回已选择文件信息 | [多文件上传](#多文件上传) | - -### slot - -| name | 默认 | 说明 | 跳转 Demo | -| ------------- | ---- | ----------------------------------------------------------------------------- | ----------------- | -| preloadFiles | -- | 可选,用于创建自定义 已选择文件列表模板,参数为 `{fileUploaders, deleteFile}` | [自定义](#自定义) | -| uploadedFiles | -- | 可选,用于创建自定义 已上传文件列表模板,参数为 `{uploadedFiles, deleteFile}` | [自定义](#自定义) | - -### 接口 & 类型定义 - -### IUploadOptions - -```typescript -export class IUploadOptions { - // 上传接口地址 - uri: string - // http 请求方法 - method?: string - // 上传文件大小限制 - maximumSize?: number - // 自定义请求headers - headers?: { [key: string]: any } - // 认证token - authToken?: string - // 认证token header标示 - authTokenHeader?: string - // 上传额外自定义参数 - additionalParameter?: { [key: string]: any } - // 上传文件字段名称,默认file - fileFieldName?: string - // 多文件上传,是否检查文件重名,设置为true,重名文件不会覆盖,否则会覆盖上传 - checkSameName?: boolean - // 指示了是否该使用类似cookies,authorization headers(头部授权)或者TLS客户端证书这一类资格证书来创建一个跨站点访问控制(cross-site Access-Control)请求 - withCredentials?: boolean - // 手动设置返回数据类型 - responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' -} -``` - -### IFileOptions - -```typescript -export class IFileOptions { - // 规定能够通过文件上传进行提交的文件类型,例如 accept: '.xls,.xlsx,.pages,.mp3,.png' - accept?: string - // 输入字段可选择多个值 - multiple?: boolean - // 是否允许用户选择文件目录,而不是文件 - webkitdirectory?: boolean -} -``` diff --git a/packages/devui-vue/docs/en-US/design.md b/packages/devui-vue/docs/en-US/design.md deleted file mode 100644 index f936956a..00000000 --- a/packages/devui-vue/docs/en-US/design.md +++ /dev/null @@ -1 +0,0 @@ -# Design \ No newline at end of file diff --git a/packages/devui-vue/docs/en-US/theme.md b/packages/devui-vue/docs/en-US/theme.md deleted file mode 100644 index b29f0a86..00000000 --- a/packages/devui-vue/docs/en-US/theme.md +++ /dev/null @@ -1 +0,0 @@ -# Theme \ No newline at end of file diff --git a/packages/devui-vue/docs/en-US/version.md b/packages/devui-vue/docs/en-US/version.md deleted file mode 100644 index e04a043b..00000000 --- a/packages/devui-vue/docs/en-US/version.md +++ /dev/null @@ -1 +0,0 @@ -# Version \ No newline at end of file -- Gitee From cba50a2d852034113ecaa20f4da22c279e2d0b9a Mon Sep 17 00:00:00 2001 From: xiaojiujiu <3507440900@qq.com> Date: Tue, 9 Nov 2021 22:03:55 +0800 Subject: [PATCH 19/59] =?UTF-8?q?docs(tooltip:=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E6=96=87=E6=A1=A3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docs/en-US/components/tooltip/index.md | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/packages/devui-vue/docs/en-US/components/tooltip/index.md b/packages/devui-vue/docs/en-US/components/tooltip/index.md index 3faa69f2..aa45d39c 100644 --- a/packages/devui-vue/docs/en-US/components/tooltip/index.md +++ b/packages/devui-vue/docs/en-US/components/tooltip/index.md @@ -1,6 +1,9 @@ # Tooltip -Text prompt component。 +Import into module. +```ts +import { TooltipModule } from 'devui/tooltip'; +``` ### When to use @@ -10,27 +13,27 @@ The user moves the mouse to the text, and it is used when further prompts are ne :::demo We can control the display position of the tooltip by controlling the attribute `position`. There are 4 values for `position`, which are `top`, `right`, `bottom`, and `left`. Control the content of the tooltip prompt box through the attribute `content`。 - + - + - + - + ```vue ``` @@ -93,8 +96,8 @@ The mouse will be triggered after moving in for more than [mouseEnterDelay] mill | parameter | type | default | description | jump Demo | Global configuration items | | :---------: | :------: | :-------: | :----------------------- | --------------------------------- | --------- | -| content | `string|DOMString` | -- | Required, tooltip displays content | [基本用法](#基本用法) || -| position | `PositionType | PositionType[]` | ['top', 'right', 'bottom', 'left'] | Optional, tooltip display position | [基本用法](#基本用法) || +| content | `string|DOMString` | -- | Required, tooltip displays content | [Basic Usage](#demo#basic-usage) || +| position | `PositionType | PositionType[]` | ['top', 'right', 'bottom', 'left'] | Optional, tooltip display position | [Basic Usage](#demo#basic-usage) || | showAnimation | `boolean` | true | Optional, whether to show the wipe out animation | |✔| -| mouseEnterDelay | `number` | 150 | Optional, how long is the delay before the Tooltip is displayed after the mouse moves in, the unit is ms | [基本用法](#延时触发) || -| mouseLeaveDelay | `number` | 100 | Optional, after the mouse is moved out, how long is the delay before the Tooltip is hidden, the unit is ms | [基本用法](#延时触发) || +| mouseEnterDelay | `number` | 150 | Optional, how long is the delay before the Tooltip is displayed after the mouse moves in, the unit is ms | [Delay Trigger](#delay-trigger) || +| mouseLeaveDelay | `number` | 100 | Optional, after the mouse is moved out, how long is the delay before the Tooltip is hidden, the unit is ms | [Delay Trigger](#delay-trigger) || -- Gitee From 7b6cbd3ddfc058150cce6bb6e5ce2d229e66f6e3 Mon Sep 17 00:00:00 2001 From: xiaojiujiu <3507440900@qq.com> Date: Tue, 9 Nov 2021 23:32:08 +0800 Subject: [PATCH 20/59] =?UTF-8?q?docs(tooltip:=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E6=96=87=E4=BB=B6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docs/en-US/components/tooltip/index.md | 103 ------------------ 1 file changed, 103 deletions(-) delete mode 100644 packages/devui-vue/docs/en-US/components/tooltip/index.md diff --git a/packages/devui-vue/docs/en-US/components/tooltip/index.md b/packages/devui-vue/docs/en-US/components/tooltip/index.md deleted file mode 100644 index aa45d39c..00000000 --- a/packages/devui-vue/docs/en-US/components/tooltip/index.md +++ /dev/null @@ -1,103 +0,0 @@ -# Tooltip - -Import into module. -```ts -import { TooltipModule } from 'devui/tooltip'; -``` - -### When to use - -The user moves the mouse to the text, and it is used when further prompts are needed。 - -### Basic usage - -:::demo We can control the display position of the tooltip by controlling the attribute `position`. There are 4 values for `position`, which are `top`, `right`, `bottom`, and `left`. Control the content of the tooltip prompt box through the attribute `content`。 - - - - - - - - - -```vue - -``` - -```css -.example { - height: 50px; - width: 60px; - background: cornflowerblue; - margin-top: 30px; -} -``` -::: - -### Delay trigger - -The mouse will be triggered after moving in for more than [mouseEnterDelay] milliseconds to prevent flashing caused by the user accidentally swiping. The default value is 150 milliseconds; after the mouse is moved out, the toolTip component will be hidden after [mouseLeaveDelay] milliseconds. The default value Is 100 milliseconds。 - -:::demo Use the `mouseEnterDelay` property to control the `delay display` of the tooltip prompt box (the default is 100ms), and the `mouseLeaveDelay` property to control the `delay disappearing` of the tooltip prompt box (the default is 150ms) -
    MouseEnter delay 500ms
    - -
    MouseLeave delay 1000ms
    -```vue - -``` - -```css -.customCss { - width: fit-content; - height: 30px; - padding: 10px; - display: flex; - justify-content: center; - align-items: center; - color: #fff; - background: cornflowerblue; -} -.customCss-leave { - width: fit-content; - height: 30px; - padding: 10px; - display: flex; - justify-content: center; - align-items: center; - color: #252b3a; - background: #fff; -} -``` -::: - -### Tooltip Api - -| parameter | type | default | description | jump Demo | Global configuration items | -| :---------: | :------: | :-------: | :----------------------- | --------------------------------- | --------- | -| content | `string|DOMString` | -- | Required, tooltip displays content | [Basic Usage](#demo#basic-usage) || -| position | `PositionType | PositionType[]` | ['top', 'right', 'bottom', 'left'] | Optional, tooltip display position | [Basic Usage](#demo#basic-usage) || -| showAnimation | `boolean` | true | Optional, whether to show the wipe out animation | |✔| -| mouseEnterDelay | `number` | 150 | Optional, how long is the delay before the Tooltip is displayed after the mouse moves in, the unit is ms | [Delay Trigger](#delay-trigger) || -| mouseLeaveDelay | `number` | 100 | Optional, after the mouse is moved out, how long is the delay before the Tooltip is hidden, the unit is ms | [Delay Trigger](#delay-trigger) || -- Gitee From e2947575b91b79d05eae82c7f365e78ce27618db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=BF=9C=E6=88=90?= Date: Wed, 10 Nov 2021 08:22:25 +0800 Subject: [PATCH 21/59] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0innerListTempla?= =?UTF-8?q?te?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devui/accordion/src/accordion-list.tsx | 84 +++++++++------ .../devui/accordion/src/accordion.tsx | 100 +++++++++++++++++- .../docs/components/accordion/index.md | 9 +- 3 files changed, 150 insertions(+), 43 deletions(-) diff --git a/packages/devui-vue/devui/accordion/src/accordion-list.tsx b/packages/devui-vue/devui/accordion/src/accordion-list.tsx index 0213622b..3fba7abb 100644 --- a/packages/devui-vue/devui/accordion/src/accordion-list.tsx +++ b/packages/devui-vue/devui/accordion/src/accordion-list.tsx @@ -3,6 +3,7 @@ import type { AccordionMenuItem } from './accordion.type' import DAccordionMenu from './accordion-menu' import { accordionProps } from './accordion-types' + export default defineComponent({ name: 'DAccordionList', inheritAttrs: false, @@ -25,44 +26,59 @@ export default defineComponent({ innerListTemplate: Boolean, ...accordionProps, }, - setup(props, ctx) { - console.log('list', props) + setup(props, {attrs, slots}) { const { - childrenKey + childrenKey, + innerListTemplate, + deepth } = toRefs(props) return () => { - return (!props.innerListTemplate || props.deepth === 0) &&
      - {props.data.map(item => { - return
    • - {/* // TODO 菜单类型 d-accordion-menu */} - {childrenKey !== undefined && } - {/*
      -
      { item.title }
      - { - // TODO 子菜单 d-accordion-list + return ( + <> + { + !innerListTemplate.value && +
        + {props.data.map(item => { + return
      • + {/* // TODO 菜单类型 d-accordion-menu */} + {childrenKey !== undefined && } + {/*
        +
        { item.title }
        + { + // TODO 子菜单 d-accordion-list + } +
        +
          + { item.children?.map(component => { + return
        • + { + // TODO 路由链接 d-accordion-item-routerlink + } +
          + +
          + { component.title } + { component.done && 已完成 } +
          +
          +
        • + })} +
        +
        +
        */} +
      • } -
        -
          - { item.children?.map(component => { - return
        • - { - // TODO 路由链接 d-accordion-item-routerlink - } -
          - -
          - { component.title } - { component.done && 已完成 } -
          -
          -
        • - })} -
        -
        -
      */} -
    • - })} -
    + )} + + } + { + innerListTemplate.value && deepth.value !== 0 && +
    + {slots.default ? slots.innerListTemplate() : ''} +
    + } + + ) } } }) \ No newline at end of file diff --git a/packages/devui-vue/devui/accordion/src/accordion.tsx b/packages/devui-vue/devui/accordion/src/accordion.tsx index d46165a0..f3cb838a 100644 --- a/packages/devui-vue/devui/accordion/src/accordion.tsx +++ b/packages/devui-vue/devui/accordion/src/accordion.tsx @@ -1,14 +1,104 @@ -import { defineComponent, toRefs } from 'vue' +import { defineComponent, onBeforeUpdate, onMounted, ref, SetupContext, toRefs, watch } from 'vue' import AccordionList from './accordion-list' -import { accordionProps } from './accordion-types' +import { accordionProps, AccordionProps } from './accordion-types' +import { AccordionItemClickEvent, AccordionMenuItem, AccordionMenuToggleEvent } from './accordion.type' import './accordion.scss' export default defineComponent({ name: 'DAccordion', props: accordionProps, - setup(props) { - const { data, accordionType } = toRefs(props) - console.log(111, toRefs(props)) + setup(props: AccordionProps, { emit }) { + const { data, childrenKey, activeKey, openKey ,accordionType, autoOpenActiveMenu , restrictOneOpen} = toRefs(props) + + let clickActiveItem: AccordionMenuItem | undefined = undefined //记录用户点击的激活菜单项 + + const flatten = (arr: Array, childrenKey = 'children', includeParent = false, includeLeaf = true) => { + return arr.reduce((acc, cur) => { + const children = cur[childrenKey]; + if (children === undefined) { + if (includeLeaf) { + acc.push(cur); + } + } else { + if (includeParent) { + acc.push(cur); + } + if (Array.isArray(children)) { + acc.push(...flatten(children, childrenKey, includeParent)); + } + } + return acc; + }, []); + } + + const initActiveItem = () => { + const activeItem = flatten(data.value, childrenKey.value) + .filter(item => item[activeKey.value]).pop(); + if (activeItem) { + if (!clickActiveItem) { + activeItemFn(activeItem); + } + } else { + clickActiveItem = undefined; + } + } + + // 激活子菜单项并去掉其他子菜单的激活 + const activeItemFn = (item) => { + if (clickActiveItem && clickActiveItem[activeKey.value]) { + clickActiveItem[activeKey.value] = false; + } + item[activeKey.value] = true; + clickActiveItem = item; + emit('activeItemChange', clickActiveItem) + } + // 打开或关闭一级菜单,如果有限制只能展开一项则关闭其他一级菜单 + const openMenuFn = (item, open) => { + if (open && restrictOneOpen.value) { + data.value.forEach(itemtemp => { itemtemp[openKey.value] = false; }); + } + item[openKey.value] = open; + } + + // 点击了可点击菜单 + const itemClickFn = (itemEvent: AccordionItemClickEvent) => { + const prevActiveItem = clickActiveItem; + activeItemFn(itemEvent.item); + emit('itemClick', {...itemEvent, prevActiveItem: prevActiveItem}); + } + + const linkItemClickFn = (itemEvent: AccordionItemClickEvent) => { + const prevActiveItem = clickActiveItem; + clickActiveItem = itemEvent.item; + emit('itemClick', {...itemEvent, prevActiveItem: prevActiveItem}); + } + + // 打开或关闭可折叠菜单 + const menuToggleFn = (menuEvent: AccordionMenuToggleEvent) => { + openMenuFn(menuEvent.item, menuEvent.open); + emit('menuToggle', menuEvent); + } + + const cleanOpenData = () => { + flatten(data.value, childrenKey.value, true, false).forEach( + item => item[openKey.value] = undefined + ) + } + + + onMounted(() => { + if (data.value) { + initActiveItem(); + } + }) + + watch(() => autoOpenActiveMenu.value, (current, preV) => { + console.log('cur, new', current, preV) + if (current && preV === false) { + cleanOpenData(); + } + }) + return () => { return
    Only one level-1 menu can be expanded.
    -
    Embedded menu (no shadow)
    +
    Embedded menu (no shadow)
    ``` +::: + +### 多选 + +:::demo + +```vue + + +``` + +::: + +### 仅叶子节点可选 + +:::demo + +```vue + + +``` + ::: \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 713eb7e3..d36991f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2790,7 +2790,7 @@ "@vue/babel-plugin-jsx" "^1.0.7" hash-sum "^2.0.0" -"@vitejs/plugin-vue@^1.2.3", "@vitejs/plugin-vue@^1.3.0", "@vitejs/plugin-vue@^1.4.0": +"@vitejs/plugin-vue@^1.3.0", "@vitejs/plugin-vue@^1.4.0", "@vitejs/plugin-vue@^1.9.0": version "1.9.4" resolved "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-1.9.4.tgz#4f48485432cbb986a9fb9d254dc33ce30ddccbfa" integrity sha512-0CZqaCoChriPTTtGkERy1LGPcYjGFpi2uYRhBPIkqJqUGV5JnJFhQAgh6oH9j5XZHfrRaisX8W0xSpO4T7S78A== @@ -2887,7 +2887,7 @@ "@vue/compiler-core" "3.2.21" "@vue/shared" "3.2.21" -"@vue/compiler-sfc@3.2.21", "@vue/compiler-sfc@^3.0.11", "@vue/compiler-sfc@^3.0.5", "@vue/compiler-sfc@^3.1.1", "@vue/compiler-sfc@^3.2.1": +"@vue/compiler-sfc@3.2.21", "@vue/compiler-sfc@^3.0.11", "@vue/compiler-sfc@^3.0.5", "@vue/compiler-sfc@^3.2.1": version "3.2.21" resolved "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.2.21.tgz#42639ee49e725afb7d8f1d1940e75dc17a56002c" integrity sha512-+yDlUSebKpz/ovxM2vLRRx7w/gVfY767pOfYTgbIhAs+ogvIV2BsIt4fpxlThnlCNChJ+yE0ERUNoROv2kEGEQ== @@ -2951,7 +2951,7 @@ "@vue/shared" "3.2.21" csstype "^2.6.8" -"@vue/server-renderer@3.2.21", "@vue/server-renderer@^3.1.1", "@vue/server-renderer@^3.2.1": +"@vue/server-renderer@3.2.21", "@vue/server-renderer@^3.2.1": version "3.2.21" resolved "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.2.21.tgz#887d0a44de76f72313cff2686a24c0315231d634" integrity sha512-QBgYqVgI7XCSBCqGa4LduV9vpfQFdZBOodFmq5Txk5W/v1KrJ1LoOh2Q0RHiRgtoK/UR9uyvRVcYqOmwHkZNEg== @@ -5767,7 +5767,7 @@ inquirer@^7.3.3: strip-ansi "^6.0.0" through "^2.3.6" -inquirer@^8.1.2, inquirer@^8.2.0: +inquirer@^8.1.2: version "8.2.0" resolved "https://registry.npmjs.org/inquirer/-/inquirer-8.2.0.tgz#f44f008dd344bbfc4b30031f45d984e034a3ac3a" integrity sha512-0crLweprevJ02tTuA6ThpoAERAGyVILC4sS74uib58Xf/zSr1/ZWtmm7D5CI+bSQEaA04f0K7idaHpQbSWgiVQ== @@ -7770,7 +7770,7 @@ optionator@^0.9.1: type-check "^0.4.0" word-wrap "^1.2.3" -ora@*, ora@^6.0.1: +ora@*: version "6.0.1" resolved "https://registry.npmjs.org/ora/-/ora-6.0.1.tgz#68caa9fd6c485a40d6f46c50a3940fa3df99c7f3" integrity sha512-TDdKkKHdWE6jo/6pIa5U5AWcSVfpNRFJ8sdRJpioGNVPLAzZzHs/N+QhUfF7ZbyoC+rnDuNTKzeDJUbAza9g4g== @@ -8264,7 +8264,7 @@ pretty-format@^27.3.1: ansi-styles "^5.0.0" react-is "^17.0.1" -prismjs@^1.23.0: +prismjs@^1.23.0, prismjs@^1.25.0: version "1.25.0" resolved "https://registry.npmjs.org/prismjs/-/prismjs-1.25.0.tgz#6f822df1bdad965734b310b315a23315cf999756" integrity sha512-WCjJHl1KEWbnkQom1+SzftbtXMKQoezOCYs5rECqMN+jP+apI7ftoflyqigqzopSO3hMhTEb0mFClA8lkolgEg== @@ -10007,7 +10007,7 @@ vite-svg-loader@^2.2.0: "@vue/compiler-sfc" "^3.0.11" svgo "^2.3.0" -vite@^2.3.7, vite@^2.4.4: +vite@^2.4.4: version "2.6.13" resolved "https://registry.npmjs.org/vite/-/vite-2.6.13.tgz#16b3ec85a66d5b461ac29a903874d4357f9af432" integrity sha512-+tGZ1OxozRirTudl4M3N3UTNJOlxdVo/qBl2IlDEy/ZpTFcskp+k5ncNjayR3bRYTCbqSOFz2JWGN1UmuDMScA== @@ -10019,9 +10019,21 @@ vite@^2.3.7, vite@^2.4.4: optionalDependencies: fsevents "~2.3.2" -vitepress-theme-demoblock@^1.2.2: +vite@^2.6.5: + version "2.6.14" + resolved "https://registry.yarnpkg.com/vite/-/vite-2.6.14.tgz#35c09a15e4df823410819a2a239ab11efb186271" + integrity sha512-2HA9xGyi+EhY2MXo0+A2dRsqsAG3eFNEVIo12olkWhOmc8LfiM+eMdrXf+Ruje9gdXgvSqjLI9freec1RUM5EA== + dependencies: + esbuild "^0.13.2" + postcss "^8.3.8" + resolve "^1.20.0" + rollup "^2.57.0" + optionalDependencies: + fsevents "~2.3.2" + +vitepress-theme-demoblock@1.3.2: version "1.3.2" - resolved "https://registry.npmjs.org/vitepress-theme-demoblock/-/vitepress-theme-demoblock-1.3.2.tgz#d423818ee38041b33ecdf9738b3ad3cf4775e40b" + resolved "https://registry.yarnpkg.com/vitepress-theme-demoblock/-/vitepress-theme-demoblock-1.3.2.tgz#d423818ee38041b33ecdf9738b3ad3cf4775e40b" integrity sha512-uyzdb28sq2hSNzU4KeITNayWNPYUqvUWcahcqQZVvAoPlSr1tF9vGraRQWEhAFW//MII3tM/mncYLfICJfmISw== dependencies: camelcase "^6.2.0" @@ -10033,38 +10045,17 @@ vitepress-theme-demoblock@^1.2.2: vitepress "^0.16.1" yaml "^2.0.0-6" -vitepress@^0.15.6: - version "0.15.6" - resolved "https://registry.npmjs.org/vitepress/-/vitepress-0.15.6.tgz#b3d2487384f60deb5e0be7da1f1896c1db75025e" - integrity sha512-+knoqxT6V3DAAP6ojXmwsbplqjPvf256xFJfAJdzu4WArJSXGoserPIhtLK7fOFKPQrcb8S6H9RpIshY31/hLg== +vitepress@0.20.1: + version "0.20.1" + resolved "https://registry.yarnpkg.com/vitepress/-/vitepress-0.20.1.tgz#34d39950a5062a4efa5621be3a78c005f656faee" + integrity sha512-2SOlvRv0bvPrQ3RPtp7Fh/G1MKidrsgAgYz18OvV+nIJb9iiYo0GUVHKN3OYswMh+vH78NyTeA1Q5v4YJ/H9LQ== dependencies: "@docsearch/css" "^1.0.0-alpha.28" "@docsearch/js" "^1.0.0-alpha.28" - "@types/markdown-it" "^12.0.1" - "@vitejs/plugin-vue" "^1.2.3" - "@vue/compiler-sfc" "^3.1.1" - "@vue/server-renderer" "^3.1.1" - chalk "^4.1.1" - compression "^1.7.4" - debug "^4.3.2" - diacritics "^1.3.0" - escape-html "^1.0.3" - fs-extra "^10.0.0" - globby "^11.0.3" - gray-matter "^4.0.3" - lru-cache "^6.0.0" - markdown-it "^12.0.6" - markdown-it-anchor "^7.1.0" - markdown-it-container "^3.0.0" - markdown-it-emoji "^2.0.0" - markdown-it-table-of-contents "^0.5.2" - minimist "^1.2.5" - ora "^5.4.0" - polka "^0.5.2" - prismjs "^1.23.0" - sirv "^1.0.12" - vite "^2.3.7" - vue "^3.1.1" + "@vitejs/plugin-vue" "^1.9.0" + prismjs "^1.25.0" + vite "^2.6.5" + vue "^3.2.19" vitepress@^0.16.1: version "0.16.1" @@ -10265,7 +10256,7 @@ vue-tsc@^0.2.2: dependencies: vscode-vue-languageservice "^0.27.0" -vue@^3.1.1, vue@^3.2.1: +vue@^3.1.1, vue@^3.2.1, vue@^3.2.19: version "3.2.21" resolved "https://registry.npmjs.org/vue/-/vue-3.2.21.tgz#55f5665172d95cf97e806b9aad0a375180be23a1" integrity sha512-jpy7ckXdyclfRzqLjL4mtq81AkzQleE54KjZsJg/9OorNVurAxdlU5XpD49GpjKdnftuffKUvx2C5jDOrgc/zg== -- Gitee From f83e4d5496c701fc3f5e3159d14d5dd7ccc0c7f3 Mon Sep 17 00:00:00 2001 From: lzm <254311563@qq.com> Date: Sun, 14 Nov 2021 14:25:41 +0800 Subject: [PATCH 28/59] =?UTF-8?q?docs:=20=E6=96=B0=E5=A2=9Eapi=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tree-select/__tests__/tree-select.spec.ts | 57 +++++++++++++++++++ .../docs/components/tree-select/index.md | 40 ++++++++++++- 2 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 packages/devui-vue/devui/tree-select/__tests__/tree-select.spec.ts diff --git a/packages/devui-vue/devui/tree-select/__tests__/tree-select.spec.ts b/packages/devui-vue/devui/tree-select/__tests__/tree-select.spec.ts new file mode 100644 index 00000000..f35fcbe2 --- /dev/null +++ b/packages/devui-vue/devui/tree-select/__tests__/tree-select.spec.ts @@ -0,0 +1,57 @@ +import { mount } from '@vue/test-utils'; +import { ref } from 'vue'; +import DTreeSelect from '../src/tree-select'; + +describe('tree-select', () => { + + it('tree-select should render correctly', async () => { + const value = ref(''); + const data = ref([{ + label: '一级 1', + children: [{ + label: '二级 1-1', + children: [{ + label: '三级 1-1-1', + }] + }] + }, { + label: '一级 2', + children: [{ + label: '二级 2-1', + children: [{ + label: '三级 2-1-1', + }] + }, { + label: '二级 2-2', + children: [{ + label: '三级 2-2-1', + }] + }] + }, { + label: '一级 3', + children: [{ + label: '二级 3-1', + children: [{ + label: '三级 3-1-1', + }] + }, { + label: '二级 3-2', + children: [{ + label: '三级 3-2-1', + }] + }] + }]); + const wrapper = mount({ + components: { DTreeSelect }, + template: ``, + setup() { + return { + value, + data, + }; + }, + }); + + expect(wrapper.classes()).toContain('devui-tree-select'); + }); +}) \ No newline at end of file diff --git a/packages/devui-vue/docs/components/tree-select/index.md b/packages/devui-vue/docs/components/tree-select/index.md index 4e623ddd..97f4017f 100644 --- a/packages/devui-vue/docs/components/tree-select/index.md +++ b/packages/devui-vue/docs/components/tree-select/index.md @@ -8,7 +8,7 @@ ```vue ``` -::: \ No newline at end of file +::: + +### API + +d-select-tree 参数 + +| 参数 | 类型 | 默认 | 说明 | 跳转 | +| ------------ | ------- | ----- | ------------------------------------------------------------------- | ------------------------------------ | +| treeData | TreeData | | 必选,树形选择框的内容 | [基本用法](#基本用法) | +| placeholder | string | '请选择'| 可选,修改输入框的默认显示内容 | [基本用法](#基本用法) | +| disabled | boolean | false | 可选,值为 true 时禁止用户使用 | [禁用](#禁用) | +| allowClear | boolean | false | 可选,值为 true 时可以清空输入框内容 | [可清空](#可清空) | +| multiple | boolean | false | 可选,值为 true 时可选择多个项 | [多选](#多选) | +| leafOnly | boolean | false | 可选,值为 true 时仅可选择叶子节点 | [仅叶子节点可选](#仅叶子节点可选) | + + +### 接口 & 类型定义 + + +```ts +interface TreeItem { + id: number | string + label: string + parent?: TreeItem + children?: Array + level?: number + loading?: boolean + opened?: boolean + checked?: boolean + halfchecked?: boolean + disabled?: boolean + + [prop: string]: any +} + +type TreeData = Array +``` \ No newline at end of file -- Gitee From cd45d5c5dfb7ce7459335db6f98882aea9081747 Mon Sep 17 00:00:00 2001 From: zcating Date: Mon, 15 Nov 2021 14:59:12 +0800 Subject: [PATCH 29/59] =?UTF-8?q?fix(dropdown):=20=E4=BF=AE=E6=94=B9=20clo?= =?UTF-8?q?seOnMouseLeaveMenu=20=E9=BB=98=E8=AE=A4=E5=80=BC=E4=B8=BA=20fal?= =?UTF-8?q?se?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/devui-vue/devui/dropdown/src/dropdown-types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/devui-vue/devui/dropdown/src/dropdown-types.ts b/packages/devui-vue/devui/dropdown/src/dropdown-types.ts index 731d39c9..706048df 100644 --- a/packages/devui-vue/devui/dropdown/src/dropdown-types.ts +++ b/packages/devui-vue/devui/dropdown/src/dropdown-types.ts @@ -30,7 +30,7 @@ export const dropdownProps = { closeOnMouseLeaveMenu: { type: Boolean, - default: true + default: false }, showAnimation: { -- Gitee From b5f139a1d601e6342d7cc44cc970d6c51d56eb94 Mon Sep 17 00:00:00 2001 From: chenxi_24 Date: Mon, 15 Nov 2021 18:10:21 +0800 Subject: [PATCH 30/59] =?UTF-8?q?feat=20:=20=E5=A2=9E=E5=8A=A0=E6=87=92?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=AE=8C=E5=96=84=E7=BB=84=E4=BB=B6=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/editable-select-types.ts | 4 + .../editable-select/src/editable-select.tsx | 156 ++++++----- .../docs/components/editable-select/index.md | 250 ++++++++++++------ yarn.lock | 71 +++-- 4 files changed, 293 insertions(+), 188 deletions(-) diff --git a/packages/devui-vue/devui/editable-select/src/editable-select-types.ts b/packages/devui-vue/devui/editable-select/src/editable-select-types.ts index 4da86666..ee9cb2fd 100644 --- a/packages/devui-vue/devui/editable-select/src/editable-select-types.ts +++ b/packages/devui-vue/devui/editable-select/src/editable-select-types.ts @@ -35,6 +35,10 @@ export const editableSelectProps = { loading: { type: Boolean }, + enableLazyLoad: { + type: Boolean, + default: false + }, remoteMethod: { type: Function as PropType<(inputValue: string) => Array> }, diff --git a/packages/devui-vue/devui/editable-select/src/editable-select.tsx b/packages/devui-vue/devui/editable-select/src/editable-select.tsx index 671e6eb9..c6f095bc 100644 --- a/packages/devui-vue/devui/editable-select/src/editable-select.tsx +++ b/packages/devui-vue/devui/editable-select/src/editable-select.tsx @@ -1,58 +1,43 @@ -import { defineComponent, ref, renderSlot, computed, Transition } from "vue" -import { - OptionItem, - editableSelectProps, - EditableSelectProps, -} from "./editable-select-types" -import "./editable-select.scss" -import { Icon } from "../../icon" -import ClickOutside from "../../shared/devui-directive/clickoutside" -import { className } from "./utils" -import { debounce } from "lodash" +import { defineComponent, ref, renderSlot, computed, Transition, watch } from 'vue' +import { OptionItem, editableSelectProps, EditableSelectProps } from './editable-select-types' +import './editable-select.scss' +import { Icon } from '../../icon' +import ClickOutside from '../../shared/devui-directive/clickoutside' +import { className } from './utils' +import { debounce } from 'lodash' export default defineComponent({ - name: "DEditableSelect", + name: 'DEditableSelect', directives: { ClickOutside }, props: editableSelectProps, - emits: ["update:modelValue"], + emits: ['update:modelValue'], setup(props: EditableSelectProps, ctx) { - const inputCls = className( - "devui-form-control devui-dropdown-origin devui-dropdown-origin-open", - { - disabled: props.disabled, - } - ) - - const getLiCls = (item) => { - const { disabledKey } = props - return className("devui-dropdown-item", { - disabled: disabledKey ? !!item[disabledKey] : false, - }) - } - + const dropdownRef = ref(null) const visible = ref(false) - const inputValue = ref("") + const inputValue = ref('') + const activeIndex = ref(0) const query = ref(props.modelValue) const wait = computed(() => (props.remote ? 300 : 0)) const emptyText = computed(() => { const options = filteredOptions.value - if (!props.remote && inputValue.value && options.length === 0) { - return "没有相关记录" + if (!props.remote && options.length === 0) { + return '没有相关记录' } if (options.length === 0) { - return "没有数据" + return '没有数据' } return null }) + const normalizeOptions = computed(() => { let options: OptionItem const { disabledKey } = props - disabledKey ? disabledKey : "disabled" + disabledKey ? disabledKey : 'disabled' return props.options.map((item) => { - if (typeof item !== "object") { + if (typeof item !== 'object') { options = { - name: item, + name: item } return options } @@ -61,9 +46,11 @@ export default defineComponent({ }) const filteredOptions = computed(() => { - const isValidOption = (o: OptionItem): boolean => { + const isValidOption = (o: OptionItem) => { const query = inputValue.value - const containsQueryString = query ? o.name.includes(query) : true + const containsQueryString = query + ? o.name.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) >= 0 + : true return containsQueryString } return normalizeOptions.value @@ -76,6 +63,12 @@ export default defineComponent({ .filter((item) => item !== null) }) + const findIndex = (o) => { + return normalizeOptions.value.findIndex((item) => { + return item.name === o.name + }) + } + const handleClose = () => { visible.value = false } @@ -84,11 +77,12 @@ export default defineComponent({ visible.value = !visible.value } } - const onInputChange = () => { + + const onInputChange = (val: string) => { if (props.filterMethod) { - props.filterMethod(inputValue.value) + props.filterMethod(val) } else if (props.remote) { - props.remoteMethod(inputValue.value) + props.remoteMethod(val) } } @@ -99,65 +93,83 @@ export default defineComponent({ inputValue.value = value query.value = value if (props.remote) { - debouncedOnInputChange() + debouncedOnInputChange(value) } else { - onInputChange() + onInputChange(value) } } + const selectOptionClick = (e, item) => { const { disabledKey } = props if (disabledKey && item[disabledKey]) { e.stopPropagation() } else { query.value = item.name - ctx.emit("update:modelValue", item.name) + activeIndex.value = findIndex(item) + inputValue.value = '' + ctx.emit('update:modelValue', item.name) } } + + const loadMore = () => { + if (!props.enableLazyLoad) return + const dropdownVal = dropdownRef.value + if (dropdownVal.clientHeight + dropdownVal.scrollTop >= dropdownVal.scrollHeight) { + props.remoteMethod(inputValue.value) + } + } + return () => { + const selectCls = className('devui-form-group devui-has-feedback', { + 'devui-select-open': visible.value + }) + const inputCls = className( + 'devui-form-control devui-dropdown-origin devui-dropdown-origin-open', + { + disabled: props.disabled + } + ) + + const getLiCls = (item, index) => { + const { disabledKey } = props + return className('devui-dropdown-item', { + disabled: disabledKey ? !!item[disabledKey] : false, + selected: activeIndex.value === index + }) + } + return ( -
    - -