@xsolla/xui-checkbox-tag-group 0.148.0 → 0.148.1
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 +211 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Checkbox Tag Group
|
|
2
|
+
|
|
3
|
+
A cross-platform React component for selecting multiple options displayed as tag-style checkboxes. Supports controlled and uncontrolled modes with validation. Works on both React (web) and React Native.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @xsolla/xui-checkbox-tag-group
|
|
9
|
+
# or
|
|
10
|
+
yarn add @xsolla/xui-checkbox-tag-group
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Demo
|
|
14
|
+
|
|
15
|
+
### Basic Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
import { CheckboxTagGroup } from '@xsolla/xui-checkbox-tag-group';
|
|
20
|
+
|
|
21
|
+
const options = [
|
|
22
|
+
{ label: 'Action', value: 'action' },
|
|
23
|
+
{ label: 'RPG', value: 'rpg' },
|
|
24
|
+
{ label: 'Strategy', value: 'strategy' },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export default function BasicCheckboxTagGroup() {
|
|
28
|
+
return (
|
|
29
|
+
<CheckboxTagGroup
|
|
30
|
+
options={options}
|
|
31
|
+
defaultValue={['action']}
|
|
32
|
+
aria-label="Game genres"
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Controlled
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import * as React from 'react';
|
|
42
|
+
import { CheckboxTagGroup } from '@xsolla/xui-checkbox-tag-group';
|
|
43
|
+
|
|
44
|
+
const options = [
|
|
45
|
+
{ label: 'Action', value: 'action' },
|
|
46
|
+
{ label: 'RPG', value: 'rpg' },
|
|
47
|
+
{ label: 'Strategy', value: 'strategy' },
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
export default function ControlledCheckboxTagGroup() {
|
|
51
|
+
const [values, setValues] = React.useState(['action']);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<CheckboxTagGroup
|
|
55
|
+
options={options}
|
|
56
|
+
value={values}
|
|
57
|
+
onChange={setValues}
|
|
58
|
+
aria-label="Game genres"
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Sizes
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import * as React from 'react';
|
|
68
|
+
import { CheckboxTagGroup } from '@xsolla/xui-checkbox-tag-group';
|
|
69
|
+
|
|
70
|
+
const options = [
|
|
71
|
+
{ label: 'Item 1', value: 'item1' },
|
|
72
|
+
{ label: 'Item 2', value: 'item2' },
|
|
73
|
+
{ label: 'Item 3', value: 'item3' },
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
export default function CheckboxTagGroupSizes() {
|
|
77
|
+
return (
|
|
78
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 24 }}>
|
|
79
|
+
<CheckboxTagGroup options={options} size="xl" defaultValue={['item1']} aria-label="XL tags" />
|
|
80
|
+
<CheckboxTagGroup options={options} size="lg" defaultValue={['item1']} aria-label="LG tags" />
|
|
81
|
+
<CheckboxTagGroup options={options} size="md" defaultValue={['item1']} aria-label="MD tags" />
|
|
82
|
+
<CheckboxTagGroup options={options} size="sm" defaultValue={['item1']} aria-label="SM tags" />
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Anatomy
|
|
89
|
+
|
|
90
|
+
Import the component and use it directly:
|
|
91
|
+
|
|
92
|
+
```jsx
|
|
93
|
+
import { CheckboxTagGroup } from '@xsolla/xui-checkbox-tag-group';
|
|
94
|
+
|
|
95
|
+
<CheckboxTagGroup
|
|
96
|
+
options={options} // Array of { label, value, disabled? }
|
|
97
|
+
value={selectedValues} // Controlled selected values
|
|
98
|
+
defaultValue={['item1']} // Default values (uncontrolled)
|
|
99
|
+
onChange={handleChange} // Callback with new values array
|
|
100
|
+
size="md" // Size variant
|
|
101
|
+
disabled={false} // Disable all options
|
|
102
|
+
errorMessage="Select at least one" // Error message
|
|
103
|
+
aria-label="Filter options" // Accessible label
|
|
104
|
+
/>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Examples
|
|
108
|
+
|
|
109
|
+
### With Error
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import * as React from 'react';
|
|
113
|
+
import { CheckboxTagGroup } from '@xsolla/xui-checkbox-tag-group';
|
|
114
|
+
|
|
115
|
+
const options = [
|
|
116
|
+
{ label: 'Action', value: 'action' },
|
|
117
|
+
{ label: 'RPG', value: 'rpg' },
|
|
118
|
+
{ label: 'Strategy', value: 'strategy' },
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
export default function ErrorCheckboxTagGroup() {
|
|
122
|
+
return (
|
|
123
|
+
<CheckboxTagGroup
|
|
124
|
+
options={options}
|
|
125
|
+
errorMessage="Please select at least one genre"
|
|
126
|
+
aria-label="Game genres"
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### With Disabled Option
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
import * as React from 'react';
|
|
136
|
+
import { CheckboxTagGroup } from '@xsolla/xui-checkbox-tag-group';
|
|
137
|
+
|
|
138
|
+
const options = [
|
|
139
|
+
{ label: 'Action', value: 'action' },
|
|
140
|
+
{ label: 'RPG (coming soon)', value: 'rpg', disabled: true },
|
|
141
|
+
{ label: 'Strategy', value: 'strategy' },
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
export default function DisabledOptionCheckboxTagGroup() {
|
|
145
|
+
return (
|
|
146
|
+
<CheckboxTagGroup
|
|
147
|
+
options={options}
|
|
148
|
+
defaultValue={['action']}
|
|
149
|
+
aria-label="Game genres"
|
|
150
|
+
/>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Fully Disabled
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
import * as React from 'react';
|
|
159
|
+
import { CheckboxTagGroup } from '@xsolla/xui-checkbox-tag-group';
|
|
160
|
+
|
|
161
|
+
const options = [
|
|
162
|
+
{ label: 'Action', value: 'action' },
|
|
163
|
+
{ label: 'RPG', value: 'rpg' },
|
|
164
|
+
{ label: 'Strategy', value: 'strategy' },
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
export default function DisabledCheckboxTagGroup() {
|
|
168
|
+
return (
|
|
169
|
+
<CheckboxTagGroup
|
|
170
|
+
options={options}
|
|
171
|
+
defaultValue={['action']}
|
|
172
|
+
disabled
|
|
173
|
+
aria-label="Game genres"
|
|
174
|
+
/>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## API Reference
|
|
180
|
+
|
|
181
|
+
### CheckboxTagGroup
|
|
182
|
+
|
|
183
|
+
**Props:**
|
|
184
|
+
|
|
185
|
+
| Prop | Type | Default | Description |
|
|
186
|
+
| :--- | :--- | :------ | :---------- |
|
|
187
|
+
| options | `CheckboxTagGroupItem[]` | - | Array of options to display. |
|
|
188
|
+
| value | `string[]` | - | Controlled selected values. |
|
|
189
|
+
| defaultValue | `string[]` | `[]` | Default selected values (uncontrolled). |
|
|
190
|
+
| onChange | `(values: string[]) => void` | - | Callback when selection changes. |
|
|
191
|
+
| size | `"xl" \| "lg" \| "md" \| "sm"` | `"md"` | Size of the tag items. |
|
|
192
|
+
| disabled | `boolean` | `false` | Disable all options. |
|
|
193
|
+
| errorMessage | `string` | - | Error message displayed below the group. |
|
|
194
|
+
| aria-label | `string` | - | Accessible label for the group. |
|
|
195
|
+
|
|
196
|
+
### CheckboxTagGroupItem
|
|
197
|
+
|
|
198
|
+
| Prop | Type | Default | Description |
|
|
199
|
+
| :--- | :--- | :------ | :---------- |
|
|
200
|
+
| label | `string` | - | Display text for the option. |
|
|
201
|
+
| value | `string` | - | Value identifier for the option. |
|
|
202
|
+
| disabled | `boolean` | `false` | Disable this specific option. |
|
|
203
|
+
|
|
204
|
+
## Accessibility
|
|
205
|
+
|
|
206
|
+
- Uses `role="group"` with `aria-label` on the container
|
|
207
|
+
- Each option has `role="checkbox"` with `aria-checked`
|
|
208
|
+
- `aria-disabled` set on disabled options
|
|
209
|
+
- `aria-describedby` links to error message when present
|
|
210
|
+
- Error messages use `role="alert"` for screen reader announcement
|
|
211
|
+
- Keyboard navigation with Tab between options and Space/Enter to toggle
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-checkbox-tag-group",
|
|
3
|
-
"version": "0.148.
|
|
3
|
+
"version": "0.148.1",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"test:coverage": "vitest run --coverage"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@xsolla/xui-core": "0.148.
|
|
17
|
-
"@xsolla/xui-primitives-core": "0.148.
|
|
16
|
+
"@xsolla/xui-core": "0.148.1",
|
|
17
|
+
"@xsolla/xui-primitives-core": "0.148.1"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": ">=16.8.0",
|