@a-vision-software/vue-input-components 1.4.29 → 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/dist/vue-input-components.cjs.js +2 -2
- package/dist/vue-input-components.css +1 -1
- package/dist/vue-input-components.es.js +2898 -2856
- package/dist/vue-input-components.umd.js +2 -2
- package/package.json +1 -1
- package/src/components/List.vue +61 -17
- package/src/components/TextInput.vue +4 -2
- package/src/views/ListTestView.vue +1 -2
package/package.json
CHANGED
package/src/components/List.vue
CHANGED
|
@@ -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
|
-
|
|
313
|
-
|
|
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
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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
|
-
|
|
326
|
-
|
|
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
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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') {
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
:max-date="max"
|
|
45
45
|
:format="dateFormat"
|
|
46
46
|
:enable-time-picker="type === 'datetime'"
|
|
47
|
-
:auto-apply="true"
|
|
48
|
-
:close-on-auto-apply="true"
|
|
49
47
|
:clearable="true"
|
|
50
48
|
:input-class-name="['text-input__input', { 'text-input__input--has-icon': icon }]"
|
|
51
49
|
@update:model-value="handleDateChange"
|
|
52
50
|
@focus="handleFocus"
|
|
53
51
|
@blur="handleBlur"
|
|
52
|
+
text-input
|
|
53
|
+
:config="dpConfig"
|
|
54
54
|
/>
|
|
55
55
|
<input
|
|
56
56
|
v-else-if="type == 'money' && isFocused"
|
|
@@ -182,6 +182,8 @@ const isFocused = ref(false)
|
|
|
182
182
|
const originalValue = ref<string | number>('')
|
|
183
183
|
const originalDateValue = ref<Date | null>(null)
|
|
184
184
|
|
|
185
|
+
const dpConfig = { setDateOnMenuClose: true }
|
|
186
|
+
|
|
185
187
|
const defaultCurrencyFormatter = new Intl.NumberFormat('en-NZ', {
|
|
186
188
|
style: 'currency',
|
|
187
189
|
currency: 'NZD',
|
|
@@ -165,7 +165,7 @@ const columns: ListColumn[] = [
|
|
|
165
165
|
label: 'Joined',
|
|
166
166
|
type: 'date',
|
|
167
167
|
sortable: true,
|
|
168
|
-
width: '
|
|
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,
|