@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
|
@@ -73,12 +73,12 @@ function initResize(el: HTMLElement, binding: { value?: ResizeOptions }) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function applyGridSnapping(height: number): number {
|
|
76
|
-
if (!options.gridSize) {return height}
|
|
76
|
+
if (!options.gridSize) { return height }
|
|
77
77
|
return Math.round(height / options.gridSize) * options.gridSize
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
function handleMove(e: MouseEvent | TouchEvent) {
|
|
81
|
-
if (!isResizing) {return}
|
|
81
|
+
if (!isResizing) { return }
|
|
82
82
|
e.preventDefault()
|
|
83
83
|
|
|
84
84
|
const clientY = 'touches' in e ? e.touches[0].clientY : e.clientY
|
|
@@ -109,7 +109,7 @@ function initResize(el: HTMLElement, binding: { value?: ResizeOptions }) {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
function handleEnd(e: MouseEvent | TouchEvent) {
|
|
112
|
-
if (!isResizing) {return}
|
|
112
|
+
if (!isResizing) { return }
|
|
113
113
|
|
|
114
114
|
const clientY = 'touches' in e ? e.changedTouches[0].clientY : e.clientY
|
|
115
115
|
const event = createResizeEvent(clientY)
|
|
@@ -136,7 +136,7 @@ function initResize(el: HTMLElement, binding: { value?: ResizeOptions }) {
|
|
|
136
136
|
|
|
137
137
|
function handleStart(e: MouseEvent | TouchEvent) {
|
|
138
138
|
// Only handle left mouse button for mouse events
|
|
139
|
-
if (e instanceof MouseEvent &&
|
|
139
|
+
if (e instanceof MouseEvent && e.button !== 0) { return }
|
|
140
140
|
|
|
141
141
|
e.preventDefault()
|
|
142
142
|
isResizing = true
|
|
@@ -186,7 +186,7 @@ export const vResize: Directive<HTMLElement, ResizeOptions> = {
|
|
|
186
186
|
|
|
187
187
|
unmounted(el) {
|
|
188
188
|
const cleanup = (el as any)[RESIZE_KEY]
|
|
189
|
-
if ('function'
|
|
189
|
+
if (typeof cleanup === 'function') {
|
|
190
190
|
cleanup()
|
|
191
191
|
delete (el as any)[RESIZE_KEY]
|
|
192
192
|
}
|
|
@@ -195,7 +195,7 @@ export const vResize: Directive<HTMLElement, ResizeOptions> = {
|
|
|
195
195
|
updated(el, binding) {
|
|
196
196
|
if (binding.value !== binding.oldValue) {
|
|
197
197
|
const cleanup = (el as any)[RESIZE_KEY]
|
|
198
|
-
if ('function'
|
|
198
|
+
if (typeof cleanup === 'function') {
|
|
199
199
|
cleanup()
|
|
200
200
|
delete (el as any)[RESIZE_KEY]
|
|
201
201
|
}
|
package/src/index.ts
CHANGED
package/src/plugins/bagel.ts
CHANGED
|
@@ -14,7 +14,7 @@ export const i18nTInjectionKey = Symbol('bagel') as InjectionKey<(key: string) =
|
|
|
14
14
|
|
|
15
15
|
export function injectI18nT(injectionKey: typeof i18nTInjectionKey = i18nTInjectionKey) {
|
|
16
16
|
const i18nT = inject(injectionKey)
|
|
17
|
-
if (!i18nT) {throw new Error('No i18nT provided')}
|
|
17
|
+
if (!i18nT) { throw new Error('No i18nT provided') }
|
|
18
18
|
return i18nT
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -55,9 +55,9 @@ export const BagelVue: Plugin<BagelOptions> = {
|
|
|
55
55
|
},
|
|
56
56
|
})
|
|
57
57
|
const { availableLangs, defaultLang, lang } = useLang()
|
|
58
|
-
if (options.availableLangs) {availableLangs.value = options.availableLangs}
|
|
59
|
-
if (options.defaultLang) {defaultLang.value = options.defaultLang}
|
|
60
|
-
if (options.language) {lang.value = options.language}
|
|
58
|
+
if (options.availableLangs) { availableLangs.value = options.availableLangs }
|
|
59
|
+
if (options.defaultLang) { defaultLang.value = options.defaultLang }
|
|
60
|
+
if (options.language) { lang.value = options.language }
|
|
61
61
|
app.config.globalProperties.$bagel = bagel
|
|
62
62
|
app.provide(bagelInjectionKey, bagel)
|
|
63
63
|
app.config.globalProperties.$i18T
|
|
@@ -46,7 +46,7 @@ export interface ModalFormComponentProps<T extends { [key: string]: any }> exten
|
|
|
46
46
|
modalOptions: ModalFormOptions<T>
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export interface ModalFormOptions<T> {
|
|
49
|
+
export interface ModalFormOptions<T> extends ModalOptions {
|
|
50
50
|
'schema': MaybeRefOrGetter<BglFormSchemaT<T>>
|
|
51
51
|
'modelValue'?: T
|
|
52
52
|
'onUpdate:modelValue'?: (val: T) => void
|
|
@@ -58,11 +58,4 @@ export interface ModalFormOptions<T> {
|
|
|
58
58
|
'deleteText'?: string
|
|
59
59
|
'duplicateText'?: string
|
|
60
60
|
'onError'?: (err: any) => void
|
|
61
|
-
'side'?: boolean
|
|
62
|
-
'title'?: string
|
|
63
|
-
'width'?: string
|
|
64
|
-
'dismissable'?: boolean
|
|
65
|
-
'visible'?: boolean
|
|
66
|
-
'actions'?: BtnOptions[]
|
|
67
|
-
'class'?: string
|
|
68
61
|
}
|
package/src/plugins/useModal.ts
CHANGED
|
@@ -80,6 +80,11 @@ export const ModalPlugin: Plugin = {
|
|
|
80
80
|
// Make options reactive so updates propagate
|
|
81
81
|
const reactiveOptions = reactive(options) as ModalOptions | ModalFormOptions<T>
|
|
82
82
|
|
|
83
|
+
// Ensure visible is set for modals
|
|
84
|
+
if (!('visible' in reactiveOptions)) {
|
|
85
|
+
reactiveOptions.visible = true
|
|
86
|
+
}
|
|
87
|
+
|
|
83
88
|
const modalComponent = {
|
|
84
89
|
modalOptions: reactiveOptions,
|
|
85
90
|
modalType,
|
|
@@ -147,6 +152,11 @@ export const ModalPlugin: Plugin = {
|
|
|
147
152
|
// Calculate z-index based on stack position
|
|
148
153
|
const zIndex = BASE_Z_INDEX + index * 10
|
|
149
154
|
|
|
155
|
+
if (!modal || !modal.modalOptions) {
|
|
156
|
+
console.error('[BageLink Modal] Invalid modal in stack:', modal)
|
|
157
|
+
return null
|
|
158
|
+
}
|
|
159
|
+
|
|
150
160
|
const props = {
|
|
151
161
|
...modal.modalOptions,
|
|
152
162
|
'visible': true,
|
|
@@ -155,8 +165,14 @@ export const ModalPlugin: Plugin = {
|
|
|
155
165
|
}
|
|
156
166
|
|
|
157
167
|
switch (modal.modalType) {
|
|
158
|
-
case 'modalForm':
|
|
168
|
+
case 'modalForm': {
|
|
169
|
+
const formOptions = modal.modalOptions as ModalFormOptions<any>
|
|
170
|
+
if (!formOptions.schema) {
|
|
171
|
+
console.error('[BageLink Modal] ModalForm requires a schema', modal.modalOptions)
|
|
172
|
+
return null
|
|
173
|
+
}
|
|
159
174
|
return h(ModalForm, props as ComponentProps<typeof ModalForm>, modal.componentSlots)
|
|
175
|
+
}
|
|
160
176
|
case 'confirmModal':
|
|
161
177
|
return h(ModalConfirm, props as ModalConfirmOptions, {})
|
|
162
178
|
default:
|
|
@@ -171,27 +187,36 @@ export const ModalPlugin: Plugin = {
|
|
|
171
187
|
|
|
172
188
|
// Auto-mount modal container to document.body
|
|
173
189
|
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|
174
|
-
|
|
190
|
+
const mountModalContainer = () => {
|
|
191
|
+
const existingContainer = document.getElementById('bagelink-modal-root')
|
|
192
|
+
if (!existingContainer) {
|
|
193
|
+
// Create mount point
|
|
194
|
+
const container = document.createElement('div')
|
|
195
|
+
container.id = 'bagelink-modal-root'
|
|
196
|
+
document.body.appendChild(container)
|
|
197
|
+
|
|
198
|
+
// Create a separate app instance for modals to avoid context issues
|
|
199
|
+
const modalApp = createApp(ModalContainerComponent)
|
|
200
|
+
|
|
201
|
+
// Share the same context/plugins
|
|
202
|
+
modalApp._context = app._context
|
|
203
|
+
|
|
204
|
+
// Mount it
|
|
205
|
+
modalApp.mount(container)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Try to mount immediately if DOM is ready
|
|
210
|
+
if (document.body) {
|
|
211
|
+
mountModalContainer()
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Also use mixin as fallback for cases where plugin is installed before DOM ready
|
|
175
215
|
app.mixin({
|
|
176
216
|
mounted() {
|
|
177
217
|
// Only run once on the root component
|
|
178
218
|
if (this.$root === this) {
|
|
179
|
-
|
|
180
|
-
if (!existingContainer) {
|
|
181
|
-
// Create mount point
|
|
182
|
-
const container = document.createElement('div')
|
|
183
|
-
container.id = 'bagelink-modal-root'
|
|
184
|
-
document.body.appendChild(container)
|
|
185
|
-
|
|
186
|
-
// Create a separate app instance for modals to avoid context issues
|
|
187
|
-
const modalApp = createApp(ModalContainerComponent)
|
|
188
|
-
|
|
189
|
-
// Share the same context/plugins
|
|
190
|
-
modalApp._context = app._context
|
|
191
|
-
|
|
192
|
-
// Mount it
|
|
193
|
-
modalApp.mount(container)
|
|
194
|
-
}
|
|
219
|
+
mountModalContainer()
|
|
195
220
|
}
|
|
196
221
|
}
|
|
197
222
|
})
|
package/src/styles/layout.css
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -37,7 +37,7 @@ export type ExtendedThemeType =
|
|
|
37
37
|
// Legacy light variants
|
|
38
38
|
| 'blue-light' | 'green-light' | 'red-light' | 'yellow-light' | 'purple-light' | 'brown-light'
|
|
39
39
|
| 'orange-light' | 'turquoise-light' | 'pink-light' | 'gray-light' | 'primary-light'
|
|
40
|
-
// Legacy tint variants
|
|
40
|
+
// Legacy tint variants
|
|
41
41
|
| 'blue-tint' | 'red-tint' | 'primary-tint' | 'black-tint' | 'blue-dark' | 'light'
|
|
42
42
|
// 10% variants (lightest)
|
|
43
43
|
| 'blue-10' | 'green-10' | 'red-10' | 'yellow-10' | 'purple-10' | 'brown-10' | 'orange-10' | 'turquoise-10' | 'gray-10' | 'black-10' | 'pink-10'
|
|
@@ -103,7 +103,7 @@ export function getBaseField<T, P extends Path<T, PO>, PO extends PathsOptions =
|
|
|
103
103
|
labelOrRest: string | Partial<BaseBagelField<T, P>> = {},
|
|
104
104
|
rest: Partial<BaseBagelField<T, P>> = {}
|
|
105
105
|
): BaseBagelField<T, P, PO> {
|
|
106
|
-
if ('object'
|
|
106
|
+
if (typeof labelOrRest === 'object') { return { id, ...labelOrRest } }
|
|
107
107
|
return { id, label: labelOrRest, ...rest }
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -429,7 +429,7 @@ export function rangeField<
|
|
|
429
429
|
}
|
|
430
430
|
|
|
431
431
|
export function bglForm<T>(idOrField?: string | FieldByP<T, Path<T>>, ...schema: FieldByP<T, Path<T>>[]) {
|
|
432
|
-
if ('string'
|
|
432
|
+
if (typeof idOrField === 'string') {
|
|
433
433
|
return {
|
|
434
434
|
$el: 'bagelform',
|
|
435
435
|
id: idOrField,
|
|
@@ -497,13 +497,13 @@ export function colorField<
|
|
|
497
497
|
|
|
498
498
|
export function findBglFieldById<T>(id: string, _schema: ShallowBglFormSchemaT<T>): FieldByP<T, Path<T>> | undefined {
|
|
499
499
|
for (const field of _schema) {
|
|
500
|
-
if (field.id === id) {return field as FieldByP<T, Path<T>> | undefined}
|
|
501
|
-
if (field.children &&
|
|
500
|
+
if (field.id === id) { return field as FieldByP<T, Path<T>> | undefined }
|
|
501
|
+
if (field.children && Number(field.children.length) > 0) {
|
|
502
502
|
const fieldChildren = field.children.filter(
|
|
503
|
-
c => 'object'
|
|
503
|
+
c => typeof c === 'object' && '$el' in c
|
|
504
504
|
)
|
|
505
505
|
const child = findBglFieldById(id, fieldChildren as ShallowBglFormSchemaT<T>)
|
|
506
|
-
if (child) {return child as FieldByP<T, Path<T>> | undefined}
|
|
506
|
+
if (child) { return child as FieldByP<T, Path<T>> | undefined }
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
509
|
return undefined
|
|
@@ -531,7 +531,7 @@ export function arrField<
|
|
|
531
531
|
options?: ArrayFieldOptions<T, P>
|
|
532
532
|
): ArrayBagelField<T, P, PO> {
|
|
533
533
|
const arraySpecificAttrs = (
|
|
534
|
-
|
|
534
|
+
typeof schemaOrType === 'string'
|
|
535
535
|
? { type: schemaOrType }
|
|
536
536
|
: { schema: schemaOrType }
|
|
537
537
|
)
|
|
@@ -11,7 +11,7 @@ export default class Helpers {
|
|
|
11
11
|
* otherwise just use navigator.language
|
|
12
12
|
*/
|
|
13
13
|
static getBrowserNavigatorLocale(): string {
|
|
14
|
-
if ('object'
|
|
14
|
+
if (typeof navigator !== 'object') { return 'en-US' }
|
|
15
15
|
|
|
16
16
|
return navigator.languages && navigator.languages.length
|
|
17
17
|
? navigator.languages[0]
|
|
@@ -22,16 +22,16 @@ export default class Helpers {
|
|
|
22
22
|
* Solution from https://github.com/vuejs/core/issues/4733#issuecomment-1024816095
|
|
23
23
|
*/
|
|
24
24
|
static hasSlotContent(slot: Slot | undefined) {
|
|
25
|
-
if (!slot) {return false}
|
|
25
|
+
if (!slot) { return false }
|
|
26
26
|
|
|
27
27
|
return slot().some((vnode: VNode) => {
|
|
28
|
-
if (vnode.type === Comment) {return false}
|
|
28
|
+
if (vnode.type === Comment) { return false }
|
|
29
29
|
|
|
30
|
-
if (Array.isArray(vnode.children) && !vnode.children.length) {return false}
|
|
30
|
+
if (Array.isArray(vnode.children) && !vnode.children.length) { return false }
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
33
|
vnode.type !== Text
|
|
34
|
-
|| (
|
|
34
|
+
|| (typeof vnode.children === 'string' && vnode.children.trim() !== '')
|
|
35
35
|
)
|
|
36
36
|
})
|
|
37
37
|
}
|
|
@@ -43,9 +43,9 @@ export default class Helpers {
|
|
|
43
43
|
const isFullDayEvent = DATE_TIME_STRING_FULL_DAY_PATTERN.test(event.time.start)
|
|
44
44
|
&& DATE_TIME_STRING_FULL_DAY_PATTERN.test(event.time.end)
|
|
45
45
|
|
|
46
|
-
if (isTimedEvent) {return this.getTimedEventType(event, time)}
|
|
46
|
+
if (isTimedEvent) { return this.getTimedEventType(event, time) }
|
|
47
47
|
|
|
48
|
-
if (isFullDayEvent) {return this.getFullDayEventType(event, time)}
|
|
48
|
+
if (isFullDayEvent) { return this.getFullDayEventType(event, time) }
|
|
49
49
|
|
|
50
50
|
throw new Error('Event has invalid type')
|
|
51
51
|
}
|
|
@@ -81,6 +81,6 @@ export default class Helpers {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
static isUIEventTouchEvent(event: UIEvent): boolean {
|
|
84
|
-
return 'touches' in event &&
|
|
84
|
+
return 'touches' in event && typeof event.touches === 'object'
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -112,8 +112,8 @@ const translations: Record<AvailableTimeLanguages, LanguageTranslations> = {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
export function timeAgo(date: string | Date, lang: AvailableTimeLanguages = 'en') {
|
|
115
|
-
if (!date) {return ''}
|
|
116
|
-
if ('string'
|
|
115
|
+
if (!date) { return '' }
|
|
116
|
+
if (typeof date === 'string') { date = new Date(date) }
|
|
117
117
|
const now: Date = new Date()
|
|
118
118
|
const nowNumber = now.getTime()
|
|
119
119
|
const dateNumber = date.getTime()
|
|
@@ -133,32 +133,32 @@ export function timeAgo(date: string | Date, lang: AvailableTimeLanguages = 'en'
|
|
|
133
133
|
|
|
134
134
|
for (const interval of intervals) {
|
|
135
135
|
const count = Math.floor(Math.abs(seconds) / interval.seconds)
|
|
136
|
-
if (
|
|
137
|
-
const suffix =
|
|
138
|
-
const prefix =
|
|
136
|
+
if (count >= 1) {
|
|
137
|
+
const suffix = seconds < 0 ? ` ${selectedLang.ago}` : ''
|
|
138
|
+
const prefix = seconds > 0 && selectedLang.in !== 'in' ? `${selectedLang.in} ` : ''
|
|
139
139
|
|
|
140
140
|
// Handle Hebrew plural forms
|
|
141
|
-
if ('he'
|
|
141
|
+
if (lang === 'he') {
|
|
142
142
|
const timeUnit = selectedLang[interval.label] as TimeUnit
|
|
143
|
-
const form =
|
|
143
|
+
const form = count === 1 ? timeUnit.singular : timeUnit.plural
|
|
144
144
|
|
|
145
145
|
// For Hebrew, we place the prefix/suffix before the number
|
|
146
|
-
const hebrewPrefix =
|
|
146
|
+
const hebrewPrefix = seconds < 0 ? `${selectedLang.ago} ` : (seconds > 0 ? `${selectedLang.in} ` : '')
|
|
147
147
|
|
|
148
|
-
if ('day'
|
|
148
|
+
if (interval.label === 'day' && seconds > 0) {
|
|
149
149
|
const hours = Math.floor((Math.abs(seconds) % 86400) / 3600)
|
|
150
150
|
const hourUnit = selectedLang.hour as TimeUnit
|
|
151
|
-
const hourForm =
|
|
152
|
-
return `${hebrewPrefix}${count} ${form}${ 0
|
|
151
|
+
const hourForm = hours === 1 ? hourUnit.singular : hourUnit.plural
|
|
152
|
+
return `${hebrewPrefix}${count} ${form}${hours > 0 ? ` ${hours} ${hourForm}` : ''}`
|
|
153
153
|
}
|
|
154
154
|
return `${hebrewPrefix}${count} ${form}`
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
// Handle other languages
|
|
158
|
-
if ('day'
|
|
158
|
+
if (interval.label === 'day' && seconds > 0) {
|
|
159
159
|
const hours = Math.floor((Math.abs(seconds) % 86400) / 3600)
|
|
160
|
-
const hourLabel =
|
|
161
|
-
return `${prefix}${count} ${selectedLang[interval.label]}${ 0
|
|
160
|
+
const hourLabel = hours > 1 ? `${selectedLang.hour}s` : selectedLang.hour
|
|
161
|
+
return `${prefix}${count} ${selectedLang[interval.label]}${hours > 0 ? ` ${hours} ${hourLabel}` : ''}${suffix}`
|
|
162
162
|
}
|
|
163
163
|
return `${prefix}${count} ${selectedLang[interval.label]}${suffix}`
|
|
164
164
|
}
|
|
@@ -168,7 +168,7 @@ export function timeAgo(date: string | Date, lang: AvailableTimeLanguages = 'en'
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
function getBrowserNavigatorLocale(): string {
|
|
171
|
-
if ('object'
|
|
171
|
+
if (typeof navigator !== 'object') { return 'en-US' }
|
|
172
172
|
return navigator.languages && navigator.languages.length
|
|
173
173
|
? navigator.languages[0]
|
|
174
174
|
: navigator.language
|
|
@@ -182,7 +182,7 @@ function getBrowserNavigatorLocale(): string {
|
|
|
182
182
|
*/
|
|
183
183
|
export function handleTimezone(date: Date, intFmtOpt: Intl.DateTimeFormatOptions): Date {
|
|
184
184
|
// If timeZone is UTC, convert to UTC directly
|
|
185
|
-
if ('UTC'
|
|
185
|
+
if (intFmtOpt.timeZone === 'UTC') {
|
|
186
186
|
const utcDate = new Date(date.getTime())
|
|
187
187
|
utcDate.setMinutes(utcDate.getMinutes() + date.getTimezoneOffset())
|
|
188
188
|
return utcDate
|
|
@@ -203,7 +203,7 @@ export function handleTimezone(date: Date, intFmtOpt: Intl.DateTimeFormatOptions
|
|
|
203
203
|
const parts: Record<string, number> = {}
|
|
204
204
|
|
|
205
205
|
formattedParts.forEach((part) => {
|
|
206
|
-
if ('literal'
|
|
206
|
+
if (part.type !== 'literal' && part.type !== 'timeZoneName') {
|
|
207
207
|
parts[part.type] = Number.parseInt(part.value, 10)
|
|
208
208
|
}
|
|
209
209
|
})
|
|
@@ -305,10 +305,10 @@ export function formatDate(
|
|
|
305
305
|
let rest: Partial<Pick<Intl.DateTimeFormatOptions, 'hour12'>> = {}
|
|
306
306
|
|
|
307
307
|
// Handle both overloads
|
|
308
|
-
if ('string'
|
|
308
|
+
if (typeof formatOrOpts === 'string') {
|
|
309
309
|
// First overload: format string directly
|
|
310
310
|
format = formatOrOpts
|
|
311
|
-
} else if (formatOrOpts && 'object'
|
|
311
|
+
} else if (formatOrOpts && typeof formatOrOpts === 'object') {
|
|
312
312
|
// Second overload: options object
|
|
313
313
|
format = formatOrOpts.fmt
|
|
314
314
|
locale = formatOrOpts.locale
|
|
@@ -316,13 +316,13 @@ export function formatDate(
|
|
|
316
316
|
rest = formatOrOpts
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
-
if (!date) {return ''}
|
|
319
|
+
if (!date) { return '' }
|
|
320
320
|
format = format || 'DD.MM.YY'
|
|
321
321
|
|
|
322
322
|
locale = locale || getBrowserNavigatorLocale()
|
|
323
323
|
try {
|
|
324
324
|
// Validate the date
|
|
325
|
-
const d = 'string'
|
|
325
|
+
const d = typeof date === 'string' || typeof date === 'number' ? new Date(date) : date
|
|
326
326
|
|
|
327
327
|
// Check if date is valid
|
|
328
328
|
if (Number.isNaN(d.getTime())) {
|
|
@@ -355,7 +355,7 @@ export function formatDate(
|
|
|
355
355
|
const partsMap: Partial<Record<Intl.DateTimeFormatPartTypes, string>> = {}
|
|
356
356
|
|
|
357
357
|
formattedParts.forEach((part) => {
|
|
358
|
-
if ('literal'
|
|
358
|
+
if (part.type !== 'literal') {
|
|
359
359
|
partsMap[part.type] = part.value
|
|
360
360
|
}
|
|
361
361
|
})
|
|
@@ -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
|
|