@rjsf/core 6.0.0-beta.1 → 6.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.umd.js +15 -9
- package/dist/index.esm.js +132 -119
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +256 -246
- package/dist/index.js.map +4 -4
- package/lib/components/RichDescription.d.ts +20 -0
- package/lib/components/RichDescription.d.ts.map +1 -0
- package/lib/components/RichDescription.js +17 -0
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +1 -3
- package/lib/components/templates/DescriptionField.d.ts.map +1 -1
- package/lib/components/templates/DescriptionField.js +3 -7
- package/lib/components/widgets/CheckboxWidget.js +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/components/RichDescription.tsx +50 -0
- package/src/components/fields/SchemaField.tsx +1 -8
- package/src/components/templates/DescriptionField.tsx +8 -14
- package/src/components/widgets/CheckboxWidget.tsx +1 -1
- package/src/index.ts +3 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
3
|
+
export interface RichDescriptionProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
|
|
4
|
+
/** The description text for a field, potentially containing markdown */
|
|
5
|
+
description: string | ReactElement;
|
|
6
|
+
/** The uiSchema object for this base component */
|
|
7
|
+
uiSchema?: UiSchema<T, S, F>;
|
|
8
|
+
/** The `registry` object */
|
|
9
|
+
registry: Registry<T, S, F>;
|
|
10
|
+
}
|
|
11
|
+
/** Renders the given `description` in the props as
|
|
12
|
+
*
|
|
13
|
+
* @param props - The `RichDescriptionProps` for this component
|
|
14
|
+
*/
|
|
15
|
+
declare function RichDescription<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ description, registry, uiSchema }: RichDescriptionProps<T, S, F>): string | import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare namespace RichDescription {
|
|
17
|
+
var TEST_IDS: import("@rjsf/utils").TestIdShape;
|
|
18
|
+
}
|
|
19
|
+
export default RichDescription;
|
|
20
|
+
//# sourceMappingURL=RichDescription.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichDescription.d.ts","sourceRoot":"","sources":["../../src/components/RichDescription.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EACL,eAAe,EACf,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,QAAQ,EAGT,MAAM,aAAa,CAAC;AAKrB,MAAM,WAAW,oBAAoB,CACnC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG;IAE/B,wEAAwE;IACxE,WAAW,EAAE,MAAM,GAAG,YAAY,CAAC;IACnC,kDAAkD;IAClD,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B,4BAA4B;IAC5B,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAC7B;AAED;;;GAGG;AACH,iBAAwB,eAAe,CACrC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAa,EAAE,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,oDAYxE;kBAhBuB,eAAe;;;eAAf,eAAe"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getTestIds, getUiOptions, } from '@rjsf/utils';
|
|
3
|
+
import Markdown from 'markdown-to-jsx';
|
|
4
|
+
const TEST_IDS = getTestIds();
|
|
5
|
+
/** Renders the given `description` in the props as
|
|
6
|
+
*
|
|
7
|
+
* @param props - The `RichDescriptionProps` for this component
|
|
8
|
+
*/
|
|
9
|
+
export default function RichDescription({ description, registry, uiSchema = {} }) {
|
|
10
|
+
const { globalUiOptions } = registry;
|
|
11
|
+
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
12
|
+
if (uiOptions.enableMarkdownInDescription && typeof description === 'string') {
|
|
13
|
+
return (_jsx(Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS.markdown, children: description }));
|
|
14
|
+
}
|
|
15
|
+
return description;
|
|
16
|
+
}
|
|
17
|
+
RichDescription.TEST_IDS = TEST_IDS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/SchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAiB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAKL,UAAU,EAEV,eAAe,EAQf,UAAU,EACV,gBAAgB,EAIjB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"SchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/SchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAiB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAKL,UAAU,EAEV,eAAe,EAQf,UAAU,EACV,gBAAgB,EAIjB,MAAM,aAAa,CAAC;AA6TrB;;GAEG;AACH,cAAM,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,CAAE,SAAQ,SAAS,CACpH,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CACpB;IACC,qBAAqB,CAAC,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAI9D,MAAM;CAGP;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -3,7 +3,6 @@ import { useCallback, Component } from 'react';
|
|
|
3
3
|
import { ADDITIONAL_PROPERTY_FLAG, deepEquals, descriptionId, getSchemaType, getTemplate, getUiOptions, ID_KEY, mergeObjects, TranslatableString, UI_OPTIONS_KEY, } from '@rjsf/utils';
|
|
4
4
|
import isObject from 'lodash-es/isObject.js';
|
|
5
5
|
import omit from 'lodash-es/omit.js';
|
|
6
|
-
import Markdown from 'markdown-to-jsx';
|
|
7
6
|
/** The map of component type to FieldName */
|
|
8
7
|
const COMPONENT_TYPES = {
|
|
9
8
|
array: 'ArrayField',
|
|
@@ -107,7 +106,6 @@ function SchemaFieldRender(props) {
|
|
|
107
106
|
: uiOptions.title || props.schema.title || schema.title || props.title || name;
|
|
108
107
|
}
|
|
109
108
|
const description = uiOptions.description || props.schema.description || schema.description || '';
|
|
110
|
-
const richDescription = uiOptions.enableMarkdownInDescription ? (_jsx(Markdown, { options: { disableParsingRawHTML: true }, children: description })) : (description);
|
|
111
109
|
const help = uiOptions.help;
|
|
112
110
|
const hidden = uiOptions.widget === 'hidden';
|
|
113
111
|
const classNames = ['rjsf-field', `rjsf-field-${getSchemaType(schema)}`];
|
|
@@ -124,7 +122,7 @@ function SchemaFieldRender(props) {
|
|
|
124
122
|
*/
|
|
125
123
|
const errorsComponent = hideError || ((schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema)) ? undefined : (_jsx(FieldErrorTemplate, { errors: __errors, errorSchema: errorSchema, idSchema: idSchema, schema: schema, uiSchema: uiSchema, registry: registry }));
|
|
126
124
|
const fieldProps = {
|
|
127
|
-
description: (_jsx(DescriptionFieldTemplate, { id: descriptionId(id), description:
|
|
125
|
+
description: (_jsx(DescriptionFieldTemplate, { id: descriptionId(id), description: description, schema: schema, uiSchema: uiSchema, registry: registry })),
|
|
128
126
|
rawDescription: description,
|
|
129
127
|
help: helpComponent,
|
|
130
128
|
rawHelp: typeof help === 'string' ? help : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DescriptionField.d.ts","sourceRoot":"","sources":["../../../src/components/templates/DescriptionField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"DescriptionField.d.ts","sourceRoot":"","sources":["../../../src/components/templates/DescriptionField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAInG;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,kDAUtC"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import RichDescription from '../RichDescription.js';
|
|
2
3
|
/** The `DescriptionField` is the template to use to render the description of a field
|
|
3
4
|
*
|
|
4
5
|
* @param props - The `DescriptionFieldProps` for this component
|
|
5
6
|
*/
|
|
6
7
|
export default function DescriptionField(props) {
|
|
7
|
-
const { id, description } = props;
|
|
8
|
+
const { id, description, registry, uiSchema } = props;
|
|
8
9
|
if (!description) {
|
|
9
10
|
return null;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
return (_jsx("p", { id: id, className: 'field-description', children: description }));
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
return (_jsx("div", { id: id, className: 'field-description', children: description }));
|
|
16
|
-
}
|
|
12
|
+
return (_jsx("div", { id: id, className: 'field-description', children: _jsx(RichDescription, { description: description, registry: registry, uiSchema: uiSchema }) }));
|
|
17
13
|
}
|
|
@@ -16,6 +16,6 @@ function CheckboxWidget({ schema, uiSchema, options, id, value, disabled, readon
|
|
|
16
16
|
const handleBlur = useCallback((event) => onBlur(id, event.target.checked), [onBlur, id]);
|
|
17
17
|
const handleFocus = useCallback((event) => onFocus(id, event.target.checked), [onFocus, id]);
|
|
18
18
|
const description = options.description ?? schema.description;
|
|
19
|
-
return (_jsxs("div", { className: `checkbox ${disabled || readonly ? 'disabled' : ''}`, children: [!hideLabel &&
|
|
19
|
+
return (_jsxs("div", { className: `checkbox ${disabled || readonly ? 'disabled' : ''}`, children: [!hideLabel && description && (_jsx(DescriptionFieldTemplate, { id: descriptionId(id), description: description, schema: schema, uiSchema: uiSchema, registry: registry })), _jsxs("label", { children: [_jsx("input", { type: 'checkbox', id: id, name: id, checked: typeof value === 'undefined' ? false : value, required: required, disabled: disabled || readonly, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, "aria-describedby": ariaDescribedByIds(id) }), labelValue(_jsx("span", { children: label }), hideLabel)] })] }));
|
|
20
20
|
}
|
|
21
21
|
export default CheckboxWidget;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import Form, { FormProps, FormState, IChangeEvent } from './components/Form.js';
|
|
2
|
+
import RichDescription, { RichDescriptionProps } from './components/RichDescription.js';
|
|
2
3
|
import withTheme, { ThemeProps } from './withTheme.js';
|
|
3
4
|
import getDefaultRegistry from './getDefaultRegistry.js';
|
|
4
|
-
export type { FormProps, FormState, IChangeEvent, ThemeProps };
|
|
5
|
-
export { withTheme, getDefaultRegistry };
|
|
5
|
+
export type { FormProps, FormState, IChangeEvent, ThemeProps, RichDescriptionProps };
|
|
6
|
+
export { withTheme, getDefaultRegistry, RichDescription };
|
|
6
7
|
export default Form;
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,eAAe,EAAE,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;AAErF,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,eAAe,EAAE,CAAC;AAC1D,eAAe,IAAI,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Form from './components/Form.js';
|
|
2
|
+
import RichDescription from './components/RichDescription.js';
|
|
2
3
|
import withTheme from './withTheme.js';
|
|
3
4
|
import getDefaultRegistry from './getDefaultRegistry.js';
|
|
4
|
-
export { withTheme, getDefaultRegistry };
|
|
5
|
+
export { withTheme, getDefaultRegistry, RichDescription };
|
|
5
6
|
export default Form;
|