@dartech/arsenal-ui 1.4.48 → 1.4.50

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 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
- setSearchValue(val);
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);
@@ -6006,6 +6029,70 @@ const CreatePropertyFormFields = /*#__PURE__*/memo(({
6006
6029
  }));
6007
6030
  });
6008
6031
 
6032
+ const ListItem$1 = ({
6033
+ entityDefinition,
6034
+ globalParameter,
6035
+ customPropertyFields,
6036
+ index,
6037
+ arrLength,
6038
+ entityReferenceDefinitionSources,
6039
+ entityReferenceValueComponent,
6040
+ control,
6041
+ setValue,
6042
+ fileReferenceValueComponent,
6043
+ handleRemoveParameter,
6044
+ error,
6045
+ item,
6046
+ extRefs
6047
+ }) => {
6048
+ const [open, setOpen] = useState(index === arrLength && !item.key);
6049
+ return jsx(Grid, Object.assign({
6050
+ sm: 12,
6051
+ ref: ref => extRefs.current[index] = ref
6052
+ }, {
6053
+ children: jsxs(Accordion, Object.assign({
6054
+ expanded: open,
6055
+ onChange: () => setOpen(!open),
6056
+ elevation: 3
6057
+ }, {
6058
+ children: [jsx(AccordionSummary, Object.assign({
6059
+ expandIcon: jsx(ExpandMore, {})
6060
+ }, {
6061
+ children: jsx(Typography, Object.assign({
6062
+ color: error && error[index] ? 'secondary' : 'initial',
6063
+ style: {
6064
+ wordBreak: 'break-word'
6065
+ }
6066
+ }, {
6067
+ children: item.name || `Property ${index + 1}`
6068
+ }))
6069
+ })), jsx(AccordionDetails, {
6070
+ children: open && jsx(CreatePropertyFormFields, {
6071
+ control: control,
6072
+ setValue: setValue,
6073
+ propertyFieldName: `properties.${index}`,
6074
+ entityDefinition: entityDefinition,
6075
+ globalParameter: globalParameter,
6076
+ customPropertyFields: customPropertyFields,
6077
+ entityReferenceDefinitionSources: entityReferenceDefinitionSources,
6078
+ entityReferenceValueComponent: entityReferenceValueComponent,
6079
+ fileReferenceValueComponent: fileReferenceValueComponent
6080
+ })
6081
+ }), jsx(AccordionActions, {
6082
+ children: jsx(Button, Object.assign({
6083
+ variant: "contained",
6084
+ size: "small",
6085
+ color: "secondary",
6086
+ onClick: () => handleRemoveParameter(index)
6087
+ }, {
6088
+ children: "Remove"
6089
+ }))
6090
+ })]
6091
+ }))
6092
+ }));
6093
+ };
6094
+ var ListItem$2 = ListItem$1;
6095
+
6009
6096
  const defaultPropertyValues$1 = {
6010
6097
  key: '',
6011
6098
  propertyType: null,
@@ -6112,49 +6199,19 @@ const CreatePropertiesList = /*#__PURE__*/forwardRef(({
6112
6199
  }, {
6113
6200
  children: error.message
6114
6201
  }))
6115
- })), Array.isArray(fields) && fields.map((item, index, array) => jsx(Grid, Object.assign({
6116
- sm: 12,
6117
- ref: ref => refs.current[index] = ref
6118
- }, {
6119
- children: jsxs(Accordion, Object.assign({
6120
- defaultExpanded: index === array.length - 1 && !item.key,
6121
- elevation: 3
6122
- }, {
6123
- children: [jsx(AccordionSummary, Object.assign({
6124
- expandIcon: jsx(ExpandMore, {})
6125
- }, {
6126
- children: jsx(Typography, Object.assign({
6127
- color: error && error[index] ? 'secondary' : 'initial',
6128
- style: {
6129
- wordBreak: 'break-word'
6130
- }
6131
- }, {
6132
- children: item.name || `Property ${index + 1}`
6133
- }))
6134
- })), jsx(AccordionDetails, {
6135
- children: jsx(CreatePropertyFormFields, {
6136
- control: control,
6137
- setValue: setValue,
6138
- propertyFieldName: `properties.${index}`,
6139
- entityDefinition: _entityDefinition,
6140
- globalParameter: _globalParameter,
6141
- customPropertyFields: _customPropertyFields,
6142
- entityReferenceDefinitionSources: entityReferenceDefinitionSources,
6143
- entityReferenceValueComponent: entityReferenceValueComponent,
6144
- fileReferenceValueComponent: fileReferenceValueComponent
6145
- })
6146
- }), jsx(AccordionActions, {
6147
- children: jsx(Button, Object.assign({
6148
- variant: "contained",
6149
- size: "small",
6150
- color: "secondary",
6151
- onClick: () => handleRemoveParameter(index)
6152
- }, {
6153
- children: "Remove"
6154
- }))
6155
- })]
6156
- }))
6157
- }), item.id)), !hideAddButton && jsxs(Grid, Object.assign({
6202
+ })), Array.isArray(fields) && fields.map((item, index, array) => jsx(ListItem$2, {
6203
+ item: item,
6204
+ index: index,
6205
+ arrLength: array.length - 1,
6206
+ control: control,
6207
+ setValue: setValue,
6208
+ error: error,
6209
+ handleRemoveParameter: handleRemoveParameter,
6210
+ fileReferenceValueComponent: fileReferenceValueComponent,
6211
+ entityReferenceValueComponent: entityReferenceValueComponent,
6212
+ entityReferenceDefinitionSources: entityReferenceDefinitionSources,
6213
+ extRefs: refs
6214
+ }, item.id)), !hideAddButton && jsxs(Grid, Object.assign({
6158
6215
  xs: 12
6159
6216
  }, {
6160
6217
  children: [jsx(Button, Object.assign({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dartech/arsenal-ui",
3
- "version": "1.4.48",
3
+ "version": "1.4.50",
4
4
  "author": "DAR",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -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;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { UseFormTrigger } from 'react-hook-form';
3
- import { CustomPropertyFieldProps, EntityReferenceProperty, PropertiesArrayType } from '../../../interfaces';
3
+ import { CustomPropertyFieldProps, EntityReferenceProperty, PropertiesArrayType } from '../../../../interfaces';
4
4
  type Props = {
5
5
  properties: PropertiesArrayType<any>;
6
6
  parentFieldName?: string;
@@ -0,0 +1,29 @@
1
+ import { MutableRefObject } from 'react';
2
+ import { Control, UseFormSetValue } from 'react-hook-form';
3
+ import { CustomPropertyFieldProps, EntityReferenceProperty } from '../../../../interfaces';
4
+ type Props = {
5
+ entityDefinition?: boolean;
6
+ globalParameter?: boolean;
7
+ customPropertyFields?: CustomPropertyFieldProps[];
8
+ index: number;
9
+ arrLength: number;
10
+ entityReferenceDefinitionSources?: {
11
+ label: string;
12
+ value: string;
13
+ }[];
14
+ entityReferenceValueComponent?: React.ElementType<{
15
+ name: string;
16
+ property: EntityReferenceProperty;
17
+ }>;
18
+ fileReferenceValueComponent?: React.ElementType<{
19
+ name: string;
20
+ }>;
21
+ control: Control<any>;
22
+ setValue: UseFormSetValue<any>;
23
+ handleRemoveParameter: (index: number) => void;
24
+ error: any;
25
+ item: any;
26
+ extRefs: MutableRefObject<any[]>;
27
+ };
28
+ declare const ListItem: ({ entityDefinition, globalParameter, customPropertyFields, index, arrLength, entityReferenceDefinitionSources, entityReferenceValueComponent, control, setValue, fileReferenceValueComponent, handleRemoveParameter, error, item, extRefs }: Props) => JSX.Element;
29
+ export default ListItem;
@@ -0,0 +1,2 @@
1
+ export * from './CreatePropertiesList';
2
+ export { default } from './CreatePropertiesList';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Control } from 'react-hook-form';
3
2
  type Props = {
4
3
  control: Control<any>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  type Props = {
3
2
  name: string;
4
3
  label?: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  type Props = {
3
2
  name: string;
4
3
  format: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  type Props = {
3
2
  name: string;
4
3
  label?: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  type Props = {
3
2
  name: string;
4
3
  label?: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { PropertyUnion } from '../../../interfaces';
3
2
  type PropertyItemProps = {
4
3
  property: PropertyUnion;