2020-07-11 04:13:11 +03:00
|
|
|
<template>
|
|
|
|
<!-- sectionを利用しているのは、deck.vue側でcolumnに対してfirst-of-typeを効かせるため -->
|
2021-11-19 12:36:12 +02:00
|
|
|
<section v-hotkey="keymap" class="dnpfarvg _panel _narrow_"
|
|
|
|
:class="{ paged: isMainColumn, naked, active, isStacked, draghover, dragging, dropready }"
|
|
|
|
:style="{ '--deckColumnHeaderHeight': deckStore.reactiveState.columnHeaderHeight.value + 'px' }"
|
2020-07-11 04:13:11 +03:00
|
|
|
@dragover.prevent.stop="onDragover"
|
|
|
|
@dragleave="onDragleave"
|
|
|
|
@drop.prevent.stop="onDrop"
|
|
|
|
>
|
|
|
|
<header :class="{ indicated }"
|
|
|
|
draggable="true"
|
|
|
|
@click="goTop"
|
|
|
|
@dragstart="onDragstart"
|
|
|
|
@dragend="onDragend"
|
|
|
|
@contextmenu.prevent.stop="onContextmenu"
|
|
|
|
>
|
2021-11-19 12:36:12 +02:00
|
|
|
<button v-if="isStacked && !isMainColumn" class="toggleActive _button" @click="toggleActive">
|
2021-04-20 17:22:59 +03:00
|
|
|
<template v-if="active"><i class="fas fa-angle-up"></i></template>
|
|
|
|
<template v-else><i class="fas fa-angle-down"></i></template>
|
2020-07-11 04:13:11 +03:00
|
|
|
</button>
|
|
|
|
<div class="action">
|
|
|
|
<slot name="action"></slot>
|
|
|
|
</div>
|
|
|
|
<span class="header"><slot name="header"></slot></span>
|
2021-11-19 12:36:12 +02:00
|
|
|
<button v-if="func" v-tooltip="func.title" class="menu _button" @click.stop="func.handler"><i :class="func.icon || 'fas fa-cog'"></i></button>
|
2020-07-11 04:13:11 +03:00
|
|
|
</header>
|
2021-11-19 12:36:12 +02:00
|
|
|
<div v-show="active" ref="body">
|
2020-07-11 04:13:11 +03:00
|
|
|
<slot></slot>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2022-03-20 20:11:14 +02:00
|
|
|
export type DeckFunc = {
|
|
|
|
title: string;
|
|
|
|
handler: (payload: MouseEvent) => void;
|
|
|
|
icon?: string;
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { onBeforeUnmount, onMounted, provide, watch } from 'vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import * as os from '@/os';
|
2022-03-20 20:11:14 +02:00
|
|
|
import { updateColumn, swapLeftColumn, swapRightColumn, swapUpColumn, swapDownColumn, stackLeftColumn, popRightColumn, removeColumn, swapColumn, Column } from './deck-store';
|
2020-12-26 15:41:00 +02:00
|
|
|
import { deckStore } from './deck-store';
|
2022-03-20 20:11:14 +02:00
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
|
|
|
|
provide('shouldHeaderThin', true);
|
|
|
|
provide('shouldOmitHeaderTitle', true);
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
column: Column;
|
|
|
|
isStacked?: boolean;
|
|
|
|
func?: DeckFunc | null;
|
|
|
|
naked?: boolean;
|
|
|
|
indicated?: boolean;
|
|
|
|
}>(), {
|
|
|
|
isStacked: false,
|
|
|
|
func: null,
|
|
|
|
naked: false,
|
|
|
|
indicated: false,
|
|
|
|
});
|
2020-07-11 04:13:11 +03:00
|
|
|
|
2022-03-20 20:11:14 +02:00
|
|
|
const emit = defineEmits<{
|
|
|
|
(e: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void;
|
|
|
|
(e: 'change-active-state', v: boolean): void;
|
|
|
|
}>();
|
2020-07-11 04:13:11 +03:00
|
|
|
|
2022-03-20 20:11:14 +02:00
|
|
|
let body = $ref<HTMLDivElement>();
|
2020-07-11 04:13:11 +03:00
|
|
|
|
2022-03-20 20:11:14 +02:00
|
|
|
let dragging = $ref(false);
|
|
|
|
watch($$(dragging), v => os.deckGlobalEvents.emit(v ? 'column.dragStart' : 'column.dragEnd'));
|
|
|
|
|
|
|
|
let draghover = $ref(false);
|
|
|
|
let dropready = $ref(false);
|
2020-07-11 04:13:11 +03:00
|
|
|
|
2022-03-20 20:11:14 +02:00
|
|
|
const isMainColumn = $computed(() => props.column.type === 'main');
|
|
|
|
const active = $computed(() => props.column.active !== false);
|
|
|
|
watch($$(active), v => emit('change-active-state', v));
|
2020-07-11 04:13:11 +03:00
|
|
|
|
2022-03-20 20:11:14 +02:00
|
|
|
const keymap = $computed(() => ({
|
|
|
|
'shift+up': () => emit('parent-focus', 'up'),
|
|
|
|
'shift+down': () => emit('parent-focus', 'down'),
|
|
|
|
'shift+left': () => emit('parent-focus', 'left'),
|
|
|
|
'shift+right': () => emit('parent-focus', 'right'),
|
|
|
|
}));
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
os.deckGlobalEvents.on('column.dragStart', onOtherDragStart);
|
|
|
|
os.deckGlobalEvents.on('column.dragEnd', onOtherDragEnd);
|
|
|
|
});
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
os.deckGlobalEvents.off('column.dragStart', onOtherDragStart);
|
|
|
|
os.deckGlobalEvents.off('column.dragEnd', onOtherDragEnd);
|
|
|
|
});
|
2020-07-11 04:13:11 +03:00
|
|
|
|
2022-03-20 20:11:14 +02:00
|
|
|
|
|
|
|
function onOtherDragStart() {
|
|
|
|
dropready = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onOtherDragEnd() {
|
|
|
|
dropready = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleActive() {
|
|
|
|
if (!props.isStacked) return;
|
|
|
|
updateColumn(props.column.id, {
|
|
|
|
active: !props.column.active
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function getMenu() {
|
|
|
|
const items = [{
|
|
|
|
icon: 'fas fa-pencil-alt',
|
|
|
|
text: i18n.ts.edit,
|
|
|
|
action: async () => {
|
|
|
|
const { canceled, result } = await os.form(props.column.name, {
|
|
|
|
name: {
|
|
|
|
type: 'string',
|
|
|
|
label: i18n.ts.name,
|
|
|
|
default: props.column.name
|
|
|
|
},
|
|
|
|
width: {
|
|
|
|
type: 'number',
|
|
|
|
label: i18n.ts.width,
|
|
|
|
default: props.column.width
|
|
|
|
},
|
|
|
|
flexible: {
|
|
|
|
type: 'boolean',
|
|
|
|
label: i18n.ts.flexible,
|
|
|
|
default: props.column.flexible
|
|
|
|
}
|
2020-07-11 04:13:11 +03:00
|
|
|
});
|
2022-03-20 20:11:14 +02:00
|
|
|
if (canceled) return;
|
|
|
|
updateColumn(props.column.id, result);
|
|
|
|
}
|
|
|
|
}, null, {
|
|
|
|
icon: 'fas fa-arrow-left',
|
|
|
|
text: i18n.ts._deck.swapLeft,
|
|
|
|
action: () => {
|
|
|
|
swapLeftColumn(props.column.id);
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
icon: 'fas fa-arrow-right',
|
|
|
|
text: i18n.ts._deck.swapRight,
|
|
|
|
action: () => {
|
|
|
|
swapRightColumn(props.column.id);
|
|
|
|
}
|
|
|
|
}, props.isStacked ? {
|
|
|
|
icon: 'fas fa-arrow-up',
|
|
|
|
text: i18n.ts._deck.swapUp,
|
|
|
|
action: () => {
|
|
|
|
swapUpColumn(props.column.id);
|
|
|
|
}
|
|
|
|
} : undefined, props.isStacked ? {
|
|
|
|
icon: 'fas fa-arrow-down',
|
|
|
|
text: i18n.ts._deck.swapDown,
|
|
|
|
action: () => {
|
|
|
|
swapDownColumn(props.column.id);
|
|
|
|
}
|
|
|
|
} : undefined, null, {
|
|
|
|
icon: 'fas fa-window-restore',
|
|
|
|
text: i18n.ts._deck.stackLeft,
|
|
|
|
action: () => {
|
|
|
|
stackLeftColumn(props.column.id);
|
|
|
|
}
|
|
|
|
}, props.isStacked ? {
|
|
|
|
icon: 'fas fa-window-maximize',
|
|
|
|
text: i18n.ts._deck.popRight,
|
|
|
|
action: () => {
|
|
|
|
popRightColumn(props.column.id);
|
|
|
|
}
|
|
|
|
} : undefined, null, {
|
|
|
|
icon: 'fas fa-trash-alt',
|
|
|
|
text: i18n.ts.remove,
|
|
|
|
danger: true,
|
|
|
|
action: () => {
|
|
|
|
removeColumn(props.column.id);
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
2022-03-20 20:11:14 +02:00
|
|
|
}];
|
|
|
|
return items;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onContextmenu(ev: MouseEvent) {
|
|
|
|
os.contextMenu(getMenu(), ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
function goTop() {
|
|
|
|
body.scrollTo({
|
|
|
|
top: 0,
|
|
|
|
behavior: 'smooth'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDragstart(e) {
|
|
|
|
e.dataTransfer.effectAllowed = 'move';
|
|
|
|
e.dataTransfer.setData(_DATA_TRANSFER_DECK_COLUMN_, props.column.id);
|
|
|
|
|
|
|
|
// Chromeのバグで、Dragstartハンドラ内ですぐにDOMを変更する(=リアクティブなプロパティを変更する)とDragが終了してしまう
|
|
|
|
// SEE: https://stackoverflow.com/questions/19639969/html5-dragend-event-firing-immediately
|
|
|
|
window.setTimeout(() => {
|
|
|
|
dragging = true;
|
|
|
|
}, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDragend(e) {
|
|
|
|
dragging = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDragover(e) {
|
|
|
|
// 自分自身がドラッグされている場合
|
|
|
|
if (dragging) {
|
|
|
|
// 自分自身にはドロップさせない
|
|
|
|
e.dataTransfer.dropEffect = 'none';
|
|
|
|
return;
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
2022-03-20 20:11:14 +02:00
|
|
|
|
|
|
|
const isDeckColumn = e.dataTransfer.types[0] == _DATA_TRANSFER_DECK_COLUMN_;
|
|
|
|
|
|
|
|
e.dataTransfer.dropEffect = isDeckColumn ? 'move' : 'none';
|
|
|
|
|
|
|
|
if (!dragging && isDeckColumn) draghover = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDragleave() {
|
|
|
|
draghover = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDrop(e) {
|
|
|
|
draghover = false;
|
|
|
|
os.deckGlobalEvents.emit('column.dragEnd');
|
|
|
|
|
|
|
|
const id = e.dataTransfer.getData(_DATA_TRANSFER_DECK_COLUMN_);
|
|
|
|
if (id != null && id != '') {
|
|
|
|
swapColumn(props.column.id, id);
|
|
|
|
}
|
|
|
|
}
|
2020-07-11 04:13:11 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.dnpfarvg {
|
2021-04-10 06:40:50 +03:00
|
|
|
--root-margin: 10px;
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2020-07-11 04:13:11 +03:00
|
|
|
height: 100%;
|
2021-03-02 15:57:16 +02:00
|
|
|
overflow: hidden;
|
2020-10-17 14:12:00 +03:00
|
|
|
contain: content;
|
2021-10-14 12:51:15 +03:00
|
|
|
box-shadow: 0 0 8px 0 var(--shadow);
|
2020-07-11 04:13:11 +03:00
|
|
|
|
|
|
|
&.draghover {
|
|
|
|
box-shadow: 0 0 0 2px var(--focus);
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
content: "";
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
z-index: 1000;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
background: var(--focus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.dragging {
|
|
|
|
box-shadow: 0 0 0 2px var(--focus);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.dropready {
|
|
|
|
* {
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&:not(.active) {
|
2020-12-26 15:41:00 +02:00
|
|
|
flex-basis: var(--deckColumnHeaderHeight);
|
|
|
|
min-height: var(--deckColumnHeaderHeight);
|
2020-07-11 04:13:11 +03:00
|
|
|
|
|
|
|
> header.indicated {
|
|
|
|
box-shadow: 4px 0px var(--accent) inset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.naked {
|
2020-12-20 10:19:18 +02:00
|
|
|
background: var(--acrylicBg) !important;
|
2021-08-11 16:34:45 +03:00
|
|
|
-webkit-backdrop-filter: var(--blur, blur(10px));
|
|
|
|
backdrop-filter: var(--blur, blur(10px));
|
2020-07-11 04:13:11 +03:00
|
|
|
|
|
|
|
> header {
|
|
|
|
background: transparent;
|
|
|
|
box-shadow: none;
|
|
|
|
|
|
|
|
> button {
|
|
|
|
color: var(--fg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.paged {
|
2020-12-28 10:00:31 +02:00
|
|
|
background: var(--bg) !important;
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
> header {
|
|
|
|
position: relative;
|
|
|
|
display: flex;
|
|
|
|
z-index: 2;
|
2020-12-26 15:41:00 +02:00
|
|
|
line-height: var(--deckColumnHeaderHeight);
|
|
|
|
height: var(--deckColumnHeaderHeight);
|
2020-07-11 04:13:11 +03:00
|
|
|
padding: 0 16px;
|
|
|
|
font-size: 0.9em;
|
|
|
|
color: var(--panelHeaderFg);
|
|
|
|
background: var(--panelHeaderBg);
|
|
|
|
box-shadow: 0 1px 0 0 var(--panelHeaderDivider);
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&, * {
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.indicated {
|
|
|
|
box-shadow: 0 3px 0 0 var(--accent);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .header {
|
|
|
|
display: inline-block;
|
|
|
|
align-items: center;
|
2021-03-02 15:57:16 +02:00
|
|
|
overflow: hidden;
|
2020-07-11 04:13:11 +03:00
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
> span:only-of-type {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .toggleActive,
|
2021-10-14 17:14:14 +03:00
|
|
|
> .action > ::v-deep(*),
|
2020-10-17 14:12:00 +03:00
|
|
|
> .menu {
|
2020-07-11 04:13:11 +03:00
|
|
|
z-index: 1;
|
2020-12-26 15:41:00 +02:00
|
|
|
width: var(--deckColumnHeaderHeight);
|
|
|
|
line-height: var(--deckColumnHeaderHeight);
|
2020-07-11 04:13:11 +03:00
|
|
|
font-size: 16px;
|
|
|
|
color: var(--faceTextButton);
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--faceTextButtonHover);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:active {
|
|
|
|
color: var(--faceTextButtonActive);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .toggleActive, > .action {
|
|
|
|
margin-left: -16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .action {
|
|
|
|
z-index: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .action:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
> .menu {
|
2020-07-11 04:13:11 +03:00
|
|
|
margin-left: auto;
|
|
|
|
margin-right: -16px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> div {
|
2020-12-26 15:41:00 +02:00
|
|
|
height: calc(100% - var(--deckColumnHeaderHeight));
|
2022-04-02 09:12:01 +03:00
|
|
|
overflow-y: auto;
|
|
|
|
overflow-x: hidden; // Safari does not supports clip
|
|
|
|
overflow-x: clip;
|
2020-07-11 04:13:11 +03:00
|
|
|
-webkit-overflow-scrolling: touch;
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|