@pitchfork-ui/react 0.6.0 → 0.8.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/AvatarGroup/AvatarGroup.css +26 -0
- package/dist/components/AvatarGroup/AvatarGroup2.js +37 -0
- package/dist/components/Calendar/Calendar.css +0 -1
- package/dist/components/Combobox/Combobox.css +155 -0
- package/dist/components/Combobox/Combobox2.js +191 -0
- package/dist/components/CommandPalette/CommandPalette.css +225 -0
- package/dist/components/CommandPalette/CommandPalette2.js +195 -0
- package/dist/components/DateRangePicker/DateRangePicker.css +258 -0
- package/dist/components/DateRangePicker/DateRangePicker2.js +378 -0
- package/dist/components/Heatmap/Heatmap.css +4 -0
- package/dist/components/Icon/Icon2.js +43 -0
- package/dist/components/Kbd/Kbd.css +25 -0
- package/dist/components/Kbd/Kbd2.js +17 -0
- package/dist/components/NumberInput/NumberInput.css +98 -0
- package/dist/components/NumberInput/NumberInput2.js +165 -0
- package/dist/components/Pagination/Pagination.css +5 -2
- package/dist/components/Popover/Popover.css +46 -0
- package/dist/components/Popover/Popover2.js +76 -0
- package/dist/components/Toast/Toast.js +129 -0
- package/dist/index.cjs +1190 -24
- package/dist/index.js +9 -1
- package/dist/src/components/AvatarGroup/AvatarGroup.d.ts +14 -0
- package/dist/src/components/AvatarGroup/AvatarGroup.test.d.ts +1 -0
- package/dist/src/components/AvatarGroup/index.d.ts +1 -0
- package/dist/src/components/Combobox/Combobox.d.ts +20 -0
- package/dist/src/components/Combobox/Combobox.test.d.ts +1 -0
- package/dist/src/components/Combobox/index.d.ts +1 -0
- package/dist/src/components/CommandPalette/CommandPalette.d.ts +18 -0
- package/dist/src/components/CommandPalette/CommandPalette.test.d.ts +1 -0
- package/dist/src/components/CommandPalette/index.d.ts +1 -0
- package/dist/src/components/DateRangePicker/DateRangePicker.d.ts +21 -0
- package/dist/src/components/DateRangePicker/DateRangePicker.test.d.ts +1 -0
- package/dist/src/components/DateRangePicker/index.d.ts +1 -0
- package/dist/src/components/Kbd/Kbd.d.ts +9 -0
- package/dist/src/components/Kbd/Kbd.test.d.ts +1 -0
- package/dist/src/components/Kbd/index.d.ts +1 -0
- package/dist/src/components/NumberInput/NumberInput.d.ts +19 -0
- package/dist/src/components/NumberInput/NumberInput.test.d.ts +1 -0
- package/dist/src/components/NumberInput/index.d.ts +1 -0
- package/dist/src/components/Popover/Popover.d.ts +21 -0
- package/dist/src/components/Popover/Popover.test.d.ts +1 -0
- package/dist/src/components/Popover/index.d.ts +1 -0
- package/dist/src/components/Toast/Toast.d.ts +35 -0
- package/dist/src/components/Toast/Toast.test.d.ts +1 -0
- package/dist/src/components/Toast/index.d.ts +1 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/styles/theme.css +68 -0
- package/dist/styles.css +986 -79
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.pf-avatar-group {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
/* Overlap amount between avatars */
|
|
5
|
+
--pf-avatar-group-overlap: 8px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.pf-avatar-group--lg,
|
|
9
|
+
.pf-avatar-group--xl {
|
|
10
|
+
--pf-avatar-group-overlap: 12px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.pf-avatar-group__item {
|
|
14
|
+
position: relative;
|
|
15
|
+
/* Ring in the surface color so overlapping avatars stay visually separated */
|
|
16
|
+
box-shadow: 0 0 0 2px var(--pf-avatar-group-ring);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.pf-avatar-group__item + .pf-avatar-group__item {
|
|
20
|
+
margin-inline-start: calc(-1 * var(--pf-avatar-group-overlap));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.pf-avatar-group__overflow {
|
|
24
|
+
background: var(--pf-avatar-group-overflow-bg);
|
|
25
|
+
color: var(--pf-avatar-group-overflow-text);
|
|
26
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { cx } from "../../utils/cx.js";
|
|
2
|
+
import { Avatar } from "../Avatar/Avatar2.js";
|
|
3
|
+
import './AvatarGroup.css';/* empty css */
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/AvatarGroup/AvatarGroup.tsx
|
|
7
|
+
var AvatarGroup = forwardRef(function AvatarGroup({ className, avatars, max = 5, size = "md", total, label, ...props }, ref) {
|
|
8
|
+
const shown = avatars.slice(0, Math.max(0, max));
|
|
9
|
+
const overflow = (total ?? avatars.length) - shown.length;
|
|
10
|
+
const count = total ?? avatars.length;
|
|
11
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
12
|
+
ref,
|
|
13
|
+
className: cx("pf-avatar-group", `pf-avatar-group--${size}`, className),
|
|
14
|
+
role: "group",
|
|
15
|
+
"aria-label": label ?? `${count} ${count === 1 ? "person" : "people"}`,
|
|
16
|
+
...props,
|
|
17
|
+
children: [shown.map((avatar, index) => /* @__PURE__ */ jsx(Avatar, {
|
|
18
|
+
size,
|
|
19
|
+
className: "pf-avatar-group__item",
|
|
20
|
+
style: { zIndex: shown.length - index },
|
|
21
|
+
...avatar
|
|
22
|
+
}, index)), overflow > 0 ? /* @__PURE__ */ jsx("span", {
|
|
23
|
+
className: cx("pf-avatar", `pf-avatar--${size}`, "pf-avatar-group__item", "pf-avatar-group__overflow"),
|
|
24
|
+
role: "img",
|
|
25
|
+
"aria-label": `${overflow} more`,
|
|
26
|
+
style: { zIndex: 0 },
|
|
27
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
28
|
+
className: "pf-avatar__fallback",
|
|
29
|
+
"aria-hidden": true,
|
|
30
|
+
children: ["+", overflow]
|
|
31
|
+
})
|
|
32
|
+
}) : null]
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
AvatarGroup.displayName = "AvatarGroup";
|
|
36
|
+
//#endregion
|
|
37
|
+
export { AvatarGroup };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
.pf-combobox {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.pf-combobox__control {
|
|
6
|
+
align-items: center;
|
|
7
|
+
background: var(--pf-combobox-bg);
|
|
8
|
+
border: 1px solid var(--pf-combobox-border);
|
|
9
|
+
border-radius: var(--radius-md);
|
|
10
|
+
display: flex;
|
|
11
|
+
gap: var(--space-2);
|
|
12
|
+
min-height: 40px;
|
|
13
|
+
padding: 0 var(--space-3);
|
|
14
|
+
transition:
|
|
15
|
+
border 0.2s,
|
|
16
|
+
box-shadow 0.2s;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.pf-combobox__control:focus-within {
|
|
20
|
+
border-color: var(--pf-combobox-focus-border);
|
|
21
|
+
box-shadow: var(--pf-combobox-focus-ring, var(--pf-focus-ring));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.pf-combobox__control--invalid {
|
|
25
|
+
border-color: var(--pf-combobox-invalid-border);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.pf-combobox__input {
|
|
29
|
+
background: transparent;
|
|
30
|
+
border: none;
|
|
31
|
+
color: var(--pf-combobox-text);
|
|
32
|
+
flex: 1;
|
|
33
|
+
font: inherit;
|
|
34
|
+
min-width: 0;
|
|
35
|
+
outline: none;
|
|
36
|
+
padding: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.pf-combobox__input::placeholder {
|
|
40
|
+
color: var(--pf-combobox-placeholder);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.pf-combobox__input:disabled {
|
|
44
|
+
cursor: not-allowed;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.pf-combobox__control:has(.pf-combobox__input:disabled) {
|
|
48
|
+
background: var(--pf-control-bg-disabled);
|
|
49
|
+
border-color: var(--pf-control-border-disabled);
|
|
50
|
+
color: var(--pf-control-text-disabled);
|
|
51
|
+
opacity: 0.6;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.pf-combobox__icon {
|
|
55
|
+
align-items: center;
|
|
56
|
+
color: var(--pf-combobox-text);
|
|
57
|
+
display: inline-flex;
|
|
58
|
+
flex-shrink: 0;
|
|
59
|
+
height: 20px;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
transform-origin: center;
|
|
62
|
+
transition: transform var(--pf-transition-fast);
|
|
63
|
+
width: 20px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.pf-combobox__icon svg {
|
|
67
|
+
display: block;
|
|
68
|
+
height: 16px;
|
|
69
|
+
width: 16px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.pf-combobox__icon--open {
|
|
73
|
+
transform: rotate(180deg);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.pf-combobox__menu {
|
|
77
|
+
animation: pf-combobox-menu-in var(--duration-fast) var(--easing-decelerate);
|
|
78
|
+
background: var(--pf-combobox-menu-bg);
|
|
79
|
+
border: 1px solid var(--pf-combobox-menu-border);
|
|
80
|
+
border-radius: var(--radius-md);
|
|
81
|
+
box-shadow: var(--pf-combobox-elevation-popover-shadow, var(--pf-elevation-popover-shadow));
|
|
82
|
+
list-style: none;
|
|
83
|
+
margin: 0;
|
|
84
|
+
max-height: 220px;
|
|
85
|
+
overflow: auto;
|
|
86
|
+
padding: var(--space-1);
|
|
87
|
+
position: fixed;
|
|
88
|
+
transform-origin: top center;
|
|
89
|
+
z-index: 1000;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.pf-combobox__menu--exiting {
|
|
93
|
+
animation: pf-combobox-menu-out var(--duration-fast) var(--easing-accelerate) forwards;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@keyframes pf-combobox-menu-in {
|
|
97
|
+
from {
|
|
98
|
+
opacity: 0;
|
|
99
|
+
transform: translateY(-4px) scaleY(0.96);
|
|
100
|
+
}
|
|
101
|
+
to {
|
|
102
|
+
opacity: 1;
|
|
103
|
+
transform: translateY(0) scaleY(1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@keyframes pf-combobox-menu-out {
|
|
108
|
+
from {
|
|
109
|
+
opacity: 1;
|
|
110
|
+
transform: translateY(0) scaleY(1);
|
|
111
|
+
}
|
|
112
|
+
to {
|
|
113
|
+
opacity: 0;
|
|
114
|
+
transform: translateY(-4px) scaleY(0.96);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.pf-combobox__option {
|
|
119
|
+
border-radius: var(--radius-sm);
|
|
120
|
+
color: var(--pf-combobox-text);
|
|
121
|
+
cursor: pointer;
|
|
122
|
+
padding: var(--space-2) var(--space-3);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.pf-combobox__option--active {
|
|
126
|
+
background: var(--pf-combobox-option-active-bg);
|
|
127
|
+
color: var(--pf-combobox-option-active-text);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.pf-combobox__option--selected {
|
|
131
|
+
font-weight: var(--font-weight-medium);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.pf-combobox__option--disabled {
|
|
135
|
+
background: transparent;
|
|
136
|
+
color: var(--pf-combobox-placeholder);
|
|
137
|
+
cursor: not-allowed;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.pf-combobox__empty {
|
|
141
|
+
color: var(--pf-combobox-placeholder);
|
|
142
|
+
padding: var(--space-2) var(--space-3);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@media (prefers-reduced-motion: reduce) {
|
|
146
|
+
.pf-combobox__control,
|
|
147
|
+
.pf-combobox__icon {
|
|
148
|
+
transition: none;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.pf-combobox__menu,
|
|
152
|
+
.pf-combobox__menu--exiting {
|
|
153
|
+
animation: none;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { Keys, composeDescribedBy } from "../../a11y/index.js";
|
|
2
|
+
import { useAnchoredPosition } from "../../hooks/useAnchoredPosition.js";
|
|
3
|
+
import { useComposedRefs } from "../../hooks/useComposedRefs.js";
|
|
4
|
+
import { useControllableState } from "../../hooks/useControllableState.js";
|
|
5
|
+
import { useOutsideInteraction } from "../../hooks/useOutsideInteraction.js";
|
|
6
|
+
import { usePresence } from "../../hooks/usePresence.js";
|
|
7
|
+
import { cx } from "../../utils/cx.js";
|
|
8
|
+
import { Icon } from "../Icon/Icon2.js";
|
|
9
|
+
import { FieldWrapper } from "../../utils/FieldWrapper.js";
|
|
10
|
+
import './Combobox.css';/* empty css */
|
|
11
|
+
import { forwardRef, useId, useMemo, useRef, useState } from "react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { createPortal } from "react-dom";
|
|
14
|
+
//#region src/components/Combobox/Combobox.tsx
|
|
15
|
+
var Combobox = forwardRef(function Combobox({ id, options, value, defaultValue, onValueChange, label, description, error, placeholder = "Search…", emptyMessage = "No matches", name, required, className, disabled, "aria-describedby": ariaDescribedBy, ...props }, ref) {
|
|
16
|
+
const generatedId = useId();
|
|
17
|
+
const fieldId = id ?? generatedId;
|
|
18
|
+
const listboxId = `${fieldId}-listbox`;
|
|
19
|
+
const descriptionId = description ? `${fieldId}-description` : void 0;
|
|
20
|
+
const errorId = error ? `${fieldId}-error` : void 0;
|
|
21
|
+
const describedBy = composeDescribedBy(ariaDescribedBy, descriptionId, errorId);
|
|
22
|
+
const [selectedValue, setSelectedValue] = useControllableState({
|
|
23
|
+
value,
|
|
24
|
+
defaultValue: defaultValue ?? "",
|
|
25
|
+
onChange: onValueChange
|
|
26
|
+
});
|
|
27
|
+
const selectedOption = options.find((option) => option.value === selectedValue);
|
|
28
|
+
const [query, setQuery] = useState(() => selectedOption?.label ?? "");
|
|
29
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
30
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
31
|
+
const rootRef = useRef(null);
|
|
32
|
+
const inputRef = useRef(null);
|
|
33
|
+
const listboxRef = useRef(null);
|
|
34
|
+
const inputRefs = useComposedRefs(inputRef, ref);
|
|
35
|
+
const { isMounted, isExiting } = usePresence(isOpen, 160);
|
|
36
|
+
const menuStyle = useAnchoredPosition({
|
|
37
|
+
anchorRef: rootRef,
|
|
38
|
+
floatingRef: listboxRef,
|
|
39
|
+
enabled: isOpen,
|
|
40
|
+
matchAnchorWidth: true,
|
|
41
|
+
flip: true
|
|
42
|
+
});
|
|
43
|
+
const filtered = useMemo(() => {
|
|
44
|
+
const q = query.trim().toLowerCase();
|
|
45
|
+
const fromSelection = selectedOption && query === selectedOption.label;
|
|
46
|
+
if (!q || fromSelection) return options;
|
|
47
|
+
return options.filter((option) => option.label.toLowerCase().includes(q));
|
|
48
|
+
}, [
|
|
49
|
+
options,
|
|
50
|
+
query,
|
|
51
|
+
selectedOption
|
|
52
|
+
]);
|
|
53
|
+
useOutsideInteraction({
|
|
54
|
+
refs: [rootRef, listboxRef],
|
|
55
|
+
enabled: isOpen,
|
|
56
|
+
onInteractOutside: () => closeAndRevert()
|
|
57
|
+
});
|
|
58
|
+
const open = () => {
|
|
59
|
+
if (disabled) return;
|
|
60
|
+
setIsOpen(true);
|
|
61
|
+
setActiveIndex(0);
|
|
62
|
+
};
|
|
63
|
+
const closeAndRevert = () => {
|
|
64
|
+
setIsOpen(false);
|
|
65
|
+
setQuery(selectedOption?.label ?? "");
|
|
66
|
+
};
|
|
67
|
+
const selectOption = (option) => {
|
|
68
|
+
if (option.disabled) return;
|
|
69
|
+
setSelectedValue(option.value);
|
|
70
|
+
setQuery(option.label);
|
|
71
|
+
setIsOpen(false);
|
|
72
|
+
};
|
|
73
|
+
const onKeyDown = (event) => {
|
|
74
|
+
if (disabled) return;
|
|
75
|
+
if (event.key === Keys.ArrowDown) {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
if (!isOpen) {
|
|
78
|
+
open();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
setActiveIndex((index) => Math.min(index + 1, filtered.length - 1));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (event.key === Keys.ArrowUp) {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
if (isOpen) setActiveIndex((index) => Math.max(index - 1, 0));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (event.key === Keys.Enter) {
|
|
90
|
+
if (isOpen && filtered[activeIndex]) {
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
selectOption(filtered[activeIndex]);
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (event.key === Keys.Escape) {
|
|
97
|
+
if (isOpen) {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
closeAndRevert();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const activeOptionId = isOpen && filtered[activeIndex] ? `${listboxId}-option-${activeIndex}` : void 0;
|
|
104
|
+
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
105
|
+
labelFor: fieldId,
|
|
106
|
+
label,
|
|
107
|
+
description,
|
|
108
|
+
descriptionId,
|
|
109
|
+
error,
|
|
110
|
+
errorId,
|
|
111
|
+
required,
|
|
112
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
113
|
+
className: "pf-combobox",
|
|
114
|
+
ref: rootRef,
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ jsxs("div", {
|
|
117
|
+
className: cx("pf-combobox__control", error && "pf-combobox__control--invalid"),
|
|
118
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
119
|
+
...props,
|
|
120
|
+
id: fieldId,
|
|
121
|
+
ref: inputRefs,
|
|
122
|
+
type: "text",
|
|
123
|
+
role: "combobox",
|
|
124
|
+
className: cx("pf-combobox__input", className),
|
|
125
|
+
value: query,
|
|
126
|
+
placeholder,
|
|
127
|
+
disabled,
|
|
128
|
+
required,
|
|
129
|
+
autoComplete: "off",
|
|
130
|
+
"aria-autocomplete": "list",
|
|
131
|
+
"aria-expanded": isOpen,
|
|
132
|
+
"aria-controls": listboxId,
|
|
133
|
+
"aria-activedescendant": activeOptionId,
|
|
134
|
+
"aria-describedby": describedBy,
|
|
135
|
+
onChange: (event) => {
|
|
136
|
+
setQuery(event.target.value);
|
|
137
|
+
setActiveIndex(0);
|
|
138
|
+
if (!isOpen) setIsOpen(true);
|
|
139
|
+
},
|
|
140
|
+
onClick: open,
|
|
141
|
+
onKeyDown
|
|
142
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
143
|
+
"aria-hidden": true,
|
|
144
|
+
className: cx("pf-combobox__icon", isOpen && "pf-combobox__icon--open"),
|
|
145
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
146
|
+
name: "chevron-down",
|
|
147
|
+
"aria-hidden": true
|
|
148
|
+
})
|
|
149
|
+
})]
|
|
150
|
+
}),
|
|
151
|
+
name ? /* @__PURE__ */ jsx("input", {
|
|
152
|
+
type: "hidden",
|
|
153
|
+
name,
|
|
154
|
+
value: selectedValue
|
|
155
|
+
}) : null,
|
|
156
|
+
isMounted && typeof document !== "undefined" ? createPortal(/* @__PURE__ */ jsx("ul", {
|
|
157
|
+
id: listboxId,
|
|
158
|
+
ref: listboxRef,
|
|
159
|
+
role: "listbox",
|
|
160
|
+
className: cx("pf-combobox__menu", isExiting && "pf-combobox__menu--exiting"),
|
|
161
|
+
style: menuStyle,
|
|
162
|
+
"aria-label": label,
|
|
163
|
+
children: filtered.length === 0 ? /* @__PURE__ */ jsx("li", {
|
|
164
|
+
className: "pf-combobox__empty",
|
|
165
|
+
role: "presentation",
|
|
166
|
+
children: emptyMessage
|
|
167
|
+
}) : filtered.map((option, index) => {
|
|
168
|
+
const isSelected = option.value === selectedValue;
|
|
169
|
+
const isActive = index === activeIndex;
|
|
170
|
+
return /* @__PURE__ */ jsx("li", {
|
|
171
|
+
id: `${listboxId}-option-${index}`,
|
|
172
|
+
role: "option",
|
|
173
|
+
"aria-selected": isSelected,
|
|
174
|
+
"aria-disabled": option.disabled ? true : void 0,
|
|
175
|
+
className: cx("pf-combobox__option", isSelected && "pf-combobox__option--selected", isActive && "pf-combobox__option--active", option.disabled && "pf-combobox__option--disabled"),
|
|
176
|
+
onMouseEnter: () => {
|
|
177
|
+
if (!option.disabled) setActiveIndex(index);
|
|
178
|
+
},
|
|
179
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
180
|
+
onClick: () => selectOption(option),
|
|
181
|
+
children: option.label
|
|
182
|
+
}, option.value);
|
|
183
|
+
})
|
|
184
|
+
}), document.body) : null
|
|
185
|
+
]
|
|
186
|
+
})
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
Combobox.displayName = "Combobox";
|
|
190
|
+
//#endregion
|
|
191
|
+
export { Combobox };
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/* ── Backdrop ─────────────────────────────────────────────────────────────── */
|
|
2
|
+
|
|
3
|
+
.pf-command__backdrop {
|
|
4
|
+
animation: pf-command-backdrop-in var(--pf-transition-fast);
|
|
5
|
+
background: var(--pf-overlay-backdrop);
|
|
6
|
+
inset: 0;
|
|
7
|
+
position: fixed;
|
|
8
|
+
z-index: 1100;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.pf-command__backdrop--exiting {
|
|
12
|
+
animation: pf-command-backdrop-out var(--pf-transition-fast) forwards;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@keyframes pf-command-backdrop-in {
|
|
16
|
+
from {
|
|
17
|
+
opacity: 0;
|
|
18
|
+
}
|
|
19
|
+
to {
|
|
20
|
+
opacity: 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@keyframes pf-command-backdrop-out {
|
|
25
|
+
from {
|
|
26
|
+
opacity: 1;
|
|
27
|
+
}
|
|
28
|
+
to {
|
|
29
|
+
opacity: 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* ── Dialog ───────────────────────────────────────────────────────────────── */
|
|
34
|
+
|
|
35
|
+
.pf-command {
|
|
36
|
+
animation: pf-command-in var(--pf-transition-fast) var(--easing-decelerate);
|
|
37
|
+
background: var(--pf-command-bg);
|
|
38
|
+
border: 1px solid var(--pf-command-border);
|
|
39
|
+
border-radius: var(--radius-lg);
|
|
40
|
+
box-shadow: var(--pf-elevation-overlay-shadow);
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
left: 50%;
|
|
44
|
+
max-height: min(560px, 80vh);
|
|
45
|
+
max-width: 560px;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
position: fixed;
|
|
48
|
+
top: 12%;
|
|
49
|
+
transform: translateX(-50%);
|
|
50
|
+
width: calc(100vw - var(--space-8));
|
|
51
|
+
z-index: 1101;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.pf-command--exiting {
|
|
55
|
+
animation: pf-command-out var(--pf-transition-fast) var(--easing-accelerate) forwards;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@keyframes pf-command-in {
|
|
59
|
+
from {
|
|
60
|
+
opacity: 0;
|
|
61
|
+
transform: translateX(-50%) translateY(-8px) scale(0.97);
|
|
62
|
+
}
|
|
63
|
+
to {
|
|
64
|
+
opacity: 1;
|
|
65
|
+
transform: translateX(-50%) translateY(0) scale(1);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@keyframes pf-command-out {
|
|
70
|
+
from {
|
|
71
|
+
opacity: 1;
|
|
72
|
+
transform: translateX(-50%) translateY(0) scale(1);
|
|
73
|
+
}
|
|
74
|
+
to {
|
|
75
|
+
opacity: 0;
|
|
76
|
+
transform: translateX(-50%) translateY(-8px) scale(0.97);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* ── Search bar ───────────────────────────────────────────────────────────── */
|
|
81
|
+
|
|
82
|
+
.pf-command__search {
|
|
83
|
+
align-items: center;
|
|
84
|
+
border-block-end: 1px solid var(--pf-command-border);
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-shrink: 0;
|
|
87
|
+
gap: var(--space-2);
|
|
88
|
+
padding: var(--space-3) var(--space-4);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.pf-command__search-icon {
|
|
92
|
+
color: var(--pf-command-text-muted);
|
|
93
|
+
flex-shrink: 0;
|
|
94
|
+
font-size: 1.1rem;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.pf-command__input {
|
|
98
|
+
background: transparent;
|
|
99
|
+
border: none;
|
|
100
|
+
color: var(--pf-command-text);
|
|
101
|
+
flex: 1;
|
|
102
|
+
font-size: var(--font-size-md);
|
|
103
|
+
min-width: 0;
|
|
104
|
+
outline: none;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.pf-command__input::placeholder {
|
|
108
|
+
color: var(--pf-command-text-muted);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.pf-command__esc-hint {
|
|
112
|
+
background: var(--pf-command-shortcut-bg);
|
|
113
|
+
border: 1px solid var(--pf-command-border);
|
|
114
|
+
border-bottom-width: 2px;
|
|
115
|
+
border-radius: var(--radius-sm);
|
|
116
|
+
color: var(--pf-command-text-muted);
|
|
117
|
+
flex-shrink: 0;
|
|
118
|
+
font-family: var(--font-family-mono);
|
|
119
|
+
font-size: var(--font-size-xs);
|
|
120
|
+
padding: 1px 6px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* ── Results list ─────────────────────────────────────────────────────────── */
|
|
124
|
+
|
|
125
|
+
.pf-command__list {
|
|
126
|
+
overflow-y: auto;
|
|
127
|
+
padding: var(--space-2);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.pf-command__empty {
|
|
131
|
+
color: var(--pf-command-text-muted);
|
|
132
|
+
font-size: var(--font-size-sm);
|
|
133
|
+
margin: 0;
|
|
134
|
+
padding: var(--space-6) var(--space-4);
|
|
135
|
+
text-align: center;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.pf-command__group-label {
|
|
139
|
+
color: var(--pf-command-text-muted);
|
|
140
|
+
font-size: var(--font-size-xs);
|
|
141
|
+
font-weight: var(--font-weight-semibold);
|
|
142
|
+
letter-spacing: 0.04em;
|
|
143
|
+
margin: 0;
|
|
144
|
+
padding: var(--space-2) var(--space-2) var(--space-1);
|
|
145
|
+
text-transform: uppercase;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* ── Items ────────────────────────────────────────────────────────────────── */
|
|
149
|
+
|
|
150
|
+
.pf-command__item {
|
|
151
|
+
align-items: center;
|
|
152
|
+
border-radius: var(--radius-md);
|
|
153
|
+
cursor: pointer;
|
|
154
|
+
display: flex;
|
|
155
|
+
gap: var(--space-3);
|
|
156
|
+
padding: var(--space-2) var(--space-3);
|
|
157
|
+
transition: background 0.1s;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.pf-command__item--active {
|
|
161
|
+
background: var(--pf-command-item-active-bg);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.pf-command__item--disabled {
|
|
165
|
+
cursor: not-allowed;
|
|
166
|
+
opacity: 0.45;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.pf-command__item-icon {
|
|
170
|
+
align-items: center;
|
|
171
|
+
color: var(--pf-command-text-muted);
|
|
172
|
+
display: inline-flex;
|
|
173
|
+
flex-shrink: 0;
|
|
174
|
+
font-size: 1rem;
|
|
175
|
+
height: 20px;
|
|
176
|
+
justify-content: center;
|
|
177
|
+
width: 20px;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.pf-command__item--active .pf-command__item-icon {
|
|
181
|
+
color: var(--pf-command-item-active-text);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.pf-command__item-content {
|
|
185
|
+
display: flex;
|
|
186
|
+
flex: 1;
|
|
187
|
+
flex-direction: column;
|
|
188
|
+
gap: 1px;
|
|
189
|
+
min-width: 0;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.pf-command__item-label {
|
|
193
|
+
color: var(--pf-command-text);
|
|
194
|
+
font-size: var(--font-size-sm);
|
|
195
|
+
font-weight: var(--font-weight-medium);
|
|
196
|
+
overflow: hidden;
|
|
197
|
+
text-overflow: ellipsis;
|
|
198
|
+
white-space: nowrap;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.pf-command__item--active .pf-command__item-label {
|
|
202
|
+
color: var(--pf-command-item-active-text);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.pf-command__item-description {
|
|
206
|
+
color: var(--pf-command-text-muted);
|
|
207
|
+
font-size: var(--font-size-xs);
|
|
208
|
+
overflow: hidden;
|
|
209
|
+
text-overflow: ellipsis;
|
|
210
|
+
white-space: nowrap;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.pf-command__item--active .pf-command__item-description {
|
|
214
|
+
color: var(--pf-command-item-active-text);
|
|
215
|
+
opacity: 0.85;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@media (prefers-reduced-motion: reduce) {
|
|
219
|
+
.pf-command__backdrop,
|
|
220
|
+
.pf-command__backdrop--exiting,
|
|
221
|
+
.pf-command,
|
|
222
|
+
.pf-command--exiting {
|
|
223
|
+
animation: none;
|
|
224
|
+
}
|
|
225
|
+
}
|