@natoora-libs/core 0.1.16-dev-doug-7 → 0.1.16-dev-doug-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/components/index.js
CHANGED
|
@@ -7823,7 +7823,7 @@ var TableDesktop = ({
|
|
|
7823
7823
|
import { Checkbox as Checkbox6, FormControlLabel as FormControlLabel4 } from "@mui/material";
|
|
7824
7824
|
|
|
7825
7825
|
// src/components/TableDesktopEditableComponent/TableDesktopNumericField.tsx
|
|
7826
|
-
import { useState as useState18, useRef as useRef5 } from "react";
|
|
7826
|
+
import { useState as useState18, useRef as useRef5, useMemo as useMemo4 } from "react";
|
|
7827
7827
|
import { TextField as TextField8 } from "@mui/material";
|
|
7828
7828
|
import { jsx as jsx120 } from "react/jsx-runtime";
|
|
7829
7829
|
var TableDesktopNumericField = ({
|
|
@@ -7834,13 +7834,16 @@ var TableDesktopNumericField = ({
|
|
|
7834
7834
|
field,
|
|
7835
7835
|
variant = "standard",
|
|
7836
7836
|
size,
|
|
7837
|
+
validateInput,
|
|
7837
7838
|
onUpdateEditableCell
|
|
7838
7839
|
}) => {
|
|
7839
7840
|
const [input, setInput] = useState18(initialValue);
|
|
7840
7841
|
const oldValue = useRef5(initialValue);
|
|
7842
|
+
const isDirty = useMemo4(() => input !== oldValue.current, [input, oldValue.current]);
|
|
7843
|
+
const hasValidationError = useMemo4(() => isDirty && !validateInput?.(input), [input, validateInput, isDirty]);
|
|
7841
7844
|
const commitValue = (value) => {
|
|
7842
|
-
|
|
7843
|
-
|
|
7845
|
+
if (hasValidationError || !onUpdateEditableCell || !isDirty) {
|
|
7846
|
+
setInput(oldValue.current);
|
|
7844
7847
|
return;
|
|
7845
7848
|
}
|
|
7846
7849
|
oldValue.current = value;
|
|
@@ -7861,6 +7864,7 @@ var TableDesktopNumericField = ({
|
|
|
7861
7864
|
value: input,
|
|
7862
7865
|
disabled,
|
|
7863
7866
|
label: inputLabel,
|
|
7867
|
+
error: hasValidationError,
|
|
7864
7868
|
onKeyDown: handleKeyDown,
|
|
7865
7869
|
onChange: (e) => {
|
|
7866
7870
|
e.target.value = e.target.value.replace(/\D/g, "");
|
|
@@ -7952,7 +7956,7 @@ var TableDesktopSmartSelect = memo22(({
|
|
|
7952
7956
|
});
|
|
7953
7957
|
|
|
7954
7958
|
// src/components/TableDesktopEditableComponent/TableDesktopTextField.tsx
|
|
7955
|
-
import { useMemo as
|
|
7959
|
+
import { useMemo as useMemo5, useState as useState20, useRef as useRef6 } from "react";
|
|
7956
7960
|
import { TextField as TextField9 } from "@mui/material";
|
|
7957
7961
|
import { jsx as jsx122 } from "react/jsx-runtime";
|
|
7958
7962
|
var TableDesktopTextField = ({
|
|
@@ -7968,10 +7972,11 @@ var TableDesktopTextField = ({
|
|
|
7968
7972
|
}) => {
|
|
7969
7973
|
const [input, setInput] = useState20(initialValue);
|
|
7970
7974
|
const oldValue = useRef6(initialValue);
|
|
7971
|
-
const
|
|
7975
|
+
const isDirty = useMemo5(() => input !== oldValue.current, [input, oldValue.current]);
|
|
7976
|
+
const hasValidationError = useMemo5(() => isDirty && !validateInput?.(input), [input, validateInput]);
|
|
7972
7977
|
const commitValue = (value) => {
|
|
7973
|
-
const isDirty = value !== oldValue.current;
|
|
7974
7978
|
if (hasValidationError || !onUpdateEditableCell || !isDirty) {
|
|
7979
|
+
setInput(oldValue.current);
|
|
7975
7980
|
return;
|
|
7976
7981
|
}
|
|
7977
7982
|
oldValue.current = value;
|
|
@@ -8085,6 +8090,7 @@ var TableDesktopEditableComponent = ({
|
|
|
8085
8090
|
field,
|
|
8086
8091
|
initialValue: editInitialValue ?? "",
|
|
8087
8092
|
inputLabel: inputLabel ?? "",
|
|
8093
|
+
validateInput,
|
|
8088
8094
|
onUpdateEditableCell
|
|
8089
8095
|
}
|
|
8090
8096
|
)
|