@backstage/plugin-scaffolder-react 1.8.4 → 1.8.5-next.1
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/CHANGELOG.md +29 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.esm.js +19 -1472
- package/dist/alpha.esm.js.map +1 -1
- package/dist/api/ref.esm.js +12 -0
- package/dist/api/ref.esm.js.map +1 -0
- package/dist/extensions/index.esm.js +25 -0
- package/dist/extensions/index.esm.js.map +1 -0
- package/dist/extensions/keys.esm.js +5 -0
- package/dist/extensions/keys.esm.js.map +1 -0
- package/dist/hooks/useCustomFieldExtensions.esm.js +16 -0
- package/dist/hooks/useCustomFieldExtensions.esm.js.map +1 -0
- package/dist/hooks/useCustomLayouts.esm.js +16 -0
- package/dist/hooks/useCustomLayouts.esm.js.map +1 -0
- package/dist/hooks/useEventStream.esm.js +167 -0
- package/dist/hooks/useEventStream.esm.js.map +1 -0
- package/dist/index.esm.js +7 -228
- package/dist/index.esm.js.map +1 -1
- package/dist/layouts/createScaffolderLayout.esm.js +17 -0
- package/dist/layouts/createScaffolderLayout.esm.js.map +1 -0
- package/dist/layouts/keys.esm.js +5 -0
- package/dist/layouts/keys.esm.js.map +1 -0
- package/dist/next/components/Form/DescriptionFieldTemplate.esm.js +37 -0
- package/dist/next/components/Form/DescriptionFieldTemplate.esm.js.map +1 -0
- package/dist/next/components/Form/FieldTemplate.esm.js +65 -0
- package/dist/next/components/Form/FieldTemplate.esm.js.map +1 -0
- package/dist/next/components/Form/Form.esm.js +44 -0
- package/dist/next/components/Form/Form.esm.js.map +1 -0
- package/dist/next/components/ReviewState/ReviewState.esm.js +43 -0
- package/dist/next/components/ReviewState/ReviewState.esm.js.map +1 -0
- package/dist/next/components/ScaffolderField/ScaffolderField.esm.js +52 -0
- package/dist/next/components/ScaffolderField/ScaffolderField.esm.js.map +1 -0
- package/dist/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.esm.js +63 -0
- package/dist/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.esm.js.map +1 -0
- package/dist/next/components/Stepper/ErrorListTemplate/errorListTemplate.esm.js +32 -0
- package/dist/next/components/Stepper/ErrorListTemplate/errorListTemplate.esm.js.map +1 -0
- package/dist/next/components/Stepper/FieldOverrides/DescriptionField.esm.js +7 -0
- package/dist/next/components/Stepper/FieldOverrides/DescriptionField.esm.js.map +1 -0
- package/dist/next/components/Stepper/FieldOverrides/index.esm.js +2 -0
- package/dist/next/components/Stepper/FieldOverrides/index.esm.js.map +1 -0
- package/dist/next/components/Stepper/Stepper.esm.js +204 -0
- package/dist/next/components/Stepper/Stepper.esm.js.map +1 -0
- package/dist/next/components/Stepper/createAsyncValidators.esm.js +80 -0
- package/dist/next/components/Stepper/createAsyncValidators.esm.js.map +1 -0
- package/dist/next/components/Stepper/utils.esm.js +27 -0
- package/dist/next/components/Stepper/utils.esm.js.map +1 -0
- package/dist/next/components/TaskLogStream/TaskLogStream.esm.js +23 -0
- package/dist/next/components/TaskLogStream/TaskLogStream.esm.js.map +1 -0
- package/dist/next/components/TaskSteps/StepIcon.esm.js +52 -0
- package/dist/next/components/TaskSteps/StepIcon.esm.js.map +1 -0
- package/dist/next/components/TaskSteps/StepTime.esm.js +36 -0
- package/dist/next/components/TaskSteps/StepTime.esm.js.map +1 -0
- package/dist/next/components/TaskSteps/TaskBorder.esm.js +29 -0
- package/dist/next/components/TaskSteps/TaskBorder.esm.js.map +1 -0
- package/dist/next/components/TaskSteps/TaskSteps.esm.js +54 -0
- package/dist/next/components/TaskSteps/TaskSteps.esm.js.map +1 -0
- package/dist/next/components/TemplateCard/CardHeader.esm.js +41 -0
- package/dist/next/components/TemplateCard/CardHeader.esm.js.map +1 -0
- package/dist/next/components/TemplateCard/CardLink.esm.js +17 -0
- package/dist/next/components/TemplateCard/CardLink.esm.js.map +1 -0
- package/dist/next/components/TemplateCard/TemplateCard.esm.js +116 -0
- package/dist/next/components/TemplateCard/TemplateCard.esm.js.map +1 -0
- package/dist/next/components/TemplateCategoryPicker/TemplateCategoryPicker.esm.js +80 -0
- package/dist/next/components/TemplateCategoryPicker/TemplateCategoryPicker.esm.js.map +1 -0
- package/dist/next/components/TemplateGroup/TemplateGroup.esm.js +30 -0
- package/dist/next/components/TemplateGroup/TemplateGroup.esm.js.map +1 -0
- package/dist/next/components/TemplateGroups/TemplateGroups.esm.js +52 -0
- package/dist/next/components/TemplateGroups/TemplateGroups.esm.js.map +1 -0
- package/dist/next/components/TemplateOutputs/DefaultTemplateOutputs.esm.js +51 -0
- package/dist/next/components/TemplateOutputs/DefaultTemplateOutputs.esm.js.map +1 -0
- package/dist/next/components/TemplateOutputs/LinkOutputs.esm.js +40 -0
- package/dist/next/components/TemplateOutputs/LinkOutputs.esm.js.map +1 -0
- package/dist/next/components/TemplateOutputs/TextOutputs.esm.js +39 -0
- package/dist/next/components/TemplateOutputs/TextOutputs.esm.js.map +1 -0
- package/dist/next/components/Workflow/Workflow.esm.js +83 -0
- package/dist/next/components/Workflow/Workflow.esm.js.map +1 -0
- package/dist/next/hooks/useFilteredSchemaProperties.esm.js +44 -0
- package/dist/next/hooks/useFilteredSchemaProperties.esm.js.map +1 -0
- package/dist/next/hooks/useFormDataFromQuery.esm.js +21 -0
- package/dist/next/hooks/useFormDataFromQuery.esm.js.map +1 -0
- package/dist/next/hooks/useTemplateParameterSchema.esm.js +19 -0
- package/dist/next/hooks/useTemplateParameterSchema.esm.js.map +1 -0
- package/dist/next/hooks/useTemplateSchema.esm.js +46 -0
- package/dist/next/hooks/useTemplateSchema.esm.js.map +1 -0
- package/dist/next/hooks/useTemplateTimeSaved.esm.js +25 -0
- package/dist/next/hooks/useTemplateTimeSaved.esm.js.map +1 -0
- package/dist/next/hooks/useTransformSchemaToProps.esm.js +24 -0
- package/dist/next/hooks/useTransformSchemaToProps.esm.js.map +1 -0
- package/dist/next/lib/schema.esm.js +108 -0
- package/dist/next/lib/schema.esm.js.map +1 -0
- package/dist/{esm/ref-NRtFlQHB.esm.js → secrets/SecretsContext.esm.js} +3 -11
- package/dist/secrets/SecretsContext.esm.js.map +1 -0
- package/package.json +15 -15
- package/dist/esm/ref-NRtFlQHB.esm.js.map +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { withTheme } from '@rjsf/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { FieldTemplate } from './FieldTemplate.esm.js';
|
|
4
|
+
import { DescriptionFieldTemplate } from './DescriptionFieldTemplate.esm.js';
|
|
5
|
+
import { Theme } from '@rjsf/material-ui';
|
|
6
|
+
|
|
7
|
+
const WrappedForm = withTheme(Theme);
|
|
8
|
+
const Form = (props) => {
|
|
9
|
+
const wrappedFields = React.useMemo(
|
|
10
|
+
() => {
|
|
11
|
+
var _a;
|
|
12
|
+
return Object.fromEntries(
|
|
13
|
+
Object.entries((_a = props.fields) != null ? _a : {}).map(([key, Component]) => [
|
|
14
|
+
key,
|
|
15
|
+
(wrapperProps) => {
|
|
16
|
+
var _a2, _b;
|
|
17
|
+
return /* @__PURE__ */ React.createElement(
|
|
18
|
+
Component,
|
|
19
|
+
{
|
|
20
|
+
...wrapperProps,
|
|
21
|
+
uiSchema: (_a2 = wrapperProps.uiSchema) != null ? _a2 : {},
|
|
22
|
+
formData: wrapperProps.formData,
|
|
23
|
+
rawErrors: (_b = wrapperProps.rawErrors) != null ? _b : []
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
])
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
[props.fields]
|
|
31
|
+
);
|
|
32
|
+
const templates = React.useMemo(
|
|
33
|
+
() => ({
|
|
34
|
+
FieldTemplate,
|
|
35
|
+
DescriptionFieldTemplate,
|
|
36
|
+
...props.templates
|
|
37
|
+
}),
|
|
38
|
+
[props.templates]
|
|
39
|
+
);
|
|
40
|
+
return /* @__PURE__ */ React.createElement(WrappedForm, { ...props, templates, fields: wrappedFields });
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { Form };
|
|
44
|
+
//# sourceMappingURL=Form.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Form.esm.js","sources":["../../../../src/next/components/Form/Form.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { withTheme } from '@rjsf/core';\nimport React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { FieldTemplate } from './FieldTemplate';\nimport { DescriptionFieldTemplate } from './DescriptionFieldTemplate';\nimport { FieldProps } from '@rjsf/utils';\nimport { ScaffolderRJSFFormProps } from '@backstage/plugin-scaffolder-react';\nimport { Theme as MuiTheme } from '@rjsf/material-ui';\n\nconst WrappedForm = withTheme(MuiTheme);\n\n/**\n * The Form component\n * @alpha\n */\nexport const Form = (props: PropsWithChildren<ScaffolderRJSFFormProps>) => {\n // This is where we unbreak the changes from RJSF, and make it work with our custom fields so we don't pass on this\n // breaking change to our users. We will look more into a better API for this in scaffolderv2.\n const wrappedFields = React.useMemo(\n () =>\n Object.fromEntries(\n Object.entries(props.fields ?? {}).map(([key, Component]) => [\n key,\n (wrapperProps: FieldProps) => {\n return (\n <Component\n {...wrapperProps}\n uiSchema={wrapperProps.uiSchema ?? {}}\n formData={wrapperProps.formData}\n rawErrors={wrapperProps.rawErrors ?? []}\n />\n );\n },\n ]),\n ),\n [props.fields],\n );\n\n const templates = React.useMemo(\n () => ({\n FieldTemplate,\n DescriptionFieldTemplate,\n ...props.templates,\n }),\n [props.templates],\n );\n\n return (\n <WrappedForm {...props} templates={templates} fields={wrappedFields} />\n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G,KAAO,EAAA,SAAA,EAAsB,QAAQ,aAAe,EAAA,CAAA,CAAA;AAEzE;;;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StructuredMetadataTable } from '@backstage/core-components';
|
|
3
|
+
import { Draft07 } from 'json-schema-library';
|
|
4
|
+
|
|
5
|
+
const ReviewState = (props) => {
|
|
6
|
+
const reviewData = Object.fromEntries(
|
|
7
|
+
Object.entries(props.formState).map(([key, value]) => {
|
|
8
|
+
var _a;
|
|
9
|
+
for (const step of props.schemas) {
|
|
10
|
+
const parsedSchema = new Draft07(step.mergedSchema);
|
|
11
|
+
const definitionInSchema = parsedSchema.getSchema({
|
|
12
|
+
pointer: `#/${key}`,
|
|
13
|
+
data: props.formState
|
|
14
|
+
});
|
|
15
|
+
if (definitionInSchema) {
|
|
16
|
+
const backstageReviewOptions = (_a = definitionInSchema["ui:backstage"]) == null ? void 0 : _a.review;
|
|
17
|
+
if (backstageReviewOptions) {
|
|
18
|
+
if (backstageReviewOptions.mask) {
|
|
19
|
+
return [key, backstageReviewOptions.mask];
|
|
20
|
+
}
|
|
21
|
+
if (backstageReviewOptions.show === false) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (definitionInSchema["ui:widget"] === "password") {
|
|
26
|
+
return [key, "******"];
|
|
27
|
+
}
|
|
28
|
+
if (definitionInSchema.enum && definitionInSchema.enumNames) {
|
|
29
|
+
return [
|
|
30
|
+
key,
|
|
31
|
+
definitionInSchema.enumNames[definitionInSchema.enum.indexOf(value)] || value
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return [key, value];
|
|
37
|
+
}).filter((prop) => prop.length > 0)
|
|
38
|
+
);
|
|
39
|
+
return /* @__PURE__ */ React.createElement(StructuredMetadataTable, { metadata: reviewData });
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { ReviewState };
|
|
43
|
+
//# sourceMappingURL=ReviewState.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReviewState.esm.js","sources":["../../../../src/next/components/ReviewState/ReviewState.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { StructuredMetadataTable } from '@backstage/core-components';\nimport { JsonObject } from '@backstage/types';\nimport { Draft07 as JSONSchema } from 'json-schema-library';\nimport { ParsedTemplateSchema } from '../../hooks/useTemplateSchema';\n\n/**\n * The props for the {@link ReviewState} component.\n * @alpha\n */\nexport type ReviewStateProps = {\n schemas: ParsedTemplateSchema[];\n formState: JsonObject;\n};\n\n/**\n * The component used by the {@link Stepper} to render the review step.\n * @alpha\n */\nexport const ReviewState = (props: ReviewStateProps) => {\n const reviewData = Object.fromEntries(\n Object.entries(props.formState)\n .map(([key, value]) => {\n for (const step of props.schemas) {\n const parsedSchema = new JSONSchema(step.mergedSchema);\n const definitionInSchema = parsedSchema.getSchema({\n pointer: `#/${key}`,\n data: props.formState,\n });\n\n if (definitionInSchema) {\n const backstageReviewOptions =\n definitionInSchema['ui:backstage']?.review;\n\n if (backstageReviewOptions) {\n if (backstageReviewOptions.mask) {\n return [key, backstageReviewOptions.mask];\n }\n if (backstageReviewOptions.show === false) {\n return [];\n }\n }\n\n if (definitionInSchema['ui:widget'] === 'password') {\n return [key, '******'];\n }\n\n if (definitionInSchema.enum && definitionInSchema.enumNames) {\n return [\n key,\n definitionInSchema.enumNames[\n definitionInSchema.enum.indexOf(value)\n ] || value,\n ];\n }\n }\n }\n return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AAmB,SAAW,EAAA;AAC3D,YAAO,OAAA;AAAA,cACL,GAAA;AAAA,cACA,mBAAmB,SACjB,CAAA,kBAAA,CAAmB,KAAK,OAAQ,CAAA,KAAK,CACvC,CAAK,IAAA,KAAA;AAAA,aACP,CAAA;AAAA,WACF;AAAA,SACF;AAAA,OACF;AACA,MAAO,OAAA,CAAC,KAAK,KAAK,CAAA,CAAA;AAAA,KACnB,CACA,CAAA,MAAA,CAAO,CAAQ,IAAA,KAAA,IAAA,CAAK,SAAS,CAAC,CAAA;AAAA,GACnC,CAAA;AACA,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,uBAAwB,EAAA,EAAA,QAAA,EAAU,UAAY,EAAA,CAAA,CAAA;AACxD;;;;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MarkdownContent } from '@backstage/core-components';
|
|
3
|
+
import FormControl from '@material-ui/core/FormControl';
|
|
4
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
5
|
+
|
|
6
|
+
const useStyles = makeStyles((theme) => ({
|
|
7
|
+
markdownDescription: {
|
|
8
|
+
fontSize: theme.typography.caption.fontSize,
|
|
9
|
+
margin: 0,
|
|
10
|
+
color: theme.palette.text.secondary,
|
|
11
|
+
"& :first-child": {
|
|
12
|
+
margin: 0,
|
|
13
|
+
marginTop: "3px"
|
|
14
|
+
// to keep the standard browser padding
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}));
|
|
18
|
+
const ScaffolderField = (props) => {
|
|
19
|
+
const {
|
|
20
|
+
children,
|
|
21
|
+
displayLabel = true,
|
|
22
|
+
rawErrors = [],
|
|
23
|
+
errors,
|
|
24
|
+
help,
|
|
25
|
+
rawDescription,
|
|
26
|
+
required,
|
|
27
|
+
disabled
|
|
28
|
+
} = props;
|
|
29
|
+
const classes = useStyles();
|
|
30
|
+
return /* @__PURE__ */ React.createElement(
|
|
31
|
+
FormControl,
|
|
32
|
+
{
|
|
33
|
+
fullWidth: true,
|
|
34
|
+
error: rawErrors.length ? true : false,
|
|
35
|
+
required,
|
|
36
|
+
disabled
|
|
37
|
+
},
|
|
38
|
+
children,
|
|
39
|
+
displayLabel && rawDescription ? /* @__PURE__ */ React.createElement(
|
|
40
|
+
MarkdownContent,
|
|
41
|
+
{
|
|
42
|
+
content: rawDescription,
|
|
43
|
+
className: classes.markdownDescription
|
|
44
|
+
}
|
|
45
|
+
) : null,
|
|
46
|
+
errors,
|
|
47
|
+
help
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { ScaffolderField };
|
|
52
|
+
//# sourceMappingURL=ScaffolderField.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScaffolderField.esm.js","sources":["../../../../src/next/components/ScaffolderField/ScaffolderField.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { PropsWithChildren, ReactElement } from 'react';\n\nimport { MarkdownContent } from '@backstage/core-components';\nimport FormControl from '@material-ui/core/FormControl';\nimport { makeStyles } from '@material-ui/core/styles';\n\nconst useStyles = makeStyles(theme => ({\n markdownDescription: {\n fontSize: theme.typography.caption.fontSize,\n margin: 0,\n color: theme.palette.text.secondary,\n '& :first-child': {\n margin: 0,\n marginTop: '3px', // to keep the standard browser padding\n },\n },\n}));\n\n/**\n * Props for the {@link ScaffolderField} component\n * @alpha\n */\nexport interface ScaffolderFieldProps {\n rawDescription?: string;\n errors?: ReactElement;\n rawErrors?: string[];\n help?: ReactElement;\n rawHelp?: string;\n required?: boolean;\n disabled?: boolean;\n displayLabel?: boolean;\n}\n\n/**\n * A component to wrap up a input field which helps with formatting and supporting markdown\n * on the field types\n * @alpha\n */\nexport const ScaffolderField = (\n props: PropsWithChildren<ScaffolderFieldProps>,\n) => {\n const {\n children,\n displayLabel = true,\n rawErrors = [],\n errors,\n help,\n rawDescription,\n required,\n disabled,\n } = props;\n const classes = useStyles();\n return (\n <FormControl\n fullWidth\n error={rawErrors.length ? true : false}\n required={required}\n disabled={disabled}\n >\n {children}\n {displayLabel && rawDescription ? (\n <MarkdownContent\n content={rawDescription}\n className={classes.markdownDescription}\n />\n ) : null}\n {errors}\n {help}\n </FormControl>\n );\n};\n"],"names":[],"mappings":";;;;;AAqBA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,mBAAqB,EAAA;AAAA,IACnB,QAAA,EAAU,KAAM,CAAA,UAAA,CAAW,OAAQ,CAAA,QAAA;AAAA,IACnC,MAAQ,EAAA,CAAA;AAAA,IACR,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,SAAA;AAAA,IAC1B,gBAAkB,EAAA;AAAA,MAChB,MAAQ,EAAA,CAAA;AAAA,MACR,SAAW,EAAA,KAAA;AAAA;AAAA,KACb;AAAA,GACF;AACF,CAAE,CAAA,CAAA,CAAA;AAsBW,MAAA,eAAA,GAAkB,CAC7B,KACG,KAAA;AACH,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,YAAe,GAAA,IAAA;AAAA,IACf,YAAY,EAAC;AAAA,IACb,MAAA;AAAA,IACA,IAAA;AAAA,IACA,cAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,GACE,GAAA,KAAA,CAAA;AACJ,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,SAAS,EAAA,IAAA;AAAA,MACT,KAAA,EAAO,SAAU,CAAA,MAAA,GAAS,IAAO,GAAA,KAAA;AAAA,MACjC,QAAA;AAAA,MACA,QAAA;AAAA,KAAA;AAAA,IAEC,QAAA;AAAA,IACA,gBAAgB,cACf,mBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,eAAA;AAAA,MAAA;AAAA,QACC,OAAS,EAAA,cAAA;AAAA,QACT,WAAW,OAAQ,CAAA,mBAAA;AAAA,OAAA;AAAA,KAEnB,GAAA,IAAA;AAAA,IACH,MAAA;AAAA,IACA,IAAA;AAAA,GACH,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
2
|
+
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
|
3
|
+
import ListItemText from '@material-ui/core/ListItemText';
|
|
4
|
+
import MenuItem from '@material-ui/core/MenuItem';
|
|
5
|
+
import MenuList from '@material-ui/core/MenuList';
|
|
6
|
+
import Popover from '@material-ui/core/Popover';
|
|
7
|
+
import CreateComponentIcon from '@material-ui/icons/AddCircleOutline';
|
|
8
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
9
|
+
import DescriptionIcon from '@material-ui/icons/Description';
|
|
10
|
+
import Edit from '@material-ui/icons/Edit';
|
|
11
|
+
import List from '@material-ui/icons/List';
|
|
12
|
+
import MoreVert from '@material-ui/icons/MoreVert';
|
|
13
|
+
import React, { useState } from 'react';
|
|
14
|
+
|
|
15
|
+
const useStyles = makeStyles((theme) => ({
|
|
16
|
+
button: {
|
|
17
|
+
color: theme.page.fontColor
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
20
|
+
function ScaffolderPageContextMenu(props) {
|
|
21
|
+
const { onEditorClicked, onActionsClicked, onTasksClicked, onCreateClicked } = props;
|
|
22
|
+
const classes = useStyles();
|
|
23
|
+
const [anchorEl, setAnchorEl] = useState();
|
|
24
|
+
if (!onEditorClicked && !onActionsClicked) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const onOpen = (event) => {
|
|
28
|
+
setAnchorEl(event.currentTarget);
|
|
29
|
+
};
|
|
30
|
+
const onClose = () => {
|
|
31
|
+
setAnchorEl(void 0);
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
34
|
+
IconButton,
|
|
35
|
+
{
|
|
36
|
+
id: "long-menu",
|
|
37
|
+
"aria-label": "more",
|
|
38
|
+
"aria-controls": "long-menu",
|
|
39
|
+
"aria-expanded": !!anchorEl,
|
|
40
|
+
"aria-haspopup": "true",
|
|
41
|
+
role: "button",
|
|
42
|
+
onClick: onOpen,
|
|
43
|
+
"data-testid": "menu-button",
|
|
44
|
+
color: "inherit",
|
|
45
|
+
className: classes.button
|
|
46
|
+
},
|
|
47
|
+
/* @__PURE__ */ React.createElement(MoreVert, null)
|
|
48
|
+
), /* @__PURE__ */ React.createElement(
|
|
49
|
+
Popover,
|
|
50
|
+
{
|
|
51
|
+
"aria-labelledby": "long-menu",
|
|
52
|
+
open: Boolean(anchorEl),
|
|
53
|
+
onClose,
|
|
54
|
+
anchorEl,
|
|
55
|
+
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
56
|
+
transformOrigin: { vertical: "top", horizontal: "right" }
|
|
57
|
+
},
|
|
58
|
+
/* @__PURE__ */ React.createElement(MenuList, null, onCreateClicked && /* @__PURE__ */ React.createElement(MenuItem, { onClick: onCreateClicked }, /* @__PURE__ */ React.createElement(ListItemIcon, null, /* @__PURE__ */ React.createElement(CreateComponentIcon, { fontSize: "small" })), /* @__PURE__ */ React.createElement(ListItemText, { primary: "Create" })), onEditorClicked && /* @__PURE__ */ React.createElement(MenuItem, { onClick: onEditorClicked }, /* @__PURE__ */ React.createElement(ListItemIcon, null, /* @__PURE__ */ React.createElement(Edit, { fontSize: "small" })), /* @__PURE__ */ React.createElement(ListItemText, { primary: "Template Editor" })), onActionsClicked && /* @__PURE__ */ React.createElement(MenuItem, { onClick: onActionsClicked }, /* @__PURE__ */ React.createElement(ListItemIcon, null, /* @__PURE__ */ React.createElement(DescriptionIcon, { fontSize: "small" })), /* @__PURE__ */ React.createElement(ListItemText, { primary: "Installed Actions" })), onTasksClicked && /* @__PURE__ */ React.createElement(MenuItem, { onClick: onTasksClicked }, /* @__PURE__ */ React.createElement(ListItemIcon, null, /* @__PURE__ */ React.createElement(List, { fontSize: "small" })), /* @__PURE__ */ React.createElement(ListItemText, { primary: "Task List" })))
|
|
59
|
+
));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { ScaffolderPageContextMenu };
|
|
63
|
+
//# sourceMappingURL=ScaffolderPageContextMenu.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScaffolderPageContextMenu.esm.js","sources":["../../../../src/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport IconButton from '@material-ui/core/IconButton';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport MenuList from '@material-ui/core/MenuList';\nimport Popover from '@material-ui/core/Popover';\nimport CreateComponentIcon from '@material-ui/icons/AddCircleOutline';\nimport { makeStyles } from '@material-ui/core/styles';\nimport Description from '@material-ui/icons/Description';\nimport Edit from '@material-ui/icons/Edit';\nimport List from '@material-ui/icons/List';\nimport MoreVert from '@material-ui/icons/MoreVert';\nimport React, { useState } from 'react';\n\nconst useStyles = makeStyles(theme => ({\n button: {\n color: theme.page.fontColor,\n },\n}));\n\n/**\n * @alpha\n */\nexport type ScaffolderPageContextMenuProps = {\n onEditorClicked?: () => void;\n onActionsClicked?: () => void;\n onTasksClicked?: () => void;\n onCreateClicked?: () => void;\n};\n\n/**\n * @alpha\n */\nexport function ScaffolderPageContextMenu(\n props: ScaffolderPageContextMenuProps,\n) {\n const { onEditorClicked, onActionsClicked, onTasksClicked, onCreateClicked } =\n props;\n const classes = useStyles();\n const [anchorEl, setAnchorEl] = useState<HTMLButtonElement>();\n\n if (!onEditorClicked && !onActionsClicked) {\n return null;\n }\n\n const onOpen = (event: React.SyntheticEvent<HTMLButtonElement>) => {\n setAnchorEl(event.currentTarget);\n };\n\n const onClose = () => {\n setAnchorEl(undefined);\n };\n\n return (\n <>\n <IconButton\n id=\"long-menu\"\n aria-label=\"more\"\n aria-controls=\"long-menu\"\n aria-expanded={!!anchorEl}\n aria-haspopup=\"true\"\n role=\"button\"\n onClick={onOpen}\n data-testid=\"menu-button\"\n color=\"inherit\"\n className={classes.button}\n >\n <MoreVert />\n </IconButton>\n <Popover\n aria-labelledby=\"long-menu\"\n open={Boolean(anchorEl)}\n onClose={onClose}\n anchorEl={anchorEl}\n anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}\n transformOrigin={{ vertical: 'top', horizontal: 'right' }}\n >\n <MenuList>\n {onCreateClicked && (\n <MenuItem onClick={onCreateClicked}>\n <ListItemIcon>\n <CreateComponentIcon fontSize=\"small\" />\n </ListItemIcon>\n <ListItemText primary=\"Create\" />\n </MenuItem>\n )}\n {onEditorClicked && (\n <MenuItem onClick={onEditorClicked}>\n <ListItemIcon>\n <Edit fontSize=\"small\" />\n </ListItemIcon>\n <ListItemText primary=\"Template Editor\" />\n </MenuItem>\n )}\n {onActionsClicked && (\n <MenuItem onClick={onActionsClicked}>\n <ListItemIcon>\n <Description fontSize=\"small\" />\n </ListItemIcon>\n <ListItemText primary=\"Installed Actions\" />\n </MenuItem>\n )}\n {onTasksClicked && (\n <MenuItem onClick={onTasksClicked}>\n <ListItemIcon>\n <List fontSize=\"small\" />\n </ListItemIcon>\n <ListItemText primary=\"Task List\" />\n </MenuItem>\n )}\n </MenuList>\n </Popover>\n </>\n );\n}\n"],"names":["Description"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,MAAQ,EAAA;AAAA,IACN,KAAA,EAAO,MAAM,IAAK,CAAA,SAAA;AAAA,GACpB;AACF,CAAE,CAAA,CAAA,CAAA;AAeK,SAAS,0BACd,KACA,EAAA;AACA,EAAA,MAAM,EAAE,eAAA,EAAiB,gBAAkB,EAAA,cAAA,EAAgB,iBACzD,GAAA,KAAA,CAAA;AACF,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,QAA4B,EAAA,CAAA;AAE5D,EAAI,IAAA,CAAC,eAAmB,IAAA,CAAC,gBAAkB,EAAA;AACzC,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAM,MAAA,MAAA,GAAS,CAAC,KAAmD,KAAA;AACjE,IAAA,WAAA,CAAY,MAAM,aAAa,CAAA,CAAA;AAAA,GACjC,CAAA;AAEA,EAAA,MAAM,UAAU,MAAM;AACpB,IAAA,WAAA,CAAY,KAAS,CAAA,CAAA,CAAA;AAAA,GACvB,CAAA;AAEA,EAAA,uBAEI,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,EAAG,EAAA,WAAA;AAAA,MACH,YAAW,EAAA,MAAA;AAAA,MACX,eAAc,EAAA,WAAA;AAAA,MACd,eAAA,EAAe,CAAC,CAAC,QAAA;AAAA,MACjB,eAAc,EAAA,MAAA;AAAA,MACd,IAAK,EAAA,QAAA;AAAA,MACL,OAAS,EAAA,MAAA;AAAA,MACT,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A,CAAA,aAAA,CAAA,YAAA,EAAA,EAAa,SAAQ,mBAAoB,EAAA,CAC5C,CAED,EAAA,cAAA,wCACE,QAAS,EAAA,EAAA,OAAA,EAAS,cACjB,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,oCACE,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,QAAS,EAAA,OAAA,EAAQ,CACzB,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,gBAAa,OAAQ,EAAA,WAAA,EAAY,CACpC,CAEJ,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import List from '@material-ui/core/List';
|
|
3
|
+
import ListItem from '@material-ui/core/ListItem';
|
|
4
|
+
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
|
5
|
+
import ListItemText from '@material-ui/core/ListItemText';
|
|
6
|
+
import Paper from '@material-ui/core/Paper';
|
|
7
|
+
import { makeStyles, createStyles } from '@material-ui/core/styles';
|
|
8
|
+
import ErrorIcon from '@material-ui/icons/Error';
|
|
9
|
+
|
|
10
|
+
const useStyles = makeStyles(
|
|
11
|
+
(_theme) => createStyles({
|
|
12
|
+
list: {
|
|
13
|
+
width: "100%"
|
|
14
|
+
},
|
|
15
|
+
text: {
|
|
16
|
+
textWrap: "wrap"
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
const ErrorListTemplate = ({ errors }) => {
|
|
21
|
+
const classes = useStyles();
|
|
22
|
+
return /* @__PURE__ */ React.createElement(Paper, null, /* @__PURE__ */ React.createElement(List, { dense: true, className: classes.list }, errors.map((error, index) => /* @__PURE__ */ React.createElement(ListItem, { key: index }, /* @__PURE__ */ React.createElement(ListItemIcon, null, /* @__PURE__ */ React.createElement(ErrorIcon, { color: "error" })), /* @__PURE__ */ React.createElement(
|
|
23
|
+
ListItemText,
|
|
24
|
+
{
|
|
25
|
+
classes: { primary: classes.text },
|
|
26
|
+
primary: error.stack
|
|
27
|
+
}
|
|
28
|
+
)))));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { ErrorListTemplate };
|
|
32
|
+
//# sourceMappingURL=errorListTemplate.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorListTemplate.esm.js","sources":["../../../../../src/next/components/Stepper/ErrorListTemplate/errorListTemplate.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { ErrorListProps } from '@rjsf/utils';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Paper from '@material-ui/core/Paper';\nimport { Theme, createStyles, makeStyles } from '@material-ui/core/styles';\nimport ErrorIcon from '@material-ui/icons/Error';\n\nconst useStyles = makeStyles((_theme: Theme) =>\n createStyles({\n list: {\n width: '100%',\n },\n text: {\n textWrap: 'wrap',\n },\n }),\n);\n\n/**\n * Shows a list of errors found in the form\n *\n * @public\n */\nexport const ErrorListTemplate = ({ errors }: ErrorListProps) => {\n const classes = useStyles();\n\n return (\n <Paper>\n <List dense className={classes.list}>\n {errors.map((error, index) => (\n <ListItem key={index}>\n <ListItemIcon>\n <ErrorIcon color=\"error\" />\n </ListItemIcon>\n <ListItemText\n classes={{ primary: classes.text }}\n primary={error.stack}\n />\n </ListItem>\n ))}\n </List>\n </Paper>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAyBA,MAAM,SAAY,GAAA,UAAA;AAAA,EAAW,CAAC,WAC5B,YAAa,CAAA;AAAA,IACX,IAAM,EAAA;AAAA,MACJ,KAAO,EAAA,MAAA;AAAA,KACT;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,QAAU,EAAA,MAAA;AAAA,KACZ;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAOO,MAAM,iBAAoB,GAAA,CAAC,EAAE,MAAA,EAA6B,KAAA;AAC/D,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAE1B,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,KACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,KAAA,EAAK,MAAC,SAAW,EAAA,OAAA,CAAQ,IAC5B,EAAA,EAAA,MAAA,CAAO,GAAI,CAAA,CAAC,OAAO,KAClB,qBAAA,KAAA,CAAA,aAAA,CAAC,QAAS,EAAA,EAAA,GAAA,EAAK,KACb,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,YACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,SAAU,EAAA,EAAA,KAAA,EAAM,OAAQ,EAAA,CAC3B,CACA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,OAAS,EAAA,EAAE,OAAS,EAAA,OAAA,CAAQ,IAAK,EAAA;AAAA,MACjC,SAAS,KAAM,CAAA,KAAA;AAAA,KAAA;AAAA,GAEnB,CACD,CACH,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MarkdownContent } from '@backstage/core-components';
|
|
3
|
+
|
|
4
|
+
const DescriptionField = ({ description }) => description && /* @__PURE__ */ React.createElement(MarkdownContent, { content: description, linkTarget: "_blank" });
|
|
5
|
+
|
|
6
|
+
export { DescriptionField };
|
|
7
|
+
//# sourceMappingURL=DescriptionField.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DescriptionField.esm.js","sources":["../../../../../src/next/components/Stepper/FieldOverrides/DescriptionField.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { MarkdownContent } from '@backstage/core-components';\nimport { FieldProps } from '@rjsf/utils';\n\nexport const DescriptionField = ({ description }: FieldProps) =>\n description && <MarkdownContent content={description} linkTarget=\"_blank\" />;\n"],"names":[],"mappings":";;;AAoBa,MAAA,gBAAA,GAAmB,CAAC,EAAE,WAAY,EAAA,KAC7C,WAAe,oBAAA,KAAA,CAAA,aAAA,CAAC,eAAgB,EAAA,EAAA,OAAA,EAAS,WAAa,EAAA,UAAA,EAAW,QAAS,EAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { useAnalytics, useApiHolder } from '@backstage/core-plugin-api';
|
|
2
|
+
import MuiStepper from '@material-ui/core/Stepper';
|
|
3
|
+
import MuiStep from '@material-ui/core/Step';
|
|
4
|
+
import MuiStepLabel from '@material-ui/core/StepLabel';
|
|
5
|
+
import Button from '@material-ui/core/Button';
|
|
6
|
+
import LinearProgress from '@material-ui/core/LinearProgress';
|
|
7
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
8
|
+
import React, { useState, useMemo, useCallback } from 'react';
|
|
9
|
+
import { createAsyncValidators } from './createAsyncValidators.esm.js';
|
|
10
|
+
import { ReviewState } from '../ReviewState/ReviewState.esm.js';
|
|
11
|
+
import { useFormDataFromQuery } from '../../hooks/useFormDataFromQuery.esm.js';
|
|
12
|
+
import { useTemplateSchema } from '../../hooks/useTemplateSchema.esm.js';
|
|
13
|
+
import 'react-use/esm/useAsync';
|
|
14
|
+
import '../../../api/ref.esm.js';
|
|
15
|
+
import 'lodash/cloneDeep';
|
|
16
|
+
import validator from '@rjsf/validator-ajv8';
|
|
17
|
+
import { useTransformSchemaToProps } from '../../hooks/useTransformSchemaToProps.esm.js';
|
|
18
|
+
import { hasErrors } from './utils.esm.js';
|
|
19
|
+
import * as index from './FieldOverrides/index.esm.js';
|
|
20
|
+
import { Form } from '../Form/Form.esm.js';
|
|
21
|
+
import { ErrorListTemplate } from './ErrorListTemplate/errorListTemplate.esm.js';
|
|
22
|
+
|
|
23
|
+
const useStyles = makeStyles((theme) => ({
|
|
24
|
+
backButton: {
|
|
25
|
+
marginRight: theme.spacing(1)
|
|
26
|
+
},
|
|
27
|
+
footer: {
|
|
28
|
+
display: "flex",
|
|
29
|
+
flexDirection: "row",
|
|
30
|
+
justifyContent: "right",
|
|
31
|
+
marginTop: theme.spacing(2)
|
|
32
|
+
},
|
|
33
|
+
formWrapper: {
|
|
34
|
+
padding: theme.spacing(2)
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
const Stepper = (stepperProps) => {
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
39
|
+
const { layouts = [], components = {}, ...props } = stepperProps;
|
|
40
|
+
const {
|
|
41
|
+
ReviewStateComponent = ReviewState,
|
|
42
|
+
ReviewStepComponent,
|
|
43
|
+
backButtonText = "Back",
|
|
44
|
+
createButtonText = "Create",
|
|
45
|
+
reviewButtonText = "Review"
|
|
46
|
+
} = components;
|
|
47
|
+
const analytics = useAnalytics();
|
|
48
|
+
const { presentation, steps } = useTemplateSchema(props.manifest);
|
|
49
|
+
const apiHolder = useApiHolder();
|
|
50
|
+
const [activeStep, setActiveStep] = useState(0);
|
|
51
|
+
const [isValidating, setIsValidating] = useState(false);
|
|
52
|
+
const [formState, setFormState] = useFormDataFromQuery(props.initialState);
|
|
53
|
+
const [errors, setErrors] = useState();
|
|
54
|
+
const styles = useStyles();
|
|
55
|
+
const backLabel = (_b = (_a = presentation == null ? void 0 : presentation.buttonLabels) == null ? void 0 : _a.backButtonText) != null ? _b : backButtonText;
|
|
56
|
+
const createLabel = (_d = (_c = presentation == null ? void 0 : presentation.buttonLabels) == null ? void 0 : _c.createButtonText) != null ? _d : createButtonText;
|
|
57
|
+
const reviewLabel = (_f = (_e = presentation == null ? void 0 : presentation.buttonLabels) == null ? void 0 : _e.reviewButtonText) != null ? _f : reviewButtonText;
|
|
58
|
+
const extensions = useMemo(() => {
|
|
59
|
+
return Object.fromEntries(
|
|
60
|
+
props.extensions.map(({ name, component }) => [name, component])
|
|
61
|
+
);
|
|
62
|
+
}, [props.extensions]);
|
|
63
|
+
const fields = useMemo(
|
|
64
|
+
() => ({ ...index, ...extensions }),
|
|
65
|
+
[extensions]
|
|
66
|
+
);
|
|
67
|
+
const validators = useMemo(() => {
|
|
68
|
+
return Object.fromEntries(
|
|
69
|
+
props.extensions.map(({ name, validation: validation2 }) => [name, validation2])
|
|
70
|
+
);
|
|
71
|
+
}, [props.extensions]);
|
|
72
|
+
const validation = useMemo(() => {
|
|
73
|
+
var _a2;
|
|
74
|
+
return createAsyncValidators((_a2 = steps[activeStep]) == null ? void 0 : _a2.mergedSchema, validators, {
|
|
75
|
+
apiHolder
|
|
76
|
+
});
|
|
77
|
+
}, [steps, activeStep, validators, apiHolder]);
|
|
78
|
+
const handleBack = () => {
|
|
79
|
+
setActiveStep((prevActiveStep) => prevActiveStep - 1);
|
|
80
|
+
};
|
|
81
|
+
const handleChange = useCallback(
|
|
82
|
+
(e) => setFormState((current) => ({ ...current, ...e.formData })),
|
|
83
|
+
[setFormState]
|
|
84
|
+
);
|
|
85
|
+
const handleCreate = useCallback(() => {
|
|
86
|
+
props.onCreate(formState);
|
|
87
|
+
analytics.captureEvent("click", `${createLabel}`);
|
|
88
|
+
}, [props, formState, analytics, createLabel]);
|
|
89
|
+
const currentStep = useTransformSchemaToProps(steps[activeStep], { layouts });
|
|
90
|
+
const handleNext = async ({
|
|
91
|
+
formData = {}
|
|
92
|
+
}) => {
|
|
93
|
+
setErrors(void 0);
|
|
94
|
+
setIsValidating(true);
|
|
95
|
+
const returnedValidation = await validation(formData);
|
|
96
|
+
setIsValidating(false);
|
|
97
|
+
if (hasErrors(returnedValidation)) {
|
|
98
|
+
setErrors(returnedValidation);
|
|
99
|
+
} else {
|
|
100
|
+
setErrors(void 0);
|
|
101
|
+
setActiveStep((prevActiveStep) => {
|
|
102
|
+
const stepNum = prevActiveStep + 1;
|
|
103
|
+
analytics.captureEvent("click", `Next Step (${stepNum})`);
|
|
104
|
+
return stepNum;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
setFormState((current) => ({ ...current, ...formData }));
|
|
108
|
+
};
|
|
109
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, isValidating && /* @__PURE__ */ React.createElement(LinearProgress, { variant: "indeterminate" }), /* @__PURE__ */ React.createElement(
|
|
110
|
+
MuiStepper,
|
|
111
|
+
{
|
|
112
|
+
activeStep,
|
|
113
|
+
alternativeLabel: true,
|
|
114
|
+
variant: "elevation",
|
|
115
|
+
style: { overflowX: "auto" }
|
|
116
|
+
},
|
|
117
|
+
steps.map((step, index) => {
|
|
118
|
+
const isAllowedLabelClick = activeStep > index;
|
|
119
|
+
return /* @__PURE__ */ React.createElement(MuiStep, { key: index }, /* @__PURE__ */ React.createElement(
|
|
120
|
+
MuiStepLabel,
|
|
121
|
+
{
|
|
122
|
+
"aria-label": `Step ${index + 1}`,
|
|
123
|
+
style: { cursor: isAllowedLabelClick ? "pointer" : "default" },
|
|
124
|
+
onClick: () => {
|
|
125
|
+
if (isAllowedLabelClick)
|
|
126
|
+
setActiveStep(index);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
step.title
|
|
130
|
+
));
|
|
131
|
+
}),
|
|
132
|
+
/* @__PURE__ */ React.createElement(MuiStep, null, /* @__PURE__ */ React.createElement(MuiStepLabel, null, "$", reviewLabel))
|
|
133
|
+
), /* @__PURE__ */ React.createElement("div", { className: styles.formWrapper }, activeStep < steps.length ? /* @__PURE__ */ React.createElement(
|
|
134
|
+
Form,
|
|
135
|
+
{
|
|
136
|
+
validator,
|
|
137
|
+
extraErrors: errors,
|
|
138
|
+
formData: formState,
|
|
139
|
+
formContext: { formData: formState },
|
|
140
|
+
schema: currentStep.schema,
|
|
141
|
+
uiSchema: currentStep.uiSchema,
|
|
142
|
+
onSubmit: handleNext,
|
|
143
|
+
fields,
|
|
144
|
+
showErrorList: "top",
|
|
145
|
+
templates: { ErrorListTemplate },
|
|
146
|
+
onChange: handleChange,
|
|
147
|
+
experimental_defaultFormStateBehavior: {
|
|
148
|
+
allOf: "populateDefaults"
|
|
149
|
+
},
|
|
150
|
+
...(_g = props.formProps) != null ? _g : {}
|
|
151
|
+
},
|
|
152
|
+
/* @__PURE__ */ React.createElement("div", { className: styles.footer }, /* @__PURE__ */ React.createElement(
|
|
153
|
+
Button,
|
|
154
|
+
{
|
|
155
|
+
onClick: handleBack,
|
|
156
|
+
className: styles.backButton,
|
|
157
|
+
disabled: activeStep < 1 || isValidating
|
|
158
|
+
},
|
|
159
|
+
backLabel
|
|
160
|
+
), /* @__PURE__ */ React.createElement(
|
|
161
|
+
Button,
|
|
162
|
+
{
|
|
163
|
+
variant: "contained",
|
|
164
|
+
color: "primary",
|
|
165
|
+
type: "submit",
|
|
166
|
+
disabled: isValidating
|
|
167
|
+
},
|
|
168
|
+
activeStep === steps.length - 1 ? reviewLabel : "Next"
|
|
169
|
+
))
|
|
170
|
+
) : (
|
|
171
|
+
// TODO: potentially move away from this pattern, deprecate?
|
|
172
|
+
ReviewStepComponent ? /* @__PURE__ */ React.createElement(
|
|
173
|
+
ReviewStepComponent,
|
|
174
|
+
{
|
|
175
|
+
disableButtons: isValidating,
|
|
176
|
+
formData: formState,
|
|
177
|
+
handleBack,
|
|
178
|
+
handleReset: () => {
|
|
179
|
+
},
|
|
180
|
+
steps,
|
|
181
|
+
handleCreate
|
|
182
|
+
}
|
|
183
|
+
) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ReviewStateComponent, { formState, schemas: steps }), /* @__PURE__ */ React.createElement("div", { className: styles.footer }, /* @__PURE__ */ React.createElement(
|
|
184
|
+
Button,
|
|
185
|
+
{
|
|
186
|
+
onClick: handleBack,
|
|
187
|
+
className: styles.backButton,
|
|
188
|
+
disabled: activeStep < 1
|
|
189
|
+
},
|
|
190
|
+
backLabel
|
|
191
|
+
), /* @__PURE__ */ React.createElement(
|
|
192
|
+
Button,
|
|
193
|
+
{
|
|
194
|
+
variant: "contained",
|
|
195
|
+
color: "primary",
|
|
196
|
+
onClick: handleCreate
|
|
197
|
+
},
|
|
198
|
+
createLabel
|
|
199
|
+
)))
|
|
200
|
+
)));
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export { Stepper };
|
|
204
|
+
//# sourceMappingURL=Stepper.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stepper.esm.js","sources":["../../../../src/next/components/Stepper/Stepper.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { useAnalytics, useApiHolder } from '@backstage/core-plugin-api';\nimport { JsonValue } from '@backstage/types';\nimport MuiStepper from '@material-ui/core/Stepper';\nimport MuiStep from '@material-ui/core/Step';\nimport MuiStepLabel from '@material-ui/core/StepLabel';\nimport Button from '@material-ui/core/Button';\nimport LinearProgress from '@material-ui/core/LinearProgress';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { type IChangeEvent } from '@rjsf/core';\nimport { ErrorSchema } from '@rjsf/utils';\nimport React, {\n useCallback,\n useMemo,\n useState,\n type ReactNode,\n ComponentType,\n} from 'react';\nimport {\n createAsyncValidators,\n type FormValidation,\n} from './createAsyncValidators';\nimport { ReviewState, type ReviewStateProps } from '../ReviewState';\nimport { useTemplateSchema, useFormDataFromQuery } from '../../hooks';\nimport validator from '@rjsf/validator-ajv8';\nimport { useTransformSchemaToProps } from '../../hooks/useTransformSchemaToProps';\nimport { hasErrors } from './utils';\nimport * as FieldOverrides from './FieldOverrides';\nimport { Form } from '../Form';\nimport {\n TemplateParameterSchema,\n LayoutOptions,\n FieldExtensionOptions,\n FormProps,\n} from '@backstage/plugin-scaffolder-react';\nimport { ReviewStepProps } from '@backstage/plugin-scaffolder-react';\nimport { ErrorListTemplate } from './ErrorListTemplate';\n\nconst useStyles = makeStyles(theme => ({\n backButton: {\n marginRight: theme.spacing(1),\n },\n footer: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'right',\n marginTop: theme.spacing(2),\n },\n formWrapper: {\n padding: theme.spacing(2),\n },\n}));\n\n/**\n * The Props for {@link Stepper} component\n * @alpha\n */\nexport type StepperProps = {\n manifest: TemplateParameterSchema;\n extensions: FieldExtensionOptions<any, any>[];\n /**\n * @deprecated This was only ever used for analytics tracking purposes, which\n * is now handled in the `<Workflow />` component. Passing it in will have no\n * effect.\n */\n templateName?: string;\n formProps?: FormProps;\n initialState?: Record<string, JsonValue>;\n onCreate: (values: Record<string, JsonValue>) => Promise<void>;\n components?: {\n ReviewStepComponent?: ComponentType<ReviewStepProps>;\n ReviewStateComponent?: (props: ReviewStateProps) => JSX.Element;\n backButtonText?: ReactNode;\n createButtonText?: ReactNode;\n reviewButtonText?: ReactNode;\n };\n layouts?: LayoutOptions[];\n};\n\n/**\n * The `Stepper` component is the Wizard that is rendered when a user selects a template\n * @alpha\n */\nexport const Stepper = (stepperProps: StepperProps) => {\n const { layouts = [], components = {}, ...props } = stepperProps;\n const {\n ReviewStateComponent = ReviewState,\n ReviewStepComponent,\n backButtonText = 'Back',\n createButtonText = 'Create',\n reviewButtonText = 'Review',\n } = components;\n const analytics = useAnalytics();\n const { presentation, steps } = useTemplateSchema(props.manifest);\n const apiHolder = useApiHolder();\n const [activeStep, setActiveStep] = useState(0);\n const [isValidating, setIsValidating] = useState(false);\n const [formState, setFormState] = useFormDataFromQuery(props.initialState);\n\n const [errors, setErrors] = useState<undefined | FormValidation>();\n const styles = useStyles();\n\n const backLabel =\n presentation?.buttonLabels?.backButtonText ?? backButtonText;\n const createLabel =\n presentation?.buttonLabels?.createButtonText ?? createButtonText;\n const reviewLabel =\n presentation?.buttonLabels?.reviewButtonText ?? reviewButtonText;\n\n const extensions = useMemo(() => {\n return Object.fromEntries(\n props.extensions.map(({ name, component }) => [name, component]),\n );\n }, [props.extensions]);\n\n const fields = useMemo(\n () => ({ ...FieldOverrides, ...extensions }),\n [extensions],\n );\n\n const validators = useMemo(() => {\n return Object.fromEntries(\n props.extensions.map(({ name, validation }) => [name, validation]),\n );\n }, [props.extensions]);\n\n const validation = useMemo(() => {\n return createAsyncValidators(steps[activeStep]?.mergedSchema, validators, {\n apiHolder,\n });\n }, [steps, activeStep, validators, apiHolder]);\n\n const handleBack = () => {\n setActiveStep(prevActiveStep => prevActiveStep - 1);\n };\n\n const handleChange = useCallback(\n (e: IChangeEvent) =>\n setFormState(current => ({ ...current, ...e.formData })),\n [setFormState],\n );\n\n const handleCreate = useCallback(() => {\n props.onCreate(formState);\n analytics.captureEvent('click', `${createLabel}`);\n }, [props, formState, analytics, createLabel]);\n\n const currentStep = useTransformSchemaToProps(steps[activeStep], { layouts });\n\n const handleNext = async ({\n formData = {},\n }: {\n formData?: Record<string, JsonValue>;\n }) => {\n // The validation should never throw, as the validators are wrapped in a try/catch.\n // This makes it fine to set and unset state without try/catch.\n setErrors(undefined);\n setIsValidating(true);\n\n const returnedValidation = await validation(formData);\n\n setIsValidating(false);\n\n if (hasErrors(returnedValidation)) {\n setErrors(returnedValidation);\n } else {\n setErrors(undefined);\n setActiveStep(prevActiveStep => {\n const stepNum = prevActiveStep + 1;\n analytics.captureEvent('click', `Next Step (${stepNum})`);\n return stepNum;\n });\n }\n setFormState(current => ({ ...current, ...formData }));\n };\n\n return (\n <>\n {isValidating && <LinearProgress variant=\"indeterminate\" />}\n <MuiStepper\n activeStep={activeStep}\n alternativeLabel\n variant=\"elevation\"\n style={{ overflowX: 'auto' }}\n >\n {steps.map((step, index) => {\n const isAllowedLabelClick = activeStep > index;\n return (\n <MuiStep key={index}>\n <MuiStepLabel\n aria-label={`Step ${index + 1}`}\n style={{ cursor: isAllowedLabelClick ? 'pointer' : 'default' }}\n onClick={() => {\n if (isAllowedLabelClick) setActiveStep(index);\n }}\n >\n {step.title}\n </MuiStepLabel>\n </MuiStep>\n );\n })}\n <MuiStep>\n <MuiStepLabel>${reviewLabel}</MuiStepLabel>\n </MuiStep>\n </MuiStepper>\n <div className={styles.formWrapper}>\n {/* eslint-disable-next-line no-nested-ternary */}\n {activeStep < steps.length ? (\n <Form\n validator={validator}\n extraErrors={errors as unknown as ErrorSchema}\n formData={formState}\n formContext={{ formData: formState }}\n schema={currentStep.schema}\n uiSchema={currentStep.uiSchema}\n onSubmit={handleNext}\n fields={fields}\n showErrorList=\"top\"\n templates={{ ErrorListTemplate }}\n onChange={handleChange}\n experimental_defaultFormStateBehavior={{\n allOf: 'populateDefaults',\n }}\n {...(props.formProps ?? {})}\n >\n <div className={styles.footer}>\n <Button\n onClick={handleBack}\n className={styles.backButton}\n disabled={activeStep < 1 || isValidating}\n >\n {backLabel}\n </Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n type=\"submit\"\n disabled={isValidating}\n >\n {activeStep === steps.length - 1 ? reviewLabel : 'Next'}\n </Button>\n </div>\n </Form>\n ) : // TODO: potentially move away from this pattern, deprecate?\n ReviewStepComponent ? (\n <ReviewStepComponent\n disableButtons={isValidating}\n formData={formState}\n handleBack={handleBack}\n handleReset={() => {}}\n steps={steps}\n handleCreate={handleCreate}\n />\n ) : (\n <>\n <ReviewStateComponent formState={formState} schemas={steps} />\n <div className={styles.footer}>\n <Button\n onClick={handleBack}\n className={styles.backButton}\n disabled={activeStep < 1}\n >\n {backLabel}\n </Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n onClick={handleCreate}\n >\n {createLabel}\n </Button>\n </div>\n </>\n )}\n </div>\n </>\n );\n};\n"],"names":["FieldOverrides","validation","_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,UAAY,EAAA;AAAA,IACV,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,GAC9B;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,OAAS,EAAA,MAAA;AAAA,IACT,aAAe,EAAA,KAAA;AAAA,IACf,cAAgB,EAAA,OAAA;AAAA,IAChB,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,GAC5B;AAAA,EACA,WAAa,EAAA;AAAA,IACX,OAAA,EAAS,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,GAC1B;AACF,CAAE,CAAA,CAAA,CAAA;AAgCW,MAAA,OAAA,GAAU,CAAC,YAA+B,KAAA;AAjGvD,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAkGE,EAAM,MAAA,EAAE,UAAU,EAAC,EAAG,aAAa,EAAC,EAAG,GAAG,KAAA,EAAU,GAAA,YAAA,CAAA;AACpD,EAAM,MAAA;AAAA,IACJ,oBAAuB,GAAA,WAAA;AAAA,IACvB,mBAA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AAA,KAErD,CAAA;AAAA,GACF;AAAA;AAAA,IAEF,mBACE,mBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,mBAAA;AAAA,MAAA;AAAA,QACC,cAAgB,EAAA,YAAA;AAAA,QAChB,QAAU,EAAA,SAAA;AAAA,QACV,UAAA;AAAA,QACA,aAAa,MAAM;AAAA,SAAC;AAAA,QACpB,KAAA;AAAA,QACA,YAAA;AAAA,OAAA;AAAA,KAGF,mBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBACG,KAAA,CAAA,aAAA,CAAA,oBAAA,EAAA,EAAqB,SAAsB,EAAA,OAAA,EAAS,KAAO,EAAA,CAAA,kBAC3D,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAI,SAAW,EAAA,MAAA,CAAO,MACrB,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAS,EAAA,UAAA;AAAA,QACT,WAAW,MAAO,CAAA,UAAA;AAAA,QAClB,UAAU,UAAa,GAAA,CAAA;AAAA,OAAA;AAAA,MAEtB,SAAA;AAAA,KAEH,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,WAAA;AAAA,QACR,KAAM,EAAA,SAAA;AAAA,QACN,OAAS,EAAA,YAAA;AAAA,OAAA;AAAA,MAER,WAAA;AAAA,KAEL,CACF,CAAA;AAAA,GAEJ,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Draft07 } from 'json-schema-library';
|
|
2
|
+
import { extractSchemaFromStep, createFieldValidation } from '../../lib/schema.esm.js';
|
|
3
|
+
import { isObject } from './utils.esm.js';
|
|
4
|
+
|
|
5
|
+
const isJsonError = (value) => "type" in value && value.type === "error";
|
|
6
|
+
const createAsyncValidators = (rootSchema, validators, context) => {
|
|
7
|
+
async function validate(formData, pathPrefix = "#", current = formData) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
const parsedSchema = new Draft07(rootSchema);
|
|
10
|
+
const formValidation = {};
|
|
11
|
+
const validateForm = async (validatorName, key, value, schema, uiSchema) => {
|
|
12
|
+
const validator = validators[validatorName];
|
|
13
|
+
if (validator) {
|
|
14
|
+
const fieldValidation = createFieldValidation();
|
|
15
|
+
try {
|
|
16
|
+
await validator(value, fieldValidation, {
|
|
17
|
+
...context,
|
|
18
|
+
formData,
|
|
19
|
+
schema,
|
|
20
|
+
uiSchema
|
|
21
|
+
});
|
|
22
|
+
} catch (ex) {
|
|
23
|
+
fieldValidation.addError(ex.message);
|
|
24
|
+
}
|
|
25
|
+
formValidation[key] = fieldValidation;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
for (const [key, value] of Object.entries(current)) {
|
|
29
|
+
const pointer = `${pathPrefix}/${key}`;
|
|
30
|
+
const definitionInSchema = parsedSchema.getSchema({
|
|
31
|
+
pointer,
|
|
32
|
+
data: formData
|
|
33
|
+
});
|
|
34
|
+
if (!definitionInSchema) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (isJsonError(definitionInSchema)) {
|
|
38
|
+
throw new Error(definitionInSchema.message);
|
|
39
|
+
}
|
|
40
|
+
const { schema, uiSchema } = extractSchemaFromStep(
|
|
41
|
+
definitionInSchema
|
|
42
|
+
);
|
|
43
|
+
const hasItems = definitionInSchema && definitionInSchema.items;
|
|
44
|
+
const doValidateItem = async (propValue, itemSchema, itemUiSchema) => {
|
|
45
|
+
await validateForm(
|
|
46
|
+
propValue["ui:field"],
|
|
47
|
+
key,
|
|
48
|
+
value,
|
|
49
|
+
itemSchema,
|
|
50
|
+
itemUiSchema
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
const doValidate = async (propValue) => {
|
|
54
|
+
if ("ui:field" in propValue) {
|
|
55
|
+
const { schema: itemsSchema, uiSchema: itemsUiSchema } = extractSchemaFromStep(definitionInSchema.items);
|
|
56
|
+
await doValidateItem(propValue, itemsSchema, itemsUiSchema);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
if ("ui:field" in definitionInSchema) {
|
|
60
|
+
await doValidateItem(definitionInSchema, schema, uiSchema);
|
|
61
|
+
} else if (hasItems && "ui:field" in definitionInSchema.items) {
|
|
62
|
+
await doValidate(definitionInSchema.items);
|
|
63
|
+
} else if (hasItems && definitionInSchema.items.type === "object") {
|
|
64
|
+
const properties = (_b = (_a = definitionInSchema.items) == null ? void 0 : _a.properties) != null ? _b : [];
|
|
65
|
+
for (const [, propValue] of Object.entries(properties)) {
|
|
66
|
+
await doValidate(propValue);
|
|
67
|
+
}
|
|
68
|
+
} else if (isObject(value)) {
|
|
69
|
+
formValidation[key] = await validate(formData, pointer, value);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return formValidation;
|
|
73
|
+
}
|
|
74
|
+
return async (formData) => {
|
|
75
|
+
return await validate(formData);
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export { createAsyncValidators };
|
|
80
|
+
//# sourceMappingURL=createAsyncValidators.esm.js.map
|