@rjsf/antd 6.1.0 → 6.1.2

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.
@@ -4,4 +4,8 @@ import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjs
4
4
  *
5
5
  * @param props - The `WidgetProps` for this component
6
6
  */
7
- export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ autofocus, disabled, registry, id, htmlName, multiple, onBlur, onChange, onFocus, options, placeholder, readonly, value, schema, }: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
7
+ declare function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ autofocus, disabled, registry, id, htmlName, multiple, onBlur, onChange, onFocus, options, placeholder, readonly, value, schema, }: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
8
+ declare namespace SelectWidget {
9
+ var getPopupContainerCallback: () => (node: any) => any;
10
+ }
11
+ export default SelectWidget;
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo, useState } from 'react';
2
3
  import { Select } from 'antd';
3
4
  import { ariaDescribedByIds, enumOptionsIndexForValue, enumOptionsValueForIndex, } from '@rjsf/utils';
4
5
  import isString from 'lodash-es/isString.js';
5
- import { useMemo } from 'react';
6
6
  const SELECT_STYLE = {
7
7
  width: '100%',
8
8
  };
@@ -12,6 +12,7 @@ const SELECT_STYLE = {
12
12
  * @param props - The `WidgetProps` for this component
13
13
  */
14
14
  export default function SelectWidget({ autofocus, disabled, registry, id, htmlName, multiple, onBlur, onChange, onFocus, options, placeholder, readonly, value, schema, }) {
15
+ const [open, setOpen] = useState(false);
15
16
  const { formContext } = registry;
16
17
  const { readonlyAsDisabled = true } = formContext;
17
18
  const { enumOptions, enumDisabled, emptyValue } = options;
@@ -25,7 +26,7 @@ export default function SelectWidget({ autofocus, disabled, registry, id, htmlNa
25
26
  }
26
27
  return false;
27
28
  };
28
- const getPopupContainer = (node) => node.parentNode;
29
+ const getPopupContainer = SelectWidget.getPopupContainerCallback();
29
30
  const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
30
31
  // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
31
32
  // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
@@ -48,6 +49,13 @@ export default function SelectWidget({ autofocus, disabled, registry, id, htmlNa
48
49
  }
49
50
  return undefined;
50
51
  }, [enumDisabled, enumOptions, placeholder, showPlaceholderOption]);
51
- return (_jsx(Select, { autoFocus: autofocus, disabled: disabled || (readonlyAsDisabled && readonly), getPopupContainer: getPopupContainer, id: id, mode: multiple ? 'multiple' : undefined, onBlur: !readonly ? handleBlur : undefined, onChange: !readonly ? handleChange : undefined, onFocus: !readonly ? handleFocus : undefined, placeholder: placeholder, style: SELECT_STYLE, value: selectedIndexes, ...extraProps, filterOption: filterOption, "aria-describedby": ariaDescribedByIds(id), options: selectOptions }));
52
+ return (_jsx(Select, { open: open, autoFocus: autofocus, disabled: disabled || (readonlyAsDisabled && readonly), getPopupContainer: getPopupContainer, id: id, mode: multiple ? 'multiple' : undefined, onBlur: !readonly ? handleBlur : undefined, onChange: !readonly ? handleChange : undefined, onFocus: !readonly ? handleFocus : undefined, placeholder: placeholder, style: SELECT_STYLE, value: selectedIndexes, ...extraProps,
53
+ // When the open change is called, set the open state, needed so that the select opens properly in the playground
54
+ onOpenChange: setOpen, filterOption: filterOption, "aria-describedby": ariaDescribedByIds(id), options: selectOptions }));
52
55
  }
56
+ /** Give the playground a place to hook into the `getPopupContainer` callback generation function so that it can be
57
+ * disabled while in the playground. Since the callback is a simple function, it can be returned by this static
58
+ * "generator" function.
59
+ */
60
+ SelectWidget.getPopupContainerCallback = () => (node) => node.parentElement;
53
61
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/widgets/SelectWidget/index.tsx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,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EACvC,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAC1C,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,EAC9C,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAC5C,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,eAAe,KAClB,UAAU;QACd,iHAAiH;QACjH,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,YAAY,sBACR,kBAAkB,CAAC,EAAE,CAAC,EACxC,OAAO,EAAE,aAAa,GACtB,CACH,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,YAAY,CAAC,yBAAyB,GAAG,GAAG,EAAE,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsf/antd",
3
- "version": "6.1.0",
3
+ "version": "6.1.2",
4
4
  "description": "Ant Design theme, fields and widgets for react-jsonschema-form",
5
5
  "main": "dist/index.js",
6
6
  "module": "lib/index.js",
@@ -34,7 +34,7 @@
34
34
  }
35
35
  },
36
36
  "scripts": {
37
- "compileReplacer": "tsc -p tsconfig.replacer.json && move-file lodashReplacer.js lodashReplacer.cjs",
37
+ "compileReplacer": "tsc -p tsconfig.replacer.json && move-file lodashReplacer.js lodashReplacer.cjs && move-file antdIconsReplacer.js antdIconsReplacer.cjs",
38
38
  "build:ts": "npm run compileReplacer && rimraf ./lib && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
39
39
  "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
40
40
  "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/antd.esm.js --sourcemap --packages=external --format=esm",
@@ -43,6 +43,8 @@ export default function BaseInputTemplate<
43
43
  type,
44
44
  } = props;
45
45
  const { formContext } = registry;
46
+ // InputNumber doesn't use a native <input type="number"> directly - it wraps it and controls the stepping behavior
47
+ // through its own props. The step prop in Ant Design expects a number, not the string "any"
46
48
  const inputProps = getInputProps<T, S, F>(schema, type, options, false);
47
49
  const { readonlyAsDisabled = true } = formContext as GenericObjectType;
48
50
 
@@ -1,3 +1,4 @@
1
+ import { useMemo, useState } from 'react';
1
2
  import { Select, SelectProps } from 'antd';
2
3
  import {
3
4
  ariaDescribedByIds,
@@ -11,7 +12,6 @@ import {
11
12
  } from '@rjsf/utils';
12
13
  import isString from 'lodash/isString';
13
14
  import { DefaultOptionType } from 'antd/es/select';
14
- import { useMemo } from 'react';
15
15
 
16
16
  const SELECT_STYLE = {
17
17
  width: '100%',
@@ -42,6 +42,7 @@ export default function SelectWidget<
42
42
  value,
43
43
  schema,
44
44
  }: WidgetProps<T, S, F>) {
45
+ const [open, setOpen] = useState(false);
45
46
  const { formContext } = registry;
46
47
  const { readonlyAsDisabled = true } = formContext as GenericObjectType;
47
48
 
@@ -61,7 +62,7 @@ export default function SelectWidget<
61
62
  return false;
62
63
  };
63
64
 
64
- const getPopupContainer = (node: any) => node.parentNode;
65
+ const getPopupContainer = SelectWidget.getPopupContainerCallback();
65
66
 
66
67
  const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, multiple);
67
68
 
@@ -92,6 +93,7 @@ export default function SelectWidget<
92
93
 
93
94
  return (
94
95
  <Select
96
+ open={open}
95
97
  autoFocus={autofocus}
96
98
  disabled={disabled || (readonlyAsDisabled && readonly)}
97
99
  getPopupContainer={getPopupContainer}
@@ -104,9 +106,17 @@ export default function SelectWidget<
104
106
  style={SELECT_STYLE}
105
107
  value={selectedIndexes}
106
108
  {...extraProps}
109
+ // When the open change is called, set the open state, needed so that the select opens properly in the playground
110
+ onOpenChange={setOpen}
107
111
  filterOption={filterOption}
108
112
  aria-describedby={ariaDescribedByIds(id)}
109
113
  options={selectOptions}
110
114
  />
111
115
  );
112
116
  }
117
+
118
+ /** Give the playground a place to hook into the `getPopupContainer` callback generation function so that it can be
119
+ * disabled while in the playground. Since the callback is a simple function, it can be returned by this static
120
+ * "generator" function.
121
+ */
122
+ SelectWidget.getPopupContainerCallback = () => (node: any) => node.parentElement;