Skip to content

Commit

Permalink
fix errors for build:react
Browse files Browse the repository at this point in the history
  • Loading branch information
mimarz committed Dec 5, 2024
1 parent 892f434 commit dfe8c87
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createContext, useRef } from 'react';
import type { ReactNode, RefObject } from 'react';

export const Context = createContext<RefObject<HTMLDialogElement>>({
export const Context = createContext<RefObject<HTMLDialogElement | null>>({
current: null,
});

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/form/Combobox/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const ComboboxComponent = forwardRef<HTMLInputElement, ComboboxProps>(
},
forwareddRef,
) => {
const inputRef = useRef<HTMLInputElement>(null);
const inputRef = useRef<HTMLInputElement | null>(null);
const portalRef = useRef<HTMLDivElement>(null);
const listRef = useRef<Array<HTMLElement | null>>([]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type ComboboxContextType = {
size: NonNullable<ComboboxProps['size']>;
formFieldProps: ReturnType<typeof useFormField>;
refs: UseFloatingReturn['refs'];
inputRef: RefObject<HTMLInputElement>;
inputRef: RefObject<HTMLInputElement | null>;
open: boolean;
inputValue: string;
customIds: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Ref } from 'react';
import { useDebounceCallback } from '../../../../utilities/hooks/useDebounceCallback/useDebounceCallback';
import { ComboboxContext } from '../ComboboxContext';
import { useComboboxId, useComboboxIdDispatch } from '../ComboboxIdContext';
import type { Option } from '../useCombobox';
import { prefix } from '../utilities';

type UseComboboxOptionProps = {
Expand All @@ -13,11 +14,19 @@ type UseComboboxOptionProps = {
value: string;
};

type UseComboboxOptionReturn = {
id: string;
ref: Ref<HTMLButtonElement>;
selected: Option;
active: boolean;
onOptionClick: () => void;
};

export const useComboboxOption = ({
id,
ref,
value,
}: UseComboboxOptionProps) => {
}: UseComboboxOptionProps): UseComboboxOptionReturn => {
const generatedId = useId();
const newId = id || generatedId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const RovingFocusRoot = forwardRef<
const [focusableValue, setFocusableValue] = useState<string | null>(null);
const [isShiftTabbing, setIsShiftTabbing] = useState(false);
const elements = useRef(new Map<string, HTMLElement>());
const myRef = useRef<HTMLElement>();
const myRef = useRef<HTMLElement | null>(null);

const refs = useMergeRefs([ref, myRef]);

Expand Down
1 change: 0 additions & 1 deletion packages/react/src/utilities/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export { useDebounceCallback } from './useDebounceCallback/useDebounceCallback';
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';
export { useMediaQuery } from './useMediaQuery/useMediaQuery';
export { useSynchronizedAnimation } from './useSynchronizedAnimation/useSynchronizedAnimation';
export { usePrevious } from './usePrevious';
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export type GetCheckboxProps = Omit<
> & {
/** Enables indeterminate handling for this `Checkbox` and `CheckboxGroup` */
allowIndeterminate?: boolean;
ref?: React.RefObject<HTMLInputElement>;
ref?: React.Ref<HTMLInputElement | null>;
value?: string;
};

Expand All @@ -78,7 +78,22 @@ const toggleIndeterminate = (
}
};

export function useCheckboxGroup(props?: UseCheckboxGroupProps) {
type useCheckboxGroupReturn = {
value: string[];
setValue: React.Dispatch<React.SetStateAction<string[]>>;
getCheckboxProps: (
propsOrValue?: string | GetCheckboxProps,
) => GetCheckboxProps;
validationMessageProps: {
children: ReactNode;
hidden: boolean;
id: string;
};
};

export function useCheckboxGroup(
props?: UseCheckboxGroupProps,
): useCheckboxGroupReturn {
const {
error,
name: groupName,
Expand Down
25 changes: 0 additions & 25 deletions packages/react/src/utilities/hooks/usePrevious.test.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/react/src/utilities/hooks/usePrevious.ts

This file was deleted.

15 changes: 13 additions & 2 deletions packages/react/src/utilities/hooks/useRadioGroup/useRadioGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,21 @@ export type GetRadioProps = Omit<
| 'checked'
| 'value'
> & {
ref?: React.RefObject<HTMLInputElement>;
ref?: React.Ref<HTMLInputElement | null>;
value?: string;
};

type useRadioGroupReturn = {
value: string;
setValue: React.Dispatch<React.SetStateAction<string>>;
getRadioProps: (propsOrValue: string | GetRadioProps) => GetRadioProps;
validationMessageProps: {
children: ReactNode;
hidden: boolean;
id: string;
};
};

/**
* useRadioGroup is used to group multiple <Radio> components
* @example
Expand All @@ -66,7 +77,7 @@ export function useRadioGroup({
name,
onChange,
value: initalValue = '',
}: UseRadioGroupProps = {}) {
}: UseRadioGroupProps = {}): useRadioGroupReturn {
const [groupValue, setGroupValue] = useState(initalValue);
const errorId = useId();
const namedId = useId();
Expand Down

0 comments on commit dfe8c87

Please sign in to comment.