efficient-storefront-blocks 0.133.9 → 0.133.10
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 +15 -0
- package/dist/editor/lib/document/blocks/commerce/FilterChipsBlock/fields.js +1 -1
- package/dist/editor/lib/storefront-editor-words.d.ts +3 -0
- package/dist/editor/lib/storefront-editor-words.js +1 -1
- package/dist/index.js +27 -27
- package/dist/render/components/Lightbox.js +1 -1
- package/dist/render/components/catalog/ShopperChips.d.ts +4 -1
- package/dist/render/components/catalog/ShopperChips.js +1 -1
- package/dist/render/lib/document/blocks/commerce/FilterChipsBlock/render.js +1 -1
- package/dist/render/lib/document/blocks/text-part-shapes.json +10 -0
- package/dist/render/lib/sections/filter-chips-look.d.ts +13 -0
- package/dist/render/lib/sections/filter-chips-look.js +1 -0
- package/dist/routine-index.json +1 -1
- package/dist/value-index.json +1 -1
- package/dist/words.d.ts +3 -0
- package/dist/words.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as x,Fragment as A,jsxs as I}from"react/jsx-runtime";import{createContext as O,useCallback as R,useContext as $,useEffect as j,useLayoutEffect as H,useRef as v,useState as K}from"react";import{createPortal as P}from"react-dom";import{SITE_BLUR as B,SITE_TINT as M}from"./PopupFrame.js";import{useModalDismiss as F}from"./useModalDismiss.js";const w="sf-themed-content",G=`.${w}`,N="sf-section-accent";function V(n,s){const r={};let i=!1;const c=[];for(let e=n;e&&e!==s;e=e.parentElement)c.push(e);for(const e of c.reverse()){e.classList.contains(N)&&(i=!0);const l=e.style;if(l)for(let u=0;u<l.length;u+=1){const a=l.item(u);a.startsWith("--")&&(r[a]=l.getPropertyValue(a))}}return{className:i?`contents ${N}`:"contents",style:r}}function X(n){const s=n.querySelectorAll("a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])");return Array.from(s).filter(r=>!r.hasAttribute("hidden")&&r.getAttribute("aria-hidden")!=="true")}const S=O(()=>{});function q({open:n,onClose:s,label:r,onPrev:i,onNext:c,className:e="",children:l}){const u=v(null),a=v(null),[p,E]=K(null);H(()=>{if(!n){E(null);return}const t=u.current;if(!t)return;const f=t.closest(G),d=f?.parentElement??t.ownerDocument.body,m=V(t,d);E({host:d,theme:f?{...m,className:`${m.className} ${w}`}:m})},[n]);const y=v({onClose:s,onPrev:i,onNext:c});y.current={onClose:s,onPrev:i,onNext:c};const g=n&&p!==null,D=R(()=>y.current.onClose(),[]);return F({active:g,onDismiss:D,scopeRef:a}),j(()=>{if(!g)return;const t=a.current,f=t?.ownerDocument??document,d=f.activeElement;t?.focus();const m=o=>{if(o.key==="ArrowLeft")y.current.onPrev?.();else if(o.key==="ArrowRight")y.current.onNext?.();else if(o.key==="Tab"&&t){const h=X(t);if(h.length===0){o.preventDefault(),t.focus();return}const C=h[0],L=h[h.length-1],b=f.activeElement,_=!!b&&t.contains(b)&&b!==t;if(o.shiftKey&&(!_||b===C))o.preventDefault(),L.focus();else if(!o.shiftKey&&(!_||b===L))o.preventDefault(),C.focus();else{o.preventDefault();const k=h.indexOf(b);h[o.shiftKey?k-1:k+1]?.focus()}}},T=f.defaultView??window;return T.addEventListener("keydown",m),()=>{T.removeEventListener("keydown",m),d&&d.isConnected&&d.focus()}},[g]),n?I(A,{children:[x("span",{ref:u,hidden:!0}),p&&P(x("div",{className:p.theme.className,style:p.theme.style,children:x("div",{ref:a,role:"dialog","aria-modal":"true","aria-label":r,tabIndex:-1,onClick:s,className:`fixed inset-0 z-(--sf-layer-lightbox) outline-none ${B[8]} ${e}`,style:{background:M},children:x(S.Provider,{value:s,children:l})})}),p.host)]}):null}const Y="color-mix(in oklab, var(--bg) 70%, transparent)";function Z({className:n="absolute right-5 top-5 flex h-10 w-10 cursor-pointer items-center justify-center border border-fg-dim/40 text-fg-dim transition-colors hover:border-accent hover:text-accent",style:s,label:r="Close",children:i="×"}){const c=$(S);return x("button",{type:"button","aria-label":r,onClick:e=>{e.stopPropagation(),c()},className:n,style:s,children:i})}export{Y as LIGHTBOX_CLOSE_TINT,G as LIGHTBOX_HOST_SELECTOR,Z as LightboxClose,q as default};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import type { SlotComponent } from "efficient-easel/blocks";
|
|
2
2
|
import type { CardPressTitle } from "efficient-web-builder/render/lib/document/card-press-titles";
|
|
3
3
|
import type { FirstShown } from "../../lib/wheels/shopper-first-paint.js";
|
|
4
|
+
import { type FilterChipsLook } from "../../lib/sections/filter-chips-look.js";
|
|
4
5
|
export type ChipsOwner = {
|
|
5
6
|
id: string;
|
|
6
7
|
template?: SlotComponent;
|
|
7
8
|
pressTitles?: readonly CardPressTitle[];
|
|
8
9
|
};
|
|
9
|
-
export default function ShopperChips({ owner, showCount, showClear, showSort, firstShown, editing, }: {
|
|
10
|
+
export default function ShopperChips({ owner, showCount, showClear, showSort, firstShown, editing, look, countWord, }: {
|
|
10
11
|
owner: ChipsOwner;
|
|
11
12
|
showCount: boolean;
|
|
12
13
|
showClear: boolean;
|
|
13
14
|
showSort: boolean;
|
|
15
|
+
look?: FilterChipsLook;
|
|
16
|
+
countWord?: string;
|
|
14
17
|
firstShown?: FirstShown;
|
|
15
18
|
editing?: boolean;
|
|
16
19
|
}): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as
|
|
1
|
+
"use client";import{jsx as e,Fragment as v,jsxs as L}from"react/jsx-runtime";import{CardTemplateRows as H}from"efficient-web-builder/render/components/CardRowContext";import{cardRow as M}from"efficient-web-builder/format/lib/content/card-template";import{say as U}from"efficient-web-builder/format/lib/editor-words";import{useCurrency as W}from"../CurrencyContext.js";import{formatPrice as D}from"../../lib/commerce.js";import{filterChipItems as X,filterStateWithoutChip as Z,optionCardRows as $}from"../../lib/sections/filter-option-rows.js";import{PlpResultRange as A,PlpToolbar as F}from"../wheels-plp/PlpToolbar.js";import N from"./ClearAllButton.js";import w from"./SortSelect.js";import{hasActivePlpFilters as q,plpSortKeysFor as z,PLP_SORT_LABELS as J}from"../../lib/wheels/plp-filters.js";import{itemKind as Q,plpKindNoun as V}from"../../lib/catalog/plp-item.js";import{CATALOG_TEXT_SIZE as ee}from"../../lib/sections/catalog-text-size.js";import{EMPTY_PLP_FILTERS as te}from"../../lib/wheels/plp-filters.js";import{GALLERY_SORT_KEYS as re,GALLERY_SORT_LABELS as se}from"../../lib/sections/gallery-toolbar.js";import{chipsTotalWords as I,DEFAULT_FILTER_CHIPS_LOOK as ne}from"../../lib/sections/filter-chips-look.js";import{useShopperMember as oe}from"./ShopperScope.js";import{HideTaker as C}from"efficient-web-builder/render/components/ViewHideRoot";import{FILTER_CHIPS_TYPE as ae}from"../../lib/document/document-nodes.js";const le="✕";function ie({owner:s,showCount:n,showClear:r,showSort:i,firstShown:o,editing:a,look:t=ne,countWord:d=""}){const{ref:p,scope:l,gallery:T}=oe("chips",null,{count:n,sort:i}),{currency:f}=W(),u=(!l?.live&&o?{state:l?.state??{...te,sort:o.sort},update:()=>{},clear:()=>{},total:o.total,range:o.range,kinds:o.kinds}:null)??(l?{...l,kinds:[...new Set(l.rows.map(Q))]}:null);if(!u&&T)return e(C,{as:"div",ref:p,"data-shopper-chips":"",children:e(pe,{owner:s,gallery:T,showCount:n,showClear:r,showSort:i,editing:a,look:t,countWord:d})});if(!u)return e(C,{as:"div",ref:p,"data-shopper-chips":"",children:a&&e("p",{className:`font-mono ${ee.labelSmall} uppercase tracking-[0.2em] text-fg-dim`,children:"Filter chips show the picks of a Filters block, or the Tags of a Gallery, in this Box"})});const{state:h,update:y,clear:g,total:c,range:x,kinds:m}=u,R=V(m.length?m:["alloy-wheel"]),G=q(h),E=X(h,f,D).map(_=>({..._,mark:le,press:()=>y(B=>Z(B,_))})),b=t==="tabs",S=L(v,{children:[n&&!b&&e("div",{"data-shopper-count":"",className:"contents",children:e(A,{total:c,range:x??{from:c?1:0,to:c},noun:R})}),E.length>0&&e(K,{owner:s,chips:E,editing:a,under:b}),r&&G&&e(N,{onClick:g})]}),Y=z(m.length?m:["alloy-wheel"]),P=i?e(w,{value:h.sort,keys:Y,labels:J,onChange:_=>y({sort:_,page:1})}):void 0;return e(C,{as:"div",ref:p,"data-shopper-chips":"",children:b?e(O,{start:S,end:P,count:n?I(c,d,R.many):null}):e(F,{start:S,end:P})})}function O({start:s,end:n,count:r}){return L("div",{"data-chips-look":"tabs",className:"flex flex-col gap-y-6",children:[L("div",{className:"flex flex-wrap items-center justify-center gap-x-4 gap-y-2",children:[s,n]}),r!==null&&e("p",{"data-shopper-count":"",className:"font-mono text-xs tabular-nums text-fg-dim",children:r})]})}function K({owner:s,chips:n,selected:r,editing:i,under:o=!1}){const a=$(n,{item:t=>t,selected:(t,d)=>d===r,press:t=>t.press});return e("ul",{className:o?"flex list-none flex-wrap items-center justify-center gap-x-8 gap-y-2":"flex list-none flex-wrap items-center gap-2",children:e(H,{ownerId:s.id,ownerType:ae,Template:s.template,rows:a.items.map(M),items:a.items,states:r===void 0?void 0:a.states,stateLine:o?"under":void 0,actions:i?void 0:a.actions,pressTitles:s.pressTitles,fallback:null,wrapCopy:t=>e("li",{children:t}),children:t=>t})})}function pe({owner:s,gallery:n,showCount:r,showClear:i,showSort:o,editing:a,look:t,countWord:d}){const{tags:p,tag:l,sort:T,shown:f,pick:k,setSort:u,clear:h}=n,y=[{label:U("All"),mark:"",press:()=>k(null)},...p.map(m=>({label:m,mark:"",press:()=>k(m)}))],g=t==="tabs",c=L(v,{children:[r&&!g&&e("div",{"data-shopper-count":"",className:"contents",children:e(A,{total:f,range:{from:f?1:0,to:f},noun:j})}),p.length>0&&e(K,{owner:s,chips:y,selected:l===null?0:p.indexOf(l)+1,editing:a,under:g}),i&&l!==null&&e(N,{onClick:h})]}),x=o?e(w,{value:T,keys:re,labels:se,onChange:u}):void 0;return g?e(O,{start:c,end:x,count:r?I(f,d,j.many):null}):e(F,{start:c,end:x})}const j={many:"items"};export{ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{CARD_TEMPLATE_SLOT as e}from"efficient-web-builder/format/lib/content/card-template";import{cardPressTitlesOf as r}from"efficient-web-builder/render/lib/document/card-press-titles";import{hidableText as i}from"efficient-easel/screen/lib/document/hidable";import m from"../../../../../components/catalog/ShopperChips.js";import{FIRST_SHOWN_PROP as l}from"../../../../wheels/shopper-first-paint.js";import{FILTER_CHIPS_COUNT_WORD_PROP as s,FILTER_CHIPS_LOOK_PROP as h,resolveFilterChipsLook as f}from"../../../../sections/filter-chips-look.js";import{FilterChipsBlockMeta as C}from"./meta.js";const R={...C,render:o=>t(m,{owner:{id:String(o.id??""),template:o.template,pressTitles:r(o,e)},showCount:o.showCount!==!1,showClear:o.showClear!==!1,showSort:o.showSort===!0,firstShown:o[l],editing:o.editor?.isEditing,look:f(o[h]),countWord:i(o[s])})};export{R as FilterChipsBlockRender};
|
|
@@ -933,6 +933,16 @@
|
|
|
933
933
|
}
|
|
934
934
|
}
|
|
935
935
|
},
|
|
936
|
+
"FilterChipsBlock": {
|
|
937
|
+
"countWord": {
|
|
938
|
+
"type": "custom",
|
|
939
|
+
"__text": {
|
|
940
|
+
"control": "plainText",
|
|
941
|
+
"label": "Count word",
|
|
942
|
+
"placeholder": "items"
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
},
|
|
936
946
|
"AppointmentBooking": {
|
|
937
947
|
"eyebrow": {
|
|
938
948
|
"type": "custom",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const FILTER_CHIPS_LOOK_PROP = "chipsLook";
|
|
2
|
+
export declare const FILTER_CHIPS_LOOK_OPTIONS: readonly [{
|
|
3
|
+
readonly value: "toolbar";
|
|
4
|
+
readonly label: "Toolbar";
|
|
5
|
+
}, {
|
|
6
|
+
readonly value: "tabs";
|
|
7
|
+
readonly label: "Tabs";
|
|
8
|
+
}];
|
|
9
|
+
export type FilterChipsLook = (typeof FILTER_CHIPS_LOOK_OPTIONS)[number]["value"];
|
|
10
|
+
export declare const DEFAULT_FILTER_CHIPS_LOOK: FilterChipsLook;
|
|
11
|
+
export declare function resolveFilterChipsLook(value: unknown): FilterChipsLook;
|
|
12
|
+
export declare const FILTER_CHIPS_COUNT_WORD_PROP = "countWord";
|
|
13
|
+
export declare function chipsTotalWords(total: number, word: string, fallback: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _="chipsLook",n=[{value:"toolbar",label:"Toolbar"},{value:"tabs",label:"Tabs"}],s="toolbar";function l(o){return n.some(t=>t.value===o)?o:s}const O="countWord";function c(o,t,e){const r=t.trim()||e;return o===0?`No ${r}`:o===1&&r.length>1&&r.endsWith("s")?`1 ${r.slice(0,-1)}`:`${o} ${r}`}export{s as DEFAULT_FILTER_CHIPS_LOOK,O as FILTER_CHIPS_COUNT_WORD_PROP,n as FILTER_CHIPS_LOOK_OPTIONS,_ as FILTER_CHIPS_LOOK_PROP,c as chipsTotalWords,l as resolveFilterChipsLook};
|