@myelophone/nuxt 0.18.2
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/.devcontainer/Dockerfile +7 -0
- package/.devcontainer/devcontainer.json +21 -0
- package/.editorconfig +43 -0
- package/.github/workflows/package.yml +73 -0
- package/.nuxtignore +6 -0
- package/.releaserc.js +132 -0
- package/.yarn/releases/yarn-4.18.0.cjs +1000 -0
- package/.yarnrc.yml +8 -0
- package/CHANGELOG.md +141 -0
- package/LICENSE +77 -0
- package/README.md +3004 -0
- package/app/app.vue +455 -0
- package/app/assets/css/animation.css +81 -0
- package/app/assets/css/backgrounds.css +57 -0
- package/app/assets/css/base.css +182 -0
- package/app/assets/css/index.css +9 -0
- package/app/assets/css/links.css +12 -0
- package/app/assets/css/multimedia.css +102 -0
- package/app/assets/css/preloader.css +68 -0
- package/app/assets/css/print.css +40 -0
- package/app/assets/css/tailwind.css +20 -0
- package/app/assets/css/theme.css +29 -0
- package/app/components/consent/GoogleMap.vue +59 -0
- package/app/components/consent/Youtube.vue +27 -0
- package/app/components/cookie/Banner.vue +70 -0
- package/app/components/cookie/ConsentWrapper.vue +71 -0
- package/app/components/cookie/PrivacyPolicy.vue +179 -0
- package/app/components/cookie/SettingsModal.vue +387 -0
- package/app/components/grid/Col.vue +262 -0
- package/app/components/grid/Container.vue +236 -0
- package/app/components/grid/Row.vue +248 -0
- package/app/components/grid/Stack.vue +233 -0
- package/app/components/myelophone/Copyright.vue +5 -0
- package/app/components/myelophone/Welcome.vue +107 -0
- package/app/components/page/FullscreenPreloader.vue +177 -0
- package/app/components/page/Preloader.vue +18 -0
- package/app/components/page/ReadyLocalized.vue +19 -0
- package/app/components/ready/.gitkeep +0 -0
- package/app/components/safe/Email.vue +52 -0
- package/app/components/safe/ImgWithLoader.vue +180 -0
- package/app/components/safe/NuxtImg.vue +25 -0
- package/app/components/safe/NuxtPicture.vue +29 -0
- package/app/components/section/.gitkeep +0 -0
- package/app/components/seo/BrandInfo.vue +76 -0
- package/app/components/seo/ContentNoIndex.vue +35 -0
- package/app/components/seo/NoIndex.vue +22 -0
- package/app/components/seo/OrgInfo.vue +130 -0
- package/app/components/seo/ProfileInfo.vue +137 -0
- package/app/components/ui/Accordion.vue +163 -0
- package/app/components/ui/Alert.vue +179 -0
- package/app/components/ui/Avatar.vue +88 -0
- package/app/components/ui/Badge.vue +150 -0
- package/app/components/ui/Banner.vue +133 -0
- package/app/components/ui/Button.vue +175 -0
- package/app/components/ui/Card.vue +66 -0
- package/app/components/ui/Checkbox.vue +134 -0
- package/app/components/ui/Chip.vue +136 -0
- package/app/components/ui/CommandPalette.vue +434 -0
- package/app/components/ui/Console.vue +583 -0
- package/app/components/ui/CursorCreative.vue +148 -0
- package/app/components/ui/FeatureAccordion.vue +165 -0
- package/app/components/ui/FileUpload.vue +705 -0
- package/app/components/ui/GeoDependent.vue +72 -0
- package/app/components/ui/Heading.vue +51 -0
- package/app/components/ui/Icon.vue +42 -0
- package/app/components/ui/Icon8.vue +39 -0
- package/app/components/ui/Input.vue +88 -0
- package/app/components/ui/LangLink.vue +34 -0
- package/app/components/ui/LangVisible.vue +33 -0
- package/app/components/ui/LanguageSelect.vue +202 -0
- package/app/components/ui/LightBox.vue +155 -0
- package/app/components/ui/LocalTime.vue +170 -0
- package/app/components/ui/Modal.vue +161 -0
- package/app/components/ui/Popup.vue +200 -0
- package/app/components/ui/PostContent.server.vue +23 -0
- package/app/components/ui/ProtectedEmail.vue +52 -0
- package/app/components/ui/RelativeTime.vue +141 -0
- package/app/components/ui/ScheduledContent.vue +150 -0
- package/app/components/ui/ScrollToTop.client.vue +48 -0
- package/app/components/ui/SegmentedControl.vue +148 -0
- package/app/components/ui/SiteSearch.vue +1191 -0
- package/app/components/ui/Skeleton.vue +91 -0
- package/app/components/ui/SmartContrast.vue +74 -0
- package/app/components/ui/SnapContainer.vue +222 -0
- package/app/components/ui/SnapSection.vue +294 -0
- package/app/components/ui/SonnerStyle.vue +7 -0
- package/app/components/ui/SplitSection.vue +99 -0
- package/app/components/ui/Steps.vue +858 -0
- package/app/components/ui/StickyWrapper.vue +46 -0
- package/app/components/ui/Table.vue +251 -0
- package/app/components/ui/Tabs.vue +451 -0
- package/app/components/ui/TextColumn.vue +36 -0
- package/app/components/ui/Textarea.vue +251 -0
- package/app/components/ui/Toggler.vue +40 -0
- package/app/components/ui/Tooltip.vue +524 -0
- package/app/components/ui/TruncateText.vue +105 -0
- package/app/components/ui/ViewportSpacer.vue +72 -0
- package/app/components/view/AnimatedCounter.vue +121 -0
- package/app/components/view/AnnouncementBar.vue +104 -0
- package/app/components/view/AvatarGroup.vue +104 -0
- package/app/components/view/Breadcrumbs.vue +97 -0
- package/app/components/view/ContentWithToc.vue +152 -0
- package/app/components/view/Copyright.vue +68 -0
- package/app/components/view/CountdownTimer.vue +184 -0
- package/app/components/view/CreativeCTA.vue +143 -0
- package/app/components/view/CurrencySelect.vue +254 -0
- package/app/components/view/FeatureBoxGrid.vue +142 -0
- package/app/components/view/HorizontalMenu.vue +97 -0
- package/app/components/view/ImageCompare.vue +141 -0
- package/app/components/view/ImgSlider.vue +333 -0
- package/app/components/view/InfiniteMarquee.vue +147 -0
- package/app/components/view/InfoBar.vue +86 -0
- package/app/components/view/LogoGrid.vue +106 -0
- package/app/components/view/LogoSlider.vue +83 -0
- package/app/components/view/NotFound.vue +81 -0
- package/app/components/view/PartialBackground.vue +313 -0
- package/app/components/view/QuoteBig.vue +111 -0
- package/app/components/view/ResponsiveMenu.vue +219 -0
- package/app/components/view/ReviewsSlider.vue +230 -0
- package/app/components/view/SocialBar.vue +78 -0
- package/app/components/view/StickyHeadingContent.vue +158 -0
- package/app/components/view/TallyForm.vue +295 -0
- package/app/components/view/WarningOutdated.vue +113 -0
- package/app/composables/useApi.ts +88 -0
- package/app/composables/useAppSeo.ts +78 -0
- package/app/composables/useBreadcrumbs.ts +106 -0
- package/app/composables/useChangeUrl.ts +73 -0
- package/app/composables/useCommand.ts +28 -0
- package/app/composables/useCookieControl.ts +111 -0
- package/app/composables/useCookieModal.ts +9 -0
- package/app/composables/useDevice.ts +109 -0
- package/app/composables/useGeoFetch.ts +139 -0
- package/app/composables/useLoadScript.ts +36 -0
- package/app/composables/useModalState.ts +37 -0
- package/app/composables/useMultiLang.ts +278 -0
- package/app/composables/useNetwork.ts +49 -0
- package/app/composables/useNuxtVersion.ts +5 -0
- package/app/composables/usePiniaStore.ts +5 -0
- package/app/composables/usePopupControl.ts +57 -0
- package/app/composables/useQuery.ts +307 -0
- package/app/composables/useReadyPage.ts +182 -0
- package/app/composables/useSafeList.ts +90 -0
- package/app/composables/useScriptLoader.ts +221 -0
- package/app/composables/useSiteSearch.ts +32 -0
- package/app/composables/useSnapScroll.ts +24 -0
- package/app/composables/useStatic.ts +5 -0
- package/app/composables/useStorage.ts +252 -0
- package/app/composables/useStoreBroadcast.ts +146 -0
- package/app/composables/useThemeSync.ts +81 -0
- package/app/constants/layout.ts +109 -0
- package/app/constants/predefinedCookieScripts.ts +1222 -0
- package/app/constants/ui-events.ts +1 -0
- package/app/error.vue +169 -0
- package/app/layouts/default-blog.vue +5 -0
- package/app/layouts/default.vue +3 -0
- package/app/locales/en/commands.json +5 -0
- package/app/locales/en/cookies.json +182 -0
- package/app/locales/en/error.json +4 -0
- package/app/locales/en/interface.json +33 -0
- package/app/locales/en/myelophone.json +8 -0
- package/app/locales/en/outdated.json +5 -0
- package/app/locales/en/times.json +18 -0
- package/app/locales/pl/commands.json +5 -0
- package/app/locales/pl/cookies.json +182 -0
- package/app/locales/pl/error.json +4 -0
- package/app/locales/pl/interface.json +33 -0
- package/app/locales/pl/myelophone.json +8 -0
- package/app/locales/pl/outdated.json +5 -0
- package/app/locales/pl/times.json +18 -0
- package/app/locales/ru/commands.json +5 -0
- package/app/locales/ru/cookies.json +182 -0
- package/app/locales/ru/error.json +4 -0
- package/app/locales/ru/interface.json +33 -0
- package/app/locales/ru/myelophone.json +8 -0
- package/app/locales/ru/outdated.json +5 -0
- package/app/locales/ru/times.json +18 -0
- package/app/middleware/blog-layout.ts +28 -0
- package/app/middleware/i18n.global.ts +17 -0
- package/app/middleware/not-found-status.ts +11 -0
- package/app/modules/default-blog/index.ts +39 -0
- package/app/modules/default-blog/posts.ts +80 -0
- package/app/modules/default-sitemap/index.ts +116 -0
- package/app/modules/default-sitemap/runtime/sitemap.get.ts +42 -0
- package/app/modules/fullscreen-preloader/module.ts +43 -0
- package/app/modules/htaccess/.htaccess +38 -0
- package/app/modules/htaccess/index.ts +23 -0
- package/app/modules/i18n-shaker.mjs +221 -0
- package/app/modules/multi18n/module.ts +71 -0
- package/app/modules/myelophone-config/module.ts +241 -0
- package/app/pages/[...all].vue +9 -0
- package/app/pages/index.vue +3 -0
- package/app/pages/post/[...slug].vue +30 -0
- package/app/plugins/bfcache-refresh.client.ts +9 -0
- package/app/plugins/canonical.ts +30 -0
- package/app/plugins/csp-nonce.server.ts +41 -0
- package/app/plugins/multi18n.client.ts +21 -0
- package/app/plugins/multi18n.server.ts +15 -0
- package/app/plugins/nuxt-version.client.ts +4 -0
- package/app/plugins/restore.client.ts +21 -0
- package/app/plugins/reveal.ts +89 -0
- package/app/plugins/url-helper.client.ts +66 -0
- package/app/server/api/exchange-rates.get.ts +216 -0
- package/app/server/api/healthz.ts +1 -0
- package/app/server/api/logout.post.ts +6 -0
- package/app/server/middleware/normalize-url.ts +14 -0
- package/app/server/middleware/security-headers.ts +147 -0
- package/app/server/middleware/url-helper.ts +43 -0
- package/app/server/plugins/clean-html-spaces.ts +15 -0
- package/app/server/plugins/clean-styles.ts +94 -0
- package/app/server/plugins/compression.ts +122 -0
- package/app/server/plugins/css-preload.ts +26 -0
- package/app/server/plugins/early-hints.ts +31 -0
- package/app/server/plugins/force-noindex.ts +43 -0
- package/app/server/plugins/html-one-line.ts +17 -0
- package/app/server/plugins/inline-style.ts +7 -0
- package/app/server/routes/healthz.get.ts +1 -0
- package/app/server/tsconfig.json +3 -0
- package/app/stores/cart.ts +945 -0
- package/app/stores/commands.ts +43 -0
- package/app/stores/device.ts +156 -0
- package/app/stores/querySync.ts +5 -0
- package/app/stores/settings.ts +145 -0
- package/app/stores/user.ts +607 -0
- package/app/types/cookie.ts +89 -0
- package/app/types/myelophone.d.ts +87 -0
- package/app/types/site-search.ts +110 -0
- package/app/utils/asyncRefresh.ts +4 -0
- package/app/utils/blog.server.ts +142 -0
- package/app/utils/jsonLd.ts +56 -0
- package/app/utils/myelophoneConfig.ts +4 -0
- package/app/utils/sortBy.ts +18 -0
- package/app/utils/transliterate.ts +75 -0
- package/app/utils/ytVideo.ts +37 -0
- package/app/workers/site-search.worker.ts +661 -0
- package/biome.json +94 -0
- package/commitlint.config.js +3 -0
- package/nuxt.config.ts +539 -0
- package/package.json +101 -0
- package/playground/content/.gitkeep +0 -0
- package/playground/locales/.gitkeep +0 -0
- package/playground/myelophone.dev.ts +45 -0
- package/playground/nuxt.config.ts +105 -0
- package/playground/package.json +5 -0
- package/playground/pages/.gitkeep +0 -0
- package/playground/tsconfig.json +3 -0
- package/playwright.config.ts +23 -0
- package/public/browsers/chrome.svg +77 -0
- package/public/browsers/edge.svg +98 -0
- package/public/browsers/firefox.svg +300 -0
- package/public/favicon.ico +0 -0
- package/public/myelophone_eng.png +0 -0
- package/public/myelophone_eng_white.png +0 -0
- package/spa-loading-template.html +72 -0
- package/tests/home.spec.ts +9 -0
- package/tests/utils.ts +23 -0
- package/tsconfig.json +16 -0
- package/vite/plugins/clean-css.ts +190 -0
- package/vite/plugins/postcss-add-viewportunits.ts +33 -0
- package/vite/plugins/postcss-viewport-fallback.ts +49 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="stickyRef"
|
|
4
|
+
class="relative w-full lg:sticky z-10"
|
|
5
|
+
:style="{ top: `${offset}px` }"
|
|
6
|
+
>
|
|
7
|
+
<div
|
|
8
|
+
class="w-full overflow-y-auto scrollbar-none"
|
|
9
|
+
:style="{ maxHeight: `calc(100vh - ${offset + 20}px)` }"
|
|
10
|
+
>
|
|
11
|
+
<slot />
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
const props = defineProps({
|
|
18
|
+
offset: {
|
|
19
|
+
type: Number,
|
|
20
|
+
default: 100,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const stickyRef = ref<HTMLElement | null>(null);
|
|
25
|
+
|
|
26
|
+
onMounted(() => {
|
|
27
|
+
const parent = stickyRef.value?.parentElement;
|
|
28
|
+
|
|
29
|
+
if (parent) {
|
|
30
|
+
parent.style.height = "100%";
|
|
31
|
+
if (getComputedStyle(parent).position === "static") {
|
|
32
|
+
parent.style.position = "relative";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<style scoped>
|
|
39
|
+
.scrollbar-none {
|
|
40
|
+
-ms-overflow-style: none;
|
|
41
|
+
scrollbar-width: none;
|
|
42
|
+
}
|
|
43
|
+
.scrollbar-none::-webkit-scrollbar {
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="w-full h-full flex flex-col bg-(--ui-bg) border border-(--ui-text) relative isolate overflow-hidden"
|
|
4
|
+
:style="{ height: height }"
|
|
5
|
+
>
|
|
6
|
+
<div
|
|
7
|
+
ref="scroller"
|
|
8
|
+
class="flex-1 w-full overflow-auto relative"
|
|
9
|
+
@scroll.passive="onScroll"
|
|
10
|
+
>
|
|
11
|
+
<div
|
|
12
|
+
class="relative min-w-fit"
|
|
13
|
+
:style="{ height: isVirtual ? `${totalHeight}px` : 'auto' }"
|
|
14
|
+
>
|
|
15
|
+
<div
|
|
16
|
+
class="sticky top-0 z-20 flex border-b border-(--ui-text) bg-(--ui-bg) text-(--ui-text) font-bold text-xs uppercase tracking-wider select-none"
|
|
17
|
+
:style="{ height: `${rowHeight}px` }"
|
|
18
|
+
>
|
|
19
|
+
<div
|
|
20
|
+
v-for="col in columns"
|
|
21
|
+
:key="col.key"
|
|
22
|
+
class="flex items-center px-4 border-r border-(--ui-text) last:border-r-0 whitespace-nowrap overflow-hidden transition-colors hover:bg-(--ui-text)/5 cursor-pointer"
|
|
23
|
+
:style="{
|
|
24
|
+
width: col.width || '150px',
|
|
25
|
+
minWidth: col.width || '150px',
|
|
26
|
+
maxWidth: col.width || '150px',
|
|
27
|
+
}"
|
|
28
|
+
@click="col.sortable && handleSort(col.key)"
|
|
29
|
+
>
|
|
30
|
+
{{ col.label }}
|
|
31
|
+
<span
|
|
32
|
+
v-if="col.sortable"
|
|
33
|
+
class="ml-2 opacity-60 text-[10px]"
|
|
34
|
+
>
|
|
35
|
+
<span v-if="currentSortKey === col.key">
|
|
36
|
+
{{ currentSortOrder === "asc" ? "▲" : "▼" }}
|
|
37
|
+
</span>
|
|
38
|
+
<span v-else class="opacity-30">⇅</span>
|
|
39
|
+
</span>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<div
|
|
44
|
+
v-if="isVirtual"
|
|
45
|
+
class="absolute left-0 w-full will-change-transform"
|
|
46
|
+
:style="{
|
|
47
|
+
top: `${rowHeight}px`,
|
|
48
|
+
transform: `translateY(${offsetY}px)`,
|
|
49
|
+
}"
|
|
50
|
+
>
|
|
51
|
+
<div
|
|
52
|
+
v-for="item in visibleItems"
|
|
53
|
+
:key="item.id || item._virtualId"
|
|
54
|
+
class="flex border-b border-(--ui-text)/20 hover:bg-(--ui-text)/5 transition-colors box-border group"
|
|
55
|
+
:style="{ height: `${rowHeight}px` }"
|
|
56
|
+
>
|
|
57
|
+
<div
|
|
58
|
+
v-for="col in columns"
|
|
59
|
+
:key="col.key"
|
|
60
|
+
class="flex items-center px-4 text-sm text-(--ui-text) border-r border-(--ui-text)/20 last:border-r-0 whitespace-nowrap overflow-hidden"
|
|
61
|
+
:style="{
|
|
62
|
+
width: col.width || '150px',
|
|
63
|
+
minWidth: col.width || '150px',
|
|
64
|
+
maxWidth: col.width || '150px',
|
|
65
|
+
}"
|
|
66
|
+
>
|
|
67
|
+
<slot :name="`cell-${col.key}`" :item="item">
|
|
68
|
+
{{ getNestedValue(item, col.key) }}
|
|
69
|
+
</slot>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<div v-else class="flex flex-col">
|
|
75
|
+
<div
|
|
76
|
+
v-for="(item, index) in sortedItems"
|
|
77
|
+
:key="item.id || index"
|
|
78
|
+
class="flex border-b border-(--ui-text)/20 hover:bg-(--ui-text)/5 transition-colors box-border group"
|
|
79
|
+
:style="{ height: `${rowHeight}px` }"
|
|
80
|
+
>
|
|
81
|
+
<div
|
|
82
|
+
v-for="col in columns"
|
|
83
|
+
:key="col.key"
|
|
84
|
+
class="flex items-center px-4 text-sm text-(--ui-text) border-r border-(--ui-text)/20 last:border-r-0 whitespace-nowrap overflow-hidden"
|
|
85
|
+
:style="{
|
|
86
|
+
width: col.width || '150px',
|
|
87
|
+
minWidth: col.width || '150px',
|
|
88
|
+
maxWidth: col.width || '150px',
|
|
89
|
+
}"
|
|
90
|
+
>
|
|
91
|
+
<slot :name="`cell-${col.key}`" :item="item">
|
|
92
|
+
{{ getNestedValue(item, col.key) }}
|
|
93
|
+
</slot>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<div
|
|
100
|
+
v-if="items.length === 0"
|
|
101
|
+
class="absolute inset-0 flex items-center justify-center pointer-events-none pt-12"
|
|
102
|
+
>
|
|
103
|
+
<span class="opacity-50 font-mono text-sm">{{
|
|
104
|
+
t("interface.nodata")
|
|
105
|
+
}}</span>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</template>
|
|
110
|
+
|
|
111
|
+
<script setup lang="ts">
|
|
112
|
+
interface Column {
|
|
113
|
+
key: string;
|
|
114
|
+
label: string;
|
|
115
|
+
width?: string;
|
|
116
|
+
sortable?: boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
interface Props {
|
|
120
|
+
items: any[];
|
|
121
|
+
columns: Column[];
|
|
122
|
+
height?: string;
|
|
123
|
+
rowHeight?: number;
|
|
124
|
+
buffer?: number;
|
|
125
|
+
virtual?: boolean;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
129
|
+
height: "100%",
|
|
130
|
+
rowHeight: 45,
|
|
131
|
+
buffer: 20,
|
|
132
|
+
virtual: true,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const { t } = useMultiLang(["interface"]);
|
|
136
|
+
|
|
137
|
+
const emit = defineEmits(["sort"]);
|
|
138
|
+
|
|
139
|
+
const scroller = ref<HTMLElement | null>(null);
|
|
140
|
+
const scrollTop = ref(0);
|
|
141
|
+
const viewportHeight = ref(800);
|
|
142
|
+
|
|
143
|
+
const currentSortKey = ref("");
|
|
144
|
+
const currentSortOrder = ref<"asc" | "desc">("asc");
|
|
145
|
+
|
|
146
|
+
const handleSort = (key: string) => {
|
|
147
|
+
if (currentSortKey.value === key) {
|
|
148
|
+
currentSortOrder.value =
|
|
149
|
+
currentSortOrder.value === "asc" ? "desc" : "asc";
|
|
150
|
+
} else {
|
|
151
|
+
currentSortKey.value = key;
|
|
152
|
+
currentSortOrder.value = "asc";
|
|
153
|
+
}
|
|
154
|
+
emit("sort", { key: currentSortKey.value, order: currentSortOrder.value });
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const sortedItems = computed(() => {
|
|
158
|
+
if (!currentSortKey.value) return props.items;
|
|
159
|
+
|
|
160
|
+
const data = [...props.items];
|
|
161
|
+
|
|
162
|
+
return data.sort((a, b) => {
|
|
163
|
+
const valA = getNestedValue(a, currentSortKey.value);
|
|
164
|
+
const valB = getNestedValue(b, currentSortKey.value);
|
|
165
|
+
|
|
166
|
+
if (valA < valB) return currentSortOrder.value === "asc" ? -1 : 1;
|
|
167
|
+
if (valA > valB) return currentSortOrder.value === "asc" ? 1 : -1;
|
|
168
|
+
return 0;
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const isVirtual = computed(() => props.virtual && props.items.length > 100);
|
|
173
|
+
|
|
174
|
+
const totalHeight = computed(
|
|
175
|
+
() => sortedItems.value.length * props.rowHeight + props.rowHeight,
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
const startIndex = computed(() =>
|
|
179
|
+
Math.floor(scrollTop.value / props.rowHeight),
|
|
180
|
+
);
|
|
181
|
+
const endIndex = computed(() =>
|
|
182
|
+
Math.ceil((scrollTop.value + viewportHeight.value) / props.rowHeight),
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
const renderStart = computed(() =>
|
|
186
|
+
Math.max(0, startIndex.value - props.buffer),
|
|
187
|
+
);
|
|
188
|
+
const renderEnd = computed(() =>
|
|
189
|
+
Math.min(sortedItems.value.length, endIndex.value + props.buffer),
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
const visibleItems = computed(() => {
|
|
193
|
+
if (!isVirtual.value) return [];
|
|
194
|
+
return sortedItems.value
|
|
195
|
+
.slice(renderStart.value, renderEnd.value)
|
|
196
|
+
.map((item, idx) => ({
|
|
197
|
+
...item,
|
|
198
|
+
_virtualId: renderStart.value + idx,
|
|
199
|
+
}));
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
const offsetY = computed(() => renderStart.value * props.rowHeight);
|
|
203
|
+
|
|
204
|
+
const onScroll = (e: Event) => {
|
|
205
|
+
if (isVirtual.value) {
|
|
206
|
+
requestAnimationFrame(() => {
|
|
207
|
+
scrollTop.value = (e.target as HTMLElement).scrollTop;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const getNestedValue = (obj: any, path: string) => {
|
|
213
|
+
return path
|
|
214
|
+
.split(".")
|
|
215
|
+
.reduce((o, key) => (o && o[key] !== undefined ? o[key] : ""), obj);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
onMounted(() => {
|
|
219
|
+
if (scroller.value) {
|
|
220
|
+
viewportHeight.value = scroller.value.clientHeight;
|
|
221
|
+
const ro = new ResizeObserver((entries) => {
|
|
222
|
+
for (const entry of entries) {
|
|
223
|
+
viewportHeight.value = entry.contentRect.height;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
ro.observe(scroller.value);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
</script>
|
|
230
|
+
|
|
231
|
+
<style scoped>
|
|
232
|
+
div {
|
|
233
|
+
scrollbar-width: thin;
|
|
234
|
+
scrollbar-color: var(--ui-text) var(--ui-bg);
|
|
235
|
+
}
|
|
236
|
+
div::-webkit-scrollbar {
|
|
237
|
+
width: 10px;
|
|
238
|
+
height: 10px;
|
|
239
|
+
}
|
|
240
|
+
div::-webkit-scrollbar-track {
|
|
241
|
+
background: var(--ui-bg);
|
|
242
|
+
border: 1px solid var(--ui-text);
|
|
243
|
+
}
|
|
244
|
+
div::-webkit-scrollbar-thumb {
|
|
245
|
+
background: var(--ui-text);
|
|
246
|
+
border: 2px solid var(--ui-bg);
|
|
247
|
+
}
|
|
248
|
+
div::-webkit-scrollbar-corner {
|
|
249
|
+
background: var(--ui-text);
|
|
250
|
+
}
|
|
251
|
+
</style>
|