@rjsf/mantine 6.1.2 → 6.2.4

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
@@ -23,6 +23,8 @@ const uiOptionsKeys = [
23
23
  'duplicateKeySuffixSeparator',
24
24
  'enumOptions',
25
25
  'enableMarkdownInDescription',
26
+ 'enableMarkdownInHelp',
27
+ 'globalOptions',
26
28
  ];
27
29
  export function cleanupOptions(options) {
28
30
  const result = {};
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,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;IAC7B,sBAAsB;IACtB,eAAe;CAChB,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.1.2",
3
+ "version": "6.2.4",
4
4
  "main": "dist/index.js",
5
5
  "module": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -64,8 +64,8 @@
64
64
  "@mantine/core": ">=8",
65
65
  "@mantine/dates": ">=8",
66
66
  "@mantine/hooks": ">=8",
67
- "@rjsf/core": "^6.x",
68
- "@rjsf/utils": "^6.x",
67
+ "@rjsf/core": "^6.2.x",
68
+ "@rjsf/utils": "^6.2.x",
69
69
  "react": ">=18"
70
70
  },
71
71
  "devDependencies": {
@@ -74,10 +74,10 @@
74
74
  "@mantine/hooks": "^8.3.6",
75
75
  "@restart/hooks": "^0.6.2",
76
76
  "@restart/ui": "^1.9.4",
77
- "@rjsf/core": "^6.x",
78
- "@rjsf/snapshot-tests": "^6.x",
79
- "@rjsf/utils": "^6.x",
80
- "@rjsf/validator-ajv8": "^6.x",
77
+ "@rjsf/core": "^6.2.0",
78
+ "@rjsf/snapshot-tests": "^6.2.0",
79
+ "@rjsf/utils": "^6.2.0",
80
+ "@rjsf/validator-ajv8": "^6.2.0",
81
81
  "eslint": "^8.57.1",
82
82
  "uncontrollable": "^9.0.0"
83
83
  },
@@ -1,4 +1,4 @@
1
- import { ChangeEvent, FocusEvent, useCallback } from 'react';
1
+ import { ChangeEvent, FocusEvent, MouseEvent, useCallback } from 'react';
2
2
  import {
3
3
  ariaDescribedByIds,
4
4
  BaseInputTemplateProps,
@@ -44,7 +44,9 @@ export default function BaseInputTemplate<
44
44
  options,
45
45
  rawErrors,
46
46
  children,
47
+ registry,
47
48
  } = props;
49
+ const { ClearButton } = registry.templates.ButtonTemplates;
48
50
 
49
51
  const inputProps = getInputProps<T, S, F>(schema, type, options, false);
50
52
  const description = hideLabel ? undefined : options.description || schema.description;
@@ -75,6 +77,15 @@ export default function BaseInputTemplate<
75
77
  [onFocus, id],
76
78
  );
77
79
 
80
+ const handleClear = useCallback(
81
+ (e: MouseEvent) => {
82
+ e.preventDefault();
83
+ e.stopPropagation();
84
+ onChange(options.emptyValue ?? '');
85
+ },
86
+ [onChange, options.emptyValue],
87
+ );
88
+
78
89
  const componentProps = {
79
90
  id,
80
91
  name: htmlName || id,
@@ -117,6 +128,9 @@ export default function BaseInputTemplate<
117
128
  return (
118
129
  <>
119
130
  {input}
131
+ {options.allowClearTextInputs && !readonly && !disabled && value && (
132
+ <ClearButton registry={registry} onClick={handleClear} />
133
+ )}
120
134
  {children}
121
135
  {Array.isArray(schema.examples) && (
122
136
  <datalist id={examplesId(id)}>
@@ -85,3 +85,15 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
85
85
  />
86
86
  );
87
87
  }
88
+
89
+ export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
90
+ props: MantineIconButtonProps<T, S, F>,
91
+ ) {
92
+ const {
93
+ registry: { translateString },
94
+ } = props;
95
+
96
+ return (
97
+ <IconButton title={translateString(TranslatableString.ClearButton)} variant='subtle' {...props} icon={<X />} />
98
+ );
99
+ }
@@ -1,7 +1,7 @@
1
1
  import { FormContextType, RJSFSchema, StrictRJSFSchema, TemplatesType } from '@rjsf/utils';
2
2
  import SubmitButton from './SubmitButton';
3
3
  import AddButton from './AddButton';
4
- import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } from './IconButton';
4
+ import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton, ClearButton } from './IconButton';
5
5
 
6
6
  function buttonTemplates<
7
7
  T = any,
@@ -15,6 +15,7 @@ function buttonTemplates<
15
15
  MoveDownButton,
16
16
  MoveUpButton,
17
17
  RemoveButton,
18
+ ClearButton,
18
19
  };
19
20
  }
20
21
 
package/src/utils.ts CHANGED
@@ -25,6 +25,8 @@ const uiOptionsKeys: Array<keyof UIOptionsType> = [
25
25
  'duplicateKeySuffixSeparator',
26
26
  'enumOptions',
27
27
  'enableMarkdownInDescription',
28
+ 'enableMarkdownInHelp',
29
+ 'globalOptions',
28
30
  ];
29
31
 
30
32
  export function cleanupOptions<T extends object>(options: T): Omit<T, keyof UIOptionsType> {