From 20d82bcda4a33d3b1ff5f74b3b1dee87f990d0cd Mon Sep 17 00:00:00 2001 From: Kia King Ishii Date: Wed, 22 Jan 2025 14:33:19 +0900 Subject: [PATCH] feat(table): add cell type "Indicator" (#573) --- lib/components/SIndicator.vue | 17 ++++++--- lib/components/STableCell.vue | 6 +++ lib/components/STableCellIndicator.vue | 38 +++++++++++++++++++ lib/composables/Table.ts | 21 +++++++--- .../SIndicator.01_Playground.story.vue | 3 +- .../components/SIndicator.02_States.story.vue | 3 +- 6 files changed, 75 insertions(+), 13 deletions(-) create mode 100644 lib/components/STableCellIndicator.vue diff --git a/lib/components/SIndicator.vue b/lib/components/SIndicator.vue index 2edc5e92..fedab43a 100644 --- a/lib/components/SIndicator.vue +++ b/lib/components/SIndicator.vue @@ -1,13 +1,14 @@ + + + + diff --git a/lib/composables/Table.ts b/lib/composables/Table.ts index 0ade33c3..f6ad170c 100644 --- a/lib/composables/Table.ts +++ b/lib/composables/Table.ts @@ -1,5 +1,6 @@ import { type Component, type MaybeRef, type MaybeRefOrGetter } from 'vue' -import { type Mode } from '../components/SButton.vue' +import { type Mode as ButtonMode } from '../components/SButton.vue' +import { type State as IndicatorState } from '../components/SIndicator.vue' import { type Day } from '../support/Day' import { type DropdownSection } from './Dropdown' import { type Position } from './Tooltip' @@ -60,6 +61,7 @@ export type TableCell = | TableCellPill | TableCellPills | TableCellState + | TableCellIndicator | TableCellAvatar | TableCellAvatars | TableCellCustom @@ -75,6 +77,7 @@ export type TableCellType = | 'pill' | 'pills' | 'state' + | 'indicator' | 'avatar' | 'avatars' | 'custom' @@ -201,17 +204,23 @@ export interface TableCellState extends TableCellBase { mode?: ColorModes } +export interface TableCellIndicator extends TableCellBase { + type: 'indicator' + state: IndicatorState + label?: string | null +} + export interface TableCellActions extends TableCellBase { type: 'actions' actions: TableCellAction[] } export interface TableCellAction { - mode?: Mode + mode?: ButtonMode icon?: Component - iconMode?: Mode + iconMode?: ButtonMode label?: string - labelMode?: Mode + labelMode?: ButtonMode onClick(record: R): void show?(record: R): boolean } @@ -224,9 +233,9 @@ export interface TableMenu { export interface TableHeaderAction { show?: boolean - mode?: Mode + mode?: ButtonMode label: string - labelMode?: Mode + labelMode?: ButtonMode onClick(): void } diff --git a/stories/components/SIndicator.01_Playground.story.vue b/stories/components/SIndicator.01_Playground.story.vue index db011b15..adddc9e3 100644 --- a/stories/components/SIndicator.01_Playground.story.vue +++ b/stories/components/SIndicator.01_Playground.story.vue @@ -36,7 +36,8 @@ function state() { queued: 'queued', running: 'running', completed: 'completed', - failed: 'failed' + failed: 'failed', + aborted: 'aborted' }" v-model="state.state" /> diff --git a/stories/components/SIndicator.02_States.story.vue b/stories/components/SIndicator.02_States.story.vue index dbb6c822..81364b95 100644 --- a/stories/components/SIndicator.02_States.story.vue +++ b/stories/components/SIndicator.02_States.story.vue @@ -10,7 +10,8 @@ const states = [ 'queued', 'running', 'completed', - 'failed' + 'failed', + 'aborted' ] as const function state() {