@keystone-sites/marketing-design-system 1.0.16 → 1.0.17

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.
@@ -8,8 +8,12 @@
8
8
  import { useEffect, useMemo, useState } from "react";
9
9
  import { fetchGraderGroup, type GraderSearchGroup, type GraderSuggestion } from "./grader";
10
10
 
11
- /** Keystroke settle time before a request goes out. */
12
- const DEBOUNCE_MS = 200;
11
+ /** Keystroke settle time before a request goes out: long enough that a
12
+ * name typed at speed is one or two searches, not one per letter. */
13
+ const DEBOUNCE_MS = 350;
14
+ /** Letters before a search is worth asking for — a single one matches
15
+ * everything and nothing. */
16
+ const MIN_QUERY = 2;
13
17
  /** Rows offered per group. */
14
18
  const MAX: Record<GraderSearchGroup, number> = { places: 5, web: 3 };
15
19
  const GROUPS: GraderSearchGroup[] = ["places", "web"];
@@ -88,9 +92,11 @@ function state(
88
92
  }
89
93
 
90
94
  /** `enabled` false parks the search (no fetch, `idle`) — the island uses
91
- * it once a business is chosen, so the chosen name is never looked up. */
95
+ * it once a business is chosen, so the chosen name is never looked up. A
96
+ * query shorter than `MIN_QUERY` is idle too. */
92
97
  export function useGraderSearch(query: string, enabled = true): GraderSearchState {
93
- const q = enabled ? query.trim() : "";
98
+ const trimmed = query.trim();
99
+ const q = enabled && trimmed.length >= MIN_QUERY ? trimmed : "";
94
100
  const [answer, setAnswer] = useState<Answer>(EMPTY_ANSWER);
95
101
 
96
102
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keystone-sites/marketing-design-system",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Keystone's marketing design system: tokens, the tick grid, type, primitives, site chrome, and the landing kit. Source-shipped CSS and TSX for Next.js consumers.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {