@oslokommune/punkt-react 16.6.2 → 16.7.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.
@@ -0,0 +1,118 @@
1
+ import type { ChangeEvent, FocusEvent, InputHTMLAttributes, ReactNode } from 'react'
2
+ import type { ITimepickerStrings } from 'shared-types/timepicker'
3
+
4
+ /**
5
+ * Props for {@link PktTimepicker}: a React time picker with `HH:MM`, aligned with Elements `pkt-timepicker`.
6
+ *
7
+ * The value is submitted via a hidden `input type="time"`; hour/minute fields are the editing UI. Use `value`
8
+ * or `defaultValue` for controlled vs. uncontrolled mode.
9
+ */
10
+ export interface IPktTimepicker
11
+ extends Omit<
12
+ InputHTMLAttributes<HTMLInputElement>,
13
+ 'value' | 'onChange' | 'min' | 'max' | 'step' | 'onFocus' | 'onBlur'
14
+ > {
15
+ /** Unique id; used for hour, minute, popup, and hidden input ids. */
16
+ id: string
17
+
18
+ /** Visible label (InputWrapper). */
19
+ label: string
20
+
21
+ /** Controlled value (`HH:MM`). */
22
+ value?: string
23
+
24
+ /** Initial value when the component is uncontrolled. */
25
+ defaultValue?: string
26
+
27
+ /**
28
+ * Earliest valid time (`HH:MM`). May be a number or string (HTML attribute / RHF).
29
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time}
30
+ */
31
+ min?: string | number
32
+
33
+ /**
34
+ * Latest valid time (`HH:MM`). May be a number or string (HTML attribute / RHF).
35
+ */
36
+ max?: string | number
37
+
38
+ /**
39
+ * Step in **seconds** (e.g. `60` = 1 min, `300` = 5 min). Must be a valid multiple (same rules as Elements).
40
+ * @default 60
41
+ */
42
+ step?: number
43
+
44
+ /** Hides the clock button and popup; shows a static clock icon. */
45
+ hidePicker?: boolean
46
+
47
+ /** Shows previous/next step buttons instead of the popup. */
48
+ stepArrows?: boolean
49
+
50
+ /** Full width (`pkt-timepicker--fullwidth`). */
51
+ fullwidth?: boolean
52
+
53
+ /** Form field name on the hidden `input`; falls back to `id` if omitted. */
54
+ name?: string
55
+
56
+ /** Help text above the field. */
57
+ helptext?: string | ReactNode
58
+
59
+ /** Expandable help text (dropdown). */
60
+ helptextDropdown?: string | ReactNode
61
+
62
+ /** Button label for expandable help text. */
63
+ helptextDropdownButton?: string
64
+
65
+ /** Forces error state on the wrapper. */
66
+ hasError?: boolean
67
+
68
+ /** Error message below the field. */
69
+ errorMessage?: string | ReactNode
70
+
71
+ /** Shows an "optional" tag. */
72
+ optionalTag?: boolean
73
+
74
+ /** Label text for the optional tag. */
75
+ optionalText?: string
76
+
77
+ /** Shows a "required" tag. */
78
+ requiredTag?: boolean
79
+
80
+ /** Label text for the required tag. */
81
+ requiredText?: string
82
+
83
+ /** Extra tag next to the label. */
84
+ tagText?: string | null
85
+
86
+ /** Inline layout in InputWrapper. */
87
+ inline?: boolean
88
+
89
+ /** Show visible label and help text (`false` = screen-reader-only label). */
90
+ useWrapper?: boolean
91
+
92
+ /** Passed through to InputWrapper as `aria-describedby`. */
93
+ ariaDescribedby?: string
94
+
95
+ /** Copy for hours, minutes, buttons, and popup. */
96
+ strings?: ITimepickerStrings
97
+
98
+ /** Change event from the hidden input (`e.target.value` is `HH:MM`). */
99
+ onChange?: (e: ChangeEvent<HTMLInputElement>) => void
100
+
101
+ /** Input events while typing or using spinners. */
102
+ onInput?: (e: ChangeEvent<HTMLInputElement>) => void
103
+
104
+ /** Callback with the committed `HH:MM` string. */
105
+ onValueChange?: (value: string) => void
106
+
107
+ /**
108
+ * Fires when focus enters this control from outside (not when moving only between hour and minute).
109
+ * Implemented on the root wrapper; spinbuttons must allow focus to bubble so this runs.
110
+ */
111
+ onFocus?: (e: FocusEvent<Element>) => void
112
+
113
+ /** Focus leaves the whole component. */
114
+ onBlur?: (e: FocusEvent<Element>) => void
115
+
116
+ /** Extra class names on the root (`pkt-timepicker`). */
117
+ className?: string
118
+ }