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