@bagelink/vue 1.6.43 → 1.6.49
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 +18 -19
- package/bin/utils.ts +4 -4
- package/dist/components/AddressSearch.vue.d.ts.map +1 -1
- package/dist/components/Alert.vue.d.ts.map +1 -1
- package/dist/components/BglVideo.vue.d.ts.map +1 -1
- package/dist/components/Card.vue.d.ts.map +1 -1
- package/dist/components/Carousel.vue.d.ts +2 -2
- package/dist/components/Carousel.vue.d.ts.map +1 -1
- package/dist/components/Dropdown.vue.d.ts.map +1 -1
- package/dist/components/Flag.vue.d.ts.map +1 -1
- package/dist/components/IframeVue.vue.d.ts.map +1 -1
- package/dist/components/ListItem.vue.d.ts.map +1 -1
- package/dist/components/Loading.vue.d.ts.map +1 -1
- package/dist/components/Modal.vue.d.ts.map +1 -1
- package/dist/components/ModalForm.vue.d.ts.map +1 -1
- package/dist/components/NavBar.vue.d.ts +1 -1
- package/dist/components/Pill.vue.d.ts.map +1 -1
- package/dist/components/Swiper.vue.d.ts +12 -4
- package/dist/components/Swiper.vue.d.ts.map +1 -1
- package/dist/components/Zoomer.vue.d.ts.map +1 -1
- package/dist/components/analytics/LineChart.vue.d.ts.map +1 -1
- package/dist/components/analytics/PieChart.vue.d.ts +2 -1
- package/dist/components/analytics/PieChart.vue.d.ts.map +1 -1
- package/dist/components/analytics/index.d.ts +1 -1
- package/dist/components/analytics/index.d.ts.map +1 -1
- package/dist/components/calendar/CalendarPopover.vue.d.ts.map +1 -1
- package/dist/components/form/BglMultiStepForm.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ColorInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/PasswordInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RadioGroup.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RangeInput.vue.d.ts +11 -11
- package/dist/components/form/inputs/RichText/components/EditorToolbar.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/components/TableGridSelector.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText/utils/commands.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/TelInput.vue.d.ts.map +1 -1
- package/dist/components/layout/AppContent.vue.d.ts.map +1 -1
- package/dist/components/layout/AppSidebar.vue.d.ts +1 -0
- package/dist/components/layout/AppSidebar.vue.d.ts.map +1 -1
- package/dist/components/layout/Layout.vue.d.ts.map +1 -1
- package/dist/components/layout/Tabs.vue.d.ts.map +1 -1
- package/dist/components/layout/index.d.ts +3 -3
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/components/lightbox/Lightbox.vue.d.ts.map +1 -1
- package/dist/index.cjs +24 -15
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1530 -1404
- package/dist/plugins/modalTypes.d.ts +1 -8
- package/dist/plugins/modalTypes.d.ts.map +1 -1
- package/dist/plugins/useModal.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -2
- package/src/components/AccordionItem.vue +13 -13
- package/src/components/AddToCalendar.vue +1 -1
- package/src/components/AddressSearch.vue +9 -8
- package/src/components/Alert.vue +2 -1
- package/src/components/Badge.vue +5 -5
- package/src/components/BglVideo.vue +44 -45
- package/src/components/Btn.vue +15 -15
- package/src/components/Card.vue +10 -8
- package/src/components/Carousel.vue +159 -162
- package/src/components/DataPreview.vue +1 -1
- package/src/components/DragOver.vue +6 -6
- package/src/components/Dropdown.vue +39 -38
- package/src/components/Flag.vue +7 -6
- package/src/components/Icon/Icon.vue +22 -22
- package/src/components/IframeVue.vue +5 -5
- package/src/components/Image.vue +17 -17
- package/src/components/ImportData.vue +79 -79
- package/src/components/ListItem.vue +12 -11
- package/src/components/Loading.vue +10 -9
- package/src/components/MapEmbed/Index.vue +24 -24
- package/src/components/Modal.vue +11 -9
- package/src/components/ModalForm.vue +15 -11
- package/src/components/NavBar.vue +6 -6
- package/src/components/Pagination.vue +27 -27
- package/src/components/Pill.vue +11 -12
- package/src/components/Rating.vue +2 -2
- package/src/components/Slider.vue +75 -75
- package/src/components/Spreadsheet/Index.vue +34 -34
- package/src/components/Spreadsheet/SpreadsheetTable.vue +3 -3
- package/src/components/Swiper.vue +4 -4
- package/src/components/Zoomer.vue +282 -182
- package/src/components/analytics/BarChart.vue +6 -6
- package/src/components/analytics/KpiCard.vue +2 -2
- package/src/components/analytics/LineChart.vue +63 -61
- package/src/components/analytics/PieChart.vue +104 -90
- package/src/components/analytics/index.ts +2 -2
- package/src/components/calendar/CalendarPopover.vue +1 -1
- package/src/components/calendar/Index.vue +1 -1
- package/src/components/calendar/views/AgendaView.vue +3 -3
- 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 +4 -4
- package/src/components/dataTable/useSorting.ts +1 -1
- package/src/components/dataTable/useTableData.ts +15 -15
- package/src/components/dataTable/useTableSelection.ts +15 -15
- package/src/components/dataTable/useTableVirtualization.ts +1 -1
- package/src/components/draggable/useDraggable.ts +42 -42
- package/src/components/form/BagelForm.vue +15 -15
- package/src/components/form/BglFieldSet.vue +5 -3
- package/src/components/form/BglMultiStepForm.vue +20 -21
- package/src/components/form/inputs/CheckInput.vue +2 -2
- 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/ColorInput.vue +5 -4
- package/src/components/form/inputs/DateInput.vue +8 -9
- package/src/components/form/inputs/DatePicker.vue +24 -24
- package/src/components/form/inputs/EmailInput.vue +24 -24
- package/src/components/form/inputs/NumberInput.vue +26 -26
- package/src/components/form/inputs/OTP.vue +7 -7
- package/src/components/form/inputs/PasswordInput.vue +3 -2
- package/src/components/form/inputs/RadioGroup.vue +28 -25
- package/src/components/form/inputs/RadioPillsInput.vue +12 -12
- package/src/components/form/inputs/RangeInput.vue +21 -21
- package/src/components/form/inputs/RichText/components/EditorToolbar.vue +107 -92
- package/src/components/form/inputs/RichText/components/TableGridSelector.vue +64 -64
- package/src/components/form/inputs/RichText/components/gridBox.vue +10 -8
- 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 +138 -138
- package/src/components/form/inputs/RichText/utils/commands.ts +84 -85
- 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 +7 -7
- 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 +54 -54
- package/src/components/form/inputs/SignaturePad.vue +40 -40
- package/src/components/form/inputs/TableField.vue +1 -1
- package/src/components/form/inputs/TelInput.vue +54 -53
- package/src/components/form/inputs/TextInput.vue +19 -19
- package/src/components/form/inputs/ToggleInput.vue +2 -2
- package/src/components/form/inputs/Upload/useFileUpload.ts +6 -6
- package/src/components/form/useBagelFormState.ts +5 -5
- package/src/components/layout/AppContent.vue +6 -3
- package/src/components/layout/AppLayout.vue +2 -2
- package/src/components/layout/AppSidebar.vue +83 -16
- package/src/components/layout/Layout.vue +12 -10
- package/src/components/layout/SidebarMenu.vue +4 -4
- package/src/components/layout/TabbedLayout.vue +17 -17
- package/src/components/layout/Tabs.vue +4 -5
- package/src/components/layout/TabsNav.vue +14 -14
- package/src/components/layout/index.ts +3 -5
- package/src/components/lightbox/Lightbox.vue +276 -126
- package/src/components/lightbox/index.ts +8 -8
- package/src/composables/index.ts +8 -8
- package/src/composables/useAddToCalendar.ts +13 -13
- package/src/composables/useDevice.ts +2 -2
- package/src/composables/useFormField.ts +4 -4
- package/src/composables/usePolling.ts +8 -8
- package/src/composables/useSchemaField.ts +38 -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/index.ts +1 -0
- package/src/plugins/bagel.ts +4 -4
- package/src/plugins/modalTypes.ts +1 -8
- package/src/plugins/useModal.ts +43 -18
- package/src/styles/layout.css +1 -1
- package/src/types/index.ts +1 -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/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 +0 -2
|
@@ -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 (
|
|
68
|
+
if (this.DAY_START === 0 && this.DAY_END === 2400) { 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 ('sunday'
|
|
89
|
+
if (this.FIRST_DAY_OF_WEEK === 'sunday') {
|
|
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
|
-
=
|
|
95
|
+
= date.getDay() === 0 ? 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 (month <= 11) {
|
|
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 (
|
|
179
|
+
if (time.length === 4) {
|
|
180
180
|
hour = time[0] + time[1]
|
|
181
181
|
minutes = time[2] + time[3]
|
|
182
|
-
} else if (
|
|
182
|
+
} else if (time.length === 3) {
|
|
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 (hourLocaleString[0] === '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}-${ 10
|
|
250
|
+
const fullDate = `${y}-${m >= 10 ? m : `0${m}`}-${d >= 10 ? 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} ${ 10
|
|
257
|
-
|
|
256
|
+
return `${fullDate} ${hour >= 10 ? hour : `0${hour}`}:${
|
|
257
|
+
minutes >= 10 ? minutes : `0${minutes}`
|
|
258
258
|
}`
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
const fullTime = 'start'
|
|
261
|
+
const fullTime = timeIsStartOrEndOfDay === 'start' ? '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}-${ 10
|
|
345
|
+
return `${yyyy}-${mm >= 10 ? mm : `0${mm}`}-${dd >= 10 ? 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 (minutePoints < 10) { 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 (weekHeight <= 0) { throw new Error('weekHeight cannot be a negative number') }
|
|
434
|
+
if (clickOffsetY < 0) { 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 (
|
|
457
|
+
if (segments.hour < 0 || segments.hour > 23) { 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 (0
|
|
472
|
+
if (boundary < 0 || boundary > 24 || boundary % 1 !== 0) {
|
|
473
473
|
throw new Error('Invalid day boundary')
|
|
474
474
|
}
|
|
475
475
|
|
|
476
|
-
if (
|
|
476
|
+
if (boundary === 0) { return boundary }
|
|
477
477
|
|
|
478
478
|
return boundary * 100
|
|
479
479
|
}
|
|
480
480
|
|
|
481
481
|
static getHourFromTimePoints(timePoints: number) {
|
|
482
|
-
if (0
|
|
482
|
+
if (timePoints < 0 || timePoints > 2400 || timePoints % 100 !== 0) {
|
|
483
483
|
throw new Error('Invalid time points')
|
|
484
484
|
}
|
|
485
485
|
|
|
486
|
-
if (
|
|
486
|
+
if (timePoints === 0) { 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 (0
|
|
562
|
+
if (number < 0 || number > 60) { throw new Error('Invalid number. This is not a valid hour or minute') }
|
|
563
563
|
|
|
564
|
-
return
|
|
564
|
+
return number < 10 ? `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 ('object'
|
|
149
|
+
if (typeof idOrOptions === 'object' && idOrOptions !== null) {
|
|
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 (textOrIcon != null) {
|
|
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 = 'string'
|
|
163
|
-
&&
|
|
162
|
+
const isLikelyIcon = typeof textOrIcon === 'string'
|
|
163
|
+
&& textOrIcon.length <= 30
|
|
164
164
|
&& !textOrIcon.includes(' ')
|
|
165
165
|
&& (textOrIcon.includes('-')
|
|
166
166
|
|| textOrIcon.includes('_')
|
|
167
|
-
||
|
|
167
|
+
|| textOrIcon.length <= 12)
|
|
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 (icon != null && id != null) {
|
|
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 ('object'
|
|
282
|
+
if (typeof idOrOptions === 'object' && idOrOptions !== null) {
|
|
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 ('string'
|
|
290
|
+
if (text != null) {
|
|
291
|
+
if (typeof tagOrOptions === 'string') {
|
|
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 ('object'
|
|
358
|
+
if (typeof idOrOptions === 'object' && idOrOptions !== null) {
|
|
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 ('string'
|
|
366
|
+
if (src != null) {
|
|
367
|
+
if (typeof altOrOptions === 'string') {
|
|
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 (
|
|
419
|
+
if (args.length > 0) {
|
|
420
420
|
const firstArg = args[0] as DropdownElementOptions<T, PO> | BaseElementField<T, PO>
|
|
421
421
|
if (
|
|
422
|
-
|
|
423
|
-
&&
|
|
422
|
+
typeof firstArg === 'object'
|
|
423
|
+
&& firstArg !== null
|
|
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 (
|
|
437
|
-
if (
|
|
438
|
-
if (
|
|
439
|
-
if (
|
|
440
|
-
if (
|
|
441
|
-
if (
|
|
442
|
-
if (
|
|
436
|
+
if (opts.options != null) { attrs.options = opts.options }
|
|
437
|
+
if (opts.placeholder != null) { attrs.placeholder = opts.placeholder }
|
|
438
|
+
if (opts.searchable != null) { attrs.searchable = opts.searchable }
|
|
439
|
+
if (opts.multiselect != null) { attrs.multiselect = opts.multiselect }
|
|
440
|
+
if (opts.clearable != null) { attrs.clearable = opts.clearable }
|
|
441
|
+
if (opts.onSelect != null) { attrs.onSelect = opts.onSelect }
|
|
442
|
+
if (opts.onSearch != null) { 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 &&
|
|
509
|
+
if (element.id === id) { return element }
|
|
510
|
+
if (element.children && element.children.length > 0) {
|
|
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 ('string'
|
|
524
|
+
if (typeof labelOrOptions === 'string') {
|
|
525
525
|
label = labelOrOptions
|
|
526
526
|
} else {
|
|
527
527
|
options = labelOrOptions
|
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 ('string'
|
|
8
|
+
if (typeof value === 'string') {
|
|
9
9
|
const sizeTypeMap: Record<SizeType, number> = {
|
|
10
10
|
xSmall: 16,
|
|
11
11
|
small: 24,
|
package/src/utils/strings.ts
CHANGED
|
@@ -2,26 +2,26 @@ export function formatString(
|
|
|
2
2
|
str: string,
|
|
3
3
|
format: 'pascal' | 'camel' | 'snake' | 'titleCase',
|
|
4
4
|
): string {
|
|
5
|
-
if ('titleCase'
|
|
5
|
+
if (format === 'titleCase') {
|
|
6
6
|
return str
|
|
7
7
|
.split('_')
|
|
8
8
|
.map(word => word[0].toUpperCase() + word.slice(1).toLocaleLowerCase())
|
|
9
9
|
.join(' ')
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
if ('pascal'
|
|
12
|
+
if (format === 'pascal') {
|
|
13
13
|
return str
|
|
14
14
|
.split('_')
|
|
15
15
|
.map(word => word[0].toUpperCase() + word.slice(1).toLocaleLowerCase())
|
|
16
16
|
.join('')
|
|
17
17
|
}
|
|
18
|
-
if ('camel'
|
|
18
|
+
if (format === 'camel') {
|
|
19
19
|
return str
|
|
20
20
|
.split('_')
|
|
21
|
-
.map((word, index) => (
|
|
21
|
+
.map((word, index) => (index === 0 ? word : word[0].toUpperCase() + word.slice(1)))
|
|
22
22
|
.join('')
|
|
23
23
|
}
|
|
24
|
-
if ('snake'
|
|
24
|
+
if (format === 'snake') {
|
|
25
25
|
return [...str]
|
|
26
26
|
.map((letter) => {
|
|
27
27
|
if (letter === letter.toUpperCase()) {
|
package/src/utils/tapDetector.ts
CHANGED
|
@@ -34,37 +34,37 @@ export default class TapDetector {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
onSingleTap(callback: TapCallback): void {
|
|
37
|
-
if ('function'
|
|
37
|
+
if (typeof callback === 'function' && !this.singleTapCallbacks.includes(callback)) {
|
|
38
38
|
this.singleTapCallbacks.push(callback)
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
onDoubleTap(callback: TapCallback): void {
|
|
43
|
-
if ('function'
|
|
43
|
+
if (typeof callback === 'function' && !this.doubleTapCallbacks.includes(callback)) {
|
|
44
44
|
this.doubleTapCallbacks.push(callback)
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
private triggerCallbacks(callbackType: CallbackType, event: { clientX: number, clientY: number }): void {
|
|
49
|
-
const callbacks = 'single'
|
|
49
|
+
const callbacks = callbackType === 'single' ? this.singleTapCallbacks : this.doubleTapCallbacks
|
|
50
50
|
callbacks.forEach((callback) => { callback(event) })
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
private onTouchStart = (event: TouchEvent): void => {
|
|
54
54
|
this.isTouchMode = true
|
|
55
|
-
if (
|
|
55
|
+
if (event.touches.length === 1) {
|
|
56
56
|
this.onPointerDown(event.touches[0].clientX, event.touches[0].clientY)
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
private onTouchMove = (event: TouchEvent): void => {
|
|
61
|
-
if (
|
|
61
|
+
if (event.touches.length === 1) {
|
|
62
62
|
this.onPointerMove(event.touches[0].clientX, event.touches[0].clientY)
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
private onTouchEnd = (): void => {
|
|
67
|
-
if (this.isTouchMode) {this.onPointerUp()}
|
|
67
|
+
if (this.isTouchMode) { this.onPointerUp() }
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
private onMouseDown = (event: MouseEvent): void => {
|
|
@@ -74,13 +74,13 @@ export default class TapDetector {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
private onMouseMove = (event: MouseEvent): void => {
|
|
77
|
-
if (!this.isTouchMode &&
|
|
77
|
+
if (!this.isTouchMode && event.button === 0) {
|
|
78
78
|
this.onPointerMove(event.clientX, event.clientY)
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
private onMouseUp = (): void => {
|
|
83
|
-
if (!this.isTouchMode) {this.onPointerUp()}
|
|
83
|
+
if (!this.isTouchMode) { this.onPointerUp() }
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
private onPointerDown(x: number, y: number): void {
|
|
@@ -91,8 +91,8 @@ export default class TapDetector {
|
|
|
91
91
|
|
|
92
92
|
private onPointerUp(): void {
|
|
93
93
|
const currTimeStamp = Date.now()
|
|
94
|
-
if (
|
|
95
|
-
if (
|
|
94
|
+
if (this.touchMovedLength < 10) {
|
|
95
|
+
if (currTimeStamp - this.lastTapTimestamp < 300) {
|
|
96
96
|
this.tappedCount++
|
|
97
97
|
} else {
|
|
98
98
|
this.tappedCount = 1
|
|
@@ -101,7 +101,7 @@ export default class TapDetector {
|
|
|
101
101
|
this.lastTapTimestamp = currTimeStamp
|
|
102
102
|
this.triggerCallbacks('single', { clientX: this.lastPointerX, clientY: this.lastPointerY })
|
|
103
103
|
|
|
104
|
-
if (
|
|
104
|
+
if (this.tappedCount === 2) {
|
|
105
105
|
this.triggerCallbacks('double', { clientX: this.lastPointerX, clientY: this.lastPointerY })
|
|
106
106
|
this.tappedCount = 0
|
|
107
107
|
}
|
package/src/utils/useSearch.ts
CHANGED
|
@@ -17,7 +17,7 @@ const htmlReplacers = {
|
|
|
17
17
|
* @returns Plain text without HTML tags
|
|
18
18
|
*/
|
|
19
19
|
export function clearHtml(value?: string) {
|
|
20
|
-
if (!value) {return ''}
|
|
20
|
+
if (!value) { return '' }
|
|
21
21
|
return Object.entries(htmlReplacers)
|
|
22
22
|
.reduce(
|
|
23
23
|
(
|
|
@@ -52,7 +52,7 @@ function getValueByPath(obj: any, path: string): any {
|
|
|
52
52
|
let result = obj
|
|
53
53
|
|
|
54
54
|
for (const key of keys) {
|
|
55
|
-
if (
|
|
55
|
+
if (result === null || result === undefined || typeof result !== 'object') {
|
|
56
56
|
return undefined
|
|
57
57
|
}
|
|
58
58
|
result = result[key]
|
|
@@ -71,7 +71,7 @@ function getValueByPath(obj: any, path: string): any {
|
|
|
71
71
|
function calculateRelevance(stringValue: string, searchTerms: string[]): number {
|
|
72
72
|
let score = 0
|
|
73
73
|
|
|
74
|
-
if (
|
|
74
|
+
if (stringValue.length === 0) { return 0 }
|
|
75
75
|
|
|
76
76
|
// Track matched character count for density calculation
|
|
77
77
|
let totalMatchedChars = 0
|
|
@@ -138,7 +138,7 @@ export interface SearchResult<T> {
|
|
|
138
138
|
* @returns True if the value is a primitive
|
|
139
139
|
*/
|
|
140
140
|
function isPrimitive(value: any): boolean {
|
|
141
|
-
return 'string'
|
|
141
|
+
return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/**
|
|
@@ -147,10 +147,10 @@ function isPrimitive(value: any): boolean {
|
|
|
147
147
|
* @returns String representation or empty string if value can't be converted
|
|
148
148
|
*/
|
|
149
149
|
function toSearchableString(value: any): string {
|
|
150
|
-
if (
|
|
151
|
-
if ('string'
|
|
152
|
-
if ('number'
|
|
153
|
-
if ('object'
|
|
150
|
+
if (value === null || value === undefined) { return '' }
|
|
151
|
+
if (typeof value === 'string') { return clearHtml(value) }
|
|
152
|
+
if (typeof value === 'number' || typeof value === 'boolean') { return String(value) }
|
|
153
|
+
if (typeof value === 'object' && value instanceof Date) { return value.toISOString() }
|
|
154
154
|
return ''
|
|
155
155
|
}
|
|
156
156
|
|
|
@@ -168,14 +168,14 @@ export function searchItems<T>(params: SearchItemParams<T>): T[] {
|
|
|
168
168
|
const itemsArray = toValue(items) || []
|
|
169
169
|
|
|
170
170
|
// Return all items if search is empty or doesn't meet minimum character threshold
|
|
171
|
-
if (!searchValue || searchValue.length < minChars) {return itemsArray}
|
|
171
|
+
if (!searchValue || searchValue.length < minChars) { return itemsArray }
|
|
172
172
|
|
|
173
173
|
// Split search term into individual words for better matching
|
|
174
174
|
const searchTerms = normalizeText(searchValue)
|
|
175
175
|
.split(/\s+/)
|
|
176
|
-
.filter(term =>
|
|
176
|
+
.filter(term => term.length > 1)
|
|
177
177
|
|
|
178
|
-
if (
|
|
178
|
+
if (searchTerms.length === 0) { return itemsArray }
|
|
179
179
|
|
|
180
180
|
// ---- Field weight configuration ----
|
|
181
181
|
// Default field weights for common fields
|
|
@@ -209,7 +209,7 @@ export function searchItems<T>(params: SearchItemParams<T>): T[] {
|
|
|
209
209
|
// First check custom weights
|
|
210
210
|
if (path in fieldWeights) {
|
|
211
211
|
const customWeight = fieldWeights[path]
|
|
212
|
-
if ('number'
|
|
212
|
+
if (typeof customWeight === 'number') {
|
|
213
213
|
return customWeight
|
|
214
214
|
}
|
|
215
215
|
}
|
|
@@ -231,13 +231,13 @@ export function searchItems<T>(params: SearchItemParams<T>): T[] {
|
|
|
231
231
|
* @returns Array of flattened key paths
|
|
232
232
|
*/
|
|
233
233
|
function collectAllKeys(obj: any, prefix = ''): string[] {
|
|
234
|
-
if (!obj || 'object'
|
|
234
|
+
if (!obj || typeof obj !== 'object') { return [] }
|
|
235
235
|
|
|
236
236
|
return Object.keys(obj).flatMap((key) => {
|
|
237
237
|
const value = obj[key]
|
|
238
238
|
const newPrefix = prefix ? `${prefix}.${key}` : key
|
|
239
239
|
|
|
240
|
-
if (value && 'object'
|
|
240
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
241
241
|
// Recurse for nested objects
|
|
242
242
|
return [newPrefix, ...collectAllKeys(value, newPrefix)]
|
|
243
243
|
}
|
|
@@ -281,7 +281,7 @@ export function searchItems<T>(params: SearchItemParams<T>): T[] {
|
|
|
281
281
|
const value = getValueByPath(item, String(keyPath))
|
|
282
282
|
|
|
283
283
|
// Skip null/undefined values
|
|
284
|
-
if (
|
|
284
|
+
if (value === null || value === undefined) { continue }
|
|
285
285
|
|
|
286
286
|
// CASE 3.1: Handle array field values
|
|
287
287
|
if (Array.isArray(value)) {
|
|
@@ -299,7 +299,7 @@ export function searchItems<T>(params: SearchItemParams<T>): T[] {
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
// CASE 3.2: Handle object fields (skip and process their properties separately)
|
|
302
|
-
if ('object'
|
|
302
|
+
if (typeof value === 'object' && !isPrimitive(value)) {
|
|
303
303
|
continue
|
|
304
304
|
}
|
|
305
305
|
|
|
@@ -322,19 +322,19 @@ export function searchItems<T>(params: SearchItemParams<T>): T[] {
|
|
|
322
322
|
})
|
|
323
323
|
|
|
324
324
|
// Filter items with non-zero relevance
|
|
325
|
-
const nonZeroItems = scoredItems.filter(([, score]) =>
|
|
325
|
+
const nonZeroItems = scoredItems.filter(([, score]) => score > 0)
|
|
326
326
|
|
|
327
327
|
// Apply dynamic threshold based on score distribution
|
|
328
328
|
let filteredItems = nonZeroItems
|
|
329
|
-
if (
|
|
329
|
+
if (nonZeroItems.length > 0) {
|
|
330
330
|
const maxScore = Math.max(...nonZeroItems.map(([, score]) => score))
|
|
331
331
|
|
|
332
332
|
// If we have very high relevance items, filter out low relevance noise
|
|
333
|
-
if (
|
|
333
|
+
if (maxScore > 5) {
|
|
334
334
|
// Items below 25% of max score are considered low relevance
|
|
335
335
|
const threshold = maxScore * 0.25
|
|
336
336
|
filteredItems = nonZeroItems.filter(([, score]) => score >= threshold)
|
|
337
|
-
} else if (
|
|
337
|
+
} else if (maxScore > 2) {
|
|
338
338
|
// For medium relevance results, use a lower threshold
|
|
339
339
|
const threshold = maxScore * 0.15
|
|
340
340
|
filteredItems = nonZeroItems.filter(([, score]) => score >= threshold)
|
|
@@ -384,8 +384,8 @@ export function useSearch<T>(
|
|
|
384
384
|
// Check if first argument is an array or ref (simplified usage)
|
|
385
385
|
// If it's a params object, it won't have these characteristics
|
|
386
386
|
const isArray = Array.isArray(paramsOrItems)
|
|
387
|
-
const isFunction = 'function'
|
|
388
|
-
const isObject = 'object'
|
|
387
|
+
const isFunction = typeof paramsOrItems === 'function'
|
|
388
|
+
const isObject = typeof paramsOrItems === 'object' && paramsOrItems !== null
|
|
389
389
|
const isRef = isObject && 'value' in paramsOrItems && !('items' in paramsOrItems)
|
|
390
390
|
|
|
391
391
|
const isSimplifiedUsage = isArray || isFunction || isRef
|
|
@@ -416,14 +416,14 @@ export function useSearch<T>(
|
|
|
416
416
|
() => toValue(searchTerm),
|
|
417
417
|
async (newTerm) => {
|
|
418
418
|
// Clear previous timeout if it exists
|
|
419
|
-
if (
|
|
419
|
+
if (debounceTimeout !== null) {
|
|
420
420
|
clearTimeout(debounceTimeout)
|
|
421
421
|
}
|
|
422
422
|
|
|
423
|
-
const term = 'string'
|
|
423
|
+
const term = typeof newTerm === 'string' ? newTerm : ''
|
|
424
424
|
|
|
425
425
|
// Allow initial/default fetch when minChars === 0 (including empty term)
|
|
426
|
-
if (term.length < minChars &&
|
|
426
|
+
if (term.length < minChars && minChars > 0) {
|
|
427
427
|
serverResults.value = []
|
|
428
428
|
return
|
|
429
429
|
}
|
|
@@ -454,11 +454,11 @@ export function useSearch<T>(
|
|
|
454
454
|
|
|
455
455
|
// If using server-side search
|
|
456
456
|
if (serverSearch) {
|
|
457
|
-
if (term && 'string'
|
|
457
|
+
if (term && typeof term === 'string' && term.length >= minChars) {
|
|
458
458
|
return serverResults.value as T[]
|
|
459
459
|
}
|
|
460
460
|
// If minChars is 0, allow default server results when empty
|
|
461
|
-
if (
|
|
461
|
+
if (minChars === 0) { return serverResults.value as T[] }
|
|
462
462
|
}
|
|
463
463
|
|
|
464
464
|
// Otherwise use client-side filtering
|
|
@@ -467,10 +467,10 @@ export function useSearch<T>(
|
|
|
467
467
|
// Create computed references
|
|
468
468
|
const results = computed(() => getFilteredResults())
|
|
469
469
|
const resultCount = computed(() => results.value.length)
|
|
470
|
-
const hasResults = computed(() =>
|
|
470
|
+
const hasResults = computed(() => resultCount.value > 0)
|
|
471
471
|
const isSearching = computed(() => {
|
|
472
472
|
const term = getSearchTermValue()
|
|
473
|
-
return !!term && 'string'
|
|
473
|
+
return !!term && typeof term === 'string' && term.length >= minChars
|
|
474
474
|
})
|
|
475
475
|
|
|
476
476
|
const result: SearchResult<T> = {
|
package/vite.config.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'node:path'
|
|
2
2
|
// import { fileURLToPath, URL } from 'node:url'
|
|
3
3
|
import vue from '@vitejs/plugin-vue'
|
|
4
|
-
import ReactivityTransform from '@vue-macros/reactivity-transform/vite'
|
|
5
4
|
import { defineConfig } from 'vite'
|
|
6
5
|
import dts from 'vite-plugin-dts'
|
|
7
6
|
import tsconfigPaths from 'vite-tsconfig-paths'
|
|
@@ -11,7 +10,6 @@ const indexDir = resolve(import.meta.dirname, 'src')
|
|
|
11
10
|
export default defineConfig(() => ({
|
|
12
11
|
plugins: [
|
|
13
12
|
tsconfigPaths({ root: indexDir, }),
|
|
14
|
-
ReactivityTransform(),
|
|
15
13
|
vue(),
|
|
16
14
|
dts({
|
|
17
15
|
entryRoot: indexDir,
|