@webiny/app-headless-cms-common 6.4.5 → 6.6.0-alpha.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/index.d.ts +1 -10
- package/index.js +1 -10
- package/package.json +10 -17
- package/types/index.d.ts +5 -338
- package/types/index.js +1 -1
- package/types/model.d.ts +9 -18
- package/types/model.js +1 -2
- package/types/model.js.map +1 -1
- package/types/shared.d.ts +6 -0
- package/Fields/ErrorBoundary.d.ts +0 -24
- package/Fields/ErrorBoundary.js +0 -35
- package/Fields/ErrorBoundary.js.map +0 -1
- package/Fields/FieldElement.d.ts +0 -64
- package/Fields/FieldElement.js +0 -54
- package/Fields/FieldElement.js.map +0 -1
- package/Fields/FieldElementError.d.ts +0 -7
- package/Fields/FieldElementError.js +0 -16
- package/Fields/FieldElementError.js.map +0 -1
- package/Fields/FieldRulesProvider.d.ts +0 -9
- package/Fields/FieldRulesProvider.js +0 -14
- package/Fields/FieldRulesProvider.js.map +0 -1
- package/Fields/Fields.d.ts +0 -11
- package/Fields/Fields.js +0 -93
- package/Fields/Fields.js.map +0 -1
- package/Fields/Label.d.ts +0 -6
- package/Fields/Label.js +0 -10
- package/Fields/Label.js.map +0 -1
- package/Fields/LayoutDescriptorCell.d.ts +0 -12
- package/Fields/LayoutDescriptorCell.js +0 -40
- package/Fields/LayoutDescriptorCell.js.map +0 -1
- package/Fields/evaluateExpression.d.ts +0 -23
- package/Fields/evaluateExpression.js +0 -66
- package/Fields/evaluateExpression.js.map +0 -1
- package/Fields/fieldOptions.d.ts +0 -36
- package/Fields/fieldOptions.js +0 -65
- package/Fields/fieldOptions.js.map +0 -1
- package/Fields/index.d.ts +0 -8
- package/Fields/index.js +0 -8
- package/Fields/layoutFieldRenderers/AlertFieldRenderer.d.ts +0 -7
- package/Fields/layoutFieldRenderers/AlertFieldRenderer.js +0 -10
- package/Fields/layoutFieldRenderers/AlertFieldRenderer.js.map +0 -1
- package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.d.ts +0 -7
- package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.js +0 -15
- package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.js.map +0 -1
- package/Fields/layoutFieldRenderers/TabsFieldRenderer.d.ts +0 -12
- package/Fields/layoutFieldRenderers/TabsFieldRenderer.js +0 -61
- package/Fields/layoutFieldRenderers/TabsFieldRenderer.js.map +0 -1
- package/Fields/operatorOptions.d.ts +0 -10
- package/Fields/operatorOptions.js +0 -120
- package/Fields/operatorOptions.js.map +0 -1
- package/Fields/useBind.d.ts +0 -10
- package/Fields/useBind.js +0 -111
- package/Fields/useBind.js.map +0 -1
- package/Fields/useFieldRules.d.ts +0 -32
- package/Fields/useFieldRules.js +0 -99
- package/Fields/useFieldRules.js.map +0 -1
- package/Fields/useRenderPlugins.d.ts +0 -2
- package/Fields/useRenderPlugins.js +0 -8
- package/Fields/useRenderPlugins.js.map +0 -1
- package/ModelFieldProvider/CanEditField.d.ts +0 -5
- package/ModelFieldProvider/CanEditField.js +0 -10
- package/ModelFieldProvider/CanEditField.js.map +0 -1
- package/ModelFieldProvider/ModelFieldContext.d.ts +0 -39
- package/ModelFieldProvider/ModelFieldContext.js +0 -19
- package/ModelFieldProvider/ModelFieldContext.js.map +0 -1
- package/ModelFieldProvider/index.d.ts +0 -3
- package/ModelFieldProvider/index.js +0 -3
- package/ModelFieldProvider/useModelField.d.ts +0 -15
- package/ModelFieldProvider/useModelField.js +0 -23
- package/ModelFieldProvider/useModelField.js.map +0 -1
- package/ModelProvider/ModelContext.d.ts +0 -9
- package/ModelProvider/ModelContext.js +0 -14
- package/ModelProvider/ModelContext.js.map +0 -1
- package/ModelProvider/index.d.ts +0 -2
- package/ModelProvider/index.js +0 -2
- package/ModelProvider/useModel.d.ts +0 -9
- package/ModelProvider/useModel.js +0 -12
- package/ModelProvider/useModel.js.map +0 -1
- package/createFieldsList.d.ts +0 -12
- package/createFieldsList.js +0 -31
- package/createFieldsList.js.map +0 -1
- package/createValidationContainer.d.ts +0 -18
- package/createValidationContainer.js +0 -16
- package/createValidationContainer.js.map +0 -1
- package/createValidators.d.ts +0 -3
- package/createValidators.js +0 -47
- package/createValidators.js.map +0 -1
- package/entries.graphql.d.ts +0 -229
- package/entries.graphql.js +0 -335
- package/entries.graphql.js.map +0 -1
- package/exports/admin/cms/model.d.ts +0 -1
- package/exports/admin/cms/model.js +0 -1
- package/getModelTitleFieldId.d.ts +0 -2
- package/getModelTitleFieldId.js +0 -7
- package/getModelTitleFieldId.js.map +0 -1
- package/normalizeIcon.d.ts +0 -3
- package/normalizeIcon.js +0 -11
- package/normalizeIcon.js.map +0 -1
- package/prepareFormData.d.ts +0 -2
- package/prepareFormData.js +0 -49
- package/prepareFormData.js.map +0 -1
- package/types/validation.d.ts +0 -79
- package/types/validation.js +0 -0
package/Fields/FieldElement.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { BindComponent, CmsEditorContentModel, CmsModelField } from "../types/index.js";
|
|
3
|
-
declare module "react" {
|
|
4
|
-
namespace JSX {
|
|
5
|
-
interface IntrinsicElements {
|
|
6
|
-
"hcms-model-field": {
|
|
7
|
-
"data-id": string;
|
|
8
|
-
"data-type": string;
|
|
9
|
-
"data-field-id": string;
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export interface FieldElementProps {
|
|
16
|
-
field: CmsModelField;
|
|
17
|
-
Bind: BindComponent;
|
|
18
|
-
contentModel: CmsEditorContentModel;
|
|
19
|
-
}
|
|
20
|
-
export declare const FieldElement: (({ field, ...props }: FieldElementProps) => React.JSX.Element | null) & {
|
|
21
|
-
original: ({ field, ...props }: FieldElementProps) => React.JSX.Element | null;
|
|
22
|
-
originalName: string;
|
|
23
|
-
displayName: string;
|
|
24
|
-
} & {
|
|
25
|
-
original: (({ field, ...props }: FieldElementProps) => React.JSX.Element | null) & {
|
|
26
|
-
original: ({ field, ...props }: FieldElementProps) => React.JSX.Element | null;
|
|
27
|
-
originalName: string;
|
|
28
|
-
displayName: string;
|
|
29
|
-
};
|
|
30
|
-
originalName: string;
|
|
31
|
-
displayName: string;
|
|
32
|
-
} & {
|
|
33
|
-
createDecorator: (decorator: import("@webiny/app-admin").ComponentDecorator<(({ field, ...props }: FieldElementProps) => React.JSX.Element | null) & {
|
|
34
|
-
original: ({ field, ...props }: FieldElementProps) => React.JSX.Element | null;
|
|
35
|
-
originalName: string;
|
|
36
|
-
displayName: string;
|
|
37
|
-
}>) => (props: unknown) => React.JSX.Element;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* @deprecated Use `FieldElement` instead.
|
|
41
|
-
*/
|
|
42
|
-
export declare const RenderFieldElement: (({ field, ...props }: FieldElementProps) => React.JSX.Element | null) & {
|
|
43
|
-
original: ({ field, ...props }: FieldElementProps) => React.JSX.Element | null;
|
|
44
|
-
originalName: string;
|
|
45
|
-
displayName: string;
|
|
46
|
-
} & {
|
|
47
|
-
original: (({ field, ...props }: FieldElementProps) => React.JSX.Element | null) & {
|
|
48
|
-
original: ({ field, ...props }: FieldElementProps) => React.JSX.Element | null;
|
|
49
|
-
originalName: string;
|
|
50
|
-
displayName: string;
|
|
51
|
-
};
|
|
52
|
-
originalName: string;
|
|
53
|
-
displayName: string;
|
|
54
|
-
} & {
|
|
55
|
-
createDecorator: (decorator: import("@webiny/app-admin").ComponentDecorator<(({ field, ...props }: FieldElementProps) => React.JSX.Element | null) & {
|
|
56
|
-
original: ({ field, ...props }: FieldElementProps) => React.JSX.Element | null;
|
|
57
|
-
originalName: string;
|
|
58
|
-
displayName: string;
|
|
59
|
-
}>) => (props: unknown) => React.JSX.Element;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* @deprecated Use `FieldElementProps` instead.
|
|
63
|
-
*/
|
|
64
|
-
export type RenderFieldElementProps = FieldElementProps;
|
package/Fields/FieldElement.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import react from "react";
|
|
2
|
-
import get from "lodash/get.js";
|
|
3
|
-
import { makeDecoratable } from "@webiny/app-admin";
|
|
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
|
-
const t = i18n.ns("app-headless-cms/admin/components/content-form");
|
|
11
|
-
const RenderField = (props)=>{
|
|
12
|
-
const renderPlugins = useRenderPlugins();
|
|
13
|
-
const { Bind, contentModel } = props;
|
|
14
|
-
const { field } = useModelField();
|
|
15
|
-
const getBind = useBind({
|
|
16
|
-
Bind
|
|
17
|
-
});
|
|
18
|
-
if ("function" == typeof field.renderer) return /*#__PURE__*/ react.createElement(react.Fragment, null, field.renderer({
|
|
19
|
-
field,
|
|
20
|
-
getBind,
|
|
21
|
-
Label: Label,
|
|
22
|
-
contentModel
|
|
23
|
-
}));
|
|
24
|
-
const fieldRendererName = get(field, "renderer.name");
|
|
25
|
-
if (!fieldRendererName) return t`Cannot render "{fieldName}" field - field renderer not defined.`({
|
|
26
|
-
fieldName: /*#__PURE__*/ react.createElement("strong", null, field.fieldId)
|
|
27
|
-
});
|
|
28
|
-
const renderPlugin = renderPlugins.find((plugin)=>plugin.renderer.rendererName === fieldRendererName);
|
|
29
|
-
if (!renderPlugin) return t`Cannot render "{fieldName}" field - field renderer missing in Admin UI plugins.`({
|
|
30
|
-
fieldName: /*#__PURE__*/ react.createElement("strong", null, field.fieldId)
|
|
31
|
-
});
|
|
32
|
-
return /*#__PURE__*/ react.createElement(react.Fragment, null, renderPlugin.renderer.render({
|
|
33
|
-
field,
|
|
34
|
-
getBind,
|
|
35
|
-
Label: Label,
|
|
36
|
-
contentModel
|
|
37
|
-
}));
|
|
38
|
-
};
|
|
39
|
-
const FieldElement = makeDecoratable("FieldElement", ({ field, ...props })=>{
|
|
40
|
-
if (!field) return null;
|
|
41
|
-
return /*#__PURE__*/ react.createElement("hcms-model-field", {
|
|
42
|
-
"data-id": field.id,
|
|
43
|
-
"data-field-id": field.fieldId,
|
|
44
|
-
"data-type": field.type
|
|
45
|
-
}, /*#__PURE__*/ react.createElement(ErrorBoundary, {
|
|
46
|
-
field: field
|
|
47
|
-
}, /*#__PURE__*/ react.createElement(ModelFieldProvider, {
|
|
48
|
-
field: field
|
|
49
|
-
}, /*#__PURE__*/ react.createElement(RenderField, props))));
|
|
50
|
-
});
|
|
51
|
-
const RenderFieldElement = FieldElement;
|
|
52
|
-
export { FieldElement, RenderFieldElement };
|
|
53
|
-
|
|
54
|
-
//# sourceMappingURL=FieldElement.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Fields/FieldElement.js","sources":["../../src/Fields/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"],"names":["t","i18n","RenderField","props","renderPlugins","useRenderPlugins","Bind","contentModel","field","useModelField","getBind","useBind","Label","fieldRendererName","get","renderPlugin","plugin","FieldElement","makeDecoratable","ErrorBoundary","ModelFieldProvider","RenderFieldElement"],"mappings":";;;;;;;;;AAWA,MAAMA,IAAIC,KAAK,EAAE,CAAC;AAiBlB,MAAMC,cAAc,CAACC;IACjB,MAAMC,gBAAgBC;IACtB,MAAM,EAAEC,IAAI,EAAEC,YAAY,EAAE,GAAGJ;IAC/B,MAAM,EAAEK,KAAK,EAAE,GAAGC;IAClB,MAAMC,UAAUC,QAAQ;QAAEL;IAAK;IAE/B,IAAI,AAA0B,cAA1B,OAAOE,MAAM,QAAQ,EACrB,OAAO,WAAP,GAAO,0CAAGA,MAAM,QAAQ,CAAC;QAAEA;QAAOE;QAASE,OAAKA;QAAEL;IAAa;IAGnE,MAAMM,oBAAoBC,IAAIN,OAAO;IACrC,IAAI,CAACK,mBACD,OAAOb,CAAC,CAAC,+DAA+D,CAAC,CAAC;QACtE,WAAW,WAAX,GAAW,oBAAC,gBAAQQ,MAAM,OAAO;IACrC;IAGJ,MAAMO,eAAeX,cAAc,IAAI,CACnCY,CAAAA,SAAUA,OAAO,QAAQ,CAAC,YAAY,KAAKH;IAG/C,IAAI,CAACE,cACD,OAAOf,CAAC,CAAC,+EAA+E,CAAC,CAAC;QACtF,WAAW,WAAX,GAAW,oBAAC,gBAAQQ,MAAM,OAAO;IACrC;IAGJ,OAAO,WAAP,GAAO,0CAAGO,aAAa,QAAQ,CAAC,MAAM,CAAC;QAAEP;QAAOE;QAASE,OAAKA;QAAEL;IAAa;AACjF;AAQO,MAAMU,eAAeC,gBACxB,gBACA,CAAC,EAAEV,KAAK,EAAE,GAAGL,OAA0B;IACnC,IAAI,CAACK,OACD,OAAO;IAGX,OAAO,WAAP,GACI,oBAAC;QACG,WAASA,MAAM,EAAE;QACjB,iBAAeA,MAAM,OAAO;QAC5B,aAAWA,MAAM,IAAI;qBAErB,oBAACW,eAAaA;QAAC,OAAOX;qBAClB,oBAACY,oBAAkBA;QAAC,OAAOZ;qBACvB,oBAACN,aAAgBC;AAKrC;AAMG,MAAMkB,qBAAqBJ"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import react from "react";
|
|
2
|
-
import styled from "@emotion/styled";
|
|
3
|
-
const StyledError = styled.div`
|
|
4
|
-
border: 2px solid red;
|
|
5
|
-
background-color: #f87e7e;
|
|
6
|
-
border-radius: 5px;
|
|
7
|
-
padding: 5px 10px;
|
|
8
|
-
`;
|
|
9
|
-
const showError = "development" === process.env.NODE_ENV;
|
|
10
|
-
const FieldElementError = (props)=>{
|
|
11
|
-
if (!showError) return null;
|
|
12
|
-
return /*#__PURE__*/ react.createElement(StyledError, null, /*#__PURE__*/ react.createElement("h5", null, props.title), /*#__PURE__*/ react.createElement("p", null, props.description));
|
|
13
|
-
};
|
|
14
|
-
export { FieldElementError };
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=FieldElementError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Fields/FieldElementError.js","sources":["../../src/Fields/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"],"names":["StyledError","styled","showError","process","FieldElementError","props"],"mappings":";;AAGA,MAAMA,cAAcC,OAAO,GAAG,CAAC;;;;;AAK/B,CAAC;AAOD,MAAMC,YAAYC,AAAyB,kBAAzBA,QAAQ,GAAG,CAAC,QAAQ;AAE/B,MAAMC,oBAAoB,CAACC;IAC9B,IAAI,CAACH,WACD,OAAO;IAGX,OAAO,WAAP,GACI,oBAACF,aAAWA,MAAAA,WAAAA,GACR,oBAAC,YAAIK,MAAM,KAAK,iBAChB,oBAAC,WAAGA,MAAM,WAAW;AAGjC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { EffectiveFieldRules } from "./useFieldRules.js";
|
|
3
|
-
interface FieldRulesProviderProps {
|
|
4
|
-
rules: EffectiveFieldRules;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare const FieldRulesProvider: ({ rules, children }: FieldRulesProviderProps) => React.JSX.Element;
|
|
8
|
-
export declare const useParentRules: () => EffectiveFieldRules;
|
|
9
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import react, { createContext, useContext } from "react";
|
|
2
|
-
const FieldRulesContext = /*#__PURE__*/ createContext({
|
|
3
|
-
canView: true,
|
|
4
|
-
canEdit: true,
|
|
5
|
-
hidden: false,
|
|
6
|
-
disabled: false
|
|
7
|
-
});
|
|
8
|
-
const FieldRulesProvider = ({ rules, children })=>/*#__PURE__*/ react.createElement(FieldRulesContext.Provider, {
|
|
9
|
-
value: rules
|
|
10
|
-
}, children);
|
|
11
|
-
const useParentRules = ()=>useContext(FieldRulesContext);
|
|
12
|
-
export { FieldRulesProvider, useParentRules };
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=FieldRulesProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Fields/FieldRulesProvider.js","sources":["../../src/Fields/FieldRulesProvider.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport type { EffectiveFieldRules } from \"./useFieldRules.js\";\n\nconst FieldRulesContext = createContext<EffectiveFieldRules>({\n canView: true,\n canEdit: true,\n hidden: false,\n disabled: false\n});\n\ninterface FieldRulesProviderProps {\n rules: EffectiveFieldRules;\n children: React.ReactNode;\n}\n\nexport const FieldRulesProvider = ({ rules, children }: FieldRulesProviderProps) => {\n return <FieldRulesContext.Provider value={rules}>{children}</FieldRulesContext.Provider>;\n};\n\nexport const useParentRules = (): EffectiveFieldRules => {\n return useContext(FieldRulesContext);\n};\n"],"names":["FieldRulesContext","createContext","FieldRulesProvider","rules","children","useParentRules","useContext"],"mappings":";AAGA,MAAMA,oBAAoB,WAAHA,GAAGC,cAAmC;IACzD,SAAS;IACT,SAAS;IACT,QAAQ;IACR,UAAU;AACd;AAOO,MAAMC,qBAAqB,CAAC,EAAEC,KAAK,EAAEC,QAAQ,EAA2B,GACpE,WAAP,GAAO,oBAACJ,kBAAkB,QAAQ;QAAC,OAAOG;OAAQC;AAG/C,MAAMC,iBAAiB,IACnBC,WAAWN"}
|
package/Fields/Fields.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { BindComponent, CmsEditorContentModel, CmsEditorFieldsLayout, CmsModelField } from "../types/index.js";
|
|
3
|
-
interface FieldsProps {
|
|
4
|
-
Bind: BindComponent;
|
|
5
|
-
contentModel: CmsEditorContentModel;
|
|
6
|
-
fields: CmsModelField[];
|
|
7
|
-
layout: CmsEditorFieldsLayout;
|
|
8
|
-
gridClassName?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare const Fields: ({ Bind, fields, layout, contentModel, gridClassName }: FieldsProps) => React.JSX.Element;
|
|
11
|
-
export {};
|
package/Fields/Fields.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import react from "react";
|
|
2
|
-
import { Alert, Grid } from "@webiny/admin-ui";
|
|
3
|
-
import { FieldElement } from "./FieldElement.js";
|
|
4
|
-
import { FieldElementError } from "./FieldElementError.js";
|
|
5
|
-
import { isLayoutField } from "../types/model.js";
|
|
6
|
-
import { LayoutDescriptorCell } from "./LayoutDescriptorCell.js";
|
|
7
|
-
import { useAuthentication } from "@webiny/app-admin";
|
|
8
|
-
import { FieldRulesProvider, useParentRules } from "./FieldRulesProvider.js";
|
|
9
|
-
import { evaluateAccessControlRules, useFieldEffectiveRules } from "./useFieldRules.js";
|
|
10
|
-
const getFieldById = (fields, id)=>fields.find((field)=>field.id === id) || null;
|
|
11
|
-
const LayoutNotDefined = ()=>/*#__PURE__*/ react.createElement(Alert, {
|
|
12
|
-
type: "warning"
|
|
13
|
-
}, "You are missing the layout definition in your code content model. Please ensure you have the layout property correctly defined.");
|
|
14
|
-
const LayoutCell = ({ cell, Bind, fields, contentModel, gridClassName })=>{
|
|
15
|
-
const isLayout = isLayoutField(cell);
|
|
16
|
-
const rules = useFieldEffectiveRules(isLayout ? cell : {});
|
|
17
|
-
if (!isLayout) return null;
|
|
18
|
-
if (!rules.canView || rules.hidden) return null;
|
|
19
|
-
return /*#__PURE__*/ react.createElement(FieldRulesProvider, {
|
|
20
|
-
rules: rules
|
|
21
|
-
}, /*#__PURE__*/ react.createElement(LayoutDescriptorCell, {
|
|
22
|
-
field: cell,
|
|
23
|
-
Bind: Bind,
|
|
24
|
-
fields: fields,
|
|
25
|
-
contentModel: contentModel,
|
|
26
|
-
gridClassName: gridClassName
|
|
27
|
-
}));
|
|
28
|
-
};
|
|
29
|
-
const FieldCell = ({ id, field, span, Bind, contentModel })=>{
|
|
30
|
-
const rules = useFieldEffectiveRules(field ?? {});
|
|
31
|
-
if (!rules.canView || rules.hidden) return null;
|
|
32
|
-
return /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
33
|
-
span: span
|
|
34
|
-
}, field ? /*#__PURE__*/ react.createElement(FieldRulesProvider, {
|
|
35
|
-
rules: rules
|
|
36
|
-
}, /*#__PURE__*/ react.createElement(FieldElement, {
|
|
37
|
-
field: field,
|
|
38
|
-
Bind: Bind,
|
|
39
|
-
contentModel: contentModel
|
|
40
|
-
})) : /*#__PURE__*/ react.createElement(FieldElementError, {
|
|
41
|
-
title: `Missing field with id "${id}"!`,
|
|
42
|
-
description: "Make sure field layout contains the correct field ids (hint: check for typos)."
|
|
43
|
-
}));
|
|
44
|
-
};
|
|
45
|
-
const RowRenderer = ({ row, fields, Bind, contentModel, gridClassName })=>{
|
|
46
|
-
const { identity } = useAuthentication();
|
|
47
|
-
const parentRules = useParentRules();
|
|
48
|
-
const visibleStringCells = row.filter((c)=>{
|
|
49
|
-
if ("string" != typeof c) return false;
|
|
50
|
-
const f = getFieldById(fields, c);
|
|
51
|
-
if (!f) return true;
|
|
52
|
-
const acPerms = evaluateAccessControlRules(f, identity);
|
|
53
|
-
return parentRules.canView && acPerms.canView;
|
|
54
|
-
});
|
|
55
|
-
const span = visibleStringCells.length > 0 ? Math.floor(12 / visibleStringCells.length) : 12;
|
|
56
|
-
return /*#__PURE__*/ react.createElement(react.Fragment, null, row.map((cell)=>{
|
|
57
|
-
if (isLayoutField(cell)) return /*#__PURE__*/ react.createElement(LayoutCell, {
|
|
58
|
-
key: cell.id,
|
|
59
|
-
cell: cell,
|
|
60
|
-
Bind: Bind,
|
|
61
|
-
fields: fields,
|
|
62
|
-
contentModel: contentModel,
|
|
63
|
-
gridClassName: gridClassName
|
|
64
|
-
});
|
|
65
|
-
const id = cell;
|
|
66
|
-
const field = getFieldById(fields, id);
|
|
67
|
-
return /*#__PURE__*/ react.createElement(FieldCell, {
|
|
68
|
-
key: id,
|
|
69
|
-
id: id,
|
|
70
|
-
field: field,
|
|
71
|
-
span: span,
|
|
72
|
-
Bind: Bind,
|
|
73
|
-
contentModel: contentModel
|
|
74
|
-
});
|
|
75
|
-
}));
|
|
76
|
-
};
|
|
77
|
-
const Fields = ({ Bind, fields, layout, contentModel, gridClassName })=>{
|
|
78
|
-
if (contentModel.plugin && fields.length > 0 && 0 === layout.length) return /*#__PURE__*/ react.createElement(LayoutNotDefined, null);
|
|
79
|
-
return /*#__PURE__*/ react.createElement(Grid, {
|
|
80
|
-
className: gridClassName
|
|
81
|
-
}, layout.map((row, rowIndex)=>/*#__PURE__*/ react.createElement(react.Fragment, {
|
|
82
|
-
key: rowIndex
|
|
83
|
-
}, /*#__PURE__*/ react.createElement(RowRenderer, {
|
|
84
|
-
row: row,
|
|
85
|
-
fields: fields,
|
|
86
|
-
Bind: Bind,
|
|
87
|
-
contentModel: contentModel,
|
|
88
|
-
gridClassName: gridClassName
|
|
89
|
-
}))));
|
|
90
|
-
};
|
|
91
|
-
export { Fields };
|
|
92
|
-
|
|
93
|
-
//# sourceMappingURL=Fields.js.map
|
package/Fields/Fields.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Fields/Fields.js","sources":["../../src/Fields/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\";\nimport type { CmsEditorLayoutCell } from \"~/types/model.js\";\nimport { isLayoutField } from \"~/types/model.js\";\nimport { LayoutDescriptorCell } from \"./LayoutDescriptorCell.js\";\nimport { useAuthentication } from \"@webiny/app-admin\";\nimport { FieldRulesProvider, useParentRules } from \"./FieldRulesProvider.js\";\nimport { evaluateAccessControlRules, useFieldEffectiveRules } from \"./useFieldRules.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\n/**\n * Renders a single layout descriptor cell with rules + permissions.\n */\ninterface LayoutCellProps {\n cell: CmsEditorLayoutCell;\n Bind: BindComponent;\n fields: CmsModelField[];\n contentModel: CmsEditorContentModel;\n gridClassName?: string;\n}\n\nconst LayoutCell = ({ cell, Bind, fields, contentModel, gridClassName }: LayoutCellProps) => {\n const isLayout = isLayoutField(cell);\n const rules = useFieldEffectiveRules(isLayout ? cell : {});\n\n if (!isLayout) {\n return null;\n }\n\n if (!rules.canView || rules.hidden) {\n return null;\n }\n\n return (\n <FieldRulesProvider rules={rules}>\n <LayoutDescriptorCell\n field={cell}\n Bind={Bind}\n fields={fields}\n contentModel={contentModel}\n gridClassName={gridClassName}\n />\n </FieldRulesProvider>\n );\n};\n\n/**\n * Renders a single data field cell with rules + permissions.\n */\ninterface FieldCellProps {\n id: string;\n field: CmsModelField | null;\n span: ColumnProps[\"span\"];\n Bind: BindComponent;\n contentModel: CmsEditorContentModel;\n}\n\nconst FieldCell = ({ id, field, span, Bind, contentModel }: FieldCellProps) => {\n const rules = useFieldEffectiveRules(field ?? {});\n\n if (!rules.canView || rules.hidden) {\n return null;\n }\n\n return (\n <Grid.Column span={span}>\n {field ? (\n <FieldRulesProvider rules={rules}>\n <FieldElement field={field} Bind={Bind} contentModel={contentModel} />\n </FieldRulesProvider>\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\n/**\n * Renders a single row, delegating each cell to FieldCell or LayoutCell.\n */\ninterface RowRendererProps {\n row: CmsEditorLayoutCell[];\n fields: CmsModelField[];\n Bind: BindComponent;\n contentModel: CmsEditorContentModel;\n gridClassName?: string;\n}\n\nconst RowRenderer = ({ row, fields, Bind, contentModel, gridClassName }: RowRendererProps) => {\n const { identity } = useAuthentication();\n const parentRules = useParentRules();\n\n // Count visible string cells for column span calculation.\n // This count is approximate based on access control rules only (not entry value rules),\n // because entry value rules require per-field hooks and we can't call them in a filter.\n // The actual visibility is enforced in FieldCell.\n const visibleStringCells = row.filter(c => {\n if (typeof c !== \"string\") {\n return false;\n }\n const f = getFieldById(fields, c);\n if (!f) {\n return true;\n }\n const acPerms = evaluateAccessControlRules(f, identity);\n return parentRules.canView && acPerms.canView;\n });\n\n const span =\n visibleStringCells.length > 0\n ? (Math.floor(12 / visibleStringCells.length) as ColumnProps[\"span\"])\n : (12 as ColumnProps[\"span\"]);\n\n return (\n <>\n {row.map(cell => {\n if (isLayoutField(cell)) {\n return (\n <LayoutCell\n key={cell.id}\n cell={cell}\n Bind={Bind}\n fields={fields}\n contentModel={contentModel}\n gridClassName={gridClassName}\n />\n );\n }\n\n const id = cell as string;\n const field = getFieldById(fields, id);\n\n return (\n <FieldCell\n key={id}\n id={id}\n field={field}\n span={span}\n Bind={Bind}\n contentModel={contentModel}\n />\n );\n })}\n </>\n );\n};\n\nexport const Fields = ({ Bind, fields, layout, contentModel, gridClassName }: FieldsProps) => {\n if (contentModel.plugin && fields.length > 0 && layout.length === 0) {\n return <LayoutNotDefined />;\n }\n\n return (\n <Grid className={gridClassName}>\n {layout.map((row, rowIndex) => (\n <React.Fragment key={rowIndex}>\n <RowRenderer\n row={row}\n fields={fields}\n Bind={Bind}\n contentModel={contentModel}\n gridClassName={gridClassName}\n />\n </React.Fragment>\n ))}\n </Grid>\n );\n};\n"],"names":["getFieldById","fields","id","field","LayoutNotDefined","Alert","LayoutCell","cell","Bind","contentModel","gridClassName","isLayout","isLayoutField","rules","useFieldEffectiveRules","FieldRulesProvider","LayoutDescriptorCell","FieldCell","span","Grid","FieldElement","FieldElementError","RowRenderer","row","identity","useAuthentication","parentRules","useParentRules","visibleStringCells","c","f","acPerms","evaluateAccessControlRules","Math","Fields","layout","rowIndex","React"],"mappings":";;;;;;;;;AAyBA,MAAMA,eAAe,CAACC,QAAyBC,KACpCD,OAAO,IAAI,CAACE,CAAAA,QAASA,MAAM,EAAE,KAAKD,OAAO;AAGpD,MAAME,mBAAmB,IACd,WAAP,GACI,oBAACC,OAAKA;QAAC,MAAM;OAAW;AAkBhC,MAAMC,aAAa,CAAC,EAAEC,IAAI,EAAEC,IAAI,EAAEP,MAAM,EAAEQ,YAAY,EAAEC,aAAa,EAAmB;IACpF,MAAMC,WAAWC,cAAcL;IAC/B,MAAMM,QAAQC,uBAAuBH,WAAWJ,OAAO,CAAC;IAExD,IAAI,CAACI,UACD,OAAO;IAGX,IAAI,CAACE,MAAM,OAAO,IAAIA,MAAM,MAAM,EAC9B,OAAO;IAGX,OAAO,WAAP,GACI,oBAACE,oBAAkBA;QAAC,OAAOF;qBACvB,oBAACG,sBAAoBA;QACjB,OAAOT;QACP,MAAMC;QACN,QAAQP;QACR,cAAcQ;QACd,eAAeC;;AAI/B;AAaA,MAAMO,YAAY,CAAC,EAAEf,EAAE,EAAEC,KAAK,EAAEe,IAAI,EAAEV,IAAI,EAAEC,YAAY,EAAkB;IACtE,MAAMI,QAAQC,uBAAuBX,SAAS,CAAC;IAE/C,IAAI,CAACU,MAAM,OAAO,IAAIA,MAAM,MAAM,EAC9B,OAAO;IAGX,OAAO,WAAP,GACI,oBAACM,KAAK,MAAM;QAAC,MAAMD;OACdf,QAAQ,WAARA,GACG,oBAACY,oBAAkBA;QAAC,OAAOF;qBACvB,oBAACO,cAAYA;QAAC,OAAOjB;QAAO,MAAMK;QAAM,cAAcC;wBAG1D,oBAACY,mBAAiBA;QACd,OAAO,CAAC,uBAAuB,EAAEnB,GAAG,EAAE,CAAC;QACvC,aACI;;AAMxB;AAaA,MAAMoB,cAAc,CAAC,EAAEC,GAAG,EAAEtB,MAAM,EAAEO,IAAI,EAAEC,YAAY,EAAEC,aAAa,EAAoB;IACrF,MAAM,EAAEc,QAAQ,EAAE,GAAGC;IACrB,MAAMC,cAAcC;IAMpB,MAAMC,qBAAqBL,IAAI,MAAM,CAACM,CAAAA;QAClC,IAAI,AAAa,YAAb,OAAOA,GACP,OAAO;QAEX,MAAMC,IAAI9B,aAAaC,QAAQ4B;QAC/B,IAAI,CAACC,GACD,OAAO;QAEX,MAAMC,UAAUC,2BAA2BF,GAAGN;QAC9C,OAAOE,YAAY,OAAO,IAAIK,QAAQ,OAAO;IACjD;IAEA,MAAMb,OACFU,mBAAmB,MAAM,GAAG,IACrBK,KAAK,KAAK,CAAC,KAAKL,mBAAmB,MAAM,IACzC;IAEX,OAAO,WAAP,GACI,0CACKL,IAAI,GAAG,CAAChB,CAAAA;QACL,IAAIK,cAAcL,OACd,OAAO,WAAP,GACI,oBAACD,YAAUA;YACP,KAAKC,KAAK,EAAE;YACZ,MAAMA;YACN,MAAMC;YACN,QAAQP;YACR,cAAcQ;YACd,eAAeC;;QAK3B,MAAMR,KAAKK;QACX,MAAMJ,QAAQH,aAAaC,QAAQC;QAEnC,OAAO,WAAP,GACI,oBAACe,WAASA;YACN,KAAKf;YACL,IAAIA;YACJ,OAAOC;YACP,MAAMe;YACN,MAAMV;YACN,cAAcC;;IAG1B;AAGZ;AAEO,MAAMyB,SAAS,CAAC,EAAE1B,IAAI,EAAEP,MAAM,EAAEkC,MAAM,EAAE1B,YAAY,EAAEC,aAAa,EAAe;IACrF,IAAID,aAAa,MAAM,IAAIR,OAAO,MAAM,GAAG,KAAKkC,AAAkB,MAAlBA,OAAO,MAAM,EACzD,OAAO,WAAP,GAAO,oBAAC/B,kBAAgBA;IAG5B,OAAO,WAAP,GACI,oBAACe,MAAIA;QAAC,WAAWT;OACZyB,OAAO,GAAG,CAAC,CAACZ,KAAKa,WAAAA,WAAAA,GACd,oBAACC,MAAAA,QAAc;YAAC,KAAKD;yBACjB,oBAACd,aAAWA;YACR,KAAKC;YACL,QAAQtB;YACR,MAAMO;YACN,cAAcC;YACd,eAAeC;;AAMvC"}
|
package/Fields/Label.d.ts
DELETED
package/Fields/Label.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import react from "react";
|
|
2
|
-
import { FormComponentLabel } from "@webiny/admin-ui";
|
|
3
|
-
const Label = ({ children })=>/*#__PURE__*/ react.createElement(FormComponentLabel, {
|
|
4
|
-
text: children
|
|
5
|
-
});
|
|
6
|
-
const Fields_Label = Label;
|
|
7
|
-
export default Fields_Label;
|
|
8
|
-
export { Label };
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=Label.js.map
|
package/Fields/Label.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Fields/Label.js","sources":["../../src/Fields/Label.tsx"],"sourcesContent":["import React from \"react\";\nimport { FormComponentLabel } from \"@webiny/admin-ui\";\n\ninterface LabelProps {\n children?: React.ReactNode;\n}\n\nexport const Label = ({ children }: LabelProps) => <FormComponentLabel text={children} />;\n\nexport default Label;\n"],"names":["Label","children","FormComponentLabel"],"mappings":";;AAOO,MAAMA,QAAQ,CAAC,EAAEC,QAAQ,EAAc,iBAAK,oBAACC,oBAAkBA;QAAC,MAAMD;;AAE7E,qBAAeD"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { CmsLayoutField } from "../types/model.js";
|
|
3
|
-
import type { BindComponent, CmsEditorContentModel, CmsModelField } from "../types/index.js";
|
|
4
|
-
interface LayoutDescriptorCellProps {
|
|
5
|
-
field: CmsLayoutField;
|
|
6
|
-
Bind: BindComponent;
|
|
7
|
-
fields: CmsModelField[];
|
|
8
|
-
contentModel: CmsEditorContentModel;
|
|
9
|
-
gridClassName?: string;
|
|
10
|
-
}
|
|
11
|
-
export declare const LayoutDescriptorCell: ({ field, Bind, fields, contentModel, gridClassName }: LayoutDescriptorCellProps) => React.JSX.Element | null;
|
|
12
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import react from "react";
|
|
2
|
-
import { plugins } from "@webiny/plugins";
|
|
3
|
-
import { SeparatorFieldRenderer } from "./layoutFieldRenderers/SeparatorFieldRenderer.js";
|
|
4
|
-
import { AlertFieldRenderer } from "./layoutFieldRenderers/AlertFieldRenderer.js";
|
|
5
|
-
import { TabsFieldRenderer } from "./layoutFieldRenderers/TabsFieldRenderer.js";
|
|
6
|
-
const LayoutDescriptorCell = ({ field, Bind, fields, contentModel, gridClassName })=>{
|
|
7
|
-
switch(field.type){
|
|
8
|
-
case "separator":
|
|
9
|
-
return /*#__PURE__*/ react.createElement(SeparatorFieldRenderer, {
|
|
10
|
-
field: field
|
|
11
|
-
});
|
|
12
|
-
case "alert":
|
|
13
|
-
return /*#__PURE__*/ react.createElement(AlertFieldRenderer, {
|
|
14
|
-
field: field
|
|
15
|
-
});
|
|
16
|
-
case "tabs":
|
|
17
|
-
return /*#__PURE__*/ react.createElement(TabsFieldRenderer, {
|
|
18
|
-
field: field,
|
|
19
|
-
Bind: Bind,
|
|
20
|
-
fields: fields,
|
|
21
|
-
contentModel: contentModel,
|
|
22
|
-
gridClassName: gridClassName
|
|
23
|
-
});
|
|
24
|
-
default:
|
|
25
|
-
{
|
|
26
|
-
const rendererPlugin = plugins.byType("cms-layout-field-renderer").find((p)=>p.fieldType === field.type);
|
|
27
|
-
if (rendererPlugin) return rendererPlugin.render({
|
|
28
|
-
field,
|
|
29
|
-
Bind,
|
|
30
|
-
fields,
|
|
31
|
-
contentModel,
|
|
32
|
-
gridClassName
|
|
33
|
-
});
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
export { LayoutDescriptorCell };
|
|
39
|
-
|
|
40
|
-
//# sourceMappingURL=LayoutDescriptorCell.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Fields/LayoutDescriptorCell.js","sources":["../../src/Fields/LayoutDescriptorCell.tsx"],"sourcesContent":["import React from \"react\";\nimport type {\n CmsAlertLayoutField,\n CmsLayoutField,\n CmsSeparatorLayoutField,\n CmsTabLayoutField\n} from \"~/types/model.js\";\nimport type {\n BindComponent,\n CmsEditorContentModel,\n CmsModelLayoutFieldRendererPlugin,\n CmsModelField\n} from \"~/types/index.js\";\nimport { plugins } from \"@webiny/plugins\";\nimport { SeparatorFieldRenderer } from \"./layoutFieldRenderers/SeparatorFieldRenderer.js\";\nimport { AlertFieldRenderer } from \"./layoutFieldRenderers/AlertFieldRenderer.js\";\nimport { TabsFieldRenderer } from \"./layoutFieldRenderers/TabsFieldRenderer.js\";\n\ninterface LayoutDescriptorCellProps {\n field: CmsLayoutField;\n Bind: BindComponent;\n fields: CmsModelField[];\n contentModel: CmsEditorContentModel;\n gridClassName?: string;\n}\n\nexport const LayoutDescriptorCell = ({\n field,\n Bind,\n fields,\n contentModel,\n gridClassName\n}: LayoutDescriptorCellProps) => {\n switch (field.type) {\n case \"separator\":\n return <SeparatorFieldRenderer field={field as CmsSeparatorLayoutField} />;\n case \"alert\":\n return <AlertFieldRenderer field={field as CmsAlertLayoutField} />;\n case \"tabs\":\n return (\n <TabsFieldRenderer\n field={field as CmsTabLayoutField}\n Bind={Bind}\n fields={fields}\n contentModel={contentModel}\n gridClassName={gridClassName}\n />\n );\n default: {\n const rendererPlugin = plugins\n .byType<CmsModelLayoutFieldRendererPlugin>(\"cms-layout-field-renderer\")\n .find(p => p.fieldType === field.type);\n if (rendererPlugin) {\n return rendererPlugin.render({\n field,\n Bind,\n fields,\n contentModel,\n gridClassName\n });\n }\n return null;\n }\n }\n};\n"],"names":["LayoutDescriptorCell","field","Bind","fields","contentModel","gridClassName","SeparatorFieldRenderer","AlertFieldRenderer","TabsFieldRenderer","rendererPlugin","plugins","p"],"mappings":";;;;;AA0BO,MAAMA,uBAAuB,CAAC,EACjCC,KAAK,EACLC,IAAI,EACJC,MAAM,EACNC,YAAY,EACZC,aAAa,EACW;IACxB,OAAQJ,MAAM,IAAI;QACd,KAAK;YACD,OAAO,WAAP,GAAO,oBAACK,wBAAsBA;gBAAC,OAAOL;;QAC1C,KAAK;YACD,OAAO,WAAP,GAAO,oBAACM,oBAAkBA;gBAAC,OAAON;;QACtC,KAAK;YACD,OAAO,WAAP,GACI,oBAACO,mBAAiBA;gBACd,OAAOP;gBACP,MAAMC;gBACN,QAAQC;gBACR,cAAcC;gBACd,eAAeC;;QAG3B;YAAS;gBACL,MAAMI,iBAAiBC,QAAAA,MACZ,CAAoC,6BAC1C,IAAI,CAACC,CAAAA,IAAKA,EAAE,SAAS,KAAKV,MAAM,IAAI;gBACzC,IAAIQ,gBACA,OAAOA,eAAe,MAAM,CAAC;oBACzBR;oBACAC;oBACAC;oBACAC;oBACAC;gBACJ;gBAEJ,OAAO;YACX;IACJ;AACJ"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export type Operator = "==" | "!=" | ">" | "<" | ">=" | "<=" | "contains" | "startsWith" | "endsWith" | "isEmpty" | "isNotEmpty";
|
|
2
|
-
export interface ParsedExpression {
|
|
3
|
-
target: string;
|
|
4
|
-
operator: Operator;
|
|
5
|
-
value: string | number | boolean | null;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Resolve a fieldPath that may contain `$` placeholders using the bindParentName.
|
|
9
|
-
*
|
|
10
|
-
* The bindParentName gives us the concrete indices for the current list context.
|
|
11
|
-
* For example, if fieldPath is `panorama.hotspots.$.title` and bindParentName
|
|
12
|
-
* is `panorama.hotspots.2`, the result is `panorama.hotspots.2.title`.
|
|
13
|
-
*
|
|
14
|
-
* Supports multiple nested `$` segments for deeply nested list objects.
|
|
15
|
-
*/
|
|
16
|
-
export declare function resolveFieldPath(fieldPath: string, bindParentName?: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* Evaluate a parsed expression against form values.
|
|
19
|
-
*
|
|
20
|
-
* If the resolved fieldPath ends with `.length`, it reads the array at the parent
|
|
21
|
-
* path and uses its length as the left-hand value.
|
|
22
|
-
*/
|
|
23
|
-
export declare function evaluateExpression(parsed: ParsedExpression, getFormValue: (path: string) => unknown): boolean;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
function resolveFieldPath(fieldPath, bindParentName) {
|
|
2
|
-
if (!fieldPath.includes("$")) return fieldPath;
|
|
3
|
-
if (fieldPath.startsWith("$.")) {
|
|
4
|
-
const relative = fieldPath.slice(2);
|
|
5
|
-
return bindParentName ? `${bindParentName}.${relative}` : relative;
|
|
6
|
-
}
|
|
7
|
-
if (!bindParentName) return fieldPath.replace(/\$/g, "0");
|
|
8
|
-
const pathParts = fieldPath.split(".");
|
|
9
|
-
const parentParts = bindParentName.split(".");
|
|
10
|
-
const indexMap = new Map();
|
|
11
|
-
const prefixParts = [];
|
|
12
|
-
for (const part of parentParts)if (/^\d+$/.test(part)) indexMap.set(prefixParts.join("."), part);
|
|
13
|
-
else prefixParts.push(part);
|
|
14
|
-
const resolved = [];
|
|
15
|
-
const currentPrefix = [];
|
|
16
|
-
for (const part of pathParts)if ("$" === part) {
|
|
17
|
-
const key = currentPrefix.join(".");
|
|
18
|
-
const index = indexMap.get(key) ?? "0";
|
|
19
|
-
resolved.push(index);
|
|
20
|
-
} else {
|
|
21
|
-
currentPrefix.push(part);
|
|
22
|
-
resolved.push(part);
|
|
23
|
-
}
|
|
24
|
-
return resolved.join(".");
|
|
25
|
-
}
|
|
26
|
-
function compareValues(operator, val, rhs) {
|
|
27
|
-
switch(operator){
|
|
28
|
-
case "==":
|
|
29
|
-
return val == rhs;
|
|
30
|
-
case "!=":
|
|
31
|
-
return val != rhs;
|
|
32
|
-
case ">":
|
|
33
|
-
return Number(val) > Number(rhs);
|
|
34
|
-
case "<":
|
|
35
|
-
return Number(val) < Number(rhs);
|
|
36
|
-
case ">=":
|
|
37
|
-
return Number(val) >= Number(rhs);
|
|
38
|
-
case "<=":
|
|
39
|
-
return Number(val) <= Number(rhs);
|
|
40
|
-
case "contains":
|
|
41
|
-
return String(val ?? "").includes(String(rhs ?? ""));
|
|
42
|
-
case "startsWith":
|
|
43
|
-
return String(val ?? "").startsWith(String(rhs ?? ""));
|
|
44
|
-
case "endsWith":
|
|
45
|
-
return String(val ?? "").endsWith(String(rhs ?? ""));
|
|
46
|
-
case "isEmpty":
|
|
47
|
-
return null == val || "" === val || Array.isArray(val) && 0 === val.length;
|
|
48
|
-
case "isNotEmpty":
|
|
49
|
-
return null != val && "" !== val && !(Array.isArray(val) && 0 === val.length);
|
|
50
|
-
default:
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function evaluateExpression(parsed, getFormValue) {
|
|
55
|
-
const { target, operator, value: rhs } = parsed;
|
|
56
|
-
let val;
|
|
57
|
-
if (target.endsWith(".length")) {
|
|
58
|
-
const arrayPath = target.slice(0, -7);
|
|
59
|
-
const arr = getFormValue(arrayPath);
|
|
60
|
-
val = Array.isArray(arr) ? arr.length : 0;
|
|
61
|
-
} else val = getFormValue(target);
|
|
62
|
-
return compareValues(operator, val, rhs);
|
|
63
|
-
}
|
|
64
|
-
export { evaluateExpression, resolveFieldPath };
|
|
65
|
-
|
|
66
|
-
//# sourceMappingURL=evaluateExpression.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Fields/evaluateExpression.js","sources":["../../src/Fields/evaluateExpression.ts"],"sourcesContent":["export type Operator =\n | \"==\"\n | \"!=\"\n | \">\"\n | \"<\"\n | \">=\"\n | \"<=\"\n | \"contains\"\n | \"startsWith\"\n | \"endsWith\"\n | \"isEmpty\"\n | \"isNotEmpty\";\n\nexport interface ParsedExpression {\n target: string;\n operator: Operator;\n value: string | number | boolean | null;\n}\n\n/**\n * Resolve a fieldPath that may contain `$` placeholders using the bindParentName.\n *\n * The bindParentName gives us the concrete indices for the current list context.\n * For example, if fieldPath is `panorama.hotspots.$.title` and bindParentName\n * is `panorama.hotspots.2`, the result is `panorama.hotspots.2.title`.\n *\n * Supports multiple nested `$` segments for deeply nested list objects.\n */\nexport function resolveFieldPath(fieldPath: string, bindParentName?: string): string {\n if (!fieldPath.includes(\"$\")) {\n return fieldPath;\n }\n\n if (fieldPath.startsWith(\"$.\")) {\n const relative = fieldPath.slice(2);\n return bindParentName ? `${bindParentName}.${relative}` : relative;\n }\n\n if (!bindParentName) {\n // No parent context, replace $ with 0 as fallback\n return fieldPath.replace(/\\$/g, \"0\");\n }\n\n const pathParts = fieldPath.split(\".\");\n const parentParts = bindParentName.split(\".\");\n\n // Build a map of prefix -> index from the parent path.\n // E.g., parentName \"panorama.hotspots.2.items.1\" gives us:\n // \"panorama.hotspots\" -> \"2\"\n // \"panorama.hotspots.2.items\" -> \"1\"\n const indexMap = new Map<string, string>();\n const prefixParts: string[] = [];\n for (const part of parentParts) {\n if (/^\\d+$/.test(part)) {\n indexMap.set(prefixParts.join(\".\"), part);\n } else {\n prefixParts.push(part);\n }\n }\n\n // Walk through pathParts and replace each `$` with the corresponding index\n const resolved: string[] = [];\n const currentPrefix: string[] = [];\n for (const part of pathParts) {\n if (part === \"$\") {\n const key = currentPrefix.join(\".\");\n const index = indexMap.get(key) ?? \"0\";\n resolved.push(index);\n } else {\n currentPrefix.push(part);\n resolved.push(part);\n }\n }\n\n return resolved.join(\".\");\n}\n\nfunction compareValues(\n operator: string,\n val: unknown,\n rhs: string | number | boolean | null\n): boolean {\n switch (operator) {\n case \"==\":\n return val == rhs;\n case \"!=\":\n return val != rhs;\n case \">\":\n return Number(val) > Number(rhs);\n case \"<\":\n return Number(val) < Number(rhs);\n case \">=\":\n return Number(val) >= Number(rhs);\n case \"<=\":\n return Number(val) <= Number(rhs);\n case \"contains\":\n return String(val ?? \"\").includes(String(rhs ?? \"\"));\n case \"startsWith\":\n return String(val ?? \"\").startsWith(String(rhs ?? \"\"));\n case \"endsWith\":\n return String(val ?? \"\").endsWith(String(rhs ?? \"\"));\n case \"isEmpty\":\n return val == null || val === \"\" || (Array.isArray(val) && val.length === 0);\n case \"isNotEmpty\":\n return val != null && val !== \"\" && !(Array.isArray(val) && val.length === 0);\n default:\n return false;\n }\n}\n\n/**\n * Evaluate a parsed expression against form values.\n *\n * If the resolved fieldPath ends with `.length`, it reads the array at the parent\n * path and uses its length as the left-hand value.\n */\nexport function evaluateExpression(\n parsed: ParsedExpression,\n getFormValue: (path: string) => unknown\n): boolean {\n const { target, operator, value: rhs } = parsed;\n\n let val: unknown;\n if (target.endsWith(\".length\")) {\n const arrayPath = target.slice(0, -\".length\".length);\n const arr = getFormValue(arrayPath);\n val = Array.isArray(arr) ? arr.length : 0;\n } else {\n val = getFormValue(target);\n }\n\n return compareValues(operator, val, rhs);\n}\n"],"names":["resolveFieldPath","fieldPath","bindParentName","relative","pathParts","parentParts","indexMap","Map","prefixParts","part","resolved","currentPrefix","key","index","compareValues","operator","val","rhs","Number","String","Array","evaluateExpression","parsed","getFormValue","target","arrayPath","arr"],"mappings":"AA4BO,SAASA,iBAAiBC,SAAiB,EAAEC,cAAuB;IACvE,IAAI,CAACD,UAAU,QAAQ,CAAC,MACpB,OAAOA;IAGX,IAAIA,UAAU,UAAU,CAAC,OAAO;QAC5B,MAAME,WAAWF,UAAU,KAAK,CAAC;QACjC,OAAOC,iBAAiB,GAAGA,eAAe,CAAC,EAAEC,UAAU,GAAGA;IAC9D;IAEA,IAAI,CAACD,gBAED,OAAOD,UAAU,OAAO,CAAC,OAAO;IAGpC,MAAMG,YAAYH,UAAU,KAAK,CAAC;IAClC,MAAMI,cAAcH,eAAe,KAAK,CAAC;IAMzC,MAAMI,WAAW,IAAIC;IACrB,MAAMC,cAAwB,EAAE;IAChC,KAAK,MAAMC,QAAQJ,YACf,IAAI,QAAQ,IAAI,CAACI,OACbH,SAAS,GAAG,CAACE,YAAY,IAAI,CAAC,MAAMC;SAEpCD,YAAY,IAAI,CAACC;IAKzB,MAAMC,WAAqB,EAAE;IAC7B,MAAMC,gBAA0B,EAAE;IAClC,KAAK,MAAMF,QAAQL,UACf,IAAIK,AAAS,QAATA,MAAc;QACd,MAAMG,MAAMD,cAAc,IAAI,CAAC;QAC/B,MAAME,QAAQP,SAAS,GAAG,CAACM,QAAQ;QACnCF,SAAS,IAAI,CAACG;IAClB,OAAO;QACHF,cAAc,IAAI,CAACF;QACnBC,SAAS,IAAI,CAACD;IAClB;IAGJ,OAAOC,SAAS,IAAI,CAAC;AACzB;AAEA,SAASI,cACLC,QAAgB,EAChBC,GAAY,EACZC,GAAqC;IAErC,OAAQF;QACJ,KAAK;YACD,OAAOC,OAAOC;QAClB,KAAK;YACD,OAAOD,OAAOC;QAClB,KAAK;YACD,OAAOC,OAAOF,OAAOE,OAAOD;QAChC,KAAK;YACD,OAAOC,OAAOF,OAAOE,OAAOD;QAChC,KAAK;YACD,OAAOC,OAAOF,QAAQE,OAAOD;QACjC,KAAK;YACD,OAAOC,OAAOF,QAAQE,OAAOD;QACjC,KAAK;YACD,OAAOE,OAAOH,OAAO,IAAI,QAAQ,CAACG,OAAOF,OAAO;QACpD,KAAK;YACD,OAAOE,OAAOH,OAAO,IAAI,UAAU,CAACG,OAAOF,OAAO;QACtD,KAAK;YACD,OAAOE,OAAOH,OAAO,IAAI,QAAQ,CAACG,OAAOF,OAAO;QACpD,KAAK;YACD,OAAOD,AAAO,QAAPA,OAAeA,AAAQ,OAARA,OAAeI,MAAM,OAAO,CAACJ,QAAQA,AAAe,MAAfA,IAAI,MAAM;QACzE,KAAK;YACD,OAAOA,AAAO,QAAPA,OAAeA,AAAQ,OAARA,OAAc,CAAEI,CAAAA,MAAM,OAAO,CAACJ,QAAQA,AAAe,MAAfA,IAAI,MAAM,AAAK;QAC/E;YACI,OAAO;IACf;AACJ;AAQO,SAASK,mBACZC,MAAwB,EACxBC,YAAuC;IAEvC,MAAM,EAAEC,MAAM,EAAET,QAAQ,EAAE,OAAOE,GAAG,EAAE,GAAGK;IAEzC,IAAIN;IACJ,IAAIQ,OAAO,QAAQ,CAAC,YAAY;QAC5B,MAAMC,YAAYD,OAAO,KAAK,CAAC,GAAG;QAClC,MAAME,MAAMH,aAAaE;QACzBT,MAAMI,MAAM,OAAO,CAACM,OAAOA,IAAI,MAAM,GAAG;IAC5C,OACIV,MAAMO,aAAaC;IAGvB,OAAOV,cAAcC,UAAUC,KAAKC;AACxC"}
|
package/Fields/fieldOptions.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { CmsModelField, CmsEditorFieldsLayout } from "../types/model.js";
|
|
2
|
-
import type { CmsModelLayoutFieldTypePlugin } from "../types/index.js";
|
|
3
|
-
export interface FieldOption {
|
|
4
|
-
label: string;
|
|
5
|
-
value: string;
|
|
6
|
-
fieldType: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Walk a model layout and collect label prefixes for each field ID by delegating
|
|
10
|
-
* to `getFieldLabelPrefixes` on the matching layout-field-type plugin.
|
|
11
|
-
*
|
|
12
|
-
* Returns a map from fieldId to its label prefix string
|
|
13
|
-
* (e.g., `"metaTitle" → "My Tabs › SEO"`).
|
|
14
|
-
*/
|
|
15
|
-
export declare function buildFieldLabelPrefixes(layout: CmsEditorFieldsLayout, plugins: CmsModelLayoutFieldTypePlugin[]): Map<string, string>;
|
|
16
|
-
/**
|
|
17
|
-
* Build a flat list of field options from the model's field tree.
|
|
18
|
-
* Paths are absolute using fieldId segments, with `$` for list-object children
|
|
19
|
-
* (e.g., `panorama.hotspots.$.title`).
|
|
20
|
-
*
|
|
21
|
-
* When `fieldLabelPrefixes` is provided, fields whose IDs appear in the map will
|
|
22
|
-
* have the layout hierarchy prepended to their labels
|
|
23
|
-
* (e.g., `"My Tabs › SEO › Meta Title"`).
|
|
24
|
-
*
|
|
25
|
-
* When `layoutPlugins` is provided, nested layouts inside object fields
|
|
26
|
-
* (e.g., tabs inside an object field) are also scanned for label prefixes.
|
|
27
|
-
*
|
|
28
|
-
* Recursion rules:
|
|
29
|
-
* - Leaf field (no settings.fields): emit option
|
|
30
|
-
* - Object field (settings.fields, not list): recurse with prefix
|
|
31
|
-
* - List object field (settings.fields, list: true): emit `.length` pseudo-option,
|
|
32
|
-
* then recurse children with `.$` segment
|
|
33
|
-
* - dynamicZone: skip
|
|
34
|
-
* - ref: emit for isEmpty checks, skip children
|
|
35
|
-
*/
|
|
36
|
-
export declare function buildFieldOptions(fields: CmsModelField[], prefix?: string, labelPrefix?: string, fieldLabelPrefixes?: Map<string, string>, layoutPlugins?: CmsModelLayoutFieldTypePlugin[]): FieldOption[];
|
package/Fields/fieldOptions.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { isLayoutField } from "../types/model.js";
|
|
2
|
-
function buildFieldLabelPrefixes(layout, plugins) {
|
|
3
|
-
const map = new Map();
|
|
4
|
-
const pluginByType = new Map(plugins.map((p)=>[
|
|
5
|
-
p.field.type,
|
|
6
|
-
p
|
|
7
|
-
]));
|
|
8
|
-
for (const row of layout)for (const cell of row){
|
|
9
|
-
if (!isLayoutField(cell)) continue;
|
|
10
|
-
const plugin = pluginByType.get(cell.type);
|
|
11
|
-
if (!plugin?.field.getFieldLabelPrefixes) continue;
|
|
12
|
-
const prefixes = plugin.field.getFieldLabelPrefixes({
|
|
13
|
-
field: cell
|
|
14
|
-
});
|
|
15
|
-
for (const [fieldId, prefix] of Object.entries(prefixes))map.set(fieldId, prefix);
|
|
16
|
-
}
|
|
17
|
-
return map;
|
|
18
|
-
}
|
|
19
|
-
function buildFieldOptions(fields, prefix = "", labelPrefix = "", fieldLabelPrefixes, layoutPlugins) {
|
|
20
|
-
const options = [];
|
|
21
|
-
for (const field of fields){
|
|
22
|
-
const path = prefix + field.fieldId;
|
|
23
|
-
const layoutPrefix = fieldLabelPrefixes?.get(field.id);
|
|
24
|
-
const label = layoutPrefix ? `${labelPrefix}${layoutPrefix} › ${field.label}` : labelPrefix + field.label;
|
|
25
|
-
if ("dynamicZone" === field.type) {
|
|
26
|
-
options.push({
|
|
27
|
-
label: `${label} › Length`,
|
|
28
|
-
value: `${path}.length`,
|
|
29
|
-
fieldType: "number"
|
|
30
|
-
});
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
const childFields = field.settings?.fields;
|
|
34
|
-
if ("ref" === field.type) {
|
|
35
|
-
options.push({
|
|
36
|
-
label,
|
|
37
|
-
value: path,
|
|
38
|
-
fieldType: field.type
|
|
39
|
-
});
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (childFields && childFields.length > 0) {
|
|
43
|
-
let childPrefixes;
|
|
44
|
-
if (layoutPlugins && field.settings?.layout) childPrefixes = buildFieldLabelPrefixes(field.settings.layout, layoutPlugins);
|
|
45
|
-
if (field.list) {
|
|
46
|
-
options.push({
|
|
47
|
-
label: `${label} › Length`,
|
|
48
|
-
value: `${path}.length`,
|
|
49
|
-
fieldType: "number"
|
|
50
|
-
});
|
|
51
|
-
options.push(...buildFieldOptions(childFields, `${path}.$.`, `${label} › `, childPrefixes, layoutPlugins));
|
|
52
|
-
} else options.push(...buildFieldOptions(childFields, `${path}.`, `${label} › `, childPrefixes, layoutPlugins));
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
options.push({
|
|
56
|
-
label,
|
|
57
|
-
value: path,
|
|
58
|
-
fieldType: field.type
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return options;
|
|
62
|
-
}
|
|
63
|
-
export { buildFieldLabelPrefixes, buildFieldOptions };
|
|
64
|
-
|
|
65
|
-
//# sourceMappingURL=fieldOptions.js.map
|