country-select-pro 4.8.2 → 5.6.4
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/LICENSE +21 -21
- package/README.md +184 -184
- package/dist/country-select.js +351 -277
- package/dist/country-select.min.js +1 -1
- package/package.json +42 -36
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 nikmauro
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 nikmauro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,184 +1,184 @@
|
|
|
1
|
-
# CountrySelect Pro 🌍
|
|
2
|
-
|
|
3
|
-
[](LICENSE)
|
|
4
|
-
[](https://www.jsdelivr.com/package/gh/nikmauro/country-select-pro)
|
|
5
|
-

|
|
6
|
-

|
|
7
|
-
|
|
8
|
-
A **lightweight, zero-dependency, vanilla JavaScript country selector** with localized browser validation and **Bootstrap 5 integration**.
|
|
9
|
-
|
|
10
|
-
CountrySelect Pro provides a clean and fast country dropdown with **search, phone codes, accessibility support and smart browser validation**, without requiring jQuery or any external framework.
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
# ✨ Features
|
|
15
|
-
|
|
16
|
-
* 🚀 **Zero Dependencies** – No jQuery, no frameworks.
|
|
17
|
-
* ⚡ **Ultra Lightweight** – Less than **4KB minified**.
|
|
18
|
-
* 🎨 **Bootstrap 5 Ready** – Seamless integration with `input-group`.
|
|
19
|
-
* 🔍 **Built-in Search** – Quickly filter countries and phone codes.
|
|
20
|
-
* 🛡️ **Smart Validation** – Uses native browser localized validation messages.
|
|
21
|
-
* 📱 **Responsive UI** – Works perfectly on mobile and desktop.
|
|
22
|
-
* ⌨️ **Keyboard Accessible** – Fully navigable with keyboard.
|
|
23
|
-
* 🌐 **International Ready** – Supports ISO country codes.
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
# 🎮 Live Demo
|
|
28
|
-
|
|
29
|
-
Try the interactive demo:
|
|
30
|
-
|
|
31
|
-
https://nikmauro.github.io/country-select-pro/
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
# 📦 Installation
|
|
36
|
-
|
|
37
|
-
## CDN (Recommended)
|
|
38
|
-
|
|
39
|
-
Include the script via **jsDelivr**:
|
|
40
|
-
|
|
41
|
-
```html
|
|
42
|
-
<script src="https://cdn.jsdelivr.net/gh/nikmauro/country-select-pro@4.8.2/dist/country-select.min.js"></script>
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## Local Installation
|
|
48
|
-
|
|
49
|
-
Download the repository and include:
|
|
50
|
-
|
|
51
|
-
```html
|
|
52
|
-
<script src="dist/country-select.min.js"></script>
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
# 🚀 Basic Usage
|
|
58
|
-
|
|
59
|
-
```html
|
|
60
|
-
<input id="country" class="form-control">
|
|
61
|
-
|
|
62
|
-
<script>
|
|
63
|
-
const countrySelect = new CountrySelect("#country", {
|
|
64
|
-
defaultCountry: "gr"
|
|
65
|
-
});
|
|
66
|
-
</script>
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
# ⚙️ Options
|
|
72
|
-
|
|
73
|
-
| Option | Type | Description |
|
|
74
|
-
| -------------------- | ------- | ----------------------------------- |
|
|
75
|
-
| `defaultCountry` | string | Default selected country (ISO code) |
|
|
76
|
-
| `preferredCountries` | array | Countries displayed first |
|
|
77
|
-
| `onlyCountries` | array | Restrict selectable countries |
|
|
78
|
-
| `search` | boolean | Enable / disable search |
|
|
79
|
-
| `placeholder` | string | Custom placeholder text |
|
|
80
|
-
|
|
81
|
-
Example:
|
|
82
|
-
|
|
83
|
-
```javascript
|
|
84
|
-
new CountrySelect("#country", {
|
|
85
|
-
defaultCountry: "gr",
|
|
86
|
-
preferredCountries: ["gr", "cy", "de"],
|
|
87
|
-
search: true
|
|
88
|
-
});
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
# 🧩 Bootstrap 5 Example
|
|
94
|
-
|
|
95
|
-
CountrySelect works perfectly with Bootstrap input groups.
|
|
96
|
-
|
|
97
|
-
```html
|
|
98
|
-
<div class="input-group">
|
|
99
|
-
<span class="input-group-text">🌍</span>
|
|
100
|
-
<input id="country" class="form-control">
|
|
101
|
-
</div>
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
```javascript
|
|
105
|
-
new CountrySelect("#country");
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
# 🌐 Browser Support
|
|
111
|
-
|
|
112
|
-
Compatible with all modern browsers:
|
|
113
|
-
|
|
114
|
-
* Chrome
|
|
115
|
-
* Firefox
|
|
116
|
-
* Safari
|
|
117
|
-
* Edge
|
|
118
|
-
* Mobile browsers (iOS / Android)
|
|
119
|
-
|
|
120
|
-
No polyfills required.
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
# 📂 Project Structure
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
country-select-pro
|
|
128
|
-
│
|
|
129
|
-
├─ dist
|
|
130
|
-
│ ├─ country-select.js
|
|
131
|
-
│ └─ country-select.min.js
|
|
132
|
-
│
|
|
133
|
-
├─ demo
|
|
134
|
-
├─ src
|
|
135
|
-
└─ README.md
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
# 🧠 Why CountrySelect Pro?
|
|
141
|
-
|
|
142
|
-
Many country dropdown libraries rely on **large frameworks like jQuery or heavy UI components**.
|
|
143
|
-
|
|
144
|
-
CountrySelect Pro was built to be:
|
|
145
|
-
|
|
146
|
-
* **Tiny**
|
|
147
|
-
* **Fast**
|
|
148
|
-
* **Dependency-free**
|
|
149
|
-
* **Easy to integrate**
|
|
150
|
-
|
|
151
|
-
Perfect for:
|
|
152
|
-
|
|
153
|
-
* checkout forms
|
|
154
|
-
* registration forms
|
|
155
|
-
* shipping address forms
|
|
156
|
-
* phone number inputs
|
|
157
|
-
* international forms
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
# 🤝 Contributing
|
|
162
|
-
|
|
163
|
-
Contributions are welcome.
|
|
164
|
-
|
|
165
|
-
1. Fork the repository
|
|
166
|
-
2. Create a feature branch
|
|
167
|
-
3. Submit a Pull Request
|
|
168
|
-
|
|
169
|
-
---
|
|
170
|
-
|
|
171
|
-
# 👨💻 Author
|
|
172
|
-
|
|
173
|
-
Developed by **Nikolaos Mavroeidis**
|
|
174
|
-
GitHub: https://github.com/nikmauro
|
|
175
|
-
|
|
176
|
-
With collaborative assistance from **Gemini (Google AI)**.
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
# 📄 License
|
|
181
|
-
|
|
182
|
-
MIT License
|
|
183
|
-
|
|
184
|
-
Feel free to use it in personal and commercial projects.
|
|
1
|
+
# CountrySelect Pro 🌍
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
[](https://www.jsdelivr.com/package/gh/nikmauro/country-select-pro)
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
A **lightweight, zero-dependency, vanilla JavaScript country selector** with localized browser validation and **Bootstrap 5 integration**.
|
|
9
|
+
|
|
10
|
+
CountrySelect Pro provides a clean and fast country dropdown with **search, phone codes, accessibility support and smart browser validation**, without requiring jQuery or any external framework.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# ✨ Features
|
|
15
|
+
|
|
16
|
+
* 🚀 **Zero Dependencies** – No jQuery, no frameworks.
|
|
17
|
+
* ⚡ **Ultra Lightweight** – Less than **4KB minified**.
|
|
18
|
+
* 🎨 **Bootstrap 5 Ready** – Seamless integration with `input-group`.
|
|
19
|
+
* 🔍 **Built-in Search** – Quickly filter countries and phone codes.
|
|
20
|
+
* 🛡️ **Smart Validation** – Uses native browser localized validation messages.
|
|
21
|
+
* 📱 **Responsive UI** – Works perfectly on mobile and desktop.
|
|
22
|
+
* ⌨️ **Keyboard Accessible** – Fully navigable with keyboard.
|
|
23
|
+
* 🌐 **International Ready** – Supports ISO country codes.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# 🎮 Live Demo
|
|
28
|
+
|
|
29
|
+
Try the interactive demo:
|
|
30
|
+
|
|
31
|
+
https://nikmauro.github.io/country-select-pro/
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
# 📦 Installation
|
|
36
|
+
|
|
37
|
+
## CDN (Recommended)
|
|
38
|
+
|
|
39
|
+
Include the script via **jsDelivr**:
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<script src="https://cdn.jsdelivr.net/gh/nikmauro/country-select-pro@4.8.2/dist/country-select.min.js"></script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Local Installation
|
|
48
|
+
|
|
49
|
+
Download the repository and include:
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<script src="dist/country-select.min.js"></script>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
# 🚀 Basic Usage
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<input id="country" class="form-control">
|
|
61
|
+
|
|
62
|
+
<script>
|
|
63
|
+
const countrySelect = new CountrySelect("#country", {
|
|
64
|
+
defaultCountry: "gr"
|
|
65
|
+
});
|
|
66
|
+
</script>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
# ⚙️ Options
|
|
72
|
+
|
|
73
|
+
| Option | Type | Description |
|
|
74
|
+
| -------------------- | ------- | ----------------------------------- |
|
|
75
|
+
| `defaultCountry` | string | Default selected country (ISO code) |
|
|
76
|
+
| `preferredCountries` | array | Countries displayed first |
|
|
77
|
+
| `onlyCountries` | array | Restrict selectable countries |
|
|
78
|
+
| `search` | boolean | Enable / disable search |
|
|
79
|
+
| `placeholder` | string | Custom placeholder text |
|
|
80
|
+
|
|
81
|
+
Example:
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
new CountrySelect("#country", {
|
|
85
|
+
defaultCountry: "gr",
|
|
86
|
+
preferredCountries: ["gr", "cy", "de"],
|
|
87
|
+
search: true
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
# 🧩 Bootstrap 5 Example
|
|
94
|
+
|
|
95
|
+
CountrySelect works perfectly with Bootstrap input groups.
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<div class="input-group">
|
|
99
|
+
<span class="input-group-text">🌍</span>
|
|
100
|
+
<input id="country" class="form-control">
|
|
101
|
+
</div>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
new CountrySelect("#country");
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
# 🌐 Browser Support
|
|
111
|
+
|
|
112
|
+
Compatible with all modern browsers:
|
|
113
|
+
|
|
114
|
+
* Chrome
|
|
115
|
+
* Firefox
|
|
116
|
+
* Safari
|
|
117
|
+
* Edge
|
|
118
|
+
* Mobile browsers (iOS / Android)
|
|
119
|
+
|
|
120
|
+
No polyfills required.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
# 📂 Project Structure
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
country-select-pro
|
|
128
|
+
│
|
|
129
|
+
├─ dist
|
|
130
|
+
│ ├─ country-select.js
|
|
131
|
+
│ └─ country-select.min.js
|
|
132
|
+
│
|
|
133
|
+
├─ demo
|
|
134
|
+
├─ src
|
|
135
|
+
└─ README.md
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
# 🧠 Why CountrySelect Pro?
|
|
141
|
+
|
|
142
|
+
Many country dropdown libraries rely on **large frameworks like jQuery or heavy UI components**.
|
|
143
|
+
|
|
144
|
+
CountrySelect Pro was built to be:
|
|
145
|
+
|
|
146
|
+
* **Tiny**
|
|
147
|
+
* **Fast**
|
|
148
|
+
* **Dependency-free**
|
|
149
|
+
* **Easy to integrate**
|
|
150
|
+
|
|
151
|
+
Perfect for:
|
|
152
|
+
|
|
153
|
+
* checkout forms
|
|
154
|
+
* registration forms
|
|
155
|
+
* shipping address forms
|
|
156
|
+
* phone number inputs
|
|
157
|
+
* international forms
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
# 🤝 Contributing
|
|
162
|
+
|
|
163
|
+
Contributions are welcome.
|
|
164
|
+
|
|
165
|
+
1. Fork the repository
|
|
166
|
+
2. Create a feature branch
|
|
167
|
+
3. Submit a Pull Request
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
# 👨💻 Author
|
|
172
|
+
|
|
173
|
+
Developed by **Nikolaos Mavroeidis**
|
|
174
|
+
GitHub: https://github.com/nikmauro
|
|
175
|
+
|
|
176
|
+
With collaborative assistance from **Gemini (Google AI)**.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
# 📄 License
|
|
181
|
+
|
|
182
|
+
MIT License
|
|
183
|
+
|
|
184
|
+
Feel free to use it in personal and commercial projects.
|
package/dist/country-select.js
CHANGED
|
@@ -1,277 +1,351 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CountrySelect Pro
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
this.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
.cs-
|
|
75
|
-
.cs-error-msg {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
.cs-wrapper
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
.cs-
|
|
97
|
-
|
|
98
|
-
.cs-
|
|
99
|
-
.cs-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
.cs-
|
|
104
|
-
.cs-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
this.
|
|
160
|
-
|
|
161
|
-
this.
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
this.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.
|
|
205
|
-
|
|
206
|
-
this.
|
|
207
|
-
this.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
this.
|
|
239
|
-
this.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
if (this.
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
1
|
+
/**
|
|
2
|
+
* CountrySelect Pro v5.6.4
|
|
3
|
+
* ---------------------------------------------------------------------------
|
|
4
|
+
* Features:
|
|
5
|
+
* - SVG Arrow Down icon
|
|
6
|
+
* - HTMX Auto-initialization
|
|
7
|
+
* - Improved Validation UI
|
|
8
|
+
* - Zero Dependencies
|
|
9
|
+
* ---------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
class CountrySelect {
|
|
13
|
+
constructor(element, options = {}) {
|
|
14
|
+
this.input = element;
|
|
15
|
+
if (!this.input) return;
|
|
16
|
+
|
|
17
|
+
// Configuration
|
|
18
|
+
this.schema = this.input.dataset.schema || "{img} {name}";
|
|
19
|
+
this.schemaReturn = this.input.dataset.schemaReturn || this.schema;
|
|
20
|
+
this.valueType = this.input.dataset.valueType || "code";
|
|
21
|
+
this.rowLimit = parseInt(this.input.dataset.countryRowValues) || 5;
|
|
22
|
+
this.hasSearch = this.input.dataset.countrySearch !== "false";
|
|
23
|
+
this.dropdownWidth = this.input.dataset.dropdownWidth || "auto";
|
|
24
|
+
|
|
25
|
+
// Preferred Logic
|
|
26
|
+
const preferredAttr = this.input.dataset.preferred || "";
|
|
27
|
+
this.preferredCodes = preferredAttr ? preferredAttr.split(',').map(c => c.trim().toUpperCase()) : [];
|
|
28
|
+
|
|
29
|
+
this.config = {
|
|
30
|
+
placeholder: this.input.dataset.placeholder || "Select",
|
|
31
|
+
...options
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
this.countries = [];
|
|
35
|
+
this.filteredCountries = [];
|
|
36
|
+
this.isOpen = false;
|
|
37
|
+
this.activeIndex = -1;
|
|
38
|
+
this.rowHeight = 44;
|
|
39
|
+
|
|
40
|
+
this._init();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async _init() {
|
|
44
|
+
this._applyStyles();
|
|
45
|
+
this._setupDOM();
|
|
46
|
+
this._bindEvents();
|
|
47
|
+
await this._loadData();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
_applyStyles() {
|
|
51
|
+
const styles = `
|
|
52
|
+
.cs-wrapper { position: relative; font-family: inherit; width: 100%; outline: none; }
|
|
53
|
+
.cs-trigger {
|
|
54
|
+
/* Bootstrap 5 Exact Specs */
|
|
55
|
+
padding: 0.375rem 2.25rem 0.375rem 0.75rem;
|
|
56
|
+
font-size: 1rem;
|
|
57
|
+
font-weight: 400;
|
|
58
|
+
line-height: 1.5;
|
|
59
|
+
color: #212529;
|
|
60
|
+
background-color: #fff;
|
|
61
|
+
background-clip: padding-box;
|
|
62
|
+
border: 1px solid #ced4da;
|
|
63
|
+
border-radius: 0.375rem;
|
|
64
|
+
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
|
|
65
|
+
display: flex; align-items: center; gap: 8px; cursor: pointer;
|
|
66
|
+
min-height: calc(1.5em + 0.75rem + 2px);
|
|
67
|
+
box-sizing: border-box; position: relative;
|
|
68
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
|
|
69
|
+
background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 16px 12px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.input-group > .cs-wrapper { flex: 1 1 auto; width: 1%; }
|
|
73
|
+
.cs-wrapper.is-invalid .cs-trigger { border-color: #dc3545 !important; }
|
|
74
|
+
.cs-error-msg { display: none; color: #dc3545; font-size: 0.825em; margin-top: 4px; position: absolute; left: 0; top: 100%; width: 100%; z-index: 10; }
|
|
75
|
+
.cs-wrapper.is-invalid .cs-error-msg { display: block; }
|
|
76
|
+
|
|
77
|
+
/* Focus state Bootstrap 5 */
|
|
78
|
+
.cs-wrapper:focus-within .cs-trigger {
|
|
79
|
+
border-color: #86b7fe;
|
|
80
|
+
outline: 0;
|
|
81
|
+
box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.cs-dropdown {
|
|
85
|
+
position: absolute; left: 0; right: 0; background: #fff;
|
|
86
|
+
border: 1px solid rgba(0,0,0,.15); border-radius: 0.375rem;
|
|
87
|
+
z-index: 2050; display: none; margin-top: 0.125rem;
|
|
88
|
+
box-shadow: 0 0.5rem 1rem rgba(0,0,0,.175);
|
|
89
|
+
overflow: hidden; max-width: 95vw;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.cs-wrapper.drop-up .cs-dropdown {
|
|
93
|
+
bottom: calc(100% + 0.25rem); top: auto;
|
|
94
|
+
box-shadow: 0 -0.5rem 1rem rgba(0,0,0,.175);
|
|
95
|
+
}
|
|
96
|
+
.cs-wrapper.open .cs-dropdown { display: block; }
|
|
97
|
+
|
|
98
|
+
.cs-search-box { padding: 8px; border-bottom: 1px solid #dee2e6; background: #f8f9fa; }
|
|
99
|
+
.cs-search-input {
|
|
100
|
+
width: 100%; padding: 0.375rem 0.75rem; border: 1px solid #ced4da;
|
|
101
|
+
border-radius: 0.25rem; outline: none; font-size: 0.875rem;
|
|
102
|
+
}
|
|
103
|
+
.cs-list { overflow-y: auto; scrollbar-width: thin; scroll-behavior: auto; min-height: 50px; padding: 0.375rem 0; }
|
|
104
|
+
.cs-option {
|
|
105
|
+
padding: 0.5rem 0.75rem; display: flex; align-items: center; gap: 10px;
|
|
106
|
+
cursor: pointer; font-size: 0.9rem; transition: background 0.1s;
|
|
107
|
+
}
|
|
108
|
+
.cs-option:hover { background-color: #f8f9fa; }
|
|
109
|
+
.cs-option.active { background-color: #0d6efd; color: #fff; }
|
|
110
|
+
|
|
111
|
+
.cs-wrapper img { width: 20px !important; height: 14px !important; object-fit: cover; border-radius: 2px; flex-shrink: 0; }
|
|
112
|
+
.cs-selected-content { display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; line-height: 1; }
|
|
113
|
+
.cs-divider { height: 1px; background: #dee2e6; margin: 0.375rem 0; pointer-events: none; }
|
|
114
|
+
.cs-hidden { display: none !important; }
|
|
115
|
+
`;
|
|
116
|
+
const styleId = 'cs-v57-styles';
|
|
117
|
+
if (!document.getElementById(styleId)) {
|
|
118
|
+
const style = document.createElement("style");
|
|
119
|
+
style.id = styleId;
|
|
120
|
+
style.textContent = styles;
|
|
121
|
+
document.head.appendChild(style);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
_setupDOM() {
|
|
126
|
+
Object.assign(this.input.style, {
|
|
127
|
+
position: 'absolute',
|
|
128
|
+
opacity: '0',
|
|
129
|
+
width: '1px',
|
|
130
|
+
height: '1px',
|
|
131
|
+
pointerEvents: 'none'
|
|
132
|
+
});
|
|
133
|
+
this.wrapper = document.createElement('div');
|
|
134
|
+
this.wrapper.className = 'cs-wrapper';
|
|
135
|
+
this.wrapper.tabIndex = 0;
|
|
136
|
+
const initialText = this.input.value ? "" : this.config.placeholder;
|
|
137
|
+
this.wrapper.innerHTML = `
|
|
138
|
+
<div class="cs-trigger"><span class="cs-selected-content">${initialText}</span></div>
|
|
139
|
+
<div class="cs-error-msg"></div>
|
|
140
|
+
<div class="cs-dropdown">
|
|
141
|
+
<div class="cs-search-box ${!this.hasSearch ? 'cs-hidden' : ''}">
|
|
142
|
+
<input type="text" class="cs-search-input" placeholder="Search..." autocomplete="off" tabindex="-1">
|
|
143
|
+
</div>
|
|
144
|
+
<div class="cs-list"><div class="cs-loading" style="padding:15px; text-align:center;">Loading...</div></div>
|
|
145
|
+
</div>
|
|
146
|
+
`;
|
|
147
|
+
const dropdown = this.wrapper.querySelector('.cs-dropdown');
|
|
148
|
+
dropdown.style.width = (this.dropdownWidth === 'auto') ? '100%' : this.dropdownWidth;
|
|
149
|
+
this.input.parentNode.insertBefore(this.wrapper, this.input.nextSibling);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
_updatePosition() {
|
|
153
|
+
const rect = this.wrapper.getBoundingClientRect();
|
|
154
|
+
const dropdownHeight = (this.rowLimit * this.rowHeight) + (this.hasSearch ? 60 : 0);
|
|
155
|
+
const spaceBelow = window.innerHeight - rect.bottom;
|
|
156
|
+
const spaceAbove = rect.top;
|
|
157
|
+
|
|
158
|
+
if (spaceBelow < dropdownHeight && spaceAbove > dropdownHeight) {
|
|
159
|
+
this.wrapper.classList.add('drop-up');
|
|
160
|
+
} else {
|
|
161
|
+
this.wrapper.classList.remove('drop-up');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async _loadData() {
|
|
166
|
+
try {
|
|
167
|
+
const res = await fetch('https://restcountries.com/v3.1/all?fields=name,flags,cca2,idd');
|
|
168
|
+
const data = await res.json();
|
|
169
|
+
|
|
170
|
+
this.countries = data.map(c => ({
|
|
171
|
+
name: c.name.common,
|
|
172
|
+
code: c.cca2.toUpperCase(),
|
|
173
|
+
flag: c.flags.svg,
|
|
174
|
+
phone: c.idd.root + (c.idd.suffixes ? (c.idd.suffixes.length > 1 ? "" : c.idd.suffixes[0]) : ""),
|
|
175
|
+
isPreferred: this.preferredCodes.includes(c.cca2.toUpperCase())
|
|
176
|
+
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
177
|
+
|
|
178
|
+
this.filteredCountries = [...this.countries];
|
|
179
|
+
this._renderOptions();
|
|
180
|
+
this._syncInitialValue();
|
|
181
|
+
} catch (e) {
|
|
182
|
+
console.error("CountrySelect API Fail", e);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
_syncInitialValue() {
|
|
187
|
+
const val = this.input.value;
|
|
188
|
+
if (!val) {
|
|
189
|
+
this.wrapper.querySelector('.cs-selected-content').innerHTML = this.config.placeholder;
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const current = this.countries.find(c => this.valueType === "phone" ? c.phone === val : this.valueType === "name" ? c.name === val : c.code === val);
|
|
193
|
+
if (current) this._updateUI(current);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
_parseTemplate(template, country) {
|
|
197
|
+
return template.replace('{img}', `<img src="${country.flag}">`).replace('{name}', `<span>${country.name}</span>`).replace('{code}', `<span>${country.code}</span>`).replace('{phone}', `<span>${country.phone}</span>`);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
_renderOptions() {
|
|
201
|
+
const listContainer = this.wrapper.querySelector('.cs-list');
|
|
202
|
+
if (!listContainer) return;
|
|
203
|
+
listContainer.innerHTML = '';
|
|
204
|
+
const searchVal = this.wrapper.querySelector('.cs-search-input')?.value || "";
|
|
205
|
+
|
|
206
|
+
const preferred = this.filteredCountries.filter(c => c.isPreferred);
|
|
207
|
+
const others = this.filteredCountries.filter(c => !c.isPreferred);
|
|
208
|
+
|
|
209
|
+
const createOption = (country, index) => {
|
|
210
|
+
const div = document.createElement('div');
|
|
211
|
+
div.className = `cs-option ${index === this.activeIndex ? 'active' : ''}`;
|
|
212
|
+
div.innerHTML = this._parseTemplate(this.schema, country);
|
|
213
|
+
div.onclick = (e) => {
|
|
214
|
+
e.stopPropagation();
|
|
215
|
+
this._select(country);
|
|
216
|
+
};
|
|
217
|
+
return div;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
preferred.forEach((c, i) => listContainer.appendChild(createOption(c, i)));
|
|
221
|
+
|
|
222
|
+
if (preferred.length > 0 && others.length > 0 && !searchVal) {
|
|
223
|
+
const hr = document.createElement('div');
|
|
224
|
+
hr.className = 'cs-divider';
|
|
225
|
+
listContainer.appendChild(hr);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
others.forEach((c, i) => listContainer.appendChild(createOption(c, preferred.length + i)));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
_select(country) {
|
|
232
|
+
this._updateUI(country);
|
|
233
|
+
|
|
234
|
+
// Ενημέρωση τιμής
|
|
235
|
+
this.input.value = (this.valueType === "phone") ? country.phone : (this.valueType === "name" ? country.name : country.code);
|
|
236
|
+
|
|
237
|
+
// Reset validation (αν χρησιμοποιείς Bootstrap classes)
|
|
238
|
+
this.input.setCustomValidity("");
|
|
239
|
+
this.wrapper.classList.remove('is-invalid');
|
|
240
|
+
|
|
241
|
+
// 1. Τυπικό change & input (για γενική χρήση)
|
|
242
|
+
this.input.dispatchEvent(new Event('change', {bubbles: true}));
|
|
243
|
+
this.input.dispatchEvent(new Event('input', {bubbles: true}));
|
|
244
|
+
|
|
245
|
+
// 2. ΤΟ ΚΛΕΙΔΙ: Μοναδικό event για το δικό μας HTMX Trigger
|
|
246
|
+
this.input.dispatchEvent(new Event('country-change', {bubbles: true}));
|
|
247
|
+
|
|
248
|
+
this._toggle(false);
|
|
249
|
+
this.wrapper.focus();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
_updateUI(country) {
|
|
253
|
+
const content = this.wrapper.querySelector('.cs-selected-content');
|
|
254
|
+
if (content) content.innerHTML = this._parseTemplate(this.schemaReturn, country);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
_toggle(force) {
|
|
258
|
+
if (this.countries.length === 0) return;
|
|
259
|
+
this.isOpen = force !== undefined ? force : !this.isOpen;
|
|
260
|
+
if (this.isOpen) {
|
|
261
|
+
this._updatePosition();
|
|
262
|
+
document.dispatchEvent(new CustomEvent('cs-close-others', {detail: {opener: this.wrapper}}));
|
|
263
|
+
|
|
264
|
+
this._renderOptions();
|
|
265
|
+
const list = this.wrapper.querySelector('.cs-list');
|
|
266
|
+
list.style.maxHeight = `${this.rowLimit * this.rowHeight}px`;
|
|
267
|
+
|
|
268
|
+
const pref = this.filteredCountries.filter(c => c.isPreferred);
|
|
269
|
+
const oth = this.filteredCountries.filter(c => !c.isPreferred);
|
|
270
|
+
const fullList = [...pref, ...oth];
|
|
271
|
+
this.activeIndex = fullList.findIndex(c => this.input.value.includes(c.code) || this.input.value.includes(c.phone));
|
|
272
|
+
|
|
273
|
+
if (this.activeIndex > -1) setTimeout(() => this._scrollToActive(), 0);
|
|
274
|
+
if (this.hasSearch) setTimeout(() => this.wrapper.querySelector('.cs-search-input').focus(), 50);
|
|
275
|
+
}
|
|
276
|
+
this.wrapper.classList.toggle('open', this.isOpen);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
_bindEvents() {
|
|
280
|
+
this.wrapper.querySelector('.cs-trigger').onclick = (e) => {
|
|
281
|
+
e.stopPropagation();
|
|
282
|
+
this._toggle();
|
|
283
|
+
};
|
|
284
|
+
this.wrapper.addEventListener('keydown', (e) => {
|
|
285
|
+
if (!this.isOpen && (e.key === 'ArrowDown')) {
|
|
286
|
+
e.preventDefault();
|
|
287
|
+
this._toggle(true);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (this.isOpen) {
|
|
291
|
+
if (e.key === 'ArrowDown') {
|
|
292
|
+
e.preventDefault();
|
|
293
|
+
this.activeIndex++;
|
|
294
|
+
this._renderOptions();
|
|
295
|
+
this._scrollToActive();
|
|
296
|
+
} else if (e.key === 'ArrowUp') {
|
|
297
|
+
e.preventDefault();
|
|
298
|
+
this.activeIndex--;
|
|
299
|
+
this._renderOptions();
|
|
300
|
+
this._scrollToActive();
|
|
301
|
+
} else if (e.key === 'Escape') this._toggle(false);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
if (this.hasSearch) {
|
|
305
|
+
this.wrapper.querySelector('.cs-search-input').oninput = (e) => {
|
|
306
|
+
const term = e.target.value.toLowerCase();
|
|
307
|
+
this.filteredCountries = this.countries.filter(c => c.name.toLowerCase().includes(term) || c.phone.includes(term));
|
|
308
|
+
this.activeIndex = 0;
|
|
309
|
+
this._renderOptions();
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
document.addEventListener('click', (e) => {
|
|
313
|
+
if (!this.wrapper.contains(e.target)) this._toggle(false);
|
|
314
|
+
});
|
|
315
|
+
document.addEventListener('cs-close-others', (e) => {
|
|
316
|
+
if (e.detail.opener !== this.wrapper) {
|
|
317
|
+
this.isOpen = false;
|
|
318
|
+
this.wrapper.classList.remove('open');
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
_scrollToActive() {
|
|
324
|
+
const list = this.wrapper.querySelector('.cs-list');
|
|
325
|
+
const options = list.querySelectorAll('.cs-option');
|
|
326
|
+
const activeItem = options[this.activeIndex];
|
|
327
|
+
if (activeItem) {
|
|
328
|
+
const scrollPos = activeItem.offsetTop - (list.offsetHeight / 2) + (this.rowHeight / 2);
|
|
329
|
+
list.scrollTop = scrollPos;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** AUTO-INIT (STATIC & HTMX) **/
|
|
335
|
+
const initCS = (target) => {
|
|
336
|
+
const root = (target && target.querySelectorAll) ? target : document;
|
|
337
|
+
root.querySelectorAll('.country-select').forEach(el => {
|
|
338
|
+
const hasWrapper = el.nextSibling && el.nextSibling.classList && el.nextSibling.classList.contains('cs-wrapper');
|
|
339
|
+
if (!hasWrapper) new CountrySelect(el);
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
const setupListeners = () => {
|
|
343
|
+
initCS(document);
|
|
344
|
+
['htmx:afterProcess', 'htmx:afterSettle'].forEach(evt => document.body.addEventListener(evt, (e) => initCS(e.detail.target || e.target)));
|
|
345
|
+
new MutationObserver((m) => m.forEach(mu => mu.addedNodes.length && initCS(mu.target))).observe(document.body, {
|
|
346
|
+
childList: true,
|
|
347
|
+
subtree: true
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', setupListeners);
|
|
351
|
+
else setupListeners();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
class CountrySelect{constructor(e,t={}){this.input=e,this.input&&(this.schema=this.input.dataset.schema||"{img} {name}",this.schemaReturn=this.input.dataset.schemaReturn||this.schema,this.valueType=this.input.dataset.valueType||"code",this.rowLimit=parseInt(this.input.dataset.countryRowValues)||5,this.hasSearch="false"!==this.input.dataset.countrySearch,this.dropdownWidth=this.input.dataset.dropdownWidth||"auto",this.config={placeholder:this.input.dataset.placeholder||"Select",preferred:this.input.dataset.preferred?this.input.dataset.preferred.split(","):[],...t},this.countries=[],this.filteredCountries=[],this.isOpen=!1,this.activeIndex=-1,this.rowHeight=44,this._init())}async _init(){this._applyStyles(),this._setupDOM(),this._bindEvents(),await this._loadData()}_applyStyles(){const e="cs-v48-final-styles";if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent="\n .cs-wrapper { position: relative; font-family: system-ui, sans-serif; outline: none; box-sizing: border-box; display: block; width: 100%; }\n .cs-trigger { \n padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; \n display: flex; align-items: center; gap: 10px; cursor: pointer; background: #fff; min-height: 42px; box-sizing: border-box;\n transition: border-color 0.15s ease-in-out;\n }\n \n /* Validation UI */\n .cs-wrapper.is-invalid .cs-trigger { border-color: #dc3545 !important; }\n .cs-error-msg { \n display: none; color: #dc3545; font-size: 0.825em; margin-top: 4px; position: absolute; left: 0; top: 100%; width: 100%; z-index: 10;\n }\n .cs-wrapper.is-invalid .cs-error-msg { display: block; }\n\n /* Bootstrap Input Group Support */\n .input-group-text .cs-wrapper .cs-trigger { border: none; background: transparent; padding: 0; min-height: auto; width: auto; }\n .input-group-text .cs-wrapper { width: auto; }\n .input-group-text { padding: 0 12px !important; position: relative; }\n .input-group-text:has(.cs-wrapper.is-invalid) { border-color: #dc3545; z-index: 5; }\n\n .cs-wrapper:focus .cs-trigger { border-color: #007bff; box-shadow: 0 0 0 3px rgba(0,123,255,0.15); }\n \n /* Dropdown Menu */\n .cs-dropdown { \n position: absolute; top: calc(100% + 8px); left: 0; background: #fff; \n border: 1px solid #ccc; z-index: 2050; display: none; \n box-shadow: 0 10px 25px rgba(0,0,0,0.1); border-radius: 6px; overflow: hidden; max-width: 95vw;\n }\n .cs-wrapper.open .cs-dropdown { display: block; }\n .cs-search-box { padding: 8px; border-bottom: 1px solid #eee; background: #f9f9f9; }\n .cs-search-input { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; outline: none; }\n .cs-list { overflow-y: auto; scrollbar-width: thin; scroll-behavior: smooth; min-height: 50px; }\n .cs-option { height: 44px; padding: 0 12px; display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; box-sizing: border-box; color: #333; }\n .cs-option:hover, .cs-option.active { background: #f0f7ff; color: #0056b3; }\n \n /* Elements */\n .cs-wrapper img { width: 22px !important; height: 15px !important; object-fit: cover; border-radius: 2px; flex-shrink: 0; }\n .cs-selected-content { display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; min-width: 20px; font-size: 14px; }\n .cs-hidden { display: none !important; }\n ",document.head.appendChild(t)}}_setupDOM(){Object.assign(this.input.style,{position:"absolute",opacity:"0",width:"1px",height:"1px",pointerEvents:"none"}),this.wrapper=document.createElement("div"),this.wrapper.className="cs-wrapper",this.wrapper.tabIndex=0;const e=this.input.value?"":this.config.placeholder;this.wrapper.innerHTML=`\n <div class="cs-trigger"><span class="cs-selected-content">${e}</span></div>\n <div class="cs-error-msg"></div>\n <div class="cs-dropdown">\n <div class="cs-search-box ${this.hasSearch?"":"cs-hidden"}">\n <input type="text" class="cs-search-input" placeholder="Search..." autocomplete="off" tabindex="-1">\n </div>\n <div class="cs-list"><div class="cs-loading" style="padding:15px; text-align:center;">Loading...</div></div>\n </div>\n `;this.wrapper.querySelector(".cs-dropdown").style.width="auto"===this.dropdownWidth?"100%":this.dropdownWidth,this.input.parentNode.insertBefore(this.wrapper,this.input.nextSibling),this.input.classList.contains("is-invalid")&&this._showError()}async _loadData(){try{const e=await fetch("https://restcountries.com/v3.1/all?fields=name,flags,cca2,idd"),t=await e.json();this.countries=t.map((e=>({name:e.name.common,code:e.cca2,flag:e.flags.svg,phone:e.idd.root+(e.idd.suffixes?e.idd.suffixes.length>1?"":e.idd.suffixes[0]:"")}))).sort(((e,t)=>e.name.localeCompare(t.name))),this.filteredCountries=[...this.countries],this._renderOptions(),this._syncInitialValue()}catch(e){console.error("CountrySelect: API Failed",e)}}_syncInitialValue(){const e=this.input.value;if(!e)return void(this.wrapper.querySelector(".cs-selected-content").innerHTML=this.config.placeholder);const t=this.countries.find((t=>"phone"===this.valueType?t.phone===e:"name"===this.valueType?t.name===e:t.code===e));t?this._updateUI(t):this.wrapper.querySelector(".cs-selected-content").innerHTML=this.config.placeholder}_parseTemplate(e,t){return e.replace("{img}",`<img src="${t.flag}">`).replace("{name}",`<span>${t.name}</span>`).replace("{code}",`<span>${t.code}</span>`).replace("{phone}",`<span>${t.phone}</span>`)}_renderOptions(){const e=this.wrapper.querySelector(".cs-list");e&&(e.innerHTML="",this.filteredCountries.forEach(((t,i)=>{const s=document.createElement("div");s.className="cs-option "+(i===this.activeIndex?"active":""),s.innerHTML=this._parseTemplate(this.schema,t),s.onclick=e=>{e.stopPropagation(),this._select(t)},e.appendChild(s)})))}_select(e){this._updateUI(e);const t="phone"===this.valueType?e.phone:"name"===this.valueType?e.name:e.code;this.input.value=t,this.input.setCustomValidity(""),this.wrapper.classList.remove("is-invalid"),this.input.dispatchEvent(new Event("change",{bubbles:!0})),this._toggle(!1),this.wrapper.focus()}_updateUI(e){const t=this.wrapper.querySelector(".cs-selected-content");t&&(t.innerHTML=this._parseTemplate(this.schemaReturn,e))}_showError(){this.wrapper.querySelector(".cs-error-msg").textContent=this.input.validationMessage||"Invalid selection",this.wrapper.classList.add("is-invalid")}_toggle(e){if(0!==this.countries.length){if(this.isOpen=void 0!==e?e:!this.isOpen,this.isOpen){document.dispatchEvent(new CustomEvent("cs-close-others",{detail:{opener:this.wrapper}})),this.activeIndex=this.filteredCountries.findIndex((e=>this.input.value.includes(e.code)||this.input.value.includes(e.phone))),this._renderOptions();this.wrapper.querySelector(".cs-list").style.maxHeight=this.rowLimit*this.rowHeight+"px",this.activeIndex>-1&&setTimeout((()=>this._scrollToActive()),50),this.hasSearch&&setTimeout((()=>this.wrapper.querySelector(".cs-search-input").focus()),50)}this.wrapper.classList.toggle("open",this.isOpen)}}_bindEvents(){this.wrapper.querySelector(".cs-trigger").onclick=e=>{e.stopPropagation(),this._toggle()},this.input.addEventListener("invalid",(e=>{e.preventDefault(),this._showError()})),this.wrapper.addEventListener("keydown",(e=>{if(!this.isOpen&&("Enter"===e.key||"ArrowDown"===e.key))return e.preventDefault(),void this._toggle(!0);this.isOpen&&("ArrowDown"===e.key?(e.preventDefault(),this.activeIndex=Math.min(this.activeIndex+1,this.filteredCountries.length-1),this._renderOptions(),this._scrollToActive()):"ArrowUp"===e.key?(e.preventDefault(),this.activeIndex=Math.max(this.activeIndex-1,0),this._renderOptions(),this._scrollToActive()):"Enter"===e.key&&this.activeIndex>-1?(e.preventDefault(),this._select(this.filteredCountries[this.activeIndex])):"Escape"===e.key&&this._toggle(!1))})),this.hasSearch&&(this.wrapper.querySelector(".cs-search-input").oninput=e=>{const t=e.target.value.toLowerCase();this.filteredCountries=this.countries.filter((e=>e.name.toLowerCase().includes(t)||e.phone.includes(t))),this.activeIndex=0,this._renderOptions()}),document.addEventListener("click",(e=>{this.wrapper.contains(e.target)||this._toggle(!1)})),document.addEventListener("cs-close-others",(e=>{e.detail.opener!==this.wrapper&&(this.isOpen=!1,this.wrapper.classList.remove("open"))}))}_scrollToActive(){const e=this.wrapper.querySelector(".cs-list"),t=e.querySelectorAll(".cs-option")[this.activeIndex];t&&(e.scrollTop=t.offsetTop-e.offsetHeight/2+this.rowHeight/2)}}document.querySelectorAll(".country-select").forEach((e=>new CountrySelect(e)));
|
|
1
|
+
class CountrySelect{constructor(e,t={}){if(this.input=e,!this.input)return;this.schema=this.input.dataset.schema||"{img} {name}",this.schemaReturn=this.input.dataset.schemaReturn||this.schema,this.valueType=this.input.dataset.valueType||"code",this.rowLimit=parseInt(this.input.dataset.countryRowValues)||5,this.hasSearch="false"!==this.input.dataset.countrySearch,this.dropdownWidth=this.input.dataset.dropdownWidth||"auto";const i=this.input.dataset.preferred||"";this.preferredCodes=i?i.split(",").map(e=>e.trim().toUpperCase()):[],this.config={placeholder:this.input.dataset.placeholder||"Select",...t},this.countries=[],this.filteredCountries=[],this.isOpen=!1,this.activeIndex=-1,this.rowHeight=44,this._init()}async _init(){this._applyStyles(),this._setupDOM(),this._bindEvents(),await this._loadData()}_applyStyles(){const e="cs-v57-styles";if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent="\n .cs-wrapper { position: relative; font-family: inherit; width: 100%; outline: none; }\n .cs-trigger { \n /* Bootstrap 5 Exact Specs */\n padding: 0.375rem 2.25rem 0.375rem 0.75rem; \n font-size: 1rem;\n font-weight: 400;\n line-height: 1.5;\n color: #212529;\n background-color: #fff;\n background-clip: padding-box;\n border: 1px solid #ced4da;\n border-radius: 0.375rem;\n transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;\n display: flex; align-items: center; gap: 8px; cursor: pointer; \n min-height: calc(1.5em + 0.75rem + 2px); \n box-sizing: border-box; position: relative;\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E\");\n background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 16px 12px;\n }\n \n .input-group > .cs-wrapper { flex: 1 1 auto; width: 1%; }\n .cs-wrapper.is-invalid .cs-trigger { border-color: #dc3545 !important; }\n .cs-error-msg { display: none; color: #dc3545; font-size: 0.825em; margin-top: 4px; position: absolute; left: 0; top: 100%; width: 100%; z-index: 10; }\n .cs-wrapper.is-invalid .cs-error-msg { display: block; }\n\n /* Focus state Bootstrap 5 */\n .cs-wrapper:focus-within .cs-trigger {\n border-color: #86b7fe;\n outline: 0;\n box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);\n }\n\n .cs-dropdown { \n position: absolute; left: 0; right: 0; background: #fff; \n border: 1px solid rgba(0,0,0,.15); border-radius: 0.375rem;\n z-index: 2050; display: none; margin-top: 0.125rem;\n box-shadow: 0 0.5rem 1rem rgba(0,0,0,.175);\n overflow: hidden; max-width: 95vw;\n }\n \n .cs-wrapper.drop-up .cs-dropdown { \n bottom: calc(100% + 0.25rem); top: auto;\n box-shadow: 0 -0.5rem 1rem rgba(0,0,0,.175);\n }\n .cs-wrapper.open .cs-dropdown { display: block; }\n \n .cs-search-box { padding: 8px; border-bottom: 1px solid #dee2e6; background: #f8f9fa; }\n .cs-search-input { \n width: 100%; padding: 0.375rem 0.75rem; border: 1px solid #ced4da; \n border-radius: 0.25rem; outline: none; font-size: 0.875rem;\n }\n .cs-list { overflow-y: auto; scrollbar-width: thin; scroll-behavior: auto; min-height: 50px; padding: 0.375rem 0; }\n .cs-option { \n padding: 0.5rem 0.75rem; display: flex; align-items: center; gap: 10px; \n cursor: pointer; font-size: 0.9rem; transition: background 0.1s;\n }\n .cs-option:hover { background-color: #f8f9fa; }\n .cs-option.active { background-color: #0d6efd; color: #fff; }\n \n .cs-wrapper img { width: 20px !important; height: 14px !important; object-fit: cover; border-radius: 2px; flex-shrink: 0; }\n .cs-selected-content { display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; line-height: 1; }\n .cs-divider { height: 1px; background: #dee2e6; margin: 0.375rem 0; pointer-events: none; }\n .cs-hidden { display: none !important; }\n ",document.head.appendChild(t)}}_setupDOM(){Object.assign(this.input.style,{position:"absolute",opacity:"0",width:"1px",height:"1px",pointerEvents:"none"}),this.wrapper=document.createElement("div"),this.wrapper.className="cs-wrapper",this.wrapper.tabIndex=0;const e=this.input.value?"":this.config.placeholder;this.wrapper.innerHTML=`\n <div class="cs-trigger"><span class="cs-selected-content">${e}</span></div>\n <div class="cs-error-msg"></div>\n <div class="cs-dropdown">\n <div class="cs-search-box ${this.hasSearch?"":"cs-hidden"}">\n <input type="text" class="cs-search-input" placeholder="Search..." autocomplete="off" tabindex="-1">\n </div>\n <div class="cs-list"><div class="cs-loading" style="padding:15px; text-align:center;">Loading...</div></div>\n </div>\n `;this.wrapper.querySelector(".cs-dropdown").style.width="auto"===this.dropdownWidth?"100%":this.dropdownWidth,this.input.parentNode.insertBefore(this.wrapper,this.input.nextSibling)}_updatePosition(){const e=this.wrapper.getBoundingClientRect(),t=this.rowLimit*this.rowHeight+(this.hasSearch?60:0),i=window.innerHeight-e.bottom,s=e.top;i<t&&s>t?this.wrapper.classList.add("drop-up"):this.wrapper.classList.remove("drop-up")}async _loadData(){try{const e=await fetch("https://restcountries.com/v3.1/all?fields=name,flags,cca2,idd"),t=await e.json();this.countries=t.map(e=>({name:e.name.common,code:e.cca2.toUpperCase(),flag:e.flags.svg,phone:e.idd.root+(e.idd.suffixes?e.idd.suffixes.length>1?"":e.idd.suffixes[0]:""),isPreferred:this.preferredCodes.includes(e.cca2.toUpperCase())})).sort((e,t)=>e.name.localeCompare(t.name)),this.filteredCountries=[...this.countries],this._renderOptions(),this._syncInitialValue()}catch(e){console.error("CountrySelect API Fail",e)}}_syncInitialValue(){const e=this.input.value;if(!e)return void(this.wrapper.querySelector(".cs-selected-content").innerHTML=this.config.placeholder);const t=this.countries.find(t=>"phone"===this.valueType?t.phone===e:"name"===this.valueType?t.name===e:t.code===e);t&&this._updateUI(t)}_parseTemplate(e,t){return e.replace("{img}",`<img src="${t.flag}">`).replace("{name}",`<span>${t.name}</span>`).replace("{code}",`<span>${t.code}</span>`).replace("{phone}",`<span>${t.phone}</span>`)}_renderOptions(){const e=this.wrapper.querySelector(".cs-list");if(!e)return;e.innerHTML="";const t=this.wrapper.querySelector(".cs-search-input")?.value||"",i=this.filteredCountries.filter(e=>e.isPreferred),s=this.filteredCountries.filter(e=>!e.isPreferred),n=(e,t)=>{const i=document.createElement("div");return i.className="cs-option "+(t===this.activeIndex?"active":""),i.innerHTML=this._parseTemplate(this.schema,e),i.onclick=t=>{t.stopPropagation(),this._select(e)},i};if(i.forEach((t,i)=>e.appendChild(n(t,i))),i.length>0&&s.length>0&&!t){const t=document.createElement("div");t.className="cs-divider",e.appendChild(t)}s.forEach((t,s)=>e.appendChild(n(t,i.length+s)))}_select(e){this._updateUI(e),this.input.value="phone"===this.valueType?e.phone:"name"===this.valueType?e.name:e.code,this.input.setCustomValidity(""),this.wrapper.classList.remove("is-invalid"),this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.input.dispatchEvent(new Event("input",{bubbles:!0})),this.input.dispatchEvent(new Event("country-change",{bubbles:!0})),this._toggle(!1),this.wrapper.focus()}_updateUI(e){const t=this.wrapper.querySelector(".cs-selected-content");t&&(t.innerHTML=this._parseTemplate(this.schemaReturn,e))}_toggle(e){if(0!==this.countries.length){if(this.isOpen=void 0!==e?e:!this.isOpen,this.isOpen){this._updatePosition(),document.dispatchEvent(new CustomEvent("cs-close-others",{detail:{opener:this.wrapper}})),this._renderOptions();this.wrapper.querySelector(".cs-list").style.maxHeight=this.rowLimit*this.rowHeight+"px";const e=[...this.filteredCountries.filter(e=>e.isPreferred),...this.filteredCountries.filter(e=>!e.isPreferred)];this.activeIndex=e.findIndex(e=>this.input.value.includes(e.code)||this.input.value.includes(e.phone)),this.activeIndex>-1&&setTimeout(()=>this._scrollToActive(),0),this.hasSearch&&setTimeout(()=>this.wrapper.querySelector(".cs-search-input").focus(),50)}this.wrapper.classList.toggle("open",this.isOpen)}}_bindEvents(){this.wrapper.querySelector(".cs-trigger").onclick=e=>{e.stopPropagation(),this._toggle()},this.wrapper.addEventListener("keydown",e=>{if(!this.isOpen&&"ArrowDown"===e.key)return e.preventDefault(),void this._toggle(!0);this.isOpen&&("ArrowDown"===e.key?(e.preventDefault(),this.activeIndex++,this._renderOptions(),this._scrollToActive()):"ArrowUp"===e.key?(e.preventDefault(),this.activeIndex--,this._renderOptions(),this._scrollToActive()):"Escape"===e.key&&this._toggle(!1))}),this.hasSearch&&(this.wrapper.querySelector(".cs-search-input").oninput=e=>{const t=e.target.value.toLowerCase();this.filteredCountries=this.countries.filter(e=>e.name.toLowerCase().includes(t)||e.phone.includes(t)),this.activeIndex=0,this._renderOptions()}),document.addEventListener("click",e=>{this.wrapper.contains(e.target)||this._toggle(!1)}),document.addEventListener("cs-close-others",e=>{e.detail.opener!==this.wrapper&&(this.isOpen=!1,this.wrapper.classList.remove("open"))})}_scrollToActive(){const e=this.wrapper.querySelector(".cs-list"),t=e.querySelectorAll(".cs-option")[this.activeIndex];if(t){const i=t.offsetTop-e.offsetHeight/2+this.rowHeight/2;e.scrollTop=i}}}const initCS=e=>{(e&&e.querySelectorAll?e:document).querySelectorAll(".country-select").forEach(e=>{e.nextSibling&&e.nextSibling.classList&&e.nextSibling.classList.contains("cs-wrapper")||new CountrySelect(e)})},setupListeners=()=>{initCS(document),["htmx:afterProcess","htmx:afterSettle"].forEach(e=>document.body.addEventListener(e,e=>initCS(e.detail.target||e.target))),new MutationObserver(e=>e.forEach(e=>e.addedNodes.length&&initCS(e.target))).observe(document.body,{childList:!0,subtree:!0})};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",setupListeners):setupListeners();
|
package/package.json
CHANGED
|
@@ -1,36 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "country-select-pro",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A lightweight, zero-dependency, vanilla JavaScript country selector with localized browser validation and Bootstrap 5 integration.",
|
|
5
|
-
"main": "dist/country-select.
|
|
6
|
-
"jsdelivr": "dist/country-select.min.js",
|
|
7
|
-
"unpkg": "dist/country-select.min.js",
|
|
8
|
-
"browser": "dist/country-select.min.js",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": "./dist/country-select.min.js"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
"dist"
|
|
14
|
-
],
|
|
15
|
-
"repository": {
|
|
16
|
-
"type": "git",
|
|
17
|
-
"url": "https://github.com/nikmauro/country-select-pro.git"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [
|
|
20
|
-
"country",
|
|
21
|
-
"dropdown",
|
|
22
|
-
"flags",
|
|
23
|
-
"select",
|
|
24
|
-
"international",
|
|
25
|
-
"vanilla-js"
|
|
26
|
-
],
|
|
27
|
-
"scripts": {
|
|
28
|
-
"build": "gulp build"
|
|
29
|
-
},
|
|
30
|
-
"author": "Nikolaos Mavroidis",
|
|
31
|
-
"license": "MIT",
|
|
32
|
-
"bugs": {
|
|
33
|
-
"url": "https://github.com/nikmauro/country-select-pro/issues"
|
|
34
|
-
},
|
|
35
|
-
"homepage": "https://github.com/nikmauro/country-select-pro"
|
|
36
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "country-select-pro",
|
|
3
|
+
"version": "5.6.4",
|
|
4
|
+
"description": "A lightweight, zero-dependency, vanilla JavaScript country selector with localized browser validation and Bootstrap 5 integration.",
|
|
5
|
+
"main": "dist/country-select.js",
|
|
6
|
+
"jsdelivr": "dist/country-select.min.js",
|
|
7
|
+
"unpkg": "dist/country-select.min.js",
|
|
8
|
+
"browser": "dist/country-select.min.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/country-select.min.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/nikmauro/country-select-pro.git"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"country",
|
|
21
|
+
"dropdown",
|
|
22
|
+
"flags",
|
|
23
|
+
"select",
|
|
24
|
+
"international",
|
|
25
|
+
"vanilla-js"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "gulp build"
|
|
29
|
+
},
|
|
30
|
+
"author": "Nikolaos Mavroidis",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/nikmauro/country-select-pro/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/nikmauro/country-select-pro",
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"gulp": "^5.0.1",
|
|
38
|
+
"gulp-cli": "^3.1.0",
|
|
39
|
+
"gulp-rename": "^2.1.0",
|
|
40
|
+
"gulp-terser": "^2.1.0"
|
|
41
|
+
}
|
|
42
|
+
}
|