@payloadcms/richtext-slate 3.0.0-beta.127 → 3.0.0-beta.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cell/rscEntry.d.ts +8 -0
- package/dist/cell/rscEntry.d.ts.map +1 -0
- package/dist/cell/rscEntry.js +51 -0
- package/dist/cell/rscEntry.js.map +1 -0
- package/dist/exports/client/index.d.ts +0 -1
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +0 -1
- package/dist/exports/client/index.js.map +1 -1
- package/dist/exports/server/rsc.d.ts +3 -0
- package/dist/exports/server/rsc.d.ts.map +1 -0
- package/dist/exports/server/rsc.js +4 -0
- package/dist/exports/server/rsc.js.map +1 -0
- package/dist/field/RichText.d.ts.map +1 -1
- package/dist/field/RichText.js +26 -43
- package/dist/field/RichText.js.map +1 -1
- package/dist/field/createFeatureMap.d.ts +2 -2
- package/dist/field/createFeatureMap.d.ts.map +1 -1
- package/dist/field/createFeatureMap.js +3 -0
- package/dist/field/createFeatureMap.js.map +1 -1
- package/dist/field/elements/link/Button/index.d.ts +3 -1
- package/dist/field/elements/link/Button/index.d.ts.map +1 -1
- package/dist/field/elements/link/Button/index.js +19 -15
- package/dist/field/elements/link/Button/index.js.map +1 -1
- package/dist/field/elements/link/Element/index.d.ts.map +1 -1
- package/dist/field/elements/link/Element/index.js +21 -17
- package/dist/field/elements/link/Element/index.js.map +1 -1
- package/dist/field/elements/link/LinkDrawer/index.d.ts.map +1 -1
- package/dist/field/elements/link/LinkDrawer/index.js +47 -42
- package/dist/field/elements/link/LinkDrawer/index.js.map +1 -1
- package/dist/field/elements/link/LinkDrawer/types.d.ts +1 -0
- package/dist/field/elements/link/LinkDrawer/types.d.ts.map +1 -1
- package/dist/field/elements/link/LinkDrawer/types.js.map +1 -1
- package/dist/field/elements/relationship/Element/index.d.ts +1 -7
- package/dist/field/elements/relationship/Element/index.d.ts.map +1 -1
- package/dist/field/elements/relationship/Element/index.js.map +1 -1
- package/dist/field/elements/upload/Element/UploadDrawer/index.d.ts.map +1 -1
- package/dist/field/elements/upload/Element/UploadDrawer/index.js +64 -55
- package/dist/field/elements/upload/Element/UploadDrawer/index.js.map +1 -1
- package/dist/field/elements/upload/Element/index.d.ts +1 -7
- package/dist/field/elements/upload/Element/index.d.ts.map +1 -1
- package/dist/field/elements/upload/Element/index.js +27 -23
- package/dist/field/elements/upload/Element/index.js.map +1 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +15 -13
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +7 -0
- package/dist/field/rscEntry.d.ts.map +1 -0
- package/dist/field/rscEntry.js +132 -0
- package/dist/field/rscEntry.js.map +1 -0
- package/dist/field/types.d.ts +5 -6
- package/dist/field/types.d.ts.map +1 -1
- package/dist/field/types.js.map +1 -1
- package/dist/generateSchemaMap.d.ts.map +1 -1
- package/dist/generateSchemaMap.js +30 -5
- package/dist/generateSchemaMap.js.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/SlatePropsProvider.d.ts +11 -0
- package/dist/utilities/SlatePropsProvider.d.ts.map +1 -0
- package/dist/utilities/SlatePropsProvider.js +21 -0
- package/dist/utilities/SlatePropsProvider.js.map +1 -0
- package/dist/utilities/useSlatePlugin.d.ts.map +1 -1
- package/dist/utilities/useSlatePlugin.js +3 -2
- package/dist/utilities/useSlatePlugin.js.map +1 -1
- package/license.md +22 -0
- package/package.json +16 -9
- package/dist/cell/index.d.ts +0 -4
- package/dist/cell/index.d.ts.map +0 -1
- package/dist/cell/index.js +0 -35
- package/dist/cell/index.js.map +0 -1
- package/dist/generateComponentMap.d.ts +0 -4
- package/dist/generateComponentMap.d.ts.map +0 -1
- package/dist/generateComponentMap.js +0 -94
- package/dist/generateComponentMap.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/elements/link/Button/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormState } from 'payload'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/elements/link/Button/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormState } from 'payload'\n\nimport {\n useDocumentInfo,\n useDrawerSlug,\n useModal,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { reduceFieldsToValues } from 'payload/shared'\nimport React, { Fragment, useState } from 'react'\nimport { Editor, Range, Transforms } from 'slate'\nimport { ReactEditor, useSlate } from 'slate-react'\n\nimport { LinkIcon } from '../../../icons/Link/index.js'\nimport { useElementButton } from '../../../providers/ElementButtonProvider.js'\nimport { ElementButton } from '../../Button.js'\nimport { isElementActive } from '../../isActive.js'\nimport { LinkDrawer } from '../LinkDrawer/index.js'\nimport { linkFieldsSchemaPath } from '../shared.js'\nimport { unwrapLink } from '../utilities.js'\n\n/**\n * This function is called when a new link is created - not when an existing link is edited.\n */\nconst insertLink = (editor, fields) => {\n const isCollapsed = editor.selection && Range.isCollapsed(editor.selection)\n const data = reduceFieldsToValues(fields, true)\n\n const newLink = {\n type: 'link',\n children: [],\n doc: data.doc,\n fields: data.fields, // Any custom user-added fields are part of data.fields\n linkType: data.linkType,\n newTab: data.newTab,\n url: data.url,\n }\n\n if (isCollapsed || !editor.selection) {\n // If selection anchor and focus are the same,\n // Just inject a new node with children already set\n Transforms.insertNodes(editor, {\n ...newLink,\n children: [{ text: String(data.text) }],\n })\n } else if (editor.selection) {\n // Otherwise we need to wrap the selected node in a link,\n // Delete its old text,\n // Move the selection one position forward into the link,\n // And insert the text back into the new link\n Transforms.wrapNodes(editor, newLink, { split: true })\n Transforms.delete(editor, { at: editor.selection.focus.path, unit: 'word' })\n Transforms.move(editor, { distance: 1, unit: 'offset' })\n Transforms.insertText(editor, String(data.text), { at: editor.selection.focus.path })\n }\n\n ReactEditor.focus(editor)\n}\n\nexport const LinkButton: React.FC<{\n schemaPath: string\n}> = ({ schemaPath }) => {\n const { fieldProps } = useElementButton()\n const [initialState, setInitialState] = useState<FormState>({})\n\n const { t } = useTranslation()\n const editor = useSlate()\n const { getFormState } = useServerFunctions()\n const { collectionSlug, docPermissions, getDocPreferences, globalSlug } = useDocumentInfo()\n\n const { closeModal, openModal } = useModal()\n const drawerSlug = useDrawerSlug('rich-text-link')\n\n const { componentMap } = fieldProps\n\n const fields = componentMap[linkFieldsSchemaPath]\n\n return (\n <Fragment>\n <ElementButton\n className=\"link\"\n format=\"link\"\n onClick={async () => {\n if (isElementActive(editor, 'link')) {\n unwrapLink(editor)\n } else {\n openModal(drawerSlug)\n const isCollapsed = editor.selection && Range.isCollapsed(editor.selection)\n\n if (!isCollapsed) {\n const data = {\n text: editor.selection ? Editor.string(editor, editor.selection) : '',\n }\n\n const { state } = await getFormState({\n collectionSlug,\n data,\n docPermissions,\n docPreferences: await getDocPreferences(),\n globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: [...schemaPath.split('.'), ...linkFieldsSchemaPath.split('.')].join(\n '.',\n ),\n })\n\n setInitialState(state)\n }\n }\n }}\n tooltip={t('fields:addLink')}\n >\n <LinkIcon />\n </ElementButton>\n <LinkDrawer\n drawerSlug={drawerSlug}\n fields={Array.isArray(fields) ? fields : []}\n handleClose={() => {\n closeModal(drawerSlug)\n }}\n handleModalSubmit={(fields) => {\n insertLink(editor, fields)\n closeModal(drawerSlug)\n }}\n initialState={initialState}\n schemaPath={schemaPath}\n />\n </Fragment>\n )\n}\n"],"names":["useDocumentInfo","useDrawerSlug","useModal","useServerFunctions","useTranslation","reduceFieldsToValues","React","Fragment","useState","Editor","Range","Transforms","ReactEditor","useSlate","LinkIcon","useElementButton","ElementButton","isElementActive","LinkDrawer","linkFieldsSchemaPath","unwrapLink","insertLink","editor","fields","isCollapsed","selection","data","newLink","type","children","doc","linkType","newTab","url","insertNodes","text","String","wrapNodes","split","delete","at","focus","path","unit","move","distance","insertText","LinkButton","schemaPath","fieldProps","initialState","setInitialState","t","getFormState","collectionSlug","docPermissions","getDocPreferences","globalSlug","closeModal","openModal","drawerSlug","componentMap","className","format","onClick","string","state","docPreferences","operation","renderAllFields","join","tooltip","Array","isArray","handleClose","handleModalSubmit"],"mappings":"AAAA;;AAIA,SACEA,eAAe,EACfC,aAAa,EACbC,QAAQ,EACRC,kBAAkB,EAClBC,cAAc,QACT,iBAAgB;AACvB,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,OAAOC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,QAAO;AACjD,SAASC,MAAM,EAAEC,KAAK,EAAEC,UAAU,QAAQ,QAAO;AACjD,SAASC,WAAW,EAAEC,QAAQ,QAAQ,cAAa;AAEnD,SAASC,QAAQ,QAAQ,+BAA8B;AACvD,SAASC,gBAAgB,QAAQ,8CAA6C;AAC9E,SAASC,aAAa,QAAQ,kBAAiB;AAC/C,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,oBAAoB,QAAQ,eAAc;AACnD,SAASC,UAAU,QAAQ,kBAAiB;AAE5C;;CAEC,GACD,MAAMC,aAAa,CAACC,QAAQC;IAC1B,MAAMC,cAAcF,OAAOG,SAAS,IAAIf,MAAMc,WAAW,CAACF,OAAOG,SAAS;IAC1E,MAAMC,OAAOrB,qBAAqBkB,QAAQ;IAE1C,MAAMI,UAAU;QACdC,MAAM;QACNC,UAAU,EAAE;QACZC,KAAKJ,KAAKI,GAAG;QACbP,QAAQG,KAAKH,MAAM;QACnBQ,UAAUL,KAAKK,QAAQ;QACvBC,QAAQN,KAAKM,MAAM;QACnBC,KAAKP,KAAKO,GAAG;IACf;IAEA,IAAIT,eAAe,CAACF,OAAOG,SAAS,EAAE;QACpC,8CAA8C;QAC9C,mDAAmD;QACnDd,WAAWuB,WAAW,CAACZ,QAAQ;YAC7B,GAAGK,OAAO;YACVE,UAAU;gBAAC;oBAAEM,MAAMC,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OG,SAAS,IAAIf,MAAMc,WAAW,CAACF,OAAOG,SAAS;wBAE1E,IAAI,CAACD,aAAa;4BAChB,MAAME,OAAO;gCACXS,MAAMb,OAAOG,SAAS,GAAGhB,OAAOwD,MAAM,CAAC3C,QAAQA,OAAOG,SAAS,IAAI;4BACrE;4BAEA,MAAM,EAAEyC,KAAK,EAAE,GAAG,MAAMb,aAAa;gCACnCC;gCACA5B;gCACA6B;gCACAY,gBAAgB,MAAMX;gCACtBC;gCACAW,WAAW;gCACXC,iBAAiB;gCACjBrB,YAAY;uCAAIA,WAAWV,KAAK,CAAC;uCAASnB,qBAAqBmB,KAAK,CAAC;iCAAK,CAACgC,IAAI,CAC7E;4BAEJ;4BAEAnB,gBAAgBe;wBAClB;oBACF;gBACF;gBACAK,SAASnB,EAAE;0BAEX,cAAA,KAACtC;;0BAEH,KAACI;gBACC0C,YAAYA;gBACZrC,QAAQiD,MAAMC,OAAO,CAAClD,UAAUA,SAAS,EAAE;gBAC3CmD,aAAa;oBACXhB,WAAWE;gBACb;gBACAe,mBAAmB,CAACpD;oBAClBF,WAAWC,QAAQC;oBACnBmC,WAAWE;gBACb;gBACAV,cAAcA;gBACdF,YAAYA;;;;AAIpB,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/link/Element/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/link/Element/index.tsx"],"names":[],"mappings":"AA2BA,OAAO,cAAc,CAAA;AAiCrB,eAAO,MAAM,WAAW,+CAsLvB,CAAA"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { getTranslation } from '@payloadcms/translations';
|
|
4
|
-
import { Button, Popup, Translation,
|
|
5
|
-
import { getFormState } from '@payloadcms/ui/shared';
|
|
4
|
+
import { Button, Popup, Translation, useConfig, useDocumentInfo, useDrawerSlug, useLocale, useModal, useServerFunctions, useTranslation } from '@payloadcms/ui';
|
|
6
5
|
import { deepCopyObject, reduceFieldsToValues } from 'payload/shared';
|
|
7
|
-
import
|
|
6
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
8
7
|
import { Editor, Node, Transforms } from 'slate';
|
|
9
8
|
import { ReactEditor, useSlate } from 'slate-react';
|
|
10
9
|
import { useElement } from '../../../providers/ElementProvider.js';
|
|
@@ -47,18 +46,18 @@ const baseClass = 'rich-text-link';
|
|
|
47
46
|
export const LinkElement = ()=>{
|
|
48
47
|
const { attributes, children, editorRef, element, fieldProps, schemaPath } = useElement();
|
|
49
48
|
const fieldMapPath = `${schemaPath}.${linkFieldsSchemaPath}`;
|
|
50
|
-
const {
|
|
51
|
-
const fields =
|
|
49
|
+
const { componentMap } = fieldProps;
|
|
50
|
+
const fields = componentMap[linkFieldsSchemaPath];
|
|
51
|
+
const { id, collectionSlug, docPermissions, getDocPreferences, globalSlug } = useDocumentInfo();
|
|
52
52
|
const editor = useSlate();
|
|
53
53
|
const { config } = useConfig();
|
|
54
|
-
const { user } = useAuth();
|
|
55
54
|
const { code: locale } = useLocale();
|
|
56
55
|
const { i18n, t } = useTranslation();
|
|
57
56
|
const { closeModal, openModal, toggleModal } = useModal();
|
|
58
57
|
const [renderModal, setRenderModal] = useState(false);
|
|
59
58
|
const [renderPopup, setRenderPopup] = useState(false);
|
|
60
59
|
const [initialState, setInitialState] = useState({});
|
|
61
|
-
const {
|
|
60
|
+
const { getFormState } = useServerFunctions();
|
|
62
61
|
const drawerSlug = useDrawerSlug('rich-text-link');
|
|
63
62
|
const handleTogglePopup = useCallback((render)=>{
|
|
64
63
|
if (!render) {
|
|
@@ -76,13 +75,14 @@ export const LinkElement = ()=>{
|
|
|
76
75
|
url: element.url
|
|
77
76
|
};
|
|
78
77
|
const { state } = await getFormState({
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
collectionSlug,
|
|
79
|
+
data,
|
|
80
|
+
docPermissions,
|
|
81
|
+
docPreferences: await getDocPreferences(),
|
|
82
|
+
globalSlug,
|
|
83
|
+
operation: 'update',
|
|
84
|
+
renderAllFields: true,
|
|
85
|
+
schemaPath: fieldMapPath ?? ''
|
|
86
86
|
});
|
|
87
87
|
setInitialState(state);
|
|
88
88
|
};
|
|
@@ -92,13 +92,16 @@ export const LinkElement = ()=>{
|
|
|
92
92
|
}, [
|
|
93
93
|
renderModal,
|
|
94
94
|
element,
|
|
95
|
-
user,
|
|
96
95
|
locale,
|
|
97
96
|
t,
|
|
98
97
|
collectionSlug,
|
|
99
98
|
config,
|
|
100
99
|
id,
|
|
101
|
-
fieldMapPath
|
|
100
|
+
fieldMapPath,
|
|
101
|
+
getFormState,
|
|
102
|
+
globalSlug,
|
|
103
|
+
getDocPreferences,
|
|
104
|
+
docPermissions
|
|
102
105
|
]);
|
|
103
106
|
return /*#__PURE__*/ _jsxs("span", {
|
|
104
107
|
className: baseClass,
|
|
@@ -122,7 +125,8 @@ export const LinkElement = ()=>{
|
|
|
122
125
|
closeModal(drawerSlug);
|
|
123
126
|
setRenderModal(false);
|
|
124
127
|
},
|
|
125
|
-
initialState: initialState
|
|
128
|
+
initialState: initialState,
|
|
129
|
+
schemaPath: schemaPath
|
|
126
130
|
}),
|
|
127
131
|
/*#__PURE__*/ _jsx(Popup, {
|
|
128
132
|
boundingRef: editorRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/elements/link/Element/index.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Popup,\n Translation,\n useAuth,\n useConfig,\n useDocumentInfo,\n useDrawerSlug,\n useLocale,\n useModal,\n useTranslation,\n} from '@payloadcms/ui'\nimport { getFormState } from '@payloadcms/ui/shared'\nimport { deepCopyObject, reduceFieldsToValues } from 'payload/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { Editor, Node, Transforms } from 'slate'\nimport { ReactEditor, useSlate } from 'slate-react'\n\nimport type { LinkElementType } from '../types.js'\n\nimport { useElement } from '../../../providers/ElementProvider.js'\nimport { LinkDrawer } from '../LinkDrawer/index.js'\nimport { linkFieldsSchemaPath } from '../shared.js'\nimport { unwrapLink } from '../utilities.js'\nimport './index.scss'\n\nconst baseClass = 'rich-text-link'\n\n/**\n * This function is called when an existing link is edited.\n * When a link is first created, another function is called: {@link ../Button/index.tsx#insertLink}\n */\nconst insertChange = (editor, fields) => {\n const data = reduceFieldsToValues(fields, true)\n\n const [, parentPath] = Editor.above(editor)\n\n const newNode: Record<string, unknown> = {\n doc: data.doc,\n linkType: data.linkType,\n newTab: data.newTab,\n url: data.url,\n }\n\n if (data.fields) {\n newNode.fields = data.fields\n }\n\n Transforms.setNodes(editor, newNode, { at: parentPath })\n\n Transforms.delete(editor, { at: editor.selection.focus.path, unit: 'block' })\n Transforms.move(editor, { distance: 1, unit: 'offset' })\n Transforms.insertText(editor, String(data.text), { at: editor.selection.focus.path })\n\n ReactEditor.focus(editor)\n}\n\nexport const LinkElement = () => {\n const { attributes, children, editorRef, element, fieldProps, schemaPath } =\n useElement<LinkElementType>()\n\n const fieldMapPath = `${schemaPath}.${linkFieldsSchemaPath}`\n\n const {\n field: { richTextComponentMap },\n } = fieldProps\n const fields = richTextComponentMap.get(linkFieldsSchemaPath)\n\n const editor = useSlate()\n const { config } = useConfig()\n const { user } = useAuth()\n const { code: locale } = useLocale()\n const { i18n, t } = useTranslation()\n const { closeModal, openModal, toggleModal } = useModal()\n const [renderModal, setRenderModal] = useState(false)\n const [renderPopup, setRenderPopup] = useState(false)\n const [initialState, setInitialState] = useState<FormState>({})\n const { id, collectionSlug } = useDocumentInfo()\n\n const drawerSlug = useDrawerSlug('rich-text-link')\n\n const handleTogglePopup = useCallback((render) => {\n if (!render) {\n setRenderPopup(render)\n }\n }, [])\n\n useEffect(() => {\n const awaitInitialState = async () => {\n const data = {\n doc: element.doc,\n fields: deepCopyObject(element.fields),\n linkType: element.linkType,\n newTab: element.newTab,\n text: Node.string(element),\n url: element.url,\n }\n\n const { state } = await getFormState({\n apiRoute: config.routes.api,\n body: {\n data,\n operation: 'update',\n schemaPath: fieldMapPath,\n },\n serverURL: config.serverURL,\n })\n\n setInitialState(state)\n }\n\n if (renderModal) {\n void awaitInitialState()\n }\n }, [renderModal, element, user, locale, t, collectionSlug, config, id, fieldMapPath])\n\n return (\n <span className={baseClass} {...attributes}>\n <span contentEditable={false} style={{ userSelect: 'none' }}>\n {renderModal && (\n <LinkDrawer\n drawerSlug={drawerSlug}\n fields={Array.isArray(fields) ? fields : []}\n handleClose={() => {\n toggleModal(drawerSlug)\n setRenderModal(false)\n }}\n handleModalSubmit={(fields) => {\n insertChange(editor, fields)\n closeModal(drawerSlug)\n setRenderModal(false)\n }}\n initialState={initialState}\n />\n )}\n <Popup\n boundingRef={editorRef}\n buttonType=\"none\"\n forceOpen={renderPopup}\n horizontalAlign=\"left\"\n onToggleOpen={handleTogglePopup}\n render={() => (\n <div className={`${baseClass}__popup`}>\n {element.linkType === 'internal' && element.doc?.relationTo && element.doc?.value && (\n <Translation\n elements={{\n '0': ({ children }) => (\n <a\n className={`${baseClass}__link-label`}\n href={`${config.routes.admin}/collections/${element.doc.relationTo}/${element.doc.value}`}\n rel=\"noreferrer\"\n target=\"_blank\"\n title={`${config.routes.admin}/collections/${element.doc.relationTo}/${element.doc.value}`}\n >\n {children}\n </a>\n ),\n }}\n i18nKey=\"fields:linkedTo\"\n t={t}\n variables={{\n label: getTranslation(\n config.collections.find(({ slug }) => slug === element.doc.relationTo)?.labels\n ?.singular,\n i18n,\n ),\n }}\n />\n )}\n {(element.linkType === 'custom' || !element.linkType) && (\n <a\n className={`${baseClass}__link-label`}\n href={element.url}\n rel=\"noreferrer\"\n target=\"_blank\"\n title={element.url}\n >\n {element.url}\n </a>\n )}\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__link-edit`}\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n setRenderPopup(false)\n openModal(drawerSlug)\n setRenderModal(true)\n }}\n round\n tooltip={t('general:edit')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__link-close`}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n unwrapLink(editor)\n }}\n round\n tooltip={t('general:remove')}\n />\n </div>\n )}\n size=\"fit-content\"\n verticalAlign=\"bottom\"\n />\n </span>\n <span\n className={[`${baseClass}__popup-toggler`].filter(Boolean).join(' ')}\n onClick={() => setRenderPopup(true)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n setRenderPopup(true)\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </span>\n </span>\n )\n}\n"],"names":["getTranslation","Button","Popup","Translation","useAuth","useConfig","useDocumentInfo","useDrawerSlug","useLocale","useModal","useTranslation","getFormState","deepCopyObject","reduceFieldsToValues","React","useCallback","useEffect","useState","Editor","Node","Transforms","ReactEditor","useSlate","useElement","LinkDrawer","linkFieldsSchemaPath","unwrapLink","baseClass","insertChange","editor","fields","data","parentPath","above","newNode","doc","linkType","newTab","url","setNodes","at","delete","selection","focus","path","unit","move","distance","insertText","String","text","LinkElement","attributes","children","editorRef","element","fieldProps","schemaPath","fieldMapPath","field","richTextComponentMap","get","config","user","code","locale","i18n","t","closeModal","openModal","toggleModal","renderModal","setRenderModal","renderPopup","setRenderPopup","initialState","setInitialState","id","collectionSlug","drawerSlug","handleTogglePopup","render","awaitInitialState","string","state","apiRoute","routes","api","body","operation","serverURL","span","className","contentEditable","style","userSelect","Array","isArray","handleClose","handleModalSubmit","boundingRef","buttonType","forceOpen","horizontalAlign","onToggleOpen","div","relationTo","value","elements","a","href","admin","rel","target","title","i18nKey","variables","label","collections","find","slug","labels","singular","buttonStyle","icon","onClick","e","preventDefault","round","tooltip","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wCACAmG,KAAK;wCACLC,SAAS9D,EAAE;;;;wBAIjB+D,MAAK;wBACLC,eAAc;;;;0BAGlB,KAACxC;gBACCC,WAAW;oBAAC,CAAC,EAAEjE,UAAU,eAAe,CAAC;iBAAC,CAACyG,MAAM,CAACC,SAASC,IAAI,CAAC;gBAChET,SAAS,IAAMnD,eAAe;gBAC9B6D,WAAW,CAACT;oBACV,IAAIA,EAAEU,GAAG,KAAK,SAAS;wBACrB9D,eAAe;oBACjB;gBACF;gBACA+D,MAAK;gBACLC,UAAU;0BAETrF;;;;AAIT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/elements/link/Element/index.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Popup,\n Translation,\n useConfig,\n useDocumentInfo,\n useDrawerSlug,\n useLocale,\n useModal,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { deepCopyObject, reduceFieldsToValues } from 'payload/shared'\nimport { useCallback, useEffect, useState } from 'react'\nimport { Editor, Node, Transforms } from 'slate'\nimport { ReactEditor, useSlate } from 'slate-react'\n\nimport type { LinkElementType } from '../types.js'\n\nimport { useElement } from '../../../providers/ElementProvider.js'\nimport { LinkDrawer } from '../LinkDrawer/index.js'\nimport { linkFieldsSchemaPath } from '../shared.js'\nimport { unwrapLink } from '../utilities.js'\nimport './index.scss'\n\nconst baseClass = 'rich-text-link'\n\n/**\n * This function is called when an existing link is edited.\n * When a link is first created, another function is called: {@link ../Button/index.tsx#insertLink}\n */\nconst insertChange = (editor, fields) => {\n const data = reduceFieldsToValues(fields, true)\n\n const [, parentPath] = Editor.above(editor)\n\n const newNode: Record<string, unknown> = {\n doc: data.doc,\n linkType: data.linkType,\n newTab: data.newTab,\n url: data.url,\n }\n\n if (data.fields) {\n newNode.fields = data.fields\n }\n\n Transforms.setNodes(editor, newNode, { at: parentPath })\n\n Transforms.delete(editor, { at: editor.selection.focus.path, unit: 'block' })\n Transforms.move(editor, { distance: 1, unit: 'offset' })\n Transforms.insertText(editor, String(data.text), { at: editor.selection.focus.path })\n\n ReactEditor.focus(editor)\n}\n\nexport const LinkElement = () => {\n const { attributes, children, editorRef, element, fieldProps, schemaPath } =\n useElement<LinkElementType>()\n\n const fieldMapPath = `${schemaPath}.${linkFieldsSchemaPath}`\n\n const { componentMap } = fieldProps\n const fields = componentMap[linkFieldsSchemaPath]\n const { id, collectionSlug, docPermissions, getDocPreferences, globalSlug } = useDocumentInfo()\n\n const editor = useSlate()\n const { config } = useConfig()\n const { code: locale } = useLocale()\n const { i18n, t } = useTranslation()\n const { closeModal, openModal, toggleModal } = useModal()\n const [renderModal, setRenderModal] = useState(false)\n const [renderPopup, setRenderPopup] = useState(false)\n const [initialState, setInitialState] = useState<FormState>({})\n\n const { getFormState } = useServerFunctions()\n\n const drawerSlug = useDrawerSlug('rich-text-link')\n\n const handleTogglePopup = useCallback((render) => {\n if (!render) {\n setRenderPopup(render)\n }\n }, [])\n\n useEffect(() => {\n const awaitInitialState = async () => {\n const data = {\n doc: element.doc,\n fields: deepCopyObject(element.fields),\n linkType: element.linkType,\n newTab: element.newTab,\n text: Node.string(element),\n url: element.url,\n }\n\n const { state } = await getFormState({\n collectionSlug,\n data,\n docPermissions,\n docPreferences: await getDocPreferences(),\n globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: fieldMapPath ?? '',\n })\n\n setInitialState(state)\n }\n\n if (renderModal) {\n void awaitInitialState()\n }\n }, [\n renderModal,\n element,\n locale,\n t,\n collectionSlug,\n config,\n id,\n fieldMapPath,\n getFormState,\n globalSlug,\n getDocPreferences,\n docPermissions,\n ])\n\n return (\n <span className={baseClass} {...attributes}>\n <span contentEditable={false} style={{ userSelect: 'none' }}>\n {renderModal && (\n <LinkDrawer\n drawerSlug={drawerSlug}\n fields={Array.isArray(fields) ? fields : []}\n handleClose={() => {\n toggleModal(drawerSlug)\n setRenderModal(false)\n }}\n handleModalSubmit={(fields) => {\n insertChange(editor, fields)\n closeModal(drawerSlug)\n setRenderModal(false)\n }}\n initialState={initialState}\n schemaPath={schemaPath}\n />\n )}\n <Popup\n boundingRef={editorRef}\n buttonType=\"none\"\n forceOpen={renderPopup}\n horizontalAlign=\"left\"\n onToggleOpen={handleTogglePopup}\n render={() => (\n <div className={`${baseClass}__popup`}>\n {element.linkType === 'internal' && element.doc?.relationTo && element.doc?.value && (\n <Translation\n elements={{\n '0': ({ children }) => (\n <a\n className={`${baseClass}__link-label`}\n href={`${config.routes.admin}/collections/${element.doc.relationTo}/${element.doc.value}`}\n rel=\"noreferrer\"\n target=\"_blank\"\n title={`${config.routes.admin}/collections/${element.doc.relationTo}/${element.doc.value}`}\n >\n {children}\n </a>\n ),\n }}\n i18nKey=\"fields:linkedTo\"\n t={t}\n variables={{\n label: getTranslation(\n config.collections.find(({ slug }) => slug === element.doc.relationTo)?.labels\n ?.singular,\n i18n,\n ),\n }}\n />\n )}\n {(element.linkType === 'custom' || !element.linkType) && (\n <a\n className={`${baseClass}__link-label`}\n href={element.url}\n rel=\"noreferrer\"\n target=\"_blank\"\n title={element.url}\n >\n {element.url}\n </a>\n )}\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__link-edit`}\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n setRenderPopup(false)\n openModal(drawerSlug)\n setRenderModal(true)\n }}\n round\n tooltip={t('general:edit')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__link-close`}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n unwrapLink(editor)\n }}\n round\n tooltip={t('general:remove')}\n />\n </div>\n )}\n size=\"fit-content\"\n verticalAlign=\"bottom\"\n />\n </span>\n <span\n className={[`${baseClass}__popup-toggler`].filter(Boolean).join(' ')}\n onClick={() => setRenderPopup(true)}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n setRenderPopup(true)\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </span>\n </span>\n )\n}\n"],"names":["getTranslation","Button","Popup","Translation","useConfig","useDocumentInfo","useDrawerSlug","useLocale","useModal","useServerFunctions","useTranslation","deepCopyObject","reduceFieldsToValues","useCallback","useEffect","useState","Editor","Node","Transforms","ReactEditor","useSlate","useElement","LinkDrawer","linkFieldsSchemaPath","unwrapLink","baseClass","insertChange","editor","fields","data","parentPath","above","newNode","doc","linkType","newTab","url","setNodes","at","delete","selection","focus","path","unit","move","distance","insertText","String","text","LinkElement","attributes","children","editorRef","element","fieldProps","schemaPath","fieldMapPath","componentMap","id","collectionSlug","docPermissions","getDocPreferences","globalSlug","config","code","locale","i18n","t","closeModal","openModal","toggleModal","renderModal","setRenderModal","renderPopup","setRenderPopup","initialState","setInitialState","getFormState","drawerSlug","handleTogglePopup","render","awaitInitialState","string","state","docPreferences","operation","renderAllFields","span","className","contentEditable","style","userSelect","Array","isArray","handleClose","handleModalSubmit","boundingRef","buttonType","forceOpen","horizontalAlign","onToggleOpen","div","relationTo","value","elements","a","href","routes","admin","rel","target","title","i18nKey","variables","label","collections","find","slug","labels","singular","buttonStyle","icon","onClick","e","preventDefault","round","tooltip","size","verticalAlign","filter","Boolean","join","onKeyDown","key","role","tabIndex"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SACEC,MAAM,EACNC,KAAK,EACLC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,aAAa,EACbC,SAAS,EACTC,QAAQ,EACRC,kBAAkB,EAClBC,cAAc,QACT,iBAAgB;AACvB,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,iBAAgB;AACrE,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AACxD,SAASC,MAAM,EAAEC,IAAI,EAAEC,UAAU,QAAQ,QAAO;AAChD,SAASC,WAAW,EAAEC,QAAQ,QAAQ,cAAa;AAInD,SAASC,UAAU,QAAQ,wCAAuC;AAClE,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SA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AShE,QAAQpB,GAAG,CAACqE,UAAU,GAAGgB,QACpEC,UACJrD;wCAEJ;;oCAGFb,CAAAA,QAAQnB,QAAQ,KAAK,YAAY,CAACmB,QAAQnB,QAAQ,AAAD,mBACjD,KAACuE;wCACCjB,WAAW,CAAC,EAAE/D,UAAU,YAAY,CAAC;wCACrCiF,MAAMrD,QAAQjB,GAAG;wCACjByE,KAAI;wCACJC,QAAO;wCACPC,OAAO1D,QAAQjB,GAAG;kDAEjBiB,QAAQjB,GAAG;;kDAGhB,KAACnC;wCACCuH,aAAY;wCACZhC,WAAW,CAAC,EAAE/D,UAAU,WAAW,CAAC;wCACpCgG,MAAK;wCACLC,SAAS,CAACC;4CACRA,EAAEC,cAAc;4CAChBlD,eAAe;4CACfL,UAAUS;4CACVN,eAAe;wCACjB;wCACAqD,KAAK;wCACLC,SAAS3D,EAAE;;kDAEb,KAAClE;wCACCuH,aAAY;wCACZhC,WAAW,CAAC,EAAE/D,UAAU,YAAY,CAAC;wCACrCgG,MAAK;wCACLC,SAAS,CAACC;4CACRA,EAAEC,cAAc;4CAChBpG,WAAWG;wCACb;wCACAkG,KAAK;wCACLC,SAAS3D,EAAE;;;;wBAIjB4D,MAAK;wBACLC,eAAc;;;;0BAGlB,KAACzC;gBACCC,WAAW;oBAAC,CAAC,EAAE/D,UAAU,eAAe,CAAC;iBAAC,CAACwG,MAAM,CAACC,SAASC,IAAI,CAAC;gBAChET,SAAS,IAAMhD,eAAe;gBAC9B0D,WAAW,CAACT;oBACV,IAAIA,EAAEU,GAAG,KAAK,SAAS;wBACrB3D,eAAe;oBACjB;gBACF;gBACA4D,MAAK;gBACLC,UAAU;0BAETpF;;;;AAIT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/link/LinkDrawer/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/link/LinkDrawer/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGvC,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAyDtC,CAAA"}
|
|
@@ -1,59 +1,64 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Drawer, Form, FormSubmit, RenderFields,
|
|
4
|
-
import { getFormState } from '@payloadcms/ui/shared';
|
|
3
|
+
import { Drawer, EditDepthProvider, Form, FormSubmit, RenderFields, useDocumentInfo, useEditDepth, useHotkey, useServerFunctions, useTranslation } from '@payloadcms/ui';
|
|
5
4
|
import React, { useCallback, useRef } from 'react';
|
|
6
5
|
import { linkFieldsSchemaPath } from '../shared.js';
|
|
7
6
|
import './index.scss';
|
|
8
7
|
const baseClass = 'rich-text-link-edit-modal';
|
|
9
|
-
export const LinkDrawer = ({ drawerSlug, fields, handleModalSubmit, initialState })=>{
|
|
8
|
+
export const LinkDrawer = ({ drawerSlug, fields, handleModalSubmit, initialState, schemaPath })=>{
|
|
10
9
|
const { t } = useTranslation();
|
|
11
|
-
const { schemaPath } = useFieldProps();
|
|
12
10
|
const fieldMapPath = `${schemaPath}.${linkFieldsSchemaPath}`;
|
|
13
|
-
const { id } = useDocumentInfo();
|
|
14
|
-
const {
|
|
11
|
+
const { id, collectionSlug, docPermissions, getDocPreferences, globalSlug } = useDocumentInfo();
|
|
12
|
+
const { getFormState } = useServerFunctions();
|
|
15
13
|
const onChange = useCallback(async ({ formState: prevFormState })=>{
|
|
16
14
|
const { state } = await getFormState({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
id,
|
|
16
|
+
collectionSlug,
|
|
17
|
+
docPermissions,
|
|
18
|
+
docPreferences: await getDocPreferences(),
|
|
19
|
+
formState: prevFormState,
|
|
20
|
+
globalSlug,
|
|
21
|
+
operation: 'update',
|
|
22
|
+
schemaPath: fieldMapPath ?? ''
|
|
25
23
|
});
|
|
26
24
|
return state;
|
|
27
25
|
}, [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
getFormState,
|
|
27
|
+
id,
|
|
28
|
+
collectionSlug,
|
|
29
|
+
getDocPreferences,
|
|
30
|
+
docPermissions,
|
|
31
|
+
globalSlug,
|
|
32
|
+
fieldMapPath
|
|
32
33
|
]);
|
|
33
|
-
return /*#__PURE__*/ _jsx(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
onChange
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
34
|
+
return /*#__PURE__*/ _jsx(EditDepthProvider, {
|
|
35
|
+
children: /*#__PURE__*/ _jsx(Drawer, {
|
|
36
|
+
className: baseClass,
|
|
37
|
+
slug: drawerSlug,
|
|
38
|
+
title: t('fields:editLink'),
|
|
39
|
+
children: /*#__PURE__*/ _jsxs(Form, {
|
|
40
|
+
beforeSubmit: [
|
|
41
|
+
onChange
|
|
42
|
+
],
|
|
43
|
+
disableValidationOnSubmit: true,
|
|
44
|
+
initialState: initialState,
|
|
45
|
+
onChange: [
|
|
46
|
+
onChange
|
|
47
|
+
],
|
|
48
|
+
onSubmit: handleModalSubmit,
|
|
49
|
+
children: [
|
|
50
|
+
/*#__PURE__*/ _jsx(RenderFields, {
|
|
51
|
+
fields: fields,
|
|
52
|
+
forceRender: true,
|
|
53
|
+
parentIndexPath: "",
|
|
54
|
+
parentPath: '',
|
|
55
|
+
parentSchemaPath: "",
|
|
56
|
+
permissions: docPermissions.fields,
|
|
57
|
+
readOnly: false
|
|
58
|
+
}),
|
|
59
|
+
/*#__PURE__*/ _jsx(LinkSubmit, {})
|
|
60
|
+
]
|
|
61
|
+
})
|
|
57
62
|
})
|
|
58
63
|
});
|
|
59
64
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/elements/link/LinkDrawer/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormProps } from '@payloadcms/ui'\n\nimport {\n Drawer,\n Form,\n FormSubmit,\n RenderFields,\n
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/elements/link/LinkDrawer/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormProps } from '@payloadcms/ui'\n\nimport {\n Drawer,\n EditDepthProvider,\n Form,\n FormSubmit,\n RenderFields,\n useDocumentInfo,\n useEditDepth,\n useHotkey,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useRef } from 'react'\n\nimport type { Props } from './types.js'\n\nimport { linkFieldsSchemaPath } from '../shared.js'\nimport './index.scss'\n\nconst baseClass = 'rich-text-link-edit-modal'\n\nexport const LinkDrawer: React.FC<Props> = ({\n drawerSlug,\n fields,\n handleModalSubmit,\n initialState,\n schemaPath,\n}) => {\n const { t } = useTranslation()\n const fieldMapPath = `${schemaPath}.${linkFieldsSchemaPath}`\n\n const { id, collectionSlug, docPermissions, getDocPreferences, globalSlug } = useDocumentInfo()\n\n const { getFormState } = useServerFunctions()\n\n const onChange: FormProps['onChange'][0] = useCallback(\n async ({ formState: prevFormState }) => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions,\n docPreferences: await getDocPreferences(),\n formState: prevFormState,\n globalSlug,\n operation: 'update',\n schemaPath: fieldMapPath ?? '',\n })\n\n return state\n },\n\n [getFormState, id, collectionSlug, getDocPreferences, docPermissions, globalSlug, fieldMapPath],\n )\n\n return (\n <EditDepthProvider>\n <Drawer className={baseClass} slug={drawerSlug} title={t('fields:editLink')}>\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleModalSubmit}\n >\n <RenderFields\n fields={fields}\n forceRender\n parentIndexPath=\"\"\n parentPath={''}\n parentSchemaPath=\"\"\n permissions={docPermissions.fields}\n readOnly={false}\n />\n <LinkSubmit />\n </Form>\n </Drawer>\n </EditDepthProvider>\n )\n}\n\nconst LinkSubmit: React.FC = () => {\n const { t } = useTranslation()\n const ref = useRef<HTMLButtonElement>(null)\n const editDepth = useEditDepth()\n\n useHotkey({ cmdCtrlKey: true, editDepth, keyCodes: ['s'] }, (e) => {\n e.preventDefault()\n e.stopPropagation()\n if (ref?.current) {\n ref.current.click()\n }\n })\n\n return <FormSubmit ref={ref}>{t('general:submit')}</FormSubmit>\n}\n"],"names":["Drawer","EditDepthProvider","Form","FormSubmit","RenderFields","useDocumentInfo","useEditDepth","useHotkey","useServerFunctions","useTranslation","React","useCallback","useRef","linkFieldsSchemaPath","baseClass","LinkDrawer","drawerSlug","fields","handleModalSubmit","initialState","schemaPath","t","fieldMapPath","id","collectionSlug","docPermissions","getDocPreferences","globalSlug","getFormState","onChange","formState","prevFormState","state","docPreferences","operation","className","slug","title","beforeSubmit","disableValidationOnSubmit","onSubmit","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","readOnly","LinkSubmit","ref","editDepth","cmdCtrlKey","keyCodes","e","preventDefault","stopPropagation","current","click"],"mappings":"AAAA;;AAIA,SACEA,MAAM,EACNC,iBAAiB,EACjBC,IAAI,EACJC,UAAU,EACVC,YAAY,EACZC,eAAe,EACfC,YAAY,EACZC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,EAAEC,MAAM,QAAQ,QAAO;AAIlD,SAASC,oBAAoB,QAAQ,eAAc;AACnD,OAAO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SAAI;IAAC,GAAG,CAACC;QAC3DA,EAAEC,cAAc;QAChBD,EAAEE,eAAe;QACjB,IAAIN,KAAKO,SAAS;YAChBP,IAAIO,OAAO,CAACC,KAAK;QACnB;IACF;IAEA,qBAAO,KAACrD;QAAW6C,KAAKA;kBAAM3B,EAAE;;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/link/LinkDrawer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAErD,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,CAAA;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,IAAI,CAAA;IAChC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;IACtF,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/link/LinkDrawer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAErD,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,CAAA;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,IAAI,CAAA;IAChC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;IACtF,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAA;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/elements/link/LinkDrawer/types.ts"],"sourcesContent":["import type { ClientField, FormState } from 'payload'\n\nexport type Props = {\n readonly drawerSlug: string\n readonly fields: ClientField[]\n readonly handleClose: () => void\n readonly handleModalSubmit: (fields: FormState, data: Record<string, unknown>) => void\n readonly initialState?: FormState\n}\n"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/elements/link/LinkDrawer/types.ts"],"sourcesContent":["import type { ClientField, FormState } from 'payload'\n\nexport type Props = {\n readonly drawerSlug: string\n readonly fields: ClientField[]\n readonly handleClose: () => void\n readonly handleModalSubmit: (fields: FormState, data: Record<string, unknown>) => void\n readonly initialState?: FormState\n readonly schemaPath: string\n}\n"],"names":[],"mappings":"AAEA,WAOC"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import type { FormFieldBase, MappedComponent } from 'payload';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import './index.scss';
|
|
4
|
-
|
|
5
|
-
name: string;
|
|
6
|
-
richTextComponentMap: Map<string, MappedComponent>;
|
|
7
|
-
} & FormFieldBase;
|
|
8
|
-
export declare const RelationshipElement: (props: Props) => React.ReactNode;
|
|
9
|
-
export {};
|
|
3
|
+
export declare const RelationshipElement: (props: any) => React.ReactNode;
|
|
10
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA4C,MAAM,OAAO,CAAA;AAQhE,OAAO,cAAc,CAAA;AA0KrB,eAAO,MAAM,mBAAmB,UAAW,GAAG,KAAG,KAAK,CAAC,SAMtD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase, MappedComponent } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n useConfig,\n useDocumentDrawer,\n useListDrawer,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useReducer, useState } from 'react'\nimport { Transforms } from 'slate'\nimport { ReactEditor, useFocused, useSelected, useSlateStatic } from 'slate-react'\n\nimport type { RelationshipElementType } from '../types.js'\n\nimport { useElement } from '../../../providers/ElementProvider.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport './index.scss'\n\nconst baseClass = 'rich-text-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n name: string\n richTextComponentMap: Map<string, MappedComponent>\n} & FormFieldBase\n\nconst RelationshipElementComponent: React.FC<Props> = () => {\n const {\n attributes,\n children,\n element,\n element: { relationTo, value },\n fieldProps,\n } = useElement<RelationshipElementType>()\n\n const {\n config: {\n collections,\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const [enabledCollectionSlugs] = useState(() =>\n collections\n .filter(({ admin: { enableRichTextRelationship } }) => enableRichTextRelationship)\n .map(({ slug }) => slug),\n )\n const [relatedCollection, setRelatedCollection] = useState(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const selected = useSelected()\n const focused = useFocused()\n const { i18n, t } = useTranslation()\n const editor = useSlateStatic()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value?.id}`,\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer: closeListDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.removeNodes(editor, { at: elementPath })\n }, [editor, element])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(\n editor,\n {\n type: 'relationship',\n children: [{ text: ' ' }],\n relationTo: relatedCollection.slug,\n value: { id: doc.id },\n },\n { at: elementPath },\n )\n\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDrawer()\n dispatchCacheBust()\n },\n [editor, element, relatedCollection, cacheBust, setParams, closeDrawer],\n )\n\n const swapRelationship = React.useCallback(\n ({ collectionSlug, docID }) => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(\n editor,\n {\n type: 'relationship',\n children: [{ text: ' ' }],\n relationTo: collectionSlug,\n value: { id: docID },\n },\n { at: elementPath },\n )\n\n setRelatedCollection(collections.find((coll) => coll.slug === collectionSlug))\n\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeListDrawer()\n dispatchCacheBust()\n },\n [closeListDrawer, editor, element, cacheBust, setParams, collections],\n )\n\n return (\n <div\n className={[baseClass, selected && focused && `${baseClass}--selected`]\n .filter(Boolean)\n .join(' ')}\n contentEditable={false}\n {...attributes}\n >\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data[relatedCollection?.admin?.useAsTitle || 'id']}\n </p>\n </DocumentDrawerToggler>\n </div>\n <div className={`${baseClass}__actions`}>\n <ListDrawerToggler\n className={`${baseClass}__list-drawer-toggler`}\n disabled={fieldProps?.field?.admin?.readOnly}\n >\n <Button\n buttonStyle=\"icon-label\"\n disabled={fieldProps?.field?.admin?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n // do nothing\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n </ListDrawerToggler>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={fieldProps?.field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n {value?.id && <DocumentDrawer onSave={updateRelationship} />}\n <ListDrawer onSelect={swapRelationship} />\n {children}\n </div>\n )\n}\n\nexport const RelationshipElement = (props: Props): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipElementComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["getTranslation","Button","useConfig","useDocumentDrawer","useListDrawer","usePayloadAPI","useTranslation","React","useCallback","useReducer","useState","Transforms","ReactEditor","useFocused","useSelected","useSlateStatic","useElement","EnabledRelationshipsCondition","baseClass","initialParams","depth","RelationshipElementComponent","attributes","children","element","relationTo","value","fieldProps","config","collections","routes","api","serverURL","enabledCollectionSlugs","filter","admin","enableRichTextRelationship","map","slug","relatedCollection","setRelatedCollection","find","coll","selected","focused","i18n","t","editor","cacheBust","dispatchCacheBust","state","data","setParams","id","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","ListDrawer","ListDrawerToggler","closeListDrawer","collectionSlugs","selectedCollection","removeRelationship","elementPath","findPath","removeNodes","at","updateRelationship","doc","setNodes","type","text","swapRelationship","docID","div","className","Boolean","join","contentEditable","p","label","labels","singular","useAsTitle","disabled","field","readOnly","buttonStyle","el","icon","onClick","round","tooltip","e","preventDefault","onSave","onSelect","RelationshipElement","props"],"mappings":"A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AG;4BACHC,MAAK;4BACLC,SAAS;4BACP,aAAa;4BACf;4BACAC,KAAK;4BACLC,SAAS/C,EAAE;;;kCAGf,KAAC7C;wBACCuF,aAAY;wBACZZ,WAAW,CAAC,EAAE1D,UAAU,cAAc,CAAC;wBACvCmE,UAAU1D,YAAY2D,OAAOnD,OAAOoD;wBACpCG,MAAK;wBACLC,SAAS,CAACG;4BACRA,EAAEC,cAAc;4BAChBhC;wBACF;wBACA6B,KAAK;wBACLC,SAAS/C,EAAE;;;;YAGdpB,OAAO2B,oBAAM,KAACC;gBAAe0C,QAAQ5B;;0BACtC,KAACV;gBAAWuC,UAAUxB;;YACrBlD;;;AAGP;AAEA,OAAO,MAAM2E,sBAAsB,CAACC;IAClC,qBACE,KAAClF;QAA+B,GAAGkF,KAAK;kBACtC,cAAA,KAAC9E;YAA8B,GAAG8E,KAAK;;;AAG7C,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/elements/relationship/Element/index.tsx"],"sourcesContent":["'use client'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n useConfig,\n useDocumentDrawer,\n useListDrawer,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useReducer, useState } from 'react'\nimport { Transforms } from 'slate'\nimport { ReactEditor, useFocused, useSelected, useSlateStatic } from 'slate-react'\n\nimport type { RelationshipElementType } from '../types.js'\n\nimport { useElement } from '../../../providers/ElementProvider.js'\nimport { EnabledRelationshipsCondition } from '../../EnabledRelationshipsCondition.js'\nimport './index.scss'\n\nconst baseClass = 'rich-text-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\nconst RelationshipElementComponent: React.FC = () => {\n const {\n attributes,\n children,\n element,\n element: { relationTo, value },\n fieldProps,\n } = useElement<RelationshipElementType>()\n\n const {\n config: {\n collections,\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const [enabledCollectionSlugs] = useState(() =>\n collections\n .filter(({ admin: { enableRichTextRelationship } }) => enableRichTextRelationship)\n .map(({ slug }) => slug),\n )\n const [relatedCollection, setRelatedCollection] = useState(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const selected = useSelected()\n const focused = useFocused()\n const { i18n, t } = useTranslation()\n const editor = useSlateStatic()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value?.id}`,\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n const [ListDrawer, ListDrawerToggler, { closeDrawer: closeListDrawer }] = useListDrawer({\n collectionSlugs: enabledCollectionSlugs,\n selectedCollection: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.removeNodes(editor, { at: elementPath })\n }, [editor, element])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(\n editor,\n {\n type: 'relationship',\n children: [{ text: ' ' }],\n relationTo: relatedCollection.slug,\n value: { id: doc.id },\n },\n { at: elementPath },\n )\n\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDrawer()\n dispatchCacheBust()\n },\n [editor, element, relatedCollection, cacheBust, setParams, closeDrawer],\n )\n\n const swapRelationship = React.useCallback(\n ({ collectionSlug, docID }) => {\n const elementPath = ReactEditor.findPath(editor, element)\n\n Transforms.setNodes(\n editor,\n {\n type: 'relationship',\n children: [{ text: ' ' }],\n relationTo: collectionSlug,\n value: { id: docID },\n },\n { at: elementPath },\n )\n\n setRelatedCollection(collections.find((coll) => coll.slug === collectionSlug))\n\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeListDrawer()\n dispatchCacheBust()\n },\n [closeListDrawer, editor, element, cacheBust, setParams, collections],\n )\n\n return (\n <div\n className={[baseClass, selected && focused && `${baseClass}--selected`]\n .filter(Boolean)\n .join(' ')}\n contentEditable={false}\n {...attributes}\n >\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data[relatedCollection?.admin?.useAsTitle || 'id']}\n </p>\n </DocumentDrawerToggler>\n </div>\n <div className={`${baseClass}__actions`}>\n <ListDrawerToggler\n className={`${baseClass}__list-drawer-toggler`}\n disabled={fieldProps?.field?.admin?.readOnly}\n >\n <Button\n buttonStyle=\"icon-label\"\n disabled={fieldProps?.field?.admin?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n // do nothing\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n </ListDrawerToggler>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={fieldProps?.field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n {value?.id && <DocumentDrawer onSave={updateRelationship} />}\n <ListDrawer onSelect={swapRelationship} />\n {children}\n </div>\n )\n}\n\nexport const RelationshipElement = (props: any): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props}>\n <RelationshipElementComponent {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["getTranslation","Button","useConfig","useDocumentDrawer","useListDrawer","usePayloadAPI","useTranslation","React","useCallback","useReducer","useState","Transforms","ReactEditor","useFocused","useSelected","useSlateStatic","useElement","EnabledRelationshipsCondition","baseClass","initialParams","depth","RelationshipElementComponent","attributes","children","element","relationTo","value","fieldProps","config","collections","routes","api","serverURL","enabledCollectionSlugs","filter","admin","enableRichTextRelationship","map","slug","relatedCollection","setRelatedCollection","find","coll","selected","focused","i18n","t","editor","cacheBust","dispatchCacheBust","state","data","setParams","id","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","ListDrawer","ListDrawerToggler","closeListDrawer","collectionSlugs","selectedCollection","removeRelationship","elementPath","findPath","removeNodes","at","updateRelationship","doc","setNodes","type","text","swapRelationship","docID","div","className","Boolean","join","contentEditable","p","label","labels","singular","useAsTitle","disabled","field","readOnly","buttonStyle","el","icon","onClick","round","tooltip","e","preventDefault","onSave","onSelect","RelationshipElement","props"],"mappings":"AAAA;;AAEA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SACEC,MAAM,EACNC,SAAS,EACTC,iBAAiB,EACjBC,aAAa,EACbC,aAAa,EACbC,cAAc,QACT,iBAAgB;AACvB,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,UAAU,QAAQ,QAAO;AAClC,SAASC,WAAW,EAAEC,UAAU,EAAEC,WAAW,EAAEC,cAAc,QAAQ,cAAa;AAIlF,SAASC,UAAU,QAAQ,wCAAuC;AAClE,SAASC,6BAA6B,QAAQ,yCAAwC;AACtF,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,MAAMC,gBAAgB;IACpBC,OAAO;AACT;AAEA,MAAMC,+BAAyC;IAC7C,MAAM,EACJC,UAAU,EACVC,QAAQ,EACRC,OAAO,EACPA,SAAS,EAAEC,UAAU,EAAEC,KAAK,EAAE,EAC9BC,UAAU,EACX,GAAGX;IAEJ,MAAM,EACJY,QAAQ,EACNC,WAAW,EACXC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAG9B;IACJ,MAAM,CAAC+B,uBAAuB,GAAGvB,SAAS,IACxCmB,YACGK,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAEC,0BAA0B,EAAE,EAAE,GAAKA,4BACtDC,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,G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;4BAAEJ,WAAW,CAAC,EAAE1D,UAAU,OAAO,CAAC;sCAChCiC,IAAI,CAACZ,mBAAmBJ,OAAOiD,cAAc,KAAK;;;;;0BAIzD,MAACT;gBAAIC,WAAW,CAAC,EAAE1D,UAAU,SAAS,CAAC;;kCACrC,KAACyC;wBACCiB,WAAW,CAAC,EAAE1D,UAAU,qBAAqB,CAAC;wBAC9CmE,UAAU1D,YAAY2D,OAAOnD,OAAOoD;kCAEpC,cAAA,KAACtF;4BACCuF,aAAY;4BACZH,UAAU1D,YAAY2D,OAAOnD,OAAOoD;4BACpCE,IAAG;4BACHC,MAAK;4BACLC,SAAS;4BACP,aAAa;4BACf;4BACAC,KAAK;4BACLC,SAAS/C,EAAE;;;kCAGf,KAAC7C;wBACCuF,aAAY;wBACZZ,WAAW,CAAC,EAAE1D,UAAU,cAAc,CAAC;wBACvCmE,UAAU1D,YAAY2D,OAAOnD,OAAOoD;wBACpCG,MAAK;wBACLC,SAAS,CAACG;4BACRA,EAAEC,cAAc;4BAChBhC;wBACF;wBACA6B,KAAK;wBACLC,SAAS/C,EAAE;;;;YAGdpB,OAAO2B,oBAAM,KAACC;gBAAe0C,QAAQ5B;;0BACtC,KAACV;gBAAWuC,UAAUxB;;YACrBlD;;;AAGP;AAEA,OAAO,MAAM2E,sBAAsB,CAACC;IAClC,qBACE,KAAClF;QAA+B,GAAGkF,KAAK;kBACtC,cAAA,KAAC9E;YAA8B,GAAG8E,KAAK;;;AAG7C,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/elements/upload/Element/UploadDrawer/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAiBrD,OAAO,KAA2C,MAAM,OAAO,CAAA;AAI/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAIvD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAA;IACnC,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAA;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,sBAAsB,CAAA;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/elements/upload/Element/UploadDrawer/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAiBrD,OAAO,KAA2C,MAAM,OAAO,CAAA;AAI/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAIvD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAA;IACnC,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAA;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,sBAAsB,CAAA;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B,CA6HA,CAAA"}
|