@xsolla/xui-icons-flag 0.148.0 → 0.148.2

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.
Files changed (2) hide show
  1. package/README.md +206 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,206 @@
1
+ # Icons Flag
2
+
3
+ A cross-platform React flag icons package containing 250+ country flags. Each flag uses ISO 3166-1 alpha-2 country codes and renders as a scalable SVG.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @xsolla/xui-icons-flag
9
+ # or
10
+ yarn add @xsolla/xui-icons-flag
11
+ ```
12
+
13
+ ## Demo
14
+
15
+ ### Individual Flag Import
16
+
17
+ ```tsx
18
+ import * as React from 'react';
19
+ import { FlagUS, FlagGB, FlagDE, FlagJP } from '@xsolla/xui-icons-flag';
20
+
21
+ export default function IndividualFlags() {
22
+ return (
23
+ <div style={{ display: 'flex', gap: 8 }}>
24
+ <FlagUS size={24} />
25
+ <FlagGB size={24} />
26
+ <FlagDE size={24} />
27
+ <FlagJP size={24} />
28
+ </div>
29
+ );
30
+ }
31
+ ```
32
+
33
+ ### Dynamic Flag Component
34
+
35
+ ```tsx
36
+ import * as React from 'react';
37
+ import { FlagIcon } from '@xsolla/xui-icons-flag';
38
+ import * as Flags from '@xsolla/xui-icons-flag';
39
+
40
+ export default function DynamicFlag() {
41
+ const countryCode = 'US';
42
+ const FlagComponent = Flags[`Flag${countryCode}`];
43
+
44
+ return FlagComponent ? <FlagComponent size={24} /> : null;
45
+ }
46
+ ```
47
+
48
+ ### Flag Sizes
49
+
50
+ ```tsx
51
+ import * as React from 'react';
52
+ import { FlagUS } from '@xsolla/xui-icons-flag';
53
+
54
+ export default function FlagSizes() {
55
+ return (
56
+ <div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
57
+ <FlagUS size={16} />
58
+ <FlagUS size={24} />
59
+ <FlagUS size={32} />
60
+ <FlagUS size={48} />
61
+ </div>
62
+ );
63
+ }
64
+ ```
65
+
66
+ ## Anatomy
67
+
68
+ ```jsx
69
+ import { FlagUS } from '@xsolla/xui-icons-flag';
70
+
71
+ <FlagUS
72
+ size={24} // Size in pixels
73
+ className="flag" // CSS class
74
+ style={{ margin: 4 }} // Inline styles
75
+ aria-label="United States" // Accessible label
76
+ />
77
+ ```
78
+
79
+ ## Examples
80
+
81
+ ### Country Selector
82
+
83
+ ```tsx
84
+ import * as React from 'react';
85
+ import { FlagUS, FlagGB, FlagDE, FlagFR, FlagJP } from '@xsolla/xui-icons-flag';
86
+
87
+ export default function CountrySelector() {
88
+ const [selected, setSelected] = React.useState('US');
89
+
90
+ const countries = [
91
+ { code: 'US', name: 'United States', Flag: FlagUS },
92
+ { code: 'GB', name: 'United Kingdom', Flag: FlagGB },
93
+ { code: 'DE', name: 'Germany', Flag: FlagDE },
94
+ { code: 'FR', name: 'France', Flag: FlagFR },
95
+ { code: 'JP', name: 'Japan', Flag: FlagJP },
96
+ ];
97
+
98
+ return (
99
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
100
+ {countries.map(({ code, name, Flag }) => (
101
+ <button
102
+ key={code}
103
+ onClick={() => setSelected(code)}
104
+ style={{
105
+ display: 'flex',
106
+ alignItems: 'center',
107
+ gap: 12,
108
+ padding: '8px 16px',
109
+ background: selected === code ? '#e0e0e0' : 'transparent',
110
+ border: 'none',
111
+ cursor: 'pointer',
112
+ }}
113
+ >
114
+ <Flag size={20} aria-hidden />
115
+ <span>{name}</span>
116
+ </button>
117
+ ))}
118
+ </div>
119
+ );
120
+ }
121
+ ```
122
+
123
+ ### With InputPhone
124
+
125
+ ```tsx
126
+ import * as React from 'react';
127
+ import { InputPhone, Country } from '@xsolla/xui-input-phone';
128
+ import { FlagUS, FlagGB, FlagDE } from '@xsolla/xui-icons-flag';
129
+
130
+ export default function PhoneWithFlags() {
131
+ const [phone, setPhone] = React.useState('');
132
+ const [country, setCountry] = React.useState<Country>();
133
+
134
+ const countries: Country[] = [
135
+ { code: 'US', name: 'United States', dialCode: '+1', flag: <FlagUS /> },
136
+ { code: 'GB', name: 'United Kingdom', dialCode: '+44', flag: <FlagGB /> },
137
+ { code: 'DE', name: 'Germany', dialCode: '+49', flag: <FlagDE /> },
138
+ ];
139
+
140
+ return (
141
+ <InputPhone
142
+ value={phone}
143
+ onChange={(e) => setPhone(e.target.value)}
144
+ countries={countries}
145
+ selectedCountry={country}
146
+ onCountryChange={setCountry}
147
+ />
148
+ );
149
+ }
150
+ ```
151
+
152
+ ## API Reference
153
+
154
+ ### Flag Components
155
+
156
+ Each flag component (e.g., `FlagUS`, `FlagGB`) accepts the same props:
157
+
158
+ **FlagIconProps:**
159
+
160
+ | Prop | Type | Default | Description |
161
+ | :--- | :--- | :------ | :---------- |
162
+ | size | `number` | `24` | Size in pixels (width and height). |
163
+ | className | `string` | - | CSS class name. |
164
+ | style | `CSSProperties` | - | Inline styles. |
165
+ | data-testid | `string` | - | Test ID (web). |
166
+ | testID | `string` | - | Test ID (React Native). |
167
+ | aria-label | `string` | - | Accessible label. |
168
+ | aria-hidden | `boolean` | `true` if no aria-label | Hide from screen readers. |
169
+
170
+ ## Available Flags
171
+
172
+ Flags are named using ISO 3166-1 alpha-2 country codes prefixed with "Flag":
173
+
174
+ | Code | Component | Country |
175
+ | :--- | :-------- | :------ |
176
+ | AD | `FlagAD` | Andorra |
177
+ | AE | `FlagAE` | United Arab Emirates |
178
+ | AF | `FlagAF` | Afghanistan |
179
+ | ... | ... | ... |
180
+ | US | `FlagUS` | United States |
181
+ | GB | `FlagGB` | United Kingdom |
182
+ | DE | `FlagDE` | Germany |
183
+ | FR | `FlagFR` | France |
184
+ | JP | `FlagJP` | Japan |
185
+ | ... | ... | ... |
186
+ | ZW | `FlagZW` | Zimbabwe |
187
+
188
+ Over 250 country flags are available. See the full list in the package source.
189
+
190
+ ## Tree Shaking
191
+
192
+ Import individual flags for optimal bundle size:
193
+
194
+ ```tsx
195
+ // Good - only imports US flag
196
+ import { FlagUS } from '@xsolla/xui-icons-flag';
197
+
198
+ // Avoid - imports all flags
199
+ import * as Flags from '@xsolla/xui-icons-flag';
200
+ ```
201
+
202
+ ## Accessibility
203
+
204
+ - Flags are hidden from screen readers by default (`aria-hidden="true"`)
205
+ - Use `aria-label` when the flag conveys meaningful information
206
+ - For decorative flags, keep the default hidden behavior
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-icons-flag",
3
- "version": "0.148.0",
3
+ "version": "0.148.2",
4
4
  "main": "./web/index.js",
5
5
  "types": "./web/index.d.ts",
6
6
  "exports": {