@dartech/arsenal-ui 1.4.47 → 1.4.49
Sign up to get free protection for your applications and to get access to all the features.
package/index.js
CHANGED
@@ -922,6 +922,7 @@ function ControlQueryAutocomplete(_a) {
|
|
922
922
|
searchBy,
|
923
923
|
labelKey,
|
924
924
|
multiple = false,
|
925
|
+
mongoQueryJson,
|
925
926
|
disabled,
|
926
927
|
valueKey,
|
927
928
|
sortBy = '',
|
@@ -934,7 +935,7 @@ function ControlQueryAutocomplete(_a) {
|
|
934
935
|
itemQueryFunction,
|
935
936
|
requiredErrorText = ''
|
936
937
|
} = _a,
|
937
|
-
autocompleteProps = __rest(_a, ["name", "label", "control", "required", "searchBy", "labelKey", "multiple", "disabled", "valueKey", "sortBy", "hideErrorMessage", "disableCloseOnSelect", "textFieldProps", "onChange", "queryFunction", "validate", "itemQueryFunction", "requiredErrorText"]);
|
938
|
+
autocompleteProps = __rest(_a, ["name", "label", "control", "required", "searchBy", "labelKey", "multiple", "mongoQueryJson", "disabled", "valueKey", "sortBy", "hideErrorMessage", "disableCloseOnSelect", "textFieldProps", "onChange", "queryFunction", "validate", "itemQueryFunction", "requiredErrorText"]);
|
938
939
|
const _b = useController({
|
939
940
|
control,
|
940
941
|
name,
|
@@ -994,9 +995,31 @@ function ControlQueryAutocomplete(_a) {
|
|
994
995
|
}
|
995
996
|
}
|
996
997
|
});
|
998
|
+
const modifyFieldsWithString = (data, replacement) => {
|
999
|
+
if (typeof data === 'object') {
|
1000
|
+
if (Array.isArray(data)) {
|
1001
|
+
return data.map(item => modifyFieldsWithString(item, replacement));
|
1002
|
+
} else {
|
1003
|
+
const modifiedData = {};
|
1004
|
+
for (const key in data) {
|
1005
|
+
modifiedData[key] = modifyFieldsWithString(data[key], replacement);
|
1006
|
+
}
|
1007
|
+
return modifiedData;
|
1008
|
+
}
|
1009
|
+
// eslint-disable-next-line no-template-curly-in-string
|
1010
|
+
} else if (typeof data === 'string' && data.includes('${variable}')) {
|
1011
|
+
// eslint-disable-next-line no-template-curly-in-string
|
1012
|
+
return data.replace('${variable}', replacement);
|
1013
|
+
} else {
|
1014
|
+
return data;
|
1015
|
+
}
|
1016
|
+
};
|
997
1017
|
const debouncedChange = useDebounce(val => {
|
998
1018
|
setPage(0);
|
999
|
-
|
1019
|
+
if (mongoQueryJson) {
|
1020
|
+
const obj = modifyFieldsWithString(mongoQueryJson, val);
|
1021
|
+
setSearchValue(JSON.stringify(obj));
|
1022
|
+
} else setSearchValue(val);
|
1000
1023
|
}, 500);
|
1001
1024
|
const handleInputChange = useCallback((_, value) => {
|
1002
1025
|
setInputValue(value);
|
@@ -1960,11 +1983,11 @@ const formatTableRowValue = ({
|
|
1960
1983
|
})
|
1961
1984
|
}));
|
1962
1985
|
case 'date':
|
1963
|
-
return value ? dateFormat ? jsx(
|
1986
|
+
return value ? dateFormat ? jsx(OverflowTip, {
|
1964
1987
|
children: dateFormat.map((formatString, index) => jsx(Box, {
|
1965
1988
|
children: format(new Date(value), formatString)
|
1966
1989
|
}, index))
|
1967
|
-
}) : jsxs(
|
1990
|
+
}) : jsxs(OverflowTip, {
|
1968
1991
|
children: [jsx(Box, {
|
1969
1992
|
children: format(new Date(value), 'dd.MM.yyyy')
|
1970
1993
|
}), jsx(Box, {
|
@@ -1972,9 +1995,11 @@ const formatTableRowValue = ({
|
|
1972
1995
|
})]
|
1973
1996
|
}) : '';
|
1974
1997
|
case 'status':
|
1975
|
-
return jsx(
|
1976
|
-
|
1977
|
-
|
1998
|
+
return jsx(OverflowTip, {
|
1999
|
+
children: jsx(Status, {
|
2000
|
+
text: value,
|
2001
|
+
status: statusVariant ? statusVariant : 'default'
|
2002
|
+
})
|
1978
2003
|
});
|
1979
2004
|
case 'json_text':
|
1980
2005
|
return jsx(JsonTypeCell$1, {
|
@@ -2015,7 +2040,7 @@ const formatTableRowValue = ({
|
|
2015
2040
|
display: "flex",
|
2016
2041
|
justifyContent: "flex-end"
|
2017
2042
|
}, {
|
2018
|
-
children: jsx(
|
2043
|
+
children: jsx(OverflowTip, {
|
2019
2044
|
children: value.toLocaleString('ru-Ru', {
|
2020
2045
|
minimumFractionDigits: 2
|
2021
2046
|
})
|
@@ -2029,21 +2054,15 @@ const formatTableRowValue = ({
|
|
2029
2054
|
width: "100%"
|
2030
2055
|
}, {
|
2031
2056
|
children: [shortId ? jsx(OverflowTip, {
|
2032
|
-
children:
|
2033
|
-
mr: "auto"
|
2034
|
-
}, {
|
2035
|
-
children: value ? `${value.slice(0, 6)}...${value.slice(-6)}` : '...'
|
2036
|
-
}))
|
2057
|
+
children: value ? `${value.slice(0, 6)}...${value.slice(-6)}` : '...'
|
2037
2058
|
}) : _fullText ? jsx(Box, Object.assign({
|
2038
2059
|
sx: {
|
2039
2060
|
whiteSpace: 'normal'
|
2040
2061
|
}
|
2041
2062
|
}, {
|
2042
2063
|
children: typeof value === 'string' ? value : JSON.stringify(value)
|
2043
|
-
})) : jsx(
|
2044
|
-
children:
|
2045
|
-
children: typeof value === 'string' ? value : JSON.stringify(value)
|
2046
|
-
})
|
2064
|
+
})) : jsx(OverflowTip, {
|
2065
|
+
children: typeof value === 'string' ? value : JSON.stringify(value)
|
2047
2066
|
}), canCopy && jsx(CopyButton, {
|
2048
2067
|
copyText: copyValue ? typeof copyValue === 'string' ? copyValue : JSON.stringify(copyValue) : value
|
2049
2068
|
})]
|
@@ -3232,6 +3251,9 @@ const ControlPhoneInput = _a => {
|
|
3232
3251
|
rules: {
|
3233
3252
|
required: required ? requiredErrorText || DEFAULT_REQUIRED_ERROR_TEXT : false,
|
3234
3253
|
validate: val => {
|
3254
|
+
if (!required && !val) {
|
3255
|
+
return true;
|
3256
|
+
}
|
3235
3257
|
if (!/(\+7\s\(\d{3}\)\s)(\d{3}\s\d{2})(\s\d{2})/.test(val)) {
|
3236
3258
|
return 'Incorrect phone number format';
|
3237
3259
|
}
|
@@ -6829,7 +6851,7 @@ const PropertyFiller = ({
|
|
6829
6851
|
parseValue: true,
|
6830
6852
|
hideErrorMessage: true,
|
6831
6853
|
useCleanValue: true,
|
6832
|
-
mode: propertyType === PropertyType.ANY
|
6854
|
+
mode: propertyType === PropertyType.ANY ? 'text' : 'json'
|
6833
6855
|
}) : jsx(ControlInput, {
|
6834
6856
|
control: control,
|
6835
6857
|
name: name,
|
package/package.json
CHANGED
@@ -8,10 +8,11 @@ type PaginateParams = {
|
|
8
8
|
};
|
9
9
|
type ControlQueryAutocompleteProps<T> = Omit<ControlAutocompleteProps, 'options'> & {
|
10
10
|
searchBy: string;
|
11
|
+
mongoQueryJson?: any;
|
11
12
|
sortBy?: string;
|
12
13
|
queryFunction: (params: PaginateParams) => Promise<PaginateData<T>>;
|
13
14
|
itemQueryFunction?: (valueKey: string) => Promise<T>;
|
14
15
|
requiredErrorText?: string;
|
15
16
|
};
|
16
|
-
export declare function ControlQueryAutocomplete<T>({ name, label, control, required, searchBy, labelKey, multiple, disabled, valueKey, sortBy, hideErrorMessage, disableCloseOnSelect, textFieldProps, onChange, queryFunction, validate, itemQueryFunction, requiredErrorText, ...autocompleteProps }: ControlQueryAutocompleteProps<T>): JSX.Element;
|
17
|
+
export declare function ControlQueryAutocomplete<T>({ name, label, control, required, searchBy, labelKey, multiple, mongoQueryJson, disabled, valueKey, sortBy, hideErrorMessage, disableCloseOnSelect, textFieldProps, onChange, queryFunction, validate, itemQueryFunction, requiredErrorText, ...autocompleteProps }: ControlQueryAutocompleteProps<T>): JSX.Element;
|
17
18
|
export default ControlQueryAutocomplete;
|