Initial
All checks were successful
Deploy / build (push) Successful in 49s

This commit is contained in:
alsaze
2025-11-19 20:49:25 +03:00
commit 3d975d6884
36 changed files with 27229 additions and 0 deletions

83
components/ShortText.vue Normal file
View File

@@ -0,0 +1,83 @@
<template>
<div ref="wrapper" class="short-text">
<!-- Mobile -->
<UTooltip
v-if="isMobile"
:text="text"
:open="open"
:disabled="!tooltipEnabled"
:ui="{ text: 'whitespace-normal break-words', content: 'max-w-50 h-auto' }"
>
<span :ref="checkSize" :class="textPrimary ? 'short-text--primary' : ''">{{ text }}</span>
<Icon
v-if="tooltipEnabled"
name="heroicons:information-circle"
class="short-text__icon"
@click.stop="open = !open"
/>
</UTooltip>
<!-- Desktop -->
<UTooltip
v-else
:text="text"
:disabled="!tooltipEnabled"
:ui="{ text: 'whitespace-normal break-words', content: 'max-w-80 h-auto' }"
>
<span :ref="checkSize" :class="textPrimary ? 'short-text--primary' : ''">{{ text }}</span>
</UTooltip>
</div>
</template>
<script setup lang="ts">
import { onClickOutside, unrefElement } from '@vueuse/core'
defineProps<{ text: string, textPrimary?: boolean }>()
const wrapper = ref<HTMLElement | null>(null)
const open = ref(false)
const tooltipEnabled = ref(true)
const { isMobile } = useScreen()
onClickOutside(wrapper, () => {
open.value = false
})
function checkSize(_el: HTMLElement) {
const el = unrefElement(_el)
tooltipEnabled.value = el ? el.scrollWidth > el.clientWidth : false
}
</script>
<style lang="scss">
.short-text {
position: relative;
width: 100%;
display: flex;
align-items: center;
gap: 8px;
&--primary {
cursor: pointer;
text-decoration: underline;
color: var(--ui-primary);
&:hover {
color: var(--ui-primary-hover);
}
}
> span {
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
&__icon {
flex-shrink: 0;
}
}
</style>

214
components/UiTable.vue Normal file
View File

@@ -0,0 +1,214 @@
<template>
<div
ref="tableContainerRef"
class="table-wrapper"
:style="{ height, width }"
>
<div :style="{ height: `${totalSize}px` }">
<table>
<thead>
<tr
v-for="headerGroup in table?.getHeaderGroups()"
:key="headerGroup?.id"
:style="{ gridTemplateColumns }"
>
<th
v-for="header in headerGroup?.headers"
:key="header.id"
:colspan="header?.colSpan"
@click="header?.column?.getToggleSortingHandler()?.($event)"
>
<FlexRender
v-if="!header?.isPlaceholder"
:render="header?.column?.columnDef?.header"
:props="header?.getContext()"
/>
{{ { asc: ' 🔼', desc: ' 🔽' }[header.column.getIsSorted() as string] }}
</th>
</tr>
</thead>
<tbody :style="{ height: `${totalSize}px` }">
<tr
v-for="vRow in virtualRows"
:ref="measureElement"
:key="rows[vRow?.index]?.id"
:data-index=" vRow?.index"
:style="{ gridTemplateColumns, transform: `translateY(${vRow?.start}px)` }"
>
<td
v-for="cell in rows[vRow?.index]?.getVisibleCells()"
:key="cell?.id"
>
<FlexRender
:render="cell?.column?.columnDef?.cell"
:props="cell?.getContext()"
/>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</template>
<script setup lang="ts">
import type { RowData } from '@tanstack/table-core'
import type { ColumnDef } from '@tanstack/vue-table'
import { FlexRender, getCoreRowModel, getSortedRowModel, useVueTable } from '@tanstack/vue-table'
import { useVirtualizer } from '@tanstack/vue-virtual'
declare module '@tanstack/vue-table' {
interface ColumnMeta<TData extends RowData, TValue> {
width?: string
}
}
const props = defineProps<{
tableData: any[]
columns: ColumnDef<any>[]
height: string
width: string
}>()
const table = useVueTable({
get data() {
return props?.tableData
},
columns: props?.columns,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
})
const rows = computed(() => table?.getRowModel()?.rows)
const tableContainerRef = ref<HTMLDivElement | null>(null)
const rowVirtualizerOptions = computed(() => {
return {
count: rows?.value?.length,
estimateSize: () => 50,
getScrollElement: () => tableContainerRef?.value,
overscan: 5,
}
})
const rowVirtualizer = useVirtualizer(rowVirtualizerOptions)
const virtualRows = computed(() => rowVirtualizer?.value?.getVirtualItems())
const totalSize = computed(() => rowVirtualizer?.value?.getTotalSize())
const gridTemplateColumns = computed(() => {
return props.columns.map((column) => {
return column.meta?.width || '1fr'
}).join(' ')
})
function measureElement(el?: Element) {
if (!el) {
return
}
rowVirtualizer?.value?.measureElement(el)
return undefined
}
</script>
<style lang="scss">
/* -------------------- TABLE WRAPPER -------------------- */
.table-wrapper {
position: relative;
margin-top: calc(40px + 10px);
border-radius: 14px;
overflow: auto;
width: 100%;
@include mobile {
height: 500px !important;
width: 100% !important;
}
}
table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
background: var(--ui-bg-elevated);
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
white-space: nowrap;
}
/* -------------------- HEADER -------------------- */
thead {
position: sticky;
top: 0;
z-index: 1;
background: var(--ui-bg-accented);
}
thead tr {
width: 100%;
}
thead th {
flex-shrink: 0;
background: var(--ui-bg-accented);
color: var(--ui-text);
padding: 12px 14px;
border-bottom: 1px solid var(--ui-border);
user-select: none;
transition: background 0.15s ease;
}
thead th:hover {
cursor: pointer;
}
/* -------------------- BODY -------------------- */
tbody {
position: relative;
}
tbody tr {
position: absolute;
width: 100%;
height: 50px;
transition: background 0.2s ease;
}
tbody tr:nth-child(odd) {
background: var(--ui-bg-subtle);
}
tbody tr:hover {
background: var(--ui-bg-accented);
}
tbody td {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
padding: 10px 12px;
border-bottom: 1px solid var(--ui-border-subtle);
}
tbody tr:last-child td {
border-bottom: none;
}
tr {
display: grid;
}
th,
td {
overflow: hidden;
}
</style>

View File

@@ -0,0 +1,74 @@
<template>
<UModal
v-model:open="open"
:title="user.email"
class="user-modal"
@after:leave="emit('close')"
>
<template #body>
<div>
<div>Имя: {{ user.name }}</div>
<div>Логин: {{ user.username }}</div>
<div>
<a
:href="`mailto:${user.email}`"
target="_blank"
rel="noopener noreferrer"
>
Электронная почта: <span>{{ user.email }}</span>
</a>
</div>
<div>
<a
:href="`tel:${user.phone}`"
target="_blank"
rel="noopener noreferrer"
>
Телефон: <span>{{ user.phone }}</span>
</a>
</div>
<a
:href="`https://${user.website}`"
target="_blank"
>
Веб-сайт: <span>{{ user.website }}</span>
</a>
<div>Название компании: {{ user.company.name }}</div>
<div>Адрес: {{ `${user.address.street} ${user.address.suite} ${user.address.city}` }}</div>
</div>
</template>
</UModal>
</template>
<script setup lang="ts">
const props = defineProps<{ user: User }>()
const emit = defineEmits<{
close: []
}>()
const open = ref(!!props.user)
watch(() => props.user, (user) => {
if (!user)
return
open.value = true
})
</script>
<style lang="scss">
.user-modal {
a {
span {
cursor: pointer;
text-decoration: underline;
color: var(--ui-primary);
&:hover {
color: var(--ui-primary-hover);
}
}
}
}
</style>