@pitchfork-ui/react 0.7.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.
Files changed (47) hide show
  1. package/dist/components/AvatarGroup/AvatarGroup.css +26 -0
  2. package/dist/components/AvatarGroup/AvatarGroup2.js +37 -0
  3. package/dist/components/Calendar/Calendar.css +0 -1
  4. package/dist/components/Combobox/Combobox.css +155 -0
  5. package/dist/components/Combobox/Combobox2.js +191 -0
  6. package/dist/components/CommandPalette/CommandPalette.css +225 -0
  7. package/dist/components/CommandPalette/CommandPalette2.js +195 -0
  8. package/dist/components/DateRangePicker/DateRangePicker.css +258 -0
  9. package/dist/components/DateRangePicker/DateRangePicker2.js +378 -0
  10. package/dist/components/Icon/Icon2.js +43 -0
  11. package/dist/components/Kbd/Kbd.css +25 -0
  12. package/dist/components/Kbd/Kbd2.js +17 -0
  13. package/dist/components/NumberInput/NumberInput.css +98 -0
  14. package/dist/components/NumberInput/NumberInput2.js +165 -0
  15. package/dist/components/Popover/Popover.css +46 -0
  16. package/dist/components/Popover/Popover2.js +76 -0
  17. package/dist/components/Toast/Toast.js +129 -0
  18. package/dist/index.cjs +1190 -24
  19. package/dist/index.js +9 -1
  20. package/dist/src/components/AvatarGroup/AvatarGroup.d.ts +14 -0
  21. package/dist/src/components/AvatarGroup/AvatarGroup.test.d.ts +1 -0
  22. package/dist/src/components/AvatarGroup/index.d.ts +1 -0
  23. package/dist/src/components/Combobox/Combobox.d.ts +20 -0
  24. package/dist/src/components/Combobox/Combobox.test.d.ts +1 -0
  25. package/dist/src/components/Combobox/index.d.ts +1 -0
  26. package/dist/src/components/CommandPalette/CommandPalette.d.ts +18 -0
  27. package/dist/src/components/CommandPalette/CommandPalette.test.d.ts +1 -0
  28. package/dist/src/components/CommandPalette/index.d.ts +1 -0
  29. package/dist/src/components/DateRangePicker/DateRangePicker.d.ts +21 -0
  30. package/dist/src/components/DateRangePicker/DateRangePicker.test.d.ts +1 -0
  31. package/dist/src/components/DateRangePicker/index.d.ts +1 -0
  32. package/dist/src/components/Kbd/Kbd.d.ts +9 -0
  33. package/dist/src/components/Kbd/Kbd.test.d.ts +1 -0
  34. package/dist/src/components/Kbd/index.d.ts +1 -0
  35. package/dist/src/components/NumberInput/NumberInput.d.ts +19 -0
  36. package/dist/src/components/NumberInput/NumberInput.test.d.ts +1 -0
  37. package/dist/src/components/NumberInput/index.d.ts +1 -0
  38. package/dist/src/components/Popover/Popover.d.ts +21 -0
  39. package/dist/src/components/Popover/Popover.test.d.ts +1 -0
  40. package/dist/src/components/Popover/index.d.ts +1 -0
  41. package/dist/src/components/Toast/Toast.d.ts +35 -0
  42. package/dist/src/components/Toast/Toast.test.d.ts +1 -0
  43. package/dist/src/components/Toast/index.d.ts +1 -0
  44. package/dist/src/index.d.ts +8 -0
  45. package/dist/styles/theme.css +68 -0
  46. package/dist/styles.css +977 -77
  47. package/package.json +1 -1
@@ -0,0 +1,195 @@
1
+ import { Keys } from "../../a11y/index.js";
2
+ import { useFocusTrap } from "../../hooks/useFocusTrap.js";
3
+ import { useListNavigation } from "../../hooks/useListNavigation.js";
4
+ import { usePresence } from "../../hooks/usePresence.js";
5
+ import { cx } from "../../utils/cx.js";
6
+ import { Icon } from "../Icon/Icon2.js";
7
+ import './CommandPalette.css';/* empty css */
8
+ import { useEffect, useId, useMemo, useRef, useState } from "react";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ import { createPortal } from "react-dom";
11
+ //#region src/components/CommandPalette/CommandPalette.tsx
12
+ function CommandPalette({ open, onOpenChange, items, placeholder = "Search commands…", emptyMessage = "No results found." }) {
13
+ const inputId = useId();
14
+ const listId = useId();
15
+ const [query, setQuery] = useState("");
16
+ const dialogRef = useRef(null);
17
+ const inputRef = useRef(null);
18
+ const { isMounted, isExiting } = usePresence(open, 180);
19
+ useEffect(() => {
20
+ if (!open) return;
21
+ const frame = requestAnimationFrame(() => {
22
+ setQuery("");
23
+ inputRef.current?.focus();
24
+ });
25
+ return () => cancelAnimationFrame(frame);
26
+ }, [open]);
27
+ useEffect(() => {
28
+ if (!isMounted || typeof document === "undefined") return;
29
+ const prev = document.body.style.overflow;
30
+ document.body.style.overflow = "hidden";
31
+ return () => {
32
+ document.body.style.overflow = prev;
33
+ };
34
+ }, [isMounted]);
35
+ useFocusTrap({
36
+ containerRef: dialogRef,
37
+ enabled: open,
38
+ onEscape: () => onOpenChange(false)
39
+ });
40
+ const filtered = useMemo(() => {
41
+ const q = query.trim().toLowerCase();
42
+ if (!q) return items;
43
+ return items.filter((item) => item.label.toLowerCase().includes(q) || item.description?.toLowerCase().includes(q) || item.group?.toLowerCase().includes(q));
44
+ }, [items, query]);
45
+ const { activeIndex, move, setActiveIndex } = useListNavigation({
46
+ items: filtered,
47
+ isDisabled: (item) => !!item.disabled
48
+ });
49
+ useEffect(() => {
50
+ setActiveIndex(0);
51
+ }, [query, setActiveIndex]);
52
+ const selectActive = () => {
53
+ const item = filtered[activeIndex];
54
+ if (item && !item.disabled) {
55
+ item.onSelect();
56
+ onOpenChange(false);
57
+ }
58
+ };
59
+ const onKeyDown = (e) => {
60
+ if (e.key === Keys.ArrowDown) {
61
+ e.preventDefault();
62
+ move("next");
63
+ } else if (e.key === Keys.ArrowUp) {
64
+ e.preventDefault();
65
+ move("previous");
66
+ } else if (e.key === Keys.Home) {
67
+ e.preventDefault();
68
+ move("first");
69
+ } else if (e.key === Keys.End) {
70
+ e.preventDefault();
71
+ move("last");
72
+ } else if (e.key === Keys.Enter) {
73
+ e.preventDefault();
74
+ selectActive();
75
+ }
76
+ };
77
+ const groupedItems = useMemo(() => {
78
+ const groups = [];
79
+ const seen = /* @__PURE__ */ new Map();
80
+ filtered.forEach((item, index) => {
81
+ const g = item.group;
82
+ if (!seen.has(g)) {
83
+ seen.set(g, groups.length);
84
+ groups.push({
85
+ group: g,
86
+ items: []
87
+ });
88
+ }
89
+ groups[seen.get(g)].items.push({
90
+ item,
91
+ index
92
+ });
93
+ });
94
+ return groups;
95
+ }, [filtered]);
96
+ const activeOptionId = filtered[activeIndex] ? `${listId}-option-${activeIndex}` : void 0;
97
+ if (!isMounted || typeof document === "undefined") return null;
98
+ return createPortal(/* @__PURE__ */ jsx("div", {
99
+ className: cx("pf-command__backdrop", isExiting && "pf-command__backdrop--exiting"),
100
+ onClick: () => onOpenChange(false),
101
+ children: /* @__PURE__ */ jsxs("div", {
102
+ ref: dialogRef,
103
+ className: cx("pf-command", isExiting && "pf-command--exiting"),
104
+ role: "dialog",
105
+ "aria-modal": "true",
106
+ "aria-label": "Command palette",
107
+ tabIndex: -1,
108
+ onClick: (e) => e.stopPropagation(),
109
+ onKeyDown,
110
+ children: [/* @__PURE__ */ jsxs("div", {
111
+ className: "pf-command__search",
112
+ children: [
113
+ /* @__PURE__ */ jsx(Icon, {
114
+ name: "magnifying-glass",
115
+ "aria-hidden": true,
116
+ className: "pf-command__search-icon"
117
+ }),
118
+ /* @__PURE__ */ jsx("input", {
119
+ ref: inputRef,
120
+ id: inputId,
121
+ type: "text",
122
+ className: "pf-command__input",
123
+ value: query,
124
+ placeholder,
125
+ autoComplete: "off",
126
+ spellCheck: false,
127
+ role: "combobox",
128
+ "aria-autocomplete": "list",
129
+ "aria-expanded": true,
130
+ "aria-controls": listId,
131
+ "aria-activedescendant": activeOptionId,
132
+ onChange: (e) => setQuery(e.target.value)
133
+ }),
134
+ /* @__PURE__ */ jsx("kbd", {
135
+ className: "pf-command__esc-hint",
136
+ "aria-hidden": true,
137
+ children: "esc"
138
+ })
139
+ ]
140
+ }), /* @__PURE__ */ jsx("div", {
141
+ id: listId,
142
+ role: "listbox",
143
+ "aria-label": "Commands",
144
+ className: "pf-command__list",
145
+ children: filtered.length === 0 ? /* @__PURE__ */ jsx("p", {
146
+ className: "pf-command__empty",
147
+ role: "presentation",
148
+ children: emptyMessage
149
+ }) : groupedItems.map(({ group, items: groupItems }) => /* @__PURE__ */ jsxs("div", {
150
+ role: "presentation",
151
+ children: [group ? /* @__PURE__ */ jsx("p", {
152
+ className: "pf-command__group-label",
153
+ role: "presentation",
154
+ children: group
155
+ }) : null, groupItems.map(({ item, index }) => {
156
+ const isActive = index === activeIndex;
157
+ return /* @__PURE__ */ jsxs("div", {
158
+ id: `${listId}-option-${index}`,
159
+ role: "option",
160
+ "aria-selected": isActive,
161
+ "aria-disabled": item.disabled ? true : void 0,
162
+ className: cx("pf-command__item", isActive && "pf-command__item--active", item.disabled && "pf-command__item--disabled"),
163
+ onMouseEnter: () => {
164
+ if (!item.disabled) setActiveIndex(index);
165
+ },
166
+ onMouseDown: (e) => e.preventDefault(),
167
+ onClick: () => {
168
+ if (!item.disabled) {
169
+ item.onSelect();
170
+ onOpenChange(false);
171
+ }
172
+ },
173
+ children: [item.icon ? /* @__PURE__ */ jsx("span", {
174
+ className: "pf-command__item-icon",
175
+ "aria-hidden": true,
176
+ children: item.icon
177
+ }) : null, /* @__PURE__ */ jsxs("span", {
178
+ className: "pf-command__item-content",
179
+ children: [/* @__PURE__ */ jsx("span", {
180
+ className: "pf-command__item-label",
181
+ children: item.label
182
+ }), item.description ? /* @__PURE__ */ jsx("span", {
183
+ className: "pf-command__item-description",
184
+ children: item.description
185
+ }) : null]
186
+ })]
187
+ }, item.id);
188
+ })]
189
+ }, group ?? "__ungrouped"))
190
+ })]
191
+ })
192
+ }), document.body);
193
+ }
194
+ //#endregion
195
+ export { CommandPalette };
@@ -0,0 +1,258 @@
1
+ .pf-daterange {
2
+ position: relative;
3
+ }
4
+
5
+ .pf-daterange__control-row {
6
+ align-items: center;
7
+ display: flex;
8
+ gap: var(--space-1);
9
+ }
10
+
11
+ /* ── Trigger button ───────────────────────────────────────────────────────── */
12
+
13
+ .pf-daterange__trigger {
14
+ align-items: center;
15
+ background: var(--pf-daterange-bg);
16
+ border: 1px solid var(--pf-daterange-border);
17
+ border-radius: var(--radius-md);
18
+ color: var(--pf-daterange-text);
19
+ cursor: pointer;
20
+ display: inline-flex;
21
+ flex: 1;
22
+ font-size: var(--font-size-sm);
23
+ gap: var(--space-2);
24
+ justify-content: space-between;
25
+ min-height: 40px;
26
+ min-width: 0;
27
+ padding: 0 var(--space-3);
28
+ text-align: start;
29
+ transition: border 0.2s;
30
+ }
31
+
32
+ .pf-daterange__trigger:hover:not(:disabled) {
33
+ border-color: var(--pf-daterange-border-strong);
34
+ }
35
+
36
+ .pf-daterange__trigger:focus-visible {
37
+ box-shadow: var(--pf-daterange-focus-ring, var(--pf-focus-ring));
38
+ outline: none;
39
+ }
40
+
41
+ .pf-daterange__trigger:disabled {
42
+ background: var(--pf-daterange-bg-subtle);
43
+ color: var(--pf-daterange-text-muted);
44
+ cursor: not-allowed;
45
+ }
46
+
47
+ .pf-daterange__trigger--invalid {
48
+ border-color: var(--pf-daterange-invalid-border);
49
+ }
50
+
51
+ .pf-daterange__value {
52
+ align-items: center;
53
+ display: flex;
54
+ flex-wrap: wrap;
55
+ gap: var(--space-1);
56
+ min-width: 0;
57
+ overflow: hidden;
58
+ }
59
+
60
+ .pf-daterange__value--placeholder {
61
+ color: var(--pf-daterange-text-muted);
62
+ }
63
+
64
+ .pf-daterange__separator {
65
+ color: var(--pf-daterange-text-muted);
66
+ }
67
+
68
+ /* ── Popover ──────────────────────────────────────────────────────────────── */
69
+
70
+ .pf-daterange__popover {
71
+ background: var(--pf-daterange-menu-bg);
72
+ border: 1px solid var(--pf-daterange-menu-border);
73
+ border-radius: var(--radius-lg);
74
+ box-shadow: var(--pf-elevation-popover-shadow);
75
+ color: var(--pf-calendar-text);
76
+ padding: var(--space-4);
77
+ position: fixed;
78
+ z-index: 999;
79
+ }
80
+
81
+ .pf-daterange__hint {
82
+ color: var(--pf-daterange-text-muted);
83
+ font-size: var(--font-size-xs);
84
+ margin: 0 0 var(--space-3);
85
+ }
86
+
87
+ /* ── Two-month layout ─────────────────────────────────────────────────────── */
88
+
89
+ .pf-daterange__months {
90
+ display: grid;
91
+ gap: var(--space-4);
92
+ grid-template-columns: 1fr;
93
+ }
94
+
95
+ @media (min-width: 640px) {
96
+ .pf-daterange__months {
97
+ grid-template-columns: 1fr 1fr;
98
+ }
99
+ }
100
+
101
+ /* ── Individual calendar panel ────────────────────────────────────────────── */
102
+
103
+ .pf-daterange__calendar {
104
+ background: var(--pf-calendar-bg);
105
+ color: var(--pf-calendar-text);
106
+ display: grid;
107
+ gap: var(--space-2);
108
+ min-width: 0;
109
+ }
110
+
111
+ .pf-daterange__cal-header {
112
+ align-items: center;
113
+ display: grid;
114
+ grid-template-columns: 28px 1fr 28px;
115
+ }
116
+
117
+ .pf-daterange__cal-title {
118
+ font-size: var(--font-size-sm);
119
+ font-weight: var(--font-weight-semibold);
120
+ text-align: center;
121
+ }
122
+
123
+ /* Nav buttons — desktop right-panel hides its own nav (left panel drives both) */
124
+ .pf-daterange__nav {
125
+ align-items: center;
126
+ background: transparent;
127
+ border: 0;
128
+ border-radius: var(--radius-sm);
129
+ color: var(--pf-calendar-text-muted);
130
+ cursor: pointer;
131
+ display: inline-flex;
132
+ font-size: var(--font-size-sm);
133
+ height: 28px;
134
+ justify-content: center;
135
+ padding: 0;
136
+ width: 28px;
137
+ }
138
+
139
+ .pf-daterange__nav:hover:not(:disabled) {
140
+ background: var(--pf-calendar-bg-subtle);
141
+ color: var(--pf-calendar-text);
142
+ }
143
+
144
+ .pf-daterange__nav:focus-visible {
145
+ box-shadow: var(--pf-calendar-focus-ring, var(--pf-focus-ring));
146
+ outline: none;
147
+ }
148
+
149
+ .pf-daterange__nav svg {
150
+ display: block;
151
+ height: 14px;
152
+ width: 14px;
153
+ }
154
+
155
+ @media (min-width: 640px) {
156
+ .pf-daterange__cal-header--hide-nav-desktop .pf-daterange__nav {
157
+ pointer-events: none;
158
+ visibility: hidden;
159
+ }
160
+ }
161
+
162
+ /* ── Grid & weekday labels ────────────────────────────────────────────────── */
163
+
164
+ .pf-daterange__grid {
165
+ display: grid;
166
+ gap: var(--space-1);
167
+ grid-template-columns: repeat(7, minmax(0, 1fr));
168
+ }
169
+
170
+ .pf-daterange__weekday {
171
+ color: var(--pf-calendar-text-muted);
172
+ font-size: var(--font-size-xs);
173
+ font-weight: var(--font-weight-medium);
174
+ text-align: center;
175
+ }
176
+
177
+ /* ── Day cells ────────────────────────────────────────────────────────────── */
178
+
179
+ .pf-daterange__day,
180
+ .pf-daterange__day-empty {
181
+ align-items: center;
182
+ aspect-ratio: 1 / 1;
183
+ border-radius: var(--radius-sm);
184
+ display: inline-flex;
185
+ font-size: var(--font-size-xs);
186
+ justify-content: center;
187
+ }
188
+
189
+ .pf-daterange__day {
190
+ background: transparent;
191
+ border: 0;
192
+ color: var(--pf-calendar-text);
193
+ cursor: pointer;
194
+ }
195
+
196
+ .pf-daterange__day:hover:not(:disabled):not(.pf-daterange__day--selected):not(
197
+ .pf-daterange__day--in-range
198
+ ) {
199
+ background: var(--pf-calendar-bg-subtle);
200
+ }
201
+
202
+ .pf-daterange__day--outside {
203
+ color: var(--pf-calendar-text-muted);
204
+ }
205
+
206
+ .pf-daterange__day--today {
207
+ background: var(--pf-calendar-today-bg);
208
+ border: 1.5px solid var(--pf-calendar-today-border);
209
+ }
210
+
211
+ .pf-daterange__day--selected {
212
+ background: var(--pf-calendar-selected-bg);
213
+ color: var(--pf-calendar-selected-text);
214
+ font-weight: var(--font-weight-semibold);
215
+ }
216
+
217
+ .pf-daterange__day--selected:hover:not(:disabled) {
218
+ background: var(--pf-calendar-selected-bg-hover);
219
+ color: var(--pf-calendar-selected-text);
220
+ }
221
+
222
+ .pf-daterange__day:disabled {
223
+ color: var(--pf-calendar-text-muted);
224
+ cursor: not-allowed;
225
+ opacity: 0.45;
226
+ }
227
+
228
+ /* ── Range highlight ──────────────────────────────────────────────────────── */
229
+
230
+ .pf-daterange__day--in-range {
231
+ background: var(--pf-daterange-range-bg);
232
+ border-radius: 0;
233
+ color: var(--pf-daterange-range-text);
234
+ }
235
+
236
+ /* In-range overrides today indicator bg (today border still shows through) */
237
+ .pf-daterange__day--today.pf-daterange__day--in-range {
238
+ background: var(--pf-daterange-range-bg);
239
+ color: var(--pf-daterange-range-text);
240
+ }
241
+
242
+ /* Selected caps already have the right bg/color from --selected;
243
+ just shape the radius to connect flush with the range band. */
244
+ .pf-daterange__day--range-start:not(.pf-daterange__day--range-end) {
245
+ border-end-end-radius: 0;
246
+ border-start-end-radius: 0;
247
+ }
248
+
249
+ .pf-daterange__day--range-end:not(.pf-daterange__day--range-start) {
250
+ border-end-start-radius: 0;
251
+ border-start-start-radius: 0;
252
+ }
253
+
254
+ @media (prefers-reduced-motion: reduce) {
255
+ .pf-daterange__trigger {
256
+ transition: none;
257
+ }
258
+ }