@xsolla/xui-input-time 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 +164 -0
  2. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # Input Time
2
+
3
+ A structured time input component for entering hours, minutes, and optionally seconds. Supports 12h and 24h formats with an optional AM/PM toggle. Cross-platform (web and React Native).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @xsolla/xui-input-time
9
+ # or
10
+ yarn add @xsolla/xui-input-time
11
+ ```
12
+
13
+ ## Demo
14
+
15
+ ### Basic Usage
16
+
17
+ ```tsx
18
+ import * as React from 'react';
19
+ import { InputTime } from '@xsolla/xui-input-time';
20
+ import type { TimeValue } from '@xsolla/xui-input-time';
21
+
22
+ export default function BasicTime() {
23
+ const [value, setValue] = React.useState<TimeValue | null>(null);
24
+
25
+ return <InputTime value={value} onChange={setValue} />;
26
+ }
27
+ ```
28
+
29
+ ### With Seconds
30
+
31
+ ```tsx
32
+ import * as React from 'react';
33
+ import { InputTime } from '@xsolla/xui-input-time';
34
+ import type { TimeValue } from '@xsolla/xui-input-time';
35
+
36
+ export default function WithSeconds() {
37
+ const [value, setValue] = React.useState<TimeValue | null>(null);
38
+
39
+ return <InputTime value={value} onChange={setValue} showSeconds />;
40
+ }
41
+ ```
42
+
43
+ ### 12-Hour Format with AM/PM
44
+
45
+ ```tsx
46
+ import * as React from 'react';
47
+ import { InputTime } from '@xsolla/xui-input-time';
48
+ import type { TimeValue } from '@xsolla/xui-input-time';
49
+
50
+ export default function TwelveHour() {
51
+ const [value, setValue] = React.useState<TimeValue | null>({
52
+ hours: 3,
53
+ minutes: 30,
54
+ period: 'pm',
55
+ });
56
+
57
+ return (
58
+ <InputTime
59
+ value={value}
60
+ onChange={setValue}
61
+ hourCycle={12}
62
+ showPeriod
63
+ />
64
+ );
65
+ }
66
+ ```
67
+
68
+ ### Custom Icon
69
+
70
+ A Clock icon is displayed by default. Pass a custom icon via the `icon` prop, or set `icon={null}` to hide it.
71
+
72
+ ```tsx
73
+ import * as React from 'react';
74
+ import { InputTime } from '@xsolla/xui-input-time';
75
+ import { Clock } from '@xsolla/xui-icons-base';
76
+ import type { TimeValue } from '@xsolla/xui-input-time';
77
+
78
+ export default function CustomIcon() {
79
+ const [value, setValue] = React.useState<TimeValue | null>(null);
80
+
81
+ return (
82
+ <InputTime
83
+ value={value}
84
+ onChange={setValue}
85
+ icon={<Clock variant="solid" />}
86
+ />
87
+ );
88
+ }
89
+ ```
90
+
91
+ ### Different Sizes
92
+
93
+ ```tsx
94
+ import * as React from 'react';
95
+ import { InputTime } from '@xsolla/xui-input-time';
96
+
97
+ export default function Sizes() {
98
+ return (
99
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
100
+ <InputTime size="xl" />
101
+ <InputTime size="lg" />
102
+ <InputTime size="md" />
103
+ <InputTime size="sm" />
104
+ <InputTime size="xs" />
105
+ </div>
106
+ );
107
+ }
108
+ ```
109
+
110
+ ## API Reference
111
+
112
+ ### InputTime
113
+
114
+ **InputTimeProps:**
115
+
116
+ | Prop | Type | Default | Description |
117
+ | :--- | :--- | :------ | :---------- |
118
+ | value | `TimeValue \| null` | - | Current time value. |
119
+ | onChange | `(value: TimeValue \| null) => void` | - | Time change callback. |
120
+ | showSeconds | `boolean` | `false` | Show seconds segment (HH:MM:SS). |
121
+ | showPeriod | `boolean` | `false` | Show AM/PM toggle. |
122
+ | hourCycle | `12 \| 24` | `24` | Hour format (12h or 24h). |
123
+ | icon | `ReactNode` | `<Clock />` | Icon displayed on the left. Set to `null` to hide. |
124
+ | size | `"xl" \| "lg" \| "md" \| "sm" \| "xs"` | `"md"` | Input size variant. |
125
+ | disabled | `boolean` | `false` | Disable the input. |
126
+ | error | `string` | - | Error message (shows error state). |
127
+ | aria-label | `string` | `"Time input"` | Accessible label. |
128
+ | testID | `string` | - | Test identifier. |
129
+
130
+ ### TimeValue
131
+
132
+ | Property | Type | Description |
133
+ | :--- | :--- | :---------- |
134
+ | hours | `number` | Hours (0-23 for 24h, 1-12 for 12h). |
135
+ | minutes | `number` | Minutes (0-59). |
136
+ | seconds | `number` (optional) | Seconds (0-59). Present when `showSeconds` is true. |
137
+ | period | `"am" \| "pm"` (optional) | Time period. Present when `showPeriod` is true. |
138
+
139
+ ## Keyboard Navigation
140
+
141
+ | Key | Action |
142
+ | :--- | :--- |
143
+ | 0-9 | Type digit. Auto-advances to next segment after 2 digits. |
144
+ | Tab | Move to next segment. |
145
+ | Shift+Tab | Move to previous segment. |
146
+ | ArrowUp | Increment focused segment by 1. |
147
+ | ArrowDown | Decrement focused segment by 1. |
148
+ | ArrowRight | Move to next segment. |
149
+ | ArrowLeft | Move to previous segment. |
150
+ | Backspace | Clear segment and move back. |
151
+
152
+ ## Validation
153
+
154
+ Values are clamped to valid ranges automatically:
155
+ - Hours: 0-23 (24h) or 1-12 (12h)
156
+ - Minutes: 0-59
157
+ - Seconds: 0-59
158
+
159
+ ## Accessibility
160
+
161
+ - Each segment has an `aria-label` ("Hours", "Minutes", "Seconds")
162
+ - Error messages use `role="alert"`
163
+ - AM/PM toggle is a button with descriptive `aria-label`
164
+ - Segments are grouped with `role="group"`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-input-time",
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,9 +13,9 @@
13
13
  "test:coverage": "vitest run --coverage"
14
14
  },
15
15
  "dependencies": {
16
- "@xsolla/xui-core": "0.148.0",
17
- "@xsolla/xui-icons-base": "0.148.0",
18
- "@xsolla/xui-primitives-core": "0.148.0"
16
+ "@xsolla/xui-core": "0.148.1",
17
+ "@xsolla/xui-icons-base": "0.148.1",
18
+ "@xsolla/xui-primitives-core": "0.148.1"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "react": ">=16.8.0",