Skip to content

Commit 06ddf7f

Browse files
authored
fix: adjustments to types (#90)
1 parent 2c5523d commit 06ddf7f

File tree

9 files changed

+55
-57
lines changed

9 files changed

+55
-57
lines changed

src/components/NeCombobox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface Props {
4444
maxOptionsShown?: number
4545
multiple?: boolean
4646
disabled?: boolean
47-
showOptionsType: boolean
47+
showOptionsType?: boolean
4848
optional?: boolean
4949
selectedLabel: string
5050
showSelectedLabel?: boolean

src/components/NeFileInput.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import NeProgressBar from './NeProgressBar.vue'
1212
interface FileInputProps {
1313
modelValue?: File | File[] | null
1414
label?: string
15-
invalidMessage: string
15+
invalidMessage?: string
1616
dropzoneLabel: string
17-
progress: number
18-
showProgress: boolean
17+
progress?: number
18+
showProgress?: boolean
1919
accept?: string | undefined
2020
}
2121

src/components/NeModal.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import NeButton, { type ButtonKind } from './NeButton.vue'
1212
import NeRoundedIcon from './NeRoundedIcon.vue'
1313
import type { PropType } from 'vue'
1414
15-
type ModalKind = 'neutral' | 'info' | 'warning' | 'error' | 'success'
16-
type PrimaryButtonKind = 'primary' | 'danger'
17-
type ModalSize = 'md' | 'lg' | 'xl' | 'xxl'
15+
export type ModalKind = 'neutral' | 'info' | 'warning' | 'error' | 'success'
16+
export type PrimaryButtonKind = 'primary' | 'danger'
17+
export type ModalSize = 'md' | 'lg' | 'xl' | 'xxl'
1818
1919
defineProps({
2020
visible: {

src/components/NeRadioSelection.vue

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,26 @@
33
SPDX-License-Identifier: GPL-3.0-or-later
44
-->
55

6-
<script lang="ts" setup>
7-
import { computed, type PropType, type Ref, ref, watch } from 'vue'
8-
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
9-
import { type IconDefinition } from '@fortawesome/fontawesome-svg-core'
10-
import { faCircleCheck } from '@fortawesome/free-solid-svg-icons'
11-
import NeFormItemLabel from './NeFormItemLabel.vue'
12-
import { v4 as uuidv4 } from 'uuid'
13-
14-
export type RadioCardSize = 'md' | 'lg' | 'xl'
6+
<script lang="ts">
7+
import type { IconDefinition } from '@fortawesome/fontawesome-svg-core'
158
16-
type RadioOption = {
9+
export type RadioOption = {
1710
id: string
1811
label: string
1912
description?: string
2013
icon?: IconDefinition
2114
disabled?: boolean
2215
}
16+
</script>
17+
18+
<script lang="ts" setup generic="T extends RadioOption">
19+
import { computed, type PropType, type Ref, ref, watch } from 'vue'
20+
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
21+
import { faCircleCheck } from '@fortawesome/free-solid-svg-icons'
22+
import NeFormItemLabel from './NeFormItemLabel.vue'
23+
import { v4 as uuidv4 } from 'uuid'
24+
25+
export type RadioCardSize = 'md' | 'lg' | 'xl'
2326
2427
const props = defineProps({
2528
modelValue: {
@@ -41,7 +44,7 @@ const props = defineProps({
4144
},
4245
options: {
4346
required: true,
44-
type: Array<RadioOption>
47+
type: Array<T>
4548
},
4649
card: {
4750
type: Boolean,

src/components/NeTable.vue

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,41 @@
33
SPDX-License-Identifier: GPL-3.0-or-later
44
-->
55
<script lang="ts" setup>
6-
import { computed, provide, type PropType } from 'vue'
6+
import { computed, provide } from 'vue'
77
import NeTableSkeleton from './NeTableSkeleton.vue'
88
99
export type Breakpoint = 'sm' | 'md' | 'lg' | 'xl' | '2xl'
1010
11-
const props = defineProps({
12-
ariaLabel: {
13-
type: String,
14-
required: true
15-
},
16-
cardBreakpoint: {
17-
type: String as PropType<Breakpoint>,
18-
default: 'md'
19-
},
20-
loading: {
21-
type: Boolean,
22-
default: false
23-
},
24-
skeletonRows: {
25-
type: Number,
26-
default: 8
27-
},
28-
skeletonColumns: {
29-
type: Number,
30-
default: 4
31-
},
32-
sortKey: {
33-
type: String,
34-
default: ''
35-
},
36-
sortDescending: {
37-
type: Boolean,
38-
default: false
39-
}
40-
})
11+
const {
12+
ariaLabel,
13+
cardBreakpoint = 'md',
14+
loading = false,
15+
skeletonRows = 8,
16+
skeletonColumns = 4,
17+
sortKey = '',
18+
sortDescending = false
19+
} = defineProps<{
20+
ariaLabel?: string
21+
cardBreakpoint?: Breakpoint
22+
loading?: boolean
23+
skeletonRows?: number
24+
skeletonColumns?: number
25+
sortKey?: string
26+
sortDescending?: boolean
27+
}>()
4128
4229
// provide props to children components
4330
provide(
4431
'cardBreakpoint',
45-
computed(() => props.cardBreakpoint)
32+
computed(() => cardBreakpoint)
4633
)
4734
provide(
4835
'sortKey',
49-
computed(() => props.sortKey)
36+
computed(() => sortKey)
5037
)
5138
provide(
5239
'sortDescending',
53-
computed(() => props.sortDescending)
40+
computed(() => sortDescending)
5441
)
5542
5643
const tableCardStyle: Record<Breakpoint, string> = {

src/components/NeTableHeadCell.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import { computed, inject, toValue } from 'vue'
77
import { faSort, faSortUp, faSortDown } from '@fortawesome/free-solid-svg-icons'
88
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
99
10+
export type SortEvent = {
11+
key: string
12+
descending: boolean
13+
}
14+
1015
const props = defineProps({
1116
columnKey: {
1217
type: String,
@@ -19,7 +24,7 @@ const props = defineProps({
1924
})
2025
2126
const emit = defineEmits<{
22-
sort: [{ key: string; descending: boolean }]
27+
sort: [SortEvent]
2328
}>()
2429
2530
// inject from NeTable.vue

src/composables/useSort.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ export function useSort<T>(
44
items: MaybeRefOrGetter<T[]>,
55
sortKey: MaybeRefOrGetter<keyof T>,
66
descending: MaybeRefOrGetter<boolean> = false,
7-
sortFunctions: Record<keyof T, (a: T, b: T) => number> = {} as Record<
8-
keyof T,
9-
(a: T, b: T) => number
10-
>
7+
sortFunctions: Partial<Record<keyof T, (a: T, b: T) => number>> = {}
118
) {
129
const sortedItems = ref<T[]>([])
1310

src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ export type { NeNotification } from './components/NeToastNotification.vue'
4646
export type { NeListboxOption } from './components/NeListbox.vue'
4747
export type { NeDropdownItem } from './components/NeDropdown.vue'
4848
export type { FilterOption, FilterKind } from './components/NeDropdownFilter.vue'
49+
export type { RadioOption } from './components/NeRadioSelection.vue'
50+
export type { SortEvent } from './components/NeTableHeadCell.vue'
51+
export type { ModalKind, PrimaryButtonKind, ModalSize } from './components/NeModal.vue'
4952

5053
// library functions export
5154
export {

src/styles/theme.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
--color-primary-900: var(--color-cyan-900);
2222
--color-primary-950: var(--color-cyan-950);
2323

24+
/* breakpoints */
25+
--breakpoint-3xl: 112rem;
26+
2427
/* animations */
2528
--animate-spin-fast: spin 0.5s linear infinite;
2629
--animate-spin-relaxed: spin 1.5s linear infinite;

0 commit comments

Comments
 (0)