diff options
| author | Hazelnoot <acomputerdog@gmail.com> | 2025-03-25 16:14:53 -0400 |
|---|---|---|
| committer | Hazelnoot <acomputerdog@gmail.com> | 2025-03-25 16:14:53 -0400 |
| commit | d8908ef2d8fa84d8e0fc1d30ab90a600a3d88054 (patch) | |
| tree | 0c8d3e0385ce7021c7187ef8b608f1abd87496e5 /packages/frontend/src/components/grid | |
| parent | merge: enhance: Update de-DE.yml (!949) (diff) | |
| parent | enhance(frontend): 設定の移行を手動でトリガーできるように (diff) | |
| download | sharkey-d8908ef2d8fa84d8e0fc1d30ab90a600a3d88054.tar.gz sharkey-d8908ef2d8fa84d8e0fc1d30ab90a600a3d88054.tar.bz2 sharkey-d8908ef2d8fa84d8e0fc1d30ab90a600a3d88054.zip | |
merge upstream
Diffstat (limited to 'packages/frontend/src/components/grid')
14 files changed, 96 insertions, 84 deletions
diff --git a/packages/frontend/src/components/grid/MkDataCell.vue b/packages/frontend/src/components/grid/MkDataCell.vue index e473b7c1af..7c8a5d64d7 100644 --- a/packages/frontend/src/components/grid/MkDataCell.vue +++ b/packages/frontend/src/components/grid/MkDataCell.vue @@ -39,10 +39,12 @@ SPDX-License-Identifier: AGPL-3.0-only {{ cell.value }} </div> <div v-else-if="cellType === 'boolean'"> - <div :class="[$style.bool, { - [$style.boolTrue]: cell.value === true, - 'ti ti-check': cell.value === true, - }]"></div> + <div + :class="[$style.bool, { + [$style.boolTrue]: cell.value === true, + 'ti ti-check': cell.value === true, + }]" + ></div> </div> <div v-else-if="cellType === 'image'"> <img @@ -88,13 +90,14 @@ SPDX-License-Identifier: AGPL-3.0-only </template> <script setup lang="ts"> -import { computed, defineAsyncComponent, nextTick, onMounted, onUnmounted, ref, shallowRef, toRefs, watch } from 'vue'; -import { GridEventEmitter, Size } from '@/components/grid/grid.js'; -import { useTooltip } from '@/scripts/use-tooltip.js'; +import { computed, defineAsyncComponent, nextTick, onMounted, onUnmounted, ref, useTemplateRef, toRefs, watch } from 'vue'; +import type { Size } from '@/components/grid/grid.js'; +import type { CellValue, GridCell } from '@/components/grid/cell.js'; +import type { GridRowSetting } from '@/components/grid/row.js'; +import { GridEventEmitter } from '@/components/grid/grid.js'; +import { useTooltip } from '@/use/use-tooltip.js'; import * as os from '@/os.js'; -import { CellValue, GridCell } from '@/components/grid/cell.js'; import { equalCellAddress, getCellAddress } from '@/components/grid/grid-utils.js'; -import { GridRowSetting } from '@/components/grid/row.js'; const emit = defineEmits<{ (ev: 'operation:beginEdit', sender: GridCell): void; @@ -110,9 +113,9 @@ const props = defineProps<{ const { cell, bus } = toRefs(props); -const rootEl = shallowRef<InstanceType<typeof HTMLTableCellElement>>(); -const contentAreaEl = shallowRef<InstanceType<typeof HTMLDivElement>>(); -const inputAreaEl = shallowRef<InstanceType<typeof HTMLDivElement>>(); +const rootEl = useTemplateRef('rootEl'); +const contentAreaEl = useTemplateRef('contentAreaEl'); +const inputAreaEl = useTemplateRef('inputAreaEl'); /** 値が編集中かどうか */ const editing = ref<boolean>(false); diff --git a/packages/frontend/src/components/grid/MkDataRow.vue b/packages/frontend/src/components/grid/MkDataRow.vue index 280a14bc4a..a35f93b435 100644 --- a/packages/frontend/src/components/grid/MkDataRow.vue +++ b/packages/frontend/src/components/grid/MkDataRow.vue @@ -37,11 +37,12 @@ SPDX-License-Identifier: AGPL-3.0-only </template> <script setup lang="ts"> -import { GridEventEmitter, Size } from '@/components/grid/grid.js'; +import { GridEventEmitter } from '@/components/grid/grid.js'; import MkDataCell from '@/components/grid/MkDataCell.vue'; import MkNumberCell from '@/components/grid/MkNumberCell.vue'; -import { CellValue, GridCell } from '@/components/grid/cell.js'; -import { GridRow, GridRowSetting } from '@/components/grid/row.js'; +import type { Size } from '@/components/grid/grid.js'; +import type { CellValue, GridCell } from '@/components/grid/cell.js'; +import type { GridRow, GridRowSetting } from '@/components/grid/row.js'; const emit = defineEmits<{ (ev: 'operation:beginEdit', sender: GridCell): void; diff --git a/packages/frontend/src/components/grid/MkGrid.stories.impl.ts b/packages/frontend/src/components/grid/MkGrid.stories.impl.ts index 5801012f15..f85bf146e8 100644 --- a/packages/frontend/src/components/grid/MkGrid.stories.impl.ts +++ b/packages/frontend/src/components/grid/MkGrid.stories.impl.ts @@ -5,14 +5,14 @@ /* eslint-disable @typescript-eslint/explicit-function-return-type */ import { action } from '@storybook/addon-actions'; -import { StoryObj } from '@storybook/vue3'; +import type { StoryObj } from '@storybook/vue3'; import { ref } from 'vue'; import { commonHandlers } from '../../../.storybook/mocks.js'; import { boolean, choose, country, date, firstName, integer, lastName, text } from '../../../.storybook/fake-utils.js'; import MkGrid from './MkGrid.vue'; -import { GridContext, GridEvent } from '@/components/grid/grid-event.js'; -import { DataSource, GridSetting } from '@/components/grid/grid.js'; -import { GridColumnSetting } from '@/components/grid/column.js'; +import type { GridContext, GridEvent } from '@/components/grid/grid-event.js'; +import type { DataSource, GridSetting } from '@/components/grid/grid.js'; +import type { GridColumnSetting } from '@/components/grid/column.js'; function d(p: { check?: boolean, diff --git a/packages/frontend/src/components/grid/MkGrid.vue b/packages/frontend/src/components/grid/MkGrid.vue index 4dbd4ebcae..94f4f3dab1 100644 --- a/packages/frontend/src/components/grid/MkGrid.vue +++ b/packages/frontend/src/components/grid/MkGrid.vue @@ -50,11 +50,11 @@ SPDX-License-Identifier: AGPL-3.0-only <script setup lang="ts"> import { computed, onMounted, ref, toRefs, watch } from 'vue'; -import { DataSource, GridEventEmitter, GridSetting, GridState, Size } from '@/components/grid/grid.js'; +import { GridEventEmitter } from '@/components/grid/grid.js'; import MkDataRow from '@/components/grid/MkDataRow.vue'; import MkHeaderRow from '@/components/grid/MkHeaderRow.vue'; import { cellValidation } from '@/components/grid/cell-validators.js'; -import { CELL_ADDRESS_NONE, CellAddress, CellValue, createCell, GridCell, resetCell } from '@/components/grid/cell.js'; +import { CELL_ADDRESS_NONE, createCell, resetCell } from '@/components/grid/cell.js'; import { copyGridDataToClipboard, equalCellAddress, @@ -63,18 +63,23 @@ import { pasteToGridFromClipboard, removeDataFromGrid, } from '@/components/grid/grid-utils.js'; -import { MenuItem } from '@/types/menu.js'; import * as os from '@/os.js'; -import { GridContext, GridEvent } from '@/components/grid/grid-event.js'; -import { createColumn, GridColumn } from '@/components/grid/column.js'; -import { createRow, defaultGridRowSetting, GridRow, GridRowSetting, resetRow } from '@/components/grid/row.js'; -import { handleKeyEvent } from '@/scripts/key-event.js'; +import { createColumn } from '@/components/grid/column.js'; +import { createRow, defaultGridRowSetting, resetRow } from '@/components/grid/row.js'; +import { handleKeyEvent } from '@/utility/key-event.js'; + +import type { DataSource, GridSetting, GridState, Size } from '@/components/grid/grid.js'; +import type { CellAddress, CellValue, GridCell } from '@/components/grid/cell.js'; +import type { GridContext, GridEvent } from '@/components/grid/grid-event.js'; +import type { GridColumn } from '@/components/grid/column.js'; +import type { GridRow, GridRowSetting } from '@/components/grid/row.js'; +import type { MenuItem } from '@/types/menu.js'; type RowHolder = { row: GridRow, cells: GridCell[], origin: DataSource, -} +}; const emit = defineEmits<{ (ev: 'event', event: GridEvent, context: GridContext): void; diff --git a/packages/frontend/src/components/grid/MkHeaderCell.vue b/packages/frontend/src/components/grid/MkHeaderCell.vue index aecfe7eaa3..69a68b6f2c 100644 --- a/packages/frontend/src/components/grid/MkHeaderCell.vue +++ b/packages/frontend/src/components/grid/MkHeaderCell.vue @@ -32,8 +32,9 @@ SPDX-License-Identifier: AGPL-3.0-only <script setup lang="ts"> import { computed, nextTick, onMounted, onUnmounted, ref, toRefs, watch } from 'vue'; -import { GridEventEmitter, Size } from '@/components/grid/grid.js'; -import { GridColumn } from '@/components/grid/column.js'; +import { GridEventEmitter } from '@/components/grid/grid.js'; +import type { Size } from '@/components/grid/grid.js'; +import type { GridColumn } from '@/components/grid/column.js'; const emit = defineEmits<{ (ev: 'operation:beginWidthChange', sender: GridColumn): void; diff --git a/packages/frontend/src/components/grid/MkHeaderRow.vue b/packages/frontend/src/components/grid/MkHeaderRow.vue index 8affa08fd5..225f623b84 100644 --- a/packages/frontend/src/components/grid/MkHeaderRow.vue +++ b/packages/frontend/src/components/grid/MkHeaderRow.vue @@ -29,11 +29,12 @@ SPDX-License-Identifier: AGPL-3.0-only </template> <script setup lang="ts"> -import { GridEventEmitter, Size } from '@/components/grid/grid.js'; +import { GridEventEmitter } from '@/components/grid/grid.js'; import MkHeaderCell from '@/components/grid/MkHeaderCell.vue'; import MkNumberCell from '@/components/grid/MkNumberCell.vue'; -import { GridColumn } from '@/components/grid/column.js'; -import { GridRowSetting } from '@/components/grid/row.js'; +import type { Size } from '@/components/grid/grid.js'; +import type { GridColumn } from '@/components/grid/column.js'; +import type { GridRowSetting } from '@/components/grid/row.js'; const emit = defineEmits<{ (ev: 'operation:beginWidthChange', sender: GridColumn): void; diff --git a/packages/frontend/src/components/grid/MkNumberCell.vue b/packages/frontend/src/components/grid/MkNumberCell.vue index 674bba96bc..d3b5956ddd 100644 --- a/packages/frontend/src/components/grid/MkNumberCell.vue +++ b/packages/frontend/src/components/grid/MkNumberCell.vue @@ -19,8 +19,7 @@ SPDX-License-Identifier: AGPL-3.0-only </template> <script setup lang="ts"> - -import { GridRow } from '@/components/grid/row.js'; +import type { GridRow } from '@/components/grid/row.js'; defineProps<{ content: string, diff --git a/packages/frontend/src/components/grid/cell-validators.ts b/packages/frontend/src/components/grid/cell-validators.ts index 949cab2ec6..7310a82c9e 100644 --- a/packages/frontend/src/components/grid/cell-validators.ts +++ b/packages/frontend/src/components/grid/cell-validators.ts @@ -3,9 +3,9 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { CellValue, GridCell } from '@/components/grid/cell.js'; -import { GridColumn } from '@/components/grid/column.js'; -import { GridRow } from '@/components/grid/row.js'; +import type { CellValue, GridCell } from '@/components/grid/cell.js'; +import type { GridColumn } from '@/components/grid/column.js'; +import type { GridRow } from '@/components/grid/row.js'; import { i18n } from '@/i18n.js'; export type ValidatorParams = { @@ -18,25 +18,25 @@ export type ValidatorParams = { export type ValidatorResult = { valid: boolean; message?: string; -} +}; export type GridCellValidator = { name?: string; ignoreViolation?: boolean; validate: (params: ValidatorParams) => ValidatorResult; -} +}; export type ValidateViolation = { valid: boolean; params: ValidatorParams; violations: ValidateViolationItem[]; -} +}; export type ValidateViolationItem = { valid: boolean; validator: GridCellValidator; result: ValidatorResult; -} +}; export function cellValidation(allCells: GridCell[], cell: GridCell, newValue: CellValue): ValidateViolation { const { column, row } = cell; diff --git a/packages/frontend/src/components/grid/cell.ts b/packages/frontend/src/components/grid/cell.ts index 71b7a3e3f1..d347d05bdb 100644 --- a/packages/frontend/src/components/grid/cell.ts +++ b/packages/frontend/src/components/grid/cell.ts @@ -3,19 +3,19 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { ValidateViolation } from '@/components/grid/cell-validators.js'; -import { Size } from '@/components/grid/grid.js'; -import { GridColumn } from '@/components/grid/column.js'; -import { GridRow } from '@/components/grid/row.js'; -import { MenuItem } from '@/types/menu.js'; -import { GridContext } from '@/components/grid/grid-event.js'; +import type { ValidateViolation } from '@/components/grid/cell-validators.js'; +import type { Size } from '@/components/grid/grid.js'; +import type { GridColumn } from '@/components/grid/column.js'; +import type { GridRow } from '@/components/grid/row.js'; +import type { MenuItem } from '@/types/menu.js'; +import type { GridContext } from '@/components/grid/grid-event.js'; export type CellValue = string | boolean | number | undefined | null | Array<unknown> | NonNullable<unknown>; export type CellAddress = { row: number; col: number; -} +}; export const CELL_ADDRESS_NONE: CellAddress = { row: -1, @@ -32,13 +32,13 @@ export type GridCell = { contentSize: Size; setting: GridCellSetting; violation: ValidateViolation; -} +}; export type GridCellContextMenuFactory = (col: GridColumn, row: GridRow, value: CellValue, context: GridContext) => MenuItem[]; export type GridCellSetting = { contextMenuFactory?: GridCellContextMenuFactory; -} +}; export function createCell( column: GridColumn, diff --git a/packages/frontend/src/components/grid/column.ts b/packages/frontend/src/components/grid/column.ts index 2f505756fe..6a694b39ec 100644 --- a/packages/frontend/src/components/grid/column.ts +++ b/packages/frontend/src/components/grid/column.ts @@ -3,13 +3,13 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { GridCellValidator } from '@/components/grid/cell-validators.js'; -import { Size, SizeStyle } from '@/components/grid/grid.js'; import { calcCellWidth } from '@/components/grid/grid-utils.js'; -import { CellValue, GridCell } from '@/components/grid/cell.js'; -import { GridRow } from '@/components/grid/row.js'; -import { MenuItem } from '@/types/menu.js'; -import { GridContext } from '@/components/grid/grid-event.js'; +import type { GridCellValidator } from '@/components/grid/cell-validators.js'; +import type { Size, SizeStyle } from '@/components/grid/grid.js'; +import type { CellValue, GridCell } from '@/components/grid/cell.js'; +import type { GridRow } from '@/components/grid/row.js'; +import type { MenuItem } from '@/types/menu.js'; +import type { GridContext } from '@/components/grid/grid-event.js'; export type ColumnType = 'text' | 'number' | 'date' | 'boolean' | 'image' | 'hidden'; @@ -40,7 +40,7 @@ export type GridColumn = { setting: GridColumnSetting; width: string; contentSize: Size; -} +}; export function createColumn(setting: GridColumnSetting, index: number): GridColumn { return { diff --git a/packages/frontend/src/components/grid/grid-event.ts b/packages/frontend/src/components/grid/grid-event.ts index 074b72b956..e2f1e44055 100644 --- a/packages/frontend/src/components/grid/grid-event.ts +++ b/packages/frontend/src/components/grid/grid-event.ts @@ -3,11 +3,11 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { CellAddress, CellValue, GridCell } from '@/components/grid/cell.js'; -import { GridState } from '@/components/grid/grid.js'; -import { ValidateViolation } from '@/components/grid/cell-validators.js'; -import { GridColumn } from '@/components/grid/column.js'; -import { GridRow } from '@/components/grid/row.js'; +import type { CellAddress, CellValue, GridCell } from '@/components/grid/cell.js'; +import type { GridState } from '@/components/grid/grid.js'; +import type { ValidateViolation } from '@/components/grid/cell-validators.js'; +import type { GridColumn } from '@/components/grid/column.js'; +import type { GridRow } from '@/components/grid/row.js'; export type GridContext = { selectedCell?: GridCell; diff --git a/packages/frontend/src/components/grid/grid-utils.ts b/packages/frontend/src/components/grid/grid-utils.ts index a45bc88926..9e5402354e 100644 --- a/packages/frontend/src/components/grid/grid-utils.ts +++ b/packages/frontend/src/components/grid/grid-utils.ts @@ -3,13 +3,15 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { isRef, Ref } from 'vue'; -import { DataSource, SizeStyle } from '@/components/grid/grid.js'; -import { CELL_ADDRESS_NONE, CellAddress, CellValue, GridCell } from '@/components/grid/cell.js'; -import { GridRow } from '@/components/grid/row.js'; -import { GridContext } from '@/components/grid/grid-event.js'; -import { copyToClipboard } from '@/scripts/copy-to-clipboard.js'; -import { GridColumn, GridColumnSetting } from '@/components/grid/column.js'; +import { isRef } from 'vue'; +import type { Ref } from 'vue'; +import type { DataSource, SizeStyle } from '@/components/grid/grid.js'; +import { CELL_ADDRESS_NONE } from '@/components/grid/cell.js'; +import type { CellAddress, CellValue, GridCell } from '@/components/grid/cell.js'; +import type { GridRow } from '@/components/grid/row.js'; +import type { GridContext } from '@/components/grid/grid-event.js'; +import { copyToClipboard } from '@/utility/copy-to-clipboard.js'; +import type { GridColumn, GridColumnSetting } from '@/components/grid/column.js'; export function isCellElement(elem: HTMLElement): boolean { return elem.hasAttribute('data-grid-cell'); diff --git a/packages/frontend/src/components/grid/grid.ts b/packages/frontend/src/components/grid/grid.ts index b82e12b304..0428e6493c 100644 --- a/packages/frontend/src/components/grid/grid.ts +++ b/packages/frontend/src/components/grid/grid.ts @@ -4,9 +4,9 @@ */ import { EventEmitter } from 'eventemitter3'; -import { CellValue, GridCellSetting } from '@/components/grid/cell.js'; -import { GridColumnSetting } from '@/components/grid/column.js'; -import { GridRowSetting } from '@/components/grid/row.js'; +import type { CellValue, GridCellSetting } from '@/components/grid/cell.js'; +import type { GridColumnSetting } from '@/components/grid/column.js'; +import type { GridRowSetting } from '@/components/grid/row.js'; export type GridSetting = { root?: { @@ -21,7 +21,7 @@ export type GridSetting = { export type DataSource = Record<string, CellValue>; -export type GridState = +export type GridState = ( 'normal' | 'cellSelecting' | 'cellEditing' | @@ -29,19 +29,19 @@ export type GridState = 'colSelecting' | 'rowSelecting' | 'hidden' - ; +); export type Size = { width: number; height: number; -} +}; export type SizeStyle = number | 'auto' | undefined; export type AdditionalStyle = { className?: string; style?: Record<string, string | number>; -} +}; export class GridEventEmitter extends EventEmitter<{ 'forceRefreshContentSize': void; diff --git a/packages/frontend/src/components/grid/row.ts b/packages/frontend/src/components/grid/row.ts index e0a317c9d3..42da22193f 100644 --- a/packages/frontend/src/components/grid/row.ts +++ b/packages/frontend/src/components/grid/row.ts @@ -3,11 +3,11 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { AdditionalStyle } from '@/components/grid/grid.js'; -import { GridCell } from '@/components/grid/cell.js'; -import { GridColumn } from '@/components/grid/column.js'; -import { MenuItem } from '@/types/menu.js'; -import { GridContext } from '@/components/grid/grid-event.js'; +import type { AdditionalStyle } from '@/components/grid/grid.js'; +import type { GridCell } from '@/components/grid/cell.js'; +import type { GridColumn } from '@/components/grid/column.js'; +import type { MenuItem } from '@/types/menu.js'; +import type { GridContext } from '@/components/grid/grid-event.js'; export const defaultGridRowSetting: Required<GridRowSetting> = { showNumber: true, @@ -27,7 +27,7 @@ export type GridRowStyleRuleConditionParams = { export type GridRowStyleRule = { condition: (params: GridRowStyleRuleConditionParams) => boolean; applyStyle: AdditionalStyle; -} +}; export type GridRowContextMenuFactory = (row: GridRow, context: GridContext) => MenuItem[]; @@ -40,7 +40,7 @@ export type GridRowSetting = { events?: { delete?: (rows: GridRow[]) => void; } -} +}; export type GridRow = { index: number; @@ -48,7 +48,7 @@ export type GridRow = { using: boolean; setting: GridRowSetting; additionalStyles: AdditionalStyle[]; -} +}; export function createRow(index: number, using: boolean, setting: GridRowSetting): GridRow { return { |