@pitchfork-ui/react 0.2.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/components/Accordion/Accordion.css +85 -0
  2. package/dist/components/Accordion/Accordion2.js +96 -0
  3. package/dist/components/Alert/Alert.css +29 -1
  4. package/dist/components/Alert/Alert2.js +4 -2
  5. package/dist/components/Avatar/Avatar.css +1 -1
  6. package/dist/components/BadgeGroup/BadgeGroup.css +4 -4
  7. package/dist/components/Button/Button.css +4 -4
  8. package/dist/components/ButtonGroup/ButtonGroup.css +2 -2
  9. package/dist/components/Carousel/Carousel.css +4 -2
  10. package/dist/components/Carousel/Carousel2.js +89 -76
  11. package/dist/components/CodeSnippet/CodeSnippet.css +2 -2
  12. package/dist/components/ContentDivider/ContentDivider.css +2 -2
  13. package/dist/components/DatePicker/DatePicker.css +1 -1
  14. package/dist/components/DatePicker/DatePicker2.js +3 -3
  15. package/dist/components/Dropdown/Dropdown.css +19 -2
  16. package/dist/components/Dropdown/Dropdown2.js +2 -3
  17. package/dist/components/GaugeChart/GaugeChart.css +18 -1
  18. package/dist/components/GaugeChart/GaugeChart2.js +5 -4
  19. package/dist/components/Heatmap/Heatmap.css +100 -0
  20. package/dist/components/Heatmap/Heatmap2.js +160 -0
  21. package/dist/components/InlineCTA/InlineCTA.css +58 -0
  22. package/dist/components/InlineCTA/InlineCTA2.js +14 -2
  23. package/dist/components/Modal/Modal.css +62 -0
  24. package/dist/components/Modal/Modal2.js +8 -6
  25. package/dist/components/MultiSelect/MultiSelect.css +19 -2
  26. package/dist/components/MultiSelect/MultiSelect2.js +3 -4
  27. package/dist/components/Notification/Notification.css +59 -4
  28. package/dist/components/Notification/Notification2.js +4 -2
  29. package/dist/components/PieChart/PieChart.css +34 -0
  30. package/dist/components/PieChart/PieChart2.js +1 -1
  31. package/dist/components/ProgressIndicators/ProgressIndicators.css +20 -2
  32. package/dist/components/ProgressIndicators/ProgressIndicators2.js +4 -1
  33. package/dist/components/ProgressSteps/ProgressSteps.css +20 -3
  34. package/dist/components/RadarChart/RadarChart.css +22 -0
  35. package/dist/components/RadarChart/RadarChart2.js +19 -13
  36. package/dist/components/RichTextEditor/RichTextEditor.css +1 -1
  37. package/dist/components/Select/Select.css +21 -2
  38. package/dist/components/Select/Select2.js +3 -4
  39. package/dist/components/SidebarNavigation/SidebarNavigation.css +1 -1
  40. package/dist/components/SlideoutMenu/SlideoutMenu.css +2 -2
  41. package/dist/components/Sparkline/Sparkline.css +48 -0
  42. package/dist/components/Sparkline/Sparkline2.js +3 -2
  43. package/dist/components/Table/Table.css +4 -4
  44. package/dist/components/Tabs/Tabs.css +31 -5
  45. package/dist/components/Tabs/Tabs2.js +51 -4
  46. package/dist/components/Tag/Tag.css +1 -1
  47. package/dist/components/Tooltip/Tooltip.css +35 -0
  48. package/dist/components/Tooltip/Tooltip2.js +4 -4
  49. package/dist/components/TreeView/TreeView.css +2 -2
  50. package/dist/hooks/useExitAnimation.js +25 -0
  51. package/dist/hooks/usePresence.js +31 -0
  52. package/dist/index.cjs +834 -454
  53. package/dist/index.js +12 -8
  54. package/dist/src/components/Accordion/Accordion.d.ts +20 -0
  55. package/dist/src/components/Accordion/Accordion.test.d.ts +1 -0
  56. package/dist/src/components/Accordion/index.d.ts +1 -0
  57. package/dist/src/components/Heatmap/Heatmap.d.ts +28 -0
  58. package/dist/src/components/Heatmap/Heatmap.test.d.ts +1 -0
  59. package/dist/src/components/Heatmap/index.d.ts +1 -0
  60. package/dist/src/components/InlineCTA/InlineCTA.d.ts +2 -0
  61. package/dist/src/components/Sparkline/Sparkline.d.ts +2 -0
  62. package/dist/src/hooks/index.d.ts +2 -0
  63. package/dist/src/hooks/useExitAnimation.d.ts +18 -0
  64. package/dist/src/hooks/usePresence.d.ts +13 -0
  65. package/dist/src/index.d.ts +2 -0
  66. package/dist/styles/theme.css +47 -13
  67. package/dist/styles.css +758 -64
  68. package/package.json +1 -1
  69. package/theme.starter.css +4 -3
@@ -1,3 +1,4 @@
1
+ import { usePresence } from "../../hooks/usePresence.js";
1
2
  import { cx } from "../../utils/cx.js";
2
3
  import './Tooltip.css';/* empty css */
3
4
  import { forwardRef, useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
@@ -87,6 +88,7 @@ var Tooltip = forwardRef(function Tooltip({ content, children, open, placement =
87
88
  const [resolvedPlacement, setResolvedPlacement] = useState(placement);
88
89
  const isControlled = open !== void 0;
89
90
  const isVisible = !disabled && (isControlled ? open : isOpen);
91
+ const { isMounted, isExiting } = usePresence(Boolean(isVisible), 160);
90
92
  const clearShowTimer = () => {
91
93
  if (showTimerRef.current !== void 0) {
92
94
  window.clearTimeout(showTimerRef.current);
@@ -105,8 +107,6 @@ var Tooltip = forwardRef(function Tooltip({ content, children, open, placement =
105
107
  clearShowTimer();
106
108
  if (isControlled) return;
107
109
  setIsOpen(false);
108
- setStyle({ visibility: "hidden" });
109
- setResolvedPlacement(placement);
110
110
  };
111
111
  useEffect(() => {
112
112
  return () => {
@@ -141,11 +141,11 @@ var Tooltip = forwardRef(function Tooltip({ content, children, open, placement =
141
141
  },
142
142
  "aria-describedby": isVisible ? tooltipId : void 0,
143
143
  children: children ?? /* @__PURE__ */ jsx("span", {})
144
- }), isVisible && typeof document !== "undefined" ? createPortal(/* @__PURE__ */ jsx("div", {
144
+ }), isMounted && typeof document !== "undefined" ? createPortal(/* @__PURE__ */ jsx("div", {
145
145
  id: tooltipId,
146
146
  ref: tooltipRef,
147
147
  role: "tooltip",
148
- className: cx("pf-tooltip", `pf-tooltip--${resolvedPlacement}`, className),
148
+ className: cx("pf-tooltip", `pf-tooltip--${resolvedPlacement}`, isExiting && "pf-tooltip--exiting", className),
149
149
  style,
150
150
  children: content
151
151
  }), document.body) : null] });
@@ -20,7 +20,7 @@
20
20
  display: grid;
21
21
  grid-template-columns: auto 1fr;
22
22
  min-width: 0;
23
- padding-left: calc(var(--pf-tree-level, 0) * var(--space-4));
23
+ padding-inline-start: calc(var(--pf-tree-level, 0) * var(--space-4));
24
24
  }
25
25
 
26
26
  .pf-tree-view__toggle-wrap {
@@ -69,7 +69,7 @@
69
69
  min-height: 34px;
70
70
  min-width: 0;
71
71
  padding: 0 var(--space-2);
72
- text-align: left;
72
+ text-align: start;
73
73
  width: 100%;
74
74
  }
75
75
 
@@ -0,0 +1,25 @@
1
+ import { useState } from "react";
2
+ //#region src/hooks/useExitAnimation.ts
3
+ var prefersReducedMotion = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
4
+ /**
5
+ * Plays an exit animation before signalling removal. Apply `isExiting` to a CSS
6
+ * class that runs the exit keyframes; `onExited` fires after `duration`. When the
7
+ * user prefers reduced motion, `onExited` fires immediately with no animation.
8
+ */
9
+ function useExitAnimation({ onExited, duration = 220 } = {}) {
10
+ const [isExiting, setIsExiting] = useState(false);
11
+ const startExit = () => {
12
+ if (prefersReducedMotion()) {
13
+ onExited?.();
14
+ return;
15
+ }
16
+ setIsExiting(true);
17
+ window.setTimeout(() => onExited?.(), duration);
18
+ };
19
+ return {
20
+ isExiting,
21
+ startExit
22
+ };
23
+ }
24
+ //#endregion
25
+ export { useExitAnimation };
@@ -0,0 +1,31 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+ //#region src/hooks/usePresence.ts
3
+ var prefersReducedMotion = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
4
+ /**
5
+ * Keeps a conditionally-rendered element mounted long enough to play an exit
6
+ * animation. Drive it with the `present` prop (e.g. a Modal's `open`): when it
7
+ * flips to false, the element stays mounted with `isExiting` true for `duration`
8
+ * ms, then unmounts. Reduced motion unmounts immediately.
9
+ */
10
+ function usePresence(present, duration = 200) {
11
+ const [isExiting, setIsExiting] = useState(false);
12
+ const wasPresent = useRef(false);
13
+ useEffect(() => {
14
+ if (present) {
15
+ wasPresent.current = true;
16
+ return;
17
+ }
18
+ if (!wasPresent.current || prefersReducedMotion()) return;
19
+ wasPresent.current = false;
20
+ setIsExiting(true);
21
+ const timer = window.setTimeout(() => setIsExiting(false), duration);
22
+ return () => window.clearTimeout(timer);
23
+ }, [present, duration]);
24
+ const exiting = !present && isExiting;
25
+ return {
26
+ isMounted: present || exiting,
27
+ isExiting: exiting
28
+ };
29
+ }
30
+ //#endregion
31
+ export { usePresence };