@bagelink/vue 1.5.15 → 1.5.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/bin/experimentalGenTypedRoutes.ts +15 -15
- package/bin/generateFormSchema.ts +12 -12
- package/bin/utils.ts +4 -4
- package/dist/components/Dropdown.vue.d.ts.map +1 -1
- package/dist/components/RouterWrapper.vue.d.ts.map +1 -1
- package/dist/components/calendar/CalendarPopover.vue.d.ts.map +1 -1
- package/dist/components/form/BagelForm.vue.d.ts.map +1 -1
- package/dist/components/form/FieldArray.vue.d.ts +5 -4
- package/dist/components/form/FieldArray.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/CheckInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/index.vue.d.ts +1 -0
- package/dist/components/form/inputs/RichText/index.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ToggleInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/Upload/UploadInput.vue.d.ts.map +1 -1
- package/dist/composables/useFormField.d.ts.map +1 -1
- package/dist/composables/useSchemaField.d.ts.map +1 -1
- package/dist/index.cjs +68 -55
- package/dist/index.mjs +34035 -143
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/AccordionItem.vue +2 -2
- package/src/components/AddToCalendar.vue +1 -1
- package/src/components/BglVideo.vue +8 -8
- package/src/components/Btn.vue +9 -9
- package/src/components/Card.vue +4 -4
- package/src/components/Carousel.vue +44 -44
- package/src/components/DataPreview.vue +1 -1
- package/src/components/DragOver.vue +6 -6
- package/src/components/Dropdown.vue +14 -14
- package/src/components/Flag.vue +3 -3
- package/src/components/Icon/Icon.vue +13 -13
- package/src/components/Image.vue +4 -4
- package/src/components/ImportData.vue +79 -79
- package/src/components/ListItem.vue +7 -7
- package/src/components/MapEmbed/Index.vue +6 -6
- package/src/components/Modal.vue +10 -10
- package/src/components/ModalForm.vue +4 -4
- package/src/components/NavBar.vue +2 -2
- package/src/components/Pagination.vue +9 -9
- package/src/components/Pill.vue +1 -1
- package/src/components/Rating.vue +2 -2
- package/src/components/RouterWrapper.vue +3 -3
- package/src/components/Slider.vue +77 -77
- package/src/components/Spreadsheet/Index.vue +34 -34
- package/src/components/Spreadsheet/SpreadsheetTable.vue +3 -3
- package/src/components/Zoomer.vue +28 -28
- package/src/components/analytics/BarChart.vue +6 -6
- package/src/components/analytics/KpiCard.vue +2 -2
- package/src/components/analytics/LineChart.vue +14 -14
- package/src/components/analytics/PieChart.vue +11 -11
- package/src/components/calendar/CalendarPopover.vue +1 -1
- package/src/components/calendar/Index.vue +1 -1
- package/src/components/calendar/views/AgendaView.vue +2 -2
- package/src/components/calendar/views/DayView.vue +6 -6
- package/src/components/calendar/views/MonthView.vue +2 -2
- package/src/components/calendar/views/WeekView.vue +18 -18
- package/src/components/dataTable/DataTable.vue +3 -3
- package/src/components/dataTable/useSorting.ts +1 -1
- package/src/components/dataTable/useTableData.ts +15 -15
- package/src/components/dataTable/useTableSelection.ts +8 -8
- package/src/components/dataTable/useTableVirtualization.ts +1 -1
- package/src/components/draggable/useDraggable.ts +42 -42
- package/src/components/form/BagelForm.vue +66 -23
- package/src/components/form/BglMultiStepForm.vue +18 -18
- package/src/components/form/FieldArray.vue +177 -67
- package/src/components/form/inputs/CheckInput.vue +2 -1
- package/src/components/form/inputs/CodeEditor/Index.vue +1 -1
- package/src/components/form/inputs/CodeEditor/format.ts +7 -7
- package/src/components/form/inputs/CodeEditor/useHighlight.ts +6 -6
- package/src/components/form/inputs/DateInput.vue +6 -6
- package/src/components/form/inputs/DatePicker.vue +19 -19
- package/src/components/form/inputs/EmailInput.vue +14 -14
- package/src/components/form/inputs/NumberInput.vue +6 -6
- package/src/components/form/inputs/OTP.vue +3 -3
- package/src/components/form/inputs/RadioGroup.vue +1 -1
- package/src/components/form/inputs/RadioPillsInput.vue +8 -8
- package/src/components/form/inputs/RichText/components/EditorToolbar.vue +10 -10
- package/src/components/form/inputs/RichText/components/TableGridSelector.vue +1 -1
- package/src/components/form/inputs/RichText/composables/useCommands.ts +1 -1
- package/src/components/form/inputs/RichText/composables/useEditor.ts +12 -12
- package/src/components/form/inputs/RichText/composables/useEditorKeyboard.ts +1 -1
- package/src/components/form/inputs/RichText/index.vue +300 -132
- package/src/components/form/inputs/RichText/utils/commands.ts +69 -69
- package/src/components/form/inputs/RichText/utils/debug.ts +1 -1
- package/src/components/form/inputs/RichText/utils/formatting.ts +39 -39
- package/src/components/form/inputs/RichText/utils/media.ts +6 -6
- package/src/components/form/inputs/RichText/utils/selection.ts +28 -28
- package/src/components/form/inputs/RichText/utils/table.ts +19 -19
- package/src/components/form/inputs/SelectBtn.vue +1 -1
- package/src/components/form/inputs/SelectInput.vue +50 -26
- package/src/components/form/inputs/SignaturePad.vue +15 -15
- package/src/components/form/inputs/TableField.vue +1 -1
- package/src/components/form/inputs/TelInput.vue +6 -6
- package/src/components/form/inputs/TextInput.vue +5 -5
- package/src/components/form/inputs/ToggleInput.vue +2 -1
- package/src/components/form/inputs/Upload/UploadInput.vue +155 -102
- package/src/components/form/inputs/Upload/upload.ts +1 -1
- package/src/components/form/inputs/Upload/useFileUpload.ts +6 -6
- package/src/components/form/useBagelFormState.ts +5 -5
- package/src/components/layout/AppContent.vue +1 -1
- package/src/components/layout/AppLayout.vue +1 -1
- package/src/components/layout/Layout.vue +4 -4
- package/src/components/layout/TabbedLayout.vue +1 -1
- package/src/components/layout/Tabs.vue +2 -2
- package/src/components/layout/TabsNav.vue +7 -7
- package/src/components/lightbox/Lightbox.vue +8 -8
- package/src/components/lightbox/index.ts +8 -8
- package/src/composables/index.ts +2 -2
- package/src/composables/useAddToCalendar.ts +13 -13
- package/src/composables/useDevice.ts +2 -2
- package/src/composables/useExcel.ts +6 -6
- package/src/composables/useFormField.ts +5 -9
- package/src/composables/usePolling.ts +8 -8
- package/src/composables/useSchemaField.ts +53 -38
- package/src/composables/useTheme.ts +9 -9
- package/src/composables/useValidateFieldValue.ts +2 -2
- package/src/directives/pattern.ts +25 -25
- package/src/directives/ripple.ts +4 -4
- package/src/directives/vResize.ts +6 -6
- package/src/plugins/bagel.ts +4 -4
- package/src/plugins/useModal.ts +3 -3
- package/src/styles/layout.css +7 -1
- package/src/utils/BagelFormUtils.ts +7 -7
- package/src/utils/calendar/Helpers.ts +8 -8
- package/src/utils/calendar/dateUtils.ts +22 -22
- package/src/utils/calendar/time.ts +25 -25
- package/src/utils/calendar/week.ts +25 -25
- package/src/utils/elementUtils.ts +27 -27
- package/src/utils/index.ts +22 -22
- package/src/utils/sizeParsing.ts +2 -2
- package/src/utils/strings.ts +5 -5
- package/src/utils/tapDetector.ts +11 -11
- package/src/utils/useSearch.ts +29 -29
- package/vite.config.ts +1 -1
|
@@ -57,7 +57,7 @@ export default class Time {
|
|
|
57
57
|
const dayEnd = Time.getHourFromTimePoints(this.DAY_END)
|
|
58
58
|
const dayStart = Time.getHourFromTimePoints(this.DAY_START)
|
|
59
59
|
|
|
60
|
-
if (dayEnd > dayStart) return dayEnd - dayStart
|
|
60
|
+
if (dayEnd > dayStart) {return dayEnd - dayStart}
|
|
61
61
|
|
|
62
62
|
return this.HOURS_PER_DAY - dayStart + dayEnd
|
|
63
63
|
})()
|
|
@@ -65,9 +65,9 @@ export default class Time {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
get dayMode() {
|
|
68
|
-
if (this.DAY_START
|
|
68
|
+
if (0 === this.DAY_START && 2400 === this.DAY_END) {return DAY_MODE.REGULAR}
|
|
69
69
|
|
|
70
|
-
if (this.DAY_START >= this.DAY_END) return DAY_MODE.FLEXIBLE
|
|
70
|
+
if (this.DAY_START >= this.DAY_END) {return DAY_MODE.FLEXIBLE}
|
|
71
71
|
|
|
72
72
|
return DAY_MODE.SHORTENED
|
|
73
73
|
}
|
|
@@ -86,13 +86,13 @@ export default class Time {
|
|
|
86
86
|
getCalendarWeekDateObjects(date: Date): calendarWeekType {
|
|
87
87
|
// If week starts on Sunday, we can get the first date of the week, by simply counting selectedDate.getDate() - selectedDate.getDay()
|
|
88
88
|
let subtractedDaysToGetFirstDate
|
|
89
|
-
if (this.FIRST_DAY_OF_WEEK
|
|
89
|
+
if ('sunday' === this.FIRST_DAY_OF_WEEK) {
|
|
90
90
|
subtractedDaysToGetFirstDate = date.getDay()
|
|
91
91
|
}
|
|
92
92
|
// However, if week starts on Monday, we need to make sure Mondays are represented as 0, instead of Sundays
|
|
93
93
|
else {
|
|
94
94
|
subtractedDaysToGetFirstDate
|
|
95
|
-
= date.getDay()
|
|
95
|
+
= 0 === date.getDay() ? 6 : date.getDay() - 1
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
const dateOfFirstDayOfWeek = date.getDate() - subtractedDaysToGetFirstDate // First date of week is the date of the month - the day of the week
|
|
@@ -163,7 +163,7 @@ export default class Time {
|
|
|
163
163
|
const yearList: calendarYearMonths = []
|
|
164
164
|
let month = 0
|
|
165
165
|
|
|
166
|
-
while (
|
|
166
|
+
while (11 >= month) {
|
|
167
167
|
yearList.push(new Date(year, month, 1))
|
|
168
168
|
month++
|
|
169
169
|
}
|
|
@@ -176,10 +176,10 @@ export default class Time {
|
|
|
176
176
|
let hour = '0'
|
|
177
177
|
let minutes = '0'
|
|
178
178
|
|
|
179
|
-
if (time.length
|
|
179
|
+
if (4 === time.length) {
|
|
180
180
|
hour = time[0] + time[1]
|
|
181
181
|
minutes = time[2] + time[3]
|
|
182
|
-
} else if (time.length
|
|
182
|
+
} else if (3 === time.length) {
|
|
183
183
|
hour = time[0]
|
|
184
184
|
minutes = time[1] + time[2]
|
|
185
185
|
}
|
|
@@ -209,7 +209,7 @@ export default class Time {
|
|
|
209
209
|
hour: '2-digit',
|
|
210
210
|
})
|
|
211
211
|
|
|
212
|
-
if (
|
|
212
|
+
if ('0' === hourLocaleString[0]) {return hourLocaleString.substring(1)}
|
|
213
213
|
|
|
214
214
|
return hourLocaleString
|
|
215
215
|
}
|
|
@@ -247,18 +247,18 @@ export default class Time {
|
|
|
247
247
|
const y = date.getFullYear()
|
|
248
248
|
const m = date.getMonth() + 1
|
|
249
249
|
const d = date.getDate()
|
|
250
|
-
const fullDate = `${y}-${
|
|
250
|
+
const fullDate = `${y}-${ 10 <= m ? m : `0${m}`}-${ 10 <= d ? d : `0${d}`}`
|
|
251
251
|
|
|
252
252
|
if (!timeIsStartOrEndOfDay) {
|
|
253
253
|
const hour = date.getHours()
|
|
254
254
|
const minutes = date.getMinutes()
|
|
255
255
|
|
|
256
|
-
return `${fullDate} ${
|
|
257
|
-
|
|
256
|
+
return `${fullDate} ${ 10 <= hour ? hour : `0${hour}`}:${
|
|
257
|
+
10 <= minutes ? minutes : `0${minutes}`
|
|
258
258
|
}`
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
const fullTime =
|
|
261
|
+
const fullTime = 'start' === timeIsStartOrEndOfDay ? '00:00' : '23:59'
|
|
262
262
|
|
|
263
263
|
return `${fullDate} ${fullTime}`
|
|
264
264
|
}
|
|
@@ -331,7 +331,7 @@ export default class Time {
|
|
|
331
331
|
const monthIsSame = month === weekDay.getMonth()
|
|
332
332
|
const yearIsSame = fullYear === weekDay.getFullYear()
|
|
333
333
|
|
|
334
|
-
if (dateIsSame && monthIsSame && yearIsSame) return true
|
|
334
|
+
if (dateIsSame && monthIsSame && yearIsSame) {return true}
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
return false
|
|
@@ -342,7 +342,7 @@ export default class Time {
|
|
|
342
342
|
const mm = (date.getMonth() + 1)
|
|
343
343
|
const dd = date.getDate()
|
|
344
344
|
|
|
345
|
-
return `${yyyy}-${
|
|
345
|
+
return `${yyyy}-${ 10 <= mm ? mm : `0${mm}`}-${ 10 <= dd ? dd : `0${dd}`}`
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
addMinutesToDateTimeString(minutes: number, dateTimeString: string) {
|
|
@@ -387,7 +387,7 @@ export default class Time {
|
|
|
387
387
|
const oneMinutePercentage = 100 / 60
|
|
388
388
|
const minutePoints = oneMinutePercentage * minutes
|
|
389
389
|
|
|
390
|
-
if (
|
|
390
|
+
if (10 > minutePoints) {return `0${minutePoints}`}
|
|
391
391
|
|
|
392
392
|
return minutePoints.toString()
|
|
393
393
|
}
|
|
@@ -430,8 +430,8 @@ export default class Time {
|
|
|
430
430
|
clickOffsetY: number,
|
|
431
431
|
weekHeight: number,
|
|
432
432
|
): string {
|
|
433
|
-
if (
|
|
434
|
-
if (
|
|
433
|
+
if (0 >= weekHeight) {throw new Error('weekHeight cannot be a negative number')}
|
|
434
|
+
if (0 > clickOffsetY) {throw new Error('clickOffsetY cannot be a negative number')}
|
|
435
435
|
|
|
436
436
|
const dayStartHour = this.DAY_START / 100
|
|
437
437
|
const hourHeight = weekHeight / this.HOURS_PER_DAY
|
|
@@ -454,7 +454,7 @@ export default class Time {
|
|
|
454
454
|
}
|
|
455
455
|
|
|
456
456
|
setSegmentOfDateTimeString(dateTimeString: string, segments: { hour: number }) {
|
|
457
|
-
if (segments.hour
|
|
457
|
+
if (0 > segments.hour || 23 < segments.hour) {throw new Error('Invalid hour')}
|
|
458
458
|
const newHour = this.doubleDigit(segments.hour)
|
|
459
459
|
dateTimeString = dateTimeString.replace(/\d{2}:/, `${newHour}:`)
|
|
460
460
|
|
|
@@ -469,21 +469,21 @@ export default class Time {
|
|
|
469
469
|
}
|
|
470
470
|
|
|
471
471
|
static getTimePointsFromHour(boundary: number) {
|
|
472
|
-
if (
|
|
472
|
+
if (0 > boundary || 24 < boundary || 0 !== boundary % 1) {
|
|
473
473
|
throw new Error('Invalid day boundary')
|
|
474
474
|
}
|
|
475
475
|
|
|
476
|
-
if (
|
|
476
|
+
if (0 === boundary) {return boundary}
|
|
477
477
|
|
|
478
478
|
return boundary * 100
|
|
479
479
|
}
|
|
480
480
|
|
|
481
481
|
static getHourFromTimePoints(timePoints: number) {
|
|
482
|
-
if (
|
|
482
|
+
if (0 > timePoints || 2400 < timePoints || 0 !== timePoints % 100) {
|
|
483
483
|
throw new Error('Invalid time points')
|
|
484
484
|
}
|
|
485
485
|
|
|
486
|
-
if (
|
|
486
|
+
if (0 === timePoints) {return timePoints}
|
|
487
487
|
|
|
488
488
|
return timePoints / 100
|
|
489
489
|
}
|
|
@@ -559,9 +559,9 @@ export default class Time {
|
|
|
559
559
|
}
|
|
560
560
|
|
|
561
561
|
doubleDigit(number: number) {
|
|
562
|
-
if (
|
|
562
|
+
if (0 > number || 60 < number) {throw new Error('Invalid number. This is not a valid hour or minute')}
|
|
563
563
|
|
|
564
|
-
return
|
|
564
|
+
return 10 > number ? `0${number}` : String(number)
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
567
|
|
|
@@ -57,7 +57,7 @@ export default class Time {
|
|
|
57
57
|
const dayEnd = Time.getHourFromTimePoints(this.DAY_END)
|
|
58
58
|
const dayStart = Time.getHourFromTimePoints(this.DAY_START)
|
|
59
59
|
|
|
60
|
-
if (dayEnd > dayStart) return dayEnd - dayStart
|
|
60
|
+
if (dayEnd > dayStart) {return dayEnd - dayStart}
|
|
61
61
|
|
|
62
62
|
return this.HOURS_PER_DAY - dayStart + dayEnd
|
|
63
63
|
})()
|
|
@@ -65,9 +65,9 @@ export default class Time {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
get dayMode() {
|
|
68
|
-
if (this.DAY_START
|
|
68
|
+
if (0 === this.DAY_START && 2400 === this.DAY_END) {return DAY_MODE.REGULAR}
|
|
69
69
|
|
|
70
|
-
if (this.DAY_START >= this.DAY_END) return DAY_MODE.FLEXIBLE
|
|
70
|
+
if (this.DAY_START >= this.DAY_END) {return DAY_MODE.FLEXIBLE}
|
|
71
71
|
|
|
72
72
|
return DAY_MODE.SHORTENED
|
|
73
73
|
}
|
|
@@ -86,13 +86,13 @@ export default class Time {
|
|
|
86
86
|
getCalendarWeekDateObjects(date: Date): calendarWeekType {
|
|
87
87
|
// If week starts on Sunday, we can get the first date of the week, by simply counting selectedDate.getDate() - selectedDate.getDay()
|
|
88
88
|
let subtractedDaysToGetFirstDate
|
|
89
|
-
if (this.FIRST_DAY_OF_WEEK
|
|
89
|
+
if ('sunday' === this.FIRST_DAY_OF_WEEK) {
|
|
90
90
|
subtractedDaysToGetFirstDate = date.getDay()
|
|
91
91
|
}
|
|
92
92
|
// However, if week starts on Monday, we need to make sure Mondays are represented as 0, instead of Sundays
|
|
93
93
|
else {
|
|
94
94
|
subtractedDaysToGetFirstDate
|
|
95
|
-
= date.getDay()
|
|
95
|
+
= 0 === date.getDay() ? 6 : date.getDay() - 1
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
const dateOfFirstDayOfWeek = date.getDate() - subtractedDaysToGetFirstDate // First date of week is the date of the month - the day of the week
|
|
@@ -163,7 +163,7 @@ export default class Time {
|
|
|
163
163
|
const yearList: calendarYearMonths = []
|
|
164
164
|
let month = 0
|
|
165
165
|
|
|
166
|
-
while (
|
|
166
|
+
while (11 >= month) {
|
|
167
167
|
yearList.push(new Date(year, month, 1))
|
|
168
168
|
month++
|
|
169
169
|
}
|
|
@@ -176,10 +176,10 @@ export default class Time {
|
|
|
176
176
|
let hour = '0'
|
|
177
177
|
let minutes = '0'
|
|
178
178
|
|
|
179
|
-
if (time.length
|
|
179
|
+
if (4 === time.length) {
|
|
180
180
|
hour = time[0] + time[1]
|
|
181
181
|
minutes = time[2] + time[3]
|
|
182
|
-
} else if (time.length
|
|
182
|
+
} else if (3 === time.length) {
|
|
183
183
|
hour = time[0]
|
|
184
184
|
minutes = time[1] + time[2]
|
|
185
185
|
}
|
|
@@ -209,7 +209,7 @@ export default class Time {
|
|
|
209
209
|
hour: '2-digit',
|
|
210
210
|
})
|
|
211
211
|
|
|
212
|
-
if (
|
|
212
|
+
if ('0' === hourLocaleString[0]) {return hourLocaleString.substring(1)}
|
|
213
213
|
|
|
214
214
|
return hourLocaleString
|
|
215
215
|
}
|
|
@@ -247,18 +247,18 @@ export default class Time {
|
|
|
247
247
|
const y = date.getFullYear()
|
|
248
248
|
const m = date.getMonth() + 1
|
|
249
249
|
const d = date.getDate()
|
|
250
|
-
const fullDate = `${y}-${
|
|
250
|
+
const fullDate = `${y}-${ 10 <= m ? m : `0${m}`}-${ 10 <= d ? d : `0${d}`}`
|
|
251
251
|
|
|
252
252
|
if (!timeIsStartOrEndOfDay) {
|
|
253
253
|
const hour = date.getHours()
|
|
254
254
|
const minutes = date.getMinutes()
|
|
255
255
|
|
|
256
|
-
return `${fullDate} ${
|
|
257
|
-
|
|
256
|
+
return `${fullDate} ${ 10 <= hour ? hour : `0${hour}`}:${
|
|
257
|
+
10 <= minutes ? minutes : `0${minutes}`
|
|
258
258
|
}`
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
const fullTime =
|
|
261
|
+
const fullTime = 'start' === timeIsStartOrEndOfDay ? '00:00' : '23:59'
|
|
262
262
|
|
|
263
263
|
return `${fullDate} ${fullTime}`
|
|
264
264
|
}
|
|
@@ -331,7 +331,7 @@ export default class Time {
|
|
|
331
331
|
const monthIsSame = month === weekDay.getMonth()
|
|
332
332
|
const yearIsSame = fullYear === weekDay.getFullYear()
|
|
333
333
|
|
|
334
|
-
if (dateIsSame && monthIsSame && yearIsSame) return true
|
|
334
|
+
if (dateIsSame && monthIsSame && yearIsSame) {return true}
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
return false
|
|
@@ -342,7 +342,7 @@ export default class Time {
|
|
|
342
342
|
const mm = (date.getMonth() + 1)
|
|
343
343
|
const dd = date.getDate()
|
|
344
344
|
|
|
345
|
-
return `${yyyy}-${
|
|
345
|
+
return `${yyyy}-${ 10 <= mm ? mm : `0${mm}`}-${ 10 <= dd ? dd : `0${dd}`}`
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
addMinutesToDateTimeString(minutes: number, dateTimeString: string) {
|
|
@@ -387,7 +387,7 @@ export default class Time {
|
|
|
387
387
|
const oneMinutePercentage = 100 / 60
|
|
388
388
|
const minutePoints = oneMinutePercentage * minutes
|
|
389
389
|
|
|
390
|
-
if (
|
|
390
|
+
if (10 > minutePoints) {return `0${minutePoints}`}
|
|
391
391
|
|
|
392
392
|
return minutePoints.toString()
|
|
393
393
|
}
|
|
@@ -430,8 +430,8 @@ export default class Time {
|
|
|
430
430
|
clickOffsetY: number,
|
|
431
431
|
weekHeight: number,
|
|
432
432
|
): string {
|
|
433
|
-
if (
|
|
434
|
-
if (
|
|
433
|
+
if (0 >= weekHeight) {throw new Error('weekHeight cannot be a negative number')}
|
|
434
|
+
if (0 > clickOffsetY) {throw new Error('clickOffsetY cannot be a negative number')}
|
|
435
435
|
|
|
436
436
|
const dayStartHour = this.DAY_START / 100
|
|
437
437
|
const hourHeight = weekHeight / this.HOURS_PER_DAY
|
|
@@ -454,7 +454,7 @@ export default class Time {
|
|
|
454
454
|
}
|
|
455
455
|
|
|
456
456
|
setSegmentOfDateTimeString(dateTimeString: string, segments: { hour: number }) {
|
|
457
|
-
if (segments.hour
|
|
457
|
+
if (0 > segments.hour || 23 < segments.hour) {throw new Error('Invalid hour')}
|
|
458
458
|
const newHour = this.doubleDigit(segments.hour)
|
|
459
459
|
dateTimeString = dateTimeString.replace(/\d{2}:/, `${newHour}:`)
|
|
460
460
|
|
|
@@ -469,21 +469,21 @@ export default class Time {
|
|
|
469
469
|
}
|
|
470
470
|
|
|
471
471
|
static getTimePointsFromHour(boundary: number) {
|
|
472
|
-
if (
|
|
472
|
+
if (0 > boundary || 24 < boundary || 0 !== boundary % 1) {
|
|
473
473
|
throw new Error('Invalid day boundary')
|
|
474
474
|
}
|
|
475
475
|
|
|
476
|
-
if (
|
|
476
|
+
if (0 === boundary) {return boundary}
|
|
477
477
|
|
|
478
478
|
return boundary * 100
|
|
479
479
|
}
|
|
480
480
|
|
|
481
481
|
static getHourFromTimePoints(timePoints: number) {
|
|
482
|
-
if (
|
|
482
|
+
if (0 > timePoints || 2400 < timePoints || 0 !== timePoints % 100) {
|
|
483
483
|
throw new Error('Invalid time points')
|
|
484
484
|
}
|
|
485
485
|
|
|
486
|
-
if (
|
|
486
|
+
if (0 === timePoints) {return timePoints}
|
|
487
487
|
|
|
488
488
|
return timePoints / 100
|
|
489
489
|
}
|
|
@@ -559,9 +559,9 @@ export default class Time {
|
|
|
559
559
|
}
|
|
560
560
|
|
|
561
561
|
doubleDigit(number: number) {
|
|
562
|
-
if (
|
|
562
|
+
if (0 > number || 60 < number) {throw new Error('Invalid number. This is not a valid hour or minute')}
|
|
563
563
|
|
|
564
|
-
return
|
|
564
|
+
return 10 > number ? `0${number}` : String(number)
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
567
|
|
|
@@ -146,7 +146,7 @@ export function btn<
|
|
|
146
146
|
let icon: IconType | undefined
|
|
147
147
|
let finalOptions: BtnElementOptions<T, PO> = {}
|
|
148
148
|
|
|
149
|
-
if (
|
|
149
|
+
if ('object' === typeof idOrOptions && null !== idOrOptions) {
|
|
150
150
|
// btn(options)
|
|
151
151
|
finalOptions = idOrOptions
|
|
152
152
|
const { id: optionId, text: optionText, icon: optionIcon } = finalOptions
|
|
@@ -156,15 +156,15 @@ export function btn<
|
|
|
156
156
|
} else {
|
|
157
157
|
// btn(id, ...) patterns
|
|
158
158
|
id = idOrOptions
|
|
159
|
-
if (
|
|
159
|
+
if (null != textOrIcon) {
|
|
160
160
|
// Check if textOrIcon is likely an icon vs text
|
|
161
161
|
// Icons are typically: lowercase, contain hyphens/underscores, no spaces, shorter length
|
|
162
|
-
const isLikelyIcon = typeof textOrIcon
|
|
163
|
-
&& textOrIcon.length
|
|
162
|
+
const isLikelyIcon = 'string' === typeof textOrIcon
|
|
163
|
+
&& 30 >= textOrIcon.length
|
|
164
164
|
&& !textOrIcon.includes(' ')
|
|
165
165
|
&& (textOrIcon.includes('-')
|
|
166
166
|
|| textOrIcon.includes('_')
|
|
167
|
-
|| textOrIcon.length
|
|
167
|
+
|| 12 >= textOrIcon.length)
|
|
168
168
|
&& textOrIcon === textOrIcon.toLowerCase()
|
|
169
169
|
|
|
170
170
|
if (isLikelyIcon) {
|
|
@@ -231,7 +231,7 @@ export function iconBtn<
|
|
|
231
231
|
icon?: IconType,
|
|
232
232
|
options?: BtnElementOptions<T, PO>,
|
|
233
233
|
): BaseElementField<T, PO> {
|
|
234
|
-
if (
|
|
234
|
+
if (null != icon && null != id) {
|
|
235
235
|
return btn(id, icon, options || {})
|
|
236
236
|
}
|
|
237
237
|
return btn({ id, icon, ...options } as BtnElementOptions<T, PO>)
|
|
@@ -279,7 +279,7 @@ export function txt<
|
|
|
279
279
|
let id: Path<T, PO> | undefined
|
|
280
280
|
let finalOptions: TxtElementOptions<T, PO> = {}
|
|
281
281
|
|
|
282
|
-
if (
|
|
282
|
+
if ('object' === typeof idOrOptions && null !== idOrOptions) {
|
|
283
283
|
// txt(options)
|
|
284
284
|
finalOptions = idOrOptions
|
|
285
285
|
const { id: optionId } = finalOptions
|
|
@@ -287,8 +287,8 @@ export function txt<
|
|
|
287
287
|
} else {
|
|
288
288
|
// txt(id, ...) patterns
|
|
289
289
|
id = idOrOptions
|
|
290
|
-
if (
|
|
291
|
-
if (typeof tagOrOptions
|
|
290
|
+
if (null != text) {
|
|
291
|
+
if ('string' === typeof tagOrOptions) {
|
|
292
292
|
// txt(id, text, tag)
|
|
293
293
|
finalOptions = { tag: tagOrOptions as any, text }
|
|
294
294
|
} else if (tagOrOptions) {
|
|
@@ -355,7 +355,7 @@ export function img<
|
|
|
355
355
|
let id: Path<T, PO> | undefined
|
|
356
356
|
let finalOptions: ImgElementOptions<T, PO> = {}
|
|
357
357
|
|
|
358
|
-
if (
|
|
358
|
+
if ('object' === typeof idOrOptions && null !== idOrOptions) {
|
|
359
359
|
// img(options)
|
|
360
360
|
finalOptions = idOrOptions
|
|
361
361
|
const { id: optionId } = finalOptions
|
|
@@ -363,8 +363,8 @@ export function img<
|
|
|
363
363
|
} else {
|
|
364
364
|
// img(id, ...) patterns
|
|
365
365
|
id = idOrOptions
|
|
366
|
-
if (
|
|
367
|
-
if (typeof altOrOptions
|
|
366
|
+
if (null != src) {
|
|
367
|
+
if ('string' === typeof altOrOptions) {
|
|
368
368
|
// img(id, src, alt)
|
|
369
369
|
finalOptions = { alt: altOrOptions }
|
|
370
370
|
} else if (altOrOptions) {
|
|
@@ -416,11 +416,11 @@ export function dropdown<
|
|
|
416
416
|
let opts: DropdownElementOptions<T, PO> | undefined
|
|
417
417
|
let children: BaseElementField<T, PO>[] = []
|
|
418
418
|
|
|
419
|
-
if (args.length
|
|
419
|
+
if (0 < args.length) {
|
|
420
420
|
const firstArg = args[0] as DropdownElementOptions<T, PO> | BaseElementField<T, PO>
|
|
421
421
|
if (
|
|
422
|
-
|
|
423
|
-
&&
|
|
422
|
+
'object' === typeof firstArg
|
|
423
|
+
&& null !== firstArg
|
|
424
424
|
&& ('$el' in (firstArg as Record<string, unknown>))
|
|
425
425
|
) {
|
|
426
426
|
children = args as BaseElementField<T, PO>[]
|
|
@@ -431,15 +431,15 @@ export function dropdown<
|
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
const attrs: Record<string, unknown> = {}
|
|
434
|
-
if (opts?.attrs) Object.assign(attrs, opts.attrs)
|
|
434
|
+
if (opts?.attrs) {Object.assign(attrs, opts.attrs)}
|
|
435
435
|
if (opts) {
|
|
436
|
-
if (opts.options
|
|
437
|
-
if (opts.placeholder
|
|
438
|
-
if (opts.searchable
|
|
439
|
-
if (opts.multiselect
|
|
440
|
-
if (opts.clearable
|
|
441
|
-
if (opts.onSelect
|
|
442
|
-
if (opts.onSearch
|
|
436
|
+
if (null != opts.options) {attrs.options = opts.options}
|
|
437
|
+
if (null != opts.placeholder) {attrs.placeholder = opts.placeholder}
|
|
438
|
+
if (null != opts.searchable) {attrs.searchable = opts.searchable}
|
|
439
|
+
if (null != opts.multiselect) {attrs.multiselect = opts.multiselect}
|
|
440
|
+
if (null != opts.clearable) {attrs.clearable = opts.clearable}
|
|
441
|
+
if (null != opts.onSelect) {attrs.onSelect = opts.onSelect}
|
|
442
|
+
if (null != opts.onSearch) {attrs.onSearch = opts.onSearch}
|
|
443
443
|
}
|
|
444
444
|
|
|
445
445
|
return {
|
|
@@ -506,10 +506,10 @@ export function findElementById<T>(
|
|
|
506
506
|
elements: BaseElementField<T, any>[]
|
|
507
507
|
): BaseElementField<T, any> | undefined {
|
|
508
508
|
for (const element of elements) {
|
|
509
|
-
if (element.id === id) return element
|
|
510
|
-
if (element.children && element.children.length
|
|
509
|
+
if (element.id === id) {return element}
|
|
510
|
+
if (element.children && 0 < element.children.length) {
|
|
511
511
|
const child = findElementById(id, element.children)
|
|
512
|
-
if (child) return child
|
|
512
|
+
if (child) {return child}
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
515
|
return undefined
|
|
@@ -521,7 +521,7 @@ export function column<T = any, P extends Path<T, PO> = any, PO extends PathsOpt
|
|
|
521
521
|
options?: Partial<BaseElementField<T, PO>>,
|
|
522
522
|
): BaseElementField<T, PO> {
|
|
523
523
|
let label: string | undefined
|
|
524
|
-
if (typeof labelOrOptions
|
|
524
|
+
if ('string' === typeof labelOrOptions) {
|
|
525
525
|
label = labelOrOptions
|
|
526
526
|
} else {
|
|
527
527
|
options = labelOrOptions
|
package/src/utils/index.ts
CHANGED
|
@@ -20,7 +20,7 @@ export function slugify(str: string) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export function keyToLabel(key?: string): string | undefined {
|
|
23
|
-
if (key === undefined) return key
|
|
23
|
+
if (key === undefined) {return key}
|
|
24
24
|
return (
|
|
25
25
|
key
|
|
26
26
|
.split('_')
|
|
@@ -31,7 +31,7 @@ export function keyToLabel(key?: string): string | undefined {
|
|
|
31
31
|
|
|
32
32
|
export async function copyText(text: string, cb?: (msg: string) => void) {
|
|
33
33
|
await navigator.clipboard.writeText(text)
|
|
34
|
-
if (cb) cb('Copied to clipboard')
|
|
34
|
+
if (cb) {cb('Copied to clipboard')}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export function initials(...strArr: string[]) {
|
|
@@ -40,7 +40,7 @@ export function initials(...strArr: string[]) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export function useEscape(event: KeyboardEvent, closeModel: () => void) {
|
|
43
|
-
if (event.key
|
|
43
|
+
if ('Escape' === event.key) {
|
|
44
44
|
closeModel()
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -48,7 +48,7 @@ export function useEscape(event: KeyboardEvent, closeModel: () => void) {
|
|
|
48
48
|
export function classify(fieldVal?: any, row?: any, ...classes: any[]) {
|
|
49
49
|
return classes
|
|
50
50
|
.map((cls) => {
|
|
51
|
-
if (typeof cls
|
|
51
|
+
if ('function' === typeof cls) {return cls(fieldVal, row)}
|
|
52
52
|
return cls
|
|
53
53
|
})
|
|
54
54
|
.join(' ')
|
|
@@ -60,14 +60,14 @@ export function bindAttrs<T, P extends Path<T>>(
|
|
|
60
60
|
row?: T
|
|
61
61
|
) {
|
|
62
62
|
// TODO: Fix this so that you don't have to return a fn for other on* event handlers
|
|
63
|
-
if (!attrs) return {}
|
|
63
|
+
if (!attrs) {return {}}
|
|
64
64
|
|
|
65
65
|
const exclude = ['class', 'onClick', '$el'] as const
|
|
66
66
|
const arr = Object.entries(attrs)
|
|
67
67
|
.filter(([key]) => !exclude.includes(key as typeof exclude[number]))
|
|
68
68
|
.map(([key, value]) => [
|
|
69
69
|
key,
|
|
70
|
-
|
|
70
|
+
'function' === typeof value ? value(fieldVal, row) : value,
|
|
71
71
|
])
|
|
72
72
|
|
|
73
73
|
const resolvedAttrs: { [key: string]: any } = Object.fromEntries(arr)
|
|
@@ -84,16 +84,16 @@ export function bindAttrs<T, P extends Path<T>>(
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
export function iffer(field: any, itemData: any) {
|
|
87
|
-
if (field['v-if'] === undefined) return true
|
|
88
|
-
if (typeof field['v-if']
|
|
89
|
-
if (typeof field['v-if']
|
|
90
|
-
if (typeof field['v-if']
|
|
91
|
-
return field['v-if']?.(itemData?.[field.id], itemData)
|
|
87
|
+
if (field['v-if'] === undefined) {return true}
|
|
88
|
+
if ('boolean' === typeof field['v-if']) {return field['v-if']}
|
|
89
|
+
if ('string' === typeof field['v-if']) {return true}
|
|
90
|
+
if ('function' === typeof field['v-if'])
|
|
91
|
+
{return field['v-if']?.(itemData?.[field.id], itemData)}
|
|
92
92
|
return true
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
export function denullify(itemData?: { [key: string]: any }, fieldID?: string) {
|
|
96
|
-
if (!fieldID) return undefined
|
|
96
|
+
if (!fieldID) {return undefined}
|
|
97
97
|
return itemData ? itemData[fieldID] : undefined
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -110,7 +110,7 @@ export function getFallbackSchema<T>(
|
|
|
110
110
|
label: keyToLabel(id),
|
|
111
111
|
transform: (val: any) => {
|
|
112
112
|
const dateFields = ['created_at', 'updated_at']
|
|
113
|
-
if (dateFields.includes(id)) return val ? new Date(val).toLocaleString() : val
|
|
113
|
+
if (dateFields.includes(id)) {return val ? new Date(val).toLocaleString() : val}
|
|
114
114
|
return val
|
|
115
115
|
},
|
|
116
116
|
})) as BglFormSchemaT<T>
|
|
@@ -133,13 +133,13 @@ export async function appendScript(src: string, options?: { id?: string }): Prom
|
|
|
133
133
|
// If this script is already loading, return the existing promise
|
|
134
134
|
if (scriptsLoading.has(scriptId)) {
|
|
135
135
|
const existingPromise = scriptsLoading.get(scriptId)
|
|
136
|
-
if (existingPromise) return existingPromise
|
|
136
|
+
if (existingPromise) {return existingPromise}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
// Check if script is already in the document
|
|
140
140
|
if (options?.id && document.getElementById(options.id)) {
|
|
141
141
|
return Promise.resolve()
|
|
142
|
-
}
|
|
142
|
+
}if (document.querySelector(`script[src="${src}"]`)) {
|
|
143
143
|
return Promise.resolve()
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -188,13 +188,13 @@ export function appendStyle(src: string): Promise<void> {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
export function normalizeURL(url: string) {
|
|
191
|
-
if (url.startsWith('https://')) return url
|
|
191
|
+
if (url.startsWith('https://')) {return url}
|
|
192
192
|
url = url.replace(/http:\/\//, '')
|
|
193
193
|
return `https://${url}`
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
export function normalizeDimension(value: string | number | undefined, defaultMetric = 'px'): string | undefined {
|
|
197
|
-
if (typeof value
|
|
197
|
+
if ('number' === typeof value) {return `${value}${defaultMetric}`}
|
|
198
198
|
return value
|
|
199
199
|
}
|
|
200
200
|
|
|
@@ -211,7 +211,7 @@ import { getBagelInstance } from '../composables/useBagel'
|
|
|
211
211
|
const URL_REGEX = /^https?:\/\/|^\/\//
|
|
212
212
|
|
|
213
213
|
export function pathKeyToURL(pathKey?: string) {
|
|
214
|
-
if (pathKey === undefined ||
|
|
214
|
+
if (pathKey === undefined || '' === pathKey || URL_REGEX.test(pathKey)) {return pathKey}
|
|
215
215
|
|
|
216
216
|
const bagel = getBagelInstance()
|
|
217
217
|
if (!bagel) {
|
|
@@ -220,7 +220,7 @@ export function pathKeyToURL(pathKey?: string) {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
if (pathKey.startsWith('static/')) {
|
|
223
|
-
if (bagel.host === undefined || bagel.host
|
|
223
|
+
if (bagel.host === undefined || '' === bagel.host) {
|
|
224
224
|
console.warn('Bagel host is not configured. Please set it in BagelVue options.')
|
|
225
225
|
return pathKey
|
|
226
226
|
}
|
|
@@ -231,12 +231,12 @@ export function pathKeyToURL(pathKey?: string) {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
export function getNestedValue(obj: any, path?: string, defaultValue: any = undefined): any {
|
|
234
|
-
if (!path) return obj
|
|
234
|
+
if (!path) {return obj}
|
|
235
235
|
const keys = path.split(/[.[]/)
|
|
236
236
|
let current = obj
|
|
237
237
|
|
|
238
238
|
for (const key of keys) {
|
|
239
|
-
if (!current || typeof current
|
|
239
|
+
if (!current || 'object' !== typeof current || !(key in current)) {
|
|
240
240
|
return defaultValue
|
|
241
241
|
}
|
|
242
242
|
current = current[key]
|
|
@@ -251,7 +251,7 @@ export function downloadFile(source: string | Blob, fileName?: string) {
|
|
|
251
251
|
const link = document.createElement('a')
|
|
252
252
|
link.target = '_blank'
|
|
253
253
|
|
|
254
|
-
if (typeof source
|
|
254
|
+
if ('string' === typeof source) {
|
|
255
255
|
link.href = upgradeHeaders(source)
|
|
256
256
|
const fileNameFromSource = source.split('/').pop()
|
|
257
257
|
link.download = fileName || fileNameFromSource || 'download'
|
package/src/utils/sizeParsing.ts
CHANGED
|
@@ -2,10 +2,10 @@ import type { SizeType, UnitSize } from '../types'
|
|
|
2
2
|
|
|
3
3
|
// Ensure size and units are correctly formatted
|
|
4
4
|
export function standardSize(value: number | string | undefined, unit: UnitSize = 'px') {
|
|
5
|
-
if (value === undefined ||
|
|
5
|
+
if (value === undefined || '' === value) {return ''}
|
|
6
6
|
|
|
7
7
|
// Handle SizeType values
|
|
8
|
-
if (typeof value
|
|
8
|
+
if ('string' === typeof value) {
|
|
9
9
|
const sizeTypeMap: Record<SizeType, number> = {
|
|
10
10
|
xSmall: 16,
|
|
11
11
|
small: 24,
|