Skip to content

Commit

Permalink
docs(form): Updated hook overrides so documentation appears correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Nov 24, 2021
1 parent 2637a6f commit 436fbff
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 62 deletions.
85 changes: 42 additions & 43 deletions packages/form/src/text-field/useNumberField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,49 +124,6 @@ export type NumberFieldHookReturnType = [
// all the overloads for the `useNumberField` -- not sure if there's an easier
// way to type these...

export function useNumberField(
options: NumberFieldHookOptions & {
defaultValue: number | (() => number);
disableMessage: true;
}
): [number, ProvidedNumberFieldProps, NumberFieldHookControls];
export function useNumberField(
options: NumberFieldHookOptions & {
defaultValue: number | (() => number);
disableMessage: false;
}
): [number, ProvidedNumberFieldMessageProps, NumberFieldHookControls];
export function useNumberField(
options: NumberFieldHookOptions & {
defaultValue: number | (() => number);
disableMessage?: boolean;
}
): [number, ProvidedNumberFieldMessageProps, NumberFieldHookControls];

export function useNumberField(
options: NumberFieldHookOptions & {
disableMessage: true;
}
): [number | undefined, ProvidedNumberFieldProps, NumberFieldHookControls];
export function useNumberField(
options: NumberFieldHookOptions & {
disableMessage: false;
}
): [
number | undefined,
ProvidedNumberFieldMessageProps,
NumberFieldHookControls
];
export function useNumberField(
options: NumberFieldHookOptions & {
disableMessage?: boolean;
}
): [
number | undefined,
ProvidedNumberFieldMessageProps,
NumberFieldHookControls
];

/**
* This hook is used to control the value for the `TextField` component acting
* as an `<input type="number">` and ensuring that a "valid" `number` is
Expand Down Expand Up @@ -209,6 +166,48 @@ export function useNumberField(
* @returns @see {@link NumberFieldHookReturnType}
* @remarks \@since 2.5.0
*/
export function useNumberField(
options: NumberFieldHookOptions & {
defaultValue: number | (() => number);
disableMessage: true;
}
): [number, ProvidedNumberFieldProps, NumberFieldHookControls];
export function useNumberField(
options: NumberFieldHookOptions & {
defaultValue: number | (() => number);
disableMessage: false;
}
): [number, ProvidedNumberFieldMessageProps, NumberFieldHookControls];
export function useNumberField(
options: NumberFieldHookOptions & {
defaultValue: number | (() => number);
disableMessage?: boolean;
}
): [number, ProvidedNumberFieldMessageProps, NumberFieldHookControls];

export function useNumberField(
options: NumberFieldHookOptions & {
disableMessage: true;
}
): [number | undefined, ProvidedNumberFieldProps, NumberFieldHookControls];
export function useNumberField(
options: NumberFieldHookOptions & {
disableMessage: false;
}
): [
number | undefined,
ProvidedNumberFieldMessageProps,
NumberFieldHookControls
];
export function useNumberField(
options: NumberFieldHookOptions & {
disableMessage?: boolean;
}
): [
number | undefined,
ProvidedNumberFieldMessageProps,
NumberFieldHookControls
];
export function useNumberField({
id,
defaultValue,
Expand Down
19 changes: 9 additions & 10 deletions packages/form/src/text-field/useTextField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,6 @@ export type TextFieldHookReturnType = [
TextFieldHookControls
];

export function useTextField(
options: TextFieldHookOptions & { disableMessage: true }
): [string, ProvidedTextFieldProps, TextFieldHookControls];
export function useTextField(
options: TextFieldHookOptions & { disableMessage: false }
): [string, ProvidedTextFieldMessageProps, TextFieldHookControls];
export function useTextField(
options: TextFieldHookOptions & { disableMessage?: boolean }
): [string, ProvidedTextFieldMessageProps, TextFieldHookControls];

/**
* This hook is used to control the `value` for a `TextField` or `TextArea`
* component along with some simple validation checks using the browser validity
Expand All @@ -264,6 +254,15 @@ export function useTextField(
* @returns @see {@link TextFieldHookReturnType}
* @remarks \@since 2.5.0
*/
export function useTextField(
options: TextFieldHookOptions & { disableMessage: true }
): [string, ProvidedTextFieldProps, TextFieldHookControls];
export function useTextField(
options: TextFieldHookOptions & { disableMessage: false }
): [string, ProvidedTextFieldMessageProps, TextFieldHookControls];
export function useTextField(
options: TextFieldHookOptions & { disableMessage?: boolean }
): [string, ProvidedTextFieldMessageProps, TextFieldHookControls];
export function useTextField({
id,
defaultValue = "",
Expand Down
17 changes: 8 additions & 9 deletions packages/form/src/useIndeterminateChecked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,6 @@ export interface CombinedIndeterminateCheckedHookReturnValue<V extends string>
getProps(value: V): ProvidedCombinedIndeterminateControlledProps<V>;
}

export function useIndeterminateChecked<V extends string>(
values: readonly V[],
options?: IndeterminateCheckedHookOptions<V> & { menu?: false }
): OnChangeReturnValue<V>;
export function useIndeterminateChecked<V extends string>(
values: readonly V[],
options: IndeterminateCheckedHookOptions<V> & { menu: true }
): OnCheckedChangeReturnValue<V>;

/**
* This hook allows you to toggle the state of multiple checkboxes in a single
* place along with an indeterminate checkbox that can check/uncheck all
Expand Down Expand Up @@ -328,6 +319,14 @@ export function useIndeterminateChecked<V extends string>(
* additional `values` in the checkbox list, a list of `checkedValues`, and a
* `setCheckedValues` function to manually override the state if needed.
*/
export function useIndeterminateChecked<V extends string>(
values: readonly V[],
options?: IndeterminateCheckedHookOptions<V> & { menu?: false }
): OnChangeReturnValue<V>;
export function useIndeterminateChecked<V extends string>(
values: readonly V[],
options: IndeterminateCheckedHookOptions<V> & { menu: true }
): OnCheckedChangeReturnValue<V>;
export function useIndeterminateChecked<V extends string>(
values: readonly V[],
{
Expand Down

0 comments on commit 436fbff

Please sign in to comment.