@pitchfork-ui/react 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Collapsible/Collapsible.css +86 -0
- package/dist/components/Collapsible/Collapsible2.js +65 -0
- package/dist/components/ContextMenu/ContextMenu.css +122 -0
- package/dist/components/ContextMenu/ContextMenu2.js +155 -0
- package/dist/components/Icon/Icon2.js +17 -0
- package/dist/components/Resizable/Resizable.css +79 -0
- package/dist/components/Resizable/Resizable2.js +101 -0
- package/dist/components/ScrollArea/ScrollArea.css +54 -0
- package/dist/components/ScrollArea/ScrollArea2.js +18 -0
- package/dist/components/TagInput/TagInput.css +72 -0
- package/dist/components/TagInput/TagInput2.js +116 -0
- package/dist/components/TimePicker/TimePicker.css +179 -0
- package/dist/components/TimePicker/TimePicker2.js +239 -0
- package/dist/components/Timeline/Timeline.css +128 -0
- package/dist/components/Timeline/Timeline2.js +49 -0
- package/dist/components/Toolbar/Toolbar.css +37 -0
- package/dist/components/Toolbar/Toolbar2.js +71 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.css +26 -0
- package/dist/components/VisuallyHidden/VisuallyHidden2.js +21 -0
- package/dist/index.cjs +786 -7
- package/dist/index.js +10 -1
- package/dist/src/components/Collapsible/Collapsible.d.ts +11 -0
- package/dist/src/components/Collapsible/Collapsible.test.d.ts +1 -0
- package/dist/src/components/Collapsible/index.d.ts +1 -0
- package/dist/src/components/ContextMenu/ContextMenu.d.ts +20 -0
- package/dist/src/components/ContextMenu/ContextMenu.test.d.ts +1 -0
- package/dist/src/components/ContextMenu/index.d.ts +1 -0
- package/dist/src/components/Resizable/Resizable.d.ts +19 -0
- package/dist/src/components/Resizable/Resizable.test.d.ts +1 -0
- package/dist/src/components/Resizable/index.d.ts +1 -0
- package/dist/src/components/ScrollArea/ScrollArea.d.ts +12 -0
- package/dist/src/components/ScrollArea/ScrollArea.test.d.ts +1 -0
- package/dist/src/components/ScrollArea/index.d.ts +1 -0
- package/dist/src/components/TagInput/TagInput.d.ts +23 -0
- package/dist/src/components/TagInput/TagInput.test.d.ts +1 -0
- package/dist/src/components/TagInput/index.d.ts +1 -0
- package/dist/src/components/TimePicker/TimePicker.d.ts +18 -0
- package/dist/src/components/TimePicker/TimePicker.test.d.ts +1 -0
- package/dist/src/components/TimePicker/index.d.ts +1 -0
- package/dist/src/components/Timeline/Timeline.d.ts +16 -0
- package/dist/src/components/Timeline/Timeline.test.d.ts +1 -0
- package/dist/src/components/Timeline/index.d.ts +1 -0
- package/dist/src/components/Toolbar/Toolbar.d.ts +8 -0
- package/dist/src/components/Toolbar/Toolbar.test.d.ts +1 -0
- package/dist/src/components/Toolbar/index.d.ts +1 -0
- package/dist/src/components/VisuallyHidden/VisuallyHidden.d.ts +15 -0
- package/dist/src/components/VisuallyHidden/VisuallyHidden.test.d.ts +1 -0
- package/dist/src/components/VisuallyHidden/index.d.ts +1 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/styles/theme.css +77 -0
- package/dist/styles.css +860 -0
- package/package.json +1 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
.pf-collapsible {
|
|
2
|
+
border: 1px solid var(--pf-collapsible-border);
|
|
3
|
+
border-radius: var(--radius-md);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.pf-collapsible__trigger {
|
|
7
|
+
align-items: center;
|
|
8
|
+
background: transparent;
|
|
9
|
+
border: 0;
|
|
10
|
+
border-radius: var(--radius-md);
|
|
11
|
+
color: var(--pf-collapsible-trigger-text);
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
display: flex;
|
|
14
|
+
font: inherit;
|
|
15
|
+
font-weight: var(--font-weight-medium);
|
|
16
|
+
gap: var(--space-2);
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
padding: var(--space-3);
|
|
19
|
+
text-align: start;
|
|
20
|
+
width: 100%;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.pf-collapsible__trigger:hover:not(:disabled) {
|
|
24
|
+
background: var(--pf-collapsible-trigger-hover-bg);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.pf-collapsible__trigger:focus-visible {
|
|
28
|
+
box-shadow: var(--pf-collapsible-focus-ring, var(--pf-focus-ring));
|
|
29
|
+
outline: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.pf-collapsible__trigger:disabled {
|
|
33
|
+
color: var(--pf-control-text-disabled);
|
|
34
|
+
cursor: not-allowed;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.pf-collapsible__label {
|
|
38
|
+
min-width: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.pf-collapsible__icon {
|
|
42
|
+
align-items: center;
|
|
43
|
+
color: var(--pf-collapsible-icon);
|
|
44
|
+
display: inline-flex;
|
|
45
|
+
flex-shrink: 0;
|
|
46
|
+
transition: transform var(--pf-transition-fast);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.pf-collapsible__icon svg {
|
|
50
|
+
display: block;
|
|
51
|
+
height: 16px;
|
|
52
|
+
width: 16px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.pf-collapsible--open .pf-collapsible__icon {
|
|
56
|
+
transform: rotate(180deg);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Height animation via the grid-template-rows 0fr → 1fr technique. */
|
|
60
|
+
.pf-collapsible__panel {
|
|
61
|
+
display: grid;
|
|
62
|
+
grid-template-rows: 0fr;
|
|
63
|
+
transition: grid-template-rows var(--pf-transition-medium);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.pf-collapsible__panel--open {
|
|
67
|
+
grid-template-rows: 1fr;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.pf-collapsible__content {
|
|
71
|
+
min-height: 0;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.pf-collapsible__content-inner {
|
|
76
|
+
border-top: 1px solid var(--pf-collapsible-border);
|
|
77
|
+
color: var(--pf-collapsible-content-text);
|
|
78
|
+
padding: var(--space-3);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@media (prefers-reduced-motion: reduce) {
|
|
82
|
+
.pf-collapsible__panel,
|
|
83
|
+
.pf-collapsible__icon {
|
|
84
|
+
transition: none;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Keys } from "../../a11y/index.js";
|
|
3
|
+
import { useDisclosure } from "../../hooks/useDisclosure.js";
|
|
4
|
+
import { cx } from "../../utils/cx.js";
|
|
5
|
+
import { Icon } from "../Icon/Icon2.js";
|
|
6
|
+
import './Collapsible.css';/* empty css */
|
|
7
|
+
import { forwardRef, useId } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/Collapsible/Collapsible.tsx
|
|
10
|
+
var Collapsible = forwardRef(function Collapsible({ className, trigger, open, defaultOpen, onOpenChange, disabled = false, showChevron = true, children, ...props }, ref) {
|
|
11
|
+
const baseId = useId();
|
|
12
|
+
const triggerId = `${baseId}-trigger`;
|
|
13
|
+
const contentId = `${baseId}-content`;
|
|
14
|
+
const disclosure = useDisclosure({
|
|
15
|
+
open,
|
|
16
|
+
defaultOpen,
|
|
17
|
+
onOpenChange,
|
|
18
|
+
disabled
|
|
19
|
+
});
|
|
20
|
+
const isOpen = disclosure.isOpen ?? false;
|
|
21
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
22
|
+
ref,
|
|
23
|
+
className: cx("pf-collapsible", isOpen && "pf-collapsible--open", className),
|
|
24
|
+
...props,
|
|
25
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
26
|
+
id: triggerId,
|
|
27
|
+
type: "button",
|
|
28
|
+
className: "pf-collapsible__trigger",
|
|
29
|
+
disabled,
|
|
30
|
+
"aria-expanded": isOpen,
|
|
31
|
+
"aria-controls": contentId,
|
|
32
|
+
onClick: () => disclosure.toggle(),
|
|
33
|
+
onKeyDown: (event) => {
|
|
34
|
+
if (event.key === Keys.Escape && isOpen) disclosure.close();
|
|
35
|
+
},
|
|
36
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
37
|
+
className: "pf-collapsible__label",
|
|
38
|
+
children: trigger
|
|
39
|
+
}), showChevron ? /* @__PURE__ */ jsx("span", {
|
|
40
|
+
className: "pf-collapsible__icon",
|
|
41
|
+
"aria-hidden": true,
|
|
42
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
43
|
+
name: "chevron-down",
|
|
44
|
+
"aria-hidden": true
|
|
45
|
+
})
|
|
46
|
+
}) : null]
|
|
47
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
48
|
+
id: contentId,
|
|
49
|
+
role: "region",
|
|
50
|
+
"aria-labelledby": triggerId,
|
|
51
|
+
className: cx("pf-collapsible__panel", isOpen && "pf-collapsible__panel--open"),
|
|
52
|
+
...!isOpen ? { inert: true } : {},
|
|
53
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
54
|
+
className: "pf-collapsible__content",
|
|
55
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
56
|
+
className: "pf-collapsible__content-inner",
|
|
57
|
+
children
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
})]
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
Collapsible.displayName = "Collapsible";
|
|
64
|
+
//#endregion
|
|
65
|
+
export { Collapsible };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
.pf-context-menu {
|
|
2
|
+
display: contents;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.pf-context-menu__menu {
|
|
6
|
+
animation: pf-context-menu-in var(--duration-fast) var(--easing-decelerate);
|
|
7
|
+
background: var(--pf-contextmenu-bg);
|
|
8
|
+
border: 1px solid var(--pf-contextmenu-border);
|
|
9
|
+
border-radius: var(--radius-md);
|
|
10
|
+
box-shadow: var(--pf-elevation-popover-shadow);
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap: 2px;
|
|
14
|
+
min-width: 180px;
|
|
15
|
+
outline: none;
|
|
16
|
+
padding: var(--space-1);
|
|
17
|
+
z-index: 1100;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.pf-context-menu__menu--exiting {
|
|
21
|
+
animation: pf-context-menu-out var(--duration-fast) var(--easing-accelerate) forwards;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@keyframes pf-context-menu-in {
|
|
25
|
+
from {
|
|
26
|
+
opacity: 0;
|
|
27
|
+
transform: scale(0.96);
|
|
28
|
+
}
|
|
29
|
+
to {
|
|
30
|
+
opacity: 1;
|
|
31
|
+
transform: scale(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@keyframes pf-context-menu-out {
|
|
36
|
+
from {
|
|
37
|
+
opacity: 1;
|
|
38
|
+
transform: scale(1);
|
|
39
|
+
}
|
|
40
|
+
to {
|
|
41
|
+
opacity: 0;
|
|
42
|
+
transform: scale(0.96);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.pf-context-menu__item {
|
|
47
|
+
align-items: center;
|
|
48
|
+
background: var(--pf-contextmenu-bg);
|
|
49
|
+
border: 0;
|
|
50
|
+
border-radius: var(--radius-sm);
|
|
51
|
+
color: var(--pf-contextmenu-text);
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
display: flex;
|
|
54
|
+
font: inherit;
|
|
55
|
+
gap: var(--space-2);
|
|
56
|
+
padding: var(--space-2) var(--space-3);
|
|
57
|
+
text-align: start;
|
|
58
|
+
width: 100%;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.pf-context-menu__item--active {
|
|
62
|
+
background: var(--pf-contextmenu-item-active-bg);
|
|
63
|
+
color: var(--pf-contextmenu-item-active-text);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.pf-context-menu__item:disabled {
|
|
67
|
+
color: var(--pf-contextmenu-text-muted);
|
|
68
|
+
cursor: not-allowed;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.pf-context-menu__item--destructive {
|
|
72
|
+
color: var(--pf-contextmenu-text-danger);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.pf-context-menu__item--destructive.pf-context-menu__item--active {
|
|
76
|
+
background: var(--pf-contextmenu-danger-active-bg);
|
|
77
|
+
color: var(--pf-contextmenu-danger-active-text);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.pf-context-menu__item-icon {
|
|
81
|
+
align-items: center;
|
|
82
|
+
display: inline-flex;
|
|
83
|
+
flex-shrink: 0;
|
|
84
|
+
height: 1rem;
|
|
85
|
+
justify-content: center;
|
|
86
|
+
width: 1rem;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.pf-context-menu__item-icon svg {
|
|
90
|
+
display: block;
|
|
91
|
+
height: 1rem;
|
|
92
|
+
width: 1rem;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.pf-context-menu__item-label {
|
|
96
|
+
flex: 1;
|
|
97
|
+
min-width: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.pf-context-menu__item-shortcut {
|
|
101
|
+
color: var(--pf-contextmenu-text-muted);
|
|
102
|
+
flex-shrink: 0;
|
|
103
|
+
font-family: var(--font-family-mono, ui-monospace, monospace);
|
|
104
|
+
font-size: var(--font-size-xs);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.pf-context-menu__item--active .pf-context-menu__item-shortcut {
|
|
108
|
+
color: inherit;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.pf-context-menu__separator {
|
|
112
|
+
background: var(--pf-contextmenu-separator);
|
|
113
|
+
height: 1px;
|
|
114
|
+
margin: var(--space-1) 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@media (prefers-reduced-motion: reduce) {
|
|
118
|
+
.pf-context-menu__menu,
|
|
119
|
+
.pf-context-menu__menu--exiting {
|
|
120
|
+
animation: none;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Keys } from "../../a11y/index.js";
|
|
3
|
+
import { useComposedRefs } from "../../hooks/useComposedRefs.js";
|
|
4
|
+
import { useListNavigation } from "../../hooks/useListNavigation.js";
|
|
5
|
+
import { useOutsideInteraction } from "../../hooks/useOutsideInteraction.js";
|
|
6
|
+
import { usePresence } from "../../hooks/usePresence.js";
|
|
7
|
+
import { cx } from "../../utils/cx.js";
|
|
8
|
+
import './ContextMenu.css';/* empty css */
|
|
9
|
+
import { forwardRef, useId, useLayoutEffect, useRef, useState } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { createPortal } from "react-dom";
|
|
12
|
+
//#region src/components/ContextMenu/ContextMenu.tsx
|
|
13
|
+
var isSeparator = (entry) => entry.separator === true;
|
|
14
|
+
var VIEWPORT_PADDING = 8;
|
|
15
|
+
var ContextMenu = forwardRef(function ContextMenu({ className, items, disabled = false, onOpenChange, children, onContextMenu, ...props }, ref) {
|
|
16
|
+
const menuId = useId();
|
|
17
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
18
|
+
const [point, setPoint] = useState({
|
|
19
|
+
x: 0,
|
|
20
|
+
y: 0
|
|
21
|
+
});
|
|
22
|
+
const [coords, setCoords] = useState(null);
|
|
23
|
+
const rootRefs = useComposedRefs(useRef(null), ref);
|
|
24
|
+
const menuRef = useRef(null);
|
|
25
|
+
const { isMounted, isExiting } = usePresence(isOpen, 140);
|
|
26
|
+
const actionable = items.filter((e) => !isSeparator(e));
|
|
27
|
+
const { activeIndex, move, setActiveIndex } = useListNavigation({
|
|
28
|
+
items: actionable,
|
|
29
|
+
isDisabled: (item) => Boolean(item.disabled)
|
|
30
|
+
});
|
|
31
|
+
const setOpen = (open) => {
|
|
32
|
+
setIsOpen(open);
|
|
33
|
+
onOpenChange?.(open);
|
|
34
|
+
};
|
|
35
|
+
useOutsideInteraction({
|
|
36
|
+
refs: [menuRef],
|
|
37
|
+
enabled: isOpen,
|
|
38
|
+
onInteractOutside: () => setOpen(false)
|
|
39
|
+
});
|
|
40
|
+
useLayoutEffect(() => {
|
|
41
|
+
if (!isMounted || !menuRef.current) return;
|
|
42
|
+
const rect = menuRef.current.getBoundingClientRect();
|
|
43
|
+
const maxLeft = window.innerWidth - rect.width - VIEWPORT_PADDING;
|
|
44
|
+
const maxTop = window.innerHeight - rect.height - VIEWPORT_PADDING;
|
|
45
|
+
setCoords({
|
|
46
|
+
left: Math.max(VIEWPORT_PADDING, Math.min(point.x, maxLeft)),
|
|
47
|
+
top: Math.max(VIEWPORT_PADDING, Math.min(point.y, maxTop))
|
|
48
|
+
});
|
|
49
|
+
}, [
|
|
50
|
+
isMounted,
|
|
51
|
+
point.x,
|
|
52
|
+
point.y
|
|
53
|
+
]);
|
|
54
|
+
const handleContextMenu = (event) => {
|
|
55
|
+
onContextMenu?.(event);
|
|
56
|
+
if (disabled || event.defaultPrevented) return;
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
setPoint({
|
|
59
|
+
x: event.clientX,
|
|
60
|
+
y: event.clientY
|
|
61
|
+
});
|
|
62
|
+
setCoords(null);
|
|
63
|
+
setActiveIndex(actionable.findIndex((item) => !item.disabled));
|
|
64
|
+
setOpen(true);
|
|
65
|
+
};
|
|
66
|
+
const select = (item) => {
|
|
67
|
+
if (item.disabled) return;
|
|
68
|
+
item.onSelect?.();
|
|
69
|
+
setOpen(false);
|
|
70
|
+
};
|
|
71
|
+
const onMenuKeyDown = (event) => {
|
|
72
|
+
if (event.key === Keys.Escape) {
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
setOpen(false);
|
|
75
|
+
} else if (event.key === Keys.ArrowDown) {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
move("next");
|
|
78
|
+
} else if (event.key === Keys.ArrowUp) {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
move("previous");
|
|
81
|
+
} else if (event.key === Keys.Home) {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
move("first");
|
|
84
|
+
} else if (event.key === Keys.End) {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
move("last");
|
|
87
|
+
} else if (event.key === Keys.Enter || event.key === Keys.Space) {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
const item = actionable[activeIndex];
|
|
90
|
+
if (item) select(item);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
useLayoutEffect(() => {
|
|
94
|
+
if (isMounted && coords) menuRef.current?.focus();
|
|
95
|
+
}, [isMounted, coords]);
|
|
96
|
+
let actionableIndex = -1;
|
|
97
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
98
|
+
ref: rootRefs,
|
|
99
|
+
className: cx("pf-context-menu", className),
|
|
100
|
+
onContextMenu: handleContextMenu,
|
|
101
|
+
...props,
|
|
102
|
+
children: [children, isMounted && typeof document !== "undefined" ? createPortal(/* @__PURE__ */ jsx("div", {
|
|
103
|
+
id: menuId,
|
|
104
|
+
ref: menuRef,
|
|
105
|
+
role: "menu",
|
|
106
|
+
"aria-label": "Context menu",
|
|
107
|
+
tabIndex: -1,
|
|
108
|
+
className: cx("pf-context-menu__menu", isExiting && "pf-context-menu__menu--exiting"),
|
|
109
|
+
style: {
|
|
110
|
+
position: "fixed",
|
|
111
|
+
left: coords?.left ?? point.x,
|
|
112
|
+
top: coords?.top ?? point.y,
|
|
113
|
+
visibility: coords ? "visible" : "hidden"
|
|
114
|
+
},
|
|
115
|
+
onKeyDown: onMenuKeyDown,
|
|
116
|
+
children: items.map((entry, index) => {
|
|
117
|
+
if (isSeparator(entry)) return /* @__PURE__ */ jsx("div", {
|
|
118
|
+
role: "separator",
|
|
119
|
+
className: "pf-context-menu__separator"
|
|
120
|
+
}, `sep-${index}`);
|
|
121
|
+
actionableIndex += 1;
|
|
122
|
+
const itemIndex = actionableIndex;
|
|
123
|
+
const isActive = itemIndex === activeIndex;
|
|
124
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
125
|
+
type: "button",
|
|
126
|
+
role: "menuitem",
|
|
127
|
+
disabled: entry.disabled,
|
|
128
|
+
className: cx("pf-context-menu__item", isActive && "pf-context-menu__item--active", entry.destructive && "pf-context-menu__item--destructive"),
|
|
129
|
+
onMouseEnter: () => {
|
|
130
|
+
if (!entry.disabled) setActiveIndex(itemIndex);
|
|
131
|
+
},
|
|
132
|
+
onClick: () => select(entry),
|
|
133
|
+
children: [
|
|
134
|
+
entry.icon ? /* @__PURE__ */ jsx("span", {
|
|
135
|
+
className: "pf-context-menu__item-icon",
|
|
136
|
+
"aria-hidden": true,
|
|
137
|
+
children: entry.icon
|
|
138
|
+
}) : null,
|
|
139
|
+
/* @__PURE__ */ jsx("span", {
|
|
140
|
+
className: "pf-context-menu__item-label",
|
|
141
|
+
children: entry.label
|
|
142
|
+
}),
|
|
143
|
+
entry.shortcut ? /* @__PURE__ */ jsx("kbd", {
|
|
144
|
+
className: "pf-context-menu__item-shortcut",
|
|
145
|
+
children: entry.shortcut
|
|
146
|
+
}) : null
|
|
147
|
+
]
|
|
148
|
+
}, entry.id ?? `${entry.label}-${index}`);
|
|
149
|
+
})
|
|
150
|
+
}), document.body) : null]
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
ContextMenu.displayName = "ContextMenu";
|
|
154
|
+
//#endregion
|
|
155
|
+
export { ContextMenu };
|
|
@@ -127,6 +127,23 @@ var customIcons = {
|
|
|
127
127
|
"aria-hidden": "true",
|
|
128
128
|
children: [/* @__PURE__ */ jsx("path", { d: "M12 5v14" }), /* @__PURE__ */ jsx("path", { d: "M5 12h14" })]
|
|
129
129
|
}),
|
|
130
|
+
clock: /* @__PURE__ */ jsxs("svg", {
|
|
131
|
+
width: "1em",
|
|
132
|
+
height: "1em",
|
|
133
|
+
viewBox: "0 0 24 24",
|
|
134
|
+
fill: "none",
|
|
135
|
+
stroke: "currentColor",
|
|
136
|
+
strokeWidth: "2",
|
|
137
|
+
strokeLinecap: "round",
|
|
138
|
+
strokeLinejoin: "round",
|
|
139
|
+
focusable: "false",
|
|
140
|
+
"aria-hidden": "true",
|
|
141
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
142
|
+
cx: "12",
|
|
143
|
+
cy: "12",
|
|
144
|
+
r: "9"
|
|
145
|
+
}), /* @__PURE__ */ jsx("path", { d: "M12 7v5l3 2" })]
|
|
146
|
+
}),
|
|
130
147
|
"magnifying-glass": /* @__PURE__ */ jsxs("svg", {
|
|
131
148
|
width: "1em",
|
|
132
149
|
height: "1em",
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
.pf-resizable {
|
|
2
|
+
display: flex;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.pf-resizable--horizontal {
|
|
7
|
+
flex-direction: row;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.pf-resizable--vertical {
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.pf-resizable__panel {
|
|
15
|
+
flex-grow: 0;
|
|
16
|
+
flex-shrink: 0;
|
|
17
|
+
min-height: 0;
|
|
18
|
+
min-width: 0;
|
|
19
|
+
overflow: auto;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.pf-resizable__panel--fill {
|
|
23
|
+
flex: 1 1 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* ── Handle ───────────────────────────────────────────────────────────────── */
|
|
27
|
+
|
|
28
|
+
.pf-resizable__handle {
|
|
29
|
+
align-items: center;
|
|
30
|
+
background: var(--pf-resizable-handle-bg);
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-shrink: 0;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
position: relative;
|
|
35
|
+
touch-action: none;
|
|
36
|
+
transition: background var(--pf-transition-fast);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.pf-resizable__handle:hover,
|
|
40
|
+
.pf-resizable__handle:focus-visible {
|
|
41
|
+
background: var(--pf-resizable-handle-active-bg);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.pf-resizable__handle:focus-visible {
|
|
45
|
+
outline: none;
|
|
46
|
+
box-shadow: var(--pf-resizable-focus-ring, var(--pf-focus-ring));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.pf-resizable--horizontal .pf-resizable__handle {
|
|
50
|
+
cursor: col-resize;
|
|
51
|
+
width: var(--pf-resizable-handle-size, 6px);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.pf-resizable--vertical .pf-resizable__handle {
|
|
55
|
+
cursor: row-resize;
|
|
56
|
+
height: var(--pf-resizable-handle-size, 6px);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Grip affordance (dots/line) centered in the handle. */
|
|
60
|
+
.pf-resizable__grip {
|
|
61
|
+
background: var(--pf-resizable-grip);
|
|
62
|
+
border-radius: var(--radius-full);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.pf-resizable--horizontal .pf-resizable__grip {
|
|
66
|
+
height: 24px;
|
|
67
|
+
width: 2px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.pf-resizable--vertical .pf-resizable__grip {
|
|
71
|
+
height: 2px;
|
|
72
|
+
width: 24px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@media (prefers-reduced-motion: reduce) {
|
|
76
|
+
.pf-resizable__handle {
|
|
77
|
+
transition: none;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Keys } from "../../a11y/index.js";
|
|
3
|
+
import { useComposedRefs } from "../../hooks/useComposedRefs.js";
|
|
4
|
+
import { useControllableState } from "../../hooks/useControllableState.js";
|
|
5
|
+
import { cx } from "../../utils/cx.js";
|
|
6
|
+
import './Resizable.css';/* empty css */
|
|
7
|
+
import { Children, forwardRef, useId, useRef } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/Resizable/Resizable.tsx
|
|
10
|
+
var clamp = (n, min, max) => Math.min(Math.max(n, min), max);
|
|
11
|
+
var Resizable = forwardRef(function Resizable({ className, orientation = "horizontal", size, defaultSize = 50, onSizeChange, min = 10, max = 90, step = 2, handleLabel = "Resize panels", children, ...props }, ref) {
|
|
12
|
+
const handleId = useId();
|
|
13
|
+
const containerRef = useRef(null);
|
|
14
|
+
const containerRefs = useComposedRefs(containerRef, ref);
|
|
15
|
+
const draggingRef = useRef(false);
|
|
16
|
+
const [current, setCurrent] = useControllableState({
|
|
17
|
+
value: size,
|
|
18
|
+
defaultValue: defaultSize,
|
|
19
|
+
onChange: onSizeChange
|
|
20
|
+
});
|
|
21
|
+
const value = clamp(current ?? defaultSize, min, max);
|
|
22
|
+
const isHorizontal = orientation === "horizontal";
|
|
23
|
+
const panels = Children.toArray(children);
|
|
24
|
+
const first = panels[0] ?? null;
|
|
25
|
+
const second = panels[1] ?? null;
|
|
26
|
+
const setFromPointer = (clientX, clientY) => {
|
|
27
|
+
const el = containerRef.current;
|
|
28
|
+
if (!el) return;
|
|
29
|
+
const rect = el.getBoundingClientRect();
|
|
30
|
+
const pct = isHorizontal ? (clientX - rect.left) / rect.width * 100 : (clientY - rect.top) / rect.height * 100;
|
|
31
|
+
setCurrent(clamp(Math.round(pct), min, max));
|
|
32
|
+
};
|
|
33
|
+
const onPointerDown = (event) => {
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
36
|
+
draggingRef.current = true;
|
|
37
|
+
};
|
|
38
|
+
const onPointerMove = (event) => {
|
|
39
|
+
if (!draggingRef.current) return;
|
|
40
|
+
setFromPointer(event.clientX, event.clientY);
|
|
41
|
+
};
|
|
42
|
+
const onPointerUp = (event) => {
|
|
43
|
+
draggingRef.current = false;
|
|
44
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
45
|
+
};
|
|
46
|
+
const onKeyDown = (event) => {
|
|
47
|
+
const decKey = isHorizontal ? Keys.ArrowLeft : Keys.ArrowUp;
|
|
48
|
+
const incKey = isHorizontal ? Keys.ArrowRight : Keys.ArrowDown;
|
|
49
|
+
if (event.key === decKey) {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
setCurrent(clamp(value - step, min, max));
|
|
52
|
+
} else if (event.key === incKey) {
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
setCurrent(clamp(value + step, min, max));
|
|
55
|
+
} else if (event.key === Keys.Home) {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
setCurrent(min);
|
|
58
|
+
} else if (event.key === Keys.End) {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
setCurrent(max);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
64
|
+
ref: containerRefs,
|
|
65
|
+
className: cx("pf-resizable", `pf-resizable--${orientation}`, className),
|
|
66
|
+
...props,
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ jsx("div", {
|
|
69
|
+
className: "pf-resizable__panel",
|
|
70
|
+
style: { flexBasis: `${value}%` },
|
|
71
|
+
children: first
|
|
72
|
+
}),
|
|
73
|
+
/* @__PURE__ */ jsx("div", {
|
|
74
|
+
id: handleId,
|
|
75
|
+
role: "separator",
|
|
76
|
+
tabIndex: 0,
|
|
77
|
+
"aria-orientation": isHorizontal ? "vertical" : "horizontal",
|
|
78
|
+
"aria-label": handleLabel,
|
|
79
|
+
"aria-valuenow": value,
|
|
80
|
+
"aria-valuemin": min,
|
|
81
|
+
"aria-valuemax": max,
|
|
82
|
+
className: "pf-resizable__handle",
|
|
83
|
+
onPointerDown,
|
|
84
|
+
onPointerMove,
|
|
85
|
+
onPointerUp,
|
|
86
|
+
onKeyDown,
|
|
87
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
88
|
+
className: "pf-resizable__grip",
|
|
89
|
+
"aria-hidden": true
|
|
90
|
+
})
|
|
91
|
+
}),
|
|
92
|
+
/* @__PURE__ */ jsx("div", {
|
|
93
|
+
className: "pf-resizable__panel pf-resizable__panel--fill",
|
|
94
|
+
children: second
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
Resizable.displayName = "Resizable";
|
|
100
|
+
//#endregion
|
|
101
|
+
export { Resizable };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
.pf-scroll-area {
|
|
2
|
+
/* Standard scrollbar styling (Firefox + modern browsers). */
|
|
3
|
+
scrollbar-color: var(--pf-scrollarea-thumb) transparent;
|
|
4
|
+
scrollbar-width: thin;
|
|
5
|
+
/* Reserve a gutter so the scrollbar never overlays (and obscures) content. */
|
|
6
|
+
scrollbar-gutter: stable;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.pf-scroll-area:focus-visible {
|
|
10
|
+
border-radius: var(--radius-sm);
|
|
11
|
+
box-shadow: var(--pf-scrollarea-focus-ring, var(--pf-focus-ring));
|
|
12
|
+
outline: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.pf-scroll-area--vertical {
|
|
16
|
+
overflow-x: hidden;
|
|
17
|
+
overflow-y: auto;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.pf-scroll-area--horizontal {
|
|
21
|
+
overflow-x: auto;
|
|
22
|
+
overflow-y: hidden;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.pf-scroll-area--both {
|
|
26
|
+
overflow: auto;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* WebKit / Blink scrollbar styling. */
|
|
30
|
+
.pf-scroll-area::-webkit-scrollbar {
|
|
31
|
+
height: 10px;
|
|
32
|
+
width: 10px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.pf-scroll-area::-webkit-scrollbar-track {
|
|
36
|
+
background: transparent;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.pf-scroll-area::-webkit-scrollbar-thumb {
|
|
40
|
+
background: var(--pf-scrollarea-thumb);
|
|
41
|
+
/* Transparent border + padding-box clip insets the thumb so it reads slimmer. */
|
|
42
|
+
background-clip: padding-box;
|
|
43
|
+
border: 2px solid transparent;
|
|
44
|
+
border-radius: var(--radius-full);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.pf-scroll-area::-webkit-scrollbar-thumb:hover {
|
|
48
|
+
background: var(--pf-scrollarea-thumb-hover);
|
|
49
|
+
background-clip: padding-box;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.pf-scroll-area::-webkit-scrollbar-corner {
|
|
53
|
+
background: transparent;
|
|
54
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../../utils/cx.js";
|
|
3
|
+
import './ScrollArea.css';/* empty css */
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/ScrollArea/ScrollArea.tsx
|
|
7
|
+
var ScrollArea = forwardRef(function ScrollArea({ className, orientation = "vertical", focusable = true, tabIndex, children, ...props }, ref) {
|
|
8
|
+
return /* @__PURE__ */ jsx("div", {
|
|
9
|
+
ref,
|
|
10
|
+
className: cx("pf-scroll-area", `pf-scroll-area--${orientation}`, className),
|
|
11
|
+
tabIndex: tabIndex ?? (focusable ? 0 : void 0),
|
|
12
|
+
...props,
|
|
13
|
+
children
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
ScrollArea.displayName = "ScrollArea";
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ScrollArea };
|