Skip to content

Commit 3a10612

Browse files
committed
Upgrade to container-field v3
1 parent 3e886d2 commit 3a10612

File tree

10 files changed

+29
-26
lines changed

10 files changed

+29
-26
lines changed

packages/forms/src/elements/Checkbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ export const Checkbox = React.forwardRef<HTMLInputElement, ICheckboxProps>(
4141
ref: combinedRef,
4242
...props,
4343
...fieldsetContext
44-
};
44+
} as any;
4545

4646
if (fieldContext) {
4747
combinedProps = fieldContext.getInputProps(combinedProps);
4848
}
4949

5050
return (
5151
<InputContext.Provider value="checkbox">
52-
<StyledCheckInput {...(combinedProps as any)} />
52+
<StyledCheckInput {...combinedProps} />
5353
{children}
5454
</InputContext.Provider>
5555
);

packages/forms/src/elements/Input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const Input = React.forwardRef<HTMLInputElement, IInputProps>(
3131
ref,
3232
onSelect: onSelectHandler,
3333
...props
34-
};
34+
} as any;
3535

3636
if (inputGroupContext) {
3737
combinedProps = {
@@ -45,7 +45,7 @@ export const Input = React.forwardRef<HTMLInputElement, IInputProps>(
4545
combinedProps = fieldContext.getInputProps(combinedProps);
4646
}
4747

48-
return <StyledTextInput {...(combinedProps as any)} />;
48+
return <StyledTextInput {...combinedProps} />;
4949
}
5050
);
5151

packages/forms/src/elements/MediaInput.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ export const MediaInput = React.forwardRef<HTMLInputElement, IMediaInputProps>(
7575
ref: mergeRefs([inputRef, ref]),
7676
onSelect: onSelectHandler,
7777
...props
78-
};
78+
} as any;
7979

8080
let isLabelHovered;
8181

8282
if (fieldContext) {
83-
combinedProps = fieldContext.getInputProps(combinedProps, { isDescribed: true });
83+
combinedProps = fieldContext.getInputProps(combinedProps);
8484
isLabelHovered = fieldContext.isLabelHovered;
8585
}
8686

@@ -113,7 +113,7 @@ export const MediaInput = React.forwardRef<HTMLInputElement, IMediaInputProps>(
113113
{start}
114114
</FauxInput.StartIcon>
115115
)}
116-
<StyledTextMediaInput {...(combinedProps as any)} />
116+
<StyledTextMediaInput {...combinedProps} />
117117
{end && (
118118
<FauxInput.EndIcon
119119
isDisabled={disabled}

packages/forms/src/elements/Radio.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ export const Radio = React.forwardRef<HTMLInputElement, IRadioProps>(
2525
ref,
2626
...props,
2727
...fieldsetContext
28-
};
28+
} as any;
2929

3030
if (fieldContext) {
3131
combinedProps = fieldContext.getInputProps(combinedProps);
3232
}
3333

3434
return (
3535
<InputContext.Provider value="radio">
36-
<StyledRadioInput {...(combinedProps as any)} />
36+
<StyledRadioInput {...combinedProps} />
3737
{children}
3838
</InputContext.Provider>
3939
);

packages/forms/src/elements/Range.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ export const Range = React.forwardRef<HTMLInputElement, IRangeProps>(
5959
backgroundSize,
6060
...props,
6161
onChange
62-
};
62+
} as any;
6363

6464
if (fieldContext) {
65-
combinedProps = fieldContext.getInputProps(combinedProps, { isDescribed: true });
65+
combinedProps = fieldContext.getInputProps(combinedProps);
6666
}
6767

68-
return <StyledRangeInput {...(combinedProps as any)} />;
68+
return <StyledRangeInput {...combinedProps} />;
6969
}
7070
);
7171

packages/forms/src/elements/Select.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ export const Select = React.forwardRef<HTMLSelectElement, ISelectProps>(
2828
focusInset,
2929
ref,
3030
...props
31-
};
31+
} as any;
3232

3333
if (fieldContext) {
34-
combinedProps = fieldContext.getInputProps(combinedProps, { isDescribed: true });
34+
combinedProps = fieldContext.getInputProps(combinedProps);
3535
}
3636

3737
return (
@@ -41,7 +41,7 @@ export const Select = React.forwardRef<HTMLSelectElement, ISelectProps>(
4141
validation={validation}
4242
focusInset={focusInset}
4343
>
44-
<StyledSelect {...(combinedProps as any)} />
44+
<StyledSelect {...combinedProps} />
4545
{!isBare && (
4646
<FauxInput.EndIcon isDisabled={disabled}>
4747
<Chevron />

packages/forms/src/elements/Textarea.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ export const Textarea = React.forwardRef<HTMLTextAreaElement, ITextareaProps>(
162162
...style
163163
},
164164
...props
165-
};
165+
} as any;
166166

167167
if (fieldContext) {
168-
combinedProps = fieldContext.getInputProps(combinedProps, { isDescribed: true });
168+
combinedProps = fieldContext.getInputProps(combinedProps);
169169
}
170170

171171
return (
172172
<>
173-
<StyledTextarea {...(combinedProps as any)} />
173+
<StyledTextarea {...combinedProps} />
174174
{isAutoResizable && (
175175
<StyledTextarea
176176
aria-hidden

packages/forms/src/elements/Toggle.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ export const Toggle = React.forwardRef<HTMLInputElement, IToggleProps>(
2525
ref,
2626
...props,
2727
...fieldsetContext
28-
};
28+
} as any;
2929

3030
if (fieldContext) {
3131
combinedProps = fieldContext.getInputProps(combinedProps);
3232
}
3333

3434
return (
3535
<InputContext.Provider value="toggle">
36-
<StyledToggleInput {...(combinedProps as any)} />
36+
<StyledToggleInput {...combinedProps} />
3737
{children}
3838
</InputContext.Provider>
3939
);

packages/forms/src/elements/common/Field.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ export const Field = React.forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElem
2828
const [isLabelActive, setIsLabelActive] = useState(false);
2929
const [isLabelHovered, setIsLabelHovered] = useState(false);
3030
const multiThumbRangeRef = useRef<HTMLDivElement>(null);
31-
const { getInputProps, getMessageProps, ...propGetters } = useField(props.id);
31+
const { getInputProps, getMessageProps, ...propGetters } = useField({
32+
idPrefix: props.id,
33+
hasHint,
34+
hasMessage
35+
});
3236
const fieldProps = useMemo(
3337
() => ({
3438
...propGetters,
35-
getInputProps: (options: any, describeOptions: any = {}) =>
36-
getInputProps(options, { ...describeOptions, isDescribed: hasHint, hasMessage }),
37-
getMessageProps: (options: any) => getMessageProps({ role: 'alert', ...options }),
39+
getInputProps,
40+
getMessageProps,
3841
isLabelActive,
3942
setIsLabelActive,
4043
isLabelHovered,

packages/forms/src/utils/useFieldContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
*/
77

88
import { createContext, useContext, MutableRefObject } from 'react';
9-
import { IUseFieldPropGetters } from '@zendeskgarden/container-field';
9+
import { IUseFieldReturnValue } from '@zendeskgarden/container-field';
1010

11-
interface IFieldContext extends IUseFieldPropGetters {
11+
interface IFieldContext extends IUseFieldReturnValue {
1212
getMessageProps: (messageProps: any) => any;
1313
isLabelActive: boolean;
1414
isLabelHovered: boolean;

0 commit comments

Comments
 (0)