@payloadcms/ui 3.32.0-internal.f2e77bd → 3.33.0-internal.d1efdd8

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.
Files changed (50) hide show
  1. package/dist/elements/RelationshipTable/index.d.ts.map +1 -1
  2. package/dist/elements/RelationshipTable/index.js +3 -1
  3. package/dist/elements/RelationshipTable/index.js.map +1 -1
  4. package/dist/elements/SortHeader/index.d.ts +8 -0
  5. package/dist/elements/SortHeader/index.d.ts.map +1 -0
  6. package/dist/elements/SortHeader/index.js +135 -0
  7. package/dist/elements/SortHeader/index.js.map +1 -0
  8. package/dist/elements/SortHeader/index.scss +52 -0
  9. package/dist/elements/SortRow/index.d.ts +4 -0
  10. package/dist/elements/SortRow/index.d.ts.map +1 -0
  11. package/dist/elements/SortRow/index.js +35 -0
  12. package/dist/elements/SortRow/index.js.map +1 -0
  13. package/dist/elements/SortRow/index.scss +22 -0
  14. package/dist/elements/Table/OrderableTable.d.ts +11 -0
  15. package/dist/elements/Table/OrderableTable.d.ts.map +1 -0
  16. package/dist/elements/Table/OrderableTable.js +162 -0
  17. package/dist/elements/Table/OrderableTable.js.map +1 -0
  18. package/dist/exports/client/index.js +11 -11
  19. package/dist/exports/client/index.js.map +3 -3
  20. package/dist/forms/Form/fieldReducer.d.ts.map +1 -1
  21. package/dist/forms/Form/fieldReducer.js +10 -40
  22. package/dist/forms/Form/fieldReducer.js.map +1 -1
  23. package/dist/forms/Form/mergeServerFormState.d.ts.map +1 -1
  24. package/dist/forms/Form/mergeServerFormState.js +4 -13
  25. package/dist/forms/Form/mergeServerFormState.js.map +1 -1
  26. package/dist/icons/Sort/index.d.ts +9 -0
  27. package/dist/icons/Sort/index.d.ts.map +1 -0
  28. package/dist/icons/Sort/index.js +38 -0
  29. package/dist/icons/Sort/index.js.map +1 -0
  30. package/dist/icons/Sort/index.scss +14 -0
  31. package/dist/providers/ListQuery/index.d.ts.map +1 -1
  32. package/dist/providers/ListQuery/index.js +3 -1
  33. package/dist/providers/ListQuery/index.js.map +1 -1
  34. package/dist/providers/ListQuery/types.d.ts +2 -0
  35. package/dist/providers/ListQuery/types.d.ts.map +1 -1
  36. package/dist/providers/ListQuery/types.js.map +1 -1
  37. package/dist/styles.css +1 -1
  38. package/dist/utilities/buildTableState.d.ts +0 -1
  39. package/dist/utilities/buildTableState.d.ts.map +1 -1
  40. package/dist/utilities/buildTableState.js +3 -1
  41. package/dist/utilities/buildTableState.js.map +1 -1
  42. package/dist/utilities/getClientConfig.d.ts.map +1 -1
  43. package/dist/utilities/getClientConfig.js +10 -8
  44. package/dist/utilities/getClientConfig.js.map +1 -1
  45. package/dist/utilities/renderTable.d.ts +3 -1
  46. package/dist/utilities/renderTable.d.ts.map +1 -1
  47. package/dist/utilities/renderTable.js +30 -1
  48. package/dist/utilities/renderTable.js.map +1 -1
  49. package/dist/views/List/index.scss +6 -0
  50. package/package.json +5 -5
@@ -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,CAsc7E"}
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,CAub7E"}
@@ -56,23 +56,9 @@ export function fieldReducer(state, action) {
56
56
  requiresRender: true,
57
57
  rows: withNewRow,
58
58
  value: siblingRows.length,
59
- /**
60
- * The `ignoreServerProps` obj is used to prevent the various properties from being overridden across form state requests.
61
- * This can happen when queueing a form state request with `requiresRender: true` while the another is already processing.
62
- * For example:
63
- * 1. One "add row" action will set `requiresRender: true` and dispatch a form state request
64
- * 2. Another "add row" action will set `requiresRender: true` and queue a form state request
65
- * 3. The first request will return with `requiresRender: false`
66
- * 4. The second request will be dispatched with `requiresRender: false` but should be `true`
67
- * To fix this, only merge the `requiresRender` property if the previous state has not set it to `true`.
68
- * See the `mergeServerFormState` function for implementation details.
69
- */
70
59
  ...(state[path]?.requiresRender === true ? {
71
- ignoreServerProps: {
72
- ...(state[path]?.ignoreServerProps || {}),
73
- requiresRender: true
74
- }
75
- } : state[path]?.ignoreServerProps || {})
60
+ serverPropsToIgnore: [...(state[path]?.serverPropsToIgnore || []), 'requiresRender']
61
+ } : state[path]?.serverPropsToIgnore || [])
76
62
  }
77
63
  };
78
64
  return newState;
@@ -178,13 +164,9 @@ export function fieldReducer(state, action) {
178
164
  requiresRender: true,
179
165
  rows: rowsMetadata,
180
166
  value: rows.length,
181
- // See note above about `ignoreServerProps`
182
167
  ...(state[path]?.requiresRender === true ? {
183
- ignoreServerProps: {
184
- ...(state[path]?.ignoreServerProps || {}),
185
- requiresRender: true
186
- }
187
- } : state[path]?.ignoreServerProps || {})
168
+ serverPropsToIgnore: [...(state[path]?.serverPropsToIgnore || []), 'requiresRender']
169
+ } : state[path]?.serverPropsToIgnore || [])
188
170
  }
189
171
  };
190
172
  return newState;
@@ -218,13 +200,9 @@ export function fieldReducer(state, action) {
218
200
  ...state[path],
219
201
  requiresRender: true,
220
202
  rows: rowsWithinField,
221
- // See note above about `ignoreServerProps`
222
203
  ...(state[path]?.requiresRender === true ? {
223
- ignoreServerProps: {
224
- ...(state[path]?.ignoreServerProps || {}),
225
- requiresRender: true
226
- }
227
- } : state[path]?.ignoreServerProps || {})
204
+ serverPropsToIgnore: [...(state[path]?.serverPropsToIgnore || []), 'requiresRender']
205
+ } : state[path]?.serverPropsToIgnore || [])
228
206
  }
229
207
  };
230
208
  // Do the same for custom components, i.e. `array.customComponents.RowLabels[0]` -> `array.customComponents.RowLabels[1]`
@@ -276,13 +254,9 @@ export function fieldReducer(state, action) {
276
254
  requiresRender: true,
277
255
  rows: rowsMetadata,
278
256
  value: rows.length,
279
- // See note above about `ignoreServerProps`
280
257
  ...(state[path]?.requiresRender === true ? {
281
- ignoreServerProps: {
282
- ...(state[path]?.ignoreServerProps || {}),
283
- requiresRender: true
284
- }
285
- } : state[path]?.ignoreServerProps || {})
258
+ serverPropsToIgnore: [...(state[path]?.serverPropsToIgnore || []), 'requiresRender']
259
+ } : state[path]?.serverPropsToIgnore || [])
286
260
  },
287
261
  ...flattenRows(path, rows)
288
262
  };
@@ -324,13 +298,9 @@ export function fieldReducer(state, action) {
324
298
  disableFormData: true,
325
299
  rows: rowsMetadata,
326
300
  value: siblingRows.length,
327
- // See note above about `ignoreServerProps`
328
301
  ...(state[path]?.requiresRender === true ? {
329
- ignoreServerProps: {
330
- ...(state[path]?.ignoreServerProps || {}),
331
- requiresRender: true
332
- }
333
- } : state[path]?.ignoreServerProps || {})
302
+ serverPropsToIgnore: [...(state[path]?.serverPropsToIgnore || []), 'requiresRender']
303
+ } : state[path]?.serverPropsToIgnore || [])
334
304
  }
335
305
  };
336
306
  return newState;
@@ -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","isLoading","splice","initialValue","valid","remainingFields","siblingRows","newState","passesCondition","requiresRender","disableFormData","ignoreServerProps","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","topLevelRows","copyOfMovingRow","rowsWithinField","copyOfMovingRow2","customComponents","RowLabels","copyOfMovingLabel","rowIndexArg","Math","max","min","optimize","newField","oldField","sanitize","field","values","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 isLoading: true,\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\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 * The `ignoreServerProps` obj is used to prevent the various properties from being overridden across form state requests.\n * This can happen when queueing a form state request with `requiresRender: true` while the another is already processing.\n * For example:\n * 1. One \"add row\" action will set `requiresRender: true` and dispatch a form state request\n * 2. Another \"add row\" action will set `requiresRender: true` and queue a form state request\n * 3. The first request will return with `requiresRender: false`\n * 4. The second request will be dispatched with `requiresRender: false` but should be `true`\n * To fix this, only merge the `requiresRender` property if the previous state has not set it to `true`.\n * See the `mergeServerFormState` function for implementation details.\n */\n ...(state[path]?.requiresRender === true\n ? {\n ignoreServerProps: {\n ...(state[path]?.ignoreServerProps || {}),\n requiresRender: true,\n },\n }\n : state[path]?.ignoreServerProps || ({} as any)),\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 // See note above about `ignoreServerProps`\n ...(state[path]?.requiresRender === true\n ? {\n ignoreServerProps: {\n ...(state[path]?.ignoreServerProps || {}),\n requiresRender: true,\n },\n }\n : state[path]?.ignoreServerProps || ({} as any)),\n },\n }\n\n return newState\n }\n\n case 'MOVE_ROW': {\n const { moveFromIndex, moveToIndex, path } = action\n\n // Handle moving rows on the top-level, i.e. `array.0.text` -> `array.1.text`\n const { remainingFields, rows: topLevelRows } = separateRows(path, state)\n const copyOfMovingRow = topLevelRows[moveFromIndex]\n topLevelRows.splice(moveFromIndex, 1)\n topLevelRows.splice(moveToIndex, 0, copyOfMovingRow)\n\n // modify array/block internal row state (i.e. collapsed, blockType)\n const rowsWithinField = [...(state[path]?.rows || [])]\n const copyOfMovingRow2 = { ...rowsWithinField[moveFromIndex] }\n rowsWithinField.splice(moveFromIndex, 1)\n rowsWithinField.splice(moveToIndex, 0, copyOfMovingRow2)\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, topLevelRows),\n [path]: {\n ...state[path],\n requiresRender: true,\n rows: rowsWithinField,\n // See note above about `ignoreServerProps`\n ...(state[path]?.requiresRender === true\n ? {\n ignoreServerProps: {\n ...(state[path]?.ignoreServerProps || {}),\n requiresRender: true,\n },\n }\n : state[path]?.ignoreServerProps || ({} as any)),\n },\n }\n\n // Do the same for custom components, i.e. `array.customComponents.RowLabels[0]` -> `array.customComponents.RowLabels[1]`\n // Do this _after_ initializing `newState` to avoid adding the `customComponents` key to the state if it doesn't exist\n if (newState[path]?.customComponents?.RowLabels) {\n const customComponents = {\n ...newState[path].customComponents,\n RowLabels: [...newState[path].customComponents.RowLabels],\n }\n\n // Ensure the array grows if necessary\n if (moveToIndex >= customComponents.RowLabels.length) {\n customComponents.RowLabels.length = moveToIndex + 1\n }\n\n const copyOfMovingLabel = customComponents.RowLabels[moveFromIndex]\n\n customComponents.RowLabels.splice(moveFromIndex, 1)\n\n customComponents.RowLabels.splice(moveToIndex, 0, copyOfMovingLabel)\n\n newState[path].customComponents = customComponents\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 // See note above about `ignoreServerProps`\n ...(state[path]?.requiresRender === true\n ? {\n ignoreServerProps: {\n ...(state[path]?.ignoreServerProps || {}),\n requiresRender: true,\n },\n }\n : state[path]?.ignoreServerProps || ({} as any)),\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 // See note above about `ignoreServerProps`\n ...(state[path]?.requiresRender === true\n ? {\n ignoreServerProps: {\n ...(state[path]?.ignoreServerProps || {}),\n requiresRender: true,\n },\n }\n : state[path]?.ignoreServerProps || ({} as any)),\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: FormState = {}\n\n for (const [path, newField] of Object.entries(action.state)) {\n const oldField = state[path]\n\n if (newField.valid !== false) {\n newField.valid = true\n }\n if (newField.passesCondition !== false) {\n newField.passesCondition = true\n }\n\n if (!dequal(oldField, newField)) {\n newState[path] = newField\n } else if (oldField) {\n newState[path] = oldField\n }\n }\n\n return newState\n }\n\n // TODO: Remove this in 4.0 - this is a temporary fix to prevent a breaking change\n if (action.sanitize) {\n for (const field of Object.values(action.state)) {\n if (field.valid !== false) {\n field.valid = true\n }\n if (field.passesCondition !== false) {\n field.passesCondition = true\n }\n }\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,G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,EAAQ0C,MAAM,CAC5C,CAACqC,KAAA,EAAO,CAACvB,GAAA,EAAK5C,KAAA,CAAM;UAClB,IACE,CACE,mBACA,gBACA,gBACA,QACA,SACA,YACA,QACD,CAACwC,QAAQ,CAACI,GAAA,GACX;YACA,OAAO;cACL,GAAGuB,KAAK;cACR,CAACvB,GAAA,GAAM5C;YACT;UACF;UAEA,OAAOmE,KAAA;QACT,GACAhF,KAAA,GAAQC,MAAA,CAAOG,IAAI,CAAC,IAAK,CAAC;QAG5B,MAAMmB,QAAA,GAAW;UACf,GAAGvB,KAAK;UACR,CAACC,MAAA,CAAOG,IAAI,GAAGyE;QACjB;QAEA,OAAOtD,QAAA;MACT;IAEA,KAAK;MAAe;QAClB,MAAMA,QAAA,GAAW;UAAE,GAAGvB;QAAM;QAE5ByC,MAAA,CAAOC,OAAO,CAACzC,MAAA,CAAOkF,SAAS,EAAErD,OAAO,CAAC,CAAC,CAAC1B,IAAA,EAAM4E,KAAA,CAAM;UACrDzD,QAAQ,CAACnB,IAAA,CAAK,GAAG4E,KAAA;QACnB;QAEA,OAAOzD,QAAA;MACT;IAEA;MAAS;QACP,OAAOvB,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","isLoading","splice","initialValue","valid","remainingFields","siblingRows","newState","passesCondition","requiresRender","disableFormData","serverPropsToIgnore","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","topLevelRows","copyOfMovingRow","rowsWithinField","copyOfMovingRow2","customComponents","RowLabels","copyOfMovingLabel","rowIndexArg","Math","max","min","optimize","newField","oldField","sanitize","field","values","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 isLoading: true,\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\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 ...(state[path]?.requiresRender === true\n ? {\n serverPropsToIgnore: [\n ...(state[path]?.serverPropsToIgnore || []),\n 'requiresRender',\n ],\n }\n : state[path]?.serverPropsToIgnore || []),\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 ...(state[path]?.requiresRender === true\n ? {\n serverPropsToIgnore: [\n ...(state[path]?.serverPropsToIgnore || []),\n 'requiresRender',\n ],\n }\n : state[path]?.serverPropsToIgnore || ([] as any)),\n },\n }\n\n return newState\n }\n\n case 'MOVE_ROW': {\n const { moveFromIndex, moveToIndex, path } = action\n\n // Handle moving rows on the top-level, i.e. `array.0.text` -> `array.1.text`\n const { remainingFields, rows: topLevelRows } = separateRows(path, state)\n const copyOfMovingRow = topLevelRows[moveFromIndex]\n topLevelRows.splice(moveFromIndex, 1)\n topLevelRows.splice(moveToIndex, 0, copyOfMovingRow)\n\n // modify array/block internal row state (i.e. collapsed, blockType)\n const rowsWithinField = [...(state[path]?.rows || [])]\n const copyOfMovingRow2 = { ...rowsWithinField[moveFromIndex] }\n rowsWithinField.splice(moveFromIndex, 1)\n rowsWithinField.splice(moveToIndex, 0, copyOfMovingRow2)\n\n const newState = {\n ...remainingFields,\n ...flattenRows(path, topLevelRows),\n [path]: {\n ...state[path],\n requiresRender: true,\n rows: rowsWithinField,\n ...(state[path]?.requiresRender === true\n ? {\n serverPropsToIgnore: [\n ...(state[path]?.serverPropsToIgnore || []),\n 'requiresRender',\n ],\n }\n : state[path]?.serverPropsToIgnore || ([] as any)),\n },\n }\n\n // Do the same for custom components, i.e. `array.customComponents.RowLabels[0]` -> `array.customComponents.RowLabels[1]`\n // Do this _after_ initializing `newState` to avoid adding the `customComponents` key to the state if it doesn't exist\n if (newState[path]?.customComponents?.RowLabels) {\n const customComponents = {\n ...newState[path].customComponents,\n RowLabels: [...newState[path].customComponents.RowLabels],\n }\n\n // Ensure the array grows if necessary\n if (moveToIndex >= customComponents.RowLabels.length) {\n customComponents.RowLabels.length = moveToIndex + 1\n }\n\n const copyOfMovingLabel = customComponents.RowLabels[moveFromIndex]\n\n customComponents.RowLabels.splice(moveFromIndex, 1)\n\n customComponents.RowLabels.splice(moveToIndex, 0, copyOfMovingLabel)\n\n newState[path].customComponents = customComponents\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 ...(state[path]?.requiresRender === true\n ? {\n serverPropsToIgnore: [\n ...(state[path]?.serverPropsToIgnore || []),\n 'requiresRender',\n ],\n }\n : state[path]?.serverPropsToIgnore || []),\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 ...(state[path]?.requiresRender === true\n ? {\n serverPropsToIgnore: [\n ...(state[path]?.serverPropsToIgnore || []),\n 'requiresRender',\n ],\n }\n : state[path]?.serverPropsToIgnore || []),\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: FormState = {}\n\n for (const [path, newField] of Object.entries(action.state)) {\n const oldField = state[path]\n\n if (newField.valid !== false) {\n newField.valid = true\n }\n if (newField.passesCondition !== false) {\n newField.passesCondition = true\n }\n\n if (!dequal(oldField, newField)) {\n newState[path] = newField\n } else if (oldField) {\n newState[path] = oldField\n }\n }\n\n return newState\n }\n\n // TODO: Remove this in 4.0 - this is a temporary fix to prevent a breaking change\n if (action.sanitize) {\n for (const field of Object.values(action.state)) {\n if (field.valid !== false) {\n field.valid = true\n }\n if (field.passesCondition !== false) {\n field.passesCondition = true\n }\n }\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,GAAWiB,WAAW;UACtEX,SAAA,EAAWA,SAAA,IAAaY,SAAA;UACxBC,SAAA,EAAW;UACXC,SAAA,EAAW;QACb;QAEAP,UAAA,CAAWQ,MAAM,CAACb,QAAA,EAAU,GAAGM,MAAA;QAE/B,IAAIR,SAAA,EAAW;UACbI,aAAA,CAAcJ,SAAS,GAAG;YACxBgB,YAAA,EAAchB,SAAA;YACdiB,K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MACT;EACF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"mergeServerFormState.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/mergeServerFormState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAA;AAIxC,KAAK,IAAI,GAAG;IACV,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,aAAa,EAAE,SAAS,CAAA;IACxB,aAAa,EAAE,SAAS,CAAA;CACzB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,oDAI9B,IAAI,KAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAuHhD,CAAA"}
1
+ {"version":3,"file":"mergeServerFormState.d.ts","sourceRoot":"","sources":["../../../src/forms/Form/mergeServerFormState.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAA;AAIxC,KAAK,IAAI,GAAG;IACV,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,aAAa,EAAE,SAAS,CAAA;IACxB,aAAa,EAAE,SAAS,CAAA;CACzB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,oDAI9B,IAAI,KAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAgHhD,CAAA"}
@@ -54,21 +54,12 @@ export const mergeServerFormState = ({
54
54
  if (!dequal(incomingState[path]?.[propFromServer], newFieldState[propFromServer])) {
55
55
  changed = true;
56
56
  fieldChanged = true;
57
- // The `ignoreServerProps` obj is used to prevent the various properties from being overridden across form state requests.
58
- // This can happen when queueing a form state request with `requiresRender: true` while the another is already processing.
59
- // For example:
60
- // 1. One "add row" action will set `requiresRender: true` and dispatch a form state request
61
- // 2. Another "add row" action will set `requiresRender: true` and queue a form state request
62
- // 3. The first request will return with `requiresRender: false`
63
- // 4. The second request will be dispatched with `requiresRender: false` but should be `true`
64
- // To fix this, only merge the `requiresRender` property if the previous state has not set it to `true`.
65
- // See the `fieldReducer` function for where this gets set.
66
- if (newFieldState?.ignoreServerProps?.[propFromServer]) {
57
+ if (newFieldState?.serverPropsToIgnore?.includes(propFromServer)) {
67
58
  // Remove the ignored prop for the next request
68
- delete newFieldState.ignoreServerProps[propFromServer];
59
+ newFieldState.serverPropsToIgnore = newFieldState.serverPropsToIgnore.filter(prop => prop !== propFromServer);
69
60
  // if no keys left, remove the entire object
70
- if (Object.keys(newFieldState.ignoreServerProps).length === 0) {
71
- delete newFieldState.ignoreServerProps;
61
+ if (!newFieldState.serverPropsToIgnore.length) {
62
+ delete newFieldState.serverPropsToIgnore;
72
63
  }
73
64
  return;
74
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mergeServerFormState.js","names":["dequal","mergeErrorPaths","mergeServerFormState","acceptValues","existingState","incomingState","changed","newState","serverPropsToAccept","push","path","newFieldState","Object","entries","fieldChanged","errorPathsResult","errorPaths","result","filterOptions","forEach","propFromServer","ignoreServerProps","keys","length","valid","passesCondition","field"],"sources":["../../../src/forms/Form/mergeServerFormState.ts"],"sourcesContent":["'use client'\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\nimport { type FormState } from 'payload'\n\nimport { mergeErrorPaths } from './mergeErrorPaths.js'\n\ntype Args = {\n acceptValues?: boolean\n existingState: FormState\n incomingState: FormState\n}\n\n/**\n * Merges certain properties from the server state into the client state. These do not include values,\n * as we do not want to update them on the client like that, which would cause flickering.\n *\n * We want to use this to update the error state, and other properties that are not user input, as the error state\n * is the thing we want to keep in sync with the server (where it's calculated) on the client.\n */\nexport const mergeServerFormState = ({\n acceptValues,\n existingState,\n incomingState,\n}: Args): { changed: boolean; newState: FormState } => {\n let changed = false\n\n const newState = {}\n\n if (existingState) {\n const serverPropsToAccept = [\n 'passesCondition',\n 'valid',\n 'errorMessage',\n 'errorPaths',\n 'rows',\n 'customComponents',\n 'requiresRender',\n ]\n\n if (acceptValues) {\n serverPropsToAccept.push('value')\n serverPropsToAccept.push('initialValue')\n }\n\n for (const [path, newFieldState] of Object.entries(existingState)) {\n if (!incomingState[path]) {\n continue\n }\n\n let fieldChanged = false\n\n /**\n * Handle error paths\n */\n const errorPathsResult = mergeErrorPaths(\n newFieldState.errorPaths,\n incomingState[path].errorPaths as unknown as string[],\n )\n\n if (errorPathsResult.result) {\n if (errorPathsResult.changed) {\n changed = errorPathsResult.changed\n }\n newFieldState.errorPaths = errorPathsResult.result\n }\n\n /**\n * Handle filterOptions\n */\n if (incomingState[path]?.filterOptions || newFieldState.filterOptions) {\n if (!dequal(incomingState[path]?.filterOptions, newFieldState.filterOptions)) {\n changed = true\n fieldChanged = true\n newFieldState.filterOptions = incomingState[path].filterOptions\n }\n }\n\n /**\n * Handle adding all the remaining props that should be updated in the local form state from the server form state\n */\n serverPropsToAccept.forEach((propFromServer) => {\n if (!dequal(incomingState[path]?.[propFromServer], newFieldState[propFromServer])) {\n changed = true\n fieldChanged = true\n\n // The `ignoreServerProps` obj is used to prevent the various properties from being overridden across form state requests.\n // This can happen when queueing a form state request with `requiresRender: true` while the another is already processing.\n // For example:\n // 1. One \"add row\" action will set `requiresRender: true` and dispatch a form state request\n // 2. Another \"add row\" action will set `requiresRender: true` and queue a form state request\n // 3. The first request will return with `requiresRender: false`\n // 4. The second request will be dispatched with `requiresRender: false` but should be `true`\n // To fix this, only merge the `requiresRender` property if the previous state has not set it to `true`.\n // See the `fieldReducer` function for where this gets set.\n if (newFieldState?.ignoreServerProps?.[propFromServer]) {\n // Remove the ignored prop for the next request\n delete newFieldState.ignoreServerProps[propFromServer]\n\n // if no keys left, remove the entire object\n if (Object.keys(newFieldState.ignoreServerProps).length === 0) {\n delete newFieldState.ignoreServerProps\n }\n\n return\n }\n\n if (!(propFromServer in incomingState[path])) {\n // Regarding excluding the customComponents prop from being deleted: the incoming state might not have been rendered, as rendering components for every form onchange is expensive.\n // Thus, we simply re-use the initial render state\n if (propFromServer !== 'customComponents') {\n delete newFieldState[propFromServer]\n }\n } else {\n newFieldState[propFromServer] = incomingState[path][propFromServer]\n }\n }\n })\n\n if (newFieldState.valid !== false) {\n newFieldState.valid = true\n }\n\n if (newFieldState.passesCondition !== false) {\n newFieldState.passesCondition = true\n }\n\n // Conditions don't work if we don't memcopy the new state, as the object references would otherwise be the same\n newState[path] = fieldChanged ? { ...newFieldState } : newFieldState\n }\n\n // Now loop over values that are part of incoming state but not part of existing state, and add them to the new state.\n // This can happen if a new array row was added. In our local state, we simply add out stubbed `array` and `array.[index].id` entries to the local form state.\n // However, all other array sub-fields are not added to the local state - those will be added by the server and may be incoming here.\n for (const [path, field] of Object.entries(incomingState)) {\n if (!existingState[path]) {\n changed = true\n newState[path] = field\n }\n }\n }\n\n return { changed, newState }\n}\n"],"mappings":"AAAA;;AACA,SAASA,MAAM,QAAQ,cAAa,CAAC;AAGrC,SAASC,eAAe,QAAQ;AAQhC;;;;;;;AAOA,OAAO,MAAMC,oBAAA,GAAuBA,CAAC;EACnCC,YAAY;EACZC,aAAa;EACbC;AAAa,CACR;EACL,IAAIC,OAAA,GAAU;EAEd,MAAMC,QAAA,GAAW,CAAC;EAElB,IAAIH,aAAA,EAAe;IACjB,MAAMI,mBAAA,GAAsB,CAC1B,mBACA,SACA,gBACA,cACA,QACA,oBACA,iBACD;IAED,IAAIL,YAAA,EAAc;MAChBK,mBAAA,CAAoBC,IAAI,CAAC;MACzBD,mBAAA,CAAoBC,IAAI,CAAC;IAC3B;IAEA,KAAK,MAAM,CAACC,IAAA,EAAMC,aAAA,CAAc,IAAIC,MAAA,CAAOC,OAAO,CAACT,aAAA,GAAgB;MACjE,IAAI,CAACC,aAAa,CAACK,IAAA,CAAK,EAAE;QACxB;MACF;MAEA,IAAII,YAAA,GAAe;MAEnB;;;MAGA,MAAMC,gBAAA,GAAmBd,eAAA,CACvBU,aAAA,CAAcK,UAAU,EACxBX,aAAa,CAACK,IAAA,CAAK,CAACM,UAAU;MAGhC,IAAID,gBAAA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CAACU,cAAA,CAAe;UACrE;QACF;MACF;MAEA,IAAIT,aAAA,CAAca,KAAK,KAAK,OAAO;QACjCb,aAAA,CAAca,KAAK,GAAG;MACxB;MAEA,IAAIb,aAAA,CAAcc,eAAe,KAAK,OAAO;QAC3Cd,aAAA,CAAcc,eAAe,GAAG;MAClC;MAEA;MACAlB,QAAQ,CAACG,IAAA,CAAK,GAAGI,YAAA,GAAe;QAAE,GAAGH;MAAc,IAAIA,aAAA;IACzD;IAEA;IACA;IACA;IACA,KAAK,MAAM,CAACD,IAAA,EAAMgB,KAAA,CAAM,IAAId,MAAA,CAAOC,OAAO,CAACR,aAAA,GAAgB;MACzD,IAAI,CAACD,aAAa,CAACM,IAAA,CAAK,EAAE;QACxBJ,OAAA,GAAU;QACVC,QAAQ,CAACG,IAAA,CAAK,GAAGgB,KAAA;MACnB;IACF;EACF;EAEA,OAAO;IAAEpB,OAAA;IAASC;EAAS;AAC7B","ignoreList":[]}
1
+ {"version":3,"file":"mergeServerFormState.js","names":["dequal","mergeErrorPaths","mergeServerFormState","acceptValues","existingState","incomingState","changed","newState","serverPropsToAccept","push","path","newFieldState","Object","entries","fieldChanged","errorPathsResult","errorPaths","result","filterOptions","forEach","propFromServer","serverPropsToIgnore","includes","filter","prop","length","valid","passesCondition","field"],"sources":["../../../src/forms/Form/mergeServerFormState.ts"],"sourcesContent":["'use client'\nimport type { FieldState } from 'payload'\n\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\nimport { type FormState } from 'payload'\n\nimport { mergeErrorPaths } from './mergeErrorPaths.js'\n\ntype Args = {\n acceptValues?: boolean\n existingState: FormState\n incomingState: FormState\n}\n\n/**\n * Merges certain properties from the server state into the client state. These do not include values,\n * as we do not want to update them on the client like that, which would cause flickering.\n *\n * We want to use this to update the error state, and other properties that are not user input, as the error state\n * is the thing we want to keep in sync with the server (where it's calculated) on the client.\n */\nexport const mergeServerFormState = ({\n acceptValues,\n existingState,\n incomingState,\n}: Args): { changed: boolean; newState: FormState } => {\n let changed = false\n\n const newState = {}\n\n if (existingState) {\n const serverPropsToAccept: Array<keyof FieldState> = [\n 'passesCondition',\n 'valid',\n 'errorMessage',\n 'errorPaths',\n 'rows',\n 'customComponents',\n 'requiresRender',\n ]\n\n if (acceptValues) {\n serverPropsToAccept.push('value')\n serverPropsToAccept.push('initialValue')\n }\n\n for (const [path, newFieldState] of Object.entries(existingState)) {\n if (!incomingState[path]) {\n continue\n }\n\n let fieldChanged = false\n\n /**\n * Handle error paths\n */\n const errorPathsResult = mergeErrorPaths(\n newFieldState.errorPaths,\n incomingState[path].errorPaths as unknown as string[],\n )\n\n if (errorPathsResult.result) {\n if (errorPathsResult.changed) {\n changed = errorPathsResult.changed\n }\n newFieldState.errorPaths = errorPathsResult.result\n }\n\n /**\n * Handle filterOptions\n */\n if (incomingState[path]?.filterOptions || newFieldState.filterOptions) {\n if (!dequal(incomingState[path]?.filterOptions, newFieldState.filterOptions)) {\n changed = true\n fieldChanged = true\n newFieldState.filterOptions = incomingState[path].filterOptions\n }\n }\n\n /**\n * Handle adding all the remaining props that should be updated in the local form state from the server form state\n */\n serverPropsToAccept.forEach((propFromServer) => {\n if (!dequal(incomingState[path]?.[propFromServer], newFieldState[propFromServer])) {\n changed = true\n fieldChanged = true\n\n if (newFieldState?.serverPropsToIgnore?.includes(propFromServer)) {\n // Remove the ignored prop for the next request\n newFieldState.serverPropsToIgnore = newFieldState.serverPropsToIgnore.filter(\n (prop) => prop !== propFromServer,\n )\n\n // if no keys left, remove the entire object\n if (!newFieldState.serverPropsToIgnore.length) {\n delete newFieldState.serverPropsToIgnore\n }\n\n return\n }\n\n if (!(propFromServer in incomingState[path])) {\n // Regarding excluding the customComponents prop from being deleted: the incoming state might not have been rendered, as rendering components for every form onchange is expensive.\n // Thus, we simply re-use the initial render state\n if (propFromServer !== 'customComponents') {\n delete newFieldState[propFromServer]\n }\n } else {\n newFieldState[propFromServer as any] = incomingState[path][propFromServer]\n }\n }\n })\n\n if (newFieldState.valid !== false) {\n newFieldState.valid = true\n }\n\n if (newFieldState.passesCondition !== false) {\n newFieldState.passesCondition = true\n }\n\n // Conditions don't work if we don't memcopy the new state, as the object references would otherwise be the same\n newState[path] = fieldChanged ? { ...newFieldState } : newFieldState\n }\n\n // Now loop over values that are part of incoming state but not part of existing state, and add them to the new state.\n // This can happen if a new array row was added. In our local state, we simply add out stubbed `array` and `array.[index].id` entries to the local form state.\n // However, all other array sub-fields are not added to the local state - those will be added by the server and may be incoming here.\n for (const [path, field] of Object.entries(incomingState)) {\n if (!existingState[path]) {\n changed = true\n newState[path] = field\n }\n }\n }\n\n return { changed, newState }\n}\n"],"mappings":"AAAA;;AAGA,SAASA,MAAM,QAAQ,cAAa,CAAC;AAGrC,SAASC,eAAe,QAAQ;AAQhC;;;;;;;AAOA,OAAO,MAAMC,oBAAA,GAAuBA,CAAC;EACnCC,YAAY;EACZC,aAAa;EACbC;AAAa,CACR;EACL,IAAIC,OAAA,GAAU;EAEd,MAAMC,QAAA,GAAW,CAAC;EAElB,IAAIH,aAAA,EAAe;IACjB,MAAMI,mBAAA,GAA+C,CACnD,mBACA,SACA,gBACA,cACA,QACA,oBACA,iBACD;IAED,IAAIL,YAAA,EAAc;MAChBK,mBAAA,CAAoBC,IAAI,CAAC;MACzBD,mBAAA,CAAoBC,IAAI,CAAC;IAC3B;IAEA,KAAK,MAAM,CAACC,IAAA,EAAMC,aAAA,CAAc,IAAIC,MAAA,CAAOC,OAAO,CAACT,aAAA,GAAgB;MACjE,IAAI,CAACC,aAAa,CAACK,IAAA,CAAK,EAAE;QACxB;MACF;MAEA,IAAII,YAAA,GAAe;MAEnB;;;MAGA,MAAMC,gBAAA,GAAmBd,eAAA,CACvBU,aAAA,CAAcK,UAAU,EACxBX,aAAa,CAACK,IAAA,CAAK,CAACM,UAAU;MAGhC,IAAID,gBAAA,CAAiBE,MAAM,EAAE;QAC3B,IAAIF,gBAAA,CAAiBT,OAAO,EAAE;UAC5BA,OAAA,GAAUS,gBAAA,CA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,GAAG;MACxB;MAEA,IAAIf,aAAA,CAAcgB,eAAe,KAAK,OAAO;QAC3ChB,aAAA,CAAcgB,eAAe,GAAG;MAClC;MAEA;MACApB,QAAQ,CAACG,IAAA,CAAK,GAAGI,YAAA,GAAe;QAAE,GAAGH;MAAc,IAAIA,aAAA;IACzD;IAEA;IACA;IACA;IACA,KAAK,MAAM,CAACD,IAAA,EAAMkB,KAAA,CAAM,IAAIhB,MAAA,CAAOC,OAAO,CAACR,aAAA,GAAgB;MACzD,IAAI,CAACD,aAAa,CAACM,IAAA,CAAK,EAAE;QACxBJ,OAAA,GAAU;QACVC,QAAQ,CAACG,IAAA,CAAK,GAAGkB,KAAA;MACnB;IACF;EACF;EAEA,OAAO;IAAEtB,OAAA;IAASC;EAAS;AAC7B","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import './index.scss';
3
+ export declare const SortDownIcon: React.FC<{
4
+ className?: string;
5
+ }>;
6
+ export declare const SortUpIcon: React.FC<{
7
+ className?: string;
8
+ }>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/icons/Sort/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAiBzD,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAiBvD,CAAA"}
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import './index.scss';
4
+ export const SortDownIcon = ({
5
+ className
6
+ }) => /*#__PURE__*/_jsx("svg", {
7
+ className: "icon icon--sort",
8
+ fill: "none",
9
+ height: "20",
10
+ viewBox: "0 0 20 20",
11
+ width: "20",
12
+ xmlns: "http://www.w3.org/2000/svg",
13
+ children: /*#__PURE__*/_jsx("path", {
14
+ className: "fill",
15
+ d: "M2.5 13.3333L5.83333 16.6667M5.83333 16.6667L9.16667 13.3333M5.83333 16.6667V3.33333M9.16667 7.08333H17.5M9.16667 10.4167H15M11.6667 13.75H12.5",
16
+ stroke: "#2F2F2F",
17
+ strokeLinecap: "round",
18
+ strokeLinejoin: "round"
19
+ })
20
+ });
21
+ export const SortUpIcon = ({
22
+ className
23
+ }) => /*#__PURE__*/_jsx("svg", {
24
+ className: "icon icon--sort",
25
+ fill: "none",
26
+ height: "20",
27
+ viewBox: "0 0 20 20",
28
+ width: "20",
29
+ xmlns: "http://www.w3.org/2000/svg",
30
+ children: /*#__PURE__*/_jsx("path", {
31
+ className: "fill",
32
+ d: "M2.5 6.66668L5.83333 3.33334M5.83333 3.33334L9.16667 6.66668M5.83333 3.33334V16.6667M11.6667 7.08354H17.5M9.16667 10.4169H15M9.16667 13.7502H12.5",
33
+ stroke: "#2F2F2F",
34
+ strokeLinecap: "round",
35
+ strokeLinejoin: "round"
36
+ })
37
+ });
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["React","SortDownIcon","className","_jsx","fill","height","viewBox","width","xmlns","d","stroke","strokeLinecap","strokeLinejoin","SortUpIcon"],"sources":["../../../src/icons/Sort/index.tsx"],"sourcesContent":["import React from 'react'\n\nimport './index.scss'\n\nexport const SortDownIcon: React.FC<{ className?: string }> = ({ className }) => (\n <svg\n className=\"icon icon--sort\"\n fill=\"none\"\n height=\"20\"\n viewBox=\"0 0 20 20\"\n width=\"20\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n className=\"fill\"\n d=\"M2.5 13.3333L5.83333 16.6667M5.83333 16.6667L9.16667 13.3333M5.83333 16.6667V3.33333M9.16667 7.08333H17.5M9.16667 10.4167H15M11.6667 13.75H12.5\"\n stroke=\"#2F2F2F\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n)\n\nexport const SortUpIcon: React.FC<{ className?: string }> = ({ className }) => (\n <svg\n className=\"icon icon--sort\"\n fill=\"none\"\n height=\"20\"\n viewBox=\"0 0 20 20\"\n width=\"20\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n className=\"fill\"\n d=\"M2.5 6.66668L5.83333 3.33334M5.83333 3.33334L9.16667 6.66668M5.83333 3.33334V16.6667M11.6667 7.08354H17.5M9.16667 10.4169H15M9.16667 13.7502H12.5\"\n stroke=\"#2F2F2F\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n)\n"],"mappings":";AAAA,OAAOA,KAAA,MAAW;AAElB,OAAO;AAEP,OAAO,MAAMC,YAAA,GAAiDA,CAAC;EAAEC;AAAS,CAAE,kBAC1EC,IAAA,CAAC;EACCD,SAAA,EAAU;EACVE,IAAA,EAAK;EACLC,MAAA,EAAO;EACPC,OAAA,EAAQ;EACRC,KAAA,EAAM;EACNC,KAAA,EAAM;YAEN,aAAAL,IAAA,CAAC;IACCD,SAAA,EAAU;IACVO,CAAA,EAAE;IACFC,MAAA,EAAO;IACPC,aAAA,EAAc;IACdC,cAAA,EAAe;;;AAKrB,OAAO,MAAMC,UAAA,GAA+CA,CAAC;EAAEX;AAAS,CAAE,kBACxEC,IAAA,CAAC;EACCD,SAAA,EAAU;EACVE,IAAA,EAAK;EACLC,MAAA,EAAO;EACPC,OAAA,EAAQ;EACRC,KAAA,EAAM;EACNC,KAAA,EAAM;YAEN,aAAAL,IAAA,CAAC;IACCD,SAAA,EAAU;IACVO,CAAA,EAAE;IACFC,MAAA,EAAO;IACPC,aAAA,EAAc;IACdC,cAAA,EAAe","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ @import '../../scss/styles';
2
+
3
+ @layer payload-default {
4
+ .icon--sort {
5
+ height: $baseline;
6
+ width: $baseline;
7
+
8
+ .fill {
9
+ stroke: currentColor;
10
+ stroke-width: $style-stroke-width-s;
11
+ fill: var(--theme-elevation-800);
12
+ }
13
+ }
14
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/ListQuery/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA4D,MAAM,OAAO,CAAA;AAEhF,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,YAAY,CAAA;AAQnE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAyMtD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/ListQuery/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA4D,MAAM,OAAO,CAAA;AAEhF,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,YAAY,CAAA;AAQnE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA2MtD,CAAA"}
@@ -20,7 +20,8 @@ export const ListQueryProvider = ({
20
20
  defaultSort,
21
21
  listPreferences,
22
22
  modifySearchParams,
23
- onQueryChange: onQueryChangeFromProps
23
+ onQueryChange: onQueryChangeFromProps,
24
+ orderableFieldName
24
25
  }) => {
25
26
  'use no memo';
26
27
 
@@ -150,6 +151,7 @@ export const ListQueryProvider = ({
150
151
  handleSearchChange,
151
152
  handleSortChange,
152
153
  handleWhereChange,
154
+ orderableFieldName,
153
155
  query: currentQuery,
154
156
  refineListData,
155
157
  setModified,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useRouter","useSearchParams","isNumber","transformColumnsToSearchParams","qs","React","useCallback","useEffect","useMemo","useRef","useState","useListDrawerContext","useEffectEvent","useRouteTransition","parseSearchParams","ListQueryContext","ListQueryModifiedContext","useListQuery","ListQueryProvider","children","collectionSlug","columns","data","defaultLimit","defaultSort","listPreferences","modifySearchParams","onQueryChange","onQueryChangeFromProps","router","rawSearchParams","startRouteTransition","modified","setModified","searchParams","contextRef","current","currentQuery","setCurrentQuery","refineListData","incomingQuery","undefined","page","newQuery","limit","String","preset","search","sort","where","replace","stringify","JSON","addQueryPrefix","onChangeFn","handlePageChange","arg","handlePerPageChange","handleSearchChange","handleSortChange","handleWhereChange","syncQuery","shouldUpdateQueryString","window","history","replaceState","_jsx","value","query"],"sources":["../../../src/providers/ListQuery/index.tsx"],"sourcesContent":["'use client'\nimport { useRouter, useSearchParams } from 'next/navigation.js'\nimport { type ListQuery, type Where } from 'payload'\nimport { isNumber, transformColumnsToSearchParams } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { IListQueryContext, ListQueryProps } from './types.js'\n\nimport { useListDrawerContext } from '../../elements/ListDrawer/Provider.js'\nimport { useEffectEvent } from '../../hooks/useEffectEvent.js'\nimport { useRouteTransition } from '../../providers/RouteTransition/index.js'\nimport { parseSearchParams } from '../../utilities/parseSearchParams.js'\nimport { ListQueryContext, ListQueryModifiedContext } from './context.js'\n\nexport { useListQuery } from './context.js'\n\nexport const ListQueryProvider: React.FC<ListQueryProps> = ({\n children,\n collectionSlug,\n columns,\n data,\n defaultLimit,\n defaultSort,\n listPreferences,\n modifySearchParams,\n onQueryChange: onQueryChangeFromProps,\n}) => {\n 'use no memo'\n const router = useRouter()\n const rawSearchParams = useSearchParams()\n const { startRouteTransition } = useRouteTransition()\n const [modified, setModified] = useState(false)\n\n const searchParams = useMemo<ListQuery>(\n () => parseSearchParams(rawSearchParams),\n [rawSearchParams],\n )\n\n const contextRef = useRef({} as IListQueryContext)\n\n contextRef.current.modified = modified\n\n const { onQueryChange } = useListDrawerContext()\n\n const [currentQuery, setCurrentQuery] = useState<ListQuery>(() => {\n if (modifySearchParams) {\n return searchParams\n } else {\n return {}\n }\n })\n\n const refineListData = useCallback(\n // eslint-disable-next-line @typescript-eslint/require-await\n async (incomingQuery: ListQuery, modified?: boolean) => {\n if (modified !== undefined) {\n setModified(modified)\n } else {\n setModified(true)\n }\n\n let page = 'page' in incomingQuery ? incomingQuery.page : currentQuery?.page\n\n if ('where' in incomingQuery || 'search' in incomingQuery) {\n page = '1'\n }\n\n const newQuery: ListQuery = {\n columns: 'columns' in incomingQuery ? incomingQuery.columns : currentQuery.columns,\n limit:\n 'limit' in incomingQuery\n ? incomingQuery.limit\n : (currentQuery?.limit ?? String(defaultLimit)),\n page,\n preset: 'preset' in incomingQuery ? incomingQuery.preset : currentQuery?.preset,\n search: 'search' in incomingQuery ? incomingQuery.search : currentQuery?.search,\n sort:\n 'sort' in incomingQuery\n ? incomingQuery.sort\n : ((currentQuery?.sort as string) ?? defaultSort),\n where: 'where' in incomingQuery ? incomingQuery.where : currentQuery?.where,\n }\n\n if (modifySearchParams) {\n startRouteTransition(() =>\n router.replace(\n `${qs.stringify(\n { ...newQuery, columns: JSON.stringify(newQuery.columns) },\n { addQueryPrefix: true },\n )}`,\n ),\n )\n } else if (\n typeof onQueryChange === 'function' ||\n typeof onQueryChangeFromProps === 'function'\n ) {\n const onChangeFn = onQueryChange || onQueryChangeFromProps\n onChangeFn(newQuery)\n }\n\n setCurrentQuery(newQuery)\n },\n [\n currentQuery?.columns,\n currentQuery?.limit,\n currentQuery?.page,\n currentQuery?.search,\n currentQuery?.sort,\n currentQuery?.where,\n currentQuery?.preset,\n startRouteTransition,\n defaultLimit,\n defaultSort,\n modifySearchParams,\n onQueryChange,\n onQueryChangeFromProps,\n router,\n ],\n )\n\n const handlePageChange = useCallback(\n async (arg: number) => {\n await refineListData({ page: String(arg) })\n },\n [refineListData],\n )\n\n const handlePerPageChange = React.useCallback(\n async (arg: number) => {\n await refineListData({ limit: String(arg), page: '1' })\n },\n [refineListData],\n )\n\n const handleSearchChange = useCallback(\n async (arg: string) => {\n const search = arg === '' ? undefined : arg\n await refineListData({ search })\n },\n [refineListData],\n )\n\n const handleSortChange = useCallback(\n async (arg: string) => {\n await refineListData({ sort: arg })\n },\n [refineListData],\n )\n\n const handleWhereChange = useCallback(\n async (arg: Where) => {\n await refineListData({ where: arg })\n },\n [refineListData],\n )\n\n const syncQuery = useEffectEvent(() => {\n let shouldUpdateQueryString = false\n const newQuery = { ...(currentQuery || {}) }\n\n // Allow the URL to override the default limit\n if (isNumber(defaultLimit) && !('limit' in currentQuery)) {\n newQuery.limit = String(defaultLimit)\n shouldUpdateQueryString = true\n }\n\n // Allow the URL to override the default sort\n if (defaultSort && !('sort' in currentQuery)) {\n newQuery.sort = defaultSort\n shouldUpdateQueryString = true\n }\n\n // Only modify columns if they originated from preferences\n // We can assume they did if `listPreferences.columns` is defined\n if (columns && listPreferences?.columns && !('columns' in currentQuery)) {\n newQuery.columns = transformColumnsToSearchParams(columns)\n shouldUpdateQueryString = true\n }\n\n if (shouldUpdateQueryString) {\n setCurrentQuery(newQuery)\n // Do not use router.replace here to avoid re-rendering on initial load\n window.history.replaceState(\n null,\n '',\n `?${qs.stringify({ ...newQuery, columns: JSON.stringify(newQuery.columns) })}`,\n )\n }\n })\n\n // If `defaultLimit` or `defaultSort` are updated externally, update the query\n // I.e. when HMR runs, these properties may be different\n useEffect(() => {\n if (modifySearchParams) {\n syncQuery()\n }\n }, [defaultSort, defaultLimit, modifySearchParams, columns])\n\n return (\n <ListQueryContext\n value={{\n collectionSlug,\n data,\n handlePageChange,\n handlePerPageChange,\n handleSearchChange,\n handleSortChange,\n handleWhereChange,\n query: currentQuery,\n refineListData,\n setModified,\n ...contextRef.current,\n }}\n >\n <ListQueryModifiedContext value={modified}>{children}</ListQueryModifiedContext>\n </ListQueryContext>\n )\n}\n"],"mappings":"AAAA;;;AACA,SAASA,SAAS,EAAEC,eAAe,QAAQ;AAE3C,SAASC,QAAQ,EAAEC,8BAA8B,QAAQ;AACzD,YAAYC,EAAA,MAAQ;AACpB,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS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Wc,YAAW,GAAI;MACxDM,UAAA,CAASC,KAAK,GAAGC,MAAA,CAAOtB,YAAA;MACxBuC,uBAAA,GAA0B;IAC5B;IAEA;IACA,IAAItC,WAAA,IAAe,EAAE,UAAUa,YAAW,GAAI;MAC5CM,UAAA,CAASK,IAAI,GAAGxB,WAAA;MAChBsC,uBAAA,GAA0B;IAC5B;IAEA;IACA;IACA,IAAIzC,OAAA,IAAWI,eAAA,EAAiBJ,OAAA,IAAW,EAAE,aAAagB,YAAW,GAAI;MACvEM,UAAA,CAAStB,OAAO,GAAGlB,8BAAA,CAA+BkB,OAAA;MAClDyC,uBAAA,GAA0B;IAC5B;IAEA,IAAIA,uBAAA,EAAyB;MAC3BxB,eAAA,CAAgBK,UAAA;MAChB;MACAoB,MAAA,CAAOC,OAAO,CAACC,YAAY,CACzB,MACA,IACA,IAAI7D,EAAA,CAAG+C,SAAS,CAAC;QAAE,GAAGR,UAAQ;QAAEtB,OAAA,EAAS+B,IAAA,CAAKD,SAAS,CAACR,UAAA,CAAStB,OAAO;MAAE,IAAI;IAElF;EACF;EAEA;EACA;EACAd,SAAA,CAAU;IACR,IAAImB,kBAAA,EAAoB;MACtBmC,SAAA;IACF;EACF,GAAG,CAACrC,WAAA,EAAaD,YAAA,EAAcG,kBAAA,EAAoBL,OAAA,CAAQ;EAE3D,oBACE6C,IAAA,CAACnD,gBAAA;IACCoD,KAAA,EAAO;MACL/C,cAAA;MACAE,IAAA;MACAiC,gBAAA;MACAE,mBAAA;MACAC,kBAAA;MACAC,gBAAA;MACAC,iBAAA;MACAQ,KAAA,EAAO/B,YAAA;MACPE,cAAA;MACAN,WAAA;MACA,GAAGE,UAAA,CAAWC;IAChB;cAEA,aAAA8B,IAAA,CAAClD,wBAAA;MAAyBmD,KAAA,EAAOnC,QAAA;gBAAWb;;;AAGlD","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useRouter","useSearchParams","isNumber","transformColumnsToSearchParams","qs","React","useCallback","useEffect","useMemo","useRef","useState","useListDrawerContext","useEffectEvent","useRouteTransition","parseSearchParams","ListQueryContext","ListQueryModifiedContext","useListQuery","ListQueryProvider","children","collectionSlug","columns","data","defaultLimit","defaultSort","listPreferences","modifySearchParams","onQueryChange","onQueryChangeFromProps","orderableFieldName","router","rawSearchParams","startRouteTransition","modified","setModified","searchParams","contextRef","current","currentQuery","setCurrentQuery","refineListData","incomingQuery","undefined","page","newQuery","limit","String","preset","search","sort","where","replace","stringify","JSON","addQueryPrefix","onChangeFn","handlePageChange","arg","handlePerPageChange","handleSearchChange","handleSortChange","handleWhereChange","syncQuery","shouldUpdateQueryString","window","history","replaceState","_jsx","value","query"],"sources":["../../../src/providers/ListQuery/index.tsx"],"sourcesContent":["'use client'\nimport { useRouter, useSearchParams } from 'next/navigation.js'\nimport { type ListQuery, type Where } from 'payload'\nimport { isNumber, transformColumnsToSearchParams } from 'payload/shared'\nimport * as qs from 'qs-esm'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport type { IListQueryContext, ListQueryProps } from './types.js'\n\nimport { useListDrawerContext } from '../../elements/ListDrawer/Provider.js'\nimport { useEffectEvent } from '../../hooks/useEffectEvent.js'\nimport { useRouteTransition } from '../../providers/RouteTransition/index.js'\nimport { parseSearchParams } from '../../utilities/parseSearchParams.js'\nimport { ListQueryContext, ListQueryModifiedContext } from './context.js'\n\nexport { useListQuery } from './context.js'\n\nexport const ListQueryProvider: React.FC<ListQueryProps> = ({\n children,\n collectionSlug,\n columns,\n data,\n defaultLimit,\n defaultSort,\n listPreferences,\n modifySearchParams,\n onQueryChange: onQueryChangeFromProps,\n orderableFieldName,\n}) => {\n 'use no memo'\n const router = useRouter()\n const rawSearchParams = useSearchParams()\n const { startRouteTransition } = useRouteTransition()\n const [modified, setModified] = useState(false)\n\n const searchParams = useMemo<ListQuery>(\n () => parseSearchParams(rawSearchParams),\n [rawSearchParams],\n )\n\n const contextRef = useRef({} as IListQueryContext)\n\n contextRef.current.modified = modified\n\n const { onQueryChange } = useListDrawerContext()\n\n const [currentQuery, setCurrentQuery] = useState<ListQuery>(() => {\n if (modifySearchParams) {\n return searchParams\n } else {\n return {}\n }\n })\n\n const refineListData = useCallback(\n // eslint-disable-next-line @typescript-eslint/require-await\n async (incomingQuery: ListQuery, modified?: boolean) => {\n if (modified !== undefined) {\n setModified(modified)\n } else {\n setModified(true)\n }\n\n let page = 'page' in incomingQuery ? incomingQuery.page : currentQuery?.page\n\n if ('where' in incomingQuery || 'search' in incomingQuery) {\n page = '1'\n }\n\n const newQuery: ListQuery = {\n columns: 'columns' in incomingQuery ? incomingQuery.columns : currentQuery.columns,\n limit:\n 'limit' in incomingQuery\n ? incomingQuery.limit\n : (currentQuery?.limit ?? String(defaultLimit)),\n page,\n preset: 'preset' in incomingQuery ? incomingQuery.preset : currentQuery?.preset,\n search: 'search' in incomingQuery ? incomingQuery.search : currentQuery?.search,\n sort:\n 'sort' in incomingQuery\n ? incomingQuery.sort\n : ((currentQuery?.sort as string) ?? defaultSort),\n where: 'where' in incomingQuery ? incomingQuery.where : currentQuery?.where,\n }\n\n if (modifySearchParams) {\n startRouteTransition(() =>\n router.replace(\n `${qs.stringify(\n { ...newQuery, columns: JSON.stringify(newQuery.columns) },\n { addQueryPrefix: true },\n )}`,\n ),\n )\n } else if (\n typeof onQueryChange === 'function' ||\n typeof onQueryChangeFromProps === 'function'\n ) {\n const onChangeFn = onQueryChange || onQueryChangeFromProps\n onChangeFn(newQuery)\n }\n\n setCurrentQuery(newQuery)\n },\n [\n currentQuery?.columns,\n currentQuery?.limit,\n currentQuery?.page,\n currentQuery?.search,\n currentQuery?.sort,\n currentQuery?.where,\n currentQuery?.preset,\n startRouteTransition,\n defaultLimit,\n defaultSort,\n modifySearchParams,\n onQueryChange,\n onQueryChangeFromProps,\n router,\n ],\n )\n\n const handlePageChange = useCallback(\n async (arg: number) => {\n await refineListData({ page: String(arg) })\n },\n [refineListData],\n )\n\n const handlePerPageChange = React.useCallback(\n async (arg: number) => {\n await refineListData({ limit: String(arg), page: '1' })\n },\n [refineListData],\n )\n\n const handleSearchChange = useCallback(\n async (arg: string) => {\n const search = arg === '' ? undefined : arg\n await refineListData({ search })\n },\n [refineListData],\n )\n\n const handleSortChange = useCallback(\n async (arg: string) => {\n await refineListData({ sort: arg })\n },\n [refineListData],\n )\n\n const handleWhereChange = useCallback(\n async (arg: Where) => {\n await refineListData({ where: arg })\n },\n [refineListData],\n )\n\n const syncQuery = useEffectEvent(() => {\n let shouldUpdateQueryString = false\n const newQuery = { ...(currentQuery || {}) }\n\n // Allow the URL to override the default limit\n if (isNumber(defaultLimit) && !('limit' in currentQuery)) {\n newQuery.limit = String(defaultLimit)\n shouldUpdateQueryString = true\n }\n\n // Allow the URL to override the default sort\n if (defaultSort && !('sort' in currentQuery)) {\n newQuery.sort = defaultSort\n shouldUpdateQueryString = true\n }\n\n // Only modify columns if they originated from preferences\n // We can assume they did if `listPreferences.columns` is defined\n if (columns && listPreferences?.columns && !('columns' in currentQuery)) {\n newQuery.columns = transformColumnsToSearchParams(columns)\n shouldUpdateQueryString = true\n }\n\n if (shouldUpdateQueryString) {\n setCurrentQuery(newQuery)\n // Do not use router.replace here to avoid re-rendering on initial load\n window.history.replaceState(\n null,\n '',\n `?${qs.stringify({ ...newQuery, columns: JSON.stringify(newQuery.columns) })}`,\n )\n }\n })\n\n // If `defaultLimit` or `defaultSort` are updated externally, update the query\n // I.e. when HMR runs, these properties may be different\n useEffect(() => {\n if (modifySearchParams) {\n syncQuery()\n }\n }, [defaultSort, defaultLimit, modifySearchParams, columns])\n\n return (\n <ListQueryContext\n value={{\n collectionSlug,\n data,\n handlePageChange,\n handlePerPageChange,\n handleSearchChange,\n handleSortChange,\n handleWhereChange,\n orderableFieldName,\n query: currentQuery,\n refineListData,\n setModified,\n ...contextRef.current,\n }}\n >\n <ListQueryModifiedContext value={modified}>{children}</ListQueryModifiedContext>\n </ListQueryContext>\n )\n}\n"],"mappings":"AAAA;;;AACA,SAASA,SAAS,EAAEC,eAA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A;MAAyBoD,KAAA,EAAOnC,QAAA;gBAAWd;;;AAGlD","ignoreList":[]}
@@ -17,6 +17,7 @@ export type ListQueryProps = {
17
17
  readonly listPreferences?: ListPreferences;
18
18
  readonly modifySearchParams?: boolean;
19
19
  readonly onQueryChange?: OnListQueryChange;
20
+ readonly orderableFieldName?: string;
20
21
  /**
21
22
  * @deprecated
22
23
  */
@@ -27,6 +28,7 @@ export type IListQueryContext = {
27
28
  data: PaginatedDocs;
28
29
  defaultLimit?: number;
29
30
  defaultSort?: Sort;
31
+ orderableFieldName?: string;
30
32
  modified: boolean;
31
33
  query: ListQuery;
32
34
  refineListData: (args: ListQuery, setModified?: boolean) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/providers/ListQuery/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,aAAa,EAEb,IAAI,EACJ,KAAK,EACN,MAAM,SAAS,CAAA;AAEhB,KAAK,eAAe,GAAG;IACrB,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAClD,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACtD,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACtD,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAClD,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACpD,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAA;AAE1D,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ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;IAC9C,IAAI,EAAE,aAAa,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,SAAS,CAAA;IAChB,cAAc,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACzE,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAA;CACzC,GAAG,eAAe,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/providers/ListQuery/types.ts"],"sourcesContent":["import type {\n ClientCollectionConfig,\n ColumnPreference,\n ListPreferences,\n ListQuery,\n PaginatedDocs,\n QueryPreset,\n Sort,\n Where,\n} from 'payload'\n\ntype ContextHandlers = {\n handlePageChange?: (page: number) => Promise<void>\n handlePerPageChange?: (limit: number) => Promise<void>\n handleSearchChange?: (search: string) => Promise<void>\n handleSortChange?: (sort: string) => Promise<void>\n handleWhereChange?: (where: Where) => Promise<void>\n}\n\nexport type OnListQueryChange = (query: ListQuery) => void\n\nexport type ListQueryProps = {\n readonly children: React.ReactNode\n readonly collectionSlug?: ClientCollectionConfig['slug']\n readonly columns?: ColumnPreference[]\n readonly data: PaginatedDocs\n readonly defaultLimit?: number\n readonly defaultSort?: Sort\n readonly listPreferences?: ListPreferences\n readonly modifySearchParams?: boolean\n readonly onQueryChange?: OnListQueryChange\n /**\n * @deprecated\n */\n readonly preferenceKey?: string\n}\n\nexport type IListQueryContext = {\n collectionSlug: ClientCollectionConfig['slug']\n data: PaginatedDocs\n defaultLimit?: number\n defaultSort?: Sort\n modified: boolean\n query: ListQuery\n refineListData: (args: ListQuery, setModified?: boolean) => Promise<void>\n setModified: (modified: boolean) => void\n} & ContextHandlers\n"],"mappings":"AAqCA","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/providers/ListQuery/types.ts"],"sourcesContent":["import type {\n ClientCollectionConfig,\n ColumnPreference,\n ListPreferences,\n ListQuery,\n PaginatedDocs,\n QueryPreset,\n Sort,\n Where,\n} from 'payload'\n\ntype ContextHandlers = {\n handlePageChange?: (page: number) => Promise<void>\n handlePerPageChange?: (limit: number) => Promise<void>\n handleSearchChange?: (search: string) => Promise<void>\n handleSortChange?: (sort: string) => Promise<void>\n handleWhereChange?: (where: Where) => Promise<void>\n}\n\nexport type OnListQueryChange = (query: ListQuery) => void\n\nexport type ListQueryProps = {\n readonly children: React.ReactNode\n readonly collectionSlug?: ClientCollectionConfig['slug']\n readonly columns?: ColumnPreference[]\n readonly data: PaginatedDocs\n readonly defaultLimit?: number\n readonly defaultSort?: Sort\n readonly listPreferences?: ListPreferences\n readonly modifySearchParams?: boolean\n readonly onQueryChange?: OnListQueryChange\n readonly orderableFieldName?: string\n /**\n * @deprecated\n */\n readonly preferenceKey?: string\n}\n\nexport type IListQueryContext = {\n collectionSlug: ClientCollectionConfig['slug']\n data: PaginatedDocs\n defaultLimit?: number\n defaultSort?: Sort\n orderableFieldName?: string\n modified: boolean\n query: ListQuery\n refineListData: (args: ListQuery, setModified?: boolean) => Promise<void>\n setModified: (modified: boolean) => void\n} & ContextHandlers\n"],"mappings":"AAsCA","ignoreList":[]}