@ramathibodi/nuxt-commons 0.1.14 → 0.1.15
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/README.md +96 -96
- package/dist/module.json +1 -1
- package/dist/runtime/components/Alert.vue +53 -53
- package/dist/runtime/components/BarcodeReader.vue +98 -98
- package/dist/runtime/components/ExportCSV.vue +55 -55
- package/dist/runtime/components/FileBtn.vue +62 -62
- package/dist/runtime/components/ImportCSV.vue +64 -64
- package/dist/runtime/components/SplitterPanel.vue +59 -59
- package/dist/runtime/components/TabsGroup.vue +32 -32
- package/dist/runtime/components/TextBarcode.vue +52 -52
- package/dist/runtime/components/dialog/Confirm.vue +100 -100
- package/dist/runtime/components/dialog/Index.vue +72 -72
- package/dist/runtime/components/dialog/Loading.vue +39 -39
- package/dist/runtime/components/document/TemplateBuilder.vue +203 -216
- package/dist/runtime/components/form/Birthdate.vue +216 -216
- package/dist/runtime/components/form/CodeEditor.vue +37 -37
- package/dist/runtime/components/form/Date.vue +163 -163
- package/dist/runtime/components/form/DateTime.vue +107 -107
- package/dist/runtime/components/form/Dialog.vue +138 -138
- package/dist/runtime/components/form/File.vue +187 -187
- package/dist/runtime/components/form/Hidden.vue +32 -32
- package/dist/runtime/components/form/Login.vue +131 -131
- package/dist/runtime/components/form/Pad.vue +217 -217
- package/dist/runtime/components/form/SignPad.vue +186 -186
- package/dist/runtime/components/form/Table.vue +266 -266
- package/dist/runtime/components/form/Time.vue +158 -158
- package/dist/runtime/components/form/images/Capture.vue +230 -230
- package/dist/runtime/components/form/images/Edit.vue +114 -114
- package/dist/runtime/components/label/Date.vue +29 -29
- package/dist/runtime/components/label/Field.vue +42 -42
- package/dist/runtime/components/label/FormatMoney.vue +29 -29
- package/dist/runtime/components/label/Mask.vue +38 -38
- package/dist/runtime/components/master/Autocomplete.vue +159 -159
- package/dist/runtime/components/master/Combobox.vue +84 -84
- package/dist/runtime/components/master/RadioGroup.vue +78 -78
- package/dist/runtime/components/master/Select.vue +82 -82
- package/dist/runtime/components/model/Pad.vue +122 -122
- package/dist/runtime/components/model/Table.vue +242 -240
- package/dist/runtime/components/model/iterator.vue +312 -312
- package/dist/runtime/components/pdf/Print.vue +63 -63
- package/dist/runtime/components/pdf/View.vue +104 -104
- package/dist/runtime/composables/graphqlModel.mjs +1 -1
- package/dist/runtime/labs/Calendar.vue +99 -99
- package/dist/runtime/labs/form/EditMobile.vue +152 -152
- package/dist/runtime/labs/form/TextFieldMask.vue +43 -43
- package/dist/runtime/types/alert.d.ts +11 -11
- package/dist/runtime/types/formDialog.d.ts +4 -4
- package/dist/runtime/types/graphqlOperation.d.ts +23 -23
- package/dist/runtime/types/menu.d.ts +25 -25
- package/dist/runtime/types/modules.d.ts +7 -7
- package/package.json +120 -119
- package/scripts/postInstall.cjs +70 -70
- package/templates/.codegen/codegen.ts +32 -32
- package/templates/.codegen/plugin-schema-object.js +154 -154
|
@@ -1,158 +1,158 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { ref, watch, watchEffect, nextTick } from 'vue'
|
|
3
|
-
import Datepicker from '@vuepic/vue-datepicker'
|
|
4
|
-
import '@vuepic/vue-datepicker/dist/main.css'
|
|
5
|
-
import { Datetime } from '../../utils/datetime'
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
readonly?: boolean
|
|
9
|
-
enableSeconds?: boolean
|
|
10
|
-
locale?: 'TH' | 'EN'
|
|
11
|
-
pickerOnly?: boolean
|
|
12
|
-
modelValue?: string | null
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
16
|
-
readonly: false,
|
|
17
|
-
locale: 'TH',
|
|
18
|
-
pickerOnly: false,
|
|
19
|
-
enableSeconds: false,
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
const emit = defineEmits(['update:modelValue'])
|
|
23
|
-
|
|
24
|
-
const time = ref<string | null>(null)
|
|
25
|
-
const tempTime = ref<string | null>(null)
|
|
26
|
-
const isMenuOpen = ref(false)
|
|
27
|
-
const isTextFieldFocused = ref(false)
|
|
28
|
-
const isTextFieldTyped = ref(false)
|
|
29
|
-
|
|
30
|
-
function onTextFieldFocus(event: Event) {
|
|
31
|
-
isTextFieldFocused.value = true
|
|
32
|
-
nextTick(() => {
|
|
33
|
-
(event.target as HTMLInputElement).select()
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function onTextFieldTyped() {
|
|
38
|
-
if (!isTextFieldTyped.value) {
|
|
39
|
-
isTextFieldTyped.value = true
|
|
40
|
-
isMenuOpen.value = false
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function onTextFieldBlur() {
|
|
45
|
-
if (isTextFieldTyped.value) {
|
|
46
|
-
setTime(tempTime.value)
|
|
47
|
-
isTextFieldTyped.value = false
|
|
48
|
-
}
|
|
49
|
-
isTextFieldFocused.value = false
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function onTextFieldEnterKey() {
|
|
53
|
-
onTextFieldBlur()
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function onTextFieldClear() {
|
|
57
|
-
reset()
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function reset() {
|
|
61
|
-
time.value = null
|
|
62
|
-
tempTime.value = null
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function setTime(TimeString: string | null) {
|
|
66
|
-
const dateTime = Datetime().fromStringTime(TimeString, undefined, props.locale)
|
|
67
|
-
if (!dateTime.luxonDateTime.isValid) {
|
|
68
|
-
tempTime.value = null
|
|
69
|
-
time.value = null
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
time.value = dateTime.toFormat('HH:mm:ss', 'EN')
|
|
73
|
-
tempTime.value = time.value
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function setDatePicker(DateString: string | null) {
|
|
78
|
-
setTime(DateString)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
watchEffect(() => {
|
|
82
|
-
if (!isTextFieldFocused.value && time.value) {
|
|
83
|
-
const dateTime = Datetime().fromString(time.value, undefined, props.locale)
|
|
84
|
-
tempTime.value = dateTime.toFormat((props.enableSeconds) ? 'HH:mm:ss' : 'HH:mm', props.locale)
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
tempTime.value = time.value
|
|
88
|
-
}
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
watch(time, (newValue) => {
|
|
92
|
-
if (!isMenuOpen.value) emit('update:modelValue', newValue)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
watch(isMenuOpen, () => {
|
|
96
|
-
if (isMenuOpen.value && !time.value) {
|
|
97
|
-
time.value = Datetime().now().toFormat((props.enableSeconds) ? 'HH:mm:ss' : 'HH:mm:00')
|
|
98
|
-
}
|
|
99
|
-
if (!isMenuOpen.value) emit('update:modelValue', time.value)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
watch(() => props.modelValue, () => {
|
|
103
|
-
setTime(props.modelValue || null)
|
|
104
|
-
}, { immediate: true })
|
|
105
|
-
|
|
106
|
-
const isOpenMenu = (value: string) => {
|
|
107
|
-
if (value === 'txtField' && props.pickerOnly) {
|
|
108
|
-
isMenuOpen.value = true
|
|
109
|
-
}
|
|
110
|
-
else if (value === 'icon' && !props.pickerOnly) {
|
|
111
|
-
isMenuOpen.value = true
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
</script>
|
|
115
|
-
|
|
116
|
-
<template>
|
|
117
|
-
<v-menu
|
|
118
|
-
v-model="isMenuOpen"
|
|
119
|
-
:close-on-content-click="false"
|
|
120
|
-
:open-on-click="false"
|
|
121
|
-
>
|
|
122
|
-
<template #activator="{ props }">
|
|
123
|
-
<v-text-field
|
|
124
|
-
ref="textField"
|
|
125
|
-
v-model="tempTime"
|
|
126
|
-
:readonly="readonly"
|
|
127
|
-
v-bind="$attrs"
|
|
128
|
-
@focus="onTextFieldFocus"
|
|
129
|
-
@blur="onTextFieldBlur"
|
|
130
|
-
@keydown="onTextFieldTyped"
|
|
131
|
-
@keyup.enter="onTextFieldEnterKey"
|
|
132
|
-
@click:clear="onTextFieldClear"
|
|
133
|
-
@click="isOpenMenu('txtField')"
|
|
134
|
-
>
|
|
135
|
-
<template #append-inner>
|
|
136
|
-
<v-icon
|
|
137
|
-
v-bind="props"
|
|
138
|
-
@click="isOpenMenu('icon')"
|
|
139
|
-
>
|
|
140
|
-
fa:fa-regular fa-clock
|
|
141
|
-
</v-icon>
|
|
142
|
-
</template>
|
|
143
|
-
</v-text-field>
|
|
144
|
-
</template>
|
|
145
|
-
<Datepicker
|
|
146
|
-
v-model="time"
|
|
147
|
-
model-type="HH:mm:ss"
|
|
148
|
-
:enable-seconds="enableSeconds"
|
|
149
|
-
minutes-grid-increment="1"
|
|
150
|
-
time-picker
|
|
151
|
-
auto-apply
|
|
152
|
-
:close-on-auto-apply="false"
|
|
153
|
-
inline
|
|
154
|
-
:locale="locale"
|
|
155
|
-
@update:model-value="setDatePicker"
|
|
156
|
-
/>
|
|
157
|
-
</v-menu>
|
|
158
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { ref, watch, watchEffect, nextTick } from 'vue'
|
|
3
|
+
import Datepicker from '@vuepic/vue-datepicker'
|
|
4
|
+
import '@vuepic/vue-datepicker/dist/main.css'
|
|
5
|
+
import { Datetime } from '../../utils/datetime'
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
readonly?: boolean
|
|
9
|
+
enableSeconds?: boolean
|
|
10
|
+
locale?: 'TH' | 'EN'
|
|
11
|
+
pickerOnly?: boolean
|
|
12
|
+
modelValue?: string | null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
16
|
+
readonly: false,
|
|
17
|
+
locale: 'TH',
|
|
18
|
+
pickerOnly: false,
|
|
19
|
+
enableSeconds: false,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const emit = defineEmits(['update:modelValue'])
|
|
23
|
+
|
|
24
|
+
const time = ref<string | null>(null)
|
|
25
|
+
const tempTime = ref<string | null>(null)
|
|
26
|
+
const isMenuOpen = ref(false)
|
|
27
|
+
const isTextFieldFocused = ref(false)
|
|
28
|
+
const isTextFieldTyped = ref(false)
|
|
29
|
+
|
|
30
|
+
function onTextFieldFocus(event: Event) {
|
|
31
|
+
isTextFieldFocused.value = true
|
|
32
|
+
nextTick(() => {
|
|
33
|
+
(event.target as HTMLInputElement).select()
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function onTextFieldTyped() {
|
|
38
|
+
if (!isTextFieldTyped.value) {
|
|
39
|
+
isTextFieldTyped.value = true
|
|
40
|
+
isMenuOpen.value = false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function onTextFieldBlur() {
|
|
45
|
+
if (isTextFieldTyped.value) {
|
|
46
|
+
setTime(tempTime.value)
|
|
47
|
+
isTextFieldTyped.value = false
|
|
48
|
+
}
|
|
49
|
+
isTextFieldFocused.value = false
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function onTextFieldEnterKey() {
|
|
53
|
+
onTextFieldBlur()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function onTextFieldClear() {
|
|
57
|
+
reset()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function reset() {
|
|
61
|
+
time.value = null
|
|
62
|
+
tempTime.value = null
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function setTime(TimeString: string | null) {
|
|
66
|
+
const dateTime = Datetime().fromStringTime(TimeString, undefined, props.locale)
|
|
67
|
+
if (!dateTime.luxonDateTime.isValid) {
|
|
68
|
+
tempTime.value = null
|
|
69
|
+
time.value = null
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
time.value = dateTime.toFormat('HH:mm:ss', 'EN')
|
|
73
|
+
tempTime.value = time.value
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function setDatePicker(DateString: string | null) {
|
|
78
|
+
setTime(DateString)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
watchEffect(() => {
|
|
82
|
+
if (!isTextFieldFocused.value && time.value) {
|
|
83
|
+
const dateTime = Datetime().fromString(time.value, undefined, props.locale)
|
|
84
|
+
tempTime.value = dateTime.toFormat((props.enableSeconds) ? 'HH:mm:ss' : 'HH:mm', props.locale)
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
tempTime.value = time.value
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
watch(time, (newValue) => {
|
|
92
|
+
if (!isMenuOpen.value) emit('update:modelValue', newValue)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
watch(isMenuOpen, () => {
|
|
96
|
+
if (isMenuOpen.value && !time.value) {
|
|
97
|
+
time.value = Datetime().now().toFormat((props.enableSeconds) ? 'HH:mm:ss' : 'HH:mm:00')
|
|
98
|
+
}
|
|
99
|
+
if (!isMenuOpen.value) emit('update:modelValue', time.value)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
watch(() => props.modelValue, () => {
|
|
103
|
+
setTime(props.modelValue || null)
|
|
104
|
+
}, { immediate: true })
|
|
105
|
+
|
|
106
|
+
const isOpenMenu = (value: string) => {
|
|
107
|
+
if (value === 'txtField' && props.pickerOnly) {
|
|
108
|
+
isMenuOpen.value = true
|
|
109
|
+
}
|
|
110
|
+
else if (value === 'icon' && !props.pickerOnly) {
|
|
111
|
+
isMenuOpen.value = true
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
</script>
|
|
115
|
+
|
|
116
|
+
<template>
|
|
117
|
+
<v-menu
|
|
118
|
+
v-model="isMenuOpen"
|
|
119
|
+
:close-on-content-click="false"
|
|
120
|
+
:open-on-click="false"
|
|
121
|
+
>
|
|
122
|
+
<template #activator="{ props }">
|
|
123
|
+
<v-text-field
|
|
124
|
+
ref="textField"
|
|
125
|
+
v-model="tempTime"
|
|
126
|
+
:readonly="readonly"
|
|
127
|
+
v-bind="$attrs"
|
|
128
|
+
@focus="onTextFieldFocus"
|
|
129
|
+
@blur="onTextFieldBlur"
|
|
130
|
+
@keydown="onTextFieldTyped"
|
|
131
|
+
@keyup.enter="onTextFieldEnterKey"
|
|
132
|
+
@click:clear="onTextFieldClear"
|
|
133
|
+
@click="isOpenMenu('txtField')"
|
|
134
|
+
>
|
|
135
|
+
<template #append-inner>
|
|
136
|
+
<v-icon
|
|
137
|
+
v-bind="props"
|
|
138
|
+
@click="isOpenMenu('icon')"
|
|
139
|
+
>
|
|
140
|
+
fa:fa-regular fa-clock
|
|
141
|
+
</v-icon>
|
|
142
|
+
</template>
|
|
143
|
+
</v-text-field>
|
|
144
|
+
</template>
|
|
145
|
+
<Datepicker
|
|
146
|
+
v-model="time"
|
|
147
|
+
model-type="HH:mm:ss"
|
|
148
|
+
:enable-seconds="enableSeconds"
|
|
149
|
+
minutes-grid-increment="1"
|
|
150
|
+
time-picker
|
|
151
|
+
auto-apply
|
|
152
|
+
:close-on-auto-apply="false"
|
|
153
|
+
inline
|
|
154
|
+
:locale="locale"
|
|
155
|
+
@update:model-value="setDatePicker"
|
|
156
|
+
/>
|
|
157
|
+
</v-menu>
|
|
158
|
+
</template>
|