@pitchfork-ui/react 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AvatarGroup/AvatarGroup.css +26 -0
- package/dist/components/AvatarGroup/AvatarGroup2.js +37 -0
- package/dist/components/Calendar/Calendar.css +0 -1
- package/dist/components/Combobox/Combobox.css +155 -0
- package/dist/components/Combobox/Combobox2.js +191 -0
- package/dist/components/CommandPalette/CommandPalette.css +225 -0
- package/dist/components/CommandPalette/CommandPalette2.js +195 -0
- package/dist/components/DateRangePicker/DateRangePicker.css +258 -0
- package/dist/components/DateRangePicker/DateRangePicker2.js +378 -0
- package/dist/components/Heatmap/Heatmap.css +4 -0
- package/dist/components/Icon/Icon2.js +43 -0
- package/dist/components/Kbd/Kbd.css +25 -0
- package/dist/components/Kbd/Kbd2.js +17 -0
- package/dist/components/NumberInput/NumberInput.css +98 -0
- package/dist/components/NumberInput/NumberInput2.js +165 -0
- package/dist/components/Pagination/Pagination.css +5 -2
- package/dist/components/Popover/Popover.css +46 -0
- package/dist/components/Popover/Popover2.js +76 -0
- package/dist/components/Toast/Toast.js +129 -0
- package/dist/index.cjs +1190 -24
- package/dist/index.js +9 -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 +986 -79
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -434,6 +434,49 @@ var customIcons = {
|
|
|
434
434
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M12 12v6" }),
|
|
435
435
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m15 15-3-3-3 3" })
|
|
436
436
|
]
|
|
437
|
+
}),
|
|
438
|
+
plus: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
439
|
+
width: "1em",
|
|
440
|
+
height: "1em",
|
|
441
|
+
viewBox: "0 0 24 24",
|
|
442
|
+
fill: "none",
|
|
443
|
+
stroke: "currentColor",
|
|
444
|
+
strokeWidth: "2.5",
|
|
445
|
+
strokeLinecap: "round",
|
|
446
|
+
strokeLinejoin: "round",
|
|
447
|
+
focusable: "false",
|
|
448
|
+
"aria-hidden": "true",
|
|
449
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M12 5v14" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M5 12h14" })]
|
|
450
|
+
}),
|
|
451
|
+
"magnifying-glass": /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
452
|
+
width: "1em",
|
|
453
|
+
height: "1em",
|
|
454
|
+
viewBox: "0 0 24 24",
|
|
455
|
+
fill: "none",
|
|
456
|
+
stroke: "currentColor",
|
|
457
|
+
strokeWidth: "2",
|
|
458
|
+
strokeLinecap: "round",
|
|
459
|
+
strokeLinejoin: "round",
|
|
460
|
+
focusable: "false",
|
|
461
|
+
"aria-hidden": "true",
|
|
462
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
463
|
+
cx: "11",
|
|
464
|
+
cy: "11",
|
|
465
|
+
r: "8"
|
|
466
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "m21 21-4.35-4.35" })]
|
|
467
|
+
}),
|
|
468
|
+
minus: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
469
|
+
width: "1em",
|
|
470
|
+
height: "1em",
|
|
471
|
+
viewBox: "0 0 24 24",
|
|
472
|
+
fill: "none",
|
|
473
|
+
stroke: "currentColor",
|
|
474
|
+
strokeWidth: "2.5",
|
|
475
|
+
strokeLinecap: "round",
|
|
476
|
+
strokeLinejoin: "round",
|
|
477
|
+
focusable: "false",
|
|
478
|
+
"aria-hidden": "true",
|
|
479
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M5 12h14" })
|
|
437
480
|
})
|
|
438
481
|
};
|
|
439
482
|
var regularIcons = {
|
|
@@ -676,6 +719,37 @@ var Avatar = (0, react.forwardRef)(({ src, alt, name, size = "md", status, class
|
|
|
676
719
|
});
|
|
677
720
|
Avatar.displayName = "Avatar";
|
|
678
721
|
//#endregion
|
|
722
|
+
//#region src/components/AvatarGroup/AvatarGroup.tsx
|
|
723
|
+
var AvatarGroup = (0, react.forwardRef)(function AvatarGroup({ className, avatars, max = 5, size = "md", total, label, ...props }, ref) {
|
|
724
|
+
const shown = avatars.slice(0, Math.max(0, max));
|
|
725
|
+
const overflow = (total ?? avatars.length) - shown.length;
|
|
726
|
+
const count = total ?? avatars.length;
|
|
727
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
728
|
+
ref,
|
|
729
|
+
className: cx("pf-avatar-group", `pf-avatar-group--${size}`, className),
|
|
730
|
+
role: "group",
|
|
731
|
+
"aria-label": label ?? `${count} ${count === 1 ? "person" : "people"}`,
|
|
732
|
+
...props,
|
|
733
|
+
children: [shown.map((avatar, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Avatar, {
|
|
734
|
+
size,
|
|
735
|
+
className: "pf-avatar-group__item",
|
|
736
|
+
style: { zIndex: shown.length - index },
|
|
737
|
+
...avatar
|
|
738
|
+
}, index)), overflow > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
739
|
+
className: cx("pf-avatar", `pf-avatar--${size}`, "pf-avatar-group__item", "pf-avatar-group__overflow"),
|
|
740
|
+
role: "img",
|
|
741
|
+
"aria-label": `${overflow} more`,
|
|
742
|
+
style: { zIndex: 0 },
|
|
743
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
744
|
+
className: "pf-avatar__fallback",
|
|
745
|
+
"aria-hidden": true,
|
|
746
|
+
children: ["+", overflow]
|
|
747
|
+
})
|
|
748
|
+
}) : null]
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
|
+
AvatarGroup.displayName = "AvatarGroup";
|
|
752
|
+
//#endregion
|
|
679
753
|
//#region src/components/Button/Button.tsx
|
|
680
754
|
var Spinner = () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
681
755
|
className: "pf-button__spinner",
|
|
@@ -709,6 +783,190 @@ var Button = (0, react.forwardRef)(({ className, variant = "primary", size = "md
|
|
|
709
783
|
});
|
|
710
784
|
Button.displayName = "Button";
|
|
711
785
|
//#endregion
|
|
786
|
+
//#region src/components/CommandPalette/CommandPalette.tsx
|
|
787
|
+
function CommandPalette({ open, onOpenChange, items, placeholder = "Search commands…", emptyMessage = "No results found." }) {
|
|
788
|
+
const inputId = (0, react.useId)();
|
|
789
|
+
const listId = (0, react.useId)();
|
|
790
|
+
const [query, setQuery] = (0, react.useState)("");
|
|
791
|
+
const dialogRef = (0, react.useRef)(null);
|
|
792
|
+
const inputRef = (0, react.useRef)(null);
|
|
793
|
+
const { isMounted, isExiting } = usePresence(open, 180);
|
|
794
|
+
(0, react.useEffect)(() => {
|
|
795
|
+
if (!open) return;
|
|
796
|
+
const frame = requestAnimationFrame(() => {
|
|
797
|
+
setQuery("");
|
|
798
|
+
inputRef.current?.focus();
|
|
799
|
+
});
|
|
800
|
+
return () => cancelAnimationFrame(frame);
|
|
801
|
+
}, [open]);
|
|
802
|
+
(0, react.useEffect)(() => {
|
|
803
|
+
if (!isMounted || typeof document === "undefined") return;
|
|
804
|
+
const prev = document.body.style.overflow;
|
|
805
|
+
document.body.style.overflow = "hidden";
|
|
806
|
+
return () => {
|
|
807
|
+
document.body.style.overflow = prev;
|
|
808
|
+
};
|
|
809
|
+
}, [isMounted]);
|
|
810
|
+
useFocusTrap({
|
|
811
|
+
containerRef: dialogRef,
|
|
812
|
+
enabled: open,
|
|
813
|
+
onEscape: () => onOpenChange(false)
|
|
814
|
+
});
|
|
815
|
+
const filtered = (0, react.useMemo)(() => {
|
|
816
|
+
const q = query.trim().toLowerCase();
|
|
817
|
+
if (!q) return items;
|
|
818
|
+
return items.filter((item) => item.label.toLowerCase().includes(q) || item.description?.toLowerCase().includes(q) || item.group?.toLowerCase().includes(q));
|
|
819
|
+
}, [items, query]);
|
|
820
|
+
const { activeIndex, move, setActiveIndex } = useListNavigation({
|
|
821
|
+
items: filtered,
|
|
822
|
+
isDisabled: (item) => !!item.disabled
|
|
823
|
+
});
|
|
824
|
+
(0, react.useEffect)(() => {
|
|
825
|
+
setActiveIndex(0);
|
|
826
|
+
}, [query, setActiveIndex]);
|
|
827
|
+
const selectActive = () => {
|
|
828
|
+
const item = filtered[activeIndex];
|
|
829
|
+
if (item && !item.disabled) {
|
|
830
|
+
item.onSelect();
|
|
831
|
+
onOpenChange(false);
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
const onKeyDown = (e) => {
|
|
835
|
+
if (e.key === Keys.ArrowDown) {
|
|
836
|
+
e.preventDefault();
|
|
837
|
+
move("next");
|
|
838
|
+
} else if (e.key === Keys.ArrowUp) {
|
|
839
|
+
e.preventDefault();
|
|
840
|
+
move("previous");
|
|
841
|
+
} else if (e.key === Keys.Home) {
|
|
842
|
+
e.preventDefault();
|
|
843
|
+
move("first");
|
|
844
|
+
} else if (e.key === Keys.End) {
|
|
845
|
+
e.preventDefault();
|
|
846
|
+
move("last");
|
|
847
|
+
} else if (e.key === Keys.Enter) {
|
|
848
|
+
e.preventDefault();
|
|
849
|
+
selectActive();
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
const groupedItems = (0, react.useMemo)(() => {
|
|
853
|
+
const groups = [];
|
|
854
|
+
const seen = /* @__PURE__ */ new Map();
|
|
855
|
+
filtered.forEach((item, index) => {
|
|
856
|
+
const g = item.group;
|
|
857
|
+
if (!seen.has(g)) {
|
|
858
|
+
seen.set(g, groups.length);
|
|
859
|
+
groups.push({
|
|
860
|
+
group: g,
|
|
861
|
+
items: []
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
groups[seen.get(g)].items.push({
|
|
865
|
+
item,
|
|
866
|
+
index
|
|
867
|
+
});
|
|
868
|
+
});
|
|
869
|
+
return groups;
|
|
870
|
+
}, [filtered]);
|
|
871
|
+
const activeOptionId = filtered[activeIndex] ? `${listId}-option-${activeIndex}` : void 0;
|
|
872
|
+
if (!isMounted || typeof document === "undefined") return null;
|
|
873
|
+
return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
874
|
+
className: cx("pf-command__backdrop", isExiting && "pf-command__backdrop--exiting"),
|
|
875
|
+
onClick: () => onOpenChange(false),
|
|
876
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
877
|
+
ref: dialogRef,
|
|
878
|
+
className: cx("pf-command", isExiting && "pf-command--exiting"),
|
|
879
|
+
role: "dialog",
|
|
880
|
+
"aria-modal": "true",
|
|
881
|
+
"aria-label": "Command palette",
|
|
882
|
+
tabIndex: -1,
|
|
883
|
+
onClick: (e) => e.stopPropagation(),
|
|
884
|
+
onKeyDown,
|
|
885
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
886
|
+
className: "pf-command__search",
|
|
887
|
+
children: [
|
|
888
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
889
|
+
name: "magnifying-glass",
|
|
890
|
+
"aria-hidden": true,
|
|
891
|
+
className: "pf-command__search-icon"
|
|
892
|
+
}),
|
|
893
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
894
|
+
ref: inputRef,
|
|
895
|
+
id: inputId,
|
|
896
|
+
type: "text",
|
|
897
|
+
className: "pf-command__input",
|
|
898
|
+
value: query,
|
|
899
|
+
placeholder,
|
|
900
|
+
autoComplete: "off",
|
|
901
|
+
spellCheck: false,
|
|
902
|
+
role: "combobox",
|
|
903
|
+
"aria-autocomplete": "list",
|
|
904
|
+
"aria-expanded": true,
|
|
905
|
+
"aria-controls": listId,
|
|
906
|
+
"aria-activedescendant": activeOptionId,
|
|
907
|
+
onChange: (e) => setQuery(e.target.value)
|
|
908
|
+
}),
|
|
909
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("kbd", {
|
|
910
|
+
className: "pf-command__esc-hint",
|
|
911
|
+
"aria-hidden": true,
|
|
912
|
+
children: "esc"
|
|
913
|
+
})
|
|
914
|
+
]
|
|
915
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
916
|
+
id: listId,
|
|
917
|
+
role: "listbox",
|
|
918
|
+
"aria-label": "Commands",
|
|
919
|
+
className: "pf-command__list",
|
|
920
|
+
children: filtered.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
921
|
+
className: "pf-command__empty",
|
|
922
|
+
role: "presentation",
|
|
923
|
+
children: emptyMessage
|
|
924
|
+
}) : groupedItems.map(({ group, items: groupItems }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
925
|
+
role: "presentation",
|
|
926
|
+
children: [group ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
927
|
+
className: "pf-command__group-label",
|
|
928
|
+
role: "presentation",
|
|
929
|
+
children: group
|
|
930
|
+
}) : null, groupItems.map(({ item, index }) => {
|
|
931
|
+
const isActive = index === activeIndex;
|
|
932
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
933
|
+
id: `${listId}-option-${index}`,
|
|
934
|
+
role: "option",
|
|
935
|
+
"aria-selected": isActive,
|
|
936
|
+
"aria-disabled": item.disabled ? true : void 0,
|
|
937
|
+
className: cx("pf-command__item", isActive && "pf-command__item--active", item.disabled && "pf-command__item--disabled"),
|
|
938
|
+
onMouseEnter: () => {
|
|
939
|
+
if (!item.disabled) setActiveIndex(index);
|
|
940
|
+
},
|
|
941
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
942
|
+
onClick: () => {
|
|
943
|
+
if (!item.disabled) {
|
|
944
|
+
item.onSelect();
|
|
945
|
+
onOpenChange(false);
|
|
946
|
+
}
|
|
947
|
+
},
|
|
948
|
+
children: [item.icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
949
|
+
className: "pf-command__item-icon",
|
|
950
|
+
"aria-hidden": true,
|
|
951
|
+
children: item.icon
|
|
952
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
953
|
+
className: "pf-command__item-content",
|
|
954
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
955
|
+
className: "pf-command__item-label",
|
|
956
|
+
children: item.label
|
|
957
|
+
}), item.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
958
|
+
className: "pf-command__item-description",
|
|
959
|
+
children: item.description
|
|
960
|
+
}) : null]
|
|
961
|
+
})]
|
|
962
|
+
}, item.id);
|
|
963
|
+
})]
|
|
964
|
+
}, group ?? "__ungrouped"))
|
|
965
|
+
})]
|
|
966
|
+
})
|
|
967
|
+
}), document.body);
|
|
968
|
+
}
|
|
969
|
+
//#endregion
|
|
712
970
|
//#region src/components/BadgeGroup/BadgeGroup.tsx
|
|
713
971
|
var BadgeGroup = (0, react.forwardRef)(({ label, message, color = "gray", appearance = "pill", badgePosition = "leading", className, ...props }, ref) => {
|
|
714
972
|
const badge = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -1145,7 +1403,7 @@ var Dropdown = (0, react.forwardRef)(({ label = "Actions", items, align = "start
|
|
|
1145
1403
|
Dropdown.displayName = "Dropdown";
|
|
1146
1404
|
//#endregion
|
|
1147
1405
|
//#region src/components/Calendar/Calendar.tsx
|
|
1148
|
-
var WEEKDAY_LABELS = [
|
|
1406
|
+
var WEEKDAY_LABELS$1 = [
|
|
1149
1407
|
"Su",
|
|
1150
1408
|
"Mo",
|
|
1151
1409
|
"Tu",
|
|
@@ -1161,22 +1419,22 @@ var MONTH_OPTIONS = Array.from({ length: 12 }, (_, month) => {
|
|
|
1161
1419
|
label: new Intl.DateTimeFormat("en-US", { month: "long" }).format(date)
|
|
1162
1420
|
};
|
|
1163
1421
|
});
|
|
1164
|
-
var toMidday$
|
|
1422
|
+
var toMidday$2 = (date) => {
|
|
1165
1423
|
const next = new Date(date);
|
|
1166
1424
|
next.setHours(12, 0, 0, 0);
|
|
1167
1425
|
return next;
|
|
1168
1426
|
};
|
|
1169
|
-
var isSameDay = (a, b) => {
|
|
1427
|
+
var isSameDay$1 = (a, b) => {
|
|
1170
1428
|
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
1171
1429
|
};
|
|
1172
|
-
var startOfMonth = (date) => {
|
|
1430
|
+
var startOfMonth$1 = (date) => {
|
|
1173
1431
|
return new Date(date.getFullYear(), date.getMonth(), 1, 12);
|
|
1174
1432
|
};
|
|
1175
|
-
var addMonths = (date, amount) => {
|
|
1433
|
+
var addMonths$1 = (date, amount) => {
|
|
1176
1434
|
return new Date(date.getFullYear(), date.getMonth() + amount, 1, 12);
|
|
1177
1435
|
};
|
|
1178
1436
|
var buildCalendarDays = (monthDate) => {
|
|
1179
|
-
const monthStart = startOfMonth(monthDate);
|
|
1437
|
+
const monthStart = startOfMonth$1(monthDate);
|
|
1180
1438
|
const firstWeekday = monthStart.getDay();
|
|
1181
1439
|
const gridStart = new Date(monthStart.getFullYear(), monthStart.getMonth(), monthStart.getDate() - firstWeekday, 12);
|
|
1182
1440
|
return Array.from({ length: 42 }, (_, index) => {
|
|
@@ -1198,7 +1456,7 @@ var Calendar = (0, react.forwardRef)(function Calendar({ className, value, defau
|
|
|
1198
1456
|
errorId
|
|
1199
1457
|
].filter(Boolean).join(" ") || void 0;
|
|
1200
1458
|
const isControlled = value !== void 0;
|
|
1201
|
-
const [internalValue, setInternalValue] = (0, react.useState)(defaultValue ? toMidday$
|
|
1459
|
+
const [internalValue, setInternalValue] = (0, react.useState)(defaultValue ? toMidday$2(defaultValue) : autoSelectToday ? toMidday$2(/* @__PURE__ */ new Date()) : void 0);
|
|
1202
1460
|
const selectedDate = isControlled ? value : internalValue;
|
|
1203
1461
|
const yearRange = (0, react.useMemo)(() => {
|
|
1204
1462
|
const fallbackStart = (/* @__PURE__ */ new Date()).getFullYear() - 50;
|
|
@@ -1217,11 +1475,11 @@ var Calendar = (0, react.forwardRef)(function Calendar({ className, value, defau
|
|
|
1217
1475
|
return date;
|
|
1218
1476
|
};
|
|
1219
1477
|
const [displayMonth, setDisplayMonth] = (0, react.useState)(() => {
|
|
1220
|
-
return clampToYearRange(startOfMonth(selectedDate ?? /* @__PURE__ */ new Date()));
|
|
1478
|
+
return clampToYearRange(startOfMonth$1(selectedDate ?? /* @__PURE__ */ new Date()));
|
|
1221
1479
|
});
|
|
1222
1480
|
(0, react.useEffect)(() => {
|
|
1223
1481
|
if (!selectedDate) return;
|
|
1224
|
-
setDisplayMonth(clampToYearRange(startOfMonth(selectedDate)));
|
|
1482
|
+
setDisplayMonth(clampToYearRange(startOfMonth$1(selectedDate)));
|
|
1225
1483
|
}, [
|
|
1226
1484
|
selectedDate,
|
|
1227
1485
|
yearRange.end,
|
|
@@ -1242,12 +1500,12 @@ var Calendar = (0, react.forwardRef)(function Calendar({ className, value, defau
|
|
|
1242
1500
|
const dayItems = (0, react.useMemo)(() => {
|
|
1243
1501
|
return buildCalendarDays(displayMonth);
|
|
1244
1502
|
}, [displayMonth]);
|
|
1245
|
-
const today = (0, react.useMemo)(() => toMidday$
|
|
1503
|
+
const today = (0, react.useMemo)(() => toMidday$2(/* @__PURE__ */ new Date()), []);
|
|
1246
1504
|
const selectDate = (nextDate) => {
|
|
1247
1505
|
if (disabledDates?.(nextDate)) return;
|
|
1248
1506
|
if (!isControlled) setInternalValue(nextDate);
|
|
1249
1507
|
onValueChange?.(nextDate);
|
|
1250
|
-
setDisplayMonth(clampToYearRange(startOfMonth(nextDate)));
|
|
1508
|
+
setDisplayMonth(clampToYearRange(startOfMonth$1(nextDate)));
|
|
1251
1509
|
};
|
|
1252
1510
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1253
1511
|
className: "pf-field",
|
|
@@ -1273,7 +1531,7 @@ var Calendar = (0, react.forwardRef)(function Calendar({ className, value, defau
|
|
|
1273
1531
|
"aria-label": "Previous month",
|
|
1274
1532
|
disabled: isPrevMonthDisabled,
|
|
1275
1533
|
onClick: () => {
|
|
1276
|
-
setDisplayMonth((current) => clampToYearRange(addMonths(current, -1)));
|
|
1534
|
+
setDisplayMonth((current) => clampToYearRange(addMonths$1(current, -1)));
|
|
1277
1535
|
},
|
|
1278
1536
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
1279
1537
|
name: "square-caret-left",
|
|
@@ -1324,7 +1582,7 @@ var Calendar = (0, react.forwardRef)(function Calendar({ className, value, defau
|
|
|
1324
1582
|
"aria-label": "Next month",
|
|
1325
1583
|
disabled: isNextMonthDisabled,
|
|
1326
1584
|
onClick: () => {
|
|
1327
|
-
setDisplayMonth((current) => clampToYearRange(addMonths(current, 1)));
|
|
1585
|
+
setDisplayMonth((current) => clampToYearRange(addMonths$1(current, 1)));
|
|
1328
1586
|
},
|
|
1329
1587
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
1330
1588
|
name: "square-caret-right",
|
|
@@ -1340,7 +1598,7 @@ var Calendar = (0, react.forwardRef)(function Calendar({ className, value, defau
|
|
|
1340
1598
|
role: "row",
|
|
1341
1599
|
style: { display: "contents" },
|
|
1342
1600
|
"aria-hidden": true,
|
|
1343
|
-
children: WEEKDAY_LABELS.map((day) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1601
|
+
children: WEEKDAY_LABELS$1.map((day) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1344
1602
|
role: "columnheader",
|
|
1345
1603
|
className: "pf-calendar__weekday",
|
|
1346
1604
|
children: day
|
|
@@ -1349,8 +1607,8 @@ var Calendar = (0, react.forwardRef)(function Calendar({ className, value, defau
|
|
|
1349
1607
|
role: "row",
|
|
1350
1608
|
style: { display: "contents" },
|
|
1351
1609
|
children: dayItems.slice(week * 7, (week + 1) * 7).map(({ date, inCurrentMonth }) => {
|
|
1352
|
-
const isSelected = selectedDate ? isSameDay(selectedDate, date) : false;
|
|
1353
|
-
const isToday = isSameDay(today, date);
|
|
1610
|
+
const isSelected = selectedDate ? isSameDay$1(selectedDate, date) : false;
|
|
1611
|
+
const isToday = isSameDay$1(today, date);
|
|
1354
1612
|
const isDisabled = Boolean(disabledDates?.(date));
|
|
1355
1613
|
if (!showOutsideDays && !inCurrentMonth) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1356
1614
|
className: "pf-calendar__day-empty",
|
|
@@ -1393,16 +1651,16 @@ var Calendar = (0, react.forwardRef)(function Calendar({ className, value, defau
|
|
|
1393
1651
|
Calendar.displayName = "Calendar";
|
|
1394
1652
|
//#endregion
|
|
1395
1653
|
//#region src/components/Carousel/Carousel.tsx
|
|
1396
|
-
var clamp$
|
|
1654
|
+
var clamp$3 = (value, min, max) => {
|
|
1397
1655
|
return Math.min(Math.max(value, min), max);
|
|
1398
1656
|
};
|
|
1399
1657
|
var Carousel = (0, react.forwardRef)(function Carousel({ className, slides, initialIndex = 0, loop = true, showIndicators = true, autoPlay = false, autoPlayInterval = 5e3, onIndexChange, "aria-label": ariaLabel = "Carousel", ...props }, ref) {
|
|
1400
1658
|
const totalSlides = slides.length;
|
|
1401
|
-
const [activeIndex, setActiveIndex] = (0, react.useState)(clamp$
|
|
1402
|
-
const resolvedActiveIndex = clamp$
|
|
1659
|
+
const [activeIndex, setActiveIndex] = (0, react.useState)(clamp$3(initialIndex, 0, Math.max(totalSlides - 1, 0)));
|
|
1660
|
+
const resolvedActiveIndex = clamp$3(activeIndex, 0, Math.max(totalSlides - 1, 0));
|
|
1403
1661
|
const goToIndex = (nextIndex) => {
|
|
1404
1662
|
if (totalSlides === 0) return;
|
|
1405
|
-
const resolvedIndex = loop ? (nextIndex % totalSlides + totalSlides) % totalSlides : clamp$
|
|
1663
|
+
const resolvedIndex = loop ? (nextIndex % totalSlides + totalSlides) % totalSlides : clamp$3(nextIndex, 0, totalSlides - 1);
|
|
1406
1664
|
setActiveIndex(resolvedIndex);
|
|
1407
1665
|
onIndexChange?.(resolvedIndex);
|
|
1408
1666
|
};
|
|
@@ -1649,6 +1907,183 @@ var CodeSnippet = (0, react.forwardRef)(function CodeSnippet({ className, code,
|
|
|
1649
1907
|
});
|
|
1650
1908
|
CodeSnippet.displayName = "CodeSnippet";
|
|
1651
1909
|
//#endregion
|
|
1910
|
+
//#region src/components/Combobox/Combobox.tsx
|
|
1911
|
+
var Combobox = (0, react.forwardRef)(function Combobox({ id, options, value, defaultValue, onValueChange, label, description, error, placeholder = "Search…", emptyMessage = "No matches", name, required, className, disabled, "aria-describedby": ariaDescribedBy, ...props }, ref) {
|
|
1912
|
+
const generatedId = (0, react.useId)();
|
|
1913
|
+
const fieldId = id ?? generatedId;
|
|
1914
|
+
const listboxId = `${fieldId}-listbox`;
|
|
1915
|
+
const descriptionId = description ? `${fieldId}-description` : void 0;
|
|
1916
|
+
const errorId = error ? `${fieldId}-error` : void 0;
|
|
1917
|
+
const describedBy = composeDescribedBy(ariaDescribedBy, descriptionId, errorId);
|
|
1918
|
+
const [selectedValue, setSelectedValue] = useControllableState({
|
|
1919
|
+
value,
|
|
1920
|
+
defaultValue: defaultValue ?? "",
|
|
1921
|
+
onChange: onValueChange
|
|
1922
|
+
});
|
|
1923
|
+
const selectedOption = options.find((option) => option.value === selectedValue);
|
|
1924
|
+
const [query, setQuery] = (0, react.useState)(() => selectedOption?.label ?? "");
|
|
1925
|
+
const [isOpen, setIsOpen] = (0, react.useState)(false);
|
|
1926
|
+
const [activeIndex, setActiveIndex] = (0, react.useState)(0);
|
|
1927
|
+
const rootRef = (0, react.useRef)(null);
|
|
1928
|
+
const inputRef = (0, react.useRef)(null);
|
|
1929
|
+
const listboxRef = (0, react.useRef)(null);
|
|
1930
|
+
const inputRefs = useComposedRefs(inputRef, ref);
|
|
1931
|
+
const { isMounted, isExiting } = usePresence(isOpen, 160);
|
|
1932
|
+
const menuStyle = useAnchoredPosition({
|
|
1933
|
+
anchorRef: rootRef,
|
|
1934
|
+
floatingRef: listboxRef,
|
|
1935
|
+
enabled: isOpen,
|
|
1936
|
+
matchAnchorWidth: true,
|
|
1937
|
+
flip: true
|
|
1938
|
+
});
|
|
1939
|
+
const filtered = (0, react.useMemo)(() => {
|
|
1940
|
+
const q = query.trim().toLowerCase();
|
|
1941
|
+
const fromSelection = selectedOption && query === selectedOption.label;
|
|
1942
|
+
if (!q || fromSelection) return options;
|
|
1943
|
+
return options.filter((option) => option.label.toLowerCase().includes(q));
|
|
1944
|
+
}, [
|
|
1945
|
+
options,
|
|
1946
|
+
query,
|
|
1947
|
+
selectedOption
|
|
1948
|
+
]);
|
|
1949
|
+
useOutsideInteraction({
|
|
1950
|
+
refs: [rootRef, listboxRef],
|
|
1951
|
+
enabled: isOpen,
|
|
1952
|
+
onInteractOutside: () => closeAndRevert()
|
|
1953
|
+
});
|
|
1954
|
+
const open = () => {
|
|
1955
|
+
if (disabled) return;
|
|
1956
|
+
setIsOpen(true);
|
|
1957
|
+
setActiveIndex(0);
|
|
1958
|
+
};
|
|
1959
|
+
const closeAndRevert = () => {
|
|
1960
|
+
setIsOpen(false);
|
|
1961
|
+
setQuery(selectedOption?.label ?? "");
|
|
1962
|
+
};
|
|
1963
|
+
const selectOption = (option) => {
|
|
1964
|
+
if (option.disabled) return;
|
|
1965
|
+
setSelectedValue(option.value);
|
|
1966
|
+
setQuery(option.label);
|
|
1967
|
+
setIsOpen(false);
|
|
1968
|
+
};
|
|
1969
|
+
const onKeyDown = (event) => {
|
|
1970
|
+
if (disabled) return;
|
|
1971
|
+
if (event.key === Keys.ArrowDown) {
|
|
1972
|
+
event.preventDefault();
|
|
1973
|
+
if (!isOpen) {
|
|
1974
|
+
open();
|
|
1975
|
+
return;
|
|
1976
|
+
}
|
|
1977
|
+
setActiveIndex((index) => Math.min(index + 1, filtered.length - 1));
|
|
1978
|
+
return;
|
|
1979
|
+
}
|
|
1980
|
+
if (event.key === Keys.ArrowUp) {
|
|
1981
|
+
event.preventDefault();
|
|
1982
|
+
if (isOpen) setActiveIndex((index) => Math.max(index - 1, 0));
|
|
1983
|
+
return;
|
|
1984
|
+
}
|
|
1985
|
+
if (event.key === Keys.Enter) {
|
|
1986
|
+
if (isOpen && filtered[activeIndex]) {
|
|
1987
|
+
event.preventDefault();
|
|
1988
|
+
selectOption(filtered[activeIndex]);
|
|
1989
|
+
}
|
|
1990
|
+
return;
|
|
1991
|
+
}
|
|
1992
|
+
if (event.key === Keys.Escape) {
|
|
1993
|
+
if (isOpen) {
|
|
1994
|
+
event.preventDefault();
|
|
1995
|
+
closeAndRevert();
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
const activeOptionId = isOpen && filtered[activeIndex] ? `${listboxId}-option-${activeIndex}` : void 0;
|
|
2000
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldWrapper, {
|
|
2001
|
+
labelFor: fieldId,
|
|
2002
|
+
label,
|
|
2003
|
+
description,
|
|
2004
|
+
descriptionId,
|
|
2005
|
+
error,
|
|
2006
|
+
errorId,
|
|
2007
|
+
required,
|
|
2008
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2009
|
+
className: "pf-combobox",
|
|
2010
|
+
ref: rootRef,
|
|
2011
|
+
children: [
|
|
2012
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2013
|
+
className: cx("pf-combobox__control", error && "pf-combobox__control--invalid"),
|
|
2014
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2015
|
+
...props,
|
|
2016
|
+
id: fieldId,
|
|
2017
|
+
ref: inputRefs,
|
|
2018
|
+
type: "text",
|
|
2019
|
+
role: "combobox",
|
|
2020
|
+
className: cx("pf-combobox__input", className),
|
|
2021
|
+
value: query,
|
|
2022
|
+
placeholder,
|
|
2023
|
+
disabled,
|
|
2024
|
+
required,
|
|
2025
|
+
autoComplete: "off",
|
|
2026
|
+
"aria-autocomplete": "list",
|
|
2027
|
+
"aria-expanded": isOpen,
|
|
2028
|
+
"aria-controls": listboxId,
|
|
2029
|
+
"aria-activedescendant": activeOptionId,
|
|
2030
|
+
"aria-describedby": describedBy,
|
|
2031
|
+
onChange: (event) => {
|
|
2032
|
+
setQuery(event.target.value);
|
|
2033
|
+
setActiveIndex(0);
|
|
2034
|
+
if (!isOpen) setIsOpen(true);
|
|
2035
|
+
},
|
|
2036
|
+
onClick: open,
|
|
2037
|
+
onKeyDown
|
|
2038
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2039
|
+
"aria-hidden": true,
|
|
2040
|
+
className: cx("pf-combobox__icon", isOpen && "pf-combobox__icon--open"),
|
|
2041
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
2042
|
+
name: "chevron-down",
|
|
2043
|
+
"aria-hidden": true
|
|
2044
|
+
})
|
|
2045
|
+
})]
|
|
2046
|
+
}),
|
|
2047
|
+
name ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
2048
|
+
type: "hidden",
|
|
2049
|
+
name,
|
|
2050
|
+
value: selectedValue
|
|
2051
|
+
}) : null,
|
|
2052
|
+
isMounted && typeof document !== "undefined" ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
2053
|
+
id: listboxId,
|
|
2054
|
+
ref: listboxRef,
|
|
2055
|
+
role: "listbox",
|
|
2056
|
+
className: cx("pf-combobox__menu", isExiting && "pf-combobox__menu--exiting"),
|
|
2057
|
+
style: menuStyle,
|
|
2058
|
+
"aria-label": label,
|
|
2059
|
+
children: filtered.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
2060
|
+
className: "pf-combobox__empty",
|
|
2061
|
+
role: "presentation",
|
|
2062
|
+
children: emptyMessage
|
|
2063
|
+
}) : filtered.map((option, index) => {
|
|
2064
|
+
const isSelected = option.value === selectedValue;
|
|
2065
|
+
const isActive = index === activeIndex;
|
|
2066
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
2067
|
+
id: `${listboxId}-option-${index}`,
|
|
2068
|
+
role: "option",
|
|
2069
|
+
"aria-selected": isSelected,
|
|
2070
|
+
"aria-disabled": option.disabled ? true : void 0,
|
|
2071
|
+
className: cx("pf-combobox__option", isSelected && "pf-combobox__option--selected", isActive && "pf-combobox__option--active", option.disabled && "pf-combobox__option--disabled"),
|
|
2072
|
+
onMouseEnter: () => {
|
|
2073
|
+
if (!option.disabled) setActiveIndex(index);
|
|
2074
|
+
},
|
|
2075
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
2076
|
+
onClick: () => selectOption(option),
|
|
2077
|
+
children: option.label
|
|
2078
|
+
}, option.value);
|
|
2079
|
+
})
|
|
2080
|
+
}), document.body) : null
|
|
2081
|
+
]
|
|
2082
|
+
})
|
|
2083
|
+
});
|
|
2084
|
+
});
|
|
2085
|
+
Combobox.displayName = "Combobox";
|
|
2086
|
+
//#endregion
|
|
1652
2087
|
//#region src/components/ContentDivider/ContentDivider.tsx
|
|
1653
2088
|
var ContentDivider = (0, react.forwardRef)(({ className, label, orientation = "horizontal", inset = false, ...props }, ref) => {
|
|
1654
2089
|
if (orientation === "vertical") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1686,7 +2121,7 @@ var ContentDivider = (0, react.forwardRef)(({ className, label, orientation = "h
|
|
|
1686
2121
|
ContentDivider.displayName = "ContentDivider";
|
|
1687
2122
|
//#endregion
|
|
1688
2123
|
//#region src/components/DatePicker/DatePicker.tsx
|
|
1689
|
-
var toMidday = (date) => {
|
|
2124
|
+
var toMidday$1 = (date) => {
|
|
1690
2125
|
const next = new Date(date);
|
|
1691
2126
|
next.setHours(12, 0, 0, 0);
|
|
1692
2127
|
return next;
|
|
@@ -1698,8 +2133,8 @@ var DatePicker = (0, react.forwardRef)(function DatePicker({ id, className, valu
|
|
|
1698
2133
|
const errorId = error ? `${pickerId}-error` : void 0;
|
|
1699
2134
|
const describedBy = composeDescribedBy(ariaDescribedBy, descriptionId, errorId);
|
|
1700
2135
|
const isControlled = value !== void 0;
|
|
1701
|
-
const [internalValue, setInternalValue] = (0, react.useState)(defaultValue ? toMidday(defaultValue) : void 0);
|
|
1702
|
-
const selectedDate = isControlled ? value ? toMidday(value) : void 0 : internalValue;
|
|
2136
|
+
const [internalValue, setInternalValue] = (0, react.useState)(defaultValue ? toMidday$1(defaultValue) : void 0);
|
|
2137
|
+
const selectedDate = isControlled ? value ? toMidday$1(value) : void 0 : internalValue;
|
|
1703
2138
|
const disclosure = useDisclosure({ disabled });
|
|
1704
2139
|
const { isOpen } = disclosure;
|
|
1705
2140
|
const rootRef = (0, react.useRef)(null);
|
|
@@ -1727,7 +2162,7 @@ var DatePicker = (0, react.forwardRef)(function DatePicker({ id, className, valu
|
|
|
1727
2162
|
}).format(selectedDate);
|
|
1728
2163
|
}, [selectedDate]);
|
|
1729
2164
|
const selectDate = (nextDate) => {
|
|
1730
|
-
const normalized = toMidday(nextDate);
|
|
2165
|
+
const normalized = toMidday$1(nextDate);
|
|
1731
2166
|
if (!isControlled) setInternalValue(normalized);
|
|
1732
2167
|
onValueChange?.(normalized);
|
|
1733
2168
|
disclosure.close();
|
|
@@ -1807,6 +2242,372 @@ var DatePicker = (0, react.forwardRef)(function DatePicker({ id, className, valu
|
|
|
1807
2242
|
});
|
|
1808
2243
|
DatePicker.displayName = "DatePicker";
|
|
1809
2244
|
//#endregion
|
|
2245
|
+
//#region src/components/DateRangePicker/DateRangePicker.tsx
|
|
2246
|
+
var WEEKDAY_LABELS = [
|
|
2247
|
+
"Su",
|
|
2248
|
+
"Mo",
|
|
2249
|
+
"Tu",
|
|
2250
|
+
"We",
|
|
2251
|
+
"Th",
|
|
2252
|
+
"Fr",
|
|
2253
|
+
"Sa"
|
|
2254
|
+
];
|
|
2255
|
+
var toMidday = (d) => {
|
|
2256
|
+
const n = new Date(d);
|
|
2257
|
+
n.setHours(12, 0, 0, 0);
|
|
2258
|
+
return n;
|
|
2259
|
+
};
|
|
2260
|
+
var isSameDay = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
2261
|
+
var startOfMonth = (d) => new Date(d.getFullYear(), d.getMonth(), 1, 12);
|
|
2262
|
+
var addMonths = (d, n) => new Date(d.getFullYear(), d.getMonth() + n, 1, 12);
|
|
2263
|
+
var buildDays = (monthDate) => {
|
|
2264
|
+
const ms = startOfMonth(monthDate);
|
|
2265
|
+
const firstDay = ms.getDay();
|
|
2266
|
+
return Array.from({ length: 42 }, (_, i) => {
|
|
2267
|
+
const date = new Date(ms.getFullYear(), ms.getMonth(), ms.getDate() - firstDay + i, 12);
|
|
2268
|
+
return {
|
|
2269
|
+
date,
|
|
2270
|
+
inCurrentMonth: date.getMonth() === monthDate.getMonth()
|
|
2271
|
+
};
|
|
2272
|
+
});
|
|
2273
|
+
};
|
|
2274
|
+
var formatDate = (d) => {
|
|
2275
|
+
if (!d) return "";
|
|
2276
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
2277
|
+
month: "short",
|
|
2278
|
+
day: "numeric",
|
|
2279
|
+
year: "numeric"
|
|
2280
|
+
}).format(d);
|
|
2281
|
+
};
|
|
2282
|
+
function RangeCalendar({ monthDate, rangeStart, rangeEnd, hoverDate, onDayClick, onDayHover, disabledDates, showOutsideDays = true, isPrevDisabled, isNextDisabled, onPrev, onNext, hideNavDesktop = false }) {
|
|
2283
|
+
const days = (0, react.useMemo)(() => buildDays(monthDate), [monthDate]);
|
|
2284
|
+
const today = (0, react.useMemo)(() => toMidday(/* @__PURE__ */ new Date()), []);
|
|
2285
|
+
const monthLabel = new Intl.DateTimeFormat("en-US", {
|
|
2286
|
+
month: "long",
|
|
2287
|
+
year: "numeric"
|
|
2288
|
+
}).format(monthDate);
|
|
2289
|
+
const effectiveEnd = rangeEnd ?? hoverDate;
|
|
2290
|
+
const isInRange = (0, react.useCallback)((date) => {
|
|
2291
|
+
if (!rangeStart || !effectiveEnd) return false;
|
|
2292
|
+
return date > (rangeStart <= effectiveEnd ? rangeStart : effectiveEnd) && date < (rangeStart <= effectiveEnd ? effectiveEnd : rangeStart);
|
|
2293
|
+
}, [rangeStart, effectiveEnd]);
|
|
2294
|
+
const isRangeStart = (date) => !!rangeStart && isSameDay(date, rangeStart);
|
|
2295
|
+
const isRangeEnd = (date) => {
|
|
2296
|
+
const end = rangeEnd ?? (hoverDate && rangeStart ? hoverDate : null);
|
|
2297
|
+
return !!end && isSameDay(date, end);
|
|
2298
|
+
};
|
|
2299
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2300
|
+
className: "pf-daterange__calendar",
|
|
2301
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2302
|
+
className: cx("pf-daterange__cal-header", hideNavDesktop && "pf-daterange__cal-header--hide-nav-desktop"),
|
|
2303
|
+
children: [
|
|
2304
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2305
|
+
type: "button",
|
|
2306
|
+
className: "pf-daterange__nav",
|
|
2307
|
+
"aria-label": "Previous month",
|
|
2308
|
+
disabled: isPrevDisabled,
|
|
2309
|
+
onClick: onPrev,
|
|
2310
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
2311
|
+
name: "chevron-left",
|
|
2312
|
+
"aria-hidden": true
|
|
2313
|
+
})
|
|
2314
|
+
}),
|
|
2315
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2316
|
+
className: "pf-daterange__cal-title",
|
|
2317
|
+
children: monthLabel
|
|
2318
|
+
}),
|
|
2319
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2320
|
+
type: "button",
|
|
2321
|
+
className: "pf-daterange__nav",
|
|
2322
|
+
"aria-label": "Next month",
|
|
2323
|
+
disabled: isNextDisabled,
|
|
2324
|
+
onClick: onNext,
|
|
2325
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
2326
|
+
name: "chevron-right",
|
|
2327
|
+
"aria-hidden": true
|
|
2328
|
+
})
|
|
2329
|
+
})
|
|
2330
|
+
]
|
|
2331
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2332
|
+
className: "pf-daterange__grid",
|
|
2333
|
+
role: "grid",
|
|
2334
|
+
"aria-label": monthLabel,
|
|
2335
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2336
|
+
role: "row",
|
|
2337
|
+
style: { display: "contents" },
|
|
2338
|
+
"aria-hidden": true,
|
|
2339
|
+
children: WEEKDAY_LABELS.map((d) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2340
|
+
role: "columnheader",
|
|
2341
|
+
className: "pf-daterange__weekday",
|
|
2342
|
+
children: d
|
|
2343
|
+
}, d))
|
|
2344
|
+
}), Array.from({ length: 6 }, (_, week) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2345
|
+
role: "row",
|
|
2346
|
+
style: { display: "contents" },
|
|
2347
|
+
children: days.slice(week * 7, (week + 1) * 7).map(({ date, inCurrentMonth }) => {
|
|
2348
|
+
const isToday = isSameDay(today, date);
|
|
2349
|
+
const isStart = isRangeStart(date);
|
|
2350
|
+
const isEnd = isRangeEnd(date);
|
|
2351
|
+
const inRng = isInRange(date);
|
|
2352
|
+
const isDisabled = Boolean(disabledDates?.(date));
|
|
2353
|
+
if (!showOutsideDays && !inCurrentMonth) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2354
|
+
className: "pf-daterange__day-empty",
|
|
2355
|
+
"aria-hidden": true
|
|
2356
|
+
}, date.toISOString());
|
|
2357
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2358
|
+
type: "button",
|
|
2359
|
+
role: "gridcell",
|
|
2360
|
+
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"),
|
|
2361
|
+
"aria-label": new Intl.DateTimeFormat("en-US", {
|
|
2362
|
+
month: "long",
|
|
2363
|
+
day: "numeric",
|
|
2364
|
+
year: "numeric"
|
|
2365
|
+
}).format(date),
|
|
2366
|
+
"aria-selected": isStart || isEnd || inRng,
|
|
2367
|
+
"aria-current": isToday ? "date" : void 0,
|
|
2368
|
+
disabled: isDisabled,
|
|
2369
|
+
onClick: () => onDayClick(date),
|
|
2370
|
+
onMouseEnter: () => onDayHover(date),
|
|
2371
|
+
onMouseLeave: () => onDayHover(null),
|
|
2372
|
+
children: date.getDate()
|
|
2373
|
+
}, date.toISOString());
|
|
2374
|
+
})
|
|
2375
|
+
}, week))]
|
|
2376
|
+
})]
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
var DateRangePicker = (0, react.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) {
|
|
2380
|
+
const generatedId = (0, react.useId)();
|
|
2381
|
+
const pickerId = id ?? generatedId;
|
|
2382
|
+
const descriptionId = description ? `${pickerId}-description` : void 0;
|
|
2383
|
+
const errorId = error ? `${pickerId}-error` : void 0;
|
|
2384
|
+
const describedBy = composeDescribedBy(ariaDescribedBy, descriptionId, errorId);
|
|
2385
|
+
const isControlled = value !== void 0;
|
|
2386
|
+
const [internalRange, setInternalRange] = (0, react.useState)(defaultValue ?? {
|
|
2387
|
+
start: null,
|
|
2388
|
+
end: null
|
|
2389
|
+
});
|
|
2390
|
+
const range = isControlled ? value : internalRange;
|
|
2391
|
+
const setRange = (next) => {
|
|
2392
|
+
if (!isControlled) setInternalRange(next);
|
|
2393
|
+
onValueChange?.(next);
|
|
2394
|
+
};
|
|
2395
|
+
const [selecting, setSelecting] = (0, react.useState)(null);
|
|
2396
|
+
const [hoverDate, setHoverDate] = (0, react.useState)(null);
|
|
2397
|
+
const yearRange = (0, react.useMemo)(() => {
|
|
2398
|
+
const fallbackStart = (/* @__PURE__ */ new Date()).getFullYear() - 50;
|
|
2399
|
+
const fallbackEnd = (/* @__PURE__ */ new Date()).getFullYear() + 50;
|
|
2400
|
+
return {
|
|
2401
|
+
start: startYear ?? fallbackStart,
|
|
2402
|
+
end: endYear ?? fallbackEnd
|
|
2403
|
+
};
|
|
2404
|
+
}, [startYear, endYear]);
|
|
2405
|
+
const clampMonth = (d) => {
|
|
2406
|
+
const y = d.getFullYear();
|
|
2407
|
+
if (y < yearRange.start) return new Date(yearRange.start, 0, 1, 12);
|
|
2408
|
+
if (y > yearRange.end) return new Date(yearRange.end, 11, 1, 12);
|
|
2409
|
+
return d;
|
|
2410
|
+
};
|
|
2411
|
+
const [leftMonth, setLeftMonth] = (0, react.useState)(() => clampMonth(startOfMonth(range.start ?? /* @__PURE__ */ new Date())));
|
|
2412
|
+
const rightMonth = addMonths(leftMonth, 1);
|
|
2413
|
+
const disclosure = useDisclosure({ disabled });
|
|
2414
|
+
const { isOpen } = disclosure;
|
|
2415
|
+
const rootRef = (0, react.useRef)(null);
|
|
2416
|
+
const triggerRef = (0, react.useRef)(null);
|
|
2417
|
+
const popoverRef = (0, react.useRef)(null);
|
|
2418
|
+
const popoverStyle = useAnchoredPosition({
|
|
2419
|
+
anchorRef: rootRef,
|
|
2420
|
+
floatingRef: popoverRef,
|
|
2421
|
+
enabled: isOpen,
|
|
2422
|
+
flip: true,
|
|
2423
|
+
matchAnchorWidth: false
|
|
2424
|
+
});
|
|
2425
|
+
useOutsideInteraction({
|
|
2426
|
+
refs: [rootRef, popoverRef],
|
|
2427
|
+
enabled: isOpen,
|
|
2428
|
+
eventName: "mousedown",
|
|
2429
|
+
onInteractOutside: () => {
|
|
2430
|
+
setSelecting(null);
|
|
2431
|
+
setHoverDate(null);
|
|
2432
|
+
disclosure.close();
|
|
2433
|
+
}
|
|
2434
|
+
});
|
|
2435
|
+
const handleDayClick = (date) => {
|
|
2436
|
+
if (selecting === null) {
|
|
2437
|
+
setRange({
|
|
2438
|
+
start: toMidday(date),
|
|
2439
|
+
end: null
|
|
2440
|
+
});
|
|
2441
|
+
setSelecting("start");
|
|
2442
|
+
} else {
|
|
2443
|
+
const start = range.start;
|
|
2444
|
+
const end = toMidday(date);
|
|
2445
|
+
if (isSameDay(start, end)) setRange({
|
|
2446
|
+
start: toMidday(date),
|
|
2447
|
+
end: null
|
|
2448
|
+
});
|
|
2449
|
+
else if (end < start) setRange({
|
|
2450
|
+
start: end,
|
|
2451
|
+
end: start
|
|
2452
|
+
});
|
|
2453
|
+
else setRange({
|
|
2454
|
+
start,
|
|
2455
|
+
end
|
|
2456
|
+
});
|
|
2457
|
+
setSelecting(null);
|
|
2458
|
+
setHoverDate(null);
|
|
2459
|
+
disclosure.close();
|
|
2460
|
+
}
|
|
2461
|
+
};
|
|
2462
|
+
const clearRange = () => {
|
|
2463
|
+
setRange({
|
|
2464
|
+
start: null,
|
|
2465
|
+
end: null
|
|
2466
|
+
});
|
|
2467
|
+
setSelecting(null);
|
|
2468
|
+
setHoverDate(null);
|
|
2469
|
+
};
|
|
2470
|
+
const isPrevDisabled = leftMonth.getFullYear() === yearRange.start && leftMonth.getMonth() === 0;
|
|
2471
|
+
const isNextDisabled = rightMonth.getFullYear() === yearRange.end && rightMonth.getMonth() === 11;
|
|
2472
|
+
const hasValue = range.start !== null || range.end !== null;
|
|
2473
|
+
const displayStart = formatDate(range.start);
|
|
2474
|
+
const displayEnd = formatDate(range.end);
|
|
2475
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldWrapper, {
|
|
2476
|
+
labelFor: `${pickerId}-trigger`,
|
|
2477
|
+
label,
|
|
2478
|
+
description,
|
|
2479
|
+
descriptionId,
|
|
2480
|
+
error,
|
|
2481
|
+
errorId,
|
|
2482
|
+
required,
|
|
2483
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2484
|
+
ref,
|
|
2485
|
+
...props,
|
|
2486
|
+
id: pickerId,
|
|
2487
|
+
className: cx("pf-daterange", className),
|
|
2488
|
+
"aria-describedby": describedBy,
|
|
2489
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2490
|
+
className: "pf-daterange__control-row",
|
|
2491
|
+
ref: rootRef,
|
|
2492
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2493
|
+
ref: triggerRef,
|
|
2494
|
+
id: `${pickerId}-trigger`,
|
|
2495
|
+
type: "button",
|
|
2496
|
+
className: cx("pf-daterange__trigger", error && "pf-daterange__trigger--invalid"),
|
|
2497
|
+
disabled,
|
|
2498
|
+
"aria-invalid": error ? true : void 0,
|
|
2499
|
+
"aria-haspopup": "dialog",
|
|
2500
|
+
"aria-expanded": isOpen,
|
|
2501
|
+
"aria-required": required || void 0,
|
|
2502
|
+
onClick: () => {
|
|
2503
|
+
if (!isOpen) setSelecting(null);
|
|
2504
|
+
disclosure.toggle();
|
|
2505
|
+
},
|
|
2506
|
+
onKeyDown: (e) => {
|
|
2507
|
+
if (e.key === Keys.Escape) disclosure.close();
|
|
2508
|
+
},
|
|
2509
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2510
|
+
className: "pf-daterange__value",
|
|
2511
|
+
children: displayStart ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
2512
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: displayStart }),
|
|
2513
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2514
|
+
className: "pf-daterange__separator",
|
|
2515
|
+
"aria-hidden": true,
|
|
2516
|
+
children: "–"
|
|
2517
|
+
}),
|
|
2518
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2519
|
+
className: cx(!displayEnd && "pf-daterange__value--placeholder"),
|
|
2520
|
+
children: displayEnd || endPlaceholder
|
|
2521
|
+
})
|
|
2522
|
+
] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2523
|
+
className: "pf-daterange__value--placeholder",
|
|
2524
|
+
children: [
|
|
2525
|
+
startPlaceholder,
|
|
2526
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2527
|
+
className: "pf-daterange__separator",
|
|
2528
|
+
"aria-hidden": true,
|
|
2529
|
+
children: [
|
|
2530
|
+
" ",
|
|
2531
|
+
"–",
|
|
2532
|
+
" "
|
|
2533
|
+
]
|
|
2534
|
+
}),
|
|
2535
|
+
endPlaceholder
|
|
2536
|
+
]
|
|
2537
|
+
})
|
|
2538
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
2539
|
+
name: "calendar",
|
|
2540
|
+
"aria-hidden": true
|
|
2541
|
+
})]
|
|
2542
|
+
}), hasValue ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2543
|
+
type: "button",
|
|
2544
|
+
className: "pf-date-picker__icon-button",
|
|
2545
|
+
"aria-label": "Clear date range",
|
|
2546
|
+
disabled,
|
|
2547
|
+
onClick: clearRange,
|
|
2548
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
2549
|
+
name: "circle-xmark",
|
|
2550
|
+
"aria-hidden": true
|
|
2551
|
+
})
|
|
2552
|
+
}) : null]
|
|
2553
|
+
}), isOpen && typeof document !== "undefined" ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2554
|
+
ref: popoverRef,
|
|
2555
|
+
className: "pf-daterange__popover",
|
|
2556
|
+
role: "dialog",
|
|
2557
|
+
"aria-label": "Date range picker",
|
|
2558
|
+
style: popoverStyle,
|
|
2559
|
+
onKeyDown: (e) => {
|
|
2560
|
+
if (e.key === Keys.Escape) {
|
|
2561
|
+
setSelecting(null);
|
|
2562
|
+
setHoverDate(null);
|
|
2563
|
+
disclosure.close();
|
|
2564
|
+
}
|
|
2565
|
+
},
|
|
2566
|
+
children: [selecting === "start" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2567
|
+
className: "pf-daterange__hint",
|
|
2568
|
+
"aria-live": "polite",
|
|
2569
|
+
children: "Select an end date"
|
|
2570
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2571
|
+
className: "pf-daterange__hint",
|
|
2572
|
+
"aria-live": "polite",
|
|
2573
|
+
children: "Select a start date"
|
|
2574
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2575
|
+
className: "pf-daterange__months",
|
|
2576
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RangeCalendar, {
|
|
2577
|
+
monthDate: leftMonth,
|
|
2578
|
+
rangeStart: range.start,
|
|
2579
|
+
rangeEnd: range.end,
|
|
2580
|
+
hoverDate: selecting === "start" ? hoverDate : null,
|
|
2581
|
+
onDayClick: handleDayClick,
|
|
2582
|
+
onDayHover: (d) => selecting === "start" && setHoverDate(d),
|
|
2583
|
+
disabledDates,
|
|
2584
|
+
showOutsideDays,
|
|
2585
|
+
isPrevDisabled,
|
|
2586
|
+
isNextDisabled: false,
|
|
2587
|
+
onPrev: () => setLeftMonth((m) => clampMonth(addMonths(m, -1))),
|
|
2588
|
+
onNext: () => setLeftMonth((m) => clampMonth(addMonths(m, 1)))
|
|
2589
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RangeCalendar, {
|
|
2590
|
+
monthDate: rightMonth,
|
|
2591
|
+
rangeStart: range.start,
|
|
2592
|
+
rangeEnd: range.end,
|
|
2593
|
+
hoverDate: selecting === "start" ? hoverDate : null,
|
|
2594
|
+
onDayClick: handleDayClick,
|
|
2595
|
+
onDayHover: (d) => selecting === "start" && setHoverDate(d),
|
|
2596
|
+
disabledDates,
|
|
2597
|
+
showOutsideDays,
|
|
2598
|
+
isPrevDisabled: false,
|
|
2599
|
+
isNextDisabled,
|
|
2600
|
+
onPrev: () => setLeftMonth((m) => clampMonth(addMonths(m, -1))),
|
|
2601
|
+
onNext: () => setLeftMonth((m) => clampMonth(addMonths(m, 1))),
|
|
2602
|
+
hideNavDesktop: true
|
|
2603
|
+
})]
|
|
2604
|
+
})]
|
|
2605
|
+
}), document.body) : null]
|
|
2606
|
+
})
|
|
2607
|
+
});
|
|
2608
|
+
});
|
|
2609
|
+
DateRangePicker.displayName = "DateRangePicker";
|
|
2610
|
+
//#endregion
|
|
1810
2611
|
//#region src/components/EmptyState/EmptyState.tsx
|
|
1811
2612
|
var EmptyState = (0, react.forwardRef)(function EmptyState({ className, heading, description, icon, iconName, action, size = "md", ...props }, ref) {
|
|
1812
2613
|
const resolvedIcon = icon ?? (iconName ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
@@ -2127,6 +2928,18 @@ var InlineCTA = (0, react.forwardRef)(function InlineCTA({ className, heading, d
|
|
|
2127
2928
|
});
|
|
2128
2929
|
InlineCTA.displayName = "InlineCTA";
|
|
2129
2930
|
//#endregion
|
|
2931
|
+
//#region src/components/Kbd/Kbd.tsx
|
|
2932
|
+
var Kbd = (0, react.forwardRef)(function Kbd({ className, keys, size = "md", separator = "+", children, ...props }, ref) {
|
|
2933
|
+
const content = keys && keys.length > 0 ? keys.join(` ${separator} `) : children;
|
|
2934
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("kbd", {
|
|
2935
|
+
ref,
|
|
2936
|
+
className: cx("pf-kbd", `pf-kbd--${size}`, className),
|
|
2937
|
+
...props,
|
|
2938
|
+
children: content
|
|
2939
|
+
});
|
|
2940
|
+
});
|
|
2941
|
+
Kbd.displayName = "Kbd";
|
|
2942
|
+
//#endregion
|
|
2130
2943
|
//#region src/components/GaugeChart/GaugeChart.tsx
|
|
2131
2944
|
var GaugeChart = (0, react.forwardRef)(function GaugeChart({ className, value, max = 100, centerLabel, subLabel, size = 200, strokeWidth = 16, color, style, ...props }, ref) {
|
|
2132
2945
|
const progress = max > 0 ? Math.min(Math.max(value, 0), max) / max : 0;
|
|
@@ -3081,6 +3894,161 @@ var Notification = (0, react.forwardRef)(({ className, variant = "info", heading
|
|
|
3081
3894
|
});
|
|
3082
3895
|
Notification.displayName = "Notification";
|
|
3083
3896
|
//#endregion
|
|
3897
|
+
//#region src/components/NumberInput/NumberInput.tsx
|
|
3898
|
+
var decimalsOf = (n) => {
|
|
3899
|
+
const str = String(n);
|
|
3900
|
+
const dot = str.indexOf(".");
|
|
3901
|
+
return dot === -1 ? 0 : str.length - dot - 1;
|
|
3902
|
+
};
|
|
3903
|
+
var clamp$2 = (n, min, max) => Math.min(Math.max(n, min), max);
|
|
3904
|
+
var NumberInput = (0, react.forwardRef)(function NumberInput({ id, value, defaultValue, onValueChange, min = -Infinity, max = Infinity, step = 1, label, description, error, formatOptions, locale, decrementLabel = "Decrease", incrementLabel = "Increase", name, required, disabled, className, placeholder, "aria-describedby": ariaDescribedBy, ...props }, ref) {
|
|
3905
|
+
const generatedId = (0, react.useId)();
|
|
3906
|
+
const fieldId = id ?? generatedId;
|
|
3907
|
+
const descriptionId = description ? `${fieldId}-description` : void 0;
|
|
3908
|
+
const errorId = error ? `${fieldId}-error` : void 0;
|
|
3909
|
+
const describedBy = composeDescribedBy(ariaDescribedBy, descriptionId, errorId);
|
|
3910
|
+
const [rawValue, setCurrentValue] = useControllableState({
|
|
3911
|
+
value,
|
|
3912
|
+
defaultValue: defaultValue ?? null,
|
|
3913
|
+
onChange: onValueChange
|
|
3914
|
+
});
|
|
3915
|
+
const currentValue = rawValue ?? null;
|
|
3916
|
+
const inputRefs = useComposedRefs((0, react.useRef)(null), ref);
|
|
3917
|
+
const stepDecimals = decimalsOf(step);
|
|
3918
|
+
const round = (n) => {
|
|
3919
|
+
const factor = 10 ** stepDecimals;
|
|
3920
|
+
return Math.round(n * factor) / factor;
|
|
3921
|
+
};
|
|
3922
|
+
const formatValue = (n) => {
|
|
3923
|
+
if (n === null) return "";
|
|
3924
|
+
if (formatOptions) return new Intl.NumberFormat(locale, formatOptions).format(n);
|
|
3925
|
+
return String(n);
|
|
3926
|
+
};
|
|
3927
|
+
const [focused, setFocused] = (0, react.useState)(false);
|
|
3928
|
+
const [draft, setDraft] = (0, react.useState)(() => formatValue(currentValue));
|
|
3929
|
+
const displayValue = focused ? draft : formatValue(currentValue);
|
|
3930
|
+
const commit = (next) => {
|
|
3931
|
+
if (next === null) {
|
|
3932
|
+
setCurrentValue(null);
|
|
3933
|
+
setDraft("");
|
|
3934
|
+
return;
|
|
3935
|
+
}
|
|
3936
|
+
const clamped = round(clamp$2(next, min, max));
|
|
3937
|
+
setCurrentValue(clamped);
|
|
3938
|
+
setDraft(focused ? String(clamped) : formatValue(clamped));
|
|
3939
|
+
};
|
|
3940
|
+
const stepBy = (direction) => {
|
|
3941
|
+
if (disabled) return;
|
|
3942
|
+
commit((currentValue ?? (Number.isFinite(min) ? min : Number.isFinite(max) ? max : 0)) + direction * step);
|
|
3943
|
+
};
|
|
3944
|
+
const atMin = currentValue !== null && currentValue <= min;
|
|
3945
|
+
const atMax = currentValue !== null && currentValue >= max;
|
|
3946
|
+
const onKeyDown = (event) => {
|
|
3947
|
+
if (disabled) return;
|
|
3948
|
+
if (event.key === Keys.ArrowUp) {
|
|
3949
|
+
event.preventDefault();
|
|
3950
|
+
stepBy(1);
|
|
3951
|
+
} else if (event.key === Keys.ArrowDown) {
|
|
3952
|
+
event.preventDefault();
|
|
3953
|
+
stepBy(-1);
|
|
3954
|
+
} else if (event.key === Keys.Home && Number.isFinite(min)) {
|
|
3955
|
+
event.preventDefault();
|
|
3956
|
+
commit(min);
|
|
3957
|
+
} else if (event.key === Keys.End && Number.isFinite(max)) {
|
|
3958
|
+
event.preventDefault();
|
|
3959
|
+
commit(max);
|
|
3960
|
+
}
|
|
3961
|
+
};
|
|
3962
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldWrapper, {
|
|
3963
|
+
labelFor: fieldId,
|
|
3964
|
+
label,
|
|
3965
|
+
description,
|
|
3966
|
+
descriptionId,
|
|
3967
|
+
error,
|
|
3968
|
+
errorId,
|
|
3969
|
+
required,
|
|
3970
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3971
|
+
className: cx("pf-numberinput", error && "pf-numberinput--invalid"),
|
|
3972
|
+
children: [
|
|
3973
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3974
|
+
type: "button",
|
|
3975
|
+
className: "pf-numberinput__step pf-numberinput__step--decrement",
|
|
3976
|
+
"aria-label": decrementLabel,
|
|
3977
|
+
disabled: disabled || atMin,
|
|
3978
|
+
tabIndex: -1,
|
|
3979
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
3980
|
+
onClick: () => stepBy(-1),
|
|
3981
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
3982
|
+
name: "minus",
|
|
3983
|
+
"aria-hidden": true
|
|
3984
|
+
})
|
|
3985
|
+
}),
|
|
3986
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3987
|
+
...props,
|
|
3988
|
+
id: fieldId,
|
|
3989
|
+
ref: inputRefs,
|
|
3990
|
+
type: "text",
|
|
3991
|
+
inputMode: "decimal",
|
|
3992
|
+
role: "spinbutton",
|
|
3993
|
+
className: cx("pf-numberinput__input", className),
|
|
3994
|
+
value: displayValue,
|
|
3995
|
+
placeholder,
|
|
3996
|
+
disabled,
|
|
3997
|
+
required,
|
|
3998
|
+
autoComplete: "off",
|
|
3999
|
+
"aria-invalid": error ? true : void 0,
|
|
4000
|
+
"aria-describedby": describedBy,
|
|
4001
|
+
"aria-valuenow": currentValue ?? void 0,
|
|
4002
|
+
"aria-valuemin": Number.isFinite(min) ? min : void 0,
|
|
4003
|
+
"aria-valuemax": Number.isFinite(max) ? max : void 0,
|
|
4004
|
+
onFocus: () => {
|
|
4005
|
+
setFocused(true);
|
|
4006
|
+
setDraft(currentValue === null ? "" : String(currentValue));
|
|
4007
|
+
},
|
|
4008
|
+
onChange: (event) => {
|
|
4009
|
+
const raw = event.target.value;
|
|
4010
|
+
setDraft(raw);
|
|
4011
|
+
if (raw.trim() === "") {
|
|
4012
|
+
setCurrentValue(null);
|
|
4013
|
+
return;
|
|
4014
|
+
}
|
|
4015
|
+
const parsed = Number(raw);
|
|
4016
|
+
if (!Number.isNaN(parsed)) setCurrentValue(round(clamp$2(parsed, min, max)));
|
|
4017
|
+
},
|
|
4018
|
+
onBlur: () => {
|
|
4019
|
+
setFocused(false);
|
|
4020
|
+
if (draft.trim() === "") commit(null);
|
|
4021
|
+
else {
|
|
4022
|
+
const parsed = Number(draft);
|
|
4023
|
+
commit(Number.isNaN(parsed) ? currentValue : parsed);
|
|
4024
|
+
}
|
|
4025
|
+
},
|
|
4026
|
+
onKeyDown
|
|
4027
|
+
}),
|
|
4028
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4029
|
+
type: "button",
|
|
4030
|
+
className: "pf-numberinput__step pf-numberinput__step--increment",
|
|
4031
|
+
"aria-label": incrementLabel,
|
|
4032
|
+
disabled: disabled || atMax,
|
|
4033
|
+
tabIndex: -1,
|
|
4034
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
4035
|
+
onClick: () => stepBy(1),
|
|
4036
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
4037
|
+
name: "plus",
|
|
4038
|
+
"aria-hidden": true
|
|
4039
|
+
})
|
|
4040
|
+
}),
|
|
4041
|
+
name ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
4042
|
+
type: "hidden",
|
|
4043
|
+
name,
|
|
4044
|
+
value: currentValue ?? ""
|
|
4045
|
+
}) : null
|
|
4046
|
+
]
|
|
4047
|
+
})
|
|
4048
|
+
});
|
|
4049
|
+
});
|
|
4050
|
+
NumberInput.displayName = "NumberInput";
|
|
4051
|
+
//#endregion
|
|
3084
4052
|
//#region src/components/PageHeader/PageHeader.tsx
|
|
3085
4053
|
var PageHeaderMeta = (0, react.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3086
4054
|
ref,
|
|
@@ -3295,6 +4263,70 @@ var PieChart = (0, react.forwardRef)(function PieChart({ className, data, size =
|
|
|
3295
4263
|
});
|
|
3296
4264
|
PieChart.displayName = "PieChart";
|
|
3297
4265
|
//#endregion
|
|
4266
|
+
//#region src/components/Popover/Popover.tsx
|
|
4267
|
+
function Popover({ trigger, children, open, defaultOpen, onOpenChange, align = "start", label, closeOnOutsideClick = true, className }) {
|
|
4268
|
+
const [isOpen = false, setOpen] = useControllableState({
|
|
4269
|
+
value: open,
|
|
4270
|
+
defaultValue: defaultOpen ?? false,
|
|
4271
|
+
onChange: onOpenChange
|
|
4272
|
+
});
|
|
4273
|
+
const contentId = (0, react.useId)();
|
|
4274
|
+
const triggerRef = (0, react.useRef)(null);
|
|
4275
|
+
const contentRef = (0, react.useRef)(null);
|
|
4276
|
+
const { isMounted, isExiting } = usePresence(isOpen, 160);
|
|
4277
|
+
const style = useAnchoredPosition({
|
|
4278
|
+
anchorRef: triggerRef,
|
|
4279
|
+
floatingRef: contentRef,
|
|
4280
|
+
enabled: isOpen,
|
|
4281
|
+
align,
|
|
4282
|
+
matchAnchorWidth: false,
|
|
4283
|
+
flip: true
|
|
4284
|
+
});
|
|
4285
|
+
useOutsideInteraction({
|
|
4286
|
+
refs: [triggerRef, contentRef],
|
|
4287
|
+
enabled: isOpen,
|
|
4288
|
+
onInteractOutside: () => {
|
|
4289
|
+
if (closeOnOutsideClick) setOpen(false);
|
|
4290
|
+
}
|
|
4291
|
+
});
|
|
4292
|
+
const wasOpen = (0, react.useRef)(false);
|
|
4293
|
+
(0, react.useEffect)(() => {
|
|
4294
|
+
if (isOpen) {
|
|
4295
|
+
wasOpen.current = true;
|
|
4296
|
+
contentRef.current?.focus();
|
|
4297
|
+
} else if (wasOpen.current) {
|
|
4298
|
+
wasOpen.current = false;
|
|
4299
|
+
triggerRef.current?.focus();
|
|
4300
|
+
}
|
|
4301
|
+
}, [isOpen]);
|
|
4302
|
+
const triggerProps = trigger.props;
|
|
4303
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react.cloneElement)(trigger, {
|
|
4304
|
+
ref: useComposedRefs(triggerRef, trigger.ref ?? triggerProps.ref),
|
|
4305
|
+
"aria-haspopup": "dialog",
|
|
4306
|
+
"aria-expanded": isOpen,
|
|
4307
|
+
onClick: (event) => {
|
|
4308
|
+
triggerProps.onClick?.(event);
|
|
4309
|
+
setOpen(!isOpen);
|
|
4310
|
+
}
|
|
4311
|
+
}), isMounted && typeof document !== "undefined" ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4312
|
+
ref: contentRef,
|
|
4313
|
+
id: contentId,
|
|
4314
|
+
role: "dialog",
|
|
4315
|
+
"aria-label": label,
|
|
4316
|
+
tabIndex: -1,
|
|
4317
|
+
className: cx("pf-popover", isExiting && "pf-popover--exiting", className),
|
|
4318
|
+
style,
|
|
4319
|
+
onKeyDown: (event) => {
|
|
4320
|
+
if (event.key === Keys.Escape) {
|
|
4321
|
+
event.stopPropagation();
|
|
4322
|
+
setOpen(false);
|
|
4323
|
+
}
|
|
4324
|
+
},
|
|
4325
|
+
children
|
|
4326
|
+
}), document.body) : null] });
|
|
4327
|
+
}
|
|
4328
|
+
Popover.displayName = "Popover";
|
|
4329
|
+
//#endregion
|
|
3298
4330
|
//#region src/components/ProgressIndicators/ProgressIndicators.tsx
|
|
3299
4331
|
var clampPercent = (value, max) => {
|
|
3300
4332
|
if (max <= 0) return 0;
|
|
@@ -4812,6 +5844,130 @@ var Textarea = (0, react.forwardRef)(({ id, label, description, error, className
|
|
|
4812
5844
|
});
|
|
4813
5845
|
Textarea.displayName = "Textarea";
|
|
4814
5846
|
//#endregion
|
|
5847
|
+
//#region src/components/Toast/Toast.tsx
|
|
5848
|
+
var _emit = null;
|
|
5849
|
+
function ToastItem({ entry, onRemove }) {
|
|
5850
|
+
const { id, shouldExit } = entry;
|
|
5851
|
+
const handleRemove = (0, react.useCallback)(() => onRemove(id), [onRemove, id]);
|
|
5852
|
+
(0, react.useEffect)(() => {
|
|
5853
|
+
if (!shouldExit) return;
|
|
5854
|
+
const t = setTimeout(handleRemove, 270);
|
|
5855
|
+
return () => clearTimeout(t);
|
|
5856
|
+
}, [shouldExit, handleRemove]);
|
|
5857
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Notification, {
|
|
5858
|
+
variant: entry.variant,
|
|
5859
|
+
heading: entry.heading,
|
|
5860
|
+
description: entry.description,
|
|
5861
|
+
action: entry.action,
|
|
5862
|
+
dismissible: entry.dismissible,
|
|
5863
|
+
onDismiss: handleRemove,
|
|
5864
|
+
className: shouldExit ? "pf-notification--exiting" : void 0,
|
|
5865
|
+
onAnimationEnd: (e) => {
|
|
5866
|
+
if (shouldExit && e.currentTarget === e.target) handleRemove();
|
|
5867
|
+
}
|
|
5868
|
+
});
|
|
5869
|
+
}
|
|
5870
|
+
function ToastProvider({ children, placement = "top-right", defaultDuration = 4e3 }) {
|
|
5871
|
+
const [entries, setEntries] = (0, react.useState)([]);
|
|
5872
|
+
const timers = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
5873
|
+
const remove = (0, react.useCallback)((id) => {
|
|
5874
|
+
timers.current.delete(id);
|
|
5875
|
+
setEntries((prev) => prev.filter((e) => e.id !== id));
|
|
5876
|
+
}, []);
|
|
5877
|
+
const signalExit = (0, react.useCallback)((id) => {
|
|
5878
|
+
timers.current.delete(id);
|
|
5879
|
+
setEntries((prev) => prev.map((e) => e.id === id ? {
|
|
5880
|
+
...e,
|
|
5881
|
+
shouldExit: true
|
|
5882
|
+
} : e));
|
|
5883
|
+
}, []);
|
|
5884
|
+
const toast = (0, react.useCallback)((options) => {
|
|
5885
|
+
const id = `t-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
5886
|
+
const duration = options.duration !== void 0 ? options.duration : defaultDuration;
|
|
5887
|
+
setEntries((prev) => [{
|
|
5888
|
+
...options,
|
|
5889
|
+
id,
|
|
5890
|
+
shouldExit: false,
|
|
5891
|
+
dismissible: options.dismissible ?? true
|
|
5892
|
+
}, ...prev]);
|
|
5893
|
+
if (typeof duration === "number" && duration > 0) {
|
|
5894
|
+
const t = setTimeout(() => signalExit(id), duration);
|
|
5895
|
+
timers.current.set(id, t);
|
|
5896
|
+
}
|
|
5897
|
+
return id;
|
|
5898
|
+
}, [defaultDuration, signalExit]);
|
|
5899
|
+
const dismiss = (0, react.useCallback)((id) => {
|
|
5900
|
+
const t = timers.current.get(id);
|
|
5901
|
+
if (t) clearTimeout(t);
|
|
5902
|
+
signalExit(id);
|
|
5903
|
+
}, [signalExit]);
|
|
5904
|
+
const dismissAll = (0, react.useCallback)(() => {
|
|
5905
|
+
timers.current.forEach(clearTimeout);
|
|
5906
|
+
timers.current.clear();
|
|
5907
|
+
setEntries((prev) => prev.map((e) => ({
|
|
5908
|
+
...e,
|
|
5909
|
+
shouldExit: true
|
|
5910
|
+
})));
|
|
5911
|
+
}, []);
|
|
5912
|
+
(0, react.useEffect)(() => {
|
|
5913
|
+
_emit = toast;
|
|
5914
|
+
return () => {
|
|
5915
|
+
if (_emit === toast) _emit = null;
|
|
5916
|
+
};
|
|
5917
|
+
}, [toast]);
|
|
5918
|
+
(0, react.useEffect)(() => {
|
|
5919
|
+
const map = timers.current;
|
|
5920
|
+
return () => map.forEach(clearTimeout);
|
|
5921
|
+
}, []);
|
|
5922
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToastContext.Provider, {
|
|
5923
|
+
value: {
|
|
5924
|
+
toast,
|
|
5925
|
+
dismiss,
|
|
5926
|
+
dismissAll
|
|
5927
|
+
},
|
|
5928
|
+
children: [children, typeof document !== "undefined" ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(NotificationStack, {
|
|
5929
|
+
placement,
|
|
5930
|
+
children: entries.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToastItem, {
|
|
5931
|
+
entry,
|
|
5932
|
+
onRemove: remove
|
|
5933
|
+
}, entry.id))
|
|
5934
|
+
}), document.body) : null]
|
|
5935
|
+
});
|
|
5936
|
+
}
|
|
5937
|
+
var ToastContext = (0, react.createContext)(null);
|
|
5938
|
+
function useToast() {
|
|
5939
|
+
const ctx = (0, react.useContext)(ToastContext);
|
|
5940
|
+
if (!ctx) throw new Error("useToast must be used inside <ToastProvider>.");
|
|
5941
|
+
return ctx;
|
|
5942
|
+
}
|
|
5943
|
+
/**
|
|
5944
|
+
* Fire a toast imperatively from anywhere — no hook needed.
|
|
5945
|
+
* Requires a `<ToastProvider>` to be mounted somewhere in the tree.
|
|
5946
|
+
*/
|
|
5947
|
+
function toast(options) {
|
|
5948
|
+
if (!_emit) {
|
|
5949
|
+
console.warn("[pitchfork-ui] toast() called before <ToastProvider> is mounted.");
|
|
5950
|
+
return "";
|
|
5951
|
+
}
|
|
5952
|
+
return _emit(options);
|
|
5953
|
+
}
|
|
5954
|
+
toast.info = (opts) => toast({
|
|
5955
|
+
...opts,
|
|
5956
|
+
variant: "info"
|
|
5957
|
+
});
|
|
5958
|
+
toast.success = (opts) => toast({
|
|
5959
|
+
...opts,
|
|
5960
|
+
variant: "success"
|
|
5961
|
+
});
|
|
5962
|
+
toast.warning = (opts) => toast({
|
|
5963
|
+
...opts,
|
|
5964
|
+
variant: "warning"
|
|
5965
|
+
});
|
|
5966
|
+
toast.danger = (opts) => toast({
|
|
5967
|
+
...opts,
|
|
5968
|
+
variant: "danger"
|
|
5969
|
+
});
|
|
5970
|
+
//#endregion
|
|
4815
5971
|
//#region src/components/Tooltip/Tooltip.tsx
|
|
4816
5972
|
var GAP = 10;
|
|
4817
5973
|
var VIEWPORT_MARGIN = 8;
|
|
@@ -5235,6 +6391,7 @@ exports.Accordion = Accordion;
|
|
|
5235
6391
|
exports.Alert = Alert;
|
|
5236
6392
|
exports.AreaChart = AreaChart;
|
|
5237
6393
|
exports.Avatar = Avatar;
|
|
6394
|
+
exports.AvatarGroup = AvatarGroup;
|
|
5238
6395
|
exports.Badge = Badge;
|
|
5239
6396
|
exports.BadgeGroup = BadgeGroup;
|
|
5240
6397
|
exports.BarChart = BarChart;
|
|
@@ -5249,9 +6406,12 @@ exports.CardHeader = CardHeader;
|
|
|
5249
6406
|
exports.Carousel = Carousel;
|
|
5250
6407
|
exports.Checkbox = Checkbox;
|
|
5251
6408
|
exports.CodeSnippet = CodeSnippet;
|
|
6409
|
+
exports.Combobox = Combobox;
|
|
6410
|
+
exports.CommandPalette = CommandPalette;
|
|
5252
6411
|
exports.ContentDivider = ContentDivider;
|
|
5253
6412
|
exports.CreditCard = CreditCard;
|
|
5254
6413
|
exports.DatePicker = DatePicker;
|
|
6414
|
+
exports.DateRangePicker = DateRangePicker;
|
|
5255
6415
|
exports.Dropdown = Dropdown;
|
|
5256
6416
|
exports.EmptyState = EmptyState;
|
|
5257
6417
|
exports.FileUploader = FileUploader;
|
|
@@ -5261,6 +6421,7 @@ exports.Heatmap = Heatmap;
|
|
|
5261
6421
|
exports.Icon = Icon;
|
|
5262
6422
|
exports.InlineCTA = InlineCTA;
|
|
5263
6423
|
exports.Input = Input;
|
|
6424
|
+
exports.Kbd = Kbd;
|
|
5264
6425
|
exports.Keys = Keys;
|
|
5265
6426
|
exports.LineChart = LineChart;
|
|
5266
6427
|
exports.LoadingDots = LoadingDots;
|
|
@@ -5275,10 +6436,12 @@ exports.ModalHeader = ModalHeader;
|
|
|
5275
6436
|
exports.MultiSelect = MultiSelect;
|
|
5276
6437
|
exports.Notification = Notification;
|
|
5277
6438
|
exports.NotificationStack = NotificationStack;
|
|
6439
|
+
exports.NumberInput = NumberInput;
|
|
5278
6440
|
exports.PageHeader = PageHeader;
|
|
5279
6441
|
exports.PageHeaderMeta = PageHeaderMeta;
|
|
5280
6442
|
exports.Pagination = Pagination;
|
|
5281
6443
|
exports.PieChart = PieChart;
|
|
6444
|
+
exports.Popover = Popover;
|
|
5282
6445
|
exports.ProgressBar = ProgressBar;
|
|
5283
6446
|
exports.ProgressCircle = ProgressCircle;
|
|
5284
6447
|
exports.ProgressSteps = ProgressSteps;
|
|
@@ -5300,6 +6463,7 @@ exports.Table = Table;
|
|
|
5300
6463
|
exports.Tabs = Tabs;
|
|
5301
6464
|
exports.Tag = Tag;
|
|
5302
6465
|
exports.Textarea = Textarea;
|
|
6466
|
+
exports.ToastProvider = ToastProvider;
|
|
5303
6467
|
exports.Tooltip = Tooltip;
|
|
5304
6468
|
exports.TreeView = TreeView;
|
|
5305
6469
|
exports.UtilityButton = UtilityButton;
|
|
@@ -5309,6 +6473,7 @@ exports.getAvailableIconNames = getAvailableIconNames;
|
|
|
5309
6473
|
exports.getCustomIconNames = getCustomIconNames;
|
|
5310
6474
|
exports.getFocusableElements = getFocusableElements;
|
|
5311
6475
|
exports.isActivationKey = isActivationKey;
|
|
6476
|
+
exports.toast = toast;
|
|
5312
6477
|
exports.useAnchoredPosition = useAnchoredPosition;
|
|
5313
6478
|
exports.useComposedRefs = useComposedRefs;
|
|
5314
6479
|
exports.useControllableState = useControllableState;
|
|
@@ -5318,3 +6483,4 @@ exports.useFocusTrap = useFocusTrap;
|
|
|
5318
6483
|
exports.useListNavigation = useListNavigation;
|
|
5319
6484
|
exports.useOutsideInteraction = useOutsideInteraction;
|
|
5320
6485
|
exports.usePresence = usePresence;
|
|
6486
|
+
exports.useToast = useToast;
|