@xsolla/xui-multi-select 0.99.0 → 0.100.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.
Files changed (2) hide show
  1. package/README.md +155 -23
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -1,43 +1,175 @@
1
- # @xsolla/xui-multi-select
1
+ ---
2
+ title: Multi Select
3
+ subtitle: A select for multiple selections.
4
+ description: A cross-platform React multi-select component for choosing multiple options from a list.
5
+ ---
2
6
 
3
- Multi-value dropdown select with tag or text display of selected items.
7
+ # Multi Select
8
+
9
+ A cross-platform React multi-select component that allows users to select multiple options from a dropdown list with checkboxes.
4
10
 
5
11
  ## Installation
6
12
 
7
13
  ```bash
14
+ npm install @xsolla/xui-multi-select
15
+ # or
8
16
  yarn add @xsolla/xui-multi-select
9
17
  ```
10
18
 
11
- ## Usage
19
+ ## Demo
20
+
21
+ ### Basic Multi Select
12
22
 
13
23
  ```tsx
24
+ import * as React from 'react';
25
+ import { MultiSelect } from '@xsolla/xui-multi-select';
26
+
27
+ export default function BasicMultiSelect() {
28
+ const [selected, setSelected] = React.useState<string[]>([]);
29
+
30
+ return (
31
+ <MultiSelect
32
+ options={['React', 'Vue', 'Angular', 'Svelte']}
33
+ value={selected}
34
+ onChange={setSelected}
35
+ placeholder="Select frameworks"
36
+ />
37
+ );
38
+ }
39
+ ```
40
+
41
+ ### With Label
42
+
43
+ ```tsx
44
+ import * as React from 'react';
45
+ import { MultiSelect } from '@xsolla/xui-multi-select';
46
+
47
+ export default function LabeledMultiSelect() {
48
+ const [selected, setSelected] = React.useState<string[]>(['Marketing']);
49
+
50
+ return (
51
+ <MultiSelect
52
+ label="Departments"
53
+ options={['Engineering', 'Marketing', 'Sales', 'Design', 'HR']}
54
+ value={selected}
55
+ onChange={setSelected}
56
+ placeholder="Select departments"
57
+ />
58
+ );
59
+ }
60
+ ```
61
+
62
+ ### Multi Select Sizes
63
+
64
+ ```tsx
65
+ import * as React from 'react';
66
+ import { MultiSelect } from '@xsolla/xui-multi-select';
67
+
68
+ export default function MultiSelectSizes() {
69
+ const options = ['Option 1', 'Option 2', 'Option 3'];
70
+
71
+ return (
72
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
73
+ <MultiSelect options={options} size="xs" placeholder="Extra Small" />
74
+ <MultiSelect options={options} size="sm" placeholder="Small" />
75
+ <MultiSelect options={options} size="md" placeholder="Medium" />
76
+ <MultiSelect options={options} size="lg" placeholder="Large" />
77
+ <MultiSelect options={options} size="xl" placeholder="Extra Large" />
78
+ </div>
79
+ );
80
+ }
81
+ ```
82
+
83
+ ## Anatomy
84
+
85
+ ```jsx
14
86
  import { MultiSelect } from '@xsolla/xui-multi-select';
15
87
 
16
88
  <MultiSelect
17
- label="Platforms"
18
- options={[
19
- { label: 'Web', value: 'web' },
20
- { label: 'iOS', value: 'ios' },
21
- { label: 'Android', value: 'android' },
22
- ]}
23
- value={selected}
24
- onChange={setSelected}
89
+ options={['a', 'b', 'c']} // Available options
90
+ value={selectedArray} // Currently selected values
91
+ onChange={setSelected} // Selection change handler
92
+ placeholder="Select..." // Placeholder text
93
+ label="Label" // Label above select
94
+ size="md" // Size variant
95
+ disabled={false} // Disabled state
25
96
  />
26
97
  ```
27
98
 
28
- ## Props
99
+ ## Examples
100
+
101
+ ### Form Integration
102
+
103
+ ```tsx
104
+ import * as React from 'react';
105
+ import { MultiSelect } from '@xsolla/xui-multi-select';
106
+ import { Button } from '@xsolla/xui-button';
107
+
108
+ export default function FormMultiSelect() {
109
+ const [skills, setSkills] = React.useState<string[]>([]);
110
+
111
+ const handleSubmit = () => {
112
+ console.log('Selected skills:', skills);
113
+ };
114
+
115
+ return (
116
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 16, width: 300 }}>
117
+ <MultiSelect
118
+ label="Skills"
119
+ options={['JavaScript', 'TypeScript', 'Python', 'Go', 'Rust', 'Java']}
120
+ value={skills}
121
+ onChange={setSkills}
122
+ placeholder="Select your skills"
123
+ />
124
+ <Button onPress={handleSubmit}>Submit</Button>
125
+ </div>
126
+ );
127
+ }
128
+ ```
129
+
130
+ ### Disabled State
131
+
132
+ ```tsx
133
+ import * as React from 'react';
134
+ import { MultiSelect } from '@xsolla/xui-multi-select';
135
+
136
+ export default function DisabledMultiSelect() {
137
+ return (
138
+ <MultiSelect
139
+ options={['Option 1', 'Option 2', 'Option 3']}
140
+ value={['Option 1']}
141
+ disabled
142
+ placeholder="Disabled select"
143
+ />
144
+ );
145
+ }
146
+ ```
147
+
148
+ ## API Reference
29
149
 
30
150
  ### MultiSelect
31
151
 
152
+ **MultiSelect Props:**
153
+
32
154
  | Prop | Type | Default | Description |
33
- |------|------|---------|-------------|
34
- | `options` | `MultiSelectOption[]` | | List of options (`{ label, value, disabled? }`) |
35
- | `value` | `MultiSelectValue` | | Array of selected values |
36
- | `onChange` | `(values: MultiSelectValue) => void` | | Called when the selection changes |
37
- | `placeholder` | `string` | `"Select"` | Placeholder text when nothing is selected |
38
- | `label` | `string` | | Label displayed above the control |
39
- | `size` | `"xs" \| "sm" \| "md" \| "lg" \| "xl"` | `"md"` | Size of the control |
40
- | `state` | `"default" \| "hover" \| "focus" \| "disable" \| "error"` | | Visual state |
41
- | `disabled` | `boolean` | `false` | Disables the control |
42
- | `errorMessage` | `string` | — | Error message shown below the control |
43
- | `variant` | `"tag" \| "text"` | `"tag"` | Display selected items as tags or comma-separated text |
155
+ | :--- | :--- | :------ | :---------- |
156
+ | options | `string[]` | - | **Required.** Available options. |
157
+ | value | `string[]` | `[]` | Currently selected values. |
158
+ | onChange | `(value: string[]) => void` | - | Selection change handler. |
159
+ | placeholder | `string` | - | Placeholder when nothing selected. |
160
+ | size | `"xs" \| "sm" \| "md" \| "lg" \| "xl"` | `"md"` | Component size. |
161
+ | label | `string` | - | Label above select. |
162
+ | disabled | `boolean` | `false` | Disabled state. |
163
+
164
+ ## Display Behavior
165
+
166
+ - When no items selected: Shows placeholder
167
+ - When items selected: Shows "N selected" text
168
+ - Dropdown shows checkboxes for each option
169
+ - Checked items are visually indicated
170
+
171
+ ## Accessibility
172
+
173
+ - Uses checkbox pattern for selections
174
+ - Dropdown is keyboard navigable
175
+ - Selection state announced to screen readers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-multi-select",
3
- "version": "0.99.0",
3
+ "version": "0.100.0",
4
4
  "main": "./web/index.js",
5
5
  "module": "./web/index.mjs",
6
6
  "types": "./web/index.d.ts",
@@ -10,10 +10,10 @@
10
10
  "build:native": "PLATFORM=native tsup"
11
11
  },
12
12
  "dependencies": {
13
- "@xsolla/xui-checkbox": "0.99.0",
14
- "@xsolla/xui-core": "0.99.0",
15
- "@xsolla/xui-dropdown": "0.99.0",
16
- "@xsolla/xui-primitives-core": "0.99.0"
13
+ "@xsolla/xui-checkbox": "0.100.0",
14
+ "@xsolla/xui-core": "0.100.0",
15
+ "@xsolla/xui-dropdown": "0.100.0",
16
+ "@xsolla/xui-primitives-core": "0.100.0"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": ">=16.8.0",