@reliability-design/web 1.4.2 → 1.4.3
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/CHANGELOG.md +27 -0
- package/dist/components/rel-autocomplete/README.md +3 -1
- package/dist/components/rel-autocomplete/rel-autocomplete.ts +24 -2
- package/dist/components/rel-button/rel-button.ts +2 -2
- package/dist/components/rel-radio/README.md +16 -1
- package/dist/components/rel-radio/rel-radio.ts +52 -1
- package/dist/components/rel-select/README.md +6 -0
- package/dist/components/rel-select/rel-select.ts +58 -7
- package/dist/components/rel-textfield/README.md +16 -0
- package/dist/components/rel-textfield/rel-textfield.ts +104 -6
- package/dist/components/rel-time-picker/README.md +199 -0
- package/dist/components/rel-time-picker/rel-time-picker.ts +994 -0
- package/dist/index.d.mts +187 -38
- package/dist/index.d.ts +187 -38
- package/dist/index.js +1195 -89
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1195 -90
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# rel-time-picker
|
|
2
|
+
|
|
3
|
+
A fully accessible time picker component built with Lit for the Reliability Design System. Features a trigger button with an hour/minute (and AM/PM) column popover. Selections are held in draft state until Apply is clicked, mirroring the rel-range-picker interaction model.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Trigger button with time-column popover (Hour / Min / AM-PM)
|
|
8
|
+
- 12-hour and 24-hour display formats
|
|
9
|
+
- Configurable minute intervals (1, 5, 10, 15, 30, …)
|
|
10
|
+
- Draft state with Now / Cancel / Apply footer
|
|
11
|
+
- Min/max time constraints
|
|
12
|
+
- Optional clear button
|
|
13
|
+
- Label, placeholder, helper text and error states
|
|
14
|
+
- Standardized input API (mirrors rel-textfield / rel-date-picker)
|
|
15
|
+
- Keyboard navigation and full ARIA support
|
|
16
|
+
- Token-driven styling with `::part` hooks
|
|
17
|
+
|
|
18
|
+
## Value format
|
|
19
|
+
|
|
20
|
+
The committed `value` is **always 24-hour `"HH:mm"`** (e.g. `"09:30"`, `"17:05"`) regardless of the display `format`, so consumers get a consistent machine-readable string.
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Basic
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<rel-time-picker></rel-time-picker>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### With Value
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<rel-time-picker value="09:30"></rel-time-picker>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### With Label
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<rel-time-picker label="Start time" placeholder="Select time"></rel-time-picker>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 24-hour format
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<rel-time-picker format="24h" value="17:05"></rel-time-picker>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Minute intervals
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<rel-time-picker minute-step="15"></rel-time-picker>
|
|
52
|
+
<rel-time-picker minute-step="30"></rel-time-picker>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### With Min/Max
|
|
56
|
+
|
|
57
|
+
```html
|
|
58
|
+
<rel-time-picker
|
|
59
|
+
min-time="09:00"
|
|
60
|
+
max-time="17:30"
|
|
61
|
+
placeholder="Business hours only"
|
|
62
|
+
></rel-time-picker>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Clearable
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<rel-time-picker value="09:30" clearable></rel-time-picker>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### States
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<rel-time-picker value="09:30" disabled></rel-time-picker>
|
|
75
|
+
<rel-time-picker value="09:30" readonly></rel-time-picker>
|
|
76
|
+
<rel-time-picker error error-message="Select a valid time"></rel-time-picker>
|
|
77
|
+
<rel-time-picker helper-text="Local timezone"></rel-time-picker>
|
|
78
|
+
<rel-time-picker label="Start time" required></rel-time-picker>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Sizes / layout
|
|
82
|
+
|
|
83
|
+
```html
|
|
84
|
+
<rel-time-picker size="small"></rel-time-picker>
|
|
85
|
+
<rel-time-picker size="large"></rel-time-picker>
|
|
86
|
+
<rel-time-picker fullWidth></rel-time-picker>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Form usage
|
|
90
|
+
|
|
91
|
+
```html
|
|
92
|
+
<form>
|
|
93
|
+
<rel-time-picker name="startTime" label="Start time" required></rel-time-picker>
|
|
94
|
+
</form>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The value is mirrored onto a hidden `<input name="...">` so native form submission works.
|
|
98
|
+
|
|
99
|
+
### Programmatic Control (JavaScript)
|
|
100
|
+
|
|
101
|
+
```javascript
|
|
102
|
+
const picker = document.querySelector('rel-time-picker');
|
|
103
|
+
|
|
104
|
+
// Set value (always 24h HH:mm)
|
|
105
|
+
picker.value = '14:30';
|
|
106
|
+
|
|
107
|
+
// Open programmatically
|
|
108
|
+
picker.open = true;
|
|
109
|
+
|
|
110
|
+
// Listen to changes (fired on Apply, and on clear with value: null)
|
|
111
|
+
picker.addEventListener('rel-change', (e) => {
|
|
112
|
+
console.log('Selected time:', e.detail.value); // "14:30" | null
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
picker.addEventListener('rel-open-change', (e) => {
|
|
116
|
+
console.log('Open:', e.detail.open);
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Interaction model
|
|
121
|
+
|
|
122
|
+
- Clicking a column entry updates the **draft** shown in the readout row; nothing is committed yet.
|
|
123
|
+
- **Apply** commits the draft, emits `rel-change` and closes.
|
|
124
|
+
- **Cancel**, `Escape` or an outside click discards the draft (same as rel-range-picker).
|
|
125
|
+
- **Now** sets the draft to the current time, snapped to `minute-step` and clamped into `min-time`/`max-time`.
|
|
126
|
+
- Picking an hour with no minute selected defaults the minute to `00`.
|
|
127
|
+
|
|
128
|
+
## Keyboard
|
|
129
|
+
|
|
130
|
+
| Key | Context | Action |
|
|
131
|
+
| --- | --- | --- |
|
|
132
|
+
| `Enter` / `Space` / `ArrowDown` | Trigger | Open the popover |
|
|
133
|
+
| `ArrowUp` / `ArrowDown` | Column | Move and select the previous/next entry |
|
|
134
|
+
| `ArrowLeft` / `ArrowRight` | Column | Jump between Hour / Min / AM-PM columns |
|
|
135
|
+
| `Home` / `End` | Column | First / last entry |
|
|
136
|
+
| `Enter` | Column | Select the entry and Apply |
|
|
137
|
+
| `Escape` | Anywhere | Discard draft and close |
|
|
138
|
+
|
|
139
|
+
## Properties
|
|
140
|
+
|
|
141
|
+
| Property | Attribute | Type | Default | Description |
|
|
142
|
+
| --- | --- | --- | --- | --- |
|
|
143
|
+
| `value` | `value` | `string \| null` | `null` | Committed time, 24h `"HH:mm"` |
|
|
144
|
+
| `placeholder` | `placeholder` | `string` | `"Select time"` | Trigger text when empty |
|
|
145
|
+
| `label` | `label` | `string \| null` | `null` | Field label |
|
|
146
|
+
| `format` | `format` | `"12h" \| "24h"` | `"12h"` | Display format (value stays `HH:mm`) |
|
|
147
|
+
| `minuteStep` | `minute-step` | `number` | `1` | Minute column granularity |
|
|
148
|
+
| `minTime` | `min-time` | `string \| null` | `null` | Earliest selectable time (inclusive) |
|
|
149
|
+
| `maxTime` | `max-time` | `string \| null` | `null` | Latest selectable time (inclusive) |
|
|
150
|
+
| `disabled` | `disabled` | `boolean` | `false` | Disables all interaction |
|
|
151
|
+
| `readonly` | `readonly` | `boolean` | `false` | Value shown, popover cannot open |
|
|
152
|
+
| `required` | `required` | `boolean` | `false` | Renders `*` and sets `aria-required` |
|
|
153
|
+
| `clearable` | `clearable` | `boolean` | `false` | Clear button when a value is set |
|
|
154
|
+
| `open` | `open` | `boolean` | `false` | Controls / reflects popover state |
|
|
155
|
+
| `error` | `error` | `boolean` | `false` | Error styling |
|
|
156
|
+
| `invalid` | `invalid` | `boolean` | `false` | Alias for `error` |
|
|
157
|
+
| `errorMessage` | `error-message` | `string` | — | Shown below when error/invalid |
|
|
158
|
+
| `helperText` | `helper-text` | `string` | — | Assistive text below the field |
|
|
159
|
+
| `name` | `name` | `string` | — | Form field name (hidden input) |
|
|
160
|
+
| `size` | `size` | `"small" \| "medium" \| "large"` | `"medium"` | Trigger size |
|
|
161
|
+
| `fullWidth` | `fullWidth` | `boolean` | `false` | Fill the parent width |
|
|
162
|
+
| `variant` | `variant` | `"outlined"` | `"outlined"` | Visual style |
|
|
163
|
+
|
|
164
|
+
## Events
|
|
165
|
+
|
|
166
|
+
| Event | Detail | Description |
|
|
167
|
+
| --- | --- | --- |
|
|
168
|
+
| `rel-change` | `{ value: string \| null }` | Fired on Apply and on clear |
|
|
169
|
+
| `rel-open-change` | `{ open: boolean }` | Popover opened/closed |
|
|
170
|
+
| `rel-focus` | — | Trigger received focus |
|
|
171
|
+
| `rel-blur` | — | Trigger lost focus |
|
|
172
|
+
|
|
173
|
+
## CSS Parts
|
|
174
|
+
|
|
175
|
+
| Part | Element |
|
|
176
|
+
| --- | --- |
|
|
177
|
+
| `base` | Outer wrapper |
|
|
178
|
+
| `label` | Field label |
|
|
179
|
+
| `trigger` | Trigger button |
|
|
180
|
+
| `value` | Trigger value/placeholder text |
|
|
181
|
+
| `icon` | Trailing clock icon |
|
|
182
|
+
| `panel` | Popover panel |
|
|
183
|
+
| `option` | Hour/minute/period entries |
|
|
184
|
+
| `footer` | Now / Cancel / Apply row |
|
|
185
|
+
| `helper` | Helper / error text |
|
|
186
|
+
|
|
187
|
+
```css
|
|
188
|
+
/* Example: widen the popover and restyle options */
|
|
189
|
+
rel-time-picker::part(panel) {
|
|
190
|
+
box-shadow: var(--rel-shadows-shadow-400);
|
|
191
|
+
}
|
|
192
|
+
rel-time-picker::part(option) {
|
|
193
|
+
border-radius: var(--rel-border-radius-xs);
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Design tokens
|
|
198
|
+
|
|
199
|
+
Styling is fully token-driven: surfaces (`--rel-bg-surface`, `--rel-bg-surface-elevated`), borders (`--rel-border-default`, `--rel-border-strong`, `--rel-border-focus`, `--rel-border-danger`, `--rel-border-subtle`), text (`--rel-text-default`, `--rel-text-label`, `--rel-text-placeholder`, `--rel-text-danger`, `--rel-text-disabled`), selection (`--rel-action-brand-fill`, `--rel-action-brand-label-icons-primary`), spacing, radius, shadows and the `--rel-body-*` typography roles.
|