@rjsf/mantine 6.0.2 → 6.1.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/dist/index.cjs +100 -91
- package/dist/index.cjs.map +2 -2
- package/dist/mantine.esm.js +83 -74
- package/dist/mantine.esm.js.map +3 -3
- package/dist/mantine.umd.js +40 -32
- package/lib/templates/ArrayFieldTitleTemplate.js +8 -4
- package/lib/templates/ArrayFieldTitleTemplate.js.map +1 -1
- package/lib/templates/BaseInputTemplate.js +15 -1
- package/lib/templates/BaseInputTemplate.js.map +1 -1
- package/lib/templates/FieldHelpTemplate.js +3 -3
- package/lib/templates/FieldHelpTemplate.js.map +1 -1
- package/lib/templates/FieldTemplate.js +1 -1
- package/lib/templates/FieldTemplate.js.map +1 -1
- package/lib/templates/WrapIfAdditionalTemplate.js +2 -2
- package/lib/templates/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils.js +1 -0
- package/lib/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/templates/ArrayFieldTitleTemplate.tsx +13 -4
- package/src/templates/BaseInputTemplate.tsx +19 -22
- package/src/templates/FieldHelpTemplate.tsx +4 -5
- package/src/templates/FieldTemplate.tsx +2 -0
- package/src/templates/WrapIfAdditionalTemplate.tsx +24 -21
- package/src/utils.ts +1 -0
package/lib/utils.js
CHANGED
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa,GAA+B;IAChD,YAAY;IACZ,YAAY;IACZ,OAAO;IACP,MAAM;IACN,cAAc;IACd,UAAU;IACV,cAAc;IACd,WAAW;IACX,UAAU;IACV,OAAO;IACP,aAAa;IACb,QAAQ;IACR,WAAW;IACX,qBAAqB;IACrB,QAAQ;IACR,WAAW;IACX,SAAS;IACT,UAAU;IACV,WAAW;IACX,WAAW;IACX,6BAA6B;IAC7B,aAAa;IACb,6BAA6B;CAC9B,CAAC;AAEF,MAAM,UAAU,cAAc,CAAmB,OAAU;IACzD,MAAM,MAAM,GAAG,EAAO,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,GAA0B,CAAC,EAAE,CAAC;YACxD,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,MAAsC,CAAC;AAChD,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa,GAA+B;IAChD,YAAY;IACZ,YAAY;IACZ,OAAO;IACP,OAAO;IACP,MAAM;IACN,cAAc;IACd,UAAU;IACV,cAAc;IACd,WAAW;IACX,UAAU;IACV,OAAO;IACP,aAAa;IACb,QAAQ;IACR,WAAW;IACX,qBAAqB;IACrB,QAAQ;IACR,WAAW;IACX,SAAS;IACT,UAAU;IACV,WAAW;IACX,WAAW;IACX,6BAA6B;IAC7B,aAAa;IACb,6BAA6B;CAC9B,CAAC;AAEF,MAAM,UAAU,cAAc,CAAmB,OAAU;IACzD,MAAM,MAAM,GAAG,EAAO,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,GAA0B,CAAC,EAAE,CAAC;YACxD,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,MAAsC,CAAC;AAChD,CAAC"}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
RJSFSchema,
|
|
7
7
|
StrictRJSFSchema,
|
|
8
8
|
} from '@rjsf/utils';
|
|
9
|
-
import { Title } from '@mantine/core';
|
|
9
|
+
import { Grid, Title } from '@mantine/core';
|
|
10
10
|
|
|
11
11
|
/** The `ArrayFieldTitleTemplate` component renders a `TitleFieldTemplate` with an `id` derived from
|
|
12
12
|
* the `fieldPathId`.
|
|
@@ -18,16 +18,25 @@ export default function ArrayFieldTitleTemplate<
|
|
|
18
18
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
19
19
|
F extends FormContextType = any,
|
|
20
20
|
>(props: ArrayFieldTitleProps<T, S, F>) {
|
|
21
|
-
const { fieldPathId, title, uiSchema, registry } = props;
|
|
21
|
+
const { fieldPathId, title, uiSchema, registry, optionalDataControl } = props;
|
|
22
22
|
|
|
23
23
|
const options = getUiOptions<T, S, F>(uiSchema, registry.globalUiOptions);
|
|
24
24
|
const { label: displayLabel = true } = options;
|
|
25
25
|
if (!title || !displayLabel) {
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
let heading = title ? (
|
|
29
29
|
<Title id={titleId(fieldPathId)} order={4} fw='normal'>
|
|
30
30
|
{title}
|
|
31
31
|
</Title>
|
|
32
|
-
);
|
|
32
|
+
) : null;
|
|
33
|
+
if (optionalDataControl) {
|
|
34
|
+
heading = (
|
|
35
|
+
<Grid>
|
|
36
|
+
<Grid.Col span='auto'>{heading}</Grid.Col>
|
|
37
|
+
<Grid.Col span='content'>{optionalDataControl}</Grid.Col>
|
|
38
|
+
</Grid>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return heading;
|
|
33
42
|
}
|
|
@@ -47,6 +47,7 @@ export default function BaseInputTemplate<
|
|
|
47
47
|
} = props;
|
|
48
48
|
|
|
49
49
|
const inputProps = getInputProps<T, S, F>(schema, type, options, false);
|
|
50
|
+
const description = hideLabel ? undefined : options.description || schema.description;
|
|
50
51
|
const themeProps = cleanupOptions(options);
|
|
51
52
|
|
|
52
53
|
const handleNumberChange = useCallback((value: number | string) => onChange(value), [onChange]);
|
|
@@ -74,44 +75,40 @@ export default function BaseInputTemplate<
|
|
|
74
75
|
[onFocus, id],
|
|
75
76
|
);
|
|
76
77
|
|
|
78
|
+
const componentProps = {
|
|
79
|
+
id,
|
|
80
|
+
name: htmlName || id,
|
|
81
|
+
label: labelValue(label || undefined, hideLabel, false),
|
|
82
|
+
required,
|
|
83
|
+
autoFocus: autofocus,
|
|
84
|
+
disabled: disabled || readonly,
|
|
85
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
86
|
+
onFocus: !readonly ? handleFocus : undefined,
|
|
87
|
+
placeholder,
|
|
88
|
+
error: rawErrors && rawErrors.length > 0 ? rawErrors.join('\n') : undefined,
|
|
89
|
+
list: schema.examples ? examplesId(id) : undefined,
|
|
90
|
+
};
|
|
91
|
+
|
|
77
92
|
const input =
|
|
78
93
|
inputProps.type === 'number' || inputProps.type === 'integer' ? (
|
|
79
94
|
<NumberInput
|
|
80
|
-
id={id}
|
|
81
|
-
name={htmlName || id}
|
|
82
|
-
label={labelValue(label || undefined, hideLabel, false)}
|
|
83
|
-
required={required}
|
|
84
|
-
autoFocus={autofocus}
|
|
85
|
-
disabled={disabled || readonly}
|
|
86
|
-
onBlur={!readonly ? handleBlur : undefined}
|
|
87
95
|
onChange={!readonly ? handleNumberChange : undefined}
|
|
88
|
-
|
|
89
|
-
placeholder={placeholder}
|
|
90
|
-
error={rawErrors && rawErrors.length > 0 ? rawErrors.join('\n') : undefined}
|
|
91
|
-
list={schema.examples ? examplesId(id) : undefined}
|
|
96
|
+
{...componentProps}
|
|
92
97
|
{...inputProps}
|
|
93
98
|
{...themeProps}
|
|
94
99
|
step={typeof inputProps.step === 'number' ? inputProps.step : 1}
|
|
95
100
|
type='text'
|
|
101
|
+
description={description}
|
|
96
102
|
value={value}
|
|
97
103
|
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
98
104
|
/>
|
|
99
105
|
) : (
|
|
100
106
|
<TextInput
|
|
101
|
-
id={id}
|
|
102
|
-
name={htmlName || id}
|
|
103
|
-
label={labelValue(label || undefined, hideLabel, false)}
|
|
104
|
-
required={required}
|
|
105
|
-
autoFocus={autofocus}
|
|
106
|
-
disabled={disabled || readonly}
|
|
107
|
-
onBlur={!readonly ? handleBlur : undefined}
|
|
108
107
|
onChange={!readonly ? handleChange : undefined}
|
|
109
|
-
|
|
110
|
-
placeholder={placeholder}
|
|
111
|
-
error={rawErrors && rawErrors.length > 0 ? rawErrors.join('\n') : undefined}
|
|
112
|
-
list={schema.examples ? examplesId(id) : undefined}
|
|
108
|
+
{...componentProps}
|
|
113
109
|
{...inputProps}
|
|
114
110
|
{...themeProps}
|
|
111
|
+
description={description}
|
|
115
112
|
value={value}
|
|
116
113
|
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
117
114
|
/>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
import { Text } from '@mantine/core';
|
|
3
|
+
import { RichHelp } from '@rjsf/core';
|
|
3
4
|
|
|
4
5
|
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
5
6
|
*
|
|
@@ -10,17 +11,15 @@ export default function FieldHelpTemplate<
|
|
|
10
11
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
11
12
|
F extends FormContextType = any,
|
|
12
13
|
>(props: FieldHelpProps<T, S, F>) {
|
|
13
|
-
const { fieldPathId, help } = props;
|
|
14
|
+
const { fieldPathId, help, uiSchema, registry } = props;
|
|
14
15
|
|
|
15
16
|
if (!help) {
|
|
16
17
|
return null;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
const id = helpId(fieldPathId);
|
|
20
|
-
|
|
21
20
|
return (
|
|
22
|
-
<Text id={
|
|
23
|
-
{help}
|
|
21
|
+
<Text id={helpId(fieldPathId)} size='sm' my='xs' c='dimmed'>
|
|
22
|
+
<RichHelp help={help} registry={registry} uiSchema={uiSchema} />
|
|
24
23
|
</Text>
|
|
25
24
|
);
|
|
26
25
|
}
|
|
@@ -25,6 +25,8 @@ export default function WrapIfAdditionalTemplate<
|
|
|
25
25
|
classNames,
|
|
26
26
|
style,
|
|
27
27
|
label,
|
|
28
|
+
displayLabel,
|
|
29
|
+
rawDescription,
|
|
28
30
|
required,
|
|
29
31
|
readonly,
|
|
30
32
|
disabled,
|
|
@@ -61,32 +63,33 @@ export default function WrapIfAdditionalTemplate<
|
|
|
61
63
|
<Flex gap='xs' align='end' justify='center'>
|
|
62
64
|
<Grid w='100%' align='center'>
|
|
63
65
|
<Grid.Col span={6} className='form-additional'>
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
</div>
|
|
66
|
+
<TextInput
|
|
67
|
+
className='form-group'
|
|
68
|
+
label={displayLabel ? keyLabel : undefined}
|
|
69
|
+
defaultValue={label}
|
|
70
|
+
required={required}
|
|
71
|
+
description={rawDescription ? '\u00A0' : undefined}
|
|
72
|
+
disabled={disabled || readonly}
|
|
73
|
+
id={`${id}-key`}
|
|
74
|
+
name={`${id}-key`}
|
|
75
|
+
onBlur={!readonly ? onKeyRenameBlur : undefined}
|
|
76
|
+
/>
|
|
76
77
|
</Grid.Col>
|
|
77
78
|
<Grid.Col span={6} className='form-additional'>
|
|
78
79
|
{children}
|
|
79
80
|
</Grid.Col>
|
|
80
81
|
</Grid>
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
<div>
|
|
83
|
+
<RemoveButton
|
|
84
|
+
id={buttonId(id, 'remove')}
|
|
85
|
+
iconType='sm'
|
|
86
|
+
className='rjsf-array-item-remove'
|
|
87
|
+
disabled={disabled || readonly}
|
|
88
|
+
onClick={onRemoveProperty}
|
|
89
|
+
uiSchema={buttonUiOptions}
|
|
90
|
+
registry={registry}
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
90
93
|
</Flex>
|
|
91
94
|
</div>
|
|
92
95
|
);
|