@idds/vue 1.4.12 → 1.4.14

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/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineComponent, inject, ref, computed, onMounted, onUnmounted, watch, createElementBlock, openBlock, normalizeClass, createElementVNode, renderSlot, createTextVNode, toDisplayString, createVNode, createCommentVNode, createBlock, resolveDynamicComponent, Transition, withCtx, provide, withModifiers, normalizeStyle, nextTick, h, unref, Fragment, renderList, mergeProps, useAttrs, withDirectives, vModelDynamic, withKeys, vModelText, Teleport, createStaticVNode, vModelRadio } from "vue";
1
+ import { defineComponent, inject, ref, computed, onMounted, onUnmounted, watch, createElementBlock, openBlock, normalizeClass, createElementVNode, renderSlot, createTextVNode, toDisplayString, createVNode, createCommentVNode, createBlock, resolveDynamicComponent, Transition, withCtx, provide, withModifiers, normalizeStyle, nextTick, h, unref, Fragment, renderList, mergeProps, useAttrs, withDirectives, vModelDynamic, Teleport, withKeys, vModelText, createStaticVNode, vModelRadio } from "vue";
2
2
  const iddsColorTokens = {
3
3
  // Neutral Colors
4
4
  "neutral-25": "var(--ina-neutral-25)",
@@ -2924,6 +2924,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
2924
2924
  const props = __props;
2925
2925
  const containerRef = ref();
2926
2926
  const isOpen = ref(false);
2927
+ const mounted = ref(false);
2927
2928
  const dropdownPosition = ref({ vertical: "bottom", horizontal: "right" });
2928
2929
  const displayItems = computed(() => {
2929
2930
  return props.items || [];
@@ -2960,6 +2961,19 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
2960
2961
  ...props.dropdownStyle
2961
2962
  };
2962
2963
  });
2964
+ const computedDropdownStyle = computed(() => {
2965
+ const style = {
2966
+ ...dropdownStyle.value,
2967
+ position: "absolute"
2968
+ };
2969
+ if (dropdownPosition.value.top !== void 0) {
2970
+ style.top = `${dropdownPosition.value.top}px`;
2971
+ }
2972
+ if (dropdownPosition.value.left !== void 0) {
2973
+ style.left = `${dropdownPosition.value.left}px`;
2974
+ }
2975
+ return style;
2976
+ });
2963
2977
  const handleTriggerClick = (e) => {
2964
2978
  e.stopPropagation();
2965
2979
  if (props.disabled) return;
@@ -2971,7 +2985,21 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
2971
2985
  const vertical = fitsBelow ? "bottom" : "top";
2972
2986
  const fitsRight = rect.right + props.dropdownWidth <= window.innerWidth;
2973
2987
  const horizontal = fitsRight ? "right" : "left";
2974
- dropdownPosition.value = { vertical, horizontal };
2988
+ const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
2989
+ const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
2990
+ let top = 0;
2991
+ let left = 0;
2992
+ if (vertical === "bottom") {
2993
+ top = rect.bottom + scrollTop + 8;
2994
+ } else {
2995
+ top = rect.top + scrollTop - dropdownHeight - 8;
2996
+ }
2997
+ if (horizontal === "right") {
2998
+ left = rect.left + scrollLeft;
2999
+ } else {
3000
+ left = rect.right + scrollLeft - props.dropdownWidth;
3001
+ }
3002
+ dropdownPosition.value = { vertical, horizontal, top, left };
2975
3003
  }
2976
3004
  isOpen.value = !isOpen.value;
2977
3005
  };
@@ -2981,6 +3009,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
2981
3009
  }
2982
3010
  };
2983
3011
  onMounted(() => {
3012
+ mounted.value = true;
2984
3013
  document.addEventListener("click", handleClickOutside);
2985
3014
  });
2986
3015
  onUnmounted(() => {
@@ -3002,38 +3031,43 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
3002
3031
  ], 64))
3003
3032
  ], true)
3004
3033
  ], 2),
3005
- createVNode(Transition, { name: "dropdown" }, {
3006
- default: withCtx(() => [
3007
- isOpen.value ? (openBlock(), createElementBlock("div", {
3008
- key: 0,
3009
- class: normalizeClass(menuClasses.value),
3010
- style: normalizeStyle(dropdownStyle.value),
3011
- role: "menu",
3012
- onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
3013
- }, ["stop"]))
3014
- }, [
3015
- createElementVNode("ul", _hoisted_1$t, [
3016
- (openBlock(true), createElementBlock(Fragment, null, renderList(displayItems.value, (item, idx) => {
3017
- return openBlock(), createElementBlock("li", {
3018
- key: idx,
3019
- role: "none"
3020
- }, [
3021
- (openBlock(), createBlock(resolveDynamicComponent(item), {
3022
- class: normalizeClass("ina-dropdown__item")
3023
- }))
3024
- ]);
3025
- }), 128))
3026
- ]),
3027
- renderSlot(_ctx.$slots, "default", {}, void 0, true)
3028
- ], 38)) : createCommentVNode("", true)
3029
- ]),
3030
- _: 3
3031
- })
3034
+ mounted.value ? (openBlock(), createBlock(Teleport, {
3035
+ key: 0,
3036
+ to: "body"
3037
+ }, [
3038
+ createVNode(Transition, { name: "dropdown" }, {
3039
+ default: withCtx(() => [
3040
+ isOpen.value ? (openBlock(), createElementBlock("div", {
3041
+ key: 0,
3042
+ class: normalizeClass(menuClasses.value),
3043
+ style: normalizeStyle(computedDropdownStyle.value),
3044
+ role: "menu",
3045
+ onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
3046
+ }, ["stop"]))
3047
+ }, [
3048
+ createElementVNode("ul", _hoisted_1$t, [
3049
+ (openBlock(true), createElementBlock(Fragment, null, renderList(displayItems.value, (item, idx) => {
3050
+ return openBlock(), createElementBlock("li", {
3051
+ key: idx,
3052
+ role: "none"
3053
+ }, [
3054
+ (openBlock(), createBlock(resolveDynamicComponent(item), {
3055
+ class: normalizeClass("ina-dropdown__item")
3056
+ }))
3057
+ ]);
3058
+ }), 128))
3059
+ ]),
3060
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
3061
+ ], 38)) : createCommentVNode("", true)
3062
+ ]),
3063
+ _: 3
3064
+ })
3065
+ ])) : createCommentVNode("", true)
3032
3066
  ], 2);
3033
3067
  };
3034
3068
  }
3035
3069
  });
3036
- const Dropdown = /* @__PURE__ */ _export_sfc(_sfc_main$x, [["__scopeId", "data-v-37b57e49"]]);
3070
+ const Dropdown = /* @__PURE__ */ _export_sfc(_sfc_main$x, [["__scopeId", "data-v-caab13f9"]]);
3037
3071
  const _hoisted_1$s = { class: "ina-field-input-table__wrapper" };
3038
3072
  const _hoisted_2$r = { class: "ina-field-input-table__label" };
3039
3073
  const _hoisted_3$p = ["value"];