mount.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <MountDescribes
  3. :name="name || data?.itemName || (type && components[type].shapeName)"
  4. :show="!hidden"
  5. :describes="describes"
  6. :data="data"
  7. :cal-delete="!data?.disableDelete"
  8. @close="
  9. () => {
  10. shapesStatus.actives = [];
  11. emit('close');
  12. }
  13. "
  14. @change="emit('change')"
  15. @delete="emit('delete')"
  16. />
  17. </template>
  18. <script lang="ts" setup>
  19. import { computed } from "vue";
  20. import { useStage } from "../../hook/use-global-vars.ts";
  21. import { useMode } from "../../hook/use-status.ts";
  22. import { PropertyDescribes } from "./index.ts";
  23. import { DC, EntityShape } from "@/deconstruction.js";
  24. import {
  25. useMouseShapesStatus,
  26. useMouseShapeStatus,
  27. } from "../../hook/use-mouse-status.ts";
  28. import { Mode } from "@/constant/mode.ts";
  29. import { useStore } from "@/core/store/index.ts";
  30. import { components } from "@/core/components/index.ts";
  31. import MountDescribes from "./mount-describes.vue";
  32. const props = defineProps<{
  33. show?: boolean;
  34. target: DC<EntityShape> | undefined;
  35. name?: string;
  36. data?: Record<string, any>;
  37. describes: PropertyDescribes;
  38. }>();
  39. const emit = defineEmits<{
  40. (e: "change"): void;
  41. (e: "delete"): void;
  42. (e: "close"): void;
  43. }>();
  44. const store = useStore();
  45. const id = computed(() => props.target?.getNode().id());
  46. const type = computed(() => id.value && store.getType(id.value));
  47. const data = computed(() => (id.value ? store.getItemById(id.value) : props.data));
  48. const stage = useStage();
  49. const status = useMouseShapeStatus(computed(() => props.target));
  50. const shapesStatus = useMouseShapesStatus();
  51. const mode = useMode();
  52. const hidden = computed(
  53. () =>
  54. !props.show &&
  55. (!stage.value?.getStage() ||
  56. !props.target?.getNode() ||
  57. !status.value.active ||
  58. mode.value.has(Mode.draw) ||
  59. mode.value.has(Mode.draging))
  60. );
  61. </script>