Skip to content

Commit 0754b1c

Browse files
authored
restore getChakra calls (#4620)
* restore getChakra calls * export getChakra util * add chakraProps to AltDateWidget * add chakra changelog
1 parent 573980d commit 0754b1c

File tree

13 files changed

+62
-9
lines changed

13 files changed

+62
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ should change the heading of the (upcoming) version to include a major version b
2222

2323
- Fixed form data propagation with `patternProperties` [#4617](https://github.com/rjsf-team/react-jsonschema-form/pull/4617)
2424

25+
## @rjsf/chakra-ui
26+
27+
- Added `getChakra` to package exports
28+
- Restored the `ui:options` customization
29+
2530
# 6.0.0-beta.7
2631

2732
## @rjsf/core

packages/chakra-ui/src/AddButton/AddButton.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Button } from '@chakra-ui/react';
33
import { PlusIcon } from 'lucide-react';
44

55
export default function AddButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
6-
uiSchema,
76
registry,
87
...props
98
}: IconButtonProps<T, S, F>) {

packages/chakra-ui/src/AltDateWidget/AltDateWidget.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { MouseEvent, useEffect, useState } from 'react';
1+
import { Box, Button, FieldsetRoot } from '@chakra-ui/react';
22
import {
33
ariaDescribedByIds,
4-
dateRangeOptions,
54
DateElementFormat,
65
DateObject,
6+
dateRangeOptions,
77
FormContextType,
88
getDateElementProps,
99
parseDateString,
@@ -13,7 +13,8 @@ import {
1313
TranslatableString,
1414
WidgetProps,
1515
} from '@rjsf/utils';
16-
import { Box, Button } from '@chakra-ui/react';
16+
import { MouseEvent, useEffect, useState } from 'react';
17+
import { getChakra } from '../utils';
1718

1819
function DateElement<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
1920
props: WidgetProps<T, S, F>,
@@ -85,8 +86,10 @@ function AltDateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
8586
onChange(undefined);
8687
};
8788

89+
const chakraProps = getChakra({ uiSchema: props.uiSchema });
90+
8891
return (
89-
<Box>
92+
<FieldsetRoot {...(chakraProps as any)}>
9093
<Box display='flex' flexWrap='wrap' alignItems='center'>
9194
{getDateElementProps(
9295
state,
@@ -127,7 +130,7 @@ function AltDateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
127130
</Button>
128131
)}
129132
</Box>
130-
</Box>
133+
</FieldsetRoot>
131134
);
132135
}
133136

packages/chakra-ui/src/BaseInputTemplate/BaseInputTemplate.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from '@rjsf/utils';
1313

1414
import { Field } from '../components/ui/field';
15+
import { getChakra } from '../utils';
1516

1617
export default function BaseInputTemplate<
1718
T = any,
@@ -36,6 +37,7 @@ export default function BaseInputTemplate<
3637
autofocus,
3738
placeholder,
3839
disabled,
40+
uiSchema,
3941
} = props;
4042
const inputProps = getInputProps<T, S, F>(schema, type, options);
4143

@@ -44,6 +46,8 @@ export default function BaseInputTemplate<
4446
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
4547
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
4648

49+
const chakraProps = getChakra({ uiSchema });
50+
4751
return (
4852
<Field
4953
mb={1}
@@ -52,6 +56,7 @@ export default function BaseInputTemplate<
5256
readOnly={readonly}
5357
invalid={rawErrors && rawErrors.length > 0}
5458
label={labelValue(label, hideLabel || !label)}
59+
{...chakraProps}
5560
>
5661
<Input
5762
id={id}

packages/chakra-ui/src/CheckboxWidget/CheckboxWidget.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414

1515
import { Field } from '../components/ui/field';
1616
import { Checkbox } from '../components/ui/checkbox';
17+
import { getChakra } from '../utils';
1718

1819
export default function CheckboxWidget<
1920
T = any,
@@ -50,8 +51,10 @@ export default function CheckboxWidget<
5051
const _onBlur = ({ target }: FocusEvent<HTMLInputElement | any>) => onBlur(id, target && target.value);
5152
const _onFocus = ({ target }: FocusEvent<HTMLInputElement | any>) => onFocus(id, target && target.value);
5253

54+
const chakraProps = getChakra({ uiSchema });
55+
5356
return (
54-
<Field mb={1} required={required}>
57+
<Field mb={1} required={required} {...chakraProps}>
5558
{!hideLabel && description && (
5659
<DescriptionFieldTemplate
5760
id={descriptionId<T>(id)}

packages/chakra-ui/src/CheckboxesWidget/CheckboxesWidget.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import { FocusEvent } from 'react';
1414

1515
import { Checkbox } from '../components/ui/checkbox';
16+
import { getChakra } from '../utils';
1617

1718
export default function CheckboxesWidget<
1819
T = any,
@@ -32,6 +33,7 @@ export default function CheckboxesWidget<
3233
label,
3334
hideLabel,
3435
rawErrors = [],
36+
uiSchema,
3537
} = props;
3638
const { enumOptions, enumDisabled, emptyValue } = options;
3739

@@ -43,8 +45,15 @@ export default function CheckboxesWidget<
4345
const row = options ? options.inline : false;
4446
const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, true) as string[];
4547

48+
const chakraProps = getChakra({ uiSchema });
49+
4650
return (
47-
<FieldsetRoot mb={1} disabled={disabled || readonly} invalid={rawErrors && rawErrors.length > 0}>
51+
<FieldsetRoot
52+
mb={1}
53+
disabled={disabled || readonly}
54+
invalid={rawErrors && rawErrors.length > 0}
55+
{...(chakraProps as any)}
56+
>
4857
<CheckboxGroup
4958
onValueChange={(option) => onChange(enumOptionsValueForIndex<S>(option, enumOptions, emptyValue))}
5059
value={selectedIndexes}

packages/chakra-ui/src/RadioWidget/RadioWidget.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414

1515
import { Field } from '../components/ui/field';
1616
import { Radio, RadioGroup } from '../components/ui/radio';
17+
import { getChakra } from '../utils';
1718

1819
export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
1920
id,
@@ -27,6 +28,7 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
2728
onChange,
2829
onBlur,
2930
onFocus,
31+
uiSchema,
3032
}: WidgetProps<T, S, F>) {
3133
const { enumOptions, enumDisabled, emptyValue } = options;
3234

@@ -40,13 +42,16 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
4042
const row = options ? options.inline : false;
4143
const selectedIndex = (enumOptionsIndexForValue<S>(value, enumOptions) as string) ?? null;
4244

45+
const chakraProps = getChakra({ uiSchema });
46+
4347
return (
4448
<Field
4549
mb={1}
4650
disabled={disabled || readonly}
4751
required={required}
4852
readOnly={readonly}
4953
label={labelValue(label, hideLabel || !label)}
54+
{...chakraProps}
5055
>
5156
<RadioGroup
5257
onChange={_onChange}

packages/chakra-ui/src/RangeWidget/RangeWidget.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212

1313
import { Field } from '../components/ui/field';
1414
import { Slider } from '../components/ui/slider';
15+
import { getChakra } from '../utils';
1516

1617
export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
1718
value,
@@ -25,14 +26,17 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
2526
label,
2627
hideLabel,
2728
id,
29+
uiSchema,
2830
}: WidgetProps<T, S, F>) {
2931
const _onChange = ({ value }: SliderValueChangeDetails) =>
3032
onChange(value === undefined ? options.emptyValue : value[0]);
3133
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
3234
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
3335

36+
const chakraProps = getChakra({ uiSchema });
37+
3438
return (
35-
<Field mb={1} label={labelValue(label, hideLabel || !label)}>
39+
<Field mb={1} label={labelValue(label, hideLabel || !label)} {...chakraProps}>
3640
<Slider
3741
{...rangeSpec<S>(schema)}
3842
id={id}

packages/chakra-ui/src/SelectNativeWidget/NativeSelectWidget.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { OptionsOrGroups } from 'chakra-react-select';
1414
import { createListCollection, NativeSelect as ChakraSelect } from '@chakra-ui/react';
1515

1616
import { Field } from '../components/ui/field';
17+
import { getChakra } from '../utils';
1718

1819
/**
1920
* NativeSelectWidget is a React component that renders a native select input.
@@ -47,6 +48,7 @@ export default function NativeSelectWidget<
4748
onFocus,
4849
rawErrors = [],
4950
schema,
51+
uiSchema,
5052
} = props;
5153
const { enumOptions, enumDisabled, emptyValue } = options;
5254

@@ -102,6 +104,8 @@ export default function NativeSelectWidget<
102104
items: displayEnumOptions.filter((item) => item.value),
103105
});
104106

107+
const chakraProps = getChakra({ uiSchema });
108+
105109
return (
106110
<Field
107111
mb={1}
@@ -110,6 +114,7 @@ export default function NativeSelectWidget<
110114
readOnly={readonly}
111115
invalid={rawErrors && rawErrors.length > 0}
112116
label={labelValue(label, hideLabel || !label)}
117+
{...chakraProps}
113118
>
114119
<ChakraSelect.Root>
115120
<ChakraSelect.Field

packages/chakra-ui/src/SelectWidget/SelectWidget.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { createListCollection, SelectValueChangeDetails, Select as ChakraSelect
1616

1717
import { Field } from '../components/ui/field';
1818
import { SelectRoot, SelectTrigger, SelectValueText } from '../components/ui/select';
19+
import { getChakra } from '../utils';
1920

2021
export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
2122
props: WidgetProps<T, S, F>,
@@ -37,6 +38,7 @@ export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFS
3738
onFocus,
3839
rawErrors = [],
3940
schema,
41+
uiSchema,
4042
} = props;
4143
const { enumOptions, enumDisabled, emptyValue } = options;
4244

@@ -114,6 +116,7 @@ export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFS
114116
});
115117

116118
const containerRef = useRef(null);
119+
const chakraProps = getChakra({ uiSchema });
117120

118121
return (
119122
<Field
@@ -125,6 +128,7 @@ export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFS
125128
invalid={rawErrors && rawErrors.length > 0}
126129
label={labelValue(label, hideLabel || !label)}
127130
position='relative'
131+
{...chakraProps}
128132
>
129133
<SelectRoot
130134
collection={selectOptions}

0 commit comments

Comments
 (0)