@bagelink/vue 1.2.18 → 1.2.20
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/views/DayView.vue.d.ts.map +1 -1
- package/dist/components/calendar/views/WeekView.vue.d.ts.map +1 -1
- package/dist/components/form/BglMultiStepForm.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
- package/dist/index.cjs +147 -93
- package/dist/index.mjs +147 -93
- package/dist/style.css +75 -117
- package/package.json +1 -1
- package/src/components/calendar/views/DayView.vue +53 -97
- package/src/components/calendar/views/WeekView.vue +1 -2
- package/src/components/form/BglMultiStepForm.vue +63 -2
- package/src/components/form/inputs/DatePicker.vue +33 -28
|
@@ -62,9 +62,62 @@ const computedSchema = computed(
|
|
|
62
62
|
() => useBglSchema({ schema: props.schema })
|
|
63
63
|
)
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
// Filter out steps with vIf conditions that evaluate to false
|
|
66
|
+
const filteredSchema = computed(() => {
|
|
67
|
+
const schema = computedSchema.value
|
|
68
|
+
return schema.filter((step, index) => {
|
|
69
|
+
// Skip steps that have vIf or v-if returning false
|
|
70
|
+
if (step.vIf !== undefined || step['v-if'] !== undefined) {
|
|
71
|
+
const condition = step.vIf ?? step['v-if']
|
|
72
|
+
// If condition is a function, evaluate it with current form data
|
|
73
|
+
if (typeof condition === 'function') {
|
|
74
|
+
return condition(undefined, formData.value)
|
|
75
|
+
}
|
|
76
|
+
// If condition is a boolean, use it directly
|
|
77
|
+
if (typeof condition === 'boolean') {
|
|
78
|
+
return condition
|
|
79
|
+
}
|
|
80
|
+
// If condition is a string, evaluate it (treat non-empty as true)
|
|
81
|
+
if (typeof condition === 'string') {
|
|
82
|
+
return !!condition
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Include steps with no vIf condition or ones that evaluate to true
|
|
86
|
+
return true
|
|
87
|
+
})
|
|
88
|
+
})
|
|
66
89
|
|
|
67
|
-
const
|
|
90
|
+
const numberOfSteps = computed(() => filteredSchema.value.length)
|
|
91
|
+
|
|
92
|
+
// Map the filtered step index to the actual schema index
|
|
93
|
+
const schemaIndexMap = computed(() => {
|
|
94
|
+
const map: number[] = []
|
|
95
|
+
computedSchema.value.forEach((step, index) => {
|
|
96
|
+
const vIfCondition = step.vIf ?? step['v-if']
|
|
97
|
+
let shouldInclude = true
|
|
98
|
+
|
|
99
|
+
if (vIfCondition !== undefined) {
|
|
100
|
+
if (typeof vIfCondition === 'function') {
|
|
101
|
+
shouldInclude = vIfCondition(undefined, formData.value)
|
|
102
|
+
} else if (typeof vIfCondition === 'boolean') {
|
|
103
|
+
shouldInclude = vIfCondition
|
|
104
|
+
} else if (typeof vIfCondition === 'string') {
|
|
105
|
+
shouldInclude = !!vIfCondition
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (shouldInclude) {
|
|
110
|
+
map.push(index)
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
return map
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
// Get current step schema using the mapping
|
|
117
|
+
const currentStepSchema = computed(() => {
|
|
118
|
+
const actualIndex = schemaIndexMap.value[currentStep.value]
|
|
119
|
+
return [computedSchema.value[actualIndex]]
|
|
120
|
+
})
|
|
68
121
|
|
|
69
122
|
const isStepping = ref(false)
|
|
70
123
|
let isSteppingTO: NodeJS.Timeout
|
|
@@ -147,6 +200,14 @@ function reset() {
|
|
|
147
200
|
// }
|
|
148
201
|
}
|
|
149
202
|
|
|
203
|
+
// Re-evaluate filtered steps when formData changes
|
|
204
|
+
watch(() => formData.value, () => {
|
|
205
|
+
// If current step index is now invalid after filtering, reset to first valid step
|
|
206
|
+
if (currentStep.value >= numberOfSteps.value && numberOfSteps.value > 0) {
|
|
207
|
+
currentStep.value = 0
|
|
208
|
+
}
|
|
209
|
+
}, { deep: true })
|
|
210
|
+
|
|
150
211
|
defineExpose({
|
|
151
212
|
submit: handleSubmit,
|
|
152
213
|
validateForm: reportValidity,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { ModeType } from '../../../utils/calendar/typings'
|
|
3
3
|
import { Btn, NumberInput } from '@bagelink/vue'
|
|
4
4
|
import { computed, ref } from 'vue'
|
|
5
5
|
import Time, { WEEK_START_DAY } from '../../../utils/calendar/time'
|
|
@@ -26,7 +26,7 @@ const emit = defineEmits(['update:modelValue'])
|
|
|
26
26
|
|
|
27
27
|
// State
|
|
28
28
|
const currentMonth = ref(new Date())
|
|
29
|
-
const currentView = ref
|
|
29
|
+
const currentView = ref('days')
|
|
30
30
|
|
|
31
31
|
// Time helper instance
|
|
32
32
|
const time = new Time(props.firstDayOfWeek, props.locale)
|
|
@@ -85,7 +85,21 @@ function useCalendarView() {
|
|
|
85
85
|
const currentMonthDays = computed(() => {
|
|
86
86
|
const year = currentMonth.value.getFullYear()
|
|
87
87
|
const month = currentMonth.value.getMonth()
|
|
88
|
-
|
|
88
|
+
|
|
89
|
+
// Get the weeks for the current month
|
|
90
|
+
const weeksInMonth = time.getCalendarMonthSplitInWeeks(year, month)
|
|
91
|
+
|
|
92
|
+
// Always ensure we have 6 rows (42 days) in our calendar
|
|
93
|
+
// If we have less than 6 weeks, add extra week(s) from the next month
|
|
94
|
+
while (weeksInMonth.length < 6) {
|
|
95
|
+
const lastWeek = weeksInMonth[weeksInMonth.length - 1]
|
|
96
|
+
const lastDay = lastWeek[lastWeek.length - 1]
|
|
97
|
+
const nextDay = new Date(lastDay.getFullYear(), lastDay.getMonth(), lastDay.getDate() + 1)
|
|
98
|
+
const nextWeek = time.getCalendarWeekDateObjects(nextDay)
|
|
99
|
+
weeksInMonth.push(nextWeek)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return weeksInMonth.flat()
|
|
89
103
|
})
|
|
90
104
|
|
|
91
105
|
const currentMonthValue = computed(() => ({
|
|
@@ -263,21 +277,21 @@ function selectDate(date: Date | null) {
|
|
|
263
277
|
<div class="calendar-section m_border-none pe-05 m_p-0">
|
|
264
278
|
<div class="flex space-between pb-1">
|
|
265
279
|
<template v-if="currentView === 'days'">
|
|
266
|
-
<Btn flat icon="chevron_left" @click="previousMonth" />
|
|
280
|
+
<Btn flat thin icon="chevron_left" @click="previousMonth" />
|
|
267
281
|
<div class="flex gap-05">
|
|
268
|
-
<Btn flat class="month-btn" @click="currentView = 'months'">
|
|
282
|
+
<Btn flat thin class="month-btn" @click="currentView = 'months'">
|
|
269
283
|
{{ currentMonthValue.formatted.month }}
|
|
270
284
|
</Btn>
|
|
271
|
-
<Btn flat class="year-btn" @click="currentView = 'years'">
|
|
285
|
+
<Btn flat thin class="year-btn" @click="currentView = 'years'">
|
|
272
286
|
{{ currentMonthValue.formatted.year }}
|
|
273
287
|
</Btn>
|
|
274
288
|
</div>
|
|
275
|
-
<Btn flat icon="chevron_right" @click="nextMonth" />
|
|
289
|
+
<Btn flat thin icon="chevron_right" @click="nextMonth" />
|
|
276
290
|
</template>
|
|
277
291
|
<template v-else>
|
|
278
|
-
<Btn flat icon="chevron_left" @click="previousYear" />
|
|
292
|
+
<Btn flat thin icon="chevron_left" @click="previousYear" />
|
|
279
293
|
<span class="month-year">{{ currentMonthValue.formatted.year }}</span>
|
|
280
|
-
<Btn flat icon="chevron_right" @click="nextYear" />
|
|
294
|
+
<Btn flat thin icon="chevron_right" @click="nextYear" />
|
|
281
295
|
</template>
|
|
282
296
|
</div>
|
|
283
297
|
|
|
@@ -309,35 +323,26 @@ function selectDate(date: Date | null) {
|
|
|
309
323
|
</div>
|
|
310
324
|
|
|
311
325
|
<div v-else-if="currentView === 'months'" class="month-grid grid gap-05 p-05">
|
|
312
|
-
<
|
|
326
|
+
<Btn
|
|
313
327
|
v-for="month in months"
|
|
314
328
|
:key="month.value"
|
|
315
|
-
|
|
316
|
-
:
|
|
317
|
-
selected: month.value === currentMonthValue.month,
|
|
318
|
-
disabled: month.disabled,
|
|
319
|
-
}"
|
|
329
|
+
thin
|
|
330
|
+
:flat="month.value !== currentMonthValue.month"
|
|
320
331
|
:disabled="month.disabled"
|
|
332
|
+
:value="month.name"
|
|
321
333
|
@click="selectMonth(month.value)"
|
|
322
|
-
|
|
323
|
-
{{ month.name }}
|
|
324
|
-
</button>
|
|
334
|
+
/>
|
|
325
335
|
</div>
|
|
326
336
|
|
|
327
337
|
<div v-else class="year-grid grid gap-05 p-0">
|
|
328
|
-
<
|
|
338
|
+
<Btn
|
|
329
339
|
v-for="year in years"
|
|
330
|
-
:key="year.value"
|
|
331
|
-
|
|
332
|
-
:class="{
|
|
333
|
-
selected: year.value === currentMonthValue.year,
|
|
334
|
-
disabled: year.disabled,
|
|
335
|
-
}"
|
|
340
|
+
:key="year.value" thin
|
|
341
|
+
:flat="year.value !== currentMonthValue.year"
|
|
336
342
|
:disabled="year.disabled"
|
|
343
|
+
:value="year.value.toString()"
|
|
337
344
|
@click="selectYear(year.value)"
|
|
338
|
-
|
|
339
|
-
{{ year.value }}
|
|
340
|
-
</button>
|
|
345
|
+
/>
|
|
341
346
|
</div>
|
|
342
347
|
</div>
|
|
343
348
|
|