@umituz/web-design-system 4.28.0 → 4.28.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-design-system",
|
|
3
|
-
"version": "4.28.
|
|
3
|
+
"version": "4.28.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Web Design System - Tailwind v4 authored, precompiled CSS shipped. Atomic Design components (Atoms, Molecules, Organisms, Templates) for React applications.",
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CommandPalette Component (Organism)
|
|
3
|
-
* @description ⌘K-style command palette — filterable grouped actions with
|
|
4
|
-
* full keyboard navigation, built on the Radix dialog primitives.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
1
|
import * as React from 'react';
|
|
8
2
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
9
3
|
import { Search } from 'lucide-react';
|
|
@@ -13,12 +7,11 @@ export interface CommandItem {
|
|
|
13
7
|
id: string;
|
|
14
8
|
label: string;
|
|
15
9
|
icon?: React.ReactNode;
|
|
16
|
-
/** Right-aligned hint (e.g. a navigation target). */
|
|
17
10
|
hint?: string;
|
|
18
|
-
/** Extra match targets beyond the label. */
|
|
19
11
|
keywords?: string;
|
|
20
12
|
danger?: boolean;
|
|
21
13
|
disabled?: boolean;
|
|
14
|
+
prefiltered?: boolean;
|
|
22
15
|
onSelect: () => void;
|
|
23
16
|
}
|
|
24
17
|
|
|
@@ -30,13 +23,10 @@ export interface CommandGroup {
|
|
|
30
23
|
export interface CommandPaletteProps {
|
|
31
24
|
open: boolean;
|
|
32
25
|
onOpenChange: (open: boolean) => void;
|
|
33
|
-
/** Static entry groups; palettes driven purely by `search` may omit them. */
|
|
34
26
|
groups?: CommandGroup[];
|
|
35
27
|
placeholder?: string;
|
|
36
28
|
emptyLabel?: string;
|
|
37
|
-
/** Accessible name for the dialog. */
|
|
38
29
|
label?: string;
|
|
39
|
-
/** Notifies the host on every query change (typing and reset-on-open). */
|
|
40
30
|
onQueryChange?: (q: string) => void;
|
|
41
31
|
}
|
|
42
32
|
|
|
@@ -46,7 +36,7 @@ interface FlatEntry {
|
|
|
46
36
|
}
|
|
47
37
|
|
|
48
38
|
const matches = (item: CommandItem, q: string): boolean => {
|
|
49
|
-
if (!q) return true;
|
|
39
|
+
if (!q || item.prefiltered) return true;
|
|
50
40
|
const needle = q.toLowerCase();
|
|
51
41
|
return (
|
|
52
42
|
item.label.toLowerCase().includes(needle) ||
|
|
@@ -77,8 +67,6 @@ export const CommandPalette = ({
|
|
|
77
67
|
[groups, query]
|
|
78
68
|
);
|
|
79
69
|
|
|
80
|
-
// Fresh query + selection every time the palette opens (render-time
|
|
81
|
-
// adjustment — the React-endorsed replacement for a reset effect).
|
|
82
70
|
const [prevOpen, setPrevOpen] = React.useState(open);
|
|
83
71
|
if (open !== prevOpen) {
|
|
84
72
|
setPrevOpen(open);
|
|
@@ -88,20 +76,22 @@ export const CommandPalette = ({
|
|
|
88
76
|
}
|
|
89
77
|
}
|
|
90
78
|
|
|
79
|
+
const onQueryChangeRef = React.useRef(onQueryChange);
|
|
80
|
+
React.useEffect(() => {
|
|
81
|
+
onQueryChangeRef.current = onQueryChange;
|
|
82
|
+
});
|
|
91
83
|
React.useEffect(() => {
|
|
92
84
|
if (open) {
|
|
93
|
-
|
|
85
|
+
onQueryChangeRef.current?.('');
|
|
94
86
|
}
|
|
95
|
-
}, [open
|
|
87
|
+
}, [open]);
|
|
96
88
|
|
|
97
|
-
// Keep the highlighted index inside the (possibly filtered) list.
|
|
98
89
|
const [prevFlatLength, setPrevFlatLength] = React.useState(flat.length);
|
|
99
90
|
if (flat.length !== prevFlatLength) {
|
|
100
91
|
setPrevFlatLength(flat.length);
|
|
101
92
|
setActiveIndex((i) => Math.min(i, Math.max(flat.length - 1, 0)));
|
|
102
93
|
}
|
|
103
94
|
|
|
104
|
-
// Keep the highlighted option in view while arrowing through the list.
|
|
105
95
|
React.useEffect(() => {
|
|
106
96
|
const active = flat[activeIndex];
|
|
107
97
|
if (!active) return;
|