@a-vision-software/vue-input-components 1.4.30 → 1.4.31

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a-vision-software/vue-input-components",
3
- "version": "1.4.30",
3
+ "version": "1.4.31",
4
4
  "description": "A collection of reusable Vue 3 input components with TypeScript support",
5
5
  "author": "A-Vision Software",
6
6
  "license": "MIT",
@@ -169,10 +169,7 @@
169
169
  {{ formatTime(row[column.key]) }}
170
170
  </template>
171
171
  <template v-else-if="column.type === 'action'">
172
- <div
173
- class="list__row-actions"
174
- v-if="row[column.key]"
175
- >
172
+ <div class="list__row-actions" v-if="row[column.key]">
176
173
  <Action
177
174
  v-for="(action, actionIndex) in row[column.key] as ListActionProps[]"
178
175
  :key="actionIndex"
@@ -309,21 +306,54 @@ const handleSort = (column: ListColumn) => {
309
306
  }
310
307
 
311
308
  const formatDate = (date: string | Date) => {
312
- const dateFormatter = new Intl.DateTimeFormat(config.dateFormat.locale, config.dateFormat.options)
313
- return dateFormatter.format(new Date(date))
309
+ try {
310
+ const dateFormatter = new Intl.DateTimeFormat(
311
+ config.dateFormat.locale,
312
+ config.dateFormat.options,
313
+ )
314
+ if (typeof date === 'string' && !isNaN(Date.parse(date))) {
315
+ return dateFormatter.format(new Date(date))
316
+ } else if (date instanceof Date && !isNaN(date.getTime())) {
317
+ return dateFormatter.format(date)
318
+ }
319
+ } catch (e) {
320
+ console.error('Error formatting date:', e)
321
+ }
322
+ return '-'
314
323
  }
315
324
 
316
325
  const formatDatetime = (date: string | Date) => {
317
- const dateFormatter = new Intl.DateTimeFormat(
318
- config.datetimeFormat.locale,
319
- config.datetimeFormat.options,
320
- )
321
- return dateFormatter.format(new Date(date))
326
+ try {
327
+ const dateFormatter = new Intl.DateTimeFormat(
328
+ config.datetimeFormat.locale,
329
+ config.datetimeFormat.options,
330
+ )
331
+ if (typeof date === 'string' && !isNaN(Date.parse(date))) {
332
+ return dateFormatter.format(new Date(date))
333
+ } else if (date instanceof Date && !isNaN(date.getTime())) {
334
+ return dateFormatter.format(date)
335
+ }
336
+ } catch (e) {
337
+ console.error('Error formatting datetime:', e)
338
+ }
339
+ return '-'
322
340
  }
323
341
 
324
342
  const formatTime = (date: string | Date) => {
325
- const dateFormatter = new Intl.DateTimeFormat(config.timeFormat.locale, config.timeFormat.options)
326
- return dateFormatter.format(new Date(date))
343
+ try {
344
+ const dateFormatter = new Intl.DateTimeFormat(
345
+ config.timeFormat.locale,
346
+ config.timeFormat.options,
347
+ )
348
+ if (typeof date === 'string' && !isNaN(Date.parse(date))) {
349
+ return dateFormatter.format(new Date(date))
350
+ } else if (date instanceof Date && !isNaN(date.getTime())) {
351
+ return dateFormatter.format(date)
352
+ }
353
+ } catch (e) {
354
+ console.error('Error formatting time:', e)
355
+ }
356
+ return '-'
327
357
  }
328
358
 
329
359
  const rowClassList = (row: any): Record<string, boolean> => {
@@ -395,10 +425,24 @@ const sortedAndFilteredData = computed(() => {
395
425
  const sortOrder = sortDirection.value === 'asc' ? 1 : -1
396
426
 
397
427
  // Handle different data types
398
- if (column.type === 'date') {
399
- const dateA = new Date(aValue).getTime()
400
- const dateB = new Date(bValue).getTime()
401
- return (dateA - dateB) * sortOrder
428
+ if (column.type === 'date' || column.type === 'datetime' || column.type === 'time') {
429
+ if (
430
+ typeof aValue === 'string' &&
431
+ !isNaN(Date.parse(aValue)) &&
432
+ typeof bValue === 'string' &&
433
+ !isNaN(Date.parse(bValue))
434
+ ) {
435
+ const dateA = new Date(aValue).getTime()
436
+ const dateB = new Date(bValue).getTime()
437
+ return (dateA - dateB) * sortOrder
438
+ }
439
+ if (typeof aValue === 'string' && !isNaN(Date.parse(aValue))) {
440
+ return sortOrder
441
+ }
442
+ if (typeof bValue === 'string' && !isNaN(Date.parse(bValue))) {
443
+ return sortOrder * -1
444
+ }
445
+ return 0
402
446
  }
403
447
 
404
448
  if (column.type === 'number') {
@@ -165,7 +165,7 @@ const columns: ListColumn[] = [
165
165
  label: 'Joined',
166
166
  type: 'date',
167
167
  sortable: true,
168
- width: '6rem',
168
+ width: '8rem',
169
169
  headerTooltip: 'Account creation date',
170
170
  cellTooltip: true,
171
171
  },
@@ -326,7 +326,6 @@ const data = ref<ListRowData[]>([
326
326
  {
327
327
  name: 'Bob Wilson',
328
328
  email: 'bob@example.com',
329
- joined: '2023-11-05',
330
329
  active: <ListCheckboxProps>{
331
330
  modelValue: true,
332
331
  disabled: true,