@payloadcms/richtext-lexical 3.0.0-beta.133 → 3.0.0-beta.134

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 (119) hide show
  1. package/dist/exports/client/Field-S5G27AVI.js +2 -0
  2. package/dist/exports/client/Field-S5G27AVI.js.map +7 -0
  3. package/dist/exports/client/bundled.css +1 -1
  4. package/dist/exports/client/chunk-2CYU43GM.js +2 -0
  5. package/dist/exports/client/chunk-2CYU43GM.js.map +7 -0
  6. package/dist/exports/client/chunk-C7S3V4EB.js +2 -0
  7. package/dist/exports/client/chunk-C7S3V4EB.js.map +7 -0
  8. package/dist/exports/client/chunk-U7O7EYCP.js +2 -0
  9. package/dist/exports/client/chunk-U7O7EYCP.js.map +7 -0
  10. package/dist/exports/client/component-H3EYQ5KG.js +2 -0
  11. package/dist/exports/client/{component-YICNYPTU.js.map → component-H3EYQ5KG.js.map} +1 -1
  12. package/dist/exports/client/componentInline-ZGO3K4TA.js +2 -0
  13. package/dist/exports/client/componentInline-ZGO3K4TA.js.map +7 -0
  14. package/dist/exports/client/index.d.ts +7 -0
  15. package/dist/exports/client/index.d.ts.map +1 -1
  16. package/dist/exports/client/index.js +7 -7
  17. package/dist/exports/client/index.js.map +4 -4
  18. package/dist/features/blocks/client/component/BlockContent.d.ts +34 -9
  19. package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
  20. package/dist/features/blocks/client/component/BlockContent.js +63 -158
  21. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  22. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +11 -0
  23. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -0
  24. package/dist/features/blocks/client/component/components/BlockCollapsible.js +37 -0
  25. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -0
  26. package/dist/features/blocks/client/component/components/BlockEditButton.d.ts +3 -0
  27. package/dist/features/blocks/client/component/components/BlockEditButton.d.ts.map +1 -0
  28. package/dist/features/blocks/client/component/components/BlockEditButton.js +22 -0
  29. package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -0
  30. package/dist/features/blocks/client/component/components/BlockRemoveButton.d.ts +3 -0
  31. package/dist/features/blocks/client/component/components/BlockRemoveButton.d.ts.map +1 -0
  32. package/dist/features/blocks/client/component/components/BlockRemoveButton.js +22 -0
  33. package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -0
  34. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  35. package/dist/features/blocks/client/component/index.js +242 -63
  36. package/dist/features/blocks/client/component/index.js.map +1 -1
  37. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts +5 -0
  38. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts.map +1 -0
  39. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js +28 -0
  40. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -0
  41. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.d.ts +3 -0
  42. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.d.ts.map +1 -0
  43. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js +22 -0
  44. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -0
  45. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.d.ts +3 -0
  46. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.d.ts.map +1 -0
  47. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js +22 -0
  48. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -0
  49. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.d.ts +3 -0
  50. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.d.ts.map +1 -0
  51. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js +22 -0
  52. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -0
  53. package/dist/features/blocks/client/componentInline/index.d.ts +13 -1
  54. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  55. package/dist/features/blocks/client/componentInline/index.js +219 -43
  56. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  57. package/dist/features/blocks/client/index.d.ts.map +1 -1
  58. package/dist/features/blocks/client/index.js +7 -10
  59. package/dist/features/blocks/client/index.js.map +1 -1
  60. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  61. package/dist/features/blocks/client/nodes/BlocksNode.js +1 -3
  62. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  63. package/dist/features/blocks/client/plugin/commands.d.ts +0 -4
  64. package/dist/features/blocks/client/plugin/commands.d.ts.map +1 -1
  65. package/dist/features/blocks/client/plugin/commands.js +0 -1
  66. package/dist/features/blocks/client/plugin/commands.js.map +1 -1
  67. package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
  68. package/dist/features/blocks/client/plugin/index.js +28 -135
  69. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  70. package/dist/features/blocks/server/index.d.ts.map +1 -1
  71. package/dist/features/blocks/server/index.js +28 -2
  72. package/dist/features/blocks/server/index.js.map +1 -1
  73. package/dist/features/typesClient.d.ts +1 -17
  74. package/dist/features/typesClient.d.ts.map +1 -1
  75. package/dist/features/typesClient.js.map +1 -1
  76. package/dist/field/Field.d.ts.map +1 -1
  77. package/dist/field/Field.js +163 -78
  78. package/dist/field/Field.js.map +1 -1
  79. package/dist/field/bundled.css +1 -1
  80. package/dist/field/rscEntry.d.ts.map +1 -1
  81. package/dist/field/rscEntry.js +23 -1
  82. package/dist/field/rscEntry.js.map +1 -1
  83. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  84. package/dist/lexical/LexicalProvider.js +9 -18
  85. package/dist/lexical/LexicalProvider.js.map +1 -1
  86. package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
  87. package/dist/lexical/config/client/sanitize.js +0 -12
  88. package/dist/lexical/config/client/sanitize.js.map +1 -1
  89. package/dist/types.d.ts +2 -0
  90. package/dist/types.d.ts.map +1 -1
  91. package/dist/types.js.map +1 -1
  92. package/dist/utilities/buildInitialState.d.ts +27 -0
  93. package/dist/utilities/buildInitialState.d.ts.map +1 -0
  94. package/dist/utilities/buildInitialState.js +53 -0
  95. package/dist/utilities/buildInitialState.js.map +1 -0
  96. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  97. package/dist/utilities/fieldsDrawer/DrawerContent.js +8 -5
  98. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  99. package/dist/utilities/fieldsDrawer/useLexicalDrawer.d.ts.map +1 -1
  100. package/dist/utilities/fieldsDrawer/useLexicalDrawer.js +8 -8
  101. package/dist/utilities/fieldsDrawer/useLexicalDrawer.js.map +1 -1
  102. package/package.json +6 -6
  103. package/dist/exports/client/Field-GWJ72IYP.js +0 -2
  104. package/dist/exports/client/Field-GWJ72IYP.js.map +0 -7
  105. package/dist/exports/client/chunk-D7PD5DUW.js +0 -2
  106. package/dist/exports/client/chunk-D7PD5DUW.js.map +0 -7
  107. package/dist/exports/client/chunk-XDEGE6I5.js +0 -2
  108. package/dist/exports/client/chunk-XDEGE6I5.js.map +0 -7
  109. package/dist/exports/client/chunk-YGRKYSDC.js +0 -2
  110. package/dist/exports/client/chunk-YGRKYSDC.js.map +0 -7
  111. package/dist/exports/client/component-KLNTKKNE.js +0 -2
  112. package/dist/exports/client/component-KLNTKKNE.js.map +0 -7
  113. package/dist/exports/client/component-YICNYPTU.js +0 -2
  114. package/dist/exports/client/componentInline-6RPSMLNJ.js +0 -2
  115. package/dist/exports/client/componentInline-6RPSMLNJ.js.map +0 -7
  116. package/dist/features/blocks/client/component/FormSavePlugin.d.ts +0 -11
  117. package/dist/features/blocks/client/component/FormSavePlugin.d.ts.map +0 -1
  118. package/dist/features/blocks/client/component/FormSavePlugin.js +0 -53
  119. package/dist/features/blocks/client/component/FormSavePlugin.js.map +0 -1
@@ -1,2 +0,0 @@
1
- import{createCommand as i}from"lexical";var O=i("INSERT_BLOCK_COMMAND"),x=i("INSERT_INLINE_BLOCK_COMMAND"),I=i("OPEN_INLINE_BLOCK_DRAWER_COMMAND");import{jsx as p}from"react/jsx-runtime";import u from"bson-objectid";import m from"react";import c from"bson-objectid";import{DecoratorNode as l}from"lexical";import{deepCopyObjectSimple as d}from"payload/shared";var r=class extends l{__fields;constructor({fields:e,key:n}){super(n),this.__fields=e}static clone(e){return new this({fields:e.__fields,key:e.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(e){return a(e.fields)}static isInline(){return!1}canIndent(){return!0}createDOM(){let e=document.createElement("span");return e.classList.add("inline-block-container"),e}decorate(e,n){return null}exportDOM(){let e=document.createElement("span");e.classList.add("inline-block-container");let n=document.createTextNode(this.getTextContent());return e.append(n),{element:e}}exportJSON(){return{type:"inlineBlock",fields:this.getFields(),version:1}}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(e){let n=d(e),s=this.getWritable();s.__fields=n}updateDOM(){return!1}};function a(t){return new r({fields:{...t,id:t?.id||new c.default().toHexString()}})}var f=m.lazy(()=>import("./componentInline-6RPSMLNJ.js").then(t=>({default:t.InlineBlockComponent}))),o=class extends r{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return _(e.fields)}decorate(e,n){return p(f,{formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function _(t){return new o({fields:{...t,id:t?.id||new u.default().toHexString()}})}function y(t){return t instanceof o}export{O as a,x as b,I as c,o as d,_ as e,y as f};
2
- //# sourceMappingURL=chunk-YGRKYSDC.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/features/blocks/client/plugin/commands.ts", "../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx", "../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],
4
- "sourcesContent": ["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { createCommand } from 'lexical'\n\nimport type { InsertBlockPayload } from './index.js'\n\nexport const INSERT_BLOCK_COMMAND: LexicalCommand<InsertBlockPayload> =\n createCommand('INSERT_BLOCK_COMMAND')\n\nexport const INSERT_INLINE_BLOCK_COMMAND: LexicalCommand<Partial<InsertBlockPayload>> =\n createCommand('INSERT_INLINE_BLOCK_COMMAND')\n\nexport const OPEN_INLINE_BLOCK_DRAWER_COMMAND: LexicalCommand<{\n fields: Partial<InsertBlockPayload>\n nodeKey?: string\n}> = createCommand('OPEN_INLINE_BLOCK_DRAWER_COMMAND')\n", "'use client'\nimport type {\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\n\nimport ObjectID from 'bson-objectid'\nimport React, { type JSX } from 'react'\n\nimport type { SerializedServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nexport type InlineBlockFields = {\n /** Block form data */\n [key: string]: any\n //blockName: string\n blockType: string\n id: string\n}\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport type SerializedInlineBlockNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static getType(): string {\n return super.getType()\n }\n\n static importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return <InlineBlockComponent formData={this.getFields()} nodeKey={this.getKey()} />\n }\n\n exportJSON(): SerializedServerInlineBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\nimport { deepCopyObjectSimple } from 'payload/shared'\n\nexport type InlineBlockFields = {\n /** Block form data */\n [key: string]: any\n //blockName: string\n blockType: string\n id: string\n}\n\nexport type SerializedServerInlineBlockNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __fields: InlineBlockFields\n\n constructor({ fields, key }: { fields: InlineBlockFields; key?: NodeKey }) {\n super(key)\n this.__fields = fields\n }\n\n static clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'inlineBlock'\n }\n\n static importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static importJSON(serializedNode: SerializedServerInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n exportJSON(): SerializedServerInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n getTextContent(): string {\n return `Block Field`\n }\n\n isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields): void {\n const fieldsCopy = deepCopyObjectSimple(fields)\n\n const writable = this.getWritable()\n writable.__fields = fieldsCopy\n }\n\n updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
5
- "mappings": "AAGA,OAASA,iBAAAA,MAAqB,UAIvB,IAAMC,EACXD,EAAc,sBAAA,EAEHE,EACXF,EAAc,6BAAA,EAEHG,EAGRH,EAAc,kCAAA,0CCPnB,OAAOI,MAAc,gBACrB,OAAOC,MAAyB,QCGhC,OAAOC,MAAc,gBACrB,OAASC,iBAAAA,MAAqB,UAC9B,OAASC,wBAAAA,MAA4B,iBAmB9B,IAAMC,EAAN,cAAoCF,CAAA,CACzCG,SAEAC,YAAY,CAAEC,OAAAA,EAAQC,IAAAA,CAAG,EAAkD,CACzE,MAAMA,CAAA,EACN,KAAKH,SAAWE,CAClB,CAEA,OAAOE,MAAMC,EAAoD,CAC/D,OAAO,IAAI,KAAK,CACdH,OAAQG,EAAKL,SACbG,IAAKE,EAAKC,KACZ,CAAA,CACF,CAEA,OAAOC,SAAkB,CACvB,MAAO,aACT,CAEA,OAAOC,WAAqD,CAC1D,MAAO,CAAC,CACV,CAEA,OAAOC,WAAWC,EAAwE,CAExF,OADaC,EAA6BD,EAAeR,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f,CAEA,OAAOC,WAAWC,EAA4D,CAE5E,OADaC,EAAuBD,EAAeE,MAAM,CAE3D,CAEAC,SAASC,EAAuBC,EAAmC,CACjE,OAAOC,EAAClB,EAAA,CAAqBmB,SAAU,KAAKC,UAAS,EAAIC,QAAS,KAAKC,OAAM,GAC/E,CAEAC,YAA8C,CAC5C,OAAO,MAAMA,WAAA,CACf,CACF,EAEO,SAASV,EAAuBC,EAAwC,CAC7E,OAAO,IAAIR,EAAgB,CACzBQ,OAAQ,CACN,GAAGA,EACHU,GAAIV,GAAQU,IAAM,IAAIC,EAASpB,QAAO,EAAGqB,YAAW,CACtD,CACF,CAAA,CACF,CAEO,SAASC,EACdlB,EAAsD,CAEtD,OAAOA,aAAgBH,CACzB",
6
- "names": ["createCommand", "INSERT_BLOCK_COMMAND", "INSERT_INLINE_BLOCK_COMMAND", "OPEN_INLINE_BLOCK_DRAWER_COMMAND", "ObjectID", "React", "ObjectID", "DecoratorNode", "deepCopyObjectSimple", "ServerInlineBlockNode", "__fields", "constructor", "fields", "key", "clone", "node", "__key", "getType", "importDOM", "importJSON", "serializedNode", "$createServerInlineBlockNode", "isInline", "canIndent", "createDOM", "element", "document", "createElement", "classList", "add", "decorate", "editor", "config", "exportDOM", "text", "createTextNode", "getTextContent", "append", "exportJSON", "type", "getFields", "version", "getLatest", "setFields", "fieldsCopy", "writable", "getWritable", "updateDOM", "id", "default", "toHexString", "InlineBlockComponent", "React", "lazy", "then", "module", "default", "InlineBlockNode", "ServerInlineBlockNode", "clone", "node", "getType", "importJSON", "serializedNode", "$createInlineBlockNode", "fields", "decorate", "editor", "config", "_jsx", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "id", "ObjectID", "toHexString", "$isInlineBlockNode"]
7
- }
@@ -1,2 +0,0 @@
1
- "use client";import{c as L}from"./chunk-D7PD5DUW.js";import{b as D}from"./chunk-CUIBIFW2.js";import{jsx as k,jsxs as ce}from"react/jsx-runtime";import{Collapsible as de,Form as me,Pill as ue,SectionTitle as fe,ShimmerEffect as pe,useDocumentInfo as H,useFormSubmitted as be,useServerFunctions as he,useTranslation as ke}from"@payloadcms/ui";import{abortAndIgnore as j}from"@payloadcms/ui/shared";import{useCallback as ye,useEffect as U,useMemo as _e,useRef as ge,useState as Ce}from"react";import{getTranslation as Se}from"@payloadcms/translations";import{v4 as ve}from"uuid";import{jsx as v,jsxs as w}from"react/jsx-runtime";import{useLexicalComposerContext as Q}from"@lexical/react/LexicalComposerContext.js";import{getTranslation as X}from"@payloadcms/translations";import{Button as Y,Collapsible as Z,ErrorPill as ee,Pill as te,RenderFields as oe,SectionTitle as le,useDocumentInfo as se,useFormSubmitted as re,useTranslation as ne}from"@payloadcms/ui";import{dequal as ie}from"dequal/lite";import{$getNodeByKey as K}from"lexical";import B,{useCallback as E,useEffect as ae}from"react";import{c as W}from"react/compiler-runtime";import{useAllFormFields as z}from"@payloadcms/ui";import{reduceFieldsToValues as G}from"payload/shared";import{useEffect as J}from"react";function M({fields:l}){for(let e in l){let t=l[e];Array.isArray(t.rows)&&"value"in t&&(t.disableFormData=!0)}return l}var V=l=>{let e=W(8),{onChange:t}=l,[r]=z(),m,s;e[0]!==r?(s=M({fields:r}),m=G(s,!0),e[0]=r,e[1]=m,e[2]=s):(m=e[1],s=e[2]);let n=m,o,u;return e[3]!==t||e[4]!==s||e[5]!==n?(o=()=>{t&&t({fullFieldsWithValues:s,newFormData:n})},u=[n,t,s],e[3]=t,e[4]=s,e[5]=n,e[6]=o,e[7]=u):(o=e[6],u=e[7]),J(o,u),null};function R(l){for(let e in l){let t=l[e];Array.isArray(t)&&!t?.length?delete l[e]:t&&typeof t=="object"?R(t):t==null&&delete l[e]}}var q=l=>{let{baseClass:e,clientBlock:t,field:r,formSchema:m,Label:s,nodeKey:n}=l,{formData:o}=l,{i18n:u}=ne(),[p]=Q(),{getDocPreferences:_,setDocFieldPreferences:x}=se(),[F,g]=B.useState();ae(()=>{_().then(a=>{let d=a?.fields[r.name]?.collapsed;g(d?d.includes(o.id):!1)})},[r.name,o.id,_]);let b=re(),[P,N]=B.useState(0),f=b&&P>0,A=[`${e}__row`,f?`${e}__row--has-errors`:`${e}__row--no-errors`].filter(Boolean).join(" "),I=E(({fullFieldsWithValues:a,newFormData:c})=>{if(c.id=o.id,c.blockType=o.blockType,R(c),R(o),ie(o,c)||setTimeout(()=>{p.update(()=>{let d=K(n);d&&L(d)&&(o=c,d.setFields(c))})},0),b){let d=0;for(let C of Object.values(a))C?.valid===!1&&d++;N(d)}},[p,n,b,o]),O=E(a=>{_().then(c=>{let C=c?.fields[r.name]?.collapsed,h=C&&C?.length?C:[];a?h.includes(o.id)||h.push(o.id):h.includes(o.id)&&h.splice(h.indexOf(o.id),1),x(r.name,{collapsed:h,hello:"hi"})})},[_,r.name,x,o.id]),i=E(()=>{p.update(()=>{K(n)?.remove()})},[p,n]);return typeof F!="boolean"?null:w(B.Fragment,{children:[v(Z,{className:A,collapsibleStyle:f?"error":"default",header:s||w("div",{className:`${e}__block-header`,children:[w("div",{children:[v(te,{className:`${e}__block-pill ${e}__block-pill-${o?.blockType}`,pillStyle:"white",children:typeof t?.labels?.singular=="string"?X(t?.labels.singular,u):t.slug}),v(le,{path:"blockName",readOnly:r?.admin?.readOnly||!1}),f&&v(ee,{count:P,i18n:u,withMessage:!0})]}),p.isEditable()&&v(Y,{buttonStyle:"icon-label",className:`${e}__removeButton`,disabled:r?.admin?.readOnly,icon:"x",onClick:a=>{a.preventDefault(),i()},round:!0,tooltip:"Remove Block"})]}),isCollapsed:F,onToggle:a=>{O(a),g(a)},children:v(oe,{fields:m,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:"",permissions:!0})},0),v(V,{onChange:I})]})};var y="lexical-block",Qe=l=>{let{formData:e,nodeKey:t}=l,r=be(),{id:m,collectionSlug:s,globalSlug:n}=H(),{fieldProps:{featureClientSchemaMap:o,field:u,path:p,schemaPath:_}}=D(),x=ge(new AbortController),{docPermissions:F,getDocPreferences:g}=H(),{getFormState:b}=he(),[P,N]=Ce(!1),f=`${_}.lexical_internal_feature.blocks.lexical_blocks.${e.blockType}.fields`,A=`${_}.lexical_internal_feature.blocks.lexical_blocks.${e.blockType}`,i=o.blocks[A][0].blocks[0],{i18n:a}=ke();U(()=>{let $=new AbortController;return e&&(async()=>{let{state:S}=await b({id:m,collectionSlug:s,data:e,docPermissions:{fields:!0},docPreferences:await g(),globalSlug:n,operation:"update",renderAllFields:!0,schemaPath:f,signal:$.signal});S&&(S.blockName={initialValue:"",passesCondition:!0,valid:!0,value:e.blockName},N(S))})(),()=>{j($)}},[b,f,m,s,n,g]);let c=ye(async({formState:$})=>{j(x.current);let T=new AbortController;x.current=T;let{state:S}=await b({id:m,collectionSlug:s,docPermissions:F,docPreferences:await g(),formState:$,globalSlug:n,operation:"update",schemaPath:f,signal:T.signal});return S?(S.blockName={initialValue:"",passesCondition:!0,valid:!0,value:e.blockName},S):$},[b,m,s,F,g,n,f,e.blockName]);U(()=>()=>{j(x.current)},[]);let d=[`${y}__row`,`${y}__row--no-errors`].filter(Boolean).join(" "),C=i?.admin?.components?.Label,h=_e(()=>i&&P!==!1?k(me,{beforeSubmit:[c],fields:i.fields,initialState:P,onChange:[c],submitted:r,uuid:ve(),children:k(q,{baseClass:y,clientBlock:i,field:u,formData:e,formSchema:i.fields,nodeKey:t,path:`${p}.lexical_internal_feature.blocks.${e.blockType}`,schemaPath:f})}):k(de,{className:d,collapsibleStyle:"default",header:i?.admin?.components?.Label?C:k("div",{className:`${y}__block-header`,children:ce("div",{children:[k(ue,{className:`${y}__block-pill ${y}__block-pill-${e?.blockType}`,pillStyle:"white",children:i&&typeof i.labels?.singular=="string"?Se(i.labels.singular,a):i?.slug}),k(fe,{path:"blockName",readOnly:u?.admin?.readOnly||!1})]})}),children:k(pe,{height:"35vh"})},0),[i,P,c,r,u,t,p,f,d,a]);return k("div",{className:y+" "+y+"-"+e.blockType,children:h})};export{Qe as BlockComponent};
2
- //# sourceMappingURL=component-KLNTKKNE.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/features/blocks/client/component/index.tsx", "../../../src/features/blocks/client/component/BlockContent.tsx", "../../../src/features/blocks/client/component/FormSavePlugin.tsx", "../../../src/features/blocks/client/component/removeEmptyArrayValues.ts"],
4
- "sourcesContent": ["'use client'\n\nimport {\n Collapsible,\n Form,\n Pill,\n SectionTitle,\n ShimmerEffect,\n useDocumentInfo,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nconst baseClass = 'lexical-block'\nimport { getTranslation } from '@payloadcms/translations'\nimport { type BlocksFieldClient, type FormState } from 'payload'\nimport { v4 as uuid } from 'uuid'\n\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { BlockContent } from './BlockContent.js'\nimport './index.scss'\n\ntype Props = {\n readonly children?: React.ReactNode\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: { featureClientSchemaMap, field: parentLexicalRichTextField, path, schemaPath },\n } = useEditorConfigContext()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const { docPermissions, getDocPreferences } = useDocumentInfo()\n\n const { getFormState } = useServerFunctions()\n\n const [initialState, setInitialState] = useState<false | FormState | undefined>(false)\n\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}.fields`\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap[\n componentMapRenderedBlockPath\n ][0] as BlocksFieldClient\n\n const clientBlock = blocksField.blocks[0]\n\n const { i18n } = useTranslation()\n\n // Field Schema\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n setInitialState(state)\n }\n }\n\n if (formData) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n id,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state: newFormState } = await getFormState({\n id,\n collectionSlug,\n docPermissions,\n docPreferences: await getDocPreferences(),\n formState: prevFormState,\n globalSlug,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n newFormState.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n docPermissions,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n formData.blockName,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const classNames = [`${baseClass}__row`, `${baseClass}__row--no-errors`].filter(Boolean).join(' ')\n\n const Label = clientBlock?.admin?.components?.Label\n\n // Memoized Form JSX\n const formContent = useMemo(() => {\n return clientBlock && initialState !== false ? (\n <Form\n beforeSubmit={[onChange]}\n fields={clientBlock.fields}\n initialState={initialState}\n onChange={[onChange]}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n clientBlock={clientBlock}\n field={parentLexicalRichTextField}\n formData={formData}\n formSchema={clientBlock.fields}\n nodeKey={nodeKey}\n path={`${path}.lexical_internal_feature.blocks.${formData.blockType}`}\n schemaPath={schemaFieldsPath}\n />\n </Form>\n ) : (\n <Collapsible\n className={classNames}\n collapsibleStyle=\"default\"\n header={\n clientBlock?.admin?.components?.Label ? (\n Label\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {clientBlock && typeof clientBlock.labels?.singular === 'string'\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug}\n </Pill>\n <SectionTitle\n path=\"blockName\"\n readOnly={parentLexicalRichTextField?.admin?.readOnly || false}\n />\n </div>\n </div>\n )\n }\n key={0}\n >\n <ShimmerEffect height=\"35vh\" />\n </Collapsible>\n )\n }, [\n clientBlock,\n initialState,\n onChange,\n submitted,\n parentLexicalRichTextField,\n nodeKey,\n path,\n schemaFieldsPath,\n classNames,\n i18n,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ])\n\n return <div className={baseClass + ' ' + baseClass + '-' + formData.blockType}>{formContent}</div>\n}\n", "'use client'\nimport type { ClientBlock, ClientField, CollapsedPreferences, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n ErrorPill,\n Pill,\n RenderFields,\n SectionTitle,\n useDocumentInfo,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport { dequal } from 'dequal/lite'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useEffect } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../../../../types.js'\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { FormSavePlugin } from './FormSavePlugin.js'\n\ntype Props = {\n baseClass: string\n clientBlock: ClientBlock\n field: LexicalRichTextFieldProps['field']\n formData: BlockFields\n formSchema: ClientField[]\n Label?: React.ReactNode\n nodeKey: string\n path: string\n schemaPath: string\n}\n\n// Recursively remove all undefined values from even being present in formData, as they will\n// cause isDeepEqual to return false if, for example, formData has a key that fields.data\n// does not have, even if it's undefined.\n// Currently, this happens if a block has another sub-blocks field. Inside formData, that sub-blocks field has an undefined blockName property.\n// Inside of fields.data however, that sub-blocks blockName property does not exist at all.\nfunction removeUndefinedAndNullAndEmptyArraysRecursively(obj: object) {\n for (const key in obj) {\n const value = obj[key]\n if (Array.isArray(value) && !value?.length) {\n delete obj[key]\n } else if (value && typeof value === 'object') {\n removeUndefinedAndNullAndEmptyArraysRecursively(value)\n } else if (value === undefined || value === null) {\n delete obj[key]\n }\n }\n}\n\n/**\n * The actual content of the Block. This should be INSIDE a Form component,\n * scoped to the block. All format operations in here are thus scoped to the block's form, and\n * not the whole document.\n */\nexport const BlockContent: React.FC<Props> = (props) => {\n const { baseClass, clientBlock, field, formSchema, Label, nodeKey } = props\n let { formData } = props\n\n const { i18n } = useTranslation()\n const [editor] = useLexicalComposerContext()\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>()\n\n useEffect(() => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n const collapsedArray = currentFieldPreferences?.collapsed\n setIsCollapsed(collapsedArray ? collapsedArray.includes(formData.id) : false)\n })\n }, [field.name, formData.id, getDocPreferences])\n\n const hasSubmitted = useFormSubmitted()\n\n const [errorCount, setErrorCount] = React.useState(0)\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n\n const classNames = [\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ]\n .filter(Boolean)\n .join(' ')\n\n const onFormChange = useCallback(\n ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: BlockFields\n }) => {\n newFormData.id = formData.id\n newFormData.blockType = formData.blockType\n\n removeUndefinedAndNullAndEmptyArraysRecursively(newFormData)\n removeUndefinedAndNullAndEmptyArraysRecursively(formData)\n\n // Only update if the data has actually changed. Otherwise, we may be triggering an unnecessary value change,\n // which would trigger the \"Leave without saving\" dialog unnecessarily\n if (!dequal(formData, newFormData)) {\n // Running this in the next tick in the meantime fixes this issue: https://github.com/payloadcms/payload/issues/4108\n // I don't know why. When this is called immediately, it might focus out of a nested lexical editor field if an update is made there.\n // My hypothesis is that the nested editor might not have fully finished its update cycle yet. By updating in the next tick, we\n // ensure that the nested editor has finished its update cycle before we update the block node.\n setTimeout(() => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n formData = newFormData\n node.setFields(newFormData)\n }\n })\n }, 0)\n }\n\n // update error count\n if (hasSubmitted) {\n let rowErrorCount = 0\n for (const formField of Object.values(fullFieldsWithValues)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n },\n [editor, nodeKey, hasSubmitted, formData],\n )\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(field.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, field.name, setDocFieldPreferences, formData.id],\n )\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n if (typeof isCollapsed !== 'boolean') {\n return null\n }\n\n return (\n <React.Fragment>\n <Collapsible\n className={classNames}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n Label || (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {typeof clientBlock?.labels?.singular === 'string'\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock.slug}\n </Pill>\n <SectionTitle path=\"blockName\" readOnly={field?.admin?.readOnly || false} />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n {editor.isEditable() && (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n )}\n </div>\n )\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n <RenderFields\n fields={formSchema}\n forceRender={true}\n parentIndexPath=\"\"\n parentPath={''}\n parentSchemaPath=\"\"\n permissions={true}\n />\n </Collapsible>\n\n <FormSavePlugin onChange={onFormChange} />\n </React.Fragment>\n )\n}\n", "'use client'\nimport type { Data, FormState } from 'payload'\nimport type React from 'react'\n\nimport { useAllFormFields } from '@payloadcms/ui'\nimport { reduceFieldsToValues } from 'payload/shared'\nimport { useEffect } from 'react'\n\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n onChange?: ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: Data\n }) => void\n}\n\nexport const FormSavePlugin: React.FC<Props> = (props) => {\n const { onChange } = props\n\n const [_fields] = useAllFormFields()\n\n const fields = removeEmptyArrayValues({ fields: _fields })\n\n // Pass in fields, and indicate if you'd like to \"unflatten\" field data.\n // The result below will reflect the data stored in the form at the given time\n const newFormData = reduceFieldsToValues(fields, true)\n\n useEffect(() => {\n if (onChange) {\n onChange({ fullFieldsWithValues: fields, newFormData })\n }\n }, [newFormData, onChange, fields])\n\n return null\n}\n", "'use client'\nimport type { FormState } from 'payload'\n\n/**\n * By default, if an array field is empty, it will be included in the form state with a value of 0.\n * We do not need this behavior here, By setting `disableFormData` to true, we can prevent the field from being included in the form state\n * like that.\n * @param fields form state\n */\nexport function removeEmptyArrayValues({ fields }: { fields: FormState }): FormState {\n for (const key in fields) {\n const field = fields[key]\n if (Array.isArray(field.rows) && 'value' in field) {\n field.disableFormData = true\n }\n }\n return fields\n}\n"],
5
- "mappings": "gJAEA,OACEA,eAAAA,GACAC,QAAAA,GACAC,QAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,mBAAAA,EACAC,oBAAAA,GACAC,sBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,kBAAAA,MAAsB,wBAC/B,OAAgBC,eAAAA,GAAaC,aAAAA,EAAWC,WAAAA,GAASC,UAAAA,GAAQC,YAAAA,OAAgB,QAGzE,OAASC,kBAAAA,OAAsB,2BAE/B,OAASC,MAAMC,OAAY,yDChB3B,OAASC,6BAAAA,MAAiC,2CAC1C,OAASC,kBAAAA,MAAsB,2BAC/B,OACEC,UAAAA,EACAC,eAAAA,EACAC,aAAAA,GACAC,QAAAA,GACAC,gBAAAA,GACAC,gBAAAA,GACAC,mBAAAA,GACA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AU,iBAET/C,GAAe,OAAOA,EAAYgD,QAAQC,UAAa,SACpDC,GAAelD,EAAYgD,OAAOC,SAAU/C,CAAA,EAC5CF,GAAamD,OAEnBhB,EAACiB,GAAA,CACCpE,KAAK,YACLqE,SAAUtE,GAA4BgD,OAAOsB,UAAY,mBAQnElB,EAACmB,GAAA,CAAcC,OAAO,UAFjB,CAAA,EAKR,CACDvD,EACAN,EACAyB,EACA7C,EACAS,EACAV,EACAW,EACAa,EACA6B,EACAxB,CAAA,CAED,EAED,OAAOiC,EAAC,MAAA,CAAIO,UAAWzE,EAAY,IAAMA,EAAY,IAAMG,EAAS0B,mBAAYmC,GAClF",
6
- "names": ["Collapsible", "Form", "Pill", "SectionTitle", "ShimmerEffect", "useDocumentInfo", "useFormSubmitted", "useServerFunctions", "useTranslation", "abortAndIgnore", "useCallback", "useEffect", "useMemo", "useRef", "useState", "getTranslation", "v4", "uuid", "useLexicalComposerContext", "getTranslation", "Button", "Collapsible", "ErrorPill", "Pill", "RenderFields", "SectionTitle", "useDocumentInfo", "useFormSubmitted", "useTranslation", "dequal", "$getNodeByKey", "React", "useCallback", "useEffect", "c", "_c", "useAllFormFields", "reduceFieldsToValues", "useEffect", "removeEmptyArrayValues", "fields", "key", "field", "Array", "isArray", "rows", "disableFormData", "FormSavePlugin", "props", "$", "_c", "onChange", "_fields", "useAllFormFields", "t0", "fields", "removeEmptyArrayValues", "reduceFieldsToValues", "newFormData", "t1", "t2", "fullFieldsWithValues", "useEffect", "removeUndefinedAndNullAndEmptyArraysRecursively", "obj", "key", "value", "Array", "isArray", "length", "BlockContent", "props", "baseClass", "clientBlock", "field", "formSchema", "Label", "nodeKey", "formData", "i18n", "useTranslation", "editor", "useLexicalComposerContext", "getDocPreferences", "setDocFieldPreferences", "useDocumentInfo", "isCollapsed", "setIsCollapsed", "React", "useState", "useEffect", "then", "currentDocPreferences", "collapsedArray", "fields", "name", "collapsed", "includes", "id", "hasSubmitted", "useFormSubmitted", "errorCount", "setErrorCount", "fieldHasErrors", "classNames", "filter", "Boolean", "join", "onFormChange", "useCallback", "fullFieldsWithValues", "newFormData", "blockType", "dequal", "setTimeout", "update", "node", "$getNodeByKey", "$isBlockNode", "setFields", "rowErrorCount", "formField", "Object", "values", "valid", "onCollapsedChange", "changedCollapsed", "newCollapsed", "push", "splice", "indexOf", "hello", "removeBlock", "remove", "_jsxs", "Fragment", "_jsx", "Collapsible", "className", "collapsibleStyle", "header", "Pill", "pillStyle", "labels", "singular", "getTranslation", "slug", "SectionTitle", "path", "readOnly", "admin", "ErrorPill", "count", "withMessage", "isEditable", "Button", "buttonStyle", "disabled", "icon", "onClick", "e", "preventDefault", "round", "tooltip", "onToggle", "incomingCollapsedState", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "permissions", "FormSavePlugin", "onChange", "baseClass", "BlockComponent", "props", "formData", "nodeKey", "submitted", "useFormSubmitted", "id", "collectionSlug", "globalSlug", "useDocumentInfo", "fieldProps", "featureClientSchemaMap", "field", "parentLexicalRichTextField", "path", "schemaPath", "useEditorConfigContext", "onChangeAbortControllerRef", "useRef", "AbortController", "docPermissions", "getDocPreferences", "getFormState", "useServerFunctions", "initialState", "setInitialState", "useState", "schemaFieldsPath", "blockType", "componentMapRenderedBlockPath", "clientBlock", "blocks", "i18n", "useTranslation", "useEffect", "abortController", "state", "data", "fields", "docPreferences", "operation", "renderAllFields", "signal", "blockName", "initialValue", "passesCondition", "valid", "value", "abortAndIgnore", "onChange", "useCallback", "formState", "prevFormState", "current", "controller", "newFormState", "classNames", "filter", "Boolean", "join", "Label", "admin", "components", "formContent", "useMemo", "_jsx", "Form", "beforeSubmit", "uuid", "BlockContent", "formSchema", "Collapsible", "className", "collapsibleStyle", "header", "_jsxs", "Pill", "pillStyle", "labels", "singular", "getTranslation", "slug", "SectionTitle", "readOnly", "ShimmerEffect", "height"]
7
- }
@@ -1,2 +0,0 @@
1
- "use client";import{a as y,b as M,c as A,d as T,g as O}from"./chunk-XDEGE6I5.js";import{a as U}from"./chunk-5PBXL4HT.js";import{b}from"./chunk-CUIBIFW2.js";import{jsx as e,jsxs as c}from"react/jsx-runtime";import{useLexicalComposerContext as ae}from"@lexical/react/LexicalComposerContext.js";import{useLexicalNodeSelection as le}from"@lexical/react/useLexicalNodeSelection.js";import{mergeRegister as re}from"@lexical/utils";import{getTranslation as F}from"@payloadcms/translations";import{Button as C,File as se,formatDrawerSlug as ie,useConfig as ne,useEditDepth as ce,usePayloadAPI as de,useTranslation as ue}from"@payloadcms/ui";import{$getNodeByKey as I,$getSelection as me,$isNodeSelection as pe,CLICK_COMMAND as fe,COMMAND_PRIORITY_LOW as w,KEY_BACKSPACE_COMMAND as ge,KEY_DELETE_COMMAND as he}from"lexical";import{useCallback as f,useEffect as _e,useId as De,useReducer as be,useRef as Ce,useState as we}from"react";var o="lexical-upload",K={depth:0},Ne=d=>{let{data:{fields:j,relationTo:N,value:n},nodeKey:l}=d;if(typeof n=="object")throw new Error("Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.");let{config:{collections:B,routes:{api:k},serverURL:W}}=ne(),g=Ce(null),{uuid:Y}=b(),z=ce(),[a]=ae(),[r,h,x]=le(l),{editorConfig:H,fieldProps:{readOnly:_,schemaPath:q}}=b(),{i18n:S,t:u}=ue(),[$,G]=be(t=>t+1,0),[s]=we(()=>B.find(t=>t.slug===N)),J=De(),v=ie({slug:"lexical-upload-drawer-"+Y+J,depth:z}),{toggleDrawer:Q}=M(v,!0),{closeDocumentDrawer:E,DocumentDrawer:V,DocumentDrawerToggler:X}=U({id:n,collectionSlug:s.slug}),[{data:m},{setParams:R}]=de(`${W}${k}/${s.slug}/${n}`,{initialParams:K}),L=m?.thumbnailURL||m?.url,Z=f(()=>{a.update(()=>{I(l)?.remove()})},[a,l]),ee=f(t=>{R({...K,cacheBust:$}),G(),E()},[R,$,E]),D=f(t=>{let p=me();return r&&pe(p)&&(t.preventDefault(),a.update(()=>{p.getNodes().forEach(i=>{O(i)&&i.remove()})})),!1},[a,r]);_e(()=>re(a.registerCommand(fe,t=>t.target===g.current||g.current?.contains(t.target)?(t.shiftKey?h(!r):r||(x(),h(!0)),!0):!1,w),a.registerCommand(he,D,w),a.registerCommand(ge,D,w)),[x,a,r,l,D,h]);let P=H?.resolvedFeatureMap?.get("upload")?.sanitizedClientFeatureProps.collections?.[s.slug]?.hasExtraFields,te=f((t,p)=>{a.update(()=>{let i=I(l);if(i){let oe={...i.getData(),fields:p};i.setData(oe)}})},[a,l]);return c("div",{className:[o,r&&`${o}--selected`].filter(Boolean).join(" "),contentEditable:!1,ref:g,children:[c("div",{className:`${o}__card`,children:[c("div",{className:`${o}__topRow`,children:[e("div",{className:`${o}__thumbnail`,children:L?e("img",{alt:m?.filename,"data-lexical-upload-id":n,"data-lexical-upload-relation-to":N,src:L}):e(se,{})}),c("div",{className:`${o}__topRowRightPanel`,children:[e("div",{className:`${o}__collectionLabel`,children:F(s.labels.singular,S)}),a.isEditable()&&c("div",{className:`${o}__actions`,children:[P?e(C,{buttonStyle:"icon-label",className:`${o}__upload-drawer-toggler`,disabled:_,el:"button",icon:"edit",onClick:()=>{Q()},round:!0,tooltip:u("fields:editRelationship")}):null,e(C,{buttonStyle:"icon-label",className:`${o}__swap-drawer-toggler`,disabled:_,el:"button",icon:"swap",onClick:()=>{a.dispatchCommand(T,{replace:{nodeKey:l}})},round:!0,tooltip:u("fields:swapUpload")}),e(C,{buttonStyle:"icon-label",className:`${o}__removeButton`,disabled:_,icon:"x",onClick:t=>{t.preventDefault(),Z()},round:!0,tooltip:u("fields:removeUpload")})]})]})]}),e("div",{className:`${o}__bottomRow`,children:e(X,{className:`${o}__doc-drawer-toggler`,children:e("strong",{children:m?.filename})})})]}),n?e(V,{onSave:ee}):null,P?e(y,{data:j,drawerSlug:v,drawerTitle:u("general:editLabel",{label:F(s.labels.singular,S)}),featureKey:"upload",handleDrawerSubmit:te,schemaPath:q,schemaPathSuffix:s.slug}):null]})},Ke=d=>e(A,{...d,uploads:!0,children:e(Ne,{...d})});export{Ke as UploadComponent};
2
- //# sourceMappingURL=component-YICNYPTU.js.map
@@ -1,2 +0,0 @@
1
- "use client";import{c as x,f as M}from"./chunk-YGRKYSDC.js";import{b as E}from"./chunk-CUIBIFW2.js";import{jsx as u,jsxs as S}from"react/jsx-runtime";import{useCallback as f,useEffect as R,useRef as A}from"react";import{useLexicalComposerContext as I}from"@lexical/react/LexicalComposerContext";import{useLexicalNodeSelection as K}from"@lexical/react/useLexicalNodeSelection";import{mergeRegister as P}from"@lexical/utils";import{getTranslation as h}from"@payloadcms/translations";import{Button as v,useTranslation as T}from"@payloadcms/ui";import{$getNodeByKey as j,$getSelection as Y,$isNodeSelection as z,CLICK_COMMAND as F,COMMAND_PRIORITY_LOW as p,KEY_BACKSPACE_COMMAND as W,KEY_DELETE_COMMAND as q}from"lexical";var l="inline-block",ie=D=>{let{formData:r,nodeKey:n}=D,[e]=I(),{i18n:b,t:C}=T(),{fieldProps:{featureClientSchemaMap:$,readOnly:k,schemaPath:y}}=E(),a=A(null),[o,c,m]=K(n),O=`${y}.lexical_internal_feature.blocks.lexical_inline_blocks.${r.blockType}`,i=$.blocks[O][0].blocks[0],L=f(()=>{e.update(()=>{j(n)?.remove()})},[e,n]),d=f(s=>{let t=Y();return o&&z(t)&&(s.preventDefault(),e.update(()=>{t.getNodes().forEach(B=>{M(B)&&B.remove()})})),!1},[e,o]),_=f(s=>{let t=s;return t.target===a.current||a.current?.contains(t.target)?(t.shiftKey?c(!o):o||(m(),c(!0)),!0):!1},[o,c,m]);R(()=>P(e.registerCommand(F,_,p),e.registerCommand(q,d,p),e.registerCommand(W,d,p)),[m,e,o,n,d,c,_]);let N=i?.labels?.singular?h(i.labels.singular,b):i?.slug,g=i?.admin?.components?.Label;return S("div",{className:[l,l+"-"+r.blockType,o&&`${l}--selected`].filter(Boolean).join(" "),ref:a,children:[g||u("div",{children:h(i.labels.singular,b)}),e.isEditable()&&S("div",{className:`${l}__actions`,children:[u(v,{buttonStyle:"icon-label",className:`${l}__editButton`,disabled:k,el:"div",icon:"edit",onClick:()=>{e.dispatchCommand(x,{fields:r,nodeKey:n})},round:!0,size:"small",tooltip:C("lexical:blocks:inlineBlocks:edit",{label:N})}),u(v,{buttonStyle:"icon-label",className:`${l}__removeButton`,disabled:k,icon:"x",onClick:s=>{s.preventDefault(),L()},round:!0,size:"small",tooltip:C("lexical:blocks:inlineBlocks:remove",{label:N})})]})]})};export{ie as InlineBlockComponent};
2
- //# sourceMappingURL=componentInline-6RPSMLNJ.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/features/blocks/client/componentInline/index.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport React, { useCallback, useEffect, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, useTranslation } from '@payloadcms/ui'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\n\nimport type { InlineBlockFields } from '../nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\nimport { OPEN_INLINE_BLOCK_DRAWER_COMMAND } from '../plugin/commands.js'\nimport './index.scss'\n\ntype Props = {\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n fieldProps: { featureClientSchemaMap, readOnly, schemaPath },\n } = useEditorConfigContext()\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap[\n componentMapRenderedBlockPath\n ][0] as BlocksFieldClient\n\n const clientBlock = blocksField.blocks[0]\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isInlineBlockNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if inlineBlockElemElemRef.target or anything WITHIN inlineBlockElemElemRef.target was clicked\n if (\n event.target === inlineBlockElemElemRef.current ||\n inlineBlockElemElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const Label = clientBlock?.admin?.components?.Label\n\n return (\n <div\n className={[\n baseClass,\n baseClass + '-' + formData.blockType,\n isSelected && `${baseClass}--selected`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {Label ? Label : <div>{getTranslation(clientBlock.labels!.singular, i18n)}</div>}\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={readOnly}\n el=\"div\"\n icon=\"edit\"\n onClick={() => {\n editor.dispatchCommand(OPEN_INLINE_BLOCK_DRAWER_COMMAND, {\n fields: formData,\n nodeKey,\n })\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n </div>\n )}\n </div>\n )\n}\n"],
5
- "mappings": "sJAEA,OAAgBA,eAAAA,EAAaC,aAAAA,EAAWC,UAAAA,MAAc,QAKtD,OAASC,6BAAAA,MAAiC,wCAC1C,OAASC,2BAAAA,MAA+B,yCACxC,OAASC,iBAAAA,MAAqB,iBAC9B,OAASC,kBAAAA,MAAsB,2BAC/B,OAASC,UAAAA,EAAQC,kBAAAA,MAAsB,iBACvC,OACEC,iBAAAA,EACAC,iBAAAA,EACAC,oBAAAA,EACAC,iBAAAA,EACAC,wBAAAA,EACAC,yBAAAA,EACAC,sBAAAA,MACK,UAjBP,IAAMC,EAAY,eA+BLC,GAAyCC,GAAA,CACpD,GAAM,CAAEC,SAAAA,EAAUC,QAAAA,CAAO,EAAKF,EACxB,CAACG,CAAA,EAAUC,EAAA,EACX,CAAEC,KAAAA,EAAMC,EAAAA,CAAC,EAAKC,EAAA,EACd,CACJC,WAAY,CA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Ma,EAAmB9B,GAAa+B,QAAQC,SAC1CC,EAAejC,EAAY+B,OAAOC,SAAUhD,CAAA,EAC5CgB,GAAakC,KAEXC,EAAQnC,GAAaoC,OAAOC,YAAYF,MAE9C,OACEG,EAAC,MAAA,CACCC,UAAW,CACT9D,EACAA,EAAY,IAAMG,EAASmB,UAC3BL,GAAc,GAAGjB,CAAA,YAAqB,EAErC+D,OAAOC,OAAA,EACPC,KAAK,GAAA,EACRC,IAAKnD,YAEJ2C,GAAgBS,EAAC,MAAA,UAAKX,EAAejC,EAAY+B,OAAQC,SAAUhD,CAAA,IACnEF,EAAO+D,WAAU,GAChBP,EAAC,MAAA,CAAIC,UAAW,GAAG9D,CAAA,sBACjBmE,EAACE,EAAA,CACCC,YAAY,aACZR,UAAW,GAAG9D,CAAA,eACduE,SAAU3D,EACV4D,GAAG,MACHC,KAAK,OACLjC,QAASA,IAAA,CACPnC,EAAOqE,gBAAgBC,EAAkC,CACvDC,OAAQzE,EACRC,QAAAA,CACF,CAAA,CACF,EACAyE,MAAK,GACLC,KAAK,QACLC,QAASvE,EAAE,mCAAoC,CAAEwE,MAAO3B,CAAiB,CAAA,IAE3Ec,EAACE,EAAA,CACCC,YAAY,aACZR,UAAW,GAAG9D,CAAA,iBACduE,SAAU3D,EACV6D,KAAK,IACLjC,QAAUyC,GAAA,CACRA,EAAE9C,eAAc,EAChBV,EAAA,CACF,EACAoD,MAAK,GACLC,KAAK,QACLC,QAASvE,EAAE,qCAAsC,CAAEwE,MAAO3B,CAAiB,CAAA,SAMvF",
6
- "names": ["useCallback", "useEffect", "useRef", "useLexicalComposerContext", "useLexicalNodeSelection", "mergeRegister", "getTranslation", "Button", "useTranslation", "$getNodeByKey", "$getSelection", "$isNodeSelection", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_BACKSPACE_COMMAND", "KEY_DELETE_COMMAND", "baseClass", "InlineBlockComponent", "props", "formData", "nodeKey", "editor", "useLexicalComposerContext", "i18n", "t", "useTranslation", "fieldProps", "featureClientSchemaMap", "readOnly", "schemaPath", "useEditorConfigContext", "inlineBlockElemElemRef", "useRef", "isSelected", "setSelected", "clearSelection", "useLexicalNodeSelection", "componentMapRenderedBlockPath", "blockType", "clientBlock", "blocks", "removeInlineBlock", "useCallback", "update", "$getNodeByKey", "remove", "$onDelete", "event", "deleteSelection", "$getSelection", "$isNodeSelection", "preventDefault", "getNodes", "forEach", "node", "$isInlineBlockNode", "onClick", "payload", "target", "current", "contains", "shiftKey", "useEffect", "mergeRegister", "registerCommand", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_DELETE_COMMAND", "KEY_BACKSPACE_COMMAND", "blockDisplayName", "labels", "singular", "getTranslation", "slug", "Label", "admin", "components", "_jsxs", "className", "filter", "Boolean", "join", "ref", "_jsx", "isEditable", "Button", "buttonStyle", "disabled", "el", "icon", "dispatchCommand", "OPEN_INLINE_BLOCK_DRAWER_COMMAND", "fields", "round", "size", "tooltip", "label", "e"]
7
- }
@@ -1,11 +0,0 @@
1
- import type { Data, FormState } from 'payload';
2
- import type React from 'react';
3
- type Props = {
4
- onChange?: ({ fullFieldsWithValues, newFormData, }: {
5
- fullFieldsWithValues: FormState;
6
- newFormData: Data;
7
- }) => void;
8
- };
9
- export declare const FormSavePlugin: React.FC<Props>;
10
- export {};
11
- //# sourceMappingURL=FormSavePlugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormSavePlugin.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/FormSavePlugin.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,CAAC,EACV,oBAAoB,EACpB,WAAW,GACZ,EAAE;QACD,oBAAoB,EAAE,SAAS,CAAA;QAC/B,WAAW,EAAE,IAAI,CAAA;KAClB,KAAK,IAAI,CAAA;CACX,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAkB1C,CAAA"}
@@ -1,53 +0,0 @@
1
- 'use client';
2
-
3
- import { c as _c } from "react/compiler-runtime";
4
- import { useAllFormFields } from '@payloadcms/ui';
5
- import { reduceFieldsToValues } from 'payload/shared';
6
- import { useEffect } from 'react';
7
- import { removeEmptyArrayValues } from './removeEmptyArrayValues.js';
8
- export const FormSavePlugin = props => {
9
- const $ = _c(8);
10
- const {
11
- onChange
12
- } = props;
13
- const [_fields] = useAllFormFields();
14
- let t0;
15
- let fields;
16
- if ($[0] !== _fields) {
17
- fields = removeEmptyArrayValues({
18
- fields: _fields
19
- });
20
- t0 = reduceFieldsToValues(fields, true);
21
- $[0] = _fields;
22
- $[1] = t0;
23
- $[2] = fields;
24
- } else {
25
- t0 = $[1];
26
- fields = $[2];
27
- }
28
- const newFormData = t0;
29
- let t1;
30
- let t2;
31
- if ($[3] !== onChange || $[4] !== fields || $[5] !== newFormData) {
32
- t1 = () => {
33
- if (onChange) {
34
- onChange({
35
- fullFieldsWithValues: fields,
36
- newFormData
37
- });
38
- }
39
- };
40
- t2 = [newFormData, onChange, fields];
41
- $[3] = onChange;
42
- $[4] = fields;
43
- $[5] = newFormData;
44
- $[6] = t1;
45
- $[7] = t2;
46
- } else {
47
- t1 = $[6];
48
- t2 = $[7];
49
- }
50
- useEffect(t1, t2);
51
- return null;
52
- };
53
- //# sourceMappingURL=FormSavePlugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormSavePlugin.js","names":["c","_c","useAllFormFields","reduceFieldsToValues","useEffect","removeEmptyArrayValues","FormSavePlugin","props","$","onChange","_fields","t0","fields","newFormData","t1","t2","fullFieldsWithValues"],"sources":["../../../../../src/features/blocks/client/component/FormSavePlugin.tsx"],"sourcesContent":["'use client'\nimport type { Data, FormState } from 'payload'\nimport type React from 'react'\n\nimport { useAllFormFields } from '@payloadcms/ui'\nimport { reduceFieldsToValues } from 'payload/shared'\nimport { useEffect } from 'react'\n\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n onChange?: ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: Data\n }) => void\n}\n\nexport const FormSavePlugin: React.FC<Props> = (props) => {\n const { onChange } = props\n\n const [_fields] = useAllFormFields()\n\n const fields = removeEmptyArrayValues({ fields: _fields })\n\n // Pass in fields, and indicate if you'd like to \"unflatten\" field data.\n // The result below will reflect the data stored in the form at the given time\n const newFormData = reduceFieldsToValues(fields, true)\n\n useEffect(() => {\n if (onChange) {\n onChange({ fullFieldsWithValues: fields, newFormData })\n }\n }, [newFormData, onChange, fields])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,gBAAgB,QAAQ;AACjC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,SAAS,QAAQ;AAE1B,SAASC,sBAAsB,QAAQ;AAYvC,OAAO,MAAMC,cAAA,GAAkCC,KAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EAC7C;IAAAQ;EAAA,IAAqBF,KAAA;EAErB,OAAAG,OAAA,IAAkBR,gBAAA;EAAA,IAAAS,EAAA;EAAA,IAAAC,MAAA;EAAA,IAAAJ,CAAA,QAAAE,OAAA;IAElBE,MAAA,GAAeP,sBAAA;MAAAO,MAAA,EAAiCF;IAAA,CAAQ;IAIpCC,EAAA,GAAAR,oBAAA,CAAqBS,MAAA,MAAQ;IAAAJ,CAAA,MAAAE,OAAA;IAAAF,CAAA,MAAAG,EAAA;IAAAH,CAAA,MAAAI,MAAA;EAAA;IAAAD,EAAA,GAAAH,CAAA;IAAAI,MAAA,GAAAJ,CAAA;EAAA;EAAjD,MAAAK,WAAA,GAAoBF,EAA6B;EAAA,IAAAG,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAP,CAAA,QAAAC,QAAA,IAAAD,CAAA,Q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