@bagelink/vue 1.9.49 → 1.9.54

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 (79) hide show
  1. package/dist/components/AddressSearch.vue.d.ts.map +1 -1
  2. package/dist/components/Btn.vue.d.ts +2 -2
  3. package/dist/components/Btn.vue.d.ts.map +1 -1
  4. package/dist/components/Filter.vue.d.ts +0 -1
  5. package/dist/components/Filter.vue.d.ts.map +1 -1
  6. package/dist/components/ImportData.vue.d.ts.map +1 -1
  7. package/dist/components/ModalConfirm.vue.d.ts.map +1 -1
  8. package/dist/components/Spreadsheet/Index.vue.d.ts.map +1 -1
  9. package/dist/components/form/FieldArray.vue.d.ts.map +1 -1
  10. package/dist/components/form/inputs/ColorInput.vue.d.ts.map +1 -1
  11. package/dist/components/form/inputs/DateInput.vue.d.ts +1 -1
  12. package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
  13. package/dist/components/form/inputs/DatePicker.vue.d.ts +1 -1
  14. package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
  15. package/dist/components/form/inputs/EmailInput.vue.d.ts.map +1 -1
  16. package/dist/components/form/inputs/PasswordInput.vue.d.ts +1 -1
  17. package/dist/components/form/inputs/PasswordInput.vue.d.ts.map +1 -1
  18. package/dist/components/form/inputs/RadioPillsInput.vue.d.ts.map +1 -1
  19. package/dist/components/form/inputs/SelectInput.vue.d.ts +0 -1
  20. package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
  21. package/dist/components/form/inputs/TelInput.vue.d.ts.map +1 -1
  22. package/dist/components/form/inputs/Upload/UploadInput.vue.d.ts.map +1 -1
  23. package/dist/components/lightbox/Lightbox.vue.d.ts.map +1 -1
  24. package/dist/dialog/DialogConfirm.vue.d.ts +0 -3
  25. package/dist/dialog/DialogConfirm.vue.d.ts.map +1 -1
  26. package/dist/dialog/DialogForm.vue.d.ts.map +1 -1
  27. package/dist/form-flow/FormFlow.vue.d.ts.map +1 -1
  28. package/dist/form-flow/MultiStepForm.vue.d.ts.map +1 -1
  29. package/dist/i18n/index.d.ts +996 -0
  30. package/dist/i18n/index.d.ts.map +1 -0
  31. package/dist/index.cjs +135 -130
  32. package/dist/index.d.ts +2 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.mjs +15415 -11483
  35. package/dist/plugins/bagel.d.ts +5 -7
  36. package/dist/plugins/bagel.d.ts.map +1 -1
  37. package/dist/plugins/useToast.d.ts.map +1 -1
  38. package/dist/style.css +1 -1
  39. package/dist/utils/calendar/dateUtils.d.ts +4 -3
  40. package/dist/utils/calendar/dateUtils.d.ts.map +1 -1
  41. package/dist/utils/index.d.ts +0 -1
  42. package/dist/utils/index.d.ts.map +1 -1
  43. package/dist/utils/lang.d.ts +6 -7
  44. package/dist/utils/lang.d.ts.map +1 -1
  45. package/package.json +2 -1
  46. package/src/components/AddressSearch.vue +5 -2
  47. package/src/components/Btn.vue +8 -6
  48. package/src/components/Filter.vue +37 -76
  49. package/src/components/ImportData.vue +35 -29
  50. package/src/components/ModalConfirm.vue +9 -7
  51. package/src/components/Spreadsheet/Index.vue +35 -60
  52. package/src/components/form/FieldArray.vue +4 -2
  53. package/src/components/form/inputs/ColorInput.vue +18 -12
  54. package/src/components/form/inputs/DateInput.vue +7 -4
  55. package/src/components/form/inputs/EmailInput.vue +9 -7
  56. package/src/components/form/inputs/PasswordInput.vue +17 -15
  57. package/src/components/form/inputs/RadioPillsInput.vue +5 -3
  58. package/src/components/form/inputs/SelectInput.vue +13 -11
  59. package/src/components/form/inputs/TelInput.vue +11 -9
  60. package/src/components/form/inputs/Upload/UploadInput.vue +7 -5
  61. package/src/components/lightbox/Lightbox.vue +4 -1
  62. package/src/dialog/DialogConfirm.vue +11 -6
  63. package/src/dialog/DialogForm.vue +9 -9
  64. package/src/form-flow/FormFlow.vue +7 -15
  65. package/src/form-flow/MultiStepForm.vue +16 -12
  66. package/src/i18n/index.ts +130 -0
  67. package/src/i18n/locales/en.json +153 -0
  68. package/src/i18n/locales/es.json +153 -0
  69. package/src/i18n/locales/fr.json +153 -0
  70. package/src/i18n/locales/he.json +174 -0
  71. package/src/i18n/locales/it.json +153 -0
  72. package/src/i18n/locales/ru.json +153 -0
  73. package/src/index.ts +11 -5
  74. package/src/plugins/bagel.ts +14 -26
  75. package/src/plugins/useToast.ts +4 -2
  76. package/src/styles/text.css +2 -1
  77. package/src/utils/calendar/dateUtils.ts +91 -59
  78. package/src/utils/index.ts +0 -2
  79. package/src/utils/lang.ts +0 -46
@@ -1,27 +1,18 @@
1
- import type { InjectionKey, Plugin } from 'vue'
2
- import FloatingVue from 'floating-vue'
3
- import { inject } from 'vue'
1
+ import type { Plugin } from 'vue'
2
+ import type { CreateBagelI18nOptions } from '../i18n'
4
3
 
4
+ import type { BagelToastOptions } from './useToast'
5
+ import FloatingVue from 'floating-vue'
5
6
  import lightboxPlugin from '../components/lightbox/index'
6
7
  import { ripple, pattern } from '../directives'
7
- import { useLang } from '../utils'
8
+ import { createI18n, getI18n } from '../i18n'
8
9
  import clickOutside from '../utils/clickOutside'
9
10
  import { ModalPlugin } from './useModal'
10
- import { ToastPlugin, type BagelToastOptions } from './useToast'
11
-
12
- export const i18nTInjectionKey = Symbol('bagel') as InjectionKey<(key: string) => string>
13
-
14
- export function injectI18nT(injectionKey: typeof i18nTInjectionKey = i18nTInjectionKey) {
15
- const i18nT = inject(injectionKey)
16
- if (!i18nT) { throw new Error('No i18nT provided') }
17
- return i18nT
18
- }
11
+ import { ToastPlugin } from './useToast'
19
12
 
20
13
  export interface BagelOptions {
21
- availableLangs?: string[]
22
- defaultLang?: string
23
- language?: string
24
- i18nT?: (key: string) => string
14
+ /** i18n configuration options */
15
+ i18n?: CreateBagelI18nOptions
25
16
  toast?: BagelToastOptions
26
17
  }
27
18
 
@@ -48,14 +39,11 @@ export const BagelVue: Plugin<BagelOptions> = {
48
39
  },
49
40
  })
50
41
 
51
- // Setup language configuration
52
- const { availableLangs, defaultLang, lang } = useLang()
53
- if (options.availableLangs) { availableLangs.value = options.availableLangs }
54
- if (options.defaultLang) { defaultLang.value = options.defaultLang }
55
- if (options.language) { lang.value = options.language }
56
-
57
- // Setup i18n translation function
58
- app.config.globalProperties.$i18T = options.i18nT || ((key?: string) => key)
59
- app.provide(i18nTInjectionKey, options.i18nT || ((key: string) => key))
42
+ // Setup i18n
43
+ const i18n = createI18n(options.i18n || {})
44
+ app.use(i18n)
60
45
  },
61
46
  }
47
+
48
+ // Re-export getI18n for advanced usage
49
+ export { getI18n }
@@ -1,12 +1,14 @@
1
1
  import type { App, InjectionKey, Plugin } from 'vue'
2
2
  import type { PluginOptions as ToastOptions } from 'vue-toastification'
3
3
  import { inject } from 'vue'
4
- import Toast from 'vue-toastification'
4
+ import * as VueToastification from 'vue-toastification'
5
5
  import CustomToast from '../components/Toast.vue'
6
6
  import 'vue-toastification/dist/index.css'
7
7
  import '../styles/toast-overrides.css'
8
8
 
9
- const { POSITION, useToast: useVueToast } = Toast as any
9
+ const Toast = (VueToastification as any).default || VueToastification
10
+ const { POSITION } = VueToastification as any
11
+ const useVueToast = (VueToastification as any).useToast
10
12
 
11
13
  export interface ToastApi {
12
14
  success: (message: string, options?: any) => void
@@ -1358,7 +1358,8 @@
1358
1358
  -webkit-line-clamp: 6;
1359
1359
  }
1360
1360
 
1361
- .pointer {
1361
+ .pointer,
1362
+ .cursor-pointer {
1362
1363
  cursor: pointer;
1363
1364
  }
1364
1365
 
@@ -1,5 +1,6 @@
1
1
  import type { DateLike } from '@vueuse/core'
2
- import type { AvailableTimeLanguages, DateTimeAcceptedFormats, LanguageTranslations, TimeUnit } from '../../types/timeAgoT'
2
+ import type { DateTimeAcceptedFormats, TimeUnit } from '../../types/timeAgoT'
3
+ import { getI18n } from '../../i18n'
3
4
 
4
5
  interface TimeDeltaOptions {
5
6
  Day?: number
@@ -26,9 +27,7 @@ interface TimeDeltaOptions {
26
27
  }
27
28
 
28
29
  export function timeDelta(date: string | Date, options: TimeDeltaOptions) {
29
- console.log('date', date)
30
30
  date = new Date(date)
31
- console.log('date', date)
32
31
  const day = options.Day || options.day || options.days || 0
33
32
  const hour = options.Hour || options.hour || options.hours || 0
34
33
  const minute = options.Minute || options.minute || options.minutes || 0
@@ -60,66 +59,92 @@ export function timeDelta(date: string | Date, options: TimeDeltaOptions) {
60
59
  return date
61
60
  }
62
61
 
63
- const translations: Record<AvailableTimeLanguages, LanguageTranslations> = {
64
- en: {
65
- year: 'year',
66
- month: 'month',
67
- week: 'week',
68
- day: 'day',
69
- hour: 'hour',
70
- minute: 'minute',
71
- second: 'second',
72
- ago: 'ago',
73
- in: 'in',
74
- justNow: 'Just now'
75
- },
76
- es: {
77
- year: 'año',
78
- month: 'mes',
79
- week: 'semana',
80
- day: 'día',
81
- hour: 'hora',
82
- minute: 'minuto',
83
- second: 'segundo',
84
- ago: 'hace',
85
- in: 'en',
86
- justNow: 'Justo ahora'
87
- },
88
- fr: {
89
- year: 'an',
90
- month: 'mois',
91
- week: 'semaine',
92
- day: 'jour',
93
- hour: 'heure',
94
- minute: 'minute',
95
- second: 'seconde',
96
- ago: 'il y a',
97
- in: 'dans',
98
- justNow: 'À l\'instant'
99
- },
100
- he: {
101
- year: { singular: 'שנה', plural: 'שנים' },
102
- month: { singular: 'חודש', plural: 'חודשים' },
103
- week: { singular: 'שבוע', plural: 'שבועות' },
104
- day: { singular: 'יום', plural: 'ימים' },
105
- hour: { singular: 'שעה', plural: 'שעות' },
106
- minute: { singular: 'דקה', plural: 'דקות' },
107
- second: { singular: 'שנייה', plural: 'שניות' },
108
- ago: 'לפני',
109
- in: 'בעוד',
110
- justNow: 'זה עתה'
62
+ type TimeAgoLang = 'en' | 'es' | 'fr' | 'he' | 'it' | 'ru'
63
+
64
+ interface TimeAgoTranslations {
65
+ year: string | TimeUnit
66
+ month: string | TimeUnit
67
+ week: string | TimeUnit
68
+ day: string | TimeUnit
69
+ hour: string | TimeUnit
70
+ minute: string | TimeUnit
71
+ second: string | TimeUnit
72
+ ago: string
73
+ in: string
74
+ justNow: string
75
+ }
76
+
77
+ /**
78
+ * Get timeAgo translations from i18n instance
79
+ */
80
+ function getTimeAgoTranslations(lang: TimeAgoLang): TimeAgoTranslations {
81
+ try {
82
+ const i18n = getI18n()
83
+ const messages = i18n.global.messages as Record<string, { timeAgo?: TimeAgoTranslations }>
84
+ const localeMessages = messages[lang] || messages.en
85
+ if (localeMessages?.timeAgo) {
86
+ return localeMessages.timeAgo
87
+ }
88
+ // Fallback to English if timeAgo not found
89
+ return {
90
+ year: 'year',
91
+ month: 'month',
92
+ week: 'week',
93
+ day: 'day',
94
+ hour: 'hour',
95
+ minute: 'minute',
96
+ second: 'second',
97
+ ago: 'ago',
98
+ in: 'in',
99
+ justNow: 'Just now',
100
+ }
101
+ } catch {
102
+ // Fallback if i18n not initialized
103
+ return {
104
+ year: 'year',
105
+ month: 'month',
106
+ week: 'week',
107
+ day: 'day',
108
+ hour: 'hour',
109
+ minute: 'minute',
110
+ second: 'second',
111
+ ago: 'ago',
112
+ in: 'in',
113
+ justNow: 'Just now',
114
+ }
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Get current locale from i18n instance
120
+ */
121
+ function getCurrentLocale(): TimeAgoLang {
122
+ try {
123
+ const i18n = getI18n()
124
+ const { locale } = i18n.global
125
+ const lang = typeof locale === 'string' ? locale : locale.value
126
+ // Map to supported timeAgo languages
127
+ const supportedLangs: TimeAgoLang[] = ['en', 'es', 'fr', 'he', 'it', 'ru']
128
+ if (supportedLangs.includes(lang as TimeAgoLang)) {
129
+ return lang as TimeAgoLang
130
+ }
131
+ return 'en'
132
+ } catch {
133
+ return 'en'
111
134
  }
112
135
  }
113
136
 
114
137
  export function timeAgo(
115
138
  date: string | Date,
116
- langOrConfig?: AvailableTimeLanguages | { lang?: AvailableTimeLanguages, mode?: 'relative' | 'absolute' }
139
+ langOrConfig?: TimeAgoLang | { lang?: TimeAgoLang, mode?: 'relative' | 'absolute' }
117
140
  ) {
118
141
  if (!date) { return '' }
119
142
  if (typeof date === 'string') { date = new Date(date) }
120
143
 
121
- // Parse config
122
- const lang = typeof langOrConfig === 'string' ? langOrConfig : (langOrConfig?.lang || 'en')
144
+ // Parse config - use global i18n locale if no lang specified
145
+ const lang = typeof langOrConfig === 'string'
146
+ ? langOrConfig
147
+ : (langOrConfig?.lang || getCurrentLocale())
123
148
  const mode = typeof langOrConfig === 'object' ? (langOrConfig.mode || 'relative') : 'relative'
124
149
  const isRelative = mode === 'relative'
125
150
 
@@ -138,7 +163,13 @@ export function timeAgo(
138
163
  { label: 'second', seconds: 1 }
139
164
  ]
140
165
 
141
- const selectedLang = translations[lang]
166
+ const selectedLang = getTimeAgoTranslations(lang)
167
+
168
+ // Helper to get time unit translation
169
+ const getTimeUnit = (label: string): string | TimeUnit => {
170
+ const key = label as keyof TimeAgoTranslations
171
+ return selectedLang[key] as string | TimeUnit
172
+ }
142
173
 
143
174
  for (const interval of intervals) {
144
175
  const count = Math.floor(Math.abs(seconds) / interval.seconds)
@@ -148,7 +179,7 @@ export function timeAgo(
148
179
 
149
180
  // Handle Hebrew plural forms
150
181
  if (lang === 'he') {
151
- const timeUnit = selectedLang[interval.label] as TimeUnit
182
+ const timeUnit = getTimeUnit(interval.label) as TimeUnit
152
183
  const form = count === 1 ? timeUnit.singular : timeUnit.plural
153
184
 
154
185
  // For Hebrew, we place the prefix/suffix before the number
@@ -168,12 +199,13 @@ export function timeAgo(
168
199
  }
169
200
 
170
201
  // Handle other languages
202
+ const intervalLabel = getTimeUnit(interval.label) as string
171
203
  if (interval.label === 'day' && seconds > 0) {
172
204
  const hours = Math.floor((Math.abs(seconds) % 86400) / 3600)
173
- const hourLabel = hours > 1 ? `${selectedLang.hour}s` : selectedLang.hour
174
- return `${prefix}${count} ${selectedLang[interval.label]}${hours > 0 ? ` ${hours} ${hourLabel}` : ''}${suffix}`
205
+ const hourLabel = hours > 1 ? `${selectedLang.hour}s` : selectedLang.hour as string
206
+ return `${prefix}${count} ${intervalLabel}${hours > 0 ? ` ${hours} ${hourLabel}` : ''}${suffix}`
175
207
  }
176
- return `${prefix}${count} ${selectedLang[interval.label]}${suffix}`
208
+ return `${prefix}${count} ${intervalLabel}${suffix}`
177
209
  }
178
210
  }
179
211
 
@@ -201,8 +201,6 @@ export function normalizeDimension(value: string | number | undefined, defaultMe
201
201
  export * as bagelFormUtils from './BagelFormUtils'
202
202
  export { useForm } from './BagelFormUtils'
203
203
 
204
- export { useLang } from './lang'
205
-
206
204
  export type { ComparisonOperator, FilterCondition, LogicalOperator, QueryConditions, QueryFilter } from './queryFilter'
207
205
  export { anyOf, parseQuery, queryFilter, range, search } from './queryFilter'
208
206
  export type { ShowdownConverter, ShowdownOptions } from './showdown'
package/src/utils/lang.ts DELETED
@@ -1,46 +0,0 @@
1
- import { computed, reactive } from 'vue'
2
-
3
- interface State {
4
- defaultLang: string
5
- availableLangs: string[]
6
- lang: string
7
- }
8
-
9
- const state: State = reactive({
10
- defaultLang: '',
11
- availableLangs: [],
12
- lang: 'en',
13
- })
14
-
15
- function $tdb<T extends { [key: string]: string }>(langEl?: T): string {
16
- if (!langEl) {
17
- console.warn('No language element provided for $tdb function')
18
- return ''
19
- }
20
-
21
- return langEl[state.lang] || langEl[state.defaultLang] || ''
22
- }
23
-
24
- export function useLang() {
25
- const lang = computed({
26
- get: () => state.lang,
27
- set: val => (state.lang = val),
28
- })
29
-
30
- const availableLangs = computed({
31
- get: () => state.availableLangs,
32
- set: val => (state.availableLangs = val),
33
- })
34
-
35
- const defaultLang = computed({
36
- get: () => state.defaultLang,
37
- set: val => (state.defaultLang = val),
38
- })
39
-
40
- return {
41
- lang,
42
- $tdb,
43
- availableLangs,
44
- defaultLang,
45
- }
46
- }