@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/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
import { Keys, composeDescribedBy, getFocusableElements, isActivationKey } from "./index3.js";
|
|
3
|
+
import { Icon, getAvailableIconNames, getCustomIconNames } from "./index6.js";
|
|
4
|
+
import { Alert } from "./index8.js";
|
|
5
|
+
import { Avatar } from "./index10.js";
|
|
6
|
+
import { Button } from "./index12.js";
|
|
7
|
+
import { BadgeGroup } from "./index14.js";
|
|
8
|
+
import { ButtonGroup } from "./index16.js";
|
|
9
|
+
import { Breadcrumbs } from "./index18.js";
|
|
10
|
+
import { Input } from "./index21.js";
|
|
11
|
+
import { Badge } from "./index23.js";
|
|
12
|
+
import { Card, CardContent, CardFooter, CardHeader } from "./index25.js";
|
|
13
|
+
import { CreditCard } from "./index27.js";
|
|
14
|
+
import { Checkbox } from "./index29.js";
|
|
15
|
+
import { useAnchoredPosition } from "./index30.js";
|
|
16
|
+
import { useComposedRefs } from "./index31.js";
|
|
17
|
+
import { useControllableState } from "./index32.js";
|
|
18
|
+
import { useDisclosure } from "./index33.js";
|
|
19
|
+
import { useFocusTrap } from "./index34.js";
|
|
20
|
+
import { useListNavigation } from "./index35.js";
|
|
21
|
+
import { useOutsideInteraction } from "./index36.js";
|
|
22
|
+
import { Dropdown } from "./index38.js";
|
|
23
|
+
import { Calendar } from "./index40.js";
|
|
24
|
+
import { Carousel } from "./index42.js";
|
|
25
|
+
import { CodeSnippet } from "./index46.js";
|
|
26
|
+
import { ContentDivider } from "./index48.js";
|
|
27
|
+
import { DatePicker } from "./index50.js";
|
|
28
|
+
import { EmptyState } from "./index52.js";
|
|
29
|
+
import { FileUploader } from "./index54.js";
|
|
30
|
+
import { HeaderNavigation } from "./index56.js";
|
|
31
|
+
import { InlineCTA } from "./index58.js";
|
|
32
|
+
import { BarChart, LineChart } from "./index60.js";
|
|
33
|
+
import { LoadingDots, LoadingSkeleton, LoadingSpinner } from "./index62.js";
|
|
34
|
+
import { MetricCard, MetricGrid } from "./index64.js";
|
|
35
|
+
import { Modal, ModalBody, ModalFooter, ModalHeader } from "./index66.js";
|
|
36
|
+
import { MultiSelect } from "./index68.js";
|
|
37
|
+
import { Notification, NotificationStack } from "./index70.js";
|
|
38
|
+
import { PageHeader, PageHeaderMeta } from "./index72.js";
|
|
39
|
+
import { Pagination } from "./index74.js";
|
|
40
|
+
import { PieChart } from "./index76.js";
|
|
41
|
+
import { ProgressBar, ProgressCircle } from "./index78.js";
|
|
42
|
+
import { ProgressSteps } from "./index80.js";
|
|
43
|
+
import { RadarChart } from "./index82.js";
|
|
44
|
+
import { RadioButton } from "./index84.js";
|
|
45
|
+
import { RadioGroup } from "./index86.js";
|
|
46
|
+
import { RatingBadge, RatingStars } from "./index88.js";
|
|
47
|
+
import { RichTextEditor } from "./index90.js";
|
|
48
|
+
import { SectionFooter } from "./index92.js";
|
|
49
|
+
import { SectionHeader } from "./index94.js";
|
|
50
|
+
import { SidebarNavigation } from "./index96.js";
|
|
51
|
+
import { SlideoutMenu } from "./index98.js";
|
|
52
|
+
import { Switch } from "./index100.js";
|
|
53
|
+
import { Select } from "./index102.js";
|
|
54
|
+
import { Slider } from "./index104.js";
|
|
55
|
+
import { Tag } from "./index106.js";
|
|
56
|
+
import { Table } from "./index108.js";
|
|
57
|
+
import { Tabs } from "./index110.js";
|
|
58
|
+
import { Textarea } from "./index112.js";
|
|
59
|
+
import { Tooltip } from "./index114.js";
|
|
60
|
+
import { TreeView } from "./index116.js";
|
|
61
|
+
import { UtilityButton } from "./index118.js";
|
|
62
|
+
import { VideoPlayer } from "./index120.js";
|
|
63
|
+
export { Alert, Avatar, Badge, BadgeGroup, BarChart, Breadcrumbs, Button, ButtonGroup, Calendar, Card, CardContent, CardFooter, CardHeader, Carousel, Checkbox, CodeSnippet, ContentDivider, CreditCard, DatePicker, Dropdown, EmptyState, FileUploader, HeaderNavigation, Icon, InlineCTA, Input, Keys, LineChart, LoadingDots, LoadingSkeleton, LoadingSpinner, MetricCard, MetricGrid, Modal, ModalBody, ModalFooter, ModalHeader, MultiSelect, Notification, NotificationStack, PageHeader, PageHeaderMeta, Pagination, PieChart, ProgressBar, ProgressCircle, ProgressSteps, RadarChart, RadioButton, RadioGroup, RatingBadge, RatingStars, RichTextEditor, SectionFooter, SectionHeader, Select, SidebarNavigation, SlideoutMenu, Slider, Switch, Table, Tabs, Tag, Textarea, Tooltip, TreeView, UtilityButton, VideoPlayer, composeDescribedBy, getAvailableIconNames, getCustomIconNames, getFocusableElements, isActivationKey, useAnchoredPosition, useComposedRefs, useControllableState, useDisclosure, useFocusTrap, useListNavigation, useOutsideInteraction };
|
package/dist/index10.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
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/Avatar/Avatar.tsx
|
|
6
|
+
var getInitials = (name) => {
|
|
7
|
+
if (!name) return "?";
|
|
8
|
+
const parts = name.trim().split(/\s+/).filter(Boolean).slice(0, 2);
|
|
9
|
+
if (parts.length === 0) return "?";
|
|
10
|
+
return parts.map((part) => part.charAt(0).toUpperCase()).join("");
|
|
11
|
+
};
|
|
12
|
+
var Avatar = forwardRef(({ src, alt, name, size = "md", status, className, children, ...props }, ref) => {
|
|
13
|
+
const initials = children ?? getInitials(name);
|
|
14
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
15
|
+
ref,
|
|
16
|
+
className: cx("pf-avatar", `pf-avatar--${size}`, className),
|
|
17
|
+
role: name ? "img" : void 0,
|
|
18
|
+
"aria-label": name,
|
|
19
|
+
...props,
|
|
20
|
+
children: [src ? /* @__PURE__ */ jsx("img", {
|
|
21
|
+
className: "pf-avatar__image",
|
|
22
|
+
src,
|
|
23
|
+
alt: alt ?? (name ? "" : "Avatar")
|
|
24
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
25
|
+
className: "pf-avatar__fallback",
|
|
26
|
+
"aria-hidden": true,
|
|
27
|
+
children: initials
|
|
28
|
+
}), status ? /* @__PURE__ */ jsx("span", {
|
|
29
|
+
className: cx("pf-avatar__status", `pf-avatar__status--${status}`),
|
|
30
|
+
"aria-hidden": true
|
|
31
|
+
}) : null]
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
Avatar.displayName = "Avatar";
|
|
35
|
+
//#endregion
|
|
36
|
+
export { Avatar };
|
package/dist/index100.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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/Switch/Switch.tsx
|
|
6
|
+
var Switch = forwardRef(({ id, label, className, ...props }, ref) => {
|
|
7
|
+
const generatedId = useId();
|
|
8
|
+
const switchId = id ?? generatedId;
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
10
|
+
className: "pf-switch-field",
|
|
11
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
12
|
+
ref,
|
|
13
|
+
id: switchId,
|
|
14
|
+
type: "checkbox",
|
|
15
|
+
role: "switch",
|
|
16
|
+
className: cx("pf-switch", className),
|
|
17
|
+
...props
|
|
18
|
+
}), label ? /* @__PURE__ */ jsx("label", {
|
|
19
|
+
htmlFor: switchId,
|
|
20
|
+
children: label
|
|
21
|
+
}) : null]
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
Switch.displayName = "Switch";
|
|
25
|
+
//#endregion
|
|
26
|
+
export { Switch };
|
package/dist/index102.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { Keys, composeDescribedBy, isActivationKey } from "./index3.js";
|
|
2
|
+
import { cx } from "./index4.js";
|
|
3
|
+
import { Icon } from "./index6.js";
|
|
4
|
+
import { FieldWrapper } from "./index19.js";
|
|
5
|
+
import { useAnchoredPosition } from "./index30.js";
|
|
6
|
+
import { useComposedRefs } from "./index31.js";
|
|
7
|
+
import { useControllableState } from "./index32.js";
|
|
8
|
+
import { useDisclosure } from "./index33.js";
|
|
9
|
+
import { useListNavigation } from "./index35.js";
|
|
10
|
+
import { useOutsideInteraction } from "./index36.js";
|
|
11
|
+
/* empty css */
|
|
12
|
+
import { forwardRef, useEffect, useId, useMemo, useRef } from "react";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { createPortal } from "react-dom";
|
|
15
|
+
//#region src/components/Select/Select.tsx
|
|
16
|
+
var Select = forwardRef(({ id, options, value, defaultValue, onValueChange, placeholder = "Select an option", name, label, description, error, className, disabled, required, "aria-describedby": ariaDescribedBy, maxVisibleOptions, ...props }, ref) => {
|
|
17
|
+
const generatedId = useId();
|
|
18
|
+
const selectId = id ?? generatedId;
|
|
19
|
+
const descriptionId = description ? `${selectId}-description` : void 0;
|
|
20
|
+
const errorId = error ? `${selectId}-error` : void 0;
|
|
21
|
+
const listboxId = `${selectId}-listbox`;
|
|
22
|
+
const describedBy = composeDescribedBy(ariaDescribedBy, descriptionId, errorId);
|
|
23
|
+
const [selectedValue, setSelectedValue] = useControllableState({
|
|
24
|
+
value,
|
|
25
|
+
defaultValue,
|
|
26
|
+
onChange: onValueChange
|
|
27
|
+
});
|
|
28
|
+
const selectedIndex = useMemo(() => options.findIndex((option) => option.value === selectedValue), [options, selectedValue]);
|
|
29
|
+
const selectedOption = selectedIndex >= 0 ? options[selectedIndex] : void 0;
|
|
30
|
+
const disclosure = useDisclosure({ disabled });
|
|
31
|
+
const { activeIndex, firstEnabledIndex, lastEnabledIndex, move, setActiveIndex } = useListNavigation({
|
|
32
|
+
items: options,
|
|
33
|
+
isDisabled: (option) => Boolean(option.disabled),
|
|
34
|
+
initialIndex: selectedIndex >= 0 && !options[selectedIndex]?.disabled ? selectedIndex : void 0
|
|
35
|
+
});
|
|
36
|
+
const { isOpen } = disclosure;
|
|
37
|
+
const rootRef = useRef(null);
|
|
38
|
+
const triggerRef = useRef(null);
|
|
39
|
+
const menuRef = useRef(null);
|
|
40
|
+
const triggerRefs = useComposedRefs(triggerRef, ref);
|
|
41
|
+
const menuStyle = useAnchoredPosition({
|
|
42
|
+
anchorRef: triggerRef,
|
|
43
|
+
enabled: isOpen,
|
|
44
|
+
matchAnchorWidth: true
|
|
45
|
+
});
|
|
46
|
+
useOutsideInteraction({
|
|
47
|
+
refs: [rootRef, menuRef],
|
|
48
|
+
enabled: isOpen,
|
|
49
|
+
onInteractOutside: disclosure.close
|
|
50
|
+
});
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!isOpen) return;
|
|
53
|
+
setActiveIndex(selectedIndex >= 0 && !options[selectedIndex]?.disabled ? selectedIndex : firstEnabledIndex);
|
|
54
|
+
}, [
|
|
55
|
+
firstEnabledIndex,
|
|
56
|
+
isOpen,
|
|
57
|
+
options,
|
|
58
|
+
selectedIndex,
|
|
59
|
+
setActiveIndex
|
|
60
|
+
]);
|
|
61
|
+
const selectValue = (nextValue) => {
|
|
62
|
+
setSelectedValue(nextValue);
|
|
63
|
+
};
|
|
64
|
+
const onTriggerKeyDown = (event) => {
|
|
65
|
+
if (disabled) return;
|
|
66
|
+
if (event.key === Keys.ArrowDown || event.key === Keys.ArrowUp) {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
if (!isOpen) {
|
|
69
|
+
disclosure.open();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const startIndex = activeIndex >= 0 ? activeIndex : selectedIndex;
|
|
73
|
+
move(event.key === Keys.ArrowDown ? "next" : "previous", startIndex);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (event.key === Keys.Home) {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
if (firstEnabledIndex >= 0) setActiveIndex(firstEnabledIndex);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (event.key === Keys.End) {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
if (lastEnabledIndex >= 0) setActiveIndex(lastEnabledIndex);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (isActivationKey(event.key)) {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
if (!isOpen) {
|
|
89
|
+
disclosure.open();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const activeOption = options[activeIndex];
|
|
93
|
+
if (activeOption && !activeOption.disabled) {
|
|
94
|
+
selectValue(activeOption.value);
|
|
95
|
+
disclosure.close();
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (event.key === Keys.Escape) disclosure.close();
|
|
100
|
+
};
|
|
101
|
+
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
102
|
+
labelFor: selectId,
|
|
103
|
+
label,
|
|
104
|
+
description,
|
|
105
|
+
descriptionId,
|
|
106
|
+
error,
|
|
107
|
+
errorId,
|
|
108
|
+
required,
|
|
109
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
110
|
+
className: "pf-select",
|
|
111
|
+
ref: rootRef,
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ jsxs("button", {
|
|
114
|
+
...props,
|
|
115
|
+
id: selectId,
|
|
116
|
+
ref: triggerRefs,
|
|
117
|
+
type: "button",
|
|
118
|
+
className: cx("pf-select__trigger", isOpen && "pf-select__trigger--open", error && "pf-select__trigger--invalid", className),
|
|
119
|
+
disabled,
|
|
120
|
+
"aria-haspopup": "listbox",
|
|
121
|
+
"aria-expanded": isOpen,
|
|
122
|
+
"aria-controls": isOpen ? listboxId : void 0,
|
|
123
|
+
"aria-required": required || void 0,
|
|
124
|
+
"aria-describedby": describedBy,
|
|
125
|
+
onClick: () => {
|
|
126
|
+
disclosure.toggle();
|
|
127
|
+
},
|
|
128
|
+
onKeyDown: onTriggerKeyDown,
|
|
129
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
130
|
+
className: cx("pf-select__value", !selectedOption && "pf-select__placeholder"),
|
|
131
|
+
children: selectedOption?.label ?? placeholder
|
|
132
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
133
|
+
"aria-hidden": true,
|
|
134
|
+
className: cx("pf-select__icon", isOpen && "pf-select__icon--open"),
|
|
135
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
136
|
+
name: "chevron-down",
|
|
137
|
+
"aria-hidden": true
|
|
138
|
+
})
|
|
139
|
+
})]
|
|
140
|
+
}),
|
|
141
|
+
name ? /* @__PURE__ */ jsx("input", {
|
|
142
|
+
type: "hidden",
|
|
143
|
+
name,
|
|
144
|
+
value: selectedOption?.value ?? ""
|
|
145
|
+
}) : null,
|
|
146
|
+
isOpen && typeof document !== "undefined" ? createPortal(/* @__PURE__ */ jsx("ul", {
|
|
147
|
+
id: listboxId,
|
|
148
|
+
ref: menuRef,
|
|
149
|
+
className: "pf-select__menu",
|
|
150
|
+
style: {
|
|
151
|
+
...menuStyle,
|
|
152
|
+
...maxVisibleOptions && options.length > 0 ? {
|
|
153
|
+
maxHeight: `calc(${maxVisibleOptions} * 36px)`,
|
|
154
|
+
overflowY: "auto"
|
|
155
|
+
} : {}
|
|
156
|
+
},
|
|
157
|
+
role: "listbox",
|
|
158
|
+
"aria-labelledby": label ? selectId : void 0,
|
|
159
|
+
children: options.map((option, index) => {
|
|
160
|
+
const isSelected = option.value === selectedOption?.value;
|
|
161
|
+
const isActive = index === activeIndex;
|
|
162
|
+
return /* @__PURE__ */ jsx("li", {
|
|
163
|
+
id: `${listboxId}-option-${index}`,
|
|
164
|
+
role: "option",
|
|
165
|
+
"aria-selected": isSelected,
|
|
166
|
+
"aria-disabled": option.disabled ? true : void 0,
|
|
167
|
+
className: cx("pf-select__option", isSelected && "pf-select__option--selected", isActive && "pf-select__option--active", option.disabled && "pf-select__option--disabled"),
|
|
168
|
+
onMouseEnter: () => {
|
|
169
|
+
if (!option.disabled) setActiveIndex(index);
|
|
170
|
+
},
|
|
171
|
+
onMouseDown: (event) => {
|
|
172
|
+
event.preventDefault();
|
|
173
|
+
},
|
|
174
|
+
onClick: () => {
|
|
175
|
+
if (option.disabled) return;
|
|
176
|
+
selectValue(option.value);
|
|
177
|
+
disclosure.close();
|
|
178
|
+
triggerRef.current?.focus();
|
|
179
|
+
},
|
|
180
|
+
children: option.label
|
|
181
|
+
}, option.value);
|
|
182
|
+
})
|
|
183
|
+
}), document.body) : null
|
|
184
|
+
]
|
|
185
|
+
})
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
Select.displayName = "Select";
|
|
189
|
+
//#endregion
|
|
190
|
+
export { Select };
|
package/dist/index104.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { forwardRef, useId, useMemo, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Slider/Slider.tsx
|
|
6
|
+
var clamp = (value, min, max) => {
|
|
7
|
+
return Math.min(Math.max(value, min), max);
|
|
8
|
+
};
|
|
9
|
+
var Slider = forwardRef(({ id, value, defaultValue, onValueChange, min = 0, max = 100, step = 1, label, description, error, showValue = true, className, disabled, "aria-describedby": ariaDescribedBy, ...props }, ref) => {
|
|
10
|
+
const generatedId = useId();
|
|
11
|
+
const sliderId = id ?? generatedId;
|
|
12
|
+
const descriptionId = description ? `${sliderId}-description` : void 0;
|
|
13
|
+
const errorId = error ? `${sliderId}-error` : void 0;
|
|
14
|
+
const describedBy = [
|
|
15
|
+
ariaDescribedBy,
|
|
16
|
+
descriptionId,
|
|
17
|
+
errorId
|
|
18
|
+
].filter(Boolean).join(" ") || void 0;
|
|
19
|
+
const minNumber = Number(min);
|
|
20
|
+
const maxNumber = Number(max);
|
|
21
|
+
const stepNumber = Number(step);
|
|
22
|
+
const safeMin = Number.isFinite(minNumber) ? minNumber : 0;
|
|
23
|
+
const safeMax = Number.isFinite(maxNumber) ? maxNumber : safeMin + 100;
|
|
24
|
+
const normalizedMax = safeMax >= safeMin ? safeMax : safeMin;
|
|
25
|
+
const normalizedStep = Number.isFinite(stepNumber) && stepNumber > 0 ? stepNumber : 1;
|
|
26
|
+
const isControlled = value !== void 0;
|
|
27
|
+
const [internalValue, setInternalValue] = useState(clamp(defaultValue ?? safeMin, safeMin, normalizedMax));
|
|
28
|
+
const currentValue = clamp(isControlled ? value ?? safeMin : internalValue, safeMin, normalizedMax);
|
|
29
|
+
const progressPercent = useMemo(() => {
|
|
30
|
+
const range = normalizedMax - safeMin;
|
|
31
|
+
if (range <= 0) return 0;
|
|
32
|
+
return (currentValue - safeMin) / range * 100;
|
|
33
|
+
}, [
|
|
34
|
+
currentValue,
|
|
35
|
+
normalizedMax,
|
|
36
|
+
safeMin
|
|
37
|
+
]);
|
|
38
|
+
const handleChange = (event) => {
|
|
39
|
+
const nextValue = Number(event.target.value);
|
|
40
|
+
if (!isControlled) setInternalValue(nextValue);
|
|
41
|
+
onValueChange?.(nextValue);
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
44
|
+
className: "pf-field",
|
|
45
|
+
children: [
|
|
46
|
+
label || showValue ? /* @__PURE__ */ jsxs("div", {
|
|
47
|
+
className: "pf-slider__header",
|
|
48
|
+
children: [label ? /* @__PURE__ */ jsxs("label", {
|
|
49
|
+
className: "pf-field__label",
|
|
50
|
+
htmlFor: sliderId,
|
|
51
|
+
children: [label, props.required && /* @__PURE__ */ jsx("span", {
|
|
52
|
+
className: "pf-field__required",
|
|
53
|
+
"aria-hidden": "true",
|
|
54
|
+
children: "*"
|
|
55
|
+
})]
|
|
56
|
+
}) : /* @__PURE__ */ jsx("span", {}), showValue ? /* @__PURE__ */ jsx("span", {
|
|
57
|
+
className: "pf-slider__value",
|
|
58
|
+
"aria-hidden": true,
|
|
59
|
+
children: Math.round(currentValue)
|
|
60
|
+
}) : null]
|
|
61
|
+
}) : null,
|
|
62
|
+
/* @__PURE__ */ jsx("input", {
|
|
63
|
+
...props,
|
|
64
|
+
ref,
|
|
65
|
+
id: sliderId,
|
|
66
|
+
type: "range",
|
|
67
|
+
value: currentValue,
|
|
68
|
+
min: safeMin,
|
|
69
|
+
max: normalizedMax,
|
|
70
|
+
step: normalizedStep,
|
|
71
|
+
disabled,
|
|
72
|
+
className: cx("pf-slider", error && "pf-slider--invalid", className),
|
|
73
|
+
"aria-invalid": error ? true : void 0,
|
|
74
|
+
"aria-describedby": describedBy,
|
|
75
|
+
onChange: handleChange,
|
|
76
|
+
style: { "--pf-slider-progress": `${progressPercent}%` }
|
|
77
|
+
}),
|
|
78
|
+
description ? /* @__PURE__ */ jsx("p", {
|
|
79
|
+
className: "pf-field__description",
|
|
80
|
+
id: descriptionId,
|
|
81
|
+
children: description
|
|
82
|
+
}) : null,
|
|
83
|
+
error ? /* @__PURE__ */ jsx("p", {
|
|
84
|
+
className: "pf-field__error",
|
|
85
|
+
id: errorId,
|
|
86
|
+
children: error
|
|
87
|
+
}) : null
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
Slider.displayName = "Slider";
|
|
92
|
+
//#endregion
|
|
93
|
+
export { Slider };
|
package/dist/index106.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
import { Icon } from "./index6.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/Tag/Tag.tsx
|
|
7
|
+
var Tag = forwardRef(({ className, variant = "neutral", dismissible = false, onDismiss, children, ...props }, ref) => /* @__PURE__ */ jsxs("span", {
|
|
8
|
+
ref,
|
|
9
|
+
className: cx("pf-tag", `pf-tag--${variant}`, className),
|
|
10
|
+
...props,
|
|
11
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
12
|
+
className: "pf-tag__label",
|
|
13
|
+
children
|
|
14
|
+
}), dismissible ? /* @__PURE__ */ jsx("button", {
|
|
15
|
+
type: "button",
|
|
16
|
+
className: "pf-tag__dismiss",
|
|
17
|
+
"aria-label": "Remove tag",
|
|
18
|
+
onClick: () => onDismiss?.(),
|
|
19
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
20
|
+
name: "circle-xmark",
|
|
21
|
+
"aria-hidden": true
|
|
22
|
+
})
|
|
23
|
+
}) : null]
|
|
24
|
+
}));
|
|
25
|
+
Tag.displayName = "Tag";
|
|
26
|
+
//#endregion
|
|
27
|
+
export { Tag };
|
package/dist/index108.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Table/Table.tsx
|
|
6
|
+
function Table({ className, columns, rows, caption, dense = false, striped = false, hoverable = true, stickyHeader = false, emptyState = "No data available.", defaultSortState, sortState, onSortStateChange, getRowKey, ...props }) {
|
|
7
|
+
const [internalSortState, setInternalSortState] = useState(defaultSortState);
|
|
8
|
+
const resolvedSortState = sortState ?? internalSortState;
|
|
9
|
+
const sortedRows = useMemo(() => {
|
|
10
|
+
if (!resolvedSortState) return rows;
|
|
11
|
+
const sortColumn = columns.find((column) => column.key === resolvedSortState.key);
|
|
12
|
+
if (!sortColumn || !sortColumn.sortable) return rows;
|
|
13
|
+
const getValue = (row) => {
|
|
14
|
+
const value = sortColumn.sortValue ? sortColumn.sortValue(row) : row[sortColumn.key];
|
|
15
|
+
if (value instanceof Date) return value.getTime();
|
|
16
|
+
if (typeof value === "number") return value;
|
|
17
|
+
return value == null ? "" : String(value);
|
|
18
|
+
};
|
|
19
|
+
const directionFactor = resolvedSortState.direction === "asc" ? 1 : -1;
|
|
20
|
+
return [...rows].sort((leftRow, rightRow) => {
|
|
21
|
+
const leftValue = getValue(leftRow);
|
|
22
|
+
const rightValue = getValue(rightRow);
|
|
23
|
+
if (typeof leftValue === "number" && typeof rightValue === "number") return (leftValue - rightValue) * directionFactor;
|
|
24
|
+
return String(leftValue).localeCompare(String(rightValue), void 0, {
|
|
25
|
+
numeric: true,
|
|
26
|
+
sensitivity: "base"
|
|
27
|
+
}) * directionFactor;
|
|
28
|
+
});
|
|
29
|
+
}, [
|
|
30
|
+
columns,
|
|
31
|
+
resolvedSortState,
|
|
32
|
+
rows
|
|
33
|
+
]);
|
|
34
|
+
const setSort = (nextState) => {
|
|
35
|
+
if (!sortState) setInternalSortState(nextState);
|
|
36
|
+
onSortStateChange?.(nextState);
|
|
37
|
+
};
|
|
38
|
+
const toggleSort = (column) => {
|
|
39
|
+
if (!column.sortable) return;
|
|
40
|
+
if (resolvedSortState?.key !== column.key) {
|
|
41
|
+
setSort({
|
|
42
|
+
key: column.key,
|
|
43
|
+
direction: "asc"
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
setSort({
|
|
48
|
+
key: column.key,
|
|
49
|
+
direction: resolvedSortState.direction === "asc" ? "desc" : "asc"
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
53
|
+
className: cx("pf-table", dense && "pf-table--dense", striped && "pf-table--striped", hoverable && "pf-table--hoverable", stickyHeader && "pf-table--sticky-header", className),
|
|
54
|
+
...props,
|
|
55
|
+
children: [caption ? /* @__PURE__ */ jsx("div", {
|
|
56
|
+
className: "pf-table__caption",
|
|
57
|
+
children: caption
|
|
58
|
+
}) : null, /* @__PURE__ */ jsxs("table", {
|
|
59
|
+
className: "pf-table__native",
|
|
60
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((column) => /* @__PURE__ */ jsx("th", {
|
|
61
|
+
className: cx("pf-table__head-cell", `pf-table__cell--${column.align ?? "left"}`, column.className),
|
|
62
|
+
scope: "col",
|
|
63
|
+
"aria-sort": resolvedSortState?.key === column.key ? resolvedSortState.direction === "asc" ? "ascending" : "descending" : "none",
|
|
64
|
+
style: column.width !== void 0 ? { "--pf-col-width": typeof column.width === "number" ? `${column.width}px` : column.width } : void 0,
|
|
65
|
+
children: column.sortable ? /* @__PURE__ */ jsxs("button", {
|
|
66
|
+
type: "button",
|
|
67
|
+
className: "pf-table__sort-button",
|
|
68
|
+
onClick: () => toggleSort(column),
|
|
69
|
+
children: [/* @__PURE__ */ jsx("span", { children: column.header }), /* @__PURE__ */ jsx("span", {
|
|
70
|
+
className: "pf-table__sort-indicator",
|
|
71
|
+
"aria-hidden": true,
|
|
72
|
+
children: resolvedSortState?.key === column.key ? resolvedSortState.direction === "asc" ? "^" : "v" : "-"
|
|
73
|
+
})]
|
|
74
|
+
}) : column.header
|
|
75
|
+
}, column.key)) }) }), /* @__PURE__ */ jsx("tbody", { children: sortedRows.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", {
|
|
76
|
+
className: "pf-table__empty",
|
|
77
|
+
colSpan: Math.max(columns.length, 1),
|
|
78
|
+
children: emptyState
|
|
79
|
+
}) }) : sortedRows.map((row, rowIndex) => /* @__PURE__ */ jsx("tr", { children: columns.map((column) => /* @__PURE__ */ jsx("td", {
|
|
80
|
+
className: cx("pf-table__body-cell", `pf-table__cell--${column.align ?? "left"}`, column.className),
|
|
81
|
+
children: row[column.key] ?? "—"
|
|
82
|
+
}, column.key)) }, getRowKey?.(row, rowIndex) ?? rowIndex)) })]
|
|
83
|
+
})]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
Table.displayName = "Table";
|
|
87
|
+
//#endregion
|
|
88
|
+
export { Table };
|
package/dist/index110.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { cx } from "./index4.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { forwardRef, useId, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Tabs/Tabs.tsx
|
|
6
|
+
function getFirstEnabledValue(items) {
|
|
7
|
+
return items.find((item) => !item.disabled)?.value;
|
|
8
|
+
}
|
|
9
|
+
var Tabs = forwardRef(function Tabs({ className, items, value, defaultValue, onValueChange, variant = "underline", size = "md", fullWidth = false, ...props }, ref) {
|
|
10
|
+
const baseId = useId();
|
|
11
|
+
const isControlled = value !== void 0;
|
|
12
|
+
const [internalValue, setInternalValue] = useState(defaultValue ?? getFirstEnabledValue(items));
|
|
13
|
+
const selectedValue = isControlled ? value : internalValue;
|
|
14
|
+
const selectedItem = useMemo(() => items.find((item) => item.value === selectedValue && !item.disabled) ?? items.find((item) => !item.disabled), [items, selectedValue]);
|
|
15
|
+
const buttonRefs = useRef([]);
|
|
16
|
+
const setSelectedValue = (nextValue) => {
|
|
17
|
+
if (!isControlled) setInternalValue(nextValue);
|
|
18
|
+
onValueChange?.(nextValue);
|
|
19
|
+
};
|
|
20
|
+
const enabledIndexes = items.map((item, index) => ({
|
|
21
|
+
item,
|
|
22
|
+
index
|
|
23
|
+
})).filter(({ item }) => !item.disabled).map(({ index }) => index);
|
|
24
|
+
const moveSelection = (currentIndex, direction) => {
|
|
25
|
+
if (enabledIndexes.length === 0) return;
|
|
26
|
+
const targetIndex = direction === "first" ? enabledIndexes[0] ?? currentIndex : direction === "last" ? enabledIndexes[enabledIndexes.length - 1] ?? currentIndex : (() => {
|
|
27
|
+
const currentEnabledPosition = enabledIndexes.indexOf(currentIndex);
|
|
28
|
+
const fallbackPosition = direction === "next" ? 0 : enabledIndexes.length - 1;
|
|
29
|
+
return enabledIndexes[((currentEnabledPosition === -1 ? fallbackPosition : currentEnabledPosition) + (direction === "next" ? 1 : -1) + enabledIndexes.length) % enabledIndexes.length] ?? currentIndex;
|
|
30
|
+
})();
|
|
31
|
+
const nextItem = items[targetIndex];
|
|
32
|
+
if (!nextItem || nextItem.disabled) return;
|
|
33
|
+
setSelectedValue(nextItem.value);
|
|
34
|
+
buttonRefs.current[targetIndex]?.focus();
|
|
35
|
+
};
|
|
36
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
37
|
+
ref,
|
|
38
|
+
className: cx("pf-tabs", className),
|
|
39
|
+
...props,
|
|
40
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
41
|
+
className: cx("pf-tabs__list", `pf-tabs__list--${variant}`, `pf-tabs__list--${size}`, fullWidth && "pf-tabs__list--full-width"),
|
|
42
|
+
role: "tablist",
|
|
43
|
+
"aria-orientation": "horizontal",
|
|
44
|
+
children: items.map((item, index) => {
|
|
45
|
+
const isSelected = item.value === selectedItem?.value;
|
|
46
|
+
const tabId = `${baseId}-tab-${item.value}`;
|
|
47
|
+
const panelId = `${baseId}-panel-${item.value}`;
|
|
48
|
+
return /* @__PURE__ */ jsx("button", {
|
|
49
|
+
ref: (element) => {
|
|
50
|
+
buttonRefs.current[index] = element;
|
|
51
|
+
},
|
|
52
|
+
id: tabId,
|
|
53
|
+
type: "button",
|
|
54
|
+
role: "tab",
|
|
55
|
+
className: cx("pf-tabs__tab", `pf-tabs__tab--${variant}`, `pf-tabs__tab--${size}`, isSelected && "pf-tabs__tab--active"),
|
|
56
|
+
"aria-controls": panelId,
|
|
57
|
+
"aria-selected": isSelected,
|
|
58
|
+
tabIndex: item.disabled ? -1 : 0,
|
|
59
|
+
disabled: item.disabled,
|
|
60
|
+
onClick: () => {
|
|
61
|
+
if (!item.disabled) setSelectedValue(item.value);
|
|
62
|
+
},
|
|
63
|
+
onKeyDown: (event) => {
|
|
64
|
+
if (event.key === "ArrowRight") {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
moveSelection(index, "next");
|
|
67
|
+
} else if (event.key === "ArrowLeft") {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
moveSelection(index, "previous");
|
|
70
|
+
} else if (event.key === "Home") {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
moveSelection(index, "first");
|
|
73
|
+
} else if (event.key === "End") {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
moveSelection(index, "last");
|
|
76
|
+
} else if (event.key === "Enter" || event.key === " ") {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
if (!item.disabled) setSelectedValue(item.value);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
children: item.label
|
|
82
|
+
}, item.value);
|
|
83
|
+
})
|
|
84
|
+
}), selectedItem ? /* @__PURE__ */ jsx("div", {
|
|
85
|
+
id: `${baseId}-panel-${selectedItem.value}`,
|
|
86
|
+
className: "pf-tabs__panel",
|
|
87
|
+
role: "tabpanel",
|
|
88
|
+
"aria-labelledby": `${baseId}-tab-${selectedItem.value}`,
|
|
89
|
+
tabIndex: 0,
|
|
90
|
+
children: selectedItem.content
|
|
91
|
+
}) : null]
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
Tabs.displayName = "Tabs";
|
|
95
|
+
//#endregion
|
|
96
|
+
export { Tabs };
|
package/dist/index112.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
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/Textarea/Textarea.tsx
|
|
7
|
+
var Textarea = forwardRef(({ id, label, description, error, className, "aria-describedby": ariaDescribedBy, rows = 4, ...props }, ref) => {
|
|
8
|
+
const generatedId = useId();
|
|
9
|
+
const textareaId = id ?? generatedId;
|
|
10
|
+
const descriptionId = description ? `${textareaId}-description` : void 0;
|
|
11
|
+
const errorId = error ? `${textareaId}-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: textareaId,
|
|
19
|
+
label,
|
|
20
|
+
description,
|
|
21
|
+
descriptionId,
|
|
22
|
+
error,
|
|
23
|
+
errorId,
|
|
24
|
+
required: props.required,
|
|
25
|
+
children: /* @__PURE__ */ jsx("textarea", {
|
|
26
|
+
ref,
|
|
27
|
+
id: textareaId,
|
|
28
|
+
rows,
|
|
29
|
+
className: cx("pf-textarea", error && "pf-textarea--invalid", className),
|
|
30
|
+
"aria-invalid": error ? true : void 0,
|
|
31
|
+
"aria-describedby": describedBy,
|
|
32
|
+
...props
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
Textarea.displayName = "Textarea";
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Textarea };
|