{"version":3,"file":"SortSelect.DbLuNqBa.mjs","names":["useState","useRef","useCallback","useState","useState"],"sources":["https:/framerusercontent.com/modules/mXgT5kkBIi580Fb4wcov/sehch9I0MDlDrNbPuRmM/BooksSort.js","https:/framerusercontent.com/modules/hNrwRrL0sxcprvtFWsUU/tpNkQGTOxKSkM0GiYL5w/CountDisplay.js","https:/framerusercontent.com/modules/nnkBTw21YSJVZpYcjXZf/i1CQo1c4HnkbqyT7bbxB/SortSelect.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useCallback,useEffect,useRef,useState}from\"react\";function useCurrentSort(){const[sort,setSort]=useState(\"date-desc\");useEffect(()=>{if(typeof window===\"undefined\")return;const onSort=e=>{const detail=e.detail;if(detail?.sort)setSort(detail.sort);};window.addEventListener(\"publicationsSortChange\",onSort);return()=>window.removeEventListener(\"publicationsSortChange\",onSort);},[]);return sort;}/**\n * Counts the rendered Book items inside the wrapped container and dispatches\n * a `booksCountChange` event.\n *\n * - `shown`: number of currently rendered Book items (filtered).\n * - `total`: dispatched only when no category filter is active, so CountDisplay\n *   remembers the unfiltered count across subsequent filter changes.\n *\n * Counting strategy: query anchors that link to a publication detail page.\n * This naturally excludes Framer's CMS empty-state placeholder (which has no\n * /publications/ link), so an empty collection yields shown=0 instead of 1.\n */function useDispatchCount(visible,container){useEffect(()=>{if(typeof window===\"undefined\")return;if(!visible||!container)return;let activeFilterCount=0;const countShown=()=>{const links=container.querySelectorAll('a[href*=\"/publications/\"]');return links.length;};const dispatch=()=>{const shown=countShown();const detail={shown};if(activeFilterCount===0)detail.total=shown;window.dispatchEvent(new CustomEvent(\"booksCountChange\",{detail}));};const onFilterChange=e=>{const detail=e.detail;activeFilterCount=Array.isArray(detail?.filters)?detail.filters.length:0;dispatch();};const initial=window.setTimeout(dispatch,0);const observer=new MutationObserver(dispatch);observer.observe(container,{childList:true,subtree:true});window.addEventListener(\"filterChange\",onFilterChange);return()=>{window.clearTimeout(initial);observer.disconnect();window.removeEventListener(\"filterChange\",onFilterChange);};},[visible,container]);}function createVariantOverride(matchSort){return function withVariant(Component){return /*#__PURE__*/forwardRef(function W(props,ref){const sort=useCurrentSort();const visible=sort===matchSort;const[node,setNode]=useState(null);const elRef=useRef(null);const setRef=useCallback(el=>{elRef.current=el;setNode(el);},[]);useDispatchCount(visible,node);if(!visible)return null;return /*#__PURE__*/_jsx(\"div\",{ref:setRef,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{ref:ref,...props})});});};}export function withSortDateDesc(Component){return createVariantOverride(\"date-desc\")(Component);}export function withSortDateAsc(Component){return createVariantOverride(\"date-asc\")(Component);}export function withSortPriceAsc(Component){return createVariantOverride(\"price-asc\")(Component);}export function withSortPriceDesc(Component){return createVariantOverride(\"price-desc\")(Component);}export function withSortNameAsc(Component){return createVariantOverride(\"name-asc\")(Component);}\nexport const __FramerMetadata__ = {\"exports\":{\"withSortDateDesc\":{\"type\":\"reactHoc\",\"name\":\"withSortDateDesc\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSortNameAsc\":{\"type\":\"reactHoc\",\"name\":\"withSortNameAsc\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSortDateAsc\":{\"type\":\"reactHoc\",\"name\":\"withSortDateAsc\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSortPriceAsc\":{\"type\":\"reactHoc\",\"name\":\"withSortPriceAsc\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSortPriceDesc\":{\"type\":\"reactHoc\",\"name\":\"withSortPriceDesc\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BooksSort.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useState}from\"react\";/**\n * Renders \"xx件表示 / 全yy件\" using the actual rendered count and total\n * dispatched by BooksSort overrides via \"booksCountChange\" CustomEvents.\n *\n * Layout: outer flex container fills the available width so the inner span\n * can be aligned via justifyContent.\n */export default function CountDisplay({fallbackTotal=0,align=\"right\",fontSize=13,color=\"#000\",style}){const[shown,setShown]=useState(null);const[total,setTotal]=useState(null);useEffect(()=>{if(typeof window===\"undefined\")return;const handler=e=>{const detail=e.detail;if(typeof detail?.shown===\"number\")setShown(detail.shown);if(typeof detail?.total===\"number\")setTotal(detail.total);};window.addEventListener(\"booksCountChange\",handler);return()=>window.removeEventListener(\"booksCountChange\",handler);},[]);const resolvedTotal=total??fallbackTotal;const resolvedShown=shown??resolvedTotal;const text=`${resolvedShown}件表示 / 全${resolvedTotal}件`;const justify=align===\"right\"?\"flex-end\":align===\"center\"?\"center\":\"flex-start\";return /*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",justifyContent:justify,width:\"100%\",...style},children:/*#__PURE__*/_jsx(\"span\",{style:{fontSize,color,fontFamily:\"'Sawarabi Gothic', sans-serif\",letterSpacing:\"0.04em\",lineHeight:1.6,whiteSpace:\"nowrap\"},children:text})});}addPropertyControls(CountDisplay,{fallbackTotal:{type:ControlType.Number,title:\"Fallback Total\",defaultValue:0,min:0,max:9999,step:1,description:\"イベント未受信時に表示する全件数\"},align:{type:ControlType.Enum,title:\"Align\",options:[\"left\",\"right\",\"center\"],optionTitles:[\"Left\",\"Right\",\"Center\"],defaultValue:\"right\"},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:13,min:10,max:24,step:1,unit:\"px\"},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CountDisplay\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CountDisplay.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useState}from\"react\";const OPTIONS=[{value:\"date-desc\",label:\"出版年月日の新しい順\"},{value:\"date-asc\",label:\"出版年月日の古い順\"},{value:\"price-asc\",label:\"価格の安い順\"},{value:\"price-desc\",label:\"価格の高い順\"},{value:\"name-asc\",label:\"タイトル順\"}];const CARET_BG=\"url(\\\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23000' d='M0 0l5 6 5-6z'/></svg>\\\")\";export default function SortSelect({initialSort=\"date-desc\",width,style}){const[sort,setSort]=useState(initialSort);useEffect(()=>{setSort(initialSort);if(typeof window!==\"undefined\"){window.dispatchEvent(new CustomEvent(\"publicationsSortChange\",{detail:{sort:initialSort}}));}},[initialSort]);function handleChange(e){const next=e.target.value;setSort(next);if(typeof window!==\"undefined\"){window.dispatchEvent(new CustomEvent(\"publicationsSortChange\",{detail:{sort:next}}));}}return /*#__PURE__*/_jsx(\"select\",{value:sort,onChange:handleChange,\"aria-label\":\"並び替え\",style:{padding:\"8px 32px 8px 12px\",border:\"1px solid #000\",borderRadius:0,backgroundColor:\"#fff\",color:\"#000\",fontSize:13,lineHeight:1.4,fontFamily:\"'Sawarabi Gothic', sans-serif\",letterSpacing:\"0.04em\",cursor:\"pointer\",appearance:\"none\",WebkitAppearance:\"none\",MozAppearance:\"none\",backgroundImage:CARET_BG,backgroundRepeat:\"no-repeat\",backgroundPosition:\"right 12px center\",width:width?`${width}px`:\"100%\",boxSizing:\"border-box\",...style},children:OPTIONS.map(o=>/*#__PURE__*/_jsx(\"option\",{value:o.value,children:o.label},o.value))});}addPropertyControls(SortSelect,{initialSort:{type:ControlType.Enum,title:\"Initial\",options:[\"date-desc\",\"date-asc\",\"price-asc\",\"price-desc\",\"name-asc\"],optionTitles:[\"出版年月日の新しい順\",\"出版年月日の古い順\",\"価格の安い順\",\"価格の高い順\",\"タイトル順\"],defaultValue:\"date-desc\"},width:{type:ControlType.Number,title:\"Width (px)\",defaultValue:220,min:80,max:400,step:10}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",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