@payloadcms/ui 3.15.2-canary.de7619e → 3.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/dist/elements/Localizer/index.d.ts.map +1 -1
- package/dist/elements/Localizer/index.js +34 -17
- package/dist/elements/Localizer/index.js.map +1 -1
- package/dist/elements/Popup/PopupButtonList/index.d.ts +1 -0
- package/dist/elements/Popup/PopupButtonList/index.d.ts.map +1 -1
- package/dist/elements/Popup/PopupButtonList/index.js +30 -27
- package/dist/elements/Popup/PopupButtonList/index.js.map +1 -1
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +3 -3
- package/dist/providers/DocumentInfo/index.d.ts.map +1 -1
- package/dist/providers/DocumentInfo/index.js +6 -3
- package/dist/providers/DocumentInfo/index.js.map +1 -1
- package/dist/providers/Locale/index.d.ts +10 -15
- package/dist/providers/Locale/index.d.ts.map +1 -1
- package/dist/providers/Locale/index.js +134 -56
- package/dist/providers/Locale/index.js.map +1 -1
- package/dist/utilities/buildTableState.js.map +1 -1
- package/dist/utilities/fetchPreferences.d.ts +2 -0
- package/dist/utilities/fetchPreferences.d.ts.map +1 -0
- package/dist/utilities/fetchPreferences.js +2 -0
- package/dist/utilities/fetchPreferences.js.map +1 -0
- package/dist/utilities/upsertPreferences.d.ts +2 -2
- package/dist/utilities/upsertPreferences.d.ts.map +1 -1
- package/dist/utilities/upsertPreferences.js +30 -22
- package/dist/utilities/upsertPreferences.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsertPreferences.js","names":["dequal","removeUndefined","
|
|
1
|
+
{"version":3,"file":"upsertPreferences.js","names":["dequal","removeUndefined","getPreferences","key","req","result","payload","find","collection","depth","limit","pagination","where","and","equals","user","id","then","res","docs","upsertPreferences","value","incomingValue","existingPrefs","newPrefs","create","data","mergedPrefs","update"],"sources":["../../src/utilities/upsertPreferences.ts"],"sourcesContent":["import type { DefaultDocumentIDType, PayloadRequest } from 'payload'\n\nimport { dequal } from 'dequal/lite'\n\nimport { removeUndefined } from './removeUndefined.js'\n\nconst getPreferences = async <T>({\n key,\n req,\n}: {\n key: string\n req: PayloadRequest\n}): Promise<{ id: DefaultDocumentIDType; value: T }> => {\n const result = (await req.payload\n .find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n pagination: false,\n where: {\n and: [\n {\n key: {\n equals: key,\n },\n },\n {\n 'user.relationTo': {\n equals: req.user.collection,\n },\n },\n {\n 'user.value': {\n equals: req.user.id,\n },\n },\n ],\n },\n })\n .then((res) => res.docs?.[0])) as { id: DefaultDocumentIDType; value: T }\n\n return result\n}\n\n/**\n * Will update the given preferences by key, creating a new record if it doesn't already exist, or merging existing preferences with the new value.\n * This is not possible to do with the existing `db.upsert` operation because it stores on the `value` key and does not perform a deep merge beyond the first level.\n * I.e. if you have a preferences record with a `value` key, `db.upsert` will overwrite the existing value. In the future if this supported we should use that instead.\n * @param req - The PayloadRequest object\n * @param key - The key of the preferences to update\n * @param value - The new value to merge with the existing preferences\n */\nexport const upsertPreferences = async <T extends Record<string, unknown> | string>({\n key,\n req,\n value: incomingValue,\n}: {\n key: string\n req: PayloadRequest\n value: T\n}): Promise<T> => {\n const existingPrefs = await getPreferences<T>({\n key,\n req,\n })\n\n let newPrefs = existingPrefs?.value\n\n if (!existingPrefs?.id) {\n await req.payload.create({\n collection: 'payload-preferences',\n data: {\n key,\n user: {\n collection: req.user.collection,\n value: req.user.id,\n },\n value: incomingValue,\n },\n depth: 0,\n req,\n })\n } else {\n // Strings are valid JSON, i.e. `locale` saved as a string to the locale preferences\n const mergedPrefs =\n typeof incomingValue === 'object'\n ? {\n ...(typeof existingPrefs.value === 'object' ? existingPrefs?.value : {}), // Shallow merge existing prefs to acquire any missing keys from incoming value\n ...removeUndefined(incomingValue || {}),\n }\n : incomingValue\n\n if (!dequal(mergedPrefs, existingPrefs.value)) {\n newPrefs = await req.payload\n .update({\n id: existingPrefs.id,\n collection: 'payload-preferences',\n data: {\n key,\n user: {\n collection: req.user.collection,\n value: req.user.id,\n },\n value: mergedPrefs,\n },\n depth: 0,\n req,\n })\n ?.then((res) => res.value)\n }\n }\n\n return newPrefs\n}\n"],"mappings":"AAEA,SAASA,MAAM,QAAQ;AAEvB,SAASC,eAAe,QAAQ;AAEhC,MAAMC,cAAA,GAAiB,MAAAA,CAAU;EAC/BC,GAAG;EACHC;AAAG,CAIJ;EACC,MAAMC,MAAA,GAAU,MAAMD,GAAA,CAAIE,OAAO,CAC9BC,IAAI,CAAC;IACJC,UAAA,EAAY;IACZC,KAAA,EAAO;IACPC,KAAA,EAAO;IACPC,UAAA,EAAY;IACZC,KAAA,EAAO;MACLC,GAAA,EAAK,CACH;QACEV,GAAA,EAAK;UACHW,MAAA,EAAQX;QACV;MACF,GACA;QACE,mBAAmB;UACjBW,MAAA,EAAQV,GAAA,CAAIW,IAAI,CAACP;QACnB;MACF,GACA;QACE,cAAc;UACZM,MAAA,EAAQV,GAAA,CAAIW,IAAI,CAACC;QACnB;MACF;IAEJ;EACF,GACCC,IAAI,CAAEC,GAAA,IAAQA,GAAA,CAAIC,IAAI,GAAG,EAAE;EAE9B,OAAOd,MAAA;AACT;AAEA;;;;;;;;AAQA,OAAO,MAAMe,iBAAA,GAAoB,MAAAA,CAAmD;EAClFjB,GAAG;EACHC,GAAG;EACHiB,KAAA,EAAOC;AAAa,CAKrB;EACC,MAAMC,aAAA,GAAgB,MAAMrB,cAAA,CAAkB;IAC5CC,GAAA;IACAC;EACF;EAEA,IAAIoB,QAAA,GAAWD,aAAA,EAAeF,KAAA;EAE9B,IAAI,CAACE,aAAA,EAAeP,EAAA,EAAI;IACtB,MAAMZ,GAAA,CAAIE,OAAO,CAACmB,MAAM,CAAC;MACvBjB,UAAA,EAAY;MACZkB,IAAA,EAAM;QACJvB,GAAA;QACAY,IAAA,EAAM;UACJP,UAAA,EAAYJ,GAAA,CAAIW,IAAI,CAACP,UAAU;UAC/Ba,KAAA,EAAOjB,GAAA,CAAIW,IAAI,CAACC;QAClB;QACAK,KAAA,EAAOC;MACT;MACAb,KAAA,EAAO;MACPL;IACF;EACF,OAAO;IACL;IACA,MAAMuB,WAAA,GACJ,OAAOL,aAAA,KAAkB,WACrB;MACE,IAAI,OAAOC,aAAA,CAAcF,KAAK,KAAK,WAAWE,aAAA,EAAeF,KAAA,GAAQ,CAAC,CAAC;MACvE,GAAGpB,eAAA,CAAgBqB,aAAA,IAAiB,CAAC;IACvC,IACAA,aAAA;IAEN,IAAI,CAACtB,MAAA,CAAO2B,WAAA,EAAaJ,aAAA,CAAcF,KAAK,GAAG;MAC7CG,QAAA,GAAW,MAAMpB,GAAA,CAAIE,OAAO,CACzBsB,MAAM,CAAC;QACNZ,EAAA,EAAIO,aAAA,CAAcP,EAAE;QACpBR,UAAA,EAAY;QACZkB,IAAA,EAAM;UACJvB,GAAA;UACAY,IAAA,EAAM;YACJP,UAAA,EAAYJ,GAAA,CAAIW,IAAI,CAACP,UAAU;YAC/Ba,KAAA,EAAOjB,GAAA,CAAIW,IAAI,CAACC;UAClB;UACAK,KAAA,EAAOM;QACT;QACAlB,KAAA,EAAO;QACPL;MACF,IACEa,IAAA,CAAMC,GAAA,IAAQA,GAAA,CAAIG,KAAK;IAC7B;EACF;EAEA,OAAOG,QAAA;AACT","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.0",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"ts-essentials": "10.0.3",
|
|
133
133
|
"use-context-selector": "2.0.0",
|
|
134
134
|
"uuid": "10.0.0",
|
|
135
|
-
"@payloadcms/translations": "3.
|
|
135
|
+
"@payloadcms/translations": "3.16.0"
|
|
136
136
|
},
|
|
137
137
|
"devDependencies": {
|
|
138
138
|
"@babel/cli": "7.25.9",
|
|
@@ -150,13 +150,13 @@
|
|
|
150
150
|
"esbuild-sass-plugin": "3.3.1",
|
|
151
151
|
"eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124",
|
|
152
152
|
"@payloadcms/eslint-config": "3.9.0",
|
|
153
|
-
"payload": "3.
|
|
153
|
+
"payload": "3.16.0"
|
|
154
154
|
},
|
|
155
155
|
"peerDependencies": {
|
|
156
156
|
"next": "^15.0.0",
|
|
157
157
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
158
158
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
159
|
-
"payload": "3.
|
|
159
|
+
"payload": "3.16.0"
|
|
160
160
|
},
|
|
161
161
|
"engines": {
|
|
162
162
|
"node": "^18.20.2 || >=20.9.0"
|