@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/index23.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Badge/Badge.tsx
|
|
6
|
+
var Badge = forwardRef(({ className, variant = "neutral", ...props }, ref) => /* @__PURE__ */ jsx("span", {
|
|
7
|
+
ref,
|
|
8
|
+
className: cx("pf-badge", `pf-badge--${variant}`, className),
|
|
9
|
+
...props
|
|
10
|
+
}));
|
|
11
|
+
Badge.displayName = "Badge";
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Badge };
|
package/dist/index25.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/Card/Card.tsx
|
|
5
|
+
function Card({ className, ref, ...props }) {
|
|
6
|
+
return /* @__PURE__ */ jsx("div", {
|
|
7
|
+
ref,
|
|
8
|
+
className: cx("pf-card", className),
|
|
9
|
+
...props
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
Card.displayName = "Card";
|
|
13
|
+
function CardHeader({ className, ref, ...props }) {
|
|
14
|
+
return /* @__PURE__ */ jsx("div", {
|
|
15
|
+
ref,
|
|
16
|
+
className: cx("pf-card__header", className),
|
|
17
|
+
...props
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
CardHeader.displayName = "CardHeader";
|
|
21
|
+
function CardContent({ className, ref, ...props }) {
|
|
22
|
+
return /* @__PURE__ */ jsx("div", {
|
|
23
|
+
ref,
|
|
24
|
+
className: cx("pf-card__content", className),
|
|
25
|
+
...props
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
CardContent.displayName = "CardContent";
|
|
29
|
+
function CardFooter({ className, ref, ...props }) {
|
|
30
|
+
return /* @__PURE__ */ jsx("div", {
|
|
31
|
+
ref,
|
|
32
|
+
className: cx("pf-card__footer", className),
|
|
33
|
+
...props
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
CardFooter.displayName = "CardFooter";
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Card, CardContent, CardFooter, CardHeader };
|
package/dist/index27.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
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/CreditCard/CreditCard.tsx
|
|
6
|
+
var maskCardNumber = (value) => {
|
|
7
|
+
const digits = value.replace(/\D+/g, "");
|
|
8
|
+
if (digits.length <= 4) return digits;
|
|
9
|
+
const visible = digits.slice(-4);
|
|
10
|
+
const hiddenLength = digits.length - 4;
|
|
11
|
+
return `${"*".repeat(hiddenLength)}${visible}`.replace(/(.{4})/g, "$1 ").trim();
|
|
12
|
+
};
|
|
13
|
+
var formatCardNumber = (value) => {
|
|
14
|
+
return value.replace(/\D+/g, "").replace(/(.{4})/g, "$1 ").trim();
|
|
15
|
+
};
|
|
16
|
+
var CreditCard = forwardRef(({ brand = "generic", cardNumber, cardholderName, expiry, cvc, masked = true, className, ...props }, ref) => {
|
|
17
|
+
const displayNumber = masked ? maskCardNumber(cardNumber) : formatCardNumber(cardNumber);
|
|
18
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
19
|
+
ref,
|
|
20
|
+
className: cx("pf-credit-card", `is-${brand}`, className),
|
|
21
|
+
...props,
|
|
22
|
+
children: [
|
|
23
|
+
/* @__PURE__ */ jsxs("div", {
|
|
24
|
+
className: "top-row",
|
|
25
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
26
|
+
className: "chip",
|
|
27
|
+
"aria-hidden": true
|
|
28
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
29
|
+
className: "brand",
|
|
30
|
+
children: brand.toUpperCase()
|
|
31
|
+
})]
|
|
32
|
+
}),
|
|
33
|
+
/* @__PURE__ */ jsx("p", {
|
|
34
|
+
className: "number",
|
|
35
|
+
children: displayNumber
|
|
36
|
+
}),
|
|
37
|
+
/* @__PURE__ */ jsxs("div", {
|
|
38
|
+
className: "meta",
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
|
|
41
|
+
className: "label",
|
|
42
|
+
children: "Card holder"
|
|
43
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
44
|
+
className: "value",
|
|
45
|
+
children: cardholderName
|
|
46
|
+
})] }),
|
|
47
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
|
|
48
|
+
className: "label",
|
|
49
|
+
children: "Expires"
|
|
50
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
51
|
+
className: "value",
|
|
52
|
+
children: expiry
|
|
53
|
+
})] }),
|
|
54
|
+
cvc ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
|
|
55
|
+
className: "label",
|
|
56
|
+
children: "CVC"
|
|
57
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
58
|
+
className: "value",
|
|
59
|
+
children: masked ? "***" : cvc
|
|
60
|
+
})] }) : null
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
CreditCard.displayName = "CreditCard";
|
|
67
|
+
//#endregion
|
|
68
|
+
export { CreditCard };
|
package/dist/index29.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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/Checkbox/Checkbox.tsx
|
|
6
|
+
var Checkbox = forwardRef(({ id, label, className, ...props }, ref) => {
|
|
7
|
+
const generatedId = useId();
|
|
8
|
+
const checkboxId = id ?? generatedId;
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
10
|
+
className: "pf-checkbox-field",
|
|
11
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
12
|
+
ref,
|
|
13
|
+
id: checkboxId,
|
|
14
|
+
type: "checkbox",
|
|
15
|
+
className: cx("pf-checkbox", className),
|
|
16
|
+
...props
|
|
17
|
+
}), label ? /* @__PURE__ */ jsx("label", {
|
|
18
|
+
htmlFor: checkboxId,
|
|
19
|
+
children: label
|
|
20
|
+
}) : null]
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
Checkbox.displayName = "Checkbox";
|
|
24
|
+
//#endregion
|
|
25
|
+
export { Checkbox };
|
package/dist/index3.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/a11y/index.ts
|
|
2
|
+
var Keys = {
|
|
3
|
+
ArrowDown: "ArrowDown",
|
|
4
|
+
ArrowLeft: "ArrowLeft",
|
|
5
|
+
ArrowRight: "ArrowRight",
|
|
6
|
+
ArrowUp: "ArrowUp",
|
|
7
|
+
End: "End",
|
|
8
|
+
Enter: "Enter",
|
|
9
|
+
Escape: "Escape",
|
|
10
|
+
Home: "Home",
|
|
11
|
+
Space: " ",
|
|
12
|
+
Tab: "Tab"
|
|
13
|
+
};
|
|
14
|
+
var isActivationKey = (key) => key === Keys.Enter || key === Keys.Space;
|
|
15
|
+
var composeDescribedBy = (...ids) => ids.filter(Boolean).join(" ") || void 0;
|
|
16
|
+
var getFocusableElements = (container) => {
|
|
17
|
+
const selector = [
|
|
18
|
+
"a[href]",
|
|
19
|
+
"button:not([disabled])",
|
|
20
|
+
"input:not([disabled])",
|
|
21
|
+
"select:not([disabled])",
|
|
22
|
+
"textarea:not([disabled])",
|
|
23
|
+
"[contenteditable=\"true\"]",
|
|
24
|
+
"[tabindex]:not([tabindex=\"-1\"])"
|
|
25
|
+
].join(",");
|
|
26
|
+
return Array.from(container.querySelectorAll(selector)).filter((element) => {
|
|
27
|
+
if (element.hasAttribute("disabled") || element.getAttribute("aria-hidden") === "true") return false;
|
|
28
|
+
return element.offsetParent !== null;
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { Keys, composeDescribedBy, getFocusableElements, isActivationKey };
|
package/dist/index30.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
//#region src/hooks/useAnchoredPosition.ts
|
|
3
|
+
function useAnchoredPosition({ anchorRef, floatingRef, enabled = true, align = "start", offset = 8, viewportPadding = 8, minWidth, matchAnchorWidth = true, flip = false }) {
|
|
4
|
+
const [style, setStyle] = useState({});
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
if (!enabled || typeof window === "undefined") return;
|
|
7
|
+
const updatePosition = () => {
|
|
8
|
+
const anchor = anchorRef.current;
|
|
9
|
+
if (!anchor) return;
|
|
10
|
+
const anchorRect = anchor.getBoundingClientRect();
|
|
11
|
+
const floatingRect = floatingRef?.current?.getBoundingClientRect();
|
|
12
|
+
const width = Math.max(matchAnchorWidth ? anchorRect.width : 0, minWidth ?? 0, floatingRect?.width ?? 0);
|
|
13
|
+
const maxLeft = window.innerWidth - viewportPadding - width;
|
|
14
|
+
const alignedLeft = align === "end" ? anchorRect.right - width : anchorRect.left;
|
|
15
|
+
const left = maxLeft >= viewportPadding ? Math.min(Math.max(alignedLeft, viewportPadding), maxLeft) : viewportPadding;
|
|
16
|
+
const floatingHeight = floatingRect?.height ?? 0;
|
|
17
|
+
const belowTop = anchorRect.bottom + offset;
|
|
18
|
+
const aboveTop = anchorRect.top - floatingHeight - offset;
|
|
19
|
+
const rawTop = flip && floatingHeight > 0 && window.innerHeight - anchorRect.bottom < floatingHeight + offset + viewportPadding ? aboveTop : belowTop;
|
|
20
|
+
const maxTop = window.innerHeight - viewportPadding - floatingHeight;
|
|
21
|
+
setStyle({
|
|
22
|
+
left,
|
|
23
|
+
top: floatingHeight > 0 && maxTop >= viewportPadding ? Math.min(Math.max(rawTop, viewportPadding), maxTop) : rawTop,
|
|
24
|
+
width: matchAnchorWidth ? width : void 0,
|
|
25
|
+
minWidth: matchAnchorWidth ? void 0 : width
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
updatePosition();
|
|
29
|
+
window.addEventListener("resize", updatePosition);
|
|
30
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
31
|
+
return () => {
|
|
32
|
+
window.removeEventListener("resize", updatePosition);
|
|
33
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
34
|
+
};
|
|
35
|
+
}, [
|
|
36
|
+
align,
|
|
37
|
+
anchorRef,
|
|
38
|
+
enabled,
|
|
39
|
+
floatingRef,
|
|
40
|
+
flip,
|
|
41
|
+
matchAnchorWidth,
|
|
42
|
+
minWidth,
|
|
43
|
+
offset,
|
|
44
|
+
viewportPadding
|
|
45
|
+
]);
|
|
46
|
+
return style;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { useAnchoredPosition };
|
package/dist/index31.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/hooks/useComposedRefs.ts
|
|
2
|
+
function useComposedRefs(...refs) {
|
|
3
|
+
return (node) => {
|
|
4
|
+
refs.forEach((ref) => {
|
|
5
|
+
if (!ref) return;
|
|
6
|
+
if (typeof ref === "function") {
|
|
7
|
+
ref(node);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
ref.current = node;
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useComposedRefs };
|
package/dist/index32.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
//#region src/hooks/useControllableState.ts
|
|
3
|
+
function useControllableState({ value, defaultValue, onChange }) {
|
|
4
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
5
|
+
const isControlled = value !== void 0;
|
|
6
|
+
const currentValue = isControlled ? value : internalValue;
|
|
7
|
+
return [
|
|
8
|
+
currentValue,
|
|
9
|
+
useCallback((nextValue) => {
|
|
10
|
+
const resolvedValue = typeof nextValue === "function" ? nextValue(currentValue) : nextValue;
|
|
11
|
+
if (!isControlled) setInternalValue(resolvedValue);
|
|
12
|
+
onChange?.(resolvedValue);
|
|
13
|
+
}, [
|
|
14
|
+
currentValue,
|
|
15
|
+
isControlled,
|
|
16
|
+
onChange
|
|
17
|
+
]),
|
|
18
|
+
isControlled
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { useControllableState };
|
package/dist/index33.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useControllableState } from "./index32.js";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
//#region src/hooks/useDisclosure.ts
|
|
4
|
+
function useDisclosure({ open, defaultOpen = false, onOpenChange, disabled = false } = {}) {
|
|
5
|
+
const [isOpen, setIsOpen] = useControllableState({
|
|
6
|
+
value: open,
|
|
7
|
+
defaultValue: defaultOpen,
|
|
8
|
+
onChange: onOpenChange
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
isOpen,
|
|
12
|
+
setIsOpen,
|
|
13
|
+
open: useCallback(() => {
|
|
14
|
+
if (!disabled) setIsOpen(true);
|
|
15
|
+
}, [disabled, setIsOpen]),
|
|
16
|
+
close: useCallback(() => {
|
|
17
|
+
setIsOpen(false);
|
|
18
|
+
}, [setIsOpen]),
|
|
19
|
+
toggle: useCallback(() => {
|
|
20
|
+
if (!disabled) setIsOpen((current) => !current);
|
|
21
|
+
}, [disabled, setIsOpen])
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { useDisclosure };
|
package/dist/index34.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Keys, getFocusableElements } from "./index3.js";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
//#region src/hooks/useFocusTrap.ts
|
|
4
|
+
function useFocusTrap({ containerRef, enabled = true, onEscape, restoreFocus = true }) {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
if (!enabled || typeof document === "undefined") return;
|
|
7
|
+
const container = containerRef.current;
|
|
8
|
+
const previousActiveElement = document.activeElement;
|
|
9
|
+
const initialFocusable = container ? getFocusableElements(container)[0] : void 0;
|
|
10
|
+
if (initialFocusable) initialFocusable.focus();
|
|
11
|
+
else container?.focus();
|
|
12
|
+
const onKeyDown = (event) => {
|
|
13
|
+
if (event.key === Keys.Escape) {
|
|
14
|
+
onEscape?.();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (event.key !== Keys.Tab || !containerRef.current) return;
|
|
18
|
+
const focusableElements = getFocusableElements(containerRef.current);
|
|
19
|
+
if (focusableElements.length === 0) {
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
containerRef.current.focus();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const firstElement = focusableElements[0];
|
|
25
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
26
|
+
const activeElement = document.activeElement;
|
|
27
|
+
if (!(activeElement ? containerRef.current.contains(activeElement) : false)) {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
(event.shiftKey ? lastElement : firstElement).focus();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (event.shiftKey && activeElement === firstElement) {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
lastElement.focus();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (!event.shiftKey && activeElement === lastElement) {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
firstElement.focus();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
document.addEventListener("keydown", onKeyDown);
|
|
43
|
+
return () => {
|
|
44
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
45
|
+
if (restoreFocus) previousActiveElement?.focus?.();
|
|
46
|
+
};
|
|
47
|
+
}, [
|
|
48
|
+
containerRef,
|
|
49
|
+
enabled,
|
|
50
|
+
onEscape,
|
|
51
|
+
restoreFocus
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { useFocusTrap };
|
package/dist/index35.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
//#region src/hooks/useListNavigation.ts
|
|
3
|
+
function useListNavigation({ items, isDisabled = () => false, initialIndex }) {
|
|
4
|
+
const enabledIndexes = useMemo(() => items.map((item, index) => ({
|
|
5
|
+
item,
|
|
6
|
+
index
|
|
7
|
+
})).filter(({ item, index }) => !isDisabled(item, index)).map(({ index }) => index), [isDisabled, items]);
|
|
8
|
+
const firstEnabledIndex = enabledIndexes[0] ?? -1;
|
|
9
|
+
const lastEnabledIndex = enabledIndexes[enabledIndexes.length - 1] ?? -1;
|
|
10
|
+
const [activeIndex, setActiveIndex] = useState(initialIndex ?? firstEnabledIndex);
|
|
11
|
+
const getNextEnabledIndex = useCallback((startIndex, direction) => {
|
|
12
|
+
if (enabledIndexes.length === 0) return -1;
|
|
13
|
+
const currentEnabledPosition = enabledIndexes.indexOf(startIndex);
|
|
14
|
+
return enabledIndexes[((currentEnabledPosition === -1 ? direction === 1 ? -1 : 0 : currentEnabledPosition) + direction + enabledIndexes.length) % enabledIndexes.length] ?? -1;
|
|
15
|
+
}, [enabledIndexes]);
|
|
16
|
+
return {
|
|
17
|
+
activeIndex,
|
|
18
|
+
enabledIndexes,
|
|
19
|
+
firstEnabledIndex,
|
|
20
|
+
lastEnabledIndex,
|
|
21
|
+
getNextEnabledIndex,
|
|
22
|
+
move: useCallback((action, currentIndex = activeIndex) => {
|
|
23
|
+
const nextIndex = action === "first" ? firstEnabledIndex : action === "last" ? lastEnabledIndex : getNextEnabledIndex(currentIndex, action === "next" ? 1 : -1);
|
|
24
|
+
if (nextIndex >= 0) setActiveIndex(nextIndex);
|
|
25
|
+
return nextIndex;
|
|
26
|
+
}, [
|
|
27
|
+
activeIndex,
|
|
28
|
+
firstEnabledIndex,
|
|
29
|
+
getNextEnabledIndex,
|
|
30
|
+
lastEnabledIndex
|
|
31
|
+
]),
|
|
32
|
+
setActiveIndex
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { useListNavigation };
|
package/dist/index36.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
//#region src/hooks/useOutsideInteraction.ts
|
|
3
|
+
function useOutsideInteraction({ refs, enabled = true, onInteractOutside, eventName = "pointerdown" }) {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
if (!enabled || typeof document === "undefined") return;
|
|
6
|
+
const handleEvent = (event) => {
|
|
7
|
+
const target = event.target;
|
|
8
|
+
if (!refs.some((ref) => ref.current?.contains(target))) onInteractOutside(event);
|
|
9
|
+
};
|
|
10
|
+
document.addEventListener(eventName, handleEvent);
|
|
11
|
+
return () => {
|
|
12
|
+
document.removeEventListener(eventName, handleEvent);
|
|
13
|
+
};
|
|
14
|
+
}, [
|
|
15
|
+
enabled,
|
|
16
|
+
eventName,
|
|
17
|
+
onInteractOutside,
|
|
18
|
+
refs
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { useOutsideInteraction };
|
package/dist/index38.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Keys, isActivationKey } from "./index3.js";
|
|
2
|
+
import { cx } from "./index4.js";
|
|
3
|
+
import { Icon } from "./index6.js";
|
|
4
|
+
import { useAnchoredPosition } from "./index30.js";
|
|
5
|
+
import { useDisclosure } from "./index33.js";
|
|
6
|
+
import { useListNavigation } from "./index35.js";
|
|
7
|
+
import { useOutsideInteraction } from "./index36.js";
|
|
8
|
+
/* empty css */
|
|
9
|
+
import { forwardRef, useEffect, useId, useRef } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { createPortal } from "react-dom";
|
|
12
|
+
//#region src/components/Dropdown/Dropdown.tsx
|
|
13
|
+
var Dropdown = forwardRef(({ label = "Actions", items, align = "start", disabled, className, maxVisibleItems, ...props }, ref) => {
|
|
14
|
+
const menuId = useId();
|
|
15
|
+
const rootRef = useRef(null);
|
|
16
|
+
const triggerRef = useRef(null);
|
|
17
|
+
const menuRef = useRef(null);
|
|
18
|
+
const disclosure = useDisclosure({ disabled });
|
|
19
|
+
const { isOpen } = disclosure;
|
|
20
|
+
const { activeIndex, firstEnabledIndex, move, setActiveIndex } = useListNavigation({
|
|
21
|
+
items,
|
|
22
|
+
isDisabled: (item) => Boolean(item.disabled)
|
|
23
|
+
});
|
|
24
|
+
const menuStyle = useAnchoredPosition({
|
|
25
|
+
anchorRef: triggerRef,
|
|
26
|
+
align,
|
|
27
|
+
enabled: isOpen,
|
|
28
|
+
matchAnchorWidth: false,
|
|
29
|
+
minWidth: 200
|
|
30
|
+
});
|
|
31
|
+
useOutsideInteraction({
|
|
32
|
+
refs: [rootRef, menuRef],
|
|
33
|
+
enabled: isOpen,
|
|
34
|
+
onInteractOutside: disclosure.close
|
|
35
|
+
});
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!isOpen) return;
|
|
38
|
+
setActiveIndex(firstEnabledIndex);
|
|
39
|
+
}, [
|
|
40
|
+
firstEnabledIndex,
|
|
41
|
+
isOpen,
|
|
42
|
+
setActiveIndex
|
|
43
|
+
]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const handleEscape = (event) => {
|
|
46
|
+
if (event.key === Keys.Escape) {
|
|
47
|
+
disclosure.close();
|
|
48
|
+
triggerRef.current?.focus();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
document.addEventListener("keydown", handleEscape);
|
|
52
|
+
return () => {
|
|
53
|
+
document.removeEventListener("keydown", handleEscape);
|
|
54
|
+
};
|
|
55
|
+
}, [disclosure]);
|
|
56
|
+
const onTriggerKeyDown = (event) => {
|
|
57
|
+
if (disabled) return;
|
|
58
|
+
if (event.key === Keys.ArrowDown || event.key === Keys.ArrowUp) {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
if (!isOpen) {
|
|
61
|
+
disclosure.open();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const startIndex = activeIndex >= 0 ? activeIndex : 0;
|
|
65
|
+
move(event.key === Keys.ArrowDown ? "next" : "previous", startIndex);
|
|
66
|
+
}
|
|
67
|
+
if (isActivationKey(event.key)) {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
disclosure.toggle();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
let menuMaxHeight;
|
|
73
|
+
if (maxVisibleItems && items.length > 0) menuMaxHeight = `calc(${maxVisibleItems} * 36px)`;
|
|
74
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
75
|
+
ref: rootRef,
|
|
76
|
+
className: cx("pf-dropdown", className),
|
|
77
|
+
...props,
|
|
78
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
79
|
+
ref: (node) => {
|
|
80
|
+
triggerRef.current = node;
|
|
81
|
+
if (typeof ref === "function") ref(node);
|
|
82
|
+
else if (ref) ref.current = node;
|
|
83
|
+
},
|
|
84
|
+
type: "button",
|
|
85
|
+
className: "pf-dropdown__trigger",
|
|
86
|
+
"aria-haspopup": "menu",
|
|
87
|
+
"aria-expanded": isOpen,
|
|
88
|
+
"aria-controls": isOpen ? menuId : void 0,
|
|
89
|
+
onClick: () => {
|
|
90
|
+
disclosure.toggle();
|
|
91
|
+
},
|
|
92
|
+
onKeyDown: onTriggerKeyDown,
|
|
93
|
+
disabled,
|
|
94
|
+
children: [/* @__PURE__ */ jsx("span", { children: label }), /* @__PURE__ */ jsx("span", {
|
|
95
|
+
className: cx("pf-dropdown__chevron", isOpen && "pf-dropdown__chevron--open"),
|
|
96
|
+
"aria-hidden": true,
|
|
97
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
98
|
+
name: "chevron-down",
|
|
99
|
+
"aria-hidden": true
|
|
100
|
+
})
|
|
101
|
+
})]
|
|
102
|
+
}), isOpen && typeof document !== "undefined" ? createPortal(/* @__PURE__ */ jsx("div", {
|
|
103
|
+
id: menuId,
|
|
104
|
+
ref: menuRef,
|
|
105
|
+
className: "pf-dropdown__menu",
|
|
106
|
+
role: "menu",
|
|
107
|
+
style: {
|
|
108
|
+
...menuStyle,
|
|
109
|
+
...menuMaxHeight ? {
|
|
110
|
+
maxHeight: menuMaxHeight,
|
|
111
|
+
overflowY: "auto"
|
|
112
|
+
} : {}
|
|
113
|
+
},
|
|
114
|
+
children: items.map((item, index) => {
|
|
115
|
+
const isActive = index === activeIndex;
|
|
116
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
117
|
+
id: `${menuId}-item-${index}`,
|
|
118
|
+
type: "button",
|
|
119
|
+
role: "menuitem",
|
|
120
|
+
disabled: item.disabled,
|
|
121
|
+
className: cx("pf-dropdown__item", isActive && "pf-dropdown__item--active", item.destructive && "pf-dropdown__item--destructive"),
|
|
122
|
+
onMouseEnter: () => {
|
|
123
|
+
if (!item.disabled) setActiveIndex(index);
|
|
124
|
+
},
|
|
125
|
+
onClick: () => {
|
|
126
|
+
if (item.disabled) return;
|
|
127
|
+
item.onSelect?.();
|
|
128
|
+
disclosure.close();
|
|
129
|
+
triggerRef.current?.focus();
|
|
130
|
+
},
|
|
131
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
132
|
+
className: "pf-dropdown__item-left",
|
|
133
|
+
children: [item.icon ? /* @__PURE__ */ jsx("span", {
|
|
134
|
+
className: "pf-dropdown__item-icon",
|
|
135
|
+
"aria-hidden": true,
|
|
136
|
+
children: item.icon
|
|
137
|
+
}) : null, /* @__PURE__ */ jsx("span", { children: item.label })]
|
|
138
|
+
}), item.shortcut ? /* @__PURE__ */ jsx("span", {
|
|
139
|
+
className: "pf-dropdown__item-shortcut",
|
|
140
|
+
children: item.shortcut
|
|
141
|
+
}) : null]
|
|
142
|
+
}, item.id ?? `${item.label}-${index}`);
|
|
143
|
+
})
|
|
144
|
+
}), document.body) : null]
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
Dropdown.displayName = "Dropdown";
|
|
148
|
+
//#endregion
|
|
149
|
+
export { Dropdown };
|