@zappie/foundations 0.21.0 → 0.22.1

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
@@ -1,5 +1,32 @@
1
1
  # @zappie/foundations
2
2
 
3
+ ## 0.22.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [48bff20]
8
+ - @zappie/sdk@0.22.0
9
+
10
+ ## 0.22.0
11
+
12
+ ### Minor Changes
13
+
14
+ - a6f2200: `useCategorySpy` in `@zappie/foundations/site` returns the menu's active category: the last one whose heading has scrolled up to its `scroll-margin-top`, or to a `line` you pass. Arriving with `?category=` scrolls to that category, except on Back or Forward to a page already shown, where the restored scroll stands.
15
+
16
+ The starter's category links mark the category the shopper has scrolled to.
17
+
18
+ - e93e157: `@zappie/sdk/rich-text` reads merchant rich text without a DOM, so it runs in a loader, a Worker or SSR: `parseRichText` gives its nodes with the entities decoded, and `plainText` its text on one line. `@zappie/foundations/rich-text` re-exports both and adds `sanitizeRichText`, the shared sanitizer on that parser. `zappie/no-unsafe-html` accepts HTML passed through the imported `sanitizeRichText`.
19
+
20
+ The starter's item sheet shows a description's formatting, and the About page shows descriptions as text, never as tags.
21
+
22
+ - 8182c0c: `createSearchIndex` also matches a word inside a word ("cake" finds "Cheesecake"), ranked under a prefix, and no longer searches the tags and entities in a description's HTML.
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [50fb80a]
27
+ - Updated dependencies [e93e157]
28
+ - @zappie/sdk@0.21.0
29
+
3
30
  ## 0.21.0
4
31
 
5
32
  ### Minor Changes
package/README.md CHANGED
@@ -45,7 +45,7 @@ Want ready-made, styled components instead? Copy them into your project from the
45
45
  | `@zappie/foundations/item-sheet` | A product sheet over the current page in a React Router site |
46
46
  | `@zappie/foundations/bag` | The bag over the page, its address and the "added" notice |
47
47
  | `@zappie/foundations/bag/server` | The `/cart` and `/checkout` redirects that open the bag |
48
- | `@zappie/foundations/site` | Page views, the table page check, page titles and the closed page's data type |
48
+ | `@zappie/foundations/site` | Page views, the table page check, titles, the active category and the closed page's data |
49
49
  | `@zappie/foundations/site/customer` | The signed-in pages' gate and the checkout return page's state |
50
50
  | `@zappie/foundations/site/server` | A React Router site's load context, server client, document handler and closed page data |
51
51
  | `@zappie/foundations/rich-text` | Sanitising and parsing merchant rich text before you render it |
@@ -842,6 +842,19 @@ Maps after mount, calls `onLoadError(error)` on a failure and shows “Map locat
842
842
  unavailable” when either point has no valid coordinates. It fits again when the
843
843
  points, the route or its size change.
844
844
 
845
+ ## Search
846
+
847
+ `createSearchIndex(menu)` returns `search(query)`: items and categories, best first. Every word must match a name,
848
+ tag or description at the start of a word, inside a word, or with one typo from four letters. Accents, case and
849
+ description markup are ignored. Pass its results, filtered and grouped your way, to `<Search.Root source={{ results }}>`
850
+ for the listbox, its keys and its announcement.
851
+
852
+ ## Rich text
853
+
854
+ `@zappie/foundations/rich-text` runs on the server and in the browser with no DOM: `sanitizeRichText(html)` keeps
855
+ the formatting tags without attributes and drops the rest, and `parseRichText` and `plainText` are the SDK's. Use
856
+ `createSanitizeRichText` with `rich-text/browser`'s parser for the DOM's.
857
+
845
858
  ## Site plumbing
846
859
 
847
860
  Every React Router site runs the same plumbing around its own pages. These parts hold it, so a site keeps only its
@@ -868,6 +881,9 @@ address redirects) are in `@zappie/sdk/server`.
868
881
  - `useAtTable()` is true on a route whose `handle` is `IN_VENUE_HANDLE`.
869
882
  - `pageTitle(store, page)` titles a page in the store's own pattern.
870
883
  - `isClosedPage(data)` tells the closed page's data from the shop's.
884
+ - `useCategorySpy(ids, { prefix, line, jump })` returns `[active, setActive]`: the last category whose heading
885
+ (`id={prefix + id}`, `c-` by default) has scrolled up to its `scroll-margin-top`, or to `line`. It jumps to
886
+ `?category=` on arrival, but not on Back or Forward, so the restored scroll stands.
871
887
 
872
888
  `@zappie/foundations/site/customer` is for the customer's pages:
873
889
 
package/dist/index.d.ts CHANGED
@@ -927,7 +927,8 @@ type SearchResult = {
927
927
  };
928
928
  /**
929
929
  * Index item names, tags and descriptions plus category names and descriptions for local search.
930
- * Matches case- and accent-insensitive prefixes and allows a single edit for query tokens of at least four characters.
930
+ * Matches case- and accent-insensitive prefixes, then words containing the token, and allows a single edit for query
931
+ * tokens of at least four characters. Description HTML tags and entities are not indexed.
931
932
  *
932
933
  * @param menu - The menu snapshot you want to search.
933
934
  * @returns A search function that requires every query token to match and sorts results by descending score.
@@ -1,4 +1,5 @@
1
1
  export { a as ParseRichText, P as ParsedRichTextNode, c as createSanitizeRichText } from '../core-Cd-_zlQx.js';
2
+ export { parseRichText, plainText } from '@zappie/sdk/rich-text';
2
3
 
3
4
  /**
4
5
  * The separator used to store multiple menu info banners in a single string.
@@ -7,4 +8,7 @@ declare const BANNER_DELIMITER = "<::>";
7
8
  /** Split a stored info-banner value into individual banner HTML fragments. */
8
9
  declare const splitInfoBanner: (infoBanner?: string | null) => string[];
9
10
 
10
- export { BANNER_DELIMITER, splitInfoBanner };
11
+ /** Sanitize merchant rich text with the shared policy, on the server or in the browser, with no DOM. */
12
+ declare const sanitizeRichText: (html?: string | null) => string;
13
+
14
+ export { BANNER_DELIMITER, sanitizeRichText, splitInfoBanner };
@@ -1,2 +1,2 @@
1
- export*from"./banners.js";export*from"./core.js";
1
+ export*from"./banners.js";export*from"./core.js";export*from"./string.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/rich-text/index.ts"],
4
- "mappings": "AAAA,WAAc,eACd,WAAc",
4
+ "mappings": "AAAA,WAAc,eACd,WAAc,YACd,WAAc",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,2 @@
1
+ import{parseRichText}from"@zappie/sdk/rich-text";import{createSanitizeRichText}from"./core.js";import{parseRichText as parseRichText2,plainText}from"@zappie/sdk/rich-text";var sanitizeRichText=/*@__PURE__ */createSanitizeRichText(parseRichText);export{parseRichText2 as parseRichText,plainText,sanitizeRichText};
2
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/rich-text/string.ts"],
4
+ "mappings": "AAAA,OAAS,kBAAqB,wBAC9B,OAAS,2BAA8B,YAEvC,OAAS,iBAAAA,eAAe,cAAiB,wBAGlC,IAAM,iBACX,eAAgB,uBAAuB,aAAa",
5
+ "names": ["parseRichText"]
6
+ }
@@ -1,2 +1,2 @@
1
- function normalizeSearch(text){return text.normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean)}function near(a,b){if(Math.abs(a.length-b.length)>1){return false}let i=0;let j=0;let edits=0;while(i<a.length&&j<b.length){if(a[i]===b[j]){i++;j++;continue}if(++edits>1){return false}if(a.length===b.length){if(a[i]===b[j+1]&&a[i+1]===b[j]){i+=2;j+=2}else{i++;j++}}else if(a.length>b.length){i++}else{j++}}return edits+(a.length-i)+(b.length-j)<=1}function createSearchIndex(menu){const entries=[...Object.values(menu.items).map(item=>({result:{type:"item",item},fields:[normalizeSearch(item.name),normalizeSearch(item.tags.join(" ")),normalizeSearch(item.description??"")]})),...menu.categories.map(category=>({result:{type:"category",category},fields:[normalizeSearch(category.name),[],normalizeSearch(category.description??"")]}))];return query=>{const tokens=normalizeSearch(query);if(!tokens.length){return[]}const results=[];for(const entry of entries){let score=0;for(const token of tokens){let best=0;for(let field=0;field<entry.fields.length;field++){const weight=[30,20,10][field];for(const word of entry.fields[field]){if(word.startsWith(token)){best=Math.max(best,weight+(word===token?3:2))}else if(token.length>=4&&near(token,word)){best=Math.max(best,weight)}}}if(!best){score=0;break}score+=best}if(score){results.push({...entry.result,score})}}return results.sort((a,b)=>b.score-a.score)}}export{createSearchIndex,normalizeSearch};
1
+ function normalizeSearch(text){return text.replace(/<[^>]*>|&#?\w+;/g," ").normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean)}function near(a,b){if(Math.abs(a.length-b.length)>1){return false}let i=0;let j=0;let edits=0;while(i<a.length&&j<b.length){if(a[i]===b[j]){i++;j++;continue}if(++edits>1){return false}if(a.length===b.length){if(a[i]===b[j+1]&&a[i+1]===b[j]){i+=2;j+=2}else{i++;j++}}else if(a.length>b.length){i++}else{j++}}return edits+(a.length-i)+(b.length-j)<=1}function createSearchIndex(menu){const entries=[...Object.values(menu.items).map(item=>({result:{type:"item",item},fields:[normalizeSearch(item.name),normalizeSearch(item.tags.join(" ")),normalizeSearch(item.description??"")]})),...menu.categories.map(category=>({result:{type:"category",category},fields:[normalizeSearch(category.name),[],normalizeSearch(category.description??"")]}))];return query=>{const tokens=normalizeSearch(query);if(!tokens.length){return[]}const results=[];for(const entry of entries){let score=0;for(const token of tokens){let best=0;for(let field=0;field<entry.fields.length;field++){const weight=[30,20,10][field];for(const word of entry.fields[field]){if(word.startsWith(token)){best=Math.max(best,weight+(word===token?3:2))}else if(token.length>=4&&near(token,word)){best=Math.max(best,weight)}else if(word.includes(token)){best=Math.max(best,weight-1)}}}if(!best){score=0;break}score+=best}if(score){results.push({...entry.result,score})}}return results.sort((a,b)=>b.score-a.score)}}export{createSearchIndex,normalizeSearch};
2
2
  //# sourceMappingURL=engine.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/search/engine.ts"],
4
- "mappings": "AAOO,SAAS,gBAAgB,KAAc,CAC5C,OAAO,KACJ,UAAU,KAAK,EACf,QAAQ,UAAW,EAAE,EACrB,YAAY,EACZ,MAAM,iBAAiB,EACvB,OAAO,OAAO,CACnB,CACA,SAAS,KAAK,EAAW,EAAW,CAClC,GAAI,KAAK,IAAI,EAAE,OAAS,EAAE,MAAM,EAAI,EAAG,CACrC,MAAO,MACT,CACA,IAAI,EAAI,EACR,IAAI,EAAI,EACR,IAAI,MAAQ,EACZ,MAAO,EAAI,EAAE,QAAU,EAAI,EAAE,OAAQ,CACnC,GAAI,EAAE,CAAC,IAAM,EAAE,CAA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ACF,CACA,OAAO,QAAQ,KAAK,CAAC,EAAG,IAAM,EAAE,MAAQ,EAAE,KAAK,CACjD,CACF",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,2 @@
1
+ import{useEffect,useState}from"react";import{useLocation,useNavigationType,useSearchParams}from"react-router";var shown=new Set;function useCategorySpy(ids,{prefix="c-",line,jump=true}={}){const[query]=useSearchParams();const{key}=useLocation();const returning=useNavigationType()==="POP"&&shown.has(key);const wanted=query.get("category");const[active,setActive]=useState(wanted&&ids.includes(wanted)?wanted:ids[0]);const list=ids.join("\n");useEffect(()=>{shown.add(key);if(jump&&wanted&&!returning){document.getElementById(prefix+wanted)?.scrollIntoView({block:"start"})}},[wanted]);useEffect(()=>{const ids2=list?list.split("\n"):[];const onScroll=()=>{let current=ids2[0];for(const id of ids2){const heading=document.getElementById(prefix+id);if(heading&&heading.getBoundingClientRect().top<=(line??parseFloat(getComputedStyle(heading).scrollMarginTop)+4)){current=id}}setActive(current)};onScroll();addEventListener("scroll",onScroll,{passive:true});return()=>removeEventListener("scroll",onScroll)},[list,prefix,line]);return[active,setActive]}export{useCategorySpy};
2
+ //# sourceMappingURL=category-spy.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/site/category-spy.ts"],
4
+ "mappings": "AAAA,OAAS,UAAW,aAAgB,QACpC,OAAS,YAAa,kBAAmB,oBAAuB,eAGhE,IAAM,MAAQ,IAAI,IAiBX,SAAS,eACd,IACA,CAAE,OAAS,KAAM,KAAM,KAAO,IAAK,EAAwB,CAAC,EAC5D,CACA,KAAM,CAAC,KAAK,EAAI,gBAAgB,EAChC,KAAM,CAAE,GAAI,EAAI,YAAY,EAC5B,MAAM,UAAY,kBAAkB,IAAM,OAAS,MAAM,IAAI,GAAG,EAChE,MAAM,OAAS,MAAM,IAAI,UAAU,EACnC,KAAM,CAAC,OAAQ,SAAS,EAAI,SAC1B,QAAU,IAAI,SAAS,MAAM,EAAI,OAAS,IAAI,CAAC,CACjD,EACA,MAAM,KAAO,IAAI,KAAK,IAAI,EAC1B,UAAU,IAAM,CACd,MAAM,IAAI,GAAG,EACb,GAAI,MAAQ,QAAU,CAAC,UAAW,CAChC,SACG,eAAe,OAAS,MAAM,GAC7B,eAAe,CAAE,MAAO,OAAQ,CAAC,CACvC,CACF,EAAG,CAAC,MAAM,CAAC,EACX,UAAU,IAAM,CACd,MAAMA,KAAM,KAAO,KAAK,MAAM,IAAI,EAAI,CAAC,EACvC,MAAM,SAAW,IAAM,CACrB,IAAI,QAAUA,KAAI,CAAC,EACnB,UAAW,MAAMA,KAAK,CACpB,MAAM,QAAU,SAAS,eAAe,OAAS,EAAE,EACnD,GACE,SACA,QAAQ,sBAAsB,EAAE,MAC7B,MAAQ,WAAW,iBAAiB,OAAO,EAAE,eAAe,EAAI,GACnE,CACA,QAAU,EACZ,CACF,CACA,UAAU,OAAO,CACnB,EACA,SAAS,EACT,iBAAiB,SAAU,SAAU,CAAE,QAAS,IAAK,CAAC,EACtD,MAAO,IAAM,oBAAoB,SAAU,QAAQ,CACrD,EAAG,CAAC,KAAM,OAAQ,IAAI,CAAC,EACvB,MAAO,CAAC,OAAQ,SAAS,CAC3B",
5
+ "names": ["ids"]
6
+ }
@@ -1,3 +1,4 @@
1
+ import * as react from 'react';
1
2
  export { C as ClosedPageData, i as isClosedPage, p as pageTitle } from '../title-CgphFqNB.js';
2
3
  import '@zappie/sdk';
3
4
 
@@ -14,6 +15,22 @@ declare const IN_VENUE_HANDLE: {
14
15
  */
15
16
  declare function useAtTable(): boolean;
16
17
 
18
+ /** Where useCategorySpy finds a category's heading and when it counts as reached. */
19
+ type CategorySpyOptions = {
20
+ /** A category's heading id is this prefix and its id. Defaults to "c-". */
21
+ prefix?: string;
22
+ /** The line, in px from the top of the viewport, a heading has reached. Defaults to its scroll-margin-top plus 4. */
23
+ line?: number;
24
+ /** Whether arriving with `?category=` scrolls to that category. Defaults to true. */
25
+ jump?: boolean;
26
+ };
27
+ /**
28
+ * The menu's active category: the last one whose heading has scrolled up to the line under the sticky controls.
29
+ * Arriving with `?category=` scrolls to it, except on Back or Forward to a page already shown, where the restored
30
+ * scroll stands. Set the active category yourself when a tab is chosen.
31
+ */
32
+ declare function useCategorySpy(ids: readonly string[], { prefix, line, jump }?: CategorySpyOptions): readonly [string | undefined, react.Dispatch<react.SetStateAction<string | undefined>>];
33
+
17
34
  /** Props for {@link PageViews}. */
18
35
  type PageViewsProps = {
19
36
  /** The store's name, which the visit records. */
@@ -31,5 +48,5 @@ type PageViewsProps = {
31
48
  */
32
49
  declare function PageViews({ storeName, enabled }: PageViewsProps): null;
33
50
 
34
- export { IN_VENUE_HANDLE, PageViews, useAtTable };
35
- export type { PageViewsProps };
51
+ export { IN_VENUE_HANDLE, PageViews, useAtTable, useCategorySpy };
52
+ export type { CategorySpyOptions, PageViewsProps };
@@ -1,2 +1,2 @@
1
- "use client";import{IN_VENUE_HANDLE,useAtTable}from"./at-table.js";import{isClosedPage}from"./closed.js";import{PageViews}from"./page-views.js";import{pageTitle}from"./title.js";export{IN_VENUE_HANDLE,PageViews,isClosedPage,pageTitle,useAtTable};
1
+ "use client";import{IN_VENUE_HANDLE,useAtTable}from"./at-table.js";import{useCategorySpy}from"./category-spy.js";import{isClosedPage}from"./closed.js";import{PageViews}from"./page-views.js";import{pageTitle}from"./title.js";export{IN_VENUE_HANDLE,PageViews,isClosedPage,pageTitle,useAtTable,useCategorySpy};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/site/index.ts"],
4
- "mappings": "aACA,OAAS,gBAAiB,eAAkB,gBAC5C,OAAS,iBAAyC,cAClD,OAAS,cAAsC,kBAC/C,OAAS,cAAiB",
4
+ "mappings": "aACA,OAAS,gBAAiB,eAAkB,gBAC5C,OAAS,mBAA+C,oBACxD,OAAS,iBAAyC,cAClD,OAAS,cAAsC,kBAC/C,OAAS,cAAiB",
5
5
  "names": []
6
6
  }
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- var PACKAGE_VERSION=true?"0.21.0":"0.0.0-development";export{PACKAGE_VERSION};
1
+ var PACKAGE_VERSION=true?"0.22.1":"0.0.0-development";export{PACKAGE_VERSION};
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zappie/foundations",
3
- "version": "0.21.0",
3
+ "version": "0.22.1",
4
4
  "description": "UI-less React primitives for Zappie storefronts: behaviour, state and accessibility without styles.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -101,7 +101,7 @@
101
101
  "peerDependencies": {
102
102
  "react": "^18.2.0 || ^19.0.0",
103
103
  "react-dom": "^18.2.0 || ^19.0.0",
104
- "@zappie/sdk": "^0.20.0",
104
+ "@zappie/sdk": "^0.22.0",
105
105
  "react-router": "^8.4.0"
106
106
  },
107
107
  "peerDependenciesMeta": {
@@ -118,7 +118,7 @@
118
118
  "@types/google.maps": "^3.66.7",
119
119
  "esbuild": "^0.28.2",
120
120
  "react-router": "8.5.0",
121
- "@zappie/sdk": "0.20.0"
121
+ "@zappie/sdk": "0.22.0"
122
122
  },
123
123
  "license": "MIT",
124
124
  "homepage": "https://github.com/zappie/storefront-packages#readme",