@payloadcms/ui 3.0.0-beta.67 → 3.0.0-beta.69

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 (77) hide show
  1. package/dist/elements/AppHeader/index.d.ts.map +1 -1
  2. package/dist/elements/AppHeader/index.js +5 -1
  3. package/dist/elements/AppHeader/index.js.map +1 -1
  4. package/dist/elements/Autosave/index.d.ts.map +1 -1
  5. package/dist/elements/Autosave/index.js +44 -28
  6. package/dist/elements/Autosave/index.js.map +1 -1
  7. package/dist/elements/DeleteDocument/index.d.ts.map +1 -1
  8. package/dist/elements/DeleteDocument/index.js +7 -3
  9. package/dist/elements/DeleteDocument/index.js.map +1 -1
  10. package/dist/elements/DocumentControls/index.d.ts.map +1 -1
  11. package/dist/elements/DocumentControls/index.js +5 -1
  12. package/dist/elements/DocumentControls/index.js.map +1 -1
  13. package/dist/elements/DocumentFields/index.d.ts.map +1 -1
  14. package/dist/elements/DocumentFields/index.js +46 -48
  15. package/dist/elements/DocumentFields/index.js.map +1 -1
  16. package/dist/elements/DuplicateDocument/index.d.ts.map +1 -1
  17. package/dist/elements/DuplicateDocument/index.js +10 -6
  18. package/dist/elements/DuplicateDocument/index.js.map +1 -1
  19. package/dist/elements/Logout/index.d.ts.map +1 -1
  20. package/dist/elements/Logout/index.js +6 -3
  21. package/dist/elements/Logout/index.js.map +1 -1
  22. package/dist/elements/StayLoggedIn/index.d.ts.map +1 -1
  23. package/dist/elements/StayLoggedIn/index.js +6 -2
  24. package/dist/elements/StayLoggedIn/index.js.map +1 -1
  25. package/dist/elements/Table/DefaultCell/index.d.ts.map +1 -1
  26. package/dist/elements/Table/DefaultCell/index.js +5 -1
  27. package/dist/elements/Table/DefaultCell/index.js.map +1 -1
  28. package/dist/elements/Upload/index.d.ts.map +1 -1
  29. package/dist/elements/Upload/index.js +1 -1
  30. package/dist/elements/Upload/index.js.map +1 -1
  31. package/dist/elements/WhereBuilder/Condition/Relationship/index.js +4 -4
  32. package/dist/elements/WhereBuilder/Condition/Relationship/index.js.map +1 -1
  33. package/dist/elements/WhereBuilder/Condition/index.d.ts.map +1 -1
  34. package/dist/elements/WhereBuilder/Condition/index.js +4 -2
  35. package/dist/elements/WhereBuilder/Condition/index.js.map +1 -1
  36. package/dist/elements/withMergedProps/index.js +8 -2
  37. package/dist/elements/withMergedProps/index.js.map +1 -1
  38. package/dist/exports/client/index.js +18 -18
  39. package/dist/exports/client/index.js.map +4 -4
  40. package/dist/exports/shared/index.d.ts +1 -0
  41. package/dist/exports/shared/index.d.ts.map +1 -1
  42. package/dist/exports/shared/index.js +2 -2
  43. package/dist/exports/shared/index.js.map +4 -4
  44. package/dist/fields/Upload/Input.d.ts +4 -0
  45. package/dist/fields/Upload/Input.d.ts.map +1 -1
  46. package/dist/fields/Upload/Input.js +2 -2
  47. package/dist/fields/Upload/Input.js.map +1 -1
  48. package/dist/fields/Upload/index.d.ts.map +1 -1
  49. package/dist/fields/Upload/index.js +18 -3
  50. package/dist/fields/Upload/index.js.map +1 -1
  51. package/dist/forms/Form/fieldReducer.d.ts.map +1 -1
  52. package/dist/forms/Form/fieldReducer.js +6 -3
  53. package/dist/forms/Form/fieldReducer.js.map +1 -1
  54. package/dist/forms/buildStateFromSchema/addFieldStatePromise.d.ts.map +1 -1
  55. package/dist/forms/buildStateFromSchema/addFieldStatePromise.js +39 -18
  56. package/dist/forms/buildStateFromSchema/addFieldStatePromise.js.map +1 -1
  57. package/dist/graphics/Account/index.d.ts.map +1 -1
  58. package/dist/graphics/Account/index.js +5 -1
  59. package/dist/graphics/Account/index.js.map +1 -1
  60. package/dist/providers/Auth/index.d.ts +1 -1
  61. package/dist/providers/Auth/index.d.ts.map +1 -1
  62. package/dist/providers/Auth/index.js +47 -76
  63. package/dist/providers/Auth/index.js.map +1 -1
  64. package/dist/providers/ComponentMap/buildComponentMap/fields.d.ts.map +1 -1
  65. package/dist/providers/ComponentMap/buildComponentMap/fields.js +1 -0
  66. package/dist/providers/ComponentMap/buildComponentMap/fields.js.map +1 -1
  67. package/dist/providers/DocumentInfo/index.d.ts.map +1 -1
  68. package/dist/providers/DocumentInfo/index.js +20 -14
  69. package/dist/providers/DocumentInfo/index.js.map +1 -1
  70. package/dist/utilities/buildFormState.d.ts.map +1 -1
  71. package/dist/utilities/buildFormState.js +1 -0
  72. package/dist/utilities/buildFormState.js.map +1 -1
  73. package/dist/utilities/formatAdminURL.d.ts +8 -0
  74. package/dist/utilities/formatAdminURL.d.ts.map +1 -0
  75. package/dist/utilities/formatAdminURL.js +15 -0
  76. package/dist/utilities/formatAdminURL.js.map +1 -0
  77. package/package.json +4 -4
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import React, { useEffect, useState } from 'react';
4
4
  import { RenderCustomClientComponent } from '../../../elements/RenderCustomClientComponent/index.js';
5
5
  import { useDebounce } from '../../../hooks/useDebounce.js';
6
+ import { useTranslation } from '../../../providers/Translation/index.js';
6
7
  import { Button } from '../../Button/index.js';
7
8
  import { ReactSelect } from '../../ReactSelect/index.js';
8
9
  import { DateField } from './Date/index.js';
@@ -22,6 +23,7 @@ const baseClass = 'condition';
22
23
  export const Condition = (props)=>{
23
24
  const { addCondition, andIndex, fieldName, fields, initialValue, operator, orIndex, removeCondition, updateCondition } = props;
24
25
  const [internalField, setInternalField] = useState(()=>fields.find((field)=>fieldName === field.value));
26
+ const { t } = useTranslation();
25
27
  const [internalOperatorOption, setInternalOperatorOption] = useState(operator);
26
28
  const [internalQueryValue, setInternalQueryValue] = useState(initialValue);
27
29
  const debouncedValue = useDebounce(internalQueryValue, 300);
@@ -55,8 +57,8 @@ export const Condition = (props)=>{
55
57
  let valueOptions;
56
58
  if (booleanSelect) {
57
59
  valueOptions = [
58
- 'true',
59
- 'false'
60
+ t('general:true'),
61
+ t('general:false')
60
62
  ];
61
63
  } else if (internalField?.props && 'options' in internalField.props) {
62
64
  valueOptions = internalField.props.options;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useEffect, useState } from 'react'\n\nimport type { FieldCondition } from '../types.js'\n\nexport type Props = {\n addCondition: ({\n andIndex,\n fieldName,\n orIndex,\n relation,\n }: {\n andIndex: number\n fieldName: string\n orIndex: number\n relation: 'and' | 'or'\n }) => void\n andIndex: number\n fieldName: string\n fields: FieldCondition[]\n initialValue: string\n operator: Operator\n orIndex: number\n removeCondition: ({ andIndex, orIndex }: { andIndex: number; orIndex: number }) => void\n updateCondition: ({\n andIndex,\n fieldName,\n operator,\n orIndex,\n value,\n }: {\n andIndex: number\n fieldName: string\n operator: string\n orIndex: number\n value: string\n }) => void\n}\n\nimport type { Operator } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { RenderCustomClientComponent } from '../../../elements/RenderCustomClientComponent/index.js'\nimport { useDebounce } from '../../../hooks/useDebounce.js'\nimport { Button } from '../../Button/index.js'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport { DateField } from './Date/index.js'\nimport { NumberField } from './Number/index.js'\nimport { RelationshipField } from './Relationship/index.js'\nimport { Select } from './Select/index.js'\nimport Text from './Text/index.js'\nimport './index.scss'\n\ntype ComponentType = 'Date' | 'Number' | 'Relationship' | 'Select' | 'Text'\nconst valueFields: Record<ComponentType, React.FC> = {\n Date: DateField,\n Number: NumberField,\n Relationship: RelationshipField,\n Select,\n Text,\n}\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldName,\n fields,\n initialValue,\n operator,\n orIndex,\n removeCondition,\n updateCondition,\n } = props\n const [internalField, setInternalField] = useState<FieldCondition>(() =>\n fields.find((field) => fieldName === field.value),\n )\n const [internalOperatorOption, setInternalOperatorOption] = useState<Operator>(operator)\n const [internalQueryValue, setInternalQueryValue] = useState<string>(initialValue)\n\n const debouncedValue = useDebounce(internalQueryValue, 300)\n\n useEffect(() => {\n // This is to trigger changes when the debounced value changes\n if (\n (internalField?.value || typeof internalField?.value === 'number') &&\n internalOperatorOption &&\n ![null, undefined].includes(debouncedValue)\n ) {\n updateCondition({\n andIndex,\n fieldName: internalField.value,\n operator: internalOperatorOption,\n orIndex,\n value: debouncedValue,\n })\n }\n }, [\n debouncedValue,\n andIndex,\n internalField?.value,\n internalOperatorOption,\n orIndex,\n updateCondition,\n operator,\n ])\n\n const booleanSelect =\n ['exists'].includes(internalOperatorOption) || internalField?.props?.type === 'checkbox'\n const ValueComponent = booleanSelect\n ? Select\n : valueFields[internalField?.component] || valueFields.Text\n\n let valueOptions\n if (booleanSelect) {\n valueOptions = ['true', 'false']\n } else if (internalField?.props && 'options' in internalField.props) {\n valueOptions = internalField.props.options\n }\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__inputs`}>\n <div className={`${baseClass}__field`}>\n <ReactSelect\n isClearable={false}\n onChange={(field: Option) => {\n setInternalField(fields.find((f) => f.value === field.value))\n setInternalOperatorOption(undefined)\n setInternalQueryValue(undefined)\n }}\n options={fields}\n value={fields.find((field) => internalField?.value === field.value) || fields[0]}\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={!internalField?.value && typeof internalField?.value !== 'number'}\n isClearable={false}\n onChange={(operator: Option<Operator>) => {\n setInternalOperatorOption(operator.value)\n }}\n options={internalField?.operators}\n value={\n internalField?.operators.find(\n (operator) => internalOperatorOption === operator.value,\n ) || null\n }\n />\n </div>\n <div className={`${baseClass}__value`}>\n <RenderCustomClientComponent\n CustomComponent={internalField?.props?.admin?.components?.Filter}\n DefaultComponent={ValueComponent}\n componentProps={{\n ...internalField?.props,\n disabled: !internalOperatorOption,\n onChange: setInternalQueryValue,\n operator: internalOperatorOption,\n options: valueOptions,\n relationTo:\n internalField?.props?.type === 'relationship' &&\n 'cellComponentProps' in internalField.props &&\n typeof internalField.props.cellComponentProps === 'object' &&\n 'relationTo' in internalField.props.cellComponentProps\n ? internalField.props.cellComponentProps?.relationTo\n : undefined,\n value: internalQueryValue ?? '',\n }}\n />\n </div>\n </div>\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-remove`}\n icon=\"x\"\n iconStyle=\"with-border\"\n onClick={() =>\n removeCondition({\n andIndex,\n orIndex,\n })\n }\n round\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-add`}\n icon=\"plus\"\n iconStyle=\"with-border\"\n onClick={() =>\n addCondition({\n andIndex: andIndex + 1,\n fieldName: fields[0].value,\n orIndex,\n relation: 'and',\n })\n }\n round\n />\n </div>\n </div>\n </div>\n )\n}\n"],"names":["React","useEffect","useState","RenderCustomClientComponent","useDebounce","Button","ReactSelect","DateField","NumberField","RelationshipField","Select","Text","valueFields","Date","Number","Relationship","baseClass","Condition","props","addCondition","andIndex","fieldName","fields","initialValue","operator","orIndex","removeCondition","updateCondition","internalField","setInternalField","find","field","value","internalOperatorOption","setInternalOperatorOption","internalQueryValue","setInternalQueryValue","debouncedValue","undefined","includes","booleanSelect","type","ValueComponent","component","valueOptions","options","div","className","isClearable","onChange","f","disabled","operators","CustomComponent","admin","components","Filter","DefaultComponent","componentProps","relationTo","cellComponentProps","buttonStyle","icon","iconStyle","onClick","round","relation"],"mappings":"AAAA;;AACA,OAAOA,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AA0ClD,SAASC,2BAA2B,QAAQ,yDAAwD;AACpG,SAASC,WAAW,QAAQ,gCAA+B;AAC3D,SAASC,MAAM,QAAQ,wBAAuB;AAC9C,SAASC,WAAW,QAAQ,6BAA4B;AACxD,SAASC,SAAS,QAAQ,kBAAiB;AAC3C,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,SAASC,iBAAiB,QAAQ,0BAAyB;AAC3D,SAASC,MAAM,QAAQ,oBAAmB;AAC1C,OAAOC,UAAU,kBAAiB;AAClC,OAAO,eAAc;AAGrB,MAAMC,cAA+C;I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hC,cAAcV,KAAK,CAAC0C,kBAAkB,EAAED,aACxCrB;oCACNN,OAAOG,sBAAsB;gCAC/B;;;;;8BAIN,MAACW;oBAAIC,WAAW,CAAC,EAAE/B,UAAU,SAAS,CAAC;;sCACrC,KAACX;4BACCwD,aAAY;4BACZd,WAAW,CAAC,EAAE/B,UAAU,gBAAgB,CAAC;4BACzC8C,MAAK;4BACLC,WAAU;4BACVC,SAAS,IACPtC,gBAAgB;oCACdN;oCACAK;gCACF;4BAEFwC,KAAK;;sCAEP,KAAC5D;4BACCwD,aAAY;4BACZd,WAAW,CAAC,EAAE/B,UAAU,aAAa,CAAC;4BACtC8C,MAAK;4BACLC,WAAU;4BACVC,SAAS,IACP7C,aAAa;oCACXC,UAAUA,WAAW;oCACrBC,WAAWC,MAAM,CAAC,EAAE,CAACU,KAAK;oCAC1BP;oCACAyC,UAAU;gCACZ;4BAEFD,KAAK;;;;;;;AAMjB,EAAC"}
1
+ {"version":3,"sources":["../../../../src/elements/WhereBuilder/Condition/index.tsx"],"sourcesContent":["'use client'\nimport React, { useEffect, useState } from 'react'\n\nimport type { FieldCondition } from '../types.js'\n\nexport type Props = {\n addCondition: ({\n andIndex,\n fieldName,\n orIndex,\n relation,\n }: {\n andIndex: number\n fieldName: string\n orIndex: number\n relation: 'and' | 'or'\n }) => void\n andIndex: number\n fieldName: string\n fields: FieldCondition[]\n initialValue: string\n operator: Operator\n orIndex: number\n removeCondition: ({ andIndex, orIndex }: { andIndex: number; orIndex: number }) => void\n updateCondition: ({\n andIndex,\n fieldName,\n operator,\n orIndex,\n value,\n }: {\n andIndex: number\n fieldName: string\n operator: string\n orIndex: number\n value: string\n }) => void\n}\n\nimport type { Operator } from 'payload'\n\nimport type { Option } from '../../ReactSelect/index.js'\n\nimport { RenderCustomClientComponent } from '../../../elements/RenderCustomClientComponent/index.js'\nimport { useDebounce } from '../../../hooks/useDebounce.js'\nimport { useTranslation } from '../../../providers/Translation/index.js'\nimport { Button } from '../../Button/index.js'\nimport { ReactSelect } from '../../ReactSelect/index.js'\nimport { DateField } from './Date/index.js'\nimport { NumberField } from './Number/index.js'\nimport { RelationshipField } from './Relationship/index.js'\nimport { Select } from './Select/index.js'\nimport Text from './Text/index.js'\nimport './index.scss'\n\ntype ComponentType = 'Date' | 'Number' | 'Relationship' | 'Select' | 'Text'\nconst valueFields: Record<ComponentType, React.FC> = {\n Date: DateField,\n Number: NumberField,\n Relationship: RelationshipField,\n Select,\n Text,\n}\n\nconst baseClass = 'condition'\n\nexport const Condition: React.FC<Props> = (props) => {\n const {\n addCondition,\n andIndex,\n fieldName,\n fields,\n initialValue,\n operator,\n orIndex,\n removeCondition,\n updateCondition,\n } = props\n const [internalField, setInternalField] = useState<FieldCondition>(() =>\n fields.find((field) => fieldName === field.value),\n )\n const { t } = useTranslation()\n const [internalOperatorOption, setInternalOperatorOption] = useState<Operator>(operator)\n const [internalQueryValue, setInternalQueryValue] = useState<string>(initialValue)\n\n const debouncedValue = useDebounce(internalQueryValue, 300)\n\n useEffect(() => {\n // This is to trigger changes when the debounced value changes\n if (\n (internalField?.value || typeof internalField?.value === 'number') &&\n internalOperatorOption &&\n ![null, undefined].includes(debouncedValue)\n ) {\n updateCondition({\n andIndex,\n fieldName: internalField.value,\n operator: internalOperatorOption,\n orIndex,\n value: debouncedValue,\n })\n }\n }, [\n debouncedValue,\n andIndex,\n internalField?.value,\n internalOperatorOption,\n orIndex,\n updateCondition,\n operator,\n ])\n\n const booleanSelect =\n ['exists'].includes(internalOperatorOption) || internalField?.props?.type === 'checkbox'\n const ValueComponent = booleanSelect\n ? Select\n : valueFields[internalField?.component] || valueFields.Text\n\n let valueOptions\n if (booleanSelect) {\n valueOptions = [t('general:true'), t('general:false')]\n } else if (internalField?.props && 'options' in internalField.props) {\n valueOptions = internalField.props.options\n }\n\n return (\n <div className={baseClass}>\n <div className={`${baseClass}__wrap`}>\n <div className={`${baseClass}__inputs`}>\n <div className={`${baseClass}__field`}>\n <ReactSelect\n isClearable={false}\n onChange={(field: Option) => {\n setInternalField(fields.find((f) => f.value === field.value))\n setInternalOperatorOption(undefined)\n setInternalQueryValue(undefined)\n }}\n options={fields}\n value={fields.find((field) => internalField?.value === field.value) || fields[0]}\n />\n </div>\n <div className={`${baseClass}__operator`}>\n <ReactSelect\n disabled={!internalField?.value && typeof internalField?.value !== 'number'}\n isClearable={false}\n onChange={(operator: Option<Operator>) => {\n setInternalOperatorOption(operator.value)\n }}\n options={internalField?.operators}\n value={\n internalField?.operators.find(\n (operator) => internalOperatorOption === operator.value,\n ) || null\n }\n />\n </div>\n <div className={`${baseClass}__value`}>\n <RenderCustomClientComponent\n CustomComponent={internalField?.props?.admin?.components?.Filter}\n DefaultComponent={ValueComponent}\n componentProps={{\n ...internalField?.props,\n disabled: !internalOperatorOption,\n onChange: setInternalQueryValue,\n operator: internalOperatorOption,\n options: valueOptions,\n relationTo:\n internalField?.props?.type === 'relationship' &&\n 'cellComponentProps' in internalField.props &&\n typeof internalField.props.cellComponentProps === 'object' &&\n 'relationTo' in internalField.props.cellComponentProps\n ? internalField.props.cellComponentProps?.relationTo\n : undefined,\n value: internalQueryValue ?? '',\n }}\n />\n </div>\n </div>\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-remove`}\n icon=\"x\"\n iconStyle=\"with-border\"\n onClick={() =>\n removeCondition({\n andIndex,\n orIndex,\n })\n }\n round\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__actions-add`}\n icon=\"plus\"\n iconStyle=\"with-border\"\n onClick={() =>\n addCondition({\n andIndex: andIndex + 1,\n fieldName: fields[0].value,\n orIndex,\n relation: 'and',\n })\n }\n round\n />\n </div>\n </div>\n </div>\n )\n}\n"],"names":["React","useEffect","useState","RenderCustomClientComponent","useDebounce","useTranslation","Button","ReactSelect","DateField","NumberField","RelationshipField","Select","Text","valueFields","Date","Number","Relationship","baseClass","Condition","props","addCondition","andIndex","fieldName","fields","initialValue","operator","orIndex","removeCondition","updateCondition","internalField","setInternalField","find","field","value","t","internalOperatorOption","setInternalOperatorOption","internalQueryValue","setInternalQueryValue","debouncedValue","undefined","includes","booleanSelect","type","ValueComponent","component","valueOptions","options","div","className","isClearable","onChange","f","disabled","operators","CustomComponent","admin","components","Filter","DefaultComponent","componentProps","relationTo","cellComponentProps","buttonStyle","icon","iconStyle","onClick","round","relation"],"mappings":"AAAA;;AACA,OAAOA,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AA0ClD,SAASC,2BAA2B,QAAQ,yDAAwD;AACpG,SAASC,WAAW,QAAQ,gCAA+B;AAC3D,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,MAAM,QAAQ,wBAAuB;AAC9C,SAASC,WAAW,QAAQ,6BAA4B;AACxD,SAASC,SAAS,QAAQ,kBAAiB;AAC3C,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,SAASC,iBAAiB,QAAQ,0BAAyB;AAC3D,SAASC,MAAM,QAAQ,oBAAmB;AAC1C,OAAOC,UAAU,kBAAiB;AAClC,OAAO,eAAc;AAGrB,MAAMC,cAA+C;IACnDC,MAAMN;IACNO,QAAQN;IACRO,cAAcN;IACdC;IACAC;AACF;AAEA,MAAMK,YAAY;AAElB,OAAO,MAAMC,YAA6B,CAACC;IACzC,MAAM,EACJC,YAAY,EACZC,QAAQ,EACRC,SAAS,EACTC,MAAM,EACNC,YAAY,EACZC,QAAQ,EACRC,OAAO,EACPC,eAAe,EACfC,eAAe,EAChB,GAAGT;IACJ,MAAM,CAACU,eAAeC,iBAAiB,GAAG5B,SAAyB,IACjEqB,OAAOQ,IAAI,CAAC,CAACC,QAAUV,cAAcU,MAAMC,KAAK;IAElD,MAAM,EAAEC,CAAC,EAAE,GAAG7B;IACd,MAAM,CAAC8B,wBAAwBC,0BAA0B,GAAGlC,SAAmBuB;IAC/E,MAAM,CAACY,oBAAoBC,sBAAsB,GAAGpC,SAAiBsB;IAErE,MAAMe,iBAAiBnC,YAAYiC,oBAAoB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M,CAAC,EAAE,CAACU,KAAK;oCAC1BP;oCACA0C,UAAU;gCACZ;4BAEFD,KAAK;;;;;;;AAMjB,EAAC"}
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { deepMerge, isReactServerComponentOrFunction, serverProps } from 'payload/shared';
2
+ import { isReactServerComponentOrFunction, serverProps } from 'payload/shared';
3
3
  import React from 'react';
4
4
  /**
5
5
  * Creates a higher-order component (HOC) that merges predefined properties (`toMergeIntoProps`)
@@ -28,7 +28,7 @@ import React from 'react';
28
28
  }
29
29
  // A wrapper around the args.Component to inject the args.toMergeArgs as props, which are merged with the passed props
30
30
  const MergedPropsComponent = (passedProps)=>{
31
- const mergedProps = deepMerge(passedProps, toMergeIntoProps);
31
+ const mergedProps = simpleMergeProps(passedProps, toMergeIntoProps);
32
32
  if (sanitizeServerOnlyProps) {
33
33
  serverProps.forEach((prop)=>{
34
34
  delete mergedProps[prop];
@@ -40,5 +40,11 @@ import React from 'react';
40
40
  };
41
41
  return MergedPropsComponent;
42
42
  }
43
+ function simpleMergeProps(props, toMerge) {
44
+ return {
45
+ ...props,
46
+ ...toMerge
47
+ };
48
+ }
43
49
 
44
50
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/elements/withMergedProps/index.tsx"],"sourcesContent":["import { deepMerge, isReactServerComponentOrFunction, serverProps } from 'payload/shared'\nimport React from 'react'\n\n/**\n * Creates a higher-order component (HOC) that merges predefined properties (`toMergeIntoProps`)\n * with any properties passed to the resulting component.\n *\n * Use this when you want to pre-specify some props for a component, while also allowing users to\n * pass in their own props. The HOC ensures the passed props and predefined props are combined before\n * rendering the original component.\n *\n * @example\n * const PredefinedComponent = getMergedPropsComponent({\n * Component: OriginalComponent,\n * toMergeIntoProps: { someExtraValue: 5 }\n * });\n * // Using <PredefinedComponent customProp=\"value\" /> will result in\n * // <OriginalComponent customProp=\"value\" someExtraValue={5} />\n *\n * @returns A higher-order component with combined properties.\n *\n * @param Component - The original component to wrap.\n * @param sanitizeServerOnlyProps - If true, server-only props will be removed from the merged props. @default true if the component is not a server component, false otherwise.\n * @param toMergeIntoProps - The properties to merge into the passed props.\n */\nexport function withMergedProps<ToMergeIntoProps, CompleteReturnProps>({\n Component,\n sanitizeServerOnlyProps,\n toMergeIntoProps,\n}: {\n Component: React.FC<CompleteReturnProps>\n sanitizeServerOnlyProps?: boolean\n toMergeIntoProps: ToMergeIntoProps\n}): React.FC<CompleteReturnProps> {\n if (sanitizeServerOnlyProps === undefined) {\n sanitizeServerOnlyProps = !isReactServerComponentOrFunction(Component)\n }\n // A wrapper around the args.Component to inject the args.toMergeArgs as props, which are merged with the passed props\n const MergedPropsComponent: React.FC<CompleteReturnProps> = (passedProps) => {\n const mergedProps = deepMerge(passedProps, toMergeIntoProps)\n\n if (sanitizeServerOnlyProps) {\n serverProps.forEach((prop) => {\n delete mergedProps[prop]\n })\n }\n\n return <Component {...mergedProps} />\n }\n\n return MergedPropsComponent\n}\n"],"names":["deepMerge","isReactServerComponentOrFunction","serverProps","React","withMergedProps","Component","sanitizeServerOnlyProps","toMergeIntoProps","undefined","MergedPropsComponent","passedProps","mergedProps","forEach","prop"],"mappings":";AAAA,SAASA,SAAS,EAAEC,gCAAgC,EAAEC,WAAW,QAAQ,iBAAgB;AACzF,OAAOC,WAAW,QAAO;AAEzB;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASC,gBAAuD,EACrEC,SAAS,EACTC,uBAAuB,EACvBC,gBAAgB,EAKjB;IACC,IAAID,4BAA4BE,WAAW;QACzCF,0BAA0B,CAACL,iCAAiCI;IAC9D;IACA,sHAAsH;IACtH,MAAMI,uBAAsD,CAACC;QAC3D,MAAMC,cAAcX,UAAUU,aAAaH;QAE3C,IAAID,yBAAyB;YAC3BJ,YAAYU,OAAO,CAAC,CAACC;gBACnB,OAAOF,WAAW,CAACE,KAAK;YAC1B;QACF;QAEA,qBAAO,KAACR;YAAW,GAAGM,WAAW;;IACnC;IAEA,OAAOF;AACT"}
1
+ {"version":3,"sources":["../../../src/elements/withMergedProps/index.tsx"],"sourcesContent":["import { isReactServerComponentOrFunction, serverProps } from 'payload/shared'\nimport React from 'react'\n\n/**\n * Creates a higher-order component (HOC) that merges predefined properties (`toMergeIntoProps`)\n * with any properties passed to the resulting component.\n *\n * Use this when you want to pre-specify some props for a component, while also allowing users to\n * pass in their own props. The HOC ensures the passed props and predefined props are combined before\n * rendering the original component.\n *\n * @example\n * const PredefinedComponent = getMergedPropsComponent({\n * Component: OriginalComponent,\n * toMergeIntoProps: { someExtraValue: 5 }\n * });\n * // Using <PredefinedComponent customProp=\"value\" /> will result in\n * // <OriginalComponent customProp=\"value\" someExtraValue={5} />\n *\n * @returns A higher-order component with combined properties.\n *\n * @param Component - The original component to wrap.\n * @param sanitizeServerOnlyProps - If true, server-only props will be removed from the merged props. @default true if the component is not a server component, false otherwise.\n * @param toMergeIntoProps - The properties to merge into the passed props.\n */\nexport function withMergedProps<ToMergeIntoProps, CompleteReturnProps>({\n Component,\n sanitizeServerOnlyProps,\n toMergeIntoProps,\n}: {\n Component: React.FC<CompleteReturnProps>\n sanitizeServerOnlyProps?: boolean\n toMergeIntoProps: ToMergeIntoProps\n}): React.FC<CompleteReturnProps> {\n if (sanitizeServerOnlyProps === undefined) {\n sanitizeServerOnlyProps = !isReactServerComponentOrFunction(Component)\n }\n // A wrapper around the args.Component to inject the args.toMergeArgs as props, which are merged with the passed props\n const MergedPropsComponent: React.FC<CompleteReturnProps> = (passedProps) => {\n const mergedProps = simpleMergeProps(passedProps, toMergeIntoProps) as CompleteReturnProps\n\n if (sanitizeServerOnlyProps) {\n serverProps.forEach((prop) => {\n delete mergedProps[prop]\n })\n }\n\n return <Component {...mergedProps} />\n }\n\n return MergedPropsComponent\n}\n\nfunction simpleMergeProps(props, toMerge) {\n return { ...props, ...toMerge }\n}\n"],"names":["isReactServerComponentOrFunction","serverProps","React","withMergedProps","Component","sanitizeServerOnlyProps","toMergeIntoProps","undefined","MergedPropsComponent","passedProps","mergedProps","simpleMergeProps","forEach","prop","props","toMerge"],"mappings":";AAAA,SAASA,gCAAgC,EAAEC,WAAW,QAAQ,iBAAgB;AAC9E,OAAOC,WAAW,QAAO;AAEzB;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASC,gBAAuD,EACrEC,SAAS,EACTC,uBAAuB,EACvBC,gBAAgB,EAKjB;IACC,IAAID,4BAA4BE,WAAW;QACzCF,0BAA0B,CAACL,iCAAiCI;IAC9D;IACA,sHAAsH;IACtH,MAAMI,uBAAsD,CAACC;QAC3D,MAAMC,cAAcC,iBAAiBF,aAAaH;QAElD,IAAID,yBAAyB;YAC3BJ,YAAYW,OAAO,CAAC,CAACC;gBACnB,OAAOH,WAAW,CAACG,KAAK;YAC1B;QACF;QAEA,qBAAO,KAACT;YAAW,GAAGM,WAAW;;IACnC;IAEA,OAAOF;AACT;AAEA,SAASG,iBAAiBG,KAAK,EAAEC,OAAO;IACtC,OAAO;QAAE,GAAGD,KAAK;QAAE,GAAGC,OAAO;IAAC;AAChC"}