@ramathibodi/nuxt-commons 0.1.66 → 0.1.68

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
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.1.66",
7
+ "version": "0.1.68",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -73,7 +73,7 @@ const loadFormData = () => {
73
73
  formData.value = cloneDeep(formDataOriginalValue.value)
74
74
  }
75
75
  else {
76
- formData.value = Object.assign({}, props.initialData)
76
+ formData.value = Object.assign({}, cloneDeep(props.initialData))
77
77
  }
78
78
  }
79
79
 
@@ -85,7 +85,7 @@ const loadFormData = () => {
85
85
  formDataOriginalValue.value = cloneDeep(props.formData)
86
86
  }
87
87
  else {
88
- formData.value = Object.assign({}, props.initialData)
88
+ formData.value = Object.assign({}, cloneDeep(props.initialData))
89
89
  }
90
90
  isSavedAndStay.value = false
91
91
  }
@@ -78,7 +78,7 @@ const loadFormData = () => {
78
78
  formDataOriginalValue.value = cloneDeep(props.formData)
79
79
  }
80
80
  else {
81
- formData.value = Object.assign({}, props.initialData)
81
+ formData.value = Object.assign({}, cloneDeep(props.initialData))
82
82
  }
83
83
  }
84
84
 
@@ -497,8 +497,6 @@ defineExpose({
497
497
  show-first-last-page
498
498
  @first="footerProps.setPage(1)"
499
499
  @last="footerProps.setPage(footerProps.pageCount)"
500
- @next="footerProps.nextPage"
501
- @prev="footerProps.prevPage"
502
500
  @update:model-value="footerProps.setPage"
503
501
  />
504
502
  </v-row>
@@ -281,6 +281,7 @@ defineExpose({
281
281
  :disabled="disabled"
282
282
  :readonly="readonly"
283
283
  :class="$attrs.class"
284
+ autocomplete="off"
284
285
  >
285
286
  <template #default="formProvided">
286
287
  <slot
@@ -137,7 +137,8 @@ const outputText = computed(() => {
137
137
  </script>
138
138
 
139
139
  <template>
140
- <span>
141
- <i v-if="props.zeroBase" class="mdi mdi-clock-time-twelve-outline" aria-hidden="true" ></i>
142
- {{ outputText }}</span>
140
+ <span>
141
+ <i v-if="props.zeroBase" class="mdi mdi-clock-time-twelve-outline"></i>
142
+ <span v-if="props.zeroBase">&nbsp;</span>{{ outputText }}
143
+ </span>
143
144
  </template>
@@ -15,12 +15,12 @@ interface Props extends /* @vue-ignore */ InstanceType<typeof PDF['$props']> {
15
15
  }
16
16
 
17
17
  const props = withDefaults(defineProps<Props>(), {
18
- base64String: "",
19
- title: "",
20
- fileName: "",
18
+ base64String: '',
19
+ title: '',
20
+ fileName: '',
21
21
  disabled: false,
22
22
  isPrint: false,
23
- showBackToTopBtn: false
23
+ showBackToTopBtn: false,
24
24
  })
25
25
 
26
26
  const emit = defineEmits(['closeDialog'])
@@ -33,25 +33,34 @@ const generateUniqueId = (): string => {
33
33
  }
34
34
 
35
35
  const downloadPdf = (): void => {
36
- const byteString = atob(props.base64String || '')
37
- const byteArray = new Uint8Array(byteString.length)
36
+ try {
37
+ if (!props.base64String) alert?.addAlert({ message: 'No Base64 provided', alertType: 'error' })
38
38
 
39
- for (let i = 0; i < byteString.length; i++) {
40
- byteArray[i] = byteString.charCodeAt(i)
41
- }
39
+ const byteString = atob(props.base64String || '')
40
+ const byteArray = new Uint8Array(byteString.length)
42
41
 
43
- const blob = new Blob([byteArray], { type: 'application/pdf' })
44
- const link = URL.createObjectURL(blob)
45
- const anchorElement = document.createElement('a')
46
- anchorElement.style.display = 'none'
47
- anchorElement.href = link
48
- anchorElement.download = `${generateUniqueId()}.pdf`
49
-
50
- document.body.appendChild(anchorElement)
51
- anchorElement.click()
52
- URL.revokeObjectURL(link)
53
- document.body.removeChild(anchorElement)
54
- base64.value = ''
42
+ for (let i = 0; i < byteString.length; i++) {
43
+ byteArray[i] = byteString.charCodeAt(i)
44
+ }
45
+
46
+ const blob = new Blob([byteArray], { type: 'application/pdf' })
47
+ const link = URL.createObjectURL(blob)
48
+ const anchorElement = document.createElement('a')
49
+ anchorElement.style.display = 'none'
50
+ anchorElement.href = link
51
+ anchorElement.download = `${generateUniqueId()}.pdf`
52
+
53
+ document.body.appendChild(anchorElement)
54
+ anchorElement.click()
55
+ URL.revokeObjectURL(link)
56
+ document.body.removeChild(anchorElement)
57
+ base64.value = ''
58
+
59
+ alert?.addAlert({ message: 'Download success', alertType: 'success' })
60
+ }
61
+ catch (error) {
62
+ alert?.addAlert({ message: `Download unsuccess : ${error}`, alertType: 'error' })
63
+ }
55
64
  }
56
65
 
57
66
  const printPdf = () => {
@@ -60,7 +69,7 @@ const printPdf = () => {
60
69
  type: 'pdf',
61
70
  base64: true,
62
71
  onPrintDialogClose: endLoadPdf,
63
- onError: (error: any) => {
72
+ onError: (error) => {
64
73
  alert?.addAlert({ message: error, alertType: 'error' })
65
74
  },
66
75
  })
@@ -73,18 +82,19 @@ const endLoadPdf = () => {
73
82
  }
74
83
 
75
84
  const isMobile = () => {
76
- return /Android|Mobi|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Macintosh/i.test(navigator.userAgent);
85
+ return /Android|Mobi|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Macintosh/i.test(navigator.userAgent)
77
86
  }
78
87
 
79
88
  const checkMobileAndPrint = computed(() => {
80
- return !isMobile() && props.isPrint;
81
- });
89
+ return !isMobile() && props.isPrint
90
+ })
82
91
 
83
92
  const setWidthPdf = computed(() => {
84
93
  if (isMobile()) {
85
- return "100%"
86
- } else {
87
- return "100dvh"
94
+ return '100%'
95
+ }
96
+ else {
97
+ return '100dvh'
88
98
  }
89
99
  })
90
100
  </script>
@@ -114,10 +124,10 @@ const setWidthPdf = computed(() => {
114
124
  </v-toolbar>
115
125
  <v-card-text class="justify-center h-screen">
116
126
  <PDF
117
- v-bind="$attrs"
118
- :pdf-width="setWidthPdf"
119
- :src="base64"
120
- :show-back-to-top-btn="props.showBackToTopBtn"
127
+ v-bind="$attrs"
128
+ :pdf-width="setWidthPdf"
129
+ :src="base64"
130
+ :show-back-to-top-btn="props.showBackToTopBtn"
121
131
  />
122
132
  </v-card-text>
123
133
  </v-card>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramathibodi/nuxt-commons",
3
- "version": "0.1.66",
3
+ "version": "0.1.68",
4
4
  "description": "Ramathibodi Nuxt modules for common components",
5
5
  "repository": {
6
6
  "type": "git",