@bagelink/vue 0.0.1240 → 0.0.1246
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/Calendar/Index.vue.d.ts +4 -4
- package/dist/components/Calendar/components/header/Header.vue.d.ts +2 -2
- package/dist/components/Calendar/components/header/Header.vue.d.ts.map +1 -1
- package/dist/components/Calendar/components/month/AgendaEventTile.vue.d.ts.map +1 -1
- package/dist/components/Calendar/components/month/AgendaEvents.vue.d.ts.map +1 -1
- package/dist/components/Calendar/components/month/Day.vue.d.ts.map +1 -1
- package/dist/components/Calendar/components/month/Month.vue.d.ts.map +1 -1
- package/dist/components/Calendar/components/week/DayEvent.vue.d.ts.map +1 -1
- package/dist/components/Calendar/components/week/DayTimeline.vue.d.ts.map +1 -1
- package/dist/components/Calendar/language/index.d.ts.map +1 -1
- package/dist/components/Calendar/language/keys.d.ts +6 -0
- package/dist/components/Calendar/language/keys.d.ts.map +1 -1
- package/dist/components/Image.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DatePick.vue.d.ts +1 -1
- package/dist/components/form/inputs/DatePick.vue.d.ts.map +1 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/lightbox/index.d.ts.map +1 -1
- package/dist/composables/useSchemaField.d.ts.map +1 -1
- package/dist/index.cjs +109 -268
- package/dist/index.mjs +110 -269
- package/dist/style.css +94 -77
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Calendar/components/header/Header.vue +29 -29
- package/src/components/Calendar/components/month/AgendaEventTile.vue +35 -28
- package/src/components/Calendar/components/month/AgendaEvents.vue +4 -4
- package/src/components/Calendar/components/month/Day.vue +9 -6
- package/src/components/Calendar/components/month/Month.vue +12 -3
- package/src/components/Calendar/components/partials/EventFlyout.vue +5 -5
- package/src/components/Calendar/components/week/DayEvent.vue +6 -6
- package/src/components/Calendar/components/week/DayTimeline.vue +15 -21
- package/src/components/Calendar/components/week/FullDayEvent.vue +1 -1
- package/src/components/Calendar/components/week/Week.vue +3 -3
- package/src/components/Calendar/language/index.ts +1 -0
- package/src/components/Calendar/language/keys.ts +6 -0
- package/src/components/Image.vue +1 -2
- package/src/components/index.ts +0 -1
- package/src/components/lightbox/index.ts +3 -2
- package/src/composables/useSchemaField.ts +0 -1
- package/src/styles/layout.css +4 -0
- package/src/styles/mobilLayout.css +4 -0
- package/src/utils/index.ts +3 -1
- package/src/components/BglComponent.vue +0 -187
|
@@ -150,7 +150,7 @@ onMounted(() => {
|
|
|
150
150
|
:time="time"
|
|
151
151
|
/>
|
|
152
152
|
</div>
|
|
153
|
-
<div class="calendar-month__weeks h-100p flex-grow flex flex-stretch column space-between
|
|
153
|
+
<div class="calendar-month__weeks h-100p flex-grow flex flex-stretch column space-between">
|
|
154
154
|
<div
|
|
155
155
|
v-for="(week, weekIndex) in month"
|
|
156
156
|
:key="weekIndex"
|
|
@@ -188,7 +188,7 @@ onMounted(() => {
|
|
|
188
188
|
|
|
189
189
|
<div
|
|
190
190
|
v-if="!(config.month?.showEventsOnMobileView === false)"
|
|
191
|
-
class="calendar-month__day_events w-100p pt-1"
|
|
191
|
+
class="calendar-month__day_events w-100p pt-1 m_pb-1"
|
|
192
192
|
>
|
|
193
193
|
<AgendaEvents
|
|
194
194
|
v-if="selectedDay"
|
|
@@ -225,8 +225,17 @@ onMounted(() => {
|
|
|
225
225
|
display: flex;
|
|
226
226
|
flex: 1;
|
|
227
227
|
}
|
|
228
|
-
|
|
229
228
|
.calendar-month__week:first-child {
|
|
230
229
|
border-top: var(--qalendar-border-gray-thin);
|
|
231
230
|
}
|
|
231
|
+
.calendar-root.mode-is-month.qalendar-is-small .calendar-month.h-100p{
|
|
232
|
+
height: auto !important;
|
|
233
|
+
}
|
|
234
|
+
.calendar-root.mode-is-month.qalendar-is-small .calendar-month__weeks{
|
|
235
|
+
display: block !important;
|
|
236
|
+
height: auto !important;
|
|
237
|
+
}
|
|
238
|
+
.calendar-root.mode-is-month.qalendar-is-small .calendar-month__weekday{
|
|
239
|
+
height: 40px !important;
|
|
240
|
+
}
|
|
232
241
|
</style>
|
|
@@ -34,7 +34,7 @@ const eventFlyoutPositionHelper = new EventFlyoutPosition()
|
|
|
34
34
|
|
|
35
35
|
const isVisible = ref(false)
|
|
36
36
|
const top = ref<number | null>(0)
|
|
37
|
-
const
|
|
37
|
+
const insetInlineEnd = ref<number | null>(0)
|
|
38
38
|
const calendarEvent = ref(props.calendarEventProp)
|
|
39
39
|
const flyoutWidth = `${EVENT_FLYOUT_WIDTH}px`
|
|
40
40
|
const colors = EVENT_COLORS
|
|
@@ -85,7 +85,7 @@ const getEventTime = computed(() => {
|
|
|
85
85
|
})
|
|
86
86
|
|
|
87
87
|
const eventFlyoutInlineStyles = computed(() => {
|
|
88
|
-
if (typeof top.value === 'number' && !
|
|
88
|
+
if (typeof top.value === 'number' && !insetInlineEnd.value) {
|
|
89
89
|
return {
|
|
90
90
|
top: `${top.value}px`,
|
|
91
91
|
left: '50%',
|
|
@@ -96,7 +96,7 @@ const eventFlyoutInlineStyles = computed(() => {
|
|
|
96
96
|
|
|
97
97
|
return {
|
|
98
98
|
top: `${top.value}px`,
|
|
99
|
-
|
|
99
|
+
insetInlineEnd: `${insetInlineEnd.value}px`,
|
|
100
100
|
position: 'fixed' as const,
|
|
101
101
|
}
|
|
102
102
|
})
|
|
@@ -132,7 +132,7 @@ function setFlyoutPosition() {
|
|
|
132
132
|
)
|
|
133
133
|
|
|
134
134
|
top.value = typeof flyoutPosition?.top === 'number' ? flyoutPosition.top : null
|
|
135
|
-
|
|
135
|
+
insetInlineEnd.value = typeof flyoutPosition?.left === 'number' ? flyoutPosition.left : null
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
function editEvent() {
|
|
@@ -355,7 +355,7 @@ onBeforeUnmount(() => {
|
|
|
355
355
|
.is-not-editable .event-flyout__menu-close {
|
|
356
356
|
position: absolute;
|
|
357
357
|
top: 0;
|
|
358
|
-
|
|
358
|
+
inset-inline-end: 0;
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
.event-flyout__menu-item {
|
|
@@ -132,12 +132,12 @@ const hasDisabledResize = computed(() => {
|
|
|
132
132
|
})
|
|
133
133
|
|
|
134
134
|
const requiredStyles = computed(() => ({
|
|
135
|
-
top: getPositionInDay(event.value.time.start),
|
|
136
|
-
height: getLengthOfEvent(event.value.time.start, event.value.time.end),
|
|
137
|
-
|
|
138
|
-
width: `${getWidthRule.value}%`,
|
|
139
|
-
transform: eventTransformValue.value,
|
|
140
|
-
zIndex: eventZIndexValue.value,
|
|
135
|
+
'top': getPositionInDay(event.value.time.start),
|
|
136
|
+
'height': getLengthOfEvent(event.value.time.start, event.value.time.end),
|
|
137
|
+
'inset-inline-start': `${getInlineStartRule.value}%`,
|
|
138
|
+
'width': `${getWidthRule.value}%`,
|
|
139
|
+
'transform': eventTransformValue.value,
|
|
140
|
+
'zIndex': eventZIndexValue.value,
|
|
141
141
|
}))
|
|
142
142
|
|
|
143
143
|
// Methods
|
|
@@ -29,13 +29,13 @@ function getLocaleTimeString(time: DAY_TIME_POINT): string {
|
|
|
29
29
|
</script>
|
|
30
30
|
|
|
31
31
|
<template>
|
|
32
|
-
<div class="day-timeline">
|
|
32
|
+
<div class="day-timeline absolute top-0 start-0 space-evenly column display-flex">
|
|
33
33
|
<div
|
|
34
34
|
v-for="hour in timelineHours"
|
|
35
35
|
:key="hour"
|
|
36
|
-
class="day-timeline__hour"
|
|
36
|
+
class="day-timeline__hour display-flex column ustify-content-start h-100p ps-05"
|
|
37
37
|
>
|
|
38
|
-
<span class="day-timeline__hour-text">
|
|
38
|
+
<span class="day-timeline__hour-text line-height-0">
|
|
39
39
|
{{ getLocaleTimeString(hour) }}
|
|
40
40
|
</span>
|
|
41
41
|
</div>
|
|
@@ -44,29 +44,29 @@ function getLocaleTimeString(time: DAY_TIME_POINT): string {
|
|
|
44
44
|
|
|
45
45
|
<style scoped>
|
|
46
46
|
.day-timeline {
|
|
47
|
-
position: absolute;
|
|
48
|
-
top: 0;
|
|
49
|
-
left: 0;
|
|
50
47
|
width: calc(100% + 10px);
|
|
51
48
|
height: v-bind(weekHeight);
|
|
52
49
|
transform: translateX(-10px);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
}
|
|
51
|
+
[dir="rtl"] .day-timeline {
|
|
52
|
+
transform: translateX(10px);
|
|
53
|
+
}
|
|
54
|
+
[dir="rtl"] .ltr .day-timeline {
|
|
55
|
+
transform: translateX(-10px);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
.day-timeline__hour {
|
|
59
|
-
padding-left: 4px;
|
|
60
|
-
display: flex;
|
|
61
|
-
flex-flow: column;
|
|
62
|
-
justify-content: flex-start;
|
|
63
|
-
height: 100%;
|
|
64
59
|
font-size: clamp(10px, 0.625rem, 14px);
|
|
65
60
|
color: var(--qalendar-gray-quite-dark);
|
|
66
61
|
}
|
|
67
62
|
|
|
68
63
|
.day-timeline__hour-text {
|
|
69
|
-
|
|
64
|
+
transform: translate(-40px, 0);
|
|
65
|
+
}
|
|
66
|
+
[dir="rtl"] .day-timeline__hour-text {
|
|
67
|
+
transform: translate(40px, 0);
|
|
68
|
+
}
|
|
69
|
+
[dir="rtl"] .ltr .day-timeline__hour-text {
|
|
70
70
|
transform: translate(-40px, 0);
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -77,10 +77,4 @@ function getLocaleTimeString(time: DAY_TIME_POINT): string {
|
|
|
77
77
|
.day-timeline__hour:not(:last-child) {
|
|
78
78
|
border-bottom: var(--qalendar-border-gray-thin);
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
@media (prefers-color-scheme: dark) {
|
|
82
|
-
.day-timeline__hour:not(:last-child) {
|
|
83
|
-
border-color: var(--qalendar-dark-mode-line-color);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
80
|
</style>
|
|
@@ -365,7 +365,7 @@ function setCurrentTime() {
|
|
|
365
365
|
<style scoped>
|
|
366
366
|
.calendar-week__wrapper {
|
|
367
367
|
position: relative;
|
|
368
|
-
padding-
|
|
368
|
+
padding-inline-start: var(--qalendar-week-padding-left);
|
|
369
369
|
overflow-y: auto;
|
|
370
370
|
}
|
|
371
371
|
|
|
@@ -384,7 +384,7 @@ function setCurrentTime() {
|
|
|
384
384
|
|
|
385
385
|
.calendar-week .current-time-line {
|
|
386
386
|
position: absolute;
|
|
387
|
-
|
|
387
|
+
inset-inline-start: 0;
|
|
388
388
|
width: 100%;
|
|
389
389
|
height: 2px;
|
|
390
390
|
z-index: 1;
|
|
@@ -407,7 +407,7 @@ function setCurrentTime() {
|
|
|
407
407
|
|
|
408
408
|
.calendar-week .custom-current-time {
|
|
409
409
|
position: absolute;
|
|
410
|
-
|
|
410
|
+
inset-inline-start: 0;
|
|
411
411
|
width: 100%;
|
|
412
412
|
z-index: 1;
|
|
413
413
|
}
|
|
@@ -16,6 +16,7 @@ export const languageKeys = {
|
|
|
16
16
|
'ja-JP': '週',
|
|
17
17
|
'pl-PL': 'Tydzień',
|
|
18
18
|
'hu-HU': 'Hét',
|
|
19
|
+
'he-IL': 'שבוע',
|
|
19
20
|
},
|
|
20
21
|
month: {
|
|
21
22
|
'it-IT': 'Mese',
|
|
@@ -33,6 +34,7 @@ export const languageKeys = {
|
|
|
33
34
|
'ja-JP': '月',
|
|
34
35
|
'pl-PL': 'Miesiąc',
|
|
35
36
|
'hu-HU': 'Hónap',
|
|
37
|
+
'he-IL': 'חודש',
|
|
36
38
|
},
|
|
37
39
|
day: {
|
|
38
40
|
'it-IT': 'Giorno',
|
|
@@ -50,9 +52,11 @@ export const languageKeys = {
|
|
|
50
52
|
'ja-JP': '日',
|
|
51
53
|
'pl-PL': 'Dzień',
|
|
52
54
|
'hu-HU': 'Nap',
|
|
55
|
+
'he-IL': 'יום',
|
|
53
56
|
},
|
|
54
57
|
agenda: {
|
|
55
58
|
'en-US': 'Agenda',
|
|
59
|
+
'he-IL': 'סדר יום',
|
|
56
60
|
},
|
|
57
61
|
/** Other keys */
|
|
58
62
|
moreEvents: {
|
|
@@ -71,6 +75,7 @@ export const languageKeys = {
|
|
|
71
75
|
'ja-JP': 'その他イベント',
|
|
72
76
|
'pl-PL': '+ więcej wydarzeń',
|
|
73
77
|
'hu-HU': 'További események',
|
|
78
|
+
'he-IL': '+ עוד אירועים',
|
|
74
79
|
},
|
|
75
80
|
|
|
76
81
|
noEvent: {
|
|
@@ -89,5 +94,6 @@ export const languageKeys = {
|
|
|
89
94
|
'ja-JP': 'イベントなし',
|
|
90
95
|
'pl-PL': 'Brak wydarzeń',
|
|
91
96
|
'hu-HU': 'Nincs esemény',
|
|
97
|
+
'he-IL': 'אין אירועים',
|
|
92
98
|
},
|
|
93
99
|
}
|
package/src/components/Image.vue
CHANGED
|
@@ -24,8 +24,7 @@ let loadingError = $ref(false)
|
|
|
24
24
|
|
|
25
25
|
function getImageUrl(): string | null {
|
|
26
26
|
if (!props.src && !props.pathKey) return null
|
|
27
|
-
|
|
28
|
-
return pathKeyToURL(props.pathKey)
|
|
27
|
+
return pathKeyToURL(props.src || props.pathKey)
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
async function getCachedImage(url: string): Promise<string | null> {
|
package/src/components/index.ts
CHANGED
|
@@ -4,7 +4,6 @@ export { default as AddressSearch } from './AddressSearch.vue'
|
|
|
4
4
|
export { default as Alert } from './Alert.vue'
|
|
5
5
|
export { default as Avatar } from './Avatar.vue'
|
|
6
6
|
export { default as Badge } from './Badge.vue'
|
|
7
|
-
export { default as BglComponent } from './BglComponent.vue'
|
|
8
7
|
export { default as BglVideo } from './BglVideo.vue'
|
|
9
8
|
export { default as Btn } from './Btn.vue'
|
|
10
9
|
// export { default as CalendarExample } from './Calendar/CalendarExample.vue'
|
|
@@ -49,7 +49,7 @@ function openClickHandler(e: MouseEvent, el: HTMLElement, binding: DirectiveBind
|
|
|
49
49
|
|
|
50
50
|
function bindingToItem(binding: DirectiveBinding, el: HTMLElement): LightboxItem {
|
|
51
51
|
let { group, src, type, name, thumbnail, enableZoom, openFile, download, pathKey } = binding.value || {}
|
|
52
|
-
src = src ||
|
|
52
|
+
src = pathKeyToURL(src || pathKey) || binding.value || el.getAttribute('src') || ''
|
|
53
53
|
type = type || determineFileType(src)
|
|
54
54
|
name = name || urlToName(src) || el.getAttribute('alt') || ''
|
|
55
55
|
return { src, type, name, thumbnail, group, enableZoom, openFile, download }
|
|
@@ -67,7 +67,8 @@ function urlToName(url: string): string {
|
|
|
67
67
|
function determineFileType(url: string): string {
|
|
68
68
|
if (!url) return 'unknown'
|
|
69
69
|
const extension = (url.split('.').pop() || '').toLowerCase()
|
|
70
|
-
|
|
70
|
+
const altExtension = url.split('?')[0].split('.').pop()?.toLowerCase() || ''
|
|
71
|
+
if (IMAGE_FORMATS_REGEXP.test(extension) || IMAGE_FORMATS_REGEXP.test(altExtension)) return 'image'
|
|
71
72
|
if (VIDEO_FORMATS_REGEXP.test(extension) || youtubeRegex.test(url) || vimeoRegex.test(url)) return 'video'
|
|
72
73
|
if (['pdf'].includes(extension)) return 'pdf'
|
|
73
74
|
return extension ?? 'unknown'
|
package/src/styles/layout.css
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -173,7 +173,9 @@ const fileBaseUrl = (import.meta.env.VITE_FILE_BASE_URL || 'https://files.bagel.
|
|
|
173
173
|
const bagelBaseUrl = import.meta.env.VITE_BAGEL_BASE_URL
|
|
174
174
|
|
|
175
175
|
export function pathKeyToURL(pathKey?: string) {
|
|
176
|
-
|
|
176
|
+
const urlRE = /^https?:\/\/|^\/\//
|
|
177
|
+
if (!pathKey || urlRE.test(pathKey)) return pathKey
|
|
178
|
+
if (pathKey.startsWith('static/')) {
|
|
177
179
|
return `${bagelBaseUrl}/${pathKey}`
|
|
178
180
|
}
|
|
179
181
|
return `${fileBaseUrl}/${pathKey}`
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts" generic="T extends Record<string, any>">
|
|
2
|
-
import type { Field } from '@bagelink/vue'
|
|
3
|
-
import {
|
|
4
|
-
CheckInput,
|
|
5
|
-
DateInput,
|
|
6
|
-
FieldArray,
|
|
7
|
-
|
|
8
|
-
FileUpload,
|
|
9
|
-
RichText,
|
|
10
|
-
SelectInput,
|
|
11
|
-
TextInput,
|
|
12
|
-
ToggleInput,
|
|
13
|
-
bindAttrs,
|
|
14
|
-
classify,
|
|
15
|
-
NumberInput,
|
|
16
|
-
UploadInput,
|
|
17
|
-
BglForm,
|
|
18
|
-
TabsNav
|
|
19
|
-
} from '@bagelink/vue'
|
|
20
|
-
|
|
21
|
-
const props = defineProps<{
|
|
22
|
-
field: Field<T>
|
|
23
|
-
id?: string
|
|
24
|
-
modelValue?: any
|
|
25
|
-
parentPath?: string
|
|
26
|
-
}>()
|
|
27
|
-
|
|
28
|
-
const emit = defineEmits<{
|
|
29
|
-
'update:modelValue': [value: any]
|
|
30
|
-
}>()
|
|
31
|
-
|
|
32
|
-
const customAttrs = $ref<{ [key: string]: any }>({})
|
|
33
|
-
|
|
34
|
-
const is = $computed(() => {
|
|
35
|
-
if (props.field.$el === 'text') return TextInput
|
|
36
|
-
if (props.field.$el === 'textarea') {
|
|
37
|
-
customAttrs.multiline = true
|
|
38
|
-
return TextInput
|
|
39
|
-
}
|
|
40
|
-
if (props.field.$el === 'number') return NumberInput
|
|
41
|
-
if (props.field.$el === 'array') return FieldArray
|
|
42
|
-
if (props.field.$el === 'select') return SelectInput
|
|
43
|
-
if (props.field.$el === 'toggle') return ToggleInput
|
|
44
|
-
if (props.field.$el === 'check') return CheckInput
|
|
45
|
-
if (props.field.$el === 'richtext') return RichText
|
|
46
|
-
if (props.field.$el === 'upload') return UploadInput
|
|
47
|
-
if (props.field.$el === 'file') return FileUpload
|
|
48
|
-
if (props.field.$el === 'date') return DateInput
|
|
49
|
-
if (props.field.$el === 'tabs') return TabsNav
|
|
50
|
-
if (props.field.$el === 'form') return BglForm
|
|
51
|
-
return props.field.$el ?? 'div'
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
function getFieldData(path?: string) {
|
|
55
|
-
if (!path) return ''
|
|
56
|
-
const keys = path.split(/[.[]/)
|
|
57
|
-
let current = props.modelValue as any
|
|
58
|
-
|
|
59
|
-
for (let i = 0; i < keys.length; i++) {
|
|
60
|
-
const key = keys[i]
|
|
61
|
-
if (!current || typeof current !== 'object' || !(key in current)) {
|
|
62
|
-
return ''
|
|
63
|
-
}
|
|
64
|
-
current = current[key]
|
|
65
|
-
}
|
|
66
|
-
return current ?? ''
|
|
67
|
-
}
|
|
68
|
-
function safeClone(obj: any): any {
|
|
69
|
-
if (obj === null || typeof obj !== 'object') return obj
|
|
70
|
-
|
|
71
|
-
const seen = new WeakSet()
|
|
72
|
-
return JSON.parse(JSON.stringify(obj, (key, value) => {
|
|
73
|
-
if (typeof value === 'object' && value !== null) {
|
|
74
|
-
if (seen.has(value)) {
|
|
75
|
-
return undefined // Remove circular reference
|
|
76
|
-
}
|
|
77
|
-
seen.add(value)
|
|
78
|
-
}
|
|
79
|
-
return value
|
|
80
|
-
}))
|
|
81
|
-
}
|
|
82
|
-
function updateField(path: string, value: any) {
|
|
83
|
-
const keys = path.split(/[.[]/)
|
|
84
|
-
|
|
85
|
-
let current = props.modelValue ?? {} as any
|
|
86
|
-
|
|
87
|
-
// Build the path, ensuring each level is an object
|
|
88
|
-
for (let i = 0; i < keys.length - 1; i++) {
|
|
89
|
-
const key = keys[i]
|
|
90
|
-
if (!(key in current) || typeof current[key] !== 'object' || current[key] === null) {
|
|
91
|
-
current[key] = {}
|
|
92
|
-
}
|
|
93
|
-
current = current[key]
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Safely clone the value to remove circular references
|
|
97
|
-
const safeValue = safeClone(value)
|
|
98
|
-
current[keys[keys.length - 1]] = safeValue
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const fieldData = $computed({
|
|
102
|
-
get: () => {
|
|
103
|
-
if (!props.id) return props.modelValue ?? props.field.defaultValue ?? (props.field.$el === 'form' ? {} : '')
|
|
104
|
-
const value = getFieldData(props.id)
|
|
105
|
-
if (props.field.$el === 'form' && !value) return {}
|
|
106
|
-
return value ?? ''
|
|
107
|
-
},
|
|
108
|
-
set: (val: any) => {
|
|
109
|
-
if (!props.id) return
|
|
110
|
-
const currentValue = getFieldData(props.id)
|
|
111
|
-
if (JSON.stringify(val) === JSON.stringify(currentValue)) return
|
|
112
|
-
|
|
113
|
-
emit('update:modelValue', val)
|
|
114
|
-
if (props.field.onUpdate) {
|
|
115
|
-
props.field.onUpdate(val, currentValue)
|
|
116
|
-
}
|
|
117
|
-
updateField(props.id, val)
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
const computedFieldData = $computed(
|
|
122
|
-
() => props.field.transform?.(fieldData, props.modelValue as T) ?? fieldData
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
const vIf = $computed(() => {
|
|
126
|
-
if (props.field['v-if'] === undefined && props.field.vIf === undefined) return true
|
|
127
|
-
if (typeof props.field['v-if'] === 'boolean' || typeof props.field.vIf === 'boolean') return props.field['v-if']
|
|
128
|
-
if (typeof props.field['v-if'] === 'string' || typeof props.field.vIf === 'string') return true
|
|
129
|
-
if (typeof props.field['v-if'] === 'function') return props.field['v-if'](fieldData, props.modelValue as T)
|
|
130
|
-
if (typeof props.field.vIf === 'function') return props.field.vIf(fieldData, props.modelValue as T)
|
|
131
|
-
return true
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
const computedOptions = $computed(
|
|
135
|
-
() => bindAttrs({ options: props.field.options }, fieldData, props.modelValue).options
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
const computedAttrs = $computed(() => {
|
|
139
|
-
const attrs = { ...customAttrs, ...props.field.attrs }
|
|
140
|
-
const boundAttrs = bindAttrs(attrs, fieldData, props.modelValue)
|
|
141
|
-
return Object.fromEntries(
|
|
142
|
-
Object.entries(boundAttrs).filter(([_, value]) => value !== undefined)
|
|
143
|
-
)
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
const computedClass = $computed(
|
|
147
|
-
() => classify(fieldData, props.modelValue, props.field.class, props.field.attrs?.class)
|
|
148
|
-
)
|
|
149
|
-
</script>
|
|
150
|
-
|
|
151
|
-
<template>
|
|
152
|
-
<component
|
|
153
|
-
v-bind="computedAttrs"
|
|
154
|
-
:is="is"
|
|
155
|
-
v-if="vIf"
|
|
156
|
-
:id="props.id"
|
|
157
|
-
v-model="fieldData"
|
|
158
|
-
:required="field.required"
|
|
159
|
-
:class="computedClass"
|
|
160
|
-
:label="field.label"
|
|
161
|
-
:placeholder="field.placeholder || field.label"
|
|
162
|
-
:defaultValue="field.defaultValue"
|
|
163
|
-
:disabled="field.disabled"
|
|
164
|
-
:options="computedOptions"
|
|
165
|
-
:helptext="field.helptext"
|
|
166
|
-
:schema="field.attrs?.schema ?? undefined"
|
|
167
|
-
>
|
|
168
|
-
<template v-if="field.$el === 'form'">
|
|
169
|
-
<slot />
|
|
170
|
-
</template>
|
|
171
|
-
<template v-else>
|
|
172
|
-
{{ computedFieldData }}
|
|
173
|
-
<template
|
|
174
|
-
v-for="(child, ii) in field.children"
|
|
175
|
-
:key="ii"
|
|
176
|
-
>
|
|
177
|
-
<BglComponent
|
|
178
|
-
v-if="(typeof child !== 'string')"
|
|
179
|
-
:id="[props.id, child.id].filter(Boolean).join('.')"
|
|
180
|
-
:field="child"
|
|
181
|
-
:parent-path="props.id"
|
|
182
|
-
/>
|
|
183
|
-
<span v-else>{{ child }}</span>
|
|
184
|
-
</template>
|
|
185
|
-
</template>
|
|
186
|
-
</component>
|
|
187
|
-
</template>
|