kui-vue 3.6.0 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{readme.md → README.md} +4 -10
- package/components/button/demo/group.md +1 -1
- package/components/button/demo/size.md +1 -1
- package/components/card/card.jsx +1 -1
- package/components/checkbox/checkbox.jsx +17 -16
- package/components/checkbox/checkboxGroup.jsx +5 -5
- package/components/checkbox/demo/group.md +17 -6
- package/components/checkbox/styles/index.less +4 -11
- package/components/collapse/collapse.jsx +9 -10
- package/components/collapse/demo/accordion.md +2 -2
- package/components/collapse/demo/basic.md +2 -2
- package/components/collapse/demo/extra.md +2 -2
- package/components/collapse/demo/nesting.md +4 -4
- package/components/collapse/demo/sample.md +2 -2
- package/components/collapse/index.md +6 -6
- package/components/colorPicker/colorpicker.jsx +5 -6
- package/components/colorPicker/demo/basic.md +14 -2
- package/components/colorPicker/demo/customTrigger.md +2 -2
- package/components/colorPicker/demo/index.jsx +0 -8
- package/components/colorPicker/demo/size.md +24 -10
- package/components/datePicker/datepicker.jsx +19 -11
- package/components/datePicker/demo/basic.md +15 -6
- package/components/datePicker/demo/lang.md +2 -2
- package/components/datePicker/demo/size.md +1 -1
- package/components/drawer/drawer.jsx +2 -2
- package/components/dropdown/dropdown.jsx +9 -40
- package/components/dropdown/dropdownButton.jsx +18 -7
- package/components/empty/demo/basic.md +1 -3
- package/components/empty/demo/nodesc.md +1 -3
- package/components/empty/demo/used.md +4 -6
- package/components/empty/empty.jsx +19 -17
- package/components/empty/styles/index.less +18 -5
- package/components/form/demo/align.md +10 -10
- package/components/form/demo/valid.md +3 -2
- package/components/form/form.jsx +1 -1
- package/components/form/formitem.jsx +1 -1
- package/components/image/image.jsx +1 -0
- package/components/image/preview.jsx +1 -1
- package/components/input/demo/basic.md +1 -1
- package/components/input/demo/group.md +1 -1
- package/components/input/index.md +1 -1
- package/components/input/input.jsx +7 -5
- package/components/input/inputBox.jsx +2 -2
- package/components/inputNumber/demo/basic.md +12 -5
- package/components/inputNumber/demo/format.md +0 -5
- package/components/inputNumber/index.md +1 -1
- package/components/inputNumber/inputNumber.jsx +3 -5
- package/components/inputNumber/styles/index.less +64 -64
- package/components/menu/submenu.jsx +5 -5
- package/components/message/demo/close.md +1 -1
- package/components/message/group.jsx +2 -2
- package/components/message/index.md +1 -1
- package/components/message/inner.jsx +26 -7
- package/components/notice/demo/close.md +1 -1
- package/components/notice/index.md +1 -1
- package/components/page/page.jsx +0 -1
- package/components/page/styles/index.less +7 -1
- package/components/popconfirm/popconfirm.jsx +18 -20
- package/components/poptip/poptip.jsx +4 -4
- package/components/progress/progress.jsx +1 -1
- package/components/radio/demo/group.md +16 -6
- package/components/radio/demo/radioButton.md +3 -8
- package/components/radio/radio.jsx +14 -11
- package/components/radio/radioButton.jsx +1 -1
- package/components/radio/radioGroup.jsx +9 -12
- package/components/radio/styles/index.less +10 -21
- package/components/rate/demo/basic.md +12 -2
- package/components/rate/demo/character.md +16 -2
- package/components/rate/demo/index.jsx +0 -8
- package/components/rate/demo/tips.md +15 -5
- package/components/rate/rate.jsx +24 -5
- package/components/select/demo/basic.md +16 -7
- package/components/select/demo/filterable.md +4 -2
- package/components/select/demo/size.md +1 -1
- package/components/select/index.md +23 -22
- package/components/select/option.jsx +7 -3
- package/components/select/select.jsx +43 -37
- package/components/select/styles/index.less +1 -0
- package/components/slider/demo/basic.md +2 -1
- package/components/slider/demo/withNumber.md +3 -3
- package/components/slider/slider.jsx +0 -25
- package/components/space/styles/index.less +5 -1
- package/components/spin/index.md +6 -5
- package/components/styles/sys.less +3 -0
- package/components/switch/switch.jsx +13 -5
- package/components/table/demo/size.md +1 -1
- package/components/table/styles/index.less +10 -5
- package/components/table/table.jsx +98 -69
- package/components/tabs/tabs.jsx +1 -1
- package/components/tooltip/tooltip.jsx +16 -11
- package/components/treeselect/demo/basic.md +11 -8
- package/components/treeselect/demo/size.md +6 -5
- package/components/treeselect/demo/theme.md +0 -1
- package/components/treeselect/treeselect.jsx +15 -20
- package/components/upload/upload.jsx +0 -1
- package/components/utils/placement.js +162 -124
- package/dist/k-ui.cjs.js +2 -2
- package/dist/k-ui.css +2 -2
- package/dist/k-ui.d.ts +131 -127
- package/dist/k-ui.esm.js +2 -2
- package/dist/k-ui.umd.js +2 -2
- package/dist/locale/de.js +1 -1
- package/dist/locale/el.js +1 -1
- package/dist/locale/en.js +1 -1
- package/dist/locale/fr.js +1 -1
- package/dist/locale/it.js +1 -1
- package/dist/locale/ja.js +1 -1
- package/dist/locale/ko.js +1 -1
- package/dist/locale/ru.js +1 -1
- package/dist/locale/th.js +1 -1
- package/dist/locale/ua.js +2 -2
- package/dist/locale/uk.js +1 -1
- package/dist/locale/vi.js +1 -1
- package/dist/locale/zh-CN.js +1 -1
- package/dist/locale/zh-TW.js +1 -1
- package/package.json +5 -5
- package/test/i18n@8.x.html +6 -2
- package/types/checkbox/Checkbox.d.ts +1 -1
- package/types/collapse/Collapse.d.ts +1 -1
- package/types/image/KImage.d.ts +1 -0
- package/types/index.d.ts +12 -12
- package/types/popconfirm/Popconfirm.d.ts +1 -0
- package/types/radio/Radio.d.ts +1 -1
- package/types/radio/RadioButton.d.ts +1 -1
- package/types/switch/Switch.d.ts +2 -1
- package/types/tooltip/Tooltip.d.ts +1 -0
- package/components/base/collapse.jsx +0 -15
- package/components/base/input.jsx +0 -210
- package/components/colorPicker/demo/disabled.md +0 -16
- package/components/colorPicker/demo/disabledAlpha.md +0 -13
- package/components/colorPicker/demo/mode.md +0 -24
- package/components/colorPicker/demo/presets.md +0 -17
- package/components/rate/demo/clear.md +0 -13
- package/components/rate/demo/custom.md +0 -23
- package/components/rate/demo/disabled.md +0 -12
- package/components/rate/demo/half.md +0 -12
- package/components/steps/index.js +0 -4
- package/components/steps/step.vue +0 -82
- package/components/steps/steps.vue +0 -68
- package/components/steps/styles/index.less +0 -198
- package/components/utils/element.js +0 -122
package/{readme.md → README.md}
RENAMED
|
@@ -70,16 +70,10 @@ Using a script tag for global use:
|
|
|
70
70
|
<Button type="primary" @click="test">Primary</Button>
|
|
71
71
|
</div>
|
|
72
72
|
</template>
|
|
73
|
-
<script>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
methods: {
|
|
79
|
-
test() {
|
|
80
|
-
this.$message.info("Hello kui !");
|
|
81
|
-
},
|
|
82
|
-
},
|
|
73
|
+
<script setup>
|
|
74
|
+
import { message } from "kui-vue";
|
|
75
|
+
const test = () => {
|
|
76
|
+
message.info("Hello kui !");
|
|
83
77
|
};
|
|
84
78
|
</script>
|
|
85
79
|
```
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
```vue
|
|
7
7
|
<template>
|
|
8
8
|
<Space vertical align="start">
|
|
9
|
-
<RadioGroup v-model="size">
|
|
9
|
+
<RadioGroup v-model="size" type="button">
|
|
10
10
|
<RadioButton value="large" label="Large" @click="()=>{}"/>
|
|
11
11
|
<RadioButton value="default" label="Default" />
|
|
12
12
|
<RadioButton value="small" label="Small" />
|
package/components/card/card.jsx
CHANGED
|
@@ -18,7 +18,7 @@ const Checkbox = defineComponent({
|
|
|
18
18
|
|
|
19
19
|
// [Vue 3 Upgrade]: Vue 2 use checked & model
|
|
20
20
|
checked: {
|
|
21
|
-
type: Boolean,
|
|
21
|
+
type: [Boolean, Number],
|
|
22
22
|
default: false,
|
|
23
23
|
},
|
|
24
24
|
|
|
@@ -43,27 +43,28 @@ const Checkbox = defineComponent({
|
|
|
43
43
|
isChecked.value = v;
|
|
44
44
|
}
|
|
45
45
|
);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (props.disabled) return;
|
|
49
|
-
|
|
50
|
-
const targetChecked = e.target.checked;
|
|
51
|
-
|
|
52
|
-
isChecked.value = targetChecked;
|
|
53
|
-
// [Vue 3 Upgrade]: emit("update:modelValue", targetChecked);
|
|
46
|
+
const emitValue = (checked) => {
|
|
47
|
+
isChecked.value = checked;
|
|
54
48
|
emit("change", {
|
|
55
|
-
checked:
|
|
49
|
+
checked: checked,
|
|
56
50
|
value: props.value,
|
|
57
|
-
label: props.label,
|
|
51
|
+
label: props.label || slots.default?.(),
|
|
58
52
|
});
|
|
59
|
-
emit("input",
|
|
53
|
+
emit("input", checked);
|
|
54
|
+
};
|
|
55
|
+
const onChange = (e) => {
|
|
56
|
+
if (props.disabled) return;
|
|
57
|
+
const checked = e.target.checked;
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
e.stopPropagation();
|
|
60
|
+
emitValue(checked);
|
|
60
61
|
};
|
|
61
|
-
const
|
|
62
|
-
// onChange({ target: { checked: isChecked.value } });
|
|
62
|
+
const triggerCheck = (e) => {
|
|
63
63
|
if (e.code == "Space") {
|
|
64
|
-
onChange({ target: { checked: !isChecked.value } });
|
|
65
64
|
e.preventDefault();
|
|
66
65
|
e.stopPropagation();
|
|
66
|
+
if (props.disabled) return;
|
|
67
|
+
emitValue(!isChecked.value);
|
|
67
68
|
}
|
|
68
69
|
};
|
|
69
70
|
return () => {
|
|
@@ -86,7 +87,7 @@ const Checkbox = defineComponent({
|
|
|
86
87
|
const labelNode = props.label || slots.default?.();
|
|
87
88
|
|
|
88
89
|
return (
|
|
89
|
-
<label class={wpClasses} onKeydown={
|
|
90
|
+
<label class={wpClasses} onKeydown={triggerCheck} tabindex="0">
|
|
90
91
|
<span class="k-checkbox-symbol">
|
|
91
92
|
<input
|
|
92
93
|
type="checkbox"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Checkbox from "./checkbox";
|
|
2
|
-
import { defineComponent, watch, toRefs } from "vue";
|
|
2
|
+
import { defineComponent, watch, toRefs, computed } from "vue";
|
|
3
3
|
import { withInstall } from "../utils/vue";
|
|
4
|
-
import { getChildren } from "../utils/
|
|
4
|
+
import { getChildren } from "../utils/vnode";
|
|
5
5
|
|
|
6
6
|
const CheckboxGroup = defineComponent({
|
|
7
7
|
name: "CheckboxGroup",
|
|
@@ -57,7 +57,7 @@ const CheckboxGroup = defineComponent({
|
|
|
57
57
|
emit("change", val);
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
const optionsData = () => {
|
|
60
|
+
const optionsData = computed(() => {
|
|
61
61
|
let { options } = props;
|
|
62
62
|
if (!options) {
|
|
63
63
|
options = [];
|
|
@@ -74,10 +74,10 @@ const CheckboxGroup = defineComponent({
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
return options;
|
|
77
|
-
};
|
|
77
|
+
});
|
|
78
78
|
|
|
79
79
|
return () => {
|
|
80
|
-
let options = optionsData
|
|
80
|
+
let options = optionsData.value;
|
|
81
81
|
let nodes = [];
|
|
82
82
|
options.forEach((option) =>
|
|
83
83
|
nodes.push(
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
<template>
|
|
8
8
|
<Space vertical>
|
|
9
9
|
use options
|
|
10
|
-
<code>value: {{
|
|
11
|
-
<CheckboxGroup :options="options" v-model="
|
|
10
|
+
<code>value: {{ value }}</code>
|
|
11
|
+
<CheckboxGroup :options="options" v-model="value" />
|
|
12
12
|
<br />
|
|
13
13
|
use children
|
|
14
|
-
<CheckboxGroup v-model="
|
|
14
|
+
<CheckboxGroup v-model="value" theme="light">
|
|
15
15
|
<Checkbox
|
|
16
16
|
:label="item.label"
|
|
17
17
|
:value="item.value"
|
|
@@ -23,13 +23,24 @@
|
|
|
23
23
|
</template>
|
|
24
24
|
<script setup>
|
|
25
25
|
import { ref } from "vue";
|
|
26
|
-
const
|
|
27
|
-
const options = [
|
|
26
|
+
const value = ref(["apple", "grape"]);
|
|
27
|
+
const options = ref([
|
|
28
28
|
{ label: "Apple", value: "apple" },
|
|
29
29
|
{ label: "Orange", value: "orange" },
|
|
30
30
|
{ label: "Banana", value: "banana" },
|
|
31
31
|
{ label: "Pear", value: "pear" },
|
|
32
32
|
{ label: "Grape", value: "grape" },
|
|
33
|
-
];
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
// 异步更新数据
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
options.value = [
|
|
38
|
+
{ label: "Apple1", value: "apple" },
|
|
39
|
+
{ label: "Orange1", value: "orange" },
|
|
40
|
+
{ label: "Banana1", value: "banana" },
|
|
41
|
+
{ label: "Pear1", value: "pear" },
|
|
42
|
+
{ label: "Grape1", value: "grape" },
|
|
43
|
+
];
|
|
44
|
+
}, 1000);
|
|
34
45
|
</script>
|
|
35
46
|
```
|
|
@@ -156,18 +156,11 @@
|
|
|
156
156
|
display: inline-flex;
|
|
157
157
|
flex-shrink: 0;
|
|
158
158
|
align-items: center;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
margin-right: 16px;
|
|
162
|
-
}
|
|
159
|
+
flex-wrap: wrap;
|
|
160
|
+
gap: 16px;
|
|
163
161
|
}
|
|
164
162
|
|
|
165
163
|
.k-checkbox-group-vertical {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
.k-checkbox {
|
|
169
|
-
display: block;
|
|
170
|
-
margin-right: 0;
|
|
171
|
-
margin-bottom: 16px;
|
|
172
|
-
}
|
|
164
|
+
flex-direction: column;
|
|
165
|
+
align-items: self-start;
|
|
173
166
|
}
|
|
@@ -4,23 +4,23 @@ import { withInstall, cloneVNode } from "../utils/vue";
|
|
|
4
4
|
const Collapse = defineComponent({
|
|
5
5
|
name: "Collapse",
|
|
6
6
|
props: {
|
|
7
|
-
|
|
7
|
+
openKeys: Array,
|
|
8
8
|
accordion: Boolean,
|
|
9
9
|
sample: Boolean,
|
|
10
10
|
},
|
|
11
11
|
setup(ps, { slots, emit }) {
|
|
12
|
-
const
|
|
12
|
+
const defaultOpenKeys = ref(ps.openKeys || []);
|
|
13
13
|
|
|
14
14
|
watch(
|
|
15
|
-
() => ps.
|
|
15
|
+
() => ps.openKeys,
|
|
16
16
|
(nv, no) => {
|
|
17
|
-
|
|
17
|
+
defaultOpenKeys.value = nv;
|
|
18
18
|
}
|
|
19
19
|
);
|
|
20
20
|
|
|
21
21
|
const change = (key) => {
|
|
22
22
|
if (!key) return;
|
|
23
|
-
let value =
|
|
23
|
+
let value = defaultOpenKeys.value;
|
|
24
24
|
let index = value.indexOf(key);
|
|
25
25
|
|
|
26
26
|
if (index >= 0) {
|
|
@@ -28,10 +28,9 @@ const Collapse = defineComponent({
|
|
|
28
28
|
} else {
|
|
29
29
|
ps.accordion ? (value = [key]) : value.push(key);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
emit("change", key);
|
|
33
|
-
|
|
34
|
-
emit("input", value); //for 3
|
|
31
|
+
defaultOpenKeys.value = value;
|
|
32
|
+
emit("change", key, value);
|
|
33
|
+
emit("update:openKeys", value);
|
|
35
34
|
};
|
|
36
35
|
|
|
37
36
|
return () => {
|
|
@@ -46,7 +45,7 @@ const Collapse = defineComponent({
|
|
|
46
45
|
return (
|
|
47
46
|
<div class={classes}>
|
|
48
47
|
{children?.map((child) => {
|
|
49
|
-
let active =
|
|
48
|
+
let active = defaultOpenKeys.value.includes(child.key);
|
|
50
49
|
// return cloneVNode(child, { active, onExpand: change }); //for 3
|
|
51
50
|
return cloneVNode(
|
|
52
51
|
child,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
```vue
|
|
7
7
|
<template>
|
|
8
8
|
<div class="demo-collapse">
|
|
9
|
-
<Collapse :
|
|
9
|
+
<Collapse :openKeys="openKeys" accordion>
|
|
10
10
|
<CollapsePanel title="Panel title" key="1">
|
|
11
11
|
<div>{{ text }}</div>
|
|
12
12
|
</CollapsePanel>
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
<script setup>
|
|
23
23
|
import { ref } from "vue";
|
|
24
|
-
const
|
|
24
|
+
const openKeys = ref(["1"]);
|
|
25
25
|
const text = `A long time ago, In a beautiful kingdom,
|
|
26
26
|
there lived a young king and queen,
|
|
27
27
|
the people loved them so much; `;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
```vue
|
|
7
7
|
<template>
|
|
8
8
|
<div class="demo-collapse">
|
|
9
|
-
<Collapse :
|
|
9
|
+
<Collapse :openKeys="openKeys">
|
|
10
10
|
<CollapsePanel title="Panel title" key="1">
|
|
11
11
|
<div>{{ text }}</div>
|
|
12
12
|
</CollapsePanel>
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
<script setup>
|
|
23
23
|
import { ref } from "vue";
|
|
24
|
-
const
|
|
24
|
+
const openKeys = ref(["1"]);
|
|
25
25
|
const text = `A long time ago, In a beautiful kingdom,
|
|
26
26
|
there lived a young king and queen,
|
|
27
27
|
the people loved them so much; `;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
```vue
|
|
7
7
|
<template>
|
|
8
8
|
<div class="demo-collapse">
|
|
9
|
-
<Collapse :
|
|
9
|
+
<Collapse :openKeys="openKeys">
|
|
10
10
|
<CollapsePanel title="Panel title" key="1">
|
|
11
11
|
<template #extra>
|
|
12
12
|
<Icon :type="SettingsOutline" />
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
</template>
|
|
31
31
|
<script setup>
|
|
32
32
|
import { ref } from "vue";
|
|
33
|
-
const
|
|
33
|
+
const openKeys = ref(["1","2"]);
|
|
34
34
|
import { SettingsOutline } from "kui-icons";
|
|
35
35
|
const text = `A long time ago, In a beautiful kingdom,
|
|
36
36
|
there lived a young king and queen,
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
```vue
|
|
7
7
|
<template>
|
|
8
8
|
<div class="demo-collapse">
|
|
9
|
-
<Collapse :
|
|
9
|
+
<Collapse :openKeys="openKeys">
|
|
10
10
|
<CollapsePanel title="Panel title" key="1">
|
|
11
|
-
<Collapse :
|
|
11
|
+
<Collapse :openKeys="openKeys2">
|
|
12
12
|
<CollapsePanel title="Panel title" key="1-1">
|
|
13
13
|
<div>{{ text }}</div>
|
|
14
14
|
</CollapsePanel>
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
</template>
|
|
29
29
|
<script setup>
|
|
30
30
|
import { ref } from "vue";
|
|
31
|
-
const
|
|
32
|
-
const
|
|
31
|
+
const openKeys = ref(["1"]);
|
|
32
|
+
const openKeys2 = ref(["1-1"]);
|
|
33
33
|
const text = `A long time ago, In a beautiful kingdom,
|
|
34
34
|
there lived a young king and queen,
|
|
35
35
|
the people loved them so much; `;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
```vue
|
|
7
7
|
<template>
|
|
8
8
|
<div class="demo-collapse">
|
|
9
|
-
<Collapse :
|
|
9
|
+
<Collapse :openKeys="openKeys" sample>
|
|
10
10
|
<CollapsePanel title="Panel title" key="1">
|
|
11
11
|
<div>{{ text }}</div>
|
|
12
12
|
</CollapsePanel>
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
<script setup>
|
|
23
23
|
import { ref } from "vue";
|
|
24
|
-
const
|
|
24
|
+
const openKeys = ref(["1"]);
|
|
25
25
|
const text = `A long time ago, In a beautiful kingdom,
|
|
26
26
|
there lived a young king and queen,
|
|
27
27
|
the people loved them so much; `;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
## API
|
|
2
2
|
|
|
3
|
-
| 属性 | 说明
|
|
4
|
-
| --------- |
|
|
5
|
-
|
|
|
6
|
-
| accordion | 是否开启手风琴模式,开启后每次至多展开一个面板
|
|
7
|
-
| sample | 是否开启简洁模式
|
|
8
|
-
| change | 切换面板时触发回调,返回当前选项卡的 `name`
|
|
3
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
4
|
+
| --------- | ---------------------------------------------- | -------- | ------ |
|
|
5
|
+
| openKeys | 当前展开的面板的 `key` | Array | - |
|
|
6
|
+
| accordion | 是否开启手风琴模式,开启后每次至多展开一个面板 | Boolean | false |
|
|
7
|
+
| sample | 是否开启简洁模式 | Boolean | false |
|
|
8
|
+
| change | 切换面板时触发回调,返回当前选项卡的 `name` | Function | - |
|
|
9
9
|
|
|
10
10
|
## Panel
|
|
11
11
|
|
|
@@ -72,12 +72,11 @@ const ColorPicker = defineComponent({
|
|
|
72
72
|
},
|
|
73
73
|
|
|
74
74
|
setup(ps, { emit, slots }) {
|
|
75
|
-
// todo 编码格式 时, 要双击 才能先中.
|
|
76
75
|
const currentMode = ref(ps.mode);
|
|
77
76
|
const currentColor = ref(ps.value || "#000000ff");
|
|
78
77
|
const visible = ref(ps.show);
|
|
79
78
|
const refPopper = ref();
|
|
80
|
-
const
|
|
79
|
+
const refSelection = ref();
|
|
81
80
|
const left = ref(0);
|
|
82
81
|
const top = ref(0);
|
|
83
82
|
const currentPlacement = ref(ps.placement);
|
|
@@ -107,7 +106,7 @@ const ColorPicker = defineComponent({
|
|
|
107
106
|
const updatePopPosition = () => {
|
|
108
107
|
nextTick(() => {
|
|
109
108
|
setPlacement({
|
|
110
|
-
|
|
109
|
+
refSelection,
|
|
111
110
|
refPopper,
|
|
112
111
|
currentPlacement,
|
|
113
112
|
transOrigin,
|
|
@@ -117,7 +116,7 @@ const ColorPicker = defineComponent({
|
|
|
117
116
|
});
|
|
118
117
|
};
|
|
119
118
|
const outsideClick = (e) => {
|
|
120
|
-
const ctx =
|
|
119
|
+
const ctx = refSelection.value?.$el || refSelection.value;
|
|
121
120
|
if (
|
|
122
121
|
refPopper.value &&
|
|
123
122
|
!refPopper.value.contains(e.target) &&
|
|
@@ -327,7 +326,7 @@ const ColorPicker = defineComponent({
|
|
|
327
326
|
{cloneNodes(
|
|
328
327
|
slots.default(),
|
|
329
328
|
{
|
|
330
|
-
ref:
|
|
329
|
+
ref: refSelection,
|
|
331
330
|
on: {
|
|
332
331
|
click: () => triggerClick && toggle(!visible.value),
|
|
333
332
|
mouseenter: () => !triggerClick && toggle(true),
|
|
@@ -342,7 +341,7 @@ const ColorPicker = defineComponent({
|
|
|
342
341
|
{drop}
|
|
343
342
|
</span>
|
|
344
343
|
) : (
|
|
345
|
-
<div class={style} ref={
|
|
344
|
+
<div class={style} ref={refSelection} v-resize={updatePopPosition}>
|
|
346
345
|
<div
|
|
347
346
|
class="k-color-picker-selection"
|
|
348
347
|
onMouseenter={() => !triggerClick && toggle(true)}
|
|
@@ -5,12 +5,24 @@
|
|
|
5
5
|
|
|
6
6
|
```vue
|
|
7
7
|
<template>
|
|
8
|
-
<
|
|
8
|
+
<Space vertical>
|
|
9
|
+
<code>v-model: {{ color }}</code>
|
|
9
10
|
<ColorPicker v-model="color" />
|
|
10
|
-
|
|
11
|
+
<code>mode = hex ,v-model: {{ hexColor }}</code>
|
|
12
|
+
<ColorPicker v-model="hexColor" />
|
|
13
|
+
<code>mode = rgb,v-model: {{ rgbColor }}</code>
|
|
14
|
+
<ColorPicker mode="rgb" v-model="rgbColor" />
|
|
15
|
+
<code>mode = hsl,v-model: {{ hslColor }}</code>
|
|
16
|
+
<ColorPicker mode="hsl" v-model="hslColor" />
|
|
17
|
+
<code>showText = true</code>
|
|
18
|
+
<ColorPicker showText v-model="color" />
|
|
19
|
+
</Space>
|
|
11
20
|
</template>
|
|
12
21
|
<script setup>
|
|
13
22
|
import { ref } from "vue";
|
|
14
23
|
const color = ref("#3a95ff");
|
|
24
|
+
const hexColor = ref("#3a95ff");
|
|
25
|
+
const rgbColor = ref("rgba(0, 188, 212, 0.72)");
|
|
26
|
+
const hslColor = ref("hsl(207, 90%, 54%)");
|
|
15
27
|
</script>
|
|
16
28
|
```
|
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
<template>
|
|
8
8
|
<Space class="demo-color-picker" vertical>
|
|
9
9
|
<Space>
|
|
10
|
-
<ColorPicker v-model="color1">
|
|
10
|
+
<ColorPicker v-model:value="color1">
|
|
11
11
|
<Button type="primary">Open</Button>
|
|
12
12
|
</ColorPicker>
|
|
13
13
|
{{ color1 }}
|
|
14
14
|
</Space>
|
|
15
15
|
<Space>
|
|
16
|
-
<ColorPicker v-model="color2" trigger="hover">
|
|
16
|
+
<ColorPicker v-model:value="color2" trigger="hover">
|
|
17
17
|
<Button type="primary">Hover</Button>
|
|
18
18
|
</ColorPicker>
|
|
19
19
|
{{ color2 }}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import Info from './info.md'
|
|
2
2
|
import Basic from './basic.md'
|
|
3
|
-
import Mode from './mode.md'
|
|
4
3
|
import Size from './size.md'
|
|
5
|
-
import Disabled from './disabled.md'
|
|
6
|
-
import DisabledAlpha from './disabledAlpha.md'
|
|
7
4
|
import CustomTrigger from './customTrigger.md'
|
|
8
5
|
import Placement from './placement.md'
|
|
9
|
-
import Presets from './presets.md'
|
|
10
6
|
import CN from '../index.md'
|
|
11
7
|
export default {
|
|
12
8
|
render() {
|
|
@@ -15,12 +11,8 @@ export default {
|
|
|
15
11
|
<Info />
|
|
16
12
|
<Basic />
|
|
17
13
|
<Size />
|
|
18
|
-
<Disabled />
|
|
19
|
-
<DisabledAlpha />
|
|
20
14
|
<CustomTrigger />
|
|
21
15
|
<Placement />
|
|
22
|
-
<Mode />
|
|
23
|
-
<Presets />
|
|
24
16
|
<CN />
|
|
25
17
|
</div>
|
|
26
18
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<cn>
|
|
2
|
-
### 尺寸大小
|
|
2
|
+
### 尺寸大小 / 不可用
|
|
3
3
|
`small` 为小尺寸, `large` 为大尺寸
|
|
4
4
|
</cn>
|
|
5
5
|
|
|
@@ -7,16 +7,29 @@
|
|
|
7
7
|
<template>
|
|
8
8
|
<Space vertical>
|
|
9
9
|
<Space>
|
|
10
|
-
<
|
|
11
|
-
|
|
10
|
+
<Space vertical>
|
|
11
|
+
<ColorPicker :value="color3" size="small" />
|
|
12
|
+
<ColorPicker :value="color2" />
|
|
13
|
+
<ColorPicker :value="color1" size="large" />
|
|
14
|
+
</Space>
|
|
15
|
+
<Space vertical>
|
|
16
|
+
<ColorPicker showText :value="color3" size="small" />
|
|
17
|
+
<ColorPicker showText :value="color2" />
|
|
18
|
+
<ColorPicker showText :value="color1" size="large" />
|
|
19
|
+
</Space>
|
|
12
20
|
</Space>
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
<br />
|
|
22
|
+
<Space vertical>
|
|
23
|
+
<code>disabled</code>
|
|
24
|
+
<Space>
|
|
25
|
+
<ColorPicker :value="color2" disabled />
|
|
26
|
+
<ColorPicker showText :value="color2" disabled />
|
|
27
|
+
</Space>
|
|
28
|
+
<br />
|
|
29
|
+
<code>disabledAlpha</code>
|
|
30
|
+
<ColorPicker showText disabledAlpha :value="color2" />
|
|
31
|
+
<code>presets colors</code>
|
|
32
|
+
<ColorPicker v-model="color1" :presets="presetsColors" />
|
|
20
33
|
</Space>
|
|
21
34
|
</Space>
|
|
22
35
|
</template>
|
|
@@ -24,5 +37,6 @@
|
|
|
24
37
|
const color1 = "#3a95ff";
|
|
25
38
|
const color2 = "#3a95ff";
|
|
26
39
|
const color3 = "#3a95ff";
|
|
40
|
+
const presetsColors = ["#9c27b0", "red", "blue"];
|
|
27
41
|
</script>
|
|
28
42
|
```
|
|
@@ -122,7 +122,7 @@ const DatePicker = defineComponent({
|
|
|
122
122
|
const top = ref(0);
|
|
123
123
|
const transOrigin = ref("bottom");
|
|
124
124
|
const refPopper = ref(null);
|
|
125
|
-
const
|
|
125
|
+
const refSelection = ref(null);
|
|
126
126
|
// console.log(local);
|
|
127
127
|
|
|
128
128
|
// DOM 引用,用于滚动计算
|
|
@@ -218,7 +218,6 @@ const DatePicker = defineComponent({
|
|
|
218
218
|
|
|
219
219
|
const syncTextFromValue = () => {
|
|
220
220
|
const fmt = getFormat();
|
|
221
|
-
const fmtDate = (d) => (d ? d.locale(localeName.value).format(fmt) : "");
|
|
222
221
|
// 空值
|
|
223
222
|
if (!innerValue.value) {
|
|
224
223
|
textValue.value = "";
|
|
@@ -227,13 +226,12 @@ const DatePicker = defineComponent({
|
|
|
227
226
|
return;
|
|
228
227
|
}
|
|
229
228
|
|
|
229
|
+
const fmtDate = (d) => (d ? d.locale(localeName.value).format(fmt) : "");
|
|
230
230
|
// Range 模式
|
|
231
231
|
if (Array.isArray(innerValue.value)) {
|
|
232
232
|
const [start, end] = innerValue.value;
|
|
233
233
|
textValueStart.value = start ? start.format(fmt) : "";
|
|
234
234
|
textValueEnd.value = end ? end.format(fmt) : "";
|
|
235
|
-
// 兼容单 input 显示 (虽然现在是双input,保留逻辑防止出错)
|
|
236
|
-
textValue.value = innerValue.value.map((d) => fmtDate(d)).join(" - ");
|
|
237
235
|
} else {
|
|
238
236
|
textValue.value = fmtDate(innerValue.value);
|
|
239
237
|
}
|
|
@@ -245,7 +243,11 @@ const DatePicker = defineComponent({
|
|
|
245
243
|
if (props.valueType === "unix") {
|
|
246
244
|
d = dayjs.unix(Number(val));
|
|
247
245
|
} else {
|
|
248
|
-
|
|
246
|
+
const fmt = getFormat();
|
|
247
|
+
d = dayjs(val, fmt, localeName.value);
|
|
248
|
+
if (!d.isValid()) {
|
|
249
|
+
d = dayjs(val);
|
|
250
|
+
}
|
|
249
251
|
}
|
|
250
252
|
|
|
251
253
|
return d.isValid() ? d.locale(localeName.value) : null;
|
|
@@ -406,7 +408,7 @@ const DatePicker = defineComponent({
|
|
|
406
408
|
};
|
|
407
409
|
|
|
408
410
|
const handleClickOutside = (e) => {
|
|
409
|
-
const ctx =
|
|
411
|
+
const ctx = refSelection.value;
|
|
410
412
|
const popper = refPopper.value;
|
|
411
413
|
if (
|
|
412
414
|
popper &&
|
|
@@ -414,9 +416,9 @@ const DatePicker = defineComponent({
|
|
|
414
416
|
ctx &&
|
|
415
417
|
!ctx.contains(e.target)
|
|
416
418
|
) {
|
|
419
|
+
syncTextFromValue();
|
|
417
420
|
isVisible.value = false;
|
|
418
421
|
isFocus.value = false;
|
|
419
|
-
syncTextFromValue();
|
|
420
422
|
}
|
|
421
423
|
};
|
|
422
424
|
const timeLabelClick = (e, direction) => {
|
|
@@ -795,7 +797,10 @@ const DatePicker = defineComponent({
|
|
|
795
797
|
i === curr ? "active" : "",
|
|
796
798
|
isDisabled ? "k-picker-time-disabled" : "",
|
|
797
799
|
]}
|
|
798
|
-
onClick={() =>
|
|
800
|
+
onClick={(e) => {
|
|
801
|
+
e.stopPropagation();
|
|
802
|
+
!isDisabled && handleTimeScrollPick(type, i);
|
|
803
|
+
}}
|
|
799
804
|
>
|
|
800
805
|
{String(i).padStart(2, "0")}
|
|
801
806
|
</li>
|
|
@@ -878,7 +883,7 @@ const DatePicker = defineComponent({
|
|
|
878
883
|
const updatePosition = () => {
|
|
879
884
|
nextTick(() => {
|
|
880
885
|
setPlacement({
|
|
881
|
-
|
|
886
|
+
refSelection,
|
|
882
887
|
refPopper,
|
|
883
888
|
currentPlacement,
|
|
884
889
|
transOrigin,
|
|
@@ -913,7 +918,10 @@ const DatePicker = defineComponent({
|
|
|
913
918
|
{ "k-datepicker-light": props.theme == "light" },
|
|
914
919
|
{ "k-datepicker-circle": props.shape == "circle" },
|
|
915
920
|
];
|
|
916
|
-
const showClear =
|
|
921
|
+
const showClear =
|
|
922
|
+
props.clearable &&
|
|
923
|
+
(textValue.value || (textValueStart.value && textValueStart.value)) &&
|
|
924
|
+
!props.disabled;
|
|
917
925
|
const selectCls = [
|
|
918
926
|
"k-datepicker-selection",
|
|
919
927
|
{
|
|
@@ -1067,7 +1075,7 @@ const DatePicker = defineComponent({
|
|
|
1067
1075
|
) : null;
|
|
1068
1076
|
|
|
1069
1077
|
return (
|
|
1070
|
-
<div class={classes} ref={
|
|
1078
|
+
<div class={classes} ref={refSelection} tabindex={0}>
|
|
1071
1079
|
<div class={selectCls} onClick={togglePanel}>
|
|
1072
1080
|
{renderInput()}
|
|
1073
1081
|
<Icon type={dateIcon} class="k-icon-calendar" />
|