@bagelink/vue 0.0.726 → 0.0.732
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/components/BglVideo.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/FileUpload.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText2/Toolbar.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText2/index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText2/richtext-types.d.ts +1 -1
- package/dist/components/form/inputs/RichText2/richtext-types.d.ts.map +1 -1
- package/dist/components/lightbox/Lightbox.vue.d.ts.map +1 -1
- package/dist/components/lightbox/index.d.ts.map +1 -1
- package/dist/components/lightbox/lightbox.types.d.ts +1 -0
- package/dist/components/lightbox/lightbox.types.d.ts.map +1 -1
- package/dist/index.cjs +245 -223
- package/dist/index.mjs +246 -224
- package/dist/style.css +104 -91
- package/package.json +1 -1
- package/src/components/BglVideo.vue +6 -3
- package/src/components/form/inputs/FileUpload.vue +15 -1
- package/src/components/form/inputs/RichText2/Toolbar.vue +30 -28
- package/src/components/form/inputs/RichText2/index.vue +38 -2
- package/src/components/form/inputs/RichText2/richtext-types.ts +3 -0
- package/src/components/lightbox/Lightbox.vue +96 -115
- package/src/components/lightbox/index.ts +34 -32
- package/src/components/lightbox/lightbox.types.ts +1 -0
- package/src/styles/modal.css +18 -0
- package/src/components/form/inputs/RichText2/FontWithASyntaxHighlighter-Regular.woff2 +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { Btn, Icon } from '@bagelink/vue'
|
|
2
|
+
import { BglVideo, Btn, Icon } from '@bagelink/vue'
|
|
3
3
|
import { watch } from 'vue'
|
|
4
4
|
import type { LightboxItem } from './lightbox.types'
|
|
5
5
|
|
|
@@ -66,153 +66,134 @@ defineExpose({ open, close })
|
|
|
66
66
|
</script>
|
|
67
67
|
|
|
68
68
|
<template>
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
<
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
<
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
69
|
+
<transition name="fade">
|
|
70
|
+
<div
|
|
71
|
+
v-if="isOpen"
|
|
72
|
+
class="bgl-lightbox-overlay fixed w-100 h-100 flex justify-content-center z-999 inset mx-auto"
|
|
73
|
+
@keydown.esc="close"
|
|
74
|
+
@keydown.left="prev"
|
|
75
|
+
@keydown.right="next"
|
|
76
|
+
@click="close"
|
|
77
|
+
>
|
|
78
|
+
<div class="bgl-lightbox relative vw90 txt-center" @click.stop>
|
|
79
|
+
<Btn flat class="fixed top-1 end-1 color-white" icon="close" @click="close" />
|
|
80
|
+
<div class="bgl-lightbox-item">
|
|
81
|
+
<template v-if="currentItem?.type === 'image'">
|
|
82
|
+
<img :src="currentItem?.src" alt="Preview">
|
|
83
|
+
</template>
|
|
84
|
+
<template v-else-if="currentItem?.type === 'video'">
|
|
85
|
+
<BglVideo
|
|
86
|
+
:src="currentItem?.src"
|
|
87
|
+
autoplay
|
|
88
|
+
controls
|
|
89
|
+
/>
|
|
90
|
+
</template>
|
|
91
|
+
<template v-else-if="currentItem?.type === 'pdf'">
|
|
92
|
+
<embed
|
|
93
|
+
:src="normalizeURL(currentItem?.src)"
|
|
94
|
+
type="application/pdf"
|
|
95
|
+
width="100%"
|
|
96
|
+
height="1080"
|
|
97
|
+
:title="currentItem?.name"
|
|
98
|
+
>
|
|
99
|
+
</template>
|
|
100
|
+
<template v-else>
|
|
101
|
+
<div class="file-info txt-white">
|
|
102
|
+
<p>File: {{ currentItem?.name }}</p>
|
|
103
|
+
<p>Type: {{ currentItem?.type }}</p>
|
|
104
|
+
<a :href="currentItem?.src" target="_blank">Open file</a>
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
</div>
|
|
108
|
+
<div v-if="group && group.length > 1" class="navigation flex space-between w-100 absolute">
|
|
109
|
+
<Btn
|
|
110
|
+
class="navigation-btn oval user-select-none"
|
|
111
|
+
icon="arrow_back"
|
|
112
|
+
@click="prev"
|
|
113
|
+
/>
|
|
114
|
+
<Btn
|
|
115
|
+
class="navigation-btn oval user-select-none"
|
|
116
|
+
icon="arrow_forward"
|
|
117
|
+
@click="next"
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
<div
|
|
121
|
+
v-if="group && group.length > 1"
|
|
122
|
+
class="flex justify-content-center mt-2 overflow
|
|
123
|
+
p-1 fixed bottom start end gap-1 m_justify-content-start"
|
|
122
124
|
>
|
|
123
|
-
<
|
|
124
|
-
v-
|
|
125
|
-
|
|
126
|
-
:src="item.src"
|
|
127
|
-
alt=""
|
|
128
|
-
@click="selectItem(index)"
|
|
125
|
+
<template
|
|
126
|
+
v-for="(item, index) in group"
|
|
127
|
+
:key="index"
|
|
129
128
|
>
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
<img
|
|
130
|
+
v-if="item.type === 'image'"
|
|
131
|
+
class="thumbnail object-fit-cover hover
|
|
132
|
+
opacity-5 round flex bg-white justify-content-center align-items-center flex-shrink-0"
|
|
133
|
+
:src="item.src"
|
|
134
|
+
alt=""
|
|
135
|
+
:class="{ active: currentIndex === index }"
|
|
136
|
+
@click="selectItem(index)"
|
|
137
|
+
>
|
|
138
|
+
<Icon
|
|
139
|
+
v-else
|
|
140
|
+
class="thumbnail object-fit-cover hover
|
|
141
|
+
opacity-5 round flex bg-white justify-content-center align-items-center flex-shrink-0"
|
|
142
|
+
icon="description"
|
|
143
|
+
:class="{ active: currentIndex === index }"
|
|
144
|
+
@click="selectItem(index)"
|
|
145
|
+
/>
|
|
146
|
+
</template>
|
|
147
|
+
</div>
|
|
137
148
|
</div>
|
|
138
149
|
</div>
|
|
139
|
-
</
|
|
150
|
+
</transition>
|
|
140
151
|
</template>
|
|
141
152
|
|
|
142
153
|
<style scoped>
|
|
143
|
-
.lightbox-overlay {
|
|
144
|
-
position: fixed;
|
|
145
|
-
top: 0;
|
|
146
|
-
left: 0;
|
|
147
|
-
width: 100%;
|
|
148
|
-
height: 100%;
|
|
154
|
+
.bgl-lightbox-overlay {
|
|
149
155
|
background: rgba(0, 0, 0, 0.8);
|
|
150
|
-
display: flex;
|
|
151
|
-
justify-content: center;
|
|
152
|
-
align-items: center;
|
|
153
|
-
z-index: 1000;
|
|
154
156
|
}
|
|
155
157
|
|
|
156
|
-
.lightbox {
|
|
157
|
-
position: relative;
|
|
158
|
+
.bgl-lightbox {
|
|
158
159
|
max-height: 90%;
|
|
159
|
-
width: 90vw;
|
|
160
|
-
text-align: center;
|
|
161
160
|
}
|
|
162
161
|
|
|
163
|
-
.
|
|
164
|
-
|
|
165
|
-
top: 1rem;
|
|
166
|
-
inset-inline-end: 1rem;
|
|
162
|
+
.bgl-lightbox-item{
|
|
163
|
+
animation: 500ms ease bgl-lightbox-load;
|
|
167
164
|
}
|
|
165
|
+
@keyframes bgl-lightbox-load {
|
|
166
|
+
from {
|
|
167
|
+
scale:0.7;
|
|
168
|
+
}
|
|
168
169
|
|
|
169
|
-
|
|
170
|
+
to {
|
|
171
|
+
scale:1;
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.bgl-lightbox-item * {
|
|
170
177
|
max-width: 90%;
|
|
171
178
|
max-height: calc(80vh - 90px);
|
|
172
179
|
border-radius: 3px;
|
|
180
|
+
margin: auto;
|
|
181
|
+
animation: 200ms ease bgl-lightbox-load;
|
|
173
182
|
}
|
|
174
183
|
|
|
175
184
|
.navigation {
|
|
176
|
-
display: flex;
|
|
177
|
-
justify-content: space-between;
|
|
178
|
-
width: 100%;
|
|
179
|
-
position: absolute;
|
|
180
185
|
top: 50%;
|
|
181
186
|
transform: translateY(-50%);
|
|
182
187
|
}
|
|
183
188
|
|
|
184
189
|
.navigation-btn {
|
|
185
|
-
user-select: none;
|
|
186
190
|
width: var(--input-height);
|
|
187
191
|
height: var(--input-height);
|
|
188
|
-
border-radius: 100%;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.thumbnails {
|
|
192
|
-
display: flex;
|
|
193
|
-
justify-content: center;
|
|
194
|
-
margin-top: 10px;
|
|
195
|
-
overflow: auto;
|
|
196
|
-
padding: 1rem;
|
|
197
|
-
position: fixed;
|
|
198
|
-
bottom: 0;
|
|
199
|
-
left: 0;
|
|
200
|
-
right: 0;
|
|
201
192
|
}
|
|
202
193
|
|
|
203
194
|
.thumbnail {
|
|
204
195
|
height: 50px;
|
|
205
196
|
width: 50px;
|
|
206
|
-
object-fit: cover;
|
|
207
|
-
margin: 0 5px;
|
|
208
|
-
cursor: pointer;
|
|
209
|
-
opacity: 0.5;
|
|
210
|
-
border-radius: 3px;
|
|
211
|
-
transition: all 200ms ease;
|
|
212
|
-
background-color: white;
|
|
213
|
-
display: flex;
|
|
214
|
-
justify-content: center;
|
|
215
|
-
align-items: center;
|
|
216
197
|
}
|
|
217
198
|
.thumbnail:hover {
|
|
218
199
|
opacity: 1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { App, DirectiveBinding } from 'vue'
|
|
1
|
+
import type { App, Directive, DirectiveBinding } from 'vue'
|
|
2
2
|
import { createApp } from 'vue'
|
|
3
3
|
import { IMAGE_FORMATS_REGEXP, VIDEO_FORMATS_REGEXP } from '@bagelink/vue'
|
|
4
4
|
import Lightbox from './Lightbox.vue'
|
|
@@ -6,44 +6,46 @@ import type { LightboxItem } from './lightbox.types'
|
|
|
6
6
|
|
|
7
7
|
type OpenFunction = (item: LightboxItem, groupItems?: LightboxItem[]) => void
|
|
8
8
|
const groups: Record<string, LightboxItem[]> = {}
|
|
9
|
-
const lightboxDirective = {
|
|
10
|
-
mounted(el: HTMLElement, binding
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
if (!groups[
|
|
15
|
-
const
|
|
16
|
-
groups[
|
|
17
|
-
src,
|
|
18
|
-
type: binding.value.type || determineFileType(src),
|
|
19
|
-
name: binding.value.name || ''
|
|
20
|
-
})
|
|
9
|
+
const lightboxDirective: Directive = {
|
|
10
|
+
mounted(el: HTMLElement, binding) {
|
|
11
|
+
el.classList.add('hover')
|
|
12
|
+
const item = bindingToItem(binding, el)
|
|
13
|
+
if (item.group) {
|
|
14
|
+
if (!groups[item.group]) groups[item.group] = []
|
|
15
|
+
const currentIndex = groups[item.group].findIndex(i => i.src === item.src)
|
|
16
|
+
if (currentIndex === -1) groups[item.group].push(item)
|
|
21
17
|
}
|
|
22
|
-
el.addEventListener('click', (e) => {
|
|
23
|
-
e.stopPropagation()
|
|
24
|
-
const group = binding.value.group || null
|
|
25
|
-
const item: LightboxItem = {
|
|
26
|
-
src: binding.value.src || binding.value,
|
|
27
|
-
type: binding.value.type || determineFileType(binding.value.src || binding.value),
|
|
28
|
-
name: binding.value.name || '',
|
|
29
|
-
thumbnail: binding.value.thumbnail || '',
|
|
30
|
-
}
|
|
31
|
-
const lightboxInstance = createLightboxInstance()
|
|
32
|
-
if (!lightboxInstance || !lightboxInstance.open) return
|
|
33
|
-
if (binding.value.group) {
|
|
34
|
-
if (!groups[binding.value.group]) groups[binding.value.group] = []
|
|
35
|
-
groups[binding.value.group].push(item)
|
|
36
|
-
}
|
|
37
|
-
const open = lightboxInstance.open as OpenFunction
|
|
38
|
-
open(item, groups[group])
|
|
39
|
-
})
|
|
18
|
+
el.addEventListener('click', (e) => { openClickHandler(e, el, binding) })
|
|
40
19
|
},
|
|
20
|
+
unmounted(el: HTMLElement, binding) {
|
|
21
|
+
el.removeEventListener('click', (e) => { openClickHandler(e, el, binding) })
|
|
22
|
+
}
|
|
41
23
|
}
|
|
42
24
|
|
|
25
|
+
function openClickHandler(e: MouseEvent, el: HTMLElement, binding: DirectiveBinding) {
|
|
26
|
+
e.stopPropagation()
|
|
27
|
+
const item = bindingToItem(binding, el)
|
|
28
|
+
const lightboxInstance = createLightboxInstance()
|
|
29
|
+
if (!lightboxInstance || !lightboxInstance.open) return
|
|
30
|
+
const open = lightboxInstance.open as OpenFunction
|
|
31
|
+
const group = item && item.group ? groups[item.group] : undefined
|
|
32
|
+
open(item, group)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function bindingToItem(binding: DirectiveBinding, el: HTMLElement): LightboxItem {
|
|
36
|
+
let { group, src, type, name, thumbnail } = binding.value || {}
|
|
37
|
+
src = src || binding.value || el.getAttribute('src') || ''
|
|
38
|
+
type = type || determineFileType(src)
|
|
39
|
+
return { src, type, name, thumbnail, group }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const youtubeRegex = /youtube\.com|youtu\.be/
|
|
43
|
+
const vimeoRegex = /vimeo\.com/
|
|
44
|
+
|
|
43
45
|
function determineFileType(url: string): string {
|
|
44
46
|
const extension = url.split('.').pop()?.toLowerCase() || ''
|
|
45
47
|
if (IMAGE_FORMATS_REGEXP.test(extension)) return 'image'
|
|
46
|
-
if (VIDEO_FORMATS_REGEXP.test(extension)) return 'video'
|
|
48
|
+
if (VIDEO_FORMATS_REGEXP.test(extension) || youtubeRegex.test(url) || vimeoRegex.test(url)) return 'video'
|
|
47
49
|
if (['pdf'].includes(extension)) return 'pdf'
|
|
48
50
|
return 'unknown'
|
|
49
51
|
}
|
package/src/styles/modal.css
CHANGED
|
@@ -34,6 +34,24 @@
|
|
|
34
34
|
height: fit-content;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
.is-active .modal {
|
|
38
|
+
animation: 200ms ease bgl-modal-animation;
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@keyframes bgl-modal-animation {
|
|
43
|
+
from {
|
|
44
|
+
scale: 0.7;
|
|
45
|
+
transform: translateY(2rem);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
to {
|
|
49
|
+
scale: 1;
|
|
50
|
+
transform: translateY(0);
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
37
55
|
.small-modal .modal {
|
|
38
56
|
max-width: 300px;
|
|
39
57
|
text-align: center;
|