chore(): Remove lodash.set entirely (#14041)

* chore(): Remove lodash.set entirely

* Create dull-balloons-sneeze.md

* chore(): Remove lodash.set entirely

* chore(): Remove lodash.set entirely
This commit is contained in:
Adrien de Peretti
2025-11-13 09:18:43 +01:00
committed by GitHub
parent b49a4451f0
commit 657a16c462
4 changed files with 26 additions and 18 deletions

View File

@@ -64,7 +64,6 @@
"i18next-http-backend": "2.4.2",
"lodash.debounce": "^4.0.8",
"lodash.isequal": "^4.5.0",
"lodash.set": "^4.3.2",
"match-sorter": "^6.3.4",
"motion": "^11.15.0",
"qs": "^6.12.1",

View File

@@ -1,4 +1,3 @@
import set from "lodash.set"
import { useCallback } from "react"
import { FieldValues, Path, PathValue, UseFormReturn } from "react-hook-form"
@@ -17,7 +16,7 @@ type UseDataGridFormHandlersOptions<TData, TFieldValues extends FieldValues> = {
export const useDataGridFormHandlers = <
TData,
TFieldValues extends FieldValues,
TFieldValues extends FieldValues
>({
matrix,
form,
@@ -139,7 +138,7 @@ function convertToggleableNumber(value: any): {
}
function setValue<
T extends DataGridToggleableNumber = DataGridToggleableNumber,
T extends DataGridToggleableNumber = DataGridToggleableNumber
>(
currentValues: any,
field: string,
@@ -148,7 +147,13 @@ function setValue<
isHistory?: boolean
) {
if (type !== "togglable-number") {
set(currentValues, field, newValue)
field.split(".").reduce((curr, key, index) => {
if (index === field.split(".").length - 1) {
curr[key] = newValue
}
curr[key] ??= {}
return curr[key]
}, currentValues)
return
}
@@ -187,11 +192,18 @@ function setValueToggleableNumber(
: newValue.checked
: determineChecked(quantity)
set(currentValues, field, {
...currentValue,
quantity,
checked,
})
const fieldParts = field.split(".")
fieldParts.reduce((curr, key: string, index) => {
if (index === fieldParts.length - 1) {
curr[key] = {
...currentValues,
quantity,
checked,
}
}
curr[key] ??= {}
return curr[key]
}, currentValues)
}
export function convertArrayToPrimitive(