ab-nextjs-components 0.7.1 → 0.8.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,28 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.8.0](https://github.com/abraham-ukachi/ab-nextjs-components/compare/v0.7.1...v0.8.0) (2026-11-22)
6
+
7
+ ### ⚠ BREAKING CHANGES
8
+
9
+ * **`shortcut={false}` no longer silences the hotkey listener.** `shortcut` is now display-only (the ⌘K / Ctrl+K cap and `aria-keyshortcuts`). To stop this trigger from registering a listener, pass `hotkey={false}`.
10
+ **Migration:** replace `shortcut={false}` with `hotkey={false}` when the intent is "do not listen". To show the cap while the app shell owns the single `useAbHotkey('mod+k')`, use `shortcut hotkey={false}`.
11
+ * **`mod+k` and `aria-keyshortcuts` are platform-strict.** The listener matches Meta+K on Apple and Control+K elsewhere (no longer both on every platform). `aria-keyshortcuts` names only that platform's pair; SSR announces `Control+K`, and Apple clients switch to `Meta+K` after hydration.
12
+ **Migration:** if a test or custom listener expected both Meta and Control to open the drawer on every platform, switch it to the platform modifier (`Meta+K` on Apple, `Control+K` elsewhere). Prefer hooks' `useAbHotkey('mod+k')` and `useAbHotkeyLabel`, which already do this.
13
+
14
+ ### Features
15
+
16
+ * ⬆️ **Requires `ab-nextjs-hooks@^0.1.9`** (peer and dev) for `useAbHotkey` (G10). `ab-nextjs-hooks` is no longer an optional peer (`peerDependenciesMeta`), because `AbSearchTrigger` imports it unconditionally.
17
+ * ⌨️ **`AbSearchTrigger` splits `shortcut` from `hotkey` (D49).** `hotkey` registers the ⌘K / Ctrl+K listener (hooks' `useAbHotkey`, default on with `onOpen`); `shortcut` only shows the key cap and `aria-keyshortcuts` (default: whatever `hotkey` does). An app shell with one `useAbHotkey('mod+k')` renders its triggers with `shortcut hotkey={false}`. Two listening triggers open once per press. `isAbApplePlatform` is re-exported from hooks.
18
+ * ⏳ **AbSearchDrawer async states:** an async `search()` sets `aria-busy` on the results and listbox and shows "Searching…" (`labels.loading`); a sync one never flashes it. A failure is no longer shown as "No results": an offline panel (`offlineTitle` / `offlineHint`) when the search throws or rejects with the new `AbSearchOfflineError` (or `{ offline: true }`) or `navigator.onLine` is false, else an error panel (`errorTitle` / `errorHint`), both with a `retry` button. Offline retries by itself on `online`. New exports: `AbSearchOfflineError`, `isAbSearchOffline`, `AbSearchDrawerStatus`.
19
+ * 🏷️ **Result badge:** `AbSearchDrawerItem.badge` (for example `"EN"` on an English-fallback page) with an optional `badgeLabel` that screen readers hear instead.
20
+
21
+ ### Bug Fixes
22
+
23
+ * 🐛 **Unique search ids (G60, part 1):** groups and options are keyed and numbered by position, not by raw `g.id` / `item.id`, so repeated ids no longer duplicate option ids or break ↑/↓.
24
+ * 🐛 **Hash returnFocus guard:** choosing a `#hash` result closes the drawer without refocusing the opener, so `#main-content` keeps the section that was just scrolled to (`hashReturnFocus` opts back in; Escape and ✕ still return focus). `AbDrawer` takes `restoreFocus` (`false` or a function read at close time). New export: `hasAbHashTarget`.
25
+ * ♿ **AbSearchTrigger touch audit:** under `pointer: coarse`, every trigger except `size="sm"` gets an invisible, centred hit area of at least 44×44px (the 40px pill, the 36px tablet field, AbAppBar's compact icon and pill). `size="sm"` keeps its 46px band and is now at least 44px wide for short labels. Nothing changes visually.
26
+
5
27
  ## [0.7.1](https://github.com/abraham-ukachi/ab-nextjs-components/compare/v0.7.0...v0.7.1) (2026-11-12)
6
28
 
7
29
  * Normalize the changelog format and backfill missing entries.
package/README.md CHANGED
@@ -86,7 +86,7 @@ New subpaths for the docs / PWA shell. All links go through **`AbLinkProvider`**
86
86
  * 🎯 **Active item (0.5.0):** `activeMatch` picks the rule: `'best'` (default) lights only the deepest matching item, so `/docs` and `/docs/x` never both light on `/docs/x`; `'prefix'` lights every parent too (the pre-0.5.0 look); `'exact'` lights only an equal href. An item's `exact: true` (never a parent) or `exact: false` (parent allowed) overrides it. Query strings, hashes and trailing slashes are ignored. AbNavDrawer takes the same `activeMatch` and `locales`. The helpers `getAbActiveHrefs`, `matchAbHref` and `normalizeAbHref` and the `AbActiveMatch` type are exported.
87
87
  * **`<AbNavbar>` v2 (G41)**: `items` of `{ kind: 'link', href, icon, label }` or `{ kind: 'button', id, icon, label, onSelect, expanded?, controls? }`, filled active icon, `aria-current`, safe-area padding.
88
88
  * **`<AbAppBar>` (G43)**: `brand`, `search`, `nav=[{ href, label }]`, `activeHref`, `actions`, `leading`, sticky with the theme hairline. Below **1180px** the nav moves into a "More" `AbMenu` (G26). It closes on Escape and outside click. With JS off the nav stays inline.
89
- * **`<AbSearchTrigger>` + `<AbKbd>` (G44)**: shows ⌘K on Apple and Ctrl K elsewhere, sets `aria-keyshortcuts="Meta+K Control+K"`, calls `onOpen` (button) or falls back to `href` (link). `comingSoon` makes it `aria-disabled`.
89
+ * **`<AbSearchTrigger>` + `<AbKbd>` (G44)**: shows ⌘K on Apple and Ctrl K elsewhere, sets `aria-keyshortcuts` (`Meta+K` on Apple, `Control+K` elsewhere since 0.8.0), calls `onOpen` (button) or falls back to `href` (link). `comingSoon` makes it `aria-disabled`.
90
90
  * **`<AbCard>` / `<AbPackageCard>` (G45)**: one link per card (the title, stretched over the card). Hover lifts 2px on laptop and up only, never under `prefers-reduced-motion`.
91
91
  * **`<AbToc>` (G46)**: plain `#id` links, `aria-current="location"`. Pair with `useAbScrollSpy` / `scrollToAbSection` from `ab-nextjs-hooks@0.1.7`.
92
92
  * **`<AbBalloon>`** is now a real tooltip: `role="tooltip"`, `aria-describedby` on the trigger, shows on focus, after 300ms on hover, and hides on Escape.
@@ -97,6 +97,25 @@ New subpaths for the docs / PWA shell. All links go through **`AbLinkProvider`**
97
97
  registerAbIcons({ code })
98
98
  ```
99
99
 
100
+ ### Search drawer & trigger (0.8.0) 🔎
101
+
102
+ Needs **`ab-nextjs-hooks@^0.1.9`** (`useAbHotkey`).
103
+
104
+ * ⌨️ **One ⌘K listener (D49):** on `<AbSearchTrigger>`, `hotkey` now only **registers** the listener (through `useAbHotkey`), and `shortcut` only **shows** the key cap and `aria-keyshortcuts`. `shortcut` is no longer an alias of `hotkey`. When the app shell owns the single listener, render every trigger with `shortcut hotkey={false}`:
105
+ ```tsx
106
+ 'use client'
107
+ import { useAbHotkey } from 'ab-nextjs-hooks/useAbHotkey'
108
+
109
+ useAbHotkey('mod+k', () => setOpen('search')) // ⌨️ once, in the shell (`mod+k` fires in inputs by default)
110
+ <AbSearchTrigger variant="field" onOpen={() => setOpen('search')} shortcut hotkey={false} /> // 👀 the cap only
111
+ ```
112
+ Without either prop nothing changes: a trigger with `onOpen` listens and shows the cap. `mod+k` is ⌘K on Apple and Ctrl+K elsewhere (no longer both on every platform), and two listening triggers no longer open twice on one press.
113
+ * ⏳ **`<AbSearchDrawer>` async states:** while an async `search()` is pending, the results get `aria-busy` and "Searching…" (labels `loading`). A failure shows an offline panel (`offlineTitle`, `offlineHint`) or an error panel (`errorTitle`, `errorHint`) with a `retry` button, never "No results". Offline means the search threw or rejected with `AbSearchOfflineError` (or an error with `offline: true`), or `navigator.onLine` is false. An offline search retries by itself on the `online` event. `isAbSearchOffline` and the `AbSearchDrawerStatus` type are exported.
114
+ * 🏷️ **Result badge:** `AbSearchDrawerItem` takes `badge` (for example `"EN"` on an English-fallback page) and `badgeLabel` (what screen readers hear instead, for example "English only").
115
+ * 🧹 **Unique ids (G60):** groups and options are keyed and numbered by position, so repeated group or item ids no longer collide.
116
+ * ↩️ **Hash guard:** choosing a `#hash` result closes the drawer **without** sending focus back to the opener, so the section that was just scrolled into view in `#main-content` stays put (`hashReturnFocus` opts back in). Escape and ✕ still return focus. Under it, `<AbDrawer restoreFocus>` takes `false` or a function that is read when the drawer closes. `hasAbHashTarget(href)` is exported.
117
+ * 👆 **Touch audit:** under `pointer: coarse` every trigger has an invisible hit area of at least 44×44px: the 40px pill, the 36px tablet `variant="field"`, AbAppBar's compact 40px icon and 34px pill, and `size="sm"` (now at least 44px wide for short labels). Nothing changes visually.
118
+
100
119
  ### 404 gaps (unreleased) 🚧
101
120
 
102
121
  * **`<AbErrorHero>`** (`ab-nextjs-components/ab-error-hero`, also in the barrel): the 404 / error hero from the 404 mocks. A big gradient `code` (default `"404"`) over a faded dot grid, a tilted `badge` tile (default `<AbIcon name="link_off" />`, needs ab-nextjs-icons ^0.2.6 and `registerAbIcons({ link_off })`; pass `badge={null}` to hide it), the `title` (h1, the code is read once), `message`, an optional `hint` row and an `actions` slot. Server-safe, no motion.
@@ -100,6 +100,9 @@ export interface AbDrawerProps {
100
100
  handleLabels?: { expand: string; collapse: string }; // ♿ the handle button (default "Expand" / "Collapse")
101
101
  centerIn?: 'main'; // 💻 bottom only, 768px and up: centred in the main pane, min(640px, main width) wide, ≤ 70% tall
102
102
  returnFocus?: string; // ↩️ selector focused on close when there was no focusable opener (an edge swipe); default AB_DRAWER_RETURN_FOCUS (the header / brand logo)
103
+ /** ↩️ 0.8.0: send focus back on close at all (default true). A function is read AT close time, e.g. AbSearchDrawer
104
+ * skips it after a `#hash` result so the opener doesn't pull `#main-content` away from the new section. */
105
+ restoreFocus?: boolean | (() => boolean);
103
106
  closeIcon?: ReactNode; // ✕ the close glyph (default a text ✕)
104
107
  headerStart?: ReactNode; // 🏷️ header content that does NOT label the dialog (e.g. a logo; then use `aria-label`). `title` wins
105
108
  className?: string; // 🏷️
@@ -175,6 +178,8 @@ const reducedMotion = (): boolean => typeof window !== 'undefined' && typeof win
175
178
  const AbDrawer = (props: AbDrawerProps): ReactElement => {
176
179
  const { open, onClose, scope = 'app', side = 'bottom', title, id, children, footer, size, modal = true, closeLabel = 'Close', noJsFallback = true, initialFocus = 'first', className } = props;
177
180
  const { tier, swipe = false, snapPoints = false, defaultSnap = 'partial', onSnapChange, handleLabels, centerIn, returnFocus, closeIcon, headerStart, fullOnly = false } = props; // 🆕 0.2.0
181
+ const restore = useRef(props.restoreFocus); // ↩️ 0.8.0: the latest restoreFocus, read by the close cleanup (not a dep)
182
+ useEffect(() => { restore.current = props.restoreFocus; }, [props.restoreFocus]); // 🔁 synced after render
178
183
  const auto = useId().replace(/[^A-Za-z0-9_-]/g, ''); // 🆔 SSR-stable
179
184
  const dialogId = id ?? `ab-drawer-${auto}`; // 🆔
180
185
  const titleId = `${dialogId}-title`; // 🏷️
@@ -242,6 +247,9 @@ const AbDrawer = (props: AbDrawerProps): ReactElement => {
242
247
  (first ?? panel.current).focus({ preventScroll: true });
243
248
  const node = panel.current; // 📌 this open's panel (for the cleanup)
244
249
  return () => {
250
+ // ↩️ 0.8.0: the owner may say "not this time" (a #hash result): leave focus where navigation puts it
251
+ const want = restore.current; // 📖 latest value
252
+ if (want === false || (typeof want === 'function' && !want())) return; // 🙅 no focus return
245
253
  const had = opener.current as HTMLElement | null; // ↩️
246
254
  const usable = had && had !== document.body && had.isConnected ? had : null; // 🤏 a swipe has no opener
247
255
  // ↩️ 0.2.0 fallback: the first VISIBLE match (an app often renders the logo twice, one hidden per breakpoint)
@@ -177,6 +177,8 @@
177
177
  .srText > b { display: block; font: 600 15px/1.3 var(--ab-font-body, 'Inter', inherit); color: var(--ab-color-text, #211a16); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
178
178
  .srText > small { display: block; font: 400 13px/1.35 var(--ab-font-body, 'Inter', inherit); color: var(--ab-color-muted, #6b5b50); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
179
179
  .srMeta { flex: none; font: 400 12px/1 var(--ab-font-mono, 'Roboto Mono', monospace); color: var(--ab-color-muted, #6b5b50); }
180
+ /* 🏷️ 0.8.0: the per-result badge (e.g. "EN" = English fallback): a small outlined pill, AA muted text, never shrinks */
181
+ .srBadge { flex: none; display: inline-flex; align-items: center; box-sizing: border-box; block-size: 20px; padding: 0 6px; border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-pill, 999px); font: 700 11px/1 var(--ab-font-body, 'Inter', inherit); letter-spacing: 0.04em; color: var(--ab-color-muted, #6b5b50); }
180
182
  .mark { background: none; color: var(--ab-color-accent-text, #8b6340); font-weight: 700; } /* 🖍️ the matched part */
181
183
  .nores { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 24px; }
182
184
  .nores > .pkgIc { inline-size: 56px; block-size: 56px; border-radius: 16px; }
@@ -31,7 +31,8 @@
31
31
  *
32
32
  * Example usage:
33
33
  * 1+|> const [open, setOpen] = useState(false)
34
- * -|> <AbSearchTrigger variant="field" label="Search…" onOpen={() => setOpen(true)} hotkey={false} />
34
+ * -|> useAbHotkey('mod+k', () => setOpen(true)) // ⌨️ 0.8.0: ONE listener (ab-nextjs-hooks/useAbHotkey); fires in inputs by default
35
+ * -|> <AbSearchTrigger variant="field" label="Search…" onOpen={() => setOpen(true)} shortcut hotkey={false} />
35
36
  * -|> <AbSearchDrawer open={open} onClose={() => setOpen(false)} search={(q) => index.query(q)} />
36
37
  */
37
38
 
@@ -65,6 +66,10 @@ export interface AbSearchDrawerItem {
65
66
  description?: string; // 📝 one line (ellipsis)
66
67
  meta?: string; // 🏷️ mono, e.g. "v0.2.x"
67
68
  icon?: string; // 🔣 the 32px tile's AbIcons name
69
+ /** 🏷️ 0.8.0: a short visible badge after the text, e.g. "EN" on a page that falls back to English */
70
+ badge?: string;
71
+ /** ♿ 0.8.0: what the badge means for screen readers (e.g. "English only"); without it the badge text is read */
72
+ badgeLabel?: string;
68
73
  }
69
74
  /** 📦 results grouped by package */
70
75
  export interface AbSearchDrawerGroup { id: string; label: string; meta?: string; items: readonly AbSearchDrawerItem[] } // 🏷️ "Components" + "ab-nextjs-components"
@@ -82,6 +87,29 @@ export interface AbSearchDrawerLabels {
82
87
  noResultsFor?: (q: string) => ReactNode; // No results for “q”
83
88
  hint?: ReactNode; // the line under it
84
89
  didYouMean?: string; // "Did you mean"
90
+ // ⏳ 0.8.0: async states (a failed search() is no longer shown as "No results")
91
+ loading?: string; // "Searching…" (shown + announced while an async search() is pending)
92
+ offlineTitle?: string; // "You're offline"
93
+ offlineHint?: ReactNode; // "Search needs a connection the first time. Reconnect and try again."
94
+ errorTitle?: string; // "Search isn't available right now"
95
+ errorHint?: ReactNode; // "Something went wrong while searching. Try again in a moment."
96
+ retry?: string; // "Try again"
97
+ }
98
+
99
+ /** ⏳ 0.8.0: where a search stands — 'idle' (under 2 characters), 'loading', 'done', 'offline' or 'error' */
100
+ export type AbSearchDrawerStatus = 'idle' | 'loading' | 'done' | 'offline' | 'error';
101
+
102
+ /** 📴 0.8.0: throw (or reject with) this from `search()` when the index can't be fetched offline */
103
+ export class AbSearchOfflineError extends Error {
104
+ constructor(message = 'Search is offline') { super(message); this.name = 'AbSearchOfflineError'; } // 🏷️ the name is what we check
105
+ }
106
+
107
+ /** 📴 0.8.0: isAbSearchOffline — is this search failure "offline"? An AbSearchOfflineError (by name, so it survives
108
+ * bundling twice), an error with `offline: true`, or any failure while `navigator.onLine` is false. */
109
+ export function isAbSearchOffline(error: unknown): boolean {
110
+ const e = error as { name?: unknown; offline?: unknown } | null | undefined; // 🔍 duck-typed
111
+ if (e && (e.name === 'AbSearchOfflineError' || e.offline === true)) return true; // 📴 said so
112
+ return typeof navigator !== 'undefined' && navigator.onLine === false; // 🌐 the browser says so
85
113
  }
86
114
 
87
115
  /** ⚙️ props */
@@ -97,6 +125,9 @@ export interface AbSearchDrawerProps {
97
125
  recentWhen?: 'always' | 'empty'; // 🕘 'always' = above the results (the frames, default); 'empty' = only with no query
98
126
  labels?: AbSearchDrawerLabels; // 🌍
99
127
  returnFocus?: string; // ↩️
128
+ /** ↩️ 0.8.0: after a `#hash` result, still send focus back to the opener (default false: the guard skips it, so the
129
+ * opener never snaps `#main-content` away from the section that was just scrolled to). Escape / ✕ always return focus. */
130
+ hashReturnFocus?: boolean;
100
131
  id?: string; // 🆔
101
132
  className?: string; // 🏷️
102
133
  }
@@ -114,6 +145,12 @@ export function addAbSearchRecent(list: readonly string[], term: string, limit =
114
145
  return [t, ...list.filter((x) => x.toLowerCase() !== t.toLowerCase())].slice(0, limit);
115
146
  }
116
147
 
148
+ /** #️⃣ 0.8.0: hasAbHashTarget — does this href jump to a section (`/docs/x#install`, `#top`)? An empty `#` does not. */
149
+ export function hasAbHashTarget(href: string): boolean {
150
+ const i = href.indexOf('#'); // 🔍 the fragment start
151
+ return i >= 0 && i < href.length - 1; // ✅ a non-empty fragment
152
+ }
153
+
117
154
  /** 🖍️ highlightAbSearch — wrap every case-insensitive match of `q` in `<mark>` (bronze 700 via the kit) */
118
155
  export function highlightAbSearch(text: string, q: string): ReactNode {
119
156
  const needle = q.trim(); if (needle.length < 2) return text;
@@ -132,20 +169,28 @@ export function highlightAbSearch(text: string, q: string): ReactNode {
132
169
  *
133
170
  * - 📱 below 768px: straight to full height (no 70% stop: the keyboard is up); a hard swipe down closes
134
171
  * - 💻 768px and up: centred in the main pane, min(640px, main width), 70% tall; results scroll inside with a 48px fade
135
- * - ⌨️ no shortcut key: open it from the Search tab / the search field (AbSearchTrigger `onOpen` + `hotkey={false}`)
172
+ * - ⌨️ no listener of its own: the app shell owns ONE `useAbHotkey('mod+k')` (hooks 0.1.9, D49) and every
173
+ * AbSearchTrigger shows the cap with `shortcut hotkey={false}` (0.8.0); the Search tab / field open it too
136
174
  * - 🔤 48px input (2px bronze border), autofocused; a 40px clear button keeps focus in the input
137
175
  * - 🕘 up to 4 recent searches (localStorage `ab:search:recent`), saved on Enter or when a result opens; each removable
138
176
  * - 📦 results after a 150ms debounce from 2 characters, grouped by package; matches in a bronze `<mark>`
139
177
  * - ♿ combobox (aria-expanded / -controls / -autocomplete="list" / -activedescendant) + listbox with labelled groups
140
178
  * and options; ↑/↓ wrap across groups, Enter opens the active (else the first) result, Esc clears then closes;
141
179
  * a polite live region says "4 results" / "No results"
180
+ * - ↩️ 0.8.0: choosing a `#hash` result closes WITHOUT refocusing the opener (`hashReturnFocus` to opt back in), so the
181
+ * scroll to the section inside `#main-content` stays put; the app moves focus to the section if it wants
182
+ * - ⏳ 0.8.0: an async `search()` sets `aria-busy` + "Searching…"; a failure shows an offline (AbSearchOfflineError /
183
+ * `navigator.onLine === false`) or error panel with "Try again" — never "No results"; offline retries on `online`
142
184
  */
143
- const AbSearchDrawer = ({ open, onClose, search, suggest, onOpenResult, defaultQuery = '', recentKey = AB_SEARCH_RECENT_KEY, recentLimit = 4, recentWhen = 'always', labels = {}, returnFocus, id, className }: AbSearchDrawerProps): ReactElement => {
185
+ const AbSearchDrawer = ({ open, onClose, search, suggest, onOpenResult, defaultQuery = '', recentKey = AB_SEARCH_RECENT_KEY, recentLimit = 4, recentWhen = 'always', labels = {}, returnFocus, hashReturnFocus = false, id, className }: AbSearchDrawerProps): ReactElement => {
144
186
  const L = {
145
187
  title: 'Search', close: 'Close search', placeholder: 'Search packages, components, hooks…', clear: 'Clear search', recent: 'Recent',
146
188
  remove: (t: string) => `Remove ${t}`, results: (n: number) => `${n} result${n === 1 ? '' : 's'}`, noResults: 'No results',
147
189
  noResultsFor: (q: string) => <>No results for “{q}”</>, didYouMean: 'Did you mean',
148
- hint: <>Check the spelling or try a package name like <code>components</code> or <code>hooks</code>.</>, ...labels,
190
+ hint: <>Check the spelling or try a package name like <code>components</code> or <code>hooks</code>.</>,
191
+ loading: 'Searching…', offlineTitle: 'You’re offline', offlineHint: 'Search needs a connection the first time. Reconnect and try again.', // ⏳ 📴 0.8.0
192
+ errorTitle: 'Search isn’t available right now', errorHint: 'Something went wrong while searching. Try again in a moment.', retry: 'Try again', // 🛑 0.8.0
193
+ ...labels,
149
194
  }; // 🌍
150
195
  const auto = useId().replace(/[^A-Za-z0-9_-]/g, ''); // 🆔
151
196
  const base = id ?? `ab-search-${auto}`;
@@ -157,34 +202,59 @@ const AbSearchDrawer = ({ open, onClose, search, suggest, onOpenResult, defaultQ
157
202
  const [groups, setGroups] = useState<readonly AbSearchDrawerGroup[] | null>(null); // 📦 null = not searched (or < 2 chars)
158
203
  const [active, setActive] = useState(0); // 🎯 index in the flat option list (-1 = none)
159
204
  const [recent, setRecent] = useState<string[]>([]); // 🕘
205
+ const [status, setStatus] = useState<AbSearchDrawerStatus>('idle'); // ⏳ 0.8.0: loading / offline / error
206
+ const [attempt, setAttempt] = useState(0); // 🔁 0.8.0: bumped by "Try again" (and on reconnect) to re-run the search
160
207
  const latest = useRef(search); // 🔁
161
208
  useEffect(() => { latest.current = search; }, [search]);
162
209
 
163
210
  // 🌱 each open: the default query, fresh recents
164
211
  const [wasOpen, setWasOpen] = useState(false);
212
+ // ↩️ 0.8.0 hash guard: set when a #hash result is chosen, read by AbDrawer when it closes, cleared on every open
213
+ const hashNav = useRef(false);
214
+ useEffect(() => { if (open) hashNav.current = false; }, [open]); // 🌱 a fresh open returns focus again
165
215
  if (open !== wasOpen) { setWasOpen(open); if (open) { setQuery(defaultQuery); setRecent(readRecent(recentKey)); } }
166
216
 
167
217
  // ⏱️ 150ms debounce, from 2 characters; stale answers are dropped
168
218
  useEffect(() => {
169
219
  const q = query.trim();
170
- if (!open || q.length < 2) { const t = setTimeout(() => setGroups(null), 0); return () => clearTimeout(t); } // 🫥
220
+ if (!open || q.length < 2) { const t = setTimeout(() => { setGroups(null); setStatus('idle'); }, 0); return () => clearTimeout(t); } // 🫥
171
221
  let live = true;
222
+ // 🧯 0.8.0: a failure is "offline" or "error" (never "No results", and never the previous query's results)
223
+ const fail = (err: unknown) => { if (live) { setGroups(null); setActive(-1); setStatus(isAbSearchOffline(err) ? 'offline' : 'error'); } };
172
224
  const t = setTimeout(() => {
173
- Promise.resolve().then(() => latest.current(q)) // 🧯 a sync throw becomes a rejection too
174
- .then((g) => { if (live) { setGroups(g); setActive(g.some((x) => x.items.length) ? 0 : -1); } })
175
- .catch(() => { if (live) { setGroups([]); setActive(-1); } }); // 🧯 review P2: a failed search shows "no results", never the previous query's results
225
+ let out: ReturnType<AbSearchDrawerProps['search']>; // 📦 sync groups or a promise
226
+ try { out = latest.current(q); } catch (err) { fail(err); return; } // 🧯 a sync throw fails the same way
227
+ // ⏳ 0.8.0: only an async search() shows "Searching…" (aria-busy); a sync one never flashes it
228
+ if (out && typeof (out as PromiseLike<unknown>).then === 'function') setStatus('loading');
229
+ Promise.resolve(out)
230
+ .then((g) => { if (live) { setGroups(g); setActive(g.some((x) => x.items.length) ? 0 : -1); setStatus('done'); } }) // ✅
231
+ .catch(fail); // 📴 / 🛑
176
232
  }, 150);
177
233
  return () => { live = false; clearTimeout(t); };
178
- }, [query, open]);
234
+ }, [query, open, attempt]);
235
+
236
+ // 🌐 0.8.0: offline → back online: retry by itself (the visitor already typed the query)
237
+ useEffect(() => {
238
+ if (status !== 'offline' || typeof window === 'undefined') return; // 🙅 only while offline
239
+ const back = () => setAttempt((n) => n + 1); // 🔁
240
+ window.addEventListener('online', back); // 👂
241
+ return () => window.removeEventListener('online', back); // 🧹
242
+ }, [status]);
179
243
 
180
- const flat = useMemo(() => (groups ?? []).flatMap((g) => g.items), [groups]); // 📋 the option order
181
- const starts = useMemo(() => { const m: Record<string, number> = {}; let n = 0; for (const g of groups ?? []) { m[g.id] = n; n += g.items.length; } return m; }, [groups]); // 🔢 each group's first option index
244
+ // 🧹 G60 (0.8.0): only groups with items are rendered, so the option order, the start offsets and the ids all
245
+ // come from THIS list, by position — never from the raw `g.id`, which apps may repeat (two "components" groups)
246
+ const shown = useMemo(() => (groups ?? []).filter((g) => g.items.length), [groups]); // 📦 rendered groups
247
+ const flat = useMemo(() => shown.flatMap((g) => g.items), [shown]); // 📋 the option order
248
+ const starts = useMemo(() => { const m: number[] = []; let n = 0; for (const g of shown) { m.push(n); n += g.items.length; } return m; }, [shown]); // 🔢 G60: each group's first option index, BY GROUP INDEX
182
249
  const optId = (i: number) => `${base}-opt-${i}`; // 🆔
183
250
  const showRecent = recentKey !== null && recent.length > 0 && (recentWhen === 'always' ? !(groups && flat.length === 0) : query.trim() === ''); // 🕘
184
251
  const expanded = flat.length > 0; // ♿ the listbox has options
185
252
  const saveRecent = (term: string) => { const next = addAbSearchRecent(recent, term, recentLimit); setRecent(next); writeRecent(recentKey, next); }; // 🕘
186
253
  const removeRecent = (term: string) => { const next = recent.filter((x) => x !== term); setRecent(next); writeRecent(recentKey, next); input.current?.focus(); };
187
- const choose = (item: AbSearchDrawerItem) => { saveRecent(query); onOpenResult?.(item); onClose(); }; // 🔗
254
+ const choose = (item: AbSearchDrawerItem) => {
255
+ hashNav.current = !hashReturnFocus && hasAbHashTarget(item.href); // ↩️ 0.8.0: a #section → don't refocus the opener
256
+ saveRecent(query); onOpenResult?.(item); onClose(); // 🔗
257
+ };
188
258
 
189
259
  // ⌨️ the combobox keys (focus stays in the input)
190
260
  const onKey = (e: KeyboardEvent<HTMLInputElement>) => {
@@ -202,13 +272,16 @@ const AbSearchDrawer = ({ open, onClose, search, suggest, onOpenResult, defaultQ
202
272
  }
203
273
  };
204
274
 
205
- const none = groups !== null && flat.length === 0; // 🫥
275
+ const busy = status === 'loading'; // ⏳ 0.8.0
276
+ const failed = status === 'offline' || status === 'error'; // 📴 🛑 0.8.0
277
+ const none = !busy && !failed && groups !== null && flat.length === 0; // 🫥 0.8.0: never while loading / failed
278
+ const retry = () => { setAttempt((n) => n + 1); input.current?.focus(); }; // 🔁 0.8.0: re-run, focus stays in the input
206
279
  const tip = suggest && none ? suggest(query.trim()) : null; // 💡
207
280
  return (
208
281
  <AbDrawer
209
282
  open={open} onClose={onClose} id={id} side="bottom" scope="app" tier="sheet"
210
283
  snapPoints fullOnly centerIn="main" title={L.title} closeLabel={L.close} closeIcon={<AbIcon name="close" size={24} />}
211
- initialFocus="input" returnFocus={returnFocus}
284
+ initialFocus="input" returnFocus={returnFocus} restoreFocus={() => !hashNav.current /* ↩️ 0.8.0 hash guard */}
212
285
  className={clsx('AbSearchDrawer', kit.sheet, kit.searchSheet, className)}
213
286
  >
214
287
  <div className={kit.searchBody}>
@@ -224,7 +297,7 @@ const AbSearchDrawer = ({ open, onClose, search, suggest, onOpenResult, defaultQ
224
297
  {query && <button type="button" className={kit.iconSm} aria-label={L.clear} onClick={() => { setQuery(''); input.current?.focus(); }}><AbIcon name="close" size={20} /></button>}
225
298
  </div>
226
299
  <div className={kit.resWrap}>
227
- <div ref={list} className={kit.results} data-ab-part="search-results">
300
+ <div ref={list} className={kit.results} data-ab-part="search-results" aria-busy={busy || undefined} data-status={status} /* ⏳ 0.8.0 */>
228
301
  {showRecent && (
229
302
  <>
230
303
  <p className={kit.lbl} id={`${base}-recent`}>{L.recent}</p>
@@ -240,16 +313,19 @@ const AbSearchDrawer = ({ open, onClose, search, suggest, onOpenResult, defaultQ
240
313
  {flat.length > 0 && <hr className={kit.hr} />}
241
314
  </>
242
315
  )}
243
- <div id={`${base}-list`} role="listbox" aria-label={L.title} hidden={!expanded}>
244
- {(groups ?? []).filter((g) => g.items.length).map((g, gi) => (
245
- <div key={g.id} role="group" aria-labelledby={groupId(g, gi)}>
316
+ {busy && !expanded && <p className={kit.lbl} data-ab-part="search-loading">{L.loading}</p> /* ⏳ 0.8.0: first answer still on its way */}
317
+ <div id={`${base}-list`} role="listbox" aria-label={L.title} aria-busy={busy || undefined} hidden={!expanded}>
318
+ {shown.map((g, gi) => (
319
+ <div key={`${gi}-${g.id}`} role="group" aria-labelledby={groupId(g, gi)} /* 🧹 G60: keyed by index too, so a repeated id never collides */>
246
320
  <p className={kit.grp2} id={groupId(g, gi)}><span>{g.label}</span>{g.meta && <code>{g.meta}</code>}</p>
247
321
  {g.items.map((it, j) => {
248
- const i = starts[g.id] + j; const on = i === active; // 🎯
322
+ const i = starts[gi] + j; const on = i === active; // 🎯 G60: the start of THIS group (by index)
249
323
  return (
250
- <Link key={it.id} id={optId(i)} href={it.href} role="option" aria-selected={on} tabIndex={-1} className={kit.sr} onClick={() => choose(it)} onMouseMove={() => { if (!on) setActive(i); }}>
324
+ <Link key={`${i}-${it.id}`} /* 🧹 G60: item ids may repeat across groups too */ id={optId(i)} href={it.href} role="option" aria-selected={on} tabIndex={-1} className={kit.sr} onClick={() => choose(it)} onMouseMove={() => { if (!on) setActive(i); }}>
251
325
  <span className={kit.pkgIc} aria-hidden="true">{it.icon && <AbIcon name={it.icon} size={20} />}</span>
252
326
  <span className={kit.srText}><b>{highlightAbSearch(it.title, query)}</b>{it.description && <small>{highlightAbSearch(it.description, query)}</small>}</span>
327
+ {it.badge && <span className={kit.srBadge} data-ab-part="search-badge" title={it.badgeLabel} aria-hidden={it.badgeLabel ? true : undefined}>{it.badge}</span> /* 🏷️ 0.8.0: e.g. EN */}
328
+ {it.badge && it.badgeLabel && <span className={kit.srOnly}>, {it.badgeLabel}</span> /* ♿ 0.8.0: the meaning, not "E N" */}
253
329
  {it.meta && <code className={kit.srMeta}>{it.meta}</code>}
254
330
  </Link>
255
331
  );
@@ -257,6 +333,14 @@ const AbSearchDrawer = ({ open, onClose, search, suggest, onOpenResult, defaultQ
257
333
  </div>
258
334
  ))}
259
335
  </div>
336
+ {failed && (
337
+ <div className={kit.nores} data-ab-part={status === 'offline' ? 'search-offline' : 'search-error'} /* 📴 🛑 0.8.0 */>
338
+ <span className={kit.pkgIc} aria-hidden="true"><AbIcon name="error" size={28} /></span>
339
+ <b>{status === 'offline' ? L.offlineTitle : L.errorTitle}</b>
340
+ <p>{status === 'offline' ? L.offlineHint : L.errorHint}</p>
341
+ <button type="button" className={clsx(kit.row, kit.didYouMean)} onClick={retry}><AbIcon name="refresh" size={20} />&nbsp;{L.retry}</button>
342
+ </div>
343
+ )}
260
344
  {none && (
261
345
  <div className={kit.nores} data-ab-part="search-empty">
262
346
  <span className={kit.pkgIc} aria-hidden="true"><AbIcon name="search" size={28} /></span>
@@ -268,7 +352,7 @@ const AbSearchDrawer = ({ open, onClose, search, suggest, onOpenResult, defaultQ
268
352
  </div>
269
353
  <div className={kit.resFade} aria-hidden="true" />
270
354
  </div>
271
- <p className={kit.srOnly} role="status" aria-live="polite">{groups === null ? '' : none ? L.noResults : L.results(flat.length)}</p>
355
+ <p className={kit.srOnly} role="status" aria-live="polite">{busy && !expanded ? L.loading : status === 'offline' ? L.offlineTitle : status === 'error' ? L.errorTitle : groups === null ? '' : none ? L.noResults : L.results(flat.length)}</p>
272
356
  </div>
273
357
  </AbDrawer>
274
358
  );
@@ -39,7 +39,9 @@
39
39
  'use client';
40
40
 
41
41
  // ⚛️ React
42
- import { useEffect, useSyncExternalStore, type MouseEvent, type ReactElement } from 'react';
42
+ import { type MouseEvent, type ReactElement } from 'react';
43
+ // ⌨️ 0.8.0 (G10, D49): the ONE shared hotkey hook + the platform-aware key cap / aria-keyshortcuts
44
+ import { useAbHotkey, useAbHotkeyLabel, AB_HOTKEY_SEARCH } from 'ab-nextjs-hooks/useAbHotkey';
43
45
  // 🧵 classes
44
46
  import clsx from 'clsx';
45
47
  // 🔗 G42 link (href fallback)
@@ -58,8 +60,12 @@ export interface AbSearchTriggerProps {
58
60
  label?: string; // 🏷️ placeholder text (default "Search")
59
61
  onOpen?: () => void; // 🔔 opens your search dialog (button mode)
60
62
  href?: string; // 🔗 no onOpen → a link to a search page (also the JS-off path)
61
- hotkey?: boolean; // ⌨️ listen for ⌘K / Ctrl+K (default true when onOpen is set)
62
- shortcut?: boolean; // ⌨️ alias of `hotkey` (the spec name); `hotkey` wins when both are set
63
+ /** ⌨️ REGISTER a ⌘K / Ctrl+K listener (via `useAbHotkey`) that calls `onOpen` (default true when `onOpen` is set).
64
+ * 0.8.0 (D49): pass `hotkey={false}` when the app shell owns the single `useAbHotkey('mod+k')`. */
65
+ hotkey?: boolean;
66
+ /** 👀 SHOW the ⌘K / Ctrl+K key cap and announce `aria-keyshortcuts` (default: whatever `hotkey` does).
67
+ * 0.8.0 (D49): no longer an alias of `hotkey` — `shortcut` + `hotkey={false}` = "the shell listens, I just show the cap". */
68
+ shortcut?: boolean;
63
69
  compact?: boolean; // 📱 icon-only pill (the label stays for screen readers), e.g. the mobile app bar
64
70
  comingSoon?: boolean; // 🚧 visible but inert: aria-disabled, no hotkey
65
71
  comingSoonLabel?: string; // 🏷️ default "Coming soon"
@@ -72,40 +78,28 @@ export interface AbSearchTriggerProps {
72
78
  className?: string; // 🏷️
73
79
  }
74
80
 
75
- // 🔕 nothing to subscribe to
76
- const noopSubscribe = () => () => {};
77
-
78
- /** 🍎 Apple platforms show ⌘, everyone else Ctrl. */
79
- export function isAbApplePlatform(nav?: { platform?: string; userAgent?: string; userAgentData?: { platform?: string } }): boolean {
80
- const p = nav?.userAgentData?.platform ?? nav?.platform ?? nav?.userAgent ?? ''; // 🔍
81
- return /mac|iphone|ipad|ipod/i.test(p); // 🍎
82
- }
81
+ /** 🍎 Apple platforms show ⌘, everyone else Ctrl. 0.8.0: the one implementation now lives in hooks 0.1.9 (re-exported here). */
82
+ export { isAbApplePlatform } from 'ab-nextjs-hooks/useAbHotkey';
83
83
 
84
84
  /**
85
85
  * 🔎 AbSearchTrigger (G44): a search "field" that opens your dialog. Shows ⌘K on Apple, Ctrl K elsewhere,
86
- * announces `aria-keyshortcuts="Meta+K Control+K"`, and falls back to a link when there's no `onOpen`.
87
- * Note: the hotkey is a local listener; G48 `useAbHotkey` is deliberately not in hooks 0.1.7.
86
+ * announces `aria-keyshortcuts` ("Meta+K" on Apple, "Control+K" elsewhere; SSR renders the Ctrl / Control pair),
87
+ * and falls back to a link when there's no `onOpen`.
88
+ * - ⌨️ 0.8.0 (D49) **shortcut / hotkey split**: `hotkey` registers the listener (hooks 0.1.9 `useAbHotkey`),
89
+ * `shortcut` only shows the cap. An app with one shell-level `useAbHotkey('mod+k')` renders every trigger with
90
+ * `shortcut hotkey={false}`: the cap everywhere, ONE listener, no double-open.
88
91
  */
89
92
  const AbSearchTrigger = ({ label = 'Search', onOpen, href, hotkey, shortcut, compact = false, comingSoon = false, comingSoonLabel = 'Coming soon', compactLabel, variant = 'pill', size = 'md', className }: AbSearchTriggerProps): ReactElement => {
90
- // 🍎 SSR renders "Ctrl"; hydration then reads the platform (useSyncExternalStore: no mismatch, no effect)
91
- const apple = useSyncExternalStore(
92
- noopSubscribe, // 🔕 the platform never changes
93
- () => isAbApplePlatform(navigator as Navigator & { userAgentData?: { platform?: string } }), // 🖥️ client
94
- () => false, // 🖨️ server
95
- );
96
- // ⌨️ ⌘K / Ctrl+K
97
- const listen = !comingSoon && !!onOpen && (hotkey ?? shortcut ?? true);
98
- useEffect(() => {
99
- if (!listen) return;
100
- const onKey = (e: KeyboardEvent) => {
101
- if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k') {
102
- e.preventDefault(); // 🚫 browser search bar
103
- onOpen?.(); // 🔔
104
- }
105
- };
106
- window.addEventListener('keydown', onKey); // 👂
107
- return () => window.removeEventListener('keydown', onKey); // 🧹
108
- }, [listen, onOpen]);
93
+ // 🍎 SSR renders "Ctrl" / "Control+K"; hydration then reads the platform (useSyncExternalStore inside: no mismatch)
94
+ const { apple, ariaKeyShortcuts } = useAbHotkeyLabel(AB_HOTKEY_SEARCH);
95
+ // ⌨️ 0.8.0 (D49): does THIS trigger register the listener? (needs something to open; never while coming soon)
96
+ const listen = !comingSoon && !!onOpen && (hotkey ?? true);
97
+ // 👀 0.8.0 (D49): does it SHOW the cap? Defaults to "only while I listen" (#3, D24a); `shortcut` forces it either way
98
+ const showCap = !comingSoon && (shortcut ?? listen);
99
+ // 👂 the listener itself: hooks' useAbHotkey ('mod+k' = ⌘K on Apple, Ctrl+K elsewhere). `mod+k` fires in
100
+ // inputs by default (hooks 0.1.9: a combo with a modifier does; a bare key does not), so this keeps the
101
+ // 0.7.1 behaviour (it fired from anywhere). A second binding of the same combo skips the handled event (no double-open)
102
+ useAbHotkey(AB_HOTKEY_SEARCH, () => onOpen?.(), { enabled: listen });
109
103
 
110
104
  // 🏠 P6: the Home looks (field / sm pill) show ONE key cap ("⌘ K" / "⌘K") and keep "coming soon" out of the field
111
105
  const home = variant === 'field' || size === 'sm' || size === 'lg'; // 🔍 404 gaps: lg is a (bigger) Home field
@@ -118,22 +112,22 @@ const AbSearchTrigger = ({ label = 'Search', onOpen, href, hotkey, shortcut, com
118
112
  <span className={styles.abSearchTriggerLabel} data-ab-part="search-label">{label}</span>
119
113
  {compactLabel != null && <span className={clsx(styles.abSearchTriggerLabel, styles.abSearchTriggerShort)} data-ab-part="search-label-compact">{compactLabel}</span> /* 📱 0.1.15 */}
120
114
  {/* 🚧 coming soon: tooltip + announced, never painted inside the field (spec §4) */}
121
- {comingSoon ? <span className={styles.abSearchTriggerSrOnly}>, {comingSoonLabel}</span> : listen && <AbKbd className={styles.abSearchTriggerCap}>{keyCap}</AbKbd>}
115
+ {comingSoon ? <span className={styles.abSearchTriggerSrOnly}>, {comingSoonLabel}</span> : showCap && <AbKbd className={styles.abSearchTriggerCap}>{keyCap}</AbKbd> /* 👀 0.8.0: shortcut, not hotkey */}
122
116
  </>
123
117
  ) : (
124
118
  <>
125
119
  <AbIcon name="search" size={20} className={styles.abSearchTriggerIcon} />
126
120
  <span className={clsx(styles.abSearchTriggerLabel, compact && styles.abSearchTriggerSrOnly)}>{label}</span>
127
- {/* 🚧 coming soon tag, or ⌨️ the key hint ONLY while a hotkey is really listening (#3, D24a) */}
121
+ {/* 🚧 coming soon tag, or ⌨️ the key hint while the shortcut is real (#3, D24a; 0.8.0: `shortcut` / a listening `hotkey`) */}
128
122
  {comingSoon
129
123
  ? !compact && <span className={styles.abSearchTriggerSoon}>{comingSoonLabel}</span>
130
- : listen && !compact && <AbKbd keys={[apple ? '⌘' : 'Ctrl', 'K']} className={styles.abSearchTriggerKbd} />}
124
+ : showCap && !compact && <AbKbd keys={[apple ? '⌘' : 'Ctrl', 'K']} className={styles.abSearchTriggerKbd} />}
131
125
  </>
132
126
  );
133
127
  const common = {
134
128
  className: clsx('AbSearchTrigger', styles.abSearchTrigger, !comingSoon && 'ab-motion-interactive', className), // 🏷️
135
129
  'data-ab-part': 'search-trigger', // 🧩
136
- 'aria-keyshortcuts': listen ? 'Meta+K Control+K' : undefined, // ♿ only announced when bound (#3)
130
+ 'aria-keyshortcuts': showCap ? ariaKeyShortcuts : undefined, // ♿ only announced when real (#3); 0.8.0: the platform's own pair
137
131
  'data-compact': compact ? 'true' : undefined, // 📱
138
132
  'data-variant': variant === 'field' ? 'field' : undefined, // 🔎 P6
139
133
  'data-size': size === 'sm' || size === 'lg' ? size : undefined, // 📱 P6 · 🔍 404 gaps: lg
@@ -80,6 +80,7 @@
80
80
  }
81
81
  .abSearchTrigger[data-size='sm'] {
82
82
  flex: none; width: auto; max-width: none; height: 34px; /* 📏 the pill still LOOKS 34px (mock) */
83
+ min-width: 44px; /* 👆 0.8.0 touch audit: never narrower than a tap target, even with a very short (or no) label */
83
84
  position: relative; /* 📌 0.3.2: anchors the invisible hit area below */
84
85
  gap: 6px; padding: 0 6px 0 10px; /* 📦 */
85
86
  border: 1px solid var(--ab-color-border, rgb(92 64 48 / 0.13)); border-radius: var(--ab-radius-pill, 999px); /* 💊 */
@@ -117,3 +118,17 @@
117
118
  .abSearchTrigger[data-size='lg'] .abSearchTriggerCap { margin-left: auto; } /* ⌨️ key cap pinned right */
118
119
  .abSearchTrigger[data-size='lg'][aria-disabled='true'] { opacity: 1; } /* 🚧 same look while coming soon */
119
120
 
121
+
122
+ /* ===== 👆 0.8.0 touch audit (pointer: coarse): every other trigger gets an invisible ≥ 44×44 hit area =====
123
+ * sm already has its 46px band above (and now a 44px min width). The rest stay as drawn but can be SMALLER than 44 on
124
+ * touch: the md pill (40px tall), the tablet `variant="field"` (36px), AbAppBar's compact 40px icon button and its
125
+ * 34px compact pill. A centred ::after of max(100%, 44px) each way covers them all without growing a target that is
126
+ * already big enough (lg = 44px, a 300px field keeps its own width). No transitions, nothing painted. */
127
+ @media (pointer: coarse) {
128
+ .abSearchTrigger:not([data-size='sm']) { position: relative; } /* 📌 anchors the hit area */
129
+ .abSearchTrigger:not([data-size='sm'])::after {
130
+ content: ''; position: absolute; left: 50%; top: 50%; /* 🫥 an empty, centred box */
131
+ inline-size: max(100%, 44px); block-size: max(100%, 44px); /* 📏 ≥ 44×44, never smaller than the trigger */
132
+ transform: translate(-50%, -50%); /* 🎯 centred on the trigger */
133
+ }
134
+ }
package/index.ts CHANGED
@@ -225,8 +225,8 @@ export { AB_MOBILE_HEADER_THEME_CYCLE } from './ab-mobile-header/index.tsx' //
225
225
  export { AbThemeModeProvider, useAbThemeModeContext, AB_THEME_MODE_ICONS, AB_THEME_ICON_BUTTON_GLYPH } from './ab-theme-mode/index.tsx' // 🔣 0.3.2: + the shared theme glyphs
226
226
  export type { AbThemeModeProviderProps, AbThemeModeContextValue } from './ab-theme-mode/index.tsx'
227
227
  // 🆕 0.2.0 drawers v2: AbSearchDrawer
228
- export { default as AbSearchDrawer, addAbSearchRecent, highlightAbSearch, AB_SEARCH_RECENT_KEY } from './ab-search-drawer/index.tsx'
229
- export type { AbSearchDrawerProps, AbSearchDrawerItem, AbSearchDrawerGroup, AbSearchDrawerLabels } from './ab-search-drawer/index.tsx'
228
+ export { default as AbSearchDrawer, addAbSearchRecent, highlightAbSearch, AB_SEARCH_RECENT_KEY, AbSearchOfflineError, isAbSearchOffline, hasAbHashTarget } from './ab-search-drawer/index.tsx' // 📴 #️⃣ 0.8.0: offline + hash helpers
229
+ export type { AbSearchDrawerProps, AbSearchDrawerItem, AbSearchDrawerGroup, AbSearchDrawerLabels, AbSearchDrawerStatus } from './ab-search-drawer/index.tsx'
230
230
  // 🆕 0.2.0 drawers v2: AbTocDrawer
231
231
  export { default as AbTocDrawer } from './ab-toc-drawer/index.tsx'
232
232
  export type { AbTocDrawerProps, AbTocDrawerLink } from './ab-toc-drawer/index.tsx'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ab-nextjs-components",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "🚀 A lightweight collection of server & client React components created by Abraham Ukachi, and optimized for Next.js applications 😎.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -41,7 +41,7 @@
41
41
  "license": "MIT",
42
42
  "peerDependencies": {
43
43
  "ab-nextjs-animations": "^0.2.5",
44
- "ab-nextjs-hooks": "^0.1.7",
44
+ "ab-nextjs-hooks": "^0.1.9",
45
45
  "ab-nextjs-icons": "^0.2.7",
46
46
  "ab-nextjs-theme": "^0.3.9",
47
47
  "clsx": "^2",
@@ -54,7 +54,7 @@
54
54
  "@types/node": "^20",
55
55
  "@types/react": "^19",
56
56
  "ab-nextjs-animations": "^0.2.5",
57
- "ab-nextjs-hooks": "^0.1.7",
57
+ "ab-nextjs-hooks": "^0.1.9",
58
58
  "ab-nextjs-icons": "^0.2.7",
59
59
  "ab-nextjs-theme": "^0.3.9",
60
60
  "clsx": "^2.1.1",
@@ -259,9 +259,6 @@
259
259
  "peerDependenciesMeta": {
260
260
  "ab-nextjs-theme": {
261
261
  "optional": true
262
- },
263
- "ab-nextjs-hooks": {
264
- "optional": true
265
262
  }
266
263
  }
267
264
  }
package/types/index.d.ts CHANGED
@@ -108,8 +108,8 @@ export { AB_MOBILE_HEADER_THEME_CYCLE } from '../ab-mobile-header/index.tsx'; //
108
108
  export { AbThemeModeProvider, useAbThemeModeContext, AB_THEME_MODE_ICONS, AB_THEME_ICON_BUTTON_GLYPH } from '../ab-theme-mode/index.tsx';
109
109
  export type { AbThemeModeProviderProps, AbThemeModeContextValue } from '../ab-theme-mode/index.tsx';
110
110
  // 🆕 0.2.0 drawers v2: AbSearchDrawer
111
- export { default as AbSearchDrawer, addAbSearchRecent, highlightAbSearch, AB_SEARCH_RECENT_KEY } from '../ab-search-drawer/index.tsx';
112
- export type { AbSearchDrawerProps, AbSearchDrawerItem, AbSearchDrawerGroup, AbSearchDrawerLabels } from '../ab-search-drawer/index.tsx';
111
+ export { default as AbSearchDrawer, addAbSearchRecent, highlightAbSearch, AB_SEARCH_RECENT_KEY, AbSearchOfflineError, isAbSearchOffline, hasAbHashTarget } from '../ab-search-drawer/index.tsx'; // 📴 #️⃣ 0.8.0
112
+ export type { AbSearchDrawerProps, AbSearchDrawerItem, AbSearchDrawerGroup, AbSearchDrawerLabels, AbSearchDrawerStatus } from '../ab-search-drawer/index.tsx';
113
113
  // 🆕 0.2.0 drawers v2: AbTocDrawer
114
114
  export { default as AbTocDrawer } from '../ab-toc-drawer/index.tsx';
115
115
  export type { AbTocDrawerProps, AbTocDrawerLink } from '../ab-toc-drawer/index.tsx';