efficient-storefront-blocks 0.139.2 → 0.139.4

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.
@@ -1 +1 @@
1
- import{jsx as t,jsxs as r}from"react/jsx-runtime";const m="font-mono text-[length:var(--size-label,12px)]",d="font-semibold uppercase tracking-[0.22em] text-fg";function x(e){return`${e??m} ${d}`}function f(){return t("span",{className:"text-accent",children:" *"})}function g({children:e,required:l,labelFace:n}){return r("span",{className:x(n),children:[e,l?t(f,{}):null]})}function h({label:e,required:l,hint:n,separate:p,htmlFor:s,labelFace:a,className:o,children:c}){const i=o?`flex flex-col gap-2 ${o}`:"flex flex-col gap-2",u=n?t("span",{className:"font-mono text-[11px] uppercase tracking-[0.22em] text-fg-dim",children:n}):null;return p||n?r("div",{className:i,children:[r("label",{htmlFor:s,className:x(a),children:[e,l?t(f,{}):null]}),c,u]}):r("label",{htmlFor:s,className:i,children:[t(g,{required:l,labelFace:a,children:e}),c]})}export{g as FieldCaption,h as default,x as fieldCaptionClass};
1
+ import{jsx as t,jsxs as a}from"react/jsx-runtime";const m="font-mono text-[length:var(--size-label,12px)]",d="font-semibold uppercase tracking-[0.22em] text-fg";function x(e){return`${e??m} ${d}`}function f(){return t("span",{className:"text-accent",children:" *"})}function g({children:e,required:l,labelFace:n}){return a("span",{className:x(n),children:[e,l?t(f,{}):null]})}function h({label:e,required:l,hint:n,separate:p,htmlFor:r,labelFace:s,className:o,children:c}){const i=o?`flex flex-col gap-2 ${o}`:"flex flex-col gap-2",u=n?t("span",{className:"font-mono text-[length:var(--size-label,13px)] uppercase tracking-[0.22em] text-fg-dim",children:n}):null;return p||n?a("div",{className:i,children:[a("label",{htmlFor:r,className:x(s),children:[e,l?t(f,{}):null]}),c,u]}):a("label",{htmlFor:r,className:i,children:[t(g,{required:l,labelFace:s,children:e}),c]})}export{g as FieldCaption,h as default,x as fieldCaptionClass};
@@ -2,6 +2,11 @@ import type { Data } from "efficient-easel/blocks";
2
2
  import type { SelectedRanges } from "efficient-web-builder/render/lib/content/box-show-for";
3
3
  import { type PlpSortKey } from "./plp-filters.js";
4
4
  export declare const SELECTED_RANGES_PROP = "selectedRanges";
5
+ export declare const HERO_RANGE_PICK_PROP = "rangePick";
6
+ export declare const HERO_PICK_RANDOM = "random";
7
+ export declare const BOX_RANGE_CHILDREN_PROP = "rangeChildren";
8
+ export declare const BOX_CHILDREN_ONE = "one";
9
+ export declare const BOX_CHILDREN_SLOT = "content";
5
10
  export declare const SHOPPER_ADDRESS_PROP = "shopperAddress";
6
11
  export declare function addressQueryOf(props: Readonly<Record<string, unknown>> | null | undefined): string;
7
12
  export interface ShopperAddressMark {
@@ -12,7 +17,7 @@ export type AddressQuery = string | URLSearchParams | Readonly<Record<string, st
12
17
  export declare function readSelectedRanges(query: AddressQuery, knownNames: readonly string[]): readonly string[];
13
18
  export declare function selectedRangesOf(rootProps: Readonly<Record<string, unknown>> | null | undefined): SelectedRanges | null;
14
19
  export declare function shopperAddressMarkOf(props: Readonly<Record<string, unknown>> | null | undefined): ShopperAddressMark | null;
15
- export declare function stampSelectedRanges(data: Data, query: AddressQuery, knownNames: readonly string[]): Data;
20
+ export declare function stampSelectedRanges(data: Data, query: AddressQuery, knownNames: readonly string[], random?: () => number): Data;
16
21
  export declare function stripSelectedRanges(data: Data): Data;
17
22
  export declare function pageReadsSelectedRanges(data: Data | null | undefined): boolean;
18
23
  export declare function pageReadsRangeNames(data: Data | null | undefined): boolean;
@@ -1 +1 @@
1
- import{SHOW_FOR_PROP as w,showForOf as E}from"efficient-web-builder/format/lib/content/box-show-for-choices";import{asPlpSortKey as O,plpFilterQuery as x,plpFiltersFromParams as D}from"./plp-filters.js";import{marksCurrentLink as F,menuLayoutOf as N}from"../content/tab-strip.js";import{ALLOY_WHEELS_LISTING_TYPE as T,FILTER_BLOCK_TYPE as Y,HERO_TYPE as U,MENU_BLOCK_TYPE as P,documentNodes as l,mapDocumentNodes as _}from"../document/document-nodes.js";import{documentShopperScopes as C,pageReachFilterOf as H}from"./shopper-first-paint.js";const m="selectedRanges",c="shopperAddress",d="addressQuery",Q=[T,P];function h(e){return Q.includes(e.type)?e.type===P?F(N(e.props.direction),e.props.currentPage):!0:!1}function G(e){const r=e?.[d];return typeof r=="string"?r:""}function A(e){if(typeof e=="string")return new URLSearchParams(e.replace(/^\?/,""));if(e instanceof URLSearchParams)return e;const r=new URLSearchParams;for(const[t,s]of Object.entries(e))if(typeof s=="string")r.append(t,s);else if(Array.isArray(s))for(const n of s)typeof n=="string"&&r.append(t,n);return r}function b(e,r){const t=new Set(r),s=[];for(const n of D(A(e)).collections)t.has(n)&&!s.includes(n)&&s.push(n);return s}function W(e){const r=e?.[m];if(!r||!Array.isArray(r.selected)||!Array.isArray(r.known))return null;const t=n=>n.filter(o=>typeof o=="string"),s=t(r.known);return{selected:t(r.selected).filter(n=>s.includes(n)),known:s}}function z(e){const r=e?.[c];return!r||typeof r!="object"?null:{writes:r.writes===!0,sort:O(typeof r.sort=="string"?r.sort:void 0)}}function J(e,r,t){const s=[...new Set(t)],n={selected:b(r,s),known:s},o=H(e),i=new Map;if(o){const p=O(typeof o.props?.openingSort=="string"?o.props.openingSort:void 0);i.set(o,{[c]:{writes:!0,sort:p}});for(const[u,a]of C(e))a===o&&i.set(u,{[c]:{writes:!1,sort:p}})}const R=x(A(r));if(R)for(const p of l(e))h(p)&&i.set(p,{...i.get(p),[d]:R});const f=l(e).some(k),S=i.size||f?_(e,(p,u)=>{const a=i.has(u)?{...p,props:{...p.props,...i.get(u)}}:p;return f?I(a,n.selected):a}):e,y=S.root??{};return{...S,root:{...y,props:{...y.props??{},[m]:n}}}}function g(e){const r=e?.props;return E(r?.[w])?.name}function k(e){const r=e.type===U?e.props.slides:void 0;return Array.isArray(r)&&r.some(t=>g(t)!==void 0)}function I(e,r){if(!k(e))return e;const t=e.props.slides,s=r.length?t.filter(o=>r.includes(g(o)??"")):[],n=s.length?s:t.filter(o=>g(o)===void 0);return{...e,props:{...e.props,slides:n.length?n:t.slice(0,1)}}}function V(e){const r=_(e,o=>{if(!(c in o.props)&&!(d in o.props))return o;const{[c]:i,[d]:R,...f}=o.props;return{...o,props:f}}),t=r.root;if(!t?.props||!(m in t.props))return r;const{[m]:s,...n}=t.props;return{...r,root:{...t,props:n}}}function L(e){return e.type===Y||E(e.props[w])!==void 0}function X(e){return e?l(e).some(r=>L(r)||h(r)):!1}function Z(e){return e?l(e).some(L):!1}export{m as SELECTED_RANGES_PROP,c as SHOPPER_ADDRESS_PROP,G as addressQueryOf,Z as pageReadsRangeNames,X as pageReadsSelectedRanges,b as readSelectedRanges,W as selectedRangesOf,z as shopperAddressMarkOf,J as stampSelectedRanges,V as stripSelectedRanges};
1
+ import{SHOW_FOR_PROP as h,showForOf as y}from"efficient-web-builder/format/lib/content/box-show-for-choices";import{asPlpSortKey as A,plpFilterQuery as T,plpFiltersFromParams as I}from"./plp-filters.js";import{marksCurrentLink as M,menuLayoutOf as Y}from"../content/tab-strip.js";import{ALLOY_WHEELS_LISTING_TYPE as B,FILTER_BLOCK_TYPE as b,HERO_TYPE as k,MENU_BLOCK_TYPE as w,documentNodes as R,mapDocumentNodes as x}from"../document/document-nodes.js";import{documentShopperScopes as K,pageReachFilterOf as U}from"./shopper-first-paint.js";const m="selectedRanges",G="rangePick",Q="random",X="rangeChildren",j="one",v="Flex",d="content",f="shopperAddress",g="addressQuery",W=[B,w];function L(r){return W.includes(r.type)?r.type===w?M(Y(r.props.direction),r.props.currentPage):!0:!1}function sr(r){const e=r?.[g];return typeof e=="string"?e:""}function N(r){if(typeof r=="string")return new URLSearchParams(r.replace(/^\?/,""));if(r instanceof URLSearchParams)return r;const e=new URLSearchParams;for(const[s,n]of Object.entries(r))if(typeof n=="string")e.append(s,n);else if(Array.isArray(n))for(const t of n)typeof t=="string"&&e.append(s,t);return e}function z(r,e){const s=new Set(e),n=[];for(const t of I(N(r)).collections)s.has(t)&&!n.includes(t)&&n.push(t);return n}function nr(r){const e=r?.[m];if(!e||!Array.isArray(e.selected)||!Array.isArray(e.known))return null;const s=t=>t.filter(o=>typeof o=="string"),n=s(e.known);return{selected:s(e.selected).filter(t=>n.includes(t)),known:n}}function or(r){const e=r?.[f];return!e||typeof e!="object"?null:{writes:e.writes===!0,sort:A(typeof e.sort=="string"?e.sort:void 0)}}function pr(r,e,s,n=Math.random){const t=[...new Set(s)],o={selected:z(e,t),known:t},p=U(r),c=new Map;if(p){const i=A(typeof p.props?.openingSort=="string"?p.props.openingSort:void 0);c.set(p,{[f]:{writes:!0,sort:i}});for(const[u,l]of K(r))l===p&&c.set(u,{[f]:{writes:!1,sort:i}})}const a=T(N(e));if(a)for(const i of R(r))L(i)&&c.set(i,{...c.get(i),[g]:a});const P=R(r).some(J),S=c.size||P?x(r,(i,u)=>{const l=c.has(u)?{...i,props:{...i.props,...c.get(u)}}:i;return P?Z(V(l,o.selected,n),o.selected):l}):r,E=S.root??{};return{...S,root:{...E,props:{...E.props??{},[m]:o}}}}function _(r){const e=r?.props;return y(e?.[h])?.name}function D(r){const e=r.type===k?r.props.slides:void 0;return Array.isArray(e)&&e.some(s=>_(s)!==void 0)}function O(r){return r.type===k&&r.props[G]===Q&&Array.isArray(r.props.slides)}function F(r){return r.type===v&&r.props[X]===j&&Array.isArray(r.props[d])}function J(r){return D(r)||O(r)||F(r)}function C(r,e){const s=e.length?r.filter(t=>e.includes(_(t)??"")):[],n=s.length?s:r.filter(t=>_(t)===void 0);return n.length?n:r.slice(0,1)}function V(r,e,s){const n=D(r),t=O(r);if(!n&&!t)return r;const o=r.props.slides;let p=n?C(o,e):o;return t&&p.length>1&&(p=[p[Math.min(p.length-1,Math.floor(s()*p.length))]]),{...r,props:{...r.props,slides:p}}}function Z(r,e){return F(r)?{...r,props:{...r.props,[d]:C(r.props[d],e)}}:r}function ir(r){const e=x(r,o=>{if(!(f in o.props)&&!(g in o.props))return o;const{[f]:p,[g]:c,...a}=o.props;return{...o,props:a}}),s=e.root;if(!s?.props||!(m in s.props))return e;const{[m]:n,...t}=s.props;return{...e,root:{...s,props:t}}}function H(r){return r.type===b||y(r.props[h])!==void 0}function cr(r){return r?R(r).some(e=>H(e)||L(e)||O(e)):!1}function fr(r){return r?R(r).some(H):!1}export{j as BOX_CHILDREN_ONE,d as BOX_CHILDREN_SLOT,X as BOX_RANGE_CHILDREN_PROP,Q as HERO_PICK_RANDOM,G as HERO_RANGE_PICK_PROP,m as SELECTED_RANGES_PROP,f as SHOPPER_ADDRESS_PROP,sr as addressQueryOf,fr as pageReadsRangeNames,cr as pageReadsSelectedRanges,z as readSelectedRanges,nr as selectedRangesOf,or as shopperAddressMarkOf,pr as stampSelectedRanges,ir as stripSelectedRanges};