@bagelink/vue 1.20.33 → 1.20.39

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.
Files changed (36) hide show
  1. package/dist/components/Image.vue.d.ts +2 -0
  2. package/dist/components/Image.vue.d.ts.map +1 -1
  3. package/dist/components/charts/StatCard.vue.d.ts +3 -0
  4. package/dist/components/charts/StatCard.vue.d.ts.map +1 -1
  5. package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
  6. package/dist/components/form/inputs/RichText/config.d.ts.map +1 -1
  7. package/dist/components/form/inputs/RichText/richTextTypes.d.ts +1 -1
  8. package/dist/components/form/inputs/RichText/richTextTypes.d.ts.map +1 -1
  9. package/dist/components/form/inputs/RichText/utils/commands.d.ts.map +1 -1
  10. package/dist/components/form/inputs/RichText/utils/selection.d.ts +1 -1
  11. package/dist/components/form/inputs/RichText/utils/selection.d.ts.map +1 -1
  12. package/dist/components/form/inputs/Upload/AssetUploadInput.vue.d.ts +146 -2
  13. package/dist/components/form/inputs/Upload/AssetUploadInput.vue.d.ts.map +1 -1
  14. package/dist/components/form/inputs/Upload/UploadInput.vue.d.ts +78 -1
  15. package/dist/components/form/inputs/Upload/UploadInput.vue.d.ts.map +1 -1
  16. package/dist/core.css +1 -1
  17. package/dist/dialog/dialogTypes.d.ts +2 -0
  18. package/dist/dialog/dialogTypes.d.ts.map +1 -1
  19. package/dist/dialog/useDialog.d.ts.map +1 -1
  20. package/dist/index.cjs +40 -40
  21. package/dist/index.css +1 -1
  22. package/dist/index.mjs +9729 -9709
  23. package/dist/style.css +1 -1
  24. package/package.json +2 -2
  25. package/src/components/Image.vue +8 -0
  26. package/src/components/charts/StatCard.vue +7 -1
  27. package/src/components/form/inputs/DateInput.vue +1 -1
  28. package/src/components/form/inputs/DatePicker.vue +5 -1
  29. package/src/components/form/inputs/RichText/config.ts +5 -0
  30. package/src/components/form/inputs/RichText/richTextTypes.ts +1 -0
  31. package/src/components/form/inputs/RichText/utils/commands.ts +20 -22
  32. package/src/components/form/inputs/RichText/utils/selection.ts +2 -0
  33. package/src/components/form/inputs/Upload/AssetUploadInput.vue +7 -3
  34. package/src/components/form/inputs/Upload/UploadInput.vue +2 -1
  35. package/src/dialog/dialogTypes.ts +2 -0
  36. package/src/dialog/useDialog.ts +18 -32
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.20.33",
4
+ "version": "1.20.39",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -63,7 +63,7 @@
63
63
  "@types/signature_pad": "^4.0.0",
64
64
  "vue": "^3.5.43",
65
65
  "vue-component-type-helpers": "^2.2.12",
66
- "@bagelink/sdk": "1.20.33"
66
+ "@bagelink/sdk": "1.20.39"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@bagelink/sdk": "*",
@@ -27,6 +27,8 @@ interface ImageProps {
27
27
  blend?: string
28
28
  /** Rounded corners — true (default radius) or a px radius. */
29
29
  rounded?: boolean | number
30
+ /** Defer the download until the image nears the viewport. */
31
+ lazy?: boolean
30
32
  }
31
33
 
32
34
  const props = defineProps<ImageProps>()
@@ -110,6 +112,8 @@ const imgFit = computed(() => props.fit ?? 'cover')
110
112
  v-if="imageSrc"
111
113
  :src="imageSrc"
112
114
  :alt="alt"
115
+ :loading="lazy ? 'lazy' : undefined"
116
+ decoding="async"
113
117
  class="bgl-image-frame-img h-100p"
114
118
  :class="[frameHasHeight ? 'absolute-fill' : 'bgl-image-frame-img--flow', { 'opacity-0': !imageLoaded }]"
115
119
  :style="{ objectFit: imgFit, mixBlendMode: blend } as StyleValue"
@@ -130,6 +134,8 @@ const imgFit = computed(() => props.fit ?? 'cover')
130
134
  :src="imageSrc"
131
135
  v-bind="$attrs"
132
136
  :alt="alt"
137
+ :loading="lazy ? 'lazy' : undefined"
138
+ decoding="async"
133
139
  :width="normalizeDimension(width)"
134
140
  :height="normalizeDimension(height)"
135
141
  :class="{ 'opacity-0': !imageLoaded }"
@@ -155,6 +161,8 @@ const imgFit = computed(() => props.fit ?? 'cover')
155
161
  v-if="imageSrc"
156
162
  :src="imageSrc"
157
163
  :alt="alt"
164
+ :loading="lazy ? 'lazy' : undefined"
165
+ decoding="async"
158
166
  class="w-100p h-100p"
159
167
  :class="{ 'opacity-0': !imageLoaded }"
160
168
  :style="{ objectFit: imgFit }"
@@ -32,6 +32,9 @@ const props = withDefaults(defineProps<{
32
32
  prefix?: string
33
33
  suffix?: string
34
34
  subtitle?: string
35
+ /** Small muted line under the value — a secondary figure such as
36
+ "1,080 unique" without inflating the headline number. */
37
+ caption?: string
35
38
  loading?: boolean
36
39
  /** Outlined card (transparent bg + border), like `<Card outline>`. */
37
40
  outline?: boolean
@@ -71,7 +74,10 @@ const good = computed(() => (props.invertChange ? !up.value : up.value))
71
74
  </div>
72
75
 
73
76
  <div class="flex space-between w-100p align-items-end gap-1">
74
- <span class="txt28 m_txt24 semibold line-height-1 tabular-nums" :class="{ 'opacity-4': loading }">{{ loading ? '…' : formatted }}</span>
77
+ <div class="grid gap-025 min-w-0">
78
+ <span class="txt28 m_txt24 semibold line-height-1 tabular-nums" :class="{ 'opacity-4': loading }">{{ loading ? '…' : formatted }}</span>
79
+ <p v-if="caption" class="txt12 color-gray m-0 ellipsis-1">{{ caption }}</p>
80
+ </div>
75
81
  <Sparkline v-if="trend?.length" :data="trend" :color="color" area class="flex-shrink-0 opacity-9" :width="96" :height="32" />
76
82
  </div>
77
83
  </Card>
@@ -111,7 +111,7 @@ function parseUserInput(input: string): Date | null {
111
111
  }
112
112
 
113
113
  function normalizeDate(date: Date): string {
114
- if (props.enableTime) return date.toISOString()
114
+ if (props.enableTime) return local.iso(date)
115
115
  // Local calendar day — not toISOString().slice(0,10), which shifts TZ≠UTC.
116
116
  return local.date(date)
117
117
  }
@@ -381,7 +381,11 @@ function useTimeHandling() {
381
381
  // Centralized date emission function
382
382
  function emitDateValue(date: Date) {
383
383
  if (props.enableTime) {
384
- emit('update:modelValue', date.toISOString())
384
+ // Local ISO with device TZ offset ("…T11:00:00.000+03:00"). This keeps the
385
+ // user's wall-clock time intact for naive `timestamp` columns and still
386
+ // round-trips correctly through `timestamptz` columns. `toISOString()`
387
+ // would shift the time by the UTC offset.
388
+ emit('update:modelValue', local.iso(date))
385
389
  } else {
386
390
  // Date-only → YYYY-MM-DD (JSON Schema format: "date"). Never toISOString():
387
391
  // local midnight becomes the previous UTC day (e.g. Asia/Jerusalem).
@@ -28,10 +28,13 @@ export const basicToolbarConfig: ToolbarConfig = [
28
28
  'blockquote',
29
29
  'orderedList',
30
30
  'unorderedList',
31
+ 'indent',
32
+ 'outdent',
31
33
  'separator',
32
34
  'bold',
33
35
  'italic',
34
36
  'underline',
37
+ 'superscript',
35
38
  'separator',
36
39
  'paragraphToolsMenu',
37
40
  'separator',
@@ -61,6 +64,7 @@ export const fullToolbarConfig: ToolbarConfig = [
61
64
  'bold',
62
65
  'italic',
63
66
  'underline',
67
+ 'superscript',
64
68
  'separator',
65
69
  'fontColor',
66
70
  'bgColor',
@@ -107,6 +111,7 @@ export const toolbarOptions: ToolbarOption[] = [
107
111
  { name: 'bold', label: 'Bold', icon: 'format_bold', shortcut: '⌘/Ctrl+B' },
108
112
  { name: 'italic', label: 'Italic', icon: 'format_italic', shortcut: '⌘/Ctrl+I' },
109
113
  { name: 'underline', label: 'Underline', icon: 'format_underlined', shortcut: '⌘/Ctrl+U' },
114
+ { name: 'superscript', label: 'Superscript', icon: 'superscript' },
110
115
  { name: 'orderedList', label: 'Ordered List', icon: 'format_list_numbered', shortcut: '⌘/Ctrl+Shift+.' },
111
116
  { name: 'unorderedList', label: 'Unordered List', icon: 'format_list_bulleted', shortcut: '⌘/Ctrl+Shift+/' },
112
117
  { name: 'link', label: 'Link', icon: 'add_link', shortcut: '⌘/Ctrl+K' },
@@ -40,6 +40,7 @@ export type FormattingCommand =
40
40
  | 'bold'
41
41
  | 'italic'
42
42
  | 'underline'
43
+ | 'superscript'
43
44
  | 'formatBlock'
44
45
  | 'orderedList'
45
46
  | 'unorderedList'
@@ -251,7 +251,7 @@ function applyFormattingToWordAtCursor(doc: Document, range: Range, tagSelector:
251
251
 
252
252
  function toggleInlineFormatting(
253
253
  state: EditorState,
254
- tagName: 'b' | 'i' | 'u',
254
+ tagName: 'b' | 'i' | 'u' | 'sup',
255
255
  matchSelector: string
256
256
  ) {
257
257
  const selectionInfo = getCurrentSelection(state)
@@ -663,6 +663,18 @@ function updateStateAfterCommand(state: EditorState, preCommandContent?: string)
663
663
  }
664
664
  }
665
665
 
666
+ function shiftBlockIndent(doc: Document, range: Range, delta: number) {
667
+ const listItems = getSelectedListItems(doc, range)
668
+ const blocks = listItems.length
669
+ ? listItems
670
+ : [findBlockElement(range.commonAncestorContainer)].filter(Boolean) as HTMLElement[]
671
+ blocks.forEach((block) => {
672
+ const current = Number.parseInt(block.style.paddingInlineStart || '0', 10) || 0
673
+ const next = Math.max(0, current + delta)
674
+ block.style.paddingInlineStart = next > 0 ? `${next}px` : ''
675
+ })
676
+ }
677
+
666
678
  function findBlockElement(node: Node): HTMLElement | null {
667
679
  let current = node.nodeType === Node.TEXT_NODE ? node.parentElement : node as HTMLElement | null
668
680
  while (current) {
@@ -1028,6 +1040,11 @@ export function createCommandRegistry(state: EditorState): CommandRegistry {
1028
1040
  s => toggleUnderline(s),
1029
1041
  s => Boolean(s.doc && isStyleActive('underline', s.doc))
1030
1042
  ),
1043
+ superscript: createCommand(
1044
+ 'Superscript',
1045
+ s => toggleInlineFormatting(s, 'sup', 'sup'),
1046
+ s => Boolean(s.doc && isStyleActive('superscript', s.doc))
1047
+ ),
1031
1048
  link: createCommand('Link', (s) => {
1032
1049
  const { openLinkModal } = s as any
1033
1050
  if (openLinkModal) {
@@ -1122,33 +1139,14 @@ export function createCommandRegistry(state: EditorState): CommandRegistry {
1122
1139
  const selectionInfo = getCurrentSelection(s)
1123
1140
  if (!selectionInfo || !s.doc) { return }
1124
1141
  if (indentSelectedListItems(s.doc, selectionInfo.selection, selectionInfo.range)) { return }
1125
- const listItems = getSelectedListItems(s.doc, selectionInfo.range)
1126
- const blocks = listItems.length
1127
- ? listItems
1128
- : [findBlockElement(selectionInfo.range.commonAncestorContainer)].filter(Boolean) as HTMLElement[]
1129
- blocks.forEach((block) => {
1130
- const isRTL = (block.dir || s.doc?.body.dir) === 'rtl'
1131
- const prop = isRTL ? 'marginRight' : 'marginLeft'
1132
- const current = Number.parseInt(block.style[prop] || '0', 10) || 0
1133
- block.style[prop] = `${current + 24}px`
1134
- })
1142
+ shiftBlockIndent(s.doc, selectionInfo.range, 24)
1135
1143
  }),
1136
1144
 
1137
1145
  outdent: createCommand('Outdent', (s) => {
1138
1146
  const selectionInfo = getCurrentSelection(s)
1139
1147
  if (!selectionInfo || !s.doc) { return }
1140
1148
  if (outdentSelectedListItems(s.doc, selectionInfo.selection, selectionInfo.range)) { return }
1141
- const listItems = getSelectedListItems(s.doc, selectionInfo.range)
1142
- const blocks = listItems.length
1143
- ? listItems
1144
- : [findBlockElement(selectionInfo.range.commonAncestorContainer)].filter(Boolean) as HTMLElement[]
1145
- blocks.forEach((block) => {
1146
- const isRTL = (block.dir || s.doc?.body.dir) === 'rtl'
1147
- const prop = isRTL ? 'marginRight' : 'marginLeft'
1148
- const current = Number.parseInt(block.style[prop] || '0', 10) || 0
1149
- const next = Math.max(0, current - 24)
1150
- block.style[prop] = next > 0 ? `${next}px` : ''
1151
- })
1149
+ shiftBlockIndent(s.doc, selectionInfo.range, -24)
1152
1150
  })
1153
1151
  }
1154
1152
 
@@ -5,6 +5,7 @@ export const ACTIVE_STYLE_KEYS = [
5
5
  'bold',
6
6
  'italic',
7
7
  'underline',
8
+ 'superscript',
8
9
  'link',
9
10
  'h1',
10
11
  'h2',
@@ -118,6 +119,7 @@ export function isStyleActive(style: string, doc: Document): boolean {
118
119
  },
119
120
  // `<u>` tags and CSS-driven underlines (e.g. the browser default on `<a>`)
120
121
  underline: el => isElementVisuallyUnderlined(el),
122
+ superscript: (el) => el.tagName?.toLowerCase() === 'sup',
121
123
  link: (el) => {
122
124
  return el.tagName?.toLowerCase() === 'a'
123
125
  },
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, inject, onScopeDispose, ref, useSlots } from 'vue'
3
- import type { CSSProperties } from 'vue'
3
+ import type { CSSProperties, Slots } from 'vue'
4
4
  import { Btn, Card, Dialog, Icon, Progress, resolveI18n, useI18n } from '../../../../index'
5
5
  import { ASSET_CLIENT_KEY, useAssetUpload, type AssetReference } from '../../../../assets'
6
6
  import { useFileUpload } from './useFileUpload'
@@ -50,7 +50,7 @@ const emit = defineEmits<{
50
50
  }>()
51
51
 
52
52
  const { $t } = useI18n()
53
- const slots = useSlots()
53
+ const slots: Slots = useSlots()
54
54
  const client = inject(ASSET_CLIENT_KEY, undefined)
55
55
  const { upload, uploading, cancel } = useAssetUpload()
56
56
  const { shellClass, shellStyle } = useBagelInputShell(props)
@@ -66,6 +66,10 @@ function output(items: AssetReference[]) {
66
66
  emit('update:modelValue', props.multiple ? items : items[0])
67
67
  }
68
68
 
69
+ function handleCropDialogOpen(value: boolean) {
70
+ if (!value) finishCrop()
71
+ }
72
+
69
73
  function urlFor(value: AssetReference) {
70
74
  return client?.assetUrl(value)
71
75
  }
@@ -703,7 +707,7 @@ const listStyle = computed<CSSProperties | undefined>(() => {
703
707
  <Dialog
704
708
  v-if="cropperAvailable"
705
709
  :open="cropOpen" :title="$t('upload.cropTitle')" width="m"
706
- @update:open="value => { if (!value) finishCrop() }"
710
+ @update:open="handleCropDialogOpen"
707
711
  >
708
712
  <ImageCropper
709
713
  v-if="cropSrc" ref="cropper" :src="cropSrc" :aspect="cropAspect"
@@ -2,6 +2,7 @@
2
2
  import type { UploadInputProps } from '../../../../types/BagelForm'
3
3
  import { Btn, IMAGE_FORMATS_REGEXP, Icon, Card, Image, pathKeyToURL, Loading, useI18n, resolveI18n } from '../../../../index'
4
4
  import { watch, computed, ref, useSlots } from 'vue'
5
+ import type { Slots } from 'vue'
5
6
  import { useFileDropzone } from '../../../file-drop/useFileDropzone'
6
7
  import { useFileUpload } from './useFileUpload'
7
8
  import { useBagelInputShell } from '../bagelInputShell'
@@ -33,7 +34,7 @@ const props = withDefaults(defineProps<UploadInputProps & { previewState?: impor
33
34
  const emit = defineEmits(['update:modelValue', 'addFileStart', 'uploadError'])
34
35
 
35
36
  const { $t } = useI18n()
36
- const slots = useSlots()
37
+ const slots: Slots = useSlots()
37
38
  const {
38
39
  fileQueue,
39
40
  pathKeys,
@@ -43,6 +43,8 @@ export interface DialogConfirmOptions extends DialogBaseOptions {
43
43
  export interface DialogOpenOptions extends DialogBaseOptions {
44
44
  component: Component | string
45
45
  props?: Record<string, any>
46
+ /** Called when the dialog closes by any means (button, ESC, backdrop). */
47
+ onClose?: () => void
46
48
  }
47
49
 
48
50
  export interface DialogRef {
@@ -40,7 +40,7 @@ interface DialogStackItem {
40
40
  id: number
41
41
  type: 'form' | 'confirm' | 'open'
42
42
  options: any
43
- resolve: (value: any) => void
43
+ resolve: (value?: any) => void
44
44
  open: boolean
45
45
  }
46
46
 
@@ -82,30 +82,29 @@ export const DialogPlugin: Plugin = {
82
82
 
83
83
  open: (options: DialogOpenOptions): DialogRef => {
84
84
  const id = ++dialogId
85
+ const close = () => {
86
+ if (!item.open) return
87
+ item.open = false
88
+ options.onClose?.()
89
+ // Remove after animation
90
+ setTimeout(() => {
91
+ const removeIdx = dialogStack.findIndex(d => d.id === id)
92
+ if (removeIdx !== -1) {
93
+ dialogStack.splice(removeIdx, 1)
94
+ }
95
+ }, 200)
96
+ }
97
+
85
98
  const item: DialogStackItem = {
86
99
  id,
87
100
  type: 'open',
88
101
  options,
89
- resolve: () => {},
102
+ resolve: close,
90
103
  open: true
91
104
  }
92
105
  dialogStack.push(item)
93
106
 
94
- return {
95
- close: () => {
96
- const idx = dialogStack.findIndex(d => d.id === id)
97
- if (idx !== -1) {
98
- dialogStack[idx].open = false
99
- // Remove after animation
100
- setTimeout(() => {
101
- const removeIdx = dialogStack.findIndex(d => d.id === id)
102
- if (removeIdx !== -1) {
103
- dialogStack.splice(removeIdx, 1)
104
- }
105
- }, 200)
106
- }
107
- }
108
- }
107
+ return { close }
109
108
  }
110
109
  }
111
110
 
@@ -143,23 +142,10 @@ export const DialogPlugin: Plugin = {
143
142
  }, 200)
144
143
  }
145
144
 
146
- function handleOpenUpdate(item: DialogStackItem, open: boolean) {
147
- if (!open) {
148
- item.open = false
149
- setTimeout(() => {
150
- const idx = dialogStack.findIndex(d => d.id === item.id)
151
- if (idx !== -1) {
152
- dialogStack.splice(idx, 1)
153
- }
154
- }, 200)
155
- }
156
- }
157
-
158
145
  return {
159
146
  dialogStack,
160
147
  handleFormResolve,
161
- handleConfirmResolve,
162
- handleOpenUpdate
148
+ handleConfirmResolve
163
149
  }
164
150
  },
165
151
  render() {
@@ -206,7 +192,7 @@ export const DialogPlugin: Plugin = {
206
192
  'position': opts.position,
207
193
  'dismissable': opts.dismissable,
208
194
  'class': opts.class,
209
- 'onUpdate:open': (open: boolean) => { this.handleOpenUpdate(item, open) }
195
+ 'onUpdate:open': (open: boolean) => { if (!open) item.resolve() }
210
196
  }, {
211
197
  default: () => h(
212
198
  typeof opts.component === 'string' ? opts.component : opts.component,