sprintify-ui 0.0.146 → 0.0.148
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 +2629 -2561
- package/dist/types/src/components/BaseIconPicker.vue.d.ts +33 -0
- package/dist/types/src/components/index.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/BaseIconPicker.stories.js +22 -0
- package/src/components/BaseIconPicker.vue +133 -0
- package/src/components/index.ts +2 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
+
modelValue?: string | null | undefined;
|
|
3
|
+
collection?: string | undefined;
|
|
4
|
+
}>, {
|
|
5
|
+
modelValue: null;
|
|
6
|
+
collection: string;
|
|
7
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
8
|
+
modelValue?: string | null | undefined;
|
|
9
|
+
collection?: string | undefined;
|
|
10
|
+
}>, {
|
|
11
|
+
modelValue: null;
|
|
12
|
+
collection: string;
|
|
13
|
+
}>>> & {
|
|
14
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
modelValue: string | null;
|
|
17
|
+
collection: string;
|
|
18
|
+
}>;
|
|
19
|
+
export default _default;
|
|
20
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
21
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
22
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
23
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
24
|
+
} : {
|
|
25
|
+
type: import('vue').PropType<T[K]>;
|
|
26
|
+
required: true;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
type __VLS_WithDefaults<P, D> = {
|
|
30
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? P[K] & {
|
|
31
|
+
default: D[K];
|
|
32
|
+
} : P[K];
|
|
33
|
+
};
|
|
@@ -39,6 +39,7 @@ import BaseFileUploader from './BaseFileUploader.vue';
|
|
|
39
39
|
import BaseForm from './BaseForm.vue';
|
|
40
40
|
import BaseHasMany from './BaseHasMany.vue';
|
|
41
41
|
import { Icon as BaseIcon } from '@iconify/vue';
|
|
42
|
+
import BaseIconPicker from './BaseIconPicker.vue';
|
|
42
43
|
import BaseInput from './BaseInput.vue';
|
|
43
44
|
import BaseInputLabel from './BaseInputLabel.vue';
|
|
44
45
|
import BaseInputPercent from './BaseInputPercent.vue';
|
|
@@ -83,4 +84,4 @@ import BaseLayoutStacked from './BaseLayoutStacked.vue';
|
|
|
83
84
|
import BaseLayoutStackedConfigurable from './BaseLayoutStackedConfigurable.vue';
|
|
84
85
|
import BaseLayoutSidebar from './BaseLayoutSidebar.vue';
|
|
85
86
|
import BaseLayoutSidebarConfigurable from './BaseLayoutSidebarConfigurable.vue';
|
|
86
|
-
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, BaseDisplayRelativeTime, BaseDropdown, BaseDropdownAutocomplete, BaseEmptyState, BaseField, BaseFieldI18n, BaseFilePicker, BaseFileUploader, BaseForm, BaseHasMany, BaseIcon, BaseInput, BaseInputLabel, BaseInputPercent, BaseLoadingCover, BaseMediaItem, BaseMediaLibrary, BaseMediaPreview, BaseMenu, BaseMenuItem, BaseModalCenter, BaseModalSide, BaseNavbar, BaseNavbarItem, BaseNavbarItemContent, BaseNumber, 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, };
|
|
87
|
+
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, BaseDisplayRelativeTime, BaseDropdown, BaseDropdownAutocomplete, BaseEmptyState, BaseField, BaseFieldI18n, BaseFilePicker, BaseFileUploader, BaseForm, BaseHasMany, BaseIcon, BaseIconPicker, BaseInput, BaseInputLabel, BaseInputPercent, BaseLoadingCover, BaseMediaItem, BaseMediaLibrary, BaseMediaPreview, BaseMenu, BaseMenuItem, BaseModalCenter, BaseModalSide, BaseNavbar, BaseNavbarItem, BaseNavbarItemContent, BaseNumber, 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, };
|
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import BaseIconPicker from './BaseIconPicker.vue';
|
|
2
|
+
import ShowValue from '../../.storybook/components/ShowValue.vue';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Components/BaseIconPicker',
|
|
6
|
+
component: BaseIconPicker,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const Template = (args) => ({
|
|
10
|
+
components: { BaseIconPicker, ShowValue },
|
|
11
|
+
setup() {
|
|
12
|
+
const value = ref(null);
|
|
13
|
+
return { args, value };
|
|
14
|
+
},
|
|
15
|
+
template: `
|
|
16
|
+
<BaseIconPicker v-bind="args" v-model="value"></BaseIconPicker>
|
|
17
|
+
<ShowValue :value="value" />
|
|
18
|
+
`,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const Demo = Template.bind({});
|
|
22
|
+
Demo.args = {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="w-full max-w-[268px] overflow-hidden rounded border bg-white">
|
|
3
|
+
<div class="flex w-full min-w-0 overflow-hidden px-3 pt-3">
|
|
4
|
+
<select
|
|
5
|
+
v-model="suffix"
|
|
6
|
+
class="max-w-[80px] shrink-0 rounded-l border-r-0 border-slate-300 text-xs focus:border-slate-300 focus:outline-none focus:ring-0"
|
|
7
|
+
@change="scrollTop"
|
|
8
|
+
>
|
|
9
|
+
<option v-for="(label, key) in suffixes" :key="key" :value="key">
|
|
10
|
+
{{ label }}
|
|
11
|
+
</option>
|
|
12
|
+
</select>
|
|
13
|
+
|
|
14
|
+
<input
|
|
15
|
+
v-model="keywords"
|
|
16
|
+
type="text"
|
|
17
|
+
:placeholder="$t('sui.autocomplete_placeholder')"
|
|
18
|
+
class="grow rounded-r border-slate-300 text-xs"
|
|
19
|
+
/>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div ref="drawer" class="h-44 overflow-y-auto py-2 px-3">
|
|
23
|
+
<ul class="flex flex-wrap">
|
|
24
|
+
<li v-for="icon in filteredIcons" :key="icon">
|
|
25
|
+
<button
|
|
26
|
+
type="button"
|
|
27
|
+
:class="[
|
|
28
|
+
modelValue == icon
|
|
29
|
+
? 'bg-primary-600 text-white'
|
|
30
|
+
: 'bg-white text-slate-900 hover:bg-slate-200',
|
|
31
|
+
]"
|
|
32
|
+
class="flex items-center justify-center rounded p-1"
|
|
33
|
+
@click="onClick(icon)"
|
|
34
|
+
>
|
|
35
|
+
<BaseIcon :icon="icon" />
|
|
36
|
+
</button>
|
|
37
|
+
</li>
|
|
38
|
+
</ul>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script lang="ts" setup>
|
|
44
|
+
import { BaseIcon, config } from '..';
|
|
45
|
+
|
|
46
|
+
const props = withDefaults(
|
|
47
|
+
defineProps<{
|
|
48
|
+
modelValue?: string | null;
|
|
49
|
+
collection?: string;
|
|
50
|
+
}>(),
|
|
51
|
+
{
|
|
52
|
+
modelValue: null,
|
|
53
|
+
collection: 'heroicons',
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const emit = defineEmits(['update:modelValue']);
|
|
58
|
+
|
|
59
|
+
function onClick(icon: string) {
|
|
60
|
+
emit('update:modelValue', icon);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const icons = ref<string[]>([]);
|
|
64
|
+
const suffixes = ref<Record<string, string>>({});
|
|
65
|
+
const suffix = ref<string | null>(null);
|
|
66
|
+
const otherSuffixValue = computed(() => {
|
|
67
|
+
return Object.keys(suffixes.value).filter((s) => {
|
|
68
|
+
return s !== suffix.value;
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const drawer = ref<HTMLElement | null>(null);
|
|
73
|
+
|
|
74
|
+
const fullIcons = computed(() => {
|
|
75
|
+
return icons.value.map((icon) => {
|
|
76
|
+
return props.collection + ':' + icon;
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const visibleIcons = computed(() => {
|
|
81
|
+
return fullIcons.value.filter((i) => {
|
|
82
|
+
const matchCurrent = i.endsWith(suffix.value ?? '');
|
|
83
|
+
|
|
84
|
+
if (!matchCurrent) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const matches = otherSuffixValue.value.filter((s) => {
|
|
89
|
+
return i.endsWith(s);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const anotherMatchHasBiggerWeight = matches.some((m) => {
|
|
93
|
+
return m.length > (suffix.value ?? '').length;
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (anotherMatchHasBiggerWeight) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return true;
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const keywords = ref('');
|
|
105
|
+
|
|
106
|
+
const filteredIcons = computed(() => {
|
|
107
|
+
if (!keywords.value) {
|
|
108
|
+
return visibleIcons.value;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return visibleIcons.value.filter((i) => {
|
|
112
|
+
return i.toLocaleLowerCase().includes(keywords.value.toLowerCase());
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
function fetchIcons() {
|
|
117
|
+
fetch('https://api.iconify.design/collection?prefix=' + props.collection)
|
|
118
|
+
.then((response) => response.json())
|
|
119
|
+
.then((data) => {
|
|
120
|
+
icons.value = data.uncategorized;
|
|
121
|
+
suffixes.value = data.suffixes;
|
|
122
|
+
suffix.value = Object.keys(suffixes.value)[0] as string;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
fetchIcons();
|
|
127
|
+
|
|
128
|
+
function scrollTop() {
|
|
129
|
+
if (drawer.value) {
|
|
130
|
+
drawer.value.scrollTop = 0;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
</script>
|
package/src/components/index.ts
CHANGED
|
@@ -39,6 +39,7 @@ import BaseFileUploader from './BaseFileUploader.vue';
|
|
|
39
39
|
import BaseForm from './BaseForm.vue';
|
|
40
40
|
import BaseHasMany from './BaseHasMany.vue';
|
|
41
41
|
import { Icon as BaseIcon } from '@iconify/vue';
|
|
42
|
+
import BaseIconPicker from './BaseIconPicker.vue';
|
|
42
43
|
import BaseInput from './BaseInput.vue';
|
|
43
44
|
import BaseInputLabel from './BaseInputLabel.vue';
|
|
44
45
|
import BaseInputPercent from './BaseInputPercent.vue';
|
|
@@ -127,6 +128,7 @@ export {
|
|
|
127
128
|
BaseForm,
|
|
128
129
|
BaseHasMany,
|
|
129
130
|
BaseIcon,
|
|
131
|
+
BaseIconPicker,
|
|
130
132
|
BaseInput,
|
|
131
133
|
BaseInputLabel,
|
|
132
134
|
BaseInputPercent,
|