sprintify-ui 0.0.111 → 0.0.113

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.
@@ -16,7 +16,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
16
16
  default: boolean;
17
17
  type: BooleanConstructor;
18
18
  };
19
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("close" | "open")[], "close" | "open", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
19
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("close" | "open" | "mounted")[], "close" | "open" | "mounted", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
20
20
  placement: {
21
21
  type: PropType<"bottom-start" | "bottom-end" | "top-start" | "top-end">;
22
22
  default(): string;
@@ -34,6 +34,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
34
34
  type: BooleanConstructor;
35
35
  };
36
36
  }>> & {
37
+ onMounted?: ((...args: any[]) => any) | undefined;
37
38
  onClose?: ((...args: any[]) => any) | undefined;
38
39
  onOpen?: ((...args: any[]) => any) | undefined;
39
40
  }, {
@@ -49,7 +49,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
49
49
  default: undefined;
50
50
  type: PropType<SelectConfiguration | undefined>;
51
51
  };
52
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("close" | "update:model-value")[], "close" | "update:model-value", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
52
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("close" | "update:model-value" | "dropdown:mounted")[], "close" | "update:model-value" | "dropdown:mounted", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
53
53
  modelValue: {
54
54
  type: PropType<Option | Option[] | null | undefined>;
55
55
  default: undefined;
@@ -101,6 +101,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
101
101
  }>> & {
102
102
  onClose?: ((...args: any[]) => any) | undefined;
103
103
  "onUpdate:model-value"?: ((...args: any[]) => any) | undefined;
104
+ "onDropdown:mounted"?: ((...args: any[]) => any) | undefined;
104
105
  }, {
105
106
  required: boolean;
106
107
  select: SelectConfiguration | undefined;
@@ -1,6 +1,6 @@
1
1
  import { MaybeElementRef } from '@vueuse/core';
2
2
  interface UseClickOutsideOptions {
3
- includes?: MaybeElementRef[];
3
+ includes?: (MaybeElementRef | string)[];
4
4
  }
5
5
  export declare function useClickOutside(element: MaybeElementRef, callback: () => void, options?: UseClickOutsideOptions): {
6
6
  stop: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.0.111",
3
+ "version": "0.0.113",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -16,7 +16,7 @@
16
16
  leave-to-class="transform scale-95 opacity-0"
17
17
  >
18
18
  <template v-if="showDropdown || keepAlive">
19
- <div v-show="showDropdown" class="inline-block">
19
+ <div v-show="showDropdown" :id="id" class="inline-block">
20
20
  <slot
21
21
  name="dropdown"
22
22
  :show-dropdown="showDropdown"
@@ -35,7 +35,7 @@
35
35
  <script lang="ts" setup>
36
36
  import { useClickOutside } from '@/composables/clickOutside';
37
37
  import { useResizeObserver } from '@vueuse/core';
38
- import { throttle } from 'lodash';
38
+ import { throttle, uniqueId } from 'lodash';
39
39
  import { PropType, StyleValue } from 'vue';
40
40
  import { disableScroll, enableScroll } from '../utils';
41
41
 
@@ -44,6 +44,9 @@ const dropdown = ref<HTMLElement | null>(null);
44
44
 
45
45
  const showDropdown = ref(false);
46
46
 
47
+ // This is id is used to configure onClickOutside includes
48
+ const id = 'base-dropdown-drawer-' + uniqueId();
49
+
47
50
  const props = defineProps({
48
51
  placement: {
49
52
  type: String as PropType<
@@ -67,7 +70,7 @@ const props = defineProps({
67
70
  },
68
71
  });
69
72
 
70
- const emit = defineEmits(['close', 'open']);
73
+ const emit = defineEmits(['close', 'open', 'mounted']);
71
74
 
72
75
  const buttonX = ref(0);
73
76
  const buttonY = ref(0);
@@ -251,6 +254,12 @@ const dropdownStyles = computed((): StyleValue => {
251
254
  return styles as StyleValue;
252
255
  });
253
256
 
257
+ onMounted(() => {
258
+ emit('mounted', {
259
+ id: id,
260
+ });
261
+ });
262
+
254
263
  onBeforeUnmount(() => {
255
264
  close();
256
265
  deactivate();
@@ -6,6 +6,7 @@
6
6
  :padding="padding"
7
7
  @open="onOpen"
8
8
  @close="onClose"
9
+ @mounted="onDropdownMounted"
9
10
  >
10
11
  <template #button="buttonProps">
11
12
  <slot name="button" v-bind="buttonProps" :new-value="newValue"></slot>
@@ -124,7 +125,7 @@ const props = defineProps({
124
125
  },
125
126
  });
126
127
 
127
- const emit = defineEmits(['update:model-value', 'close']);
128
+ const emit = defineEmits(['update:model-value', 'close', 'dropdown:mounted']);
128
129
 
129
130
  const componentName = computed(() => {
130
131
  if (props.multiple) {
@@ -227,4 +228,8 @@ function getNewValue(value: Option | Option[] | null | undefined) {
227
228
  function update() {
228
229
  emit('update:model-value', newValue.value);
229
230
  }
231
+
232
+ function onDropdownMounted(payload: any) {
233
+ emit('dropdown:mounted', payload);
234
+ }
230
235
  </script>
@@ -1,7 +1,8 @@
1
1
  import { MaybeElementRef, unrefElement, tryOnScopeDispose } from '@vueuse/core';
2
+ import { isString } from 'lodash';
2
3
 
3
4
  interface UseClickOutsideOptions {
4
- includes?: MaybeElementRef[];
5
+ includes?: (MaybeElementRef | string)[];
5
6
  }
6
7
 
7
8
  export function useClickOutside(
@@ -27,7 +28,18 @@ export function useClickOutside(
27
28
  function onClick(e: Event) {
28
29
  const el = unrefElement(element);
29
30
 
30
- const includeEls = options.includes?.map(unrefElement) ?? [];
31
+ const includeEls = [] as Element[];
32
+
33
+ options.includes?.forEach((include) => {
34
+ if (isString(include)) {
35
+ includeEls.push(...document.querySelectorAll(include));
36
+ return;
37
+ }
38
+ const element = unrefElement(include);
39
+ if (element) {
40
+ includeEls.push(element);
41
+ }
42
+ }) ?? [];
31
43
 
32
44
  if (!el) {
33
45
  return;