qt-ui-kit 1.0.106 → 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 CHANGED
@@ -162,8 +162,10 @@ type Props$2 = {
162
162
  results?: SearchResult[];
163
163
  initialText?: string;
164
164
  onUpdate?: (query: string) => void;
165
+ /** Optional debounce for onUpdate calls (ms). Defaults to 250ms. */
166
+ debounceMs?: number;
165
167
  };
166
- declare function SearchBar({ loading, results, initialText, onUpdate, }: Props$2): react_jsx_runtime.JSX.Element;
168
+ declare function SearchBar({ loading, results, initialText, onUpdate, debounceMs, }: Props$2): react_jsx_runtime.JSX.Element;
167
169
 
168
170
  type FilterButtonKey = "fires" | "unread" | "done" | "more" | IntegrationService;
169
171
  type NavButtonConfig = {
package/dist/index.d.ts CHANGED
@@ -162,8 +162,10 @@ type Props$2 = {
162
162
  results?: SearchResult[];
163
163
  initialText?: string;
164
164
  onUpdate?: (query: string) => void;
165
+ /** Optional debounce for onUpdate calls (ms). Defaults to 250ms. */
166
+ debounceMs?: number;
165
167
  };
166
- declare function SearchBar({ loading, results, initialText, onUpdate, }: Props$2): react_jsx_runtime.JSX.Element;
168
+ declare function SearchBar({ loading, results, initialText, onUpdate, debounceMs, }: Props$2): react_jsx_runtime.JSX.Element;
167
169
 
168
170
  type FilterButtonKey = "fires" | "unread" | "done" | "more" | IntegrationService;
169
171
  type NavButtonConfig = {
package/dist/index.js CHANGED
@@ -16894,28 +16894,58 @@ function Search({
16894
16894
  // src/components/organisms/search_bar/search_bar.tsx
16895
16895
  var import_react5 = require("react");
16896
16896
  var import_jsx_runtime40 = require("react/jsx-runtime");
16897
+ var ResultsList = (0, import_react5.memo)(function ResultsList2({
16898
+ results
16899
+ }) {
16900
+ if (!results) return null;
16901
+ const totalCount = (0, import_react5.useMemo)(
16902
+ () => results.reduce((acc, r) => acc + r.count, 0),
16903
+ [results]
16904
+ );
16905
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "text-sm", children: [
16906
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "text-gray-700 font-medium", children: [
16907
+ "Search results",
16908
+ totalCount > 0 ? ` (${totalCount})` : "",
16909
+ ":"
16910
+ ] }),
16911
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "flex flex-wrap gap-2 mt-2", children: results.map((r) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
16912
+ "span",
16913
+ {
16914
+ className: "px-3 py-1 rounded-full bg-gray-100 text-gray-700",
16915
+ children: [
16916
+ r.label,
16917
+ r.count > 0 ? ` (${r.count})` : ""
16918
+ ]
16919
+ },
16920
+ r.label
16921
+ )) })
16922
+ ] });
16923
+ });
16897
16924
  function SearchBar({
16898
16925
  loading,
16899
16926
  results,
16900
16927
  initialText,
16901
- onUpdate
16928
+ onUpdate,
16929
+ debounceMs = 250
16902
16930
  }) {
16903
- const [query, setQuery] = (0, import_react5.useState)("");
16931
+ const [query, setQuery] = (0, import_react5.useState)(initialText ?? "");
16932
+ const onUpdateRef = (0, import_react5.useRef)(onUpdate);
16904
16933
  (0, import_react5.useEffect)(() => {
16905
- if (!onUpdate) {
16906
- return;
16907
- }
16908
- onUpdate(query);
16909
- }, [query]);
16934
+ onUpdateRef.current = onUpdate;
16935
+ }, [onUpdate]);
16910
16936
  (0, import_react5.useEffect)(() => {
16911
- if (initialText) {
16937
+ if (initialText !== void 0) {
16912
16938
  setQuery(initialText);
16913
16939
  }
16914
16940
  }, [initialText]);
16915
- const clearQuery = () => {
16916
- setQuery("");
16917
- };
16918
- const totalCount = results?.reduce((acc, r) => acc + r.count, 0) ?? 0;
16941
+ (0, import_react5.useEffect)(() => {
16942
+ if (!onUpdateRef.current) return;
16943
+ const id = window.setTimeout(() => {
16944
+ onUpdateRef.current?.(query);
16945
+ }, Math.max(0, debounceMs));
16946
+ return () => window.clearTimeout(id);
16947
+ }, [query, debounceMs]);
16948
+ const clearQuery = (0, import_react5.useCallback)(() => setQuery(""), []);
16919
16949
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "w-full space-y-3", children: [
16920
16950
  /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex items-center px-4 py-2 rounded-full bg-gray-100 gap-2 text-gray-900", children: [
16921
16951
  loading ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Loading, {}) : /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Search, {}),
@@ -16926,29 +16956,13 @@ function SearchBar({
16926
16956
  className: "flex-1 bg-transparent outline-none placeholder:text-gray-400",
16927
16957
  placeholder: "Search your filtered queue",
16928
16958
  value: query,
16929
- onChange: (e) => setQuery(e.target.value)
16959
+ onChange: (e) => setQuery(e.currentTarget.value),
16960
+ "aria-label": "Search"
16930
16961
  }
16931
16962
  ),
16932
- query && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("button", { onClick: clearQuery, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CircleX, {}) })
16963
+ query && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("button", { onClick: clearQuery, "aria-label": "Clear search", className: "shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CircleX, {}) })
16933
16964
  ] }),
16934
- results && /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "text-sm", children: [
16935
- /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "text-gray-700 font-medium", children: [
16936
- "Search results",
16937
- totalCount > 0 ? ` (${totalCount})` : "",
16938
- ":"
16939
- ] }),
16940
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "flex flex-wrap gap-2 mt-2", children: results.map((r) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
16941
- "span",
16942
- {
16943
- className: "px-3 py-1 rounded-full bg-gray-100 text-gray-700",
16944
- children: [
16945
- r.label,
16946
- r.count > 0 ? ` (${r.count})` : ""
16947
- ]
16948
- },
16949
- r.label
16950
- )) })
16951
- ] })
16965
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ResultsList, { results })
16952
16966
  ] });
16953
16967
  }
16954
16968