@djangocfg/ui-core 2.1.145 → 2.1.147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @djangocfg/ui-core
2
2
 
3
- Pure React UI library with 60 components built on Radix UI + Tailwind CSS v4.
3
+ Pure React UI library with 61 components built on Radix UI + Tailwind CSS v4.
4
4
 
5
5
  **No Next.js dependencies** — works with Electron, Vite, CRA, and any React environment.
6
6
 
@@ -23,8 +23,8 @@ pnpm add @djangocfg/ui-core
23
23
 
24
24
  ## Components (60)
25
25
 
26
- ### Forms (16)
27
- `Label` `Button` `ButtonLink` `Input` `Checkbox` `RadioGroup` `Select` `Textarea` `Switch` `Slider` `Combobox` `MultiSelect` `InputOTP` `PhoneInput` `Form` `Field`
26
+ ### Forms (17)
27
+ `Label` `Button` `ButtonLink` `Input` `Checkbox` `RadioGroup` `Select` `Textarea` `Switch` `Slider` `Combobox` `MultiSelect` `CountrySelect` `InputOTP` `PhoneInput` `Form` `Field`
28
28
 
29
29
  ### Layout (8)
30
30
  `Card` `Separator` `Skeleton` `AspectRatio` `Sticky` `ScrollArea` `Resizable` `Section`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/ui-core",
3
- "version": "2.1.145",
3
+ "version": "2.1.147",
4
4
  "description": "Pure React UI component library without Next.js dependencies - for Electron, Vite, CRA apps",
5
5
  "keywords": [
6
6
  "ui-components",
@@ -66,7 +66,8 @@
66
66
  "playground": "playground dev"
67
67
  },
68
68
  "peerDependencies": {
69
- "@djangocfg/i18n": "^2.1.145",
69
+ "@djangocfg/i18n": "^2.1.147",
70
+ "consola": "^3.4.2",
70
71
  "lucide-react": "^0.545.0",
71
72
  "moment": "^2.30.1",
72
73
  "react": "^19.0.0",
@@ -74,8 +75,7 @@
74
75
  "react-hook-form": "^7.69.0",
75
76
  "tailwindcss": "^4.1.18",
76
77
  "zod": "^4.0.0",
77
- "zustand": "^5.0.0",
78
- "consola": "^3.4.2"
78
+ "zustand": "^5.0.0"
79
79
  },
80
80
  "dependencies": {
81
81
  "@hookform/resolvers": "^5.2.2",
@@ -111,8 +111,10 @@
111
111
  "class-variance-authority": "^0.7.1",
112
112
  "clsx": "^2.1.1",
113
113
  "cmdk": "1.1.1",
114
+ "countries-list": "^3.2.2",
114
115
  "date-fns": "^4.1.0",
115
116
  "embla-carousel-react": "8.6.0",
117
+ "i18n-iso-countries": "^7.14.0",
116
118
  "input-otp": "1.4.2",
117
119
  "libphonenumber-js": "^1.12.24",
118
120
  "react-day-picker": "9.11.1",
@@ -124,9 +126,9 @@
124
126
  "vaul": "1.1.2"
125
127
  },
126
128
  "devDependencies": {
127
- "@djangocfg/i18n": "^2.1.145",
129
+ "@djangocfg/i18n": "^2.1.147",
128
130
  "@djangocfg/playground": "workspace:*",
129
- "@djangocfg/typescript-config": "^2.1.145",
131
+ "@djangocfg/typescript-config": "^2.1.147",
130
132
  "@types/node": "^24.7.2",
131
133
  "@types/react": "^19.1.0",
132
134
  "@types/react-dom": "^19.1.0",
@@ -0,0 +1,261 @@
1
+ import { useState } from 'react';
2
+ import { defineStory } from '@djangocfg/playground';
3
+ import { CountrySelect, type TCountryCode } from './country-select';
4
+ import { Label } from './label';
5
+
6
+ export default defineStory({
7
+ title: 'Core/CountrySelect',
8
+ component: CountrySelect,
9
+ description: 'Country selector with emoji flags. Supports dropdown and inline variants, single and multiple selection.',
10
+ });
11
+
12
+ // ============================================================================
13
+ // Dropdown Variants
14
+ // ============================================================================
15
+
16
+ export const SingleDropdown = () => {
17
+ const [value, setValue] = useState<string[]>([]);
18
+
19
+ return (
20
+ <div className="max-w-sm space-y-2">
21
+ <Label>Select country</Label>
22
+ <CountrySelect
23
+ value={value}
24
+ onChange={setValue}
25
+ placeholder="Choose a country..."
26
+ />
27
+ {value.length > 0 && (
28
+ <p className="text-sm text-muted-foreground">Selected: {value[0]}</p>
29
+ )}
30
+ </div>
31
+ );
32
+ };
33
+
34
+ export const MultipleDropdown = () => {
35
+ const [value, setValue] = useState<string[]>([]);
36
+
37
+ return (
38
+ <div className="max-w-sm space-y-2">
39
+ <Label>Select countries</Label>
40
+ <CountrySelect
41
+ multiple
42
+ value={value}
43
+ onChange={setValue}
44
+ placeholder="Choose countries..."
45
+ />
46
+ {value.length > 0 && (
47
+ <p className="text-sm text-muted-foreground">Selected: {value.join(', ')}</p>
48
+ )}
49
+ </div>
50
+ );
51
+ };
52
+
53
+ export const WithDefaultValue = () => {
54
+ const [value, setValue] = useState<string[]>(['US', 'GB', 'DE']);
55
+
56
+ return (
57
+ <div className="max-w-sm space-y-2">
58
+ <Label>Preselected countries</Label>
59
+ <CountrySelect
60
+ multiple
61
+ value={value}
62
+ onChange={setValue}
63
+ />
64
+ </div>
65
+ );
66
+ };
67
+
68
+ export const WithNativeNames = () => {
69
+ const [value, setValue] = useState<string[]>([]);
70
+
71
+ return (
72
+ <div className="max-w-sm space-y-2">
73
+ <Label>With native names</Label>
74
+ <CountrySelect
75
+ multiple
76
+ value={value}
77
+ onChange={setValue}
78
+ showNativeName
79
+ />
80
+ </div>
81
+ );
82
+ };
83
+
84
+ // ============================================================================
85
+ // Inline Variants
86
+ // ============================================================================
87
+
88
+ export const InlineSingle = () => {
89
+ const [value, setValue] = useState<string[]>([]);
90
+
91
+ return (
92
+ <div className="max-w-sm space-y-2">
93
+ <Label>Select your country</Label>
94
+ <CountrySelect
95
+ variant="inline"
96
+ value={value}
97
+ onChange={setValue}
98
+ maxHeight={250}
99
+ />
100
+ {value.length > 0 && (
101
+ <p className="text-sm text-muted-foreground">Selected: {value[0]}</p>
102
+ )}
103
+ </div>
104
+ );
105
+ };
106
+
107
+ export const InlineMultiple = () => {
108
+ const [value, setValue] = useState<string[]>([]);
109
+
110
+ return (
111
+ <div className="max-w-sm space-y-2">
112
+ <Label>Select target markets</Label>
113
+ <CountrySelect
114
+ variant="inline"
115
+ multiple
116
+ value={value}
117
+ onChange={setValue}
118
+ maxHeight={300}
119
+ />
120
+ </div>
121
+ );
122
+ };
123
+
124
+ export const InlineWithNativeNames = () => {
125
+ const [value, setValue] = useState<string[]>(['KR', 'JP']);
126
+
127
+ return (
128
+ <div className="max-w-sm space-y-2">
129
+ <Label>Countries with native names</Label>
130
+ <CountrySelect
131
+ variant="inline"
132
+ multiple
133
+ value={value}
134
+ onChange={setValue}
135
+ showNativeName
136
+ maxHeight={300}
137
+ />
138
+ </div>
139
+ );
140
+ };
141
+
142
+ export const InlineNoSearch = () => {
143
+ const [value, setValue] = useState<string[]>([]);
144
+
145
+ return (
146
+ <div className="max-w-sm space-y-2">
147
+ <Label>Without search</Label>
148
+ <CountrySelect
149
+ variant="inline"
150
+ multiple
151
+ value={value}
152
+ onChange={setValue}
153
+ showSearch={false}
154
+ maxHeight={200}
155
+ />
156
+ </div>
157
+ );
158
+ };
159
+
160
+ // ============================================================================
161
+ // Filtered Countries
162
+ // ============================================================================
163
+
164
+ const CIS_COUNTRIES: TCountryCode[] = ['RU', 'KZ', 'UZ', 'KG', 'TJ', 'TM', 'AZ', 'AM', 'GE', 'BY', 'MD', 'UA'];
165
+ const ASIAN_AUTO_MARKETS: TCountryCode[] = ['KR', 'JP', 'CN', 'TH', 'MY', 'ID', 'VN', 'PH'];
166
+
167
+ export const FilteredCISCountries = () => {
168
+ const [value, setValue] = useState<string[]>([]);
169
+
170
+ return (
171
+ <div className="max-w-sm space-y-2">
172
+ <Label>CIS Countries only</Label>
173
+ <CountrySelect
174
+ variant="inline"
175
+ multiple
176
+ value={value}
177
+ onChange={setValue}
178
+ allowedCountries={CIS_COUNTRIES}
179
+ maxHeight={300}
180
+ />
181
+ </div>
182
+ );
183
+ };
184
+
185
+ export const FilteredAsianMarkets = () => {
186
+ const [value, setValue] = useState<string[]>([]);
187
+
188
+ return (
189
+ <div className="max-w-sm space-y-2">
190
+ <Label>Asian Auto Markets</Label>
191
+ <CountrySelect
192
+ multiple
193
+ value={value}
194
+ onChange={setValue}
195
+ allowedCountries={ASIAN_AUTO_MARKETS}
196
+ showNativeName
197
+ />
198
+ </div>
199
+ );
200
+ };
201
+
202
+ export const ExcludeSanctioned = () => {
203
+ const [value, setValue] = useState<string[]>([]);
204
+ const excluded: TCountryCode[] = ['KP', 'IR', 'SY', 'CU'];
205
+
206
+ return (
207
+ <div className="max-w-sm space-y-2">
208
+ <Label>All except sanctioned</Label>
209
+ <CountrySelect
210
+ multiple
211
+ value={value}
212
+ onChange={setValue}
213
+ excludedCountries={excluded}
214
+ />
215
+ </div>
216
+ );
217
+ };
218
+
219
+ // ============================================================================
220
+ // States
221
+ // ============================================================================
222
+
223
+ export const Disabled = () => (
224
+ <div className="max-w-sm space-y-4">
225
+ <div className="space-y-2">
226
+ <Label>Disabled dropdown</Label>
227
+ <CountrySelect
228
+ value={['US']}
229
+ onChange={() => {}}
230
+ disabled
231
+ />
232
+ </div>
233
+ <div className="space-y-2">
234
+ <Label>Disabled inline</Label>
235
+ <CountrySelect
236
+ variant="inline"
237
+ multiple
238
+ value={['US', 'GB']}
239
+ onChange={() => {}}
240
+ disabled
241
+ maxHeight={150}
242
+ />
243
+ </div>
244
+ </div>
245
+ );
246
+
247
+ export const MaxDisplayBadges = () => {
248
+ const [value, setValue] = useState<string[]>(['US', 'GB', 'DE', 'FR', 'IT', 'ES']);
249
+
250
+ return (
251
+ <div className="max-w-sm space-y-2">
252
+ <Label>Max 2 badges displayed</Label>
253
+ <CountrySelect
254
+ multiple
255
+ value={value}
256
+ onChange={setValue}
257
+ maxDisplay={2}
258
+ />
259
+ </div>
260
+ );
261
+ };
@@ -0,0 +1,401 @@
1
+ "use client"
2
+
3
+ import { Check, ChevronsUpDown, Search, X } from 'lucide-react';
4
+ import * as React from 'react';
5
+ import { countries, getEmojiFlag, type TCountryCode } from 'countries-list';
6
+
7
+ import { useTypedT, type I18nTranslations } from '@djangocfg/i18n';
8
+ import { cn } from '../lib/utils';
9
+ import { Badge } from './badge';
10
+ import { Button } from './button';
11
+ import { Checkbox } from './checkbox';
12
+ import {
13
+ Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList
14
+ } from './command';
15
+ import { Input } from './input';
16
+ import { Popover, PopoverContent, PopoverTrigger } from './popover';
17
+ import { ScrollArea } from './scroll-area';
18
+
19
+ export interface CountryOption {
20
+ code: TCountryCode;
21
+ name: string;
22
+ native: string;
23
+ emoji: string;
24
+ }
25
+
26
+ export type CountrySelectVariant = 'dropdown' | 'inline';
27
+
28
+ export interface CountrySelectProps {
29
+ /** Selected country codes (ISO 3166-1 alpha-2) */
30
+ value?: string[];
31
+ /** Callback when selection changes */
32
+ onChange?: (value: string[]) => void;
33
+ /** Allow multiple selection */
34
+ multiple?: boolean;
35
+ /** Display variant: dropdown (popover) or inline (scrollable list) */
36
+ variant?: CountrySelectVariant;
37
+ /** Placeholder text */
38
+ placeholder?: string;
39
+ /** Search placeholder text */
40
+ searchPlaceholder?: string;
41
+ /** Empty results text */
42
+ emptyText?: string;
43
+ /** Additional CSS class */
44
+ className?: string;
45
+ /** Disable the component */
46
+ disabled?: boolean;
47
+ /** Max badges to display (for multiple dropdown mode) */
48
+ maxDisplay?: number;
49
+ /** Custom country name resolver (for i18n) */
50
+ getCountryName?: (code: TCountryCode) => string;
51
+ /** Show native name alongside translated name */
52
+ showNativeName?: boolean;
53
+ /** Filter to specific country codes */
54
+ allowedCountries?: TCountryCode[];
55
+ /** Exclude specific country codes */
56
+ excludedCountries?: TCountryCode[];
57
+ /** Max height for inline variant */
58
+ maxHeight?: number;
59
+ /** Show search input */
60
+ showSearch?: boolean;
61
+ }
62
+
63
+ /**
64
+ * Country Select component with emoji flags
65
+ *
66
+ * Supports:
67
+ * - Single and multiple selection
68
+ * - Dropdown (popover) and inline (scrollable list) variants
69
+ * - Custom country name translations via getCountryName prop
70
+ * - Country filtering via allowedCountries/excludedCountries
71
+ *
72
+ * Uses ISO 3166-1 alpha-2 country codes.
73
+ *
74
+ * @example Single dropdown
75
+ * ```tsx
76
+ * <CountrySelect
77
+ * value={country ? [country] : []}
78
+ * onChange={(codes) => setCountry(codes[0])}
79
+ * />
80
+ * ```
81
+ *
82
+ * @example Multiple dropdown
83
+ * ```tsx
84
+ * <CountrySelect
85
+ * multiple
86
+ * value={countries}
87
+ * onChange={setCountries}
88
+ * />
89
+ * ```
90
+ *
91
+ * @example Inline list with checkboxes
92
+ * ```tsx
93
+ * <CountrySelect
94
+ * variant="inline"
95
+ * multiple
96
+ * value={countries}
97
+ * onChange={setCountries}
98
+ * maxHeight={300}
99
+ * />
100
+ * ```
101
+ *
102
+ * @example With i18n translations
103
+ * ```tsx
104
+ * <CountrySelect
105
+ * value={value}
106
+ * onChange={onChange}
107
+ * getCountryName={(code) => i18nCountries.getName(code, locale)}
108
+ * />
109
+ * ```
110
+ */
111
+ export function CountrySelect({
112
+ value = [],
113
+ onChange,
114
+ multiple = false,
115
+ variant = 'dropdown',
116
+ placeholder,
117
+ searchPlaceholder,
118
+ emptyText,
119
+ className,
120
+ disabled = false,
121
+ maxDisplay = 3,
122
+ getCountryName,
123
+ showNativeName = false,
124
+ allowedCountries,
125
+ excludedCountries,
126
+ maxHeight = 300,
127
+ showSearch = true,
128
+ }: CountrySelectProps) {
129
+ const t = useTypedT<I18nTranslations>()
130
+ const [open, setOpen] = React.useState(false)
131
+ const [search, setSearch] = React.useState("")
132
+
133
+ // Resolve translations
134
+ const resolvedPlaceholder = placeholder ?? t('ui.select.placeholder')
135
+ const resolvedSearchPlaceholder = searchPlaceholder ?? t('ui.select.search')
136
+ const resolvedEmptyText = emptyText ?? t('ui.select.noResults')
137
+
138
+ // Build country options
139
+ const allCountries = React.useMemo<CountryOption[]>(() => {
140
+ let codes = Object.keys(countries) as TCountryCode[];
141
+
142
+ // Apply filters
143
+ if (allowedCountries?.length) {
144
+ codes = codes.filter(code => allowedCountries.includes(code));
145
+ }
146
+ if (excludedCountries?.length) {
147
+ codes = codes.filter(code => !excludedCountries.includes(code));
148
+ }
149
+
150
+ return codes
151
+ .map((code) => ({
152
+ code,
153
+ name: getCountryName?.(code) ?? countries[code].name,
154
+ native: countries[code].native,
155
+ emoji: getEmojiFlag(code),
156
+ }))
157
+ .sort((a, b) => a.name.localeCompare(b.name));
158
+ }, [getCountryName, allowedCountries, excludedCountries]);
159
+
160
+ const selectedCountries = React.useMemo(
161
+ () => allCountries.filter((c) => value.includes(c.code)),
162
+ [allCountries, value]
163
+ )
164
+
165
+ const filteredCountries = React.useMemo(() => {
166
+ if (!search) return allCountries
167
+ const searchLower = search.toLowerCase()
168
+ return allCountries.filter(
169
+ (c) =>
170
+ c.name.toLowerCase().includes(searchLower) ||
171
+ c.native.toLowerCase().includes(searchLower) ||
172
+ c.code.toLowerCase().includes(searchLower)
173
+ )
174
+ }, [allCountries, search])
175
+
176
+ const handleSelect = React.useCallback((code: string) => {
177
+ if (multiple) {
178
+ const newValue = value.includes(code)
179
+ ? value.filter((v) => v !== code)
180
+ : [...value, code]
181
+ onChange?.(newValue)
182
+ } else {
183
+ onChange?.([code])
184
+ if (variant === 'dropdown') {
185
+ setOpen(false)
186
+ }
187
+ }
188
+ }, [multiple, value, onChange, variant])
189
+
190
+ const handleRemove = React.useCallback((code: string, e: React.MouseEvent) => {
191
+ e.stopPropagation()
192
+ onChange?.(value.filter((v) => v !== code))
193
+ }, [value, onChange])
194
+
195
+ // Inline variant
196
+ if (variant === 'inline') {
197
+ return (
198
+ <div className={cn("space-y-3", className)}>
199
+ {/* Search input */}
200
+ {showSearch && (
201
+ <div className="relative">
202
+ <Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
203
+ <Input
204
+ type="text"
205
+ placeholder={resolvedSearchPlaceholder}
206
+ value={search}
207
+ onChange={(e) => setSearch(e.target.value)}
208
+ className="pl-9"
209
+ disabled={disabled}
210
+ />
211
+ </div>
212
+ )}
213
+
214
+ {/* Selected count */}
215
+ {multiple && selectedCountries.length > 0 && (
216
+ <p className="text-sm text-muted-foreground">
217
+ {selectedCountries.length} {t('ui.table.selected')}
218
+ </p>
219
+ )}
220
+
221
+ {/* Country list */}
222
+ <ScrollArea style={{ maxHeight }} className="rounded-md border">
223
+ <div className="p-1">
224
+ {filteredCountries.length === 0 ? (
225
+ <p className="text-sm text-muted-foreground text-center py-4">
226
+ {resolvedEmptyText}
227
+ </p>
228
+ ) : (
229
+ filteredCountries.map((country) => {
230
+ const isSelected = value.includes(country.code);
231
+ return (
232
+ <label
233
+ key={country.code}
234
+ className={cn(
235
+ 'flex items-center gap-3 px-3 py-2 rounded-md cursor-pointer',
236
+ 'hover:bg-accent/50 transition-colors',
237
+ isSelected && 'bg-primary/5',
238
+ disabled && 'opacity-50 cursor-not-allowed',
239
+ )}
240
+ >
241
+ {multiple ? (
242
+ <Checkbox
243
+ checked={isSelected}
244
+ onCheckedChange={() => !disabled && handleSelect(country.code)}
245
+ disabled={disabled}
246
+ />
247
+ ) : (
248
+ <div className={cn(
249
+ "h-4 w-4 rounded-full border-2 flex items-center justify-center",
250
+ isSelected ? "border-primary bg-primary" : "border-muted-foreground"
251
+ )}>
252
+ {isSelected && <div className="h-2 w-2 rounded-full bg-primary-foreground" />}
253
+ </div>
254
+ )}
255
+ <span className="text-lg">{country.emoji}</span>
256
+ <div className="flex flex-col flex-1 min-w-0">
257
+ <span className={cn('text-sm', isSelected && 'font-medium')}>
258
+ {country.name}
259
+ </span>
260
+ {showNativeName && country.native !== country.name && (
261
+ <span className="text-xs text-muted-foreground">
262
+ {country.native}
263
+ </span>
264
+ )}
265
+ </div>
266
+ </label>
267
+ );
268
+ })
269
+ )}
270
+ </div>
271
+ </ScrollArea>
272
+ </div>
273
+ );
274
+ }
275
+
276
+ // Dropdown variant
277
+ const displayValue = React.useMemo(() => {
278
+ if (selectedCountries.length === 0) {
279
+ return <span className="text-muted-foreground">{resolvedPlaceholder}</span>
280
+ }
281
+
282
+ if (!multiple && selectedCountries.length === 1) {
283
+ const country = selectedCountries[0];
284
+ return (
285
+ <div className="flex items-center gap-2">
286
+ <span>{country.emoji}</span>
287
+ <span>{country.name}</span>
288
+ </div>
289
+ );
290
+ }
291
+
292
+ const displayed = selectedCountries.slice(0, maxDisplay)
293
+ const remaining = selectedCountries.length - maxDisplay
294
+
295
+ return (
296
+ <div className="flex flex-wrap gap-1">
297
+ {displayed.map((country) => (
298
+ <Badge
299
+ key={country.code}
300
+ variant="secondary"
301
+ className="mr-1 text-xs"
302
+ >
303
+ <span className="mr-1">{country.emoji}</span>
304
+ {country.name}
305
+ <button
306
+ className="ml-1 rounded-full hover:bg-muted-foreground/20"
307
+ onClick={(e) => handleRemove(country.code, e)}
308
+ disabled={disabled}
309
+ aria-label={t('ui.actions.remove', { item: country.name })}
310
+ >
311
+ <X className="h-3 w-3" />
312
+ </button>
313
+ </Badge>
314
+ ))}
315
+ {remaining > 0 && (
316
+ <Badge variant="outline" className="text-xs">
317
+ {t('ui.select.moreItems', { count: remaining })}
318
+ </Badge>
319
+ )}
320
+ </div>
321
+ )
322
+ }, [selectedCountries, maxDisplay, resolvedPlaceholder, disabled, t, multiple, handleRemove])
323
+
324
+ return (
325
+ <Popover
326
+ open={open}
327
+ onOpenChange={(isOpen) => {
328
+ setOpen(isOpen)
329
+ if (!isOpen) {
330
+ setSearch("")
331
+ }
332
+ }}
333
+ >
334
+ <PopoverTrigger asChild>
335
+ <Button
336
+ variant="outline"
337
+ role="combobox"
338
+ aria-expanded={open}
339
+ className={cn(
340
+ "w-full justify-between min-h-10 h-auto py-2",
341
+ className
342
+ )}
343
+ disabled={disabled}
344
+ >
345
+ <div className="flex-1 text-left overflow-hidden">
346
+ {displayValue}
347
+ </div>
348
+ <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
349
+ </Button>
350
+ </PopoverTrigger>
351
+ <PopoverContent className="w-[var(--radix-popover-trigger-width)] p-0" align="start">
352
+ <Command shouldFilter={false} className="flex flex-col">
353
+ <CommandInput
354
+ placeholder={resolvedSearchPlaceholder}
355
+ className="shrink-0"
356
+ value={search}
357
+ onValueChange={setSearch}
358
+ />
359
+ <CommandList className="max-h-[300px]">
360
+ {filteredCountries.length === 0 ? (
361
+ <CommandEmpty>{resolvedEmptyText}</CommandEmpty>
362
+ ) : (
363
+ <CommandGroup>
364
+ {filteredCountries.map((country) => {
365
+ const isSelected = value.includes(country.code)
366
+ return (
367
+ <CommandItem
368
+ key={country.code}
369
+ value={country.code}
370
+ onSelect={() => handleSelect(country.code)}
371
+ >
372
+ <Check
373
+ className={cn(
374
+ "mr-2 h-4 w-4 shrink-0",
375
+ isSelected ? "opacity-100" : "opacity-0"
376
+ )}
377
+ />
378
+ <span className="mr-2 text-lg">{country.emoji}</span>
379
+ <div className="flex flex-col flex-1 min-w-0">
380
+ <span className="truncate">{country.name}</span>
381
+ {showNativeName && country.native !== country.name && (
382
+ <span className="text-xs text-muted-foreground truncate">
383
+ {country.native}
384
+ </span>
385
+ )}
386
+ </div>
387
+ </CommandItem>
388
+ )
389
+ })}
390
+ </CommandGroup>
391
+ )}
392
+ </CommandList>
393
+ </Command>
394
+ </PopoverContent>
395
+ </Popover>
396
+ )
397
+ }
398
+
399
+ // Re-export types for convenience
400
+ export type { TCountryCode } from 'countries-list';
401
+ export { getEmojiFlag } from 'countries-list';
@@ -21,6 +21,8 @@ export { MultiSelect } from './multi-select';
21
21
  export type { MultiSelectOption, MultiSelectProps } from './multi-select';
22
22
  export { MultiSelectPro } from './multi-select-pro';
23
23
  export type { MultiSelectProOption, MultiSelectProGroup, MultiSelectProProps, MultiSelectProRef, AnimationConfig, ResponsiveConfig } from './multi-select-pro';
24
+ export { CountrySelect, getEmojiFlag } from './country-select';
25
+ export type { CountrySelectProps, CountrySelectVariant, CountryOption, TCountryCode } from './country-select';
24
26
  export { MultiSelectProAsync } from './multi-select-pro/async';
25
27
  export type { MultiSelectProAsyncProps } from './multi-select-pro/async';
26
28
  export { Switch } from './switch';