@pitchfork-ui/react 0.1.9
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/README.md +60 -0
- package/dist/index.cjs +9010 -0
- package/dist/index.js +63 -0
- package/dist/index10.js +36 -0
- package/dist/index100.js +26 -0
- package/dist/index102.js +190 -0
- package/dist/index104.js +93 -0
- package/dist/index106.js +27 -0
- package/dist/index108.js +88 -0
- package/dist/index110.js +96 -0
- package/dist/index112.js +38 -0
- package/dist/index114.js +155 -0
- package/dist/index116.js +193 -0
- package/dist/index118.js +24 -0
- package/dist/index12.js +38 -0
- package/dist/index120.js +69 -0
- package/dist/index14.js +24 -0
- package/dist/index16.js +64 -0
- package/dist/index18.js +39 -0
- package/dist/index19.js +35 -0
- package/dist/index21.js +37 -0
- package/dist/index23.js +13 -0
- package/dist/index25.js +38 -0
- package/dist/index27.js +68 -0
- package/dist/index29.js +25 -0
- package/dist/index3.js +32 -0
- package/dist/index30.js +49 -0
- package/dist/index31.js +15 -0
- package/dist/index32.js +22 -0
- package/dist/index33.js +25 -0
- package/dist/index34.js +55 -0
- package/dist/index35.js +36 -0
- package/dist/index36.js +22 -0
- package/dist/index38.js +149 -0
- package/dist/index4.js +6 -0
- package/dist/index40.js +255 -0
- package/dist/index42.js +134 -0
- package/dist/index43.js +16 -0
- package/dist/index44.js +4232 -0
- package/dist/index46.js +123 -0
- package/dist/index48.js +41 -0
- package/dist/index50.js +135 -0
- package/dist/index52.js +39 -0
- package/dist/index54.js +186 -0
- package/dist/index56.js +63 -0
- package/dist/index58.js +45 -0
- package/dist/index6.js +182 -0
- package/dist/index60.js +264 -0
- package/dist/index62.js +68 -0
- package/dist/index64.js +69 -0
- package/dist/index66.js +95 -0
- package/dist/index68.js +202 -0
- package/dist/index70.js +68 -0
- package/dist/index72.js +50 -0
- package/dist/index74.js +88 -0
- package/dist/index76.js +92 -0
- package/dist/index78.js +76 -0
- package/dist/index8.js +61 -0
- package/dist/index80.js +44 -0
- package/dist/index82.js +116 -0
- package/dist/index84.js +25 -0
- package/dist/index86.js +56 -0
- package/dist/index88.js +88 -0
- package/dist/index90.js +167 -0
- package/dist/index92.js +32 -0
- package/dist/index94.js +40 -0
- package/dist/index96.js +87 -0
- package/dist/index98.js +185 -0
- package/dist/src/a11y/index.d.ts +15 -0
- package/dist/src/components/Alert/Alert.d.ts +10 -0
- package/dist/src/components/Alert/Alert.test.d.ts +1 -0
- package/dist/src/components/Alert/index.d.ts +1 -0
- package/dist/src/components/Avatar/Avatar.d.ts +10 -0
- package/dist/src/components/Avatar/Avatar.test.d.ts +1 -0
- package/dist/src/components/Avatar/index.d.ts +1 -0
- package/dist/src/components/Badge/Badge.d.ts +5 -0
- package/dist/src/components/Badge/Badge.test.d.ts +1 -0
- package/dist/src/components/Badge/index.d.ts +1 -0
- package/dist/src/components/BadgeGroup/BadgeGroup.d.ts +11 -0
- package/dist/src/components/BadgeGroup/BadgeGroup.test.d.ts +1 -0
- package/dist/src/components/BadgeGroup/index.d.ts +1 -0
- package/dist/src/components/Breadcrumbs/Breadcrumbs.d.ts +11 -0
- package/dist/src/components/Breadcrumbs/Breadcrumbs.test.d.ts +1 -0
- package/dist/src/components/Breadcrumbs/index.d.ts +1 -0
- package/dist/src/components/Button/Button.d.ts +9 -0
- package/dist/src/components/Button/Button.test.d.ts +1 -0
- package/dist/src/components/Button/index.d.ts +1 -0
- package/dist/src/components/ButtonGroup/ButtonGroup.d.ts +16 -0
- package/dist/src/components/ButtonGroup/ButtonGroup.test.d.ts +1 -0
- package/dist/src/components/ButtonGroup/index.d.ts +1 -0
- package/dist/src/components/Calendar/Calendar.d.ts +14 -0
- package/dist/src/components/Calendar/Calendar.test.d.ts +1 -0
- package/dist/src/components/Calendar/index.d.ts +1 -0
- package/dist/src/components/Card/Card.d.ts +20 -0
- package/dist/src/components/Card/Card.test.d.ts +1 -0
- package/dist/src/components/Card/index.d.ts +1 -0
- package/dist/src/components/Carousel/Carousel.d.ts +10 -0
- package/dist/src/components/Carousel/Carousel.test.d.ts +1 -0
- package/dist/src/components/Carousel/index.d.ts +1 -0
- package/dist/src/components/Checkbox/Checkbox.d.ts +4 -0
- package/dist/src/components/Checkbox/Checkbox.test.d.ts +1 -0
- package/dist/src/components/Checkbox/index.d.ts +1 -0
- package/dist/src/components/CodeSnippet/CodeSnippet.d.ts +11 -0
- package/dist/src/components/CodeSnippet/CodeSnippet.test.d.ts +1 -0
- package/dist/src/components/CodeSnippet/index.d.ts +1 -0
- package/dist/src/components/ContentDivider/ContentDivider.d.ts +7 -0
- package/dist/src/components/ContentDivider/ContentDivider.test.d.ts +1 -0
- package/dist/src/components/ContentDivider/index.d.ts +1 -0
- package/dist/src/components/CreditCard/CreditCard.d.ts +10 -0
- package/dist/src/components/CreditCard/CreditCard.test.d.ts +1 -0
- package/dist/src/components/CreditCard/index.d.ts +1 -0
- package/dist/src/components/DatePicker/DatePicker.d.ts +17 -0
- package/dist/src/components/DatePicker/DatePicker.test.d.ts +1 -0
- package/dist/src/components/DatePicker/index.d.ts +1 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts +20 -0
- package/dist/src/components/Dropdown/Dropdown.test.d.ts +1 -0
- package/dist/src/components/Dropdown/index.d.ts +1 -0
- package/dist/src/components/EmptyState/EmptyState.d.ts +11 -0
- package/dist/src/components/EmptyState/EmptyState.test.d.ts +1 -0
- package/dist/src/components/EmptyState/index.d.ts +1 -0
- package/dist/src/components/FileUploader/FileUploader.d.ts +15 -0
- package/dist/src/components/FileUploader/FileUploader.test.d.ts +1 -0
- package/dist/src/components/FileUploader/index.d.ts +1 -0
- package/dist/src/components/HeaderNavigation/HeaderNavigation.d.ts +12 -0
- package/dist/src/components/HeaderNavigation/HeaderNavigation.test.d.ts +1 -0
- package/dist/src/components/HeaderNavigation/index.d.ts +1 -0
- package/dist/src/components/Icon/Icon.d.ts +12 -0
- package/dist/src/components/Icon/Icon.test.d.ts +1 -0
- package/dist/src/components/Icon/index.d.ts +1 -0
- package/dist/src/components/InlineCTA/InlineCTA.d.ts +11 -0
- package/dist/src/components/InlineCTA/InlineCTA.test.d.ts +1 -0
- package/dist/src/components/InlineCTA/index.d.ts +1 -0
- package/dist/src/components/Input/Input.d.ts +6 -0
- package/dist/src/components/Input/Input.test.d.ts +1 -0
- package/dist/src/components/Input/index.d.ts +1 -0
- package/dist/src/components/LineBarCharts/LineBarChart.d.ts +29 -0
- package/dist/src/components/LineBarCharts/LineBarChart.test.d.ts +1 -0
- package/dist/src/components/LineBarCharts/index.d.ts +1 -0
- package/dist/src/components/LoadingIndicators/LoadingIndicators.d.ts +17 -0
- package/dist/src/components/LoadingIndicators/LoadingIndicators.test.d.ts +1 -0
- package/dist/src/components/LoadingIndicators/index.d.ts +1 -0
- package/dist/src/components/Metrics/Metrics.d.ts +15 -0
- package/dist/src/components/Metrics/Metrics.test.d.ts +1 -0
- package/dist/src/components/Metrics/index.d.ts +1 -0
- package/dist/src/components/Modal/Modal.d.ts +16 -0
- package/dist/src/components/Modal/Modal.test.d.ts +1 -0
- package/dist/src/components/Modal/index.d.ts +1 -0
- package/dist/src/components/MultiSelect/MultiSelect.d.ts +18 -0
- package/dist/src/components/MultiSelect/MultiSelect.test.d.ts +1 -0
- package/dist/src/components/MultiSelect/index.d.ts +1 -0
- package/dist/src/components/Notification/Notification.d.ts +16 -0
- package/dist/src/components/Notification/Notification.test.d.ts +1 -0
- package/dist/src/components/Notification/index.d.ts +1 -0
- package/dist/src/components/PageHeader/PageHeader.d.ts +12 -0
- package/dist/src/components/PageHeader/PageHeader.test.d.ts +1 -0
- package/dist/src/components/PageHeader/index.d.ts +1 -0
- package/dist/src/components/Pagination/Pagination.d.ts +14 -0
- package/dist/src/components/Pagination/Pagination.test.d.ts +1 -0
- package/dist/src/components/Pagination/index.d.ts +1 -0
- package/dist/src/components/PieChart/PieChart.d.ts +14 -0
- package/dist/src/components/PieChart/PieChart.test.d.ts +1 -0
- package/dist/src/components/PieChart/index.d.ts +1 -0
- package/dist/src/components/ProgressIndicators/ProgressIndicators.d.ts +16 -0
- package/dist/src/components/ProgressIndicators/ProgressIndicators.test.d.ts +1 -0
- package/dist/src/components/ProgressIndicators/index.d.ts +1 -0
- package/dist/src/components/ProgressSteps/ProgressSteps.d.ts +12 -0
- package/dist/src/components/ProgressSteps/ProgressSteps.test.d.ts +1 -0
- package/dist/src/components/ProgressSteps/index.d.ts +1 -0
- package/dist/src/components/RadarChart/RadarChart.d.ts +15 -0
- package/dist/src/components/RadarChart/RadarChart.test.d.ts +1 -0
- package/dist/src/components/RadarChart/index.d.ts +1 -0
- package/dist/src/components/RadioButton/RadioButton.d.ts +4 -0
- package/dist/src/components/RadioButton/RadioButton.test.d.ts +1 -0
- package/dist/src/components/RadioButton/index.d.ts +1 -0
- package/dist/src/components/RadioGroup/RadioGroup.d.ts +17 -0
- package/dist/src/components/RadioGroup/RadioGroup.test.d.ts +1 -0
- package/dist/src/components/RadioGroup/index.d.ts +1 -0
- package/dist/src/components/Rating/Rating.d.ts +15 -0
- package/dist/src/components/Rating/Rating.test.d.ts +1 -0
- package/dist/src/components/Rating/index.d.ts +1 -0
- package/dist/src/components/RichTextEditor/RichTextEditor.d.ts +14 -0
- package/dist/src/components/RichTextEditor/RichTextEditor.test.d.ts +1 -0
- package/dist/src/components/RichTextEditor/index.d.ts +1 -0
- package/dist/src/components/SectionFooter/SectionFooter.d.ts +8 -0
- package/dist/src/components/SectionFooter/SectionFooter.test.d.ts +1 -0
- package/dist/src/components/SectionFooter/index.d.ts +1 -0
- package/dist/src/components/SectionHeader/SectionHeader.d.ts +10 -0
- package/dist/src/components/SectionHeader/SectionHeader.test.d.ts +1 -0
- package/dist/src/components/SectionHeader/index.d.ts +1 -0
- package/dist/src/components/Select/Select.d.ts +22 -0
- package/dist/src/components/Select/Select.test.d.ts +1 -0
- package/dist/src/components/Select/index.d.ts +1 -0
- package/dist/src/components/SidebarNavigation/SidebarNavigation.d.ts +19 -0
- package/dist/src/components/SidebarNavigation/SidebarNavigation.test.d.ts +1 -0
- package/dist/src/components/SidebarNavigation/index.d.ts +1 -0
- package/dist/src/components/SlideoutMenu/SlideoutMenu.d.ts +17 -0
- package/dist/src/components/SlideoutMenu/SlideoutMenu.test.d.ts +1 -0
- package/dist/src/components/SlideoutMenu/index.d.ts +1 -0
- package/dist/src/components/Slider/Slider.d.ts +10 -0
- package/dist/src/components/Slider/Slider.test.d.ts +1 -0
- package/dist/src/components/Slider/index.d.ts +1 -0
- package/dist/src/components/Switch/Switch.d.ts +4 -0
- package/dist/src/components/Switch/Switch.test.d.ts +1 -0
- package/dist/src/components/Switch/index.d.ts +1 -0
- package/dist/src/components/Table/Table.d.ts +34 -0
- package/dist/src/components/Table/Table.test.d.ts +1 -0
- package/dist/src/components/Table/index.d.ts +1 -0
- package/dist/src/components/Tabs/Tabs.d.ts +18 -0
- package/dist/src/components/Tabs/Tabs.test.d.ts +1 -0
- package/dist/src/components/Tabs/index.d.ts +1 -0
- package/dist/src/components/Tag/Tag.d.ts +7 -0
- package/dist/src/components/Tag/Tag.test.d.ts +1 -0
- package/dist/src/components/Tag/index.d.ts +1 -0
- package/dist/src/components/Textarea/Textarea.d.ts +6 -0
- package/dist/src/components/Textarea/Textarea.test.d.ts +1 -0
- package/dist/src/components/Textarea/index.d.ts +1 -0
- package/dist/src/components/Tooltip/Tooltip.d.ts +11 -0
- package/dist/src/components/Tooltip/Tooltip.test.d.ts +1 -0
- package/dist/src/components/Tooltip/index.d.ts +1 -0
- package/dist/src/components/TreeView/TreeView.d.ts +22 -0
- package/dist/src/components/TreeView/TreeView.test.d.ts +1 -0
- package/dist/src/components/TreeView/index.d.ts +1 -0
- package/dist/src/components/UtilityButton/UtilityButton.d.ts +9 -0
- package/dist/src/components/UtilityButton/UtilityButton.test.d.ts +1 -0
- package/dist/src/components/UtilityButton/index.d.ts +1 -0
- package/dist/src/components/VideoPlayer/VideoPlayer.d.ts +20 -0
- package/dist/src/components/VideoPlayer/VideoPlayer.test.d.ts +1 -0
- package/dist/src/components/VideoPlayer/index.d.ts +1 -0
- package/dist/src/hooks/index.d.ts +7 -0
- package/dist/src/hooks/useAnchoredPosition.d.ts +12 -0
- package/dist/src/hooks/useComposedRefs.d.ts +1 -0
- package/dist/src/hooks/useControllableState.d.ts +6 -0
- package/dist/src/hooks/useDisclosure.d.ts +13 -0
- package/dist/src/hooks/useFocusTrap.d.ts +7 -0
- package/dist/src/hooks/useListNavigation.d.ts +15 -0
- package/dist/src/hooks/useOutsideInteraction.d.ts +7 -0
- package/dist/src/index.d.ts +55 -0
- package/dist/src/test/setup.d.ts +0 -0
- package/dist/src/utils/FieldWrapper.d.ts +15 -0
- package/dist/src/utils/cx.d.ts +1 -0
- package/dist/styles.css +5676 -0
- package/package.json +43 -0
package/dist/index40.js
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
import { Icon } from "./index6.js";
|
|
3
|
+
import { Dropdown } from "./index38.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { forwardRef, useEffect, useId, useMemo, useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/Calendar/Calendar.tsx
|
|
8
|
+
var WEEKDAY_LABELS = [
|
|
9
|
+
"Su",
|
|
10
|
+
"Mo",
|
|
11
|
+
"Tu",
|
|
12
|
+
"We",
|
|
13
|
+
"Th",
|
|
14
|
+
"Fr",
|
|
15
|
+
"Sa"
|
|
16
|
+
];
|
|
17
|
+
var MONTH_OPTIONS = Array.from({ length: 12 }, (_, month) => {
|
|
18
|
+
const date = new Date(2024, month, 1);
|
|
19
|
+
return {
|
|
20
|
+
value: month,
|
|
21
|
+
label: new Intl.DateTimeFormat("en-US", { month: "long" }).format(date)
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
var toMidday = (date) => {
|
|
25
|
+
const next = new Date(date);
|
|
26
|
+
next.setHours(12, 0, 0, 0);
|
|
27
|
+
return next;
|
|
28
|
+
};
|
|
29
|
+
var isSameDay = (a, b) => {
|
|
30
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
31
|
+
};
|
|
32
|
+
var startOfMonth = (date) => {
|
|
33
|
+
return new Date(date.getFullYear(), date.getMonth(), 1, 12);
|
|
34
|
+
};
|
|
35
|
+
var addMonths = (date, amount) => {
|
|
36
|
+
return new Date(date.getFullYear(), date.getMonth() + amount, 1, 12);
|
|
37
|
+
};
|
|
38
|
+
var buildCalendarDays = (monthDate) => {
|
|
39
|
+
const monthStart = startOfMonth(monthDate);
|
|
40
|
+
const firstWeekday = monthStart.getDay();
|
|
41
|
+
const gridStart = new Date(monthStart.getFullYear(), monthStart.getMonth(), monthStart.getDate() - firstWeekday, 12);
|
|
42
|
+
return Array.from({ length: 42 }, (_, index) => {
|
|
43
|
+
const date = new Date(gridStart.getFullYear(), gridStart.getMonth(), gridStart.getDate() + index, 12);
|
|
44
|
+
return {
|
|
45
|
+
date,
|
|
46
|
+
inCurrentMonth: date.getMonth() === monthDate.getMonth()
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
var Calendar = forwardRef(function Calendar({ className, value, defaultValue, onValueChange, autoSelectToday = true, label, description, error, disabledDates, showOutsideDays = true, startYear, endYear, "aria-describedby": ariaDescribedBy, ...props }, ref) {
|
|
51
|
+
const generatedId = useId();
|
|
52
|
+
const calendarId = props.id ?? generatedId;
|
|
53
|
+
const descriptionId = description ? `${calendarId}-description` : void 0;
|
|
54
|
+
const errorId = error ? `${calendarId}-error` : void 0;
|
|
55
|
+
const describedBy = [
|
|
56
|
+
ariaDescribedBy,
|
|
57
|
+
descriptionId,
|
|
58
|
+
errorId
|
|
59
|
+
].filter(Boolean).join(" ") || void 0;
|
|
60
|
+
const isControlled = value !== void 0;
|
|
61
|
+
const [internalValue, setInternalValue] = useState(defaultValue ? toMidday(defaultValue) : autoSelectToday ? toMidday(/* @__PURE__ */ new Date()) : void 0);
|
|
62
|
+
const selectedDate = isControlled ? value : internalValue;
|
|
63
|
+
const yearRange = useMemo(() => {
|
|
64
|
+
const fallbackStart = (/* @__PURE__ */ new Date()).getFullYear() - 50;
|
|
65
|
+
const fallbackEnd = (/* @__PURE__ */ new Date()).getFullYear() + 50;
|
|
66
|
+
const nextStart = startYear ?? fallbackStart;
|
|
67
|
+
const nextEnd = endYear ?? fallbackEnd;
|
|
68
|
+
return {
|
|
69
|
+
start: Math.min(nextStart, nextEnd),
|
|
70
|
+
end: Math.max(nextStart, nextEnd)
|
|
71
|
+
};
|
|
72
|
+
}, [endYear, startYear]);
|
|
73
|
+
const clampToYearRange = (date) => {
|
|
74
|
+
const year = date.getFullYear();
|
|
75
|
+
if (year < yearRange.start) return new Date(yearRange.start, 0, 1, 12);
|
|
76
|
+
if (year > yearRange.end) return new Date(yearRange.end, 11, 1, 12);
|
|
77
|
+
return date;
|
|
78
|
+
};
|
|
79
|
+
const [displayMonth, setDisplayMonth] = useState(() => {
|
|
80
|
+
return clampToYearRange(startOfMonth(selectedDate ?? /* @__PURE__ */ new Date()));
|
|
81
|
+
});
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (!selectedDate) return;
|
|
84
|
+
setDisplayMonth(clampToYearRange(startOfMonth(selectedDate)));
|
|
85
|
+
}, [
|
|
86
|
+
selectedDate,
|
|
87
|
+
yearRange.end,
|
|
88
|
+
yearRange.start
|
|
89
|
+
]);
|
|
90
|
+
const monthLabel = useMemo(() => {
|
|
91
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
92
|
+
month: "long",
|
|
93
|
+
year: "numeric"
|
|
94
|
+
}).format(displayMonth);
|
|
95
|
+
}, [displayMonth]);
|
|
96
|
+
const yearOptions = useMemo(() => {
|
|
97
|
+
const length = yearRange.end - yearRange.start + 1;
|
|
98
|
+
return Array.from({ length }, (_, index) => yearRange.start + index);
|
|
99
|
+
}, [yearRange.end, yearRange.start]);
|
|
100
|
+
const isPrevMonthDisabled = displayMonth.getFullYear() === yearRange.start && displayMonth.getMonth() === 0;
|
|
101
|
+
const isNextMonthDisabled = displayMonth.getFullYear() === yearRange.end && displayMonth.getMonth() === 11;
|
|
102
|
+
const dayItems = useMemo(() => {
|
|
103
|
+
return buildCalendarDays(displayMonth);
|
|
104
|
+
}, [displayMonth]);
|
|
105
|
+
const today = useMemo(() => toMidday(/* @__PURE__ */ new Date()), []);
|
|
106
|
+
const selectDate = (nextDate) => {
|
|
107
|
+
if (disabledDates?.(nextDate)) return;
|
|
108
|
+
if (!isControlled) setInternalValue(nextDate);
|
|
109
|
+
onValueChange?.(nextDate);
|
|
110
|
+
setDisplayMonth(clampToYearRange(startOfMonth(nextDate)));
|
|
111
|
+
};
|
|
112
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
113
|
+
className: "pf-field",
|
|
114
|
+
children: [
|
|
115
|
+
label ? /* @__PURE__ */ jsx("label", {
|
|
116
|
+
className: "pf-field__label",
|
|
117
|
+
htmlFor: calendarId,
|
|
118
|
+
children: label
|
|
119
|
+
}) : null,
|
|
120
|
+
/* @__PURE__ */ jsxs("div", {
|
|
121
|
+
ref,
|
|
122
|
+
...props,
|
|
123
|
+
id: calendarId,
|
|
124
|
+
className: cx("pf-calendar", error && "pf-calendar--invalid", className),
|
|
125
|
+
"aria-invalid": error ? true : void 0,
|
|
126
|
+
"aria-describedby": describedBy,
|
|
127
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
128
|
+
className: "pf-calendar__header",
|
|
129
|
+
children: [
|
|
130
|
+
/* @__PURE__ */ jsx("button", {
|
|
131
|
+
type: "button",
|
|
132
|
+
className: "pf-calendar__nav",
|
|
133
|
+
"aria-label": "Previous month",
|
|
134
|
+
disabled: isPrevMonthDisabled,
|
|
135
|
+
onClick: () => {
|
|
136
|
+
setDisplayMonth((current) => clampToYearRange(addMonths(current, -1)));
|
|
137
|
+
},
|
|
138
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
139
|
+
name: "square-caret-left",
|
|
140
|
+
"aria-hidden": true
|
|
141
|
+
})
|
|
142
|
+
}),
|
|
143
|
+
/* @__PURE__ */ jsxs("div", {
|
|
144
|
+
className: "pf-calendar__month-controls",
|
|
145
|
+
children: [
|
|
146
|
+
/* @__PURE__ */ jsx("label", {
|
|
147
|
+
className: "pf-calendar__control-label",
|
|
148
|
+
children: "Month"
|
|
149
|
+
}),
|
|
150
|
+
/* @__PURE__ */ jsx(Dropdown, {
|
|
151
|
+
label: MONTH_OPTIONS[displayMonth.getMonth()].label,
|
|
152
|
+
items: MONTH_OPTIONS.map((month) => ({
|
|
153
|
+
id: String(month.value),
|
|
154
|
+
label: month.label,
|
|
155
|
+
onSelect: () => {
|
|
156
|
+
setDisplayMonth((current) => clampToYearRange(new Date(current.getFullYear(), month.value, 1, 12)));
|
|
157
|
+
},
|
|
158
|
+
disabled: false
|
|
159
|
+
})),
|
|
160
|
+
align: "start"
|
|
161
|
+
}),
|
|
162
|
+
/* @__PURE__ */ jsx("label", {
|
|
163
|
+
className: "pf-calendar__control-label",
|
|
164
|
+
children: "Year"
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ jsx(Dropdown, {
|
|
167
|
+
label: String(displayMonth.getFullYear()),
|
|
168
|
+
items: yearOptions.map((year) => ({
|
|
169
|
+
id: String(year),
|
|
170
|
+
label: String(year),
|
|
171
|
+
onSelect: () => {
|
|
172
|
+
setDisplayMonth((current) => clampToYearRange(new Date(year, current.getMonth(), 1, 12)));
|
|
173
|
+
},
|
|
174
|
+
disabled: false
|
|
175
|
+
})),
|
|
176
|
+
align: "start",
|
|
177
|
+
maxVisibleItems: 7
|
|
178
|
+
})
|
|
179
|
+
]
|
|
180
|
+
}),
|
|
181
|
+
/* @__PURE__ */ jsx("button", {
|
|
182
|
+
type: "button",
|
|
183
|
+
className: "pf-calendar__nav",
|
|
184
|
+
"aria-label": "Next month",
|
|
185
|
+
disabled: isNextMonthDisabled,
|
|
186
|
+
onClick: () => {
|
|
187
|
+
setDisplayMonth((current) => clampToYearRange(addMonths(current, 1)));
|
|
188
|
+
},
|
|
189
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
190
|
+
name: "square-caret-right",
|
|
191
|
+
"aria-hidden": true
|
|
192
|
+
})
|
|
193
|
+
})
|
|
194
|
+
]
|
|
195
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
196
|
+
className: "pf-calendar__grid",
|
|
197
|
+
role: "grid",
|
|
198
|
+
"aria-label": monthLabel,
|
|
199
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
200
|
+
role: "row",
|
|
201
|
+
style: { display: "contents" },
|
|
202
|
+
"aria-hidden": true,
|
|
203
|
+
children: WEEKDAY_LABELS.map((day) => /* @__PURE__ */ jsx("span", {
|
|
204
|
+
role: "columnheader",
|
|
205
|
+
className: "pf-calendar__weekday",
|
|
206
|
+
children: day
|
|
207
|
+
}, day))
|
|
208
|
+
}), Array.from({ length: 6 }, (_, week) => /* @__PURE__ */ jsx("div", {
|
|
209
|
+
role: "row",
|
|
210
|
+
style: { display: "contents" },
|
|
211
|
+
children: dayItems.slice(week * 7, (week + 1) * 7).map(({ date, inCurrentMonth }) => {
|
|
212
|
+
const isSelected = selectedDate ? isSameDay(selectedDate, date) : false;
|
|
213
|
+
const isToday = isSameDay(today, date);
|
|
214
|
+
const isDisabled = Boolean(disabledDates?.(date));
|
|
215
|
+
if (!showOutsideDays && !inCurrentMonth) return /* @__PURE__ */ jsx("span", {
|
|
216
|
+
className: "pf-calendar__day-empty",
|
|
217
|
+
"aria-hidden": true
|
|
218
|
+
}, date.toISOString());
|
|
219
|
+
return /* @__PURE__ */ jsx("button", {
|
|
220
|
+
type: "button",
|
|
221
|
+
role: "gridcell",
|
|
222
|
+
className: cx("pf-calendar__day", !inCurrentMonth && "pf-calendar__day--outside", isToday && "pf-calendar__day--today", isSelected && "pf-calendar__day--selected"),
|
|
223
|
+
"aria-label": new Intl.DateTimeFormat("en-US", {
|
|
224
|
+
month: "long",
|
|
225
|
+
day: "numeric",
|
|
226
|
+
year: "numeric"
|
|
227
|
+
}).format(date),
|
|
228
|
+
"aria-selected": isSelected,
|
|
229
|
+
"aria-current": isToday ? "date" : void 0,
|
|
230
|
+
disabled: isDisabled,
|
|
231
|
+
onClick: () => {
|
|
232
|
+
selectDate(date);
|
|
233
|
+
},
|
|
234
|
+
children: date.getDate()
|
|
235
|
+
}, date.toISOString());
|
|
236
|
+
})
|
|
237
|
+
}, week))]
|
|
238
|
+
})]
|
|
239
|
+
}),
|
|
240
|
+
description ? /* @__PURE__ */ jsx("p", {
|
|
241
|
+
className: "pf-field__description",
|
|
242
|
+
id: descriptionId,
|
|
243
|
+
children: description
|
|
244
|
+
}) : null,
|
|
245
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
246
|
+
className: "pf-field__error",
|
|
247
|
+
id: errorId,
|
|
248
|
+
children: error
|
|
249
|
+
}) : null
|
|
250
|
+
]
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
Calendar.displayName = "Calendar";
|
|
254
|
+
//#endregion
|
|
255
|
+
export { Calendar };
|
package/dist/index42.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
import { Icon } from "./index6.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { forwardRef, useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/Carousel/Carousel.tsx
|
|
7
|
+
var clamp = (value, min, max) => {
|
|
8
|
+
return Math.min(Math.max(value, min), max);
|
|
9
|
+
};
|
|
10
|
+
var Carousel = forwardRef(function Carousel({ className, slides, initialIndex = 0, loop = true, showIndicators = true, autoPlay = false, autoPlayInterval = 5e3, onIndexChange, "aria-label": ariaLabel = "Carousel", ...props }, ref) {
|
|
11
|
+
const totalSlides = slides.length;
|
|
12
|
+
const [activeIndex, setActiveIndex] = useState(clamp(initialIndex, 0, Math.max(totalSlides - 1, 0)));
|
|
13
|
+
const resolvedActiveIndex = clamp(activeIndex, 0, Math.max(totalSlides - 1, 0));
|
|
14
|
+
const goToIndex = (nextIndex) => {
|
|
15
|
+
if (totalSlides === 0) return;
|
|
16
|
+
const resolvedIndex = loop ? (nextIndex % totalSlides + totalSlides) % totalSlides : clamp(nextIndex, 0, totalSlides - 1);
|
|
17
|
+
setActiveIndex(resolvedIndex);
|
|
18
|
+
onIndexChange?.(resolvedIndex);
|
|
19
|
+
};
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!autoPlay || totalSlides < 2) return;
|
|
22
|
+
const interval = window.setInterval(() => {
|
|
23
|
+
setActiveIndex((current) => {
|
|
24
|
+
const next = loop ? (current + 1) % totalSlides : Math.min(current + 1, totalSlides - 1);
|
|
25
|
+
onIndexChange?.(next);
|
|
26
|
+
return next;
|
|
27
|
+
});
|
|
28
|
+
}, autoPlayInterval);
|
|
29
|
+
return () => {
|
|
30
|
+
window.clearInterval(interval);
|
|
31
|
+
};
|
|
32
|
+
}, [
|
|
33
|
+
autoPlay,
|
|
34
|
+
autoPlayInterval,
|
|
35
|
+
loop,
|
|
36
|
+
onIndexChange,
|
|
37
|
+
totalSlides
|
|
38
|
+
]);
|
|
39
|
+
const isPrevDisabled = !loop && resolvedActiveIndex <= 0;
|
|
40
|
+
const isNextDisabled = !loop && resolvedActiveIndex >= totalSlides - 1;
|
|
41
|
+
const slideLabel = useMemo(() => {
|
|
42
|
+
if (totalSlides === 0) return "No slides";
|
|
43
|
+
return `Slide ${resolvedActiveIndex + 1} of ${totalSlides}`;
|
|
44
|
+
}, [resolvedActiveIndex, totalSlides]);
|
|
45
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
46
|
+
ref,
|
|
47
|
+
className: cx("pf-carousel", className),
|
|
48
|
+
"aria-label": ariaLabel,
|
|
49
|
+
...props,
|
|
50
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
51
|
+
className: "pf-carousel__viewport",
|
|
52
|
+
role: "region",
|
|
53
|
+
"aria-roledescription": "carousel",
|
|
54
|
+
"aria-label": slideLabel,
|
|
55
|
+
children: totalSlides === 0 ? /* @__PURE__ */ jsx("div", {
|
|
56
|
+
className: "pf-carousel__empty",
|
|
57
|
+
role: "status",
|
|
58
|
+
children: "Add at least one slide."
|
|
59
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
60
|
+
className: "pf-carousel__track",
|
|
61
|
+
style: { transform: `translateX(-${resolvedActiveIndex * 100}%)` },
|
|
62
|
+
children: slides.map((slide, index) => /* @__PURE__ */ jsx("div", {
|
|
63
|
+
className: "pf-carousel__slide",
|
|
64
|
+
role: "group",
|
|
65
|
+
"aria-roledescription": "slide",
|
|
66
|
+
"aria-label": `Slide ${index + 1} of ${totalSlides}`,
|
|
67
|
+
"aria-hidden": index !== resolvedActiveIndex,
|
|
68
|
+
children: slide
|
|
69
|
+
}, `slide-${index}`))
|
|
70
|
+
})
|
|
71
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
72
|
+
className: "pf-carousel__controls",
|
|
73
|
+
onKeyDown: (event) => {
|
|
74
|
+
if (event.key === "ArrowLeft") {
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
goToIndex(resolvedActiveIndex - 1);
|
|
77
|
+
} else if (event.key === "ArrowRight") {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
goToIndex(resolvedActiveIndex + 1);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ jsx("button", {
|
|
84
|
+
type: "button",
|
|
85
|
+
className: "pf-carousel__nav",
|
|
86
|
+
"aria-label": "Previous slide",
|
|
87
|
+
disabled: isPrevDisabled || totalSlides < 2,
|
|
88
|
+
onClick: () => {
|
|
89
|
+
goToIndex(resolvedActiveIndex - 1);
|
|
90
|
+
},
|
|
91
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
92
|
+
name: "square-caret-left",
|
|
93
|
+
"aria-hidden": true
|
|
94
|
+
})
|
|
95
|
+
}),
|
|
96
|
+
showIndicators && totalSlides > 1 ? /* @__PURE__ */ jsx("div", {
|
|
97
|
+
className: "pf-carousel__indicators",
|
|
98
|
+
"aria-label": "Slide indicators",
|
|
99
|
+
children: slides.map((_, index) => {
|
|
100
|
+
const isActive = index === resolvedActiveIndex;
|
|
101
|
+
return /* @__PURE__ */ jsx("button", {
|
|
102
|
+
type: "button",
|
|
103
|
+
className: cx("pf-carousel__indicator", isActive && "pf-carousel__indicator--active"),
|
|
104
|
+
"aria-label": `Go to slide ${index + 1}`,
|
|
105
|
+
"aria-current": isActive ? "true" : void 0,
|
|
106
|
+
onClick: () => {
|
|
107
|
+
goToIndex(index);
|
|
108
|
+
}
|
|
109
|
+
}, `indicator-${index}`);
|
|
110
|
+
})
|
|
111
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
112
|
+
className: "pf-carousel__indicator-spacer",
|
|
113
|
+
"aria-hidden": true
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ jsx("button", {
|
|
116
|
+
type: "button",
|
|
117
|
+
className: "pf-carousel__nav",
|
|
118
|
+
"aria-label": "Next slide",
|
|
119
|
+
disabled: isNextDisabled || totalSlides < 2,
|
|
120
|
+
onClick: () => {
|
|
121
|
+
goToIndex(resolvedActiveIndex + 1);
|
|
122
|
+
},
|
|
123
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
124
|
+
name: "square-caret-right",
|
|
125
|
+
"aria-hidden": true
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
})]
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
Carousel.displayName = "Carousel";
|
|
133
|
+
//#endregion
|
|
134
|
+
export { Carousel };
|
package/dist/index43.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region ../../node_modules/clsx/dist/clsx.mjs
|
|
2
|
+
function r(e) {
|
|
3
|
+
var t, f, n = "";
|
|
4
|
+
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
5
|
+
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
6
|
+
var o = e.length;
|
|
7
|
+
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
8
|
+
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
function clsx() {
|
|
12
|
+
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
13
|
+
return n;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { clsx as default };
|