@webiny/app-headless-cms-common 6.0.0-alpha.5 β 6.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Fields/ErrorBoundary.d.ts +1 -1
- package/Fields/ErrorBoundary.js +1 -1
- package/Fields/ErrorBoundary.js.map +1 -1
- package/Fields/FieldElement.d.ts +2 -2
- package/Fields/FieldElement.js +15 -9
- package/Fields/FieldElement.js.map +1 -1
- package/Fields/FieldElementError.js +1 -2
- package/Fields/FieldElementError.js.map +1 -1
- package/Fields/Fields.d.ts +1 -1
- package/Fields/Fields.js +11 -3
- package/Fields/Fields.js.map +1 -1
- package/Fields/index.d.ts +3 -3
- package/Fields/index.js +3 -3
- package/Fields/index.js.map +1 -1
- package/Fields/useBind.d.ts +1 -1
- package/Fields/useBind.js +5 -5
- package/Fields/useBind.js.map +1 -1
- package/Fields/useRenderPlugins.d.ts +1 -1
- package/Fields/useRenderPlugins.js.map +1 -1
- package/ModelFieldProvider/ModelFieldContext.d.ts +15 -13
- package/ModelFieldProvider/ModelFieldContext.js.map +1 -1
- package/ModelFieldProvider/index.d.ts +2 -2
- package/ModelFieldProvider/index.js +2 -2
- package/ModelFieldProvider/index.js.map +1 -1
- package/ModelFieldProvider/useModelField.d.ts +2 -3
- package/ModelFieldProvider/useModelField.js +1 -1
- package/ModelFieldProvider/useModelField.js.map +1 -1
- package/ModelProvider/ModelContext.d.ts +1 -1
- package/ModelProvider/ModelContext.js.map +1 -1
- package/ModelProvider/index.d.ts +2 -2
- package/ModelProvider/index.js +2 -2
- package/ModelProvider/index.js.map +1 -1
- package/ModelProvider/useModel.d.ts +1 -1
- package/ModelProvider/useModel.js +1 -1
- package/ModelProvider/useModel.js.map +1 -1
- package/README.md +6 -13
- package/constants.d.ts +1 -1
- package/constants.js +1 -1
- package/constants.js.map +1 -1
- package/createFieldsList.d.ts +5 -1
- package/createFieldsList.js +4 -0
- package/createFieldsList.js.map +1 -1
- package/createValidationContainer.d.ts +2 -2
- package/createValidationContainer.js +5 -8
- package/createValidationContainer.js.map +1 -1
- package/createValidators.d.ts +2 -2
- package/createValidators.js +1 -1
- package/createValidators.js.map +1 -1
- package/entries.graphql.d.ts +1 -1
- package/entries.graphql.js +36 -16
- package/entries.graphql.js.map +1 -1
- package/exports/admin/cms.d.ts +1 -0
- package/exports/admin/cms.js +3 -0
- package/exports/admin/cms.js.map +1 -0
- package/getModelTitleFieldId.d.ts +1 -1
- package/getModelTitleFieldId.js.map +1 -1
- package/index.d.ts +10 -10
- package/index.js +10 -10
- package/index.js.map +1 -1
- package/package.json +16 -21
- package/prepareFormData.d.ts +1 -1
- package/prepareFormData.js +1 -1
- package/prepareFormData.js.map +1 -1
- package/types/index.d.ts +24 -23
- package/types/index.js +0 -53
- package/types/index.js.map +1 -1
- package/types/model.d.ts +14 -12
- package/types/model.js.map +1 -1
- package/types/validation.d.ts +2 -2
- package/types/validation.js.map +1 -1
package/Fields/ErrorBoundary.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","FieldElementError","ErrorBoundary","Component","constructor","props","state","hasError","error","undefined","getDerivedStateFromError","componentDidCatch","errorInfo","field","console","groupCollapsed","fieldId","id","type","log","groupEnd","render","createElement","title","message","description","children"],"sources":["ErrorBoundary.tsx"],"sourcesContent":["import type { ErrorInfo } from \"react\";\nimport React from \"react\";\nimport type { CmsModelField } from \"~/types\";\nimport { FieldElementError } from \"./FieldElementError\";\n\ntype State =\n | {\n hasError: true;\n error: Error;\n }\n | { hasError: false; error: undefined };\n\ninterface Props {\n field: CmsModelField;\n [key: string]: any;\n}\n\nexport class ErrorBoundary extends React.Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = {\n hasError: false,\n error: undefined\n };\n }\n\n static getDerivedStateFromError(error: Error) {\n return {\n hasError: true,\n error\n };\n }\n\n public override componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n const { field } = this.props;\n if (!field) {\n return;\n }\n console.groupCollapsed(\n `%cFIELD ERROR%c: An error occurred while rendering model field \"${field.fieldId}\" (${field.id}) of type \"${field.type}\".`,\n \"color:red\",\n \"color:default\"\n );\n console.log(\"Field definition\", field);\n console.error(error, errorInfo);\n console.groupEnd();\n }\n\n public override render() {\n if (this.state.hasError) {\n return (\n <FieldElementError\n title={`Error: ${this.state.error.message}`}\n description={\"See developer console for more details.\"}\n />\n );\n }\n\n return this.props.children;\n }\n}\n"],"mappings":"AACA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,iBAAiB;AAc1B,OAAO,MAAMC,aAAa,SAASF,KAAK,CAACG,SAAS,CAAe;EAC7DC,WAAWA,CAACC,KAAY,EAAE;IACtB,KAAK,CAACA,KAAK,CAAC;IACZ,IAAI,CAACC,KAAK,GAAG;MACTC,QAAQ,EAAE,KAAK;MACfC,KAAK,EAAEC;IACX,CAAC;EACL;EAEA,OAAOC,wBAAwBA,CAACF,KAAY,EAAE;IAC1C,OAAO;MACHD,QAAQ,EAAE,IAAI;MACdC;IACJ,CAAC;EACL;EAEgBG,iBAAiBA,CAACH,KAAY,EAAEI,SAAoB,EAAE;IAClE,MAAM;MAAEC;IAAM,CAAC,GAAG,IAAI,CAACR,KAAK;IAC5B,IAAI,CAACQ,KAAK,EAAE;MACR;IACJ;IACAC,OAAO,CAACC,cAAc,CAClB,mEAAmEF,KAAK,CAACG,OAAO,MAAMH,KAAK,CAACI,EAAE,cAAcJ,KAAK,CAACK,IAAI,IAAI,EAC1H,WAAW,EACX,eACJ,CAAC;IACDJ,OAAO,CAACK,GAAG,CAAC,kBAAkB,EAAEN,KAAK,CAAC;IACtCC,OAAO,CAACN,KAAK,CAACA,KAAK,EAAEI,SAAS,CAAC;IAC/BE,OAAO,CAACM,QAAQ,CAAC,CAAC;EACtB;EAEgBC,MAAMA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACf,KAAK,CAACC,QAAQ,EAAE;MACrB,oBACIP,KAAA,CAAAsB,aAAA,CAACrB,iBAAiB;QACdsB,KAAK,EAAE,UAAU,IAAI,CAACjB,KAAK,CAACE,KAAK,CAACgB,OAAO,EAAG;QAC5CC,WAAW,EAAE;MAA0C,CAC1D,CAAC;IAEV;IAEA,OAAO,IAAI,CAACpB,KAAK,CAACqB,QAAQ;EAC9B;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","FieldElementError","ErrorBoundary","Component","constructor","props","state","hasError","error","undefined","getDerivedStateFromError","componentDidCatch","errorInfo","field","console","groupCollapsed","fieldId","id","type","log","groupEnd","render","createElement","title","message","description","children"],"sources":["ErrorBoundary.tsx"],"sourcesContent":["import type { ErrorInfo } from \"react\";\nimport React from \"react\";\nimport type { CmsModelField } from \"~/types/index.js\";\nimport { FieldElementError } from \"./FieldElementError.js\";\n\ntype State =\n | {\n hasError: true;\n error: Error;\n }\n | { hasError: false; error: undefined };\n\ninterface Props {\n field: CmsModelField;\n [key: string]: any;\n}\n\nexport class ErrorBoundary extends React.Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = {\n hasError: false,\n error: undefined\n };\n }\n\n static getDerivedStateFromError(error: Error) {\n return {\n hasError: true,\n error\n };\n }\n\n public override componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n const { field } = this.props;\n if (!field) {\n return;\n }\n console.groupCollapsed(\n `%cFIELD ERROR%c: An error occurred while rendering model field \"${field.fieldId}\" (${field.id}) of type \"${field.type}\".`,\n \"color:red\",\n \"color:default\"\n );\n console.log(\"Field definition\", field);\n console.error(error, errorInfo);\n console.groupEnd();\n }\n\n public override render() {\n if (this.state.hasError) {\n return (\n <FieldElementError\n title={`Error: ${this.state.error.message}`}\n description={\"See developer console for more details.\"}\n />\n );\n }\n\n return this.props.children;\n }\n}\n"],"mappings":"AACA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,iBAAiB;AAc1B,OAAO,MAAMC,aAAa,SAASF,KAAK,CAACG,SAAS,CAAe;EAC7DC,WAAWA,CAACC,KAAY,EAAE;IACtB,KAAK,CAACA,KAAK,CAAC;IACZ,IAAI,CAACC,KAAK,GAAG;MACTC,QAAQ,EAAE,KAAK;MACfC,KAAK,EAAEC;IACX,CAAC;EACL;EAEA,OAAOC,wBAAwBA,CAACF,KAAY,EAAE;IAC1C,OAAO;MACHD,QAAQ,EAAE,IAAI;MACdC;IACJ,CAAC;EACL;EAEgBG,iBAAiBA,CAACH,KAAY,EAAEI,SAAoB,EAAE;IAClE,MAAM;MAAEC;IAAM,CAAC,GAAG,IAAI,CAACR,KAAK;IAC5B,IAAI,CAACQ,KAAK,EAAE;MACR;IACJ;IACAC,OAAO,CAACC,cAAc,CAClB,mEAAmEF,KAAK,CAACG,OAAO,MAAMH,KAAK,CAACI,EAAE,cAAcJ,KAAK,CAACK,IAAI,IAAI,EAC1H,WAAW,EACX,eACJ,CAAC;IACDJ,OAAO,CAACK,GAAG,CAAC,kBAAkB,EAAEN,KAAK,CAAC;IACtCC,OAAO,CAACN,KAAK,CAACA,KAAK,EAAEI,SAAS,CAAC;IAC/BE,OAAO,CAACM,QAAQ,CAAC,CAAC;EACtB;EAEgBC,MAAMA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACf,KAAK,CAACC,QAAQ,EAAE;MACrB,oBACIP,KAAA,CAAAsB,aAAA,CAACrB,iBAAiB;QACdsB,KAAK,EAAE,UAAU,IAAI,CAACjB,KAAK,CAACE,KAAK,CAACgB,OAAO,EAAG;QAC5CC,WAAW,EAAE;MAA0C,CAC1D,CAAC;IAEV;IAEA,OAAO,IAAI,CAACpB,KAAK,CAACqB,QAAQ;EAC9B;AACJ","ignoreList":[]}
|
package/Fields/FieldElement.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type {
|
|
3
|
-
declare
|
|
2
|
+
import type { BindComponent, CmsEditorContentModel, CmsModelField } from "../types/index.js";
|
|
3
|
+
declare module "react" {
|
|
4
4
|
namespace JSX {
|
|
5
5
|
interface IntrinsicElements {
|
|
6
6
|
"hcms-model-field": {
|
package/Fields/FieldElement.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import get from "lodash/get";
|
|
2
|
+
import get from "lodash/get.js";
|
|
3
3
|
import { makeDecoratable } from "@webiny/app-admin";
|
|
4
|
-
import { i18n } from "@webiny/app/i18n";
|
|
5
|
-
import Label from "./Label";
|
|
6
|
-
import { useBind } from "./useBind";
|
|
7
|
-
import { useRenderPlugins } from "./useRenderPlugins";
|
|
8
|
-
import { ModelFieldProvider, useModelField } from "../ModelFieldProvider";
|
|
9
|
-
import { ErrorBoundary } from "./ErrorBoundary";
|
|
4
|
+
import { i18n } from "@webiny/app/i18n/index.js";
|
|
5
|
+
import Label from "./Label.js";
|
|
6
|
+
import { useBind } from "./useBind.js";
|
|
7
|
+
import { useRenderPlugins } from "./useRenderPlugins.js";
|
|
8
|
+
import { ModelFieldProvider, useModelField } from "../ModelFieldProvider/index.js";
|
|
9
|
+
import { ErrorBoundary } from "./ErrorBoundary.js";
|
|
10
10
|
const t = i18n.ns("app-headless-cms/admin/components/content-form");
|
|
11
11
|
const RenderField = props => {
|
|
12
12
|
const renderPlugins = useRenderPlugins();
|
|
@@ -28,9 +28,15 @@ const RenderField = props => {
|
|
|
28
28
|
contentModel
|
|
29
29
|
}));
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const fieldRendererName = get(field, "renderer.name");
|
|
32
|
+
if (!fieldRendererName) {
|
|
33
|
+
return t`Cannot render "{fieldName}" field - field renderer not defined.`({
|
|
34
|
+
fieldName: /*#__PURE__*/React.createElement("strong", null, field.fieldId)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const renderPlugin = renderPlugins.find(plugin => plugin.renderer.rendererName === fieldRendererName);
|
|
32
38
|
if (!renderPlugin) {
|
|
33
|
-
return t`Cannot render "{fieldName}" field - field renderer missing.`({
|
|
39
|
+
return t`Cannot render "{fieldName}" field - field renderer missing in Admin UI plugins.`({
|
|
34
40
|
fieldName: /*#__PURE__*/React.createElement("strong", null, field.fieldId)
|
|
35
41
|
});
|
|
36
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","get","makeDecoratable","i18n","Label","useBind","useRenderPlugins","ModelFieldProvider","useModelField","ErrorBoundary","t","ns","RenderField","props","renderPlugins","Bind","contentModel","field","getBind","renderer","createElement","Fragment","
|
|
1
|
+
{"version":3,"names":["React","get","makeDecoratable","i18n","Label","useBind","useRenderPlugins","ModelFieldProvider","useModelField","ErrorBoundary","t","ns","RenderField","props","renderPlugins","Bind","contentModel","field","getBind","renderer","createElement","Fragment","fieldRendererName","fieldName","fieldId","renderPlugin","find","plugin","rendererName","render","FieldElement","id","type","RenderFieldElement"],"sources":["FieldElement.tsx"],"sourcesContent":["import React from \"react\";\nimport get from \"lodash/get.js\";\nimport { makeDecoratable } from \"@webiny/app-admin\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport Label from \"./Label.js\";\nimport { useBind } from \"./useBind.js\";\nimport { useRenderPlugins } from \"./useRenderPlugins.js\";\nimport { ModelFieldProvider, useModelField } from \"../ModelFieldProvider/index.js\";\nimport type { BindComponent, CmsEditorContentModel, CmsModelField } from \"~/types/index.js\";\nimport { ErrorBoundary } from \"./ErrorBoundary.js\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/components/content-form\");\n\ndeclare module \"react\" {\n namespace JSX {\n interface IntrinsicElements {\n \"hcms-model-field\": {\n \"data-id\": string;\n \"data-type\": string;\n \"data-field-id\": string;\n children: React.ReactNode;\n };\n }\n }\n}\n\ntype RenderFieldProps = Omit<FieldElementProps, \"field\">;\n\nconst RenderField = (props: RenderFieldProps) => {\n const renderPlugins = useRenderPlugins();\n const { Bind, contentModel } = props;\n const { field } = useModelField();\n const getBind = useBind({ Bind });\n\n if (typeof field.renderer === \"function\") {\n return <>{field.renderer({ field, getBind, Label, contentModel })}</>;\n }\n\n const fieldRendererName = get(field, \"renderer.name\");\n if (!fieldRendererName) {\n return t`Cannot render \"{fieldName}\" field - field renderer not defined.`({\n fieldName: <strong>{field.fieldId}</strong>\n });\n }\n\n const renderPlugin = renderPlugins.find(\n plugin => plugin.renderer.rendererName === fieldRendererName\n );\n\n if (!renderPlugin) {\n return t`Cannot render \"{fieldName}\" field - field renderer missing in Admin UI plugins.`({\n fieldName: <strong>{field.fieldId}</strong>\n });\n }\n\n return <>{renderPlugin.renderer.render({ field, getBind, Label, contentModel })}</>;\n};\n\nexport interface FieldElementProps {\n field: CmsModelField;\n Bind: BindComponent;\n contentModel: CmsEditorContentModel;\n}\n\nexport const FieldElement = makeDecoratable(\n \"FieldElement\",\n ({ field, ...props }: FieldElementProps) => {\n if (!field) {\n return null;\n }\n\n return (\n <hcms-model-field\n data-id={field.id}\n data-field-id={field.fieldId}\n data-type={field.type}\n >\n <ErrorBoundary field={field}>\n <ModelFieldProvider field={field}>\n <RenderField {...props} />\n </ModelFieldProvider>\n </ErrorBoundary>\n </hcms-model-field>\n );\n }\n);\n\n/**\n * @deprecated Use `FieldElement` instead.\n */\nexport const RenderFieldElement = FieldElement;\n\n/**\n * @deprecated Use `FieldElementProps` instead.\n */\nexport type RenderFieldElementProps = FieldElementProps;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,GAAG,MAAM,eAAe;AAC/B,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,IAAI,QAAQ,2BAA2B;AAChD,OAAOC,KAAK;AACZ,SAASC,OAAO;AAChB,SAASC,gBAAgB;AACzB,SAASC,kBAAkB,EAAEC,aAAa;AAE1C,SAASC,aAAa;AAEtB,MAAMC,CAAC,GAAGP,IAAI,CAACQ,EAAE,CAAC,gDAAgD,CAAC;AAiBnE,MAAMC,WAAW,GAAIC,KAAuB,IAAK;EAC7C,MAAMC,aAAa,GAAGR,gBAAgB,CAAC,CAAC;EACxC,MAAM;IAAES,IAAI;IAAEC;EAAa,CAAC,GAAGH,KAAK;EACpC,MAAM;I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WAASH,KAAK,CAACc,EAAG;IAClB,iBAAed,KAAK,CAACO,OAAQ;IAC7B,aAAWP,KAAK,CAACe;EAAK,gBAEtBhC,KAAA,CAAAoB,aAAA,CAACX,aAAa;IAACQ,KAAK,EAAEA;EAAM,gBACxBjB,KAAA,CAAAoB,aAAA,CAACb,kBAAkB;IAACU,KAAK,EAAEA;EAAM,gBAC7BjB,KAAA,CAAAoB,aAAA,CAACR,WAAW,EAAKC,KAAQ,CACT,CACT,CACD,CAAC;AAE3B,CACJ,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMoB,kBAAkB,GAAGH,YAAY;;AAE9C;AACA;AACA","ignoreList":[]}
|
|
@@ -11,8 +11,7 @@ const StyledError = /*#__PURE__*/_styled("div", process.env.NODE_ENV === "produc
|
|
|
11
11
|
styles: "border:2px solid red;background-color:#f87e7e;border-radius:5px;padding:5px 10px"
|
|
12
12
|
} : {
|
|
13
13
|
name: "1ybf6v5",
|
|
14
|
-
styles: "border:2px solid red;background-color:#f87e7e;border-radius:5px;padding:5px 10px",
|
|
15
|
-
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkZpZWxkRWxlbWVudEVycm9yLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFHOEIiLCJmaWxlIjoiRmllbGRFbGVtZW50RXJyb3IudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0IGZyb20gXCJyZWFjdFwiO1xuaW1wb3J0IHN0eWxlZCBmcm9tIFwiQGVtb3Rpb24vc3R5bGVkXCI7XG5cbmNvbnN0IFN0eWxlZEVycm9yID0gc3R5bGVkLmRpdmBcbiAgICBib3JkZXI6IDJweCBzb2xpZCByZWQ7XG4gICAgYmFja2dyb3VuZC1jb2xvcjogI2Y4N2U3ZTtcbiAgICBib3JkZXItcmFkaXVzOiA1cHg7XG4gICAgcGFkZGluZzogNXB4IDEwcHg7XG5gO1xuXG5pbnRlcmZhY2UgRmllbGRFbGVtZW50RXJyb3JQcm9wcyB7XG4gICAgdGl0bGU6IHN0cmluZztcbiAgICBkZXNjcmlwdGlvbjogc3RyaW5nO1xufVxuXG5jb25zdCBzaG93RXJyb3IgPSBwcm9jZXNzLmVudi5OT0RFX0VOViA9PT0gXCJkZXZlbG9wbWVudFwiO1xuXG5leHBvcnQgY29uc3QgRmllbGRFbGVtZW50RXJyb3IgPSAocHJvcHM6IEZpZWxkRWxlbWVudEVycm9yUHJvcHMpID0+IHtcbiAgICBpZiAoIXNob3dFcnJvcikge1xuICAgICAgICByZXR1cm4gbnVsbDtcbiAgICB9XG5cbiAgICByZXR1cm4gKFxuICAgICAgICA8U3R5bGVkRXJyb3I+XG4gICAgICAgICAgICA8aDU+e3Byb3BzLnRpdGxlfTwvaDU+XG4gICAgICAgICAgICA8cD57cHJvcHMuZGVzY3JpcHRpb259PC9wPlxuICAgICAgICA8L1N0eWxlZEVycm9yPlxuICAgICk7XG59O1xuIl19 */",
|
|
14
|
+
styles: "border:2px solid red;background-color:#f87e7e;border-radius:5px;padding:5px 10px/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkZpZWxkRWxlbWVudEVycm9yLnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFHOEIiLCJmaWxlIjoiRmllbGRFbGVtZW50RXJyb3IudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0IGZyb20gXCJyZWFjdFwiO1xuaW1wb3J0IHN0eWxlZCBmcm9tIFwiQGVtb3Rpb24vc3R5bGVkXCI7XG5cbmNvbnN0IFN0eWxlZEVycm9yID0gc3R5bGVkLmRpdmBcbiAgICBib3JkZXI6IDJweCBzb2xpZCByZWQ7XG4gICAgYmFja2dyb3VuZC1jb2xvcjogI2Y4N2U3ZTtcbiAgICBib3JkZXItcmFkaXVzOiA1cHg7XG4gICAgcGFkZGluZzogNXB4IDEwcHg7XG5gO1xuXG5pbnRlcmZhY2UgRmllbGRFbGVtZW50RXJyb3JQcm9wcyB7XG4gICAgdGl0bGU6IHN0cmluZztcbiAgICBkZXNjcmlwdGlvbjogc3RyaW5nO1xufVxuXG5jb25zdCBzaG93RXJyb3IgPSBwcm9jZXNzLmVudi5OT0RFX0VOViA9PT0gXCJkZXZlbG9wbWVudFwiO1xuXG5leHBvcnQgY29uc3QgRmllbGRFbGVtZW50RXJyb3IgPSAocHJvcHM6IEZpZWxkRWxlbWVudEVycm9yUHJvcHMpID0+IHtcbiAgICBpZiAoIXNob3dFcnJvcikge1xuICAgICAgICByZXR1cm4gbnVsbDtcbiAgICB9XG5cbiAgICByZXR1cm4gKFxuICAgICAgICA8U3R5bGVkRXJyb3I+XG4gICAgICAgICAgICA8aDU+e3Byb3BzLnRpdGxlfTwvaDU+XG4gICAgICAgICAgICA8cD57cHJvcHMuZGVzY3JpcHRpb259PC9wPlxuICAgICAgICA8L1N0eWxlZEVycm9yPlxuICAgICk7XG59O1xuIl19 */",
|
|
16
15
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
17
16
|
});
|
|
18
17
|
const showError = process.env.NODE_ENV === "development";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","StyledError","_styled","process","env","NODE_ENV","target","label","name","styles","
|
|
1
|
+
{"version":3,"names":["React","StyledError","_styled","process","env","NODE_ENV","target","label","name","styles","toString","_EMOTION_STRINGIFIED_CSS_ERROR__","showError","FieldElementError","props","createElement","title","description"],"sources":["FieldElementError.tsx"],"sourcesContent":["import React from \"react\";\nimport styled from \"@emotion/styled\";\n\nconst StyledError = styled.div`\n border: 2px solid red;\n background-color: #f87e7e;\n border-radius: 5px;\n padding: 5px 10px;\n`;\n\ninterface FieldElementErrorProps {\n title: string;\n description: string;\n}\n\nconst showError = process.env.NODE_ENV === \"development\";\n\nexport const FieldElementError = (props: FieldElementErrorProps) => {\n if (!showError) {\n return null;\n }\n\n return (\n <StyledError>\n <h5>{props.title}</h5>\n <p>{props.description}</p>\n </StyledError>\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,MAAMC,WAAW,gBAAAC,OAAA,QAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAC,MAAA;AAAA;EAAAA,MAAA;EAAAC,KAAA;AAAA,GAAAJ,OAAA,CAAAC,GAAA,CAAAC,QAAA;EAAAG,IAAA;EAAAC,MAAA;AAAA;EAAAD,IAAA;EAAAC,MAAA;EAAAC,QAAA,EAAAC;AAAA,EAKhB;AAOD,MAAMC,SAAS,GAAGT,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa;AAExD,OAAO,MAAMQ,iBAAiB,GAAIC,KAA6B,IAAK;EAChE,IAAI,CAACF,SAAS,EAAE;IACZ,OAAO,IAAI;EACf;EAEA,oBACIZ,KAAA,CAAAe,aAAA,CAACd,WAAW,qBACRD,KAAA,CAAAe,aAAA,aAAKD,KAAK,CAACE,KAAU,CAAC,eACtBhB,KAAA,CAAAe,aAAA,YAAID,KAAK,CAACG,WAAe,CAChB,CAAC;AAEtB,CAAC","ignoreList":[]}
|
package/Fields/Fields.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { BindComponent, CmsEditorContentModel, CmsEditorFieldsLayout, CmsModelField } from "../types/index.js";
|
|
3
3
|
interface FieldsProps {
|
|
4
4
|
Bind: BindComponent;
|
|
5
5
|
contentModel: CmsEditorContentModel;
|
package/Fields/Fields.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Grid } from "@webiny/admin-ui";
|
|
3
|
-
import { FieldElement } from "./FieldElement";
|
|
4
|
-
import { FieldElementError } from "./FieldElementError";
|
|
2
|
+
import { Alert, Grid } from "@webiny/admin-ui";
|
|
3
|
+
import { FieldElement } from "./FieldElement.js";
|
|
4
|
+
import { FieldElementError } from "./FieldElementError.js";
|
|
5
5
|
const getFieldById = (fields, id) => {
|
|
6
6
|
return fields.find(field => field.id === id) || null;
|
|
7
7
|
};
|
|
8
|
+
const LayoutNotDefined = () => {
|
|
9
|
+
return /*#__PURE__*/React.createElement(Alert, {
|
|
10
|
+
type: "warning"
|
|
11
|
+
}, "You are missing the layout definition in your code content model. Please ensure you have the layout property correctly defined.");
|
|
12
|
+
};
|
|
8
13
|
export const Fields = ({
|
|
9
14
|
Bind,
|
|
10
15
|
fields,
|
|
@@ -12,6 +17,9 @@ export const Fields = ({
|
|
|
12
17
|
contentModel,
|
|
13
18
|
gridClassName
|
|
14
19
|
}) => {
|
|
20
|
+
if (!layout?.length) {
|
|
21
|
+
return /*#__PURE__*/React.createElement(LayoutNotDefined, null);
|
|
22
|
+
}
|
|
15
23
|
return /*#__PURE__*/React.createElement(Grid, {
|
|
16
24
|
className: gridClassName
|
|
17
25
|
}, layout.map((row, rowIndex) => /*#__PURE__*/React.createElement(React.Fragment, {
|
package/Fields/Fields.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Grid","FieldElement","FieldElementError","getFieldById","fields","id","find","field","Fields","Bind","layout","contentModel","gridClassName","
|
|
1
|
+
{"version":3,"names":["React","Alert","Grid","FieldElement","FieldElementError","getFieldById","fields","id","find","field","LayoutNotDefined","createElement","type","Fields","Bind","layout","contentModel","gridClassName","length","className","map","row","rowIndex","Fragment","key","Column","span","Math","floor","title","description"],"sources":["Fields.tsx"],"sourcesContent":["import React from \"react\";\nimport { Alert, type ColumnProps, Grid } from \"@webiny/admin-ui\";\nimport { FieldElement } from \"./FieldElement.js\";\nimport { FieldElementError } from \"./FieldElementError.js\";\nimport type {\n BindComponent,\n CmsEditorContentModel,\n CmsEditorFieldsLayout,\n CmsModelField\n} from \"~/types/index.js\";\n\ninterface FieldsProps {\n Bind: BindComponent;\n contentModel: CmsEditorContentModel;\n fields: CmsModelField[];\n layout: CmsEditorFieldsLayout;\n gridClassName?: string;\n}\n\nconst getFieldById = (fields: CmsModelField[], id: string): CmsModelField | null => {\n return fields.find(field => field.id === id) || null;\n};\n\nconst LayoutNotDefined = () => {\n return (\n <Alert type={\"warning\"}>\n You are missing the layout definition in your code content model. Please ensure you have\n the layout property correctly defined.\n </Alert>\n );\n};\n\nexport const Fields = ({ Bind, fields, layout, contentModel, gridClassName }: FieldsProps) => {\n if (!layout?.length) {\n return <LayoutNotDefined />;\n }\n\n return (\n <Grid className={gridClassName}>\n {layout.map((row, rowIndex) => (\n <React.Fragment key={rowIndex}>\n {row.map(id => {\n const field = getFieldById(fields, id) as CmsModelField;\n\n return (\n <Grid.Column\n span={Math.floor(12 / row.length) as ColumnProps[\"span\"]}\n key={id}\n >\n {field ? (\n <FieldElement\n field={field}\n Bind={Bind}\n contentModel={contentModel}\n />\n ) : (\n <FieldElementError\n title={`Missing field with id \"${id}\"!`}\n description={\n \"Make sure field layout contains the correct field ids (hint: check for typos).\"\n }\n />\n )}\n </Grid.Column>\n );\n })}\n </React.Fragment>\n ))}\n </Grid>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,KAAK,EAAoBC,IAAI,QAAQ,kBAAkB;AAChE,SAASC,YAAY;AACrB,SAASC,iBAAiB;AAgB1B,MAAMC,YAAY,GAAGA,CAACC,MAAuB,EAAEC,EAAU,KAA2B;EAChF,OAAOD,MAAM,CAACE,IAAI,CAACC,KAAK,IAAIA,KAAK,CAACF,EAAE,KAAKA,EAAE,CAAC,IAAI,IAAI;AACxD,CAAC;AAED,MAAMG,gBAAgB,GAAGA,CAAA,KAAM;EAC3B,oBACIV,KAAA,CAAAW,aAAA,CAACV,KAAK;IAACW,IAAI,EAAE;EAAU,GAAC,iIAGjB,CAAC;AAEhB,CAAC;AAED,OAAO,MAAMC,MAAM,GAAGA,CAAC;EAAEC,IAAI;EAAER,MAAM;EAAES,MAAM;EAAEC,YAAY;EAAEC;AAA2B,CAAC,KAAK;EAC1F,IAAI,CAACF,MAAM,EAAEG,MAAM,EAAE;IACjB,oBAAOlB,KAAA,CAAAW,aAAA,CAACD,gBAAgB,MAAE,CAAC;EAC/B;EAEA,oBACIV,KAAA,CAAAW,aAAA,CAACT,IAAI;IAACiB,SAAS,EAAEF;EAAc,GAC1BF,MAAM,CAACK,GAAG,CAAC,CAACC,GAAG,EAAEC,QAAQ,kBACtBtB,KAAA,CAAAW,aAAA,CAACX,KAAK,CAACuB,QAAQ;IAACC,GAAG,EAAEF;EAAS,GACzBD,GAAG,CAACD,GAAG,CAACb,EAAE,IAAI;IACX,MAAME,KAAK,GAAGJ,YAAY,CAACC,MAAM,EAAEC,EAAE,CAAkB;IAEvD,oBACIP,KAAA,CAAAW,aAAA,CAACT,IAAI,CAACuB,MAAM;MACRC,IAAI,EAAEC,IAAI,CAACC,KAAK,CAAC,EAAE,GAAGP,GAAG,CAACH,MAAM,CAAyB;MACzDM,GAAG,EAAEjB;IAAG,GAEPE,KAAK,gBACFT,KAAA,CAAAW,aAAA,CAACR,YAAY;MACTM,KAAK,EAAEA,KAAM;MACbK,IAAI,EAAEA,IAAK;MACXE,YAAY,EAAEA;IAAa,CAC9B,CAAC,gBAEFhB,KAAA,CAAAW,aAAA,CAACP,iBAAiB;MACdyB,KAAK,EAAE,0BAA0BtB,EAAE,IAAK;MACxCuB,WAAW,EACP;IACH,CACJ,CAEI,CAAC;EAEtB,CAAC,CACW,CACnB,CACC,CAAC;AAEf,CAAC","ignoreList":[]}
|
package/Fields/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./FieldElement";
|
|
2
|
-
export * from "./Fields";
|
|
3
|
-
export * from "./useBind";
|
|
1
|
+
export * from "./FieldElement.js";
|
|
2
|
+
export * from "./Fields.js";
|
|
3
|
+
export * from "./useBind.js";
|
package/Fields/index.js
CHANGED
package/Fields/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./FieldElement\";\nexport * from \"./Fields\";\nexport * from \"./useBind\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./FieldElement.js\";\nexport * from \"./Fields.js\";\nexport * from \"./useBind.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
|
package/Fields/useBind.d.ts
CHANGED
package/Fields/useBind.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useRef, cloneElement } from "react";
|
|
2
2
|
import { useForm } from "@webiny/form";
|
|
3
|
-
import { createValidators } from "../createValidators";
|
|
4
|
-
import { useModelField } from "../ModelFieldProvider";
|
|
5
|
-
import { createValidationContainer } from "../createValidationContainer";
|
|
3
|
+
import { createValidators } from "../createValidators.js";
|
|
4
|
+
import { useModelField } from "../ModelFieldProvider/index.js";
|
|
5
|
+
import { createValidationContainer } from "../createValidationContainer.js";
|
|
6
6
|
const createFieldCacheKey = field => {
|
|
7
7
|
return [field.id, field.fieldId, JSON.stringify(field.validation), JSON.stringify(field.listValidation)].join(";");
|
|
8
8
|
};
|
|
@@ -30,7 +30,7 @@ export function useBind({
|
|
|
30
30
|
}
|
|
31
31
|
const validators = createValidators(field, field.validation || emptyValidators);
|
|
32
32
|
const listValidators = createValidators(field, field.listValidation || emptyValidators);
|
|
33
|
-
const isMultipleValues = index === -1 && field.
|
|
33
|
+
const isMultipleValues = index === -1 && field.list;
|
|
34
34
|
const inputValidators = isMultipleValues ? listValidators : validators;
|
|
35
35
|
|
|
36
36
|
// We only use default values for single-value fields.
|
|
@@ -57,7 +57,7 @@ export function useBind({
|
|
|
57
57
|
const props = {
|
|
58
58
|
...bind
|
|
59
59
|
};
|
|
60
|
-
if (field.
|
|
60
|
+
if (field.list && index === -1) {
|
|
61
61
|
props.appendValue = (newValue, index) => {
|
|
62
62
|
const currentValue = bind.value || [];
|
|
63
63
|
const newIndex = index ?? currentValue.length;
|
package/Fields/useBind.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useRef","cloneElement","useForm","createValidators","useModelField","createValidationContainer","createFieldCacheKey","field","id","fieldId","JSON","stringify","validation","listValidation","join","emptyValidators","useBind","Bind","memoizedBindComponents","cacheKey","form","index","parentName","name","undefined","filter","v","componentId","current","validators","listValidators","isMultipleValues","multipleValues","inputValidators","defaultValueFromSettings","settings","defaultValue","UseBind","params","childName","childValidators","children","createElement","context","bind","props","appendValue","newValue","currentValue","value","newIndex","length","onChange","slice","prependValue","appendValues","newValues","removeValue","validateInput","moveValueUp","splice","moveValueDown","displayName","ValidationContainer"],"sources":["useBind.tsx"],"sourcesContent":["import React, { useRef, cloneElement } from \"react\";\nimport type { Validator } from \"@webiny/validation/types\";\nimport { useForm } from \"@webiny/form\";\nimport { createValidators } from \"~/createValidators\";\nimport type { BindComponent, CmsModelField } from \"~/types\";\nimport { useModelField } from \"~/ModelFieldProvider\";\nimport { createValidationContainer } from \"~/createValidationContainer\";\n\ninterface UseBindProps {\n Bind: BindComponent;\n}\n\ninterface UseBindParams {\n name?: string;\n validators?: Validator | Validator[];\n children?: any;\n defaultValue?: any;\n}\n\nconst createFieldCacheKey = (field: CmsModelField) => {\n return [\n field.id,\n field.fieldId,\n JSON.stringify(field.validation),\n JSON.stringify(field.listValidation)\n ].join(\";\");\n};\n\nexport interface GetBindCallable {\n (index?: number): BindComponent;\n}\n\nconst emptyValidators: Validator[] = [];\n\nexport function useBind({ Bind }: UseBindProps) {\n const { field } = useModelField();\n const memoizedBindComponents = useRef<Record<string, BindComponent>>({});\n const cacheKey = createFieldCacheKey(field);\n const form = useForm();\n\n return (index = -1) => {\n const { parentName } = Bind;\n\n // If there's a parent name assigned to the given Bind component, we need to include it in the new field \"name\".\n // This allows us to have nested fields (like \"object\" field with nested properties)\n const name = [parentName, field.fieldId, index >= 0 ? index : undefined]\n .filter(v => v !== undefined)\n .join(\".\");\n\n const componentId = `${name};${cacheKey}`;\n\n if (memoizedBindComponents.current[componentId]) {\n return memoizedBindComponents.current[componentId];\n }\n\n const validators = createValidators(field, field.validation || emptyValidators);\n const listValidators = createValidators(field, field.listValidation || emptyValidators);\n const isMultipleValues = index === -1 && field.multipleValues;\n const inputValidators = isMultipleValues ? listValidators : validators;\n\n // We only use default values for single-value fields.\n const defaultValueFromSettings = !isMultipleValues ? field.settings?.defaultValue : null;\n\n memoizedBindComponents.current[componentId] = function UseBind(params: UseBindParams) {\n const {\n name: childName,\n validators: childValidators,\n children,\n defaultValue = defaultValueFromSettings\n } = params;\n\n const { field } = useModelField();\n\n return (\n <Bind\n name={childName || name}\n validators={childValidators || inputValidators}\n defaultValue={defaultValue ?? null}\n context={{ field }}\n >\n {bind => {\n // Multiple-values functions below.\n const props = { ...bind };\n if (field.multipleValues && index === -1) {\n props.appendValue = (newValue: any, index?: number) => {\n const currentValue = bind.value || [];\n const newIndex = index ?? currentValue.length;\n\n bind.onChange([\n ...currentValue.slice(0, newIndex),\n newValue,\n ...currentValue.slice(newIndex)\n ]);\n };\n props.prependValue = (newValue: any) => {\n bind.onChange([newValue, ...(bind.value || [])]);\n };\n props.appendValues = (newValues: any[]) => {\n bind.onChange([...(bind.value || []), ...newValues]);\n };\n\n props.removeValue = (index: number) => {\n if (index < 0) {\n return;\n }\n\n const value = [\n ...bind.value.slice(0, index),\n ...bind.value.slice(index + 1)\n ];\n\n bind.onChange(value.length === 0 ? null : value);\n\n // To make sure the field is still valid, we must trigger validation.\n form.validateInput(field.fieldId);\n };\n\n props.moveValueUp = (index: number) => {\n if (index <= 0) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index - 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n\n props.moveValueDown = (index: number) => {\n if (index >= bind.value.length) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index + 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n }\n\n return typeof children === \"function\"\n ? children(props)\n : cloneElement(children, props);\n }}\n </Bind>\n );\n } as BindComponent;\n\n // We need to keep track of current field name, to support nested fields.\n memoizedBindComponents.current[componentId].parentName = name;\n memoizedBindComponents.current[componentId].displayName = `Bind<${name}>`;\n memoizedBindComponents.current[componentId].ValidationContainer =\n createValidationContainer(name);\n\n return memoizedBindComponents.current[componentId];\n };\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,YAAY,QAAQ,OAAO;AAEnD,SAASC,OAAO,QAAQ,cAAc;AACtC,SAASC,gBAAgB;AAEzB,SAASC,aAAa;AACtB,SAASC,yBAAyB;AAalC,MAAMC,mBAAmB,GAAIC,KAAoB,IAAK;EAClD,OAAO,CACHA,KAAK,CAACC,EAAE,EACRD,KAAK,CAACE,OAAO,EACbC,IAAI,CAACC,SAAS,CAACJ,KAAK,CAACK,UAAU,CAAC,EAChCF,IAAI,CAACC,SAAS,CAACJ,KAAK,CAACM,cAAc,CAAC,CACvC,CAACC,IAAI,CAAC,GAAG,CAAC;AACf,CAAC;AAMD,MAAMC,eAA4B,GAAG,EAAE;AAEvC,OAAO,SAASC,OAAOA,CAAC;EAAEC;AAAmB,CAAC,EAAE;EAC5C,MAAM;IAAEV;EAAM,CAAC,GAAGH,aAAa,CAAC,CAAC;EACjC,MAAMc,sBAAsB,GAAGlB,MAAM,CAAgC,CAAC,CAAC,CAAC;EACxE,MAAMmB,QAAQ,GAAGb,mBAAmB,CAACC,KAAK,CAAC;EAC3C,MAAMa,IAAI,GAAGlB,OAAO,CAAC,CAAC;EAEtB,OAAO,CAACmB,KAAK,GAAG,CAAC,CAAC,KAAK;IACnB,MAAM;MAAEC;IAAW,CAAC,GAAGL,IAAI;;IAE3B;IACA;IACA,MAAMM,IAAI,GAAG,CAACD,UAAU,EAAEf,KAAK,CAACE,OAAO,EAAEY,KAAK,IAAI,CAAC,GAAGA,KAAK,GAAGG,SAAS,CAAC,CACnEC,MAAM,CAACC,CAAC,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C,OAAOL,sBAAsB,CAACU,OAAO,CAACD,WAAW,CAAC;EACtD,CAAC;AACL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useRef","cloneElement","useForm","createValidators","useModelField","createValidationContainer","createFieldCacheKey","field","id","fieldId","JSON","stringify","validation","listValidation","join","emptyValidators","useBind","Bind","memoizedBindComponents","cacheKey","form","index","parentName","name","undefined","filter","v","componentId","current","validators","listValidators","isMultipleValues","list","inputValidators","defaultValueFromSettings","settings","defaultValue","UseBind","params","childName","childValidators","children","createElement","context","bind","props","appendValue","newValue","currentValue","value","newIndex","length","onChange","slice","prependValue","appendValues","newValues","removeValue","validateInput","moveValueUp","splice","moveValueDown","displayName","ValidationContainer"],"sources":["useBind.tsx"],"sourcesContent":["import React, { useRef, cloneElement } from \"react\";\nimport type { Validator } from \"@webiny/validation/types.js\";\nimport { useForm } from \"@webiny/form\";\nimport { createValidators } from \"~/createValidators.js\";\nimport type { BindComponent, CmsModelField } from \"~/types/index.js\";\nimport { useModelField } from \"~/ModelFieldProvider/index.js\";\nimport { createValidationContainer } from \"~/createValidationContainer.js\";\n\ninterface UseBindProps {\n Bind: BindComponent;\n}\n\ninterface UseBindParams {\n name?: string;\n validators?: Validator | Validator[];\n children?: any;\n defaultValue?: any;\n}\n\nconst createFieldCacheKey = (field: CmsModelField) => {\n return [\n field.id,\n field.fieldId,\n JSON.stringify(field.validation),\n JSON.stringify(field.listValidation)\n ].join(\";\");\n};\n\nexport interface GetBindCallable {\n (index?: number): BindComponent;\n}\n\nconst emptyValidators: Validator[] = [];\n\nexport function useBind({ Bind }: UseBindProps) {\n const { field } = useModelField();\n const memoizedBindComponents = useRef<Record<string, BindComponent>>({});\n const cacheKey = createFieldCacheKey(field);\n const form = useForm();\n\n return (index = -1) => {\n const { parentName } = Bind;\n\n // If there's a parent name assigned to the given Bind component, we need to include it in the new field \"name\".\n // This allows us to have nested fields (like \"object\" field with nested properties)\n const name = [parentName, field.fieldId, index >= 0 ? index : undefined]\n .filter(v => v !== undefined)\n .join(\".\");\n\n const componentId = `${name};${cacheKey}`;\n\n if (memoizedBindComponents.current[componentId]) {\n return memoizedBindComponents.current[componentId];\n }\n\n const validators = createValidators(field, field.validation || emptyValidators);\n const listValidators = createValidators(field, field.listValidation || emptyValidators);\n const isMultipleValues = index === -1 && field.list;\n const inputValidators = isMultipleValues ? listValidators : validators;\n\n // We only use default values for single-value fields.\n const defaultValueFromSettings = !isMultipleValues ? field.settings?.defaultValue : null;\n\n memoizedBindComponents.current[componentId] = function UseBind(params: UseBindParams) {\n const {\n name: childName,\n validators: childValidators,\n children,\n defaultValue = defaultValueFromSettings\n } = params;\n\n const { field } = useModelField();\n\n return (\n <Bind\n name={childName || name}\n validators={childValidators || inputValidators}\n defaultValue={defaultValue ?? null}\n context={{ field }}\n >\n {bind => {\n // Multiple-values functions below.\n const props = { ...bind };\n if (field.list && index === -1) {\n props.appendValue = (newValue: any, index?: number) => {\n const currentValue = bind.value || [];\n const newIndex = index ?? currentValue.length;\n\n bind.onChange([\n ...currentValue.slice(0, newIndex),\n newValue,\n ...currentValue.slice(newIndex)\n ]);\n };\n props.prependValue = (newValue: any) => {\n bind.onChange([newValue, ...(bind.value || [])]);\n };\n props.appendValues = (newValues: any[]) => {\n bind.onChange([...(bind.value || []), ...newValues]);\n };\n\n props.removeValue = (index: number) => {\n if (index < 0) {\n return;\n }\n\n const value = [\n ...bind.value.slice(0, index),\n ...bind.value.slice(index + 1)\n ];\n\n bind.onChange(value.length === 0 ? null : value);\n\n // To make sure the field is still valid, we must trigger validation.\n form.validateInput(field.fieldId);\n };\n\n props.moveValueUp = (index: number) => {\n if (index <= 0) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index - 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n\n props.moveValueDown = (index: number) => {\n if (index >= bind.value.length) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index + 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n }\n\n return typeof children === \"function\"\n ? children(props)\n : cloneElement(children, props);\n }}\n </Bind>\n );\n } as BindComponent;\n\n // We need to keep track of current field name, to support nested fields.\n memoizedBindComponents.current[componentId].parentName = name;\n memoizedBindComponents.current[componentId].displayName = `Bind<${name}>`;\n memoizedBindComponents.current[componentId].ValidationContainer =\n createValidationContainer(name);\n\n return memoizedBindComponents.current[componentId];\n };\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,YAAY,QAAQ,OAAO;AAEnD,SAASC,OAAO,QAAQ,cAAc;AACtC,SAASC,gBAAgB;AAEzB,SAASC,aAAa;AACtB,SAASC,yBAAyB;AAalC,MAAMC,mBAAmB,GAAIC,KAAoB,IAAK;EAClD,OAAO,CACHA,KAAK,CAACC,EAAE,EACRD,KAAK,CAACE,OAAO,EACbC,IAAI,CAACC,SAAS,CAACJ,KAAK,CAACK,UAAU,CAAC,EAChCF,IAAI,CAACC,SAAS,CAACJ,KAAK,CAACM,cAAc,CAAC,CACvC,CAACC,IAAI,CAAC,GAAG,CAAC;AACf,CAAC;AAMD,MAAMC,eAA4B,GAAG,EAAE;AAEvC,OAAO,SAASC,OAAOA,CAAC;EAAEC;AAAmB,CAAC,EAAE;EAC5C,MAAM;IAAEV;EAAM,CAAC,GAAGH,aAAa,CAAC,CAAC;EACjC,MAAMc,sBAAsB,GAAGlB,MAAM,CAAgC,CAAC,CAAC,CAAC;EACxE,MAAMmB,QAAQ,GAAGb,mBAAmB,CAACC,KAAK,CAAC;EAC3C,MAAMa,IAAI,GAAGlB,OAAO,CAAC,CAAC;EAEtB,OAAO,CAACmB,KAAK,GAAG,CAAC,CAAC,KAAK;IACnB,MAAM;MAAEC;IAAW,CAAC,GAAGL,IAAI;;IAE3B;IACA;IACA,MAAMM,IAAI,GAAG,CAACD,UAAU,EAAEf,KAAK,CAACE,OAAO,EAAEY,KAAK,IAAI,CAAC,GAAGA,KAAK,GAAGG,SAAS,CAAC,CACnEC,MAAM,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,CAAC;IAEnC,OAAOL,sBAAsB,CAACU,OAAO,CAACD,WAAW,CAAC;EACtD,CAAC;AACL","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useRenderPlugins(): import("@webiny/plugins/PluginsContainer").WithName<import("
|
|
1
|
+
export declare function useRenderPlugins(): import("@webiny/plugins/PluginsContainer").WithName<import("~/types/index.js").CmsModelFieldRendererPlugin>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["plugins","useMemo","useRenderPlugins","byType"],"sources":["useRenderPlugins.ts"],"sourcesContent":["import { plugins } from \"@webiny/plugins\";\nimport { useMemo } from \"react\";\nimport type { CmsEditorFieldRendererPlugin } from \"~/types\";\n\nexport function useRenderPlugins() {\n return useMemo(\n () => plugins.byType<CmsEditorFieldRendererPlugin>(\"cms-editor-field-renderer\"),\n []\n );\n}\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,iBAAiB;AACzC,SAASC,OAAO,QAAQ,OAAO;AAG/B,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EAC/B,OAAOD,OAAO,CACV,MAAMD,OAAO,CAACG,MAAM,CAA+B,2BAA2B,CAAC,EAC/E,EACJ,CAAC;AACL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["plugins","useMemo","useRenderPlugins","byType"],"sources":["useRenderPlugins.ts"],"sourcesContent":["import { plugins } from \"@webiny/plugins\";\nimport { useMemo } from \"react\";\nimport type { CmsEditorFieldRendererPlugin } from \"~/types/index.js\";\n\nexport function useRenderPlugins() {\n return useMemo(\n () => plugins.byType<CmsEditorFieldRendererPlugin>(\"cms-editor-field-renderer\"),\n []\n );\n}\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,iBAAiB;AACzC,SAASC,OAAO,QAAQ,OAAO;AAG/B,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EAC/B,OAAOD,OAAO,CACV,MAAMD,OAAO,CAACG,MAAM,CAA+B,2BAA2B,CAAC,EAC/E,EACJ,CAAC;AACL","ignoreList":[]}
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { CmsModelField } from "../types";
|
|
2
|
+
import type { CmsModelField } from "../types/index.js";
|
|
3
3
|
export type ModelFieldContext = CmsModelField;
|
|
4
4
|
export declare const ModelFieldContext: React.Context<{
|
|
5
5
|
id: string;
|
|
6
6
|
type: string;
|
|
7
|
-
fieldId:
|
|
8
|
-
storageId?: string
|
|
7
|
+
fieldId: import("~/types/index.js").CmsEditorFieldId;
|
|
8
|
+
storageId?: string;
|
|
9
9
|
label: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
help?: string | React.ReactNode;
|
|
11
|
+
description?: string | React.ReactNode;
|
|
12
|
+
note?: string | React.ReactNode;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
validation?: (import("~/types/index.js").CmsModelFieldValidator | import("@webiny/validation/types").Validator)[];
|
|
15
|
+
listValidation?: import("~/types/index.js").CmsModelFieldValidator[];
|
|
16
|
+
list?: boolean;
|
|
17
|
+
predefinedValues?: import("~/types/index.js").CmsEditorFieldPredefinedValues;
|
|
18
|
+
settings?: import("~/types/index.js").CmsModelFieldSettings<unknown> | undefined;
|
|
17
19
|
renderer: {
|
|
18
20
|
name: string;
|
|
19
|
-
settings?: Record<string, any
|
|
20
|
-
} |
|
|
21
|
-
tags?: string[]
|
|
21
|
+
settings?: Record<string, any>;
|
|
22
|
+
} | import("~/types/index.js").CmsModelFieldRendererPlugin["renderer"]["render"];
|
|
23
|
+
tags?: string[];
|
|
22
24
|
} | undefined>;
|
|
23
25
|
export interface ModelFieldProviderProps {
|
|
24
26
|
field: CmsModelField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","createGenericContext","ModelFieldContext","createContext","undefined","ModelFieldProvider","field","children","createElement","Provider","value","useHook","ParentValueIndexProvider","useParentValueIndex","context","index"],"sources":["ModelFieldContext.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CmsModelField } from \"~/types\";\nimport { createGenericContext } from \"@webiny/app-admin\";\n\nexport type ModelFieldContext = CmsModelField;\n\nexport const ModelFieldContext = React.createContext<ModelFieldContext | undefined>(undefined);\n\nexport interface ModelFieldProviderProps {\n field: CmsModelField;\n children: React.ReactNode;\n}\n\nexport const ModelFieldProvider = ({ field, children }: ModelFieldProviderProps) => {\n return <ModelFieldContext.Provider value={field}>{children}</ModelFieldContext.Provider>;\n};\n\nconst { Provider, useHook } = createGenericContext<{ index: number }>(\"FieldIndex\");\n\nexport const ParentValueIndexProvider = Provider;\n\nexport const useParentValueIndex = () => {\n try {\n const context = useHook();\n return context.index;\n } catch {\n return -1;\n }\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,oBAAoB,QAAQ,mBAAmB;AAIxD,OAAO,MAAMC,iBAAiB,gBAAGF,KAAK,CAACG,aAAa,CAAgCC,SAAS,CAAC;AAO9F,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAkC,CAAC,KAAK;EAChF,oBAAOP,KAAA,CAAAQ,aAAA,CAACN,iBAAiB,CAACO,QAAQ;IAACC,KAAK,EAAEJ;EAAM,GAAEC,QAAqC,CAAC;AAC5F,CAAC;AAED,MAAM;EAAEE,QAAQ;EAAEE;AAAQ,CAAC,GAAGV,oBAAoB,CAAoB,YAAY,CAAC;AAEnF,OAAO,MAAMW,wBAAwB,GAAGH,QAAQ;AAEhD,OAAO,MAAMI,mBAAmB,GAAGA,CAAA,KAAM;EACrC,IAAI;IACA,MAAMC,OAAO,GAAGH,OAAO,CAAC,CAAC;IACzB,OAAOG,OAAO,CAACC,KAAK;EACxB,CAAC,CAAC,MAAM;IACJ,OAAO,CAAC,CAAC;EACb;AACJ,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","createGenericContext","ModelFieldContext","createContext","undefined","ModelFieldProvider","field","children","createElement","Provider","value","useHook","ParentValueIndexProvider","useParentValueIndex","context","index"],"sources":["ModelFieldContext.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CmsModelField } from \"~/types/index.js\";\nimport { createGenericContext } from \"@webiny/app-admin\";\n\nexport type ModelFieldContext = CmsModelField;\n\nexport const ModelFieldContext = React.createContext<ModelFieldContext | undefined>(undefined);\n\nexport interface ModelFieldProviderProps {\n field: CmsModelField;\n children: React.ReactNode;\n}\n\nexport const ModelFieldProvider = ({ field, children }: ModelFieldProviderProps) => {\n return <ModelFieldContext.Provider value={field}>{children}</ModelFieldContext.Provider>;\n};\n\nconst { Provider, useHook } = createGenericContext<{ index: number }>(\"FieldIndex\");\n\nexport const ParentValueIndexProvider = Provider;\n\nexport const useParentValueIndex = () => {\n try {\n const context = useHook();\n return context.index;\n } catch {\n return -1;\n }\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,oBAAoB,QAAQ,mBAAmB;AAIxD,OAAO,MAAMC,iBAAiB,gBAAGF,KAAK,CAACG,aAAa,CAAgCC,SAAS,CAAC;AAO9F,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAkC,CAAC,KAAK;EAChF,oBAAOP,KAAA,CAAAQ,aAAA,CAACN,iBAAiB,CAACO,QAAQ;IAACC,KAAK,EAAEJ;EAAM,GAAEC,QAAqC,CAAC;AAC5F,CAAC;AAED,MAAM;EAAEE,QAAQ;EAAEE;AAAQ,CAAC,GAAGV,oBAAoB,CAAoB,YAAY,CAAC;AAEnF,OAAO,MAAMW,wBAAwB,GAAGH,QAAQ;AAEhD,OAAO,MAAMI,mBAAmB,GAAGA,CAAA,KAAM;EACrC,IAAI;IACA,MAAMC,OAAO,GAAGH,OAAO,CAAC,CAAC;IACzB,OAAOG,OAAO,CAACC,KAAK;EACxB,CAAC,CAAC,MAAM;IACJ,OAAO,CAAC,CAAC;EACb;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./ModelFieldContext";
|
|
2
|
-
export * from "./useModelField";
|
|
1
|
+
export * from "./ModelFieldContext.js";
|
|
2
|
+
export * from "./useModelField.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ModelFieldContext\";\nexport * from \"./useModelField\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ModelFieldContext.js\";\nexport * from \"./useModelField.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import type { CmsModelField, CmsModelFieldTypePlugin } from "../types";
|
|
1
|
+
import type { CmsModelField, CmsModelFieldTypePlugin } from "../types/index.js";
|
|
3
2
|
export interface UseModelField {
|
|
4
3
|
field: CmsModelField;
|
|
5
4
|
parentValueIndex: number;
|
|
@@ -12,5 +11,5 @@ export declare const useModelField: import("@webiny/react-composition").GenericH
|
|
|
12
11
|
original: import("@webiny/react-composition").GenericHook<unknown, UseModelField>;
|
|
13
12
|
originalName: string;
|
|
14
13
|
} & {
|
|
15
|
-
createDecorator: (decorator: import("@webiny/react-composition").Decorator<() => UseModelField>) => () =>
|
|
14
|
+
createDecorator: (decorator: import("@webiny/react-composition").Decorator<() => UseModelField>) => () => React.JSX.Element;
|
|
16
15
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
2
|
import { plugins } from "@webiny/plugins";
|
|
3
3
|
import { makeDecoratable } from "@webiny/react-composition";
|
|
4
|
-
import { ModelFieldContext, useParentValueIndex } from "./ModelFieldContext";
|
|
4
|
+
import { ModelFieldContext, useParentValueIndex } from "./ModelFieldContext.js";
|
|
5
5
|
const getFieldPlugin = type => {
|
|
6
6
|
const plugin = plugins.byType("cms-editor-field-type").find(plugin => plugin.field.type === type);
|
|
7
7
|
if (!plugin) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useContext","plugins","makeDecoratable","ModelFieldContext","useParentValueIndex","getFieldPlugin","type","plugin","byType","find","field","Error","useModelField","parentValueIndex","fieldPlugin"],"sources":["useModelField.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { ModelFieldContext, useParentValueIndex } from \"./ModelFieldContext\";\nimport type { CmsModelField, CmsModelFieldTypePlugin } from \"~/types\";\n\ninterface GetFieldPlugin {\n (type: string): CmsModelFieldTypePlugin;\n}\n\nconst getFieldPlugin: GetFieldPlugin = type => {\n const plugin = plugins\n .byType<CmsModelFieldTypePlugin>(\"cms-editor-field-type\")\n .find(plugin => plugin.field.type === type);\n\n if (!plugin) {\n throw Error(`Missing plugin for field type \"${type}\"!`);\n }\n\n return plugin;\n};\n\nexport interface UseModelField {\n field: CmsModelField;\n parentValueIndex: number;\n fieldPlugin: CmsModelFieldTypePlugin;\n}\n\n/**\n * Get model field from the current context.\n */\nexport const useModelField = makeDecoratable((): UseModelField => {\n const field = useContext(ModelFieldContext);\n const parentValueIndex = useParentValueIndex();\n\n if (!field) {\n throw Error(\n `Missing \"ModelFieldProvider\" in the component tree. Are you using the \"useModelField()\" hook in the right place?`\n );\n }\n\n const fieldPlugin = getFieldPlugin(field.type);\n\n return { field, fieldPlugin, parentValueIndex };\n});\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,iBAAiB,EAAEC,mBAAmB;AAO/C,MAAMC,cAA8B,GAAGC,IAAI,IAAI;EAC3C,MAAMC,MAAM,GAAGN,OAAO,CACjBO,MAAM,CAA0B,uBAAuB,CAAC,CACxDC,IAAI,CAACF,MAAM,IAAIA,MAAM,CAACG,KAAK,CAACJ,IAAI,KAAKA,IAAI,CAAC;EAE/C,IAAI,CAACC,MAAM,EAAE;IACT,MAAMI,KAAK,CAAC,kCAAkCL,IAAI,IAAI,CAAC;EAC3D;EAEA,OAAOC,MAAM;AACjB,CAAC;AAQD;AACA;AACA;AACA,OAAO,MAAMK,aAAa,GAAGV,eAAe,CAAC,MAAqB;EAC9D,MAAMQ,KAAK,GAAGV,UAAU,CAACG,iBAAiB,CAAC;EAC3C,MAAMU,gBAAgB,GAAGT,mBAAmB,CAAC,CAAC;EAE9C,IAAI,CAACM,KAAK,EAAE;IACR,MAAMC,KAAK,CACP,kHACJ,CAAC;EACL;EAEA,MAAMG,WAAW,GAAGT,cAAc,CAACK,KAAK,CAACJ,IAAI,CAAC;EAE9C,OAAO;IAAEI,KAAK;IAAEI,WAAW;IAAED;EAAiB,CAAC;AACnD,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useContext","plugins","makeDecoratable","ModelFieldContext","useParentValueIndex","getFieldPlugin","type","plugin","byType","find","field","Error","useModelField","parentValueIndex","fieldPlugin"],"sources":["useModelField.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { ModelFieldContext, useParentValueIndex } from \"./ModelFieldContext.js\";\nimport type { CmsModelField, CmsModelFieldTypePlugin } from \"~/types/index.js\";\n\ninterface GetFieldPlugin {\n (type: string): CmsModelFieldTypePlugin;\n}\n\nconst getFieldPlugin: GetFieldPlugin = type => {\n const plugin = plugins\n .byType<CmsModelFieldTypePlugin>(\"cms-editor-field-type\")\n .find(plugin => plugin.field.type === type);\n\n if (!plugin) {\n throw Error(`Missing plugin for field type \"${type}\"!`);\n }\n\n return plugin;\n};\n\nexport interface UseModelField {\n field: CmsModelField;\n parentValueIndex: number;\n fieldPlugin: CmsModelFieldTypePlugin;\n}\n\n/**\n * Get model field from the current context.\n */\nexport const useModelField = makeDecoratable((): UseModelField => {\n const field = useContext(ModelFieldContext);\n const parentValueIndex = useParentValueIndex();\n\n if (!field) {\n throw Error(\n `Missing \"ModelFieldProvider\" in the component tree. Are you using the \"useModelField()\" hook in the right place?`\n );\n }\n\n const fieldPlugin = getFieldPlugin(field.type);\n\n return { field, fieldPlugin, parentValueIndex };\n});\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,iBAAiB,EAAEC,mBAAmB;AAO/C,MAAMC,cAA8B,GAAGC,IAAI,IAAI;EAC3C,MAAMC,MAAM,GAAGN,OAAO,CACjBO,MAAM,CAA0B,uBAAuB,CAAC,CACxDC,IAAI,CAACF,MAAM,IAAIA,MAAM,CAACG,KAAK,CAACJ,IAAI,KAAKA,IAAI,CAAC;EAE/C,IAAI,CAACC,MAAM,EAAE;IACT,MAAMI,KAAK,CAAC,kCAAkCL,IAAI,IAAI,CAAC;EAC3D;EAEA,OAAOC,MAAM;AACjB,CAAC;AAQD;AACA;AACA;AACA,OAAO,MAAMK,aAAa,GAAGV,eAAe,CAAC,MAAqB;EAC9D,MAAMQ,KAAK,GAAGV,UAAU,CAACG,iBAAiB,CAAC;EAC3C,MAAMU,gBAAgB,GAAGT,mBAAmB,CAAC,CAAC;EAE9C,IAAI,CAACM,KAAK,EAAE;IACR,MAAMC,KAAK,CACP,kHACJ,CAAC;EACL;EAEA,MAAMG,WAAW,GAAGT,cAAc,CAACK,KAAK,CAACJ,IAAI,CAAC;EAE9C,OAAO;IAAEI,KAAK;IAAEI,WAAW;IAAED;EAAiB,CAAC;AACnD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { CmsModel } from "../types";
|
|
2
|
+
import type { CmsModel } from "../types/index.js";
|
|
3
3
|
export type ModelContext = CmsModel;
|
|
4
4
|
export declare const ModelContext: React.Context<CmsModel | undefined>;
|
|
5
5
|
export interface ModelProviderProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","ModelContext","createContext","undefined","ModelProvider","model","children","createElement","Provider","value"],"sources":["ModelContext.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CmsModel } from \"~/types\";\n\nexport type ModelContext = CmsModel;\n\nexport const ModelContext = React.createContext<ModelContext | undefined>(undefined);\n\nexport interface ModelProviderProps {\n model: CmsModel;\n children: React.ReactNode;\n}\n\nexport const ModelProvider = ({ model, children }: ModelProviderProps) => {\n return <ModelContext.Provider value={model}>{children}</ModelContext.Provider>;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAKzB,OAAO,MAAMC,YAAY,gBAAGD,KAAK,CAACE,aAAa,CAA2BC,SAAS,CAAC;AAOpF,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAA6B,CAAC,KAAK;EACtE,oBAAON,KAAA,CAAAO,aAAA,CAACN,YAAY,CAACO,QAAQ;IAACC,KAAK,EAAEJ;EAAM,GAAEC,QAAgC,CAAC;AAClF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","ModelContext","createContext","undefined","ModelProvider","model","children","createElement","Provider","value"],"sources":["ModelContext.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CmsModel } from \"~/types/index.js\";\n\nexport type ModelContext = CmsModel;\n\nexport const ModelContext = React.createContext<ModelContext | undefined>(undefined);\n\nexport interface ModelProviderProps {\n model: CmsModel;\n children: React.ReactNode;\n}\n\nexport const ModelProvider = ({ model, children }: ModelProviderProps) => {\n return <ModelContext.Provider value={model}>{children}</ModelContext.Provider>;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAKzB,OAAO,MAAMC,YAAY,gBAAGD,KAAK,CAACE,aAAa,CAA2BC,SAAS,CAAC;AAOpF,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAA6B,CAAC,KAAK;EACtE,oBAAON,KAAA,CAAAO,aAAA,CAACN,YAAY,CAACO,QAAQ;IAACC,KAAK,EAAEJ;EAAM,GAAEC,QAAgC,CAAC;AAClF,CAAC","ignoreList":[]}
|
package/ModelProvider/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./ModelContext";
|
|
2
|
-
export * from "./useModel";
|
|
1
|
+
export * from "./ModelContext.js";
|
|
2
|
+
export * from "./useModel.js";
|
package/ModelProvider/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ModelContext\";\nexport * from \"./useModel\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ModelContext.js\";\nexport * from \"./useModel.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useContext","ModelContext","useModel","model","Error"],"sources":["useModel.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { ModelContext } from \"./ModelContext\";\nimport type { CmsModel } from \"~/types\";\n\ntype UseModelReturnType = {\n model: CmsModel;\n};\n\n/**\n * Get model from the current context.\n */\nexport function useModel(): UseModelReturnType {\n const model = useContext(ModelContext);\n if (!model) {\n throw Error(\n `Missing \"ModelContext\" in the component tree. Are you using the \"useModel()\" hook in the right place?`\n );\n }\n\n return { model };\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,YAAY;AAOrB;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAAA,EAAuB;EAC3C,MAAMC,KAAK,GAAGH,UAAU,CAACC,YAAY,CAAC;EACtC,IAAI,CAACE,KAAK,EAAE;IACR,MAAMC,KAAK,CACP,uGACJ,CAAC;EACL;EAEA,OAAO;IAAED;EAAM,CAAC;AACpB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useContext","ModelContext","useModel","model","Error"],"sources":["useModel.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { ModelContext } from \"./ModelContext.js\";\nimport type { CmsModel } from \"~/types/index.js\";\n\ntype UseModelReturnType = {\n model: CmsModel;\n};\n\n/**\n * Get model from the current context.\n */\nexport function useModel(): UseModelReturnType {\n const model = useContext(ModelContext);\n if (!model) {\n throw Error(\n `Missing \"ModelContext\" in the component tree. Are you using the \"useModel()\" hook in the right place?`\n );\n }\n\n return { model };\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,YAAY;AAOrB;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAAA,EAAuB;EAC3C,MAAMC,KAAK,GAAGH,UAAU,CAACC,YAAY,CAAC;EACtC,IAAI,CAACE,KAAK,EAAE;IACR,MAAMC,KAAK,CACP,uGACJ,CAAC;EACL;EAEA,OAAO;IAAED;EAAM,CAAC;AACpB","ignoreList":[]}
|
package/README.md
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
# @webiny/app-headless-cms-common
|
|
2
2
|
|
|
3
|
-
[!
|
|
4
|
-
[
|
|
5
|
-
|
|
6
|
-
[](http://makeapullrequest.com)
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> Itβs **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
π **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
npm install --save @webiny/app-headless-cms-common
|
|
12
|
-
```
|
|
9
|
+
---
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
yarn add @webiny/app-headless-cms-common
|
|
18
|
-
```
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/constants.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CMS_MODEL_SINGLETON_TAG = "
|
|
1
|
+
export declare const CMS_MODEL_SINGLETON_TAG = "singleEntry";
|
package/constants.js
CHANGED
package/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CMS_MODEL_SINGLETON_TAG"],"sources":["constants.ts"],"sourcesContent":["export const CMS_MODEL_SINGLETON_TAG = \"
|
|
1
|
+
{"version":3,"names":["CMS_MODEL_SINGLETON_TAG"],"sources":["constants.ts"],"sourcesContent":["export const CMS_MODEL_SINGLETON_TAG = \"singleEntry\";\n"],"mappings":"AAAA,OAAO,MAAMA,uBAAuB,GAAG,aAAa","ignoreList":[]}
|
package/createFieldsList.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import type { CmsModel, CmsModelField } from "./types";
|
|
1
|
+
import type { CmsModel, CmsModelField } from "./types/index.js";
|
|
2
2
|
interface CreateFieldsListParams {
|
|
3
3
|
model: CmsModel;
|
|
4
4
|
fields: CmsModelField[];
|
|
5
5
|
graphQLTypePrefix?: string;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* When used in ACO, this method receives a filtered list of field types.
|
|
9
|
+
* Find `createListRecords` in app-aco to find out more.
|
|
10
|
+
*/
|
|
7
11
|
export declare function createFieldsList({ model, fields: inputFields, graphQLTypePrefix }: CreateFieldsListParams): string;
|
|
8
12
|
export {};
|
package/createFieldsList.js
CHANGED