@payloadcms/ui 3.0.2 → 3.0.3-canary.5abb7d5

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.
@@ -21,4 +21,5 @@ export { hasSavePermission } from '../../utilities/hasSavePermission.js';
21
21
  export { isClientUserObject } from '../../utilities/isClientUserObject.js';
22
22
  export { isEditing } from '../../utilities/isEditing.js';
23
23
  export { mergeListSearchAndWhere } from '../../utilities/mergeListSearchAndWhere.js';
24
+ export { sanitizeID } from '../../utilities/sanitizeID.js';
24
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/shared/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAA;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAA;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAA;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAA;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAA;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,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AAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAClE,OAAO,EACL,KAAK,aAAa,EAClB,UAAU,EACV,aAAa,EACb,KAAK,YAAY,GAClB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAA;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA"}
@@ -1,6 +1,6 @@
1
- var P=e=>{let t=o=>o.type!=="ui"&&o.admin?.disabled===!0||o?.admin?.disableListColumn===!0;return e?.reduce((o,n)=>{if(t(n))return o;let i=n.type==="tabs"&&"tabs"in n?{...n,tabs:n.tabs.map(s=>({...s,fields:s.fields.filter(a=>!t(a))}))}:n;return[...o,i]},[])};import{fieldAffectsData as b}from"payload/shared";var f=(e,t)=>e?.reduce((r,o)=>b(o)&&o.name===t?r:!b(o)&&"fields"in o?[...r,...f(o.fields,t)]:o.type==="tabs"&&"tabs"in o?[...r,...o.tabs.reduce((n,i)=>[...n,..."name"in i?[i.name]:f(i.fields,t)],[])]:[...r,o.name],[]),R=(e,t,r)=>{let o=[];if(Array.isArray(r)&&r.length>=1)o=r;else{t&&o.push(t);let n=f(e,t);o=o.concat(n),o=o.slice(0,4)}return o.map(n=>({accessor:n,active:!0}))};import*as m from"react";var x=({elements:e,translationString:t})=>{let r=/(<[^>]+>.*?<\/[^>]+>)/g,o=t.split(r);return m.createElement("span",null,o.map((n,i)=>{if(e&&n.startsWith("<")&&n.endsWith(">")){let s=n[1],a=e[s];if(a){let d=new RegExp(`<${s}>(.*?)</${s}>`,"g"),p=n.replace(d,(c,F)=>F);return m.createElement(a,{key:i},m.createElement(x,{translationString:p}))}}return n}))},L=({elements:e,i18nKey:t,t:r,variables:o})=>{let n=r(t,o||{});return e?m.createElement(x,{elements:e,translationString:n}):n};import{isReactServerComponentOrFunction as T,serverProps as I}from"payload/shared";import M from"react";function w({Component:e,sanitizeServerOnlyProps:t,toMergeIntoProps:r}){return t===void 0&&(t=!T(e)),n=>{let i=k(n,r);return t&&I.forEach(s=>{delete i[s]}),M.createElement(e,{...i})}}function k(e,t){return{...e,...t}}import{isReactServerComponentOrFunction as A}from"payload/shared";import D from"react";var z=({Component:e,serverOnlyProps:t,...r})=>e?(n=>{let i={...n,...A(e)?t??{}:{}};return D.createElement(e,{...i})})(r):null;var O=e=>({...e?.admin?.style||{},...e?.admin?.width?{"--field-width":e.admin.width}:{flex:"1 1 auto"},...e?.admin?.style?.flex?{flex:e.admin.style.flex}:{}});import{deepCopyObjectComplex as Z}from"payload/shared";var N=["validate","customComponents"],$=e=>{let t=Z(e);return N.forEach(r=>{delete t[r]}),t},B=e=>Object.keys(e).reduce((t,r)=>(t[r]=$(e[r]),t),{});import h from"react";var E=({fill:e})=>{let t=e||"var(--theme-elevation-1000)";return h.createElement("svg",{className:"graphic-icon",height:"100%",viewBox:"0 0 25 25",width:"100%",xmlns:"http://www.w3.org/2000/svg"},h.createElement("path",{d:"M11.8673 21.2336L4.40922 16.9845C4.31871 16.9309 4.25837 16.8355 4.25837 16.7282V10.1609C4.25837 10.0477 4.38508 9.97616 4.48162 10.0298L13.1404 14.9642C13.2611 15.0358 13.412 14.9464 13.412 14.8093V11.6091C13.412 11.4839 13.3456 11.3647 13.2309 11.2992L2.81624 5.36353C2.72573 5.30989 2.60505 5.30989 2.51454 5.36353L1.15085 6.14422C1.06034 6.19786 1 6.29321 1 6.40048V18.5995C1 18.7068 1.06034 18.8021 1.15085 18.8558L11.8491 24.9583C11.9397 25.0119 12.0603 25.0119 12.1509 24.9583L21.1355 19.8331C21.2562 19.7616 21.2562 19.5948 21.1355 19.5232L18.3357 17.9261C18.2211 17.8605 18.0883 17.8605 17.9737 17.9261L12.175 21.2336C12.0845 21.2872 11.9638 21.2872 11.8733 21.2336H11.8673Z",fill:t}),h.createElement("path",{d:"M22.8491 6.13827L12.1508 0.0417218C12.0603 -0.0119135 11.9397 -0.0119135 11.8491 0.0417218L6.19528 3.2658C6.0746 3.33731 6.0746 3.50418 6.19528 3.57569L8.97092 5.16091C9.08557 5.22647 9.21832 5.22647 9.33296 5.16091L11.8672 3.71872C11.9578 3.66508 12.0784 3.66508 12.1689 3.71872L19.627 7.96782C19.7175 8.02146 19.7778 8.11681 19.7778 8.22408V14.8212C19.7778 14.9464 19.8442 15.0656 19.9589 15.1311L22.7345 16.7104C22.8552 16.7819 23.006 16.6925 23.006 16.5554V6.40048C23.006 6.29321 22.9457 6.19786 22.8552 6.14423L22.8491 6.13827Z",fill:t}))};import l from"react";var U=`
1
+ var P=e=>{let t=o=>o.type!=="ui"&&o.admin?.disabled===!0||o?.admin?.disableListColumn===!0;return e?.reduce((o,n)=>{if(t(n))return o;let i=n.type==="tabs"&&"tabs"in n?{...n,tabs:n.tabs.map(s=>({...s,fields:s.fields.filter(a=>!t(a))}))}:n;return[...o,i]},[])};import{fieldAffectsData as b}from"payload/shared";var f=(e,t)=>e?.reduce((r,o)=>b(o)&&o.name===t?r:!b(o)&&"fields"in o?[...r,...f(o.fields,t)]:o.type==="tabs"&&"tabs"in o?[...r,...o.tabs.reduce((n,i)=>[...n,..."name"in i?[i.name]:f(i.fields,t)],[])]:[...r,o.name],[]),R=(e,t,r)=>{let o=[];if(Array.isArray(r)&&r.length>=1)o=r;else{t&&o.push(t);let n=f(e,t);o=o.concat(n),o=o.slice(0,4)}return o.map(n=>({accessor:n,active:!0}))};import*as m from"react";var x=({elements:e,translationString:t})=>{let r=/(<[^>]+>.*?<\/[^>]+>)/g,o=t.split(r);return m.createElement("span",null,o.map((n,i)=>{if(e&&n.startsWith("<")&&n.endsWith(">")){let s=n[1],a=e[s];if(a){let d=new RegExp(`<${s}>(.*?)</${s}>`,"g"),p=n.replace(d,(c,F)=>F);return m.createElement(a,{key:i},m.createElement(x,{translationString:p}))}}return n}))},L=({elements:e,i18nKey:t,t:r,variables:o})=>{let n=r(t,o||{});return e?m.createElement(x,{elements:e,translationString:n}):n};import{isReactServerComponentOrFunction as T,serverProps as I}from"payload/shared";import M from"react";function w({Component:e,sanitizeServerOnlyProps:t,toMergeIntoProps:r}){return t===void 0&&(t=!T(e)),n=>{let i=k(n,r);return t&&I.forEach(s=>{delete i[s]}),M.createElement(e,{...i})}}function k(e,t){return{...e,...t}}import{isReactServerComponentOrFunction as A}from"payload/shared";import D from"react";var z=({Component:e,serverOnlyProps:t,...r})=>e?(n=>{let i={...n,...A(e)?t??{}:{}};return D.createElement(e,{...i})})(r):null;var O=e=>({...e?.admin?.style||{},...e?.admin?.width?{"--field-width":e.admin.width}:{flex:"1 1 auto"},...e?.admin?.style?.flex?{flex:e.admin.style.flex}:{}});import{deepCopyObjectComplex as Z}from"payload/shared";var N=["validate","customComponents"],$=e=>{let t=Z(e);return N.forEach(r=>{delete t[r]}),t},B=e=>Object.keys(e).reduce((t,r)=>(t[r]=$(e[r]),t),{});import g from"react";var E=({fill:e})=>{let t=e||"var(--theme-elevation-1000)";return g.createElement("svg",{className:"graphic-icon",height:"100%",viewBox:"0 0 25 25",width:"100%",xmlns:"http://www.w3.org/2000/svg"},g.createElement("path",{d:"M11.8673 21.2336L4.40922 16.9845C4.31871 16.9309 4.25837 16.8355 4.25837 16.7282V10.1609C4.25837 10.0477 4.38508 9.97616 4.48162 10.0298L13.1404 14.9642C13.2611 15.0358 13.412 14.9464 13.412 14.8093V11.6091C13.412 11.4839 13.3456 11.3647 13.2309 11.2992L2.81624 5.36353C2.72573 5.30989 2.60505 5.30989 2.51454 5.36353L1.15085 6.14422C1.06034 6.19786 1 6.29321 1 6.40048V18.5995C1 18.7068 1.06034 18.8021 1.15085 18.8558L11.8491 24.9583C11.9397 25.0119 12.0603 25.0119 12.1509 24.9583L21.1355 19.8331C21.2562 19.7616 21.2562 19.5948 21.1355 19.5232L18.3357 17.9261C18.2211 17.8605 18.0883 17.8605 17.9737 17.9261L12.175 21.2336C12.0845 21.2872 11.9638 21.2872 11.8733 21.2336H11.8673Z",fill:t}),g.createElement("path",{d:"M22.8491 6.13827L12.1508 0.0417218C12.0603 -0.0119135 11.9397 -0.0119135 11.8491 0.0417218L6.19528 3.2658C6.0746 3.33731 6.0746 3.50418 6.19528 3.57569L8.97092 5.16091C9.08557 5.22647 9.21832 5.22647 9.33296 5.16091L11.8672 3.71872C11.9578 3.66508 12.0784 3.66508 12.1689 3.71872L19.627 7.96782C19.7175 8.02146 19.7778 8.11681 19.7778 8.22408V14.8212C19.7778 14.9464 19.8442 15.0656 19.9589 15.1311L22.7345 16.7104C22.8552 16.7819 23.006 16.6925 23.006 16.5554V6.40048C23.006 6.29321 22.9457 6.19786 22.8552 6.14423L22.8491 6.13827Z",fill:t}))};import l from"react";var U=`
2
2
  .graphic-logo path {
3
3
  fill: var(--theme-elevation-1000);
4
4
  }
5
- `,q=()=>l.createElement("svg",{className:"graphic-logo",fill:"none",height:"43.5",id:"b",viewBox:"0 0 193.38 43.5",width:"193.38",xmlns:"http://www.w3.org/2000/svg"},l.createElement("style",null,U),l.createElement("g",{id:"c"},l.createElement("path",{d:"M18.01,35.63l-12.36-7.13c-.15-.09-.25-.25-.25-.43v-11.02c0-.19.21-.31.37-.22l14.35,8.28c.2.12.45-.03.45-.26v-5.37c0-.21-.11-.41-.3-.52L3.01,9c-.15-.09-.35-.09-.5,0l-2.26,1.31c-.15.09-.25.25-.25.43v20.47c0,.18.1.34.25.43l17.73,10.24c.15.09.35.09.5,0l14.89-8.6c.2-.12.2-.4,0-.52l-4.64-2.68c-.19-.11-.41-.11-.6,0l-9.61,5.55c-.15.09-.35.09-.5,0Z"}),l.createElement("path",{d:"M36.21,10.3L18.48.07c-.15-.09-.35-.09-.5,0l-9.37,5.41c-.2.12-.2.4,0,.52l4.6,2.66c.19.11.41.11.6,0l4.2-2.42c.15-.09.35-.09.5,0l12.36,7.13c.15.09.25.25.25.43v11.07c0,.21.11.41.3.52l4.6,2.65c.2.12.45-.03.45-.26V10.74c0-.18-.1-.34-.25-.43Z"}),l.createElement("g",{id:"d"},l.createElement("path",{d:"M193.38,9.47c0,1.94-1.48,3.32-3.3,3.32s-3.31-1.39-3.31-3.32,1.49-3.31,3.31-3.31,3.3,1.39,3.3,3.31ZM192.92,9.47c0-1.68-1.26-2.88-2.84-2.88s-2.84,1.2-2.84,2.88,1.26,2.89,2.84,2.89,2.84-1.2,2.84-2.89ZM188.69,11.17v-3.51h1.61c.85,0,1.35.39,1.35,1.15,0,.53-.3.86-.67,1.02l.79,1.35h-.89l-.72-1.22h-.64v1.22h-.82ZM190.18,9.31c.46,0,.64-.16.64-.5s-.19-.49-.64-.49h-.67v.99h.67Z"}),l.createElement("path",{d:"M54.72,24.84v10.93h-5.4V6.1h12.26c7.02,0,11.1,3.2,11.1,9.39s-4.07,9.35-11.06,9.35h-6.9,0ZM61.12,20.52c4.07,0,6.11-1.66,6.11-5.03s-2.04-5.03-6.11-5.03h-6.4v10.06h6.4Z"}),l.createElement("path",{d:"M85.94,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.18-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM85.73,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z"}),l.createElement("path",{d:"M90.39,14.66h5.4l5.86,15.92h.08l5.57-15.92h5.28l-8.23,21.49c-2,5.28-4.45,7.32-8.89,7.36-.71,0-1.7-.08-2.45-.21v-4.03c.62.13.96.13,1.41.13,2.16,0,3.07-.75,4.2-3.66l-8.23-21.07h0Z"}),l.createElement("path",{d:"M113.46,35.77V6.1h5.32v29.67h-5.32Z"}),l.createElement("path",{d:"M130.79,36.27c-6.23,0-10.68-4.2-10.68-11.05s4.45-11.05,10.68-11.05,10.68,4.24,10.68,11.05-4.45,11.05-10.68,11.05ZM130.79,32.32c3.41,0,5.36-2.66,5.36-7.11s-1.95-7.11-5.36-7.11-5.36,2.7-5.36,7.11,1.91,7.11,5.36,7.11Z"}),l.createElement("path",{d:"M156.19,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.19-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM155.98,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z"}),l.createElement("path",{d:"M178.5,32.41c-1.04,2.12-3.58,3.87-6.78,3.87-5.53,0-9.31-4.49-9.31-11.05s3.78-11.05,9.31-11.05c3.28,0,5.69,1.83,6.69,3.95V6.1h5.32v29.67h-5.24v-3.37h0ZM178.55,24.84c0-4.11-1.95-6.78-5.32-6.78s-5.45,2.83-5.45,7.15,2,7.15,5.45,7.15,5.32-2.66,5.32-6.78v-.75h0Z"}))));function j(e){if(e)try{e.abort()}catch{}}import*as v from"qs-esm";var V={delete:(e,t={headers:{}})=>{let r=t&&t.headers?{...t.headers}:{},o={...t,credentials:"include",headers:{...r},method:"delete"};return fetch(e,o)},get:(e,t={headers:{}})=>{let r="";return t.params&&(r=v.stringify(t.params,{addQueryPrefix:!0})),fetch(`${e}${r}`,{credentials:"include",...t})},patch:(e,t={headers:{}})=>{let r=t&&t.headers?{...t.headers}:{},o={...t,credentials:"include",headers:{...r},method:"PATCH"};return fetch(e,o)},post:(e,t={headers:{}})=>{let r=t&&t.headers?{...t.headers}:{},o={...t,credentials:"include",headers:{...r},method:"post"};return fetch(`${e}`,o)},put:(e,t={headers:{}})=>{let r=t&&t.headers?{...t.headers}:{},o={...t,credentials:"include",headers:{...r},method:"put"};return fetch(e,o)}};var K=(e,t)=>!e?.locales||e.locales.length===0?null:e.locales.find(r=>r?.code===t);var u=e=>{let{adminRoute:t,basePath:r="",path:o,serverURL:n}=e;if(t)if(t==="/"){if(!o)return`${n||""}${r}${t}`}else return`${n||""}${r}${t}${o}`;return`${n||""}${r}${o}`};import{format as G,formatDistanceToNow as Le}from"date-fns";var g=({date:e,i18n:t,pattern:r})=>{let o=new Date(e);return G(o,r,{locale:t.dateFNS})};import{getTranslation as W}from"@payloadcms/translations";var Q=({collectionConfig:e,data:t,dateFormat:r,fallback:o,globalConfig:n,i18n:i})=>{let s;if(e){let a=e?.admin?.useAsTitle;if(a&&(s=t?.[a]||s,s)){let d=e.fields.find(c=>"name"in c&&c.name===a);if(d?.type==="date"){let c="date"in d.admin&&d?.admin?.date?.displayFormat||r;s=g({date:s,i18n:i,pattern:c})||s}}}return n&&(s=W(n?.label,i)||n?.slug),s||(s=o||`[${i.t("general:untitled")}]`),s};import{getTranslation as y}from"@payloadcms/translations";var S=(r=>(r.collection="collections",r.global="globals",r))(S||{});function H(e,t,r){return e.reduce((n,i)=>{if(t?.[i.type.toLowerCase()]?.[i.entity.slug]?.read){let s=y(i.entity.admin.group,r);if(i.entity.admin.group){let a=n.find(p=>y(p.label,r)===s),d=a;a||(d={entities:[],label:s},n.push(d)),d.entities.push({slug:i.entity.slug,type:i.type,label:"labels"in i.entity?typeof i.entity.labels.plural=="function"?i.entity.labels.plural({t:r.t}):i.entity.labels.plural:i.entity.label})}else n.find(d=>y(d.label,r)===r.t(`general:${i.type}`)).entities.push({slug:i.entity.slug,type:i.type,label:"labels"in i.entity?typeof i.entity.labels.plural=="function"?i.entity.labels.plural({t:r.t}):i.entity.labels.plural:i.entity.label})}return n},[{entities:[],label:r.t("general:collections")},{entities:[],label:r.t("general:globals")}]).filter(n=>n.entities.length>0)}var _=({adminRoute:e,router:t})=>{let r=u({adminRoute:e,path:"/"});t.push(r)};var J=({adminRoute:e,collectionSlug:t,router:r})=>{let o=u({adminRoute:e,path:t?`/collections/${t}`:"/"});r.push(o)};var X=(e,t,r,o,n,i,s,a,d,p)=>{if(d)try{i(e,t??r,o),n||(a.current.hasShownLockedModal=!0),a.current={hasShownLockedModal:a.current?.hasShownLockedModal,isLocked:!0,user:o},s(o),n&&p&&p(!1)}catch(c){console.error("Error during document takeover:",c)}};var Y=e=>{let{collectionSlug:t,docPermissions:r,globalSlug:o,isEditing:n}=e;return t?!!(n&&r?.update||!n&&r?.create):o?!!r?.update:!1};var ee=e=>e&&typeof e=="object";var te=({id:e,collectionSlug:t,globalSlug:r})=>!!(r||t&&e);var C=e=>Object.keys(e).length===0,re=(e,t)=>C(t)?e:C(e)?t:("and"in e?e.and.push(t):"or"in e?e={and:[e,t]}:e={and:[e,t]},e),oe=({collectionConfig:e,search:t,where:r={}})=>{if(t){let o={...r||{}},n=(e.admin.listSearchableFields||[e.admin?.useAsTitle||"id"]).map(i=>({[i]:{like:t}}));n.length>0&&(o=re(o,{or:n})),C(o)||(r=o)}return r};export{S as EntityType,E as PayloadIcon,q as PayloadLogo,L as Translation,z as WithServerSideProps,j as abortAndIgnore,P as filterFields,K as findLocaleFromCode,u as formatAdminURL,g as formatDate,Q as formatDocTitle,R as getInitialColumns,H as groupNavItems,_ as handleBackToDashboard,J as handleGoBack,X as handleTakeOver,Y as hasSavePermission,ee as isClientUserObject,te as isEditing,O as mergeFieldStyles,oe as mergeListSearchAndWhere,B as reduceToSerializableFields,V as requests,w as withMergedProps};
5
+ `,q=()=>l.createElement("svg",{className:"graphic-logo",fill:"none",height:"43.5",id:"b",viewBox:"0 0 193.38 43.5",width:"193.38",xmlns:"http://www.w3.org/2000/svg"},l.createElement("style",null,U),l.createElement("g",{id:"c"},l.createElement("path",{d:"M18.01,35.63l-12.36-7.13c-.15-.09-.25-.25-.25-.43v-11.02c0-.19.21-.31.37-.22l14.35,8.28c.2.12.45-.03.45-.26v-5.37c0-.21-.11-.41-.3-.52L3.01,9c-.15-.09-.35-.09-.5,0l-2.26,1.31c-.15.09-.25.25-.25.43v20.47c0,.18.1.34.25.43l17.73,10.24c.15.09.35.09.5,0l14.89-8.6c.2-.12.2-.4,0-.52l-4.64-2.68c-.19-.11-.41-.11-.6,0l-9.61,5.55c-.15.09-.35.09-.5,0Z"}),l.createElement("path",{d:"M36.21,10.3L18.48.07c-.15-.09-.35-.09-.5,0l-9.37,5.41c-.2.12-.2.4,0,.52l4.6,2.66c.19.11.41.11.6,0l4.2-2.42c.15-.09.35-.09.5,0l12.36,7.13c.15.09.25.25.25.43v11.07c0,.21.11.41.3.52l4.6,2.65c.2.12.45-.03.45-.26V10.74c0-.18-.1-.34-.25-.43Z"}),l.createElement("g",{id:"d"},l.createElement("path",{d:"M193.38,9.47c0,1.94-1.48,3.32-3.3,3.32s-3.31-1.39-3.31-3.32,1.49-3.31,3.31-3.31,3.3,1.39,3.3,3.31ZM192.92,9.47c0-1.68-1.26-2.88-2.84-2.88s-2.84,1.2-2.84,2.88,1.26,2.89,2.84,2.89,2.84-1.2,2.84-2.89ZM188.69,11.17v-3.51h1.61c.85,0,1.35.39,1.35,1.15,0,.53-.3.86-.67,1.02l.79,1.35h-.89l-.72-1.22h-.64v1.22h-.82ZM190.18,9.31c.46,0,.64-.16.64-.5s-.19-.49-.64-.49h-.67v.99h.67Z"}),l.createElement("path",{d:"M54.72,24.84v10.93h-5.4V6.1h12.26c7.02,0,11.1,3.2,11.1,9.39s-4.07,9.35-11.06,9.35h-6.9,0ZM61.12,20.52c4.07,0,6.11-1.66,6.11-5.03s-2.04-5.03-6.11-5.03h-6.4v10.06h6.4Z"}),l.createElement("path",{d:"M85.94,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.18-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM85.73,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z"}),l.createElement("path",{d:"M90.39,14.66h5.4l5.86,15.92h.08l5.57-15.92h5.28l-8.23,21.49c-2,5.28-4.45,7.32-8.89,7.36-.71,0-1.7-.08-2.45-.21v-4.03c.62.13.96.13,1.41.13,2.16,0,3.07-.75,4.2-3.66l-8.23-21.07h0Z"}),l.createElement("path",{d:"M113.46,35.77V6.1h5.32v29.67h-5.32Z"}),l.createElement("path",{d:"M130.79,36.27c-6.23,0-10.68-4.2-10.68-11.05s4.45-11.05,10.68-11.05,10.68,4.24,10.68,11.05-4.45,11.05-10.68,11.05ZM130.79,32.32c3.41,0,5.36-2.66,5.36-7.11s-1.95-7.11-5.36-7.11-5.36,2.7-5.36,7.11,1.91,7.11,5.36,7.11Z"}),l.createElement("path",{d:"M156.19,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.19-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM155.98,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z"}),l.createElement("path",{d:"M178.5,32.41c-1.04,2.12-3.58,3.87-6.78,3.87-5.53,0-9.31-4.49-9.31-11.05s3.78-11.05,9.31-11.05c3.28,0,5.69,1.83,6.69,3.95V6.1h5.32v29.67h-5.24v-3.37h0ZM178.55,24.84c0-4.11-1.95-6.78-5.32-6.78s-5.45,2.83-5.45,7.15,2,7.15,5.45,7.15,5.32-2.66,5.32-6.78v-.75h0Z"}))));function j(e){if(e)try{e.abort()}catch{}}import*as v from"qs-esm";var V={delete:(e,t={headers:{}})=>{let r=t&&t.headers?{...t.headers}:{},o={...t,credentials:"include",headers:{...r},method:"delete"};return fetch(e,o)},get:(e,t={headers:{}})=>{let r="";return t.params&&(r=v.stringify(t.params,{addQueryPrefix:!0})),fetch(`${e}${r}`,{credentials:"include",...t})},patch:(e,t={headers:{}})=>{let r=t&&t.headers?{...t.headers}:{},o={...t,credentials:"include",headers:{...r},method:"PATCH"};return fetch(e,o)},post:(e,t={headers:{}})=>{let r=t&&t.headers?{...t.headers}:{},o={...t,credentials:"include",headers:{...r},method:"post"};return fetch(`${e}`,o)},put:(e,t={headers:{}})=>{let r=t&&t.headers?{...t.headers}:{},o={...t,credentials:"include",headers:{...r},method:"put"};return fetch(e,o)}};var K=(e,t)=>!e?.locales||e.locales.length===0?null:e.locales.find(r=>r?.code===t);var u=e=>{let{adminRoute:t,basePath:r="",path:o,serverURL:n}=e;if(t)if(t==="/"){if(!o)return`${n||""}${r}${t}`}else return`${n||""}${r}${t}${o}`;return`${n||""}${r}${o}`};import{format as G,formatDistanceToNow as Te}from"date-fns";var h=({date:e,i18n:t,pattern:r})=>{let o=new Date(e);return G(o,r,{locale:t.dateFNS})};import{getTranslation as W}from"@payloadcms/translations";var Q=({collectionConfig:e,data:t,dateFormat:r,fallback:o,globalConfig:n,i18n:i})=>{let s;if(e){let a=e?.admin?.useAsTitle;if(a&&(s=t?.[a]||s,s)){let d=e.fields.find(c=>"name"in c&&c.name===a);if(d?.type==="date"){let c="date"in d.admin&&d?.admin?.date?.displayFormat||r;s=h({date:s,i18n:i,pattern:c})||s}}}return n&&(s=W(n?.label,i)||n?.slug),s||(s=o||`[${i.t("general:untitled")}]`),s};import{getTranslation as y}from"@payloadcms/translations";var S=(r=>(r.collection="collections",r.global="globals",r))(S||{});function H(e,t,r){return e.reduce((n,i)=>{if(t?.[i.type.toLowerCase()]?.[i.entity.slug]?.read){let s=y(i.entity.admin.group,r);if(i.entity.admin.group){let a=n.find(p=>y(p.label,r)===s),d=a;a||(d={entities:[],label:s},n.push(d)),d.entities.push({slug:i.entity.slug,type:i.type,label:"labels"in i.entity?typeof i.entity.labels.plural=="function"?i.entity.labels.plural({t:r.t}):i.entity.labels.plural:i.entity.label})}else n.find(d=>y(d.label,r)===r.t(`general:${i.type}`)).entities.push({slug:i.entity.slug,type:i.type,label:"labels"in i.entity?typeof i.entity.labels.plural=="function"?i.entity.labels.plural({t:r.t}):i.entity.labels.plural:i.entity.label})}return n},[{entities:[],label:r.t("general:collections")},{entities:[],label:r.t("general:globals")}]).filter(n=>n.entities.length>0)}var _=({adminRoute:e,router:t})=>{let r=u({adminRoute:e,path:"/"});t.push(r)};var J=({adminRoute:e,collectionSlug:t,router:r})=>{let o=u({adminRoute:e,path:t?`/collections/${t}`:"/"});r.push(o)};var X=(e,t,r,o,n,i,s,a,d,p)=>{if(d)try{i(e,t??r,o),n||(a.current.hasShownLockedModal=!0),a.current={hasShownLockedModal:a.current?.hasShownLockedModal,isLocked:!0,user:o},s(o),n&&p&&p(!1)}catch(c){console.error("Error during document takeover:",c)}};var Y=e=>{let{collectionSlug:t,docPermissions:r,globalSlug:o,isEditing:n}=e;return t?!!(n&&r?.update||!n&&r?.create):o?!!r?.update:!1};var ee=e=>e&&typeof e=="object";var te=({id:e,collectionSlug:t,globalSlug:r})=>!!(r||t&&e);var C=e=>Object.keys(e).length===0,re=(e,t)=>C(t)?e:C(e)?t:("and"in e?e.and.push(t):"or"in e?e={and:[e,t]}:e={and:[e,t]},e),oe=({collectionConfig:e,search:t,where:r={}})=>{if(t){let o={...r||{}},n=(e.admin.listSearchableFields||[e.admin?.useAsTitle||"id"]).map(i=>({[i]:{like:t}}));n.length>0&&(o=re(o,{or:n})),C(o)||(r=o)}return r};function ne(e){return e===void 0||typeof e=="number"?e:decodeURIComponent(e)}export{S as EntityType,E as PayloadIcon,q as PayloadLogo,L as Translation,z as WithServerSideProps,j as abortAndIgnore,P as filterFields,K as findLocaleFromCode,u as formatAdminURL,h as formatDate,Q as formatDocTitle,R as getInitialColumns,H as groupNavItems,_ as handleBackToDashboard,J as handleGoBack,X as handleTakeOver,Y as hasSavePermission,ee as isClientUserObject,te as isEditing,O as mergeFieldStyles,oe as mergeListSearchAndWhere,B as reduceToSerializableFields,V as requests,ne as sanitizeID,w as withMergedProps};
6
6
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/elements/TableColumns/filterFields.tsx", "../../../src/elements/TableColumns/getInitialColumns.ts", "../../../src/elements/Translation/index.tsx", "../../../src/elements/withMergedProps/index.tsx", "../../../src/elements/WithServerSideProps/index.tsx", "../../../src/fields/mergeFieldStyles.ts", "../../../src/forms/Form/reduceToSerializableFields.ts", "../../../src/graphics/Icon/index.tsx", "../../../src/graphics/Logo/index.tsx", "../../../src/utilities/abortAndIgnore.ts", "../../../src/utilities/api.ts", "../../../src/utilities/findLocaleFromCode.ts", "../../../src/utilities/formatAdminURL.ts", "../../../src/utilities/formatDate.ts", "../../../src/utilities/formatDocTitle.ts", "../../../src/utilities/groupNavItems.ts", "../../../src/utilities/handleBackToDashboard.tsx", "../../../src/utilities/handleGoBack.tsx", "../../../src/utilities/handleTakeOver.tsx", "../../../src/utilities/hasSavePermission.ts", "../../../src/utilities/isClientUserObject.ts", "../../../src/utilities/isEditing.ts", "../../../src/utilities/mergeListSearchAndWhere.ts"],
4
- "sourcesContent": ["import type { ClientField, Field } from 'payload'\n\n// 1. Skips fields that are hidden, disabled, or presentational-only (i.e. `ui` fields)\n// 2. Maps through top-level `tabs` fields and filters out the same\nexport const filterFields = <T extends ClientField | Field>(incomingFields: T[]): T[] => {\n const shouldSkipField = (field: T): boolean =>\n (field.type !== 'ui' && field.admin?.disabled === true) ||\n field?.admin?.disableListColumn === true\n\n const fields: T[] = incomingFields?.reduce((formatted, field) => {\n if (shouldSkipField(field)) {\n return formatted\n }\n\n const formattedField: T =\n field.type === 'tabs' && 'tabs' in field\n ? {\n ...field,\n tabs: field.tabs.map((tab) => ({\n ...tab,\n fields: tab.fields.filter((tabField) => !shouldSkipField(tabField)),\n })),\n }\n : field\n\n return [...formatted, formattedField]\n }, [])\n\n return fields\n}\n", "import type { ClientField, Field } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { ColumnPreferences } from '../../providers/ListQuery/index.js'\n\nconst getRemainingColumns = <T extends ClientField[] | Field[]>(\n fields: T,\n useAsTitle: string,\n): ColumnPreferences =>\n fields?.reduce((remaining, field) => {\n if (fieldAffectsData(field) && field.name === useAsTitle) {\n return remaining\n }\n\n if (!fieldAffectsData(field) && 'fields' in field) {\n return [...remaining, ...getRemainingColumns(field.fields, useAsTitle)]\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n return [\n ...remaining,\n ...field.tabs.reduce(\n (tabFieldColumns, tab) => [\n ...tabFieldColumns,\n ...('name' in tab ? [tab.name] : getRemainingColumns(tab.fields, useAsTitle)),\n ],\n [],\n ),\n ]\n }\n\n return [...remaining, field.name]\n }, [])\n\nexport const getInitialColumns = <T extends ClientField[] | Field[]>(\n fields: T,\n useAsTitle: string,\n defaultColumns: string[],\n): ColumnPreferences => {\n let initialColumns = []\n\n if (Array.isArray(defaultColumns) && defaultColumns.length >= 1) {\n initialColumns = defaultColumns\n } else {\n if (useAsTitle) {\n initialColumns.push(useAsTitle)\n }\n\n const remainingColumns = getRemainingColumns(fields, useAsTitle)\n\n initialColumns = initialColumns.concat(remainingColumns)\n initialColumns = initialColumns.slice(0, 4)\n }\n\n return initialColumns.map((column) => ({\n accessor: column,\n active: true,\n }))\n}\n", "import type { ClientTranslationKeys, TFunction } from '@payloadcms/translations'\n\nimport * as React from 'react'\n\nconst RecursiveTranslation: React.FC<{\n elements?: Record<string, React.FC<{ children: React.ReactNode }>>\n translationString: string\n}> = ({ elements, translationString }) => {\n const regex = /(<[^>]+>.*?<\\/[^>]+>)/g\n const sections = translationString.split(regex)\n\n return (\n <span>\n {sections.map((section, index) => {\n if (elements && section.startsWith('<') && section.endsWith('>')) {\n const elementKey = section[1]\n const Element = elements[elementKey]\n\n if (Element) {\n const regex = new RegExp(`<${elementKey}>(.*?)<\\/${elementKey}>`, 'g')\n const children = section.replace(regex, (_, group) => group)\n\n return (\n <Element key={index}>\n <RecursiveTranslation translationString={children} />\n </Element>\n )\n }\n }\n\n return section\n })}\n </span>\n )\n}\n\nexport type TranslationProps = {\n elements?: Record<string, React.FC<{ children: React.ReactNode }>>\n i18nKey: ClientTranslationKeys\n t: TFunction\n variables?: Record<string, unknown>\n}\n\nexport const Translation: React.FC<TranslationProps> = ({ elements, i18nKey, t, variables }) => {\n const stringWithVariables = t(i18nKey, variables || {})\n\n if (!elements) {\n return stringWithVariables\n }\n\n return <RecursiveTranslation elements={elements} translationString={stringWithVariables} />\n}\n", "import { isReactServerComponentOrFunction, serverProps } from 'payload/shared'\nimport React from 'react'\n\n/**\n * Creates a higher-order component (HOC) that merges predefined properties (`toMergeIntoProps`)\n * with any properties passed to the resulting component.\n *\n * Use this when you want to pre-specify some props for a component, while also allowing users to\n * pass in their own props. The HOC ensures the passed props and predefined props are combined before\n * rendering the original component.\n *\n * @example\n * const PredefinedComponent = getMergedPropsComponent({\n * Component: OriginalComponent,\n * toMergeIntoProps: { someExtraValue: 5 }\n * });\n * // Using <PredefinedComponent customProp=\"value\" /> will result in\n * // <OriginalComponent customProp=\"value\" someExtraValue={5} />\n *\n * @returns A higher-order component with combined properties.\n *\n * @param Component - The original component to wrap.\n * @param sanitizeServerOnlyProps - If true, server-only props will be removed from the merged props. @default true if the component is not a server component, false otherwise.\n * @param toMergeIntoProps - The properties to merge into the passed props.\n */\nexport function withMergedProps<ToMergeIntoProps, CompleteReturnProps>({\n Component,\n sanitizeServerOnlyProps,\n toMergeIntoProps,\n}: {\n Component: React.FC<CompleteReturnProps>\n sanitizeServerOnlyProps?: boolean\n toMergeIntoProps: ToMergeIntoProps\n}): React.FC<CompleteReturnProps> {\n if (sanitizeServerOnlyProps === undefined) {\n sanitizeServerOnlyProps = !isReactServerComponentOrFunction(Component)\n }\n // A wrapper around the args.Component to inject the args.toMergeArgs as props, which are merged with the passed props\n const MergedPropsComponent: React.FC<CompleteReturnProps> = (passedProps) => {\n const mergedProps = simpleMergeProps(passedProps, toMergeIntoProps) as CompleteReturnProps\n\n if (sanitizeServerOnlyProps) {\n serverProps.forEach((prop) => {\n delete mergedProps[prop]\n })\n }\n\n return <Component {...mergedProps} />\n }\n\n return MergedPropsComponent\n}\n\nfunction simpleMergeProps(props, toMerge) {\n return { ...props, ...toMerge }\n}\n", "import type { WithServerSidePropsComponent } from 'payload'\n\nimport { isReactServerComponentOrFunction } from 'payload/shared'\nimport React from 'react'\n\nexport const WithServerSideProps: WithServerSidePropsComponent = ({\n Component,\n serverOnlyProps,\n ...rest\n}) => {\n if (Component) {\n const WithServerSideProps: React.FC = (passedProps) => {\n const propsWithServerOnlyProps = {\n ...passedProps,\n ...(isReactServerComponentOrFunction(Component) ? (serverOnlyProps ?? {}) : {}),\n }\n\n return <Component {...propsWithServerOnlyProps} />\n }\n\n return WithServerSideProps(rest)\n }\n\n return null\n}\n", "import type { ClientField } from 'payload'\n\nexport const mergeFieldStyles = (\n field: ClientField | Omit<ClientField, 'type'>,\n): React.CSSProperties => ({\n ...(field?.admin?.style || {}),\n ...(field?.admin?.width\n ? {\n '--field-width': field.admin.width,\n }\n : {\n flex: '1 1 auto',\n }),\n // allow flex overrides to still take precedence over the fallback\n ...(field?.admin?.style?.flex\n ? {\n flex: field.admin.style.flex,\n }\n : {}),\n})\n", "import { type FormField, type FormState } from 'payload'\nimport { deepCopyObjectComplex } from 'payload/shared'\n\ntype BlacklistedKeys = 'customComponents' | 'validate'\nconst blacklistedKeys: BlacklistedKeys[] = ['validate', 'customComponents']\n\nconst sanitizeField = (incomingField: FormField): FormField => {\n const field = deepCopyObjectComplex(incomingField)\n\n blacklistedKeys.forEach((key) => {\n delete field[key]\n })\n\n return field\n}\n\n/* \n Takes in FormState and removes fields that are not serializable.\n Returns FormState without blacklisted keys.\n**/\nexport const reduceToSerializableFields = (\n fields: FormState,\n): {\n [key: string]: Omit<FormField, BlacklistedKeys>\n} => {\n return Object.keys(fields).reduce(\n (acc, key) => {\n acc[key] = sanitizeField(fields[key])\n return acc\n },\n {} as {\n [key: string]: Omit<FormField, BlacklistedKeys>\n },\n )\n}\n", "import React from 'react'\n\nexport const PayloadIcon: React.FC<{\n fill?: string\n}> = ({ fill: fillFromProps }) => {\n const fill = fillFromProps || 'var(--theme-elevation-1000)'\n\n return (\n <svg\n className=\"graphic-icon\"\n height=\"100%\"\n viewBox=\"0 0 25 25\"\n width=\"100%\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M11.8673 21.2336L4.40922 16.9845C4.31871 16.9309 4.25837 16.8355 4.25837 16.7282V10.1609C4.25837 10.0477 4.38508 9.97616 4.48162 10.0298L13.1404 14.9642C13.2611 15.0358 13.412 14.9464 13.412 14.8093V11.6091C13.412 11.4839 13.3456 11.3647 13.2309 11.2992L2.81624 5.36353C2.72573 5.30989 2.60505 5.30989 2.51454 5.36353L1.15085 6.14422C1.06034 6.19786 1 6.29321 1 6.40048V18.5995C1 18.7068 1.06034 18.8021 1.15085 18.8558L11.8491 24.9583C11.9397 25.0119 12.0603 25.0119 12.1509 24.9583L21.1355 19.8331C21.2562 19.7616 21.2562 19.5948 21.1355 19.5232L18.3357 17.9261C18.2211 17.8605 18.0883 17.8605 17.9737 17.9261L12.175 21.2336C12.0845 21.2872 11.9638 21.2872 11.8733 21.2336H11.8673Z\"\n fill={fill}\n />\n <path\n d=\"M22.8491 6.13827L12.1508 0.0417218C12.0603 -0.0119135 11.9397 -0.0119135 11.8491 0.0417218L6.19528 3.2658C6.0746 3.33731 6.0746 3.50418 6.19528 3.57569L8.97092 5.16091C9.08557 5.22647 9.21832 5.22647 9.33296 5.16091L11.8672 3.71872C11.9578 3.66508 12.0784 3.66508 12.1689 3.71872L19.627 7.96782C19.7175 8.02146 19.7778 8.11681 19.7778 8.22408V14.8212C19.7778 14.9464 19.8442 15.0656 19.9589 15.1311L22.7345 16.7104C22.8552 16.7819 23.006 16.6925 23.006 16.5554V6.40048C23.006 6.29321 22.9457 6.19786 22.8552 6.14423L22.8491 6.13827Z\"\n fill={fill}\n />\n </svg>\n )\n}\n", "import React from 'react'\n\nconst css = `\n .graphic-logo path {\n fill: var(--theme-elevation-1000);\n }\n`\n\nexport const PayloadLogo: React.FC = () => (\n <svg\n className=\"graphic-logo\"\n fill=\"none\"\n height=\"43.5\"\n id=\"b\"\n viewBox=\"0 0 193.38 43.5\"\n width=\"193.38\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <style>{css}</style>\n <g id=\"c\">\n <path d=\"M18.01,35.63l-12.36-7.13c-.15-.09-.25-.25-.25-.43v-11.02c0-.19.21-.31.37-.22l14.35,8.28c.2.12.45-.03.45-.26v-5.37c0-.21-.11-.41-.3-.52L3.01,9c-.15-.09-.35-.09-.5,0l-2.26,1.31c-.15.09-.25.25-.25.43v20.47c0,.18.1.34.25.43l17.73,10.24c.15.09.35.09.5,0l14.89-8.6c.2-.12.2-.4,0-.52l-4.64-2.68c-.19-.11-.41-.11-.6,0l-9.61,5.55c-.15.09-.35.09-.5,0Z\" />\n <path d=\"M36.21,10.3L18.48.07c-.15-.09-.35-.09-.5,0l-9.37,5.41c-.2.12-.2.4,0,.52l4.6,2.66c.19.11.41.11.6,0l4.2-2.42c.15-.09.35-.09.5,0l12.36,7.13c.15.09.25.25.25.43v11.07c0,.21.11.41.3.52l4.6,2.65c.2.12.45-.03.45-.26V10.74c0-.18-.1-.34-.25-.43Z\" />\n <g id=\"d\">\n <path d=\"M193.38,9.47c0,1.94-1.48,3.32-3.3,3.32s-3.31-1.39-3.31-3.32,1.49-3.31,3.31-3.31,3.3,1.39,3.3,3.31ZM192.92,9.47c0-1.68-1.26-2.88-2.84-2.88s-2.84,1.2-2.84,2.88,1.26,2.89,2.84,2.89,2.84-1.2,2.84-2.89ZM188.69,11.17v-3.51h1.61c.85,0,1.35.39,1.35,1.15,0,.53-.3.86-.67,1.02l.79,1.35h-.89l-.72-1.22h-.64v1.22h-.82ZM190.18,9.31c.46,0,.64-.16.64-.5s-.19-.49-.64-.49h-.67v.99h.67Z\" />\n <path d=\"M54.72,24.84v10.93h-5.4V6.1h12.26c7.02,0,11.1,3.2,11.1,9.39s-4.07,9.35-11.06,9.35h-6.9,0ZM61.12,20.52c4.07,0,6.11-1.66,6.11-5.03s-2.04-5.03-6.11-5.03h-6.4v10.06h6.4Z\" />\n <path d=\"M85.94,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.18-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM85.73,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z\" />\n <path d=\"M90.39,14.66h5.4l5.86,15.92h.08l5.57-15.92h5.28l-8.23,21.49c-2,5.28-4.45,7.32-8.89,7.36-.71,0-1.7-.08-2.45-.21v-4.03c.62.13.96.13,1.41.13,2.16,0,3.07-.75,4.2-3.66l-8.23-21.07h0Z\" />\n <path d=\"M113.46,35.77V6.1h5.32v29.67h-5.32Z\" />\n <path d=\"M130.79,36.27c-6.23,0-10.68-4.2-10.68-11.05s4.45-11.05,10.68-11.05,10.68,4.24,10.68,11.05-4.45,11.05-10.68,11.05ZM130.79,32.32c3.41,0,5.36-2.66,5.36-7.11s-1.95-7.11-5.36-7.11-5.36,2.7-5.36,7.11,1.91,7.11,5.36,7.11Z\" />\n <path d=\"M156.19,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.19-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM155.98,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z\" />\n <path d=\"M178.5,32.41c-1.04,2.12-3.58,3.87-6.78,3.87-5.53,0-9.31-4.49-9.31-11.05s3.78-11.05,9.31-11.05c3.28,0,5.69,1.83,6.69,3.95V6.1h5.32v29.67h-5.24v-3.37h0ZM178.55,24.84c0-4.11-1.95-6.78-5.32-6.78s-5.45,2.83-5.45,7.15,2,7.15,5.45,7.15,5.32-2.66,5.32-6.78v-.75h0Z\" />\n </g>\n </g>\n </svg>\n)\n", "export function abortAndIgnore(controller: AbortController) {\n if (controller) {\n try {\n controller.abort()\n } catch (_err) {\n // swallow error\n }\n }\n}\n", "import * as qs from 'qs-esm'\n\ntype GetOptions = {\n params?: Record<string, unknown>\n} & RequestInit\n\nexport const requests = {\n delete: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'delete',\n }\n\n return fetch(url, formattedOptions)\n },\n\n get: (url: string, options: GetOptions = { headers: {} }): Promise<Response> => {\n let query = ''\n if (options.params) {\n query = qs.stringify(options.params, { addQueryPrefix: true })\n }\n return fetch(`${url}${query}`, {\n credentials: 'include',\n ...options,\n })\n },\n\n patch: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'PATCH',\n }\n\n return fetch(url, formattedOptions)\n },\n\n post: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'post',\n }\n\n return fetch(`${url}`, formattedOptions)\n },\n\n put: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'put',\n }\n\n return fetch(url, formattedOptions)\n },\n}\n", "import type { Locale, SanitizedLocalizationConfig } from 'payload'\n/*\n return the Locale for given locale code, else return null\n*/\nexport const findLocaleFromCode = (\n localizationConfig: SanitizedLocalizationConfig,\n locale: string,\n): Locale | null => {\n if (!localizationConfig?.locales || localizationConfig.locales.length === 0) {\n return null\n }\n\n return localizationConfig.locales.find((el) => el?.code === locale)\n}\n", "import type { Config } from 'payload'\n\n/** Will read the `routes.admin` config and appropriately handle `\"/\"` admin paths */\nexport const formatAdminURL = (args: {\n adminRoute: Config['routes']['admin']\n basePath?: string\n path: string\n serverURL?: Config['serverURL']\n}): string => {\n const { adminRoute, basePath = '', path, serverURL } = args\n\n if (adminRoute) {\n if (adminRoute === '/') {\n if (!path) {\n return `${serverURL || ''}${basePath}${adminRoute}`\n }\n } else {\n return `${serverURL || ''}${basePath}${adminRoute}${path}`\n }\n }\n\n return `${serverURL || ''}${basePath}${path}`\n}\n", "import type { I18n } from '@payloadcms/translations'\n\nimport { format, formatDistanceToNow } from 'date-fns'\n\ntype FormatDateArgs = {\n date: Date | number | string | undefined\n i18n: I18n<any, any>\n pattern: string\n}\n\nexport const formatDate = ({ date, i18n, pattern }: FormatDateArgs): string => {\n const theDate = new Date(date)\n return format(theDate, pattern, { locale: i18n.dateFNS })\n}\n\ntype FormatTimeToNowArgs = {\n date: Date | number | string | undefined\n i18n: I18n<any, any>\n}\n\nexport const formatTimeToNow = ({ date, i18n }: FormatTimeToNowArgs): string => {\n const theDate = new Date(date)\n return formatDistanceToNow(theDate, { locale: i18n.dateFNS })\n}\n", "import type { I18n } from '@payloadcms/translations'\nimport type {\n ClientCollectionConfig,\n ClientGlobalConfig,\n SanitizedConfig,\n TypeWithID,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\n\nimport { formatDate } from '../utilities/formatDate.js'\n\nexport const formatDocTitle = ({\n collectionConfig,\n data,\n dateFormat: dateFormatFromConfig,\n fallback,\n globalConfig,\n i18n,\n}: {\n collectionConfig?: ClientCollectionConfig\n data: TypeWithID\n dateFormat: SanitizedConfig['admin']['dateFormat']\n fallback?: string\n globalConfig?: ClientGlobalConfig\n i18n: I18n<any, any>\n}): string => {\n let title: string\n\n if (collectionConfig) {\n const useAsTitle = collectionConfig?.admin?.useAsTitle\n\n if (useAsTitle) {\n title = data?.[useAsTitle] || title\n\n if (title) {\n const fieldConfig = collectionConfig.fields.find(\n (f) => 'name' in f && f.name === useAsTitle,\n )\n\n const isDate = fieldConfig?.type === 'date'\n\n if (isDate) {\n const dateFormat =\n ('date' in fieldConfig.admin && fieldConfig?.admin?.date?.displayFormat) ||\n dateFormatFromConfig\n title = formatDate({ date: title, i18n, pattern: dateFormat }) || title\n }\n }\n }\n }\n\n if (globalConfig) {\n title = getTranslation(globalConfig?.label, i18n) || globalConfig?.slug\n }\n\n if (!title) {\n title = fallback || `[${i18n.t('general:untitled')}]`\n }\n\n return title\n}\n", "import type { I18nClient } from '@payloadcms/translations'\nimport type {\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n SanitizedPermissions,\n StaticLabel,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\n\nexport enum EntityType {\n collection = 'collections',\n global = 'globals',\n}\n\nexport type EntityToGroup =\n | {\n entity: SanitizedCollectionConfig\n type: EntityType.collection\n }\n | {\n entity: SanitizedGlobalConfig\n type: EntityType.global\n }\n\nexport type NavGroupType = {\n entities: {\n label: StaticLabel\n slug: string\n type: EntityType\n }[]\n label: string\n}\n\nexport function groupNavItems(\n entities: EntityToGroup[],\n permissions: SanitizedPermissions,\n i18n: I18nClient,\n): NavGroupType[] {\n const result = entities.reduce(\n (groups, entityToGroup) => {\n if (permissions?.[entityToGroup.type.toLowerCase()]?.[entityToGroup.entity.slug]?.read) {\n const translatedGroup = getTranslation(entityToGroup.entity.admin.group, i18n)\n\n if (entityToGroup.entity.admin.group) {\n const existingGroup = groups.find(\n (group) => getTranslation(group.label, i18n) === translatedGroup,\n ) as NavGroupType\n\n let matchedGroup: NavGroupType = existingGroup\n\n if (!existingGroup) {\n matchedGroup = { entities: [], label: translatedGroup }\n groups.push(matchedGroup)\n }\n\n matchedGroup.entities.push({\n slug: entityToGroup.entity.slug,\n type: entityToGroup.type,\n label:\n 'labels' in entityToGroup.entity\n ? typeof entityToGroup.entity.labels.plural === 'function'\n ? entityToGroup.entity.labels.plural({ t: i18n.t })\n : entityToGroup.entity.labels.plural\n : entityToGroup.entity.label,\n })\n } else {\n const defaultGroup = groups.find((group) => {\n return getTranslation(group.label, i18n) === i18n.t(`general:${entityToGroup.type}`)\n }) as NavGroupType\n defaultGroup.entities.push({\n slug: entityToGroup.entity.slug,\n type: entityToGroup.type,\n label:\n 'labels' in entityToGroup.entity\n ? typeof entityToGroup.entity.labels.plural === 'function'\n ? entityToGroup.entity.labels.plural({ t: i18n.t })\n : entityToGroup.entity.labels.plural\n : entityToGroup.entity.label,\n })\n }\n }\n\n return groups\n },\n [\n {\n entities: [],\n label: i18n.t('general:collections'),\n },\n {\n entities: [],\n label: i18n.t('general:globals'),\n },\n ],\n )\n\n return result.filter((group) => group.entities.length > 0)\n}\n", "import type { AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'\n\nimport { formatAdminURL } from './formatAdminURL.js'\n\ntype BackToDashboardProps = {\n adminRoute: string\n router: AppRouterInstance\n}\n\nexport const handleBackToDashboard = ({ adminRoute, router }: BackToDashboardProps) => {\n const redirectRoute = formatAdminURL({\n adminRoute,\n path: '/',\n })\n router.push(redirectRoute)\n}\n", "import type { AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'\n\nimport { formatAdminURL } from './formatAdminURL.js'\n\ntype GoBackProps = {\n adminRoute: string\n collectionSlug: string\n router: AppRouterInstance\n}\n\nexport const handleGoBack = ({ adminRoute, collectionSlug, router }: GoBackProps) => {\n const redirectRoute = formatAdminURL({\n adminRoute,\n path: collectionSlug ? `/collections/${collectionSlug}` : '/',\n })\n router.push(redirectRoute)\n}\n", "import type { ClientUser } from 'payload'\n\nexport const handleTakeOver = (\n id: number | string,\n collectionSlug: string,\n globalSlug: string,\n user: ClientUser | number | string,\n isWithinDoc: boolean,\n updateDocumentEditor: (\n docId: number | string,\n slug: string,\n user: ClientUser | number | string,\n ) => Promise<void>,\n setCurrentEditor: (value: React.SetStateAction<ClientUser | number | string>) => void,\n documentLockStateRef: React.RefObject<{\n hasShownLockedModal: boolean\n isLocked: boolean\n user: ClientUser | number | string\n }>,\n isLockingEnabled: boolean,\n setIsReadOnlyForIncomingUser?: (value: React.SetStateAction<boolean>) => void,\n): void => {\n if (!isLockingEnabled) {\n return\n }\n\n try {\n // Call updateDocumentEditor to update the document's owner to the current user\n void updateDocumentEditor(id, collectionSlug ?? globalSlug, user)\n\n if (!isWithinDoc) {\n documentLockStateRef.current.hasShownLockedModal = true\n }\n\n // Update the locked state to reflect the current user as the owner\n documentLockStateRef.current = {\n hasShownLockedModal: documentLockStateRef.current?.hasShownLockedModal,\n isLocked: true,\n user,\n }\n setCurrentEditor(user)\n\n // If this is a takeover within the document, ensure the document is editable\n if (isWithinDoc && setIsReadOnlyForIncomingUser) {\n setIsReadOnlyForIncomingUser(false)\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error during document takeover:', error)\n }\n}\n", "import type {\n SanitizedCollectionPermission,\n SanitizedDocumentPermissions,\n SanitizedGlobalPermission,\n} from 'payload'\n\nexport const hasSavePermission = (args: {\n /*\n * Pass either `collectionSlug` or `globalSlug`\n */\n collectionSlug?: string\n docPermissions: SanitizedDocumentPermissions\n /*\n * Pass either `collectionSlug` or `globalSlug`\n */\n globalSlug?: string\n isEditing: boolean\n}) => {\n const { collectionSlug, docPermissions, globalSlug, isEditing } = args\n\n if (collectionSlug) {\n return Boolean(\n (isEditing && docPermissions?.update) ||\n (!isEditing && (docPermissions as SanitizedCollectionPermission)?.create),\n )\n }\n\n if (globalSlug) {\n return Boolean((docPermissions as SanitizedGlobalPermission)?.update)\n }\n\n return false\n}\n", "import type { ClientUser } from 'payload'\n\nexport const isClientUserObject = (user): user is ClientUser => {\n return user && typeof user === 'object'\n}\n", "export const isEditing = ({\n id,\n collectionSlug,\n globalSlug,\n}: {\n collectionSlug?: string\n globalSlug?: string\n id?: number | string\n}): boolean => Boolean(globalSlug || (collectionSlug && !!id))\n", "import type { ClientCollectionConfig, SanitizedCollectionConfig, Where } from 'payload'\n\nconst isEmptyObject = (obj: object) => Object.keys(obj).length === 0\n\nexport const hoistQueryParamsToAnd = (currentWhere: Where, incomingWhere: Where) => {\n if (isEmptyObject(incomingWhere)) {\n return currentWhere\n }\n\n if (isEmptyObject(currentWhere)) {\n return incomingWhere\n }\n\n if ('and' in currentWhere) {\n currentWhere.and.push(incomingWhere)\n } else if ('or' in currentWhere) {\n currentWhere = {\n and: [currentWhere, incomingWhere],\n }\n } else {\n currentWhere = {\n and: [currentWhere, incomingWhere],\n }\n }\n\n return currentWhere\n}\n\ntype Args = {\n collectionConfig: ClientCollectionConfig | SanitizedCollectionConfig\n search: string\n where?: Where\n}\n\nexport const mergeListSearchAndWhere = ({ collectionConfig, search, where = {} }: Args): Where => {\n if (search) {\n let copyOfWhere = { ...(where || {}) }\n\n const searchAsConditions = (\n collectionConfig.admin.listSearchableFields || [collectionConfig.admin?.useAsTitle || 'id']\n ).map((fieldName) => ({\n [fieldName]: {\n like: search,\n },\n }))\n\n if (searchAsConditions.length > 0) {\n copyOfWhere = hoistQueryParamsToAnd(copyOfWhere, {\n or: searchAsConditions,\n })\n }\n\n if (!isEmptyObject(copyOfWhere)) {\n where = copyOfWhere\n }\n }\n\n return where\n}\n"],
5
- "mappings": "AAIO,IAAMA,EAA+CC,GAA6B,CACvF,IAAMC,EAAmBC,GACtBA,EAAM,OAAS,MAAQA,EAAM,OAAO,WAAa,IAClDA,GAAO,OAAO,oBAAsB,GAqBtC,OAnBoBF,GAAgB,OAAO,CAACG,EAAWD,IAAU,CAC/D,GAAID,EAAgBC,CAAK,EACvB,OAAOC,EAGT,IAAMC,EACJF,EAAM,OAAS,QAAU,SAAUA,EAC/B,CACE,GAAGA,EACH,KAAMA,EAAM,KAAK,IAAKG,IAAS,CAC7B,GAAGA,EACH,OAAQA,EAAI,OAAO,OAAQC,GAAa,CAACL,EAAgBK,CAAQ,CAAC,CACpE,EAAE,CACJ,EACAJ,EAEN,MAAO,CAAC,GAAGC,EAAWC,CAAc,CACtC,EAAG,CAAC,CAAC,CAGP,EC3BA,OAAS,oBAAAG,MAAwB,iBAIjC,IAAMC,EAAsB,CAC1BC,EACAC,IAEAD,GAAQ,OAAO,CAACE,EAAWC,IACrBL,EAAiBK,CAAK,GAAKA,EAAM,OAASF,EACrCC,EAGL,CAAC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B,MAAM,sBAAwB,CAACA,EAAiB,OAAO,YAAc,IAAI,GAC1F,IAAKK,IAAe,CACpB,CAACA,CAAS,EAAG,CACX,KAAMJ,CACR,CACF,EAAE,EAEEG,EAAmB,OAAS,IAC9BD,EAAcP,GAAsBO,EAAa,CAC/C,GAAIC,CACN,CAAC,GAGEV,EAAcS,CAAW,IAC5BD,EAAQC,EAEZ,CAEA,OAAOD,CACT",
6
- "names": ["filterFields", "incomingFields", "shouldSkipField", "field", "formatted", "formattedField", "tab", "tabField", "fieldAffectsData", "getRemainingColumns", "fields", "useAsTitle", "remaining", "field", "tabFieldColumns", "tab", "getInitialColumns", "defaultColumns", "initialColumns", "remainingColumns", "column", "React", "RecursiveTranslation", "elements", "translationString", "regex", "sections", "section", "index", "elementKey", "Element", "children", "_", "group", "Translation", "i18nKey", "t", "variables", "stringWithVariables", "isReactServerComponentOrFunction", "serverProps", "React", "withMergedProps", "Component", "sanitizeServerOnlyProps", "toMergeIntoProps", "passedProps", "mergedProps", "simpleMergeProps", "prop", "props", "toMerge", "isReactServerComponentOrFunction", "React", "WithServerSideProps", "Component", "serverOnlyProps", "rest", "passedProps", "propsWithServerOnlyProps", "mergeFieldStyles", "field", "deepCopyObjectComplex", "blacklistedKeys", "sanitizeField", "incomingField", "field", "key", "reduceToSerializableFields", "fields", "acc", "React", "PayloadIcon", "fillFromProps", "fill", "React", "css", "PayloadLogo", "abortAndIgnore", "controller", "qs", "requests", "url", "options", "headers", "formattedOptions", "query", "findLocaleFromCode", "localizationConfig", "locale", "el", "formatAdminURL", "args", "adminRoute", "basePath", "path", "serverURL", "format", "formatDistanceToNow", "formatDate", "date", "i18n", "pattern", "theDate", "getTranslation", "formatDocTitle", "collectionConfig", "data", "dateFormatFromConfig", "fallback", "globalConfig", "i18n", "title", "useAsTitle", "fieldConfig", "f", "dateFormat", "formatDate", "getTranslation", "getTranslation", "EntityType", "groupNavItems", "entities", "permissions", "i18n", "groups", "entityToGroup", "translatedGroup", "existingGroup", "group", "matchedGroup", "handleBackToDashboard", "adminRoute", "router", "redirectRoute", "formatAdminURL", "handleGoBack", "adminRoute", "collectionSlug", "router", "redirectRoute", "formatAdminURL", "handleTakeOver", "id", "collectionSlug", "globalSlug", "user", "isWithinDoc", "updateDocumentEditor", "setCurrentEditor", "documentLockStateRef", "isLockingEnabled", "setIsReadOnlyForIncomingUser", "error", "hasSavePermission", "args", "collectionSlug", "docPermissions", "globalSlug", "isEditing", "isClientUserObject", "user", "isEditing", "id", "collectionSlug", "globalSlug", "isEmptyObject", "obj", "hoistQueryParamsToAnd", "currentWhere", "incomingWhere", "mergeListSearchAndWhere", "collectionConfig", "search", "where", "copyOfWhere", "searchAsConditions", "fieldName"]
3
+ "sources": ["../../../src/elements/TableColumns/filterFields.tsx", "../../../src/elements/TableColumns/getInitialColumns.ts", "../../../src/elements/Translation/index.tsx", "../../../src/elements/withMergedProps/index.tsx", "../../../src/elements/WithServerSideProps/index.tsx", "../../../src/fields/mergeFieldStyles.ts", "../../../src/forms/Form/reduceToSerializableFields.ts", "../../../src/graphics/Icon/index.tsx", "../../../src/graphics/Logo/index.tsx", "../../../src/utilities/abortAndIgnore.ts", "../../../src/utilities/api.ts", "../../../src/utilities/findLocaleFromCode.ts", "../../../src/utilities/formatAdminURL.ts", "../../../src/utilities/formatDate.ts", "../../../src/utilities/formatDocTitle.ts", "../../../src/utilities/groupNavItems.ts", "../../../src/utilities/handleBackToDashboard.tsx", "../../../src/utilities/handleGoBack.tsx", "../../../src/utilities/handleTakeOver.tsx", "../../../src/utilities/hasSavePermission.ts", "../../../src/utilities/isClientUserObject.ts", "../../../src/utilities/isEditing.ts", "../../../src/utilities/mergeListSearchAndWhere.ts", "../../../src/utilities/sanitizeID.ts"],
4
+ "sourcesContent": ["import type { ClientField, Field } from 'payload'\n\n// 1. Skips fields that are hidden, disabled, or presentational-only (i.e. `ui` fields)\n// 2. Maps through top-level `tabs` fields and filters out the same\nexport const filterFields = <T extends ClientField | Field>(incomingFields: T[]): T[] => {\n const shouldSkipField = (field: T): boolean =>\n (field.type !== 'ui' && field.admin?.disabled === true) ||\n field?.admin?.disableListColumn === true\n\n const fields: T[] = incomingFields?.reduce((formatted, field) => {\n if (shouldSkipField(field)) {\n return formatted\n }\n\n const formattedField: T =\n field.type === 'tabs' && 'tabs' in field\n ? {\n ...field,\n tabs: field.tabs.map((tab) => ({\n ...tab,\n fields: tab.fields.filter((tabField) => !shouldSkipField(tabField)),\n })),\n }\n : field\n\n return [...formatted, formattedField]\n }, [])\n\n return fields\n}\n", "import type { ClientField, Field } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { ColumnPreferences } from '../../providers/ListQuery/index.js'\n\nconst getRemainingColumns = <T extends ClientField[] | Field[]>(\n fields: T,\n useAsTitle: string,\n): ColumnPreferences =>\n fields?.reduce((remaining, field) => {\n if (fieldAffectsData(field) && field.name === useAsTitle) {\n return remaining\n }\n\n if (!fieldAffectsData(field) && 'fields' in field) {\n return [...remaining, ...getRemainingColumns(field.fields, useAsTitle)]\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n return [\n ...remaining,\n ...field.tabs.reduce(\n (tabFieldColumns, tab) => [\n ...tabFieldColumns,\n ...('name' in tab ? [tab.name] : getRemainingColumns(tab.fields, useAsTitle)),\n ],\n [],\n ),\n ]\n }\n\n return [...remaining, field.name]\n }, [])\n\nexport const getInitialColumns = <T extends ClientField[] | Field[]>(\n fields: T,\n useAsTitle: string,\n defaultColumns: string[],\n): ColumnPreferences => {\n let initialColumns = []\n\n if (Array.isArray(defaultColumns) && defaultColumns.length >= 1) {\n initialColumns = defaultColumns\n } else {\n if (useAsTitle) {\n initialColumns.push(useAsTitle)\n }\n\n const remainingColumns = getRemainingColumns(fields, useAsTitle)\n\n initialColumns = initialColumns.concat(remainingColumns)\n initialColumns = initialColumns.slice(0, 4)\n }\n\n return initialColumns.map((column) => ({\n accessor: column,\n active: true,\n }))\n}\n", "import type { ClientTranslationKeys, TFunction } from '@payloadcms/translations'\n\nimport * as React from 'react'\n\nconst RecursiveTranslation: React.FC<{\n elements?: Record<string, React.FC<{ children: React.ReactNode }>>\n translationString: string\n}> = ({ elements, translationString }) => {\n const regex = /(<[^>]+>.*?<\\/[^>]+>)/g\n const sections = translationString.split(regex)\n\n return (\n <span>\n {sections.map((section, index) => {\n if (elements && section.startsWith('<') && section.endsWith('>')) {\n const elementKey = section[1]\n const Element = elements[elementKey]\n\n if (Element) {\n const regex = new RegExp(`<${elementKey}>(.*?)<\\/${elementKey}>`, 'g')\n const children = section.replace(regex, (_, group) => group)\n\n return (\n <Element key={index}>\n <RecursiveTranslation translationString={children} />\n </Element>\n )\n }\n }\n\n return section\n })}\n </span>\n )\n}\n\nexport type TranslationProps = {\n elements?: Record<string, React.FC<{ children: React.ReactNode }>>\n i18nKey: ClientTranslationKeys\n t: TFunction\n variables?: Record<string, unknown>\n}\n\nexport const Translation: React.FC<TranslationProps> = ({ elements, i18nKey, t, variables }) => {\n const stringWithVariables = t(i18nKey, variables || {})\n\n if (!elements) {\n return stringWithVariables\n }\n\n return <RecursiveTranslation elements={elements} translationString={stringWithVariables} />\n}\n", "import { isReactServerComponentOrFunction, serverProps } from 'payload/shared'\nimport React from 'react'\n\n/**\n * Creates a higher-order component (HOC) that merges predefined properties (`toMergeIntoProps`)\n * with any properties passed to the resulting component.\n *\n * Use this when you want to pre-specify some props for a component, while also allowing users to\n * pass in their own props. The HOC ensures the passed props and predefined props are combined before\n * rendering the original component.\n *\n * @example\n * const PredefinedComponent = getMergedPropsComponent({\n * Component: OriginalComponent,\n * toMergeIntoProps: { someExtraValue: 5 }\n * });\n * // Using <PredefinedComponent customProp=\"value\" /> will result in\n * // <OriginalComponent customProp=\"value\" someExtraValue={5} />\n *\n * @returns A higher-order component with combined properties.\n *\n * @param Component - The original component to wrap.\n * @param sanitizeServerOnlyProps - If true, server-only props will be removed from the merged props. @default true if the component is not a server component, false otherwise.\n * @param toMergeIntoProps - The properties to merge into the passed props.\n */\nexport function withMergedProps<ToMergeIntoProps, CompleteReturnProps>({\n Component,\n sanitizeServerOnlyProps,\n toMergeIntoProps,\n}: {\n Component: React.FC<CompleteReturnProps>\n sanitizeServerOnlyProps?: boolean\n toMergeIntoProps: ToMergeIntoProps\n}): React.FC<CompleteReturnProps> {\n if (sanitizeServerOnlyProps === undefined) {\n sanitizeServerOnlyProps = !isReactServerComponentOrFunction(Component)\n }\n // A wrapper around the args.Component to inject the args.toMergeArgs as props, which are merged with the passed props\n const MergedPropsComponent: React.FC<CompleteReturnProps> = (passedProps) => {\n const mergedProps = simpleMergeProps(passedProps, toMergeIntoProps) as CompleteReturnProps\n\n if (sanitizeServerOnlyProps) {\n serverProps.forEach((prop) => {\n delete mergedProps[prop]\n })\n }\n\n return <Component {...mergedProps} />\n }\n\n return MergedPropsComponent\n}\n\nfunction simpleMergeProps(props, toMerge) {\n return { ...props, ...toMerge }\n}\n", "import type { WithServerSidePropsComponent } from 'payload'\n\nimport { isReactServerComponentOrFunction } from 'payload/shared'\nimport React from 'react'\n\nexport const WithServerSideProps: WithServerSidePropsComponent = ({\n Component,\n serverOnlyProps,\n ...rest\n}) => {\n if (Component) {\n const WithServerSideProps: React.FC = (passedProps) => {\n const propsWithServerOnlyProps = {\n ...passedProps,\n ...(isReactServerComponentOrFunction(Component) ? (serverOnlyProps ?? {}) : {}),\n }\n\n return <Component {...propsWithServerOnlyProps} />\n }\n\n return WithServerSideProps(rest)\n }\n\n return null\n}\n", "import type { ClientField } from 'payload'\n\nexport const mergeFieldStyles = (\n field: ClientField | Omit<ClientField, 'type'>,\n): React.CSSProperties => ({\n ...(field?.admin?.style || {}),\n ...(field?.admin?.width\n ? {\n '--field-width': field.admin.width,\n }\n : {\n flex: '1 1 auto',\n }),\n // allow flex overrides to still take precedence over the fallback\n ...(field?.admin?.style?.flex\n ? {\n flex: field.admin.style.flex,\n }\n : {}),\n})\n", "import { type FormField, type FormState } from 'payload'\nimport { deepCopyObjectComplex } from 'payload/shared'\n\ntype BlacklistedKeys = 'customComponents' | 'validate'\nconst blacklistedKeys: BlacklistedKeys[] = ['validate', 'customComponents']\n\nconst sanitizeField = (incomingField: FormField): FormField => {\n const field = deepCopyObjectComplex(incomingField)\n\n blacklistedKeys.forEach((key) => {\n delete field[key]\n })\n\n return field\n}\n\n/* \n Takes in FormState and removes fields that are not serializable.\n Returns FormState without blacklisted keys.\n**/\nexport const reduceToSerializableFields = (\n fields: FormState,\n): {\n [key: string]: Omit<FormField, BlacklistedKeys>\n} => {\n return Object.keys(fields).reduce(\n (acc, key) => {\n acc[key] = sanitizeField(fields[key])\n return acc\n },\n {} as {\n [key: string]: Omit<FormField, BlacklistedKeys>\n },\n )\n}\n", "import React from 'react'\n\nexport const PayloadIcon: React.FC<{\n fill?: string\n}> = ({ fill: fillFromProps }) => {\n const fill = fillFromProps || 'var(--theme-elevation-1000)'\n\n return (\n <svg\n className=\"graphic-icon\"\n height=\"100%\"\n viewBox=\"0 0 25 25\"\n width=\"100%\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M11.8673 21.2336L4.40922 16.9845C4.31871 16.9309 4.25837 16.8355 4.25837 16.7282V10.1609C4.25837 10.0477 4.38508 9.97616 4.48162 10.0298L13.1404 14.9642C13.2611 15.0358 13.412 14.9464 13.412 14.8093V11.6091C13.412 11.4839 13.3456 11.3647 13.2309 11.2992L2.81624 5.36353C2.72573 5.30989 2.60505 5.30989 2.51454 5.36353L1.15085 6.14422C1.06034 6.19786 1 6.29321 1 6.40048V18.5995C1 18.7068 1.06034 18.8021 1.15085 18.8558L11.8491 24.9583C11.9397 25.0119 12.0603 25.0119 12.1509 24.9583L21.1355 19.8331C21.2562 19.7616 21.2562 19.5948 21.1355 19.5232L18.3357 17.9261C18.2211 17.8605 18.0883 17.8605 17.9737 17.9261L12.175 21.2336C12.0845 21.2872 11.9638 21.2872 11.8733 21.2336H11.8673Z\"\n fill={fill}\n />\n <path\n d=\"M22.8491 6.13827L12.1508 0.0417218C12.0603 -0.0119135 11.9397 -0.0119135 11.8491 0.0417218L6.19528 3.2658C6.0746 3.33731 6.0746 3.50418 6.19528 3.57569L8.97092 5.16091C9.08557 5.22647 9.21832 5.22647 9.33296 5.16091L11.8672 3.71872C11.9578 3.66508 12.0784 3.66508 12.1689 3.71872L19.627 7.96782C19.7175 8.02146 19.7778 8.11681 19.7778 8.22408V14.8212C19.7778 14.9464 19.8442 15.0656 19.9589 15.1311L22.7345 16.7104C22.8552 16.7819 23.006 16.6925 23.006 16.5554V6.40048C23.006 6.29321 22.9457 6.19786 22.8552 6.14423L22.8491 6.13827Z\"\n fill={fill}\n />\n </svg>\n )\n}\n", "import React from 'react'\n\nconst css = `\n .graphic-logo path {\n fill: var(--theme-elevation-1000);\n }\n`\n\nexport const PayloadLogo: React.FC = () => (\n <svg\n className=\"graphic-logo\"\n fill=\"none\"\n height=\"43.5\"\n id=\"b\"\n viewBox=\"0 0 193.38 43.5\"\n width=\"193.38\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <style>{css}</style>\n <g id=\"c\">\n <path d=\"M18.01,35.63l-12.36-7.13c-.15-.09-.25-.25-.25-.43v-11.02c0-.19.21-.31.37-.22l14.35,8.28c.2.12.45-.03.45-.26v-5.37c0-.21-.11-.41-.3-.52L3.01,9c-.15-.09-.35-.09-.5,0l-2.26,1.31c-.15.09-.25.25-.25.43v20.47c0,.18.1.34.25.43l17.73,10.24c.15.09.35.09.5,0l14.89-8.6c.2-.12.2-.4,0-.52l-4.64-2.68c-.19-.11-.41-.11-.6,0l-9.61,5.55c-.15.09-.35.09-.5,0Z\" />\n <path d=\"M36.21,10.3L18.48.07c-.15-.09-.35-.09-.5,0l-9.37,5.41c-.2.12-.2.4,0,.52l4.6,2.66c.19.11.41.11.6,0l4.2-2.42c.15-.09.35-.09.5,0l12.36,7.13c.15.09.25.25.25.43v11.07c0,.21.11.41.3.52l4.6,2.65c.2.12.45-.03.45-.26V10.74c0-.18-.1-.34-.25-.43Z\" />\n <g id=\"d\">\n <path d=\"M193.38,9.47c0,1.94-1.48,3.32-3.3,3.32s-3.31-1.39-3.31-3.32,1.49-3.31,3.31-3.31,3.3,1.39,3.3,3.31ZM192.92,9.47c0-1.68-1.26-2.88-2.84-2.88s-2.84,1.2-2.84,2.88,1.26,2.89,2.84,2.89,2.84-1.2,2.84-2.89ZM188.69,11.17v-3.51h1.61c.85,0,1.35.39,1.35,1.15,0,.53-.3.86-.67,1.02l.79,1.35h-.89l-.72-1.22h-.64v1.22h-.82ZM190.18,9.31c.46,0,.64-.16.64-.5s-.19-.49-.64-.49h-.67v.99h.67Z\" />\n <path d=\"M54.72,24.84v10.93h-5.4V6.1h12.26c7.02,0,11.1,3.2,11.1,9.39s-4.07,9.35-11.06,9.35h-6.9,0ZM61.12,20.52c4.07,0,6.11-1.66,6.11-5.03s-2.04-5.03-6.11-5.03h-6.4v10.06h6.4Z\" />\n <path d=\"M85.94,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.18-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM85.73,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z\" />\n <path d=\"M90.39,14.66h5.4l5.86,15.92h.08l5.57-15.92h5.28l-8.23,21.49c-2,5.28-4.45,7.32-8.89,7.36-.71,0-1.7-.08-2.45-.21v-4.03c.62.13.96.13,1.41.13,2.16,0,3.07-.75,4.2-3.66l-8.23-21.07h0Z\" />\n <path d=\"M113.46,35.77V6.1h5.32v29.67h-5.32Z\" />\n <path d=\"M130.79,36.27c-6.23,0-10.68-4.2-10.68-11.05s4.45-11.05,10.68-11.05,10.68,4.24,10.68,11.05-4.45,11.05-10.68,11.05ZM130.79,32.32c3.41,0,5.36-2.66,5.36-7.11s-1.95-7.11-5.36-7.11-5.36,2.7-5.36,7.11,1.91,7.11,5.36,7.11Z\" />\n <path d=\"M156.19,32.45c-1,2.41-3.66,3.78-7.02,3.78-4.11,0-7.11-2.29-7.11-6.11,0-4.24,3.32-5.98,7.61-6.48l6.32-.71v-1c0-2.58-1.58-3.82-3.99-3.82s-3.74,1.29-3.91,3.24h-5.11c.46-4.53,3.99-7.19,9.19-7.19,5.74,0,9.02,2.7,9.02,8.19v8.15c0,1.95.08,3.58.42,5.28h-5.11c-.21-1.16-.29-2.29-.29-3.32h0ZM155.98,27.58v-1.29l-4.7.54c-2.24.29-3.95.79-3.95,2.99,0,1.66,1.16,2.7,3.28,2.7,2.74,0,5.36-1.62,5.36-4.95h0Z\" />\n <path d=\"M178.5,32.41c-1.04,2.12-3.58,3.87-6.78,3.87-5.53,0-9.31-4.49-9.31-11.05s3.78-11.05,9.31-11.05c3.28,0,5.69,1.83,6.69,3.95V6.1h5.32v29.67h-5.24v-3.37h0ZM178.55,24.84c0-4.11-1.95-6.78-5.32-6.78s-5.45,2.83-5.45,7.15,2,7.15,5.45,7.15,5.32-2.66,5.32-6.78v-.75h0Z\" />\n </g>\n </g>\n </svg>\n)\n", "export function abortAndIgnore(controller: AbortController) {\n if (controller) {\n try {\n controller.abort()\n } catch (_err) {\n // swallow error\n }\n }\n}\n", "import * as qs from 'qs-esm'\n\ntype GetOptions = {\n params?: Record<string, unknown>\n} & RequestInit\n\nexport const requests = {\n delete: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'delete',\n }\n\n return fetch(url, formattedOptions)\n },\n\n get: (url: string, options: GetOptions = { headers: {} }): Promise<Response> => {\n let query = ''\n if (options.params) {\n query = qs.stringify(options.params, { addQueryPrefix: true })\n }\n return fetch(`${url}${query}`, {\n credentials: 'include',\n ...options,\n })\n },\n\n patch: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'PATCH',\n }\n\n return fetch(url, formattedOptions)\n },\n\n post: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'post',\n }\n\n return fetch(`${url}`, formattedOptions)\n },\n\n put: (url: string, options: RequestInit = { headers: {} }): Promise<Response> => {\n const headers = options && options.headers ? { ...options.headers } : {}\n\n const formattedOptions: RequestInit = {\n ...options,\n credentials: 'include',\n headers: {\n ...headers,\n },\n method: 'put',\n }\n\n return fetch(url, formattedOptions)\n },\n}\n", "import type { Locale, SanitizedLocalizationConfig } from 'payload'\n/*\n return the Locale for given locale code, else return null\n*/\nexport const findLocaleFromCode = (\n localizationConfig: SanitizedLocalizationConfig,\n locale: string,\n): Locale | null => {\n if (!localizationConfig?.locales || localizationConfig.locales.length === 0) {\n return null\n }\n\n return localizationConfig.locales.find((el) => el?.code === locale)\n}\n", "import type { Config } from 'payload'\n\n/** Will read the `routes.admin` config and appropriately handle `\"/\"` admin paths */\nexport const formatAdminURL = (args: {\n adminRoute: Config['routes']['admin']\n basePath?: string\n path: string\n serverURL?: Config['serverURL']\n}): string => {\n const { adminRoute, basePath = '', path, serverURL } = args\n\n if (adminRoute) {\n if (adminRoute === '/') {\n if (!path) {\n return `${serverURL || ''}${basePath}${adminRoute}`\n }\n } else {\n return `${serverURL || ''}${basePath}${adminRoute}${path}`\n }\n }\n\n return `${serverURL || ''}${basePath}${path}`\n}\n", "import type { I18n } from '@payloadcms/translations'\n\nimport { format, formatDistanceToNow } from 'date-fns'\n\ntype FormatDateArgs = {\n date: Date | number | string | undefined\n i18n: I18n<any, any>\n pattern: string\n}\n\nexport const formatDate = ({ date, i18n, pattern }: FormatDateArgs): string => {\n const theDate = new Date(date)\n return format(theDate, pattern, { locale: i18n.dateFNS })\n}\n\ntype FormatTimeToNowArgs = {\n date: Date | number | string | undefined\n i18n: I18n<any, any>\n}\n\nexport const formatTimeToNow = ({ date, i18n }: FormatTimeToNowArgs): string => {\n const theDate = new Date(date)\n return formatDistanceToNow(theDate, { locale: i18n.dateFNS })\n}\n", "import type { I18n } from '@payloadcms/translations'\nimport type {\n ClientCollectionConfig,\n ClientGlobalConfig,\n SanitizedConfig,\n TypeWithID,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\n\nimport { formatDate } from '../utilities/formatDate.js'\n\nexport const formatDocTitle = ({\n collectionConfig,\n data,\n dateFormat: dateFormatFromConfig,\n fallback,\n globalConfig,\n i18n,\n}: {\n collectionConfig?: ClientCollectionConfig\n data: TypeWithID\n dateFormat: SanitizedConfig['admin']['dateFormat']\n fallback?: string\n globalConfig?: ClientGlobalConfig\n i18n: I18n<any, any>\n}): string => {\n let title: string\n\n if (collectionConfig) {\n const useAsTitle = collectionConfig?.admin?.useAsTitle\n\n if (useAsTitle) {\n title = data?.[useAsTitle] || title\n\n if (title) {\n const fieldConfig = collectionConfig.fields.find(\n (f) => 'name' in f && f.name === useAsTitle,\n )\n\n const isDate = fieldConfig?.type === 'date'\n\n if (isDate) {\n const dateFormat =\n ('date' in fieldConfig.admin && fieldConfig?.admin?.date?.displayFormat) ||\n dateFormatFromConfig\n title = formatDate({ date: title, i18n, pattern: dateFormat }) || title\n }\n }\n }\n }\n\n if (globalConfig) {\n title = getTranslation(globalConfig?.label, i18n) || globalConfig?.slug\n }\n\n if (!title) {\n title = fallback || `[${i18n.t('general:untitled')}]`\n }\n\n return title\n}\n", "import type { I18nClient } from '@payloadcms/translations'\nimport type {\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n SanitizedPermissions,\n StaticLabel,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\n\nexport enum EntityType {\n collection = 'collections',\n global = 'globals',\n}\n\nexport type EntityToGroup =\n | {\n entity: SanitizedCollectionConfig\n type: EntityType.collection\n }\n | {\n entity: SanitizedGlobalConfig\n type: EntityType.global\n }\n\nexport type NavGroupType = {\n entities: {\n label: StaticLabel\n slug: string\n type: EntityType\n }[]\n label: string\n}\n\nexport function groupNavItems(\n entities: EntityToGroup[],\n permissions: SanitizedPermissions,\n i18n: I18nClient,\n): NavGroupType[] {\n const result = entities.reduce(\n (groups, entityToGroup) => {\n if (permissions?.[entityToGroup.type.toLowerCase()]?.[entityToGroup.entity.slug]?.read) {\n const translatedGroup = getTranslation(entityToGroup.entity.admin.group, i18n)\n\n if (entityToGroup.entity.admin.group) {\n const existingGroup = groups.find(\n (group) => getTranslation(group.label, i18n) === translatedGroup,\n ) as NavGroupType\n\n let matchedGroup: NavGroupType = existingGroup\n\n if (!existingGroup) {\n matchedGroup = { entities: [], label: translatedGroup }\n groups.push(matchedGroup)\n }\n\n matchedGroup.entities.push({\n slug: entityToGroup.entity.slug,\n type: entityToGroup.type,\n label:\n 'labels' in entityToGroup.entity\n ? typeof entityToGroup.entity.labels.plural === 'function'\n ? entityToGroup.entity.labels.plural({ t: i18n.t })\n : entityToGroup.entity.labels.plural\n : entityToGroup.entity.label,\n })\n } else {\n const defaultGroup = groups.find((group) => {\n return getTranslation(group.label, i18n) === i18n.t(`general:${entityToGroup.type}`)\n }) as NavGroupType\n defaultGroup.entities.push({\n slug: entityToGroup.entity.slug,\n type: entityToGroup.type,\n label:\n 'labels' in entityToGroup.entity\n ? typeof entityToGroup.entity.labels.plural === 'function'\n ? entityToGroup.entity.labels.plural({ t: i18n.t })\n : entityToGroup.entity.labels.plural\n : entityToGroup.entity.label,\n })\n }\n }\n\n return groups\n },\n [\n {\n entities: [],\n label: i18n.t('general:collections'),\n },\n {\n entities: [],\n label: i18n.t('general:globals'),\n },\n ],\n )\n\n return result.filter((group) => group.entities.length > 0)\n}\n", "import type { AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'\n\nimport { formatAdminURL } from './formatAdminURL.js'\n\ntype BackToDashboardProps = {\n adminRoute: string\n router: AppRouterInstance\n}\n\nexport const handleBackToDashboard = ({ adminRoute, router }: BackToDashboardProps) => {\n const redirectRoute = formatAdminURL({\n adminRoute,\n path: '/',\n })\n router.push(redirectRoute)\n}\n", "import type { AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'\n\nimport { formatAdminURL } from './formatAdminURL.js'\n\ntype GoBackProps = {\n adminRoute: string\n collectionSlug: string\n router: AppRouterInstance\n}\n\nexport const handleGoBack = ({ adminRoute, collectionSlug, router }: GoBackProps) => {\n const redirectRoute = formatAdminURL({\n adminRoute,\n path: collectionSlug ? `/collections/${collectionSlug}` : '/',\n })\n router.push(redirectRoute)\n}\n", "import type { ClientUser } from 'payload'\n\nexport const handleTakeOver = (\n id: number | string,\n collectionSlug: string,\n globalSlug: string,\n user: ClientUser | number | string,\n isWithinDoc: boolean,\n updateDocumentEditor: (\n docId: number | string,\n slug: string,\n user: ClientUser | number | string,\n ) => Promise<void>,\n setCurrentEditor: (value: React.SetStateAction<ClientUser | number | string>) => void,\n documentLockStateRef: React.RefObject<{\n hasShownLockedModal: boolean\n isLocked: boolean\n user: ClientUser | number | string\n }>,\n isLockingEnabled: boolean,\n setIsReadOnlyForIncomingUser?: (value: React.SetStateAction<boolean>) => void,\n): void => {\n if (!isLockingEnabled) {\n return\n }\n\n try {\n // Call updateDocumentEditor to update the document's owner to the current user\n void updateDocumentEditor(id, collectionSlug ?? globalSlug, user)\n\n if (!isWithinDoc) {\n documentLockStateRef.current.hasShownLockedModal = true\n }\n\n // Update the locked state to reflect the current user as the owner\n documentLockStateRef.current = {\n hasShownLockedModal: documentLockStateRef.current?.hasShownLockedModal,\n isLocked: true,\n user,\n }\n setCurrentEditor(user)\n\n // If this is a takeover within the document, ensure the document is editable\n if (isWithinDoc && setIsReadOnlyForIncomingUser) {\n setIsReadOnlyForIncomingUser(false)\n }\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error during document takeover:', error)\n }\n}\n", "import type {\n SanitizedCollectionPermission,\n SanitizedDocumentPermissions,\n SanitizedGlobalPermission,\n} from 'payload'\n\nexport const hasSavePermission = (args: {\n /*\n * Pass either `collectionSlug` or `globalSlug`\n */\n collectionSlug?: string\n docPermissions: SanitizedDocumentPermissions\n /*\n * Pass either `collectionSlug` or `globalSlug`\n */\n globalSlug?: string\n isEditing: boolean\n}) => {\n const { collectionSlug, docPermissions, globalSlug, isEditing } = args\n\n if (collectionSlug) {\n return Boolean(\n (isEditing && docPermissions?.update) ||\n (!isEditing && (docPermissions as SanitizedCollectionPermission)?.create),\n )\n }\n\n if (globalSlug) {\n return Boolean((docPermissions as SanitizedGlobalPermission)?.update)\n }\n\n return false\n}\n", "import type { ClientUser } from 'payload'\n\nexport const isClientUserObject = (user): user is ClientUser => {\n return user && typeof user === 'object'\n}\n", "export const isEditing = ({\n id,\n collectionSlug,\n globalSlug,\n}: {\n collectionSlug?: string\n globalSlug?: string\n id?: number | string\n}): boolean => Boolean(globalSlug || (collectionSlug && !!id))\n", "import type { ClientCollectionConfig, SanitizedCollectionConfig, Where } from 'payload'\n\nconst isEmptyObject = (obj: object) => Object.keys(obj).length === 0\n\nexport const hoistQueryParamsToAnd = (currentWhere: Where, incomingWhere: Where) => {\n if (isEmptyObject(incomingWhere)) {\n return currentWhere\n }\n\n if (isEmptyObject(currentWhere)) {\n return incomingWhere\n }\n\n if ('and' in currentWhere) {\n currentWhere.and.push(incomingWhere)\n } else if ('or' in currentWhere) {\n currentWhere = {\n and: [currentWhere, incomingWhere],\n }\n } else {\n currentWhere = {\n and: [currentWhere, incomingWhere],\n }\n }\n\n return currentWhere\n}\n\ntype Args = {\n collectionConfig: ClientCollectionConfig | SanitizedCollectionConfig\n search: string\n where?: Where\n}\n\nexport const mergeListSearchAndWhere = ({ collectionConfig, search, where = {} }: Args): Where => {\n if (search) {\n let copyOfWhere = { ...(where || {}) }\n\n const searchAsConditions = (\n collectionConfig.admin.listSearchableFields || [collectionConfig.admin?.useAsTitle || 'id']\n ).map((fieldName) => ({\n [fieldName]: {\n like: search,\n },\n }))\n\n if (searchAsConditions.length > 0) {\n copyOfWhere = hoistQueryParamsToAnd(copyOfWhere, {\n or: searchAsConditions,\n })\n }\n\n if (!isEmptyObject(copyOfWhere)) {\n where = copyOfWhere\n }\n }\n\n return where\n}\n", "export function sanitizeID(id: number | string): number | string {\n if (id === undefined) {\n return id\n }\n\n if (typeof id === 'number') {\n return id\n }\n\n return decodeURIComponent(id)\n}\n"],
5
+ "mappings": "AAIO,IAAMA,EAA+CC,GAA6B,CACvF,IAAMC,EAAmBC,GACtBA,EAAM,OAAS,MAAQA,EAAM,OAAO,WAAa,IAClDA,GAAO,OAAO,oBAAsB,GAqBtC,OAnBoBF,GAAgB,OAAO,CAACG,EAAWD,IAAU,CAC/D,GAAID,EAAgBC,CAAK,EACvB,OAAOC,EAGT,IAAMC,EACJF,EAAM,OAAS,QAAU,SAAUA,EAC/B,CACE,GAAGA,EACH,KAAMA,EAAM,KAAK,IAAKG,IAAS,CAC7B,GAAGA,EACH,OAAQA,EAAI,OAAO,OAAQC,GAAa,CAACL,EAAgBK,CAAQ,CAAC,CACpE,EAAE,CACJ,EACAJ,EAEN,MAAO,CAAC,GAAGC,EAAWC,CAAc,CACtC,EAAG,CAAC,CAAC,CAGP,EC3BA,OAAS,oBAAAG,MAAwB,iBAIjC,IAAMC,EAAsB,CAC1BC,EACAC,IAEAD,GAAQ,OAAO,CAACE,EAAWC,IACrBL,EAAiBK,CAAK,GAAKA,EAAM,OAASF,EACrCC,EAGL,CAACJ,EAAiBK,CAAK,GAAK,WAAYA,EACnC,CAAC,GAAGD,EAAW,GAAGH,EAAoBI,EAAM,OAAQF,CAAU,CAAC,EAGpEE,EAAM,OAAS,QAAU,SAAUA,EAC9B,CACL,GAAGD,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EAAcP,GAAsBO,EAAa,CAC/C,GAAIC,CACN,CAAC,GAGEV,EAAcS,CAAW,IAC5BD,EAAQC,EAEZ,CAEA,OAAOD,CACT,EC1DO,SAASI,GAAWC,EAAsC,CAK/D,OAJIA,IAAO,QAIP,OAAOA,GAAO,SACTA,EAGF,mBAAmBA,CAAE,CAC9B",
6
+ "names": ["filterFields", "incomingFields", "shouldSkipField", "field", "formatted", "formattedField", "tab", "tabField", "fieldAffectsData", "getRemainingColumns", "fields", "useAsTitle", "remaining", "field", "tabFieldColumns", "tab", "getInitialColumns", "defaultColumns", "initialColumns", "remainingColumns", "column", "React", "RecursiveTranslation", "elements", "translationString", "regex", "sections", "section", "index", "elementKey", "Element", "children", "_", "group", "Translation", "i18nKey", "t", "variables", "stringWithVariables", "isReactServerComponentOrFunction", "serverProps", "React", "withMergedProps", "Component", "sanitizeServerOnlyProps", "toMergeIntoProps", "passedProps", "mergedProps", "simpleMergeProps", "prop", "props", "toMerge", "isReactServerComponentOrFunction", "React", "WithServerSideProps", "Component", "serverOnlyProps", "rest", "passedProps", "propsWithServerOnlyProps", "mergeFieldStyles", "field", "deepCopyObjectComplex", "blacklistedKeys", "sanitizeField", "incomingField", "field", "key", "reduceToSerializableFields", "fields", "acc", "React", "PayloadIcon", "fillFromProps", "fill", "React", "css", "PayloadLogo", "abortAndIgnore", "controller", "qs", "requests", "url", "options", "headers", "formattedOptions", "query", "findLocaleFromCode", "localizationConfig", "locale", "el", "formatAdminURL", "args", "adminRoute", "basePath", "path", "serverURL", "format", "formatDistanceToNow", "formatDate", "date", "i18n", "pattern", "theDate", "getTranslation", "formatDocTitle", "collectionConfig", "data", "dateFormatFromConfig", "fallback", "globalConfig", "i18n", "title", "useAsTitle", "fieldConfig", "f", "dateFormat", "formatDate", "getTranslation", "getTranslation", "EntityType", "groupNavItems", "entities", "permissions", "i18n", "groups", "entityToGroup", "translatedGroup", "existingGroup", "group", "matchedGroup", "handleBackToDashboard", "adminRoute", "router", "redirectRoute", "formatAdminURL", "handleGoBack", "adminRoute", "collectionSlug", "router", "redirectRoute", "formatAdminURL", "handleTakeOver", "id", "collectionSlug", "globalSlug", "user", "isWithinDoc", "updateDocumentEditor", "setCurrentEditor", "documentLockStateRef", "isLockingEnabled", "setIsReadOnlyForIncomingUser", "error", "hasSavePermission", "args", "collectionSlug", "docPermissions", "globalSlug", "isEditing", "isClientUserObject", "user", "isEditing", "id", "collectionSlug", "globalSlug", "isEmptyObject", "obj", "hoistQueryParamsToAnd", "currentWhere", "incomingWhere", "mergeListSearchAndWhere", "collectionConfig", "search", "where", "copyOfWhere", "searchAsConditions", "fieldName", "sanitizeID", "id"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fieldReducer.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/fieldReducer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,SAAS,EAAO,MAAM,SAAS,CAAA;AAMxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAO7C;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,CAqW7E"}
1
+ {"version":3,"file":"fieldReducer.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/fieldReducer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,SAAS,EAAO,MAAM,SAAS,CAAA;AAMxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAO7C;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,CAsW7E"}
@@ -193,6 +193,7 @@ export function fieldReducer(state, action) {
193
193
  ...flattenRows(path, rows),
194
194
  [path]: {
195
195
  ...state[path],
196
+ requiresRender: true,
196
197
  rows: rowStateCopy
197
198
  }
198
199
  };
@@ -1 +1 @@
1
- {"version":3,"file":"fieldReducer.js","names":["ObjectIdImport","dequal","deepCopyObjectSimple","deepCopyObjectSimpleWithoutReactComponents","flattenRows","separateRows","ObjectId","default","fieldReducer","state","action","type","blockType","path","rowIndex","rowIndexFromArgs","subFieldState","rows","length","withNewRow","newRow","id","value","toHexString","undefined","collapsed","splice","initialValue","valid","remainingFields","siblingRows","newState","passesCondition","requiresRender","disableFormData","errorPaths","errors","forEach","message","fieldPath","errorMessage","segments","split","push","fieldErrorPath","parentPath","slice","join","Object","entries","reduce","acc","fieldState","fieldErrorPaths","errorACC","startsWith","changed","newErrorPaths","Array","isArray","includes","rowsMetadata","duplicateRowMetadata","duplicateRowState","key","keys","filter","endsWith","idState","isValid","moveFromIndex","moveToIndex","copyOfMovingRow","rowStateCopy","movingRowState","rowIndexArg","Math","max","min","optimize","field","oldField","newField","updatedRows","formState"],"sources":["../../../src/forms/Form/fieldReducer.ts"],"sourcesContent":["'use client'\nimport type { FormField, FormState, Row } from 'payload'\n\nimport ObjectIdImport from 'bson-objectid'\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\nimport { deepCopyObjectSimple, deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\n\nimport type { FieldAction } from './types.js'\n\nimport { flattenRows, separateRows } from './rows.js'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n\n/**\n * Reducer which modifies the form field state (all the current data of the fields in the form). When called using dispatch, it will return a new state object.\n */\nexport function fieldReducer(state: FormState, action: FieldAction): FormState {\n switch (action.type) {\n case 'ADD_ROW': {\n const { blockType, path, rowIndex: rowIndexFromArgs, subFieldState = {} } = action\n\n const rowIndex =\n typeof rowIndexFromArgs === 'number' ? rowIndexFromArgs : state[path]?.rows?.length || 0\n\n const withNewRow = [...(state[path]?.rows || [])]\n\n const newRow: Row = {\n id: (subFieldState?.id?.value as string) || new ObjectId().toHexString(),\n blockType: blockType || undefined,\n collapsed: false,\n }\n\n withNewRow.splice(rowIndex, 0, newRow)\n\n if (blockType) {\n subFieldState.blockType = {\n initialValue: blockType,\n valid: true,\n value: blockType,\n }\n }\n\n // add new row to array _field state_\n const { remainingFields, rows: siblingRows } = separateRows(path, state)\n siblingRows.splice(rowIndex, 0, subFieldState)\n\n const newState: FormState = {\n ...remainingFields,\n ...flattenRows(path, siblingRows),\n [`${path}.${rowIndex}.id`]: {\n initialValue: newRow.id,\n passesCondition: true,\n requiresRender: true,\n valid: true,\n value: newRow.id,\n },\n [path]: {\n ...state[path],\n disableFormData: true,\n requiresRender: true,\n rows: withNewRow,\n value: siblingRows.length,\n },\n }\n\n return newState\n }\n\n case 'ADD_SERVER_ERRORS': {\n let newState = { ...state }\n\n const errorPaths: { fieldErrorPath: string; parentPath: string }[] = []\n\n action.errors.forEach(({ message, path: fieldPath }) => {\n newState[fieldPath] = {\n ...(newState[fieldPath] || {\n initialValue: null,\n value: null,\n }),\n errorMessage: message,\n valid: false,\n }\n\n const segments = fieldPath.split('.')\n if (segments.length > 1) {\n errorPaths.push({\n fieldErrorPath: fieldPath,\n parentPath: segments.slice(0, segments.length - 1).join('.'),\n })\n }\n })\n\n newState = Object.entries(newState).reduce((acc, [path, fieldState]) => {\n const fieldErrorPaths = errorPaths.reduce((errorACC, { fieldErrorPath, parentPath }) => {\n if (parentPath.startsWith(path)) {\n errorACC.push(fieldErrorPath)\n }\n return errorACC\n }, [])\n\n let changed = false\n\n if (fieldErrorPaths.length > 0) {\n const newErrorPaths = Array.isArray(fieldState.errorPaths) ? fieldState.errorPaths : []\n\n fieldErrorPaths.forEach((fieldErrorPath) => {\n if (!newErrorPaths.includes(fieldErrorPath)) {\n newErrorPaths.push(fieldErrorPath)\n changed = true\n }\n })\n\n if (changed) {\n acc[path] = {\n ...fieldState,\n errorPaths: newErrorPaths,\n }\n }\n }\n\n if (!changed) {\n acc[path] = fieldState\n }\n\n return acc\n }, {})\n\n return newState\n }\n\n case 'DUPLICATE_ROW': {\n const { path, rowIndex } = action\n const { remainingFields, rows } = separateRows(path, state)\n const rowsMetadata = [...(state[path].rows || [])]\n\n const duplicateRowMetadata = deepCopyObjectSimple(rowsMetadata[rowIndex])\n if (duplicateRowMetadata.id) {\n duplicateRowMetadata.id = new ObjectId().toHexString()\n }\n\n const duplicateRowState = deepCopyObjectSimpleWithoutReactComponents(rows[rowIndex])\n if (duplicateRowState.id) {\n duplicateRowState.id.value = new ObjectId().toHexString()\n duplicateRowState.id.initialValue = new ObjectId().toHexString()\n }\n\n for (const key of Object.keys(duplicateRowState).filter((key) => key.endsWith('.id'))) {\n const idState = duplicateRowState[key]\n\n if (idState && typeof idState.value === 'string' && ObjectId.isValid(idState.value)) {\n duplicateRowState[key].value = new ObjectId().toHexString()\n duplicateRowState[key].initialValue = new ObjectId().toHexString()\n }\n }\n\n // If there are subfields\n if (Object.keys(duplicateRowState).length > 0) {\n // Add new object containing subfield names to unflattenedRows array\n rows.splice(rowIndex + 1, 0, duplicateRowState)\n rowsMetadata.splice(rowIndex + 1, 0, duplicateRowMetadata)\n }\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, rows),\n [path]: {\n ...state[path],\n disableFormData: true,\n requiresRender: true,\n rows: rowsMetadata,\n value: rows.length,\n },\n }\n\n return newState\n }\n\n case 'MOVE_ROW': {\n const { moveFromIndex, moveToIndex, path } = action\n const { remainingFields, rows } = separateRows(path, state)\n\n // copy the row to move\n const copyOfMovingRow = rows[moveFromIndex]\n // delete the row by index\n rows.splice(moveFromIndex, 1)\n // insert row copyOfMovingRow back in\n rows.splice(moveToIndex, 0, copyOfMovingRow)\n\n // modify array/block internal row state (i.e. collapsed, blockType)\n const rowStateCopy = [...(state[path]?.rows || [])]\n const movingRowState = { ...rowStateCopy[moveFromIndex] }\n rowStateCopy.splice(moveFromIndex, 1)\n rowStateCopy.splice(moveToIndex, 0, movingRowState)\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, rows),\n [path]: {\n ...state[path],\n rows: rowStateCopy,\n },\n }\n\n return newState\n }\n\n case 'REMOVE': {\n const newState = { ...state }\n if (newState[action.path]) {\n delete newState[action.path]\n }\n return newState\n }\n\n case 'REMOVE_ROW': {\n const { path, rowIndex } = action\n const { remainingFields, rows } = separateRows(path, state)\n const rowsMetadata = [...(state[path]?.rows || [])]\n\n rows.splice(rowIndex, 1)\n rowsMetadata.splice(rowIndex, 1)\n\n const newState: FormState = {\n ...remainingFields,\n [path]: {\n ...state[path],\n disableFormData: rows.length > 0,\n requiresRender: true,\n rows: rowsMetadata,\n value: rows.length,\n },\n ...flattenRows(path, rows),\n }\n\n return newState\n }\n\n case 'REPLACE_ROW': {\n const { blockType, path, rowIndex: rowIndexArg, subFieldState = {} } = action\n\n const { remainingFields, rows: siblingRows } = separateRows(path, state)\n const rowIndex = Math.max(0, Math.min(rowIndexArg, siblingRows?.length - 1 || 0))\n\n const rowsMetadata = [...(state[path]?.rows || [])]\n rowsMetadata[rowIndex] = {\n id: new ObjectId().toHexString(),\n blockType: blockType || undefined,\n collapsed: false,\n }\n\n if (blockType) {\n subFieldState.blockType = {\n initialValue: blockType,\n valid: true,\n value: blockType,\n }\n }\n\n // replace form _field state_\n siblingRows[rowIndex] = subFieldState\n\n const newState: FormState = {\n ...remainingFields,\n ...flattenRows(path, siblingRows),\n [path]: {\n ...state[path],\n disableFormData: true,\n rows: rowsMetadata,\n value: siblingRows.length,\n },\n }\n\n return newState\n }\n\n case 'REPLACE_STATE': {\n if (action.optimize !== false) {\n // Only update fields that have changed\n // by comparing old value / initialValue to new\n // ..\n // This is a performance enhancement for saving\n // large documents with hundreds of fields\n const newState = {}\n\n Object.entries(action.state).forEach(([path, field]) => {\n const oldField = state[path]\n const newField = field\n\n if (!dequal(oldField, newField)) {\n newState[path] = newField\n } else if (oldField) {\n newState[path] = oldField\n }\n })\n return newState\n }\n // If we're not optimizing, just set the state to the new state\n return action.state\n }\n\n case 'SET_ALL_ROWS_COLLAPSED': {\n const { path, updatedRows } = action\n\n return {\n ...state,\n [path]: {\n ...state[path],\n rows: updatedRows,\n },\n }\n }\n\n case 'SET_ROW_COLLAPSED': {\n const { path, updatedRows } = action\n\n const newState = {\n ...state,\n [path]: {\n ...state[path],\n rows: updatedRows,\n },\n }\n\n return newState\n }\n\n case 'UPDATE': {\n const newField = Object.entries(action).reduce(\n (field, [key, value]) => {\n if (\n [\n 'disableFormData',\n 'errorMessage',\n 'initialValue',\n 'rows',\n 'valid',\n 'validate',\n 'value',\n ].includes(key)\n ) {\n return {\n ...field,\n [key]: value,\n }\n }\n\n return field\n },\n state[action.path] || ({} as FormField),\n )\n\n const newState = {\n ...state,\n [action.path]: newField,\n }\n\n return newState\n }\n\n case 'UPDATE_MANY': {\n const newState = { ...state }\n\n Object.entries(action.formState).forEach(([path, field]) => {\n newState[path] = field\n })\n\n return newState\n }\n\n default: {\n return state\n }\n }\n}\n"],"mappings":"AAAA;;AAGA,OAAOA,cAAA,MAAoB;AAC3B,SAASC,MAAM,QAAQ,cAAa,CAAC;AACrC,SAASC,oBAAoB,EAAEC,0CAA0C,QAAQ;AAIjF,SAASC,WAAW,EAAEC,YAAY,QAAQ;AAE1C,MAAMC,QAAA,GAAYN,cAAA,CAAeO,OAAO,IACtCP,cAAA;AAEF;;;AAGA,OAAO,SAASQ,aAAaC,KAAgB,EAAEC,MAAmB;EAChE,QAAQA,MAAA,CAAOC,IAAI;IACjB,KAAK;MAAW;QACd,MAAM;UAAEC,SAAS;UAAEC,IAAI;UAAEC,QAAA,EAAUC,gBAAgB;UAAEC,aAAA,GAAgB,CAAC;QAAC,CAAE,GAAGN,MAAA;QAE5E,MAAMI,QAAA,GACJ,OAAOC,gBAAA,KAAqB,WAAWA,gBAAA,GAAmBN,KAAK,CAACI,IAAA,CAAK,EAAEI,IAAA,EAAMC,MAAA,IAAU;QAEzF,MAAMC,UAAA,GAAa,C,IAAKV,KAAK,CAACI,IAAA,CAAK,EAAEI,IAAA,IAAQ,EAAE,EAAE;QAEjD,MAAMG,MAAA,GAAc;UAClBC,EAAA,EAAIL,aAAC,EAAeK,EAAA,EAAIC,KAAA,IAAoB,IAAIhB,QAAA,GAA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f,GAAGtB,KAAK;UACR,CAACC,MAAA,CAAOG,IAAI,GAAGqE;QACjB;QAEA,OAAOnD,QAAA;MACT;IAEA,KAAK;MAAe;QAClB,MAAMA,QAAA,GAAW;UAAE,GAAGtB;QAAM;QAE5BuC,MAAA,CAAOC,OAAO,CAACvC,MAAA,CAAO0E,SAAS,EAAE/C,OAAO,CAAC,CAAC,CAACxB,IAAA,EAAMmE,KAAA,CAAM;UACrDjD,QAAQ,CAAClB,IAAA,CAAK,GAAGmE,KAAA;QACnB;QAEA,OAAOjD,QAAA;MACT;IAEA;MAAS;QACP,OAAOtB,KAAA;MACT;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"fieldReducer.js","names":["ObjectIdImport","dequal","deepCopyObjectSimple","deepCopyObjectSimpleWithoutReactComponents","flattenRows","separateRows","ObjectId","default","fieldReducer","state","action","type","blockType","path","rowIndex","rowIndexFromArgs","subFieldState","rows","length","withNewRow","newRow","id","value","toHexString","undefined","collapsed","splice","initialValue","valid","remainingFields","siblingRows","newState","passesCondition","requiresRender","disableFormData","errorPaths","errors","forEach","message","fieldPath","errorMessage","segments","split","push","fieldErrorPath","parentPath","slice","join","Object","entries","reduce","acc","fieldState","fieldErrorPaths","errorACC","startsWith","changed","newErrorPaths","Array","isArray","includes","rowsMetadata","duplicateRowMetadata","duplicateRowState","key","keys","filter","endsWith","idState","isValid","moveFromIndex","moveToIndex","copyOfMovingRow","rowStateCopy","movingRowState","rowIndexArg","Math","max","min","optimize","field","oldField","newField","updatedRows","formState"],"sources":["../../../src/forms/Form/fieldReducer.ts"],"sourcesContent":["'use client'\nimport type { FormField, FormState, Row } from 'payload'\n\nimport ObjectIdImport from 'bson-objectid'\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\nimport { deepCopyObjectSimple, deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\n\nimport type { FieldAction } from './types.js'\n\nimport { flattenRows, separateRows } from './rows.js'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\n\n/**\n * Reducer which modifies the form field state (all the current data of the fields in the form). When called using dispatch, it will return a new state object.\n */\nexport function fieldReducer(state: FormState, action: FieldAction): FormState {\n switch (action.type) {\n case 'ADD_ROW': {\n const { blockType, path, rowIndex: rowIndexFromArgs, subFieldState = {} } = action\n\n const rowIndex =\n typeof rowIndexFromArgs === 'number' ? rowIndexFromArgs : state[path]?.rows?.length || 0\n\n const withNewRow = [...(state[path]?.rows || [])]\n\n const newRow: Row = {\n id: (subFieldState?.id?.value as string) || new ObjectId().toHexString(),\n blockType: blockType || undefined,\n collapsed: false,\n }\n\n withNewRow.splice(rowIndex, 0, newRow)\n\n if (blockType) {\n subFieldState.blockType = {\n initialValue: blockType,\n valid: true,\n value: blockType,\n }\n }\n\n // add new row to array _field state_\n const { remainingFields, rows: siblingRows } = separateRows(path, state)\n siblingRows.splice(rowIndex, 0, subFieldState)\n\n const newState: FormState = {\n ...remainingFields,\n ...flattenRows(path, siblingRows),\n [`${path}.${rowIndex}.id`]: {\n initialValue: newRow.id,\n passesCondition: true,\n requiresRender: true,\n valid: true,\n value: newRow.id,\n },\n [path]: {\n ...state[path],\n disableFormData: true,\n requiresRender: true,\n rows: withNewRow,\n value: siblingRows.length,\n },\n }\n\n return newState\n }\n\n case 'ADD_SERVER_ERRORS': {\n let newState = { ...state }\n\n const errorPaths: { fieldErrorPath: string; parentPath: string }[] = []\n\n action.errors.forEach(({ message, path: fieldPath }) => {\n newState[fieldPath] = {\n ...(newState[fieldPath] || {\n initialValue: null,\n value: null,\n }),\n errorMessage: message,\n valid: false,\n }\n\n const segments = fieldPath.split('.')\n if (segments.length > 1) {\n errorPaths.push({\n fieldErrorPath: fieldPath,\n parentPath: segments.slice(0, segments.length - 1).join('.'),\n })\n }\n })\n\n newState = Object.entries(newState).reduce((acc, [path, fieldState]) => {\n const fieldErrorPaths = errorPaths.reduce((errorACC, { fieldErrorPath, parentPath }) => {\n if (parentPath.startsWith(path)) {\n errorACC.push(fieldErrorPath)\n }\n return errorACC\n }, [])\n\n let changed = false\n\n if (fieldErrorPaths.length > 0) {\n const newErrorPaths = Array.isArray(fieldState.errorPaths) ? fieldState.errorPaths : []\n\n fieldErrorPaths.forEach((fieldErrorPath) => {\n if (!newErrorPaths.includes(fieldErrorPath)) {\n newErrorPaths.push(fieldErrorPath)\n changed = true\n }\n })\n\n if (changed) {\n acc[path] = {\n ...fieldState,\n errorPaths: newErrorPaths,\n }\n }\n }\n\n if (!changed) {\n acc[path] = fieldState\n }\n\n return acc\n }, {})\n\n return newState\n }\n\n case 'DUPLICATE_ROW': {\n const { path, rowIndex } = action\n const { remainingFields, rows } = separateRows(path, state)\n const rowsMetadata = [...(state[path].rows || [])]\n\n const duplicateRowMetadata = deepCopyObjectSimple(rowsMetadata[rowIndex])\n if (duplicateRowMetadata.id) {\n duplicateRowMetadata.id = new ObjectId().toHexString()\n }\n\n const duplicateRowState = deepCopyObjectSimpleWithoutReactComponents(rows[rowIndex])\n if (duplicateRowState.id) {\n duplicateRowState.id.value = new ObjectId().toHexString()\n duplicateRowState.id.initialValue = new ObjectId().toHexString()\n }\n\n for (const key of Object.keys(duplicateRowState).filter((key) => key.endsWith('.id'))) {\n const idState = duplicateRowState[key]\n\n if (idState && typeof idState.value === 'string' && ObjectId.isValid(idState.value)) {\n duplicateRowState[key].value = new ObjectId().toHexString()\n duplicateRowState[key].initialValue = new ObjectId().toHexString()\n }\n }\n\n // If there are subfields\n if (Object.keys(duplicateRowState).length > 0) {\n // Add new object containing subfield names to unflattenedRows array\n rows.splice(rowIndex + 1, 0, duplicateRowState)\n rowsMetadata.splice(rowIndex + 1, 0, duplicateRowMetadata)\n }\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, rows),\n [path]: {\n ...state[path],\n disableFormData: true,\n requiresRender: true,\n rows: rowsMetadata,\n value: rows.length,\n },\n }\n\n return newState\n }\n\n case 'MOVE_ROW': {\n const { moveFromIndex, moveToIndex, path } = action\n const { remainingFields, rows } = separateRows(path, state)\n\n // copy the row to move\n const copyOfMovingRow = rows[moveFromIndex]\n // delete the row by index\n rows.splice(moveFromIndex, 1)\n // insert row copyOfMovingRow back in\n rows.splice(moveToIndex, 0, copyOfMovingRow)\n\n // modify array/block internal row state (i.e. collapsed, blockType)\n const rowStateCopy = [...(state[path]?.rows || [])]\n const movingRowState = { ...rowStateCopy[moveFromIndex] }\n rowStateCopy.splice(moveFromIndex, 1)\n rowStateCopy.splice(moveToIndex, 0, movingRowState)\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, rows),\n [path]: {\n ...state[path],\n requiresRender: true,\n rows: rowStateCopy,\n },\n }\n\n return newState\n }\n\n case 'REMOVE': {\n const newState = { ...state }\n if (newState[action.path]) {\n delete newState[action.path]\n }\n return newState\n }\n\n case 'REMOVE_ROW': {\n const { path, rowIndex } = action\n const { remainingFields, rows } = separateRows(path, state)\n const rowsMetadata = [...(state[path]?.rows || [])]\n\n rows.splice(rowIndex, 1)\n rowsMetadata.splice(rowIndex, 1)\n\n const newState: FormState = {\n ...remainingFields,\n [path]: {\n ...state[path],\n disableFormData: rows.length > 0,\n requiresRender: true,\n rows: rowsMetadata,\n value: rows.length,\n },\n ...flattenRows(path, rows),\n }\n\n return newState\n }\n\n case 'REPLACE_ROW': {\n const { blockType, path, rowIndex: rowIndexArg, subFieldState = {} } = action\n\n const { remainingFields, rows: siblingRows } = separateRows(path, state)\n const rowIndex = Math.max(0, Math.min(rowIndexArg, siblingRows?.length - 1 || 0))\n\n const rowsMetadata = [...(state[path]?.rows || [])]\n rowsMetadata[rowIndex] = {\n id: new ObjectId().toHexString(),\n blockType: blockType || undefined,\n collapsed: false,\n }\n\n if (blockType) {\n subFieldState.blockType = {\n initialValue: blockType,\n valid: true,\n value: blockType,\n }\n }\n\n // replace form _field state_\n siblingRows[rowIndex] = subFieldState\n\n const newState: FormState = {\n ...remainingFields,\n ...flattenRows(path, siblingRows),\n [path]: {\n ...state[path],\n disableFormData: true,\n rows: rowsMetadata,\n value: siblingRows.length,\n },\n }\n\n return newState\n }\n\n case 'REPLACE_STATE': {\n if (action.optimize !== false) {\n // Only update fields that have changed\n // by comparing old value / initialValue to new\n // ..\n // This is a performance enhancement for saving\n // large documents with hundreds of fields\n const newState = {}\n\n Object.entries(action.state).forEach(([path, field]) => {\n const oldField = state[path]\n const newField = field\n\n if (!dequal(oldField, newField)) {\n newState[path] = newField\n } else if (oldField) {\n newState[path] = oldField\n }\n })\n return newState\n }\n // If we're not optimizing, just set the state to the new state\n return action.state\n }\n\n case 'SET_ALL_ROWS_COLLAPSED': {\n const { path, updatedRows } = action\n\n return {\n ...state,\n [path]: {\n ...state[path],\n rows: updatedRows,\n },\n }\n }\n\n case 'SET_ROW_COLLAPSED': {\n const { path, updatedRows } = action\n\n const newState = {\n ...state,\n [path]: {\n ...state[path],\n rows: updatedRows,\n },\n }\n\n return newState\n }\n\n case 'UPDATE': {\n const newField = Object.entries(action).reduce(\n (field, [key, value]) => {\n if (\n [\n 'disableFormData',\n 'errorMessage',\n 'initialValue',\n 'rows',\n 'valid',\n 'validate',\n 'value',\n ].includes(key)\n ) {\n return {\n ...field,\n [key]: value,\n }\n }\n\n return field\n },\n state[action.path] || ({} as FormField),\n )\n\n const newState = {\n ...state,\n [action.path]: newField,\n }\n\n return newState\n }\n\n case 'UPDATE_MANY': {\n const newState = { ...state }\n\n Object.entries(action.formState).forEach(([path, field]) => {\n newState[path] = field\n })\n\n return newState\n }\n\n default: {\n return state\n }\n }\n}\n"],"mappings":"AAAA;;AAGA,OAAOA,cAAA,MAAoB;AAC3B,SAASC,MAAM,QAAQ,cAAa,CAAC;AACrC,SAASC,oBAAoB,EAAEC,0CAA0C,QAAQ;AAIjF,SAASC,WAAW,EAAEC,YAAY,QAAQ;AAE1C,MAAMC,QAAA,GAAYN,cAAA,CAAeO,OAAO,IACtCP,cAAA;AAEF;;;AAGA,OAAO,SAASQ,aAAaC,KAAgB,EAAEC,MAAmB;EAChE,QAAQA,MAAA,C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KAAK,CAACI,IAAA,CAAK;YACdI,IAAA,EAAMkE;UACR;QACF;QAEA,OAAOpD,QAAA;MACT;IAEA,KAAK;MAAU;QACb,MAAMmD,QAAA,GAAWlC,MAAA,CAAOC,OAAO,CAACvC,MAAA,EAAQwC,MAAM,CAC5C,CAAC8B,KAAA,EAAO,CAAChB,GAAA,EAAK1C,KAAA,CAAM;UAClB,IACE,CACE,mBACA,gBACA,gBACA,QACA,SACA,YACA,QACD,CAACsC,QAAQ,CAACI,GAAA,GACX;YACA,OAAO;cACL,GAAGgB,KAAK;cACR,CAAChB,GAAA,GAAM1C;YACT;UACF;UAEA,OAAO0D,KAAA;QACT,GACAvE,KAAK,CAACC,MAAA,CAAOG,IAAI,CAAC,IAAK,CAAC;QAG1B,MAAMkB,QAAA,GAAW;UACf,GAAGtB,KAAK;UACR,CAACC,MAAA,CAAOG,IAAI,GAAGqE;QACjB;QAEA,OAAOnD,QAAA;MACT;IAEA,KAAK;MAAe;QAClB,MAAMA,QAAA,GAAW;UAAE,GAAGtB;QAAM;QAE5BuC,MAAA,CAAOC,OAAO,CAACvC,MAAA,CAAO0E,SAAS,EAAE/C,OAAO,CAAC,CAAC,CAACxB,IAAA,EAAMmE,KAAA,CAAM;UACrDjD,QAAQ,CAAClB,IAAA,CAAK,GAAGmE,KAAA;QACnB;QAEA,OAAOjD,QAAA;MACT;IAEA;MAAS;QACP,OAAOtB,KAAA;MACT;EACF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Preferences/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoE,MAAM,OAAO,CAAA;AAQxF,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;IACnD;;;;OAIG;IACH,aAAa,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAClF,CAAA;AAYD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAuHxE,CAAA;AAED,eAAO,MAAM,cAAc,QAAO,kBAAyC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/Preferences/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoE,MAAM,OAAO,CAAA;AAQxF,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;IACnD;;;;OAIG;IACH,aAAa,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAClF,CAAA;AAYD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAyHxE,CAAA;AAED,eAAO,MAAM,cAAc,QAAO,kBAAyC,CAAA"}
@@ -80,7 +80,9 @@ export const PreferencesProvider = ({
80
80
  // handle value objects where multiple values can be set under one key
81
81
  if (typeof value_0 === 'object' && typeof currentPreference === 'object' && typeof newValue === 'object') {
82
82
  // merge the value with any existing preference for the key
83
- newValue = deepMergeSimple(currentPreference, newValue);
83
+ if (currentPreference) {
84
+ newValue = deepMergeSimple(currentPreference, newValue);
85
+ }
84
86
  if (dequal(newValue, currentPreference)) {
85
87
  return;
86
88
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["dequal","React","createContext","useCallback","useContext","useEffect","useRef","useTranslation","requests","deepMergeSimple","useAuth","useConfig","Context","requestOptions","value","language","body","JSON","stringify","headers","PreferencesProvider","children","contextRef","preferencesRef","pendingUpdate","config","user","i18n","routes","api","serverURL","current","getPreference","key","prefs","promise","Promise","resolve","request","get","status","preference","json","setPreference","merge","post","newValue","currentPreference","updatePreference","setTimeout","_jsx","Provider","usePreferences"],"sources":["../../../src/providers/Preferences/index.tsx"],"sourcesContent":["'use client'\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\nimport React, { createContext, useCallback, useContext, useEffect, useRef } from 'react'\n\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { requests } from '../../utilities/api.js'\nimport { deepMergeSimple } from '../../utilities/deepMerge.js'\nimport { useAuth } from '../Auth/index.js'\nimport { useConfig } from '../Config/index.js'\n\ntype PreferencesContext = {\n getPreference: <T = any>(key: string) => Promise<T>\n /**\n * @param key - a string identifier for the property being set\n * @param value - preference data to store\n * @param merge - when true will combine the existing preference object batch the change into one request for objects, default = false\n */\n setPreference: <T = any>(key: string, value: T, merge?: boolean) => Promise<void>\n}\n\nconst Context = createContext({} as PreferencesContext)\n\nconst requestOptions = (value, language) => ({\n body: JSON.stringify({ value }),\n headers: {\n 'Accept-Language': language,\n 'Content-Type': 'application/json',\n },\n})\n\nexport const PreferencesProvider: React.FC<{ children?: React.ReactNode }> = ({ children }) => {\n const contextRef = useRef({} as PreferencesContext)\n const preferencesRef = useRef({})\n const pendingUpdate = useRef({})\n const { config } = useConfig()\n const { user } = useAuth()\n const { i18n } = useTranslation()\n\n const {\n routes: { api },\n serverURL,\n } = config\n\n useEffect(() => {\n if (!user) {\n // clear preferences between users\n preferencesRef.current = {}\n }\n }, [user])\n\n const getPreference = useCallback(\n async <T = any,>(key: string): Promise<T> => {\n const prefs = preferencesRef.current\n if (typeof prefs[key] !== 'undefined') {\n return prefs[key]\n }\n const promise = new Promise((resolve: (value: T) => void) => {\n void (async () => {\n const request = await requests.get(`${serverURL}${api}/payload-preferences/${key}`, {\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n let value = null\n if (request.status === 200) {\n const preference = await request.json()\n value = preference.value\n }\n preferencesRef.current[key] = value\n resolve(value)\n })()\n })\n prefs[key] = promise\n return promise\n },\n [i18n.language, api, preferencesRef, serverURL],\n )\n\n const setPreference = useCallback(\n async (key: string, value: unknown, merge = false): Promise<void> => {\n if (merge === false) {\n preferencesRef.current[key] = value\n\n await requests.post(\n `${serverURL}${api}/payload-preferences/${key}`,\n requestOptions(value, i18n.language),\n )\n\n return\n }\n\n let newValue = value\n const currentPreference = await getPreference(key)\n\n // handle value objects where multiple values can be set under one key\n if (\n typeof value === 'object' &&\n typeof currentPreference === 'object' &&\n typeof newValue === 'object'\n ) {\n // merge the value with any existing preference for the key\n newValue = deepMergeSimple(currentPreference, newValue)\n\n if (dequal(newValue, currentPreference)) {\n return\n }\n\n // add the requested changes to a pendingUpdate batch for the key\n pendingUpdate.current[key] = {\n ...pendingUpdate.current[key],\n ...(newValue as Record<string, unknown>),\n }\n } else {\n if (newValue === currentPreference) {\n return\n }\n pendingUpdate.current[key] = newValue\n }\n\n const updatePreference = async () => {\n // compare the value stored in context before sending to eliminate duplicate requests\n if (dequal(pendingUpdate.current[key], preferencesRef.current[key])) {\n return\n }\n\n // preference set in context here to prevent other updatePreference at the same time\n preferencesRef.current[key] = pendingUpdate.current[key]\n\n await requests.post(\n `${serverURL}${api}/payload-preferences/${key}`,\n requestOptions(preferencesRef.current[key], i18n.language),\n )\n\n // reset any changes for this key after sending the request\n delete pendingUpdate.current[key]\n }\n\n // use timeout to allow multiple changes of different values using the same key in one request\n setTimeout(() => {\n void updatePreference()\n })\n },\n [api, getPreference, i18n.language, pendingUpdate, serverURL],\n )\n\n contextRef.current.getPreference = getPreference\n contextRef.current.setPreference = setPreference\n\n return <Context.Provider value={contextRef.current}>{children}</Context.Provider>\n}\n\nexport const usePreferences = (): PreferencesContext => useContext(Context)\n"],"mappings":"AAAA;;;AACA,SAASA,MAAM,Q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AAM+B,cAAA,GAAiBA,CAAA;EAAA,OAA0BhD,UAAA,CAAAQ,OAAW;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["dequal","React","createContext","useCallback","useContext","useEffect","useRef","useTranslation","requests","deepMergeSimple","useAuth","useConfig","Context","requestOptions","value","language","body","JSON","stringify","headers","PreferencesProvider","children","contextRef","preferencesRef","pendingUpdate","config","user","i18n","routes","api","serverURL","current","getPreference","key","prefs","promise","Promise","resolve","request","get","status","preference","json","setPreference","merge","post","newValue","currentPreference","updatePreference","setTimeout","_jsx","Provider","usePreferences"],"sources":["../../../src/providers/Preferences/index.tsx"],"sourcesContent":["'use client'\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\nimport React, { createContext, useCallback, useContext, useEffect, useRef } from 'react'\n\nimport { useTranslation } from '../../providers/Translation/index.js'\nimport { requests } from '../../utilities/api.js'\nimport { deepMergeSimple } from '../../utilities/deepMerge.js'\nimport { useAuth } from '../Auth/index.js'\nimport { useConfig } from '../Config/index.js'\n\ntype PreferencesContext = {\n getPreference: <T = any>(key: string) => Promise<T>\n /**\n * @param key - a string identifier for the property being set\n * @param value - preference data to store\n * @param merge - when true will combine the existing preference object batch the change into one request for objects, default = false\n */\n setPreference: <T = any>(key: string, value: T, merge?: boolean) => Promise<void>\n}\n\nconst Context = createContext({} as PreferencesContext)\n\nconst requestOptions = (value, language) => ({\n body: JSON.stringify({ value }),\n headers: {\n 'Accept-Language': language,\n 'Content-Type': 'application/json',\n },\n})\n\nexport const PreferencesProvider: React.FC<{ children?: React.ReactNode }> = ({ children }) => {\n const contextRef = useRef({} as PreferencesContext)\n const preferencesRef = useRef({})\n const pendingUpdate = useRef({})\n const { config } = useConfig()\n const { user } = useAuth()\n const { i18n } = useTranslation()\n\n const {\n routes: { api },\n serverURL,\n } = config\n\n useEffect(() => {\n if (!user) {\n // clear preferences between users\n preferencesRef.current = {}\n }\n }, [user])\n\n const getPreference = useCallback(\n async <T = any,>(key: string): Promise<T> => {\n const prefs = preferencesRef.current\n if (typeof prefs[key] !== 'undefined') {\n return prefs[key]\n }\n const promise = new Promise((resolve: (value: T) => void) => {\n void (async () => {\n const request = await requests.get(`${serverURL}${api}/payload-preferences/${key}`, {\n headers: {\n 'Accept-Language': i18n.language,\n },\n })\n let value = null\n if (request.status === 200) {\n const preference = await request.json()\n value = preference.value\n }\n preferencesRef.current[key] = value\n resolve(value)\n })()\n })\n prefs[key] = promise\n return promise\n },\n [i18n.language, api, preferencesRef, serverURL],\n )\n\n const setPreference = useCallback(\n async (key: string, value: unknown, merge = false): Promise<void> => {\n if (merge === false) {\n preferencesRef.current[key] = value\n\n await requests.post(\n `${serverURL}${api}/payload-preferences/${key}`,\n requestOptions(value, i18n.language),\n )\n\n return\n }\n\n let newValue = value\n const currentPreference = await getPreference(key)\n\n // handle value objects where multiple values can be set under one key\n if (\n typeof value === 'object' &&\n typeof currentPreference === 'object' &&\n typeof newValue === 'object'\n ) {\n // merge the value with any existing preference for the key\n if (currentPreference) {\n newValue = deepMergeSimple(currentPreference, newValue)\n }\n\n if (dequal(newValue, currentPreference)) {\n return\n }\n\n // add the requested changes to a pendingUpdate batch for the key\n pendingUpdate.current[key] = {\n ...pendingUpdate.current[key],\n ...(newValue as Record<string, unknown>),\n }\n } else {\n if (newValue === currentPreference) {\n return\n }\n pendingUpdate.current[key] = newValue\n }\n\n const updatePreference = async () => {\n // compare the value stored in context before sending to eliminate duplicate requests\n if (dequal(pendingUpdate.current[key], preferencesRef.current[key])) {\n return\n }\n\n // preference set in context here to prevent other updatePreference at the same time\n preferencesRef.current[key] = pendingUpdate.current[key]\n\n await requests.post(\n `${serverURL}${api}/payload-preferences/${key}`,\n requestOptions(preferencesRef.current[key], i18n.language),\n )\n\n // reset any changes for this key after sending the request\n delete pendingUpdate.current[key]\n }\n\n // use timeout to allow multiple changes of different values using the same key in one request\n setTimeout(() => {\n void updatePreference()\n })\n },\n [api, getPreference, i18n.language, pendingUpdate, serverURL],\n )\n\n contextRef.current.getPreference = getPreference\n contextRef.current.setPreference = setPreference\n\n return <Context.Provider value={contextRef.current}>{children}</Context.Provider>\n}\n\nexport const usePreferences = (): PreferencesContext => useContext(Context)\n"],"mappings":"AAAA;;;AACA,SAASA,MAAM,QAAQ,cAAa,CAAC;AACrC,OAAOC,KAAA,IAASC,aAAa,EAAEC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ;AAEjF,SAASC,cAAc,QAAQ;AAC/B,SAASC,QAAQ,QAAQ;AACzB,SAASC,eAAe,QAAQ;AAChC,SAASC,OAAO,QAAQ;AACxB,SAASC,SAAS,QAAQ;AAY1B,MAAMC,OAAA,gBAAUV,aAAA,CAAc,CAAC;AAE/B,MAAMW,cAAA,GAAiBA,CAACC,KAAA,EAAOC,QAAA,MAAc;EAC3CC,IAAA,EAAMC,IAAA,CAAKC,SAAS,CAAC;IAAEJ;EAAM;EAC7BK,OAAA,EAAS;IACP,mBAAmBJ,QAAA;IACnB,gBAAgB;EAClB;AACF;AAEA,OAAO,MAAMK,mBAAA,GAAgEA,CAAC;EAAEC;AAAQ,CAAE;EACxF,MAAMC,UAAA,GAAahB,MAAA,CAAO,CAAC;EAC3B,MAAMiB,cAAA,GAAiBjB,MAAA,CAAO,CAAC;EAC/B,MAAMkB,aAAA,GAAgBlB,MAAA,CAAO,CAAC;EAC9B,MAAM;IAAEmB;EAAM,CAAE,GAAGd,SAAA;EACnB,MAAM;IAAEe;EAAI,CAAE,GAAGhB,OAAA;EACjB,MAAM;IAAEiB;EAAI,CAAE,GAAGpB,cAAA;EAEjB,MAAM;IACJqB,MAAA,EAAQ;MAAEC;IAAG,CAAE;IACfC;EAAS,CACV,GAAGL,MAAA;EAEJpB,SAAA,CAAU;IACR,IAAI,CAACqB,IAAA,EAAM;MACT;MACAH,cAAA,CAAeQ,OAAO,GAAG,CAAC;IAC5B;EACF,GAAG,CAACL,IAAA,CAAK;EAET,MAAMM,aAAA,GAAgB7B,WAAA,CACpB,MAAiB8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,GAAGA,aAAA;EACnCV,UAAA,CAAWS,OAAO,CAACY,aAAa,GAAGA,aAAA;EAEnC,oBAAOO,IAAA,CAACtC,OAAA,CAAQuC,QAAQ;IAACrC,KAAA,EAAOQ,UAAA,CAAWS,OAAO;cAAGV;;AACvD;AAEA,OAAO,MAAM+B,cAAA,GAAiBA,CAAA;EAAA,OAA0BhD,UAAA,CAAAQ,OAAW;AAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export declare function sanitizeID(id: number | string): number | string;
2
+ //# sourceMappingURL=sanitizeID.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitizeID.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizeID.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAU/D"}
@@ -0,0 +1,10 @@
1
+ export function sanitizeID(id) {
2
+ if (id === undefined) {
3
+ return id;
4
+ }
5
+ if (typeof id === 'number') {
6
+ return id;
7
+ }
8
+ return decodeURIComponent(id);
9
+ }
10
+ //# sourceMappingURL=sanitizeID.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitizeID.js","names":["sanitizeID","id","undefined","decodeURIComponent"],"sources":["../../src/utilities/sanitizeID.ts"],"sourcesContent":["export function sanitizeID(id: number | string): number | string {\n if (id === undefined) {\n return id\n }\n\n if (typeof id === 'number') {\n return id\n }\n\n return decodeURIComponent(id)\n}\n"],"mappings":"AAAA,OAAO,SAASA,WAAWC,EAAmB;EAC5C,IAAIA,EAAA,KAAOC,SAAA,EAAW;IACpB,OAAOD,EAAA;EACT;EAEA,IAAI,OAAOA,EAAA,KAAO,UAAU;IAC1B,OAAOA,EAAA;EACT;EAEA,OAAOE,kBAAA,CAAmBF,EAAA;AAC5B","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/ui",
3
- "version": "3.0.2",
3
+ "version": "3.0.3-canary.5abb7d5",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -133,7 +133,7 @@
133
133
  "ts-essentials": "10.0.3",
134
134
  "use-context-selector": "2.0.0",
135
135
  "uuid": "10.0.0",
136
- "@payloadcms/translations": "3.0.2"
136
+ "@payloadcms/translations": "3.0.3-canary.5abb7d5"
137
137
  },
138
138
  "devDependencies": {
139
139
  "@babel/cli": "^7.24.5",
@@ -151,14 +151,14 @@
151
151
  "esbuild": "0.23.1",
152
152
  "esbuild-sass-plugin": "3.3.1",
153
153
  "eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
154
- "@payloadcms/eslint-config": "3.0.0",
155
- "payload": "3.0.2"
154
+ "payload": "3.0.3-canary.5abb7d5",
155
+ "@payloadcms/eslint-config": "3.0.0"
156
156
  },
157
157
  "peerDependencies": {
158
158
  "next": "^15.0.0",
159
159
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
160
160
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
161
- "payload": "3.0.2"
161
+ "payload": "3.0.3-canary.5abb7d5"
162
162
  },
163
163
  "engines": {
164
164
  "node": "^18.20.2 || >=20.9.0"