2020-07-11 10:13:11 +09:00
|
|
|
<template>
|
2023-05-20 10:12:18 +09:00
|
|
|
<div
|
2023-01-10 09:53:01 +09:00
|
|
|
:class="[$style.root, { [$style.paged]: isMainColumn, [$style.naked]: naked, [$style.active]: active, [$style.isStacked]: isStacked, [$style.draghover]: draghover, [$style.dragging]: dragging, [$style.dropready]: dropready }]"
|
2020-07-11 10:13:11 +09:00
|
|
|
@dragover.prevent.stop="onDragover"
|
|
|
|
@dragleave="onDragleave"
|
|
|
|
@drop.prevent.stop="onDrop"
|
|
|
|
>
|
2022-07-03 20:30:58 +09:00
|
|
|
<header
|
2023-01-10 10:30:38 +09:00
|
|
|
:class="[$style.header]"
|
2020-07-11 10:13:11 +09:00
|
|
|
draggable="true"
|
|
|
|
@click="goTop"
|
|
|
|
@dragstart="onDragstart"
|
|
|
|
@dragend="onDragend"
|
|
|
|
@contextmenu.prevent.stop="onContextmenu"
|
|
|
|
>
|
2023-05-26 10:48:49 +09:00
|
|
|
<svg viewBox="0 0 256 128" :class="$style.tabShape">
|
|
|
|
<g transform="matrix(6.2431,0,0,6.2431,-677.417,-29.3839)">
|
2023-05-26 11:31:39 +09:00
|
|
|
<path d="M149.512,4.707L108.507,4.707C116.252,4.719 118.758,14.958 118.758,14.958C118.758,14.958 121.381,25.283 129.009,25.209L149.512,25.209L149.512,4.707Z" style="fill:var(--deckBg);"/>
|
2023-05-26 10:48:49 +09:00
|
|
|
</g>
|
|
|
|
</svg>
|
2023-05-26 11:31:39 +09:00
|
|
|
<div :class="$style.color"></div>
|
2023-01-10 09:53:01 +09:00
|
|
|
<button v-if="isStacked && !isMainColumn" :class="$style.toggleActive" class="_button" @click="toggleActive">
|
2022-12-19 19:01:30 +09:00
|
|
|
<template v-if="active"><i class="ti ti-chevron-up"></i></template>
|
|
|
|
<template v-else><i class="ti ti-chevron-down"></i></template>
|
2020-07-11 10:13:11 +09:00
|
|
|
</button>
|
2023-01-10 09:53:01 +09:00
|
|
|
<span :class="$style.title"><slot name="header"></slot></span>
|
|
|
|
<button v-tooltip="i18n.ts.settings" :class="$style.menu" class="_button" @click.stop="showSettingsMenu"><i class="ti ti-dots"></i></button>
|
2020-07-11 10:13:11 +09:00
|
|
|
</header>
|
2023-05-20 10:12:18 +09:00
|
|
|
<div v-if="active" ref="body" :class="$style.body">
|
2020-07-11 10:13:11 +09:00
|
|
|
<slot></slot>
|
|
|
|
</div>
|
2023-05-20 10:12:18 +09:00
|
|
|
</div>
|
2020-07-11 10:13:11 +09:00
|
|
|
</template>
|
|
|
|
|
2022-03-21 03:11:14 +09:00
|
|
|
<script lang="ts" setup>
|
2023-02-16 23:09:41 +09:00
|
|
|
import { onBeforeUnmount, onMounted, provide, watch } from 'vue';
|
|
|
|
import { updateColumn, swapLeftColumn, swapRightColumn, swapUpColumn, swapDownColumn, stackLeftColumn, popRightColumn, removeColumn, swapColumn, Column } from './deck-store';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as os from '@/os';
|
2022-03-21 03:11:14 +09:00
|
|
|
import { i18n } from '@/i18n';
|
2022-07-17 05:33:21 +09:00
|
|
|
import { MenuItem } from '@/types/menu';
|
2022-03-21 03:11:14 +09:00
|
|
|
|
|
|
|
provide('shouldHeaderThin', true);
|
|
|
|
provide('shouldOmitHeaderTitle', true);
|
2023-01-03 10:46:56 +09:00
|
|
|
provide('forceSpacerMin', true);
|
2022-03-21 03:11:14 +09:00
|
|
|
|
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
column: Column;
|
|
|
|
isStacked?: boolean;
|
|
|
|
naked?: boolean;
|
2022-07-17 05:33:21 +09:00
|
|
|
menu?: MenuItem[];
|
2022-03-21 03:11:14 +09:00
|
|
|
}>(), {
|
|
|
|
isStacked: false,
|
|
|
|
naked: false,
|
|
|
|
});
|
2020-07-11 10:13:11 +09:00
|
|
|
|
2023-05-20 10:12:18 +09:00
|
|
|
let body = $shallowRef<HTMLDivElement | null>();
|
2020-07-11 10:13:11 +09:00
|
|
|
|
2022-03-21 03:11:14 +09: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 10:13:11 +09:00
|
|
|
|
2022-03-21 03:11:14 +09:00
|
|
|
const isMainColumn = $computed(() => props.column.type === 'main');
|
|
|
|
const active = $computed(() => props.column.active !== false);
|
|
|
|
|
|
|
|
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 10:13:11 +09:00
|
|
|
|
2022-03-21 03:11:14 +09:00
|
|
|
function onOtherDragStart() {
|
|
|
|
dropready = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onOtherDragEnd() {
|
|
|
|
dropready = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleActive() {
|
|
|
|
if (!props.isStacked) return;
|
|
|
|
updateColumn(props.column.id, {
|
2022-07-03 20:30:58 +09:00
|
|
|
active: !props.column.active,
|
2022-03-21 03:11:14 +09:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function getMenu() {
|
2022-07-17 05:33:21 +09:00
|
|
|
let items = [{
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-settings',
|
2022-07-17 05:33:21 +09:00
|
|
|
text: i18n.ts._deck.configureColumn,
|
2022-03-21 03:11:14 +09:00
|
|
|
action: async () => {
|
|
|
|
const { canceled, result } = await os.form(props.column.name, {
|
|
|
|
name: {
|
|
|
|
type: 'string',
|
|
|
|
label: i18n.ts.name,
|
2022-07-03 20:30:58 +09:00
|
|
|
default: props.column.name,
|
2022-03-21 03:11:14 +09:00
|
|
|
},
|
|
|
|
width: {
|
|
|
|
type: 'number',
|
|
|
|
label: i18n.ts.width,
|
2022-07-03 20:30:58 +09:00
|
|
|
default: props.column.width,
|
2022-03-21 03:11:14 +09:00
|
|
|
},
|
|
|
|
flexible: {
|
|
|
|
type: 'boolean',
|
|
|
|
label: i18n.ts.flexible,
|
2022-07-03 20:30:58 +09:00
|
|
|
default: props.column.flexible,
|
|
|
|
},
|
2020-07-11 10:13:11 +09:00
|
|
|
});
|
2022-03-21 03:11:14 +09:00
|
|
|
if (canceled) return;
|
|
|
|
updateColumn(props.column.id, result);
|
2022-07-03 20:30:58 +09:00
|
|
|
},
|
2022-03-21 03:11:14 +09:00
|
|
|
}, {
|
2022-07-17 23:18:05 +09:00
|
|
|
type: 'parent',
|
|
|
|
text: i18n.ts.move + '...',
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-arrows-move',
|
2022-07-17 23:18:05 +09:00
|
|
|
children: [{
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-arrow-left',
|
2022-07-17 23:18:05 +09:00
|
|
|
text: i18n.ts._deck.swapLeft,
|
|
|
|
action: () => {
|
|
|
|
swapLeftColumn(props.column.id);
|
|
|
|
},
|
|
|
|
}, {
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-arrow-right',
|
2022-07-17 23:18:05 +09:00
|
|
|
text: i18n.ts._deck.swapRight,
|
|
|
|
action: () => {
|
|
|
|
swapRightColumn(props.column.id);
|
|
|
|
},
|
|
|
|
}, props.isStacked ? {
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-arrow-up',
|
2022-07-17 23:18:05 +09:00
|
|
|
text: i18n.ts._deck.swapUp,
|
|
|
|
action: () => {
|
|
|
|
swapUpColumn(props.column.id);
|
|
|
|
},
|
|
|
|
} : undefined, props.isStacked ? {
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-arrow-down',
|
2022-07-17 23:18:05 +09:00
|
|
|
text: i18n.ts._deck.swapDown,
|
|
|
|
action: () => {
|
|
|
|
swapDownColumn(props.column.id);
|
|
|
|
},
|
|
|
|
} : undefined],
|
|
|
|
}, {
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-stack-2',
|
2022-03-21 03:11:14 +09:00
|
|
|
text: i18n.ts._deck.stackLeft,
|
|
|
|
action: () => {
|
|
|
|
stackLeftColumn(props.column.id);
|
2022-07-03 20:30:58 +09:00
|
|
|
},
|
2022-03-21 03:11:14 +09:00
|
|
|
}, props.isStacked ? {
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-window-maximize',
|
2022-03-21 03:11:14 +09:00
|
|
|
text: i18n.ts._deck.popRight,
|
|
|
|
action: () => {
|
|
|
|
popRightColumn(props.column.id);
|
2022-07-03 20:30:58 +09:00
|
|
|
},
|
2022-03-21 03:11:14 +09:00
|
|
|
} : undefined, null, {
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-trash',
|
2022-03-21 03:11:14 +09:00
|
|
|
text: i18n.ts.remove,
|
|
|
|
danger: true,
|
|
|
|
action: () => {
|
|
|
|
removeColumn(props.column.id);
|
2022-07-03 20:30:58 +09:00
|
|
|
},
|
2022-03-21 03:11:14 +09:00
|
|
|
}];
|
2022-07-03 20:30:58 +09:00
|
|
|
|
2022-07-17 05:33:21 +09:00
|
|
|
if (props.menu) {
|
2022-07-03 20:30:58 +09:00
|
|
|
items.unshift(null);
|
2022-07-17 05:33:21 +09:00
|
|
|
items = props.menu.concat(items);
|
2022-07-03 20:30:58 +09:00
|
|
|
}
|
|
|
|
|
2022-03-21 03:11:14 +09:00
|
|
|
return items;
|
|
|
|
}
|
|
|
|
|
2022-07-03 20:30:58 +09:00
|
|
|
function showSettingsMenu(ev: MouseEvent) {
|
|
|
|
os.popupMenu(getMenu(), ev.currentTarget ?? ev.target);
|
|
|
|
}
|
|
|
|
|
2022-03-21 03:11:14 +09:00
|
|
|
function onContextmenu(ev: MouseEvent) {
|
|
|
|
os.contextMenu(getMenu(), ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
function goTop() {
|
2023-05-20 10:12:18 +09:00
|
|
|
if (body) {
|
|
|
|
body.scrollTo({
|
|
|
|
top: 0,
|
|
|
|
behavior: 'smooth',
|
|
|
|
});
|
|
|
|
}
|
2022-03-21 03:11:14 +09:00
|
|
|
}
|
|
|
|
|
2022-05-19 17:35:43 +09:00
|
|
|
function onDragstart(ev) {
|
|
|
|
ev.dataTransfer.effectAllowed = 'move';
|
|
|
|
ev.dataTransfer.setData(_DATA_TRANSFER_DECK_COLUMN_, props.column.id);
|
2022-03-21 03:11:14 +09:00
|
|
|
|
|
|
|
// Chromeのバグで、Dragstartハンドラ内ですぐにDOMを変更する(=リアクティブなプロパティを変更する)とDragが終了してしまう
|
|
|
|
// SEE: https://stackoverflow.com/questions/19639969/html5-dragend-event-firing-immediately
|
|
|
|
window.setTimeout(() => {
|
|
|
|
dragging = true;
|
|
|
|
}, 10);
|
|
|
|
}
|
|
|
|
|
2022-05-19 17:35:43 +09:00
|
|
|
function onDragend(ev) {
|
2022-03-21 03:11:14 +09:00
|
|
|
dragging = false;
|
|
|
|
}
|
|
|
|
|
2022-05-19 17:35:43 +09:00
|
|
|
function onDragover(ev) {
|
2022-03-21 03:11:14 +09:00
|
|
|
// 自分自身がドラッグされている場合
|
|
|
|
if (dragging) {
|
|
|
|
// 自分自身にはドロップさせない
|
2022-05-19 17:35:43 +09:00
|
|
|
ev.dataTransfer.dropEffect = 'none';
|
2022-05-29 15:15:52 +09:00
|
|
|
} else {
|
|
|
|
const isDeckColumn = ev.dataTransfer.types[0] === _DATA_TRANSFER_DECK_COLUMN_;
|
2022-03-21 03:11:14 +09:00
|
|
|
|
2022-05-29 15:15:52 +09:00
|
|
|
ev.dataTransfer.dropEffect = isDeckColumn ? 'move' : 'none';
|
2022-03-21 03:11:14 +09:00
|
|
|
|
2022-05-29 15:15:52 +09:00
|
|
|
if (isDeckColumn) draghover = true;
|
|
|
|
}
|
2022-03-21 03:11:14 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
function onDragleave() {
|
|
|
|
draghover = false;
|
|
|
|
}
|
|
|
|
|
2022-05-19 17:35:43 +09:00
|
|
|
function onDrop(ev) {
|
2022-03-21 03:11:14 +09:00
|
|
|
draghover = false;
|
|
|
|
os.deckGlobalEvents.emit('column.dragEnd');
|
|
|
|
|
2022-05-19 17:35:43 +09:00
|
|
|
const id = ev.dataTransfer.getData(_DATA_TRANSFER_DECK_COLUMN_);
|
|
|
|
if (id != null && id !== '') {
|
2022-03-21 03:11:14 +09:00
|
|
|
swapColumn(props.column.id, id);
|
|
|
|
}
|
|
|
|
}
|
2020-07-11 10:13:11 +09:00
|
|
|
</script>
|
|
|
|
|
2023-01-10 09:53:01 +09:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2021-04-10 12:40:50 +09:00
|
|
|
--root-margin: 10px;
|
2023-04-22 20:22:09 +09:00
|
|
|
--deckColumnHeaderHeight: 38px;
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2020-07-11 10:13:11 +09:00
|
|
|
height: 100%;
|
2023-01-02 12:15:26 +09:00
|
|
|
overflow: clip;
|
2022-07-03 20:30:58 +09:00
|
|
|
contain: strict;
|
2023-05-26 11:31:39 +09:00
|
|
|
border-radius: 8px;
|
2020-07-11 10:13:11 +09:00
|
|
|
|
|
|
|
&.draghover {
|
|
|
|
&:after {
|
|
|
|
content: "";
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
z-index: 1000;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
background: var(--focus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.dragging {
|
2022-07-03 20:30:58 +09:00
|
|
|
&:after {
|
|
|
|
content: "";
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
z-index: 1000;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
background: var(--focus);
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
2020-07-11 10:13:11 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
&.dropready {
|
|
|
|
* {
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&:not(.active) {
|
2020-12-26 22:41:00 +09:00
|
|
|
flex-basis: var(--deckColumnHeaderHeight);
|
|
|
|
min-height: var(--deckColumnHeaderHeight);
|
2023-05-26 11:31:39 +09:00
|
|
|
border-bottom-right-radius: 0;
|
2020-07-11 10:13:11 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
&.naked {
|
2020-12-20 17:19:18 +09:00
|
|
|
background: var(--acrylicBg) !important;
|
2021-08-11 22:34:45 +09:00
|
|
|
-webkit-backdrop-filter: var(--blur, blur(10px));
|
|
|
|
backdrop-filter: var(--blur, blur(10px));
|
2020-07-11 10:13:11 +09:00
|
|
|
|
2023-01-10 09:53:01 +09:00
|
|
|
> .header {
|
2020-07-11 10:13:11 +09:00
|
|
|
background: transparent;
|
|
|
|
box-shadow: none;
|
2023-01-10 09:53:01 +09:00
|
|
|
color: var(--fg);
|
2020-07-11 10:13:11 +09:00
|
|
|
}
|
2023-05-26 11:31:39 +09:00
|
|
|
|
|
|
|
> .body {
|
|
|
|
&::-webkit-scrollbar-track {
|
|
|
|
background: inherit;
|
|
|
|
}
|
|
|
|
}
|
2020-07-11 10:13:11 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
&.paged {
|
2020-12-28 17:00:31 +09:00
|
|
|
background: var(--bg) !important;
|
2023-05-26 11:31:39 +09:00
|
|
|
|
|
|
|
> .body {
|
|
|
|
&::-webkit-scrollbar-track {
|
|
|
|
background: inherit;
|
|
|
|
}
|
|
|
|
}
|
2020-07-11 10:13:11 +09:00
|
|
|
}
|
2023-01-10 09:53:01 +09:00
|
|
|
}
|
2020-07-11 10:13:11 +09:00
|
|
|
|
2023-01-10 09:53:01 +09:00
|
|
|
.header {
|
|
|
|
position: relative;
|
|
|
|
display: flex;
|
|
|
|
z-index: 2;
|
|
|
|
line-height: var(--deckColumnHeaderHeight);
|
|
|
|
height: var(--deckColumnHeaderHeight);
|
2023-05-26 11:31:39 +09:00
|
|
|
padding: 0 16px 0 28px;
|
2023-01-10 09:53:01 +09:00
|
|
|
font-size: 0.9em;
|
|
|
|
color: var(--panelHeaderFg);
|
|
|
|
background: var(--panelHeaderBg);
|
2023-04-21 09:29:32 +09:00
|
|
|
box-shadow: 0 1px 0 0 var(--panelHeaderDivider);
|
2023-01-10 09:53:01 +09:00
|
|
|
cursor: pointer;
|
2023-04-21 09:34:36 +09:00
|
|
|
user-select: none;
|
2023-01-10 09:53:01 +09:00
|
|
|
}
|
2020-07-11 10:13:11 +09:00
|
|
|
|
2023-05-26 11:31:39 +09:00
|
|
|
.color {
|
|
|
|
position: absolute;
|
|
|
|
top: 10px;
|
|
|
|
left: 10px;
|
|
|
|
width: 3px;
|
|
|
|
height: calc(100% - 20px);
|
|
|
|
background: var(--accent);
|
|
|
|
border-radius: 999px;
|
|
|
|
}
|
|
|
|
|
2023-05-26 10:48:49 +09:00
|
|
|
.tabShape {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
right: -8px;
|
|
|
|
width: auto;
|
|
|
|
height: calc(100% - 6px);
|
|
|
|
}
|
|
|
|
|
2023-01-10 09:53:01 +09:00
|
|
|
.title {
|
|
|
|
display: inline-block;
|
|
|
|
align-items: center;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
width: 100%;
|
|
|
|
}
|
2020-07-11 10:13:11 +09:00
|
|
|
|
2023-01-10 09:53:01 +09:00
|
|
|
.toggleActive,
|
|
|
|
.menu {
|
|
|
|
z-index: 1;
|
|
|
|
width: var(--deckColumnHeaderHeight);
|
|
|
|
line-height: var(--deckColumnHeaderHeight);
|
|
|
|
color: var(--faceTextButton);
|
2020-07-11 10:13:11 +09:00
|
|
|
|
2023-01-10 09:53:01 +09:00
|
|
|
&:hover {
|
|
|
|
color: var(--faceTextButtonHover);
|
|
|
|
}
|
2020-07-11 10:13:11 +09:00
|
|
|
|
2023-01-10 09:53:01 +09:00
|
|
|
&:active {
|
|
|
|
color: var(--faceTextButtonActive);
|
|
|
|
}
|
|
|
|
}
|
2020-07-11 10:13:11 +09:00
|
|
|
|
2023-01-10 09:53:01 +09:00
|
|
|
.toggleActive {
|
|
|
|
margin-left: -16px;
|
|
|
|
}
|
2020-07-11 10:13:11 +09:00
|
|
|
|
2023-01-10 09:53:01 +09:00
|
|
|
.menu {
|
|
|
|
margin-left: auto;
|
|
|
|
margin-right: -16px;
|
|
|
|
}
|
2020-07-11 10:13:11 +09:00
|
|
|
|
2023-01-10 09:53:01 +09:00
|
|
|
.body {
|
|
|
|
height: calc(100% - var(--deckColumnHeaderHeight));
|
|
|
|
overflow-y: auto;
|
|
|
|
overflow-x: hidden; // Safari does not supports clip
|
|
|
|
overflow-x: clip;
|
|
|
|
-webkit-overflow-scrolling: touch;
|
|
|
|
box-sizing: border-box;
|
2023-05-08 18:30:40 +09:00
|
|
|
container-type: size;
|
2023-01-10 09:53:01 +09:00
|
|
|
background-color: var(--bg);
|
2023-05-26 11:31:39 +09:00
|
|
|
|
|
|
|
&::-webkit-scrollbar-track {
|
|
|
|
background: var(--panel);
|
|
|
|
}
|
2020-07-11 10:13:11 +09:00
|
|
|
}
|
|
|
|
</style>
|