@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/index114.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { forwardRef, useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { createPortal } from "react-dom";
|
|
6
|
+
//#region src/components/Tooltip/Tooltip.tsx
|
|
7
|
+
var GAP = 10;
|
|
8
|
+
var VIEWPORT_MARGIN = 8;
|
|
9
|
+
var placementFallbacks = {
|
|
10
|
+
top: [
|
|
11
|
+
"top",
|
|
12
|
+
"bottom",
|
|
13
|
+
"right",
|
|
14
|
+
"left"
|
|
15
|
+
],
|
|
16
|
+
bottom: [
|
|
17
|
+
"bottom",
|
|
18
|
+
"top",
|
|
19
|
+
"right",
|
|
20
|
+
"left"
|
|
21
|
+
],
|
|
22
|
+
left: [
|
|
23
|
+
"left",
|
|
24
|
+
"right",
|
|
25
|
+
"top",
|
|
26
|
+
"bottom"
|
|
27
|
+
],
|
|
28
|
+
right: [
|
|
29
|
+
"right",
|
|
30
|
+
"left",
|
|
31
|
+
"top",
|
|
32
|
+
"bottom"
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
var clamp = (value, min, max) => Math.min(Math.max(value, min), Math.max(min, max));
|
|
36
|
+
var getViewportSize = () => ({
|
|
37
|
+
width: window.innerWidth || document.documentElement.clientWidth,
|
|
38
|
+
height: window.innerHeight || document.documentElement.clientHeight
|
|
39
|
+
});
|
|
40
|
+
var getTooltipCoordinates = (triggerRect, tooltipRect, placement) => {
|
|
41
|
+
const centerX = triggerRect.left + triggerRect.width / 2;
|
|
42
|
+
const centerY = triggerRect.top + triggerRect.height / 2;
|
|
43
|
+
if (placement === "bottom") return {
|
|
44
|
+
left: centerX - tooltipRect.width / 2,
|
|
45
|
+
top: triggerRect.bottom + GAP
|
|
46
|
+
};
|
|
47
|
+
if (placement === "left") return {
|
|
48
|
+
left: triggerRect.left - tooltipRect.width - GAP,
|
|
49
|
+
top: centerY - tooltipRect.height / 2
|
|
50
|
+
};
|
|
51
|
+
if (placement === "right") return {
|
|
52
|
+
left: triggerRect.right + GAP,
|
|
53
|
+
top: centerY - tooltipRect.height / 2
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
left: centerX - tooltipRect.width / 2,
|
|
57
|
+
top: triggerRect.top - tooltipRect.height - GAP
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
var getOverflow = (coordinates, tooltipRect) => {
|
|
61
|
+
const viewport = getViewportSize();
|
|
62
|
+
return Math.max(VIEWPORT_MARGIN - coordinates.left, 0) + Math.max(VIEWPORT_MARGIN - coordinates.top, 0) + Math.max(coordinates.left + tooltipRect.width - viewport.width + VIEWPORT_MARGIN, 0) + Math.max(coordinates.top + tooltipRect.height - viewport.height + VIEWPORT_MARGIN, 0);
|
|
63
|
+
};
|
|
64
|
+
var getTooltipPosition = (triggerRect, tooltipRect, placement) => {
|
|
65
|
+
const bestPlacement = placementFallbacks[placement].map((candidatePlacement) => ({
|
|
66
|
+
placement: candidatePlacement,
|
|
67
|
+
coordinates: getTooltipCoordinates(triggerRect, tooltipRect, candidatePlacement)
|
|
68
|
+
})).reduce((best, candidate) => getOverflow(candidate.coordinates, tooltipRect) < getOverflow(best.coordinates, tooltipRect) ? candidate : best);
|
|
69
|
+
const viewport = getViewportSize();
|
|
70
|
+
return {
|
|
71
|
+
placement: bestPlacement.placement,
|
|
72
|
+
style: {
|
|
73
|
+
left: clamp(bestPlacement.coordinates.left, VIEWPORT_MARGIN, viewport.width - tooltipRect.width - VIEWPORT_MARGIN),
|
|
74
|
+
top: clamp(bestPlacement.coordinates.top, VIEWPORT_MARGIN, viewport.height - tooltipRect.height - VIEWPORT_MARGIN),
|
|
75
|
+
visibility: "visible"
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
var Tooltip = forwardRef(function Tooltip({ content, children, open, placement = "top", delay = 120, disabled = false, className }, ref) {
|
|
80
|
+
const tooltipId = useId();
|
|
81
|
+
const triggerRef = useRef(null);
|
|
82
|
+
useImperativeHandle(ref, () => triggerRef.current, []);
|
|
83
|
+
const tooltipRef = useRef(null);
|
|
84
|
+
const showTimerRef = useRef(void 0);
|
|
85
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
86
|
+
const [style, setStyle] = useState({ visibility: "hidden" });
|
|
87
|
+
const [resolvedPlacement, setResolvedPlacement] = useState(placement);
|
|
88
|
+
const isControlled = open !== void 0;
|
|
89
|
+
const isVisible = !disabled && (isControlled ? open : isOpen);
|
|
90
|
+
const clearShowTimer = () => {
|
|
91
|
+
if (showTimerRef.current !== void 0) {
|
|
92
|
+
window.clearTimeout(showTimerRef.current);
|
|
93
|
+
showTimerRef.current = void 0;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const openTooltip = () => {
|
|
97
|
+
if (disabled) return;
|
|
98
|
+
if (isControlled) return;
|
|
99
|
+
clearShowTimer();
|
|
100
|
+
showTimerRef.current = window.setTimeout(() => {
|
|
101
|
+
setIsOpen(true);
|
|
102
|
+
}, delay);
|
|
103
|
+
};
|
|
104
|
+
const closeTooltip = () => {
|
|
105
|
+
clearShowTimer();
|
|
106
|
+
if (isControlled) return;
|
|
107
|
+
setIsOpen(false);
|
|
108
|
+
setStyle({ visibility: "hidden" });
|
|
109
|
+
setResolvedPlacement(placement);
|
|
110
|
+
};
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
return () => {
|
|
113
|
+
clearShowTimer();
|
|
114
|
+
};
|
|
115
|
+
}, []);
|
|
116
|
+
useLayoutEffect(() => {
|
|
117
|
+
if (!isVisible) return;
|
|
118
|
+
const updatePosition = () => {
|
|
119
|
+
if (!triggerRef.current || !tooltipRef.current) return;
|
|
120
|
+
const position = getTooltipPosition(triggerRef.current.getBoundingClientRect(), tooltipRef.current.getBoundingClientRect(), placement);
|
|
121
|
+
setStyle(position.style);
|
|
122
|
+
setResolvedPlacement(position.placement);
|
|
123
|
+
};
|
|
124
|
+
updatePosition();
|
|
125
|
+
window.addEventListener("resize", updatePosition);
|
|
126
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
127
|
+
return () => {
|
|
128
|
+
window.removeEventListener("resize", updatePosition);
|
|
129
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
130
|
+
};
|
|
131
|
+
}, [isVisible, placement]);
|
|
132
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
133
|
+
ref: triggerRef,
|
|
134
|
+
className: "pf-tooltip__trigger",
|
|
135
|
+
onMouseEnter: openTooltip,
|
|
136
|
+
onMouseLeave: closeTooltip,
|
|
137
|
+
onFocus: openTooltip,
|
|
138
|
+
onBlur: closeTooltip,
|
|
139
|
+
onKeyDown: (event) => {
|
|
140
|
+
if (event.key === "Escape") closeTooltip();
|
|
141
|
+
},
|
|
142
|
+
"aria-describedby": isVisible ? tooltipId : void 0,
|
|
143
|
+
children: children ?? /* @__PURE__ */ jsx("span", {})
|
|
144
|
+
}), isVisible && typeof document !== "undefined" ? createPortal(/* @__PURE__ */ jsx("div", {
|
|
145
|
+
id: tooltipId,
|
|
146
|
+
ref: tooltipRef,
|
|
147
|
+
role: "tooltip",
|
|
148
|
+
className: cx("pf-tooltip", `pf-tooltip--${resolvedPlacement}`, className),
|
|
149
|
+
style,
|
|
150
|
+
children: content
|
|
151
|
+
}), document.body) : null] });
|
|
152
|
+
});
|
|
153
|
+
Tooltip.displayName = "Tooltip";
|
|
154
|
+
//#endregion
|
|
155
|
+
export { Tooltip };
|
package/dist/index116.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { forwardRef, useCallback, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/TreeView/TreeView.tsx
|
|
6
|
+
function flattenVisibleNodes(nodes, expandedSet, level = 1, parentValue) {
|
|
7
|
+
const flattened = [];
|
|
8
|
+
for (const node of nodes) {
|
|
9
|
+
flattened.push({
|
|
10
|
+
node,
|
|
11
|
+
level,
|
|
12
|
+
parentValue
|
|
13
|
+
});
|
|
14
|
+
if (node.children && node.children.length > 0 && expandedSet.has(node.value)) flattened.push(...flattenVisibleNodes(node.children, expandedSet, level + 1, node.value));
|
|
15
|
+
}
|
|
16
|
+
return flattened;
|
|
17
|
+
}
|
|
18
|
+
function findFirstEnabledValue(nodes) {
|
|
19
|
+
for (const node of nodes) {
|
|
20
|
+
if (!node.disabled) return node.value;
|
|
21
|
+
if (node.children && node.children.length > 0) {
|
|
22
|
+
const childValue = findFirstEnabledValue(node.children);
|
|
23
|
+
if (childValue) return childValue;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function collectExpandableNodeValues(nodes) {
|
|
28
|
+
const values = [];
|
|
29
|
+
for (const node of nodes) if (node.children && node.children.length > 0) {
|
|
30
|
+
values.push(node.value);
|
|
31
|
+
values.push(...collectExpandableNodeValues(node.children));
|
|
32
|
+
}
|
|
33
|
+
return values;
|
|
34
|
+
}
|
|
35
|
+
var TreeView = forwardRef(function TreeView({ className, nodes, selectedValue, defaultSelectedValue, onSelectedValueChange, expandedValues, defaultExpandedValues = [], onExpandedValuesChange, ...props }, ref) {
|
|
36
|
+
const isSelectedControlled = selectedValue !== void 0;
|
|
37
|
+
const isExpandedControlled = expandedValues !== void 0;
|
|
38
|
+
const [internalSelectedValue, setInternalSelectedValue] = useState(defaultSelectedValue ?? findFirstEnabledValue(nodes));
|
|
39
|
+
const [internalExpandedValues, setInternalExpandedValues] = useState(defaultExpandedValues);
|
|
40
|
+
const resolvedSelectedValue = isSelectedControlled ? selectedValue : internalSelectedValue;
|
|
41
|
+
const resolvedExpandedValues = isExpandedControlled ? expandedValues : internalExpandedValues;
|
|
42
|
+
const expandedSet = useMemo(() => new Set(resolvedExpandedValues), [resolvedExpandedValues]);
|
|
43
|
+
const flattenedNodes = useMemo(() => flattenVisibleNodes(nodes, expandedSet), [expandedSet, nodes]);
|
|
44
|
+
const itemRefs = useRef({});
|
|
45
|
+
const updateExpandedValues = useCallback((nextValues) => {
|
|
46
|
+
if (!isExpandedControlled) setInternalExpandedValues(nextValues);
|
|
47
|
+
onExpandedValuesChange?.(nextValues);
|
|
48
|
+
}, [isExpandedControlled, onExpandedValuesChange]);
|
|
49
|
+
const expandAll = useCallback(() => {
|
|
50
|
+
updateExpandedValues(collectExpandableNodeValues(nodes));
|
|
51
|
+
}, [nodes, updateExpandedValues]);
|
|
52
|
+
const collapseAll = useCallback(() => {
|
|
53
|
+
updateExpandedValues([]);
|
|
54
|
+
}, [updateExpandedValues]);
|
|
55
|
+
useImperativeHandle(ref, () => ({
|
|
56
|
+
expandAll,
|
|
57
|
+
collapseAll
|
|
58
|
+
}), [collapseAll, expandAll]);
|
|
59
|
+
const setExpandedState = (value, expanded) => {
|
|
60
|
+
const nextSet = new Set(resolvedExpandedValues);
|
|
61
|
+
if (expanded) nextSet.add(value);
|
|
62
|
+
else nextSet.delete(value);
|
|
63
|
+
updateExpandedValues(Array.from(nextSet));
|
|
64
|
+
};
|
|
65
|
+
const toggleExpanded = (value) => {
|
|
66
|
+
setExpandedState(value, !expandedSet.has(value));
|
|
67
|
+
};
|
|
68
|
+
const setSelectedValue = (value) => {
|
|
69
|
+
if (!isSelectedControlled) setInternalSelectedValue(value);
|
|
70
|
+
onSelectedValueChange?.(value);
|
|
71
|
+
};
|
|
72
|
+
const focusNodeByValue = (value) => {
|
|
73
|
+
if (!value) return;
|
|
74
|
+
itemRefs.current[value]?.focus();
|
|
75
|
+
};
|
|
76
|
+
const onItemKeyDown = (current, event) => {
|
|
77
|
+
const currentIndex = flattenedNodes.findIndex((item) => item.node.value === current.node.value);
|
|
78
|
+
if (currentIndex === -1) return;
|
|
79
|
+
const hasChildren = !!(current.node.children && current.node.children.length > 0);
|
|
80
|
+
const isExpanded = expandedSet.has(current.node.value);
|
|
81
|
+
if (event.key === "ArrowDown") {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
focusNodeByValue(flattenedNodes[currentIndex + 1]?.node.value);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (event.key === "ArrowUp") {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
focusNodeByValue(flattenedNodes[currentIndex - 1]?.node.value);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (event.key === "ArrowRight") {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
if (hasChildren && !isExpanded) {
|
|
94
|
+
setExpandedState(current.node.value, true);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (hasChildren && isExpanded) {
|
|
98
|
+
const nextNode = flattenedNodes[currentIndex + 1];
|
|
99
|
+
if (nextNode && nextNode.parentValue === current.node.value) focusNodeByValue(nextNode.node.value);
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (event.key === "ArrowLeft") {
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
if (hasChildren && isExpanded) {
|
|
106
|
+
setExpandedState(current.node.value, false);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
focusNodeByValue(current.parentValue);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (event.key === "Home") {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
focusNodeByValue(flattenedNodes[0]?.node.value);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (event.key === "End") {
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
focusNodeByValue(flattenedNodes[flattenedNodes.length - 1]?.node.value);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
if (!current.node.disabled) setSelectedValue(current.node.value);
|
|
125
|
+
if (hasChildren) toggleExpanded(current.node.value);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
return /* @__PURE__ */ jsx("div", {
|
|
129
|
+
className: cx("pf-tree-view", className),
|
|
130
|
+
role: "tree",
|
|
131
|
+
...props,
|
|
132
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
133
|
+
className: "pf-tree-view__list",
|
|
134
|
+
role: "presentation",
|
|
135
|
+
children: flattenedNodes.map((item) => {
|
|
136
|
+
const hasChildren = !!(item.node.children && item.node.children.length > 0);
|
|
137
|
+
const isExpanded = expandedSet.has(item.node.value);
|
|
138
|
+
const isSelected = resolvedSelectedValue === item.node.value;
|
|
139
|
+
return /* @__PURE__ */ jsx("li", {
|
|
140
|
+
className: "pf-tree-view__item",
|
|
141
|
+
role: "presentation",
|
|
142
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
143
|
+
className: cx("pf-tree-view__row", isSelected && "pf-tree-view__row--selected", item.node.disabled && "pf-tree-view__row--disabled"),
|
|
144
|
+
style: { "--pf-tree-level": String(item.level - 1) },
|
|
145
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
146
|
+
className: "pf-tree-view__toggle-wrap",
|
|
147
|
+
"aria-hidden": true,
|
|
148
|
+
children: hasChildren ? /* @__PURE__ */ jsx("button", {
|
|
149
|
+
type: "button",
|
|
150
|
+
className: "pf-tree-view__toggle",
|
|
151
|
+
onClick: () => toggleExpanded(item.node.value),
|
|
152
|
+
tabIndex: -1,
|
|
153
|
+
children: isExpanded ? "▾" : "▸"
|
|
154
|
+
}) : /* @__PURE__ */ jsx("span", { className: "pf-tree-view__spacer" })
|
|
155
|
+
}), /* @__PURE__ */ jsxs("button", {
|
|
156
|
+
ref: (element) => {
|
|
157
|
+
itemRefs.current[item.node.value] = element;
|
|
158
|
+
},
|
|
159
|
+
type: "button",
|
|
160
|
+
role: "treeitem",
|
|
161
|
+
className: "pf-tree-view__node",
|
|
162
|
+
"aria-level": item.level,
|
|
163
|
+
"aria-expanded": hasChildren ? isExpanded : void 0,
|
|
164
|
+
"aria-selected": isSelected,
|
|
165
|
+
disabled: item.node.disabled,
|
|
166
|
+
onClick: () => {
|
|
167
|
+
if (!item.node.disabled) setSelectedValue(item.node.value);
|
|
168
|
+
},
|
|
169
|
+
onKeyDown: (event) => onItemKeyDown(item, event),
|
|
170
|
+
children: [
|
|
171
|
+
item.node.icon ? /* @__PURE__ */ jsx("span", {
|
|
172
|
+
className: "pf-tree-view__icon",
|
|
173
|
+
children: item.node.icon
|
|
174
|
+
}) : null,
|
|
175
|
+
/* @__PURE__ */ jsx("span", {
|
|
176
|
+
className: "pf-tree-view__label",
|
|
177
|
+
children: item.node.label
|
|
178
|
+
}),
|
|
179
|
+
item.node.badge ? /* @__PURE__ */ jsx("span", {
|
|
180
|
+
className: "pf-tree-view__badge",
|
|
181
|
+
children: item.node.badge
|
|
182
|
+
}) : null
|
|
183
|
+
]
|
|
184
|
+
})]
|
|
185
|
+
})
|
|
186
|
+
}, item.node.value);
|
|
187
|
+
})
|
|
188
|
+
})
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
TreeView.displayName = "TreeView";
|
|
192
|
+
//#endregion
|
|
193
|
+
export { TreeView };
|
package/dist/index118.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/UtilityButton/UtilityButton.tsx
|
|
6
|
+
var UtilityButton = forwardRef(({ className, variant = "neutral", size = "md", type = "button", icon, children, tooltip, ...props }, ref) => {
|
|
7
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
8
|
+
ref,
|
|
9
|
+
type,
|
|
10
|
+
className: cx("pf-utility-button", `pf-utility-button--${variant}`, `pf-utility-button--${size}`, className),
|
|
11
|
+
title: tooltip,
|
|
12
|
+
...props,
|
|
13
|
+
children: [icon ? /* @__PURE__ */ jsx("span", {
|
|
14
|
+
className: "pf-utility-button__icon",
|
|
15
|
+
children: icon
|
|
16
|
+
}) : null, children ? /* @__PURE__ */ jsx("span", {
|
|
17
|
+
className: "pf-utility-button__label",
|
|
18
|
+
children
|
|
19
|
+
}) : null]
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
UtilityButton.displayName = "UtilityButton";
|
|
23
|
+
//#endregion
|
|
24
|
+
export { UtilityButton };
|
package/dist/index12.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Button/Button.tsx
|
|
6
|
+
var Spinner = () => /* @__PURE__ */ jsx("svg", {
|
|
7
|
+
className: "pf-button__spinner",
|
|
8
|
+
viewBox: "0 0 24 24",
|
|
9
|
+
fill: "none",
|
|
10
|
+
width: "1em",
|
|
11
|
+
height: "1em",
|
|
12
|
+
"aria-hidden": "true",
|
|
13
|
+
focusable: "false",
|
|
14
|
+
children: /* @__PURE__ */ jsx("circle", {
|
|
15
|
+
cx: "12",
|
|
16
|
+
cy: "12",
|
|
17
|
+
r: "10",
|
|
18
|
+
stroke: "currentColor",
|
|
19
|
+
strokeWidth: "3",
|
|
20
|
+
strokeLinecap: "round",
|
|
21
|
+
strokeDasharray: "32",
|
|
22
|
+
strokeDashoffset: "8"
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
var Button = forwardRef(({ className, variant = "primary", size = "md", fullWidth = false, loading = false, type = "button", disabled, children, ...props }, ref) => {
|
|
26
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
27
|
+
ref,
|
|
28
|
+
type,
|
|
29
|
+
disabled: disabled || loading,
|
|
30
|
+
"aria-busy": loading || void 0,
|
|
31
|
+
className: cx("pf-button", `pf-button--${variant}`, `pf-button--${size}`, fullWidth && "pf-button--full", loading && "pf-button--loading", className),
|
|
32
|
+
...props,
|
|
33
|
+
children: [loading && /* @__PURE__ */ jsx(Spinner, {}), children]
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
Button.displayName = "Button";
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Button };
|
package/dist/index120.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { forwardRef, useId } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/VideoPlayer/VideoPlayer.tsx
|
|
6
|
+
var VideoPlayer = forwardRef(({ id, label, description, error, aspectRatio = "16/9", sources, tracks, className, src, controls = true, preload = "metadata", "aria-describedby": ariaDescribedBy, ...props }, ref) => {
|
|
7
|
+
const generatedId = useId();
|
|
8
|
+
const videoId = id ?? generatedId;
|
|
9
|
+
const descriptionId = description ? `${videoId}-description` : void 0;
|
|
10
|
+
const errorId = error ? `${videoId}-error` : void 0;
|
|
11
|
+
const describedBy = [
|
|
12
|
+
ariaDescribedBy,
|
|
13
|
+
descriptionId,
|
|
14
|
+
errorId
|
|
15
|
+
].filter(Boolean).join(" ") || void 0;
|
|
16
|
+
const hasSource = Boolean(src) || Boolean(sources?.length);
|
|
17
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
18
|
+
className: "pf-field",
|
|
19
|
+
children: [
|
|
20
|
+
label ? /* @__PURE__ */ jsx("label", {
|
|
21
|
+
className: "pf-field__label",
|
|
22
|
+
htmlFor: videoId,
|
|
23
|
+
children: label
|
|
24
|
+
}) : null,
|
|
25
|
+
/* @__PURE__ */ jsx("div", {
|
|
26
|
+
className: cx("pf-video-player", `pf-video-player--ratio-${aspectRatio.replace("/", "-")}`, error && "pf-video-player--invalid", className),
|
|
27
|
+
children: hasSource ? /* @__PURE__ */ jsxs("video", {
|
|
28
|
+
...props,
|
|
29
|
+
ref,
|
|
30
|
+
id: videoId,
|
|
31
|
+
className: "pf-video-player__video",
|
|
32
|
+
controls,
|
|
33
|
+
preload,
|
|
34
|
+
src,
|
|
35
|
+
"aria-invalid": error ? true : void 0,
|
|
36
|
+
"aria-describedby": describedBy,
|
|
37
|
+
children: [sources?.map((source) => /* @__PURE__ */ jsx("source", {
|
|
38
|
+
src: source.src,
|
|
39
|
+
type: source.type
|
|
40
|
+
}, `${source.src}-${source.type ?? "default"}`)), tracks?.map((track) => /* @__PURE__ */ jsx("track", {
|
|
41
|
+
src: track.src,
|
|
42
|
+
kind: track.kind,
|
|
43
|
+
srcLang: track.srcLang,
|
|
44
|
+
label: track.label,
|
|
45
|
+
default: track.default
|
|
46
|
+
}, `${track.src}-${track.kind}-${track.srcLang}`))]
|
|
47
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
48
|
+
className: "pf-video-player__empty",
|
|
49
|
+
role: "note",
|
|
50
|
+
id: videoId,
|
|
51
|
+
children: "Add a video src to display playback."
|
|
52
|
+
})
|
|
53
|
+
}),
|
|
54
|
+
description ? /* @__PURE__ */ jsx("p", {
|
|
55
|
+
className: "pf-field__description",
|
|
56
|
+
id: descriptionId,
|
|
57
|
+
children: description
|
|
58
|
+
}) : null,
|
|
59
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
60
|
+
className: "pf-field__error",
|
|
61
|
+
id: errorId,
|
|
62
|
+
children: error
|
|
63
|
+
}) : null
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
VideoPlayer.displayName = "VideoPlayer";
|
|
68
|
+
//#endregion
|
|
69
|
+
export { VideoPlayer };
|
package/dist/index14.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/BadgeGroup/BadgeGroup.tsx
|
|
6
|
+
var BadgeGroup = forwardRef(({ label, message, color = "gray", appearance = "pill", badgePosition = "leading", className, ...props }, ref) => {
|
|
7
|
+
const badge = /* @__PURE__ */ jsx("span", {
|
|
8
|
+
className: cx("pf-badge-group__badge", `pf-badge-group__badge--${color}`),
|
|
9
|
+
children: label
|
|
10
|
+
});
|
|
11
|
+
const text = /* @__PURE__ */ jsx("span", {
|
|
12
|
+
className: cx("pf-badge-group__text", `pf-badge-group__text--${appearance}`, `pf-badge-group__text--${color}`),
|
|
13
|
+
children: message
|
|
14
|
+
});
|
|
15
|
+
return /* @__PURE__ */ jsx("div", {
|
|
16
|
+
ref,
|
|
17
|
+
className: cx("pf-badge-group", `pf-badge-group--${appearance}`, `pf-badge-group--${badgePosition}`, className),
|
|
18
|
+
...props,
|
|
19
|
+
children: badgePosition === "leading" ? /* @__PURE__ */ jsxs(Fragment, { children: [badge, text] }) : /* @__PURE__ */ jsxs(Fragment, { children: [text, badge] })
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
BadgeGroup.displayName = "BadgeGroup";
|
|
23
|
+
//#endregion
|
|
24
|
+
export { BadgeGroup };
|
package/dist/index16.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { forwardRef, useMemo, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/ButtonGroup/ButtonGroup.tsx
|
|
6
|
+
var isSelected = (currentValue, itemValue, multiple) => {
|
|
7
|
+
if (multiple) return Array.isArray(currentValue) ? currentValue.includes(itemValue) : false;
|
|
8
|
+
return currentValue === itemValue;
|
|
9
|
+
};
|
|
10
|
+
var ButtonGroup = forwardRef(({ items, value, defaultValue, multiple = false, onValueChange, disabled = false, className, ...props }, ref) => {
|
|
11
|
+
const isControlled = value !== void 0;
|
|
12
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
13
|
+
const selectedValue = isControlled ? value : internalValue;
|
|
14
|
+
const selectedSet = useMemo(() => {
|
|
15
|
+
if (!multiple) return new Set(typeof selectedValue === "string" ? [selectedValue] : []);
|
|
16
|
+
return new Set(Array.isArray(selectedValue) ? selectedValue : []);
|
|
17
|
+
}, [multiple, selectedValue]);
|
|
18
|
+
const handleSelect = (itemValue) => {
|
|
19
|
+
if (disabled) return;
|
|
20
|
+
if (multiple) {
|
|
21
|
+
const nextValue = selectedSet.has(itemValue) ? [...selectedSet].filter((currentItem) => currentItem !== itemValue) : [...selectedSet, itemValue];
|
|
22
|
+
if (!isControlled) setInternalValue(nextValue);
|
|
23
|
+
onValueChange?.(nextValue);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (!isControlled) setInternalValue(itemValue);
|
|
27
|
+
onValueChange?.(itemValue);
|
|
28
|
+
};
|
|
29
|
+
return /* @__PURE__ */ jsx("div", {
|
|
30
|
+
ref,
|
|
31
|
+
className: cx("pf-button-group", className),
|
|
32
|
+
role: "group",
|
|
33
|
+
...props,
|
|
34
|
+
children: items.map((item) => {
|
|
35
|
+
const selected = isSelected(selectedValue, item.value, multiple);
|
|
36
|
+
const isDisabled = disabled || item.disabled;
|
|
37
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
38
|
+
type: "button",
|
|
39
|
+
className: cx("pf-button-group__button", selected && "pf-button-group__button--selected"),
|
|
40
|
+
"aria-pressed": selected,
|
|
41
|
+
disabled: isDisabled,
|
|
42
|
+
onClick: () => handleSelect(item.value),
|
|
43
|
+
children: [
|
|
44
|
+
item.icon ? /* @__PURE__ */ jsx("span", {
|
|
45
|
+
"aria-hidden": true,
|
|
46
|
+
className: "pf-button-group__icon",
|
|
47
|
+
children: item.icon
|
|
48
|
+
}) : null,
|
|
49
|
+
item.dot ? /* @__PURE__ */ jsx("span", {
|
|
50
|
+
"aria-hidden": true,
|
|
51
|
+
className: "pf-button-group__dot"
|
|
52
|
+
}) : null,
|
|
53
|
+
/* @__PURE__ */ jsx("span", {
|
|
54
|
+
className: "pf-button-group__label",
|
|
55
|
+
children: item.label
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
}, item.value);
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
ButtonGroup.displayName = "ButtonGroup";
|
|
63
|
+
//#endregion
|
|
64
|
+
export { ButtonGroup };
|
package/dist/index18.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Breadcrumbs/Breadcrumbs.tsx
|
|
6
|
+
var Breadcrumbs = forwardRef(({ className, items, separator = "/", "aria-label": ariaLabel = "Breadcrumb", ...props }, ref) => /* @__PURE__ */ jsx("nav", {
|
|
7
|
+
ref,
|
|
8
|
+
className: cx("pf-breadcrumbs", className),
|
|
9
|
+
"aria-label": ariaLabel,
|
|
10
|
+
...props,
|
|
11
|
+
children: /* @__PURE__ */ jsx("ol", {
|
|
12
|
+
className: "pf-breadcrumbs__list",
|
|
13
|
+
children: items.map((item, index) => {
|
|
14
|
+
const isLast = index === items.length - 1;
|
|
15
|
+
const isCurrent = item.current ?? isLast;
|
|
16
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
17
|
+
className: "pf-breadcrumbs__item",
|
|
18
|
+
children: [item.href ? /* @__PURE__ */ jsx("a", {
|
|
19
|
+
href: item.href,
|
|
20
|
+
onClick: item.onClick,
|
|
21
|
+
className: cx("pf-breadcrumbs__link", isCurrent && "pf-breadcrumbs__link--current"),
|
|
22
|
+
"aria-current": isCurrent ? "page" : void 0,
|
|
23
|
+
children: item.label
|
|
24
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
25
|
+
className: cx("pf-breadcrumbs__link", isCurrent && "pf-breadcrumbs__link--current"),
|
|
26
|
+
"aria-current": isCurrent ? "page" : void 0,
|
|
27
|
+
children: item.label
|
|
28
|
+
}), !isLast ? /* @__PURE__ */ jsx("span", {
|
|
29
|
+
className: "pf-breadcrumbs__separator",
|
|
30
|
+
"aria-hidden": true,
|
|
31
|
+
children: separator
|
|
32
|
+
}) : null]
|
|
33
|
+
}, `${index}-${typeof item.label === "string" ? item.label : "item"}`);
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
}));
|
|
37
|
+
Breadcrumbs.displayName = "Breadcrumbs";
|
|
38
|
+
//#endregion
|
|
39
|
+
export { Breadcrumbs };
|
package/dist/index19.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
//#region src/utils/FieldWrapper.tsx
|
|
5
|
+
var FieldWrapper = forwardRef(({ labelFor, label, description, descriptionId, error, errorId, required, children, footer, className }, ref) => /* @__PURE__ */ jsxs("div", {
|
|
6
|
+
ref,
|
|
7
|
+
className: cx("pf-field", className),
|
|
8
|
+
children: [
|
|
9
|
+
label ? /* @__PURE__ */ jsxs("label", {
|
|
10
|
+
className: "pf-field__label",
|
|
11
|
+
id: `${labelFor}-label`,
|
|
12
|
+
htmlFor: labelFor,
|
|
13
|
+
children: [label, required && /* @__PURE__ */ jsx("span", {
|
|
14
|
+
className: "pf-field__required",
|
|
15
|
+
"aria-hidden": "true",
|
|
16
|
+
children: "*"
|
|
17
|
+
})]
|
|
18
|
+
}) : null,
|
|
19
|
+
children,
|
|
20
|
+
description ? /* @__PURE__ */ jsx("p", {
|
|
21
|
+
className: "pf-field__description",
|
|
22
|
+
id: descriptionId,
|
|
23
|
+
children: description
|
|
24
|
+
}) : null,
|
|
25
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
26
|
+
className: "pf-field__error",
|
|
27
|
+
id: errorId,
|
|
28
|
+
children: error
|
|
29
|
+
}) : null,
|
|
30
|
+
footer
|
|
31
|
+
]
|
|
32
|
+
}));
|
|
33
|
+
FieldWrapper.displayName = "FieldWrapper";
|
|
34
|
+
//#endregion
|
|
35
|
+
export { FieldWrapper };
|
package/dist/index21.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
import { FieldWrapper } from "./index19.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { forwardRef, useId } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/Input/Input.tsx
|
|
7
|
+
var Input = forwardRef(({ id, label, description, error, className, "aria-describedby": ariaDescribedBy, ...props }, ref) => {
|
|
8
|
+
const generatedId = useId();
|
|
9
|
+
const inputId = id ?? generatedId;
|
|
10
|
+
const descriptionId = description ? `${inputId}-description` : void 0;
|
|
11
|
+
const errorId = error ? `${inputId}-error` : void 0;
|
|
12
|
+
const describedBy = [
|
|
13
|
+
ariaDescribedBy,
|
|
14
|
+
descriptionId,
|
|
15
|
+
errorId
|
|
16
|
+
].filter(Boolean).join(" ") || void 0;
|
|
17
|
+
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
18
|
+
labelFor: inputId,
|
|
19
|
+
label,
|
|
20
|
+
description,
|
|
21
|
+
descriptionId,
|
|
22
|
+
error,
|
|
23
|
+
errorId,
|
|
24
|
+
required: props.required,
|
|
25
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
26
|
+
...props,
|
|
27
|
+
ref,
|
|
28
|
+
id: inputId,
|
|
29
|
+
className: cx("pf-input", error && "pf-input--invalid", className),
|
|
30
|
+
"aria-invalid": error ? true : void 0,
|
|
31
|
+
"aria-describedby": describedBy
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
Input.displayName = "Input";
|
|
36
|
+
//#endregion
|
|
37
|
+
export { Input };
|