Skip to content

Commit

Permalink
Merge pull request #2028 from gluestack/fix/typing-form-components
Browse files Browse the repository at this point in the history
Fix/typing form components
  • Loading branch information
Viraj-10 authored Apr 3, 2024
2 parents bccfb52 + c894013 commit c5d2fc4
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type { VariantProps } from '@gluestack-ui/nativewind-utils';

import React from 'react';
export const UILink = createLink({
// @ts-ignore
Root:
Platform.OS === 'web'
? withStyleContext(Pressable)
Expand Down Expand Up @@ -47,6 +46,7 @@ const Link = React.forwardRef(

type ILinkTextProps = React.ComponentProps<typeof UILink.Text> &
VariantProps<typeof linkTextStyle>;

const LinkText = React.forwardRef(
(
{ className, ...props }: { className?: string } & ILinkTextProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { withStates } from '@gluestack-ui/nativewind-utils/withStates';

const SCOPE = 'SLIDER';
export const UISlider = createSlider({
// @ts-ignore
Root:
Platform.OS === 'web'
? withStyleContext(View, SCOPE)
Expand All @@ -25,7 +24,6 @@ export const UISlider = createSlider({
ThumbInteraction: View,
});

//@ts-ignore
cssInterop(UISlider, { className: 'style' });
cssInterop(UISlider.Thumb, { className: 'style' });
cssInterop(UISlider.Track, { className: 'style' });
Expand Down Expand Up @@ -163,7 +161,7 @@ export const Slider = React.forwardRef(
isReversed = false,
...props
}: any,
ref
ref?: any
) => {
return (
<UISlider
Expand All @@ -183,7 +181,7 @@ export const Slider = React.forwardRef(
);

export const SliderThumb = React.forwardRef(
({ className, size, ...props }: any, ref) => {
({ className, size, ...props }: any, ref?: any) => {
const { size: parentSize } = useStyleContext(SCOPE);

return (
Expand All @@ -203,7 +201,7 @@ export const SliderThumb = React.forwardRef(
);

export const SliderTrack = React.forwardRef(
({ className, ...props }: any, ref) => {
({ className, ...props }: any, ref?: any) => {
const {
orientation: parentOrientation,
size: parentSize,
Expand All @@ -228,7 +226,7 @@ export const SliderTrack = React.forwardRef(
);

export const SliderFilledTrack = React.forwardRef(
({ className, ...props }: any, ref) => {
({ className, ...props }: any, ref?: any) => {
const { orientation: parentOrientation } = useStyleContext(SCOPE);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type ISwitchProps = React.ComponentProps<typeof UISwitch> &
const Switch = React.forwardRef(
(
{ className, size = 'md', ...props }: { className?: string } & ISwitchProps,
ref
ref?: any
) => {
return (
<UISwitch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { withStates } from '@gluestack-ui/nativewind-utils/withStates';
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
const SCOPE = 'TEXTAREA';
const UITextarea = createTextarea({
// @ts-ignore
Root:
Platform.OS === 'web'
? withStyleContext(View, SCOPE)
Expand All @@ -32,6 +31,12 @@ const textareaStyle = tva({
default:
'data-[focus=true]:border-primary-700 data-[focus=true]:web:ring-1 data-[focus=true]:web:ring-inset data-[focus=true]:web:ring-primary-700 data-[invalid=true]:border-error-700 data-[invalid=true]:web:ring-1 data-[invalid=true]:web:ring-inset data-[invalid=true]:web:ring-error-700 data-[invalid=true]:hover:border-error-700 data-[invalid=true]:data-[focus=true]:hover:border-primary-700 data-[invalid=true]:data-[focus=true]:hover:web:ring-1 data-[invalid=true]:data-[focus=true]:hover:web:ring-inset data-[invalid=true]:data-[focus=true]:hover:web:ring-primary-700 data-[invalid=true]:data-[disabled=true]:hover:border-error-700 data-[invalid=true]:data-[disabled=true]:hover:web:ring-1 data-[invalid=true]:data-[disabled=true]:hover:web:ring-inset data-[invalid=true]:data-[disabled=true]:hover:web:ring-error-700 ',
},
size: {
sm: '',
md: '',
lg: '',
xl: '',
},
},
});

Expand All @@ -58,7 +63,7 @@ const Textarea = React.forwardRef(
size = 'md',
...props
}: { className?: string } & ITextareaProps,
ref
ref?: any
) => {
return (
<UITextarea
Expand All @@ -77,7 +82,7 @@ type ITextareaInputProps = React.ComponentProps<typeof UITextarea.Input> &
const TextareaInput = React.forwardRef(
(
{ className, ...props }: { className?: string } & ITextareaInputProps,
ref
ref?: any
) => {
const { size: parentSize } = useStyleContext(SCOPE);

Expand Down
2 changes: 2 additions & 0 deletions example/storybook-nativewind/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"../../packages/unstyled/alert-dialog/src"
],
"@gluestack-ui/menu": ["../../packages/unstyled/menu/src"],
"@gluestack-ui/textarea": ["../../packages/unstyled/textarea/src"],
"@gluestack-ui/link": ["../../packages/unstyled/link/src"],
"@gluestack-ui/nativewind-utils/tva": [
"../../packages/nativewind/utils/src/tva"
],
Expand Down
5 changes: 4 additions & 1 deletion packages/unstyled/link/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { MutableRefObject } from 'react';
import React from 'react';
import type { GestureResponderEvent, ViewProps } from 'react-native';

export interface InterfaceLinkProps extends ViewProps {
Expand Down Expand Up @@ -29,5 +30,7 @@ export type IUseLinkProp = {

export type ILinkComponentType<Root, TextProps> =
React.ForwardRefExoticComponent<Root & InterfaceLinkProps> & {
Text: React.ForwardRefExoticComponent<TextProps>;
Text: React.ForwardRefExoticComponent<
TextProps & React.RefAttributes<TextProps>
>;
};
4 changes: 3 additions & 1 deletion packages/unstyled/textarea/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ export interface IInputProps {

export type ITextareaComponentType<Root, Input> =
React.ForwardRefExoticComponent<Root & ITextareaProps> & {
Input: React.ForwardRefExoticComponent<Input & IInputProps>;
Input: React.ForwardRefExoticComponent<
Input & React.RefAttributes<Input> & IInputProps
>;
};

0 comments on commit c5d2fc4

Please sign in to comment.