@dartech/arsenal-ui 1.4.11 → 1.4.13
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/index.js +33 -24
- package/package.json +1 -1
- package/src/lib/Property/PropertyFiller/PropertyFiller.d.ts +1 -1
- package/src/lib/Property/UpsertProperty/PropertyValueField/BooleanValueField.d.ts +0 -1
- package/src/lib/Property/UpsertProperty/PropertyValueField/DateTimeValueField.d.ts +0 -1
- package/src/lib/Property/UpsertProperty/PropertyValueField/DateValueField.d.ts +0 -1
- package/src/lib/Property/UpsertProperty/PropertyValueField/JsonValueField.d.ts +0 -1
- package/src/lib/Property/UpsertProperty/PropertyValueField/TimeValueField.d.ts +0 -1
- package/src/lib/Property/ViewProperty/PropertyItem.d.ts +0 -1
package/index.js
CHANGED
@@ -2306,23 +2306,29 @@ const ControlArrayInput = ({
|
|
2306
2306
|
required,
|
2307
2307
|
defaultValue: _defaultValue = null
|
2308
2308
|
}) => {
|
2309
|
-
var _a, _b
|
2309
|
+
var _a, _b;
|
2310
2310
|
const [localValue, setLoacalValue] = useState('');
|
2311
2311
|
const [error, setError] = useState(null);
|
2312
|
-
const {
|
2313
|
-
|
2312
|
+
const _c = useController({
|
2313
|
+
control,
|
2314
|
+
name,
|
2315
|
+
defaultValue: _defaultValue,
|
2316
|
+
rules: {
|
2317
|
+
required: required && DEFAULT_REQUIRED_ERROR_TEXT
|
2318
|
+
}
|
2319
|
+
}),
|
2320
|
+
_d = _c.field,
|
2321
|
+
{
|
2314
2322
|
onChange,
|
2315
2323
|
value: values
|
2316
|
-
},
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
defaultValue: _defaultValue
|
2325
|
-
});
|
2324
|
+
} = _d,
|
2325
|
+
fieldData = __rest(_d, ["onChange", "value"]),
|
2326
|
+
{
|
2327
|
+
// fieldState: { error },
|
2328
|
+
formState: {
|
2329
|
+
errors
|
2330
|
+
}
|
2331
|
+
} = _c;
|
2326
2332
|
const handleInputChange = useCallback(e => {
|
2327
2333
|
const {
|
2328
2334
|
value
|
@@ -2330,15 +2336,16 @@ const ControlArrayInput = ({
|
|
2330
2336
|
setLoacalValue(value);
|
2331
2337
|
}, []);
|
2332
2338
|
const handleAdd = useCallback(() => {
|
2333
|
-
var _a;
|
2334
2339
|
setError(null);
|
2335
|
-
if (localValue &&
|
2340
|
+
if (localValue &&
|
2341
|
+
// !errors[name]?.message &&
|
2342
|
+
!(Array.isArray(values) && values.includes(localValue))) {
|
2336
2343
|
onChange([...(values !== null && values !== void 0 ? values : []), localValue]);
|
2337
2344
|
setLoacalValue('');
|
2338
2345
|
} else if (Array.isArray(values) && values.includes(localValue)) {
|
2339
2346
|
setError('This value already exists');
|
2340
2347
|
}
|
2341
|
-
}, [localValue,
|
2348
|
+
}, [localValue, onChange, values]);
|
2342
2349
|
const handleDelete = useCallback(value => {
|
2343
2350
|
onChange(values.filter(code => code !== value));
|
2344
2351
|
}, [values, onChange]);
|
@@ -2376,9 +2383,10 @@ const ControlArrayInput = ({
|
|
2376
2383
|
}, index))
|
2377
2384
|
})), jsx("input", Object.assign({
|
2378
2385
|
type: "hidden"
|
2379
|
-
}, control.register(name, {
|
2380
|
-
|
2381
|
-
|
2386
|
+
}, control.register(name), {
|
2387
|
+
onChange: onChange,
|
2388
|
+
value: values
|
2389
|
+
}, fieldData)), jsx(TextField, {
|
2382
2390
|
fullWidth: true,
|
2383
2391
|
variant: "outlined",
|
2384
2392
|
size: "small",
|
@@ -2392,8 +2400,7 @@ const ControlArrayInput = ({
|
|
2392
2400
|
InputProps: {
|
2393
2401
|
endAdornment: jsx(IconButton, Object.assign({
|
2394
2402
|
size: "small",
|
2395
|
-
onClick: handleAdd
|
2396
|
-
disabled: !!((_c = errors[name]) === null || _c === void 0 ? void 0 : _c.message)
|
2403
|
+
onClick: handleAdd
|
2397
2404
|
}, {
|
2398
2405
|
children: jsx(SvgIcon, {
|
2399
2406
|
children: jsx("path", {
|
@@ -5956,19 +5963,21 @@ const PropertyFiller = ({
|
|
5956
5963
|
}
|
5957
5964
|
}
|
5958
5965
|
clearErrors();
|
5959
|
-
}, [name,
|
5966
|
+
}, [name, clearErrors, value, setFillOption, fillOption, propertyType, property]);
|
5960
5967
|
useEffect(() => {
|
5961
5968
|
var _a;
|
5962
5969
|
if (!isDirty && isPropertyValueEmpty(value)) {
|
5963
5970
|
if (property.isRequired && (property.defaultValue === null || property.value === null)) {
|
5964
|
-
setValue(name, (_a = prevValueRef.current[fillOption]) !== null && _a !== void 0 ? _a : defaultProperyValue
|
5971
|
+
setValue(name, (_a = prevValueRef.current[fillOption]) !== null && _a !== void 0 ? _a : defaultProperyValue, {
|
5972
|
+
shouldDirty: true
|
5973
|
+
});
|
5965
5974
|
} else if (!property.isRequired && (property.defaultValue === null || property.value === null)) {
|
5966
5975
|
setValue(name, null);
|
5967
5976
|
} else if (!(isPropertyValueEmpty(property.defaultValue) || isPropertyValueEmpty(property.value))) {
|
5968
5977
|
setValue(name, property.defaultValue || property.value);
|
5969
5978
|
}
|
5970
5979
|
}
|
5971
|
-
}, [value,
|
5980
|
+
}, [value, property, name, fillOption, isDirty]);
|
5972
5981
|
useEffect(() => {
|
5973
5982
|
if (!isPropertyValueEmpty(value) && property.propertyType !== PropertyType.JSON) {
|
5974
5983
|
setValue(name, value);
|
package/package.json
CHANGED
@@ -20,5 +20,5 @@ export type PropertyFillerProps = {
|
|
20
20
|
name: string;
|
21
21
|
}>;
|
22
22
|
};
|
23
|
-
export declare const PropertyFiller: ({ property, name, useExpression, label, required, title, entityReferenceDefinitionSources, entityReferenceValueComponent, fileReferenceValueComponent, requiredErrorText }: PropertyFillerProps) => JSX.Element;
|
23
|
+
export declare const PropertyFiller: ({ property, name, useExpression, label, required, title, entityReferenceDefinitionSources, entityReferenceValueComponent, fileReferenceValueComponent, requiredErrorText, }: PropertyFillerProps) => JSX.Element;
|
24
24
|
export default PropertyFiller;
|