@ramathibodi/nuxt-commons 0.1.16 → 0.1.18
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/module.json
CHANGED
|
@@ -18,6 +18,10 @@ const headers = ref([
|
|
|
18
18
|
key: 'operation',
|
|
19
19
|
width: '120px',
|
|
20
20
|
},
|
|
21
|
+
{
|
|
22
|
+
title: 'Rec No.',
|
|
23
|
+
key: 'recNo',
|
|
24
|
+
},
|
|
21
25
|
{
|
|
22
26
|
title: 'Input Type',
|
|
23
27
|
key: 'inputType',
|
|
@@ -99,6 +103,9 @@ const ruleOptions = (inputType: string) => (value: any) => {
|
|
|
99
103
|
Convert To Advance
|
|
100
104
|
</VBtn>
|
|
101
105
|
</template>
|
|
106
|
+
<template #item.recNo="{internalItem}">
|
|
107
|
+
{{ internalItem.index }}
|
|
108
|
+
</template>
|
|
102
109
|
<template #form="{ data, rules }">
|
|
103
110
|
<v-container fluid>
|
|
104
111
|
<v-row dense>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { DateTime, type ToRelativeOptions } from "luxon";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
modelValue: DateTime;
|
|
7
|
+
locale?: 'TH' | 'EN';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
11
|
+
locale: 'TH',
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const timeAgo = computed(() => {
|
|
15
|
+
const now = DateTime.now();
|
|
16
|
+
const diff = now.diff(props.modelValue, ['years', 'months', 'days', 'hours', 'minutes', 'seconds']).toObject();
|
|
17
|
+
|
|
18
|
+
let unit: ToRelativeOptions['unit'] = 'seconds';
|
|
19
|
+
if (diff.years && diff.years > 0) {
|
|
20
|
+
unit = 'years';
|
|
21
|
+
} else if (diff.months && diff.months > 0) {
|
|
22
|
+
unit = 'months';
|
|
23
|
+
} else if (diff.days && diff.days > 0) {
|
|
24
|
+
unit = 'days';
|
|
25
|
+
} else if (diff.hours && diff.hours > 0) {
|
|
26
|
+
unit = 'hours';
|
|
27
|
+
} else if (diff.minutes && diff.minutes > 0) {
|
|
28
|
+
unit = 'minutes';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return props.modelValue.setLocale(props.locale).toRelative({ unit });
|
|
32
|
+
});
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<span>{{ timeAgo }}</span>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<style scoped>
|
|
40
|
+
|
|
41
|
+
</style>
|
|
@@ -1,42 +1,100 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
+
import { computed, ref } from 'vue';
|
|
3
|
+
|
|
2
4
|
interface Props {
|
|
3
|
-
label: string
|
|
4
|
-
value?: string
|
|
5
|
-
horizontal?: boolean
|
|
5
|
+
label: string;
|
|
6
|
+
value?: string | null;
|
|
7
|
+
horizontal?: boolean;
|
|
8
|
+
size?: 'large' | 'medium';
|
|
9
|
+
truncate?: boolean;
|
|
6
10
|
}
|
|
7
11
|
|
|
8
12
|
const props = withDefaults(defineProps<Props>(), {
|
|
9
|
-
label: '',
|
|
10
|
-
|
|
13
|
+
label: '',
|
|
14
|
+
value: '',
|
|
15
|
+
horizontal: false,
|
|
16
|
+
size: 'large',
|
|
17
|
+
truncate: false,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const valueText = ref<HTMLElement | null>(null);
|
|
21
|
+
const isTooltip = ref(false);
|
|
22
|
+
|
|
23
|
+
const calSize = computed(() => (props.size === 'medium' ? 'text-subtitle-1' : 'text-h6'));
|
|
24
|
+
const calTruncate = computed(() => (props.truncate ? 'text-truncate' : ''));
|
|
25
|
+
|
|
26
|
+
const setTruncate = (event: Event) => {
|
|
27
|
+
const target = event.target as HTMLElement;
|
|
28
|
+
isTooltip.value = target.offsetWidth < target.scrollWidth;
|
|
29
|
+
};
|
|
30
|
+
|
|
11
31
|
</script>
|
|
12
32
|
|
|
13
33
|
<template>
|
|
14
|
-
<div
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
34
|
+
<div
|
|
35
|
+
v-if="props.horizontal"
|
|
36
|
+
class="d-flex align-top"
|
|
37
|
+
v-bind="$attrs"
|
|
38
|
+
@resize="setTruncate"
|
|
39
|
+
>
|
|
40
|
+
<div class="text-medium-emphasis text-no-wrap">
|
|
41
|
+
<slot name="label">{{ props.label }}:</slot>
|
|
19
42
|
</div>
|
|
20
|
-
<div class="ml-1">
|
|
43
|
+
<div :class="`ml-1 ${calTruncate}`" ref="valueText">
|
|
21
44
|
<slot name="value">
|
|
22
|
-
{{ value }}
|
|
45
|
+
<div v-if="!props.truncate">{{ props.value }}</div>
|
|
46
|
+
<div
|
|
47
|
+
v-else
|
|
48
|
+
@mouseover="setTruncate"
|
|
49
|
+
@mouseout="isTooltip = false"
|
|
50
|
+
>
|
|
51
|
+
<v-tooltip :model-value="isTooltip" location="bottom">
|
|
52
|
+
<template #activator="{ props }">
|
|
53
|
+
<div
|
|
54
|
+
class="text-truncate"
|
|
55
|
+
v-bind="isTooltip ? props : ''"
|
|
56
|
+
>
|
|
57
|
+
{{ value }}
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
<span>{{ value }}</span>
|
|
61
|
+
</v-tooltip>
|
|
62
|
+
</div>
|
|
23
63
|
</slot>
|
|
24
64
|
</div>
|
|
25
65
|
</div>
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
{{ label }}
|
|
30
|
-
</
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
66
|
+
|
|
67
|
+
<v-card v-else variant="text" v-bind="$attrs">
|
|
68
|
+
<VCardSubtitle class="ma-0 pa-0 text-black">
|
|
69
|
+
<slot name="label">{{ props.label }}</slot>
|
|
70
|
+
</VCardSubtitle>
|
|
71
|
+
<VCardText :class="`pa-0 mb-2 ${calSize}`">
|
|
72
|
+
<div :class="calTruncate" ref="valueText">
|
|
73
|
+
<slot name="value">
|
|
74
|
+
<div v-if="!props.truncate">{{ props.value }}</div>
|
|
75
|
+
<div
|
|
76
|
+
v-else
|
|
77
|
+
@mouseover="setTruncate"
|
|
78
|
+
@mouseout="isTooltip = false"
|
|
79
|
+
>
|
|
80
|
+
<v-tooltip :model-value="isTooltip" location="bottom">
|
|
81
|
+
<template #activator="{ props }">
|
|
82
|
+
<div
|
|
83
|
+
class="text-truncate"
|
|
84
|
+
v-bind="isTooltip ? props : ''"
|
|
85
|
+
>
|
|
86
|
+
{{ value }}
|
|
87
|
+
</div>
|
|
88
|
+
</template>
|
|
89
|
+
<span>{{ value }}</span>
|
|
90
|
+
</v-tooltip>
|
|
91
|
+
</div>
|
|
92
|
+
</slot>
|
|
93
|
+
</div>
|
|
94
|
+
</VCardText>
|
|
95
|
+
</v-card>
|
|
38
96
|
</template>
|
|
39
97
|
|
|
40
|
-
<style
|
|
98
|
+
<style scoped>
|
|
41
99
|
|
|
42
100
|
</style>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ramathibodi/nuxt-commons",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Ramathibodi Nuxt modules for common components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -116,5 +116,5 @@
|
|
|
116
116
|
"vitest": "^1.5.1",
|
|
117
117
|
"vue-tsc": "^1.8.27"
|
|
118
118
|
},
|
|
119
|
-
"packageManager": "pnpm@9.
|
|
119
|
+
"packageManager": "pnpm@9.7.1+sha512.faf344af2d6ca65c4c5c8c2224ea77a81a5e8859cbc4e06b1511ddce2f0151512431dd19e6aff31f2c6a8f5f2aced9bd2273e1fed7dd4de1868984059d2c4247"
|
|
120
120
|
}
|