@opentiny/vue-renderless 3.21.0 → 3.21.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/common/deps/popper.js +3 -0
- package/common/deps/vue-popper.js +3 -0
- package/common/index.js +1 -1
- package/common/runtime.js +1 -1
- package/dropdown/index.js +37 -20
- package/dropdown/vue.js +10 -5
- package/grid/utils/dom.js +4 -1
- package/package.json +3 -3
- package/types/dropdown.type.d.ts +7 -1
package/common/deps/popper.js
CHANGED
|
@@ -22,6 +22,9 @@ const getReferMaxZIndex = (reference) => {
|
|
|
22
22
|
let z;
|
|
23
23
|
do {
|
|
24
24
|
reference = reference.parentNode;
|
|
25
|
+
if (reference && reference instanceof ShadowRoot && reference.host) {
|
|
26
|
+
reference = reference.host;
|
|
27
|
+
}
|
|
25
28
|
if (reference) {
|
|
26
29
|
z = getZIndex(reference);
|
|
27
30
|
} else {
|
package/common/index.js
CHANGED
package/common/runtime.js
CHANGED
package/dropdown/index.js
CHANGED
|
@@ -11,19 +11,23 @@ const watchFocusing = (parent) => (value) => {
|
|
|
11
11
|
value ? addClass(selfDefine, "focusing") : removeClass(selfDefine, "focusing");
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
const show = ({ props, state }) => () => {
|
|
14
|
+
const show = ({ props, state, emit }) => () => {
|
|
15
15
|
if (props.disabled) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
if (state.visibleIsBoolean) {
|
|
19
|
+
emit("update:visible", true);
|
|
20
|
+
} else {
|
|
21
|
+
clearTimeout(Number(state.timeout));
|
|
22
|
+
state.timeout = setTimeout(
|
|
23
|
+
() => {
|
|
24
|
+
state.visible = true;
|
|
25
|
+
},
|
|
26
|
+
state.trigger === "click" ? 0 : props.showTimeout
|
|
27
|
+
);
|
|
28
|
+
}
|
|
25
29
|
};
|
|
26
|
-
const hide = ({ api, props, state }) => () => {
|
|
30
|
+
const hide = ({ api, props, state, emit }) => () => {
|
|
27
31
|
if (props.disabled) {
|
|
28
32
|
return;
|
|
29
33
|
}
|
|
@@ -31,20 +35,28 @@ const hide = ({ api, props, state }) => () => {
|
|
|
31
35
|
if (props.tabindex >= 0 && state.triggerElm) {
|
|
32
36
|
api.resetTabindex(state.triggerElm);
|
|
33
37
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
if (state.visibleIsBoolean) {
|
|
39
|
+
emit("update:visible", false);
|
|
40
|
+
} else {
|
|
41
|
+
clearTimeout(Number(state.timeout));
|
|
42
|
+
state.timeout = setTimeout(
|
|
43
|
+
() => {
|
|
44
|
+
state.visible = false;
|
|
45
|
+
},
|
|
46
|
+
state.trigger === "click" ? 0 : props.hideTimeout
|
|
47
|
+
);
|
|
48
|
+
}
|
|
41
49
|
};
|
|
42
50
|
const handleClick = ({ api, props, state, emit }) => () => {
|
|
43
51
|
if (props.disabled) {
|
|
44
52
|
return;
|
|
45
53
|
}
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
if (state.visibleIsBoolean) {
|
|
55
|
+
emit("handle-click", props.visible);
|
|
56
|
+
} else {
|
|
57
|
+
emit("handle-click", state.visible);
|
|
58
|
+
state.visible ? api.hide() : api.show();
|
|
59
|
+
}
|
|
48
60
|
};
|
|
49
61
|
const handleTriggerKeyDown = ({ api, state }) => (event) => {
|
|
50
62
|
const keyCode = event.keyCode;
|
|
@@ -62,7 +74,7 @@ const handleTriggerKeyDown = ({ api, state }) => (event) => {
|
|
|
62
74
|
api.hide();
|
|
63
75
|
}
|
|
64
76
|
};
|
|
65
|
-
const handleItemKeyDown = ({ api, props, state }) => (event) => {
|
|
77
|
+
const handleItemKeyDown = ({ api, props, state, emit }) => (event) => {
|
|
66
78
|
const keyCode = event.keyCode;
|
|
67
79
|
const target = event.target;
|
|
68
80
|
const currentIndex = state.menuItemsArray.indexOf(target);
|
|
@@ -128,6 +140,9 @@ const initEvent = ({ api, props, state, vm, mode }) => () => {
|
|
|
128
140
|
on(state.triggerElm, "blur", api.toggleFocusOnFalse);
|
|
129
141
|
on(state.triggerElm, "click", api.toggleFocusOnFalse);
|
|
130
142
|
}
|
|
143
|
+
if (state.visibleIsBoolean) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
131
146
|
if (state.trigger === "hover") {
|
|
132
147
|
on(state.triggerElm, "mouseenter", api.show);
|
|
133
148
|
on(state.triggerElm, "mouseleave", api.hide);
|
|
@@ -176,7 +191,9 @@ const mounted = ({ api, vm, state, broadcast }) => () => {
|
|
|
176
191
|
vm.$on("selected-index", (selectedIndex) => {
|
|
177
192
|
broadcast("TinyDropdownMenu", "menu-selected-index", selectedIndex);
|
|
178
193
|
});
|
|
179
|
-
|
|
194
|
+
if (!state.visibleIsBoolean) {
|
|
195
|
+
vm.$on("is-disabled", api.clickOutside);
|
|
196
|
+
}
|
|
180
197
|
};
|
|
181
198
|
const beforeDistory = ({ vm, api, state }) => () => {
|
|
182
199
|
if (state.triggerElm) {
|
package/dropdown/vue.js
CHANGED
|
@@ -39,19 +39,20 @@ const renderless = (props, { reactive, watch, provide, onMounted, computed, onBe
|
|
|
39
39
|
trigger: computed(() => {
|
|
40
40
|
var _a;
|
|
41
41
|
return props.trigger || ((_a = designConfig == null ? void 0 : designConfig.props) == null ? void 0 : _a.trigger) || "hover";
|
|
42
|
-
})
|
|
42
|
+
}),
|
|
43
|
+
visibleIsBoolean: computed(() => typeof props.visible === "boolean")
|
|
43
44
|
});
|
|
44
45
|
provide("dropdownVm", vm);
|
|
45
46
|
Object.assign(api2, {
|
|
46
47
|
state,
|
|
47
48
|
watchVisible: watchVisible({ broadcast, emit, nextTick }),
|
|
48
49
|
watchFocusing: watchFocusing(parent),
|
|
49
|
-
show: show({ props, state }),
|
|
50
|
-
hide: hide({ api: api2, props, state }),
|
|
50
|
+
show: show({ props, state, emit }),
|
|
51
|
+
hide: hide({ api: api2, props, state, emit }),
|
|
51
52
|
mounted: mounted({ api: api2, vm, state, broadcast }),
|
|
52
53
|
handleClick: handleClick({ api: api2, props, state, emit }),
|
|
53
54
|
handleTriggerKeyDown: handleTriggerKeyDown({ api: api2, state }),
|
|
54
|
-
handleItemKeyDown: handleItemKeyDown({ api: api2, props, state }),
|
|
55
|
+
handleItemKeyDown: handleItemKeyDown({ api: api2, props, state, emit }),
|
|
55
56
|
resetTabindex: resetTabindex(api2),
|
|
56
57
|
removeTabindex: removeTabindex(state),
|
|
57
58
|
initAria: initAria({ state, props }),
|
|
@@ -65,7 +66,11 @@ const renderless = (props, { reactive, watch, provide, onMounted, computed, onBe
|
|
|
65
66
|
toggleFocusOnTrue: toggleFocus({ state, value: true }),
|
|
66
67
|
toggleFocusOnFalse: toggleFocus({ state, value: false })
|
|
67
68
|
});
|
|
68
|
-
|
|
69
|
+
if (typeof props.visible === "boolean") {
|
|
70
|
+
watch(() => props.visible, api2.watchVisible);
|
|
71
|
+
} else {
|
|
72
|
+
watch(() => state.visible, api2.watchVisible);
|
|
73
|
+
}
|
|
69
74
|
watch(() => state.focusing, api2.watchFocusing);
|
|
70
75
|
onMounted(api2.mounted);
|
|
71
76
|
onBeforeUnmount(api2.beforeDistory);
|
package/grid/utils/dom.js
CHANGED
|
@@ -119,9 +119,12 @@ const colToVisible = ($table, column, move) => {
|
|
|
119
119
|
});
|
|
120
120
|
};
|
|
121
121
|
const hasDataTag = (el, value) => {
|
|
122
|
-
if (!el || !value
|
|
122
|
+
if (!el || !value) {
|
|
123
123
|
return false;
|
|
124
124
|
}
|
|
125
|
+
if (el.host) {
|
|
126
|
+
el = el.host;
|
|
127
|
+
}
|
|
125
128
|
return (" " + el.getAttribute("data-tag") + " ").includes(" " + value + " ");
|
|
126
129
|
};
|
|
127
130
|
const getEventTargetNode = (event, container, queryCls) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentiny/vue-renderless",
|
|
3
|
-
"version": "3.21.
|
|
3
|
+
"version": "3.21.2",
|
|
4
4
|
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
|
|
5
5
|
"author": "OpenTiny Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
],
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"@opentiny/utils": "^1.0.0",
|
|
29
|
+
"color": "4.2.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"esno": "^4.7.0",
|
package/types/dropdown.type.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import { ISharedRenderlessFunctionParams, ISharedRenderlessParamUtils } from './
|
|
|
3
3
|
|
|
4
4
|
declare const dropdownProps: {
|
|
5
5
|
modelValue: (StringConstructor | NumberConstructor)[];
|
|
6
|
+
visible: {
|
|
7
|
+
type: BooleanConstructor;
|
|
8
|
+
default: undefined;
|
|
9
|
+
};
|
|
6
10
|
type: StringConstructor;
|
|
7
11
|
trigger: StringConstructor;
|
|
8
12
|
size: {
|
|
@@ -97,7 +101,7 @@ interface IDropdownState {
|
|
|
97
101
|
visible: boolean;
|
|
98
102
|
timeout: null | NodeJS.Timeout;
|
|
99
103
|
focusing: false;
|
|
100
|
-
menuItems: NodeListOf<HTMLElement> | undefined | null;
|
|
104
|
+
menuItems: NodeListOf<HTMLElement> | undefined | null | [];
|
|
101
105
|
menuItemsArray: HTMLElement[] | null;
|
|
102
106
|
triggerElm: HTMLElement | null;
|
|
103
107
|
dropdownElm: HTMLElement | null;
|
|
@@ -105,6 +109,8 @@ interface IDropdownState {
|
|
|
105
109
|
showIcon: boolean;
|
|
106
110
|
showSelfIcon: boolean;
|
|
107
111
|
designConfig: IDropdownRenderlessParamUtils['designConfig'];
|
|
112
|
+
trigger: 'click' | 'hover';
|
|
113
|
+
visibleIsBoolean: boolean;
|
|
108
114
|
}
|
|
109
115
|
interface IDropdownApi {
|
|
110
116
|
state: IDropdownState;
|