@pitchfork-ui/react 0.7.0 → 0.9.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/AvatarGroup.css +26 -0
- package/dist/components/AvatarGroup/AvatarGroup2.js +38 -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/Calendar.css +0 -1
- 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/Combobox/Combobox.css +155 -0
- package/dist/components/Combobox/Combobox2.js +192 -0
- package/dist/components/CommandPalette/CommandPalette.css +225 -0
- package/dist/components/CommandPalette/CommandPalette2.js +196 -0
- package/dist/components/ContentDivider/ContentDivider2.js +1 -0
- package/dist/components/CreditCard/CreditCard2.js +1 -0
- package/dist/components/DatePicker/DatePicker2.js +1 -0
- package/dist/components/DateRangePicker/DateRangePicker.css +258 -0
- package/dist/components/DateRangePicker/DateRangePicker2.js +379 -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 +44 -0
- package/dist/components/InlineCTA/InlineCTA2.js +1 -0
- package/dist/components/Input/Input2.js +1 -0
- package/dist/components/Kbd/Kbd.css +25 -0
- package/dist/components/Kbd/Kbd2.js +18 -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/NumberInput.css +98 -0
- package/dist/components/NumberInput/NumberInput2.js +166 -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/Popover.css +46 -0
- package/dist/components/Popover/Popover2.js +77 -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/RichTextEditor/RichTextEditor2.js +1 -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/Textarea/Textarea2.js +1 -0
- package/dist/components/Toast/Toast.js +130 -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/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 +1191 -24
- package/dist/index.js +10 -1
- package/dist/src/components/AvatarGroup/AvatarGroup.d.ts +14 -0
- package/dist/src/components/AvatarGroup/AvatarGroup.test.d.ts +1 -0
- package/dist/src/components/AvatarGroup/index.d.ts +1 -0
- package/dist/src/components/Combobox/Combobox.d.ts +20 -0
- package/dist/src/components/Combobox/Combobox.test.d.ts +1 -0
- package/dist/src/components/Combobox/index.d.ts +1 -0
- package/dist/src/components/CommandPalette/CommandPalette.d.ts +18 -0
- package/dist/src/components/CommandPalette/CommandPalette.test.d.ts +1 -0
- package/dist/src/components/CommandPalette/index.d.ts +1 -0
- package/dist/src/components/DateRangePicker/DateRangePicker.d.ts +21 -0
- package/dist/src/components/DateRangePicker/DateRangePicker.test.d.ts +1 -0
- package/dist/src/components/DateRangePicker/index.d.ts +1 -0
- package/dist/src/components/Kbd/Kbd.d.ts +9 -0
- package/dist/src/components/Kbd/Kbd.test.d.ts +1 -0
- package/dist/src/components/Kbd/index.d.ts +1 -0
- package/dist/src/components/NumberInput/NumberInput.d.ts +19 -0
- package/dist/src/components/NumberInput/NumberInput.test.d.ts +1 -0
- package/dist/src/components/NumberInput/index.d.ts +1 -0
- package/dist/src/components/Popover/Popover.d.ts +21 -0
- package/dist/src/components/Popover/Popover.test.d.ts +1 -0
- package/dist/src/components/Popover/index.d.ts +1 -0
- package/dist/src/components/Toast/Toast.d.ts +35 -0
- package/dist/src/components/Toast/Toast.test.d.ts +1 -0
- package/dist/src/components/Toast/index.d.ts +1 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/styles/theme.css +68 -0
- package/dist/styles.css +983 -80
- package/dist/utils/FieldWrapper.js +1 -0
- package/dist/utils/cx.js +1 -0
- package/package.json +29 -3
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Keys, composeDescribedBy } from "../../a11y/index.js";
|
|
3
|
+
import { useAnchoredPosition } from "../../hooks/useAnchoredPosition.js";
|
|
4
|
+
import { useDisclosure } from "../../hooks/useDisclosure.js";
|
|
5
|
+
import { useOutsideInteraction } from "../../hooks/useOutsideInteraction.js";
|
|
6
|
+
import { cx } from "../../utils/cx.js";
|
|
7
|
+
import { Icon } from "../Icon/Icon2.js";
|
|
8
|
+
import { FieldWrapper } from "../../utils/FieldWrapper.js";
|
|
9
|
+
import './DateRangePicker.css';/* empty css */
|
|
10
|
+
import { forwardRef, useCallback, useId, useMemo, useRef, useState } from "react";
|
|
11
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { createPortal } from "react-dom";
|
|
13
|
+
//#region src/components/DateRangePicker/DateRangePicker.tsx
|
|
14
|
+
var WEEKDAY_LABELS = [
|
|
15
|
+
"Su",
|
|
16
|
+
"Mo",
|
|
17
|
+
"Tu",
|
|
18
|
+
"We",
|
|
19
|
+
"Th",
|
|
20
|
+
"Fr",
|
|
21
|
+
"Sa"
|
|
22
|
+
];
|
|
23
|
+
var toMidday = (d) => {
|
|
24
|
+
const n = new Date(d);
|
|
25
|
+
n.setHours(12, 0, 0, 0);
|
|
26
|
+
return n;
|
|
27
|
+
};
|
|
28
|
+
var isSameDay = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
29
|
+
var startOfMonth = (d) => new Date(d.getFullYear(), d.getMonth(), 1, 12);
|
|
30
|
+
var addMonths = (d, n) => new Date(d.getFullYear(), d.getMonth() + n, 1, 12);
|
|
31
|
+
var buildDays = (monthDate) => {
|
|
32
|
+
const ms = startOfMonth(monthDate);
|
|
33
|
+
const firstDay = ms.getDay();
|
|
34
|
+
return Array.from({ length: 42 }, (_, i) => {
|
|
35
|
+
const date = new Date(ms.getFullYear(), ms.getMonth(), ms.getDate() - firstDay + i, 12);
|
|
36
|
+
return {
|
|
37
|
+
date,
|
|
38
|
+
inCurrentMonth: date.getMonth() === monthDate.getMonth()
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var formatDate = (d) => {
|
|
43
|
+
if (!d) return "";
|
|
44
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
45
|
+
month: "short",
|
|
46
|
+
day: "numeric",
|
|
47
|
+
year: "numeric"
|
|
48
|
+
}).format(d);
|
|
49
|
+
};
|
|
50
|
+
function RangeCalendar({ monthDate, rangeStart, rangeEnd, hoverDate, onDayClick, onDayHover, disabledDates, showOutsideDays = true, isPrevDisabled, isNextDisabled, onPrev, onNext, hideNavDesktop = false }) {
|
|
51
|
+
const days = useMemo(() => buildDays(monthDate), [monthDate]);
|
|
52
|
+
const today = useMemo(() => toMidday(/* @__PURE__ */ new Date()), []);
|
|
53
|
+
const monthLabel = new Intl.DateTimeFormat("en-US", {
|
|
54
|
+
month: "long",
|
|
55
|
+
year: "numeric"
|
|
56
|
+
}).format(monthDate);
|
|
57
|
+
const effectiveEnd = rangeEnd ?? hoverDate;
|
|
58
|
+
const isInRange = useCallback((date) => {
|
|
59
|
+
if (!rangeStart || !effectiveEnd) return false;
|
|
60
|
+
return date > (rangeStart <= effectiveEnd ? rangeStart : effectiveEnd) && date < (rangeStart <= effectiveEnd ? effectiveEnd : rangeStart);
|
|
61
|
+
}, [rangeStart, effectiveEnd]);
|
|
62
|
+
const isRangeStart = (date) => !!rangeStart && isSameDay(date, rangeStart);
|
|
63
|
+
const isRangeEnd = (date) => {
|
|
64
|
+
const end = rangeEnd ?? (hoverDate && rangeStart ? hoverDate : null);
|
|
65
|
+
return !!end && isSameDay(date, end);
|
|
66
|
+
};
|
|
67
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
68
|
+
className: "pf-daterange__calendar",
|
|
69
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
70
|
+
className: cx("pf-daterange__cal-header", hideNavDesktop && "pf-daterange__cal-header--hide-nav-desktop"),
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx("button", {
|
|
73
|
+
type: "button",
|
|
74
|
+
className: "pf-daterange__nav",
|
|
75
|
+
"aria-label": "Previous month",
|
|
76
|
+
disabled: isPrevDisabled,
|
|
77
|
+
onClick: onPrev,
|
|
78
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
79
|
+
name: "chevron-left",
|
|
80
|
+
"aria-hidden": true
|
|
81
|
+
})
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ jsx("span", {
|
|
84
|
+
className: "pf-daterange__cal-title",
|
|
85
|
+
children: monthLabel
|
|
86
|
+
}),
|
|
87
|
+
/* @__PURE__ */ jsx("button", {
|
|
88
|
+
type: "button",
|
|
89
|
+
className: "pf-daterange__nav",
|
|
90
|
+
"aria-label": "Next month",
|
|
91
|
+
disabled: isNextDisabled,
|
|
92
|
+
onClick: onNext,
|
|
93
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
94
|
+
name: "chevron-right",
|
|
95
|
+
"aria-hidden": true
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
100
|
+
className: "pf-daterange__grid",
|
|
101
|
+
role: "grid",
|
|
102
|
+
"aria-label": monthLabel,
|
|
103
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
104
|
+
role: "row",
|
|
105
|
+
style: { display: "contents" },
|
|
106
|
+
"aria-hidden": true,
|
|
107
|
+
children: WEEKDAY_LABELS.map((d) => /* @__PURE__ */ jsx("span", {
|
|
108
|
+
role: "columnheader",
|
|
109
|
+
className: "pf-daterange__weekday",
|
|
110
|
+
children: d
|
|
111
|
+
}, d))
|
|
112
|
+
}), Array.from({ length: 6 }, (_, week) => /* @__PURE__ */ jsx("div", {
|
|
113
|
+
role: "row",
|
|
114
|
+
style: { display: "contents" },
|
|
115
|
+
children: days.slice(week * 7, (week + 1) * 7).map(({ date, inCurrentMonth }) => {
|
|
116
|
+
const isToday = isSameDay(today, date);
|
|
117
|
+
const isStart = isRangeStart(date);
|
|
118
|
+
const isEnd = isRangeEnd(date);
|
|
119
|
+
const inRng = isInRange(date);
|
|
120
|
+
const isDisabled = Boolean(disabledDates?.(date));
|
|
121
|
+
if (!showOutsideDays && !inCurrentMonth) return /* @__PURE__ */ jsx("span", {
|
|
122
|
+
className: "pf-daterange__day-empty",
|
|
123
|
+
"aria-hidden": true
|
|
124
|
+
}, date.toISOString());
|
|
125
|
+
return /* @__PURE__ */ jsx("button", {
|
|
126
|
+
type: "button",
|
|
127
|
+
role: "gridcell",
|
|
128
|
+
className: cx("pf-daterange__day", !inCurrentMonth && "pf-daterange__day--outside", isToday && "pf-daterange__day--today", (isStart || isEnd) && "pf-daterange__day--selected", isStart && "pf-daterange__day--range-start", isEnd && "pf-daterange__day--range-end", inRng && "pf-daterange__day--in-range"),
|
|
129
|
+
"aria-label": new Intl.DateTimeFormat("en-US", {
|
|
130
|
+
month: "long",
|
|
131
|
+
day: "numeric",
|
|
132
|
+
year: "numeric"
|
|
133
|
+
}).format(date),
|
|
134
|
+
"aria-selected": isStart || isEnd || inRng,
|
|
135
|
+
"aria-current": isToday ? "date" : void 0,
|
|
136
|
+
disabled: isDisabled,
|
|
137
|
+
onClick: () => onDayClick(date),
|
|
138
|
+
onMouseEnter: () => onDayHover(date),
|
|
139
|
+
onMouseLeave: () => onDayHover(null),
|
|
140
|
+
children: date.getDate()
|
|
141
|
+
}, date.toISOString());
|
|
142
|
+
})
|
|
143
|
+
}, week))]
|
|
144
|
+
})]
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
var DateRangePicker = forwardRef(function DateRangePicker({ id, className, value, defaultValue, onValueChange, label, description, error, startPlaceholder = "Start date", endPlaceholder = "End date", required, disabled, disabledDates, showOutsideDays = true, startYear, endYear, "aria-describedby": ariaDescribedBy, ...props }, ref) {
|
|
148
|
+
const generatedId = useId();
|
|
149
|
+
const pickerId = id ?? generatedId;
|
|
150
|
+
const descriptionId = description ? `${pickerId}-description` : void 0;
|
|
151
|
+
const errorId = error ? `${pickerId}-error` : void 0;
|
|
152
|
+
const describedBy = composeDescribedBy(ariaDescribedBy, descriptionId, errorId);
|
|
153
|
+
const isControlled = value !== void 0;
|
|
154
|
+
const [internalRange, setInternalRange] = useState(defaultValue ?? {
|
|
155
|
+
start: null,
|
|
156
|
+
end: null
|
|
157
|
+
});
|
|
158
|
+
const range = isControlled ? value : internalRange;
|
|
159
|
+
const setRange = (next) => {
|
|
160
|
+
if (!isControlled) setInternalRange(next);
|
|
161
|
+
onValueChange?.(next);
|
|
162
|
+
};
|
|
163
|
+
const [selecting, setSelecting] = useState(null);
|
|
164
|
+
const [hoverDate, setHoverDate] = useState(null);
|
|
165
|
+
const yearRange = useMemo(() => {
|
|
166
|
+
const fallbackStart = (/* @__PURE__ */ new Date()).getFullYear() - 50;
|
|
167
|
+
const fallbackEnd = (/* @__PURE__ */ new Date()).getFullYear() + 50;
|
|
168
|
+
return {
|
|
169
|
+
start: startYear ?? fallbackStart,
|
|
170
|
+
end: endYear ?? fallbackEnd
|
|
171
|
+
};
|
|
172
|
+
}, [startYear, endYear]);
|
|
173
|
+
const clampMonth = (d) => {
|
|
174
|
+
const y = d.getFullYear();
|
|
175
|
+
if (y < yearRange.start) return new Date(yearRange.start, 0, 1, 12);
|
|
176
|
+
if (y > yearRange.end) return new Date(yearRange.end, 11, 1, 12);
|
|
177
|
+
return d;
|
|
178
|
+
};
|
|
179
|
+
const [leftMonth, setLeftMonth] = useState(() => clampMonth(startOfMonth(range.start ?? /* @__PURE__ */ new Date())));
|
|
180
|
+
const rightMonth = addMonths(leftMonth, 1);
|
|
181
|
+
const disclosure = useDisclosure({ disabled });
|
|
182
|
+
const { isOpen } = disclosure;
|
|
183
|
+
const rootRef = useRef(null);
|
|
184
|
+
const triggerRef = useRef(null);
|
|
185
|
+
const popoverRef = useRef(null);
|
|
186
|
+
const popoverStyle = useAnchoredPosition({
|
|
187
|
+
anchorRef: rootRef,
|
|
188
|
+
floatingRef: popoverRef,
|
|
189
|
+
enabled: isOpen,
|
|
190
|
+
flip: true,
|
|
191
|
+
matchAnchorWidth: false
|
|
192
|
+
});
|
|
193
|
+
useOutsideInteraction({
|
|
194
|
+
refs: [rootRef, popoverRef],
|
|
195
|
+
enabled: isOpen,
|
|
196
|
+
eventName: "mousedown",
|
|
197
|
+
onInteractOutside: () => {
|
|
198
|
+
setSelecting(null);
|
|
199
|
+
setHoverDate(null);
|
|
200
|
+
disclosure.close();
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
const handleDayClick = (date) => {
|
|
204
|
+
if (selecting === null) {
|
|
205
|
+
setRange({
|
|
206
|
+
start: toMidday(date),
|
|
207
|
+
end: null
|
|
208
|
+
});
|
|
209
|
+
setSelecting("start");
|
|
210
|
+
} else {
|
|
211
|
+
const start = range.start;
|
|
212
|
+
const end = toMidday(date);
|
|
213
|
+
if (isSameDay(start, end)) setRange({
|
|
214
|
+
start: toMidday(date),
|
|
215
|
+
end: null
|
|
216
|
+
});
|
|
217
|
+
else if (end < start) setRange({
|
|
218
|
+
start: end,
|
|
219
|
+
end: start
|
|
220
|
+
});
|
|
221
|
+
else setRange({
|
|
222
|
+
start,
|
|
223
|
+
end
|
|
224
|
+
});
|
|
225
|
+
setSelecting(null);
|
|
226
|
+
setHoverDate(null);
|
|
227
|
+
disclosure.close();
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
const clearRange = () => {
|
|
231
|
+
setRange({
|
|
232
|
+
start: null,
|
|
233
|
+
end: null
|
|
234
|
+
});
|
|
235
|
+
setSelecting(null);
|
|
236
|
+
setHoverDate(null);
|
|
237
|
+
};
|
|
238
|
+
const isPrevDisabled = leftMonth.getFullYear() === yearRange.start && leftMonth.getMonth() === 0;
|
|
239
|
+
const isNextDisabled = rightMonth.getFullYear() === yearRange.end && rightMonth.getMonth() === 11;
|
|
240
|
+
const hasValue = range.start !== null || range.end !== null;
|
|
241
|
+
const displayStart = formatDate(range.start);
|
|
242
|
+
const displayEnd = formatDate(range.end);
|
|
243
|
+
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
244
|
+
labelFor: `${pickerId}-trigger`,
|
|
245
|
+
label,
|
|
246
|
+
description,
|
|
247
|
+
descriptionId,
|
|
248
|
+
error,
|
|
249
|
+
errorId,
|
|
250
|
+
required,
|
|
251
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
252
|
+
ref,
|
|
253
|
+
...props,
|
|
254
|
+
id: pickerId,
|
|
255
|
+
className: cx("pf-daterange", className),
|
|
256
|
+
"aria-describedby": describedBy,
|
|
257
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
258
|
+
className: "pf-daterange__control-row",
|
|
259
|
+
ref: rootRef,
|
|
260
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
261
|
+
ref: triggerRef,
|
|
262
|
+
id: `${pickerId}-trigger`,
|
|
263
|
+
type: "button",
|
|
264
|
+
className: cx("pf-daterange__trigger", error && "pf-daterange__trigger--invalid"),
|
|
265
|
+
disabled,
|
|
266
|
+
"aria-invalid": error ? true : void 0,
|
|
267
|
+
"aria-haspopup": "dialog",
|
|
268
|
+
"aria-expanded": isOpen,
|
|
269
|
+
"aria-required": required || void 0,
|
|
270
|
+
onClick: () => {
|
|
271
|
+
if (!isOpen) setSelecting(null);
|
|
272
|
+
disclosure.toggle();
|
|
273
|
+
},
|
|
274
|
+
onKeyDown: (e) => {
|
|
275
|
+
if (e.key === Keys.Escape) disclosure.close();
|
|
276
|
+
},
|
|
277
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
278
|
+
className: "pf-daterange__value",
|
|
279
|
+
children: displayStart ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
280
|
+
/* @__PURE__ */ jsx("span", { children: displayStart }),
|
|
281
|
+
/* @__PURE__ */ jsx("span", {
|
|
282
|
+
className: "pf-daterange__separator",
|
|
283
|
+
"aria-hidden": true,
|
|
284
|
+
children: "–"
|
|
285
|
+
}),
|
|
286
|
+
/* @__PURE__ */ jsx("span", {
|
|
287
|
+
className: cx(!displayEnd && "pf-daterange__value--placeholder"),
|
|
288
|
+
children: displayEnd || endPlaceholder
|
|
289
|
+
})
|
|
290
|
+
] }) : /* @__PURE__ */ jsxs("span", {
|
|
291
|
+
className: "pf-daterange__value--placeholder",
|
|
292
|
+
children: [
|
|
293
|
+
startPlaceholder,
|
|
294
|
+
/* @__PURE__ */ jsxs("span", {
|
|
295
|
+
className: "pf-daterange__separator",
|
|
296
|
+
"aria-hidden": true,
|
|
297
|
+
children: [
|
|
298
|
+
" ",
|
|
299
|
+
"–",
|
|
300
|
+
" "
|
|
301
|
+
]
|
|
302
|
+
}),
|
|
303
|
+
endPlaceholder
|
|
304
|
+
]
|
|
305
|
+
})
|
|
306
|
+
}), /* @__PURE__ */ jsx(Icon, {
|
|
307
|
+
name: "calendar",
|
|
308
|
+
"aria-hidden": true
|
|
309
|
+
})]
|
|
310
|
+
}), hasValue ? /* @__PURE__ */ jsx("button", {
|
|
311
|
+
type: "button",
|
|
312
|
+
className: "pf-date-picker__icon-button",
|
|
313
|
+
"aria-label": "Clear date range",
|
|
314
|
+
disabled,
|
|
315
|
+
onClick: clearRange,
|
|
316
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
317
|
+
name: "circle-xmark",
|
|
318
|
+
"aria-hidden": true
|
|
319
|
+
})
|
|
320
|
+
}) : null]
|
|
321
|
+
}), isOpen && typeof document !== "undefined" ? createPortal(/* @__PURE__ */ jsxs("div", {
|
|
322
|
+
ref: popoverRef,
|
|
323
|
+
className: "pf-daterange__popover",
|
|
324
|
+
role: "dialog",
|
|
325
|
+
"aria-label": "Date range picker",
|
|
326
|
+
style: popoverStyle,
|
|
327
|
+
onKeyDown: (e) => {
|
|
328
|
+
if (e.key === Keys.Escape) {
|
|
329
|
+
setSelecting(null);
|
|
330
|
+
setHoverDate(null);
|
|
331
|
+
disclosure.close();
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
children: [selecting === "start" ? /* @__PURE__ */ jsx("p", {
|
|
335
|
+
className: "pf-daterange__hint",
|
|
336
|
+
"aria-live": "polite",
|
|
337
|
+
children: "Select an end date"
|
|
338
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
339
|
+
className: "pf-daterange__hint",
|
|
340
|
+
"aria-live": "polite",
|
|
341
|
+
children: "Select a start date"
|
|
342
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
343
|
+
className: "pf-daterange__months",
|
|
344
|
+
children: [/* @__PURE__ */ jsx(RangeCalendar, {
|
|
345
|
+
monthDate: leftMonth,
|
|
346
|
+
rangeStart: range.start,
|
|
347
|
+
rangeEnd: range.end,
|
|
348
|
+
hoverDate: selecting === "start" ? hoverDate : null,
|
|
349
|
+
onDayClick: handleDayClick,
|
|
350
|
+
onDayHover: (d) => selecting === "start" && setHoverDate(d),
|
|
351
|
+
disabledDates,
|
|
352
|
+
showOutsideDays,
|
|
353
|
+
isPrevDisabled,
|
|
354
|
+
isNextDisabled: false,
|
|
355
|
+
onPrev: () => setLeftMonth((m) => clampMonth(addMonths(m, -1))),
|
|
356
|
+
onNext: () => setLeftMonth((m) => clampMonth(addMonths(m, 1)))
|
|
357
|
+
}), /* @__PURE__ */ jsx(RangeCalendar, {
|
|
358
|
+
monthDate: rightMonth,
|
|
359
|
+
rangeStart: range.start,
|
|
360
|
+
rangeEnd: range.end,
|
|
361
|
+
hoverDate: selecting === "start" ? hoverDate : null,
|
|
362
|
+
onDayClick: handleDayClick,
|
|
363
|
+
onDayHover: (d) => selecting === "start" && setHoverDate(d),
|
|
364
|
+
disabledDates,
|
|
365
|
+
showOutsideDays,
|
|
366
|
+
isPrevDisabled: false,
|
|
367
|
+
isNextDisabled,
|
|
368
|
+
onPrev: () => setLeftMonth((m) => clampMonth(addMonths(m, -1))),
|
|
369
|
+
onNext: () => setLeftMonth((m) => clampMonth(addMonths(m, 1))),
|
|
370
|
+
hideNavDesktop: true
|
|
371
|
+
})]
|
|
372
|
+
})]
|
|
373
|
+
}), document.body) : null]
|
|
374
|
+
})
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
DateRangePicker.displayName = "DateRangePicker";
|
|
378
|
+
//#endregion
|
|
379
|
+
export { DateRangePicker };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { cx } from "../../utils/cx.js";
|
|
2
3
|
import './Icon.css';/* empty css */
|
|
3
4
|
import { faBarChart, faCalendar, faCircleCheck, faCircleQuestion, faCircleXmark, faCopy, faCreditCard, faSquareCaretLeft, faSquareCaretRight, faSquareCheck, faStar, faUser } from "@fortawesome/free-regular-svg-icons";
|
|
@@ -112,6 +113,49 @@ var customIcons = {
|
|
|
112
113
|
/* @__PURE__ */ jsx("path", { d: "M12 12v6" }),
|
|
113
114
|
/* @__PURE__ */ jsx("path", { d: "m15 15-3-3-3 3" })
|
|
114
115
|
]
|
|
116
|
+
}),
|
|
117
|
+
plus: /* @__PURE__ */ jsxs("svg", {
|
|
118
|
+
width: "1em",
|
|
119
|
+
height: "1em",
|
|
120
|
+
viewBox: "0 0 24 24",
|
|
121
|
+
fill: "none",
|
|
122
|
+
stroke: "currentColor",
|
|
123
|
+
strokeWidth: "2.5",
|
|
124
|
+
strokeLinecap: "round",
|
|
125
|
+
strokeLinejoin: "round",
|
|
126
|
+
focusable: "false",
|
|
127
|
+
"aria-hidden": "true",
|
|
128
|
+
children: [/* @__PURE__ */ jsx("path", { d: "M12 5v14" }), /* @__PURE__ */ jsx("path", { d: "M5 12h14" })]
|
|
129
|
+
}),
|
|
130
|
+
"magnifying-glass": /* @__PURE__ */ jsxs("svg", {
|
|
131
|
+
width: "1em",
|
|
132
|
+
height: "1em",
|
|
133
|
+
viewBox: "0 0 24 24",
|
|
134
|
+
fill: "none",
|
|
135
|
+
stroke: "currentColor",
|
|
136
|
+
strokeWidth: "2",
|
|
137
|
+
strokeLinecap: "round",
|
|
138
|
+
strokeLinejoin: "round",
|
|
139
|
+
focusable: "false",
|
|
140
|
+
"aria-hidden": "true",
|
|
141
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
142
|
+
cx: "11",
|
|
143
|
+
cy: "11",
|
|
144
|
+
r: "8"
|
|
145
|
+
}), /* @__PURE__ */ jsx("path", { d: "m21 21-4.35-4.35" })]
|
|
146
|
+
}),
|
|
147
|
+
minus: /* @__PURE__ */ jsx("svg", {
|
|
148
|
+
width: "1em",
|
|
149
|
+
height: "1em",
|
|
150
|
+
viewBox: "0 0 24 24",
|
|
151
|
+
fill: "none",
|
|
152
|
+
stroke: "currentColor",
|
|
153
|
+
strokeWidth: "2.5",
|
|
154
|
+
strokeLinecap: "round",
|
|
155
|
+
strokeLinejoin: "round",
|
|
156
|
+
focusable: "false",
|
|
157
|
+
"aria-hidden": "true",
|
|
158
|
+
children: /* @__PURE__ */ jsx("path", { d: "M5 12h14" })
|
|
115
159
|
})
|
|
116
160
|
};
|
|
117
161
|
var regularIcons = {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.pf-kbd {
|
|
2
|
+
align-items: center;
|
|
3
|
+
background: var(--pf-kbd-bg);
|
|
4
|
+
border: 1px solid var(--pf-kbd-border);
|
|
5
|
+
border-bottom-width: 2px;
|
|
6
|
+
border-radius: var(--radius-sm);
|
|
7
|
+
color: var(--pf-kbd-text);
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
font-family: var(--font-family-mono, ui-monospace, monospace);
|
|
10
|
+
font-weight: var(--font-weight-medium);
|
|
11
|
+
line-height: 1;
|
|
12
|
+
white-space: nowrap;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.pf-kbd--md {
|
|
16
|
+
font-size: var(--font-size-xs);
|
|
17
|
+
min-width: 1.5em;
|
|
18
|
+
padding: 3px 6px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.pf-kbd--sm {
|
|
22
|
+
font-size: var(--font-size-2xs);
|
|
23
|
+
min-width: 1.35em;
|
|
24
|
+
padding: 2px 5px;
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../../utils/cx.js";
|
|
3
|
+
import './Kbd.css';/* empty css */
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/Kbd/Kbd.tsx
|
|
7
|
+
var Kbd = forwardRef(function Kbd({ className, keys, size = "md", separator = "+", children, ...props }, ref) {
|
|
8
|
+
const content = keys && keys.length > 0 ? keys.join(` ${separator} `) : children;
|
|
9
|
+
return /* @__PURE__ */ jsx("kbd", {
|
|
10
|
+
ref,
|
|
11
|
+
className: cx("pf-kbd", `pf-kbd--${size}`, className),
|
|
12
|
+
...props,
|
|
13
|
+
children: content
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
Kbd.displayName = "Kbd";
|
|
17
|
+
//#endregion
|
|
18
|
+
export { Kbd };
|
|
@@ -30,10 +30,11 @@
|
|
|
30
30
|
.pf-modal {
|
|
31
31
|
background: var(--pf-modal-bg);
|
|
32
32
|
border: 1px solid color-mix(in srgb, var(--pf-modal-border) 85%, transparent);
|
|
33
|
-
border-radius: var(--radius-lg)
|
|
33
|
+
border-radius: var(--radius-lg);
|
|
34
34
|
box-shadow: var(--pf-modal-elevation-overlay-shadow, var(--pf-elevation-overlay-shadow));
|
|
35
35
|
color: var(--pf-modal-text);
|
|
36
|
-
display:
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
37
38
|
max-height: 92vh;
|
|
38
39
|
overflow: hidden;
|
|
39
40
|
width: 100%;
|
|
@@ -41,7 +42,6 @@
|
|
|
41
42
|
|
|
42
43
|
@media (min-width: 768px) {
|
|
43
44
|
.pf-modal {
|
|
44
|
-
border-radius: var(--radius-lg);
|
|
45
45
|
max-height: min(90vh, 720px);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
.pf-modal__footer {
|
|
67
67
|
align-items: start;
|
|
68
68
|
display: flex;
|
|
69
|
+
flex-shrink: 0;
|
|
69
70
|
gap: var(--space-3);
|
|
70
71
|
justify-content: space-between;
|
|
71
72
|
padding: var(--space-3);
|
|
@@ -90,7 +91,9 @@
|
|
|
90
91
|
|
|
91
92
|
.pf-modal__body {
|
|
92
93
|
display: grid;
|
|
94
|
+
flex: 1 1 auto;
|
|
93
95
|
gap: var(--space-4);
|
|
96
|
+
min-height: 0;
|
|
94
97
|
overflow-y: auto;
|
|
95
98
|
padding: var(--space-3);
|
|
96
99
|
}
|