@skolo-saka/school-search 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +209 -2
- package/THIRD_PARTY_NOTICES.md +25 -0
- package/dist/SchoolSearch.d.cts +45 -0
- package/dist/SchoolSearch.d.ts +45 -0
- package/dist/icons.d.cts +4 -0
- package/dist/icons.d.ts +4 -0
- package/dist/index.cjs +297 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +268 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +67 -0
- package/dist/types.d.cts +51 -0
- package/dist/types.d.ts +51 -0
- package/dist/useSchoolSearch.d.cts +24 -0
- package/dist/useSchoolSearch.d.ts +24 -0
- package/package.json +76 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Skolo Saka
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,210 @@
|
|
|
1
|
-
#
|
|
1
|
+
# school-search
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/skolo-saka/school-search/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@skolo-saka/school-search)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
`@skolo-saka/school-search` is an accessible React and TypeScript combobox for finding a school as you type and picking it. It was extracted from the "Which school will you help?" search on [Skolo Saka](https://skolosaka.co.za)'s homepage, and works in any React 18 or 19 app.
|
|
8
|
+
|
|
9
|
+
**[Try the demo](https://skolo-saka.github.io/school-search/)**, which searches the live Skolo Saka school directory. Type **sunnyside primary**: two real schools share that name, in Cape Town and Pretoria, and the one you pick is the one handed back, with a link to its page on the Skolo Saka website.
|
|
10
|
+
|
|
11
|
+
You supply two functions:
|
|
12
|
+
|
|
13
|
+
- **`searchSchools(query, { signal })`** returns the schools that match the typed text, from any source: an API, a database or an array.
|
|
14
|
+
- **`onSelectSchool(school)`** receives the exact school the person picked.
|
|
15
|
+
|
|
16
|
+
The component handles the rest: a 250 ms search delay and two-letter minimum, names with a verified badge and a place line ("Primary school, Riverbend, Limpopo"), arrow keys, Enter and Escape, loading, no-results and error messages with "Try again", a clear button, screen-reader announcements and a mobile layout. A slow answer to an older query never replaces newer results.
|
|
17
|
+
|
|
18
|
+
## Status
|
|
19
|
+
|
|
20
|
+
**Published on [npm](https://www.npmjs.com/package/@skolo-saka/school-search)** and used by the [Skolo Saka website](https://www.skolosaka.co.za)'s homepage search. Releases are listed on the [releases page](https://github.com/skolo-saka/school-search/releases). Each one is published from a version tag by GitHub Actions with npm provenance; see [RELEASING.md](RELEASING.md). The API may still change before 1.0. A change that can need work in your app gets a new minor version.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @skolo-saka/school-search
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
React and React DOM 18 or later are peer dependencies. The package ships ES module and CommonJS builds, TypeScript declarations for each (`.d.ts` and `.d.cts`) and one stylesheet. The types work with TypeScript's `bundler`, `node16` and `nodenext` module resolution.
|
|
29
|
+
|
|
30
|
+
## Use it
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { useState } from 'react';
|
|
34
|
+
import { SchoolSearch, schoolPlace, type School } from '@skolo-saka/school-search';
|
|
35
|
+
import '@skolo-saka/school-search/styles.css';
|
|
36
|
+
|
|
37
|
+
// Fictional schools. In a real app, searchSchools would call your API instead.
|
|
38
|
+
const SCHOOLS: School[] = [
|
|
39
|
+
{ id: 'sunbird-riverbend', name: 'Sunbird Primary School', level: 'primary', town: 'Riverbend', province: 'Limpopo', verified: true },
|
|
40
|
+
{ id: 'sunbird-kopjeskloof', name: 'Sunbird Primary School', level: 'primary', town: 'Kopjeskloof', province: 'Free State' },
|
|
41
|
+
{ id: 'baobab-ridge', name: 'Baobab Ridge High School', level: 'high', town: 'Riverbend', province: 'Limpopo', verified: true },
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
async function searchSchools(query: string, { signal }: { signal: AbortSignal }): Promise<School[]> {
|
|
45
|
+
// With an API: const res = await fetch(`/api/schools?q=${encodeURIComponent(query)}`, { signal });
|
|
46
|
+
// if (!res.ok) throw new Error('Search failed'); // shows the error message and "Try again"
|
|
47
|
+
// return res.json();
|
|
48
|
+
signal.throwIfAborted();
|
|
49
|
+
const q = query.toLowerCase();
|
|
50
|
+
return SCHOOLS.filter(s => `${s.name} ${s.town} ${s.province}`.toLowerCase().includes(q));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default function App() {
|
|
54
|
+
const [school, setSchool] = useState<School | null>(null);
|
|
55
|
+
return <main>
|
|
56
|
+
<SchoolSearch searchSchools={searchSchools} onSelectSchool={setSchool} />
|
|
57
|
+
{school && <p>You picked {school.name} ({schoolPlace(school)}), id {school.id}.</p>}
|
|
58
|
+
</main>;
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`signal` is aborted when newer text replaces a search; pass it to `fetch` so stale requests are cancelled. Throw (or reject) to show the error message.
|
|
63
|
+
|
|
64
|
+
### Props
|
|
65
|
+
|
|
66
|
+
| Prop | Default | |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| `searchSchools(query, { signal })` | required | Returns a promise of matching schools. Throw to show the error message. |
|
|
69
|
+
| `onSelectSchool(school)` | required | The exact school object picked, including any extra fields you returned. |
|
|
70
|
+
| `onSearchAll(query)` | none | "Find school" or Enter with several matches, or while loading or after a failure, e.g. to open a full results page. Without it, the button opens the list (or retries after a failure). One match is always picked directly. |
|
|
71
|
+
| `links.error`, `links.empty(query)` | none | `{ href, label }` links added to the error and no-results messages. |
|
|
72
|
+
| `renderLink` | plain `<a>` | Render those links with your router, e.g. Next.js `<Link>`. |
|
|
73
|
+
| `messages` | English | Replace any text, e.g. for translations. See `SchoolSearchMessages`. |
|
|
74
|
+
| `formatPlace(school)` | `schoolPlace` | The line under each name. |
|
|
75
|
+
| `limit` / `debounceMs` / `minChars` | 6 / 250 / 2 | Results shown, search delay, shortest search. |
|
|
76
|
+
| `focusHash` | `'#find-school'` | URL hash that focuses the box; `null` turns it off. |
|
|
77
|
+
| `className` | | Added to the outer `<form>`. |
|
|
78
|
+
|
|
79
|
+
A school is `{ id, name, level?, town?, municipality?, province?, verified? }`. A `level` of `primary`, `high` or `combined` shows as "Primary school", "High school" or "Combined school". For a custom layout, the `useSchoolSearch` hook gives you the search state without the markup.
|
|
80
|
+
|
|
81
|
+
### Keyboard
|
|
82
|
+
|
|
83
|
+
The search box is an [editable combobox](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/) with list autocomplete. Focus stays in the text box; `aria-activedescendant` points at the highlighted school.
|
|
84
|
+
|
|
85
|
+
| Key | List open | List closed (after Escape) |
|
|
86
|
+
| --- | --- | --- |
|
|
87
|
+
| ArrowDown | Highlights the next school. Stops at the last one. | Opens the list on the first school. |
|
|
88
|
+
| ArrowUp | Highlights the previous school. Stops at the first one. | Opens the list on the last school. |
|
|
89
|
+
| Enter | Picks the highlighted school. | Same as "Find school": one match is picked, several go to `onSearchAll`. |
|
|
90
|
+
| Escape | Closes the list. The text stays. | Nothing. |
|
|
91
|
+
| Home / End | Move the text caret. The highlight stays where it is. | Move the text caret. |
|
|
92
|
+
| Tab | Leaves the box and closes the list without picking a school. | Leaves the box. |
|
|
93
|
+
|
|
94
|
+
The arrows do not wrap from the last school to the first. Home and End belong to the text box, as the ARIA Authoring Practices recommend for an editable combobox, so people can still edit their search while the list is open. The first school is highlighted when results arrive.
|
|
95
|
+
|
|
96
|
+
### Schools with the same name
|
|
97
|
+
|
|
98
|
+
School names are not unique. In the live demo, **sunnyside primary** finds two real Sunnyside Primary Schools, one in Cape Town and one in Pretoria. In testing mode, the fictional **Sunbird Primary School** results are in **Riverbend** and **Kopjeskloof**. The place line under each name tells them apart: by default, `schoolPlace` combines the level, town (or municipality when there is no town), and province. Return `town`, `municipality` and/or `province` from `searchSchools` so people can see which school they are choosing.
|
|
99
|
+
|
|
100
|
+
`onSelectSchool` receives the exact school object picked, including its `id` and any extra fields. Always use **`school.id`**, rather than `school.name`, to identify the selection in your app or navigate to its record.
|
|
101
|
+
|
|
102
|
+
If two schools share both a name and the same displayed place, those lines look the same; the component does not invent a distinction. Use `formatPlace` to add a suburb or school code supplied by your directory. For example, with the fictional data and functions above, you can append the unique id:
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<SchoolSearch
|
|
106
|
+
searchSchools={searchSchools}
|
|
107
|
+
onSelectSchool={school => console.log(school.id)}
|
|
108
|
+
formatPlace={school => `${schoolPlace(school)} · ${school.id}`}
|
|
109
|
+
/>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Styles
|
|
113
|
+
|
|
114
|
+
Import `@skolo-saka/school-search/styles.css` once. Classes are prefixed `skolo-search`. Colours follow these CSS custom properties when the page defines them: `--brand`, `--brand-deep`, `--sun`, `--sun-deep`, `--ink`, `--muted`, `--line`, `--glass-tint`, `--radius-control`, `--shadow-3` and `--z-raised`; otherwise a default green and yellow apply. Any `--skolo-search-*` property can also be set on `.skolo-search`.
|
|
115
|
+
|
|
116
|
+
### Next.js
|
|
117
|
+
|
|
118
|
+
The built files start with `'use client'`, so the App Router treats the component as a client component. Pass `renderLink={({ href, children }) => <Link href={href}>{children}</Link>}` to route the message links with `next/link`, and navigate in `onSelectSchool` with `useRouter()`.
|
|
119
|
+
|
|
120
|
+
## Develop
|
|
121
|
+
|
|
122
|
+
You need [Node.js 24](https://nodejs.org/) (24.11 or later; `.nvmrc` pins the major version) and npm.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
git clone https://github.com/skolo-saka/school-search.git
|
|
126
|
+
cd school-search
|
|
127
|
+
npm ci
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Run the demo at http://localhost:5173:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npm run demo
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The demo imports `@skolo-saka/school-search` exactly as an app would (Vite points that name at `src/`).
|
|
137
|
+
|
|
138
|
+
### Live search
|
|
139
|
+
|
|
140
|
+
By default the demo searches the **live Skolo Saka school directory** through the website's public API, `GET https://www.skolosaka.co.za/api/public/schools/search?q=<text>`. The API returns at most 10 real schools with public fields only: `id`, `name`, `town`, `municipality`, `province`, `level` and `verified`. The connection lives in the demo (`demo/src/liveSearch.ts`), not in the package. The package has no knowledge of Skolo Saka's backend, and any app supplies its own `searchSchools`.
|
|
141
|
+
|
|
142
|
+
- The request uses the `AbortSignal` the component passes, so a newer search cancels the older one.
|
|
143
|
+
- An answer without a `schools` array is treated as an error. Malformed schools in an answer are skipped.
|
|
144
|
+
- A failed request shows the error and **Try again**. It never falls back to fictional schools.
|
|
145
|
+
- Picking a school shows its name, place and ID, with a link to `https://www.skolosaka.co.za/school/<id>`.
|
|
146
|
+
- **Find school** with several matches opens the website's directory search (`/schools?q=`). The no-results and error messages link to the website's contact and donate pages.
|
|
147
|
+
|
|
148
|
+
Try **sunnyside primary** (two schools with the same name), **hoerskool ben vorster**, **st john's college** and **zzqqxx** (no matches).
|
|
149
|
+
|
|
150
|
+
#### Configuration
|
|
151
|
+
|
|
152
|
+
`VITE_SKOLO_SAKA_ORIGIN` chooses the website whose API and pages the demo uses. The default is production, `https://www.skolosaka.co.za`, and the GitHub Pages workflow sets it explicitly. Set it in the environment or in `demo/.env.local`.
|
|
153
|
+
|
|
154
|
+
- **Published demo (`npm run demo:build`):** the browser calls `<origin>/api/public/schools/search` directly. The API allows cross-origin requests only from `https://skolo-saka.github.io`.
|
|
155
|
+
- **Local demo (`npm run demo` or `vite preview`):** the browser calls the demo's own server, which forwards `/api/public/` to the origin. No CORS exception is needed.
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# UAT: test data, and links open UAT school pages
|
|
159
|
+
VITE_SKOLO_SAKA_ORIGIN=https://skolo-saka-uat.azurewebsites.net npm run demo
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# A website running locally on port 3000
|
|
164
|
+
VITE_SKOLO_SAKA_ORIGIN=http://localhost:3000 npm run demo
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
A built demo served from another local origin calls the website directly. That website must list the origin in `PUBLIC_API_DEV_ORIGINS`, which production ignores.
|
|
168
|
+
|
|
169
|
+
### Testing mode (fictional schools)
|
|
170
|
+
|
|
171
|
+
Choose **Testing mode: 8 fictional schools** under **Data source** to use made-up schools (`demo/src/schools.ts`). The simulation controls appear only in testing mode and affect only the fictional source:
|
|
172
|
+
|
|
173
|
+
- Try **sunbird** (same name, two towns) and **zzz** (no results).
|
|
174
|
+
- Choose "Every search fails", then press **Try again**.
|
|
175
|
+
- Choose "Slow short queries", then type **sun** and then **bird**. The late answer for "sun" is logged but not shown.
|
|
176
|
+
|
|
177
|
+
Switching between the live directory and testing mode clears the search and cancels any request in flight, so results from the two sources never mix. Fictional schools have no website page. The automated tests use fixtures only and never call the live API.
|
|
178
|
+
|
|
179
|
+
Run the checks that CI runs:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
npm run typecheck
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
npm test
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
npm run build
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
npm run demo:build
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
`npm run build` writes the package to `dist/`; `npm run demo:build` writes the static demo to `demo/dist/`. `npm pack` builds and writes `skolo-saka-school-search-<version>.tgz`, which another app can install with `npm install ./skolo-saka-school-search-<version>.tgz`. `node scripts/check-package.mjs` packs the package and checks it in a clean app: its files, ES module and CommonJS builds, `styles.css` and TypeScript types.
|
|
198
|
+
|
|
199
|
+
## Related projects
|
|
200
|
+
|
|
201
|
+
- [school-directory](https://github.com/skolo-saka/school-directory): the open-source school directory behind Skolo Saka's search. It provides the PostgreSQL schema, the validated Department of Basic Education importer and a public search API you can connect to `searchSchools`.
|
|
202
|
+
- [Live demo](https://skolo-saka.github.io/school-search/): this component searching the real Skolo Saka directory.
|
|
203
|
+
|
|
204
|
+
## Contributing
|
|
205
|
+
|
|
206
|
+
Maintainers ([MAINTAINERS.md](MAINTAINERS.md)) release new versions as described in [RELEASING.md](RELEASING.md). See [CONTRIBUTING.md](CONTRIBUTING.md) for the fork, branch, test and pull-request workflow, and the [good first issues](https://github.com/skolo-saka/school-search/labels/good%20first%20issue). Everyone taking part follows the [code of conduct](CODE_OF_CONDUCT.md). Report security problems privately as described in [SECURITY.md](SECURITY.md).
|
|
207
|
+
|
|
208
|
+
## Licence
|
|
209
|
+
|
|
210
|
+
[MIT](LICENSE) © 2026 Skolo Saka. The inlined Lucide icons are ISC licensed; see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
`@skolo-saka/school-search` is MIT licensed (see [LICENSE](LICENSE)). It includes the following third-party material.
|
|
4
|
+
|
|
5
|
+
## Lucide icons
|
|
6
|
+
|
|
7
|
+
`src/icons.tsx` inlines the SVG paths of the Search, X and BadgeCheck icons from [Lucide](https://lucide.dev), so the built package (`dist/`) contains them too.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
ISC License
|
|
11
|
+
|
|
12
|
+
Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022.
|
|
13
|
+
|
|
14
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
15
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
16
|
+
copyright notice and this permission notice appear in all copies.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
19
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
20
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
21
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
22
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
23
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
24
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
25
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { FallbackLink, School, SchoolSearchMessages, SearchSchools } from './types.cjs';
|
|
3
|
+
export declare const defaultMessages: SchoolSearchMessages;
|
|
4
|
+
export interface SchoolSearchProps<S extends School = School> {
|
|
5
|
+
/** Supplies the schools matching the typed text. */
|
|
6
|
+
searchSchools: SearchSchools<S>;
|
|
7
|
+
/** Receives the school the person picked (click, Enter on a highlighted school, or "Find school" with one match). */
|
|
8
|
+
onSelectSchool: (school: S) => void;
|
|
9
|
+
/**
|
|
10
|
+
* "Find school" (or Enter with nothing highlighted) when there are several matches, or while a search
|
|
11
|
+
* is loading or has failed. On the website this opens the full directory search. Without it, the
|
|
12
|
+
* button opens the results list instead.
|
|
13
|
+
*/
|
|
14
|
+
onSearchAll?: (query: string) => void;
|
|
15
|
+
/** Links shown inside the messages. Leave out to show the messages without links. */
|
|
16
|
+
links?: {
|
|
17
|
+
/** Shown after a failed search, e.g. donate without choosing a school. */
|
|
18
|
+
error?: FallbackLink | null;
|
|
19
|
+
/** Shown when nothing matches, e.g. "tell us about the school". Gets the trimmed search text. */
|
|
20
|
+
empty?: ((query: string) => FallbackLink | null) | null;
|
|
21
|
+
};
|
|
22
|
+
/** Renders a link, e.g. with Next.js `<Link>`. Default: a plain `<a>`. */
|
|
23
|
+
renderLink?: (link: {
|
|
24
|
+
href: string;
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
}) => ReactNode;
|
|
27
|
+
/** Replace any of the text, e.g. for translations. */
|
|
28
|
+
messages?: Partial<SchoolSearchMessages>;
|
|
29
|
+
/** The line under a school's name. Default: "High school, Town, Province". */
|
|
30
|
+
formatPlace?: (school: S) => string;
|
|
31
|
+
/** Most results to show. Default 6. */
|
|
32
|
+
limit?: number;
|
|
33
|
+
/** Search delay after the last keystroke, in ms. Default 250. */
|
|
34
|
+
debounceMs?: number;
|
|
35
|
+
/** Shortest text that searches. Default 2. */
|
|
36
|
+
minChars?: number;
|
|
37
|
+
/** When the page URL has this hash (default '#find-school'), the box takes focus. null turns it off. */
|
|
38
|
+
focusHash?: string | null;
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* "Which school will you help?" A combobox: type a school name or town, then pick a school with the
|
|
43
|
+
* mouse, or the arrow keys and Enter. The app decides where a picked school goes.
|
|
44
|
+
*/
|
|
45
|
+
export declare function SchoolSearch<S extends School = School>({ searchSchools, onSelectSchool, onSearchAll, links, renderLink, messages, formatPlace, limit, debounceMs, minChars, focusHash, className, }: SchoolSearchProps<S>): import("react").JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { FallbackLink, School, SchoolSearchMessages, SearchSchools } from './types.js';
|
|
3
|
+
export declare const defaultMessages: SchoolSearchMessages;
|
|
4
|
+
export interface SchoolSearchProps<S extends School = School> {
|
|
5
|
+
/** Supplies the schools matching the typed text. */
|
|
6
|
+
searchSchools: SearchSchools<S>;
|
|
7
|
+
/** Receives the school the person picked (click, Enter on a highlighted school, or "Find school" with one match). */
|
|
8
|
+
onSelectSchool: (school: S) => void;
|
|
9
|
+
/**
|
|
10
|
+
* "Find school" (or Enter with nothing highlighted) when there are several matches, or while a search
|
|
11
|
+
* is loading or has failed. On the website this opens the full directory search. Without it, the
|
|
12
|
+
* button opens the results list instead.
|
|
13
|
+
*/
|
|
14
|
+
onSearchAll?: (query: string) => void;
|
|
15
|
+
/** Links shown inside the messages. Leave out to show the messages without links. */
|
|
16
|
+
links?: {
|
|
17
|
+
/** Shown after a failed search, e.g. donate without choosing a school. */
|
|
18
|
+
error?: FallbackLink | null;
|
|
19
|
+
/** Shown when nothing matches, e.g. "tell us about the school". Gets the trimmed search text. */
|
|
20
|
+
empty?: ((query: string) => FallbackLink | null) | null;
|
|
21
|
+
};
|
|
22
|
+
/** Renders a link, e.g. with Next.js `<Link>`. Default: a plain `<a>`. */
|
|
23
|
+
renderLink?: (link: {
|
|
24
|
+
href: string;
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
}) => ReactNode;
|
|
27
|
+
/** Replace any of the text, e.g. for translations. */
|
|
28
|
+
messages?: Partial<SchoolSearchMessages>;
|
|
29
|
+
/** The line under a school's name. Default: "High school, Town, Province". */
|
|
30
|
+
formatPlace?: (school: S) => string;
|
|
31
|
+
/** Most results to show. Default 6. */
|
|
32
|
+
limit?: number;
|
|
33
|
+
/** Search delay after the last keystroke, in ms. Default 250. */
|
|
34
|
+
debounceMs?: number;
|
|
35
|
+
/** Shortest text that searches. Default 2. */
|
|
36
|
+
minChars?: number;
|
|
37
|
+
/** When the page URL has this hash (default '#find-school'), the box takes focus. null turns it off. */
|
|
38
|
+
focusHash?: string | null;
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* "Which school will you help?" A combobox: type a school name or town, then pick a school with the
|
|
43
|
+
* mouse, or the arrow keys and Enter. The app decides where a picked school goes.
|
|
44
|
+
*/
|
|
45
|
+
export declare function SchoolSearch<S extends School = School>({ searchSchools, onSelectSchool, onSearchAll, links, renderLink, messages, formatPlace, limit, debounceMs, minChars, focusHash, className, }: SchoolSearchProps<S>): import("react").JSX.Element;
|
package/dist/icons.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SVGProps } from 'react';
|
|
2
|
+
export declare const SearchIcon: (props: SVGProps<SVGSVGElement>) => import("react").JSX.Element;
|
|
3
|
+
export declare const XIcon: (props: SVGProps<SVGSVGElement>) => import("react").JSX.Element;
|
|
4
|
+
export declare const BadgeCheckIcon: (props: SVGProps<SVGSVGElement>) => import("react").JSX.Element;
|
package/dist/icons.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SVGProps } from 'react';
|
|
2
|
+
export declare const SearchIcon: (props: SVGProps<SVGSVGElement>) => import("react").JSX.Element;
|
|
3
|
+
export declare const XIcon: (props: SVGProps<SVGSVGElement>) => import("react").JSX.Element;
|
|
4
|
+
export declare const BadgeCheckIcon: (props: SVGProps<SVGSVGElement>) => import("react").JSX.Element;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
SchoolSearch: () => SchoolSearch,
|
|
25
|
+
defaultMessages: () => defaultMessages,
|
|
26
|
+
schoolPlace: () => schoolPlace,
|
|
27
|
+
useSchoolSearch: () => useSchoolSearch
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(index_exports);
|
|
30
|
+
|
|
31
|
+
// src/SchoolSearch.tsx
|
|
32
|
+
var import_react2 = require("react");
|
|
33
|
+
|
|
34
|
+
// src/useSchoolSearch.ts
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var LEVEL = { primary: "Primary school", high: "High school", combined: "Combined school" };
|
|
37
|
+
var schoolPlace = (s) => [s.level ? LEVEL[s.level] ?? s.level : null, [s.town || s.municipality, s.province].filter(Boolean).join(", ")].filter(Boolean).join(", ");
|
|
38
|
+
function useSchoolSearch({ searchSchools, limit = 6, debounceMs = 250, minChars = 2 }) {
|
|
39
|
+
const [query, setQuery] = (0, import_react.useState)("");
|
|
40
|
+
const [state, setState] = (0, import_react.useState)("idle");
|
|
41
|
+
const [results, setResults] = (0, import_react.useState)([]);
|
|
42
|
+
const [attempt, setAttempt] = (0, import_react.useState)(0);
|
|
43
|
+
const request = (0, import_react.useRef)(0);
|
|
44
|
+
const search = (0, import_react.useRef)(searchSchools);
|
|
45
|
+
search.current = searchSchools;
|
|
46
|
+
(0, import_react.useEffect)(() => {
|
|
47
|
+
const term = query.trim();
|
|
48
|
+
if (term.length < minChars) {
|
|
49
|
+
request.current++;
|
|
50
|
+
setState("idle");
|
|
51
|
+
setResults([]);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const seq = ++request.current;
|
|
55
|
+
const controller = new AbortController();
|
|
56
|
+
setState("loading");
|
|
57
|
+
const timer = setTimeout(async () => {
|
|
58
|
+
try {
|
|
59
|
+
const found = await search.current(term, { signal: controller.signal });
|
|
60
|
+
if (seq !== request.current) return;
|
|
61
|
+
const items = (found || []).slice(0, limit);
|
|
62
|
+
setResults(items);
|
|
63
|
+
setState(items.length ? "results" : "empty");
|
|
64
|
+
} catch {
|
|
65
|
+
if (seq === request.current) {
|
|
66
|
+
setResults([]);
|
|
67
|
+
setState("error");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, debounceMs);
|
|
71
|
+
return () => {
|
|
72
|
+
clearTimeout(timer);
|
|
73
|
+
controller.abort();
|
|
74
|
+
};
|
|
75
|
+
}, [query, attempt, limit, debounceMs, minChars]);
|
|
76
|
+
return { query, setQuery, state, results, retry: () => setAttempt((n) => n + 1) };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// src/icons.tsx
|
|
80
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
81
|
+
var base = { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" };
|
|
82
|
+
var SearchIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { ...base, ...props, children: [
|
|
83
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m21 21-4.34-4.34" }),
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "11", cy: "11", r: "8" })
|
|
85
|
+
] });
|
|
86
|
+
var XIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { ...base, ...props, children: [
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18 6 6 18" }),
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m6 6 12 12" })
|
|
89
|
+
] });
|
|
90
|
+
var BadgeCheckIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { ...base, ...props, children: [
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z" }),
|
|
92
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m9 12 2 2 4-4" })
|
|
93
|
+
] });
|
|
94
|
+
|
|
95
|
+
// src/SchoolSearch.tsx
|
|
96
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
97
|
+
var defaultMessages = {
|
|
98
|
+
label: "Search for a school",
|
|
99
|
+
placeholder: "School name or town",
|
|
100
|
+
submit: "Find school",
|
|
101
|
+
clear: "Clear search",
|
|
102
|
+
listLabel: "Schools",
|
|
103
|
+
verified: "Verified",
|
|
104
|
+
loading: "Searching schools\u2026",
|
|
105
|
+
retry: "Try again",
|
|
106
|
+
error: ({ retry, link }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
107
|
+
"We couldn\u2019t load schools. ",
|
|
108
|
+
retry,
|
|
109
|
+
link ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
110
|
+
", or ",
|
|
111
|
+
link
|
|
112
|
+
] }) : null,
|
|
113
|
+
"."
|
|
114
|
+
] }),
|
|
115
|
+
empty: ({ query, link }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
116
|
+
"No school matches \u201C",
|
|
117
|
+
query,
|
|
118
|
+
"\u201D. Try fewer words or the town name",
|
|
119
|
+
link ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
120
|
+
", or ",
|
|
121
|
+
link
|
|
122
|
+
] }) : null,
|
|
123
|
+
"."
|
|
124
|
+
] }),
|
|
125
|
+
announceResults: (count) => `${count} ${count === 1 ? "school" : "schools"} found. Choose one to see its page.`,
|
|
126
|
+
announceEmpty: "No schools found",
|
|
127
|
+
announceError: "We couldn\u2019t load schools"
|
|
128
|
+
};
|
|
129
|
+
var plainLink = ({ href, children }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { href, children });
|
|
130
|
+
function NameWithBadge({ name, badge }) {
|
|
131
|
+
const split = name.trimEnd().lastIndexOf(" ") + 1;
|
|
132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
133
|
+
name.slice(0, split),
|
|
134
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "skolo-search__name-end", children: [
|
|
135
|
+
name.slice(split),
|
|
136
|
+
badge
|
|
137
|
+
] })
|
|
138
|
+
] });
|
|
139
|
+
}
|
|
140
|
+
function SchoolSearch({
|
|
141
|
+
searchSchools,
|
|
142
|
+
onSelectSchool,
|
|
143
|
+
onSearchAll,
|
|
144
|
+
links,
|
|
145
|
+
renderLink = plainLink,
|
|
146
|
+
messages,
|
|
147
|
+
formatPlace = schoolPlace,
|
|
148
|
+
limit,
|
|
149
|
+
debounceMs,
|
|
150
|
+
minChars = 2,
|
|
151
|
+
focusHash = "#find-school",
|
|
152
|
+
className
|
|
153
|
+
}) {
|
|
154
|
+
const t = { ...defaultMessages, ...messages };
|
|
155
|
+
const id = (0, import_react2.useId)();
|
|
156
|
+
const listId = `${id}-schools`;
|
|
157
|
+
const { query, setQuery, state, results, retry } = useSchoolSearch({ searchSchools, limit, debounceMs, minChars });
|
|
158
|
+
const [active, setActive] = (0, import_react2.useState)(-1);
|
|
159
|
+
(0, import_react2.useEffect)(() => setActive(results.length ? 0 : -1), [results]);
|
|
160
|
+
const [open, setOpen] = (0, import_react2.useState)(false);
|
|
161
|
+
const input = (0, import_react2.useRef)(null);
|
|
162
|
+
(0, import_react2.useEffect)(() => {
|
|
163
|
+
if (!focusHash) return;
|
|
164
|
+
const focusFromHash = () => {
|
|
165
|
+
if (window.location.hash === focusHash) input.current?.focus({ preventScroll: true });
|
|
166
|
+
};
|
|
167
|
+
focusFromHash();
|
|
168
|
+
window.addEventListener("hashchange", focusFromHash);
|
|
169
|
+
return () => window.removeEventListener("hashchange", focusFromHash);
|
|
170
|
+
}, [focusHash]);
|
|
171
|
+
function pick(school) {
|
|
172
|
+
setOpen(false);
|
|
173
|
+
onSelectSchool(school);
|
|
174
|
+
}
|
|
175
|
+
function clear() {
|
|
176
|
+
setQuery("");
|
|
177
|
+
requestAnimationFrame(() => input.current?.focus());
|
|
178
|
+
}
|
|
179
|
+
function onKey(e) {
|
|
180
|
+
if (e.key === "Escape") {
|
|
181
|
+
setOpen(false);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (e.key === "Enter" && open && state === "results" && results[active]) {
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
pick(results[active]);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (state !== "results" || e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
|
|
190
|
+
e.preventDefault();
|
|
191
|
+
const down = e.key === "ArrowDown";
|
|
192
|
+
if (!open) {
|
|
193
|
+
setOpen(true);
|
|
194
|
+
setActive(down ? 0 : results.length - 1);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
setActive((i) => down ? Math.min(results.length - 1, i + 1) : Math.max(0, i - 1));
|
|
198
|
+
}
|
|
199
|
+
function find(e) {
|
|
200
|
+
e.preventDefault();
|
|
201
|
+
const term = query.trim();
|
|
202
|
+
if (term.length < minChars) {
|
|
203
|
+
input.current?.focus();
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (state === "results" && results.length === 1) {
|
|
207
|
+
pick(results[0]);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (state === "empty" || state === "error" && !onSearchAll) {
|
|
211
|
+
retry();
|
|
212
|
+
setOpen(true);
|
|
213
|
+
input.current?.focus();
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (onSearchAll) {
|
|
217
|
+
setOpen(false);
|
|
218
|
+
onSearchAll(term);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
setOpen(true);
|
|
222
|
+
input.current?.focus();
|
|
223
|
+
}
|
|
224
|
+
const typed = query.trim();
|
|
225
|
+
const showList = open && state !== "idle";
|
|
226
|
+
const errorLink = links?.error ? renderLink({ href: links.error.href, children: links.error.label }) : null;
|
|
227
|
+
const emptyFallback = state === "empty" && links?.empty ? links.empty(typed) : null;
|
|
228
|
+
const emptyLink = emptyFallback ? renderLink({ href: emptyFallback.href, children: emptyFallback.label }) : null;
|
|
229
|
+
const retryButton = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "skolo-search__retry", onClick: () => {
|
|
230
|
+
retry();
|
|
231
|
+
input.current?.focus();
|
|
232
|
+
}, children: t.retry });
|
|
233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("form", { className: `skolo-search${className ? ` ${className}` : ""}`, role: "search", onSubmit: find, children: [
|
|
234
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { htmlFor: `${id}-input`, className: "skolo-search__sr-only", children: t.label }),
|
|
235
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `skolo-search__box${showList ? " skolo-search__box--open" : ""}`, children: [
|
|
236
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SearchIcon, { "aria-hidden": "true", className: "skolo-search__icon" }),
|
|
237
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
238
|
+
"input",
|
|
239
|
+
{
|
|
240
|
+
ref: input,
|
|
241
|
+
id: `${id}-input`,
|
|
242
|
+
role: "combobox",
|
|
243
|
+
"aria-expanded": showList,
|
|
244
|
+
"aria-controls": listId,
|
|
245
|
+
"aria-autocomplete": "list",
|
|
246
|
+
"aria-activedescendant": showList && state === "results" && active >= 0 ? `${listId}-${active}` : void 0,
|
|
247
|
+
value: query,
|
|
248
|
+
placeholder: t.placeholder,
|
|
249
|
+
autoComplete: "off",
|
|
250
|
+
spellCheck: false,
|
|
251
|
+
onChange: (e) => {
|
|
252
|
+
setQuery(e.target.value);
|
|
253
|
+
setOpen(true);
|
|
254
|
+
},
|
|
255
|
+
onFocus: () => setOpen(true),
|
|
256
|
+
onKeyDown: onKey,
|
|
257
|
+
onBlur: () => setTimeout(() => setOpen(false), 150)
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
query && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "skolo-search__clear", "aria-label": t.clear, onClick: clear, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(XIcon, { "aria-hidden": "true" }) }),
|
|
261
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "submit", className: "skolo-search__go", children: t.submit })
|
|
262
|
+
] }),
|
|
263
|
+
showList && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skolo-search__panel", onMouseDown: (e) => e.preventDefault(), children: [
|
|
264
|
+
state === "loading" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "skolo-search__status", children: t.loading }),
|
|
265
|
+
state === "error" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "skolo-search__status", children: t.error({ retry: retryButton, link: errorLink }) }),
|
|
266
|
+
state === "empty" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "skolo-search__status", children: t.empty({ query: typed, link: emptyLink }) }),
|
|
267
|
+
state === "results" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { id: listId, role: "listbox", "aria-label": t.listLabel, children: results.map((school, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
268
|
+
"li",
|
|
269
|
+
{
|
|
270
|
+
id: `${listId}-${i}`,
|
|
271
|
+
role: "option",
|
|
272
|
+
"aria-selected": i === active,
|
|
273
|
+
className: i === active ? "skolo-search__option--active" : void 0,
|
|
274
|
+
onMouseEnter: () => setActive(i),
|
|
275
|
+
onMouseDown: (e) => {
|
|
276
|
+
e.preventDefault();
|
|
277
|
+
pick(school);
|
|
278
|
+
},
|
|
279
|
+
children: [
|
|
280
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: school.verified ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NameWithBadge, { name: school.name, badge: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BadgeCheckIcon, { role: "img", "aria-label": t.verified }) }) : school.name }),
|
|
281
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: formatPlace(school) })
|
|
282
|
+
]
|
|
283
|
+
},
|
|
284
|
+
school.id
|
|
285
|
+
)) })
|
|
286
|
+
] }),
|
|
287
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "skolo-search__sr-only", "aria-live": "polite", children: state === "results" ? t.announceResults(results.length) : state === "empty" ? t.announceEmpty : state === "error" ? t.announceError : "" })
|
|
288
|
+
] });
|
|
289
|
+
}
|
|
290
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
291
|
+
0 && (module.exports = {
|
|
292
|
+
SchoolSearch,
|
|
293
|
+
defaultMessages,
|
|
294
|
+
schoolPlace,
|
|
295
|
+
useSchoolSearch
|
|
296
|
+
});
|
|
297
|
+
//# sourceMappingURL=index.cjs.map
|