@evoke-platform/ui-components 1.1.0-testing.2 → 1.1.0-testing.4

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.
@@ -1,4 +1,4 @@
1
- import { ElementType } from 'react';
1
+ /// <reference types="react" />
2
2
  import 'react-querybuilder/dist/query-builder.css';
3
3
  import { EvokeObject } from '../../../types';
4
4
  import { ObjectProperty, Operator, PresetValue, TreeViewObject } from './types';
@@ -10,10 +10,9 @@ export type CriteriaInputProps = {
10
10
  originalCriteria?: Record<string, unknown>;
11
11
  enablePresetValues?: boolean;
12
12
  presetValues?: PresetValue[];
13
- dynamicContentInput?: {
14
- component: ElementType;
15
- previousSteps: unknown[];
16
- trigger?: Record<string, unknown>;
13
+ customValueEditor?: {
14
+ component: (props: ValueEditorProps) => JSX.Element;
15
+ props?: Record<string, unknown>;
17
16
  };
18
17
  operators?: Operator[];
19
18
  disabledCriteria?: {
@@ -212,7 +212,10 @@ const customSelector = (props) => {
212
212
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
213
213
  onChange: (event, newValue) => {
214
214
  handleOnChange(newValue?.value.name);
215
- }, renderInput: (params) => React.createElement(TextField, { ...params, placeholder: placeholder, size: "small" }), sx: { width: width, background: '#fff' }, disableClearable: true, readOnly: readOnly }))));
215
+ }, renderInput: (params) => (React.createElement(TextField, { ...params, placeholder: placeholder, size: "small", inputProps: {
216
+ ...params.inputProps,
217
+ 'aria-label': placeholder,
218
+ } })), sx: { width: width, background: '#fff' }, disableClearable: true, readOnly: readOnly }))));
216
219
  };
217
220
  const customCombinator = (props) => {
218
221
  const { value, handleOnChange, context, level, path } = props;
@@ -277,7 +280,7 @@ export const valueEditor = (props) => {
277
280
  return ValueEditor(props);
278
281
  };
279
282
  const CriteriaBuilder = (props) => {
280
- const { properties, criteria, setCriteria, originalCriteria, enablePresetValues, presetValues, operators, dynamicContentInput, disabled, disabledCriteria, hideBorder, presetGroupLabel, treeViewOpts, disableRegexEscapeChars, } = props;
283
+ const { properties, criteria, setCriteria, originalCriteria, enablePresetValues, presetValues, operators, disabled, disabledCriteria, hideBorder, presetGroupLabel, customValueEditor, treeViewOpts, disableRegexEscapeChars, } = props;
281
284
  const [query, setQuery] = useState(undefined);
282
285
  const [propertyTreeMap, setPropertyTreeMap] = useState();
283
286
  useEffect(() => {
@@ -294,7 +297,7 @@ const CriteriaBuilder = (props) => {
294
297
  setQuery({ combinator: 'and', rules: [] });
295
298
  }
296
299
  }, [originalCriteria]);
297
- function processRules(rules, isSavedValue) {
300
+ const processRules = (rules, isSavedValue) => {
298
301
  return rules.map((rule) => {
299
302
  if ('rules' in rule) {
300
303
  return {
@@ -320,7 +323,7 @@ const CriteriaBuilder = (props) => {
320
323
  };
321
324
  }
322
325
  });
323
- }
326
+ };
324
327
  // this retrieves the properties from a treeview for each property in the query
325
328
  // they are then used in the custom query builder components to determine the input type etc
326
329
  const updatePropertyTreeMap = (q) => {
@@ -386,16 +389,12 @@ const CriteriaBuilder = (props) => {
386
389
  return defaultRuleProcessorMongoDB(newRule, options);
387
390
  },
388
391
  }));
389
- //when q has no rules, it formats and parses to { $and: [{ $expr: true }] }
390
- const allRulesDeleted = isEmpty(difference(newCriteria, { $and: [{ $expr: true }] }));
391
- // since the Add Condition / Add Group buttons add rules with all the fields empty,
392
- // we need to check if the first rule was added because q will still parse to { $and: [{ $expr: true }] }
393
- const firstRuleAdded = isEmpty(criteria) && q.rules.length > 0;
394
- if (allRulesDeleted && !firstRuleAdded) {
395
- setCriteria(undefined);
392
+ if (!isEmpty(difference(newCriteria, { $and: [{ $expr: true }] }))) {
393
+ setCriteria(newCriteria);
396
394
  }
397
395
  else {
398
- setCriteria(newCriteria);
396
+ if (q.rules.length === 0)
397
+ setCriteria(undefined);
399
398
  }
400
399
  };
401
400
  const fields = useMemo(() => {
@@ -498,9 +497,9 @@ const CriteriaBuilder = (props) => {
498
497
  ruleGroup: CustomRuleGroup,
499
498
  removeGroupAction: customDelete,
500
499
  removeRuleAction: customDelete,
501
- valueEditor: valueEditor,
500
+ valueEditor: customValueEditor ? customValueEditor.component : valueEditor,
502
501
  }, context: {
503
- dynamicContentInput,
502
+ ...(customValueEditor?.props ?? {}),
504
503
  presetValues,
505
504
  enablePresetValues,
506
505
  presetGroupLabel,
@@ -78,7 +78,11 @@ export const ObjectPropertyInput = (props) => {
78
78
  updatedFilter = {};
79
79
  }
80
80
  updatedFilter.limit = 100;
81
- updatedFilter.order = 'name ASC';
81
+ const { propertyId, direction } = layout?.sort ?? {
82
+ propertyId: 'name',
83
+ direction: 'asc',
84
+ };
85
+ updatedFilter.order = `${propertyId} ${direction}`;
82
86
  const where = name
83
87
  ? transformToWhere({
84
88
  name: {
@@ -103,7 +107,7 @@ export const ObjectPropertyInput = (props) => {
103
107
  setLoadingOptions(false);
104
108
  }
105
109
  });
106
- }, [relatedObject, setLoadingOptions, setOptions, property, filter]);
110
+ }, [relatedObject, setLoadingOptions, setOptions, property, filter, layout]);
107
111
  useEffect(() => {
108
112
  if (displayOption === 'dropdown') {
109
113
  getDropdownOptions();
@@ -281,7 +285,7 @@ export const ObjectPropertyInput = (props) => {
281
285
  caretColor: 'white',
282
286
  }
283
287
  : {}),
284
- } })), readOnly: !loadingOptions && !canUpdateProperty, error: error }))) : (React.createElement(Box, { sx: {
288
+ } })), readOnly: !loadingOptions && !canUpdateProperty, error: error, sortBy: "NONE" }))) : (React.createElement(Box, { sx: {
285
289
  padding: (instance?.[property.id]?.name ?? selectedInstance?.name)
286
290
  ? '16.5px 14px'
287
291
  : '10.5px 0',
@@ -78,9 +78,13 @@ export const DropdownRepeatableField = (props) => {
78
78
  setLoading(true);
79
79
  const endObjectProperty = middleObject.properties?.find((currProperty) => property.manyToManyPropertyId === currProperty.id);
80
80
  if (endObjectProperty?.objectId) {
81
+ const { propertyId, direction } = layout?.sort ?? {
82
+ propertyId: 'name',
83
+ direction: 'asc',
84
+ };
81
85
  const filter = {
82
86
  limit: 100,
83
- order: 'name ASC',
87
+ order: `${propertyId} ${direction}`,
84
88
  };
85
89
  let searchCriteria = criteria && !isEmpty(criteria) ? transformToWhere(criteria) : {};
86
90
  if (searchedName?.length) {
@@ -106,7 +110,7 @@ export const DropdownRepeatableField = (props) => {
106
110
  });
107
111
  }
108
112
  }
109
- }, [property.objectId, property.manyToManyPropertyId, apiServices, middleObject]);
113
+ }, [property.objectId, property.manyToManyPropertyId, apiServices, middleObject, layout]);
110
114
  const debouncedEndObjectSearch = useCallback(debounce(fetchEndObjectInstances, 500), [fetchEndObjectInstances]);
111
115
  useEffect(() => {
112
116
  debouncedEndObjectSearch(searchValue);
@@ -86,6 +86,7 @@ export const DropdownRepeatableFieldInput = (props) => {
86
86
  setSearchValue(event.target.value);
87
87
  } })),
88
88
  loading: loading,
89
+ sortBy: 'NONE',
89
90
  } }),
90
91
  React.createElement(Snackbar, { open: snackbarError.showAlert, handleClose: () => setSnackbarError({ isError: snackbarError.isError, showAlert: false }), message: snackbarError.message, error: snackbarError.isError })))) : (React.createElement(Typography, null, selectedOptions && selectedOptions.map((option) => option.label).join(', ')))));
91
92
  };
@@ -384,7 +384,7 @@ export function convertComponentsToForm(components) {
384
384
  ...(component.orderBy ? { sortBy: component.orderBy } : {}),
385
385
  }
386
386
  : isArray(component.initialValue)
387
- ? component.initialValue.map((c) => c.value)
387
+ ? component.initialValue.map((c) => typeof c === 'string' ? c : c.value)
388
388
  : component.initialValue?.value
389
389
  ? component.initialValue?.value
390
390
  : component.initialValue,
@@ -1,11 +1,13 @@
1
- export { ClickAwayListener, Toolbar, createTheme, styled } from '@mui/material';
1
+ export { ClickAwayListener, createTheme, darken, lighten, styled, Toolbar } from '@mui/material';
2
2
  export { CalendarPicker, DateTimePicker, MonthPicker, PickersDay, StaticDateTimePicker, StaticTimePicker, TimePicker, YearPicker, } from '@mui/x-date-pickers';
3
+ export * from './colors';
3
4
  export * from './components/core';
4
- export { BuilderGrid, CriteriaBuilder, DataGrid, ErrorComponent, Form, FormField, MenuBar, MultiSelect, RepeatableField, UserAvatar, HistoryLog, RichTextViewer, } from './components/custom';
5
+ export { BuilderGrid, CriteriaBuilder, DataGrid, ErrorComponent, Form, FormField, HistoryLog, MenuBar, MultiSelect, RepeatableField, RichTextViewer, UserAvatar, } from './components/custom';
6
+ export { NumericFormat } from './components/custom/FormField/InputFieldComponent';
5
7
  export { Box, Container, Grid, Stack } from './components/layout';
6
8
  export * as EVOKE_TYPES from './types';
7
9
  export * from './util';
8
- export type { ButtonBaseActions, ButtonBaseClasses, FormControlProps, FormHelperTextProps, GridSize, MenuItemClasses, Theme, } from '@mui/material';
10
+ export type { AutocompleteRenderGroupParams, ButtonBaseActions, ButtonBaseClasses, FormControlProps, FormHelperTextProps, GridSize, MenuItemClasses, TextFieldProps, Theme, } from '@mui/material';
9
11
  export type { TouchRippleActions, TouchRippleProps } from '@mui/material/ButtonBase/TouchRipple';
10
12
  export type { CommonProps } from '@mui/material/OverridableComponent';
11
13
  export type { SxProps } from '@mui/system';
@@ -1,7 +1,9 @@
1
- export { ClickAwayListener, Toolbar, createTheme, styled } from '@mui/material';
1
+ export { ClickAwayListener, createTheme, darken, lighten, styled, Toolbar } from '@mui/material';
2
2
  export { CalendarPicker, DateTimePicker, MonthPicker, PickersDay, StaticDateTimePicker, StaticTimePicker, TimePicker, YearPicker, } from '@mui/x-date-pickers';
3
+ export * from './colors';
3
4
  export * from './components/core';
4
- export { BuilderGrid, CriteriaBuilder, DataGrid, ErrorComponent, Form, FormField, MenuBar, MultiSelect, RepeatableField, UserAvatar, HistoryLog, RichTextViewer, } from './components/custom';
5
+ export { BuilderGrid, CriteriaBuilder, DataGrid, ErrorComponent, Form, FormField, HistoryLog, MenuBar, MultiSelect, RepeatableField, RichTextViewer, UserAvatar, } from './components/custom';
6
+ export { NumericFormat } from './components/custom/FormField/InputFieldComponent';
5
7
  export { Box, Container, Grid, Stack } from './components/layout';
6
8
  export * as EVOKE_TYPES from './types';
7
9
  export * from './util';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.1.0-testing.2",
3
+ "version": "1.1.0-testing.4",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",
@@ -94,7 +94,7 @@
94
94
  "@dnd-kit/sortable": "^7.0.1",
95
95
  "@emotion/react": "^11.13.5",
96
96
  "@emotion/styled": "^11.8.1",
97
- "@evoke-platform/context": "^1.0.0-dev.118",
97
+ "@evoke-platform/context": "^1.0.0-dev.126",
98
98
  "@formio/react": "^5.2.4-rc.1",
99
99
  "@js-joda/core": "^3.2.0",
100
100
  "@js-joda/locale_en-us": "^3.2.2",
@@ -135,12 +135,6 @@
135
135
  "npm run lint:fix"
136
136
  ]
137
137
  },
138
- "husky": {
139
- "hooks": {
140
- "pre-commit": "npx lint-staged",
141
- "commit-msg": "npx commitlint --edit $1"
142
- }
143
- },
144
138
  "jest": {
145
139
  "verbose": true,
146
140
  "testEnvironment": "jsdom",