sprintify-ui 0.0.113 → 0.0.115
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/sprintify-ui.es.js +6447 -6431
- package/dist/types/src/components/BaseClickOutside.vue.d.ts +26 -0
- package/dist/types/src/components/BaseDropdown.vue.d.ts +1 -2
- package/dist/types/src/components/BaseDropdownAutocomplete.vue.d.ts +1 -2
- package/dist/types/src/components/index.d.ts +2 -1
- package/dist/types/src/composables/clickOutside.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/BaseClickOutside.vue +37 -0
- package/src/components/BaseDropdown.stories.js +27 -0
- package/src/components/BaseDropdown.vue +10 -14
- package/src/components/BaseDropdownAutocomplete.vue +1 -6
- package/src/components/index.ts +2 -0
- package/src/composables/clickOutside.ts +14 -8
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MaybeElement } from '@vueuse/core';
|
|
2
|
+
import { MaybeRef } from '@vueuse/shared';
|
|
3
|
+
import { PropType } from 'vue';
|
|
4
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
5
|
+
includes: {
|
|
6
|
+
type: PropType<(string | MaybeRef<MaybeElement>)[]>;
|
|
7
|
+
default: () => never[];
|
|
8
|
+
};
|
|
9
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "clickOutside"[], "clickOutside", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
10
|
+
includes: {
|
|
11
|
+
type: PropType<(string | MaybeRef<MaybeElement>)[]>;
|
|
12
|
+
default: () => never[];
|
|
13
|
+
};
|
|
14
|
+
}>> & {
|
|
15
|
+
onClickOutside?: ((...args: any[]) => any) | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
includes: (string | MaybeRef<MaybeElement>)[];
|
|
18
|
+
}>, {
|
|
19
|
+
default: (_: {}) => any;
|
|
20
|
+
}>;
|
|
21
|
+
export default _default;
|
|
22
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
23
|
+
new (): {
|
|
24
|
+
$slots: S;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -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"
|
|
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<{
|
|
20
20
|
placement: {
|
|
21
21
|
type: PropType<"bottom-start" | "bottom-end" | "top-start" | "top-end">;
|
|
22
22
|
default(): string;
|
|
@@ -34,7 +34,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
34
34
|
type: BooleanConstructor;
|
|
35
35
|
};
|
|
36
36
|
}>> & {
|
|
37
|
-
onMounted?: ((...args: any[]) => any) | undefined;
|
|
38
37
|
onClose?: ((...args: any[]) => any) | undefined;
|
|
39
38
|
onOpen?: ((...args: any[]) => any) | undefined;
|
|
40
39
|
}, {
|
|
@@ -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"
|
|
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<{
|
|
53
53
|
modelValue: {
|
|
54
54
|
type: PropType<Option | Option[] | null | undefined>;
|
|
55
55
|
default: undefined;
|
|
@@ -101,7 +101,6 @@ 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;
|
|
105
104
|
}, {
|
|
106
105
|
required: boolean;
|
|
107
106
|
select: SelectConfiguration | undefined;
|
|
@@ -16,6 +16,7 @@ import BaseButtonGroup from './BaseButtonGroup.vue';
|
|
|
16
16
|
import BaseCard from './BaseCard.vue';
|
|
17
17
|
import BaseCardRow from './BaseCardRow.vue';
|
|
18
18
|
import BaseCharacterCounter from './BaseCharacterCounter.vue';
|
|
19
|
+
import BaseClickOutside from './BaseClickOutside.vue';
|
|
19
20
|
import BaseClipboard from './BaseClipboard.vue';
|
|
20
21
|
import BaseColor from './BaseColor.vue';
|
|
21
22
|
import BaseContainer from './BaseContainer.vue';
|
|
@@ -78,4 +79,4 @@ import BaseLayoutStacked from './BaseLayoutStacked.vue';
|
|
|
78
79
|
import BaseLayoutStackedConfigurable from './BaseLayoutStackedConfigurable.vue';
|
|
79
80
|
import BaseLayoutSidebar from './BaseLayoutSidebar.vue';
|
|
80
81
|
import BaseLayoutSidebarConfigurable from './BaseLayoutSidebarConfigurable.vue';
|
|
81
|
-
export { BaseActionItem, BaseAlert, BaseApp, BaseAppDialogs, BaseAppNotifications, BaseAutocomplete, BaseAutocompleteFetch, BaseAvatar, BaseAvatarGroup, BaseBadge, BaseBelongsTo, BaseBoolean, BaseBreadcrumbs, BaseButton, BaseButtonGroup, BaseCard, BaseCardRow, BaseCharacterCounter, BaseClipboard, BaseColor, BaseContainer, BaseCounter, BaseDataIterator, BaseDataTable, BaseDatePicker, BaseDateSelect, BaseDescriptionList, BaseDescriptionListItem, BaseDialog, BaseDropdown, BaseDropdownAutocomplete, BaseField, BaseFieldI18n, BaseFilePicker, BaseFileUploader, BaseForm, BaseHasMany, BaseIcon, BaseInput, BaseInputLabel, BaseLoadingCover, BaseMediaItem, BaseMediaLibrary, BaseMediaPreview, BaseMenu, BaseMenuItem, BaseModalCenter, BaseModalSide, BaseNavbar, BaseNavbarItem, BaseNavbarItemContent, BasePagination, BasePanel, BasePassword, BaseProgressCircle, BaseRadioGroup, BaseReadMore, BaseRichText, BaseSelect, BaseShortcut, BaseSideNavigation, BaseSideNavigationItem, BaseSkeleton, BaseStatistic, BaseSwitch, BaseSystemAlert, BaseTabs, BaseTabItem, BaseTagAutocomplete, BaseTagAutocompleteFetch, BaseTable, BaseTableColumn, BaseTextarea, BaseTextareaAutoresize, BaseTimeline, BaseTimelineItem, BaseLayoutStacked, BaseLayoutStackedConfigurable, BaseLayoutSidebar, BaseLayoutSidebarConfigurable, };
|
|
82
|
+
export { BaseActionItem, BaseAlert, BaseApp, BaseAppDialogs, BaseAppNotifications, BaseAutocomplete, BaseAutocompleteFetch, BaseAvatar, BaseAvatarGroup, BaseBadge, BaseBelongsTo, BaseBoolean, BaseBreadcrumbs, BaseButton, BaseButtonGroup, BaseCard, BaseCardRow, BaseCharacterCounter, BaseClickOutside, BaseClipboard, BaseColor, BaseContainer, BaseCounter, BaseDataIterator, BaseDataTable, BaseDatePicker, BaseDateSelect, BaseDescriptionList, BaseDescriptionListItem, BaseDialog, BaseDropdown, BaseDropdownAutocomplete, BaseField, BaseFieldI18n, BaseFilePicker, BaseFileUploader, BaseForm, BaseHasMany, BaseIcon, BaseInput, BaseInputLabel, BaseLoadingCover, BaseMediaItem, BaseMediaLibrary, BaseMediaPreview, BaseMenu, BaseMenuItem, BaseModalCenter, BaseModalSide, BaseNavbar, BaseNavbarItem, BaseNavbarItemContent, BasePagination, BasePanel, BasePassword, BaseProgressCircle, BaseRadioGroup, BaseReadMore, BaseRichText, BaseSelect, BaseShortcut, BaseSideNavigation, BaseSideNavigationItem, BaseSkeleton, BaseStatistic, BaseSwitch, BaseSystemAlert, BaseTabs, BaseTabItem, BaseTagAutocomplete, BaseTagAutocompleteFetch, BaseTable, BaseTableColumn, BaseTextarea, BaseTextareaAutoresize, BaseTimeline, BaseTimelineItem, BaseLayoutStacked, BaseLayoutStackedConfigurable, BaseLayoutSidebar, BaseLayoutSidebarConfigurable, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MaybeElementRef } from '@vueuse/core';
|
|
2
2
|
interface UseClickOutsideOptions {
|
|
3
|
-
includes?: (MaybeElementRef | string)[];
|
|
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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="root">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { useClickOutside } from '@/composables/clickOutside';
|
|
9
|
+
import { MaybeElement } from '@vueuse/core';
|
|
10
|
+
import { MaybeRef } from '@vueuse/shared';
|
|
11
|
+
import { PropType } from 'vue';
|
|
12
|
+
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
includes: {
|
|
15
|
+
type: Array as PropType<(MaybeRef<MaybeElement> | string)[]>,
|
|
16
|
+
default: () => [],
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const emit = defineEmits(['clickOutside']);
|
|
21
|
+
|
|
22
|
+
const root = ref<null | HTMLElement>(null);
|
|
23
|
+
|
|
24
|
+
const includes = [] as (MaybeRef<MaybeElement> | string)[];
|
|
25
|
+
|
|
26
|
+
function addInclude(include: MaybeRef<MaybeElement> | string) {
|
|
27
|
+
includes.push(include);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
provide('clickOutside:addInclude', addInclude);
|
|
31
|
+
|
|
32
|
+
useClickOutside(root, () => emit('clickOutside'), {
|
|
33
|
+
includes: () => {
|
|
34
|
+
return [...includes, ...props.includes];
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
@@ -3,6 +3,7 @@ import BaseAutocomplete from './BaseAutocomplete.vue';
|
|
|
3
3
|
import BaseModalCenter from './BaseModalCenter.vue';
|
|
4
4
|
import BaseDropdown from './BaseDropdown.vue';
|
|
5
5
|
import BaseDatePicker from './BaseDatePicker.vue';
|
|
6
|
+
import BaseClickOutside from './BaseClickOutside.vue';
|
|
6
7
|
import { options } from '../../.storybook/utils';
|
|
7
8
|
|
|
8
9
|
const items = [];
|
|
@@ -181,3 +182,29 @@ export const WithDatePicker = (args) => ({
|
|
|
181
182
|
WithDatePicker.args = {
|
|
182
183
|
placement: 'bottom-start',
|
|
183
184
|
};
|
|
185
|
+
|
|
186
|
+
export const WithinClickOutside = (args) => ({
|
|
187
|
+
components: { BaseDropdown, BaseClickOutside },
|
|
188
|
+
setup() {
|
|
189
|
+
function onClickOutside() {
|
|
190
|
+
alert('click outside');
|
|
191
|
+
}
|
|
192
|
+
return { args, items, onClickOutside };
|
|
193
|
+
},
|
|
194
|
+
template: `
|
|
195
|
+
<BaseClickOutside @clickOutside="onClickOutside">
|
|
196
|
+
<div class="bg-slate-200 shadow-md min-h-[100px] p-3">
|
|
197
|
+
<BaseDropdown v-bind="args">
|
|
198
|
+
<template #button>
|
|
199
|
+
<div class="btn btn-primary">Click me</div>
|
|
200
|
+
</template>
|
|
201
|
+
<template #dropdown>
|
|
202
|
+
<div class="bg-white shadow-lg rounded border p-2 w-[260px]">
|
|
203
|
+
...
|
|
204
|
+
</div>
|
|
205
|
+
</template>
|
|
206
|
+
</BaseDropdown>
|
|
207
|
+
</div>
|
|
208
|
+
</BaseClickOutside>
|
|
209
|
+
`,
|
|
210
|
+
});
|
|
@@ -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"
|
|
19
|
+
<div v-show="showDropdown" class="inline-block">
|
|
20
20
|
<slot
|
|
21
21
|
name="dropdown"
|
|
22
22
|
:show-dropdown="showDropdown"
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
|
|
35
35
|
<script lang="ts" setup>
|
|
36
36
|
import { useClickOutside } from '@/composables/clickOutside';
|
|
37
|
-
import { useResizeObserver } from '@vueuse/core';
|
|
38
|
-
import { throttle
|
|
37
|
+
import { MaybeElement, MaybeRef, useResizeObserver } from '@vueuse/core';
|
|
38
|
+
import { throttle } from 'lodash';
|
|
39
39
|
import { PropType, StyleValue } from 'vue';
|
|
40
40
|
import { disableScroll, enableScroll } from '../utils';
|
|
41
41
|
|
|
@@ -43,10 +43,6 @@ const button = ref<HTMLElement | null>(null);
|
|
|
43
43
|
const dropdown = ref<HTMLElement | null>(null);
|
|
44
44
|
|
|
45
45
|
const showDropdown = ref(false);
|
|
46
|
-
|
|
47
|
-
// This is id is used to configure onClickOutside includes
|
|
48
|
-
const id = 'base-dropdown-drawer-' + uniqueId();
|
|
49
|
-
|
|
50
46
|
const props = defineProps({
|
|
51
47
|
placement: {
|
|
52
48
|
type: String as PropType<
|
|
@@ -70,7 +66,7 @@ const props = defineProps({
|
|
|
70
66
|
},
|
|
71
67
|
});
|
|
72
68
|
|
|
73
|
-
const emit = defineEmits(['close', 'open'
|
|
69
|
+
const emit = defineEmits(['close', 'open']);
|
|
74
70
|
|
|
75
71
|
const buttonX = ref(0);
|
|
76
72
|
const buttonY = ref(0);
|
|
@@ -166,7 +162,7 @@ useClickOutside(
|
|
|
166
162
|
close();
|
|
167
163
|
}
|
|
168
164
|
},
|
|
169
|
-
{ includes: [button] }
|
|
165
|
+
{ includes: () => [button] }
|
|
170
166
|
);
|
|
171
167
|
|
|
172
168
|
const placementInternal = computed(() => {
|
|
@@ -254,11 +250,11 @@ const dropdownStyles = computed((): StyleValue => {
|
|
|
254
250
|
return styles as StyleValue;
|
|
255
251
|
});
|
|
256
252
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
253
|
+
const addClickOutsideInclude = inject('clickOutside:addInclude', () => {
|
|
254
|
+
return;
|
|
255
|
+
}) as (include: MaybeRef<MaybeElement> | string) => void;
|
|
256
|
+
|
|
257
|
+
addClickOutsideInclude(dropdown);
|
|
262
258
|
|
|
263
259
|
onBeforeUnmount(() => {
|
|
264
260
|
close();
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
:padding="padding"
|
|
7
7
|
@open="onOpen"
|
|
8
8
|
@close="onClose"
|
|
9
|
-
@mounted="onDropdownMounted"
|
|
10
9
|
>
|
|
11
10
|
<template #button="buttonProps">
|
|
12
11
|
<slot name="button" v-bind="buttonProps" :new-value="newValue"></slot>
|
|
@@ -125,7 +124,7 @@ const props = defineProps({
|
|
|
125
124
|
},
|
|
126
125
|
});
|
|
127
126
|
|
|
128
|
-
const emit = defineEmits(['update:model-value', 'close'
|
|
127
|
+
const emit = defineEmits(['update:model-value', 'close']);
|
|
129
128
|
|
|
130
129
|
const componentName = computed(() => {
|
|
131
130
|
if (props.multiple) {
|
|
@@ -228,8 +227,4 @@ function getNewValue(value: Option | Option[] | null | undefined) {
|
|
|
228
227
|
function update() {
|
|
229
228
|
emit('update:model-value', newValue.value);
|
|
230
229
|
}
|
|
231
|
-
|
|
232
|
-
function onDropdownMounted(payload: any) {
|
|
233
|
-
emit('dropdown:mounted', payload);
|
|
234
|
-
}
|
|
235
230
|
</script>
|
package/src/components/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ import BaseButtonGroup from './BaseButtonGroup.vue';
|
|
|
16
16
|
import BaseCard from './BaseCard.vue';
|
|
17
17
|
import BaseCardRow from './BaseCardRow.vue';
|
|
18
18
|
import BaseCharacterCounter from './BaseCharacterCounter.vue';
|
|
19
|
+
import BaseClickOutside from './BaseClickOutside.vue';
|
|
19
20
|
import BaseClipboard from './BaseClipboard.vue';
|
|
20
21
|
import BaseColor from './BaseColor.vue';
|
|
21
22
|
import BaseContainer from './BaseContainer.vue';
|
|
@@ -99,6 +100,7 @@ export {
|
|
|
99
100
|
BaseCard,
|
|
100
101
|
BaseCardRow,
|
|
101
102
|
BaseCharacterCounter,
|
|
103
|
+
BaseClickOutside,
|
|
102
104
|
BaseClipboard,
|
|
103
105
|
BaseColor,
|
|
104
106
|
BaseContainer,
|
|
@@ -2,7 +2,7 @@ import { MaybeElementRef, unrefElement, tryOnScopeDispose } from '@vueuse/core';
|
|
|
2
2
|
import { isString } from 'lodash';
|
|
3
3
|
|
|
4
4
|
interface UseClickOutsideOptions {
|
|
5
|
-
includes?: (MaybeElementRef | string)[];
|
|
5
|
+
includes?: () => (MaybeElementRef | string)[];
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export function useClickOutside(
|
|
@@ -30,16 +30,22 @@ export function useClickOutside(
|
|
|
30
30
|
|
|
31
31
|
const includeEls = [] as Element[];
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const optionIncludes = [];
|
|
34
|
+
|
|
35
|
+
if (options.includes) {
|
|
36
|
+
optionIncludes.push(...options.includes());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
optionIncludes.forEach((include) => {
|
|
34
40
|
if (isString(include)) {
|
|
35
41
|
includeEls.push(...document.querySelectorAll(include));
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
} else {
|
|
43
|
+
const element = unrefElement(include);
|
|
44
|
+
if (element) {
|
|
45
|
+
includeEls.push(element);
|
|
46
|
+
}
|
|
41
47
|
}
|
|
42
|
-
})
|
|
48
|
+
});
|
|
43
49
|
|
|
44
50
|
if (!el) {
|
|
45
51
|
return;
|