@opentiny/vue-renderless 3.21.0 → 3.21.1

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/index.js CHANGED
@@ -237,7 +237,7 @@ const CASCADER = {
237
237
  PropsHover: "hoverThreshold",
238
238
  MenuConnector: "cascader-menu-"
239
239
  };
240
- const version = "3.21.0";
240
+ const version = "3.21.1";
241
241
  const log = (data, type = "log") => {
242
242
  uLog.logger[type](data);
243
243
  };
package/common/runtime.js CHANGED
@@ -22,7 +22,7 @@ import vuePopup from "./deps/vue-popup";
22
22
  import validate from "./validate";
23
23
  import memorize from "./deps/memorize";
24
24
  import * as common from ".";
25
- const version = "3.21.0";
25
+ const version = "3.21.1";
26
26
  const Renderless = {
27
27
  browser,
28
28
  array,
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
- clearTimeout(Number(state.timeout));
19
- state.timeout = setTimeout(
20
- () => {
21
- state.visible = true;
22
- },
23
- state.trigger === "click" ? 0 : props.showTimeout
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
- clearTimeout(Number(state.timeout));
35
- state.timeout = setTimeout(
36
- () => {
37
- state.visible = false;
38
- },
39
- state.trigger === "click" ? 0 : props.hideTimeout
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
- emit("handle-click", state.visible);
47
- state.visible ? api.hide() : api.show();
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
- vm.$on("is-disabled", api.clickOutside);
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
- watch(() => state.visible, api2.watchVisible);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/vue-renderless",
3
- "version": "3.21.0",
3
+ "version": "3.21.1",
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",
@@ -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;