@ticatec/uniface-element 0.2.4 → 0.3.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/dist/accordion/README.md +169 -0
- package/dist/accordion/README_CN.md +176 -0
- package/dist/action-bar/README.md +275 -0
- package/dist/action-bar/README_CN.md +285 -0
- package/dist/app-layout/README.md +374 -0
- package/dist/app-layout/README_CN.md +381 -0
- package/dist/app-top-bar/README.md +357 -0
- package/dist/app-top-bar/README_CN.md +365 -0
- package/dist/attachment-files/AttachmentFilesField.svelte +67 -1
- package/dist/attachment-files/AttachmentFilesField.svelte.d.ts +8 -1
- package/dist/base-calendar/CalendarBase.svelte +0 -3
- package/dist/box/README.md +385 -0
- package/dist/box/README_CN.md +393 -0
- package/dist/breadcrumbs/README.md +442 -0
- package/dist/breadcrumbs/README_CN.md +442 -0
- package/dist/button/Button.svelte +27 -7
- package/dist/button/Button.svelte.d.ts +3 -1
- package/dist/button/IconButton.svelte +26 -6
- package/dist/button/IconButton.svelte.d.ts +3 -1
- package/dist/button/IconButton_README.md +513 -0
- package/dist/button/IconButton_README_CN.md +513 -0
- package/dist/button/README.md +428 -0
- package/dist/button/README_CN.md +428 -0
- package/dist/button/TextButton.svelte +26 -6
- package/dist/button/TextButton.svelte.d.ts +3 -1
- package/dist/button/TextButton_README.md +571 -0
- package/dist/button/TextButton_README_CN.md +571 -0
- package/dist/card/README.md +666 -0
- package/dist/card/README_CN.md +666 -0
- package/dist/cascade-options-select/CascadeOptionSelect.svelte +43 -7
- package/dist/cascade-options-select/CascadeOptionSelect.svelte.d.ts +3 -4
- package/dist/cascade-options-select/README.md +663 -2
- package/dist/cascade-options-select/README_CN.md +664 -0
- package/dist/checkbox/CheckBox.svelte +20 -6
- package/dist/checkbox/CheckBox.svelte.d.ts +4 -2
- package/dist/checkbox/README.md +562 -0
- package/dist/checkbox/README_CN.md +727 -0
- package/dist/common-editor/NumberInput.svelte +39 -26
- package/dist/common-editor/NumberInput.svelte.d.ts +5 -1
- package/dist/concise-data-table/ConciseListTable.svelte +133 -36
- package/dist/concise-data-table/ConciseListTable.svelte.d.ts +8 -1
- package/dist/concise-data-table/DataCell.svelte +5 -6
- package/dist/concise-data-table/DataRow.svelte +22 -2
- package/dist/concise-data-table/DataRow.svelte.d.ts +1 -0
- package/dist/concise-data-table/README.md +606 -0
- package/dist/concise-data-table/README_CN.md +611 -0
- package/dist/context-menu/ContextMenu.svelte +138 -21
- package/dist/context-menu/ContextMenu.svelte.d.ts +5 -0
- package/dist/context-menu/ContextMenuItem.d.ts +20 -4
- package/dist/context-menu/README.md +551 -0
- package/dist/context-menu/README_CN.md +551 -0
- package/dist/criteria-field/CriteriaField.svelte +3 -5
- package/dist/criteria-field/README.md +532 -0
- package/dist/criteria-field/README_CN.md +532 -0
- package/dist/data-table/README.md +712 -0
- package/dist/data-table/README_CN.md +712 -0
- package/dist/date-picker/DatePicker.svelte +44 -7
- package/dist/date-picker/DatePicker.svelte.d.ts +3 -4
- package/dist/date-picker/DateTimePicker.svelte +32 -8
- package/dist/date-picker/DateTimePicker.svelte.d.ts +3 -4
- package/dist/date-picker/README.md +326 -0
- package/dist/date-picker/README_CN.md +316 -0
- package/dist/date-picker/ScrollBar.svelte +18 -8
- package/dist/date-picker/ScrollBar.svelte.d.ts +1 -1
- package/dist/date-picker/TimePanel.svelte +5 -5
- package/dist/date-picker/TimePanel.svelte.d.ts +1 -1
- package/dist/date-range/README.md +374 -0
- package/dist/date-range/README_CN.md +374 -0
- package/dist/dialog/README.md +596 -0
- package/dist/dialog/README_CN.md +596 -0
- package/dist/drawer/README.md +679 -1
- package/dist/drawer/README_CN.md +679 -0
- package/dist/group-box/group-check-box/GroupCheckBox.svelte +62 -5
- package/dist/group-box/group-check-box/GroupCheckBox.svelte.d.ts +7 -2
- package/dist/group-box/group-check-box/README.md +749 -0
- package/dist/group-box/group-check-box/README_CN.md +750 -0
- package/dist/group-box/group-radio-box/GroupRadioBox.svelte +69 -4
- package/dist/group-box/group-radio-box/GroupRadioBox.svelte.d.ts +8 -2
- package/dist/group-box/group-radio-box/README.md +920 -0
- package/dist/group-box/group-radio-box/README_CN.md +920 -0
- package/dist/image-files/README.md +1346 -0
- package/dist/image-files/README_CN.md +1346 -0
- package/dist/input-options-select/InputOptionsSelect.svelte +161 -65
- package/dist/input-options-select/InputOptionsSelect.svelte.d.ts +4 -1
- package/dist/lib/forwardAllEvents.d.ts +3 -0
- package/dist/lib/forwardAllEvents.js +24 -0
- package/dist/list-box/README.md +579 -0
- package/dist/list-box/README_CN.md +682 -0
- package/dist/lookup-editor/LookupEditor.svelte +15 -3
- package/dist/lookup-editor/LookupEditor.svelte.d.ts +3 -4
- package/dist/lookup-editor/README.md +684 -0
- package/dist/lookup-editor/README_CN.md +684 -0
- package/dist/memo-editor/MemoEditor.svelte +77 -27
- package/dist/memo-editor/MemoEditor.svelte.d.ts +6 -3
- package/dist/memo-editor/README.md +819 -0
- package/dist/memo-editor/README_CN.md +819 -0
- package/dist/message-box/README.md +398 -0
- package/dist/message-box/README_CN.md +398 -0
- package/dist/number-editor/NumberEditor.svelte +2 -2
- package/dist/number-editor/NumberEditor.svelte.d.ts +1 -1
- package/dist/number-editor/README.md +353 -22
- package/dist/number-editor/README_CN.md +357 -0
- package/dist/number-range/README.md +443 -0
- package/dist/number-range/README_CN.md +443 -0
- package/dist/options-multi-select/OptionsMultiSelect.svelte +87 -12
- package/dist/options-multi-select/OptionsMultiSelect.svelte.d.ts +3 -1
- package/dist/options-multi-select/README.md +480 -0
- package/dist/options-multi-select/README_CN.md +480 -0
- package/dist/options-select/OptionsSelect.svelte +36 -5
- package/dist/options-select/OptionsSelect.svelte.d.ts +3 -4
- package/dist/options-select/README.md +632 -0
- package/dist/options-select/README_CN.md +632 -0
- package/dist/page/README.md +605 -0
- package/dist/page/README_CN.md +605 -0
- package/dist/pagination/README.md +946 -0
- package/dist/pagination/README_CN.md +946 -0
- package/dist/pagination-panel/README.md +1075 -0
- package/dist/pagination-panel/README_CN.md +1075 -0
- package/dist/popup-hint/README.md +841 -0
- package/dist/popup-hint/README_CN.md +840 -0
- package/dist/progress-bar/README.md +242 -0
- package/dist/progress-bar/README_CN.md +242 -0
- package/dist/progress-step-bar/README.md +316 -0
- package/dist/progress-step-bar/README_CN.md +316 -0
- package/dist/prompts-text-editor/PromptsTextEditor.svelte +6 -3
- package/dist/prompts-text-editor/PromptsTextEditor.svelte.d.ts +3 -1
- package/dist/prompts-text-editor/README.md +329 -0
- package/dist/prompts-text-editor/README_CN.md +329 -0
- package/dist/property-editor/README.md +969 -0
- package/dist/property-editor/README_CN.md +969 -0
- package/dist/radio-button/README.md +372 -0
- package/dist/radio-button/README_CN.md +372 -0
- package/dist/radio-button/RadioButton.svelte +32 -3
- package/dist/radio-button/RadioButton.svelte.d.ts +12 -1
- package/dist/search-box/README.md +425 -0
- package/dist/search-box/README_CN.md +424 -0
- package/dist/search-box/SearchBox.svelte +22 -6
- package/dist/search-box/SearchBox.svelte.d.ts +4 -1
- package/dist/tabs/README.md +919 -0
- package/dist/tabs/README_CN.md +920 -0
- package/dist/tag/README.md +922 -0
- package/dist/tag/README_CN.md +922 -0
- package/dist/text-editor/PasswordEditor.svelte +17 -2
- package/dist/text-editor/PasswordEditor.svelte.d.ts +3 -3
- package/dist/text-editor/PasswordEditor_README.md +551 -0
- package/dist/text-editor/PasswordEditor_README_CN.md +551 -0
- package/dist/text-editor/README.md +466 -0
- package/dist/text-editor/README_CN.md +466 -0
- package/dist/text-editor/TextEditor.svelte +51 -19
- package/dist/text-editor/TextEditor.svelte.d.ts +0 -1
- package/dist/time-editor/README.md +498 -24
- package/dist/time-editor/README_CN.md +498 -0
- package/dist/time-editor/TimeEditor.svelte +7 -3
- package/dist/time-editor/TimeEditor.svelte.d.ts +3 -1
- package/dist/toast/README.md +667 -0
- package/dist/toast/README_CN.md +667 -0
- package/dist/transfer/README.md +795 -0
- package/dist/transfer/Transfer.svelte +6 -4
- package/dist/transfer/Transfer.svelte.d.ts +3 -1
- package/dist/tree-view/README.md +761 -0
- package/dist/tree-view/README_CN.md +761 -0
- package/dist/tree-view/TreeView.svelte +5 -3
- package/dist/tree-view/TreeView.svelte.d.ts +3 -1
- package/dist/unit-number-editor/README.md +546 -20
- package/dist/unit-number-editor/README_CN.md +525 -0
- package/dist/unit-number-editor/UnitNumberEditor.svelte +62 -8
- package/dist/unit-number-editor/UnitNumberEditor.svelte.d.ts +5 -1
- package/docs/form-field/cn/README_CN.md +364 -0
- package/docs/form-field/en/README.md +364 -0
- package/docs/form-panel/flex-form/cn/README_CN.md +586 -0
- package/docs/form-panel/flex-form/en/README.md +586 -0
- package/docs/form-panel/flex-row-form/cn/README_CN.md +787 -0
- package/docs/form-panel/flex-row-form/en/README.md +787 -0
- package/docs/form-panel/grid-form/en/README.md +744 -0
- package/package.json +1 -1
- package/dist/drawer/README-CN.md +0 -1
|
@@ -1,26 +1,500 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
# TimeEditor
|
|
2
|
+
|
|
3
|
+
A specialized time input component with interactive time selection functionality. Features keyboard navigation, automatic validation, and support for both minute and second precision. The component stores time as a numeric value representing total minutes (with fractional seconds).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ticatec/uniface-element
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import TimeEditor from "@ticatec/uniface-element/TimeEditor";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Basic Usage
|
|
18
|
+
|
|
19
|
+
```svelte
|
|
20
|
+
<script>
|
|
21
|
+
import TimeEditor from "@ticatec/uniface-element/TimeEditor";
|
|
22
|
+
|
|
23
|
+
let timeValue = null; // null or number (minutes)
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<TimeEditor bind:value={timeValue} />
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Props
|
|
30
|
+
|
|
31
|
+
| Prop | Type | Default | Description |
|
|
32
|
+
|------|------|---------|-------------|
|
|
33
|
+
| `value` | `number \| null` | `null` | Time value in minutes (e.g., 90.5 = 1:30:30) |
|
|
34
|
+
| `precision` | `"M" \| "S"` | `"M"` | Time precision - Minutes or Seconds |
|
|
35
|
+
| `mandatory` | `boolean` | `false` | Whether to show zeros instead of underscores for empty fields |
|
|
36
|
+
| `disabled` | `boolean` | `false` | Whether the input is disabled |
|
|
37
|
+
| `readonly` | `boolean` | `false` | Whether the input is read-only |
|
|
38
|
+
| `variant` | `"" \| "plain" \| "outlined" \| "filled"` | `""` | Input visual variant |
|
|
39
|
+
| `compact` | `boolean` | `false` | Whether to use compact spacing |
|
|
40
|
+
| `style` | `string` | `""` | Additional CSS styles |
|
|
41
|
+
| `prefix` | `string` | `""` | Text prefix to display |
|
|
42
|
+
| `suffix` | `string` | `""` | Text suffix to display |
|
|
43
|
+
| `displayMode` | `DisplayMode` | `DisplayMode.Edit` | Display mode (Edit/View) |
|
|
44
|
+
| `class` | `string` | `""` | CSS class name |
|
|
45
|
+
| `onchange` | `OnChangeHandler<number>` | `null` | Callback when time value changes |
|
|
46
|
+
| `onfocus` | `((event: FocusEvent) => void) \| null` | `null` | Callback when input gains focus |
|
|
47
|
+
| `onblur` | `((event: FocusEvent) => void) \| null` | `null` | Callback when input loses focus |
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
- **Interactive Selection**: Click or use arrow keys to navigate between time segments
|
|
52
|
+
- **Automatic Validation**: Prevents invalid time entries (e.g., 25:70)
|
|
53
|
+
- **Flexible Precision**: Support for both minute (HH:MM) and second (HH:MM:SS) precision
|
|
54
|
+
- **Clear Functionality**: Built-in clear button to reset the time
|
|
55
|
+
- **Visual Feedback**: Highlighted segments show current cursor position
|
|
56
|
+
- **Mandatory Mode**: Option to show zeros instead of underscores for required fields
|
|
57
|
+
|
|
58
|
+
## Value Format
|
|
59
|
+
|
|
60
|
+
The TimeEditor stores time as a number representing total minutes:
|
|
61
|
+
- `90` = 1 hour 30 minutes (01:30)
|
|
62
|
+
- `90.5` = 1 hour 30 minutes 30 seconds (01:30:30)
|
|
63
|
+
- `null` = empty/unset time
|
|
64
|
+
|
|
65
|
+
## Examples
|
|
66
|
+
|
|
67
|
+
### Basic Time Input (Minutes)
|
|
68
|
+
|
|
69
|
+
```svelte
|
|
70
|
+
<script>
|
|
71
|
+
import TimeEditor from "@ticatec/uniface-element/TimeEditor";
|
|
72
|
+
|
|
73
|
+
let meetingTime = 570; // 9:30 AM (9*60 + 30 = 570 minutes)
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<div class="form-group">
|
|
77
|
+
<label>Meeting Time:</label>
|
|
78
|
+
<TimeEditor bind:value={meetingTime} precision="M" />
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<p>Selected time: {meetingTime ? Math.floor(meetingTime / 60) + ':' + (meetingTime % 60).toString().padStart(2, '0') : 'Not set'}</p>
|
|
82
|
+
|
|
83
|
+
<style>
|
|
84
|
+
.form-group {
|
|
85
|
+
margin-bottom: 16px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
label {
|
|
89
|
+
display: block;
|
|
90
|
+
margin-bottom: 4px;
|
|
91
|
+
font-weight: 500;
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Time Input with Seconds
|
|
97
|
+
|
|
98
|
+
```svelte
|
|
99
|
+
<script>
|
|
100
|
+
import TimeEditor from "@ticatec/uniface-element/TimeEditor";
|
|
101
|
+
|
|
102
|
+
let duration = 125.75; // 2:05:45 (125 minutes + 45 seconds)
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<div class="form-group">
|
|
106
|
+
<label>Video Duration:</label>
|
|
107
|
+
<TimeEditor bind:value={duration} precision="S" />
|
|
108
|
+
</div>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### With Event Handlers
|
|
112
|
+
|
|
113
|
+
```svelte
|
|
114
|
+
<script>
|
|
115
|
+
import TimeEditor from "@ticatec/uniface-element/TimeEditor";
|
|
116
|
+
|
|
117
|
+
let scheduleTime = null;
|
|
118
|
+
let isFocused = false;
|
|
119
|
+
|
|
120
|
+
function handleTimeChange(newTime) {
|
|
121
|
+
console.log('Time changed:', newTime);
|
|
122
|
+
if (newTime !== null) {
|
|
123
|
+
const hours = Math.floor(newTime / 60);
|
|
124
|
+
const minutes = Math.floor(newTime % 60);
|
|
125
|
+
const seconds = Math.floor((newTime % 1) * 60);
|
|
126
|
+
console.log(`Time: ${hours}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function handleFocus(event) {
|
|
131
|
+
console.log('Time editor focused');
|
|
132
|
+
isFocused = true;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function handleBlur(event) {
|
|
136
|
+
console.log('Time editor blurred');
|
|
137
|
+
isFocused = false;
|
|
138
|
+
}
|
|
139
|
+
</script>
|
|
140
|
+
|
|
141
|
+
<TimeEditor
|
|
142
|
+
bind:value={scheduleTime}
|
|
143
|
+
precision="S"
|
|
144
|
+
onchange={handleTimeChange}
|
|
145
|
+
onfocus={handleFocus}
|
|
146
|
+
onblur={handleBlur}
|
|
147
|
+
/>
|
|
148
|
+
|
|
149
|
+
{#if isFocused}
|
|
150
|
+
<p>Time editor is active - use arrow keys to navigate, numbers to input</p>
|
|
151
|
+
{/if}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Mandatory Mode
|
|
155
|
+
|
|
156
|
+
```svelte
|
|
157
|
+
<script>
|
|
158
|
+
import TimeEditor from "@ticatec/uniface-element/TimeEditor";
|
|
159
|
+
|
|
160
|
+
let time1 = null;
|
|
161
|
+
let time2 = null;
|
|
162
|
+
</script>
|
|
163
|
+
|
|
164
|
+
<!-- Optional mode (shows underscores) -->
|
|
165
|
+
<div class="form-group">
|
|
166
|
+
<label>Optional Time:</label>
|
|
167
|
+
<TimeEditor bind:value={time1} mandatory={false} />
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<!-- Mandatory mode (shows zeros) -->
|
|
171
|
+
<div class="form-group">
|
|
172
|
+
<label>Required Time:</label>
|
|
173
|
+
<TimeEditor bind:value={time2} mandatory={true} />
|
|
174
|
+
</div>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Different Variants
|
|
178
|
+
|
|
179
|
+
```svelte
|
|
180
|
+
<script>
|
|
181
|
+
import TimeEditor from "@ticatec/uniface-element/TimeEditor";
|
|
182
|
+
|
|
183
|
+
let time1 = 480; // 8:00
|
|
184
|
+
let time2 = 540; // 9:00
|
|
185
|
+
let time3 = 600; // 10:00
|
|
186
|
+
</script>
|
|
187
|
+
|
|
188
|
+
<!-- Default variant -->
|
|
189
|
+
<TimeEditor bind:value={time1} />
|
|
190
|
+
|
|
191
|
+
<!-- Outlined variant -->
|
|
192
|
+
<TimeEditor bind:value={time2} variant="outlined" />
|
|
193
|
+
|
|
194
|
+
<!-- Filled variant -->
|
|
195
|
+
<TimeEditor bind:value={time3} variant="filled" />
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### With Prefix and Suffix
|
|
199
|
+
|
|
200
|
+
```svelte
|
|
201
|
+
<script>
|
|
202
|
+
import TimeEditor from "@ticatec/uniface-element/TimeEditor";
|
|
203
|
+
|
|
204
|
+
let startTime = 480; // 8:00 AM
|
|
205
|
+
let duration = 120; // 2:00 hours
|
|
206
|
+
</script>
|
|
207
|
+
|
|
208
|
+
<div class="form-group">
|
|
209
|
+
<label>Start Time:</label>
|
|
210
|
+
<TimeEditor bind:value={startTime} suffix=" AM" />
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
<div class="form-group">
|
|
214
|
+
<label>Duration:</label>
|
|
215
|
+
<TimeEditor bind:value={duration} prefix="Duration: " suffix=" hrs" />
|
|
216
|
+
</div>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Schedule Form Example
|
|
220
|
+
|
|
221
|
+
```svelte
|
|
222
|
+
<script>
|
|
223
|
+
import TimeEditor from "@ticatec/uniface-element/TimeEditor";
|
|
224
|
+
import Button from "@ticatec/uniface-element/Button";
|
|
225
|
+
import TextEditor from "@ticatec/uniface-element/TextEditor";
|
|
226
|
+
|
|
227
|
+
let schedule = {
|
|
228
|
+
title: '',
|
|
229
|
+
startTime: null,
|
|
230
|
+
endTime: null,
|
|
231
|
+
breakDuration: 15 // 15 minutes
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
$: totalDuration = schedule.startTime !== null && schedule.endTime !== null
|
|
235
|
+
? schedule.endTime - schedule.startTime - schedule.breakDuration
|
|
236
|
+
: 0;
|
|
237
|
+
|
|
238
|
+
function formatTime(minutes) {
|
|
239
|
+
if (minutes === null) return 'Not set';
|
|
240
|
+
const hours = Math.floor(minutes / 60);
|
|
241
|
+
const mins = Math.floor(minutes % 60);
|
|
242
|
+
return `${hours}:${mins.toString().padStart(2, '0')}`;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function handleSubmit() {
|
|
246
|
+
console.log('Schedule:', schedule);
|
|
247
|
+
}
|
|
248
|
+
</script>
|
|
249
|
+
|
|
250
|
+
<div class="schedule-form">
|
|
251
|
+
<h3>Create Schedule</h3>
|
|
252
|
+
|
|
253
|
+
<div class="form-field">
|
|
254
|
+
<label>Event Title</label>
|
|
255
|
+
<TextEditor bind:value={schedule.title} placeholder="Enter event title" />
|
|
256
|
+
</div>
|
|
257
|
+
|
|
258
|
+
<div class="form-row">
|
|
259
|
+
<div class="form-field">
|
|
260
|
+
<label>Start Time</label>
|
|
261
|
+
<TimeEditor bind:value={schedule.startTime} precision="M" />
|
|
262
|
+
</div>
|
|
263
|
+
|
|
264
|
+
<div class="form-field">
|
|
265
|
+
<label>End Time</label>
|
|
266
|
+
<TimeEditor bind:value={schedule.endTime} precision="M" />
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<div class="form-field">
|
|
271
|
+
<label>Break Duration (minutes)</label>
|
|
272
|
+
<TimeEditor bind:value={schedule.breakDuration} precision="M" />
|
|
273
|
+
</div>
|
|
274
|
+
|
|
275
|
+
{#if totalDuration > 0}
|
|
276
|
+
<div class="summary">
|
|
277
|
+
<p><strong>Summary:</strong></p>
|
|
278
|
+
<p>Duration: {formatTime(totalDuration)} (excluding breaks)</p>
|
|
279
|
+
<p>Start: {formatTime(schedule.startTime)} - End: {formatTime(schedule.endTime)}</p>
|
|
280
|
+
</div>
|
|
281
|
+
{/if}
|
|
282
|
+
|
|
283
|
+
<Button
|
|
284
|
+
type="primary"
|
|
285
|
+
label="Create Schedule"
|
|
286
|
+
onClick={handleSubmit}
|
|
287
|
+
disabled={!schedule.title || schedule.startTime === null || schedule.endTime === null}
|
|
288
|
+
/>
|
|
289
|
+
</div>
|
|
290
|
+
|
|
291
|
+
<style>
|
|
292
|
+
.schedule-form {
|
|
293
|
+
max-width: 500px;
|
|
294
|
+
padding: 24px;
|
|
295
|
+
border: 1px solid #ddd;
|
|
296
|
+
border-radius: 8px;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
h3 {
|
|
300
|
+
margin-bottom: 24px;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.form-row {
|
|
304
|
+
display: grid;
|
|
305
|
+
grid-template-columns: 1fr 1fr;
|
|
306
|
+
gap: 16px;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.form-field {
|
|
310
|
+
margin-bottom: 16px;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
label {
|
|
314
|
+
display: block;
|
|
315
|
+
margin-bottom: 4px;
|
|
316
|
+
font-weight: 500;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.summary {
|
|
320
|
+
background: #f8f9fa;
|
|
321
|
+
padding: 16px;
|
|
322
|
+
border-radius: 4px;
|
|
323
|
+
margin-bottom: 16px;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.summary p {
|
|
327
|
+
margin: 0 0 4px 0;
|
|
328
|
+
}
|
|
329
|
+
</style>
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Disabled and Readonly States
|
|
333
|
+
|
|
334
|
+
```svelte
|
|
335
|
+
<script>
|
|
336
|
+
import TimeEditor from "@ticatec/uniface-element/TimeEditor";
|
|
337
|
+
|
|
338
|
+
let normalTime = 540; // 9:00
|
|
339
|
+
let readonlyTime = 600; // 10:00
|
|
340
|
+
let disabledTime = null;
|
|
341
|
+
</script>
|
|
342
|
+
|
|
343
|
+
<!-- Normal time input -->
|
|
344
|
+
<TimeEditor bind:value={normalTime} />
|
|
345
|
+
|
|
346
|
+
<!-- Readonly time input -->
|
|
347
|
+
<TimeEditor bind:value={readonlyTime} readonly />
|
|
348
|
+
|
|
349
|
+
<!-- Disabled time input -->
|
|
350
|
+
<TimeEditor bind:value={disabledTime} disabled />
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Timer/Stopwatch Example
|
|
354
|
+
|
|
355
|
+
```svelte
|
|
356
|
+
<script>
|
|
357
|
+
import TimeEditor from "@ticatec/uniface-element/TimeEditor";
|
|
358
|
+
import Button from "@ticatec/uniface-element/Button";
|
|
359
|
+
|
|
360
|
+
let timerDuration = 5; // 5 minutes
|
|
361
|
+
let currentTime = 0;
|
|
362
|
+
let isRunning = false;
|
|
363
|
+
let interval;
|
|
364
|
+
|
|
365
|
+
function startTimer() {
|
|
366
|
+
if (timerDuration > 0) {
|
|
367
|
+
currentTime = timerDuration;
|
|
368
|
+
isRunning = true;
|
|
369
|
+
|
|
370
|
+
interval = setInterval(() => {
|
|
371
|
+
currentTime -= 1/60; // Subtract 1 second (1/60 minute)
|
|
372
|
+
|
|
373
|
+
if (currentTime <= 0) {
|
|
374
|
+
currentTime = 0;
|
|
375
|
+
stopTimer();
|
|
376
|
+
alert('Timer finished!');
|
|
377
|
+
}
|
|
378
|
+
}, 1000);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function stopTimer() {
|
|
383
|
+
isRunning = false;
|
|
384
|
+
if (interval) {
|
|
385
|
+
clearInterval(interval);
|
|
386
|
+
interval = null;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function resetTimer() {
|
|
391
|
+
stopTimer();
|
|
392
|
+
currentTime = 0;
|
|
393
|
+
}
|
|
394
|
+
</script>
|
|
395
|
+
|
|
396
|
+
<div class="timer-container">
|
|
397
|
+
<h3>Timer</h3>
|
|
398
|
+
|
|
399
|
+
<div class="form-field">
|
|
400
|
+
<label>Set Duration:</label>
|
|
401
|
+
<TimeEditor bind:value={timerDuration} precision="S" disabled={isRunning} />
|
|
402
|
+
</div>
|
|
403
|
+
|
|
404
|
+
<div class="form-field">
|
|
405
|
+
<label>Remaining Time:</label>
|
|
406
|
+
<TimeEditor bind:value={currentTime} precision="S" readonly />
|
|
407
|
+
</div>
|
|
408
|
+
|
|
409
|
+
<div class="timer-controls">
|
|
410
|
+
{#if !isRunning}
|
|
411
|
+
<Button label="Start" onClick={startTimer} disabled={timerDuration <= 0} />
|
|
412
|
+
{:else}
|
|
413
|
+
<Button label="Stop" onClick={stopTimer} />
|
|
414
|
+
{/if}
|
|
415
|
+
<Button label="Reset" onClick={resetTimer} />
|
|
416
|
+
</div>
|
|
417
|
+
</div>
|
|
418
|
+
|
|
419
|
+
<style>
|
|
420
|
+
.timer-container {
|
|
421
|
+
max-width: 300px;
|
|
422
|
+
padding: 20px;
|
|
423
|
+
border: 1px solid #ddd;
|
|
424
|
+
border-radius: 8px;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
.form-field {
|
|
428
|
+
margin-bottom: 16px;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
label {
|
|
432
|
+
display: block;
|
|
433
|
+
margin-bottom: 4px;
|
|
434
|
+
font-weight: 500;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.timer-controls {
|
|
438
|
+
display: flex;
|
|
439
|
+
gap: 8px;
|
|
440
|
+
}
|
|
441
|
+
</style>
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
## Keyboard Navigation
|
|
445
|
+
|
|
446
|
+
| Key | Action |
|
|
447
|
+
|-----|--------|
|
|
448
|
+
| `Arrow Left/Up` | Move cursor to previous time segment |
|
|
449
|
+
| `Arrow Right/Down` | Move cursor to next time segment |
|
|
450
|
+
| `0-9` | Input number at current cursor position |
|
|
451
|
+
| `Delete` | Clear current segment |
|
|
452
|
+
| `Backspace` | Clear current segment and move cursor back |
|
|
453
|
+
| `Tab` | Move focus to next element |
|
|
454
|
+
|
|
455
|
+
## Time Format
|
|
456
|
+
|
|
457
|
+
- **Display Format**: HH:MM or HH:MM:SS depending on precision
|
|
458
|
+
- **Storage Format**: Numeric value representing total minutes
|
|
459
|
+
- **Range**: 00:00 to 23:59 (0 to 1439 minutes)
|
|
460
|
+
- **Seconds**: Stored as fractional minutes (30 seconds = 0.5 minutes)
|
|
461
|
+
|
|
462
|
+
## Behavior
|
|
463
|
+
|
|
464
|
+
1. **Focus**: Clicking focuses the input and selects the first time segment
|
|
465
|
+
2. **Navigation**: Arrow keys move between hour, minute, and second segments
|
|
466
|
+
3. **Input**: Number keys replace the current segment value
|
|
467
|
+
4. **Validation**: Invalid times are rejected automatically
|
|
468
|
+
5. **Clear**: Clear button resets to empty state
|
|
469
|
+
6. **Blur**: Validates and commits the final time value
|
|
470
|
+
|
|
471
|
+
## Accessibility
|
|
472
|
+
|
|
473
|
+
- Proper keyboard navigation between time segments
|
|
474
|
+
- Screen reader compatible with semantic HTML
|
|
475
|
+
- Focus indicators for current time segment
|
|
476
|
+
- Clear visual feedback for interaction states
|
|
477
|
+
|
|
478
|
+
## Best Practices
|
|
479
|
+
|
|
480
|
+
1. **Precision**: Use minute precision for most scheduling applications
|
|
481
|
+
2. **Validation**: Implement additional validation in change handlers if needed
|
|
482
|
+
3. **Labels**: Provide clear labels describing the time format expected
|
|
483
|
+
4. **Default Values**: Consider providing sensible default times
|
|
484
|
+
5. **Range Validation**: Validate time ranges in your application logic
|
|
485
|
+
|
|
486
|
+
## Browser Support
|
|
487
|
+
|
|
488
|
+
- Modern browsers with full input event support
|
|
489
|
+
- Compatible with Svelte 5+
|
|
490
|
+
- Keyboard navigation support
|
|
491
|
+
- Touch-friendly interface
|
|
492
|
+
|
|
493
|
+
## Related Components
|
|
494
|
+
|
|
495
|
+
- `DatePicker` - Date selection component
|
|
496
|
+
- `DateTimePicker` - Combined date and time selection
|
|
497
|
+
- `NumberEditor` - Numeric input validation
|
|
498
|
+
- `TextEditor` - Basic text input component
|
|
25
499
|
|
|
26
500
|
|