minsky-webform-formkit 1.0.0
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/.pnp.cjs +11555 -0
- package/.pnp.loader.mjs +2126 -0
- package/LICENSE +21 -0
- package/README.md +324 -0
- package/dist/index.css +1 -0
- package/dist/index.js +1 -0
- package/package.json +55 -0
- package/src/components/FormKit/FormKitPhoneEnhanced/FormKitPhoneEnhanced.js +100 -0
- package/src/components/FormKit/FormKitPhoneEnhanced/FormKitPhoneEnhanced.vue +30 -0
- package/src/components/FormKit/FormKitPhoneEnhanced/countryCodes.js +1214 -0
- package/src/components/FormKit/FormKitRecaptcha/FormKitRecaptcha.vue +46 -0
- package/src/components/Icon.vue +38 -0
- package/src/components/InfoTooltip.vue +16 -0
- package/src/components/MinksyWebformFormKit/MinskyWebformFormKit.vue +357 -0
- package/src/components/MinksyWebformFormKit/_MinskyWebformFormKit.js +282 -0
- package/src/composables/useExample.js +0 -0
- package/src/formkit.config.js +72 -0
- package/src/index.mjs +20 -0
- package/src/plugins/customLabelPlugin.js +42 -0
- package/src/plugins/htmlHelpPlugin.js +23 -0
- package/src/rules/iban.js +9 -0
- package/src/rules/insz.js +21 -0
- package/src/rules/phone.js +29 -0
- package/src/rules/time.js +79 -0
- package/src/rules/vat.js +42 -0
- package/src/styles/_functions.scss +96 -0
- package/src/styles/_mixins.scss +29 -0
- package/src/styles/_variables.scss +7 -0
- package/src/styles/main.scss +11 -0
- package/src/styles/webform-formkit-multistep.scss +98 -0
- package/src/styles/webform-formkit.scss +215 -0
- package/src/styles/webform.scss +400 -0
- package/src/utils/functions.js +78 -0
- package/src/utils/lodash.js +208 -0
- package/src/utils/messages.js +37 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import examples from 'libphonenumber-js/mobile/examples';
|
|
2
|
+
import getUnicodeFlagIcon from 'country-flag-icons/unicode';
|
|
3
|
+
import { getExampleNumber, parsePhoneNumber } from 'libphonenumber-js';
|
|
4
|
+
import { watchEffect, nextTick } from 'vue';
|
|
5
|
+
import countryCodes from './countryCodes';
|
|
6
|
+
|
|
7
|
+
const isOnlyNumbers = /[0-9.]/;
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
props: {
|
|
11
|
+
context: {
|
|
12
|
+
type: Object,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
components: {},
|
|
17
|
+
|
|
18
|
+
beforeMount() {
|
|
19
|
+
this.setCode();
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
mounted() {
|
|
23
|
+
this.setCountries();
|
|
24
|
+
|
|
25
|
+
// for prefilling number from userData
|
|
26
|
+
watchEffect(async () => {
|
|
27
|
+
if (this.context.value) {
|
|
28
|
+
await nextTick(); // Ensure DOM updates if needed
|
|
29
|
+
const parsedNumber = parsePhoneNumber(this.context.value);
|
|
30
|
+
this.country = parsedNumber.country;
|
|
31
|
+
this.phone = parsedNumber.nationalNumber;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
data() {
|
|
37
|
+
return {
|
|
38
|
+
country: this.context.attrs.initialCountry,
|
|
39
|
+
countries: [],
|
|
40
|
+
code: '',
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
computed: {
|
|
45
|
+
maskFn() {
|
|
46
|
+
const exampleNumber = getExampleNumber(this.country, examples);
|
|
47
|
+
const phoneNumber = exampleNumber.formatInternational();
|
|
48
|
+
return maskPhoneExceptCode(this.code, phoneNumber);
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
methods: {
|
|
53
|
+
getUnicodeFlagIcon,
|
|
54
|
+
|
|
55
|
+
setCode() {
|
|
56
|
+
this.code = countryCodes.find((obj) => obj.code === this.country).dial_code;
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
setCountries() {
|
|
60
|
+
const countries = [...countryCodes];
|
|
61
|
+
if (this.context.attrs.preferredCountries) {
|
|
62
|
+
if (this.context.attrs.preferredCountries) {
|
|
63
|
+
this.context.attrs.preferredCountries.reverse().forEach((prefCode) => {
|
|
64
|
+
countries.sort((a) => (a.code === prefCode ? -1 : 1));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (this.context.attrs.initialCountry) countries.sort((a) => (a.code === this.context.attrs.initialCountry ? -1 : 1));
|
|
69
|
+
this.countries = countries;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (this.context.attrs.initialCountry) countries.sort((a) => (a.code === this.context.attrs.initialCountry ? -1 : 1));
|
|
73
|
+
this.countries = countries;
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
watch: {
|
|
78
|
+
country() {
|
|
79
|
+
this.setCode();
|
|
80
|
+
this.context.value = '';
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
'context.value': function (val) {
|
|
84
|
+
this.context.node.input(val);
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
function maskPhoneExceptCode(code, phone) {
|
|
90
|
+
const codeDigits = String(code).replace(/\D/g, ''); // remove + or other chars
|
|
91
|
+
let matchIndex = 0;
|
|
92
|
+
|
|
93
|
+
return phone.replace(/\d/g, (digit) => {
|
|
94
|
+
if (matchIndex < codeDigits.length && digit === codeDigits[matchIndex]) {
|
|
95
|
+
matchIndex += 1;
|
|
96
|
+
return digit;
|
|
97
|
+
}
|
|
98
|
+
return '#';
|
|
99
|
+
});
|
|
100
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<!-- prettier-ignore -->
|
|
2
|
+
<template>
|
|
3
|
+
<div class="formkit-phone-enhanced">
|
|
4
|
+
<div class="formkit-phone-enhanced__flag">
|
|
5
|
+
<select class="formkit-phone-enhanced__list" v-model="country">
|
|
6
|
+
<option v-for="c in countries" :key="c.code" :value="c.code">{{ getUnicodeFlagIcon(c.code) }} {{ c.name }}</option>
|
|
7
|
+
</select>
|
|
8
|
+
<div class="formkit-phone-enhanced__flag-wrapper">
|
|
9
|
+
<img :src="`https://purecatamphetamine.github.io/country-flag-icons/3x2/${country}.svg`" alt="" />
|
|
10
|
+
</div>
|
|
11
|
+
<Icon name="chevron-down-fat" />
|
|
12
|
+
</div>
|
|
13
|
+
<!-- label field filled is in here (and hidden with css) to send label value to local storage (see setUserData() in Webform.vue) -->
|
|
14
|
+
<FormKit
|
|
15
|
+
:classes="{
|
|
16
|
+
outer: 'formkit-phone-enhanced__outer',
|
|
17
|
+
input: 'formkit-phone-enhanced__input',
|
|
18
|
+
}"
|
|
19
|
+
:label="context.label"
|
|
20
|
+
type="mask"
|
|
21
|
+
:name="context.node.name"
|
|
22
|
+
:id="context.id"
|
|
23
|
+
:mask="maskFn"
|
|
24
|
+
:key="code"
|
|
25
|
+
v-model="context.value"
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
<!-- prettier-ignore -->
|
|
30
|
+
<script src="./FormKitPhoneEnhanced.js"></script>
|