@bagelink/vue 1.4.165 → 1.4.169
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/analytics/BarChart.vue.d.ts.map +1 -1
- package/dist/components/calendar/views/AgendaView.vue.d.ts.map +1 -1
- package/dist/components/calendar/views/MonthView.vue.d.ts.map +1 -1
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/index.d.ts.map +1 -1
- package/dist/composables/useBagel.d.ts +5 -0
- package/dist/composables/useBagel.d.ts.map +1 -0
- package/dist/index.cjs +20 -20
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +20 -20
- package/dist/plugins/bagel.d.ts +1 -2
- package/dist/plugins/bagel.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/analytics/BarChart.vue +21 -26
- package/src/components/calendar/views/AgendaView.vue +5 -4
- package/src/components/calendar/views/DayView.vue +1 -1
- package/src/components/calendar/views/MonthView.vue +9 -1
- package/src/composables/index.ts +1 -0
- package/src/composables/useBagel.ts +21 -0
- package/src/index.ts +1 -2
- package/src/plugins/bagel.ts +6 -7
- package/src/styles/inputs.css +1 -0
- package/src/utils/index.ts +20 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAI1E,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,IAAI,GAAE,MAAY,QAO1D;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,UAMlC;AAED,wBAAgB,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQ3D;AAED,wBAAsB,QAAQ,CAAC,IA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AAa,EAAE,MAAM,cAAc,CAAA;AAM5C,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,sBAsB5C;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,YAAY,GAAE,GAAe,GAAG,GAAG,CAa1F;AAID,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,QAkBpE"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { Icon, Loading } from '@bagelink/vue'
|
|
2
|
+
import { formatDate, Icon, Loading } from '@bagelink/vue'
|
|
3
3
|
import { computed, ref, onMounted, onUnmounted } from 'vue'
|
|
4
4
|
|
|
5
5
|
interface SecondaryValue {
|
|
@@ -61,11 +61,10 @@ const chartData = computed(() => {
|
|
|
61
61
|
|
|
62
62
|
// Use all data without limiting to maxBars
|
|
63
63
|
const maxValue = Math.max(...props.data.map(d => d.value), 1)
|
|
64
|
-
|
|
65
64
|
return props.data.map(item => ({
|
|
66
65
|
...item,
|
|
67
66
|
height: Math.max((item.value / maxValue) * 100, 2), // Minimum height of 2%
|
|
68
|
-
displayLabel: formatDate(item.date)
|
|
67
|
+
displayLabel: formatDate(item.date, 'MMM')
|
|
69
68
|
}))
|
|
70
69
|
})
|
|
71
70
|
|
|
@@ -87,7 +86,7 @@ const getBarOpacity = computed(() => {
|
|
|
87
86
|
|
|
88
87
|
// Animation functions
|
|
89
88
|
function easeOutCubic(t: number): number {
|
|
90
|
-
return 1 -
|
|
89
|
+
return 1 - (1 - t) ** 3
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
function startAnimation() {
|
|
@@ -122,7 +121,7 @@ function setupIntersectionObserver() {
|
|
|
122
121
|
|
|
123
122
|
observer.value = new IntersectionObserver(
|
|
124
123
|
(entries) => {
|
|
125
|
-
entries.forEach(entry => {
|
|
124
|
+
entries.forEach((entry) => {
|
|
126
125
|
if (entry.isIntersecting && !isInView.value) {
|
|
127
126
|
console.log(`👀 TrendChart: Entered viewport, starting animation in ${props.animationStartDelay}ms`)
|
|
128
127
|
isInView.value = true
|
|
@@ -157,14 +156,6 @@ onUnmounted(() => {
|
|
|
157
156
|
}
|
|
158
157
|
})
|
|
159
158
|
|
|
160
|
-
function formatDate(dateStr: string): string {
|
|
161
|
-
const date = new Date(dateStr)
|
|
162
|
-
return date.toLocaleDateString('he-IL', {
|
|
163
|
-
month: 'short',
|
|
164
|
-
day: 'numeric'
|
|
165
|
-
})
|
|
166
|
-
}
|
|
167
|
-
|
|
168
159
|
function formatValue(value: number, isCurrency: boolean = false): string {
|
|
169
160
|
if (isCurrency) {
|
|
170
161
|
return new Intl.NumberFormat('he-IL', {
|
|
@@ -179,8 +170,7 @@ function formatValue(value: number, isCurrency: boolean = false): string {
|
|
|
179
170
|
function formatTooltip(item: any): string {
|
|
180
171
|
const primaryValue = formatValue(item.value, props.currency)
|
|
181
172
|
const primaryText = `${props.prefix}${primaryValue}${props.suffix}`
|
|
182
|
-
|
|
183
|
-
let tooltipLines = [`${item.displayLabel}`, `<b>${primaryText}</b>`]
|
|
173
|
+
const tooltipLines = [`${item.displayLabel}`, `<b>${primaryText}</b>`]
|
|
184
174
|
|
|
185
175
|
if (item.secondaryValues && Array.isArray(item.secondaryValues)) {
|
|
186
176
|
item.secondaryValues.forEach((secondary: SecondaryValue) => {
|
|
@@ -204,27 +194,29 @@ function formatTooltip(item: any): string {
|
|
|
204
194
|
</p>
|
|
205
195
|
</div>
|
|
206
196
|
<div v-if="percentageChange !== 0" class="flex align-center gap-025">
|
|
207
|
-
<Icon
|
|
197
|
+
<Icon
|
|
198
|
+
:name="percentageChange > 0 ? 'trending_up' : 'trending_down'" size="1"
|
|
199
|
+
:class="percentageChange > 0 ? 'color-success' : 'color-danger'"
|
|
200
|
+
/>
|
|
208
201
|
<span class="txt12 bold" :class="percentageChange > 0 ? 'color-success' : 'color-danger'">
|
|
209
202
|
{{ Math.abs(percentageChange) }}%
|
|
210
203
|
</span>
|
|
211
204
|
</div>
|
|
212
205
|
</div>
|
|
213
|
-
<div
|
|
206
|
+
<div
|
|
207
|
+
class="flex w-100p align-items-end mt-auto gap-075 overflow justify-content-start"
|
|
208
|
+
:class="[rtl ? 'rtl' : 'ltr']"
|
|
209
|
+
>
|
|
214
210
|
<div
|
|
215
|
-
v-for="(bar, index) in chartData"
|
|
216
|
-
:
|
|
217
|
-
v-tooltip="{ content: formatTooltip(bar), html: true }"
|
|
218
|
-
class="flex-grow txt-center hover transition-400 relative barWrap mb-1"
|
|
219
|
-
:style="{
|
|
211
|
+
v-for="(bar, index) in chartData" :key="index" v-tooltip="{ content: formatTooltip(bar), html: true }"
|
|
212
|
+
class="flex-grow txt-center hover transition-400 relative barWrap mb-1" :style="{
|
|
220
213
|
width: `max(2rem, ${100 / chartData.length}%)`,
|
|
221
214
|
opacity: getBarOpacity(index),
|
|
222
|
-
transition: animated ? 'opacity 0.3s ease-out' : 'none'
|
|
215
|
+
transition: animated ? 'opacity 0.3s ease-out' : 'none',
|
|
223
216
|
}"
|
|
224
217
|
>
|
|
225
218
|
<div
|
|
226
|
-
class="bar radius-05 transition-400 "
|
|
227
|
-
:style="{
|
|
219
|
+
class="bar radius-05 transition-400 " :style="{
|
|
228
220
|
height: `${bar.height * 1.8}px`,
|
|
229
221
|
background: `linear-gradient(180deg, ${color}60, ${color}30)`,
|
|
230
222
|
minHeight: '4px',
|
|
@@ -250,16 +242,19 @@ function formatTooltip(item: any): string {
|
|
|
250
242
|
font-weight: 300 !important;
|
|
251
243
|
font-size: 12px;
|
|
252
244
|
}
|
|
245
|
+
|
|
253
246
|
.trendTooltip {
|
|
254
247
|
font-weight: 700 !important;
|
|
255
248
|
}
|
|
249
|
+
|
|
256
250
|
.v-popper--theme-tooltip .v-popper__inner:has(.trendTooltip) {
|
|
257
251
|
background-color: var(--bgl-black) !important;
|
|
258
252
|
color: var(--bgl-white) !important;
|
|
259
253
|
border-radius: 0.5rem !important;
|
|
260
254
|
padding: 0.25rem 0.5rem !important;
|
|
261
255
|
}
|
|
262
|
-
|
|
256
|
+
|
|
257
|
+
.bar {
|
|
263
258
|
min-width: 2rem;
|
|
264
259
|
}
|
|
265
260
|
</style>
|
|
@@ -157,7 +157,7 @@ onUnmounted(() => {
|
|
|
157
157
|
:key="event.id"
|
|
158
158
|
class="event"
|
|
159
159
|
:style="{
|
|
160
|
-
|
|
160
|
+
// height: `${event.height}px`,
|
|
161
161
|
backgroundColor: event.color || 'var(--bgl-primary)',
|
|
162
162
|
}"
|
|
163
163
|
:data-date="event.start_time"
|
|
@@ -207,11 +207,11 @@ onUnmounted(() => {
|
|
|
207
207
|
.agenda-content {
|
|
208
208
|
flex-grow: 1;
|
|
209
209
|
overflow-y: auto;
|
|
210
|
-
|
|
210
|
+
padding: 1rem 0;
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
.event {
|
|
214
|
-
|
|
214
|
+
margin-bottom: 0.5rem;
|
|
215
215
|
border-radius: 4px;
|
|
216
216
|
overflow: hidden;
|
|
217
217
|
cursor: pointer;
|
|
@@ -219,7 +219,8 @@ onUnmounted(() => {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
.event:hover {
|
|
222
|
-
|
|
222
|
+
/* transform: scale(1.01); */
|
|
223
|
+
filter: brightness(90%);
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
.event-content {
|
|
@@ -217,13 +217,21 @@ function handleEventSelection(event: CalendarEvent, domEvent?: MouseEvent) {
|
|
|
217
217
|
font-size: 0.8rem;
|
|
218
218
|
cursor: pointer;
|
|
219
219
|
transition: all 0.2s ease;
|
|
220
|
+
display: flex;
|
|
221
|
+
align-items: center;
|
|
222
|
+
gap: 0.25rem;
|
|
223
|
+
min-width: 0;
|
|
224
|
+
justify-content: space-between;
|
|
225
|
+
/* Allow flex items to shrink */
|
|
220
226
|
}
|
|
221
227
|
|
|
222
228
|
.event-title {
|
|
223
229
|
font-weight: 500;
|
|
224
|
-
white-space: nowrap;
|
|
230
|
+
/* white-space: nowrap; */
|
|
231
|
+
height: 1lh;
|
|
225
232
|
overflow: hidden;
|
|
226
233
|
text-overflow: ellipsis;
|
|
234
|
+
|
|
227
235
|
}
|
|
228
236
|
|
|
229
237
|
.event-time {
|
package/src/composables/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { MaybeRefOrGetter, Ref, UnwrapRef } from 'vue'
|
|
|
4
4
|
import { getFallbackSchema } from '@bagelink/vue'
|
|
5
5
|
import { ref, toValue, watch } from 'vue'
|
|
6
6
|
|
|
7
|
+
export { getBagelInstance, setBagelInstance, useBagel } from './useBagel'
|
|
7
8
|
export { useDevice } from './useDevice'
|
|
8
9
|
export { useExcel } from './useExcel'
|
|
9
10
|
export { usePolling } from './usePolling'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Bagel } from '@bagelink/sdk'
|
|
2
|
+
import { shallowRef } from 'vue'
|
|
3
|
+
|
|
4
|
+
// Global state for the Bagel instance (using shallowRef to avoid deep reactivity on class instance)
|
|
5
|
+
const bagelInstance = shallowRef<Bagel | null>(null)
|
|
6
|
+
|
|
7
|
+
export function useBagel(): Bagel {
|
|
8
|
+
const instance = bagelInstance.value
|
|
9
|
+
if (!instance) {
|
|
10
|
+
throw new Error('Bagel instance is not initialized. Please install BagelVue plugin first.')
|
|
11
|
+
}
|
|
12
|
+
return instance
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function setBagelInstance(instance: Bagel) {
|
|
16
|
+
bagelInstance.value = instance
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getBagelInstance(): Bagel | null {
|
|
20
|
+
return bagelInstance.value
|
|
21
|
+
}
|
package/src/index.ts
CHANGED
package/src/plugins/bagel.ts
CHANGED
|
@@ -4,6 +4,7 @@ import FloatingVue from 'floating-vue'
|
|
|
4
4
|
import { inject } from 'vue'
|
|
5
5
|
|
|
6
6
|
import lightboxPlugin from '../components/lightbox/index'
|
|
7
|
+
import { setBagelInstance } from '../composables/useBagel'
|
|
7
8
|
import { ripple, pattern } from '../directives'
|
|
8
9
|
import { useLang } from '../utils'
|
|
9
10
|
import clickOutside from '../utils/clickOutside'
|
|
@@ -11,13 +12,7 @@ import clickOutside from '../utils/clickOutside'
|
|
|
11
12
|
export const bagelInjectionKey = Symbol('bagel') as InjectionKey<Bagel>
|
|
12
13
|
export const i18nTInjectionKey = Symbol('bagel') as InjectionKey<(key: string) => string>
|
|
13
14
|
|
|
14
|
-
export function
|
|
15
|
-
const bagel = inject(injectionKey)
|
|
16
|
-
if (!bagel) throw new Error('No bagel provided')
|
|
17
|
-
return bagel
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function useI18nT(injectionKey: typeof i18nTInjectionKey = i18nTInjectionKey) {
|
|
15
|
+
export function injectI18nT(injectionKey: typeof i18nTInjectionKey = i18nTInjectionKey) {
|
|
21
16
|
const i18nT = inject(injectionKey)
|
|
22
17
|
if (!i18nT) throw new Error('No i18nT provided')
|
|
23
18
|
return i18nT
|
|
@@ -36,6 +31,10 @@ export interface BagelOptions {
|
|
|
36
31
|
export const BagelVue: Plugin<BagelOptions> = {
|
|
37
32
|
install: (app, options) => {
|
|
38
33
|
const bagel = new Bagel({ host: options.host, fileBaseUrl: options.fileBaseUrl, onError: options.onError })
|
|
34
|
+
|
|
35
|
+
// Set global Bagel instance for the composable
|
|
36
|
+
setBagelInstance(bagel)
|
|
37
|
+
|
|
39
38
|
app.directive('click-outside', clickOutside)
|
|
40
39
|
app.directive('ripple', ripple)
|
|
41
40
|
app.directive('pattern', pattern)
|
package/src/styles/inputs.css
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -206,17 +206,32 @@ export { useLang } from './lang'
|
|
|
206
206
|
export { formatString } from './strings'
|
|
207
207
|
export { useDebounceFn } from '@vueuse/core'
|
|
208
208
|
|
|
209
|
-
|
|
210
|
-
const bagelBaseUrl = import.meta.env.VITE_BAGEL_BASE_URL
|
|
209
|
+
import { getBagelInstance } from '../composables/useBagel'
|
|
211
210
|
|
|
212
211
|
const URL_REGEX = /^https?:\/\/|^\/\//
|
|
213
212
|
|
|
214
213
|
export function pathKeyToURL(pathKey?: string) {
|
|
215
|
-
if (
|
|
214
|
+
if (pathKey === undefined || pathKey === '' || URL_REGEX.test(pathKey)) return pathKey
|
|
215
|
+
|
|
216
|
+
const bagel = getBagelInstance()
|
|
217
|
+
if (!bagel) {
|
|
218
|
+
console.warn('Bagel instance is not initialized. Please install BagelVue plugin.')
|
|
219
|
+
return pathKey
|
|
220
|
+
}
|
|
221
|
+
|
|
216
222
|
if (pathKey.startsWith('static/')) {
|
|
217
|
-
|
|
223
|
+
if (bagel.host === undefined || bagel.host === '') {
|
|
224
|
+
console.warn('Bagel host is not configured. Please set it in BagelVue options.')
|
|
225
|
+
return pathKey
|
|
226
|
+
}
|
|
227
|
+
return `${bagel.host}/${pathKey}`
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (bagel.fileBaseUrl === undefined || bagel.fileBaseUrl === '') {
|
|
231
|
+
console.warn('File base URL is not configured. Please set it in BagelVue options.')
|
|
232
|
+
return pathKey
|
|
218
233
|
}
|
|
219
|
-
return `${fileBaseUrl}/${pathKey}`
|
|
234
|
+
return `${bagel.fileBaseUrl}/${pathKey}`
|
|
220
235
|
}
|
|
221
236
|
|
|
222
237
|
export function getNestedValue(obj: any, path?: string, defaultValue: any = undefined): any {
|