@maz-ui/mcp 4.0.0-beta.26
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 -0
- package/README.md +264 -0
- package/bin/maz-ui-mcp.mjs +7 -0
- package/dist/mcp.d.mts +13 -0
- package/dist/mcp.d.ts +13 -0
- package/dist/mcp.mjs +586 -0
- package/docs/generated-docs/maz-accordion.doc.md +21 -0
- package/docs/generated-docs/maz-animated-counter.doc.md +17 -0
- package/docs/generated-docs/maz-animated-element.doc.md +14 -0
- package/docs/generated-docs/maz-animated-text.doc.md +14 -0
- package/docs/generated-docs/maz-avatar.doc.md +44 -0
- package/docs/generated-docs/maz-backdrop.doc.md +61 -0
- package/docs/generated-docs/maz-badge.doc.md +16 -0
- package/docs/generated-docs/maz-bottom-sheet.doc.md +21 -0
- package/docs/generated-docs/maz-btn.doc.md +30 -0
- package/docs/generated-docs/maz-card-spotlight.doc.md +16 -0
- package/docs/generated-docs/maz-card.doc.md +39 -0
- package/docs/generated-docs/maz-carousel.doc.md +16 -0
- package/docs/generated-docs/maz-chart.doc.md +10 -0
- package/docs/generated-docs/maz-checkbox.doc.md +34 -0
- package/docs/generated-docs/maz-checklist.doc.md +30 -0
- package/docs/generated-docs/maz-circular-progress-bar.doc.md +27 -0
- package/docs/generated-docs/maz-date-picker.doc.md +52 -0
- package/docs/generated-docs/maz-dialog-confirm.doc.md +24 -0
- package/docs/generated-docs/maz-dialog.doc.md +22 -0
- package/docs/generated-docs/maz-drawer.doc.md +26 -0
- package/docs/generated-docs/maz-dropdown.doc.md +42 -0
- package/docs/generated-docs/maz-dropzone.doc.md +82 -0
- package/docs/generated-docs/maz-expand-animation.doc.md +12 -0
- package/docs/generated-docs/maz-fullscreen-loader.doc.md +13 -0
- package/docs/generated-docs/maz-gallery.doc.md +17 -0
- package/docs/generated-docs/maz-icon.doc.md +18 -0
- package/docs/generated-docs/maz-input-code.doc.md +25 -0
- package/docs/generated-docs/maz-input-number.doc.md +31 -0
- package/docs/generated-docs/maz-input-phone-number.doc.md +56 -0
- package/docs/generated-docs/maz-input-price.doc.md +26 -0
- package/docs/generated-docs/maz-input-tags.doc.md +24 -0
- package/docs/generated-docs/maz-input.doc.md +54 -0
- package/docs/generated-docs/maz-lazy-img.doc.md +31 -0
- package/docs/generated-docs/maz-link.doc.md +31 -0
- package/docs/generated-docs/maz-loading-bar.doc.md +6 -0
- package/docs/generated-docs/maz-pagination.doc.md +22 -0
- package/docs/generated-docs/maz-popover.doc.md +70 -0
- package/docs/generated-docs/maz-pull-to-refresh.doc.md +31 -0
- package/docs/generated-docs/maz-radio-buttons.doc.md +33 -0
- package/docs/generated-docs/maz-radio.doc.md +33 -0
- package/docs/generated-docs/maz-reading-progress-bar.doc.md +18 -0
- package/docs/generated-docs/maz-select-country.doc.md +44 -0
- package/docs/generated-docs/maz-select.doc.md +65 -0
- package/docs/generated-docs/maz-slider.doc.md +20 -0
- package/docs/generated-docs/maz-spinner.doc.md +6 -0
- package/docs/generated-docs/maz-stepper.doc.md +29 -0
- package/docs/generated-docs/maz-switch.doc.md +31 -0
- package/docs/generated-docs/maz-table-cell.doc.md +5 -0
- package/docs/generated-docs/maz-table-row.doc.md +11 -0
- package/docs/generated-docs/maz-table-title.doc.md +5 -0
- package/docs/generated-docs/maz-table.doc.md +66 -0
- package/docs/generated-docs/maz-tabs-bar.doc.md +18 -0
- package/docs/generated-docs/maz-tabs-content-item.doc.md +11 -0
- package/docs/generated-docs/maz-tabs-content.doc.md +5 -0
- package/docs/generated-docs/maz-tabs.doc.md +17 -0
- package/docs/generated-docs/maz-textarea.doc.md +41 -0
- package/docs/src/components/index.md +8 -0
- package/docs/src/components/maz-accordion.md +80 -0
- package/docs/src/components/maz-animated-counter.md +124 -0
- package/docs/src/components/maz-animated-element.md +36 -0
- package/docs/src/components/maz-animated-text.md +36 -0
- package/docs/src/components/maz-avatar.md +179 -0
- package/docs/src/components/maz-backdrop.md +16 -0
- package/docs/src/components/maz-badge.md +222 -0
- package/docs/src/components/maz-bottom-sheet.md +398 -0
- package/docs/src/components/maz-btn.md +526 -0
- package/docs/src/components/maz-card-spotlight.md +163 -0
- package/docs/src/components/maz-card.md +447 -0
- package/docs/src/components/maz-carousel.md +127 -0
- package/docs/src/components/maz-chart.md +346 -0
- package/docs/src/components/maz-checkbox.md +168 -0
- package/docs/src/components/maz-checklist.md +414 -0
- package/docs/src/components/maz-circular-progress-bar.md +147 -0
- package/docs/src/components/maz-date-picker.md +1078 -0
- package/docs/src/components/maz-dialog-confirm.md +240 -0
- package/docs/src/components/maz-dialog.md +208 -0
- package/docs/src/components/maz-drawer.md +177 -0
- package/docs/src/components/maz-dropdown.md +650 -0
- package/docs/src/components/maz-dropzone.md +442 -0
- package/docs/src/components/maz-expand-animation.md +99 -0
- package/docs/src/components/maz-fullscreen-loader.md +58 -0
- package/docs/src/components/maz-gallery.md +85 -0
- package/docs/src/components/maz-icon.md +85 -0
- package/docs/src/components/maz-input-code.md +61 -0
- package/docs/src/components/maz-input-number.md +81 -0
- package/docs/src/components/maz-input-phone-number.md +867 -0
- package/docs/src/components/maz-input-price.md +58 -0
- package/docs/src/components/maz-input-tags.md +114 -0
- package/docs/src/components/maz-input.md +453 -0
- package/docs/src/components/maz-lazy-img.md +24 -0
- package/docs/src/components/maz-link.md +156 -0
- package/docs/src/components/maz-loading-bar.md +26 -0
- package/docs/src/components/maz-pagination.md +81 -0
- package/docs/src/components/maz-popover.md +1414 -0
- package/docs/src/components/maz-pull-to-refresh.md +49 -0
- package/docs/src/components/maz-radio-buttons.md +456 -0
- package/docs/src/components/maz-radio.md +141 -0
- package/docs/src/components/maz-reading-progress-bar.md +74 -0
- package/docs/src/components/maz-select-country.md +636 -0
- package/docs/src/components/maz-select.md +439 -0
- package/docs/src/components/maz-slider.md +191 -0
- package/docs/src/components/maz-spinner.md +93 -0
- package/docs/src/components/maz-stepper.md +418 -0
- package/docs/src/components/maz-switch.md +92 -0
- package/docs/src/components/maz-table.md +571 -0
- package/docs/src/components/maz-tabs.md +231 -0
- package/docs/src/components/maz-textarea.md +218 -0
- package/docs/src/composables/use-aos.md +34 -0
- package/docs/src/composables/use-breakpoints.md +35 -0
- package/docs/src/composables/use-dialog.md +88 -0
- package/docs/src/composables/use-display-names.md +174 -0
- package/docs/src/composables/use-form-validator.md +1149 -0
- package/docs/src/composables/use-idle-timeout.md +256 -0
- package/docs/src/composables/use-reading-time.md +168 -0
- package/docs/src/composables/use-string-matching.md +63 -0
- package/docs/src/composables/use-swipe.md +223 -0
- package/docs/src/composables/use-timer.md +130 -0
- package/docs/src/composables/use-toast.md +71 -0
- package/docs/src/composables/use-user-visibility.md +169 -0
- package/docs/src/composables/use-wait.md +62 -0
- package/docs/src/composables/use-window-size.md +18 -0
- package/docs/src/demo/DemoAuthPage.vue +178 -0
- package/docs/src/demo/DemoDashboardPage.vue +298 -0
- package/docs/src/demo/DemoProductPage.vue +135 -0
- package/docs/src/directives/click-outside.md +275 -0
- package/docs/src/directives/fullscreen-img.md +101 -0
- package/docs/src/directives/lazy-img.md +184 -0
- package/docs/src/directives/tooltip.md +458 -0
- package/docs/src/directives/zoom-img.md +127 -0
- package/docs/src/guide/cli.md +144 -0
- package/docs/src/guide/getting-started.md +284 -0
- package/docs/src/guide/icon-set.md +60 -0
- package/docs/src/guide/icons.md +481 -0
- package/docs/src/guide/mcp.md +210 -0
- package/docs/src/guide/migration-v4.md +898 -0
- package/docs/src/guide/nuxt.md +411 -0
- package/docs/src/guide/resolvers.md +697 -0
- package/docs/src/guide/themes.md +789 -0
- package/docs/src/guide/translations.md +1173 -0
- package/docs/src/guide/vue.md +243 -0
- package/docs/src/helpers/camel-case.md +14 -0
- package/docs/src/helpers/capitalize.md +51 -0
- package/docs/src/helpers/check-availability.md +14 -0
- package/docs/src/helpers/country-code-to-unicode-flag.md +213 -0
- package/docs/src/helpers/currency.md +67 -0
- package/docs/src/helpers/date.md +67 -0
- package/docs/src/helpers/debounce-callback.md +14 -0
- package/docs/src/helpers/debounce-id.md +14 -0
- package/docs/src/helpers/debounce.md +14 -0
- package/docs/src/helpers/get-country-flag-url.md +156 -0
- package/docs/src/helpers/is-client.md +14 -0
- package/docs/src/helpers/is-equal.md +14 -0
- package/docs/src/helpers/is-standalone-mode.md +14 -0
- package/docs/src/helpers/kebab-case.md +14 -0
- package/docs/src/helpers/normalize-string.md +14 -0
- package/docs/src/helpers/number.md +65 -0
- package/docs/src/helpers/pascal-case.md +14 -0
- package/docs/src/helpers/script-loader.md +14 -0
- package/docs/src/helpers/sleep.md +14 -0
- package/docs/src/helpers/snake-case.md +14 -0
- package/docs/src/helpers/throttle-id.md +14 -0
- package/docs/src/helpers/throttle.md +14 -0
- package/docs/src/index.md +555 -0
- package/docs/src/made-with-maz-ui.md +58 -0
- package/docs/src/plugins/aos.md +347 -0
- package/docs/src/plugins/dialog.md +411 -0
- package/docs/src/plugins/toast.md +349 -0
- package/docs/src/plugins/wait.md +109 -0
- package/package.json +84 -0
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: MazSelectCountry
|
|
3
|
+
description: MazSelectCountry is a versatile Vue 3 component for selecting countries or languages with built-in internationalization support and customizable display options
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
<!--@include: ./../.vitepress/mixins/translated-component.md-->
|
|
11
|
+
|
|
12
|
+
## Basic usage
|
|
13
|
+
|
|
14
|
+
The most common use case is selecting a country. The component automatically displays country names in the user's locale with their respective flags.
|
|
15
|
+
|
|
16
|
+
<ComponentDemo>
|
|
17
|
+
<div class="maz-flex maz-gap-4 maz-flex-wrap">
|
|
18
|
+
<MazSelectCountry
|
|
19
|
+
v-model="selectedCountry"
|
|
20
|
+
:codes="['FR', 'DE', 'IT', 'ES', 'GB', 'NL', 'BE', 'AT', 'CH', 'PT']"
|
|
21
|
+
label="Select a country"
|
|
22
|
+
/>
|
|
23
|
+
<div class="maz-text-sm maz-text-muted">
|
|
24
|
+
Selected: {{ selectedCountry || 'None' }}
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<template #code>
|
|
29
|
+
|
|
30
|
+
```vue
|
|
31
|
+
<script setup>
|
|
32
|
+
import { ref } from 'vue'
|
|
33
|
+
|
|
34
|
+
const selectedCountry = ref('FR')
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<MazSelectCountry
|
|
39
|
+
v-model="selectedCountry"
|
|
40
|
+
label="Select a country"
|
|
41
|
+
/>
|
|
42
|
+
</template>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
</template>
|
|
46
|
+
</ComponentDemo>
|
|
47
|
+
|
|
48
|
+
## Language selection
|
|
49
|
+
|
|
50
|
+
Configure the component to display languages instead of countries by setting the appropriate `displayNamesOptions`.
|
|
51
|
+
|
|
52
|
+
<ComponentDemo>
|
|
53
|
+
<div class="maz-flex maz-gap-4 maz-flex-wrap">
|
|
54
|
+
<MazSelectCountry
|
|
55
|
+
v-model="selectedLanguage"
|
|
56
|
+
label="Select a language"
|
|
57
|
+
:display-names-options="{ type: 'language' }"
|
|
58
|
+
/>
|
|
59
|
+
<div class="maz-text-sm maz-text-muted">
|
|
60
|
+
Selected: {{ selectedLanguage || 'None' }}
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<template #code>
|
|
65
|
+
|
|
66
|
+
```vue
|
|
67
|
+
<script setup>
|
|
68
|
+
import { ref } from 'vue'
|
|
69
|
+
|
|
70
|
+
const selectedLanguage = ref('en')
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<template>
|
|
74
|
+
<MazSelectCountry
|
|
75
|
+
v-model="selectedLanguage"
|
|
76
|
+
label="Select a language"
|
|
77
|
+
:display-names-options="{ type: 'language' }"
|
|
78
|
+
/>
|
|
79
|
+
</template>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
</template>
|
|
83
|
+
</ComponentDemo>
|
|
84
|
+
|
|
85
|
+
## Sizes and colors
|
|
86
|
+
|
|
87
|
+
<ComponentDemo>
|
|
88
|
+
<div class="maz-grid maz-grid-cols-1 md:maz-grid-cols-2 maz-gap-4">
|
|
89
|
+
<div class="maz-space-y-4">
|
|
90
|
+
<h4 class="maz-font-semibold">Sizes</h4>
|
|
91
|
+
<MazSelectCountry
|
|
92
|
+
v-model="sizeExample1"
|
|
93
|
+
size="sm"
|
|
94
|
+
label="Small"
|
|
95
|
+
/>
|
|
96
|
+
<MazSelectCountry
|
|
97
|
+
v-model="sizeExample2"
|
|
98
|
+
size="md"
|
|
99
|
+
label="Medium (default)"
|
|
100
|
+
/>
|
|
101
|
+
<MazSelectCountry
|
|
102
|
+
v-model="sizeExample3"
|
|
103
|
+
size="lg"
|
|
104
|
+
label="Large"
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
<div class="maz-space-y-4">
|
|
108
|
+
<h4 class="maz-font-semibold">Colors</h4>
|
|
109
|
+
<MazSelectCountry
|
|
110
|
+
v-model="colorExample1"
|
|
111
|
+
color="primary"
|
|
112
|
+
label="Primary"
|
|
113
|
+
/>
|
|
114
|
+
<MazSelectCountry
|
|
115
|
+
v-model="colorExample2"
|
|
116
|
+
color="secondary"
|
|
117
|
+
label="Secondary"
|
|
118
|
+
/>
|
|
119
|
+
<MazSelectCountry
|
|
120
|
+
v-model="colorExample3"
|
|
121
|
+
color="accent"
|
|
122
|
+
label="Accent"
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<template #code>
|
|
128
|
+
|
|
129
|
+
```vue
|
|
130
|
+
<template>
|
|
131
|
+
<!-- Sizes -->
|
|
132
|
+
<MazSelectCountry
|
|
133
|
+
v-model="selectedCountry"
|
|
134
|
+
size="sm"
|
|
135
|
+
label="Small"
|
|
136
|
+
/>
|
|
137
|
+
<MazSelectCountry
|
|
138
|
+
v-model="selectedCountry"
|
|
139
|
+
size="md"
|
|
140
|
+
label="Medium (default)"
|
|
141
|
+
/>
|
|
142
|
+
<MazSelectCountry
|
|
143
|
+
v-model="selectedCountry"
|
|
144
|
+
size="lg"
|
|
145
|
+
label="Large"
|
|
146
|
+
/>
|
|
147
|
+
|
|
148
|
+
<!-- Colors -->
|
|
149
|
+
<MazSelectCountry
|
|
150
|
+
v-model="selectedCountry"
|
|
151
|
+
color="primary"
|
|
152
|
+
label="Primary"
|
|
153
|
+
/>
|
|
154
|
+
<MazSelectCountry
|
|
155
|
+
v-model="selectedCountry"
|
|
156
|
+
color="secondary"
|
|
157
|
+
label="Secondary"
|
|
158
|
+
/>
|
|
159
|
+
<MazSelectCountry
|
|
160
|
+
v-model="selectedCountry"
|
|
161
|
+
color="accent"
|
|
162
|
+
label="Accent"
|
|
163
|
+
/>
|
|
164
|
+
</template>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
</template>
|
|
168
|
+
</ComponentDemo>
|
|
169
|
+
|
|
170
|
+
## Preferred countries
|
|
171
|
+
|
|
172
|
+
You can prioritize certain countries to appear at the top of the list using the `preferredCodes` prop.
|
|
173
|
+
|
|
174
|
+
<ComponentDemo>
|
|
175
|
+
<div class="maz-flex maz-gap-4 maz-flex-wrap">
|
|
176
|
+
<MazSelectCountry
|
|
177
|
+
v-model="preferredExample"
|
|
178
|
+
label="European countries first"
|
|
179
|
+
:preferred-codes="['FR', 'DE', 'IT', 'ES', 'GB']"
|
|
180
|
+
/>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<template #code>
|
|
184
|
+
|
|
185
|
+
```vue
|
|
186
|
+
<template>
|
|
187
|
+
<MazSelectCountry
|
|
188
|
+
v-model="selectedCountry"
|
|
189
|
+
label="European countries first"
|
|
190
|
+
:preferred-codes="['FR', 'DE', 'IT', 'ES', 'GB']"
|
|
191
|
+
/>
|
|
192
|
+
</template>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
</template>
|
|
196
|
+
</ComponentDemo>
|
|
197
|
+
|
|
198
|
+
## Filtering options
|
|
199
|
+
|
|
200
|
+
Control which countries are displayed using `onlyCodes` to show only specific countries, or `ignoredCodes` to exclude certain ones.
|
|
201
|
+
|
|
202
|
+
<ComponentDemo>
|
|
203
|
+
<div class="maz-grid maz-grid-cols-1 md:maz-grid-cols-2 maz-gap-4">
|
|
204
|
+
<div>
|
|
205
|
+
<h4 class="maz-font-semibold maz-mb-2">Only European countries</h4>
|
|
206
|
+
<MazSelectCountry
|
|
207
|
+
v-model="europeExample"
|
|
208
|
+
label="European countries only"
|
|
209
|
+
:only-codes="['FR', 'DE', 'IT', 'ES', 'GB', 'NL', 'BE', 'AT', 'CH', 'PT']"
|
|
210
|
+
/>
|
|
211
|
+
</div>
|
|
212
|
+
<div>
|
|
213
|
+
<h4 class="maz-font-semibold maz-mb-2">Exclude specific countries</h4>
|
|
214
|
+
<MazSelectCountry
|
|
215
|
+
v-model="excludeExample"
|
|
216
|
+
label="All except some countries"
|
|
217
|
+
:ignored-codes="['KP', 'SY', 'AF']"
|
|
218
|
+
/>
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
|
|
222
|
+
<template #code>
|
|
223
|
+
|
|
224
|
+
```vue
|
|
225
|
+
<template>
|
|
226
|
+
<!-- Only specific countries -->
|
|
227
|
+
<MazSelectCountry
|
|
228
|
+
v-model="selectedCountry"
|
|
229
|
+
label="European countries only"
|
|
230
|
+
:only-codes="['FR', 'DE', 'IT', 'ES', 'GB', 'NL', 'BE', 'AT', 'CH', 'PT']"
|
|
231
|
+
/>
|
|
232
|
+
|
|
233
|
+
<!-- Exclude specific countries -->
|
|
234
|
+
<MazSelectCountry
|
|
235
|
+
v-model="selectedCountry"
|
|
236
|
+
label="All except some countries"
|
|
237
|
+
:ignored-codes="['KP', 'SY', 'AF']"
|
|
238
|
+
/>
|
|
239
|
+
</template>
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
</template>
|
|
243
|
+
</ComponentDemo>
|
|
244
|
+
|
|
245
|
+
## Custom display options
|
|
246
|
+
|
|
247
|
+
Configure how country/language names are displayed using the `displayNamesOptions` prop, which leverages the browser's `Intl.DisplayNames` API.
|
|
248
|
+
|
|
249
|
+
<ComponentDemo>
|
|
250
|
+
<div class="maz-grid maz-grid-cols-1 md:maz-grid-cols-2 maz-gap-4">
|
|
251
|
+
<div>
|
|
252
|
+
<h4 class="maz-font-semibold maz-mb-2">Short country names</h4>
|
|
253
|
+
<MazSelectCountry
|
|
254
|
+
v-model="shortExample"
|
|
255
|
+
label="Short names"
|
|
256
|
+
:display-names-options="{ type: 'region', style: 'short' }"
|
|
257
|
+
/>
|
|
258
|
+
</div>
|
|
259
|
+
<div>
|
|
260
|
+
<h4 class="maz-font-semibold maz-mb-2">Languages with narrow style</h4>
|
|
261
|
+
<MazSelectCountry
|
|
262
|
+
v-model="languageNarrowExample"
|
|
263
|
+
label="Language names (narrow)"
|
|
264
|
+
:display-names-options="{ type: 'language', style: 'narrow' }"
|
|
265
|
+
hide-flags
|
|
266
|
+
/>
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<template #code>
|
|
271
|
+
|
|
272
|
+
```vue
|
|
273
|
+
<template>
|
|
274
|
+
<!-- Short country names -->
|
|
275
|
+
<MazSelectCountry
|
|
276
|
+
v-model="selectedCountry"
|
|
277
|
+
label="Short names"
|
|
278
|
+
:display-names-options="{ type: 'region', style: 'short' }"
|
|
279
|
+
/>
|
|
280
|
+
|
|
281
|
+
<!-- Languages with narrow style -->
|
|
282
|
+
<MazSelectCountry
|
|
283
|
+
v-model="selectedLanguage"
|
|
284
|
+
label="Language names (narrow)"
|
|
285
|
+
:display-names-options="{ type: 'language', style: 'narrow' }"
|
|
286
|
+
hide-flags
|
|
287
|
+
/>
|
|
288
|
+
</template>
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
</template>
|
|
292
|
+
</ComponentDemo>
|
|
293
|
+
|
|
294
|
+
## Without flags
|
|
295
|
+
|
|
296
|
+
Hide country flags using the `hideFlags` prop for a cleaner text-only interface.
|
|
297
|
+
|
|
298
|
+
<ComponentDemo>
|
|
299
|
+
<div class="maz-flex maz-gap-4 maz-flex-wrap">
|
|
300
|
+
<MazSelectCountry
|
|
301
|
+
v-model="noFlagsExample"
|
|
302
|
+
label="Countries without flags"
|
|
303
|
+
hide-flags
|
|
304
|
+
placeholder="Text-only country selection"
|
|
305
|
+
/>
|
|
306
|
+
</div>
|
|
307
|
+
|
|
308
|
+
<template #code>
|
|
309
|
+
|
|
310
|
+
```vue
|
|
311
|
+
<template>
|
|
312
|
+
<MazSelectCountry
|
|
313
|
+
v-model="selectedCountry"
|
|
314
|
+
label="Countries without flags"
|
|
315
|
+
hide-flags
|
|
316
|
+
placeholder="Text-only country selection"
|
|
317
|
+
/>
|
|
318
|
+
</template>
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
</template>
|
|
322
|
+
</ComponentDemo>
|
|
323
|
+
|
|
324
|
+
## Custom locale
|
|
325
|
+
|
|
326
|
+
Override the default locale to display country/language names in a specific language.
|
|
327
|
+
|
|
328
|
+
<ComponentDemo>
|
|
329
|
+
<div class="maz-grid maz-grid-cols-1 md:maz-grid-cols-2 maz-gap-4">
|
|
330
|
+
<div>
|
|
331
|
+
<h4 class="maz-font-semibold maz-mb-2">Countries in French</h4>
|
|
332
|
+
<MazSelectCountry
|
|
333
|
+
v-model="frenchExample"
|
|
334
|
+
label="Pays (French)"
|
|
335
|
+
locale="fr-FR"
|
|
336
|
+
/>
|
|
337
|
+
</div>
|
|
338
|
+
<div>
|
|
339
|
+
<h4 class="maz-font-semibold maz-mb-2">Countries in Spanish</h4>
|
|
340
|
+
<MazSelectCountry
|
|
341
|
+
v-model="spanishExample"
|
|
342
|
+
label="País (Spanish)"
|
|
343
|
+
locale="es-ES"
|
|
344
|
+
/>
|
|
345
|
+
</div>
|
|
346
|
+
</div>
|
|
347
|
+
|
|
348
|
+
<template #code>
|
|
349
|
+
|
|
350
|
+
```vue
|
|
351
|
+
<template>
|
|
352
|
+
<!-- Countries in French -->
|
|
353
|
+
<MazSelectCountry
|
|
354
|
+
v-model="selectedCountry"
|
|
355
|
+
label="Pays (French)"
|
|
356
|
+
locale="fr-FR"
|
|
357
|
+
/>
|
|
358
|
+
|
|
359
|
+
<!-- Countries in Spanish -->
|
|
360
|
+
<MazSelectCountry
|
|
361
|
+
v-model="selectedCountry"
|
|
362
|
+
label="País (Spanish)"
|
|
363
|
+
locale="es-ES"
|
|
364
|
+
/>
|
|
365
|
+
</template>
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
</template>
|
|
369
|
+
</ComponentDemo>
|
|
370
|
+
|
|
371
|
+
## States and validation
|
|
372
|
+
|
|
373
|
+
The component supports all the standard form states for better user experience.
|
|
374
|
+
|
|
375
|
+
<ComponentDemo>
|
|
376
|
+
<div class="maz-grid maz-grid-cols-1 md:maz-grid-cols-2 maz-gap-4">
|
|
377
|
+
<div class="maz-space-y-4">
|
|
378
|
+
<MazSelectCountry
|
|
379
|
+
v-model="successExample"
|
|
380
|
+
label="Success state"
|
|
381
|
+
success
|
|
382
|
+
hint="Valid country selected"
|
|
383
|
+
/>
|
|
384
|
+
<MazSelectCountry
|
|
385
|
+
v-model="warningExample"
|
|
386
|
+
label="Warning state"
|
|
387
|
+
warning
|
|
388
|
+
hint="Please verify your selection"
|
|
389
|
+
/>
|
|
390
|
+
</div>
|
|
391
|
+
<div class="maz-space-y-4">
|
|
392
|
+
<MazSelectCountry
|
|
393
|
+
v-model="errorExample"
|
|
394
|
+
label="Error state"
|
|
395
|
+
error
|
|
396
|
+
hint="Please select a valid country"
|
|
397
|
+
/>
|
|
398
|
+
<MazSelectCountry
|
|
399
|
+
v-model="disabledExample"
|
|
400
|
+
label="Disabled state"
|
|
401
|
+
disabled
|
|
402
|
+
hint="Selection is not available"
|
|
403
|
+
/>
|
|
404
|
+
</div>
|
|
405
|
+
</div>
|
|
406
|
+
|
|
407
|
+
<template #code>
|
|
408
|
+
|
|
409
|
+
```vue
|
|
410
|
+
<template>
|
|
411
|
+
<MazSelectCountry
|
|
412
|
+
v-model="selectedCountry"
|
|
413
|
+
label="Success state"
|
|
414
|
+
success
|
|
415
|
+
hint="Valid country selected"
|
|
416
|
+
/>
|
|
417
|
+
|
|
418
|
+
<MazSelectCountry
|
|
419
|
+
v-model="selectedCountry"
|
|
420
|
+
label="Warning state"
|
|
421
|
+
warning
|
|
422
|
+
hint="Please verify your selection"
|
|
423
|
+
/>
|
|
424
|
+
|
|
425
|
+
<MazSelectCountry
|
|
426
|
+
v-model="selectedCountry"
|
|
427
|
+
label="Error state"
|
|
428
|
+
error
|
|
429
|
+
hint="Please select a valid country"
|
|
430
|
+
/>
|
|
431
|
+
|
|
432
|
+
<MazSelectCountry
|
|
433
|
+
v-model="selectedCountry"
|
|
434
|
+
label="Disabled state"
|
|
435
|
+
disabled
|
|
436
|
+
hint="Selection is not available"
|
|
437
|
+
/>
|
|
438
|
+
</template>
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
</template>
|
|
442
|
+
</ComponentDemo>
|
|
443
|
+
|
|
444
|
+
## Custom options
|
|
445
|
+
|
|
446
|
+
Provide your own list of options instead of using the built-in country/language codes.
|
|
447
|
+
|
|
448
|
+
<ComponentDemo>
|
|
449
|
+
<div class="maz-flex maz-gap-4 maz-flex-wrap">
|
|
450
|
+
<MazSelectCountry
|
|
451
|
+
v-model="customExample"
|
|
452
|
+
label="Custom regions"
|
|
453
|
+
:options="customRegions"
|
|
454
|
+
hide-flags
|
|
455
|
+
/>
|
|
456
|
+
</div>
|
|
457
|
+
|
|
458
|
+
<template #code>
|
|
459
|
+
|
|
460
|
+
```vue
|
|
461
|
+
<script setup>
|
|
462
|
+
import { ref } from 'vue'
|
|
463
|
+
|
|
464
|
+
const selectedCustom = ref()
|
|
465
|
+
const customRegions = [
|
|
466
|
+
{ code: 'EUROPE', name: 'Europe' },
|
|
467
|
+
{ code: 'ASIA', name: 'Asia' },
|
|
468
|
+
{ code: 'AFRICA', name: 'Africa' },
|
|
469
|
+
{ code: 'AMERICAS', name: 'Americas' },
|
|
470
|
+
{ code: 'OCEANIA', name: 'Oceania' }
|
|
471
|
+
]
|
|
472
|
+
</script>
|
|
473
|
+
|
|
474
|
+
<template>
|
|
475
|
+
<MazSelectCountry
|
|
476
|
+
v-model="selectedCustom"
|
|
477
|
+
label="Custom regions"
|
|
478
|
+
:options="customRegions"
|
|
479
|
+
hide-flags
|
|
480
|
+
/>
|
|
481
|
+
</template>
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
</template>
|
|
485
|
+
</ComponentDemo>
|
|
486
|
+
|
|
487
|
+
## Display code instead of name
|
|
488
|
+
|
|
489
|
+
Show country/language codes in the input field instead of names using the `displayCode` prop.
|
|
490
|
+
|
|
491
|
+
<ComponentDemo>
|
|
492
|
+
<div class="maz-flex maz-gap-4 maz-flex-wrap">
|
|
493
|
+
<MazSelectCountry
|
|
494
|
+
v-model="codeDisplayExample"
|
|
495
|
+
label="Display country codes"
|
|
496
|
+
display-code
|
|
497
|
+
placeholder="Shows codes like 'FR', 'US'..."
|
|
498
|
+
/>
|
|
499
|
+
</div>
|
|
500
|
+
|
|
501
|
+
<template #code>
|
|
502
|
+
|
|
503
|
+
```vue
|
|
504
|
+
<template>
|
|
505
|
+
<MazSelectCountry
|
|
506
|
+
v-model="selectedCountry"
|
|
507
|
+
label="Display country codes"
|
|
508
|
+
display-code
|
|
509
|
+
placeholder="Shows codes like 'FR', 'US'..."
|
|
510
|
+
/>
|
|
511
|
+
</template>
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
</template>
|
|
515
|
+
</ComponentDemo>
|
|
516
|
+
|
|
517
|
+
## Advanced configuration
|
|
518
|
+
|
|
519
|
+
Combine multiple features for complex use cases, such as business applications requiring specific country lists with custom styling.
|
|
520
|
+
|
|
521
|
+
<ComponentDemo>
|
|
522
|
+
<div class="maz-max-w-md">
|
|
523
|
+
<MazSelectCountry
|
|
524
|
+
v-model="advancedExample"
|
|
525
|
+
label="Business countries"
|
|
526
|
+
color="primary"
|
|
527
|
+
size="lg"
|
|
528
|
+
:preferred-codes="['US', 'GB', 'DE', 'FR', 'CA']"
|
|
529
|
+
:ignored-codes="['AQ', 'BV', 'HM']"
|
|
530
|
+
:search-threshold="2"
|
|
531
|
+
display-code
|
|
532
|
+
success
|
|
533
|
+
hint="Primary business regions prioritized"
|
|
534
|
+
/>
|
|
535
|
+
</div>
|
|
536
|
+
|
|
537
|
+
<template #code>
|
|
538
|
+
|
|
539
|
+
```vue
|
|
540
|
+
<template>
|
|
541
|
+
<MazSelectCountry
|
|
542
|
+
v-model="selectedCountry"
|
|
543
|
+
label="Business countries"
|
|
544
|
+
color="primary"
|
|
545
|
+
size="lg"
|
|
546
|
+
:preferred-codes="['US', 'GB', 'DE', 'FR', 'CA']"
|
|
547
|
+
:ignored-codes="['AQ', 'BV', 'HM']"
|
|
548
|
+
:search-threshold="2"
|
|
549
|
+
display-code
|
|
550
|
+
success
|
|
551
|
+
hint="Primary business regions prioritized"
|
|
552
|
+
/>
|
|
553
|
+
</template>
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
</template>
|
|
557
|
+
</ComponentDemo>
|
|
558
|
+
|
|
559
|
+
## How it works
|
|
560
|
+
|
|
561
|
+
The `MazSelectCountry` component is built on top of `MazSelect` and leverages the powerful `useDisplayNames` composable, which uses the browser's native `Intl.DisplayNames` API for internationalization.
|
|
562
|
+
|
|
563
|
+
### Key features:
|
|
564
|
+
|
|
565
|
+
- **Automatic localization**: Country and language names are displayed in the user's locale
|
|
566
|
+
- **Built-in search**: Users can quickly find countries by typing
|
|
567
|
+
- **Flag integration**: Automatic flag display using country codes
|
|
568
|
+
- **Flexible filtering**: Support for preferred, ignored, or specific country lists
|
|
569
|
+
- **Custom options**: Override default behavior with custom data
|
|
570
|
+
- **Accessibility**: Full keyboard navigation and screen reader support
|
|
571
|
+
|
|
572
|
+
### useDisplayNames composable
|
|
573
|
+
|
|
574
|
+
The component uses the `useDisplayNames` composable internally, which provides:
|
|
575
|
+
|
|
576
|
+
```typescript
|
|
577
|
+
// Get display name for a single code
|
|
578
|
+
const displayName = getDisplayName('FR', {
|
|
579
|
+
locale: 'en-US',
|
|
580
|
+
type: 'region'
|
|
581
|
+
})
|
|
582
|
+
|
|
583
|
+
// Get all display names with filtering
|
|
584
|
+
const allCountries = getAllDisplayNames({
|
|
585
|
+
locale: 'en-US',
|
|
586
|
+
codesType: 'country',
|
|
587
|
+
preferred: ['US', 'GB', 'FR'],
|
|
588
|
+
exclude: ['AQ']
|
|
589
|
+
})
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
This ensures consistent internationalization across your application while providing maximum flexibility for different use cases.
|
|
593
|
+
|
|
594
|
+
<script setup>
|
|
595
|
+
import { ref } from 'vue'
|
|
596
|
+
|
|
597
|
+
// Basic examples
|
|
598
|
+
const selectedCountry = ref('FR')
|
|
599
|
+
const selectedLanguage = ref('en-US')
|
|
600
|
+
|
|
601
|
+
// Size and color examples
|
|
602
|
+
const sizeExample1 = ref()
|
|
603
|
+
const sizeExample2 = ref()
|
|
604
|
+
const sizeExample3 = ref()
|
|
605
|
+
const colorExample1 = ref()
|
|
606
|
+
const colorExample2 = ref()
|
|
607
|
+
const colorExample3 = ref()
|
|
608
|
+
|
|
609
|
+
// Other examples
|
|
610
|
+
const preferredExample = ref()
|
|
611
|
+
const europeExample = ref()
|
|
612
|
+
const excludeExample = ref()
|
|
613
|
+
const shortExample = ref()
|
|
614
|
+
const languageNarrowExample = ref()
|
|
615
|
+
const noFlagsExample = ref()
|
|
616
|
+
const frenchExample = ref()
|
|
617
|
+
const spanishExample = ref()
|
|
618
|
+
const successExample = ref()
|
|
619
|
+
const warningExample = ref()
|
|
620
|
+
const errorExample = ref()
|
|
621
|
+
const disabledExample = ref()
|
|
622
|
+
const codeDisplayExample = ref()
|
|
623
|
+
const advancedExample = ref()
|
|
624
|
+
|
|
625
|
+
// Custom options example
|
|
626
|
+
const customExample = ref()
|
|
627
|
+
const customRegions = [
|
|
628
|
+
{ code: 'EUROPE', name: 'Europe' },
|
|
629
|
+
{ code: 'ASIA', name: 'Asia' },
|
|
630
|
+
{ code: 'AFRICA', name: 'Africa' },
|
|
631
|
+
{ code: 'AMERICAS', name: 'Americas' },
|
|
632
|
+
{ code: 'OCEANIA', name: 'Oceania' }
|
|
633
|
+
]
|
|
634
|
+
</script>
|
|
635
|
+
|
|
636
|
+
<!--@include: ./../../.vitepress/generated-docs/maz-select-country.doc.md-->
|