@bagelink/vue 1.6.47 → 1.6.51
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/Zoomer.vue.d.ts +0 -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/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/index.cjs +34 -25
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +6668 -5883
- package/dist/plugins/useToast.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +5 -10
- package/src/components/AccordionItem.vue +11 -11
- 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 +20 -13
- 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 +9 -8
- 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/Zoomer.vue +165 -170
- 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/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/AppLayout.vue +2 -2
- package/src/components/layout/AppSidebar.vue +77 -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 +22 -22
- 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/useToast.ts +56 -51
- 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
|
@@ -36,7 +36,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
36
36
|
const dropTarget = ref<DraggableElement | null>(null)
|
|
37
37
|
|
|
38
38
|
// Only run in browser environment
|
|
39
|
-
const isBrowser = 'undefined'
|
|
39
|
+
const isBrowser = typeof window !== 'undefined'
|
|
40
40
|
|
|
41
41
|
// Move style injection into setup
|
|
42
42
|
if (isBrowser) {
|
|
@@ -79,7 +79,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
79
79
|
const POSITION_CACHE = new Map<number, { top: number, bottom: number }>()
|
|
80
80
|
|
|
81
81
|
function createGhost(el: DraggableElement) {
|
|
82
|
-
if (!isBrowser) {return null}
|
|
82
|
+
if (!isBrowser) { return null }
|
|
83
83
|
const ghost = el.cloneNode(true) as HTMLElement
|
|
84
84
|
const rect = el.getBoundingClientRect()
|
|
85
85
|
ghost.style.position = 'fixed'
|
|
@@ -99,7 +99,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
function createDropIndicator(el: DraggableElement) {
|
|
102
|
-
if (!isBrowser) {return null}
|
|
102
|
+
if (!isBrowser) { return null }
|
|
103
103
|
const line = document.createElement('div')
|
|
104
104
|
line.classList.add(defaultOptions.dropIndicatorClass!)
|
|
105
105
|
line.style.position = 'fixed'
|
|
@@ -127,7 +127,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
function updateDropIndicator(target: DraggableElement, isAfter: boolean) {
|
|
130
|
-
if (!dropIndicator.value) {return}
|
|
130
|
+
if (!dropIndicator.value) { return }
|
|
131
131
|
|
|
132
132
|
const rect = target.getBoundingClientRect()
|
|
133
133
|
dropIndicator.value.style.display = 'block'
|
|
@@ -144,7 +144,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
144
144
|
|
|
145
145
|
function findDraggableParent(element: Element | null): DraggableElement | null {
|
|
146
146
|
let current = element
|
|
147
|
-
while (current && (!('__drag_group' in current) ||
|
|
147
|
+
while (current && (!('__drag_group' in current) || (current as any).dataset.draggable === 'false')) {
|
|
148
148
|
current = current.parentElement
|
|
149
149
|
}
|
|
150
150
|
return current as DraggableElement | null
|
|
@@ -185,11 +185,11 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
185
185
|
const now = Date.now()
|
|
186
186
|
if (now - lastUpdateTime < UPDATE_THRESHOLD) {
|
|
187
187
|
// Return last calculated index if we're within threshold
|
|
188
|
-
return
|
|
188
|
+
return lastDropIndex !== -1 ? lastDropIndex : dragIndex
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
// Use cached positions if available, otherwise calculate new ones
|
|
192
|
-
if (
|
|
192
|
+
if (POSITION_CACHE.size === 0) {
|
|
193
193
|
cacheElementPositions(draggedList)
|
|
194
194
|
}
|
|
195
195
|
|
|
@@ -197,7 +197,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
197
197
|
const targetIndex = draggedList.indexOf(newDropTarget)
|
|
198
198
|
const targetPos = POSITION_CACHE.get(targetIndex)
|
|
199
199
|
|
|
200
|
-
if (!targetPos) {return dragIndex}
|
|
200
|
+
if (!targetPos) { return dragIndex }
|
|
201
201
|
|
|
202
202
|
const elementHeight = targetPos.bottom - targetPos.top
|
|
203
203
|
const relativeY = mouseY - targetPos.top
|
|
@@ -211,19 +211,19 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
211
211
|
// Different behavior based on context
|
|
212
212
|
if (targetIndex === dragIndex) {
|
|
213
213
|
// On original element - require significant movement
|
|
214
|
-
if (relativeY > lowerSticky) {dropIndex += 1}
|
|
214
|
+
if (relativeY > lowerSticky) { dropIndex += 1 }
|
|
215
215
|
} else if (targetIndex === lastDropIndex) {
|
|
216
216
|
// On previously targeted element - use sticky zones
|
|
217
217
|
if (targetIndex > dragIndex) {
|
|
218
|
-
if (relativeY < upperSticky) {dropIndex = targetIndex}
|
|
219
|
-
else {dropIndex = targetIndex + 1}
|
|
218
|
+
if (relativeY < upperSticky) { dropIndex = targetIndex }
|
|
219
|
+
else { dropIndex = targetIndex + 1 }
|
|
220
220
|
} else {
|
|
221
|
-
if (relativeY > lowerSticky) {dropIndex = targetIndex + 1}
|
|
222
|
-
else {dropIndex = targetIndex}
|
|
221
|
+
if (relativeY > lowerSticky) { dropIndex = targetIndex + 1 }
|
|
222
|
+
else { dropIndex = targetIndex }
|
|
223
223
|
}
|
|
224
224
|
} else {
|
|
225
225
|
// On new element - use 60/40 split
|
|
226
|
-
if (relativeY > elementHeight * 0.6) {dropIndex += 1}
|
|
226
|
+
if (relativeY > elementHeight * 0.6) { dropIndex += 1 }
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
// Update state
|
|
@@ -234,7 +234,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
function cleanup() {
|
|
237
|
-
if (!isBrowser) {return}
|
|
237
|
+
if (!isBrowser) { return }
|
|
238
238
|
|
|
239
239
|
document.removeEventListener('mousemove', onDragMove)
|
|
240
240
|
document.removeEventListener('mouseup', onDragEnd)
|
|
@@ -294,23 +294,23 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
function onKeyDown(e: KeyboardEvent) {
|
|
297
|
-
if ('Escape'
|
|
297
|
+
if (e.key === 'Escape' && isDragging.value) {
|
|
298
298
|
cleanup()
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
function onDragStart(e: MouseEvent) {
|
|
303
|
-
if (!isBrowser || defaultOptions.disabled) {return}
|
|
304
|
-
if (
|
|
305
|
-
if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) {return}
|
|
303
|
+
if (!isBrowser || defaultOptions.disabled) { return }
|
|
304
|
+
if (e.button !== 0) { return } // Only left mouse button
|
|
305
|
+
if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) { return }
|
|
306
306
|
|
|
307
307
|
const dragEl = findDraggableParent(e.target as Element)
|
|
308
|
-
if (!dragEl ||
|
|
308
|
+
if (!dragEl || dragEl.dataset.draggable === 'false') { return }
|
|
309
309
|
|
|
310
310
|
// If handle is specified, check if clicked element matches
|
|
311
311
|
if (defaultOptions.handle) {
|
|
312
312
|
const handleEl = (e.target as Element).closest(defaultOptions.handle)
|
|
313
|
-
if (!handleEl || !dragEl.contains(handleEl)) {return}
|
|
313
|
+
if (!handleEl || !dragEl.contains(handleEl)) { return }
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
e.preventDefault()
|
|
@@ -332,13 +332,13 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
// Only create drop indicator in line mode
|
|
335
|
-
if ('line'
|
|
335
|
+
if (defaultOptions.mode === 'line') {
|
|
336
336
|
dropIndicator.value = createDropIndicator(dragEl)
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
// Apply mode-specific styles and get shift amount
|
|
340
340
|
dragEl.classList.add(defaultOptions.dragClass!)
|
|
341
|
-
shiftAmount = 'ghost'
|
|
341
|
+
shiftAmount = defaultOptions.mode === 'ghost'
|
|
342
342
|
? handleGhostMode(dragEl)
|
|
343
343
|
: handleLineMode(dragEl)
|
|
344
344
|
|
|
@@ -370,8 +370,8 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
function autoScroll(e: MouseEvent) {
|
|
373
|
-
if (!dragElement.value) {return}
|
|
374
|
-
if (scrollRAF) {cancelAnimationFrame(scrollRAF)}
|
|
373
|
+
if (!dragElement.value) { return }
|
|
374
|
+
if (scrollRAF) { cancelAnimationFrame(scrollRAF) }
|
|
375
375
|
|
|
376
376
|
scrollRAF = requestAnimationFrame(() => {
|
|
377
377
|
const scrollParent = findScrollParent(dragElement.value!) as HTMLElement
|
|
@@ -394,7 +394,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
function onDragMove(e: MouseEvent) {
|
|
397
|
-
if (!isDragging.value || !dragElement.value) {return}
|
|
397
|
+
if (!isDragging.value || !dragElement.value) { return }
|
|
398
398
|
|
|
399
399
|
// Move ghost element with cursor
|
|
400
400
|
if (ghostElement.value) {
|
|
@@ -405,7 +405,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
405
405
|
|
|
406
406
|
// Get the draggable list and current positions
|
|
407
407
|
const list = dragElement.value.__drag_list!
|
|
408
|
-
const draggedList = list.filter(el =>
|
|
408
|
+
const draggedList = list.filter(el => el.dataset.draggable !== 'false')
|
|
409
409
|
const dragIndex = draggedList.indexOf(dragElement.value)
|
|
410
410
|
|
|
411
411
|
// Find the element at cursor position
|
|
@@ -428,7 +428,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
428
428
|
dropTarget.value.__intended_index = dropIndex
|
|
429
429
|
|
|
430
430
|
// Update line indicator
|
|
431
|
-
if (dropIndicator.value && 'line'
|
|
431
|
+
if (dropIndicator.value && defaultOptions.mode === 'line') {
|
|
432
432
|
const isAfter = dropIndex > dragIndex
|
|
433
433
|
updateDropIndicator(newDropTarget, isAfter)
|
|
434
434
|
}
|
|
@@ -441,7 +441,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
441
441
|
el.style.transform = 'translate3d(0, 0, 0)'
|
|
442
442
|
|
|
443
443
|
if (el === dragElement.value) {
|
|
444
|
-
if ('ghost'
|
|
444
|
+
if (defaultOptions.mode === 'ghost') {
|
|
445
445
|
const offset = (dropIndex - dragIndex) * shift
|
|
446
446
|
el.style.transform = `translate3d(0, ${offset}px, 0)`
|
|
447
447
|
}
|
|
@@ -475,11 +475,11 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
475
475
|
return
|
|
476
476
|
}
|
|
477
477
|
|
|
478
|
-
const draggedList = list.filter(el =>
|
|
478
|
+
const draggedList = list.filter(el => el.dataset.draggable !== 'false')
|
|
479
479
|
const actualDragIndex = draggedList.indexOf(dragElement.value)
|
|
480
480
|
const actualDropIndex = dropTarget.value.__intended_index!
|
|
481
481
|
|
|
482
|
-
if (
|
|
482
|
+
if (actualDragIndex !== -1 && actualDropIndex !== -1) {
|
|
483
483
|
list.forEach((el) => {
|
|
484
484
|
el.style.transition = 'none'
|
|
485
485
|
el.style.transform = ''
|
|
@@ -499,18 +499,18 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
499
499
|
}
|
|
500
500
|
|
|
501
501
|
function onTouchStart(e: TouchEvent) {
|
|
502
|
-
if (!isBrowser || defaultOptions.disabled || !e.target) {return}
|
|
502
|
+
if (!isBrowser || defaultOptions.disabled || !e.target) { return }
|
|
503
503
|
|
|
504
504
|
const touch = e.touches[0]
|
|
505
|
-
if (!touch) {return}
|
|
505
|
+
if (!touch) { return }
|
|
506
506
|
|
|
507
507
|
const target = e.target as Element
|
|
508
508
|
const draggableParent = findDraggableParent(target)
|
|
509
509
|
|
|
510
|
-
if (!draggableParent) {return}
|
|
510
|
+
if (!draggableParent) { return }
|
|
511
511
|
|
|
512
512
|
const { handle } = defaultOptions
|
|
513
|
-
if (handle && !target.closest(handle)) {return}
|
|
513
|
+
if (handle && !target.closest(handle)) { return }
|
|
514
514
|
|
|
515
515
|
e.preventDefault() // Prevent scrolling
|
|
516
516
|
isDragging.value = true
|
|
@@ -530,13 +530,13 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
530
530
|
}
|
|
531
531
|
|
|
532
532
|
// Only create drop indicator in line mode
|
|
533
|
-
if ('line'
|
|
533
|
+
if (defaultOptions.mode === 'line') {
|
|
534
534
|
dropIndicator.value = createDropIndicator(draggableParent)
|
|
535
535
|
}
|
|
536
536
|
|
|
537
537
|
// Apply mode-specific styles and get shift amount
|
|
538
538
|
dragElement.value.classList.add(defaultOptions.dragClass!)
|
|
539
|
-
shiftAmount = 'ghost'
|
|
539
|
+
shiftAmount = defaultOptions.mode === 'ghost'
|
|
540
540
|
? handleGhostMode(dragElement.value)
|
|
541
541
|
: handleLineMode(dragElement.value)
|
|
542
542
|
|
|
@@ -558,7 +558,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
558
558
|
function onTouchMove(e: TouchEvent) {
|
|
559
559
|
e.preventDefault() // Prevent scrolling
|
|
560
560
|
const touch = e.touches[0]
|
|
561
|
-
if (!touch) {return}
|
|
561
|
+
if (!touch) { return }
|
|
562
562
|
|
|
563
563
|
const mouseEvent = {
|
|
564
564
|
clientX: touch.clientX,
|
|
@@ -572,7 +572,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
572
572
|
|
|
573
573
|
function onTouchEnd(e: TouchEvent) {
|
|
574
574
|
const touch = e.changedTouches[0]
|
|
575
|
-
if (!touch) {return}
|
|
575
|
+
if (!touch) { return }
|
|
576
576
|
|
|
577
577
|
const mouseEvent = {
|
|
578
578
|
clientX: touch.clientX,
|
|
@@ -587,7 +587,7 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
587
587
|
}
|
|
588
588
|
|
|
589
589
|
function initDraggableContainer(container: HTMLElement) {
|
|
590
|
-
if (!isBrowser) {return}
|
|
590
|
+
if (!isBrowser) { return }
|
|
591
591
|
cleanupFn?.()
|
|
592
592
|
|
|
593
593
|
// Reset state
|
|
@@ -607,12 +607,12 @@ export function useDraggable(options: DraggableOptions = {}) {
|
|
|
607
607
|
|
|
608
608
|
let currentIndex = 0
|
|
609
609
|
elements.forEach((el, index) => {
|
|
610
|
-
if (
|
|
610
|
+
if (el.dataset.draggable !== 'false') {
|
|
611
611
|
el.style.userSelect = 'none'
|
|
612
612
|
el.style.webkitUserSelect = 'none'
|
|
613
613
|
el.__drag_group = options.group
|
|
614
614
|
el.__drag_index = currentIndex++
|
|
615
|
-
el.__drag_list = elements.filter(e =>
|
|
615
|
+
el.__drag_list = elements.filter(e => e.dataset.draggable !== 'false')
|
|
616
616
|
|
|
617
617
|
if (options.items) {
|
|
618
618
|
el.__drag_data = options.items[index]
|
|
@@ -45,7 +45,7 @@ onMounted(() => {
|
|
|
45
45
|
if (props.modelValue) {
|
|
46
46
|
initialFormData.value = clone(props.modelValue)
|
|
47
47
|
// Ensure formData is properly initialized with the model value
|
|
48
|
-
if (
|
|
48
|
+
if (Object.keys(formData.value).length === 0 && Object.keys(props.modelValue).length > 0) {
|
|
49
49
|
formData.value = clone(props.modelValue)
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -57,42 +57,42 @@ onMounted(() => {
|
|
|
57
57
|
|
|
58
58
|
// Watch for model changes
|
|
59
59
|
watch(() => props.modelValue, (val) => {
|
|
60
|
-
if (val !== undefined) {formData.value = clone(val)}
|
|
60
|
+
if (val !== undefined) { formData.value = clone(val) }
|
|
61
61
|
}, { immediate: true, deep: true })
|
|
62
62
|
|
|
63
63
|
let isApplyingDefaults = false
|
|
64
64
|
|
|
65
65
|
function applyDefaultValues() {
|
|
66
|
-
if (isApplyingDefaults) {return}
|
|
66
|
+
if (isApplyingDefaults) { return }
|
|
67
67
|
isApplyingDefaults = true
|
|
68
68
|
|
|
69
69
|
try {
|
|
70
70
|
const schema = resolvedSchema.value as unknown as Array<BaseBagelField<T, any>> | undefined
|
|
71
|
-
if (!schema) {return}
|
|
71
|
+
if (!schema) { return }
|
|
72
72
|
|
|
73
73
|
const walk = (nodes: any[]) => {
|
|
74
74
|
for (const node of nodes) {
|
|
75
|
-
if (!node || 'object'
|
|
76
|
-
const hasId =
|
|
75
|
+
if (!node || typeof node !== 'object') { continue }
|
|
76
|
+
const hasId = typeof node.id === 'string' && node.id.length > 0
|
|
77
77
|
const hasDefault = Object.hasOwn(node, 'defaultValue') && node.defaultValue !== undefined
|
|
78
78
|
if (hasId && hasDefault) {
|
|
79
79
|
const current = getNestedValue(formData.value as any, node.id as string, undefined)
|
|
80
80
|
|
|
81
81
|
// Skip arrays completely - let FieldArray manage its own defaults
|
|
82
|
-
if (
|
|
82
|
+
if (node.$el === 'array' || node.type === 'array') {
|
|
83
83
|
// Don't apply any defaults to arrays - let FieldArray handle it
|
|
84
84
|
continue
|
|
85
85
|
} else {
|
|
86
86
|
// Don't restore defaultValue for regular inputs - let user control their content
|
|
87
87
|
// Only apply defaultValue on initial load when truly undefined/null
|
|
88
|
-
if (current === undefined ||
|
|
88
|
+
if (current === undefined || current === null) {
|
|
89
89
|
updateFormData({ fieldId: node.id, value: node.defaultValue })
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
if (Array.isArray(node.children) && node.children.length) {walk(node.children)}
|
|
93
|
+
if (Array.isArray(node.children) && node.children.length) { walk(node.children) }
|
|
94
94
|
// Also check nested fields in array/object configurations
|
|
95
|
-
if (Array.isArray(node.fields) && node.fields.length) {walk(node.fields)}
|
|
95
|
+
if (Array.isArray(node.fields) && node.fields.length) { walk(node.fields) }
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
walk(schema as any[])
|
|
@@ -125,7 +125,7 @@ function updateFormData({ fieldId, value }: { fieldId?: string, value: any }) {
|
|
|
125
125
|
|
|
126
126
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
127
127
|
const key = keys[i]
|
|
128
|
-
if (!current[key] ||
|
|
128
|
+
if (!current[key] || typeof current[key] !== 'object') { current[key] = {} }
|
|
129
129
|
current = current[key]
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -142,8 +142,8 @@ const formError = ref<Error>()
|
|
|
142
142
|
async function handleSubmit() {
|
|
143
143
|
try {
|
|
144
144
|
const valid = validateForm()
|
|
145
|
-
if (!valid) {return}
|
|
146
|
-
if ('submitting'
|
|
145
|
+
if (!valid) { return }
|
|
146
|
+
if (formState.value === 'submitting') { return }
|
|
147
147
|
formState.value = 'submitting'
|
|
148
148
|
await props.onSubmit?.(formData.value)
|
|
149
149
|
initialFormData.value = clone(formData.value)
|
|
@@ -161,7 +161,7 @@ const { renderField } = useSchemaField<T>({
|
|
|
161
161
|
mode: 'form',
|
|
162
162
|
getFormData: () => formData.value,
|
|
163
163
|
onUpdateModelValue: (field, value) => {
|
|
164
|
-
if (!field.id) {return}
|
|
164
|
+
if (!field.id) { return }
|
|
165
165
|
|
|
166
166
|
updateFormData({ fieldId: field.id, value })
|
|
167
167
|
field.onUpdate?.(value, formData.value)
|
|
@@ -174,7 +174,7 @@ const renderSchemaField = (field: any) => renderField(field as BaseBagelField<T,
|
|
|
174
174
|
function handleSlotInputChange(event: Event) {
|
|
175
175
|
const input = event.target as HTMLInputElement
|
|
176
176
|
if (input.name) {
|
|
177
|
-
const value = 'checkbox'
|
|
177
|
+
const value = input.type === 'checkbox' ? input.checked : input.value
|
|
178
178
|
updateFormData({ fieldId: input.name, value })
|
|
179
179
|
}
|
|
180
180
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
const fieldSet = ref<HTMLFieldSetElement | undefined>()
|
|
5
|
+
const isDirty = ref(false)
|
|
6
|
+
const validateForm = () => fieldSet.value?.reportValidity()
|
|
5
7
|
defineExpose({ validateForm, isDirty })
|
|
6
8
|
</script>
|
|
7
9
|
|
|
@@ -49,7 +49,7 @@ const previousStep = ref(0)
|
|
|
49
49
|
const validatedSteps = ref<number[]>([])
|
|
50
50
|
|
|
51
51
|
function reportValidity() {
|
|
52
|
-
if (!formRef.value) {return false}
|
|
52
|
+
if (!formRef.value) { return false }
|
|
53
53
|
const isValid = formRef.value.validateForm()
|
|
54
54
|
|
|
55
55
|
if (isValid && !validatedSteps.value.includes(currentStep.value)) {
|
|
@@ -71,15 +71,15 @@ const filteredSchema = computed(() => {
|
|
|
71
71
|
if ((step as any).vIf !== undefined || (step as any)['v-if'] !== undefined) {
|
|
72
72
|
const condition = (step as any).vIf ?? (step as any)['v-if']
|
|
73
73
|
// If condition is a function, evaluate it with current form data
|
|
74
|
-
if ('function'
|
|
74
|
+
if (typeof condition === 'function') {
|
|
75
75
|
return condition(undefined, formData.value)
|
|
76
76
|
}
|
|
77
77
|
// If condition is a boolean, use it directly
|
|
78
|
-
if ('boolean'
|
|
78
|
+
if (typeof condition === 'boolean') {
|
|
79
79
|
return condition
|
|
80
80
|
}
|
|
81
81
|
// If condition is a string, evaluate it (treat non-empty as true)
|
|
82
|
-
if ('string'
|
|
82
|
+
if (typeof condition === 'string') {
|
|
83
83
|
return !!condition
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -98,11 +98,11 @@ const schemaIndexMap = computed(() => {
|
|
|
98
98
|
let shouldInclude = true
|
|
99
99
|
|
|
100
100
|
if (vIfCondition !== undefined) {
|
|
101
|
-
if ('function'
|
|
101
|
+
if (typeof vIfCondition === 'function') {
|
|
102
102
|
shouldInclude = vIfCondition(undefined, formData.value)
|
|
103
|
-
} else if ('boolean'
|
|
103
|
+
} else if (typeof vIfCondition === 'boolean') {
|
|
104
104
|
shouldInclude = vIfCondition
|
|
105
|
-
} else if ('string'
|
|
105
|
+
} else if (typeof vIfCondition === 'string') {
|
|
106
106
|
shouldInclude = !!vIfCondition
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -127,7 +127,7 @@ watch(
|
|
|
127
127
|
() => currentStep.value,
|
|
128
128
|
(newStep, oldStep) => {
|
|
129
129
|
// Set direction based on step change
|
|
130
|
-
if ('auto'
|
|
130
|
+
if (props.direction === 'auto') {
|
|
131
131
|
slideDirection.value = props.rtl
|
|
132
132
|
? (newStep > oldStep ? 'right' : 'left')
|
|
133
133
|
: (newStep > oldStep ? 'left' : 'right')
|
|
@@ -155,12 +155,12 @@ const isStepValid = ref(false)
|
|
|
155
155
|
|
|
156
156
|
async function checkCurrentStepValidity() {
|
|
157
157
|
await nextTick()
|
|
158
|
-
if (!props.validateOnSteps) {isStepValid.value = true}
|
|
159
|
-
else {isStepValid.value = formRef.value?.checkValidity() ?? false}
|
|
158
|
+
if (!props.validateOnSteps) { isStepValid.value = true }
|
|
159
|
+
else { isStepValid.value = formRef.value?.checkValidity() ?? false }
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
function prevStep() {
|
|
163
|
-
if (
|
|
163
|
+
if (currentStep.value > 0) { currentStep.value-- }
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
const formContainer = ref<HTMLElement>()
|
|
@@ -168,8 +168,8 @@ const formContainer = ref<HTMLElement>()
|
|
|
168
168
|
async function nextStep() {
|
|
169
169
|
// Always use reportValidity when attempting to move to next step
|
|
170
170
|
// This will show validation errors to the user
|
|
171
|
-
if (props.validateOnSteps &&
|
|
172
|
-
if (!isLastStep.value) {currentStep.value++}
|
|
171
|
+
if (props.validateOnSteps && reportValidity() === false) { return }
|
|
172
|
+
if (!isLastStep.value) { currentStep.value++ }
|
|
173
173
|
await sleep(400)
|
|
174
174
|
checkCurrentStepValidity()
|
|
175
175
|
}
|
|
@@ -184,7 +184,7 @@ async function goToStep(stepIndex: number) {
|
|
|
184
184
|
// For forward navigation, validate each step sequentially until target or invalid step
|
|
185
185
|
if (stepIndex > currentStep.value) {
|
|
186
186
|
// Validate current step first
|
|
187
|
-
if (props.validateOnSteps &&
|
|
187
|
+
if (props.validateOnSteps && reportValidity() === false) {
|
|
188
188
|
return false
|
|
189
189
|
}
|
|
190
190
|
|
|
@@ -206,11 +206,10 @@ async function goToStep(stepIndex: number) {
|
|
|
206
206
|
// If this step is invalid, stop here
|
|
207
207
|
return false
|
|
208
208
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
209
|
+
// Mark this step as validated
|
|
210
|
+
if (!validatedSteps.value.includes(step)) {
|
|
211
|
+
validatedSteps.value.push(step)
|
|
212
|
+
}
|
|
214
213
|
}
|
|
215
214
|
}
|
|
216
215
|
|
|
@@ -222,7 +221,7 @@ async function goToStep(stepIndex: number) {
|
|
|
222
221
|
|
|
223
222
|
function handleSubmit() {
|
|
224
223
|
// Show validation errors to the user when submitting
|
|
225
|
-
if (
|
|
224
|
+
if (reportValidity() === false) { return }
|
|
226
225
|
emits('submit', formData.value)
|
|
227
226
|
}
|
|
228
227
|
|
|
@@ -234,7 +233,7 @@ function reset() {
|
|
|
234
233
|
// Re-evaluate filtered steps when formData changes
|
|
235
234
|
watch(() => formData.value, () => {
|
|
236
235
|
checkCurrentStepValidity()
|
|
237
|
-
if (currentStep.value >= numberOfSteps.value &&
|
|
236
|
+
if (currentStep.value >= numberOfSteps.value && numberOfSteps.value > 0) {
|
|
238
237
|
currentStep.value = 0
|
|
239
238
|
}
|
|
240
239
|
}, { deep: true })
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts" generic="T extends boolean | undefined | any[]">
|
|
2
|
-
import { onMounted } from 'vue'
|
|
2
|
+
import { computed, onMounted } from 'vue'
|
|
3
3
|
|
|
4
4
|
const { defaultValue, id } = defineProps<{
|
|
5
5
|
label?: string
|
|
@@ -12,7 +12,7 @@ const { defaultValue, id } = defineProps<{
|
|
|
12
12
|
value?: any
|
|
13
13
|
}>()
|
|
14
14
|
|
|
15
|
-
const inputId =
|
|
15
|
+
const inputId = computed(() => id || Math.random().toString(36).slice(7))
|
|
16
16
|
|
|
17
17
|
const checked = defineModel<T>('modelValue', { default: undefined })
|
|
18
18
|
|
|
@@ -38,7 +38,7 @@ const format = {
|
|
|
38
38
|
for (let i = 0; i < jsCode.length; i++) {
|
|
39
39
|
const char = jsCode[i]
|
|
40
40
|
const nextChar = jsCode[i + 1]
|
|
41
|
-
if ('"'
|
|
41
|
+
if (char === '"' || char === '\'' || char === '`') {
|
|
42
42
|
formatted += char
|
|
43
43
|
if (inString.length && inString === char) {
|
|
44
44
|
inString = ''
|
|
@@ -51,25 +51,25 @@ const format = {
|
|
|
51
51
|
formatted += char
|
|
52
52
|
continue
|
|
53
53
|
}
|
|
54
|
-
if ('{'
|
|
54
|
+
if (char === '{' || char === '[') {
|
|
55
55
|
formatted += `${char}\n${tab.repeat(++level)}`
|
|
56
56
|
continue
|
|
57
57
|
}
|
|
58
|
-
if ('}'
|
|
58
|
+
if (char === '}' || char === ']') {
|
|
59
59
|
formatted += `\n${tab.repeat(--level)}${char}`
|
|
60
60
|
continue
|
|
61
61
|
}
|
|
62
|
-
if (';'
|
|
62
|
+
if (char === ';' || char === ',') {
|
|
63
63
|
formatted += `${char}\n${tab.repeat(level)}`
|
|
64
64
|
continue
|
|
65
65
|
}
|
|
66
|
-
if ('\n'
|
|
66
|
+
if (char === '\n') {
|
|
67
67
|
formatted += `\n${tab.repeat(level)}`
|
|
68
68
|
continue
|
|
69
69
|
}
|
|
70
70
|
if (
|
|
71
|
-
(')'
|
|
72
|
-
|| (')'
|
|
71
|
+
(char === ')' && nextChar === '{')
|
|
72
|
+
|| (char === ')' && nextChar === ' ')
|
|
73
73
|
) {
|
|
74
74
|
formatted += `${char}\n${tab.repeat(level)}`
|
|
75
75
|
continue
|
|
@@ -14,8 +14,8 @@ export function useHighlight(theme: HighlightTheme = 'dark') {
|
|
|
14
14
|
const currentTheme = ref<HighlightTheme>(theme)
|
|
15
15
|
|
|
16
16
|
const normalizeTheme = (t: HighlightTheme): HighlightTheme => {
|
|
17
|
-
if ('dark'
|
|
18
|
-
if ('light'
|
|
17
|
+
if (t === 'dark') { return 'atom-one-dark' }
|
|
18
|
+
if (t === 'light') { return 'atom-one-light' }
|
|
19
19
|
return t
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -24,14 +24,14 @@ export function useHighlight(theme: HighlightTheme = 'dark') {
|
|
|
24
24
|
const removeExistingThemeLinks = () => {
|
|
25
25
|
document.querySelectorAll('link[rel="stylesheet"]').forEach((link) => {
|
|
26
26
|
if (link instanceof HTMLLinkElement && link.href.includes('/styles/')) {
|
|
27
|
-
if (link.href.includes('highlight.js')) {link.parentElement?.removeChild(link)}
|
|
27
|
+
if (link.href.includes('highlight.js')) { link.parentElement?.removeChild(link) }
|
|
28
28
|
}
|
|
29
29
|
})
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
const setTheme = async (theme: HighlightTheme) => {
|
|
33
33
|
const next = normalizeTheme(theme)
|
|
34
|
-
if (next === currentTheme.value) {return}
|
|
34
|
+
if (next === currentTheme.value) { return }
|
|
35
35
|
try {
|
|
36
36
|
removeExistingThemeLinks()
|
|
37
37
|
const url = getThemeCssUrl(next)
|
|
@@ -48,7 +48,7 @@ export function useHighlight(theme: HighlightTheme = 'dark') {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const loadHighlight = async () => {
|
|
51
|
-
if (loaded.value) {return}
|
|
51
|
+
if (loaded.value) { return }
|
|
52
52
|
|
|
53
53
|
try {
|
|
54
54
|
// Load highlight.js
|
|
@@ -80,7 +80,7 @@ export function useHighlight(theme: HighlightTheme = 'dark') {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
const highlightCode = (code: string, language?: string, autodetect = true, ignoreIllegals = true) => {
|
|
83
|
-
if (!hljs.value) {return escapeHtml(code)}
|
|
83
|
+
if (!hljs.value) { return escapeHtml(code) }
|
|
84
84
|
|
|
85
85
|
try {
|
|
86
86
|
const lang = language || ''
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { Btn } from '@bagelink/vue'
|
|
3
|
-
import { watch } from 'vue'
|
|
3
|
+
import { ref, watch } from 'vue'
|
|
4
4
|
|
|
5
5
|
const props = withDefaults(
|
|
6
6
|
defineProps<{
|
|
@@ -18,10 +18,10 @@ const props = withDefaults(
|
|
|
18
18
|
},
|
|
19
19
|
)
|
|
20
20
|
const emits = defineEmits(['update:modelValue'])
|
|
21
|
-
const inputVal =
|
|
21
|
+
const inputVal = ref<string>(props.modelValue)
|
|
22
22
|
|
|
23
23
|
watch(
|
|
24
|
-
() => inputVal,
|
|
24
|
+
() => inputVal.value,
|
|
25
25
|
(newVal) => { emits('update:modelValue', newVal) },
|
|
26
26
|
)
|
|
27
27
|
</script>
|
|
@@ -36,7 +36,8 @@ watch(
|
|
|
36
36
|
v-model="inputVal" class="border" type="color" :placeholder="placeholder || label"
|
|
37
37
|
:class="{ 'no-edit': !editMode, 'opacity-1': !inputVal }" :required="required" v-bind="nativeInputAttrs"
|
|
38
38
|
>
|
|
39
|
-
<input
|
|
39
|
+
<input
|
|
40
|
+
v-if="!small"
|
|
40
41
|
v-model="inputVal"
|
|
41
42
|
class="flex-grow-1 border colorInputPick"
|
|
42
43
|
type="text"
|