@xsolla/xui-multi-select 0.140.0-pr246.1776914902 → 0.141.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 +169 -0
- package/native/index.js +13 -13
- package/native/index.js.map +1 -1
- package/native/index.mjs +13 -13
- package/native/index.mjs.map +1 -1
- package/package.json +5 -5
- package/web/index.js +18 -18
- package/web/index.js.map +1 -1
- package/web/index.mjs +18 -18
- package/web/index.mjs.map +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Multi Select
|
|
2
|
+
|
|
3
|
+
A cross-platform React multi-select component that allows users to select multiple options from a dropdown list with checkboxes.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @xsolla/xui-multi-select
|
|
9
|
+
# or
|
|
10
|
+
yarn add @xsolla/xui-multi-select
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Demo
|
|
14
|
+
|
|
15
|
+
### Basic Multi Select
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
import { MultiSelect } from '@xsolla/xui-multi-select';
|
|
20
|
+
|
|
21
|
+
export default function BasicMultiSelect() {
|
|
22
|
+
const [selected, setSelected] = React.useState<string[]>([]);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<MultiSelect
|
|
26
|
+
options={['React', 'Vue', 'Angular', 'Svelte']}
|
|
27
|
+
value={selected}
|
|
28
|
+
onChange={setSelected}
|
|
29
|
+
placeholder="Select frameworks"
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### With Label
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import * as React from 'react';
|
|
39
|
+
import { MultiSelect } from '@xsolla/xui-multi-select';
|
|
40
|
+
|
|
41
|
+
export default function LabeledMultiSelect() {
|
|
42
|
+
const [selected, setSelected] = React.useState<string[]>(['Marketing']);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<MultiSelect
|
|
46
|
+
label="Departments"
|
|
47
|
+
options={['Engineering', 'Marketing', 'Sales', 'Design', 'HR']}
|
|
48
|
+
value={selected}
|
|
49
|
+
onChange={setSelected}
|
|
50
|
+
placeholder="Select departments"
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Multi Select Sizes
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import * as React from 'react';
|
|
60
|
+
import { MultiSelect } from '@xsolla/xui-multi-select';
|
|
61
|
+
|
|
62
|
+
export default function MultiSelectSizes() {
|
|
63
|
+
const options = ['Option 1', 'Option 2', 'Option 3'];
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
67
|
+
<MultiSelect options={options} size="xs" placeholder="Extra Small" />
|
|
68
|
+
<MultiSelect options={options} size="sm" placeholder="Small" />
|
|
69
|
+
<MultiSelect options={options} size="md" placeholder="Medium" />
|
|
70
|
+
<MultiSelect options={options} size="lg" placeholder="Large" />
|
|
71
|
+
<MultiSelect options={options} size="xl" placeholder="Extra Large" />
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Anatomy
|
|
78
|
+
|
|
79
|
+
```jsx
|
|
80
|
+
import { MultiSelect } from '@xsolla/xui-multi-select';
|
|
81
|
+
|
|
82
|
+
<MultiSelect
|
|
83
|
+
options={['a', 'b', 'c']} // Available options
|
|
84
|
+
value={selectedArray} // Currently selected values
|
|
85
|
+
onChange={setSelected} // Selection change handler
|
|
86
|
+
placeholder="Select..." // Placeholder text
|
|
87
|
+
label="Label" // Label above select
|
|
88
|
+
size="md" // Size variant
|
|
89
|
+
disabled={false} // Disabled state
|
|
90
|
+
/>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Examples
|
|
94
|
+
|
|
95
|
+
### Form Integration
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import * as React from 'react';
|
|
99
|
+
import { MultiSelect } from '@xsolla/xui-multi-select';
|
|
100
|
+
import { Button } from '@xsolla/xui-button';
|
|
101
|
+
|
|
102
|
+
export default function FormMultiSelect() {
|
|
103
|
+
const [skills, setSkills] = React.useState<string[]>([]);
|
|
104
|
+
|
|
105
|
+
const handleSubmit = () => {
|
|
106
|
+
console.log('Selected skills:', skills);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 16, width: 300 }}>
|
|
111
|
+
<MultiSelect
|
|
112
|
+
label="Skills"
|
|
113
|
+
options={['JavaScript', 'TypeScript', 'Python', 'Go', 'Rust', 'Java']}
|
|
114
|
+
value={skills}
|
|
115
|
+
onChange={setSkills}
|
|
116
|
+
placeholder="Select your skills"
|
|
117
|
+
/>
|
|
118
|
+
<Button onPress={handleSubmit}>Submit</Button>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Disabled State
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
import * as React from 'react';
|
|
128
|
+
import { MultiSelect } from '@xsolla/xui-multi-select';
|
|
129
|
+
|
|
130
|
+
export default function DisabledMultiSelect() {
|
|
131
|
+
return (
|
|
132
|
+
<MultiSelect
|
|
133
|
+
options={['Option 1', 'Option 2', 'Option 3']}
|
|
134
|
+
value={['Option 1']}
|
|
135
|
+
disabled
|
|
136
|
+
placeholder="Disabled select"
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## API Reference
|
|
143
|
+
|
|
144
|
+
### MultiSelect
|
|
145
|
+
|
|
146
|
+
**MultiSelect Props:**
|
|
147
|
+
|
|
148
|
+
| Prop | Type | Default | Description |
|
|
149
|
+
| :--- | :--- | :------ | :---------- |
|
|
150
|
+
| options | `string[]` | - | **Required.** Available options. |
|
|
151
|
+
| value | `string[]` | `[]` | Currently selected values. |
|
|
152
|
+
| onChange | `(value: string[]) => void` | - | Selection change handler. |
|
|
153
|
+
| placeholder | `string` | - | Placeholder when nothing selected. |
|
|
154
|
+
| size | `"xs" \| "sm" \| "md" \| "lg" \| "xl"` | `"md"` | Component size. |
|
|
155
|
+
| label | `string` | - | Label above select. |
|
|
156
|
+
| disabled | `boolean` | `false` | Disabled state. |
|
|
157
|
+
|
|
158
|
+
## Display Behavior
|
|
159
|
+
|
|
160
|
+
- When no items selected: Shows placeholder
|
|
161
|
+
- When items selected: Shows "N selected" text
|
|
162
|
+
- Dropdown shows checkboxes for each option
|
|
163
|
+
- Checked items are visually indicated
|
|
164
|
+
|
|
165
|
+
## Accessibility
|
|
166
|
+
|
|
167
|
+
- Uses checkbox pattern for selections
|
|
168
|
+
- Dropdown is keyboard navigable
|
|
169
|
+
- Selection state announced to screen readers
|
package/native/index.js
CHANGED
|
@@ -37,7 +37,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
37
37
|
// src/MultiSelect.tsx
|
|
38
38
|
var import_react10 = require("react");
|
|
39
39
|
|
|
40
|
-
//
|
|
40
|
+
// ../primitives-native/src/Box.tsx
|
|
41
41
|
var import_react_native = require("react-native");
|
|
42
42
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
43
|
var Box = ({
|
|
@@ -211,7 +211,7 @@ var Box = ({
|
|
|
211
211
|
);
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
-
//
|
|
214
|
+
// ../primitives-native/src/Text.tsx
|
|
215
215
|
var import_react_native2 = require("react-native");
|
|
216
216
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
217
217
|
var roleMap = {
|
|
@@ -274,7 +274,7 @@ var Text = ({
|
|
|
274
274
|
);
|
|
275
275
|
};
|
|
276
276
|
|
|
277
|
-
//
|
|
277
|
+
// ../primitives-native/src/Icon.tsx
|
|
278
278
|
var import_react = __toESM(require("react"));
|
|
279
279
|
var import_react_native3 = require("react-native");
|
|
280
280
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -305,7 +305,7 @@ var import_xui_core4 = require("@xsolla/xui-core");
|
|
|
305
305
|
var import_react8 = require("react");
|
|
306
306
|
var import_xui_core3 = require("@xsolla/xui-core");
|
|
307
307
|
|
|
308
|
-
//
|
|
308
|
+
// ../icons-base/dist/web/index.mjs
|
|
309
309
|
var import_styled_components = __toESM(require("styled-components"), 1);
|
|
310
310
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
311
311
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -1097,24 +1097,24 @@ var import_styled_components5 = __toESM(require("styled-components"), 1);
|
|
|
1097
1097
|
var import_jsx_runtime729 = require("react/jsx-runtime");
|
|
1098
1098
|
var import_xui_core = require("@xsolla/xui-core");
|
|
1099
1099
|
|
|
1100
|
-
//
|
|
1100
|
+
// ../icons/dist/web/index.mjs
|
|
1101
1101
|
var import_react4 = __toESM(require("react"), 1);
|
|
1102
1102
|
var import_styled_components2 = __toESM(require("styled-components"), 1);
|
|
1103
1103
|
var import_jsx_runtime725 = require("react/jsx-runtime");
|
|
1104
1104
|
|
|
1105
|
-
//
|
|
1105
|
+
// ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
|
|
1106
1106
|
var import_react3 = require("react");
|
|
1107
1107
|
|
|
1108
|
-
//
|
|
1108
|
+
// ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
|
|
1109
1109
|
var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1110
1110
|
var mergeClasses = (...classes) => classes.filter((className, index3, array) => {
|
|
1111
1111
|
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index3;
|
|
1112
1112
|
}).join(" ").trim();
|
|
1113
1113
|
|
|
1114
|
-
//
|
|
1114
|
+
// ../../node_modules/lucide-react/dist/esm/Icon.js
|
|
1115
1115
|
var import_react2 = require("react");
|
|
1116
1116
|
|
|
1117
|
-
//
|
|
1117
|
+
// ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
|
|
1118
1118
|
var defaultAttributes = {
|
|
1119
1119
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1120
1120
|
width: 24,
|
|
@@ -1127,7 +1127,7 @@ var defaultAttributes = {
|
|
|
1127
1127
|
strokeLinejoin: "round"
|
|
1128
1128
|
};
|
|
1129
1129
|
|
|
1130
|
-
//
|
|
1130
|
+
// ../../node_modules/lucide-react/dist/esm/Icon.js
|
|
1131
1131
|
var Icon2 = (0, import_react2.forwardRef)(
|
|
1132
1132
|
({
|
|
1133
1133
|
color = "currentColor",
|
|
@@ -1159,7 +1159,7 @@ var Icon2 = (0, import_react2.forwardRef)(
|
|
|
1159
1159
|
}
|
|
1160
1160
|
);
|
|
1161
1161
|
|
|
1162
|
-
//
|
|
1162
|
+
// ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
|
|
1163
1163
|
var createLucideIcon = (iconName, iconNode) => {
|
|
1164
1164
|
const Component = (0, import_react3.forwardRef)(
|
|
1165
1165
|
({ className, ...props }, ref) => (0, import_react3.createElement)(Icon2, {
|
|
@@ -1173,13 +1173,13 @@ var createLucideIcon = (iconName, iconNode) => {
|
|
|
1173
1173
|
return Component;
|
|
1174
1174
|
};
|
|
1175
1175
|
|
|
1176
|
-
//
|
|
1176
|
+
// ../../node_modules/lucide-react/dist/esm/icons/x.js
|
|
1177
1177
|
var X = createLucideIcon("X", [
|
|
1178
1178
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
1179
1179
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
1180
1180
|
]);
|
|
1181
1181
|
|
|
1182
|
-
//
|
|
1182
|
+
// ../icons/dist/web/index.mjs
|
|
1183
1183
|
var import_jsx_runtime726 = require("react/jsx-runtime");
|
|
1184
1184
|
function memoize(fn) {
|
|
1185
1185
|
var cache = {};
|