@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.
Files changed (54) hide show
  1. package/README.md +96 -96
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/components/Alert.vue +53 -53
  4. package/dist/runtime/components/BarcodeReader.vue +98 -98
  5. package/dist/runtime/components/ExportCSV.vue +55 -55
  6. package/dist/runtime/components/FileBtn.vue +62 -62
  7. package/dist/runtime/components/ImportCSV.vue +64 -64
  8. package/dist/runtime/components/SplitterPanel.vue +59 -59
  9. package/dist/runtime/components/TabsGroup.vue +32 -32
  10. package/dist/runtime/components/TextBarcode.vue +52 -52
  11. package/dist/runtime/components/dialog/Confirm.vue +100 -100
  12. package/dist/runtime/components/dialog/Index.vue +72 -72
  13. package/dist/runtime/components/dialog/Loading.vue +39 -39
  14. package/dist/runtime/components/document/TemplateBuilder.vue +203 -216
  15. package/dist/runtime/components/form/Birthdate.vue +216 -216
  16. package/dist/runtime/components/form/CodeEditor.vue +37 -37
  17. package/dist/runtime/components/form/Date.vue +163 -163
  18. package/dist/runtime/components/form/DateTime.vue +107 -107
  19. package/dist/runtime/components/form/Dialog.vue +138 -138
  20. package/dist/runtime/components/form/File.vue +187 -187
  21. package/dist/runtime/components/form/Hidden.vue +32 -32
  22. package/dist/runtime/components/form/Login.vue +131 -131
  23. package/dist/runtime/components/form/Pad.vue +217 -217
  24. package/dist/runtime/components/form/SignPad.vue +186 -186
  25. package/dist/runtime/components/form/Table.vue +266 -266
  26. package/dist/runtime/components/form/Time.vue +158 -158
  27. package/dist/runtime/components/form/images/Capture.vue +230 -230
  28. package/dist/runtime/components/form/images/Edit.vue +114 -114
  29. package/dist/runtime/components/label/Date.vue +29 -29
  30. package/dist/runtime/components/label/Field.vue +42 -42
  31. package/dist/runtime/components/label/FormatMoney.vue +29 -29
  32. package/dist/runtime/components/label/Mask.vue +38 -38
  33. package/dist/runtime/components/master/Autocomplete.vue +159 -159
  34. package/dist/runtime/components/master/Combobox.vue +84 -84
  35. package/dist/runtime/components/master/RadioGroup.vue +78 -78
  36. package/dist/runtime/components/master/Select.vue +82 -82
  37. package/dist/runtime/components/model/Pad.vue +122 -122
  38. package/dist/runtime/components/model/Table.vue +242 -240
  39. package/dist/runtime/components/model/iterator.vue +312 -312
  40. package/dist/runtime/components/pdf/Print.vue +63 -63
  41. package/dist/runtime/components/pdf/View.vue +104 -104
  42. package/dist/runtime/composables/graphqlModel.mjs +1 -1
  43. package/dist/runtime/labs/Calendar.vue +99 -99
  44. package/dist/runtime/labs/form/EditMobile.vue +152 -152
  45. package/dist/runtime/labs/form/TextFieldMask.vue +43 -43
  46. package/dist/runtime/types/alert.d.ts +11 -11
  47. package/dist/runtime/types/formDialog.d.ts +4 -4
  48. package/dist/runtime/types/graphqlOperation.d.ts +23 -23
  49. package/dist/runtime/types/menu.d.ts +25 -25
  50. package/dist/runtime/types/modules.d.ts +7 -7
  51. package/package.json +120 -119
  52. package/scripts/postInstall.cjs +70 -70
  53. package/templates/.codegen/codegen.ts +32 -32
  54. package/templates/.codegen/plugin-schema-object.js +154 -154
@@ -1,216 +1,216 @@
1
- <script lang="ts" setup>
2
- import Datepicker from '@vuepic/vue-datepicker'
3
- import '@vuepic/vue-datepicker/dist/main.css'
4
- import {nextTick, ref, watch, watchEffect,computed} from 'vue'
5
- import {type dateFormat, Datetime} from '../../utils/datetime'
6
-
7
- interface IDobPrecision {
8
- yearMonthDay: string
9
- yearMonth: string
10
- year: string
11
- }
12
- interface Props {
13
- readonly?: boolean
14
- locale?: 'TH' | 'EN'
15
- format?: dateFormat | string
16
- modelValue?: string | null
17
- holiday?: object[] | undefined
18
- minDate?: Date | string
19
- maxDate?: Date | string
20
- pickerOnly?: boolean
21
- flow?: ('month' | 'year' | 'calendar' | 'time' | 'minutes' | 'hours' | 'seconds')[]
22
- dobPrecisionText?: IDobPrecision
23
- }
24
-
25
- const props = withDefaults(defineProps<Props>(), {
26
- readonly: false,
27
- locale: 'TH',
28
- format: 'shortDate',
29
- pickerOnly: false,
30
- flow: () => ['year', 'month', 'calendar'],
31
- })
32
-
33
- const emit = defineEmits(['update:modelValue'])
34
-
35
- const dobPrecisionText = computed(() => {
36
- if (props.dobPrecisionText) return props.dobPrecisionText
37
- else return {
38
- yearMonthDay: 'YMD',
39
- yearMonth: 'YM',
40
- year: 'Y',
41
- }
42
- })
43
- const dobPrecisionChoice = ref<('yearMonthDay' | 'yearMonth' | 'year')[]>(['yearMonthDay', 'yearMonth', 'year'])
44
- const dobPrecisionSelected = defineModel<'yearMonthDay' | 'yearMonth' | 'year'>('dobPrecision', { default: 'yearMonthDay' })
45
-
46
- const dobPrecisionDisplay = computed(() => {
47
- return (dobPrecisionSelected.value) ? dobPrecisionText.value[dobPrecisionSelected.value] : dobPrecisionText.value['yearMonthDay']
48
- })
49
-
50
- const changeDobPrecision = () => {
51
- if (dobPrecisionSelected.value && dobPrecisionChoice.value.includes(dobPrecisionSelected.value)) {
52
- dobPrecisionSelected.value = dobPrecisionChoice.value[(dobPrecisionChoice.value.indexOf(dobPrecisionSelected.value) + 1) % dobPrecisionChoice.value.length]
53
- }
54
- else {
55
- dobPrecisionSelected.value = dobPrecisionChoice.value[0]
56
- }
57
- }
58
-
59
- const selectedDate = ref<string | null>(null)
60
- const displayedDate = ref<string | null>(null)
61
-
62
- const isMenuOpen = ref(false)
63
- const isTextFieldFocused = ref(false)
64
- const hasTextFieldInput = ref(false)
65
-
66
- function handleTextFieldFocus(event: Event) {
67
- isTextFieldFocused.value = true
68
- nextTick(() => {
69
- (event.target as HTMLInputElement).select()
70
- })
71
- }
72
-
73
- function handleTextFieldInput() {
74
- if (!hasTextFieldInput.value) {
75
- hasTextFieldInput.value = true
76
- isMenuOpen.value = false
77
- }
78
- }
79
-
80
- function handleTextFieldBlur() {
81
- if (hasTextFieldInput.value) {
82
- updateDate(displayedDate.value)
83
- hasTextFieldInput.value = false
84
- }
85
- isTextFieldFocused.value = false
86
- }
87
-
88
- function handleTextFieldEnterKey() {
89
- handleTextFieldBlur()
90
- }
91
-
92
- function updateDatePicker(dateString: string | null) {
93
- isMenuOpen.value = false
94
- updateDate(dateString)
95
- }
96
-
97
- function updateDate(dateString: string | null) {
98
- const dateTime = Datetime().fromString(dateString, undefined, props.locale)
99
- if (!dateTime.luxonDateTime.isValid) {
100
- displayedDate.value = null
101
- selectedDate.value = null
102
- }
103
- else {
104
- if (dobPrecisionSelected.value=="yearMonth") {
105
- dateTime.luxonDateTime = dateTime.luxonDateTime.startOf('month')
106
- }
107
- if (dobPrecisionSelected.value=="year") {
108
- dateTime.luxonDateTime = dateTime.luxonDateTime.startOf('year')
109
- }
110
- selectedDate.value = dateTime.toFormat('yyyy-MM-dd', 'EN')
111
- displayedDate.value = selectedDate.value
112
- }
113
-
114
- if (!isTextFieldFocused.value) displayedDate.value = formatDate(displayedDate.value)
115
- }
116
-
117
- function formatDate(dateString: string | null) {
118
- if (!dateString) return null
119
-
120
- let displayFormat = props.format
121
- if (dobPrecisionSelected.value=="yearMonth") {
122
- displayFormat = "MMM yyyy"
123
- }
124
- if (dobPrecisionSelected.value=="year") {
125
- displayFormat = "yyyy"
126
- }
127
-
128
- const dateTime = Datetime().fromString(dateString, undefined, props.locale)
129
- return dateTime.toFormat(displayFormat, props.locale)
130
- }
131
-
132
- function handleTextFieldClear() {
133
- resetDatePicker()
134
- }
135
-
136
- function resetDatePicker() {
137
- selectedDate.value = null
138
- displayedDate.value = null
139
- }
140
-
141
- watchEffect(() => {
142
- if (!isTextFieldFocused.value && selectedDate.value) {
143
- displayedDate.value = formatDate(selectedDate.value)
144
- }
145
- else {
146
- displayedDate.value = selectedDate.value
147
- }
148
- })
149
-
150
- watch(selectedDate, (newValue) => {
151
- emit('update:modelValue', newValue)
152
- })
153
-
154
- watch(() => props.modelValue, () => {
155
- updateDate(props.modelValue || null)
156
- }, { immediate: true })
157
-
158
- watch(dobPrecisionSelected,()=>{
159
- updateDate(selectedDate.value)
160
- })
161
-
162
- function toggleMenuOpen(trigger: string) {
163
- if ((trigger === 'textField' && props.pickerOnly) || (trigger === 'icon' && !props.pickerOnly)) {
164
- isMenuOpen.value = true
165
- }
166
- }
167
- </script>
168
-
169
- <template>
170
- <v-menu
171
- v-model="isMenuOpen"
172
- :open-on-click="false"
173
- >
174
- <template #activator="{ props: activatorProps }">
175
- <v-text-field
176
- ref="textField"
177
- v-model="displayedDate"
178
- :readonly="readonly"
179
- v-bind="$attrs"
180
- @focus="handleTextFieldFocus"
181
- @blur="handleTextFieldBlur"
182
- @keydown="handleTextFieldInput"
183
- @keyup.enter="handleTextFieldEnterKey"
184
- @click:clear="handleTextFieldClear"
185
- @click="toggleMenuOpen('textField')"
186
- >
187
- <template #append-inner>
188
- <span
189
- style="cursor: pointer;"
190
- class="font-weight-medium"
191
- @click="changeDobPrecision"
192
- >{{ dobPrecisionDisplay }}</span>
193
- &nbsp;
194
- <v-icon
195
- v-bind="activatorProps"
196
- @click="toggleMenuOpen('icon')"
197
- >
198
- fa:fa-regular fa-calendar
199
- </v-icon>
200
- </template>
201
- </v-text-field>
202
- </template>
203
- <Datepicker
204
- v-model="selectedDate"
205
- model-type="yyyy-MM-dd"
206
- :enable-time-picker="false"
207
- :flow="flow"
208
- :min-date="props.minDate"
209
- :max-date="props.maxDate"
210
- auto-apply
211
- inline
212
- :locale="locale"
213
- @update:model-value="updateDatePicker"
214
- />
215
- </v-menu>
216
- </template>
1
+ <script lang="ts" setup>
2
+ import Datepicker from '@vuepic/vue-datepicker'
3
+ import '@vuepic/vue-datepicker/dist/main.css'
4
+ import {nextTick, ref, watch, watchEffect,computed} from 'vue'
5
+ import {type dateFormat, Datetime} from '../../utils/datetime'
6
+
7
+ interface IDobPrecision {
8
+ yearMonthDay: string
9
+ yearMonth: string
10
+ year: string
11
+ }
12
+ interface Props {
13
+ readonly?: boolean
14
+ locale?: 'TH' | 'EN'
15
+ format?: dateFormat | string
16
+ modelValue?: string | null
17
+ holiday?: object[] | undefined
18
+ minDate?: Date | string
19
+ maxDate?: Date | string
20
+ pickerOnly?: boolean
21
+ flow?: ('month' | 'year' | 'calendar' | 'time' | 'minutes' | 'hours' | 'seconds')[]
22
+ dobPrecisionText?: IDobPrecision
23
+ }
24
+
25
+ const props = withDefaults(defineProps<Props>(), {
26
+ readonly: false,
27
+ locale: 'TH',
28
+ format: 'shortDate',
29
+ pickerOnly: false,
30
+ flow: () => ['year', 'month', 'calendar'],
31
+ })
32
+
33
+ const emit = defineEmits(['update:modelValue'])
34
+
35
+ const dobPrecisionText = computed(() => {
36
+ if (props.dobPrecisionText) return props.dobPrecisionText
37
+ else return {
38
+ yearMonthDay: 'YMD',
39
+ yearMonth: 'YM',
40
+ year: 'Y',
41
+ }
42
+ })
43
+ const dobPrecisionChoice = ref<('yearMonthDay' | 'yearMonth' | 'year')[]>(['yearMonthDay', 'yearMonth', 'year'])
44
+ const dobPrecisionSelected = defineModel<'yearMonthDay' | 'yearMonth' | 'year'>('dobPrecision', { default: 'yearMonthDay' })
45
+
46
+ const dobPrecisionDisplay = computed(() => {
47
+ return (dobPrecisionSelected.value) ? dobPrecisionText.value[dobPrecisionSelected.value] : dobPrecisionText.value['yearMonthDay']
48
+ })
49
+
50
+ const changeDobPrecision = () => {
51
+ if (dobPrecisionSelected.value && dobPrecisionChoice.value.includes(dobPrecisionSelected.value)) {
52
+ dobPrecisionSelected.value = dobPrecisionChoice.value[(dobPrecisionChoice.value.indexOf(dobPrecisionSelected.value) + 1) % dobPrecisionChoice.value.length]
53
+ }
54
+ else {
55
+ dobPrecisionSelected.value = dobPrecisionChoice.value[0]
56
+ }
57
+ }
58
+
59
+ const selectedDate = ref<string | null>(null)
60
+ const displayedDate = ref<string | null>(null)
61
+
62
+ const isMenuOpen = ref(false)
63
+ const isTextFieldFocused = ref(false)
64
+ const hasTextFieldInput = ref(false)
65
+
66
+ function handleTextFieldFocus(event: Event) {
67
+ isTextFieldFocused.value = true
68
+ nextTick(() => {
69
+ (event.target as HTMLInputElement).select()
70
+ })
71
+ }
72
+
73
+ function handleTextFieldInput() {
74
+ if (!hasTextFieldInput.value) {
75
+ hasTextFieldInput.value = true
76
+ isMenuOpen.value = false
77
+ }
78
+ }
79
+
80
+ function handleTextFieldBlur() {
81
+ if (hasTextFieldInput.value) {
82
+ updateDate(displayedDate.value)
83
+ hasTextFieldInput.value = false
84
+ }
85
+ isTextFieldFocused.value = false
86
+ }
87
+
88
+ function handleTextFieldEnterKey() {
89
+ handleTextFieldBlur()
90
+ }
91
+
92
+ function updateDatePicker(dateString: string | null) {
93
+ isMenuOpen.value = false
94
+ updateDate(dateString)
95
+ }
96
+
97
+ function updateDate(dateString: string | null) {
98
+ const dateTime = Datetime().fromString(dateString, undefined, props.locale)
99
+ if (!dateTime.luxonDateTime.isValid) {
100
+ displayedDate.value = null
101
+ selectedDate.value = null
102
+ }
103
+ else {
104
+ if (dobPrecisionSelected.value=="yearMonth") {
105
+ dateTime.luxonDateTime = dateTime.luxonDateTime.startOf('month')
106
+ }
107
+ if (dobPrecisionSelected.value=="year") {
108
+ dateTime.luxonDateTime = dateTime.luxonDateTime.startOf('year')
109
+ }
110
+ selectedDate.value = dateTime.toFormat('yyyy-MM-dd', 'EN')
111
+ displayedDate.value = selectedDate.value
112
+ }
113
+
114
+ if (!isTextFieldFocused.value) displayedDate.value = formatDate(displayedDate.value)
115
+ }
116
+
117
+ function formatDate(dateString: string | null) {
118
+ if (!dateString) return null
119
+
120
+ let displayFormat = props.format
121
+ if (dobPrecisionSelected.value=="yearMonth") {
122
+ displayFormat = "MMM yyyy"
123
+ }
124
+ if (dobPrecisionSelected.value=="year") {
125
+ displayFormat = "yyyy"
126
+ }
127
+
128
+ const dateTime = Datetime().fromString(dateString, undefined, props.locale)
129
+ return dateTime.toFormat(displayFormat, props.locale)
130
+ }
131
+
132
+ function handleTextFieldClear() {
133
+ resetDatePicker()
134
+ }
135
+
136
+ function resetDatePicker() {
137
+ selectedDate.value = null
138
+ displayedDate.value = null
139
+ }
140
+
141
+ watchEffect(() => {
142
+ if (!isTextFieldFocused.value && selectedDate.value) {
143
+ displayedDate.value = formatDate(selectedDate.value)
144
+ }
145
+ else {
146
+ displayedDate.value = selectedDate.value
147
+ }
148
+ })
149
+
150
+ watch(selectedDate, (newValue) => {
151
+ emit('update:modelValue', newValue)
152
+ })
153
+
154
+ watch(() => props.modelValue, () => {
155
+ updateDate(props.modelValue || null)
156
+ }, { immediate: true })
157
+
158
+ watch(dobPrecisionSelected,()=>{
159
+ updateDate(selectedDate.value)
160
+ })
161
+
162
+ function toggleMenuOpen(trigger: string) {
163
+ if ((trigger === 'textField' && props.pickerOnly) || (trigger === 'icon' && !props.pickerOnly)) {
164
+ isMenuOpen.value = true
165
+ }
166
+ }
167
+ </script>
168
+
169
+ <template>
170
+ <v-menu
171
+ v-model="isMenuOpen"
172
+ :open-on-click="false"
173
+ >
174
+ <template #activator="{ props: activatorProps }">
175
+ <v-text-field
176
+ ref="textField"
177
+ v-model="displayedDate"
178
+ :readonly="readonly"
179
+ v-bind="$attrs"
180
+ @focus="handleTextFieldFocus"
181
+ @blur="handleTextFieldBlur"
182
+ @keydown="handleTextFieldInput"
183
+ @keyup.enter="handleTextFieldEnterKey"
184
+ @click:clear="handleTextFieldClear"
185
+ @click="toggleMenuOpen('textField')"
186
+ >
187
+ <template #append-inner>
188
+ <span
189
+ style="cursor: pointer;"
190
+ class="font-weight-medium"
191
+ @click="changeDobPrecision"
192
+ >{{ dobPrecisionDisplay }}</span>
193
+ &nbsp;
194
+ <v-icon
195
+ v-bind="activatorProps"
196
+ @click="toggleMenuOpen('icon')"
197
+ >
198
+ fa:fa-regular fa-calendar
199
+ </v-icon>
200
+ </template>
201
+ </v-text-field>
202
+ </template>
203
+ <Datepicker
204
+ v-model="selectedDate"
205
+ model-type="yyyy-MM-dd"
206
+ :enable-time-picker="false"
207
+ :flow="flow"
208
+ :min-date="props.minDate"
209
+ :max-date="props.maxDate"
210
+ auto-apply
211
+ inline
212
+ :locale="locale"
213
+ @update:model-value="updateDatePicker"
214
+ />
215
+ </v-menu>
216
+ </template>
@@ -1,37 +1,37 @@
1
- <script setup lang="ts">
2
- import {Codemirror} from 'vue-codemirror'
3
- import {oneDark} from '@codemirror/theme-one-dark'
4
- import {javascript} from '@codemirror/lang-javascript'
5
- import {html} from '@codemirror/lang-html'
6
- import {vue as vueLang} from '@codemirror/lang-vue'
7
-
8
- interface Props {
9
- height?: string | number
10
- minHeight?: string | number
11
- lang?: 'html' | 'javascript' | 'vue'
12
- }
13
-
14
- const props = withDefaults(defineProps<Props>(), {
15
- height: '100%',
16
- minHeight: '20em',
17
- lang: 'vue',
18
- })
19
-
20
- const extensions = [oneDark]
21
- if (props.lang == 'vue') {
22
- extensions.push(vueLang({ base: html({ autoCloseTags: true, matchClosingTags: true, selfClosingTags: true }) }))
23
- }
24
- else {
25
- extensions.push(javascript({ typescript: true }))
26
- }
27
-
28
- const model = defineModel<string>()
29
- </script>
30
-
31
- <template>
32
- <codemirror
33
- v-model="model"
34
- :extensions="extensions"
35
- :style="{ height: height, minHeight: minHeight }"
36
- />
37
- </template>
1
+ <script setup lang="ts">
2
+ import {Codemirror} from 'vue-codemirror'
3
+ import {oneDark} from '@codemirror/theme-one-dark'
4
+ import {javascript} from '@codemirror/lang-javascript'
5
+ import {html} from '@codemirror/lang-html'
6
+ import {vue as vueLang} from '@codemirror/lang-vue'
7
+
8
+ interface Props {
9
+ height?: string | number
10
+ minHeight?: string | number
11
+ lang?: 'html' | 'javascript' | 'vue'
12
+ }
13
+
14
+ const props = withDefaults(defineProps<Props>(), {
15
+ height: '100%',
16
+ minHeight: '20em',
17
+ lang: 'vue',
18
+ })
19
+
20
+ const extensions = [oneDark]
21
+ if (props.lang == 'vue') {
22
+ extensions.push(vueLang({ base: html({ autoCloseTags: true, matchClosingTags: true, selfClosingTags: true }) }))
23
+ }
24
+ else {
25
+ extensions.push(javascript({ typescript: true }))
26
+ }
27
+
28
+ const model = defineModel<string>()
29
+ </script>
30
+
31
+ <template>
32
+ <codemirror
33
+ v-model="model"
34
+ :extensions="extensions"
35
+ :style="{ height: height, minHeight: minHeight }"
36
+ />
37
+ </template>