@mailwoman/react 0.0.1 → 7.4.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.
Files changed (143) hide show
  1. package/README.md +34 -4
  2. package/common/ClientOnly.tsx +30 -0
  3. package/common/CopyButton.tsx +44 -0
  4. package/common/KindBadge.tsx +44 -0
  5. package/common/LoadingIndicator.tsx +104 -0
  6. package/common/PresetChips.tsx +43 -0
  7. package/common/cx.ts +34 -0
  8. package/common/useClipboard.ts +73 -0
  9. package/common/useDebouncedValue.ts +23 -0
  10. package/index.ts +83 -4
  11. package/out/common/ClientOnly.d.ts +22 -0
  12. package/out/common/ClientOnly.d.ts.map +1 -0
  13. package/out/common/ClientOnly.js +20 -0
  14. package/out/common/ClientOnly.js.map +1 -0
  15. package/out/common/CopyButton.d.ts +21 -0
  16. package/out/common/CopyButton.d.ts.map +1 -0
  17. package/out/common/CopyButton.js +7 -0
  18. package/out/common/CopyButton.js.map +1 -0
  19. package/out/common/KindBadge.d.ts +24 -0
  20. package/out/common/KindBadge.d.ts.map +1 -0
  21. package/out/common/KindBadge.js +6 -0
  22. package/out/common/KindBadge.js.map +1 -0
  23. package/out/common/LoadingIndicator.d.ts +27 -0
  24. package/out/common/LoadingIndicator.d.ts.map +1 -0
  25. package/out/common/LoadingIndicator.js +41 -0
  26. package/out/common/LoadingIndicator.js.map +1 -0
  27. package/out/common/PresetChips.d.ts +22 -0
  28. package/out/common/PresetChips.d.ts.map +1 -0
  29. package/out/common/PresetChips.js +5 -0
  30. package/out/common/PresetChips.js.map +1 -0
  31. package/out/common/cx.d.ts +13 -0
  32. package/out/common/cx.d.ts.map +1 -0
  33. package/out/common/cx.js +28 -0
  34. package/out/common/cx.js.map +1 -0
  35. package/out/common/useClipboard.d.ts +16 -0
  36. package/out/common/useClipboard.d.ts.map +1 -0
  37. package/out/common/useClipboard.js +56 -0
  38. package/out/common/useClipboard.js.map +1 -0
  39. package/out/common/useDebouncedValue.d.ts +11 -0
  40. package/out/common/useDebouncedValue.d.ts.map +1 -0
  41. package/out/common/useDebouncedValue.js +19 -0
  42. package/out/common/useDebouncedValue.js.map +1 -0
  43. package/out/index.d.ts +57 -4
  44. package/out/index.d.ts.map +1 -1
  45. package/out/index.js +37 -4
  46. package/out/index.js.map +1 -1
  47. package/out/pipeline/CandidatePicker.d.ts +17 -0
  48. package/out/pipeline/CandidatePicker.d.ts.map +1 -0
  49. package/out/pipeline/CandidatePicker.js +6 -0
  50. package/out/pipeline/CandidatePicker.js.map +1 -0
  51. package/out/pipeline/ComponentTable.d.ts +14 -0
  52. package/out/pipeline/ComponentTable.d.ts.map +1 -0
  53. package/out/pipeline/ComponentTable.js +6 -0
  54. package/out/pipeline/ComponentTable.js.map +1 -0
  55. package/out/pipeline/ConfidenceCell.d.ts +13 -0
  56. package/out/pipeline/ConfidenceCell.d.ts.map +1 -0
  57. package/out/pipeline/ConfidenceCell.js +22 -0
  58. package/out/pipeline/ConfidenceCell.js.map +1 -0
  59. package/out/pipeline/PipelineExplorer.d.ts +25 -0
  60. package/out/pipeline/PipelineExplorer.d.ts.map +1 -0
  61. package/out/pipeline/PipelineExplorer.js +27 -0
  62. package/out/pipeline/PipelineExplorer.js.map +1 -0
  63. package/out/pipeline/QueryForm.d.ts +19 -0
  64. package/out/pipeline/QueryForm.d.ts.map +1 -0
  65. package/out/pipeline/QueryForm.js +9 -0
  66. package/out/pipeline/QueryForm.js.map +1 -0
  67. package/out/pipeline/ResolvedPlace.d.ts +16 -0
  68. package/out/pipeline/ResolvedPlace.d.ts.map +1 -0
  69. package/out/pipeline/ResolvedPlace.js +14 -0
  70. package/out/pipeline/ResolvedPlace.js.map +1 -0
  71. package/out/pipeline/copy.d.ts +11 -0
  72. package/out/pipeline/copy.d.ts.map +1 -0
  73. package/out/pipeline/copy.js +31 -0
  74. package/out/pipeline/copy.js.map +1 -0
  75. package/out/pipeline/presets.d.ts +12 -0
  76. package/out/pipeline/presets.d.ts.map +1 -0
  77. package/out/pipeline/presets.js +21 -0
  78. package/out/pipeline/presets.js.map +1 -0
  79. package/out/pipeline/types.d.ts +110 -0
  80. package/out/pipeline/types.d.ts.map +1 -0
  81. package/out/pipeline/types.js +12 -0
  82. package/out/pipeline/types.js.map +1 -0
  83. package/out/pipeline/useParsePipeline.d.ts +34 -0
  84. package/out/pipeline/useParsePipeline.d.ts.map +1 -0
  85. package/out/pipeline/useParsePipeline.js +55 -0
  86. package/out/pipeline/useParsePipeline.js.map +1 -0
  87. package/out/poi/AbstainPanel.d.ts +14 -0
  88. package/out/poi/AbstainPanel.d.ts.map +1 -0
  89. package/out/poi/AbstainPanel.js +5 -0
  90. package/out/poi/AbstainPanel.js.map +1 -0
  91. package/out/poi/LiveResultsBlock.d.ts +21 -0
  92. package/out/poi/LiveResultsBlock.d.ts.map +1 -0
  93. package/out/poi/LiveResultsBlock.js +7 -0
  94. package/out/poi/LiveResultsBlock.js.map +1 -0
  95. package/out/poi/OverpassBlock.d.ts +15 -0
  96. package/out/poi/OverpassBlock.d.ts.map +1 -0
  97. package/out/poi/OverpassBlock.js +11 -0
  98. package/out/poi/OverpassBlock.js.map +1 -0
  99. package/out/poi/POIExplorer.d.ts +25 -0
  100. package/out/poi/POIExplorer.d.ts.map +1 -0
  101. package/out/poi/POIExplorer.js +31 -0
  102. package/out/poi/POIExplorer.js.map +1 -0
  103. package/out/poi/QueryInput.d.ts +17 -0
  104. package/out/poi/QueryInput.d.ts.map +1 -0
  105. package/out/poi/QueryInput.js +5 -0
  106. package/out/poi/QueryInput.js.map +1 -0
  107. package/out/poi/SubjectPanel.d.ts +15 -0
  108. package/out/poi/SubjectPanel.d.ts.map +1 -0
  109. package/out/poi/SubjectPanel.js +5 -0
  110. package/out/poi/SubjectPanel.js.map +1 -0
  111. package/out/poi/runtime.d.ts +34 -0
  112. package/out/poi/runtime.d.ts.map +1 -0
  113. package/out/poi/runtime.js +43 -0
  114. package/out/poi/runtime.js.map +1 -0
  115. package/out/poi/types.d.ts +86 -0
  116. package/out/poi/types.d.ts.map +1 -0
  117. package/out/poi/types.js +12 -0
  118. package/out/poi/types.js.map +1 -0
  119. package/out/poi/usePOISearch.d.ts +35 -0
  120. package/out/poi/usePOISearch.d.ts.map +1 -0
  121. package/out/poi/usePOISearch.js +123 -0
  122. package/out/poi/usePOISearch.js.map +1 -0
  123. package/package.json +52 -8
  124. package/pipeline/CandidatePicker.tsx +45 -0
  125. package/pipeline/ComponentTable.tsx +41 -0
  126. package/pipeline/ConfidenceCell.tsx +33 -0
  127. package/pipeline/PipelineExplorer.tsx +148 -0
  128. package/pipeline/QueryForm.tsx +52 -0
  129. package/pipeline/ResolvedPlace.tsx +50 -0
  130. package/pipeline/copy.ts +37 -0
  131. package/pipeline/presets.ts +24 -0
  132. package/pipeline/types.ts +118 -0
  133. package/pipeline/useParsePipeline.ts +84 -0
  134. package/poi/AbstainPanel.tsx +22 -0
  135. package/poi/LiveResultsBlock.tsx +70 -0
  136. package/poi/OverpassBlock.tsx +37 -0
  137. package/poi/POIExplorer.tsx +102 -0
  138. package/poi/QueryInput.tsx +26 -0
  139. package/poi/SubjectPanel.tsx +44 -0
  140. package/poi/runtime.ts +53 -0
  141. package/poi/types.ts +82 -0
  142. package/poi/usePOISearch.ts +183 -0
  143. package/styles.css +627 -0
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * @copyright Sister Software
4
+ * @license AGPL-3.0
5
+ * @author Teffen Ellis, et al.
6
+ *
7
+ * `POIExplorer` — the composed POI-intent tester. Detects a POI subject in free text, shows the
8
+ * category + OverpassQL export, and (when a live-search probe is injected) searches the published
9
+ * poi.db layer. The intent path is self-contained — no weights, no network. All runtime concerns are
10
+ * in {@link usePOISearch}; this file is composition + a `ClientOnly` SSR boundary.
11
+ */
12
+ import { useState } from "react";
13
+ import { ClientOnly } from "../common/ClientOnly.js";
14
+ import { KindBadge } from "../common/KindBadge.js";
15
+ import { PresetChips } from "../common/PresetChips.js";
16
+ import { AbstainPanel } from "./AbstainPanel.js";
17
+ import { LiveResultsBlock } from "./LiveResultsBlock.js";
18
+ import { OverpassBlock } from "./OverpassBlock.js";
19
+ import { QueryInput } from "./QueryInput.js";
20
+ import { POI_DEFAULT_TEXT, POI_PRESETS } from "./runtime.js";
21
+ import { SubjectPanel } from "./SubjectPanel.js";
22
+ import { usePOISearch } from "./usePOISearch.js";
23
+ function POIExplorerInner({ defaultText, presets, loadRuntime, runLiveSearch }) {
24
+ const [text, setText] = useState(defaultText);
25
+ const { result, liveSearch, searchLive } = usePOISearch({ text, loadRuntime, runLiveSearch });
26
+ return (_jsxs("div", { className: "mw-poi-explorer", children: [_jsx(QueryInput, { id: "mw-poi-input", label: "Query", value: text, onChange: setText, placeholder: POI_DEFAULT_TEXT }), _jsx(PresetChips, { presets: presets, onPick: setText }), result ? (_jsxs("div", { className: "mw-result", children: [_jsx(KindBadge, { kindResult: result.kindResult }), result.subject ? (_jsxs(_Fragment, { children: [_jsx(SubjectPanel, { subject: result.subject }), _jsx(OverpassBlock, { overpassQL: result.overpassQL, overpassError: result.overpassError }), runLiveSearch && !result.subject.buildLocal ? (_jsx(LiveResultsBlock, { categoryLabel: result.subject.category.label, anchor: result.subject.remainder, state: liveSearch, onSearch: searchLive })) : null] })) : (_jsx(AbstainPanel, { kind: result.kindResult.kind }))] })) : null] }));
27
+ }
28
+ export function POIExplorer({ defaultText = POI_DEFAULT_TEXT, presets = POI_PRESETS, loadRuntime, runLiveSearch, }) {
29
+ return (_jsx(ClientOnly, { fallback: _jsx("div", { className: "mw-poi-explorer", children: _jsx("p", { children: "Loading POI tester\u2026" }) }), children: () => (_jsx(POIExplorerInner, { defaultText: defaultText, presets: presets, loadRuntime: loadRuntime, runLiveSearch: runLiveSearch })) }));
30
+ }
31
+ //# sourceMappingURL=POIExplorer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"POIExplorer.js","sourceRoot":"","sources":["../../poi/POIExplorer.ts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ACzB,KAAC,SAAS,IAAC,UAAU,EAAE,MAAM,CAAC,UAAU,GAAI,EAE3C,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CACjB,8BACC,KAAC,YAAY,IAAC,OAAO,EAAE,MAAM,CAAC,OAAO,GAAI,EACzC,KAAC,aAAa,IAAC,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,GAAI,EAEpF,aAAa,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAC9C,KAAC,gBAAgB,IAChB,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAC5C,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,EAChC,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,UAAU,GACnB,CACF,CAAC,CAAC,CAAC,IAAI,IACN,CACH,CAAC,CAAC,CAAC,CACH,KAAC,YAAY,IAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,GAAI,CAC9C,IACI,CACN,CAAC,CAAC,CAAC,IAAI,IACH,CACN,CAAA;AACF,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,EAC3B,WAAW,GAAG,gBAAgB,EAC9B,OAAO,GAAG,WAAW,EACrB,WAAW,EACX,aAAa,GACK;IAClB,OAAO,CACN,KAAC,UAAU,IACV,QAAQ,EACP,cAAK,SAAS,EAAC,iBAAiB,YAC/B,mDAA0B,GACrB,YAGN,GAAG,EAAE,CAAC,CACN,KAAC,gBAAgB,IAChB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,GAC3B,CACF,GACW,CACb,CAAA;AACF,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `QueryInput` — the labelled text field for the POI explorer. Controlled; presentational only.
7
+ */
8
+ import type { ReactNode } from "react";
9
+ export interface QueryInputProps {
10
+ id: string;
11
+ label: string;
12
+ value: string;
13
+ onChange: (value: string) => void;
14
+ placeholder?: string;
15
+ }
16
+ export declare function QueryInput({ id, label, value, onChange, placeholder }: QueryInputProps): ReactNode;
17
+ //# sourceMappingURL=QueryInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryInput.d.ts","sourceRoot":"","sources":["../../poi/QueryInput.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,MAAM,WAAW,eAAe;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,eAAe,GAAG,SAAS,CAOlG"}
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export function QueryInput({ id, label, value, onChange, placeholder }) {
3
+ return (_jsxs("div", { className: "mw-field", children: [_jsx("label", { htmlFor: id, children: label }), _jsx("input", { id: id, type: "text", value: value, onChange: (e) => onChange(e.target.value), placeholder: placeholder })] }));
4
+ }
5
+ //# sourceMappingURL=QueryInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryInput.js","sourceRoot":"","sources":["../../poi/QueryInput.tsx"],"names":[],"mappings":";AAkBA,MAAM,UAAU,UAAU,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAmB;IACtF,OAAO,CACN,eAAK,SAAS,EAAC,UAAU,aACxB,gBAAO,OAAO,EAAE,EAAE,YAAG,KAAK,GAAS,EACnC,gBAAO,EAAE,EAAE,EAAE,EAAE,IAAI,EAAC,MAAM,EAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,WAAW,GAAI,IAC3G,CACN,CAAA;AACF,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `SubjectPanel` — renders the detected POI subject: the category chip, the optional build-local
7
+ * badge + note, and the match-detail list (matched phrase, confidence, anchor). Presentational.
8
+ */
9
+ import type { ReactNode } from "react";
10
+ import type { POISubject } from "./types.ts";
11
+ export interface SubjectPanelProps {
12
+ subject: POISubject;
13
+ }
14
+ export declare function SubjectPanel({ subject }: SubjectPanelProps): ReactNode;
15
+ //# sourceMappingURL=SubjectPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubjectPanel.d.ts","sourceRoot":"","sources":["../../poi/SubjectPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,UAAU,CAAA;CACnB;AAED,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,EAAE,iBAAiB,GAAG,SAAS,CA0BtE"}
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ export function SubjectPanel({ subject }) {
3
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "mw-subject__row", children: [_jsx("span", { className: "mw-subject__chip", children: subject.category.label }), subject.buildLocal ? _jsx("span", { className: "mw-subject__badge", children: "build-local" }) : null] }), _jsxs("dl", { className: "mw-subject__detail", children: [_jsx("dt", { children: "matched phrase" }), _jsx("dd", { children: _jsx("code", { children: subject.matchedPhrase }) }), _jsx("dt", { children: "confidence" }), _jsxs("dd", { children: [Math.round(subject.confidence * 100), "%"] }), _jsx("dt", { children: "anchor" }), _jsx("dd", { children: subject.remainder ? subject.remainder : _jsx("em", { children: "none \u2014 global query" }) })] }), subject.buildLocal ? (_jsx("p", { className: "mw-subject__note", children: "Requires the locally-built OSM layer (ODbL) \u2014 mailwoman ships the builder, not the data." })) : null] }));
4
+ }
5
+ //# sourceMappingURL=SubjectPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubjectPanel.js","sourceRoot":"","sources":["../../poi/SubjectPanel.tsx"],"names":[],"mappings":";AAiBA,MAAM,UAAU,YAAY,CAAC,EAAE,OAAO,EAAqB;IAC1D,OAAO,CACN,8BACC,eAAK,SAAS,EAAC,iBAAiB,aAC/B,eAAM,SAAS,EAAC,kBAAkB,YAAE,OAAO,CAAC,QAAQ,CAAC,KAAK,GAAQ,EACjE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,mBAAmB,4BAAmB,CAAC,CAAC,CAAC,IAAI,IAC9E,EAEN,cAAI,SAAS,EAAC,oBAAoB,aACjC,0CAAuB,EACvB,uBACC,yBAAO,OAAO,CAAC,aAAa,GAAQ,GAChC,EACL,sCAAmB,EACnB,yBAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,GAAG,GAAG,CAAC,SAAO,EAChD,kCAAe,EACf,uBAAK,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,oDAA4B,GAAM,IAC3E,EAEJ,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CACrB,YAAG,SAAS,EAAC,kBAAkB,8GAE3B,CACJ,CAAC,CAAC,CAAC,IAAI,IACN,CACH,CAAA;AACF,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * The default POI runtime loader + presentation helpers. `loadPOIRuntime` dynamically imports the
7
+ * ~2k-record Overture taxonomy snapshot (so bundlers code-split it into its own chunk, fetched only
8
+ * when the explorer actually mounts) and wires the kind classifier over it. Pure + browser-safe: no
9
+ * network, no DOM — the whole intent path runs offline.
10
+ */
11
+ import type { POIRuntime } from "./types.ts";
12
+ /**
13
+ * Build the POI runtime, dynamically importing the taxonomy JSON so the ~2k-record table lands in its own chunk. A
14
+ * static import would inline the whole snapshot into every consumer's bundle.
15
+ */
16
+ export declare function loadPOIRuntime(): Promise<POIRuntime>;
17
+ /** Default example queries for the POI explorer. */
18
+ export declare const POI_PRESETS: readonly [{
19
+ readonly label: "Drinking fountain";
20
+ readonly value: "drinking fountain near Springfield";
21
+ }, {
22
+ readonly label: "Fire hydrant";
23
+ readonly value: "fire hydrant";
24
+ }, {
25
+ readonly label: "Hospital + address";
26
+ readonly value: "hospital, 350 5th Ave, New York";
27
+ }, {
28
+ readonly label: "Biking trails";
29
+ readonly value: "biking trails near Portland";
30
+ }];
31
+ export declare const POI_DEFAULT_TEXT: "drinking fountain near Springfield";
32
+ /** `742 m` under 1 km, `1.9 km` past it — matches the demo's distance captions. */
33
+ export declare function formatDistance(distanceM: number): string;
34
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../poi/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,UAAU,CAAC,CAc1D;AAED,oDAAoD;AACpD,eAAO,MAAM,WAAW;;;;;;;;;;;;EAKd,CAAA;AAEV,eAAO,MAAM,gBAAgB,sCAAuB,CAAA;AAEpD,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAIxD"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * The default POI runtime loader + presentation helpers. `loadPOIRuntime` dynamically imports the
7
+ * ~2k-record Overture taxonomy snapshot (so bundlers code-split it into its own chunk, fetched only
8
+ * when the explorer actually mounts) and wires the kind classifier over it. Pure + browser-safe: no
9
+ * network, no DOM — the whole intent path runs offline.
10
+ */
11
+ import { createKindClassifier } from "@mailwoman/kind-classifier";
12
+ import { createPOITaxonomyLookup } from "@mailwoman/poi-taxonomy/table";
13
+ /**
14
+ * Build the POI runtime, dynamically importing the taxonomy JSON so the ~2k-record table lands in its own chunk. A
15
+ * static import would inline the whole snapshot into every consumer's bundle.
16
+ */
17
+ export async function loadPOIRuntime() {
18
+ const table = (await import("@mailwoman/poi-taxonomy/data/taxonomy.json")).default;
19
+ const lookup = createPOITaxonomyLookup(table);
20
+ // Adapt `POITaxonomyLookup.lookupPOICategory` to the `POIPhraseLookup` shape the classifier expects.
21
+ const lexicon = (phrase, locale) => lookup.lookupPOICategory(phrase, locale).map((match) => ({
22
+ kind: "category",
23
+ categoryID: match.category.id,
24
+ matchedPhrase: match.matchedPhrase,
25
+ confidence: match.confidence,
26
+ }));
27
+ return { lookup, lexicon, classify: createKindClassifier({ poiLexicon: lexicon }) };
28
+ }
29
+ /** Default example queries for the POI explorer. */
30
+ export const POI_PRESETS = [
31
+ { label: "Drinking fountain", value: "drinking fountain near Springfield" },
32
+ { label: "Fire hydrant", value: "fire hydrant" },
33
+ { label: "Hospital + address", value: "hospital, 350 5th Ave, New York" },
34
+ { label: "Biking trails", value: "biking trails near Portland" },
35
+ ];
36
+ export const POI_DEFAULT_TEXT = POI_PRESETS[0].value;
37
+ /** `742 m` under 1 km, `1.9 km` past it — matches the demo's distance captions. */
38
+ export function formatDistance(distanceM) {
39
+ if (distanceM < 1000)
40
+ return `${Math.round(distanceM)} m`;
41
+ return `${(distanceM / 1000).toFixed(1)} km`;
42
+ }
43
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../poi/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AAIvE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IACnC,MAAM,KAAK,GAAG,CAAC,MAAM,MAAM,CAAC,4CAA4C,CAAC,CAAC,CAAC,OAAO,CAAA;IAClF,MAAM,MAAM,GAAG,uBAAuB,CAAC,KAAiE,CAAC,CAAA;IAEzG,qGAAqG;IACrG,MAAM,OAAO,GAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CACnD,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxD,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE;QAC7B,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,UAAU,EAAE,KAAK,CAAC,UAAU;KAC5B,CAAC,CAAC,CAAA;IAEJ,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,EAAE,CAAA;AACpF,CAAC;AAED,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,oCAAoC,EAAE;IAC3E,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,EAAE;IAChD,EAAE,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,iCAAiC,EAAE;IACzE,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,6BAA6B,EAAE;CACvD,CAAA;AAEV,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AAEpD,mFAAmF;AACnF,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC/C,IAAI,SAAS,GAAG,IAAI;QAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAA;IAEzD,OAAO,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAA;AAC7C,CAAC"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Types for the POI explorer. The intent path (classification → subject → OverpassQL) is fully
7
+ * self-contained over the pure `@mailwoman/*` packages; the live poi.db path is expressed only as an
8
+ * INJECTED async function ({@link POILiveSearch}) so the httpvfs/worker machinery stays out of this
9
+ * package's browser graph (it lives in the docs site, which knows where the layer is served).
10
+ */
11
+ import type { POIPhraseLookup, QueryKindResult } from "@mailwoman/kind-classifier";
12
+ import type { createKindClassifier } from "@mailwoman/kind-classifier";
13
+ import type { createPOITaxonomyLookup } from "@mailwoman/poi-taxonomy/table";
14
+ export type TaxonomyLookup = ReturnType<typeof createPOITaxonomyLookup>;
15
+ export type CategoryRecord = NonNullable<ReturnType<TaxonomyLookup["getPOICategory"]>>;
16
+ /** The lazily-loaded POI runtime: the taxonomy lookup, the adapted lexicon, and the kind classifier over it. */
17
+ export interface POIRuntime {
18
+ lookup: TaxonomyLookup;
19
+ lexicon: POIPhraseLookup;
20
+ classify: ReturnType<typeof createKindClassifier>;
21
+ }
22
+ /** A resolved POI subject — the category the query names plus its match metadata. */
23
+ export interface POISubject {
24
+ category: CategoryRecord;
25
+ matchedPhrase: string;
26
+ confidence: number;
27
+ /** The non-subject remainder of the query (the location anchor, e.g. "near Springfield"). */
28
+ remainder: string;
29
+ /** Whether this category needs the locally-built OSM (ODbL) layer — precomputed off the runtime. */
30
+ buildLocal: boolean;
31
+ }
32
+ /** The intent-only result: the kind verdict plus (when a subject was detected) its OverpassQL export. */
33
+ export interface POIExplorerResult {
34
+ kindResult: QueryKindResult;
35
+ subject?: POISubject;
36
+ overpassQL?: string;
37
+ overpassError?: string;
38
+ }
39
+ /** One live poi.db hit, as the results list renders it. */
40
+ export interface POISearchHit {
41
+ name: string;
42
+ lat: number;
43
+ lon: number;
44
+ distanceM: number;
45
+ country: string;
46
+ confidence: number;
47
+ }
48
+ /**
49
+ * Result of an injected live search. Preserves the original tester's two failure modes — the anchor not resolving vs
50
+ * the published layer being unreachable — so the UI can word them differently.
51
+ */
52
+ export type POILiveSearchResult = {
53
+ status: "success";
54
+ hits: POISearchHit[];
55
+ centerName: string;
56
+ } | {
57
+ status: "unplaced";
58
+ anchor: string;
59
+ } | {
60
+ status: "unavailable";
61
+ };
62
+ /**
63
+ * The injected live-search function. Given the resolved category (+ its Overture leaf fan-out) and the anchor text, it
64
+ * probes the published poi.db and returns hits. Absent ⇒ the explorer runs intent-only (no "Search live" button).
65
+ */
66
+ export type POILiveSearch = (params: {
67
+ categoryID: string;
68
+ overtureCategoryIDs: string[];
69
+ anchor: string;
70
+ }) => Promise<POILiveSearchResult>;
71
+ /** "Search live" state machine. */
72
+ export type LiveSearchState = {
73
+ status: "idle";
74
+ } | {
75
+ status: "loading";
76
+ } | {
77
+ status: "error";
78
+ message: string;
79
+ } | {
80
+ status: "success";
81
+ hits: POISearchHit[];
82
+ centerName: string;
83
+ };
84
+ /** A single-argument runtime loader — injectable so stories/tests can substitute a mock taxonomy. */
85
+ export type LoadPOIRuntime = () => Promise<POIRuntime>;
86
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAC5B;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,YAAY,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC/D;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,MAAM,EAAE,aAAa,CAAA;CAAE,CAAA;AAE5B;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE;IACpC,UAAU,EAAE,MAAM,CAAA;IAClB,mBAAmB,EAAE,MAAM,EAAE,CAAA;IAC7B,MAAM,EAAE,MAAM,CAAA;CACd,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAElC,mCAAmC;AACnC,MAAM,MAAM,eAAe,GACxB;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,YAAY,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAA;AAElE,qGAAqG;AACrG,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Types for the POI explorer. The intent path (classification → subject → OverpassQL) is fully
7
+ * self-contained over the pure `@mailwoman/*` packages; the live poi.db path is expressed only as an
8
+ * INJECTED async function ({@link POILiveSearch}) so the httpvfs/worker machinery stays out of this
9
+ * package's browser graph (it lives in the docs site, which knows where the layer is served).
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../poi/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `usePOISearch` — the headless core of the POI explorer. Owns the taxonomy-runtime load, the
7
+ * debounced classify → subject → OverpassQL derivation, and the "Search live" state machine. The
8
+ * runtime loader and the live-search probe are both INJECTABLE, so stories/tests drive it with mocks
9
+ * and no network or db. Presentation is entirely the caller's concern.
10
+ */
11
+ import type { LiveSearchState, LoadPOIRuntime, POIExplorerResult, POILiveSearch } from "./types.ts";
12
+ export interface UsePOISearchOptions {
13
+ /** The current query text (controlled by the caller). */
14
+ text: string;
15
+ /** Runtime loader. @default loadPOIRuntime */
16
+ loadRuntime?: LoadPOIRuntime;
17
+ /** Injected live-search probe. Absent ⇒ the live-results affordance is disabled. */
18
+ runLiveSearch?: POILiveSearch;
19
+ /** Debounce before (re)classifying. @default 250 */
20
+ debounceMs?: number;
21
+ }
22
+ export interface UsePOISearch {
23
+ /** True once the taxonomy runtime has loaded. */
24
+ runtimeReady: boolean;
25
+ /** The intent result for the current (debounced) query, or null for empty input. */
26
+ result: POIExplorerResult | null;
27
+ /** State of the on-demand live poi.db search. */
28
+ liveSearch: LiveSearchState;
29
+ /** Whether a live search can run right now (a probe is wired + there's a resolved subject with an anchor). */
30
+ canSearchLive: boolean;
31
+ /** Kick off a live search for the current subject. No-op when {@link canSearchLive} is false. */
32
+ searchLive: () => Promise<void>;
33
+ }
34
+ export declare function usePOISearch({ text, loadRuntime, runLiveSearch, debounceMs, }: UsePOISearchOptions): UsePOISearch;
35
+ //# sourceMappingURL=usePOISearch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePOISearch.d.ts","sourceRoot":"","sources":["../../poi/usePOISearch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAc,MAAM,YAAY,CAAA;AAE/G,MAAM,WAAW,mBAAmB;IACnC,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAA;IACZ,8CAA8C;IAC9C,WAAW,CAAC,EAAE,cAAc,CAAA;IAC5B,oFAAoF;IACpF,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,YAAY;IAC5B,iDAAiD;IACjD,YAAY,EAAE,OAAO,CAAA;IACrB,oFAAoF;IACpF,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAChC,iDAAiD;IACjD,UAAU,EAAE,eAAe,CAAA;IAC3B,8GAA8G;IAC9G,aAAa,EAAE,OAAO,CAAA;IACtB,iGAAiG;IACjG,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC/B;AA2BD,wBAAgB,YAAY,CAAC,EAC5B,IAAI,EACJ,WAA4B,EAC5B,aAAa,EACb,UAAgB,GAChB,EAAE,mBAAmB,GAAG,YAAY,CA2GpC"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `usePOISearch` — the headless core of the POI explorer. Owns the taxonomy-runtime load, the
7
+ * debounced classify → subject → OverpassQL derivation, and the "Search live" state machine. The
8
+ * runtime loader and the live-search probe are both INJECTABLE, so stories/tests drive it with mocks
9
+ * and no network or db. Presentation is entirely the caller's concern.
10
+ */
11
+ import { matchPOISubject } from "@mailwoman/kind-classifier";
12
+ import { emitOverpassQL } from "@mailwoman/poi-taxonomy/overpass";
13
+ import { computeQueryShape } from "@mailwoman/query-shape";
14
+ import { useCallback, useEffect, useRef, useState } from "react";
15
+ import { useDebouncedValue } from "../common/useDebouncedValue.js";
16
+ import { loadPOIRuntime } from "./runtime.js";
17
+ /** Compute the OverpassQL export for a matched subject, capturing any emitter error rather than throwing. */
18
+ function buildOverpass(runtime, categoryID, matchedPhrase, remainder) {
19
+ const category = runtime.lookup.getPOICategory(categoryID);
20
+ if (!category) {
21
+ return {};
22
+ }
23
+ const intent = {
24
+ subject: { kind: "category", categoryID, matched: matchedPhrase },
25
+ ...(remainder ? { anchor: { text: remainder } } : {}),
26
+ };
27
+ try {
28
+ return { overpassQL: emitOverpassQL(intent, category.osmTag ? { osmTag: category.osmTag } : {}) };
29
+ }
30
+ catch (err) {
31
+ return { overpassError: err instanceof Error ? err.message : String(err) };
32
+ }
33
+ }
34
+ export function usePOISearch({ text, loadRuntime = loadPOIRuntime, runLiveSearch, debounceMs = 250, }) {
35
+ const [runtime, setRuntime] = useState(null);
36
+ const [result, setResult] = useState(null);
37
+ const [liveSearch, setLiveSearch] = useState({ status: "idle" });
38
+ const debouncedText = useDebouncedValue(text, debounceMs);
39
+ // Capture the loader in a ref so the load fires exactly ONCE on mount, regardless of whether the
40
+ // caller passes a fresh `loadRuntime` closure each render (an inline `async () => …` would otherwise
41
+ // retrigger the effect → reload → re-render loop). The runtime is a load-once resource.
42
+ const loadRuntimeRef = useRef(loadRuntime);
43
+ loadRuntimeRef.current = loadRuntime;
44
+ useEffect(() => {
45
+ let cancelled = false;
46
+ loadRuntimeRef.current().then((loaded) => {
47
+ if (!cancelled) {
48
+ setRuntime(loaded);
49
+ }
50
+ });
51
+ return () => {
52
+ cancelled = true;
53
+ };
54
+ }, []);
55
+ // Classify the debounced query and derive the subject + OverpassQL (async, so it lives in an effect).
56
+ useEffect(() => {
57
+ if (!runtime)
58
+ return;
59
+ let cancelled = false;
60
+ const trimmed = debouncedText.trim();
61
+ // A new query invalidates live results from the previous one.
62
+ setLiveSearch({ status: "idle" });
63
+ if (!trimmed) {
64
+ setResult(null);
65
+ return;
66
+ }
67
+ const input = { raw: trimmed, normalized: trimmed };
68
+ const shape = computeQueryShape(trimmed);
69
+ runtime.classify(input, shape).then((kindResult) => {
70
+ if (cancelled)
71
+ return;
72
+ const matched = kindResult.kind === "poi_query" ? matchPOISubject(trimmed, undefined, runtime.lexicon) : null;
73
+ const category = matched ? runtime.lookup.getPOICategory(matched.match.categoryID) : undefined;
74
+ if (!matched || !category) {
75
+ setResult({ kindResult });
76
+ return;
77
+ }
78
+ setResult({
79
+ kindResult,
80
+ subject: {
81
+ category,
82
+ matchedPhrase: matched.match.matchedPhrase,
83
+ confidence: matched.match.confidence,
84
+ remainder: matched.remainder,
85
+ buildLocal: runtime.lookup.requiresBuildLocalLayer(category),
86
+ },
87
+ ...buildOverpass(runtime, matched.match.categoryID, matched.match.matchedPhrase, matched.remainder),
88
+ });
89
+ });
90
+ return () => {
91
+ cancelled = true;
92
+ };
93
+ }, [debouncedText, runtime]);
94
+ const subject = result?.subject;
95
+ const canSearchLive = Boolean(runLiveSearch && runtime && subject && !subject.buildLocal && subject.remainder.trim().length > 0);
96
+ const searchLive = useCallback(async () => {
97
+ if (!runLiveSearch || !runtime || !subject || subject.buildLocal || !subject.remainder.trim())
98
+ return;
99
+ setLiveSearch({ status: "loading" });
100
+ try {
101
+ const outcome = await runLiveSearch({
102
+ categoryID: subject.category.id,
103
+ // Fan the canonical seed id out over its Overture leaves — the same translation the Node reader uses.
104
+ overtureCategoryIDs: runtime.lookup.resolveOvertureCategories(subject.category.id),
105
+ anchor: subject.remainder,
106
+ });
107
+ if (outcome.status === "success") {
108
+ setLiveSearch({ status: "success", hits: outcome.hits, centerName: outcome.centerName });
109
+ }
110
+ else if (outcome.status === "unplaced") {
111
+ setLiveSearch({ status: "error", message: `couldn't place "${outcome.anchor}"` });
112
+ }
113
+ else {
114
+ setLiveSearch({ status: "error", message: "the published POI layer isn't reachable" });
115
+ }
116
+ }
117
+ catch {
118
+ setLiveSearch({ status: "error", message: "the published POI layer isn't reachable" });
119
+ }
120
+ }, [runLiveSearch, runtime, subject]);
121
+ return { runtimeReady: runtime !== null, result, liveSearch, canSearchLive, searchLive };
122
+ }
123
+ //# sourceMappingURL=usePOISearch.js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AAU,EAAE,CAAC;gBAC1C,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;YAClF,CAAC;iBAAM,CAAC;gBACP,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,yCAAyC,EAAE,CAAC,CAAA;YACvF,CAAC;QACF,CAAC;QAAC,MAAM,CAAC;YACR,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,yCAAyC,EAAE,CAAC,CAAA;QACvF,CAAC;IACF,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IAErC,OAAO,EAAE,YAAY,EAAE,OAAO,KAAK,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,CAAA;AACzF,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mailwoman/react",
3
- "version": "0.0.1",
4
- "description": "React components + headless hooks for mailwoman — parse/geocode/POI explorers, Storybook-tested, Docusaurus-independent. 0.0.1 is a name-reservation placeholder; the first functional release ships with the next mailwoman minor.",
3
+ "version": "7.4.0",
4
+ "description": "React components + headless hooks for mailwoman — parse/geocode/POI explorers, Storybook-tested, Docusaurus-independent.",
5
5
  "license": "AGPL-3.0-only OR LicenseRef-Commercial",
6
6
  "repository": {
7
7
  "type": "git",
@@ -13,6 +13,8 @@
13
13
  "out/**/*.js.map",
14
14
  "out/**/*.d.ts",
15
15
  "out/**/*.d.ts.map",
16
+ "README.md",
17
+ "styles.css",
16
18
  "*.ts",
17
19
  "*.tsx",
18
20
  "**/*.ts",
@@ -20,21 +22,63 @@
20
22
  "!*.test.ts",
21
23
  "!*.test.tsx",
22
24
  "!**/*.test.ts",
23
- "!**/*.test.tsx"
25
+ "!**/*.test.tsx",
26
+ "!**/*.stories.ts",
27
+ "!**/*.stories.tsx",
28
+ "!.storybook/**",
29
+ "!vitest.config.ts",
30
+ "!test/**",
31
+ "!out/test/**",
32
+ "!out/storybook-static/**",
33
+ "!storybook-static/**"
24
34
  ],
25
35
  "type": "module",
26
36
  "exports": {
27
37
  "./package.json": "./package.json",
38
+ "./styles.css": "./styles.css",
28
39
  ".": {
29
- "node": "./index.ts",
30
- "default": "./out/index.js",
31
- "types": "./out/index.d.ts"
40
+ "types": "./out/index.d.ts",
41
+ "default": "./out/index.js"
32
42
  }
33
43
  },
34
44
  "publishConfig": {
35
- "access": "public"
45
+ "access": "public",
46
+ "exports": {
47
+ "./package.json": "./package.json",
48
+ "./styles.css": "./styles.css",
49
+ ".": {
50
+ "types": "./out/index.d.ts",
51
+ "default": "./out/index.js"
52
+ }
53
+ }
54
+ },
55
+ "scripts": {
56
+ "storybook": "storybook dev -p 6007 --no-open",
57
+ "build-storybook": "storybook build",
58
+ "test:browser": "vitest run --config vitest.config.ts"
59
+ },
60
+ "dependencies": {
61
+ "@mailwoman/kind-classifier": "7.4.0",
62
+ "@mailwoman/poi-taxonomy": "7.4.0",
63
+ "@mailwoman/query-shape": "7.4.0"
64
+ },
65
+ "devDependencies": {
66
+ "@storybook/addon-docs": "^10.5.0",
67
+ "@storybook/react-vite": "^10.5.0",
68
+ "@types/react": "^19.2.17",
69
+ "@types/react-dom": "^19.2.3",
70
+ "@vitejs/plugin-react": "^6.0.3",
71
+ "@vitest/browser": "4.1.10",
72
+ "@vitest/browser-playwright": "4.1.10",
73
+ "playwright": "^1.61.1",
74
+ "react": "^19.2.7",
75
+ "react-dom": "^19.2.7",
76
+ "storybook": "^10.5.0",
77
+ "vite": "^8.0.16",
78
+ "vitest": "4.1.10"
36
79
  },
37
80
  "peerDependencies": {
38
- "react": ">=18"
81
+ "react": ">=18",
82
+ "react-dom": ">=18"
39
83
  }
40
84
  }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * `CandidatePicker` — the ranked list of alternate gazetteer candidates; clicking one selects it.
7
+ * Presentational; the selected index is owned by the caller (the pipeline hook).
8
+ */
9
+
10
+ import type { ReactNode } from "react"
11
+
12
+ import { cx } from "../common/cx.ts"
13
+ import type { ResolvedPlaceView } from "./types.ts"
14
+
15
+ export interface CandidatePickerProps {
16
+ candidates: ResolvedPlaceView[]
17
+ selectedIndex: number
18
+ onSelect: (index: number) => void
19
+ }
20
+
21
+ export function CandidatePicker({ candidates, selectedIndex, onSelect }: CandidatePickerProps): ReactNode {
22
+ return (
23
+ <div className="mw-candidates">
24
+ <h2>Other candidates ({candidates.length - 1})</h2>
25
+ <ol className="mw-candidates__list">
26
+ {candidates.map((candidate, i) => (
27
+ <li key={`${candidate.id}-${i}`}>
28
+ <button
29
+ type="button"
30
+ className={cx("mw-candidates__btn", { "mw-candidates__btn--active": i === selectedIndex })}
31
+ onClick={() => onSelect(i)}
32
+ title={`${candidate.placetype} • WOF ${candidate.id} • score ${candidate.score.toFixed(3)}`}
33
+ >
34
+ <span className="mw-candidates__rank">#{i + 1}</span>
35
+ <span className="mw-candidates__name">{candidate.name}</span>
36
+ <span className="mw-candidates__meta">
37
+ {candidate.placetype} · {candidate.score.toFixed(2)}
38
+ </span>
39
+ </button>
40
+ </li>
41
+ ))}
42
+ </ol>
43
+ </div>
44
+ )
45
+ }