@eslamdevui/ui 3.3.0 → 3.3.1
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/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/DashboardSidebarToggle.vue +5 -2
- package/dist/runtime/components/DashboardToolbar.vue.d.ts +2 -2
- package/dist/runtime/components/PricingTable.vue +76 -31
- package/dist/runtime/components/Tabs.vue +15 -14
- package/dist/runtime/components/content/ContentSearch.vue +16 -5
- package/dist/runtime/components/content/ContentSurround.vue +10 -4
- package/dist/runtime/composables/useBreakpoint.js +8 -8
- package/dist/runtime/composables/useQuerySection.d.ts +14 -0
- package/dist/runtime/composables/useQuerySection.js +44 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -24,8 +24,11 @@ const ui = computed(() => tv({ extend: tv(theme), ...appConfig.ui?.dashboardSide
|
|
|
24
24
|
</script>
|
|
25
25
|
|
|
26
26
|
<template>
|
|
27
|
-
<UButton
|
|
27
|
+
<UButton
|
|
28
|
+
v-bind="rootProps"
|
|
28
29
|
:aria-label="sidebarOpen ? t('dashboardSidebarToggle.close') : t('dashboardSidebarToggle.open')"
|
|
29
30
|
:icon="sidebarOpen ? appConfig.ui.icons.close : appConfig.ui.icons.menu"
|
|
30
|
-
:class="ui({ class: props.class, side: props.side })"
|
|
31
|
+
:class="ui({ class: props.class, side: props.side })"
|
|
32
|
+
@click="toggleSidebar"
|
|
33
|
+
/>
|
|
31
34
|
</template>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import theme from
|
|
1
|
+
import theme from '#build/ui/dashboard-toolbar';
|
|
2
2
|
import type { AppConfig } from '@nuxt/schema';
|
|
3
|
-
import type { ComponentConfig } from
|
|
3
|
+
import type { ComponentConfig } from '../types';
|
|
4
4
|
type DashboardToolbar = ComponentConfig<typeof theme, AppConfig, 'dashboardToolbar'>;
|
|
5
5
|
export interface DashboardToolbarProps {
|
|
6
6
|
/**
|
|
@@ -53,15 +53,21 @@ const [DefineFeatureTemplate, ReuseFeatureTemplate] = createReusableTemplate({
|
|
|
53
53
|
|
|
54
54
|
<slot :name="`${tier.id}-badge`" :tier="tier">
|
|
55
55
|
<slot name="tier-badge" :tier="tier">
|
|
56
|
-
<UBadge
|
|
56
|
+
<UBadge
|
|
57
|
+
v-if="tier.badge"
|
|
58
|
+
color="primary"
|
|
59
|
+
variant="subtle"
|
|
57
60
|
v-bind="typeof tier.badge === 'string' ? { label: tier.badge } : tier.badge"
|
|
58
|
-
:class="ui.tierBadge({ class: props.ui?.tierBadge })"
|
|
61
|
+
:class="ui.tierBadge({ class: props.ui?.tierBadge })"
|
|
62
|
+
/>
|
|
59
63
|
</slot>
|
|
60
64
|
</slot>
|
|
61
65
|
</div>
|
|
62
66
|
|
|
63
|
-
<div
|
|
64
|
-
|
|
67
|
+
<div
|
|
68
|
+
v-if="tier.description || !!slots['tier-description'] || !!slots[`${tier.id}-description`]"
|
|
69
|
+
:class="ui.tierDescription({ class: props.ui?.tierDescription })"
|
|
70
|
+
>
|
|
65
71
|
<slot :name="`${tier.id}-description`" :tier="tier">
|
|
66
72
|
<slot name="tier-description" :tier="tier">
|
|
67
73
|
{{ tier.description }}
|
|
@@ -71,9 +77,12 @@ const [DefineFeatureTemplate, ReuseFeatureTemplate] = createReusableTemplate({
|
|
|
71
77
|
|
|
72
78
|
<div
|
|
73
79
|
v-if="tier.discount || tier.price || !!slots['tier-discount'] || !!slots[`${tier.id}-discount`] || !!slots['tier-price'] || !!slots[`${tier.id}-price`] || tier.billingCycle || tier.billingPeriod || !!slots['tier-billing'] || !!slots[`${tier.id}-billing`]"
|
|
74
|
-
:class="ui.tierPriceWrapper({ class: props.ui?.tierPriceWrapper })"
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
:class="ui.tierPriceWrapper({ class: props.ui?.tierPriceWrapper })"
|
|
81
|
+
>
|
|
82
|
+
<div
|
|
83
|
+
v-if="tier.discount && tier.price || !!slots[`${tier.id}-discount`] || !!slots['tier-discount']"
|
|
84
|
+
:class="ui.tierDiscount({ class: props.ui?.tierDiscount })"
|
|
85
|
+
>
|
|
77
86
|
<slot :name="`${tier.id}-discount`" :tier="tier">
|
|
78
87
|
<slot name="tier-discount" :tier="tier">
|
|
79
88
|
{{ tier.price }}
|
|
@@ -81,8 +90,10 @@ const [DefineFeatureTemplate, ReuseFeatureTemplate] = createReusableTemplate({
|
|
|
81
90
|
</slot>
|
|
82
91
|
</div>
|
|
83
92
|
|
|
84
|
-
<div
|
|
85
|
-
|
|
93
|
+
<div
|
|
94
|
+
v-if="tier.discount || tier.price || !!slots[`${tier.id}-price`] || !!slots['tier-price']"
|
|
95
|
+
:class="ui.tierPrice({ class: props.ui?.tierPrice })"
|
|
96
|
+
>
|
|
86
97
|
<slot :name="`${tier.id}-price`" :tier="tier">
|
|
87
98
|
<slot name="tier-price" :tier="tier">
|
|
88
99
|
{{ tier.discount || tier.price }}
|
|
@@ -92,7 +103,8 @@ const [DefineFeatureTemplate, ReuseFeatureTemplate] = createReusableTemplate({
|
|
|
92
103
|
|
|
93
104
|
<div
|
|
94
105
|
v-if="tier.billingCycle || tier.billingPeriod || !!slots[`${tier.id}-billing`] || !!slots['tier-billing']"
|
|
95
|
-
:class="ui.tierBilling({ class: props.ui?.tierBilling })"
|
|
106
|
+
:class="ui.tierBilling({ class: props.ui?.tierBilling })"
|
|
107
|
+
>
|
|
96
108
|
<slot :name="`${tier.id}-billing`" :tier="tier">
|
|
97
109
|
<slot name="tier-billing" :tier="tier">
|
|
98
110
|
<span :class="ui.tierBillingPeriod({ class: props.ui?.tierBillingPeriod })">
|
|
@@ -107,8 +119,10 @@ const [DefineFeatureTemplate, ReuseFeatureTemplate] = createReusableTemplate({
|
|
|
107
119
|
</div>
|
|
108
120
|
</div>
|
|
109
121
|
|
|
110
|
-
<div
|
|
111
|
-
|
|
122
|
+
<div
|
|
123
|
+
v-if="!!slots[`${tier.id}-button`] || !!slots['tier-button'] || tier.button"
|
|
124
|
+
:class="ui.tierButton({ class: props.ui?.tierButton })"
|
|
125
|
+
>
|
|
112
126
|
<slot :name="`${tier.id}-button`" :tier="tier">
|
|
113
127
|
<slot name="tier-button" :tier="tier">
|
|
114
128
|
<UButton v-if="tier.button" block size="lg" v-bind="tier.button" />
|
|
@@ -121,8 +135,11 @@ const [DefineFeatureTemplate, ReuseFeatureTemplate] = createReusableTemplate({
|
|
|
121
135
|
|
|
122
136
|
<DefineFeatureTemplate v-slot="{ feature, tier }">
|
|
123
137
|
<template v-if="feature.tiers?.[tier.id]">
|
|
124
|
-
<UIcon
|
|
125
|
-
|
|
138
|
+
<UIcon
|
|
139
|
+
v-if="typeof feature.tiers[tier.id] === 'boolean'"
|
|
140
|
+
:name="appConfig.ui.icons.success"
|
|
141
|
+
:class="ui.tierFeatureIcon({ class: props.ui?.tierFeatureIcon, active: true })"
|
|
142
|
+
/>
|
|
126
143
|
<template v-else>
|
|
127
144
|
{{ feature.tiers[tier.id] }}
|
|
128
145
|
</template>
|
|
@@ -143,8 +160,12 @@ const [DefineFeatureTemplate, ReuseFeatureTemplate] = createReusableTemplate({
|
|
|
143
160
|
<tr :class="ui.tr({ class: props.ui?.tr })">
|
|
144
161
|
<td />
|
|
145
162
|
|
|
146
|
-
<th
|
|
147
|
-
|
|
163
|
+
<th
|
|
164
|
+
v-for="(tier, index) in tiers"
|
|
165
|
+
:key="index"
|
|
166
|
+
scope="col"
|
|
167
|
+
:class="ui.tier({ class: props.ui?.tier, highlight: tier.highlight })"
|
|
168
|
+
>
|
|
148
169
|
<ReuseTierTemplate :tier="tier" />
|
|
149
170
|
</th>
|
|
150
171
|
</tr>
|
|
@@ -156,7 +177,8 @@ const [DefineFeatureTemplate, ReuseFeatureTemplate] = createReusableTemplate({
|
|
|
156
177
|
<th scope="row" :class="ui.th({ class: props.ui?.th })">
|
|
157
178
|
<div
|
|
158
179
|
v-if="section.title || !!slots['section-title'] || !!slots[`section-${formatSlotName(section)}-title`]"
|
|
159
|
-
:class="ui.sectionTitle({ class: props.ui?.sectionTitle })"
|
|
180
|
+
:class="ui.sectionTitle({ class: props.ui?.sectionTitle })"
|
|
181
|
+
>
|
|
160
182
|
<slot :name="`section-${formatSlotName(section)}-title`" :section="section">
|
|
161
183
|
<slot name="section-title" :section="section">
|
|
162
184
|
{{ section.title }}
|
|
@@ -165,8 +187,11 @@ const [DefineFeatureTemplate, ReuseFeatureTemplate] = createReusableTemplate({
|
|
|
165
187
|
</div>
|
|
166
188
|
</th>
|
|
167
189
|
|
|
168
|
-
<td
|
|
169
|
-
|
|
190
|
+
<td
|
|
191
|
+
v-for="(tier, index) in tiers"
|
|
192
|
+
:key="`${sectionIndex}-tier-${index}`"
|
|
193
|
+
:class="ui.td({ class: props.ui?.td, highlight: tier.highlight })"
|
|
194
|
+
/>
|
|
170
195
|
</tr>
|
|
171
196
|
|
|
172
197
|
<tr v-for="(feature, featureIndex) in section.features" :key="`${sectionIndex}-feature-${featureIndex}`">
|
|
@@ -180,11 +205,18 @@ const [DefineFeatureTemplate, ReuseFeatureTemplate] = createReusableTemplate({
|
|
|
180
205
|
</div>
|
|
181
206
|
</th>
|
|
182
207
|
|
|
183
|
-
<td
|
|
184
|
-
|
|
208
|
+
<td
|
|
209
|
+
v-for="(tier, index) in tiers"
|
|
210
|
+
:key="`${sectionIndex}-feature-${featureIndex}-tier-${index}`"
|
|
211
|
+
:class="ui.td({ class: props.ui?.td, highlight: tier.highlight })"
|
|
212
|
+
>
|
|
185
213
|
<div :class="ui.featureValue({ class: props.ui?.featureValue })">
|
|
186
|
-
<slot
|
|
187
|
-
:
|
|
214
|
+
<slot
|
|
215
|
+
:name="`feature-${formatSlotName(feature)}-value`"
|
|
216
|
+
:feature="feature"
|
|
217
|
+
:tier="tier"
|
|
218
|
+
:section="section"
|
|
219
|
+
>
|
|
188
220
|
<slot name="feature-value" :feature="feature" :tier="tier" :section="section">
|
|
189
221
|
<ReuseFeatureTemplate :tier="tier" :feature="feature" />
|
|
190
222
|
</slot>
|
|
@@ -197,12 +229,18 @@ const [DefineFeatureTemplate, ReuseFeatureTemplate] = createReusableTemplate({
|
|
|
197
229
|
</table>
|
|
198
230
|
|
|
199
231
|
<ul :class="ui.list({ class: props.ui?.list })">
|
|
200
|
-
<li
|
|
201
|
-
|
|
232
|
+
<li
|
|
233
|
+
v-for="(tier, index) in tiers"
|
|
234
|
+
:key="index"
|
|
235
|
+
:class="ui.item({ class: props.ui?.item, highlight: tier.highlight })"
|
|
236
|
+
>
|
|
202
237
|
<ReuseTierTemplate :tier="tier" />
|
|
203
238
|
|
|
204
|
-
<div
|
|
205
|
-
|
|
239
|
+
<div
|
|
240
|
+
v-for="(section, sectionIndex) in sections"
|
|
241
|
+
:key="`section-${sectionIndex}`"
|
|
242
|
+
:class="ui.section({ class: props.ui?.section })"
|
|
243
|
+
>
|
|
206
244
|
<div v-if="section.title" :class="ui.sectionTitle({ class: props.ui?.sectionTitle })">
|
|
207
245
|
<slot :name="`section-${formatSlotName(section)}-title`" :section="section">
|
|
208
246
|
<slot name="section-title" :section="section">
|
|
@@ -211,8 +249,11 @@ const [DefineFeatureTemplate, ReuseFeatureTemplate] = createReusableTemplate({
|
|
|
211
249
|
</slot>
|
|
212
250
|
</div>
|
|
213
251
|
|
|
214
|
-
<div
|
|
215
|
-
|
|
252
|
+
<div
|
|
253
|
+
v-for="(feature, featureIndex) in section.features"
|
|
254
|
+
:key="`section-${sectionIndex}-feature-${featureIndex}`"
|
|
255
|
+
:class="ui.feature({ class: props.ui?.feature })"
|
|
256
|
+
>
|
|
216
257
|
<div :class="ui.featureTitle({ class: props.ui?.featureTitle })">
|
|
217
258
|
<slot :name="`feature-${formatSlotName(feature)}-title`" :feature="feature" :section="section">
|
|
218
259
|
<slot name="feature-title" :feature="feature" :section="section">
|
|
@@ -222,8 +263,12 @@ const [DefineFeatureTemplate, ReuseFeatureTemplate] = createReusableTemplate({
|
|
|
222
263
|
</div>
|
|
223
264
|
|
|
224
265
|
<div :class="ui.featureValue({ class: props.ui?.featureValue })">
|
|
225
|
-
<slot
|
|
226
|
-
:
|
|
266
|
+
<slot
|
|
267
|
+
:name="`feature-${formatSlotName(feature)}-value`"
|
|
268
|
+
:feature="feature"
|
|
269
|
+
:tier="tier"
|
|
270
|
+
:section="section"
|
|
271
|
+
>
|
|
227
272
|
<slot name="feature-value" :feature="feature" :tier="tier" :section="section">
|
|
228
273
|
<ReuseFeatureTemplate :tier="tier" :feature="feature" />
|
|
229
274
|
</slot>
|
|
@@ -50,21 +50,20 @@ defineExpose({
|
|
|
50
50
|
|
|
51
51
|
<slot name="list-leading" />
|
|
52
52
|
|
|
53
|
-
<TabsTrigger
|
|
54
|
-
|
|
55
|
-
:
|
|
56
|
-
:ref="(el) => triggersRef[index] = el"
|
|
57
|
-
`
|
|
58
|
-
:value="item.value || String(index)"
|
|
59
|
-
:disabled="item.disabled"
|
|
60
|
-
:class="ui.trigger({ class: [props.ui?.trigger, item.ui?.trigger] })"
|
|
61
|
-
>
|
|
53
|
+
<TabsTrigger v-for="(item, index) of items" :key="index"
|
|
54
|
+
:ref="(el) => triggersRef[index] = el" ` :value="item.value || String(index)"
|
|
55
|
+
:disabled="item.disabled" :class="ui.trigger({ class: [props.ui?.trigger, item.ui?.trigger] })">
|
|
62
56
|
<slot name="leading" :item="item" :index="index">
|
|
63
|
-
<UIcon v-if="item.icon" :name="item.icon"
|
|
64
|
-
|
|
57
|
+
<UIcon v-if="item.icon" :name="item.icon"
|
|
58
|
+
:class="ui.leadingIcon({ class: [props.ui?.leadingIcon, item.ui?.leadingIcon] })" />
|
|
59
|
+
<UAvatar v-else-if="item.avatar"
|
|
60
|
+
:size="props.ui?.leadingAvatarSize || ui.leadingAvatarSize()"
|
|
61
|
+
v-bind="item.avatar"
|
|
62
|
+
:class="ui.leadingAvatar({ class: [props.ui?.leadingAvatar, item.ui?.leadingAvatar] })" />
|
|
65
63
|
</slot>
|
|
66
64
|
|
|
67
|
-
<span v-if="get(item, props.labelKey) || !!slots.default"
|
|
65
|
+
<span v-if="get(item, props.labelKey) || !!slots.default"
|
|
66
|
+
:class="ui.label({ class: [props.ui?.label, item.ui?.label] })">
|
|
68
67
|
<slot :item="item" :index="index">{{ get(item, props.labelKey) }}</slot>
|
|
69
68
|
</span>
|
|
70
69
|
|
|
@@ -75,8 +74,10 @@ defineExpose({
|
|
|
75
74
|
</TabsList>
|
|
76
75
|
|
|
77
76
|
<template v-if="!!content">
|
|
78
|
-
<TabsContent v-for="(item, index) of items" :key="index" :value="item.value || String(index)"
|
|
79
|
-
|
|
77
|
+
<TabsContent v-for="(item, index) of items || []" :key="index" :value="item.value || String(index)"
|
|
78
|
+
:class="ui.content({ class: [props.ui?.content, item.ui?.content, item.class] })">
|
|
79
|
+
<slot :name="item.slot || 'content'" :item="item"
|
|
80
|
+
:index="index">
|
|
80
81
|
{{ item.content }}
|
|
81
82
|
</slot>
|
|
82
83
|
</TabsContent>
|
|
@@ -165,13 +165,24 @@ defineExpose({ commandPaletteRef });
|
|
|
165
165
|
</script>
|
|
166
166
|
|
|
167
167
|
<template>
|
|
168
|
-
<UModal
|
|
169
|
-
:
|
|
168
|
+
<UModal
|
|
169
|
+
v-model:open="open"
|
|
170
|
+
:title="t('contentSearch.title')"
|
|
171
|
+
:description="t('contentSearch.description')"
|
|
172
|
+
:class="ui.modal({ class: props.class })"
|
|
173
|
+
>
|
|
170
174
|
<template #content>
|
|
171
175
|
<slot name="content">
|
|
172
|
-
<UCommandPalette
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
<UCommandPalette
|
|
177
|
+
ref="commandPaletteRef"
|
|
178
|
+
v-model:search-term="searchTerm"
|
|
179
|
+
v-bind="commandPaletteProps"
|
|
180
|
+
:groups="groups"
|
|
181
|
+
:fuse="fuse"
|
|
182
|
+
:ui="transformUI(omit(ui, ['modal']), props.ui)"
|
|
183
|
+
@update:model-value="onSelect"
|
|
184
|
+
@update:open="open = $event"
|
|
185
|
+
>
|
|
175
186
|
<template v-for="(_, name) in proxySlots" #[name]="slotData">
|
|
176
187
|
<slot :name="name" v-bind="slotData" />
|
|
177
188
|
</template>
|
|
@@ -24,13 +24,19 @@ const ui = computed(() => tv({ extend: tv(theme), ...appConfig.ui?.contentSurrou
|
|
|
24
24
|
|
|
25
25
|
<template>
|
|
26
26
|
<DefineLinkTemplate v-slot="{ link, icon, direction }">
|
|
27
|
-
<ULink
|
|
28
|
-
|
|
27
|
+
<ULink
|
|
28
|
+
v-if="link"
|
|
29
|
+
:to="link.path"
|
|
30
|
+
raw
|
|
31
|
+
:class="ui.link({ class: [props.ui?.link, link.ui?.link, link.class], direction })"
|
|
32
|
+
>
|
|
29
33
|
<slot name="link" :link="link">
|
|
30
34
|
<div :class="ui.linkLeading({ class: [props.ui?.linkLeading, link.ui?.linkLeading] })">
|
|
31
35
|
<slot name="link-leading" :link="link">
|
|
32
|
-
<UIcon
|
|
33
|
-
:
|
|
36
|
+
<UIcon
|
|
37
|
+
:name="link.icon || icon"
|
|
38
|
+
:class="ui.linkLeadingIcon({ class: [props.ui?.linkLeadingIcon, link.ui?.linkLeadingIcon], direction })"
|
|
39
|
+
/>
|
|
34
40
|
</slot>
|
|
35
41
|
</div>
|
|
36
42
|
|
|
@@ -2,10 +2,10 @@ import { useMediaQuery } from "@vueuse/core";
|
|
|
2
2
|
import { computed } from "vue";
|
|
3
3
|
import { useAppConfig } from "#imports";
|
|
4
4
|
const defaultBreakpoints = {
|
|
5
|
-
sm: "640px",
|
|
6
|
-
md: "768px",
|
|
7
|
-
lg: "1024px",
|
|
8
|
-
xl: "1280px",
|
|
5
|
+
"sm": "640px",
|
|
6
|
+
"md": "768px",
|
|
7
|
+
"lg": "1024px",
|
|
8
|
+
"xl": "1280px",
|
|
9
9
|
"2xl": "1536px"
|
|
10
10
|
};
|
|
11
11
|
export function useBreakpoint() {
|
|
@@ -15,10 +15,10 @@ export function useBreakpoint() {
|
|
|
15
15
|
...config.ui?.breakpoints || {}
|
|
16
16
|
};
|
|
17
17
|
const queries = {
|
|
18
|
-
sm: useMediaQuery(`(min-width: ${breakpoints.sm})`),
|
|
19
|
-
md: useMediaQuery(`(min-width: ${breakpoints.md})`),
|
|
20
|
-
lg: useMediaQuery(`(min-width: ${breakpoints.lg})`),
|
|
21
|
-
xl: useMediaQuery(`(min-width: ${breakpoints.xl})`),
|
|
18
|
+
"sm": useMediaQuery(`(min-width: ${breakpoints.sm})`),
|
|
19
|
+
"md": useMediaQuery(`(min-width: ${breakpoints.md})`),
|
|
20
|
+
"lg": useMediaQuery(`(min-width: ${breakpoints.lg})`),
|
|
21
|
+
"xl": useMediaQuery(`(min-width: ${breakpoints.xl})`),
|
|
22
22
|
"2xl": useMediaQuery(`(min-width: ${breakpoints["2xl"]})`)
|
|
23
23
|
};
|
|
24
24
|
const current = computed(() => {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type UseQuerySectionOptions = {
|
|
2
|
+
key?: string;
|
|
3
|
+
offset?: number;
|
|
4
|
+
behavior?: ScrollBehavior;
|
|
5
|
+
autoScroll?: boolean;
|
|
6
|
+
clearQuery?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const useQuerySection: (options?: UseQuerySectionOptions) => {
|
|
9
|
+
setSection: (section: string) => void;
|
|
10
|
+
getSection: () => string | null;
|
|
11
|
+
clearSection: () => void;
|
|
12
|
+
scrollToSection: (customId?: string) => void;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { onMounted } from "vue";
|
|
2
|
+
import { useRouter, useRoute } from "vue-router";
|
|
3
|
+
export const useQuerySection = (options = {}) => {
|
|
4
|
+
const router = useRouter();
|
|
5
|
+
const route = useRoute();
|
|
6
|
+
const key = options.key || "section";
|
|
7
|
+
const offset = options.offset || 0;
|
|
8
|
+
const behavior = options.behavior || "smooth";
|
|
9
|
+
const getSection = () => {
|
|
10
|
+
return route.query[key] || null;
|
|
11
|
+
};
|
|
12
|
+
const setSection = (section) => {
|
|
13
|
+
router.replace({
|
|
14
|
+
query: {
|
|
15
|
+
...route.query,
|
|
16
|
+
[key]: section
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const clearSection = () => {
|
|
21
|
+
const query = { ...route.query };
|
|
22
|
+
delete query[key];
|
|
23
|
+
router.replace({ query });
|
|
24
|
+
};
|
|
25
|
+
const scrollToSection = (customId) => {
|
|
26
|
+
if (!import.meta.client) return;
|
|
27
|
+
const sectionId = customId || getSection();
|
|
28
|
+
if (!sectionId) return;
|
|
29
|
+
const el = document.getElementById(sectionId);
|
|
30
|
+
if (!el) return;
|
|
31
|
+
const top = el.getBoundingClientRect().top + window.scrollY - offset;
|
|
32
|
+
window.scrollTo({ top, behavior });
|
|
33
|
+
if (options.clearQuery) clearSection();
|
|
34
|
+
};
|
|
35
|
+
if (options.autoScroll && import.meta.client) {
|
|
36
|
+
onMounted(() => scrollToSection());
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
setSection,
|
|
40
|
+
getSection,
|
|
41
|
+
clearSection,
|
|
42
|
+
scrollToSection
|
|
43
|
+
};
|
|
44
|
+
};
|
package/package.json
CHANGED