@bitrix24/b24ui-nuxt 0.3.2 → 0.3.4
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/.nuxt/b24ui/container.ts +1 -1
- package/.nuxt/b24ui/index.ts +1 -0
- package/.nuxt/b24ui/slideover.ts +101 -0
- package/dist/meta.cjs +696 -233
- package/dist/meta.d.cts +696 -233
- package/dist/meta.d.mts +696 -233
- package/dist/meta.d.ts +696 -233
- package/dist/meta.mjs +696 -233
- package/dist/module.cjs +1 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -2
- package/dist/runtime/components/App.vue +3 -4
- package/dist/runtime/components/Modal.vue +4 -2
- package/dist/runtime/components/OverlayProvider.vue +29 -0
- package/dist/runtime/components/Slideover.vue +193 -0
- package/dist/runtime/composables/useOverlay.d.ts +30 -0
- package/dist/runtime/composables/useOverlay.js +71 -0
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/vue/components/Link.vue +10 -37
- package/dist/runtime/vue/composables/useAppConfig.d.ts +1 -0
- package/dist/runtime/vue/composables/useAppConfig.js +2 -0
- package/dist/runtime/vue/stubs.d.ts +21 -0
- package/dist/runtime/vue/stubs.js +39 -0
- package/dist/shared/{b24ui-nuxt.ngV6AJEg.cjs → b24ui-nuxt.BpFAFOHo.cjs} +120 -1
- package/dist/shared/{b24ui-nuxt.BTln9cW-.mjs → b24ui-nuxt.BqTJ-9uP.mjs} +120 -1
- package/dist/unplugin.cjs +3 -3
- package/dist/unplugin.mjs +3 -3
- package/dist/vite.cjs +1 -1
- package/dist/vite.mjs +1 -1
- package/package.json +9 -8
- package/dist/runtime/components/ModalProvider.vue +0 -12
- package/dist/runtime/composables/useModal.d.ts +0 -17
- package/dist/runtime/composables/useModal.js +0 -46
- package/dist/runtime/plugins/modal.d.ts +0 -2
- package/dist/runtime/plugins/modal.js +0 -10
package/dist/module.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const defu = require('defu');
|
|
4
4
|
const kit = require('@nuxt/kit');
|
|
5
|
-
const templates = require('./shared/b24ui-nuxt.
|
|
5
|
+
const templates = require('./shared/b24ui-nuxt.BpFAFOHo.cjs');
|
|
6
6
|
require('node:url');
|
|
7
7
|
require('scule');
|
|
8
8
|
|
|
@@ -41,7 +41,6 @@ const module$1 = kit.defineNuxtModule({
|
|
|
41
41
|
await registerModule("@nuxtjs/color-mode", "colorMode", { classSuffix: "", disableTransition: true });
|
|
42
42
|
}
|
|
43
43
|
kit.addPlugin({ src: resolve("./runtime/plugins/colors") });
|
|
44
|
-
kit.addPlugin({ src: resolve("./runtime/plugins/modal") });
|
|
45
44
|
kit.addComponentsDir({
|
|
46
45
|
path: resolve("./runtime/components"),
|
|
47
46
|
prefix: "B24",
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defu } from 'defu';
|
|
2
2
|
import { defineNuxtModule, createResolver, addVitePlugin, addPlugin, addComponentsDir, addImportsDir, hasNuxtModule, installModule } from '@nuxt/kit';
|
|
3
|
-
import { d as defaultOptions, a as getDefaultUiConfig, b as addTemplates } from './shared/b24ui-nuxt.
|
|
3
|
+
import { d as defaultOptions, a as getDefaultUiConfig, b as addTemplates } from './shared/b24ui-nuxt.BqTJ-9uP.mjs';
|
|
4
4
|
import 'node:url';
|
|
5
5
|
import 'scule';
|
|
6
6
|
|
|
@@ -38,7 +38,6 @@ const module = defineNuxtModule({
|
|
|
38
38
|
await registerModule("@nuxtjs/color-mode", "colorMode", { classSuffix: "", disableTransition: true });
|
|
39
39
|
}
|
|
40
40
|
addPlugin({ src: resolve("./runtime/plugins/colors") });
|
|
41
|
-
addPlugin({ src: resolve("./runtime/plugins/modal") });
|
|
42
41
|
addComponentsDir({
|
|
43
42
|
path: resolve("./runtime/components"),
|
|
44
43
|
prefix: "B24",
|
|
@@ -23,8 +23,7 @@ import { toRef, useId, provide } from 'vue'
|
|
|
23
23
|
import { ConfigProvider, TooltipProvider, useForwardProps } from 'reka-ui'
|
|
24
24
|
import { reactivePick } from '@vueuse/core'
|
|
25
25
|
import B24Toaster from './Toaster.vue'
|
|
26
|
-
import
|
|
27
|
-
// import B24SlideoverProvider from './SlideoverProvider.vue'
|
|
26
|
+
import B24OverlayProvider from './OverlayProvider.vue'
|
|
28
27
|
|
|
29
28
|
const props = defineProps<AppProps>()
|
|
30
29
|
defineSlots<AppSlots>()
|
|
@@ -44,8 +43,8 @@ provide(localeContextInjectionKey, locale)
|
|
|
44
43
|
<slot />
|
|
45
44
|
</B24Toaster>
|
|
46
45
|
<slot v-else />
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
|
|
47
|
+
<B24OverlayProvider />
|
|
49
48
|
</TooltipProvider>
|
|
50
49
|
</ConfigProvider>
|
|
51
50
|
</template>
|
|
@@ -56,7 +56,9 @@ export interface ModalProps extends DialogRootProps {
|
|
|
56
56
|
b24ui?: Partial<typeof modal.slots>
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
export interface ModalEmits extends DialogRootEmits {
|
|
59
|
+
export interface ModalEmits extends DialogRootEmits {
|
|
60
|
+
'after:leave': []
|
|
61
|
+
}
|
|
60
62
|
|
|
61
63
|
export interface ModalSlots {
|
|
62
64
|
default(props: { open: boolean }): any
|
|
@@ -124,7 +126,7 @@ const b24ui = computed(() => modal({
|
|
|
124
126
|
<DialogPortal :disabled="!portal">
|
|
125
127
|
<DialogOverlay v-if="overlay" :class="b24ui.overlay({ class: props.b24ui?.overlay })" />
|
|
126
128
|
|
|
127
|
-
<DialogContent :class="b24ui.content({ class: [!slots.default && props.class, props.b24ui?.content] })" v-bind="contentProps" v-on="contentEvents">
|
|
129
|
+
<DialogContent :class="b24ui.content({ class: [!slots.default && props.class, props.b24ui?.content] })" v-bind="contentProps" @after-leave="emits('after:leave')" v-on="contentEvents">
|
|
128
130
|
<VisuallyHidden v-if="!!slots.content && ((title || !!slots.title) || (description || !!slots.description))">
|
|
129
131
|
<DialogTitle v-if="title || !!slots.title">
|
|
130
132
|
<slot name="title">
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useOverlay } from '../composables/useOverlay'
|
|
4
|
+
|
|
5
|
+
const { overlays, unMount, close } = useOverlay()
|
|
6
|
+
|
|
7
|
+
const mountedOverlays = computed(() => overlays.filter(overlay => overlay.isMounted))
|
|
8
|
+
|
|
9
|
+
const onAfterLeave = (id: symbol) => {
|
|
10
|
+
close(id)
|
|
11
|
+
unMount(id)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const onClose = (id: symbol, value: any) => {
|
|
15
|
+
close(id, value)
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<component
|
|
21
|
+
:is="overlay.component"
|
|
22
|
+
v-for="overlay in mountedOverlays"
|
|
23
|
+
:key="overlay.id"
|
|
24
|
+
v-bind="overlay.props"
|
|
25
|
+
v-model:open="overlay.modelValue"
|
|
26
|
+
@close="(value:any) => onClose(overlay.id, value)"
|
|
27
|
+
@after:leave="onAfterLeave(overlay.id)"
|
|
28
|
+
/>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { VariantProps } from 'tailwind-variants'
|
|
3
|
+
import type { DialogRootProps, DialogRootEmits, DialogContentProps } from 'reka-ui'
|
|
4
|
+
import type { AppConfig } from '@nuxt/schema'
|
|
5
|
+
import _appConfig from '#build/app.config'
|
|
6
|
+
import theme from '#build/b24ui/slideover'
|
|
7
|
+
import { tv } from '../utils/tv'
|
|
8
|
+
import type { ButtonProps, IconComponent } from '../types'
|
|
9
|
+
|
|
10
|
+
const appConfigSlideover = _appConfig as AppConfig & { b24ui: { slideover: Partial<typeof theme> } }
|
|
11
|
+
|
|
12
|
+
const slideover = tv({ extend: tv(theme), ...(appConfigSlideover.b24ui?.slideover || {}) })
|
|
13
|
+
|
|
14
|
+
type SlideoverVariants = VariantProps<typeof slideover>
|
|
15
|
+
|
|
16
|
+
export interface SlideoverProps extends DialogRootProps {
|
|
17
|
+
title?: string
|
|
18
|
+
description?: string
|
|
19
|
+
/** The content of the slideover. */
|
|
20
|
+
content?: Omit<DialogContentProps, 'as' | 'asChild' | 'forceMount'>
|
|
21
|
+
/**
|
|
22
|
+
* Render an overlay behind the slideover.
|
|
23
|
+
* @defaultValue true
|
|
24
|
+
*/
|
|
25
|
+
overlay?: boolean
|
|
26
|
+
/**
|
|
27
|
+
* Animate the slideover when opening or closing.
|
|
28
|
+
* @defaultValue true
|
|
29
|
+
*/
|
|
30
|
+
transition?: boolean
|
|
31
|
+
side?: SlideoverVariants['side']
|
|
32
|
+
/**
|
|
33
|
+
* Render the slideover in a portal.
|
|
34
|
+
* @defaultValue true
|
|
35
|
+
*/
|
|
36
|
+
portal?: boolean
|
|
37
|
+
/**
|
|
38
|
+
* Display a close button to dismiss the slideover.
|
|
39
|
+
* `{ color: 'primary' }`{lang="ts"} for `left`, `right`
|
|
40
|
+
* `{ color: 'link' }`{lang="ts"} for `top`, `bottom`
|
|
41
|
+
* @defaultValue true
|
|
42
|
+
*/
|
|
43
|
+
close?: boolean | Partial<ButtonProps>
|
|
44
|
+
/**
|
|
45
|
+
* The icon displayed in the close button.
|
|
46
|
+
* @defaultValue icons.close
|
|
47
|
+
*/
|
|
48
|
+
closeIcon?: IconComponent
|
|
49
|
+
/**
|
|
50
|
+
* When `false`, the slideover will not close when clicking outside or pressing escape.
|
|
51
|
+
* @defaultValue true
|
|
52
|
+
*/
|
|
53
|
+
dismissible?: boolean
|
|
54
|
+
scrollbarThin?: boolean
|
|
55
|
+
class?: any
|
|
56
|
+
b24ui?: Partial<typeof slideover.slots>
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface SlideoverEmits extends DialogRootEmits {
|
|
60
|
+
'after:leave': []
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface SlideoverSlots {
|
|
64
|
+
default(props: { open: boolean }): any
|
|
65
|
+
content(props?: {}): any
|
|
66
|
+
header(props?: {}): any
|
|
67
|
+
title(props?: {}): any
|
|
68
|
+
description(props?: {}): any
|
|
69
|
+
close(props: { b24ui: any }): any
|
|
70
|
+
body(props?: {}): any
|
|
71
|
+
footer(props?: {}): any
|
|
72
|
+
}
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<script setup lang="ts">
|
|
76
|
+
import { computed, toRef } from 'vue'
|
|
77
|
+
import { DialogRoot, DialogTrigger, DialogPortal, DialogOverlay, DialogContent, DialogTitle, DialogDescription, DialogClose, VisuallyHidden, useForwardPropsEmits } from 'reka-ui'
|
|
78
|
+
import { reactivePick } from '@vueuse/core'
|
|
79
|
+
import { useLocale } from '../composables/useLocale'
|
|
80
|
+
import icons from '../dictionary/icons'
|
|
81
|
+
import B24Button from './Button.vue'
|
|
82
|
+
|
|
83
|
+
const props = withDefaults(defineProps<SlideoverProps>(), {
|
|
84
|
+
close: true,
|
|
85
|
+
portal: true,
|
|
86
|
+
overlay: true,
|
|
87
|
+
transition: true,
|
|
88
|
+
modal: true,
|
|
89
|
+
dismissible: true,
|
|
90
|
+
side: 'right',
|
|
91
|
+
scrollbarThin: true
|
|
92
|
+
})
|
|
93
|
+
const emits = defineEmits<SlideoverEmits>()
|
|
94
|
+
const slots = defineSlots<SlideoverSlots>()
|
|
95
|
+
|
|
96
|
+
const { t } = useLocale()
|
|
97
|
+
|
|
98
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, 'open', 'defaultOpen', 'modal'), emits)
|
|
99
|
+
const contentProps = toRef(() => props.content)
|
|
100
|
+
const contentEvents = computed(() => {
|
|
101
|
+
if (!props.dismissible) {
|
|
102
|
+
return {
|
|
103
|
+
pointerDownOutside: (e: Event) => e.preventDefault(),
|
|
104
|
+
interactOutside: (e: Event) => e.preventDefault(),
|
|
105
|
+
escapeKeyDown: (e: Event) => e.preventDefault(),
|
|
106
|
+
closeAutoFocus: (e: Event) => e.preventDefault()
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
closeAutoFocus: (e: Event) => e.preventDefault()
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
const b24ui = computed(() => slideover({
|
|
116
|
+
transition: props.transition,
|
|
117
|
+
side: props.side
|
|
118
|
+
}))
|
|
119
|
+
</script>
|
|
120
|
+
|
|
121
|
+
<template>
|
|
122
|
+
<DialogRoot v-slot="{ open }" v-bind="rootProps">
|
|
123
|
+
<DialogTrigger v-if="!!slots.default" as-child :class="props.class">
|
|
124
|
+
<slot :open="open" />
|
|
125
|
+
</DialogTrigger>
|
|
126
|
+
|
|
127
|
+
<DialogPortal :disabled="!portal">
|
|
128
|
+
<DialogOverlay v-if="overlay" :class="b24ui.overlay({ class: props.b24ui?.overlay })" />
|
|
129
|
+
|
|
130
|
+
<DialogContent :data-side="side" :class="b24ui.content({ class: [!slots.default && props.class, props.b24ui?.content] })" v-bind="contentProps" @after-leave="emits('after:leave')" v-on="contentEvents">
|
|
131
|
+
<VisuallyHidden v-if="!!slots.content && ((title || !!slots.title) || (description || !!slots.description))">
|
|
132
|
+
<DialogTitle v-if="title || !!slots.title">
|
|
133
|
+
<slot name="title">
|
|
134
|
+
{{ title }}
|
|
135
|
+
</slot>
|
|
136
|
+
</DialogTitle>
|
|
137
|
+
|
|
138
|
+
<DialogDescription v-if="description || !!slots.description">
|
|
139
|
+
<slot name="description">
|
|
140
|
+
{{ description }}
|
|
141
|
+
</slot>
|
|
142
|
+
</DialogDescription>
|
|
143
|
+
</VisuallyHidden>
|
|
144
|
+
|
|
145
|
+
<slot name="content">
|
|
146
|
+
<div v-if="!!slots.header || (title || !!slots.title) || (description || !!slots.description) || (close || !!slots.close)" :class="b24ui.header({ class: props.b24ui?.header })">
|
|
147
|
+
<slot name="header">
|
|
148
|
+
<div :class="b24ui.wrapper({ class: props.b24ui?.wrapper })">
|
|
149
|
+
<DialogTitle v-if="title || !!slots.title" :class="b24ui.title({ class: props.b24ui?.title })">
|
|
150
|
+
<slot name="title">
|
|
151
|
+
{{ title }}
|
|
152
|
+
</slot>
|
|
153
|
+
</DialogTitle>
|
|
154
|
+
|
|
155
|
+
<DialogDescription v-if="description || !!slots.description" :class="b24ui.description({ class: props.b24ui?.description })">
|
|
156
|
+
<slot name="description">
|
|
157
|
+
{{ description }}
|
|
158
|
+
</slot>
|
|
159
|
+
</DialogDescription>
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
<DialogClose as-child>
|
|
163
|
+
<slot name="close" :b24ui="b24ui">
|
|
164
|
+
<B24Button
|
|
165
|
+
v-if="close"
|
|
166
|
+
:icon="closeIcon || icons.close"
|
|
167
|
+
size="md"
|
|
168
|
+
class="group"
|
|
169
|
+
:color="['left', 'right'].includes(props?.side) ? 'primary' : 'link'"
|
|
170
|
+
:aria-label="t('slideover.close')"
|
|
171
|
+
:b24ui="{
|
|
172
|
+
leadingIcon: ['left', 'right'].includes(props?.side) ? 'group-hover:rounded-full group-hover:border-1 group-hover:border-current' : ''
|
|
173
|
+
}"
|
|
174
|
+
v-bind="(typeof close === 'object' ? close as Partial<ButtonProps> : {})"
|
|
175
|
+
:class="b24ui.close({ class: props.b24ui?.close })"
|
|
176
|
+
/>
|
|
177
|
+
</slot>
|
|
178
|
+
</DialogClose>
|
|
179
|
+
</slot>
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
<div :class="b24ui.body({ class: props.b24ui?.body, scrollbarThin: Boolean(props.scrollbarThin) })">
|
|
183
|
+
<slot name="body" />
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<div v-if="!!slots.footer" :class="b24ui.footer({ class: props.b24ui?.footer })">
|
|
187
|
+
<slot name="footer" />
|
|
188
|
+
</div>
|
|
189
|
+
</slot>
|
|
190
|
+
</DialogContent>
|
|
191
|
+
</DialogPortal>
|
|
192
|
+
</DialogRoot>
|
|
193
|
+
</template>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
|
+
import type { ComponentProps } from 'vue-component-type-helpers';
|
|
3
|
+
export type OverlayOptions<OverlayAttrs = Record<string, any>> = {
|
|
4
|
+
defaultOpen?: boolean;
|
|
5
|
+
props?: OverlayAttrs;
|
|
6
|
+
destroyOnClose?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type ManagedOverlayOptionsPrivate<T extends Component> = {
|
|
9
|
+
component?: T;
|
|
10
|
+
id: symbol;
|
|
11
|
+
isMounted: boolean;
|
|
12
|
+
modelValue: boolean;
|
|
13
|
+
resolvePromise?: (value: unknown) => void;
|
|
14
|
+
};
|
|
15
|
+
export type Overlay = OverlayOptions<Component> & ManagedOverlayOptionsPrivate<Component>;
|
|
16
|
+
interface OverlayInstance<T> {
|
|
17
|
+
open: (props?: ComponentProps<T>) => Promise<any>;
|
|
18
|
+
close: (value?: any) => void;
|
|
19
|
+
patch: (props: Partial<ComponentProps<T>>) => void;
|
|
20
|
+
}
|
|
21
|
+
declare function _useOverlay(): {
|
|
22
|
+
overlays: import("vue").ShallowReactive<Overlay[]>;
|
|
23
|
+
open: <T extends Component>(id: symbol, props?: ComponentProps<T>) => Promise<any>;
|
|
24
|
+
close: (id: symbol, value?: any) => void;
|
|
25
|
+
create: <T extends Component>(component: T, _options?: OverlayOptions<ComponentProps<T>>) => OverlayInstance<T>;
|
|
26
|
+
patch: <T extends Component>(id: symbol, props: Partial<ComponentProps<T>>) => void;
|
|
27
|
+
unMount: (id: symbol) => void;
|
|
28
|
+
};
|
|
29
|
+
export declare const useOverlay: typeof _useOverlay;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { shallowReactive, reactive, markRaw } from "vue";
|
|
2
|
+
import { createSharedComposable } from "@vueuse/core";
|
|
3
|
+
function _useOverlay() {
|
|
4
|
+
const overlays = shallowReactive([]);
|
|
5
|
+
const create = (component, _options) => {
|
|
6
|
+
const { props, defaultOpen, destroyOnClose } = _options || {};
|
|
7
|
+
const options = reactive({
|
|
8
|
+
id: Symbol(import.meta.dev ? "useOverlay" : ""),
|
|
9
|
+
modelValue: !!defaultOpen,
|
|
10
|
+
component: markRaw(component),
|
|
11
|
+
isMounted: !!defaultOpen,
|
|
12
|
+
destroyOnClose: !!destroyOnClose,
|
|
13
|
+
props: props || {}
|
|
14
|
+
});
|
|
15
|
+
overlays.push(options);
|
|
16
|
+
return {
|
|
17
|
+
open: (props2) => open(options.id, props2),
|
|
18
|
+
close: (value) => close(options.id, value),
|
|
19
|
+
patch: (props2) => patch(options.id, props2)
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const open = (id, props) => {
|
|
23
|
+
const overlay = getOverlay(id);
|
|
24
|
+
if (props) {
|
|
25
|
+
patch(overlay.id, props);
|
|
26
|
+
}
|
|
27
|
+
overlay.modelValue = true;
|
|
28
|
+
overlay.isMounted = true;
|
|
29
|
+
return new Promise((resolve) => {
|
|
30
|
+
overlay.resolvePromise = resolve;
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
const close = (id, value) => {
|
|
34
|
+
const overlay = getOverlay(id);
|
|
35
|
+
overlay.modelValue = false;
|
|
36
|
+
if (overlay.resolvePromise) {
|
|
37
|
+
overlay.resolvePromise(value);
|
|
38
|
+
overlay.resolvePromise = void 0;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const unMount = (id) => {
|
|
42
|
+
const overlay = getOverlay(id);
|
|
43
|
+
overlay.isMounted = false;
|
|
44
|
+
if (overlay.destroyOnClose) {
|
|
45
|
+
const index = overlays.findIndex((overlay2) => overlay2.id === id);
|
|
46
|
+
overlays.splice(index, 1);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const patch = (id, props) => {
|
|
50
|
+
const overlay = getOverlay(id);
|
|
51
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
52
|
+
overlay.props[key] = value;
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const getOverlay = (id) => {
|
|
56
|
+
const overlay = overlays.find((overlay2) => overlay2.id === id);
|
|
57
|
+
if (!overlay) {
|
|
58
|
+
throw new Error("Overlay not found");
|
|
59
|
+
}
|
|
60
|
+
return overlay;
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
overlays,
|
|
64
|
+
open,
|
|
65
|
+
close,
|
|
66
|
+
create,
|
|
67
|
+
patch,
|
|
68
|
+
unMount
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export const useOverlay = createSharedComposable(_useOverlay);
|
|
@@ -27,6 +27,7 @@ export * from '../components/Select.vue';
|
|
|
27
27
|
export * from '../components/SelectMenu.vue';
|
|
28
28
|
export * from '../components/Separator.vue';
|
|
29
29
|
export * from '../components/Skeleton.vue';
|
|
30
|
+
export * from '../components/Slideover.vue';
|
|
30
31
|
export * from '../components/Switch.vue';
|
|
31
32
|
export * from '../components/Tabs.vue';
|
|
32
33
|
export * from '../components/Textarea.vue';
|
|
@@ -27,6 +27,7 @@ export * from "../components/Select.vue";
|
|
|
27
27
|
export * from "../components/SelectMenu.vue";
|
|
28
28
|
export * from "../components/Separator.vue";
|
|
29
29
|
export * from "../components/Skeleton.vue";
|
|
30
|
+
export * from "../components/Slideover.vue";
|
|
30
31
|
export * from "../components/Switch.vue";
|
|
31
32
|
export * from "../components/Tabs.vue";
|
|
32
33
|
export * from "../components/Textarea.vue";
|
|
@@ -186,7 +186,7 @@ function isLinkActive({ route: linkRoute, isActive, isExactActive }: any) {
|
|
|
186
186
|
return false
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
function resolveLinkClass({ route, isActive, isExactActive }: any) {
|
|
189
|
+
function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
|
|
190
190
|
const active = isLinkActive({ route, isActive, isExactActive })
|
|
191
191
|
|
|
192
192
|
if (props.raw) {
|
|
@@ -200,38 +200,10 @@ function resolveLinkClass({ route, isActive, isExactActive }: any) {
|
|
|
200
200
|
isAction: Boolean(props.isAction)
|
|
201
201
|
})
|
|
202
202
|
}
|
|
203
|
-
|
|
204
|
-
function resolveLinkClassNoRouter() {
|
|
205
|
-
if (props.raw) {
|
|
206
|
-
return [props.class, props.inactiveClass]
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return b24ui.value({
|
|
210
|
-
class: props.class,
|
|
211
|
-
disabled: props.disabled,
|
|
212
|
-
isAction: Boolean(props.isAction)
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Handle navigation without vue-router
|
|
217
|
-
const handleNavigation = (href: string) => {
|
|
218
|
-
if (isExternal.value) {
|
|
219
|
-
window.location.href = href
|
|
220
|
-
} else {
|
|
221
|
-
const [path, hash] = href.split('#')
|
|
222
|
-
|
|
223
|
-
window.location.pathname = path || ''
|
|
224
|
-
if (hash) {
|
|
225
|
-
window.location.hash = hash
|
|
226
|
-
} else {
|
|
227
|
-
window.location.hash = ''
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
203
|
</script>
|
|
232
204
|
|
|
233
205
|
<template>
|
|
234
|
-
<template v-if="hasRouter">
|
|
206
|
+
<template v-if="hasRouter && !isExternal">
|
|
235
207
|
<RouterLink v-slot="{ href, navigate, route: linkRoute, isActive, isExactActive }" v-bind="routerLinkProps" :to="to || '#'" custom>
|
|
236
208
|
<template v-if="custom">
|
|
237
209
|
<slot
|
|
@@ -241,7 +213,7 @@ const handleNavigation = (href: string) => {
|
|
|
241
213
|
type,
|
|
242
214
|
disabled,
|
|
243
215
|
target: props.target ? props.target : undefined,
|
|
244
|
-
href: to ?
|
|
216
|
+
href: to ? href : undefined,
|
|
245
217
|
navigate,
|
|
246
218
|
active: isLinkActive({ route: linkRoute, isActive, isExactActive })
|
|
247
219
|
}"
|
|
@@ -254,7 +226,7 @@ const handleNavigation = (href: string) => {
|
|
|
254
226
|
as,
|
|
255
227
|
type,
|
|
256
228
|
disabled,
|
|
257
|
-
href: to ?
|
|
229
|
+
href: to ? href : undefined,
|
|
258
230
|
navigate
|
|
259
231
|
}"
|
|
260
232
|
:class="resolveLinkClass({ route: linkRoute, isActive: isActive, isExactActive: isExactActive })"
|
|
@@ -272,8 +244,8 @@ const handleNavigation = (href: string) => {
|
|
|
272
244
|
as,
|
|
273
245
|
type,
|
|
274
246
|
disabled,
|
|
275
|
-
href: to
|
|
276
|
-
|
|
247
|
+
href: to,
|
|
248
|
+
target: isExternal ? '_blank' : undefined,
|
|
277
249
|
active: false
|
|
278
250
|
}"
|
|
279
251
|
/>
|
|
@@ -285,10 +257,11 @@ const handleNavigation = (href: string) => {
|
|
|
285
257
|
as,
|
|
286
258
|
type,
|
|
287
259
|
disabled,
|
|
288
|
-
href:
|
|
260
|
+
href: (to as string),
|
|
261
|
+
target: isExternal ? '_blank' : undefined
|
|
289
262
|
}"
|
|
290
|
-
:
|
|
291
|
-
|
|
263
|
+
:is-external="isExternal"
|
|
264
|
+
:class="resolveLinkClass()"
|
|
292
265
|
>
|
|
293
266
|
<slot :active="false" />
|
|
294
267
|
</B24LinkBase>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useAppConfig: () => any;
|
|
@@ -2,7 +2,28 @@ import type { Ref } from 'vue';
|
|
|
2
2
|
import type { NuxtApp } from '#app';
|
|
3
3
|
export { useHead } from '@unhead/vue';
|
|
4
4
|
export { useRoute, useRouter } from 'vue-router';
|
|
5
|
+
export { defineShortcuts } from '../composables/defineShortcuts';
|
|
6
|
+
export { useLocale } from '../composables/useLocale';
|
|
7
|
+
export { useConfetti } from '../composables/useConfetti';
|
|
8
|
+
export { useOverlay } from '../composables/useOverlay';
|
|
9
|
+
export declare const useColorMode: () => {
|
|
10
|
+
forced: boolean;
|
|
11
|
+
preference?: undefined;
|
|
12
|
+
readonly value?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
preference: "light" | "dark" | "system";
|
|
15
|
+
readonly value: import("@vueuse/core").BasicColorMode;
|
|
16
|
+
forced: boolean;
|
|
17
|
+
};
|
|
5
18
|
export declare const useAppConfig: () => any;
|
|
19
|
+
export declare const useCookie: <T = string>(_name: string, _options?: Record<string, any>) => {
|
|
20
|
+
value: Ref<T, T>;
|
|
21
|
+
get: () => T;
|
|
22
|
+
set: () => void;
|
|
23
|
+
update: () => void;
|
|
24
|
+
refresh: () => Promise<Awaited<T>>;
|
|
25
|
+
remove: () => void;
|
|
26
|
+
};
|
|
6
27
|
export declare const useState: <T>(key: string, init: () => T) => Ref<T>;
|
|
7
28
|
export declare function useNuxtApp(): {
|
|
8
29
|
isHydrating: boolean;
|
|
@@ -1,8 +1,47 @@
|
|
|
1
1
|
import { ref } from "vue";
|
|
2
2
|
import appConfig from "#build/app.config";
|
|
3
|
+
import { useColorMode as useColorModeVueUse } from "@vueuse/core";
|
|
3
4
|
export { useHead } from "@unhead/vue";
|
|
4
5
|
export { useRoute, useRouter } from "vue-router";
|
|
6
|
+
export { defineShortcuts } from "../composables/defineShortcuts.js";
|
|
7
|
+
export { useLocale } from "../composables/useLocale.js";
|
|
8
|
+
export { useConfetti } from "../composables/useConfetti.js";
|
|
9
|
+
export { useOverlay } from "../composables/useOverlay.js";
|
|
10
|
+
export const useColorMode = () => {
|
|
11
|
+
if (!appConfig.colorMode) {
|
|
12
|
+
return {
|
|
13
|
+
forced: true
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const { store, system } = useColorModeVueUse();
|
|
17
|
+
return {
|
|
18
|
+
get preference() {
|
|
19
|
+
return store.value === "auto" ? "system" : store.value;
|
|
20
|
+
},
|
|
21
|
+
set preference(value) {
|
|
22
|
+
store.value = value === "system" ? "auto" : value;
|
|
23
|
+
},
|
|
24
|
+
get value() {
|
|
25
|
+
return store.value === "auto" ? system.value : store.value;
|
|
26
|
+
},
|
|
27
|
+
forced: false
|
|
28
|
+
};
|
|
29
|
+
};
|
|
5
30
|
export const useAppConfig = () => appConfig;
|
|
31
|
+
export const useCookie = (_name, _options = {}) => {
|
|
32
|
+
const value = ref(null);
|
|
33
|
+
return {
|
|
34
|
+
value,
|
|
35
|
+
get: () => value.value,
|
|
36
|
+
set: () => {
|
|
37
|
+
},
|
|
38
|
+
update: () => {
|
|
39
|
+
},
|
|
40
|
+
refresh: () => Promise.resolve(value.value),
|
|
41
|
+
remove: () => {
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
6
45
|
const state = {};
|
|
7
46
|
export const useState = (key, init) => {
|
|
8
47
|
if (state[key]) {
|