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