@opentiny/vue-renderless 3.10.5 → 3.10.7

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.
@@ -21,6 +21,7 @@ const DEFAULTS = {
21
21
  modifiers,
22
22
  modifiersIgnored: []
23
23
  };
24
+ const getRealWindow = () => window.tinyGetRealWindow ? window.tinyGetRealWindow() : window;
24
25
  const getRealElement = (el) => el.jquery ? el[0] : el;
25
26
  const setStyle = (el, styles) => {
26
27
  const isNumeric = (n) => n !== "" && !isNaN(parseFloat(n)) && isFinite(n);
@@ -109,14 +110,17 @@ const getScrollParent = (el) => {
109
110
  };
110
111
  const getOffsetRectRelativeToCustomParent = (el, parent, fixed) => {
111
112
  let { top, left, width, height } = getBoundingClientRect(el);
112
- let parentRect = getBoundingClientRect(parent);
113
113
  if (fixed) {
114
- let { scrollTop, scrollLeft } = getScrollParent(parent);
115
- parentRect.top += scrollTop;
116
- parentRect.bottom += scrollTop;
117
- parentRect.left += scrollLeft;
118
- parentRect.right += scrollLeft;
114
+ return {
115
+ top,
116
+ left,
117
+ bottom: top + height,
118
+ right: left + width,
119
+ width,
120
+ height
121
+ };
119
122
  }
123
+ let parentRect = getBoundingClientRect(parent);
120
124
  let rect = {
121
125
  top: top - parentRect.top,
122
126
  left: left - parentRect.left,
@@ -171,6 +175,9 @@ const getAllScrollParents = (el, parents = []) => {
171
175
  const parent = el.parentNode;
172
176
  if (parent) {
173
177
  isScrollElement(parent) && parents.push(parent);
178
+ if (getStyleComputedProperty(parent, "position") === "fixed") {
179
+ return parents;
180
+ }
174
181
  return getAllScrollParents(parent, parents);
175
182
  }
176
183
  return parents;
@@ -374,10 +381,11 @@ Popper.prototype._getBoundaries = function(data, padding, boundariesElement) {
374
381
  let isFixed2 = data.offsets.popper.position === "fixed";
375
382
  let scrollTop = isFixed2 ? 0 : getScrollTopValue(scrollParent);
376
383
  let scrollLeft = isFixed2 ? 0 : getScrollLeftValue(scrollParent);
384
+ const viewportWindow = getRealWindow();
377
385
  boundaries = {
378
386
  top: 0 - (offsetParentRect.top - scrollTop),
379
- right: window.document.documentElement.clientWidth - (offsetParentRect.left - scrollLeft),
380
- bottom: window.document.documentElement.clientHeight - (offsetParentRect.top - scrollTop),
387
+ right: viewportWindow.document.documentElement.clientWidth - (offsetParentRect.left - scrollLeft),
388
+ bottom: viewportWindow.document.documentElement.clientHeight - (offsetParentRect.top - scrollTop),
381
389
  left: 0 - (offsetParentRect.left - scrollLeft)
382
390
  };
383
391
  } else {
package/dropdown/index.js CHANGED
@@ -135,12 +135,14 @@ const initEvent = ({ api, props, state, vm, mode }) => () => {
135
135
  }
136
136
  }
137
137
  };
138
- const handleMenuItemClick = ({ props, state, emit }) => (itemData, instance, isDisabled) => {
139
- state.isDisabled = isDisabled;
140
- if (props.hideOnClick) {
141
- !state.isDisabled && (state.visible = false);
138
+ const handleMenuItemClick = ({ props, state, emit }) => ({ itemData, vm, disabled }) => {
139
+ if (props.hideOnClick && !disabled) {
140
+ state.visible = false;
141
+ }
142
+ if (!disabled) {
143
+ const data = { itemData, vm, disabled };
144
+ emit("item-click", data);
142
145
  }
143
- emit("item-click", itemData, instance);
144
146
  };
145
147
  const triggerElmFocus = ({ state }) => () => {
146
148
  state.triggerElm.focus && state.triggerElm.focus();
@@ -185,9 +187,9 @@ const beforeDistory = ({ api, state }) => () => {
185
187
  state.dropdownElm = null;
186
188
  }
187
189
  };
188
- const clickOutside = ({ props, api, state }) => (value) => {
190
+ const clickOutside = ({ props, api }) => (disabled) => {
189
191
  if (props.hideOnClick) {
190
- state.isDisabled ? value ? api.show() : api.hide() : api.hide();
192
+ disabled ? api.show() : api.hide();
191
193
  }
192
194
  };
193
195
  export {
package/dropdown/vue.js CHANGED
@@ -34,7 +34,6 @@ const renderless = (props, { reactive, watch, provide, onMounted }, { emit, pare
34
34
  listId: `dropdown-menu-${guid()}`,
35
35
  showIcon: props.showIcon,
36
36
  showSelfIcon: props.showSelfIcon,
37
- isDisabled: false,
38
37
  designConfig
39
38
  });
40
39
  provide("dropdownVm", vm);
@@ -57,7 +56,7 @@ const renderless = (props, { reactive, watch, provide, onMounted }, { emit, pare
57
56
  triggerElmFocus: triggerElmFocus({ state }),
58
57
  initDomOperation: initDomOperation({ api: api2, state, vm }),
59
58
  beforeDistory: beforeDistory({ api: api2, state }),
60
- clickOutside: clickOutside({ state, props, api: api2 })
59
+ clickOutside: clickOutside({ props, api: api2 })
61
60
  });
62
61
  watch(() => state.visible, api2.watchVisible);
63
62
  watch(() => state.focusing, api2.watchFocusing);
@@ -92,7 +92,9 @@ const clickOutside = (parent) => () => {
92
92
  const handleClick = ({ props, dispatch, vm, emit }) => (event) => {
93
93
  event.stopPropagation();
94
94
  const data = { itemData: props.itemData, vm, disabled: props.disabled };
95
- emit("item-click", data);
95
+ if (!props.disabled) {
96
+ emit("item-click", data);
97
+ }
96
98
  dispatch("TinyDropdown", "menu-item-click", data);
97
99
  dispatch("TinyDropdown", "is-disabled", [props.disabled]);
98
100
  };
@@ -32,13 +32,14 @@ const renderless = (props, { reactive, inject }, { dispatch, vm }) => {
32
32
  dataStore2.currentIndex = `${props2.currentIndex}`;
33
33
  }
34
34
  dispatch("TinyDropdown", "selectedIndex", [dataStore2.currentIndex]);
35
- dispatch("TinyDropdownMenu", "menu-item-click", [
36
- dataStore2.itemData,
37
- vm2,
38
- dataStore2.itemLabel,
39
- dataStore2.showContent,
40
- props2.disabled
41
- ]);
35
+ const data = {
36
+ itemData: dataStore2.itemData,
37
+ vm: vm2,
38
+ label: dataStore2.itemLabel,
39
+ showContent: dataStore2.showContent,
40
+ disabled: props2.disabled
41
+ };
42
+ dispatch("TinyDropdownMenu", "menu-item-click", data);
42
43
  dispatch("TinyDropdown", "is-disabled", [props2.disabled]);
43
44
  };
44
45
  const mouseLeave = ({ dataStore: dataStore2 }) => () => {
@@ -129,10 +129,11 @@ const mounted = ({ api, parent, state }) => () => {
129
129
  state.showContent = showContent;
130
130
  });
131
131
  };
132
- const handleMenuItemClick = ({ state, dispatch }) => (itemData, instance, label, showContent, isDisabled) => {
132
+ const handleMenuItemClick = ({ state, dispatch }) => ({ itemData, vm, label, showContent, disabled }) => {
133
133
  state.label = label;
134
134
  state.showContent = showContent;
135
- dispatch("TinyDropdown", "current-item-click", [itemData, instance, isDisabled]);
135
+ const data = { itemData, vm, disabled };
136
+ dispatch("TinyDropdown", "current-item-click", data);
136
137
  };
137
138
  const handleMouseenter = ({ emit }) => ($event) => {
138
139
  emit("mouseenter", $event);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/vue-renderless",
3
- "version": "3.10.5",
3
+ "version": "3.10.7",
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
  "homepage": "https://opentiny.design/tiny-vue",
6
6
  "keywords": [