Skip to content

Commit 71b484e

Browse files
typings
1 parent 4c5799b commit 71b484e

File tree

16 files changed

+121
-133
lines changed

16 files changed

+121
-133
lines changed

src/documentation/components/AnswersDialog.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
</template>
2828

2929
<script setup lang="ts">
30-
import { inject } from 'vue';
31-
32-
3330
const modelValue = defineModel<boolean>();
3431
const { answers } = defineProps<{ answers: any; }>();
3532

src/documentation/components/ExampleContainer.vue

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,20 @@
110110
</v-col>
111111
</template>
112112

113-
<script setup>
113+
<script setup lang="ts">
114114
115115
const emit = defineEmits(['closePicker']);
116-
const props = defineProps({
117-
code: {
118-
required: true,
119-
type: Object,
120-
},
121-
codeBlockOptions: {
122-
required: true,
123-
type: Object,
124-
},
125-
});
126116
127-
const codeBlockSettings = computed(() => props.codeBlockOptions);
117+
export interface ExampleCode {
118+
desc?: string;
119+
name?: string;
120+
script?: string;
121+
template: string;
122+
}
123+
124+
const codeBlockSettings = inject<Docs.CodeBlockSettings>('codeBlockSettings')!;
125+
const { code } = defineProps<{ code: ExampleCode; }>();
126+
128127
const hasRendered = ref(true);
129128
const showCode = ref(false);
130129
const template = ref('template');
@@ -135,10 +134,10 @@ function showCodeBlocks() {
135134
}
136135
137136
const getHrefId = computed(() => {
138-
const id = props.code.name?.toLowerCase().replace(/\s+/g, '-');
137+
const id = code.name?.toLowerCase().replace(/\s+/g, '-');
139138
140139
return `examples-${id}`;
141-
})
140+
});
142141
143142
</script>
144143

src/documentation/components/MenuComponent.vue

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
:color="drawerOptions.color ? 'white' : 'primary'"
44
density="compact"
55
>
6-
<template v-for="item in menuItems">
6+
<template v-for="item, k in menuItems">
77
<v-list-group
88
v-if="item.items"
9-
:key="item.items"
9+
:key="k"
1010
:value="item.title"
1111
>
1212
<template v-slot:activator="{ props }">
@@ -51,41 +51,42 @@
5151
</v-list>
5252
</template>
5353

54-
<script setup>
55-
import { inject, onMounted, ref } from 'vue';
54+
<script setup lang="ts">
5655
import { useMenuStore } from '@/stores/menu';
5756
58-
const drawerOptions = inject('drawerOptions');
59-
const store = useMenuStore();
6057
61-
const active = ref('');
62-
const menuItems = store.menuItems;
58+
const drawerOptions = inject<Docs.DrawerOptions>('drawerOptions')!;
59+
const store = useMenuStore();
60+
const active = ref<string>('');
61+
const menuItems: Docs.MenuItem[] = store.menuItems;
6362
6463
onMounted(() => {
6564
smoothScroll();
6665
6766
active.value = window.location.hash || '#home';
6867
});
6968
70-
function smoothScroll() {
71-
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
72-
anchor.addEventListener('click', (e) => {
69+
function smoothScroll(): void {
70+
document.querySelectorAll<HTMLAnchorElement>('a[href^="#"]').forEach((anchor) => {
71+
anchor.addEventListener('click', (e: MouseEvent) => {
7372
e.preventDefault();
7473
75-
const hash = anchor.hash;
76-
const id = hash.replace('#', '');
77-
const yOffset = -55;
78-
const element = document.getElementById(id);
79-
const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
74+
const hash: string = anchor.hash;
75+
const id: string = hash.replace('#', '');
76+
const yOffset: number = -55;
77+
const element: HTMLElement | null = document.getElementById(id);
8078
81-
active.value = hash;
79+
if (element) {
80+
const y: number = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
8281
83-
window.location.hash = hash;
84-
window.scrollTo({ behavior: 'smooth', top: y });
82+
active.value = hash;
83+
84+
window.location.hash = hash;
85+
window.scrollTo({ behavior: 'smooth', top: y });
86+
}
8587
});
8688
});
8789
}
88-
8990
</script>
9091

9192
<style lang="scss" scoped>

src/documentation/components/PropsTable.vue

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -79,36 +79,27 @@
7979
</v-row>
8080
</template>
8181

82-
<script setup>
83-
import { inject } from 'vue';
82+
<script setup lang="ts">
83+
const classes = inject<Docs.GlobalClasses>('classes')!;
8484
85+
interface Item {
86+
name: string;
87+
type: string;
88+
default: string;
89+
desc: string;
90+
}
8591
86-
const classes = inject('classes');
92+
interface Props {
93+
headers: any;
94+
items?: Item[];
95+
sectionId?: string;
96+
sectionTitle?: string;
97+
subtitle?: string;
98+
}
8799
88-
defineProps({
89-
headers: {
90-
default: () => [],
91-
type: Array,
92-
},
93-
items: {
94-
default: () => [],
95-
type: Array,
96-
},
97-
sectionId: {
98-
default: '',
99-
type: String,
100-
},
101-
sectionTitle: {
102-
default: null,
103-
type: String,
104-
},
105-
subtitle: {
106-
default: null,
107-
type: String,
108-
},
109-
});
100+
defineProps<Props>();
110101
111-
const search = ref('');
102+
const search = ref<string>('');
112103
</script>
113104

114105
<style lang="scss" scoped></style>

src/documentation/components/examples/ColumnsExample.vue

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818
/>
1919
</template>
2020

21-
<script setup>
22-
import { inject, ref } from 'vue';
21+
<script setup lang="ts">
2322
import AnswersDialog from '../AnswersDialog.vue';
2423
2524
26-
const links = inject('links');
25+
const links = inject<Docs.Links>('links')!;
2726
const dialog = ref(false);
2827
2928
const answers = ref({
@@ -43,7 +42,7 @@ const pages = [
4342
},
4443
label: 'Foo',
4544
name: 'foo',
46-
type: 'text',
45+
type: 'text' as const,
4746
},
4847
{
4948
columns: {
@@ -52,7 +51,7 @@ const pages = [
5251
},
5352
label: 'Bar',
5453
name: 'bar',
55-
type: 'text',
54+
type: 'text' as const,
5655
},
5756
],
5857
},
@@ -61,12 +60,12 @@ const pages = [
6160
{
6261
label: 'Biz',
6362
name: 'biz',
64-
type: 'text',
63+
type: 'text' as const,
6564
},
6665
{
6766
label: 'Baz',
6867
name: 'baz',
69-
type: 'text',
68+
type: 'text' as const,
7069
},
7170
],
7271
pageFieldColumns: {
@@ -76,7 +75,7 @@ const pages = [
7675
},
7776
];
7877
79-
function submitForm() {
78+
function submitForm(): void {
8079
dialog.value = true;
8180
}
8281
@@ -165,7 +164,7 @@ defineExpose({
165164
name: 'Columns',
166165
script: scriptCode,
167166
template: templateCode,
168-
}
167+
},
169168
});
170169
</script>
171170

src/documentation/components/examples/ConditionalExample.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const pages = [
6262
},
6363
];
6464
65-
function submitForm() {
65+
function submitForm(): void {
6666
dialog.value = true;
6767
}
6868
@@ -135,7 +135,7 @@ defineExpose({
135135
name: 'Conditional Fields',
136136
script: scriptCode,
137137
template: templateCode,
138-
}
138+
},
139139
});
140140
</script>
141141

src/documentation/components/examples/FieldSlotExample.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ const pages = [
7070
{
7171
label: 'Foo',
7272
name: 'foo',
73-
type: 'field',
73+
type: 'field' as const,
7474
},
7575
{
7676
label: 'Bar',
7777
name: 'bar',
78-
type: 'field',
78+
type: 'field' as const,
7979
},
8080
],
8181
},
8282
];
8383
84-
function submitForm() {
84+
function submitForm(): void {
8585
dialog.value = true;
8686
}
8787
@@ -172,7 +172,7 @@ defineExpose({
172172
name: 'Field Slots',
173173
script: scriptCode,
174174
template: templateCode,
175-
}
175+
},
176176
});
177177
</script>
178178

src/documentation/components/examples/SimpleExample.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const pages = [
2929
{
3030
label: 'Foo',
3131
name: 'foo',
32-
type: 'text',
32+
type: 'text' as const,
3333
},
3434
],
3535
title: 'Page 1',
@@ -39,14 +39,14 @@ const pages = [
3939
{
4040
label: 'Bar',
4141
name: 'bar',
42-
type: 'text',
42+
type: 'text' as const,
4343
},
4444
],
4545
title: 'Page 2',
46-
}
46+
},
4747
];
4848
49-
function submitForm() {
49+
function submitForm(): void {
5050
dialog.value = true;
5151
}
5252
@@ -76,7 +76,7 @@ const pages = [
7676
{
7777
label: 'Foo',
7878
name: 'foo',
79-
type: 'text',
79+
type: 'text' as const,
8080
},
8181
],
8282
},
@@ -86,7 +86,7 @@ const pages = [
8686
{
8787
label: 'Bar',
8888
name: 'bar',
89-
type: 'text',
89+
type: 'text' as const,
9090
},
9191
],
9292
}
@@ -102,7 +102,7 @@ defineExpose({
102102
desc: 'A simple example of the <code class="ic">VStepperForm</code> component.',
103103
script: scriptCode,
104104
template: templateCode,
105-
}
105+
},
106106
});
107107
</script>
108108

0 commit comments

Comments
 (0)