@ramathibodi/nuxt-commons 0.0.7 → 0.0.9

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 CHANGED
@@ -67,6 +67,15 @@ npm run test:watch
67
67
  npm run release
68
68
  ```
69
69
 
70
+ ## NPM PUBLISH
71
+ ```bash
72
+ 1. ตรวจสอบ source code, ตรวจสอบ Branch ว่าเป็น master แล้ว จากนั้นตรวจสอบ version ของ npm ว่ามีการเปลี่ยนและไม่ชนกับ version บน npm
73
+ 2. npm run dev:build
74
+ 3. npm publish --access public
75
+ 4. set token ใน link ที่ npm ให้มา
76
+ 5. เสร็จสิ้น
77
+ ```
78
+
70
79
  <!-- Badges -->
71
80
  [npm-version-src]: https://img.shields.io/npm/v/my-module/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
72
81
  [npm-version-href]: https://npmjs.com/package/my-module
package/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.0.7"
7
+ "version": "0.0.9"
8
8
  }
@@ -29,23 +29,23 @@ watch(() => alert?.hasAlert(), (hasAlert) => {
29
29
 
30
30
  <template>
31
31
  <VSnackbar
32
- v-if="currentItem"
33
- v-model="isAlertOpen"
34
- :timeout="timeout"
35
- location="center"
36
- multi-line
37
- variant="text"
38
- @update:model-value="renewAlert()"
32
+ v-if="currentItem"
33
+ v-model="isAlertOpen"
34
+ :timeout="timeout"
35
+ location="center"
36
+ multi-line
37
+ variant="text"
38
+ @update:model-value="renewAlert()"
39
39
  >
40
40
  <!-- @vue-expected-error Type conversion problem -->
41
41
  <VAlert
42
- v-model="isAlertOpen"
43
- closable
44
- :type="currentItem.alertType"
45
- elevation="2"
46
- theme="dark"
47
- variant="flat"
48
- @click:close="renewAlert()"
42
+ v-model="isAlertOpen"
43
+ closable
44
+ :type="currentItem.alertType"
45
+ elevation="2"
46
+ theme="dark"
47
+ variant="flat"
48
+ @click:close="renewAlert()"
49
49
  >
50
50
  {{ currentItem.statusCode ? currentItem.statusCode + ' ' : '' }} {{ currentItem.message }} {{ !isEmpty(currentItem.data) ? currentItem.data : '' }}
51
51
  </VAlert>
@@ -93,23 +93,36 @@ onMounted(() => {
93
93
  </v-card-title>
94
94
  <v-card-text class="d-flex justify-center">
95
95
  <video
96
- ref="videoRef"
97
- autoplay
98
- style="max-width: 1024px"
96
+ ref="videoRef"
97
+ autoplay
98
+ style="max-width: 1024px"
99
99
  />
100
100
  <div style="z-index: 2000; position: relative; bottom: -410px; left: -80px; height: 50px">
101
101
  <FileBtn
102
- accept="image/*"
103
- icon="mdi mdi-image-plus"
104
- icon-only
105
- @update:model-value="loadImageFile"
102
+ accept="image/*"
103
+ icon="mdi mdi-image-plus"
104
+ icon-only
105
+ @update:model-value="loadImageFile"
106
106
  />
107
107
  </div>
108
108
  </v-card-text>
109
109
  <v-card-actions class="d-flex justify-center">
110
- <v-btn icon size="x-large" variant="tonal" @click="captureImage()">
111
- <v-icon icon="fa:fa-solid fa-circle" size="x-large"></v-icon>
112
- <v-tooltip activator="parent" location="top">ถ่ายภาพ</v-tooltip>
110
+ <v-btn
111
+ icon
112
+ size="x-large"
113
+ variant="tonal"
114
+ @click="captureImage()"
115
+ >
116
+ <v-icon
117
+ icon="fa:fa-solid fa-circle"
118
+ size="x-large"
119
+ />
120
+ <v-tooltip
121
+ activator="parent"
122
+ location="top"
123
+ >
124
+ ถ่ายภาพ
125
+ </v-tooltip>
113
126
  </v-btn>
114
127
  </v-card-actions>
115
128
  </v-card>
@@ -1,9 +1,9 @@
1
1
  <script setup lang="ts">
2
- import PDF from 'pdf-vue3';
3
- import { uid } from 'uid';
4
- import { useAlert } from '../../composables/alert'
2
+ import PDF from 'pdf-vue3'
3
+ import { uid } from 'uid'
5
4
  import printJS from 'print-js'
6
- import {ref, computed} from 'vue'
5
+ import { ref, computed } from 'vue'
6
+ import { useAlert } from '../../composables/alert'
7
7
 
8
8
  const props = defineProps<{
9
9
  base64String?: string
@@ -40,7 +40,7 @@ const downloadPdf = (): void => {
40
40
  anchorElement.click()
41
41
  URL.revokeObjectURL(link)
42
42
  document.body.removeChild(anchorElement)
43
- base64.value = ""
43
+ base64.value = ''
44
44
  }
45
45
 
46
46
  const printPdf = () => {
@@ -53,16 +53,16 @@ const printPdf = () => {
53
53
  alert?.addAlert({ message: error, alertType: 'error' })
54
54
  },
55
55
  })
56
- base64.value = ""
56
+ base64.value = ''
57
57
  }
58
58
 
59
59
  const endLoadPdf = () => {
60
60
  emit('closeDialog', false)
61
- base64.value = ""
61
+ base64.value = ''
62
62
  }
63
63
 
64
64
  const isMobile = computed(() => {
65
- if(/Android|Mobi|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Macintosh/i.test(navigator.userAgent)){
65
+ if (/Android|Mobi|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Macintosh/i.test(navigator.userAgent)) {
66
66
  return true
67
67
  }
68
68
  })
@@ -74,31 +74,31 @@ const isMobile = computed(() => {
74
74
  <v-toolbar-title>{{ props.title }}</v-toolbar-title>
75
75
  <v-spacer />
76
76
  <v-btn
77
- v-if="!isMobile"
78
- icon="mdi mdi-printer"
79
- variant="plain"
80
- @click="printPdf"
77
+ v-if="!isMobile"
78
+ icon="mdi mdi-printer"
79
+ variant="plain"
80
+ @click="printPdf"
81
81
  />
82
82
  <v-btn
83
- v-if="!props.disabled"
84
- icon="mdi mdi-download"
85
- variant="plain"
86
- @click="downloadPdf"
83
+ v-if="!props.disabled"
84
+ icon="mdi mdi-download"
85
+ variant="plain"
86
+ @click="downloadPdf"
87
87
  />
88
88
  <v-btn
89
- icon="mdi mdi-close"
90
- variant="plain"
91
- @click="endLoadPdf"
89
+ icon="mdi mdi-close"
90
+ variant="plain"
91
+ @click="endLoadPdf"
92
92
  />
93
93
  </v-toolbar>
94
94
  <v-card-text class="justify-center">
95
95
  <PDF
96
- :show-progress="true"
97
- pdf-width="100%"
98
- :src="base64"
99
- :showPageTooltip="false"
100
- :show-back-to-top-btn="false"
96
+ :show-progress="true"
97
+ pdf-width="100%"
98
+ :src="base64"
99
+ :show-page-tooltip="false"
100
+ :show-back-to-top-btn="false"
101
101
  />
102
102
  </v-card-text>
103
103
  </v-card>
104
- </template>
104
+ </template>
@@ -0,0 +1,59 @@
1
+ <script setup lang="ts">
2
+ import { ref, onMounted, onUnmounted } from 'vue';
3
+ import { VCard } from 'vuetify/components/VCard'
4
+ const isResizing = ref(false);
5
+ const pane1Width = ref('50%');
6
+ interface Props extends /* @vue-ignore */ InstanceType<typeof VCard['$props']>{
7
+ height : number | string
8
+ }
9
+ const props = defineProps<Props>()
10
+
11
+ const startResize = () => {
12
+ isResizing.value = true;
13
+ };
14
+
15
+ const stopResize = () => {
16
+ isResizing.value = false;
17
+ };
18
+
19
+ const resize = (event: MouseEvent) => {
20
+ if (isResizing.value) {
21
+ const container = document.querySelector('.split-pane') as HTMLElement;
22
+ const containerRect = container.getBoundingClientRect();
23
+ const newWidth = event.clientX - containerRect.left;
24
+ pane1Width.value = `${(newWidth / containerRect.width) * 100}%`;
25
+ }
26
+ };
27
+
28
+ onMounted(() => {
29
+ document.addEventListener('mousemove', resize);
30
+ document.addEventListener('mouseup', stopResize);
31
+ });
32
+
33
+ onUnmounted(() => {
34
+ document.removeEventListener('mousemove', resize);
35
+ document.removeEventListener('mouseup', stopResize);
36
+ });
37
+ </script>
38
+
39
+ <template>
40
+ <v-card :="$attrs">
41
+ <v-sheet border :height="height">
42
+ <div class="split-pane">
43
+ <div class="pane" :style="{ width: pane1Width }">
44
+ <slot name="left"></slot>
45
+ </div>
46
+ <v-divider :thickness="3" vertical class="cursor-move" @mousedown="startResize"></v-divider>
47
+ <div class="pane" :style="{ width: `calc(100% - ${pane1Width})` }">
48
+ <slot name="right"></slot>
49
+ </div>
50
+ </div>
51
+ </v-sheet>
52
+
53
+ </v-card>
54
+
55
+ </template>
56
+
57
+ <style scoped>
58
+ .split-pane{height:100%;overflow:hidden;width:100%}.pane,.split-pane{display:flex}
59
+ </style>
@@ -182,6 +182,6 @@ watch(combinedBase64String, (newValue, oldValue) => {
182
182
  :accept="props.accept"
183
183
  :multiple="props.multiple"
184
184
  style="display: none"
185
- @update:modelValue="addFiles"
185
+ @update:model-value="addFiles"
186
186
  />
187
187
  </template>
@@ -127,7 +127,7 @@ onBeforeUnmount(() => {
127
127
  <v-icon>fa-solid fa-trash</v-icon>
128
128
  </v-btn>
129
129
  <v-menu>
130
- <template #activator="{ props : activatorProps }">
130
+ <template #activator="{ props: activatorProps }">
131
131
  <v-btn
132
132
  :color="selectedColor"
133
133
  :icon="true"
@@ -141,11 +141,11 @@ onBeforeUnmount(() => {
141
141
  <v-col class="text-center">
142
142
  <v-avatar
143
143
  v-for="(color, index) in colorOptions"
144
+ :key="index"
144
145
  :color="color"
145
146
  :value="color"
146
147
  class="mr-1"
147
148
  @click="changePenColor(color)"
148
- :key="index"
149
149
  >
150
150
  <v-icon color="white">
151
151
  {{ selectedColor === color ? 'fa-solid fa-check' : '' }}
@@ -20,7 +20,7 @@ const handleAddImage = (image: string) => {
20
20
 
21
21
  const handleCloseDialog = () => {
22
22
  isDialogOpen.value = false
23
- emit("openCamera", true);
23
+ emit('openCamera', true)
24
24
  emit('closeDialog', false)
25
25
  }
26
26
 
@@ -56,13 +56,13 @@ const handleCrop = () => {
56
56
  if (croppedCanvas) {
57
57
  const dataURL = croppedCanvas.toDataURL()
58
58
  emit('update:modelValue', dataURL)
59
- emit("closeDialog", false);
59
+ emit('closeDialog', false)
60
60
  }
61
61
  }
62
62
 
63
63
  const resetCrop = () => {
64
- emit("closeDialog", false);
65
- emit("openCamera", true);
64
+ emit('closeDialog', false)
65
+ emit('openCamera', true)
66
66
  }
67
67
 
68
68
  const close = () => {
@@ -1,28 +1,25 @@
1
1
  <script lang="ts" setup>
2
-
3
-
4
2
  interface Props {
5
- label: string;
6
- value?: string | String | null | undefined;
3
+ label: string
4
+ value?: string | string | null | undefined
7
5
  }
8
6
 
9
7
  const props = withDefaults(defineProps<Props>(), {
10
- label: '', value: ''
11
- });
12
-
8
+ label: '', value: '',
9
+ })
13
10
  </script>
11
+
14
12
  <template>
15
13
  <v-card variant="flat">
16
14
  <VCardSubtitle class="ma-0 pa-0">
17
15
  <slot name="label">
18
16
  {{ label }}
19
17
  </slot>
20
- </VCardSubtitle>
18
+ </VCardSubtitle>
21
19
  <VCardText class="text-h6 pa-0 mb-2">
22
20
  <slot name="value">
23
21
  {{ value }}
24
22
  </slot>
25
-
26
23
  </VCardText>
27
24
  </v-card>
28
25
  </template>
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
- import {computed} from "vue";
2
+ import { computed } from 'vue'
3
+
3
4
  interface Props {
4
5
  modelValue: string
5
6
  variant?: 'mobilePhone' | 'homePhone' | 'citizenId' | 'creditCard'
@@ -12,25 +13,26 @@ const props = withDefaults(defineProps<Props>(), {
12
13
 
13
14
  const labelMask = computed(() => {
14
15
  if (!props.hideContent) {
15
- if(props.variant == 'mobilePhone') return props.modelValue.length == 10 ? `${props.modelValue.substring(0,3)}-${props.modelValue.substring(3,6)}-${props.modelValue.substring(6,10)}` : "invalid format"
16
- if(props.variant == 'homePhone') return props.modelValue.length == 9 ? `${props.modelValue.substring(0,2)}-${props.modelValue.substring(2,5)}-${props.modelValue.substring(5,9)}` : "invalid format"
17
- if(props.variant == 'citizenId') return props.modelValue.length == 13 ? `${props.modelValue.substring(0,1)}-${props.modelValue.substring(1,5)}-${props.modelValue.substring(5,10)}-${props.modelValue.substring(10,12)}-${props.modelValue.substring(12,13)}` : "invalid format"
18
- if(props.variant == 'creditCard') return props.modelValue.length == 16 ? `${props.modelValue.substring(0,4)}-${props.modelValue.substring(4,8)}-${props.modelValue.substring(8,12)}-${props.modelValue.substring(12,16)}` : "invalid format"
16
+ if (props.variant == 'mobilePhone') return props.modelValue.length == 10 ? `${props.modelValue.substring(0, 3)}-${props.modelValue.substring(3, 6)}-${props.modelValue.substring(6, 10)}` : 'invalid format'
17
+ if (props.variant == 'homePhone') return props.modelValue.length == 9 ? `${props.modelValue.substring(0, 2)}-${props.modelValue.substring(2, 5)}-${props.modelValue.substring(5, 9)}` : 'invalid format'
18
+ if (props.variant == 'citizenId') return props.modelValue.length == 13 ? `${props.modelValue.substring(0, 1)}-${props.modelValue.substring(1, 5)}-${props.modelValue.substring(5, 10)}-${props.modelValue.substring(10, 12)}-${props.modelValue.substring(12, 13)}` : 'invalid format'
19
+ if (props.variant == 'creditCard') return props.modelValue.length == 16 ? `${props.modelValue.substring(0, 4)}-${props.modelValue.substring(4, 8)}-${props.modelValue.substring(8, 12)}-${props.modelValue.substring(12, 16)}` : 'invalid format'
19
20
 
20
- const middlePart = 'x'.repeat(props.modelValue.length - 6);
21
- return `${props.modelValue.substring(0,3)}${middlePart}${props.modelValue.slice(-3)}`
22
- } else {
23
- if(props.variant == 'mobilePhone') return props.modelValue.length == 10 ? `${props.modelValue.substring(0,2)}x-xxx-${props.modelValue.substring(6,10)}` : "invalid format"
24
- if(props.variant == 'homePhone') return props.modelValue.length == 9 ? `${props.modelValue.substring(0,2)}-xxx-${props.modelValue.substring(5,9)}` : "invalid format"
25
- if(props.variant == 'citizenId') return props.modelValue.length == 13 ? `${props.modelValue.substring(0,1)}-xxxx-xxxxx-${props.modelValue.substring(10,12)}-${props.modelValue.substring(12,13)}` : "invalid format"
26
- if(props.variant == 'creditCard') return props.modelValue.length == 16 ? `xxxx-xxxx-xxxx-${props.modelValue.substring(12,16)}` : "invalid format"
21
+ const middlePart = 'x'.repeat(props.modelValue.length - 6)
22
+ return `${props.modelValue.substring(0, 3)}${middlePart}${props.modelValue.slice(-3)}`
23
+ }
24
+ else {
25
+ if (props.variant == 'mobilePhone') return props.modelValue.length == 10 ? `${props.modelValue.substring(0, 2)}x-xxx-${props.modelValue.substring(6, 10)}` : 'invalid format'
26
+ if (props.variant == 'homePhone') return props.modelValue.length == 9 ? `${props.modelValue.substring(0, 2)}-xxx-${props.modelValue.substring(5, 9)}` : 'invalid format'
27
+ if (props.variant == 'citizenId') return props.modelValue.length == 13 ? `${props.modelValue.substring(0, 1)}-xxxx-xxxxx-${props.modelValue.substring(10, 12)}-${props.modelValue.substring(12, 13)}` : 'invalid format'
28
+ if (props.variant == 'creditCard') return props.modelValue.length == 16 ? `xxxx-xxxx-xxxx-${props.modelValue.substring(12, 16)}` : 'invalid format'
27
29
 
28
- const middlePart = 'x'.repeat(props.modelValue.length - 6);
29
- return `${props.modelValue.substring(0,3)}${middlePart}${props.modelValue.slice(-3)}`
30
+ const middlePart = 'x'.repeat(props.modelValue.length - 6)
31
+ return `${props.modelValue.substring(0, 3)}${middlePart}${props.modelValue.slice(-3)}`
30
32
  }
31
33
  })
32
34
  </script>
33
35
 
34
36
  <template>
35
- {{labelMask}}
37
+ {{ labelMask }}
36
38
  </template>
@@ -13,6 +13,7 @@ export declare function useRules(): {
13
13
  telephone: (customError?: string) => (value: any) => string | true;
14
14
  email: (customError?: string) => (value: any) => string | true;
15
15
  regex: (regex: string, customError?: string) => (value: any) => string | true;
16
+ idcard: (customError?: string) => (value: any) => string | true;
16
17
  rules: import("vue").Ref<{
17
18
  require: (customError?: string) => (value: any) => string | true;
18
19
  requireIf: (conditionIf: boolean, customError?: string) => (value: any) => string | true;
@@ -28,5 +29,6 @@ export declare function useRules(): {
28
29
  telephone: (customError?: string) => (value: any) => string | true;
29
30
  email: (customError?: string) => (value: any) => string | true;
30
31
  regex: (regex: string, customError?: string) => (value: any) => string | true;
32
+ idcard: (customError?: string) => (value: any) => string | true;
31
33
  }>;
32
34
  };
@@ -16,6 +16,7 @@ export function useRules() {
16
16
  const telephone = (customError = "Invalid telephone number") => (value) => condition(!value || /^(?:\s*(?:0[23457][0-9]{7}|0[689][0-9]{8})(?:#[0-9]{1,5})?\s*(?:\([^()]+\))?\s*(?:,(?=.+))?)*$/.test(value), customError);
17
17
  const email = (customError = "Invalid email address") => (value) => condition(!value || /^([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5})$/.test(value), customError);
18
18
  const regex = (regex2, customError = "Invalid format") => (value) => condition(!value || new RegExp(regex2).test(value), customError);
19
+ const idcard = (customError = "Invalid idcard") => (value) => condition(/^\d{13}$/.test(value) && (11 - [...value].slice(0, 12).reduce((sum, n, i) => sum + +n * (13 - i), 0) % 11) % 10 === +value[12], customError);
19
20
  const rules = ref({
20
21
  require,
21
22
  requireIf,
@@ -30,7 +31,8 @@ export function useRules() {
30
31
  lengthLess,
31
32
  telephone,
32
33
  email,
33
- regex
34
+ regex,
35
+ idcard
34
36
  });
35
37
  return { rules, ...rules.value };
36
38
  }
@@ -68,7 +68,7 @@ const eventContentDay = (arg: any) => {
68
68
  return { domNodes: [list] }
69
69
  }
70
70
 
71
- // @ts-ignore
71
+ // @ts-expect-error
72
72
  const calendarOptions = ref<CalendarOptions>({
73
73
  plugins: [dayGridPlugin, timeGridPlugin, listPlugin, interactionPlugin],
74
74
  initialView: props.mode,
@@ -9,7 +9,7 @@ export function classAttributes(cls) {
9
9
  return Object.keys(new cls());
10
10
  }
11
11
  export function onlyAttributes(keys, object) {
12
- let returnObject = cloneDeep(object);
12
+ const returnObject = cloneDeep(object);
13
13
  Object.keys(object).forEach((localKey) => {
14
14
  if (!keys.includes(localKey))
15
15
  delete returnObject[localKey];
@@ -17,7 +17,7 @@ export function onlyAttributes(keys, object) {
17
17
  return returnObject;
18
18
  }
19
19
  export function renameAttributes(object, mapper) {
20
- let returnObject = cloneDeep(object);
20
+ const returnObject = cloneDeep(object);
21
21
  Object.keys(mapper).forEach((key) => {
22
22
  if (returnObject.hasOwnProperty(key)) {
23
23
  returnObject[mapper[key]] = cloneDeep(returnObject[key]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramathibodi/nuxt-commons",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Ramathibodi Nuxt modules for common components",
5
5
  "repository": {
6
6
  "type": "git",