@pitchfork-ui/react 0.8.0 → 0.10.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/LICENSE +21 -0
- package/dist/a11y/index.js +1 -0
- package/dist/components/Accordion/Accordion2.js +1 -0
- package/dist/components/Alert/Alert2.js +1 -0
- package/dist/components/Avatar/Avatar2.js +1 -0
- package/dist/components/AvatarGroup/AvatarGroup2.js +1 -0
- package/dist/components/Badge/Badge2.js +1 -0
- package/dist/components/BadgeGroup/BadgeGroup2.js +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs2.js +1 -0
- package/dist/components/Button/Button2.js +1 -0
- package/dist/components/ButtonGroup/ButtonGroup2.js +1 -0
- package/dist/components/Calendar/Calendar2.js +1 -0
- package/dist/components/Card/Card2.js +1 -0
- package/dist/components/Carousel/Carousel2.js +1 -0
- package/dist/components/Checkbox/Checkbox2.js +1 -0
- package/dist/components/CodeSnippet/CodeSnippet2.js +1 -0
- package/dist/components/Collapsible/Collapsible.css +86 -0
- package/dist/components/Collapsible/Collapsible2.js +65 -0
- package/dist/components/Combobox/Combobox2.js +1 -0
- package/dist/components/CommandPalette/CommandPalette2.js +1 -0
- package/dist/components/ContentDivider/ContentDivider2.js +1 -0
- package/dist/components/ContextMenu/ContextMenu.css +122 -0
- package/dist/components/ContextMenu/ContextMenu2.js +155 -0
- package/dist/components/CreditCard/CreditCard2.js +1 -0
- package/dist/components/DatePicker/DatePicker2.js +1 -0
- package/dist/components/DateRangePicker/DateRangePicker2.js +1 -0
- package/dist/components/Dropdown/Dropdown2.js +1 -0
- package/dist/components/EmptyState/EmptyState2.js +1 -0
- package/dist/components/FileUploader/FileUploader2.js +1 -0
- package/dist/components/GaugeChart/GaugeChart2.js +1 -0
- package/dist/components/HeaderNavigation/HeaderNavigation2.js +1 -0
- package/dist/components/Heatmap/Heatmap2.js +1 -0
- package/dist/components/Icon/Icon2.js +18 -0
- package/dist/components/InlineCTA/InlineCTA2.js +1 -0
- package/dist/components/Input/Input2.js +1 -0
- package/dist/components/Kbd/Kbd2.js +1 -0
- package/dist/components/LineBarCharts/LineBarChart2.js +1 -0
- package/dist/components/LoadingIndicators/LoadingIndicators2.js +1 -0
- package/dist/components/Metrics/Metrics2.js +1 -0
- package/dist/components/Modal/Modal.css +6 -3
- package/dist/components/Modal/Modal2.js +1 -0
- package/dist/components/MultiSelect/MultiSelect2.js +1 -0
- package/dist/components/Notification/Notification2.js +1 -0
- package/dist/components/NumberInput/NumberInput2.js +1 -0
- package/dist/components/PageHeader/PageHeader2.js +1 -0
- package/dist/components/Pagination/Pagination2.js +1 -0
- package/dist/components/PieChart/PieChart2.js +1 -0
- package/dist/components/Popover/Popover2.js +1 -0
- package/dist/components/ProgressIndicators/ProgressIndicators2.js +1 -0
- package/dist/components/ProgressSteps/ProgressSteps2.js +1 -0
- package/dist/components/RadarChart/RadarChart2.js +1 -0
- package/dist/components/RadioButton/RadioButton2.js +1 -0
- package/dist/components/RadioGroup/RadioGroup2.js +1 -0
- package/dist/components/Rating/Rating2.js +1 -0
- package/dist/components/Resizable/Resizable.css +79 -0
- package/dist/components/Resizable/Resizable2.js +101 -0
- package/dist/components/RichTextEditor/RichTextEditor2.js +1 -0
- package/dist/components/ScrollArea/ScrollArea.css +54 -0
- package/dist/components/ScrollArea/ScrollArea2.js +18 -0
- package/dist/components/SectionFooter/SectionFooter2.js +1 -0
- package/dist/components/SectionHeader/SectionHeader2.js +1 -0
- package/dist/components/Select/Select2.js +1 -0
- package/dist/components/SidebarNavigation/SidebarNavigation2.js +1 -0
- package/dist/components/SlideoutMenu/SlideoutMenu2.js +1 -0
- package/dist/components/Slider/Slider2.js +1 -0
- package/dist/components/Sparkline/Sparkline2.js +1 -0
- package/dist/components/Switch/Switch2.js +1 -0
- package/dist/components/Table/Table2.js +1 -0
- package/dist/components/Tabs/Tabs2.js +1 -0
- package/dist/components/Tag/Tag2.js +1 -0
- package/dist/components/TagInput/TagInput.css +72 -0
- package/dist/components/TagInput/TagInput2.js +116 -0
- package/dist/components/Textarea/Textarea2.js +1 -0
- package/dist/components/TimePicker/TimePicker.css +179 -0
- package/dist/components/TimePicker/TimePicker2.js +239 -0
- package/dist/components/Timeline/Timeline.css +128 -0
- package/dist/components/Timeline/Timeline2.js +49 -0
- package/dist/components/Toast/Toast.js +1 -0
- package/dist/components/Toolbar/Toolbar.css +37 -0
- package/dist/components/Toolbar/Toolbar2.js +71 -0
- package/dist/components/Tooltip/Tooltip2.js +1 -0
- package/dist/components/TreeView/TreeView2.js +1 -0
- package/dist/components/UtilityButton/UtilityButton2.js +1 -0
- package/dist/components/VideoPlayer/VideoPlayer2.js +1 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.css +26 -0
- package/dist/components/VisuallyHidden/VisuallyHidden2.js +21 -0
- package/dist/hooks/useAnchoredPosition.js +1 -0
- package/dist/hooks/useComposedRefs.js +1 -0
- package/dist/hooks/useControllableState.js +1 -0
- package/dist/hooks/useDisclosure.js +1 -0
- package/dist/hooks/useExitAnimation.js +1 -0
- package/dist/hooks/useFocusTrap.js +1 -0
- package/dist/hooks/useListNavigation.js +1 -0
- package/dist/hooks/useOutsideInteraction.js +1 -0
- package/dist/hooks/usePresence.js +1 -0
- package/dist/index.cjs +787 -7
- package/dist/index.js +11 -1
- package/dist/src/components/Collapsible/Collapsible.d.ts +11 -0
- package/dist/src/components/Collapsible/Collapsible.test.d.ts +1 -0
- package/dist/src/components/Collapsible/index.d.ts +1 -0
- package/dist/src/components/ContextMenu/ContextMenu.d.ts +20 -0
- package/dist/src/components/ContextMenu/ContextMenu.test.d.ts +1 -0
- package/dist/src/components/ContextMenu/index.d.ts +1 -0
- package/dist/src/components/Resizable/Resizable.d.ts +19 -0
- package/dist/src/components/Resizable/Resizable.test.d.ts +1 -0
- package/dist/src/components/Resizable/index.d.ts +1 -0
- package/dist/src/components/ScrollArea/ScrollArea.d.ts +12 -0
- package/dist/src/components/ScrollArea/ScrollArea.test.d.ts +1 -0
- package/dist/src/components/ScrollArea/index.d.ts +1 -0
- package/dist/src/components/TagInput/TagInput.d.ts +23 -0
- package/dist/src/components/TagInput/TagInput.test.d.ts +1 -0
- package/dist/src/components/TagInput/index.d.ts +1 -0
- package/dist/src/components/TimePicker/TimePicker.d.ts +18 -0
- package/dist/src/components/TimePicker/TimePicker.test.d.ts +1 -0
- package/dist/src/components/TimePicker/index.d.ts +1 -0
- package/dist/src/components/Timeline/Timeline.d.ts +16 -0
- package/dist/src/components/Timeline/Timeline.test.d.ts +1 -0
- package/dist/src/components/Timeline/index.d.ts +1 -0
- package/dist/src/components/Toolbar/Toolbar.d.ts +8 -0
- package/dist/src/components/Toolbar/Toolbar.test.d.ts +1 -0
- package/dist/src/components/Toolbar/index.d.ts +1 -0
- package/dist/src/components/VisuallyHidden/VisuallyHidden.d.ts +15 -0
- package/dist/src/components/VisuallyHidden/VisuallyHidden.test.d.ts +1 -0
- package/dist/src/components/VisuallyHidden/index.d.ts +1 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/styles/theme.css +77 -0
- package/dist/styles.css +866 -3
- package/dist/utils/FieldWrapper.js +1 -0
- package/dist/utils/cx.js +1 -0
- package/package.json +29 -3
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
.pf-timepicker {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/* ── Trigger ──────────────────────────────────────────────────────────────── */
|
|
6
|
+
|
|
7
|
+
.pf-timepicker__trigger {
|
|
8
|
+
align-items: center;
|
|
9
|
+
background: var(--pf-timepicker-bg);
|
|
10
|
+
border: 1px solid var(--pf-timepicker-border);
|
|
11
|
+
border-radius: var(--radius-md);
|
|
12
|
+
color: var(--pf-timepicker-text);
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
display: flex;
|
|
15
|
+
font: inherit;
|
|
16
|
+
gap: var(--space-2);
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
min-height: 40px;
|
|
19
|
+
padding: 0 var(--space-3);
|
|
20
|
+
text-align: start;
|
|
21
|
+
width: 100%;
|
|
22
|
+
transition:
|
|
23
|
+
border 0.2s,
|
|
24
|
+
box-shadow 0.2s;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.pf-timepicker__trigger:focus {
|
|
28
|
+
outline: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.pf-timepicker__trigger:focus-visible,
|
|
32
|
+
.pf-timepicker__trigger--open {
|
|
33
|
+
border-color: var(--pf-timepicker-focus-border);
|
|
34
|
+
box-shadow: var(--pf-timepicker-focus-ring, var(--pf-focus-ring));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.pf-timepicker__trigger--invalid {
|
|
38
|
+
border-color: var(--pf-timepicker-invalid-border);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.pf-timepicker__trigger:disabled {
|
|
42
|
+
background: var(--pf-control-bg-disabled);
|
|
43
|
+
border-color: var(--pf-control-border-disabled);
|
|
44
|
+
color: var(--pf-control-text-disabled);
|
|
45
|
+
cursor: not-allowed;
|
|
46
|
+
opacity: 0.6;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.pf-timepicker__value {
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
text-overflow: ellipsis;
|
|
52
|
+
white-space: nowrap;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.pf-timepicker__value--placeholder {
|
|
56
|
+
color: var(--pf-timepicker-placeholder);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.pf-timepicker__icon {
|
|
60
|
+
align-items: center;
|
|
61
|
+
color: var(--pf-timepicker-text-muted);
|
|
62
|
+
display: inline-flex;
|
|
63
|
+
flex-shrink: 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.pf-timepicker__icon svg {
|
|
67
|
+
display: block;
|
|
68
|
+
height: 18px;
|
|
69
|
+
width: 18px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* ── Panel ────────────────────────────────────────────────────────────────── */
|
|
73
|
+
|
|
74
|
+
.pf-timepicker__panel {
|
|
75
|
+
animation: pf-timepicker-in var(--duration-fast) var(--easing-decelerate);
|
|
76
|
+
background: var(--pf-timepicker-menu-bg);
|
|
77
|
+
border: 1px solid var(--pf-timepicker-menu-border);
|
|
78
|
+
border-radius: var(--radius-md);
|
|
79
|
+
box-shadow: var(--pf-elevation-popover-shadow);
|
|
80
|
+
display: flex;
|
|
81
|
+
gap: var(--space-1);
|
|
82
|
+
padding: var(--space-1);
|
|
83
|
+
position: fixed;
|
|
84
|
+
z-index: 1000;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.pf-timepicker__panel--exiting {
|
|
88
|
+
animation: pf-timepicker-out var(--duration-fast) var(--easing-accelerate) forwards;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@keyframes pf-timepicker-in {
|
|
92
|
+
from {
|
|
93
|
+
opacity: 0;
|
|
94
|
+
transform: translateY(-4px);
|
|
95
|
+
}
|
|
96
|
+
to {
|
|
97
|
+
opacity: 1;
|
|
98
|
+
transform: translateY(0);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@keyframes pf-timepicker-out {
|
|
103
|
+
from {
|
|
104
|
+
opacity: 1;
|
|
105
|
+
transform: translateY(0);
|
|
106
|
+
}
|
|
107
|
+
to {
|
|
108
|
+
opacity: 0;
|
|
109
|
+
transform: translateY(-4px);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* ── Columns ──────────────────────────────────────────────────────────────── */
|
|
114
|
+
|
|
115
|
+
.pf-timepicker__column {
|
|
116
|
+
display: flex;
|
|
117
|
+
flex-direction: column;
|
|
118
|
+
gap: 2px;
|
|
119
|
+
max-height: 220px;
|
|
120
|
+
overflow-y: auto;
|
|
121
|
+
scroll-behavior: smooth;
|
|
122
|
+
scrollbar-width: thin;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.pf-timepicker__column--meridiem {
|
|
126
|
+
overflow-y: visible;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.pf-timepicker__option {
|
|
130
|
+
appearance: none;
|
|
131
|
+
/* Explicit opaque background (matching the panel) so axe can determine the
|
|
132
|
+
contrast background directly on each option, even when it's partially
|
|
133
|
+
clipped by the scrolling column. */
|
|
134
|
+
background: var(--pf-timepicker-menu-bg);
|
|
135
|
+
border: 0;
|
|
136
|
+
border-radius: var(--radius-sm);
|
|
137
|
+
color: var(--pf-timepicker-text);
|
|
138
|
+
cursor: pointer;
|
|
139
|
+
font: inherit;
|
|
140
|
+
font-variant-numeric: tabular-nums;
|
|
141
|
+
min-width: 3ch;
|
|
142
|
+
padding: var(--space-2) var(--space-3);
|
|
143
|
+
text-align: center;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.pf-timepicker__option:hover {
|
|
147
|
+
background: var(--pf-timepicker-option-hover-bg);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.pf-timepicker__option:focus-visible {
|
|
151
|
+
outline: none;
|
|
152
|
+
box-shadow: inset 0 0 0 2px var(--pf-timepicker-focus-border);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.pf-timepicker__option--selected {
|
|
156
|
+
background: var(--pf-timepicker-option-active-bg);
|
|
157
|
+
color: var(--pf-timepicker-option-active-text);
|
|
158
|
+
font-weight: var(--font-weight-medium);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.pf-timepicker__option--selected:hover {
|
|
162
|
+
background: var(--pf-timepicker-option-active-bg);
|
|
163
|
+
color: var(--pf-timepicker-option-active-text);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@media (prefers-reduced-motion: reduce) {
|
|
167
|
+
.pf-timepicker__trigger {
|
|
168
|
+
transition: none;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.pf-timepicker__panel,
|
|
172
|
+
.pf-timepicker__panel--exiting {
|
|
173
|
+
animation: none;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.pf-timepicker__column {
|
|
177
|
+
scroll-behavior: auto;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Keys, composeDescribedBy } from "../../a11y/index.js";
|
|
3
|
+
import { useAnchoredPosition } from "../../hooks/useAnchoredPosition.js";
|
|
4
|
+
import { useComposedRefs } from "../../hooks/useComposedRefs.js";
|
|
5
|
+
import { useControllableState } from "../../hooks/useControllableState.js";
|
|
6
|
+
import { useDisclosure } from "../../hooks/useDisclosure.js";
|
|
7
|
+
import { useOutsideInteraction } from "../../hooks/useOutsideInteraction.js";
|
|
8
|
+
import { usePresence } from "../../hooks/usePresence.js";
|
|
9
|
+
import { cx } from "../../utils/cx.js";
|
|
10
|
+
import { Icon } from "../Icon/Icon2.js";
|
|
11
|
+
import { FieldWrapper } from "../../utils/FieldWrapper.js";
|
|
12
|
+
import './TimePicker.css';/* empty css */
|
|
13
|
+
import { forwardRef, useEffect, useId, useRef } from "react";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
import { createPortal } from "react-dom";
|
|
16
|
+
//#region src/components/TimePicker/TimePicker.tsx
|
|
17
|
+
var pad = (n) => String(n).padStart(2, "0");
|
|
18
|
+
var parseValue = (value) => {
|
|
19
|
+
const match = /^(\d{1,2}):(\d{2})$/.exec(value.trim());
|
|
20
|
+
if (!match) return {
|
|
21
|
+
hour: null,
|
|
22
|
+
minute: null
|
|
23
|
+
};
|
|
24
|
+
const hour = Number(match[1]);
|
|
25
|
+
const minute = Number(match[2]);
|
|
26
|
+
if (hour > 23 || minute > 59) return {
|
|
27
|
+
hour: null,
|
|
28
|
+
minute: null
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
hour,
|
|
32
|
+
minute
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
var formatDisplay = (parts, hourCycle) => {
|
|
36
|
+
if (parts.hour === null || parts.minute === null) return "";
|
|
37
|
+
if (hourCycle === 24) return `${pad(parts.hour)}:${pad(parts.minute)}`;
|
|
38
|
+
const meridiem = parts.hour < 12 ? "AM" : "PM";
|
|
39
|
+
return `${parts.hour % 12 === 0 ? 12 : parts.hour % 12}:${pad(parts.minute)} ${meridiem}`;
|
|
40
|
+
};
|
|
41
|
+
var range = (length, step = 1) => Array.from({ length: Math.ceil(length / step) }, (_, i) => i * step);
|
|
42
|
+
var TimePicker = forwardRef(function TimePicker({ id, value, defaultValue, onValueChange, hourCycle = 24, minuteStep = 1, label, description, error, placeholder = "Select time", required, name, disabled, className, "aria-describedby": ariaDescribedBy, ...props }, ref) {
|
|
43
|
+
const generatedId = useId();
|
|
44
|
+
const fieldId = id ?? generatedId;
|
|
45
|
+
const panelId = `${fieldId}-panel`;
|
|
46
|
+
const descriptionId = description ? `${fieldId}-description` : void 0;
|
|
47
|
+
const errorId = error ? `${fieldId}-error` : void 0;
|
|
48
|
+
const describedBy = composeDescribedBy(ariaDescribedBy, descriptionId, errorId);
|
|
49
|
+
const [current, setCurrent] = useControllableState({
|
|
50
|
+
value,
|
|
51
|
+
defaultValue: defaultValue ?? "",
|
|
52
|
+
onChange: onValueChange
|
|
53
|
+
});
|
|
54
|
+
const parts = parseValue(current ?? "");
|
|
55
|
+
const disclosure = useDisclosure({ disabled });
|
|
56
|
+
const isOpen = disclosure.isOpen ?? false;
|
|
57
|
+
const rootRef = useRef(null);
|
|
58
|
+
const triggerRefs = useComposedRefs(useRef(null), ref);
|
|
59
|
+
const panelRef = useRef(null);
|
|
60
|
+
const { isMounted, isExiting } = usePresence(isOpen, 160);
|
|
61
|
+
const panelStyle = useAnchoredPosition({
|
|
62
|
+
anchorRef: rootRef,
|
|
63
|
+
floatingRef: panelRef,
|
|
64
|
+
enabled: isOpen,
|
|
65
|
+
matchAnchorWidth: false,
|
|
66
|
+
flip: true
|
|
67
|
+
});
|
|
68
|
+
useOutsideInteraction({
|
|
69
|
+
refs: [rootRef, panelRef],
|
|
70
|
+
enabled: isOpen,
|
|
71
|
+
onInteractOutside: () => disclosure.close()
|
|
72
|
+
});
|
|
73
|
+
const hours = hourCycle === 24 ? range(24) : range(12).map((h) => h + 1);
|
|
74
|
+
const minutes = range(60, minuteStep);
|
|
75
|
+
const meridiems = ["AM", "PM"];
|
|
76
|
+
const selectedMeridiem = parts.hour === null ? null : parts.hour < 12 ? "AM" : "PM";
|
|
77
|
+
const selectedHourDisplay = parts.hour === null ? null : hourCycle === 24 ? parts.hour : parts.hour % 12 === 0 ? 12 : parts.hour % 12;
|
|
78
|
+
const emit = (next) => {
|
|
79
|
+
if (next.hour === null || next.minute === null) return;
|
|
80
|
+
setCurrent(`${pad(next.hour)}:${pad(next.minute)}`);
|
|
81
|
+
};
|
|
82
|
+
const selectHour = (h) => {
|
|
83
|
+
let hour24;
|
|
84
|
+
if (hourCycle === 24) hour24 = h;
|
|
85
|
+
else {
|
|
86
|
+
const meridiem = selectedMeridiem ?? "AM";
|
|
87
|
+
const base = h % 12;
|
|
88
|
+
hour24 = meridiem === "PM" ? base + 12 : base;
|
|
89
|
+
}
|
|
90
|
+
emit({
|
|
91
|
+
hour: hour24,
|
|
92
|
+
minute: parts.minute ?? 0
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
const selectMinute = (m) => {
|
|
96
|
+
emit({
|
|
97
|
+
hour: parts.hour ?? (hourCycle === 12 ? 0 : 0),
|
|
98
|
+
minute: m
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
const selectMeridiem = (mer) => {
|
|
102
|
+
const base = (parts.hour ?? 0) % 12;
|
|
103
|
+
emit({
|
|
104
|
+
hour: mer === "PM" ? base + 12 : base,
|
|
105
|
+
minute: parts.minute ?? 0
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
const display = formatDisplay(parts, hourCycle);
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (!isMounted) return;
|
|
111
|
+
const frame = requestAnimationFrame(() => {
|
|
112
|
+
panelRef.current?.querySelectorAll("[data-selected=\"true\"]").forEach((el) => el.scrollIntoView({ block: "center" }));
|
|
113
|
+
});
|
|
114
|
+
return () => cancelAnimationFrame(frame);
|
|
115
|
+
}, [isMounted]);
|
|
116
|
+
const onColumnKeyDown = (event) => {
|
|
117
|
+
if (event.key !== Keys.ArrowDown && event.key !== Keys.ArrowUp) return;
|
|
118
|
+
const buttons = Array.from(event.currentTarget.querySelectorAll("button:not(:disabled)"));
|
|
119
|
+
const index = buttons.indexOf(document.activeElement);
|
|
120
|
+
if (index === -1) return;
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
buttons[event.key === Keys.ArrowDown ? Math.min(index + 1, buttons.length - 1) : Math.max(index - 1, 0)]?.focus();
|
|
123
|
+
};
|
|
124
|
+
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
125
|
+
labelFor: fieldId,
|
|
126
|
+
label,
|
|
127
|
+
description,
|
|
128
|
+
descriptionId,
|
|
129
|
+
error,
|
|
130
|
+
errorId,
|
|
131
|
+
required,
|
|
132
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
133
|
+
className: "pf-timepicker",
|
|
134
|
+
ref: rootRef,
|
|
135
|
+
children: [
|
|
136
|
+
/* @__PURE__ */ jsxs("button", {
|
|
137
|
+
...props,
|
|
138
|
+
id: fieldId,
|
|
139
|
+
ref: triggerRefs,
|
|
140
|
+
type: "button",
|
|
141
|
+
className: cx("pf-timepicker__trigger", isOpen && "pf-timepicker__trigger--open", error && "pf-timepicker__trigger--invalid", className),
|
|
142
|
+
disabled,
|
|
143
|
+
"aria-haspopup": "dialog",
|
|
144
|
+
"aria-expanded": isOpen,
|
|
145
|
+
"aria-required": required || void 0,
|
|
146
|
+
"aria-invalid": error ? true : void 0,
|
|
147
|
+
"aria-describedby": describedBy,
|
|
148
|
+
onClick: () => disclosure.toggle(),
|
|
149
|
+
onKeyDown: (event) => {
|
|
150
|
+
if (event.key === Keys.Escape) disclosure.close();
|
|
151
|
+
},
|
|
152
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
153
|
+
className: cx("pf-timepicker__value", !display && "pf-timepicker__value--placeholder"),
|
|
154
|
+
children: display || placeholder
|
|
155
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
156
|
+
"aria-hidden": true,
|
|
157
|
+
className: "pf-timepicker__icon",
|
|
158
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
159
|
+
name: "clock",
|
|
160
|
+
"aria-hidden": true
|
|
161
|
+
})
|
|
162
|
+
})]
|
|
163
|
+
}),
|
|
164
|
+
name ? /* @__PURE__ */ jsx("input", {
|
|
165
|
+
type: "hidden",
|
|
166
|
+
name,
|
|
167
|
+
value: current ?? ""
|
|
168
|
+
}) : null,
|
|
169
|
+
isMounted && typeof document !== "undefined" ? createPortal(/* @__PURE__ */ jsxs("div", {
|
|
170
|
+
id: panelId,
|
|
171
|
+
ref: panelRef,
|
|
172
|
+
role: "dialog",
|
|
173
|
+
"aria-label": label ? `${label} picker` : "Time picker",
|
|
174
|
+
className: cx("pf-timepicker__panel", isExiting && "pf-timepicker__panel--exiting"),
|
|
175
|
+
style: panelStyle,
|
|
176
|
+
children: [
|
|
177
|
+
/* @__PURE__ */ jsx("div", {
|
|
178
|
+
className: "pf-timepicker__column",
|
|
179
|
+
role: "listbox",
|
|
180
|
+
"aria-label": "Hour",
|
|
181
|
+
onKeyDown: onColumnKeyDown,
|
|
182
|
+
children: hours.map((h) => {
|
|
183
|
+
const isSel = selectedHourDisplay === h;
|
|
184
|
+
return /* @__PURE__ */ jsx("button", {
|
|
185
|
+
type: "button",
|
|
186
|
+
role: "option",
|
|
187
|
+
"aria-selected": isSel,
|
|
188
|
+
"data-selected": isSel,
|
|
189
|
+
className: cx("pf-timepicker__option", isSel && "pf-timepicker__option--selected"),
|
|
190
|
+
onClick: () => selectHour(h),
|
|
191
|
+
children: pad(h)
|
|
192
|
+
}, h);
|
|
193
|
+
})
|
|
194
|
+
}),
|
|
195
|
+
/* @__PURE__ */ jsx("div", {
|
|
196
|
+
className: "pf-timepicker__column",
|
|
197
|
+
role: "listbox",
|
|
198
|
+
"aria-label": "Minute",
|
|
199
|
+
onKeyDown: onColumnKeyDown,
|
|
200
|
+
children: minutes.map((m) => {
|
|
201
|
+
const isSel = parts.minute === m;
|
|
202
|
+
return /* @__PURE__ */ jsx("button", {
|
|
203
|
+
type: "button",
|
|
204
|
+
role: "option",
|
|
205
|
+
"aria-selected": isSel,
|
|
206
|
+
"data-selected": isSel,
|
|
207
|
+
className: cx("pf-timepicker__option", isSel && "pf-timepicker__option--selected"),
|
|
208
|
+
onClick: () => selectMinute(m),
|
|
209
|
+
children: pad(m)
|
|
210
|
+
}, m);
|
|
211
|
+
})
|
|
212
|
+
}),
|
|
213
|
+
hourCycle === 12 ? /* @__PURE__ */ jsx("div", {
|
|
214
|
+
className: "pf-timepicker__column pf-timepicker__column--meridiem",
|
|
215
|
+
role: "listbox",
|
|
216
|
+
"aria-label": "AM or PM",
|
|
217
|
+
onKeyDown: onColumnKeyDown,
|
|
218
|
+
children: meridiems.map((mer) => {
|
|
219
|
+
const isSel = selectedMeridiem === mer;
|
|
220
|
+
return /* @__PURE__ */ jsx("button", {
|
|
221
|
+
type: "button",
|
|
222
|
+
role: "option",
|
|
223
|
+
"aria-selected": isSel,
|
|
224
|
+
"data-selected": isSel,
|
|
225
|
+
className: cx("pf-timepicker__option", isSel && "pf-timepicker__option--selected"),
|
|
226
|
+
onClick: () => selectMeridiem(mer),
|
|
227
|
+
children: mer
|
|
228
|
+
}, mer);
|
|
229
|
+
})
|
|
230
|
+
}) : null
|
|
231
|
+
]
|
|
232
|
+
}), document.body) : null
|
|
233
|
+
]
|
|
234
|
+
})
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
TimePicker.displayName = "TimePicker";
|
|
238
|
+
//#endregion
|
|
239
|
+
export { TimePicker };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
.pf-timeline {
|
|
2
|
+
display: grid;
|
|
3
|
+
gap: 0;
|
|
4
|
+
list-style: none;
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.pf-timeline__item {
|
|
10
|
+
/* Shared line height for the title; markers center themselves on it. */
|
|
11
|
+
--pf-timeline-line: 1.375rem;
|
|
12
|
+
--pf-timeline-marker-size: 16px;
|
|
13
|
+
column-gap: var(--space-3);
|
|
14
|
+
display: grid;
|
|
15
|
+
grid-template-columns: auto 1fr;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* ── Rail (marker + connector) ────────────────────────────────────────────── */
|
|
19
|
+
|
|
20
|
+
.pf-timeline__rail {
|
|
21
|
+
align-items: center;
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.pf-timeline__marker {
|
|
27
|
+
align-items: center;
|
|
28
|
+
background: var(--pf-timeline-marker-bg);
|
|
29
|
+
border: 2px solid var(--pf-timeline-marker-border);
|
|
30
|
+
border-radius: var(--radius-full);
|
|
31
|
+
color: var(--pf-timeline-marker-icon);
|
|
32
|
+
display: inline-flex;
|
|
33
|
+
flex-shrink: 0;
|
|
34
|
+
height: var(--pf-timeline-marker-size);
|
|
35
|
+
justify-content: center;
|
|
36
|
+
/* Vertically center the marker on the title's first line. */
|
|
37
|
+
margin-top: calc((var(--pf-timeline-line) - var(--pf-timeline-marker-size)) / 2);
|
|
38
|
+
width: var(--pf-timeline-marker-size);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* Markers carrying an icon are larger to fit it. */
|
|
42
|
+
.pf-timeline__marker:has(.pf-timeline__marker-icon) {
|
|
43
|
+
--pf-timeline-marker-size: 28px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.pf-timeline__marker-icon {
|
|
47
|
+
align-items: center;
|
|
48
|
+
display: inline-flex;
|
|
49
|
+
font-size: 0.8rem;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.pf-timeline__marker-icon svg {
|
|
54
|
+
display: block;
|
|
55
|
+
height: 14px;
|
|
56
|
+
width: 14px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.pf-timeline__marker--default {
|
|
60
|
+
background: var(--pf-timeline-default-bg);
|
|
61
|
+
border-color: var(--pf-timeline-default-border);
|
|
62
|
+
color: var(--pf-timeline-default-icon);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.pf-timeline__marker--success {
|
|
66
|
+
background: var(--pf-timeline-success-bg);
|
|
67
|
+
border-color: var(--pf-timeline-success-border);
|
|
68
|
+
color: var(--pf-timeline-success-icon);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.pf-timeline__marker--warning {
|
|
72
|
+
background: var(--pf-timeline-warning-bg);
|
|
73
|
+
border-color: var(--pf-timeline-warning-border);
|
|
74
|
+
color: var(--pf-timeline-warning-icon);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.pf-timeline__marker--danger {
|
|
78
|
+
background: var(--pf-timeline-danger-bg);
|
|
79
|
+
border-color: var(--pf-timeline-danger-border);
|
|
80
|
+
color: var(--pf-timeline-danger-icon);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.pf-timeline__connector {
|
|
84
|
+
background: var(--pf-timeline-connector);
|
|
85
|
+
flex: 1;
|
|
86
|
+
margin: var(--space-1) 0;
|
|
87
|
+
min-height: var(--space-4);
|
|
88
|
+
width: 2px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* ── Content ──────────────────────────────────────────────────────────────── */
|
|
92
|
+
|
|
93
|
+
.pf-timeline__content {
|
|
94
|
+
padding-bottom: var(--space-5);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.pf-timeline__item--last .pf-timeline__content {
|
|
98
|
+
padding-bottom: 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.pf-timeline__header {
|
|
102
|
+
align-items: baseline;
|
|
103
|
+
column-gap: var(--space-2);
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-wrap: wrap;
|
|
106
|
+
justify-content: space-between;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.pf-timeline__title {
|
|
110
|
+
color: var(--pf-timeline-title);
|
|
111
|
+
font-size: var(--font-size-sm);
|
|
112
|
+
font-weight: var(--font-weight-medium);
|
|
113
|
+
line-height: var(--pf-timeline-line);
|
|
114
|
+
margin: 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.pf-timeline__timestamp {
|
|
118
|
+
color: var(--pf-timeline-timestamp);
|
|
119
|
+
font-size: var(--font-size-xs);
|
|
120
|
+
flex-shrink: 0;
|
|
121
|
+
white-space: nowrap;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.pf-timeline__description {
|
|
125
|
+
color: var(--pf-timeline-description);
|
|
126
|
+
font-size: var(--font-size-sm);
|
|
127
|
+
margin-top: var(--space-1);
|
|
128
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../../utils/cx.js";
|
|
3
|
+
import './Timeline.css';/* empty css */
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/Timeline/Timeline.tsx
|
|
7
|
+
var Timeline = forwardRef(function Timeline({ className, items, ...props }, ref) {
|
|
8
|
+
return /* @__PURE__ */ jsx("ol", {
|
|
9
|
+
ref,
|
|
10
|
+
className: cx("pf-timeline", className),
|
|
11
|
+
...props,
|
|
12
|
+
children: items.map((item, index) => {
|
|
13
|
+
const tone = item.tone ?? "default";
|
|
14
|
+
const isLast = index === items.length - 1;
|
|
15
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
16
|
+
className: cx("pf-timeline__item", isLast && "pf-timeline__item--last"),
|
|
17
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
18
|
+
className: "pf-timeline__rail",
|
|
19
|
+
"aria-hidden": true,
|
|
20
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
21
|
+
className: cx("pf-timeline__marker", `pf-timeline__marker--${tone}`),
|
|
22
|
+
children: item.icon ? /* @__PURE__ */ jsx("span", {
|
|
23
|
+
className: "pf-timeline__marker-icon",
|
|
24
|
+
children: item.icon
|
|
25
|
+
}) : null
|
|
26
|
+
}), !isLast ? /* @__PURE__ */ jsx("span", { className: "pf-timeline__connector" }) : null]
|
|
27
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
28
|
+
className: "pf-timeline__content",
|
|
29
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
30
|
+
className: "pf-timeline__header",
|
|
31
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
32
|
+
className: "pf-timeline__title",
|
|
33
|
+
children: item.title
|
|
34
|
+
}), item.timestamp ? /* @__PURE__ */ jsx("span", {
|
|
35
|
+
className: "pf-timeline__timestamp",
|
|
36
|
+
children: item.timestamp
|
|
37
|
+
}) : null]
|
|
38
|
+
}), item.description ? /* @__PURE__ */ jsx("div", {
|
|
39
|
+
className: "pf-timeline__description",
|
|
40
|
+
children: item.description
|
|
41
|
+
}) : null]
|
|
42
|
+
})]
|
|
43
|
+
}, item.id ?? index);
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
Timeline.displayName = "Timeline";
|
|
48
|
+
//#endregion
|
|
49
|
+
export { Timeline };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.pf-toolbar {
|
|
2
|
+
align-items: center;
|
|
3
|
+
background: var(--pf-toolbar-bg);
|
|
4
|
+
border: 1px solid var(--pf-toolbar-border);
|
|
5
|
+
border-radius: var(--radius-md);
|
|
6
|
+
display: flex;
|
|
7
|
+
gap: var(--space-1);
|
|
8
|
+
padding: var(--space-1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.pf-toolbar--horizontal {
|
|
12
|
+
flex-direction: row;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.pf-toolbar--vertical {
|
|
16
|
+
align-items: stretch;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
width: fit-content;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* ── Separator ────────────────────────────────────────────────────────────── */
|
|
22
|
+
|
|
23
|
+
.pf-toolbar__separator {
|
|
24
|
+
background: var(--pf-toolbar-separator);
|
|
25
|
+
flex-shrink: 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.pf-toolbar--horizontal .pf-toolbar__separator {
|
|
29
|
+
align-self: stretch;
|
|
30
|
+
margin: var(--space-1) var(--space-1);
|
|
31
|
+
width: 1px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.pf-toolbar--vertical .pf-toolbar__separator {
|
|
35
|
+
height: 1px;
|
|
36
|
+
margin: var(--space-1) var(--space-1);
|
|
37
|
+
}
|