qt-ui-kit 1.0.105 → 1.0.107
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/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +47 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -34
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +3 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -16864,30 +16864,67 @@ function Search({
|
|
|
16864
16864
|
}
|
|
16865
16865
|
|
|
16866
16866
|
// src/components/organisms/search_bar/search_bar.tsx
|
|
16867
|
-
import {
|
|
16867
|
+
import {
|
|
16868
|
+
memo,
|
|
16869
|
+
useEffect as useEffect3,
|
|
16870
|
+
useMemo,
|
|
16871
|
+
useRef,
|
|
16872
|
+
useState as useState5,
|
|
16873
|
+
useCallback
|
|
16874
|
+
} from "react";
|
|
16868
16875
|
import { jsx as jsx40, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
16876
|
+
var ResultsList = memo(function ResultsList2({
|
|
16877
|
+
results
|
|
16878
|
+
}) {
|
|
16879
|
+
if (!results) return null;
|
|
16880
|
+
const totalCount = useMemo(
|
|
16881
|
+
() => results.reduce((acc, r) => acc + r.count, 0),
|
|
16882
|
+
[results]
|
|
16883
|
+
);
|
|
16884
|
+
return /* @__PURE__ */ jsxs29("div", { className: "text-sm", children: [
|
|
16885
|
+
/* @__PURE__ */ jsxs29("p", { className: "text-gray-700 font-medium", children: [
|
|
16886
|
+
"Search results",
|
|
16887
|
+
totalCount > 0 ? ` (${totalCount})` : "",
|
|
16888
|
+
":"
|
|
16889
|
+
] }),
|
|
16890
|
+
/* @__PURE__ */ jsx40("div", { className: "flex flex-wrap gap-2 mt-2", children: results.map((r) => /* @__PURE__ */ jsxs29(
|
|
16891
|
+
"span",
|
|
16892
|
+
{
|
|
16893
|
+
className: "px-3 py-1 rounded-full bg-gray-100 text-gray-700",
|
|
16894
|
+
children: [
|
|
16895
|
+
r.label,
|
|
16896
|
+
r.count > 0 ? ` (${r.count})` : ""
|
|
16897
|
+
]
|
|
16898
|
+
},
|
|
16899
|
+
r.label
|
|
16900
|
+
)) })
|
|
16901
|
+
] });
|
|
16902
|
+
});
|
|
16869
16903
|
function SearchBar({
|
|
16870
16904
|
loading,
|
|
16871
16905
|
results,
|
|
16872
16906
|
initialText,
|
|
16873
|
-
onUpdate
|
|
16907
|
+
onUpdate,
|
|
16908
|
+
debounceMs = 250
|
|
16874
16909
|
}) {
|
|
16875
|
-
const [query, setQuery] = useState5("");
|
|
16910
|
+
const [query, setQuery] = useState5(initialText ?? "");
|
|
16911
|
+
const onUpdateRef = useRef(onUpdate);
|
|
16876
16912
|
useEffect3(() => {
|
|
16877
|
-
|
|
16878
|
-
|
|
16879
|
-
}
|
|
16880
|
-
onUpdate(query);
|
|
16881
|
-
}, [query]);
|
|
16913
|
+
onUpdateRef.current = onUpdate;
|
|
16914
|
+
}, [onUpdate]);
|
|
16882
16915
|
useEffect3(() => {
|
|
16883
|
-
if (initialText) {
|
|
16916
|
+
if (initialText !== void 0) {
|
|
16884
16917
|
setQuery(initialText);
|
|
16885
16918
|
}
|
|
16886
|
-
}, []);
|
|
16887
|
-
|
|
16888
|
-
|
|
16889
|
-
|
|
16890
|
-
|
|
16919
|
+
}, [initialText]);
|
|
16920
|
+
useEffect3(() => {
|
|
16921
|
+
if (!onUpdateRef.current) return;
|
|
16922
|
+
const id = window.setTimeout(() => {
|
|
16923
|
+
onUpdateRef.current?.(query);
|
|
16924
|
+
}, Math.max(0, debounceMs));
|
|
16925
|
+
return () => window.clearTimeout(id);
|
|
16926
|
+
}, [query, debounceMs]);
|
|
16927
|
+
const clearQuery = useCallback(() => setQuery(""), []);
|
|
16891
16928
|
return /* @__PURE__ */ jsxs29("div", { className: "w-full space-y-3", children: [
|
|
16892
16929
|
/* @__PURE__ */ jsxs29("div", { className: "flex items-center px-4 py-2 rounded-full bg-gray-100 gap-2 text-gray-900", children: [
|
|
16893
16930
|
loading ? /* @__PURE__ */ jsx40(Loading, {}) : /* @__PURE__ */ jsx40(Search, {}),
|
|
@@ -16898,29 +16935,13 @@ function SearchBar({
|
|
|
16898
16935
|
className: "flex-1 bg-transparent outline-none placeholder:text-gray-400",
|
|
16899
16936
|
placeholder: "Search your filtered queue",
|
|
16900
16937
|
value: query,
|
|
16901
|
-
onChange: (e) => setQuery(e.
|
|
16938
|
+
onChange: (e) => setQuery(e.currentTarget.value),
|
|
16939
|
+
"aria-label": "Search"
|
|
16902
16940
|
}
|
|
16903
16941
|
),
|
|
16904
|
-
query && /* @__PURE__ */ jsx40("button", { onClick: clearQuery, children: /* @__PURE__ */ jsx40(CircleX, {}) })
|
|
16942
|
+
query && /* @__PURE__ */ jsx40("button", { onClick: clearQuery, "aria-label": "Clear search", className: "shrink-0", children: /* @__PURE__ */ jsx40(CircleX, {}) })
|
|
16905
16943
|
] }),
|
|
16906
|
-
|
|
16907
|
-
/* @__PURE__ */ jsxs29("p", { className: "text-gray-700 font-medium", children: [
|
|
16908
|
-
"Search results",
|
|
16909
|
-
totalCount > 0 ? ` (${totalCount})` : "",
|
|
16910
|
-
":"
|
|
16911
|
-
] }),
|
|
16912
|
-
/* @__PURE__ */ jsx40("div", { className: "flex flex-wrap gap-2 mt-2", children: results.map((r) => /* @__PURE__ */ jsxs29(
|
|
16913
|
-
"span",
|
|
16914
|
-
{
|
|
16915
|
-
className: "px-3 py-1 rounded-full bg-gray-100 text-gray-700",
|
|
16916
|
-
children: [
|
|
16917
|
-
r.label,
|
|
16918
|
-
r.count > 0 ? ` (${r.count})` : ""
|
|
16919
|
-
]
|
|
16920
|
-
},
|
|
16921
|
-
r.label
|
|
16922
|
-
)) })
|
|
16923
|
-
] })
|
|
16944
|
+
/* @__PURE__ */ jsx40(ResultsList, { results })
|
|
16924
16945
|
] });
|
|
16925
16946
|
}
|
|
16926
16947
|
|