@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.
|
@@ -8007,13 +8007,16 @@ var TableDesktopNumericField = ({
|
|
|
8007
8007
|
field,
|
|
8008
8008
|
variant = "standard",
|
|
8009
8009
|
size,
|
|
8010
|
+
validateInput,
|
|
8010
8011
|
onUpdateEditableCell
|
|
8011
8012
|
}) => {
|
|
8012
8013
|
const [input, setInput] = (0, import_react36.useState)(initialValue);
|
|
8013
8014
|
const oldValue = (0, import_react36.useRef)(initialValue);
|
|
8015
|
+
const isDirty = (0, import_react36.useMemo)(() => input !== oldValue.current, [input, oldValue.current]);
|
|
8016
|
+
const hasValidationError = (0, import_react36.useMemo)(() => isDirty && !validateInput?.(input), [input, validateInput, isDirty]);
|
|
8014
8017
|
const commitValue = (value) => {
|
|
8015
|
-
|
|
8016
|
-
|
|
8018
|
+
if (hasValidationError || !onUpdateEditableCell || !isDirty) {
|
|
8019
|
+
setInput(oldValue.current);
|
|
8017
8020
|
return;
|
|
8018
8021
|
}
|
|
8019
8022
|
oldValue.current = value;
|
|
@@ -8034,6 +8037,7 @@ var TableDesktopNumericField = ({
|
|
|
8034
8037
|
value: input,
|
|
8035
8038
|
disabled,
|
|
8036
8039
|
label: inputLabel,
|
|
8040
|
+
error: hasValidationError,
|
|
8037
8041
|
onKeyDown: handleKeyDown,
|
|
8038
8042
|
onChange: (e) => {
|
|
8039
8043
|
e.target.value = e.target.value.replace(/\D/g, "");
|
|
@@ -8141,10 +8145,11 @@ var TableDesktopTextField = ({
|
|
|
8141
8145
|
}) => {
|
|
8142
8146
|
const [input, setInput] = (0, import_react38.useState)(initialValue);
|
|
8143
8147
|
const oldValue = (0, import_react38.useRef)(initialValue);
|
|
8144
|
-
const
|
|
8148
|
+
const isDirty = (0, import_react38.useMemo)(() => input !== oldValue.current, [input, oldValue.current]);
|
|
8149
|
+
const hasValidationError = (0, import_react38.useMemo)(() => isDirty && !validateInput?.(input), [input, validateInput]);
|
|
8145
8150
|
const commitValue = (value) => {
|
|
8146
|
-
const isDirty = value !== oldValue.current;
|
|
8147
8151
|
if (hasValidationError || !onUpdateEditableCell || !isDirty) {
|
|
8152
|
+
setInput(oldValue.current);
|
|
8148
8153
|
return;
|
|
8149
8154
|
}
|
|
8150
8155
|
oldValue.current = value;
|
|
@@ -8258,6 +8263,7 @@ var TableDesktopEditableComponent = ({
|
|
|
8258
8263
|
field,
|
|
8259
8264
|
initialValue: editInitialValue ?? "",
|
|
8260
8265
|
inputLabel: inputLabel ?? "",
|
|
8266
|
+
validateInput,
|
|
8261
8267
|
onUpdateEditableCell
|
|
8262
8268
|
}
|
|
8263
8269
|
)
|