Fixed some typings on Board component
also removed FeatureComponent type since it's no longer used
This commit is contained in:
parent
05eb2a2bed
commit
2ec1a03d8f
2 changed files with 28 additions and 16 deletions
|
@ -25,7 +25,7 @@
|
||||||
<svg class="stage" width="100%" height="100%">
|
<svg class="stage" width="100%" height="100%">
|
||||||
<g class="g1">
|
<g class="g1">
|
||||||
<transition-group name="link" appear>
|
<transition-group name="link" appear>
|
||||||
<g v-for="(link, i) in links || []" :key="i">
|
<g v-for="(link, i) in unref(links) || []" :key="i">
|
||||||
<BoardLinkVue :link="link" />
|
<BoardLinkVue :link="link" />
|
||||||
</g>
|
</g>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
|
@ -38,8 +38,8 @@
|
||||||
:dragged="dragged"
|
:dragged="dragged"
|
||||||
:hasDragged="hasDragged"
|
:hasDragged="hasDragged"
|
||||||
:receivingNode="receivingNode?.id === node.id"
|
:receivingNode="receivingNode?.id === node.id"
|
||||||
:selectedNode="selectedNode"
|
:selectedNode="unref(selectedNode)"
|
||||||
:selectedAction="selectedAction"
|
:selectedAction="unref(selectedAction)"
|
||||||
@mouseDown="mouseDown"
|
@mouseDown="mouseDown"
|
||||||
@endDragging="endDragging"
|
@endDragging="endDragging"
|
||||||
/>
|
/>
|
||||||
|
@ -51,15 +51,35 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { BoardNode, GenericBoard, getNodeProperty } from "features/boards/board";
|
import {
|
||||||
import { FeatureComponent, Visibility } from "features/feature";
|
BoardData,
|
||||||
|
BoardNode,
|
||||||
|
BoardNodeLink,
|
||||||
|
GenericBoardNodeAction,
|
||||||
|
GenericNodeType,
|
||||||
|
getNodeProperty
|
||||||
|
} from "features/boards/board";
|
||||||
|
import { StyleValue, Visibility } from "features/feature";
|
||||||
import { PersistentState } from "game/persistence";
|
import { PersistentState } from "game/persistence";
|
||||||
import { computed, ref, toRefs } from "vue";
|
import { ProcessedComputable } from "util/computed";
|
||||||
|
import { computed, Ref, ref, toRefs, unref } from "vue";
|
||||||
import panZoom from "vue-panzoom";
|
import panZoom from "vue-panzoom";
|
||||||
import BoardLinkVue from "./BoardLink.vue";
|
import BoardLinkVue from "./BoardLink.vue";
|
||||||
import BoardNodeVue from "./BoardNode.vue";
|
import BoardNodeVue from "./BoardNode.vue";
|
||||||
|
|
||||||
const _props = defineProps<FeatureComponent<GenericBoard>>();
|
const _props = defineProps<{
|
||||||
|
nodes: Ref<BoardNode[]>;
|
||||||
|
types: Record<string, GenericNodeType>;
|
||||||
|
[PersistentState]: Ref<BoardData>;
|
||||||
|
visibility: ProcessedComputable<Visibility>;
|
||||||
|
width?: ProcessedComputable<string>;
|
||||||
|
height?: ProcessedComputable<string>;
|
||||||
|
style?: ProcessedComputable<StyleValue>;
|
||||||
|
classes?: ProcessedComputable<Record<string, boolean>>;
|
||||||
|
links: Ref<BoardNodeLink[] | null>;
|
||||||
|
selectedAction: Ref<GenericBoardNodeAction | null>;
|
||||||
|
selectedNode: Ref<BoardNode | null>;
|
||||||
|
}>();
|
||||||
const props = toRefs(_props);
|
const props = toRefs(_props);
|
||||||
|
|
||||||
const lastMousePosition = ref({ x: 0, y: 0 });
|
const lastMousePosition = ref({ x: 0, y: 0 });
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { DefaultValue } from "game/persistence";
|
|
||||||
import Decimal from "util/bignum";
|
import Decimal from "util/bignum";
|
||||||
import { DoNotCache, ProcessedComputable } from "util/computed";
|
import { DoNotCache } from "util/computed";
|
||||||
import { CSSProperties, DefineComponent, isRef } from "vue";
|
import { CSSProperties, DefineComponent, isRef } from "vue";
|
||||||
|
|
||||||
export const Component = Symbol("Component");
|
export const Component = Symbol("Component");
|
||||||
|
@ -15,13 +14,6 @@ export type StyleValue = string | CSSProperties | Array<string | CSSProperties>;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
export type GenericComponent = DefineComponent<any, any, any>;
|
export type GenericComponent = DefineComponent<any, any, any>;
|
||||||
|
|
||||||
export type FeatureComponent<T> = Omit<
|
|
||||||
{
|
|
||||||
[K in keyof T]: T[K] extends ProcessedComputable<infer S> ? S : T[K];
|
|
||||||
},
|
|
||||||
typeof Component | typeof DefaultValue
|
|
||||||
>;
|
|
||||||
|
|
||||||
export type Replace<T, S> = S & Omit<T, keyof S>;
|
export type Replace<T, S> = S & Omit<T, keyof S>;
|
||||||
|
|
||||||
export type OptionsFunc<T, S = T, R = Record<string, unknown>> = () => T & ThisType<S> & Partial<R>;
|
export type OptionsFunc<T, S = T, R = Record<string, unknown>> = () => T & ThisType<S> & Partial<R>;
|
||||||
|
|
Loading…
Reference in a new issue