mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-07 17:18:21 +00:00
Fixed more typescript warnings
- Mainly moved type exports to .ts file
This commit is contained in:
parent
822209cd18
commit
3cd07d7e63
5 changed files with 45 additions and 48 deletions
|
@ -1,21 +1,7 @@
|
||||||
<!-- Base component that implements selecting single and multiple values from a list in a type-unsafe manner -->
|
<!-- Base component that implements selecting single and multiple values from a list in a type-unsafe manner -->
|
||||||
<script lang="ts">
|
|
||||||
// Types
|
|
||||||
export type Options = Record<Index, Option>;
|
|
||||||
export type Option = {
|
|
||||||
[key: Index]: any, // Allow additional properties for customization
|
|
||||||
display?: string,
|
|
||||||
};
|
|
||||||
export type SearchProvider = (opts: SearchOptions) => Promise<Options>;
|
|
||||||
export type MaybeSearchProvider = SearchProvider | null;
|
|
||||||
export type SearchOptions = {
|
|
||||||
search: string,
|
|
||||||
unknownKeys?: Index[],
|
|
||||||
// parentData?: any,
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { equals, isNullish, Index } from '../../util';
|
import { equals, isNullish, Index } from '../../util';
|
||||||
|
import type { Options, MaybeSearchProvider } from './input';
|
||||||
// --- Prop setup ---
|
// --- Prop setup ---
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
// Two-Way Bindings (v-model)
|
// Two-Way Bindings (v-model)
|
||||||
|
@ -89,9 +75,9 @@ watch($$(multiple), () => modelValue = multiple ? [] : null );
|
||||||
// --- Everything Else ---
|
// --- Everything Else ---
|
||||||
let expanded = $ref(false);
|
let expanded = $ref(false);
|
||||||
let navigated = $ref(0);
|
let navigated = $ref(0);
|
||||||
let inputDiv: HTMLElement | null = $ref(null);
|
let inputDiv = $ref(null as HTMLElement | null);
|
||||||
let input: HTMLElement | null = $ref(null);
|
let input = $ref(null as HTMLElement | null);
|
||||||
let valueButton: HTMLElement | null = $ref(null);
|
let valueButton = $ref(null as HTMLElement | null);
|
||||||
|
|
||||||
const selCount = $computed(() => modelValue?.length || 0);
|
const selCount = $computed(() => modelValue?.length || 0);
|
||||||
|
|
||||||
|
@ -266,4 +252,4 @@ input { padding: 0.25rem; outline: none; }
|
||||||
|
|
||||||
div:empty { display: none; }
|
div:empty { display: none; }
|
||||||
button { padding: 0.25rem; }
|
button { padding: 0.25rem; }
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,19 +1,6 @@
|
||||||
<script lang="ts">
|
|
||||||
import { Index, MaybeIndex, equals, variantOf } from '../../util';
|
|
||||||
import { Fields } from './NicerForm.vue';
|
|
||||||
|
|
||||||
export type Variant = {
|
|
||||||
fields?: Fields,
|
|
||||||
display?: string,
|
|
||||||
icon?: Component
|
|
||||||
};
|
|
||||||
export type Variants = Record<Index, Variant>;
|
|
||||||
export type EnumValueWithFields = { [index: Index]: Record<Index, any> }
|
|
||||||
export type EnumValue = Index | EnumValueWithFields;
|
|
||||||
export type MaybeEnumValue = EnumValue | null;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { MaybeEnumValue, Variants, EnumValueWithFields } from './input';
|
||||||
|
import { equals, variantOf, MaybeIndex, Index } from '~/util';
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
// Two-Way Bindings
|
// Two-Way Bindings
|
||||||
|
|
|
@ -1,17 +1,6 @@
|
||||||
<script lang="ts">
|
|
||||||
import { equals, Index } from '../../util';
|
|
||||||
|
|
||||||
export type Field = {
|
|
||||||
is: Component | string,
|
|
||||||
label?: string,
|
|
||||||
props?: any,
|
|
||||||
// actions?: Action[],
|
|
||||||
// forceCastNumber`?: bool,
|
|
||||||
};
|
|
||||||
export type Fields = Record<Index, Field>;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { equals, Index } from '../../util';
|
||||||
|
import type { Fields } from './input';
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
// Two-Way Bindings
|
// Two-Way Bindings
|
||||||
modelValue?: Record<Index, any>,
|
modelValue?: Record<Index, any>,
|
||||||
|
|
35
client/src/components/input/input.ts
Normal file
35
client/src/components/input/input.ts
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import { Index } from '~/util';
|
||||||
|
// --- DROPDOWN_INPUT ---
|
||||||
|
export type Options = Record<Index, Option>;
|
||||||
|
export type Option = {
|
||||||
|
[key: Index]: any, // Allow additional properties for customization
|
||||||
|
display?: string,
|
||||||
|
};
|
||||||
|
export type SearchProvider = (opts: SearchOptions) => Promise<Options>;
|
||||||
|
export type MaybeSearchProvider = SearchProvider | null;
|
||||||
|
export type SearchOptions = {
|
||||||
|
search: string,
|
||||||
|
unknownKeys?: Index[],
|
||||||
|
// parentData?: any,
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- FORM INPUT ---
|
||||||
|
export type Field = {
|
||||||
|
is: Component | string,
|
||||||
|
label?: string,
|
||||||
|
props?: any,
|
||||||
|
// actions?: Action[],
|
||||||
|
// forceCastNumber`?: bool,
|
||||||
|
};
|
||||||
|
export type Fields = Record<Index, Field>;
|
||||||
|
|
||||||
|
// --- ENUM INPUT ---
|
||||||
|
export type Variant = {
|
||||||
|
fields?: Fields,
|
||||||
|
display?: string,
|
||||||
|
icon?: Component
|
||||||
|
};
|
||||||
|
export type Variants = Record<Index, Variant>;
|
||||||
|
export type EnumValueWithFields = { [index: Index]: Record<Index, any> }
|
||||||
|
export type EnumValue = Index | EnumValueWithFields;
|
||||||
|
export type MaybeEnumValue = EnumValue | null;
|
|
@ -1,4 +1,4 @@
|
||||||
import { SearchProvider, Options } from '~/components/input/DropdownInput.vue';
|
import { SearchProvider, Options } from '~/components/input/input';
|
||||||
import { apiCall } from './api';
|
import { apiCall } from './api';
|
||||||
|
|
||||||
const GetHardwareInterfaces: SearchProvider = async (o) => {
|
const GetHardwareInterfaces: SearchProvider = async (o) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue