@xsolla/xui-input-copy 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 +166 -19
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,39 +1,186 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Input Copy
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A cross-platform React input component that includes a copy-to-clipboard button. Supports visibility toggle for sensitive data like API keys or tokens.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
+
npm install @xsolla/xui-input-copy
|
|
9
|
+
# or
|
|
8
10
|
yarn add @xsolla/xui-input-copy
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## Demo
|
|
14
|
+
|
|
15
|
+
### Basic Input Copy
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
import { InputCopy } from '@xsolla/xui-input-copy';
|
|
20
|
+
|
|
21
|
+
export default function BasicInputCopy() {
|
|
22
|
+
return (
|
|
23
|
+
<InputCopy
|
|
24
|
+
value="sk_live_abc123xyz"
|
|
25
|
+
onCopy={(val) => console.log('Copied:', val)}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### With Label
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import * as React from 'react';
|
|
35
|
+
import { InputCopy } from '@xsolla/xui-input-copy';
|
|
36
|
+
|
|
37
|
+
export default function LabeledInputCopy() {
|
|
38
|
+
return (
|
|
39
|
+
<InputCopy
|
|
40
|
+
label="API Key"
|
|
41
|
+
value="sk_live_abc123xyz789"
|
|
42
|
+
onCopy={(val) => console.log('Copied:', val)}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Secure Text Entry
|
|
12
49
|
|
|
13
50
|
```tsx
|
|
51
|
+
import * as React from 'react';
|
|
52
|
+
import { InputCopy } from '@xsolla/xui-input-copy';
|
|
53
|
+
|
|
54
|
+
export default function SecureInputCopy() {
|
|
55
|
+
return (
|
|
56
|
+
<InputCopy
|
|
57
|
+
label="Secret Token"
|
|
58
|
+
value="super_secret_token_12345"
|
|
59
|
+
secureTextEntry={true}
|
|
60
|
+
onCopy={(val) => console.log('Copied:', val)}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Editable Input Copy
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import * as React from 'react';
|
|
70
|
+
import { InputCopy } from '@xsolla/xui-input-copy';
|
|
71
|
+
|
|
72
|
+
export default function EditableInputCopy() {
|
|
73
|
+
const [value, setValue] = React.useState('editable-value');
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<InputCopy
|
|
77
|
+
label="Editable Field"
|
|
78
|
+
value={value}
|
|
79
|
+
onChange={(e) => setValue(e.target.value)}
|
|
80
|
+
onCopy={(val) => console.log('Copied:', val)}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Anatomy
|
|
87
|
+
|
|
88
|
+
```jsx
|
|
14
89
|
import { InputCopy } from '@xsolla/xui-input-copy';
|
|
15
90
|
|
|
16
91
|
<InputCopy
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
onCopy={
|
|
92
|
+
value="text to copy" // Value to display and copy
|
|
93
|
+
onChange={handleChange} // Change event handler
|
|
94
|
+
onCopy={handleCopy} // Callback after copying
|
|
95
|
+
secureTextEntry={false} // Hide text like password
|
|
96
|
+
initialVisible={false} // Initial visibility (when secure)
|
|
97
|
+
size="md" // Size variant
|
|
98
|
+
label="Label" // Label above input
|
|
99
|
+
disabled={false} // Disabled state
|
|
100
|
+
error={false} // Error state
|
|
101
|
+
errorMessage="Error" // Error message text
|
|
20
102
|
/>
|
|
21
103
|
```
|
|
22
104
|
|
|
23
|
-
##
|
|
105
|
+
## Examples
|
|
106
|
+
|
|
107
|
+
### Input Copy Sizes
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
import * as React from 'react';
|
|
111
|
+
import { InputCopy } from '@xsolla/xui-input-copy';
|
|
112
|
+
|
|
113
|
+
export default function InputCopySizes() {
|
|
114
|
+
return (
|
|
115
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
116
|
+
<InputCopy size="xs" value="Extra Small" />
|
|
117
|
+
<InputCopy size="sm" value="Small" />
|
|
118
|
+
<InputCopy size="md" value="Medium" />
|
|
119
|
+
<InputCopy size="lg" value="Large" />
|
|
120
|
+
<InputCopy size="xl" value="Extra Large" />
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Error State
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import * as React from 'react';
|
|
130
|
+
import { InputCopy } from '@xsolla/xui-input-copy';
|
|
131
|
+
|
|
132
|
+
export default function ErrorInputCopy() {
|
|
133
|
+
return (
|
|
134
|
+
<InputCopy
|
|
135
|
+
label="API Key"
|
|
136
|
+
value="invalid-key"
|
|
137
|
+
error={true}
|
|
138
|
+
errorMessage="Invalid API key format"
|
|
139
|
+
/>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## API Reference
|
|
24
145
|
|
|
25
146
|
### InputCopy
|
|
26
147
|
|
|
148
|
+
**InputCopy Props:**
|
|
149
|
+
|
|
27
150
|
| Prop | Type | Default | Description |
|
|
28
|
-
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
151
|
+
| :--- | :--- | :------ | :---------- |
|
|
152
|
+
| value | `string` | `""` | Value to display and copy. |
|
|
153
|
+
| onChange | `(e: ChangeEvent) => void` | - | Change event handler. |
|
|
154
|
+
| onChangeText | `(text: string) => void` | - | Text change handler. |
|
|
155
|
+
| onCopy | `(value: string) => void` | - | Callback when value is copied. |
|
|
156
|
+
| secureTextEntry | `boolean` | `false` | Hide text like a password field. |
|
|
157
|
+
| initialVisible | `boolean` | `false` | Initial visibility when secureTextEntry is true. |
|
|
158
|
+
| size | `"xl" \| "lg" \| "md" \| "sm" \| "xs"` | `"md"` | Component size. |
|
|
159
|
+
| label | `string` | - | Label above input. |
|
|
160
|
+
| disabled | `boolean` | `false` | Disabled state. |
|
|
161
|
+
| error | `boolean` | `false` | Error state. |
|
|
162
|
+
| errorMessage | `string` | - | Error message text. |
|
|
163
|
+
| placeholder | `string` | - | Placeholder text. |
|
|
164
|
+
| testID | `string` | - | Test identifier. |
|
|
165
|
+
|
|
166
|
+
## Behavior
|
|
167
|
+
|
|
168
|
+
- **Copy Button**: Shows checkmark icon briefly (2 seconds) after successful copy
|
|
169
|
+
- **Visibility Toggle**: When `secureTextEntry` is enabled, the eye icon reflects the current state:
|
|
170
|
+
- Open eye (👁️) = Text is currently **visible** (type="text")
|
|
171
|
+
- Closed eye (🙈) = Text is currently **hidden** (type="password")
|
|
172
|
+
- This follows modern design system conventions (Material, Apple, Atlassian, Polaris)
|
|
173
|
+
- Uses browser Clipboard API for copying
|
|
174
|
+
- Error state shows red border and error message
|
|
175
|
+
|
|
176
|
+
## Accessibility
|
|
177
|
+
|
|
178
|
+
- Copy button has `aria-label` that changes from "Copy to clipboard" to "Copied" after action
|
|
179
|
+
- Visibility toggle button has appropriate `aria-label`:
|
|
180
|
+
- "Show text" when text is hidden
|
|
181
|
+
- "Hide text" when text is visible
|
|
182
|
+
- Toggle button uses `aria-pressed` to indicate current visibility state
|
|
183
|
+
- Error messages linked via `aria-describedby` for screen reader context
|
|
184
|
+
- Labels properly linked via `aria-labelledby` when provided
|
|
185
|
+
- Input has `aria-invalid` when in error state
|
|
186
|
+
- Error messages use `role="alert"` for immediate announcement
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-input-copy",
|
|
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",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"test:coverage": "vitest run --coverage"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@xsolla/xui-button": "0.
|
|
17
|
-
"@xsolla/xui-core": "0.
|
|
18
|
-
"@xsolla/xui-icons": "0.
|
|
19
|
-
"@xsolla/xui-input": "0.
|
|
20
|
-
"@xsolla/xui-primitives-core": "0.
|
|
16
|
+
"@xsolla/xui-button": "0.101.0",
|
|
17
|
+
"@xsolla/xui-core": "0.101.0",
|
|
18
|
+
"@xsolla/xui-icons": "0.101.0",
|
|
19
|
+
"@xsolla/xui-input": "0.101.0",
|
|
20
|
+
"@xsolla/xui-primitives-core": "0.101.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": ">=16.8.0",
|