Skip to content

Commit d4dee94

Browse files
committed
Merge branch '2.x'
2 parents 07d2e06 + a769803 commit d4dee94

File tree

33 files changed

+424
-81
lines changed

33 files changed

+424
-81
lines changed

docs/src/assets/css/index.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@
5454
#nprogress .spinner-icon {
5555
border-top-color: var(--global-primary-color);
5656
}
57+
58+
.layui-space {
59+
flex-wrap: wrap;
60+
}

docs/src/document/zh-CN/components/dropdown.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ export default {
529529
| alignPoint |跟随鼠标|`boolean`|`false`|`true` `false`|
530530
| contentClass| 弹出内容的类名 | `string`| -| -|
531531
| contentStyle| 弹出内容的样式 | `string` | - | -|
532-
| teleportProps | 继承至 dropdown 组件,下拉面板 `传递` 属性 | `object` | `{to: 'body', disabled: false}` | `vue teleport` 组件 | `2.19.0` |
532+
| teleportProps | 下拉面板 `传递` 属性 | `object` | `{to: 'body', disabled: false}` | `vue teleport` 组件 | `2.19.0` |
533533

534534
:::
535535

docs/src/document/zh-CN/components/popconfirm.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ const cancel = () => {
142142
| position | 显示位置 | `top`(默认值)、`bottom``left``right` |
143143
| disabled | 是否禁用 | `false`(默认值)、`true`(禁用) |
144144
| trigger | 触发方式 | `click` `hover`(默认值) `contextmenu` `focus` `trigger[]`|
145+
| teleportProps | 继承至 `tooltip` 组件 下拉面板 `传递` 属性 | `object` | `{to: 'body', disabled: false}` | `vue teleport` 组件 | `2.19.3` |
146+
145147

146148
:::
147149

@@ -158,4 +160,4 @@ const cancel = () => {
158160
:::
159161

160162
::: previousNext tooltip
161-
:::
163+
:::

docs/src/document/zh-CN/components/timeSelect.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,30 @@ const time5 = ref();
278278

279279
::: table
280280

281-
| 属性名 | 类型 | 默认值 | 说明 |
282-
| :-------------- | :-------------- | :----------- | :-------------------------------------------------------------------------- |
283-
| _modelValue_ | `string` | - | 绑定的值 |
284-
| _inputFormat_ | `string` | `'H:i'` | 输入框时间格式 |
285-
| _interval_ | `string` | `'00:30:00'` | 时间间隔 |
286-
| _start_ | `string` | `'00:00:00'` | 开始时间 |
287-
| _end_ | `string` | `'00:00:00'` | 结束时间,如果时分秒加起来等于 0,则会生成到第二天 |
288-
| _withStartTime_ | `boolean` | `true` | 是否显示开始时间 |
289-
| _withEndTime_ | `boolean` | `true` | 是否显示结束时间 |
290-
| _format_ | `string` | `'H:i'` | 绑定值的格式 |
291-
| _skip_ | `Array<string>` | `[]` | 跳过的值,例如:`['00:00', '30:00']`,需要与绑定值的格式 _valueFormat_ 匹配 |
281+
| 属性名 | 类型 | 默认值 | 说明 |
282+
| :--------------------------------------------------------------------------------------------------------------------------------------- | :-------------- | :----------- | :-------------------------------------------------------------------------- |
283+
| _modelValue_ | `string` | - | 绑定的值 |
284+
| _inputFormat_ | `string` | `'H:i'` | 输入框时间格式 |
285+
| _interval_ | `string` | `'00:30:00'` | 时间间隔 |
286+
| _start_ | `string` | `'00:00:00'` | 开始时间 |
287+
| _end_ | `string` | `'00:00:00'` | 结束时间,如果时分秒加起来等于 0,则会生成到第二天 |
288+
| _withStartTime_ | `boolean` | `true` | 是否显示开始时间 |
289+
| _withEndTime_ | `boolean` | `true` | 是否显示结束时间 |
290+
| _format_ | `string` | `'H:i'` | 绑定值的格式 |
291+
| _skip_ | `Array<string>` | `[]` | 跳过的值,例如:`['00:00', '30:00']`,需要与绑定值的格式 _valueFormat_ 匹配 |
292+
| 支持所有 select 中的 props 属性<br>[selectProps 快捷查看](https://www.layui-vue.com/zh-CN/components/select#Select%20%E5%B1%9E%E6%80%A7) |
293+
294+
:::
295+
296+
::: title 事件
297+
:::
298+
299+
::: table
300+
301+
| 属性 | 描述 | 接收值 |
302+
| -------- | -------- | ------ |
303+
| _change_ | 选择事件 | value |
304+
| _clear_ | 清空事件 | - |
292305

293306
:::
294307

docs/src/document/zh-CN/components/tooltip.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ const changeText = () => {
397397
| trigger | 触发方式 | `string` | `hover` | `click` `hover` `contextmenu` `focus` | - |
398398
| popper-class | tooltip内容box类名 | `string` `array` | | | `2.17.7类型删除object` |
399399
| popper-style | tooltip内容box类名 | `string` `object` | | | |
400+
| teleportProps | 下拉面板 `传递` 属性 | `object` | `{to: 'body', disabled: false}` | `vue teleport` 组件 | `2.19.3` |
400401

401402
:::
402403

packages/component/component/cascader/__tests__/cascader.test.tsx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { mount } from "@vue/test-utils";
44

55
import LayCascader from "../index.vue";
66
import LayDropdown from "../../dropdown/index.vue";
7+
import LayTagInput from "../../tagInput/index.vue";
78
import { sleep } from "../../../test-utils";
89

910
describe("LayCascader", () => {
@@ -126,4 +127,62 @@ describe("LayCascader", () => {
126127
await sleep();
127128
expect((dropdown.vm as any).open).toBe(false);
128129
});
130+
131+
test("multiple tag-input 初始化tag", async () => {
132+
const wrapper = mount({
133+
setup() {
134+
const modelValue: Ref<string | string[]> = ref(["1", "2"]);
135+
const options = [
136+
{
137+
label: "label1",
138+
value: "1",
139+
},
140+
{ label: "label2", value: "2" },
141+
{ label: "label3", value: "3" },
142+
];
143+
144+
return () => (
145+
<LayCascader
146+
multiple={true}
147+
options={options}
148+
modelValue={modelValue.value}
149+
></LayCascader>
150+
);
151+
},
152+
});
153+
154+
await nextTick();
155+
const tagInputInstance = wrapper.findComponent(LayTagInput);
156+
const tags = tagInputInstance.findAll(".layui-tag");
157+
158+
expect(tags.length).toBe(2);
159+
expect(tags[0].text()).toBe("label1");
160+
expect(tags[1].text()).toBe("label2");
161+
});
162+
163+
test("options 数据源通过push方法改变未刷新", async () => {
164+
const wrapper = mount({
165+
setup() {
166+
const options = ref<any>([]);
167+
168+
onMounted(() => {
169+
options.value.push(
170+
...[
171+
{ label: "label1", value: "1" },
172+
{ label: "label2", value: "2" },
173+
{ label: "label3", value: "3" },
174+
]
175+
);
176+
});
177+
178+
return () => <LayCascader options={options.value}></LayCascader>;
179+
},
180+
});
181+
182+
const component = wrapper.getComponent(LayCascader);
183+
184+
await nextTick();
185+
186+
expect((component.vm as any)._context.flatData.value.length).toBe(3);
187+
});
129188
});

packages/component/component/cascaderPanel/index.hook.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ export default function useCascaderPanel(
210210
() => props.options,
211211
() => {
212212
originData.value = sanitizer(props.options ?? [], undefined);
213-
}
213+
},
214+
{ deep: true }
214215
);
215216

216217
watch(
@@ -390,6 +391,8 @@ export default function useCascaderPanel(
390391
return [addDiff, removeDiff];
391392
};
392393

394+
onMounted(() => setup());
395+
393396
return {
394397
dataSource,
395398
sanitizer,

packages/component/component/cascaderPanel/index.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,9 @@ const {
158158
changeOnSelect,
159159
buildMultipleStatus,
160160
modelValue,
161-
setup,
162161
} =
163162
((inject(CASCADER_CONTEXT_KEY) as tCascaderPanel) || null) ??
164163
useCascaderPanel(props);
165-
onMounted(() => setup());
166164
/**
167165
* 插槽
168166
*/

packages/component/component/datePicker/__tests__/datePicker-range.test.tsx

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { mount } from "@vue/test-utils";
22
import { afterEach, describe, expect, test } from "vitest";
33
import { sleep } from "../../../test-utils";
44

5+
import LayDropdown from "../../dropdown/index.vue";
56
import LayDatePicker from "../index.vue";
67
import DateRangeComponent from "../component/DateRange.vue";
7-
import DateComponent from "../component/common/Date.vue";
8-
import Year from "../component/common/Year.vue";
9-
import Footer from "../component/common/Footer.vue";
8+
import Shortcuts from "../component/common/Shortcuts.vue";
9+
// import DateComponent from "../component/common/Date.vue";
10+
// import Year from "../component/common/Year.vue";
11+
// import Footer from "../component/common/Footer.vue";
1012
// import Month from "../component/common/Month.vue";
1113
import { nextTick } from "vue";
1214
import { dayjsToString } from "../util";
@@ -52,4 +54,36 @@ describe("LayDatePicker date type", () => {
5254
expect(parseInt(rightYear.text())).toBe(2024);
5355
expect(parseInt(rightMonth.text())).toBe(11);
5456
});
57+
58+
test("simple模式 点击快捷选项下拉关闭", async () => {
59+
const shortcuts = [
60+
{
61+
text: "两年",
62+
value: ["2024", "2025"],
63+
},
64+
];
65+
66+
const wrapper = mount(LayDatePicker, {
67+
props: {
68+
range: true,
69+
simple: true,
70+
modelValue: [],
71+
shortcuts,
72+
},
73+
});
74+
75+
await mockInputClick(wrapper);
76+
77+
const dropdownInstance1 = wrapper.findComponent(LayDropdown);
78+
expect((dropdownInstance1.vm as any).open).toBeTruthy();
79+
80+
const shortcut = wrapper.findComponent(Shortcuts);
81+
const lis = shortcut.findAll("li");
82+
expect(lis.length).toBe(1);
83+
84+
await (lis[0] as any).trigger("click");
85+
await sleep();
86+
const dropdownInstance2 = wrapper.findComponent(LayDropdown);
87+
expect((dropdownInstance2.vm as any).open).toBeFalsy();
88+
});
5589
});

packages/component/component/datePicker/component/DateRange.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ const handleChangeShortcut = (shortcuts: ShortcutsType) => {
258258
rightDate.value = shortcutsValues[1];
259259
startDate.value = shortcutsValues[0];
260260
endDate.value = shortcutsValues[1];
261+
262+
if (props.simple) handleConfirm();
261263
};
262264
263265
const handleConfirm = () => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy