Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8a72d3a
export typeahead utils
Michele-Masciave Apr 11, 2025
f8dc2b0
integrate placeholder fix and changelog
Michele-Masciave Apr 16, 2025
a857384
adjust typescript
Michele-Masciave Apr 16, 2025
e1267ef
prepare-pr
Michele-Masciave Apr 28, 2025
12211f1
fixed
Michele-Masciave Apr 30, 2025
92e5c21
Merge branch 'main' of https://github.com/Michele-Masciave/react-hook…
Michele-Masciave Apr 30, 2025
a9347da
Merge branch 'neolution-ch:main' into main
Michele-Masciave May 7, 2025
2987413
Merge branch 'neolution-ch:main' into main
Michele-Masciave Jun 3, 2025
acad69e
Merge branch 'main' of https://github.com/Michele-Masciave/react-hook…
Michele-Masciave Jun 13, 2025
de96e5c
Merge branch 'neolution-ch:main' into main
Michele-Masciave Jun 18, 2025
fbfcc8e
Merge branch 'neolution-ch:main' into main
Michele-Masciave Jun 25, 2025
b5c2533
Merge branch 'main' of https://github.com/Michele-Masciave/react-hook…
Michele-Masciave Jul 7, 2025
7843d38
Merge branch 'neolution-ch:main' into main
Michele-Masciave Jul 16, 2025
6b81771
Merge branch 'neolution-ch:main' into main
Michele-Masciave Sep 26, 2025
743acf1
Merge branch 'neolution-ch:main' into main
Michele-Masciave Sep 29, 2025
022db3c
Merge branch 'neolution-ch:main' into main
Michele-Masciave Oct 1, 2025
bbd78a7
Merge branch 'neolution-ch:main' into main
Michele-Masciave Oct 21, 2025
827933f
try
Michele-Masciave Oct 21, 2025
87ed553
x
Michele-Masciave Oct 21, 2025
7fc7ff4
try on controllers
Michele-Masciave Oct 21, 2025
3444ee1
x
Michele-Masciave Oct 23, 2025
9190929
x
Michele-Masciave Oct 23, 2025
c10c124
drop console
Michele-Masciave Oct 23, 2025
8c25499
x
Michele-Masciave Oct 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const plugins = [
terser({
output: { comments: false },
compress: {
drop_console: true,
drop_console: false,
},
}),
];
Expand Down
3 changes: 2 additions & 1 deletion src/lib/AsyncTypeaheadInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const AsyncTypeaheadInput = <T extends FieldValues>(props: AsyncTypeaheadInputPr
const { name, id } = useSafeNameId(props.name ?? "", props.id);
const { setDebounceSearch, isLoading } = useDebounceHook(queryFn, setOptions);
const { control, disabled: formDisabled, getFieldState, setValue: setFormValue } = useFormContext();
const isDisabled = useMemo(() => formDisabled || disabled, [formDisabled, disabled]);

validateFixedOptions(fixedOptions, multiple, autocompleteProps, withFixedOptionsInValue, value);

Expand All @@ -91,14 +92,14 @@ const AsyncTypeaheadInput = <T extends FieldValues>(props: AsyncTypeaheadInputPr
} = useController({
name,
control,
shouldUnregister: isDisabled,
rules: {
validate: {
required: () => getFieldState(name)?.error?.message,
},
},
});

const isDisabled = useMemo(() => formDisabled || disabled, [formDisabled, disabled]);
const paginatedOptions = useMemo(
() => (limitResults === undefined ? options : options.slice(0, page * limitResults)),
[limitResults, page, options],
Expand Down
1 change: 1 addition & 0 deletions src/lib/DatePickerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const DatePickerInput = <T extends FieldValues>(props: DatePickerInputProps<T>)
return (
<Controller
control={control}
shouldUnregister={isDisabled}
name={name}
render={({ field, fieldState: { error } }) => (
<FormGroupLayout<T, DatePickerRenderAddonProps>
Expand Down
1 change: 1 addition & 0 deletions src/lib/FormattedInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const FormattedInput = <T extends FieldValues>(props: FormattedInputProps<T>) =>
<Controller
control={control}
name={name}
shouldUnregister={isDisabled}
render={({ field: { name, onBlur, onChange, ref, value }, fieldState: { error } }) => {
const commonProps: NumericFormatProps = {
name: name,
Expand Down
1 change: 1 addition & 0 deletions src/lib/RatingInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const RatingInput = <T extends FieldValues>(props: RatingInputProps<T>) => {
return (
<Controller
control={control}
shouldUnregister={disabled || formDisabled}
name={props.name}
render={({ field: { value, onBlur, onChange, ...fieldRest } }) => (
<FormGroupLayout
Expand Down
4 changes: 3 additions & 1 deletion src/lib/StaticTypeaheadInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,21 @@ const StaticTypeaheadInput = <T extends FieldValues>(props: StaticTypeaheadInput

const { name, id } = useSafeNameId(props.name ?? "", props.id);
const { control, disabled: formDisabled, getFieldState, clearErrors, watch } = useFormContext();
const isDisabled = useMemo(() => formDisabled || disabled, [formDisabled, disabled]);

const {
field: { ref, ...field },
} = useController({
name,
control,
shouldUnregister: isDisabled,
rules: {
validate: {
required: () => getFieldState(name)?.error?.message,
},
},
});

const isDisabled = useMemo(() => formDisabled || disabled, [formDisabled, disabled]);
const paginatedOptions = useMemo(
() => (limitResults === undefined ? options : options.slice(0, page * limitResults)),
[limitResults, page, options],
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/ColorPicker/ColorPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const ColorPicker = <T extends FieldValues>(props: ColorPickerInputProps<T>) =>
} = useController({
name,
control,
shouldUnregister: true,
rules: {
validate: {
required: () => getFieldState(name)?.error?.message,
Expand Down
18 changes: 15 additions & 3 deletions src/lib/components/Input/InputInternal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const InputInternal = <T extends FieldValues>(props: InputProps<T>) => {
} = useFormContext();

const { ref, ...rest } = register(name, {
// disabled: formDisabled || disabled, // FIXME this one unregister on submit
setValueAs: (value: string) => (value === UNDEFINED_OPTION_VALUE ? undefined : value),
});

Expand All @@ -69,7 +70,7 @@ const InputInternal = <T extends FieldValues>(props: InputProps<T>) => {
maxLength={maxLength}
rows={textAreaRows}
multiple={multiple}
disabled={formDisabled || disabled}
disabled={formDisabled || disabled} // this one just disables the input
plaintext={plainText}
style={plainText ? { color: "black", marginLeft: 10, ...style } : { ...style }}
placeholder={placeholder}
Expand All @@ -88,12 +89,23 @@ const InputInternal = <T extends FieldValues>(props: InputProps<T>) => {
})();
}}
onChange={(e) => {
console.log("event before the IIFE-->", e);

void (async () => {
// if (onChange) {
// onChange(e);
// }

// setTimeout(async () => {
// console.log("event after the IIFE-->", e);
// }, 1000);

await rest.onChange(e);

if (onChange) {
console.log("calling custom onChange", e);
onChange(e);
}

await rest.onChange(e);
})();
}}
onKeyDown={onKeyDown}
Expand Down
Loading