@gv-tech/ui-web 2.15.1 → 2.15.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/dist/search.cjs +1 -1
- package/dist/search.mjs +51 -38
- package/package.json +1 -1
- package/src/search.tsx +15 -4
package/dist/search.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./jsx-runtime-nZSsnGb7.js"),p=require("lucide-react"),h=require("react"),j=require("./button.cjs"),g=require("./command.cjs"),u=require("./utils-IjLH3w2e.js");function y(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(s,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}return s.default=t,Object.freeze(s)}const d=y(h);function b({children:t,open:s,onOpenChange:e}){const[r,x]=d.useState(!1),a=s!==void 0,i=a?s:r,l=d.useCallback(o=>{let n;typeof o=="function"?n=o(i):n=o,a?e?.(n):x(n)},[a,i,e]);return d.useEffect(()=>{const o=n=>{n.key==="k"&&(n.metaKey||n.ctrlKey)&&(n.preventDefault(),l(f=>!f))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[l]),c.jsxRuntimeExports.jsx(g.CommandDialog,{open:i,onOpenChange:l,children:t})}const m=d.forwardRef(({className:t,placeholder:s,variant:e="default",responsive:r=!1,...x},a)=>{const l=s||(e==="compact"?"Search...":"Search docs...");return c.jsxRuntimeExports.jsxs(j.Button,{variant:"outline",className:u.cn("text-muted-foreground relative h-9 text-sm transition-all transition-colors",e==="default"?"w-full justify-start pr-12":u.cn("w-9 justify-center px-0",r&&"2xl:w-48 2xl:justify-start 2xl:px-3 2xl:pr-12"),t),ref:a,...x,children:[c.jsxRuntimeExports.jsxs("span",{className:"inline-flex items-center gap-2",children:[c.jsxRuntimeExports.jsx(p.Search,{className:"h-4 w-4 shrink-0"}),c.jsxRuntimeExports.jsx("span",{className:u.cn("truncate",e==="compact"&&(r?"hidden 2xl:inline":"hidden")),children:l})]}),c.jsxRuntimeExports.jsxs("kbd",{className:u.cn("bg-muted pointer-events-none absolute top-1.5 right-1.5 hidden h-6 items-center gap-1 rounded border px-1.5 font-mono text-[10px] font-medium opacity-100 select-none",e==="default"&&"sm:flex",e==="compact"&&r&&"2xl:flex"),children:[c.jsxRuntimeExports.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]})});m.displayName="SearchTrigger";exports.Search=b;exports.SearchTrigger=m;
|
package/dist/search.mjs
CHANGED
|
@@ -1,52 +1,65 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { j as
|
|
2
|
+
import { j as n } from "./jsx-runtime-tc70JA_2.mjs";
|
|
3
3
|
import { Search as u } from "lucide-react";
|
|
4
|
-
import * as
|
|
4
|
+
import * as d from "react";
|
|
5
5
|
import { Button as x } from "./button.mjs";
|
|
6
6
|
import { CommandDialog as h } from "./command.mjs";
|
|
7
|
-
import { c as
|
|
8
|
-
function
|
|
9
|
-
const [
|
|
10
|
-
(
|
|
7
|
+
import { c as i } from "./utils-B6yFEsav.mjs";
|
|
8
|
+
function N({ children: m, open: l, onOpenChange: t }) {
|
|
9
|
+
const [o, f] = d.useState(!1), r = l !== void 0, c = r ? l : o, a = d.useCallback(
|
|
10
|
+
(s) => {
|
|
11
11
|
let e;
|
|
12
|
-
typeof
|
|
12
|
+
typeof s == "function" ? e = s(c) : e = s, r ? t?.(e) : f(e);
|
|
13
13
|
},
|
|
14
|
-
[
|
|
14
|
+
[r, c, t]
|
|
15
15
|
);
|
|
16
|
-
return
|
|
17
|
-
const
|
|
18
|
-
e.key === "k" && (e.metaKey || e.ctrlKey) && (e.preventDefault(),
|
|
16
|
+
return d.useEffect(() => {
|
|
17
|
+
const s = (e) => {
|
|
18
|
+
e.key === "k" && (e.metaKey || e.ctrlKey) && (e.preventDefault(), a((p) => !p));
|
|
19
19
|
};
|
|
20
|
-
return document.addEventListener("keydown",
|
|
21
|
-
}, [
|
|
20
|
+
return document.addEventListener("keydown", s), () => document.removeEventListener("keydown", s);
|
|
21
|
+
}, [a]), /* @__PURE__ */ n.jsx(h, { open: c, onOpenChange: a, children: m });
|
|
22
22
|
}
|
|
23
|
-
const j =
|
|
24
|
-
({ className:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
23
|
+
const j = d.forwardRef(
|
|
24
|
+
({ className: m, placeholder: l, variant: t = "default", responsive: o = !1, ...f }, r) => {
|
|
25
|
+
const a = l || (t === "compact" ? "Search..." : "Search docs...");
|
|
26
|
+
return /* @__PURE__ */ n.jsxs(
|
|
27
|
+
x,
|
|
28
|
+
{
|
|
29
|
+
variant: "outline",
|
|
30
|
+
className: i(
|
|
31
|
+
"text-muted-foreground relative h-9 text-sm transition-all transition-colors",
|
|
32
|
+
t === "default" ? "w-full justify-start pr-12" : i("w-9 justify-center px-0", o && "2xl:w-48 2xl:justify-start 2xl:px-3 2xl:pr-12"),
|
|
33
|
+
m
|
|
34
|
+
),
|
|
35
|
+
ref: r,
|
|
36
|
+
...f,
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ n.jsxs("span", { className: "inline-flex items-center gap-2", children: [
|
|
39
|
+
/* @__PURE__ */ n.jsx(u, { className: "h-4 w-4 shrink-0" }),
|
|
40
|
+
/* @__PURE__ */ n.jsx("span", { className: i("truncate", t === "compact" && (o ? "hidden 2xl:inline" : "hidden")), children: a })
|
|
41
|
+
] }),
|
|
42
|
+
/* @__PURE__ */ n.jsxs(
|
|
43
|
+
"kbd",
|
|
44
|
+
{
|
|
45
|
+
className: i(
|
|
46
|
+
"bg-muted pointer-events-none absolute top-1.5 right-1.5 hidden h-6 items-center gap-1 rounded border px-1.5 font-mono text-[10px] font-medium opacity-100 select-none",
|
|
47
|
+
t === "default" && "sm:flex",
|
|
48
|
+
t === "compact" && o && "2xl:flex"
|
|
49
|
+
),
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ n.jsx("span", { className: "text-xs", children: "⌘" }),
|
|
52
|
+
"K"
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
47
60
|
);
|
|
48
61
|
j.displayName = "SearchTrigger";
|
|
49
62
|
export {
|
|
50
|
-
|
|
63
|
+
N as Search,
|
|
51
64
|
j as SearchTrigger
|
|
52
65
|
};
|
package/package.json
CHANGED
package/src/search.tsx
CHANGED
|
@@ -59,7 +59,10 @@ export function Search({ children, open: customOpen, onOpenChange }: SearchProps
|
|
|
59
59
|
export interface SearchTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, SearchTriggerBaseProps {}
|
|
60
60
|
|
|
61
61
|
export const SearchTrigger = React.forwardRef<HTMLButtonElement, SearchTriggerProps>(
|
|
62
|
-
({ className, placeholder = '
|
|
62
|
+
({ className, placeholder, variant = 'default', responsive = false, ...props }, ref) => {
|
|
63
|
+
const defaultPlaceholder = variant === 'compact' ? 'Search...' : 'Search docs...';
|
|
64
|
+
const activePlaceholder = placeholder || defaultPlaceholder;
|
|
65
|
+
|
|
63
66
|
return (
|
|
64
67
|
<Button
|
|
65
68
|
variant="outline"
|
|
@@ -67,7 +70,7 @@ export const SearchTrigger = React.forwardRef<HTMLButtonElement, SearchTriggerPr
|
|
|
67
70
|
'text-muted-foreground relative h-9 text-sm transition-all transition-colors',
|
|
68
71
|
variant === 'default'
|
|
69
72
|
? 'w-full justify-start pr-12'
|
|
70
|
-
: 'w-9 justify-center px-0
|
|
73
|
+
: cn('w-9 justify-center px-0', responsive && '2xl:w-48 2xl:justify-start 2xl:px-3 2xl:pr-12'),
|
|
71
74
|
className,
|
|
72
75
|
)}
|
|
73
76
|
ref={ref}
|
|
@@ -75,9 +78,17 @@ export const SearchTrigger = React.forwardRef<HTMLButtonElement, SearchTriggerPr
|
|
|
75
78
|
>
|
|
76
79
|
<span className="inline-flex items-center gap-2">
|
|
77
80
|
<SearchIcon className="h-4 w-4 shrink-0" />
|
|
78
|
-
<span className={cn('truncate', variant === 'compact' && 'hidden
|
|
81
|
+
<span className={cn('truncate', variant === 'compact' && (responsive ? 'hidden 2xl:inline' : 'hidden'))}>
|
|
82
|
+
{activePlaceholder}
|
|
83
|
+
</span>
|
|
79
84
|
</span>
|
|
80
|
-
<kbd
|
|
85
|
+
<kbd
|
|
86
|
+
className={cn(
|
|
87
|
+
'bg-muted pointer-events-none absolute top-1.5 right-1.5 hidden h-6 items-center gap-1 rounded border px-1.5 font-mono text-[10px] font-medium opacity-100 select-none',
|
|
88
|
+
variant === 'default' && 'sm:flex',
|
|
89
|
+
variant === 'compact' && responsive && '2xl:flex',
|
|
90
|
+
)}
|
|
91
|
+
>
|
|
81
92
|
<span className="text-xs">⌘</span>K
|
|
82
93
|
</kbd>
|
|
83
94
|
</Button>
|