@xsolla/xui-tag 0.99.0 → 0.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +263 -12
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,30 +1,281 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Tag
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A cross-platform React tag component for displaying labels, categories, and removable chips. Supports multiple tones and optional icons.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
+
npm install @xsolla/xui-tag
|
|
9
|
+
# or
|
|
8
10
|
yarn add @xsolla/xui-tag
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## Demo
|
|
14
|
+
|
|
15
|
+
### Basic Tag
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
import { Tag } from '@xsolla/xui-tag';
|
|
20
|
+
|
|
21
|
+
export default function BasicTag() {
|
|
22
|
+
return (
|
|
23
|
+
<div style={{ display: 'flex', gap: 8 }}>
|
|
24
|
+
<Tag>Default</Tag>
|
|
25
|
+
<Tag tone="brand">Brand</Tag>
|
|
26
|
+
<Tag tone="success">Success</Tag>
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Tag Tones
|
|
12
33
|
|
|
13
34
|
```tsx
|
|
14
|
-
import
|
|
35
|
+
import * as React from 'react';
|
|
36
|
+
import { Tag } from '@xsolla/xui-tag';
|
|
37
|
+
|
|
38
|
+
export default function TagTones() {
|
|
39
|
+
return (
|
|
40
|
+
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
|
|
41
|
+
<Tag tone="primary">Primary</Tag>
|
|
42
|
+
<Tag tone="secondary">Secondary</Tag>
|
|
43
|
+
<Tag tone="brand">Brand</Tag>
|
|
44
|
+
<Tag tone="brandExtra">Brand Extra</Tag>
|
|
45
|
+
<Tag tone="success">Success</Tag>
|
|
46
|
+
<Tag tone="warning">Warning</Tag>
|
|
47
|
+
<Tag tone="alert">Alert</Tag>
|
|
48
|
+
<Tag tone="neutral">Neutral</Tag>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
15
53
|
|
|
16
|
-
|
|
17
|
-
|
|
54
|
+
### Tag Sizes
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import * as React from 'react';
|
|
58
|
+
import { Tag } from '@xsolla/xui-tag';
|
|
59
|
+
|
|
60
|
+
export default function TagSizes() {
|
|
61
|
+
return (
|
|
62
|
+
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
|
63
|
+
<Tag size="xs">Extra Small</Tag>
|
|
64
|
+
<Tag size="sm">Small</Tag>
|
|
65
|
+
<Tag size="md">Medium</Tag>
|
|
66
|
+
<Tag size="lg">Large</Tag>
|
|
67
|
+
<Tag size="xl">Extra Large</Tag>
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Tag with Icon
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import * as React from 'react';
|
|
77
|
+
import { Tag } from '@xsolla/xui-tag';
|
|
78
|
+
import { Check } from '@xsolla/xui-icons';
|
|
79
|
+
import { Star, Clock } from '@xsolla/xui-icons-base';
|
|
80
|
+
|
|
81
|
+
export default function TagWithIcon() {
|
|
82
|
+
return (
|
|
83
|
+
<div style={{ display: 'flex', gap: 8 }}>
|
|
84
|
+
<Tag icon={<Star size={12} />} tone="warning">Featured</Tag>
|
|
85
|
+
<Tag icon={<Check size={12} />} tone="success">Verified</Tag>
|
|
86
|
+
<Tag icon={<Clock size={12} />} tone="neutral">Pending</Tag>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Removable Tag
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import * as React from 'react';
|
|
96
|
+
import { Tag } from '@xsolla/xui-tag';
|
|
97
|
+
|
|
98
|
+
export default function RemovableTag() {
|
|
99
|
+
const [tags, setTags] = React.useState(['React', 'TypeScript', 'Node.js', 'GraphQL']);
|
|
100
|
+
|
|
101
|
+
const removeTag = (tagToRemove: string) => {
|
|
102
|
+
setTags(tags.filter(tag => tag !== tagToRemove));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
|
|
107
|
+
{tags.map(tag => (
|
|
108
|
+
<Tag key={tag} tone="brand" onRemove={() => removeTag(tag)}>
|
|
109
|
+
{tag}
|
|
110
|
+
</Tag>
|
|
111
|
+
))}
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Anatomy
|
|
118
|
+
|
|
119
|
+
Import the component and use it directly:
|
|
120
|
+
|
|
121
|
+
```jsx
|
|
122
|
+
import { Tag } from '@xsolla/xui-tag';
|
|
123
|
+
|
|
124
|
+
<Tag
|
|
125
|
+
size="md" // Size variant
|
|
126
|
+
tone="brand" // Color tone
|
|
127
|
+
icon={<Icon />} // Optional leading icon
|
|
128
|
+
onRemove={handleRemove} // Makes tag removable
|
|
129
|
+
>
|
|
130
|
+
Tag Label
|
|
18
131
|
</Tag>
|
|
19
132
|
```
|
|
20
133
|
|
|
21
|
-
##
|
|
134
|
+
## Examples
|
|
135
|
+
|
|
136
|
+
### Category Tags
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import * as React from 'react';
|
|
140
|
+
import { Tag } from '@xsolla/xui-tag';
|
|
141
|
+
|
|
142
|
+
export default function CategoryTags() {
|
|
143
|
+
const categories = [
|
|
144
|
+
{ name: 'Technology', tone: 'brand' as const },
|
|
145
|
+
{ name: 'Design', tone: 'brandExtra' as const },
|
|
146
|
+
{ name: 'Marketing', tone: 'success' as const },
|
|
147
|
+
{ name: 'Sales', tone: 'warning' as const },
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<div style={{ display: 'flex', gap: 8 }}>
|
|
152
|
+
{categories.map(cat => (
|
|
153
|
+
<Tag key={cat.name} tone={cat.tone} size="sm">
|
|
154
|
+
{cat.name}
|
|
155
|
+
</Tag>
|
|
156
|
+
))}
|
|
157
|
+
</div>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Status Tags
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
import * as React from 'react';
|
|
166
|
+
import { Tag } from '@xsolla/xui-tag';
|
|
167
|
+
import { CheckCircle, Clock, XCircle } from '@xsolla/xui-icons-base';
|
|
168
|
+
|
|
169
|
+
export default function StatusTags() {
|
|
170
|
+
return (
|
|
171
|
+
<div style={{ display: 'flex', gap: 8 }}>
|
|
172
|
+
<Tag
|
|
173
|
+
icon={<CheckCircle size={12} />}
|
|
174
|
+
tone="success"
|
|
175
|
+
>
|
|
176
|
+
Completed
|
|
177
|
+
</Tag>
|
|
178
|
+
<Tag
|
|
179
|
+
icon={<Clock size={12} />}
|
|
180
|
+
tone="warning"
|
|
181
|
+
>
|
|
182
|
+
In Progress
|
|
183
|
+
</Tag>
|
|
184
|
+
<Tag
|
|
185
|
+
icon={<XCircle size={12} />}
|
|
186
|
+
tone="alert"
|
|
187
|
+
>
|
|
188
|
+
Failed
|
|
189
|
+
</Tag>
|
|
190
|
+
</div>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Tag Input
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
import * as React from 'react';
|
|
199
|
+
import { Tag } from '@xsolla/xui-tag';
|
|
200
|
+
import { Input } from '@xsolla/xui-input';
|
|
201
|
+
|
|
202
|
+
export default function TagInput() {
|
|
203
|
+
const [tags, setTags] = React.useState(['react', 'typescript']);
|
|
204
|
+
const [inputValue, setInputValue] = React.useState('');
|
|
205
|
+
|
|
206
|
+
const addTag = () => {
|
|
207
|
+
if (inputValue.trim() && !tags.includes(inputValue.trim())) {
|
|
208
|
+
setTags([...tags, inputValue.trim()]);
|
|
209
|
+
setInputValue('');
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
return (
|
|
214
|
+
<div>
|
|
215
|
+
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap', marginBottom: 8 }}>
|
|
216
|
+
{tags.map(tag => (
|
|
217
|
+
<Tag
|
|
218
|
+
key={tag}
|
|
219
|
+
tone="secondary"
|
|
220
|
+
onRemove={() => setTags(tags.filter(t => t !== tag))}
|
|
221
|
+
>
|
|
222
|
+
{tag}
|
|
223
|
+
</Tag>
|
|
224
|
+
))}
|
|
225
|
+
</div>
|
|
226
|
+
<Input
|
|
227
|
+
value={inputValue}
|
|
228
|
+
onChangeText={setInputValue}
|
|
229
|
+
placeholder="Add a tag..."
|
|
230
|
+
onKeyDown={(e) => e.key === 'Enter' && addTag()}
|
|
231
|
+
/>
|
|
232
|
+
</div>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## API Reference
|
|
22
238
|
|
|
23
239
|
### Tag
|
|
24
240
|
|
|
241
|
+
A tag/chip component.
|
|
242
|
+
|
|
243
|
+
**Tag Props:**
|
|
244
|
+
|
|
25
245
|
| Prop | Type | Default | Description |
|
|
26
|
-
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
246
|
+
| :--- | :--- | :------ | :---------- |
|
|
247
|
+
| children | `ReactNode` | - | **Required.** Tag content. |
|
|
248
|
+
| size | `"xl" \| "lg" \| "md" \| "sm" \| "xs"` | `"md"` | Size of the tag. |
|
|
249
|
+
| tone | `"primary" \| "secondary" \| "brand" \| "brandExtra" \| "success" \| "warning" \| "alert" \| "neutral"` | `"primary"` | Color tone. |
|
|
250
|
+
| icon | `ReactNode` | - | Leading icon. |
|
|
251
|
+
| onRemove | `() => void` | - | Callback for remove button. Makes tag removable. |
|
|
252
|
+
|
|
253
|
+
**Tone Color Mapping:**
|
|
254
|
+
|
|
255
|
+
| Tone | Background | Text |
|
|
256
|
+
| :--- | :--------- | :--- |
|
|
257
|
+
| primary | Background primary | Content primary |
|
|
258
|
+
| secondary | Background secondary | Content primary |
|
|
259
|
+
| brand | Brand primary | On brand |
|
|
260
|
+
| brandExtra | BrandExtra primary | On brandExtra |
|
|
261
|
+
| success | Success primary | On success |
|
|
262
|
+
| warning | Warning primary | On warning |
|
|
263
|
+
| alert | Alert primary | On alert |
|
|
264
|
+
| neutral | Neutral primary | On neutral |
|
|
265
|
+
|
|
266
|
+
## Theming
|
|
267
|
+
|
|
268
|
+
Tag uses the design system theme for colors:
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
// Colors accessed via theme (example for "brand" tone)
|
|
272
|
+
theme.colors.background.brand.primary // Background
|
|
273
|
+
theme.colors.content.onBrand // Text color
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Accessibility
|
|
277
|
+
|
|
278
|
+
- Uses semantic elements for proper structure
|
|
279
|
+
- Remove button includes accessible label
|
|
280
|
+
- Keyboard accessible remove action
|
|
281
|
+
- Focus indicator on interactive elements
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-tag",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.101.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"build:native": "PLATFORM=native tsup"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xsolla/xui-core": "0.
|
|
14
|
-
"@xsolla/xui-icons": "0.
|
|
15
|
-
"@xsolla/xui-primitives-core": "0.
|
|
13
|
+
"@xsolla/xui-core": "0.101.0",
|
|
14
|
+
"@xsolla/xui-icons": "0.101.0",
|
|
15
|
+
"@xsolla/xui-primitives-core": "0.101.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": ">=16.8.0",
|