@meistrari/tela-build 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -0
- package/app.config.ts +73 -0
- package/components/tela/animated/animated-calculating-number.vue +16 -0
- package/components/tela/animated/animated-number.mdx +248 -0
- package/components/tela/animated/animated-number.stories.ts +52 -0
- package/components/tela/animated/animated-number.vue +23 -0
- package/components/tela/animated/animated-text.vue +124 -0
- package/components/tela/animated/animated-value.vue +68 -0
- package/components/tela/avatar/avatar.mdx +117 -0
- package/components/tela/avatar/avatar.stories.ts +62 -0
- package/components/tela/avatar/avatar.vue +71 -0
- package/components/tela/avatar/group/avatar-group.stories.ts +78 -0
- package/components/tela/avatar/group/avatar-group.vue +46 -0
- package/components/tela/badge/badge.mdx +154 -0
- package/components/tela/badge/badge.stories.ts +82 -0
- package/components/tela/badge/badge.vue +41 -0
- package/components/tela/button/button.mdx +155 -0
- package/components/tela/button/button.stories.ts +202 -0
- package/components/tela/button/button.vue +107 -0
- package/components/tela/card.vue +30 -0
- package/components/tela/chart/chart-bar.vue +58 -0
- package/components/tela/chat/chat.mdx +268 -0
- package/components/tela/chat/chat.stories.ts +253 -0
- package/components/tela/chat/command/index.vue +41 -0
- package/components/tela/chat/command/mention/index.vue +138 -0
- package/components/tela/chat/index.vue +112 -0
- package/components/tela/chat/pure-text-input/chat-text-input.vue +190 -0
- package/components/tela/chat/text-input/chat-text-input.stories.ts +128 -0
- package/components/tela/chat/text-input/index.vue +217 -0
- package/components/tela/chat/text-message/chat-text-message.stories.ts +138 -0
- package/components/tela/chat/text-message/index.vue +355 -0
- package/components/tela/chat/types.ts +19 -0
- package/components/tela/checkbox/checkbox-card.vue +30 -0
- package/components/tela/checkbox/checkbox.mdx +164 -0
- package/components/tela/checkbox/checkbox.stories.ts +104 -0
- package/components/tela/checkbox/checkbox.vue +43 -0
- package/components/tela/collapsible/Collapsible.vue +15 -0
- package/components/tela/collapsible/CollapsibleContent.vue +59 -0
- package/components/tela/collapsible/CollapsibleTrigger.vue +12 -0
- package/components/tela/collapsible/collapsible.mdx +157 -0
- package/components/tela/collapsible-section/collapsible-section.mdx +180 -0
- package/components/tela/collapsible-section/collapsible-section.stories.ts +53 -0
- package/components/tela/collapsible-section/collapsible-section.vue +51 -0
- package/components/tela/collapsible-section-with-actions.vue +98 -0
- package/components/tela/combobox/combobox-anchor.vue +24 -0
- package/components/tela/combobox/combobox-empty.vue +19 -0
- package/components/tela/combobox/combobox-group.vue +24 -0
- package/components/tela/combobox/combobox-indicator.vue +22 -0
- package/components/tela/combobox/combobox-input.vue +31 -0
- package/components/tela/combobox/combobox-item.vue +28 -0
- package/components/tela/combobox/combobox-label.vue +24 -0
- package/components/tela/combobox/combobox-list.vue +90 -0
- package/components/tela/combobox/combobox-module-selector.vue +366 -0
- package/components/tela/combobox/combobox-root.vue +15 -0
- package/components/tela/combobox/combobox-trigger.vue +12 -0
- package/components/tela/combobox/combobox.mdx +285 -0
- package/components/tela/combobox/combobox.stories.ts +232 -0
- package/components/tela/combobox/combobox.vue +497 -0
- package/components/tela/command/command-dialog.vue +22 -0
- package/components/tela/command/command-empty.vue +25 -0
- package/components/tela/command/command-group.vue +46 -0
- package/components/tela/command/command-input.vue +38 -0
- package/components/tela/command/command-item.vue +78 -0
- package/components/tela/command/command-list.vue +78 -0
- package/components/tela/command/command-separator.vue +23 -0
- package/components/tela/command/command-shortcut.vue +13 -0
- package/components/tela/command/command.vue +88 -0
- package/components/tela/command/dialog-base.vue +15 -0
- package/components/tela/command/dialog-content.vue +50 -0
- package/components/tela/command/utils.ts +15 -0
- package/components/tela/complex-table/complex-table-cell.stories.ts +145 -0
- package/components/tela/complex-table/complex-table-cell.vue +45 -0
- package/components/tela/complex-table/complex-table-header-cell.stories.ts +103 -0
- package/components/tela/complex-table/complex-table-header-cell.vue +48 -0
- package/components/tela/complex-table/complex-table-header.stories.ts +89 -0
- package/components/tela/complex-table/complex-table-header.vue +70 -0
- package/components/tela/complex-table/complex-table-row.vue +199 -0
- package/components/tela/complex-table/complex-table-virtualized.vue +326 -0
- package/components/tela/complex-table/complex-table.stories.ts +358 -0
- package/components/tela/complex-table/complex-table.vue +237 -0
- package/components/tela/complex-table/composables/table-common.ts +93 -0
- package/components/tela/complex-table/composables/table-selection.ts +87 -0
- package/components/tela/complex-table/composables/virtual-scroll.ts +252 -0
- package/components/tela/complex-table/styles/table-shared.css +170 -0
- package/components/tela/complex-table/types.ts +63 -0
- package/components/tela/complex-table/utils.ts +35 -0
- package/components/tela/confirm-button/confirm-button.vue +137 -0
- package/components/tela/confirmation-modal/confirmation-modal.vue +72 -0
- package/components/tela/copy-button.vue +86 -0
- package/components/tela/date-range-picker.vue +221 -0
- package/components/tela/dialog/dialog.mdx +170 -0
- package/components/tela/dialog/dialog.vue +182 -0
- package/components/tela/disabled-area.vue +16 -0
- package/components/tela/disclaimer/disclaimer.mdx +238 -0
- package/components/tela/disclaimer/disclaimer.stories.ts +196 -0
- package/components/tela/disclaimer/disclaimer.vue +125 -0
- package/components/tela/dropdown-menu/DropdownMenu.vue +121 -0
- package/components/tela/dropdown-menu/DropdownMenuCheckboxItem.vue +40 -0
- package/components/tela/dropdown-menu/DropdownMenuContent.vue +75 -0
- package/components/tela/dropdown-menu/DropdownMenuGroup.vue +12 -0
- package/components/tela/dropdown-menu/DropdownMenuItem.vue +137 -0
- package/components/tela/dropdown-menu/DropdownMenuLabel.vue +26 -0
- package/components/tela/dropdown-menu/DropdownMenuRadioGroup.vue +18 -0
- package/components/tela/dropdown-menu/DropdownMenuRadioItem.vue +40 -0
- package/components/tela/dropdown-menu/DropdownMenuRoot.vue +15 -0
- package/components/tela/dropdown-menu/DropdownMenuSeparator.vue +21 -0
- package/components/tela/dropdown-menu/DropdownMenuShortcut.vue +14 -0
- package/components/tela/dropdown-menu/DropdownMenuSub.vue +18 -0
- package/components/tela/dropdown-menu/DropdownMenuSubContent.vue +30 -0
- package/components/tela/dropdown-menu/DropdownMenuSubTrigger.vue +35 -0
- package/components/tela/dropdown-menu/DropdownMenuTrigger.vue +14 -0
- package/components/tela/dropdown-menu/dropdown-menu.mdx +265 -0
- package/components/tela/dropdown-menu/dropdown-menu.stories.ts +156 -0
- package/components/tela/expandable-input.vue +96 -0
- package/components/tela/file-drop.vue +37 -0
- package/components/tela/file-upload/file-upload.mdx +189 -0
- package/components/tela/file-upload/file-upload.stories.ts +48 -0
- package/components/tela/file-upload/file-upload.vue +205 -0
- package/components/tela/filters/checkbox-filter.stories.ts +218 -0
- package/components/tela/filters/checkbox-filter.vue +165 -0
- package/components/tela/filters/date-filter.stories.ts +258 -0
- package/components/tela/filters/date-filter.vue +200 -0
- package/components/tela/filters/user-filter.stories.ts +344 -0
- package/components/tela/filters/user-filter.vue +271 -0
- package/components/tela/hover-card/hover-card.mdx +221 -0
- package/components/tela/hover-card/hover-card.stories.ts +87 -0
- package/components/tela/hover-card/hover-card.vue +61 -0
- package/components/tela/icon/custom.vue +319 -0
- package/components/tela/icon/spinner.vue +12 -0
- package/components/tela/icon-button/icon-button.vue +114 -0
- package/components/tela/icon.vue +37 -0
- package/components/tela/initials.vue +28 -0
- package/components/tela/inline-input.vue +77 -0
- package/components/tela/input/input.mdx +182 -0
- package/components/tela/input/input.stories.ts +153 -0
- package/components/tela/input/tela-input.vue +240 -0
- package/components/tela/kbd/kbd-return.vue +6 -0
- package/components/tela/kbd/kbd.mdx +238 -0
- package/components/tela/kbd/kbd.vue +18 -0
- package/components/tela/label/label.mdx +121 -0
- package/components/tela/label/label.stories.ts +37 -0
- package/components/tela/label/label.vue +25 -0
- package/components/tela/link-decoration/link-decoration.vue +19 -0
- package/components/tela/live-label.vue +32 -0
- package/components/tela/long-press-button.vue +98 -0
- package/components/tela/menubar/menubar-content.vue +77 -0
- package/components/tela/menubar/menubar-item.vue +32 -0
- package/components/tela/menubar/menubar-label.vue +14 -0
- package/components/tela/menubar/menubar-menu.vue +12 -0
- package/components/tela/menubar/menubar-root.vue +30 -0
- package/components/tela/menubar/menubar-separator.vue +17 -0
- package/components/tela/menubar/menubar-shortcut.vue +14 -0
- package/components/tela/menubar/menubar-sub-content.vue +36 -0
- package/components/tela/menubar/menubar-sub-trigger.vue +28 -0
- package/components/tela/menubar/menubar-sub.vue +20 -0
- package/components/tela/menubar/menubar-trigger.vue +27 -0
- package/components/tela/menubar/menubar.vue +298 -0
- package/components/tela/modal/modal.mdx +145 -0
- package/components/tela/modal/modal.vue +242 -0
- package/components/tela/multiple-select/multiple-select.mdx +274 -0
- package/components/tela/multiple-select/multiple-select.stories.ts +325 -0
- package/components/tela/multiple-select/multiple-select.vue +666 -0
- package/components/tela/pane.vue +110 -0
- package/components/tela/popover/popover-content.vue +48 -0
- package/components/tela/popover/popover-trigger.vue +12 -0
- package/components/tela/popover/popover.mdx +239 -0
- package/components/tela/popover/popover.stories.ts +150 -0
- package/components/tela/popover/popover.vue +15 -0
- package/components/tela/popover-list/popover-list-nested.vue +104 -0
- package/components/tela/popover-list/popover-list.stories.ts +330 -0
- package/components/tela/popover-list/popover-list.vue +191 -0
- package/components/tela/radio-button.vue +66 -0
- package/components/tela/radio-group/radio-group-item.vue +40 -0
- package/components/tela/radio-group/radio-group-root.vue +26 -0
- package/components/tela/radio-group/radio-group.mdx +78 -0
- package/components/tela/radio-group/radio-group.stories.ts +106 -0
- package/components/tela/radio-group/radio-group.vue +23 -0
- package/components/tela/range-calendar.stories.ts +110 -0
- package/components/tela/range-calendar.vue +109 -0
- package/components/tela/scroll-area/scroll-area.mdx +183 -0
- package/components/tela/scroll-area/scroll-area.vue +30 -0
- package/components/tela/scroll-area/scroll-bar.vue +31 -0
- package/components/tela/segment-toggle.stories.ts +114 -0
- package/components/tela/segment-toggle.vue +66 -0
- package/components/tela/select-menu/select-menu-content.vue +106 -0
- package/components/tela/select-menu/select-menu-down-button.vue +20 -0
- package/components/tela/select-menu/select-menu-group.vue +16 -0
- package/components/tela/select-menu/select-menu-item.vue +40 -0
- package/components/tela/select-menu/select-menu-root.vue +15 -0
- package/components/tela/select-menu/select-menu-trigger.vue +34 -0
- package/components/tela/select-menu/select-menu-up-button.vue +20 -0
- package/components/tela/select-menu/select-menu-value.vue +12 -0
- package/components/tela/select-menu/select-menu.mdx +221 -0
- package/components/tela/select-menu/select-menu.stories.ts +91 -0
- package/components/tela/select-menu/select-menu.vue +165 -0
- package/components/tela/selector/selector.vue +47 -0
- package/components/tela/sheet/sheet-close.vue +12 -0
- package/components/tela/sheet/sheet-content.vue +57 -0
- package/components/tela/sheet/sheet-description.vue +23 -0
- package/components/tela/sheet/sheet-footer.vue +18 -0
- package/components/tela/sheet/sheet-header.vue +15 -0
- package/components/tela/sheet/sheet-root.vue +18 -0
- package/components/tela/sheet/sheet-title.vue +23 -0
- package/components/tela/sheet/sheet-trigger.vue +12 -0
- package/components/tela/sheet/sheet.client.vue +150 -0
- package/components/tela/sheet/sheet.mdx +176 -0
- package/components/tela/sheet/sheet.stories.ts +201 -0
- package/components/tela/sheet/variants.ts +22 -0
- package/components/tela/side-sheet/side-sheet.mdx +131 -0
- package/components/tela/side-sheet/side-sheet.stories.ts +134 -0
- package/components/tela/side-sheet/side-sheet.vue +106 -0
- package/components/tela/skeleton/skeleton.mdx +165 -0
- package/components/tela/skeleton/skeleton.stories.ts +35 -0
- package/components/tela/skeleton/skeleton.vue +45 -0
- package/components/tela/skeleton-icon.vue +24 -0
- package/components/tela/span.vue +24 -0
- package/components/tela/star-button.vue +70 -0
- package/components/tela/status/status-lean.vue +30 -0
- package/components/tela/status/status.mdx +187 -0
- package/components/tela/status/status.stories.ts +160 -0
- package/components/tela/status/status.vue +420 -0
- package/components/tela/status-bar/status-bar.mdx +178 -0
- package/components/tela/status-bar/status-bar.stories.ts +64 -0
- package/components/tela/status-bar/status-bar.vue +56 -0
- package/components/tela/status-bar/types.ts +5 -0
- package/components/tela/switch/switch.mdx +118 -0
- package/components/tela/switch/switch.stories.ts +80 -0
- package/components/tela/switch/switch.vue +56 -0
- package/components/tela/table/table-body.vue +13 -0
- package/components/tela/table/table-caption.vue +13 -0
- package/components/tela/table/table-cell.vue +20 -0
- package/components/tela/table/table-empty.vue +37 -0
- package/components/tela/table/table-footer.vue +13 -0
- package/components/tela/table/table-head.vue +13 -0
- package/components/tela/table/table-header.vue +13 -0
- package/components/tela/table/table-row.vue +13 -0
- package/components/tela/table/table.mdx +230 -0
- package/components/tela/table/table.stories.ts +384 -0
- package/components/tela/table/table.vue +15 -0
- package/components/tela/tabs/tabs-content.vue +20 -0
- package/components/tela/tabs/tabs-indicator.vue +22 -0
- package/components/tela/tabs/tabs-list.vue +23 -0
- package/components/tela/tabs/tabs-root.vue +15 -0
- package/components/tela/tabs/tabs-trigger.vue +27 -0
- package/components/tela/tabs/tabs.mdx +138 -0
- package/components/tela/tabs/tabs.stories.ts +72 -0
- package/components/tela/tabs/tabs.vue +61 -0
- package/components/tela/tags/tags-select.mdx +318 -0
- package/components/tela/tags/tags-select.stories.ts +47 -0
- package/components/tela/tags/tags-select.vue +637 -0
- package/components/tela/tags/tags.mdx +151 -0
- package/components/tela/tags/tags.stories.ts +118 -0
- package/components/tela/tags/tags.vue +112 -0
- package/components/tela/textarea/textarea.mdx +102 -0
- package/components/tela/textarea/textarea.stories.ts +50 -0
- package/components/tela/textarea/textarea.vue +34 -0
- package/components/tela/toggle-group.vue +91 -0
- package/components/tela/tooltip/tooltip-content.vue +45 -0
- package/components/tela/tooltip/tooltip-provider.vue +12 -0
- package/components/tela/tooltip/tooltip-root.vue +15 -0
- package/components/tela/tooltip/tooltip-trigger.vue +12 -0
- package/components/tela/tooltip/tooltip.mdx +196 -0
- package/components/tela/tooltip/tooltip.stories.ts +200 -0
- package/components/tela/tooltip/tooltip.vue +91 -0
- package/components/tela/tooltip-group/tooltip-group-trigger.vue +92 -0
- package/components/tela/tooltip-group/tooltip-group.mdx +236 -0
- package/components/tela/tooltip-group/tooltip-group.stories.ts +465 -0
- package/components/tela/tooltip-group/tooltip-group.vue +35 -0
- package/components/tela/transparent-input.vue +151 -0
- package/components/tela/variable-icon.vue +28 -0
- package/components/tela/variable-input.vue +77 -0
- package/components/tela/wide-button/wide-button.vue +40 -0
- package/components.json +18 -0
- package/composables/status-toast.ts +67 -0
- package/css/reset.css +386 -0
- package/css/text.css +22 -0
- package/lib/doc-generator.ts +903 -0
- package/lib/extractors/volar-extract.ts +186 -0
- package/lib/type-resolver.ts +402 -0
- package/lib/utils.ts +6 -0
- package/modules/tela-build-docs/index.ts +139 -0
- package/nuxt.config.ts +80 -0
- package/package.json +84 -0
- package/plugins/test-id.ts +7 -0
- package/tsconfig.json +7 -0
- package/types/custom-icon.ts +1 -0
- package/types/index.ts +2 -0
- package/types/status.ts +1 -0
- package/unocss.config.ts +89 -0
- package/utils/component-utils.ts +30 -0
- package/utils/design-tokens.ts +431 -0
- package/utils/fold.ts +8 -0
- package/utils/select-menu.ts +10 -0
- package/utils/status.ts +1 -0
- package/utils/without-keys.ts +34 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Column } from './types'
|
|
3
|
+
|
|
4
|
+
defineOptions({
|
|
5
|
+
name: 'TelaComplexTableHeaderCell',
|
|
6
|
+
})
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
column?: Column
|
|
9
|
+
type?: 'default' | 'checkbox'
|
|
10
|
+
rows?: any[]
|
|
11
|
+
selectedRows?: any[]
|
|
12
|
+
tabSize?: 'sm' | 'md' | string
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const emit = defineEmits(['selectAll'])
|
|
16
|
+
|
|
17
|
+
function selectAll() {
|
|
18
|
+
emit('selectAll')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const size = computed(() => ({
|
|
22
|
+
md: 24,
|
|
23
|
+
sm: 12,
|
|
24
|
+
})[props.tabSize ?? 'sm'] ?? props.tabSize)
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<div
|
|
29
|
+
v-if="type === 'default' && column"
|
|
30
|
+
w-full
|
|
31
|
+
min-w-52px pr-12px text-start h-full flex items-center
|
|
32
|
+
bg-white whitespace-nowrap
|
|
33
|
+
body-12-medium gap-4px
|
|
34
|
+
:class="column.isDefault && 'text-gray-400 italic'"
|
|
35
|
+
border-b-0.5px border-gray-200
|
|
36
|
+
:style="{
|
|
37
|
+
color: column.color || '#71757B',
|
|
38
|
+
paddingLeft: `${size}px`,
|
|
39
|
+
}"
|
|
40
|
+
>
|
|
41
|
+
<TelaIcon v-if="column.icon" :name="column.icon.name" :size="column.icon.size" :style="column.icon.style" />
|
|
42
|
+
{{ column.title }}
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<div v-else-if="type === 'checkbox' && rows" flex="~" justify-center h-full items-center bg-white z-2>
|
|
46
|
+
<TelaCheckbox :model-value="selectedRows?.length === rows.length" @update:model-value="selectAll" />
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
+
import TelaComplexTableHeader from './complex-table-header.vue'
|
|
3
|
+
import type { Column } from './types'
|
|
4
|
+
|
|
5
|
+
const sampleColumns: Column[] = [
|
|
6
|
+
{ key: 'name', title: 'Name' },
|
|
7
|
+
{ key: 'email', title: 'Email' },
|
|
8
|
+
{ key: 'role', title: 'Role' },
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
const sampleRows = [
|
|
12
|
+
{ id: '1', status: 'active', name: 'Row 1', data: { name: 'John Doe', email: 'john@example.com', role: 'Admin' } },
|
|
13
|
+
{ id: '2', status: 'active', name: 'Row 2', data: { name: 'Jane Smith', email: 'jane@example.com', role: 'User' } },
|
|
14
|
+
{ id: '3', status: 'active', name: 'Row 3', data: { name: 'Bob Johnson', email: 'bob@example.com', role: 'Editor' } },
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
const meta = {
|
|
18
|
+
title: 'Components/Tela/ComplexTableHeader',
|
|
19
|
+
component: TelaComplexTableHeader,
|
|
20
|
+
tags: ['autodocs'],
|
|
21
|
+
parameters: {
|
|
22
|
+
layout: 'centered',
|
|
23
|
+
docs: {
|
|
24
|
+
description: {
|
|
25
|
+
component: 'A table header component for ComplexTable that displays column headers, selection controls, row actions, and index indicators. Supports customizable header rendering and table configuration options.',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
argTypes: {
|
|
30
|
+
columns: {
|
|
31
|
+
control: 'object',
|
|
32
|
+
description: 'Array of column definitions to display in the header.',
|
|
33
|
+
},
|
|
34
|
+
rows: {
|
|
35
|
+
control: 'object',
|
|
36
|
+
description: 'Array of row data for header calculations.',
|
|
37
|
+
},
|
|
38
|
+
allowSelect: {
|
|
39
|
+
control: 'boolean',
|
|
40
|
+
description: 'Enable row selection checkbox in the header.',
|
|
41
|
+
},
|
|
42
|
+
allowRowIndex: {
|
|
43
|
+
control: 'boolean',
|
|
44
|
+
description: 'Show row index column in the header.',
|
|
45
|
+
},
|
|
46
|
+
allowRowAction: {
|
|
47
|
+
control: 'boolean',
|
|
48
|
+
description: 'Show row action column in the header.',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
args: {
|
|
52
|
+
columns: sampleColumns,
|
|
53
|
+
rows: sampleRows,
|
|
54
|
+
allowSelect: true,
|
|
55
|
+
allowRowIndex: true,
|
|
56
|
+
allowRowAction: true,
|
|
57
|
+
},
|
|
58
|
+
} satisfies Meta<typeof TelaComplexTableHeader>
|
|
59
|
+
|
|
60
|
+
export default meta
|
|
61
|
+
type Story = StoryObj<typeof meta>
|
|
62
|
+
|
|
63
|
+
export const Default: Story = {
|
|
64
|
+
args: {
|
|
65
|
+
rows: sampleRows,
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const WithoutRows: Story = {
|
|
70
|
+
args: {
|
|
71
|
+
rows: [],
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const WithoutRowAction: Story = {
|
|
76
|
+
args: {
|
|
77
|
+
allowRowAction: false,
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const CustomColumns: Story = {
|
|
82
|
+
args: {
|
|
83
|
+
columns: [
|
|
84
|
+
{ key: 'id', title: 'ID' },
|
|
85
|
+
{ key: 'status', title: 'Status' },
|
|
86
|
+
{ key: 'date', title: 'Date' },
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Column, Row } from './types'
|
|
3
|
+
import TelaTableHeaderCell from './complex-table-header-cell.vue'
|
|
4
|
+
|
|
5
|
+
defineOptions({
|
|
6
|
+
name: 'TelaComplexTableHeader',
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
defineProps<{
|
|
10
|
+
columns: Column[]
|
|
11
|
+
rows?: Row[]
|
|
12
|
+
selectedRows?: string[]
|
|
13
|
+
allowSelect?: boolean
|
|
14
|
+
allowRowIndex?: boolean
|
|
15
|
+
allowRowAction?: boolean
|
|
16
|
+
headerClass?: string
|
|
17
|
+
}>()
|
|
18
|
+
|
|
19
|
+
const emit = defineEmits(['selectAll'])
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<thead>
|
|
24
|
+
<tr
|
|
25
|
+
body-12-medium text="gray-800" h-56px px-12px py-10px
|
|
26
|
+
bg-white :class="headerClass"
|
|
27
|
+
>
|
|
28
|
+
<th v-if="allowSelect && rows?.length" class="sticky left-0 top-0 bg-white h-56px z-12 w-32px p-0px" :class="headerClass">
|
|
29
|
+
<div flex="~" justify-center h-56px items-center bg-white z-2 border-b-0.5px border-gray-200 :class="headerClass">
|
|
30
|
+
<TelaCheckbox v-if="rows.length" :model-value="selectedRows?.length === rows.length" @update:model-value="emit('selectAll', $event)" />
|
|
31
|
+
</div>
|
|
32
|
+
</th>
|
|
33
|
+
<th v-if="allowRowIndex" class="sticky top-0 h-56px bg-white z-12 p-0px" :style="{ left: (allowSelect && rows?.length) ? '32px' : '0', width: '48px', minWidth: '48px', maxWidth: '48px' }" :class="headerClass">
|
|
34
|
+
<TelaTableHeaderCell type="default" :column="{ title: 'ID' }" />
|
|
35
|
+
</th>
|
|
36
|
+
<slot name="leading-header" />
|
|
37
|
+
<th
|
|
38
|
+
v-for="column in columns"
|
|
39
|
+
:key="column.key"
|
|
40
|
+
z-11
|
|
41
|
+
sticky top-0px h-56px
|
|
42
|
+
p-0px
|
|
43
|
+
:class="headerClass"
|
|
44
|
+
>
|
|
45
|
+
<slot v-if="column.key && $slots[`header-${column.key}`] !== undefined" :name="`header-${column.key}`" :column="column" />
|
|
46
|
+
<TelaTableHeaderCell v-else :column="column" type="default" />
|
|
47
|
+
</th>
|
|
48
|
+
<th v-for="(_, idx) in (rows?.length ? 0 : 3)" :key="idx" sticky top-0px p-0px />
|
|
49
|
+
<th sticky top-0px z-10 w-full p-0px>
|
|
50
|
+
<div h-56px bg-white border-b-0.5px border-gray-200 rounded-tr-8px :class="headerClass" />
|
|
51
|
+
</th>
|
|
52
|
+
<th v-if="allowRowAction && rows?.length" sticky right-0px top-0px h-56px rounded-tr-8px p-0px :class="headerClass">
|
|
53
|
+
<div
|
|
54
|
+
w-full h-56px rounded-tr-8px class="shadow"
|
|
55
|
+
bg-white b="b-0.5px l-0.5px gray-200"
|
|
56
|
+
/>
|
|
57
|
+
</th>
|
|
58
|
+
</tr>
|
|
59
|
+
</thead>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<style scoped>
|
|
63
|
+
th {
|
|
64
|
+
padding: 0!important;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.sticky {
|
|
68
|
+
position: sticky !important;
|
|
69
|
+
}
|
|
70
|
+
</style>
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Column, Row, HoverMechanism } from './types'
|
|
3
|
+
import { HoverMechanismTypes } from './types'
|
|
4
|
+
import TelaTableCell from './complex-table-cell.vue'
|
|
5
|
+
import { isLoading, hasContent, hasError, getRowTitle, readRowPath } from './utils'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
row: Row
|
|
9
|
+
rowIndex: number
|
|
10
|
+
columns: Column[]
|
|
11
|
+
allowSelect?: boolean
|
|
12
|
+
allowRowIndex?: boolean
|
|
13
|
+
allowRowAction?: boolean
|
|
14
|
+
isSelected?: boolean
|
|
15
|
+
loading?: boolean
|
|
16
|
+
disableRowClick?: boolean
|
|
17
|
+
hoverMechanism?: HoverMechanism
|
|
18
|
+
hoveredRowIndex?: number | null
|
|
19
|
+
rowClass?: string | ((row: Row) => string)
|
|
20
|
+
rowIndexClass?: string
|
|
21
|
+
rowTitlePath?: string
|
|
22
|
+
rowIndexPath?: string
|
|
23
|
+
columnsClass?: string
|
|
24
|
+
isFirstRow?: boolean
|
|
25
|
+
isLastRow?: boolean
|
|
26
|
+
totalRows?: number
|
|
27
|
+
hideError?: boolean
|
|
28
|
+
}>()
|
|
29
|
+
|
|
30
|
+
const emit = defineEmits<{
|
|
31
|
+
select: [id: string]
|
|
32
|
+
open: [id: string]
|
|
33
|
+
hover: [index: number | null]
|
|
34
|
+
}>()
|
|
35
|
+
|
|
36
|
+
const slots = useSlots()
|
|
37
|
+
|
|
38
|
+
const computedRowClass = computed(() => {
|
|
39
|
+
const classes = []
|
|
40
|
+
|
|
41
|
+
// Base classes
|
|
42
|
+
classes.push('bg-white')
|
|
43
|
+
|
|
44
|
+
// Border classes
|
|
45
|
+
if (props.isFirstRow && props.totalRows && props.totalRows > 1) {
|
|
46
|
+
classes.push('b-b-0.5px b-t-0px b-gray-200!')
|
|
47
|
+
}
|
|
48
|
+
if (props.rowIndex % 2 !== 0 && props.rowIndex > 0) {
|
|
49
|
+
classes.push('b-y-0.5px b-gray-200!')
|
|
50
|
+
}
|
|
51
|
+
if (props.isLastRow) {
|
|
52
|
+
classes.push('b-b-0px!')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Hover classes
|
|
56
|
+
if (props.hoverMechanism === HoverMechanismTypes.Row) {
|
|
57
|
+
classes.push('cursor-pointer')
|
|
58
|
+
if (props.hoveredRowIndex === props.rowIndex) {
|
|
59
|
+
classes.push('bg-gray-50!')
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Custom row class
|
|
64
|
+
if (typeof props.rowClass === 'function') {
|
|
65
|
+
classes.push(props.rowClass(props.row))
|
|
66
|
+
}
|
|
67
|
+
else if (props.rowClass) {
|
|
68
|
+
classes.push(props.rowClass)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return classes
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
function handleRowClick() {
|
|
75
|
+
if (shouldEnableRowClick() && props.row.id) {
|
|
76
|
+
emit('open', props.row.id)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function shouldEnableRowClick() {
|
|
81
|
+
return props.hoverMechanism === HoverMechanismTypes.Row && !props.disableRowClick
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function handleCheckboxChange() {
|
|
85
|
+
if (props.row.id) {
|
|
86
|
+
emit('select', props.row.id)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<template>
|
|
92
|
+
<tr
|
|
93
|
+
h-64px
|
|
94
|
+
:class="computedRowClass"
|
|
95
|
+
@mouseenter="emit('hover', rowIndex)"
|
|
96
|
+
@mouseleave="emit('hover', null)"
|
|
97
|
+
@click.stop="handleRowClick"
|
|
98
|
+
>
|
|
99
|
+
<td v-if="allowSelect" class="sticky left-0 bg-white z-9" @click.stop>
|
|
100
|
+
<div
|
|
101
|
+
flex="~" h-px items-center justify-center w-32px relative z-0
|
|
102
|
+
>
|
|
103
|
+
<TelaCheckbox
|
|
104
|
+
:model-value="isSelected || false"
|
|
105
|
+
@update:model-value="handleCheckboxChange"
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
</td>
|
|
109
|
+
|
|
110
|
+
<td v-if="allowRowIndex" class="sticky bg-white z-10" :style="{ left: allowSelect ? '32px' : '0', width: '48px', minWidth: '48px', maxWidth: '48px' }">
|
|
111
|
+
<div
|
|
112
|
+
h-64px flex="~" items-center pl-12px body-12-medium text-gray-600
|
|
113
|
+
:class="rowClass"
|
|
114
|
+
:style="{ width: '48px', minWidth: '48px', maxWidth: '48px' }"
|
|
115
|
+
>
|
|
116
|
+
<div v-if="!row.id" flex="~ col" w-full h-64px justify-center :class="rowClass">
|
|
117
|
+
<TelaSkeleton h-16px rounded="2px" w="18px" bg="#E9ECEF" />
|
|
118
|
+
</div>
|
|
119
|
+
<span v-else>
|
|
120
|
+
{{ readRowPath(row, rowIndexPath || '') }}
|
|
121
|
+
</span>
|
|
122
|
+
</div>
|
|
123
|
+
</td>
|
|
124
|
+
|
|
125
|
+
<slot
|
|
126
|
+
name="leading"
|
|
127
|
+
:row-data="row"
|
|
128
|
+
:is-loading="isLoading(row, loading || false)"
|
|
129
|
+
:row-title="getRowTitle(row, rowTitlePath || '')"
|
|
130
|
+
:row-emit="emit"
|
|
131
|
+
/>
|
|
132
|
+
|
|
133
|
+
<td v-if="hasError(row)" :colspan="columns.length">
|
|
134
|
+
<div v-if="!hideError" flex="~ row" items-center py-12px pl-12px h-64px b="gray-200" :class="rowClass">
|
|
135
|
+
<span z-1 body-14-medium class="text-[#BE2741]">
|
|
136
|
+
{{ $t('common.error') }}
|
|
137
|
+
</span>
|
|
138
|
+
<span v-if="row.errorMessage" line-clamp-2 body-14-medium class="text-[#BE2741]">
|
|
139
|
+
: {{ row.errorMessage }}
|
|
140
|
+
</span>
|
|
141
|
+
</div>
|
|
142
|
+
</td>
|
|
143
|
+
|
|
144
|
+
<td
|
|
145
|
+
v-for="(column, columnIdx) in columns"
|
|
146
|
+
v-else
|
|
147
|
+
:key="columnIdx"
|
|
148
|
+
>
|
|
149
|
+
<div v-if="isLoading(row, loading || false)" flex="~ col" gap-4px pl-12px h-64px justify-center :class="rowClass">
|
|
150
|
+
<TelaSkeleton w="70%" h-8px />
|
|
151
|
+
</div>
|
|
152
|
+
<template v-else>
|
|
153
|
+
<slot
|
|
154
|
+
v-if="column.key && slots[column.key]"
|
|
155
|
+
:name="column.key"
|
|
156
|
+
:row-data="row"
|
|
157
|
+
:is-loading="isLoading(row, loading || false)"
|
|
158
|
+
:row-title="getRowTitle(row, rowTitlePath || '')"
|
|
159
|
+
:row-emit="emit"
|
|
160
|
+
/>
|
|
161
|
+
<div v-else flex items-center h-64px :class="[columnsClass, rowClass]">
|
|
162
|
+
<button
|
|
163
|
+
flex items-center z-8 h-full w-full rounded-8px
|
|
164
|
+
:class="[
|
|
165
|
+
hoverMechanism === HoverMechanismTypes.Cell
|
|
166
|
+
&& 'box-border focus:outline-none',
|
|
167
|
+
hoverMechanism === HoverMechanismTypes.Cell
|
|
168
|
+
&& !isLoading(row, loading || false)
|
|
169
|
+
&& hasContent(row, column)
|
|
170
|
+
&& 'cursor-pointer b-x-2px b-y-2px b-transparent hover:b-gray-800',
|
|
171
|
+
]"
|
|
172
|
+
@click="!isLoading(row, loading || false) && hasContent(row, column) && emit('open', row.id as string)"
|
|
173
|
+
>
|
|
174
|
+
<TelaTableCell :column="column" :row="row" />
|
|
175
|
+
</button>
|
|
176
|
+
</div>
|
|
177
|
+
</template>
|
|
178
|
+
</td>
|
|
179
|
+
|
|
180
|
+
<td z-0>
|
|
181
|
+
<div z-0 h-64px :class="rowClass" />
|
|
182
|
+
</td>
|
|
183
|
+
|
|
184
|
+
<td v-if="slots['row-action']" sticky h-64px right-0px z-10 colspan="1" :class="rowClass">
|
|
185
|
+
<div
|
|
186
|
+
flex="~" bg-white w-90px h-64px items-center justify-center h-full px-12px
|
|
187
|
+
b="l-0.5px gray-200"
|
|
188
|
+
class="shadow"
|
|
189
|
+
:class="[
|
|
190
|
+
totalRows === 1 && 'b-b-0px!',
|
|
191
|
+
isLastRow && 'b-b-0.5px! b-gray-200',
|
|
192
|
+
rowClass,
|
|
193
|
+
]"
|
|
194
|
+
>
|
|
195
|
+
<slot name="row-action" :row="row" />
|
|
196
|
+
</div>
|
|
197
|
+
</td>
|
|
198
|
+
</tr>
|
|
199
|
+
</template>
|