@bagelink/vue 1.0.66 → 1.1.6-beta.1
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/dist/components/calendar/Index.vue.d.ts +41 -41
- package/dist/components/calendar/components/header/Header.vue.d.ts +10 -10
- package/dist/components/calendar/components/month/Month.vue.d.ts +6 -6
- package/dist/components/calendar/components/partials/EventFlyout.vue.d.ts +6 -6
- package/dist/components/calendar/components/week/Day.vue.d.ts +9 -9
- package/dist/components/calendar/components/week/DayEvent.vue.d.ts +9 -9
- package/dist/components/calendar/components/week/FullDayEvent.vue.d.ts +3 -3
- package/dist/components/calendar/components/week/Week.vue.d.ts +16 -16
- package/dist/components/calendar/components/week/WeekTimeline.vue.d.ts +2 -2
- package/dist/components/calendar/models/Event.d.ts +7 -7
- package/dist/components/calendar/typings/config.interface.d.ts +2 -2
- package/dist/components/calendar/typings/interfaces/event.interface.d.ts +4 -4
- package/dist/components/calendar/typings/types.d.ts +2 -1
- package/dist/components/calendar/typings/types.d.ts.map +1 -1
- package/dist/components/form/inputs/DateInput.vue.d.ts +7 -3
- package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DatePick.vue.d.ts +3 -3
- package/dist/components/form/inputs/DatePick.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/OTP.vue.d.ts.map +1 -1
- package/dist/index.cjs +278 -120
- package/dist/index.mjs +279 -121
- package/dist/style.css +724 -716
- package/dist/types/timeago.d.ts +23 -0
- package/dist/types/timeago.d.ts.map +1 -0
- package/dist/utils/timeAgo.d.ts +2 -3
- package/dist/utils/timeAgo.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/components/calendar/Index.vue +3 -3
- package/src/components/calendar/components/header/Header.vue +4 -4
- package/src/components/calendar/components/week/Day.vue +2 -2
- package/src/components/calendar/components/week/DayEvent.vue +2 -2
- package/src/components/calendar/components/week/FullDayEvent.vue +2 -2
- package/src/components/calendar/components/week/Week.vue +4 -4
- package/src/components/calendar/components/week/WeekTimeline.vue +2 -2
- package/src/components/calendar/models/Event.ts +7 -7
- package/src/components/calendar/typings/config.interface.ts +2 -2
- package/src/components/calendar/typings/interfaces/event.interface.ts +4 -4
- package/src/components/calendar/typings/types.ts +3 -1
- package/src/components/form/inputs/DateInput.vue +18 -24
- package/src/components/form/inputs/DatePick.vue +6 -7
- package/src/components/form/inputs/OTP.vue +18 -5
- package/src/components/form/inputs/SignaturePad.vue +1 -1
- package/src/components/lightbox/Lightbox.vue +1 -1
- package/src/types/timeago.ts +51 -0
- package/src/utils/timeAgo.ts +30 -36
package/src/utils/timeAgo.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
singular: string
|
|
3
|
-
plural: string
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
type TranslationValue = string | TimeUnit
|
|
7
|
-
|
|
8
|
-
interface LanguageTranslations {
|
|
9
|
-
[key: string]: TranslationValue
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type AvailableTimeLanguages = 'en' | 'es' | 'fr' | 'he'
|
|
1
|
+
import type { AvailableTimeLanguages, DateTimeAcceptedFormats, LanguageTranslations, TimeUnit } from '../types/timeago'
|
|
13
2
|
|
|
14
3
|
const translations: Record<AvailableTimeLanguages, LanguageTranslations> = {
|
|
15
4
|
en: {
|
|
@@ -125,7 +114,7 @@ function getBrowserNavigatorLocale(): string {
|
|
|
125
114
|
: navigator.language
|
|
126
115
|
}
|
|
127
116
|
|
|
128
|
-
export function formatDate(date?: string | Date, format:
|
|
117
|
+
export function formatDate(date?: string | Date, format: DateTimeAcceptedFormats = 'DD.MM.YY', locale?: string) {
|
|
129
118
|
if (!date) return ''
|
|
130
119
|
locale = locale || getBrowserNavigatorLocale()
|
|
131
120
|
try {
|
|
@@ -138,31 +127,34 @@ export function formatDate(date?: string | Date, format: string = 'dd.mm.yy', lo
|
|
|
138
127
|
return ''
|
|
139
128
|
}
|
|
140
129
|
|
|
141
|
-
|
|
142
|
-
const datePartsMap
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
mmm: d.toLocaleString(locale, { month: 'short' }),
|
|
148
|
-
mmmm: d.toLocaleString(locale, { month: 'long' }),
|
|
149
|
-
yy: String(d.getFullYear()).slice(-2),
|
|
150
|
-
yyyy: String(d.getFullYear()),
|
|
130
|
+
/// keep-sorted
|
|
131
|
+
const datePartsMap = {
|
|
132
|
+
AmPm: d.toLocaleString(locale, { hour: 'numeric', hour12: true, minute: 'numeric' }).split(' ')[1],
|
|
133
|
+
DD: String(d.getDate()).padStart(2, '0'),
|
|
134
|
+
DDD: d.toLocaleString(locale, { weekday: 'short' }),
|
|
135
|
+
DDDD: d.toLocaleString(locale, { weekday: 'long' }),
|
|
151
136
|
HH: String(d.getHours()).padStart(2, '0'),
|
|
152
|
-
|
|
153
|
-
|
|
137
|
+
mm: String(d.getMinutes()).padStart(2, '0'),
|
|
138
|
+
MM: String(d.getMonth() + 1).padStart(2, '0'),
|
|
139
|
+
MMM: d.toLocaleString(locale, { month: 'short' }),
|
|
140
|
+
MMMM: d.toLocaleString(locale, { month: 'long' }),
|
|
141
|
+
ss: String(d.getSeconds()).padStart(2, '0'),
|
|
142
|
+
sss: String(d.getMilliseconds()).padStart(3, '0'),
|
|
143
|
+
YY: String(d.getFullYear()).slice(-2),
|
|
144
|
+
YYYY: String(d.getFullYear()),
|
|
154
145
|
}
|
|
155
146
|
|
|
156
147
|
// For more complex formats that need localization, use Intl.DateTimeFormat
|
|
148
|
+
/// keep-sorted
|
|
157
149
|
const formatter = new Intl.DateTimeFormat(locale, {
|
|
158
|
-
weekday: 'long',
|
|
159
|
-
month: 'long',
|
|
160
150
|
day: 'numeric',
|
|
161
|
-
year: 'numeric',
|
|
162
151
|
hour: '2-digit',
|
|
152
|
+
hour12: true,
|
|
163
153
|
minute: '2-digit',
|
|
154
|
+
month: 'long',
|
|
164
155
|
second: '2-digit',
|
|
165
|
-
|
|
156
|
+
weekday: 'long',
|
|
157
|
+
year: 'numeric',
|
|
166
158
|
})
|
|
167
159
|
|
|
168
160
|
const formattedParts = formatter.formatToParts(d)
|
|
@@ -176,24 +168,26 @@ export function formatDate(date?: string | Date, format: string = 'dd.mm.yy', lo
|
|
|
176
168
|
|
|
177
169
|
// Add localized formats to our map
|
|
178
170
|
if (partsMap.month) {
|
|
179
|
-
datePartsMap.
|
|
180
|
-
datePartsMap.
|
|
171
|
+
datePartsMap.MMM = partsMap.month.substring(0, 3)
|
|
172
|
+
datePartsMap.MMMM = partsMap.month
|
|
181
173
|
}
|
|
182
174
|
|
|
183
175
|
if (partsMap.weekday) {
|
|
184
|
-
datePartsMap.
|
|
185
|
-
datePartsMap.
|
|
176
|
+
datePartsMap.DDD = partsMap.weekday.substring(0, 3)
|
|
177
|
+
datePartsMap.DDDD = partsMap.weekday
|
|
186
178
|
}
|
|
187
179
|
|
|
188
180
|
if (partsMap.dayPeriod) {
|
|
189
|
-
datePartsMap.
|
|
181
|
+
datePartsMap.AmPm = partsMap.dayPeriod
|
|
190
182
|
}
|
|
191
183
|
|
|
192
184
|
// Process the format string by replacing each token with its value
|
|
193
|
-
let formattedDate = format
|
|
185
|
+
let formattedDate: string = format
|
|
194
186
|
|
|
195
187
|
// Sort tokens by length (longest first) to avoid partial replacements
|
|
196
|
-
const tokens =
|
|
188
|
+
const tokens = (
|
|
189
|
+
Object.keys(datePartsMap).sort((a, b) => b.length - a.length)
|
|
190
|
+
) as (keyof typeof datePartsMap)[]
|
|
197
191
|
|
|
198
192
|
// Replace each token with its value
|
|
199
193
|
for (const token of tokens) {
|