@xsolla/xui-field-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.
Files changed (2) hide show
  1. package/README.md +197 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,197 @@
1
+ # Field Group
2
+
3
+ A cross-platform React wrapper component that adds consistent labeling, required indicators, helper text, and spacing to form fields.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @xsolla/xui-field-group
9
+ # or
10
+ yarn add @xsolla/xui-field-group
11
+ ```
12
+
13
+ ## Demo
14
+
15
+ ### Basic Field Group
16
+
17
+ ```tsx
18
+ import * as React from 'react';
19
+ import { FieldGroup } from '@xsolla/xui-field-group';
20
+ import { Input } from '@xsolla/xui-input';
21
+
22
+ export default function BasicFieldGroup() {
23
+ return (
24
+ <FieldGroup label="Username">
25
+ <Input placeholder="Enter username" />
26
+ </FieldGroup>
27
+ );
28
+ }
29
+ ```
30
+
31
+ ### Required Field
32
+
33
+ ```tsx
34
+ import * as React from 'react';
35
+ import { FieldGroup } from '@xsolla/xui-field-group';
36
+ import { Input } from '@xsolla/xui-input';
37
+
38
+ export default function RequiredField() {
39
+ return (
40
+ <FieldGroup label="Email" required>
41
+ <Input type="email" placeholder="Enter email" />
42
+ </FieldGroup>
43
+ );
44
+ }
45
+ ```
46
+
47
+ ### With Helper Text
48
+
49
+ ```tsx
50
+ import * as React from 'react';
51
+ import { FieldGroup } from '@xsolla/xui-field-group';
52
+ import { Input } from '@xsolla/xui-input';
53
+
54
+ export default function HelperField() {
55
+ return (
56
+ <FieldGroup
57
+ label="Password"
58
+ helper="Must be at least 8 characters"
59
+ >
60
+ <Input type="password" placeholder="Enter password" />
61
+ </FieldGroup>
62
+ );
63
+ }
64
+ ```
65
+
66
+ ### With Icon
67
+
68
+ ```tsx
69
+ import * as React from 'react';
70
+ import { FieldGroup } from '@xsolla/xui-field-group';
71
+ import { Input } from '@xsolla/xui-input';
72
+ import { Info } from '@xsolla/xui-icons-base';
73
+
74
+ export default function IconField() {
75
+ return (
76
+ <FieldGroup
77
+ label="API Key"
78
+ icon={<Info />}
79
+ >
80
+ <Input placeholder="Enter API key" />
81
+ </FieldGroup>
82
+ );
83
+ }
84
+ ```
85
+
86
+ ## Anatomy
87
+
88
+ ```jsx
89
+ import { FieldGroup } from '@xsolla/xui-field-group';
90
+
91
+ <FieldGroup
92
+ label="Field Label" // Label text
93
+ required={false} // Show required asterisk
94
+ helper="Helper text" // Helper text below field
95
+ icon={<Icon />} // Icon next to label
96
+ size="md" // Size variant
97
+ marginBottom={16} // Bottom margin (spacing)
98
+ htmlFor="field-id" // Associate with form field
99
+ >
100
+ <FormField /> // Form control component
101
+ </FieldGroup>
102
+ ```
103
+
104
+ ## Examples
105
+
106
+ ### Form with Field Groups
107
+
108
+ ```tsx
109
+ import * as React from 'react';
110
+ import { FieldGroup } from '@xsolla/xui-field-group';
111
+ import { Input } from '@xsolla/xui-input';
112
+ import { Select } from '@xsolla/xui-select';
113
+ import { Textarea } from '@xsolla/xui-textarea';
114
+ import { Button } from '@xsolla/xui-button';
115
+
116
+ export default function CompleteForm() {
117
+ return (
118
+ <div style={{ maxWidth: 400 }}>
119
+ <FieldGroup label="Full Name" required>
120
+ <Input placeholder="John Doe" />
121
+ </FieldGroup>
122
+ <FieldGroup label="Email" required helper="We'll never share your email">
123
+ <Input type="email" placeholder="john@example.com" />
124
+ </FieldGroup>
125
+ <FieldGroup label="Country">
126
+ <Select
127
+ options={['United States', 'Canada', 'United Kingdom']}
128
+ placeholder="Select country"
129
+ />
130
+ </FieldGroup>
131
+ <FieldGroup label="Bio" helper="Max 500 characters">
132
+ <Textarea placeholder="Tell us about yourself" />
133
+ </FieldGroup>
134
+ <FieldGroup marginBottom={0}>
135
+ <Button>Submit</Button>
136
+ </FieldGroup>
137
+ </div>
138
+ );
139
+ }
140
+ ```
141
+
142
+ ### Field Group Sizes
143
+
144
+ ```tsx
145
+ import * as React from 'react';
146
+ import { FieldGroup } from '@xsolla/xui-field-group';
147
+ import { Input } from '@xsolla/xui-input';
148
+
149
+ export default function FieldGroupSizes() {
150
+ return (
151
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
152
+ <FieldGroup size="sm" label="Small Field" required helper="Small helper">
153
+ <Input size="sm" placeholder="Small input" />
154
+ </FieldGroup>
155
+ <FieldGroup size="md" label="Medium Field" required helper="Medium helper">
156
+ <Input size="md" placeholder="Medium input" />
157
+ </FieldGroup>
158
+ <FieldGroup size="lg" label="Large Field" required helper="Large helper">
159
+ <Input size="lg" placeholder="Large input" />
160
+ </FieldGroup>
161
+ </div>
162
+ );
163
+ }
164
+ ```
165
+
166
+ ## API Reference
167
+
168
+ ### FieldGroup
169
+
170
+ **FieldGroup Props:**
171
+
172
+ | Prop | Type | Default | Description |
173
+ | :--- | :--- | :------ | :---------- |
174
+ | children | `ReactNode` | - | Form field component. |
175
+ | label | `string` | - | Label text. |
176
+ | required | `boolean` | `false` | Show required asterisk (*). |
177
+ | helper | `string` | - | Helper text below field. |
178
+ | icon | `ReactElement` | - | Icon next to label. |
179
+ | size | `"sm" \| "md" \| "lg"` | `"md"` | Size variant. |
180
+ | marginBottom | `number` | Based on size | Bottom margin for spacing. |
181
+ | htmlFor | `string` | - | Associate label with field by ID. |
182
+ | data-testid | `string` | - | Test identifier. |
183
+
184
+ ## Size Specifications
185
+
186
+ | Size | Label Font | Label Line Height | Helper Font | Margin Bottom |
187
+ | :--- | :--------- | :---------------- | :---------- | :------------ |
188
+ | sm | 10px | 16px | 12px | 8px |
189
+ | md | 12px | 20px | 12px | 16px |
190
+ | lg | 14px | 24px | 12px | 24px |
191
+
192
+ ## Behavior
193
+
194
+ - Required asterisk (*) appears before label in red
195
+ - Icon appears after label with appropriate spacing
196
+ - Helper text appears below the field content
197
+ - Consistent vertical rhythm with configurable margins
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-field-group",
3
- "version": "0.148.0",
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.0",
17
- "@xsolla/xui-primitives-core": "0.148.0"
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",