Skip to content

Commit

Permalink
feat: typed slots and generic components (#178)
Browse files Browse the repository at this point in the history
* feat(Alert): add typed slots

* feat(AppBar): add typed slots

* feat(AppShell): add typed slots

* feat(Autocomplete): add typed slots

* feat(Avatar): add typed slots

* feat(Badge): add typed slots

* chore(vscode): enable format on save

* feat(Banner): add typed slots

* feat(BottomNavigation): add typed slots

* feat(BottomSheet): add typed slots

* feat(Breadcrumbs): add typed slots

* feat(Button): add typed slots

* feat(Card): add typed slots

* feat(Collapsible): add typed slots

* feat(Command): add typed slots

* feat(Container): add typed slots

* feat(Dropdown): add typed slots

* feat(Forms): add typed slots

* feat(List): add typed slots

* feat(Menus): add typed slots

* feat(Modal): add typed slots

* feat(MultiSelect): add typed slots

* feat(NavDrawer): add typed slots

* feat(Pagination): add typed slots

* feat(Popover): add typed slots

* feat(ProgressBar): add typed slots

* feat(ProgressCircular): add typed slots

* feat(Select): add typed slots

* feat(Stepper): add typed slots

* feat(Switch): add typed slots

* feat(Breadcrumbs): add typed slots

* feat(DataTable): add typed slots

* fix(DataTable): fix generate slot name

* feat(Tabs): add typed slots

* feat(Text): add typed slots

* feat(Toast): add typed slots

* feat(Tooltip): add typed slots

* chore(Select): fix types
  • Loading branch information
gravitano authored Jul 31, 2023
1 parent c1318cf commit 4c59596
Show file tree
Hide file tree
Showing 92 changed files with 1,204 additions and 360 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}
7 changes: 7 additions & 0 deletions packages/alert/src/VAlert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ onMounted(() => {
);
}
});
defineSlots<{
default?: (props: {}) => any
icon?: (props: { icon: string }) => any
'x-button'?: (props: { dismiss: () => void }) => any
'x-icon'?: (props: {}) => any
}>()
</script>

<template>
Expand Down
4 changes: 4 additions & 0 deletions packages/alert/src/VAlertGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ type Props = {
withDefaults(defineProps<Props>(), {
name: 'alert-group-transition',
});
defineSlots<{
default?: (props: {}) => any
}>()
</script>

<template>
Expand Down
4 changes: 4 additions & 0 deletions packages/alert/src/VAlertTitle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ withDefaults(
);
const api = useAlert();
defineSlots<{
default?: (props: {}) => any
}>()
</script>

<template>
Expand Down
4 changes: 4 additions & 0 deletions packages/app-bar/src/VAppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ if (props.hideOnScroll) {
window.removeEventListener('scroll', handleScroll);
});
}
defineSlots<{
default?: (props: {toggle: () => boolean}) => any
}>()
</script>

<template>
Expand Down
10 changes: 10 additions & 0 deletions packages/app-shell/src/VAppShell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ defineProps<{
containerClass?: string;
paddedContent?: boolean;
}>();
defineSlots<{
default?: (props: {}) => any
header?: (props: {}) => any
aside?: (props: {}) => any
navigation?: (props: {}) => any
'container.after'?: (props: {}) => any
'content.after'?: (props: {}) => any
footer?: (props: {}) => any
}>()
</script>

<template>
Expand Down
4 changes: 4 additions & 0 deletions packages/app-shell/src/VMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ defineProps<{
centered?: boolean;
fluid?: boolean;
}>();
defineSlots<{
default?: (props: {}) => any
}>()
</script>

<template>
Expand Down
26 changes: 26 additions & 0 deletions packages/autocomplete/src/Autocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,32 @@ const defaultDisplayValue = (item: any) => {
const displayValue = computed(() => {
return props.displayValue ?? defaultDisplayValue;
});
defineSlots<{
default?: (props: {}) => any
hint?: (props: {}) => any
selection?: (props: {
selected: ModelValue;
multiple?: boolean;
itemValue?: string;
itemText?: string;
selectionItemProps?: InstanceType<typeof VBadge>['$props'];
}) => any
'selection-item'?: (props: {
item: any;
idx: any;
itemValue?: string;
itemText?: string;
remove: () => void;
}) => any
item?: (props: {
item: any;
active: boolean;
selected: boolean;
itemValue?: string;
itemText?: string;
}) => any
}>()
</script>

<template>
Expand Down
5 changes: 5 additions & 0 deletions packages/autocomplete/src/VAutocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ const clear = () => {
query.value = '';
clearField()
};
defineSlots<{
default?: (props: {}) => any
hint?: (props: {}) => any
}>()
</script>

<template>
Expand Down
7 changes: 6 additions & 1 deletion packages/avatar/src/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type Props = {
src?: string;
name?: string;
maxInitial?: number;
indicator?: 'online' | 'verified' | string;
indicator?: 'online' | 'verified' | (string & {});
indicatorClass?: string;
width?: string | number;
height?: string | number;
Expand Down Expand Up @@ -62,6 +62,11 @@ const computedStyle = computed(() => {
return {};
});
defineSlots<{
default?: (props: {}) => any;
indicator?: (props: {indicator: Props['indicator']}) => any;
}>()
</script>

<template>
Expand Down
4 changes: 4 additions & 0 deletions packages/avatar/src/AvatarGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const computedStyles = computed(() => {
return {};
});
defineSlots<{
default?: (props: {}) => any;
}>()
</script>

<template>
Expand Down
5 changes: 5 additions & 0 deletions packages/badge/src/VBadge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ const classes = computed(() => {
},
];
});
defineSlots<{
default?: (props: {}) => any;
dismissable?: (props: { dismiss: () => void }) => any;
}>()
</script>

<template>
Expand Down
6 changes: 5 additions & 1 deletion packages/badge/src/VBadgeContent.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<script setup lang="ts"></script>
<script setup lang="ts">
defineSlots<{
default?: (props: {}) => any;
}>()
</script>

<template>
<div class="badge-content">
Expand Down
4 changes: 4 additions & 0 deletions packages/badge/src/VBadgeGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const api: VBadgeContextApi = {
};
provide(VBadgeInjectionKey, api);
defineSlots<{
default?: (props: {}) => any;
}>()
</script>

<template>
Expand Down
6 changes: 6 additions & 0 deletions packages/banner/src/VBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ const api = {
};
provide(VBannerSymbol, api);
defineSlots<{
default?: (props: {}) => any;
prefix?: (props: {close: () => void; isOpen: boolean}) => any;
actions?: (props: {close: () => void; isOpen: boolean}) => any;
}>();
</script>

<template>
Expand Down
4 changes: 4 additions & 0 deletions packages/banner/src/VBannerText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ withDefaults(
tag: 'div',
},
);
defineSlots<{
default?: (props: {}) => any;
}>();
</script>

<template>
Expand Down
37 changes: 21 additions & 16 deletions packages/bottom-navigation/src/VBottomNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ export default {
</script>

<script setup lang="ts">
import type { DefaultColors } from "@morpheme/theme/defaultTheme";
import { useVModel } from "@vueuse/core";
import { provide, ref, watch } from "vue";
import { VBottomNavigationInjectionKey } from "./api";
import type {DefaultColors} from '@morpheme/theme/defaultTheme';
import {useVModel} from '@vueuse/core';
import {provide, ref, watch} from 'vue';
import {VBottomNavigationInjectionKey} from './api';
const props = withDefaults(
defineProps<{
Expand All @@ -19,22 +19,23 @@ const props = withDefaults(
defaultActive?: number;
transition?: string;
hideSlider?: boolean;
variant?: "filled" | "bordered" | "filled-bordered";
variant?: 'filled' | 'bordered' | 'filled-bordered';
}>(),
{
color: "primary",
color: 'primary',
modelValue: true,
fixed: true,
defaultActive: 0,
transition: "slide-up",
}
transition: 'slide-up',
},
);
const emit = defineEmits<{
(e: "update:modelValue", value: boolean): void;
}>();
const emit =
defineEmits<{
(e: 'update:modelValue', value: boolean): void;
}>();
const modelValue = useVModel(props, "modelValue", emit);
const modelValue = useVModel(props, 'modelValue', emit);
function toggle() {
modelValue.value = !modelValue.value;
Expand Down Expand Up @@ -79,12 +80,12 @@ function isActive(el: HTMLButtonElement) {
function setSliderPosition(el: HTMLButtonElement) {
if (slider.value) {
if (props.variant === "filled") {
if (props.variant === 'filled') {
slider.value.style.height = `${el.offsetHeight}px`;
}
slider.value.style.width = `${el.offsetWidth}px`;
slider.value.style.left = `${el.offsetLeft}px`;
slider.value.style.display = "block";
slider.value.style.display = 'block';
}
}
Expand All @@ -101,7 +102,7 @@ watch(
}
}
},
{ immediate: true }
{immediate: true},
);
function setInitalActive() {
Expand All @@ -113,7 +114,7 @@ watch(
() => {
setInitalActive();
},
{ immediate: true, deep: true }
{immediate: true, deep: true},
);
const api = {
Expand All @@ -134,6 +135,10 @@ const api = {
provide(VBottomNavigationInjectionKey, api);
defineExpose(api);
defineSlots<{
default?: (props: {}) => any;
}>();
</script>

<template>
Expand Down
5 changes: 5 additions & 0 deletions packages/bottom-navigation/src/VBottomNavigationItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ const attributes = computed(() => {
return attrs
})
defineSlots<{
default?: (props: {}) => any;
icon?: (props: {}) => any;
}>()
</script>

<template>
Expand Down
4 changes: 4 additions & 0 deletions packages/bottom-sheets/src/BottomSheet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ defineExpose({
setHeight,
getHeight,
});
defineSlots<{
default?: (props: {close: () => void}) => any;
}>();
</script>

<template>
Expand Down
6 changes: 6 additions & 0 deletions packages/bottom-sheets/src/BottomSheetBody.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<script setup lang="ts">
defineSlots<{
default?: (props: {}) => any;
}>();
</script>

<template>
<div class="v-bottom-sheet-body">
<slot />
Expand Down
6 changes: 6 additions & 0 deletions packages/bottom-sheets/src/BottomSheetFooter.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<script setup lang="ts">
defineSlots<{
default?: (props: {}) => any;
}>();
</script>

<template>
<div class="v-bottom-sheet-footer">
<slot />
Expand Down
4 changes: 4 additions & 0 deletions packages/bottom-sheets/src/BottomSheetHandle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ onUnmounted(() => {
window.removeEventListener('mouseup', onDragEnd);
});
defineSlots<{
default?: (props: {}) => any;
}>();
</script>

<template>
Expand Down
4 changes: 4 additions & 0 deletions packages/bottom-sheets/src/BottomSheetHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import {BottomSheetInjectionKey} from './api';
import type {BottomSheetApi} from './types';
const api = inject<BottomSheetApi>(BottomSheetInjectionKey);
defineSlots<{
default?: (props: {}) => any;
}>();
</script>

<template>
Expand Down
Loading

0 comments on commit 4c59596

Please sign in to comment.