@payloadcms/ui 3.0.2 → 3.0.3-canary.27acdae

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"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,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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AAa,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":[]}
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,G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ACnC;IAEA;IACAgB,UAAA,CAAW;MACT,KAAKD,gBAAA;IACP;EACF,GACA,CAACnB,GAAA,EAAKG,aAAA,EAAeL,IAAA,CAAKZ,QAAQ,EAAES,aAAA,EAAeM,SAAA,CAAU;EAG/DR,UAAA,CAAWS,OAAO,CAACC,aAAa,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.27acdae",
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.27acdae"
137
137
  },
138
138
  "devDependencies": {
139
139
  "@babel/cli": "^7.24.5",
@@ -152,13 +152,13 @@
152
152
  "esbuild-sass-plugin": "3.3.1",
153
153
  "eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
154
154
  "@payloadcms/eslint-config": "3.0.0",
155
- "payload": "3.0.2"
155
+ "payload": "3.0.3-canary.27acdae"
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.27acdae"
162
162
  },
163
163
  "engines": {
164
164
  "node": "^18.20.2 || >=20.9.0"