@ramathibodi/nuxt-commons 0.0.5 → 0.0.7
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 +6 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Alert.vue +1 -1
- package/dist/runtime/components/label/Field.vue +32 -0
- package/dist/runtime/components/label/Mask.vue +36 -0
- package/dist/runtime/utils/datetime.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Find and replace all on all files (CMD+SHIFT+F):
|
|
|
6
6
|
- Package name: @ramahis/common-components
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
|
-
#
|
|
9
|
+
# @ramathibodi/nuxt-commons
|
|
10
10
|
|
|
11
11
|
[![npm version][npm-version-src]][npm-version-href]
|
|
12
12
|
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
@@ -16,17 +16,17 @@ Find and replace all on all files (CMD+SHIFT+F):
|
|
|
16
16
|
|
|
17
17
|
## Quick Setup
|
|
18
18
|
|
|
19
|
-
1. Add
|
|
19
|
+
1. Add `'@ramathibodi/nuxt-commons'` dependency to your project
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
# Using pnpm
|
|
23
|
-
pnpm add -D @
|
|
23
|
+
pnpm add -D @ramathibodi/nuxt-commons
|
|
24
24
|
|
|
25
25
|
# Using yarn
|
|
26
|
-
yarn add --dev @
|
|
26
|
+
yarn add --dev @ramathibodi/nuxt-commons
|
|
27
27
|
|
|
28
28
|
# Using npm
|
|
29
|
-
npm install --save-dev @
|
|
29
|
+
npm install --save-dev @ramathibodi/nuxt-commons
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
2. Add `my-module` to the `modules` section of `nuxt.config.ts`
|
|
@@ -34,7 +34,7 @@ npm install --save-dev @deverloprama/common-components
|
|
|
34
34
|
```js
|
|
35
35
|
export default defineNuxtConfig({
|
|
36
36
|
modules: [
|
|
37
|
-
'@
|
|
37
|
+
'@ramathibodi/nuxt-commons'
|
|
38
38
|
]
|
|
39
39
|
})
|
|
40
40
|
```
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -17,7 +17,7 @@ const module = defineNuxtModule({
|
|
|
17
17
|
pathPrefix: true,
|
|
18
18
|
global: true
|
|
19
19
|
});
|
|
20
|
-
addImportsDir(resolver.resolve("runtime/composables"));
|
|
20
|
+
addImportsDir(resolver.resolve("runtime/composables/**"));
|
|
21
21
|
addTypeTemplate({
|
|
22
22
|
filename: "types/modules.d.ts",
|
|
23
23
|
getContents: () => `
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
label: string;
|
|
6
|
+
value?: string | String | null | undefined;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
10
|
+
label: '', value: ''
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
</script>
|
|
14
|
+
<template>
|
|
15
|
+
<v-card variant="flat">
|
|
16
|
+
<VCardSubtitle class="ma-0 pa-0">
|
|
17
|
+
<slot name="label">
|
|
18
|
+
{{ label }}
|
|
19
|
+
</slot>
|
|
20
|
+
</VCardSubtitle>
|
|
21
|
+
<VCardText class="text-h6 pa-0 mb-2">
|
|
22
|
+
<slot name="value">
|
|
23
|
+
{{ value }}
|
|
24
|
+
</slot>
|
|
25
|
+
|
|
26
|
+
</VCardText>
|
|
27
|
+
</v-card>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<style lang="">
|
|
31
|
+
|
|
32
|
+
</style>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {computed} from "vue";
|
|
3
|
+
interface Props {
|
|
4
|
+
modelValue: string
|
|
5
|
+
variant?: 'mobilePhone' | 'homePhone' | 'citizenId' | 'creditCard'
|
|
6
|
+
hideContent?: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
10
|
+
hideContent: false,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const labelMask = computed(() => {
|
|
14
|
+
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"
|
|
19
|
+
|
|
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"
|
|
27
|
+
|
|
28
|
+
const middlePart = 'x'.repeat(props.modelValue.length - 6);
|
|
29
|
+
return `${props.modelValue.substring(0,3)}${middlePart}${props.modelValue.slice(-3)}`
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
{{labelMask}}
|
|
36
|
+
</template>
|
|
@@ -68,7 +68,7 @@ export const Datetime = () => ({
|
|
|
68
68
|
setDateTime: function(inputDate, locale = "EN") {
|
|
69
69
|
if (inputDate.isValid) {
|
|
70
70
|
if (inputDate.year - DateTime.now().year > 300)
|
|
71
|
-
inputDate.set({ year: inputDate.year - 543 });
|
|
71
|
+
inputDate = inputDate.set({ year: inputDate.year - 543 });
|
|
72
72
|
}
|
|
73
73
|
this.luxonDateTime = inputDate;
|
|
74
74
|
if (locale == "TH")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ramathibodi/nuxt-commons",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Ramathibodi Nuxt modules for common components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"uid": "^2.0.2",
|
|
65
65
|
"vue": "^3.4.25",
|
|
66
66
|
"vue-signature-pad": "^3.0.2",
|
|
67
|
-
"vuetify": "^3.6.
|
|
67
|
+
"vuetify": "^3.6.8",
|
|
68
68
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.0/xlsx-0.20.0.tgz"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|