@rjsf/mantine 6.0.2 → 6.1.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/lib/utils.js CHANGED
@@ -2,6 +2,7 @@ const uiOptionsKeys = [
2
2
  'emptyValue',
3
3
  'classNames',
4
4
  'title',
5
+ 'label',
5
6
  'help',
6
7
  'autocomplete',
7
8
  'disabled',
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsf/mantine",
3
- "version": "6.0.2",
3
+ "version": "6.1.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -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
- return (
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
- onFocus={!readonly ? handleFocus : undefined}
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
- onFocus={!readonly ? handleFocus : undefined}
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={id} size='sm' my='xs' c='dimmed'>
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
  }
@@ -53,6 +53,8 @@ export default function FieldTemplate<
53
53
  classNames={classNames}
54
54
  style={style}
55
55
  label={label}
56
+ displayLabel={displayLabel}
57
+ rawDescription={rawDescription}
56
58
  schema={schema}
57
59
  uiSchema={uiSchema}
58
60
  registry={registry}
@@ -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
- <div className='form-group'>
65
- <TextInput
66
- className='form-group'
67
- label={keyLabel}
68
- defaultValue={label}
69
- required={required}
70
- disabled={disabled || readonly}
71
- id={`${id}-key`}
72
- name={`${id}-key`}
73
- onBlur={!readonly ? onKeyRenameBlur : undefined}
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
- <RemoveButton
82
- id={buttonId(id, 'remove')}
83
- iconType='sm'
84
- className='rjsf-array-item-remove'
85
- disabled={disabled || readonly}
86
- onClick={onRemoveProperty}
87
- uiSchema={buttonUiOptions}
88
- registry={registry}
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
  );
package/src/utils.ts CHANGED
@@ -4,6 +4,7 @@ const uiOptionsKeys: Array<keyof UIOptionsType> = [
4
4
  'emptyValue',
5
5
  'classNames',
6
6
  'title',
7
+ 'label',
7
8
  'help',
8
9
  'autocomplete',
9
10
  'disabled',