@irontec/ivoz-ui 1.8.0 → 1.8.1

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.
@@ -26,7 +26,7 @@ export const Empty = (props) => {
26
26
  const globalActions = Object.values(entity.customActions).filter((action) => action.global);
27
27
  return (_jsx(Fade, Object.assign({ in: true, style: {
28
28
  transitionDelay: '750ms',
29
- }, unmountOnExit: true }, { children: _jsxs("section", Object.assign({ className: className }, { children: [_jsx("img", { src: 'assets/img/empty.svg', alt: '' }), _jsx("h3", { children: _('No {{entity}} yet', { entity: pluralTitle }) }), _jsx("p", { children: _('You havent created any {{entity}} yet.', {
29
+ }, unmountOnExit: true }, { children: _jsxs("section", Object.assign({ className: className }, { children: [_jsx("img", { src: 'assets/img/empty.svg', alt: '' }), _jsx("h3", { children: _('No {{entity}} yet', { entity: pluralTitle }) }), _jsx("p", { children: _("You haven't created any {{entity}} yet.", {
30
30
  entity: singularTitle,
31
31
  }) }), create && (_jsxs(Box, Object.assign({ className: 'empty-actions' }, { children: [globalActions &&
32
32
  globalActions.length < 2 &&
@@ -58,7 +58,7 @@ const ListContentValue = (props) => {
58
58
  response = _jsx(StyledCheckBoxOutlineBlankIcon, {});
59
59
  }
60
60
  else {
61
- response = _jsx(ListDecorator, { field: columnName, row: row, property: column, entityPath: entityService.getEntity().path });
61
+ response = (_jsx(ListDecorator, { field: columnName, row: row, property: column, entityPath: entityService.getEntity().path }));
62
62
  }
63
63
  if (isDownloadable && isFileType) {
64
64
  response = (_jsx(DownloadFile, { row: row, path: entityService.getEntity().path, fileType: columnName }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irontec/ivoz-ui",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "UI library used in ivozprovider",
5
5
  "license": "GPL-3.0",
6
6
  "main": "index.js",
@@ -26,6 +26,11 @@ const DynamicAutocomplete = (props) => {
26
26
  const [currentOption, setCurrentOption] = useState(nullOptionObject);
27
27
  const debounceTimeoutRef = useRef();
28
28
  const loadedValuesRef = useRef(new Set());
29
+ const currentOptionRef = useRef(nullOptionObject);
30
+ const updateCurrentOption = useCallback((option) => {
31
+ currentOptionRef.current = option;
32
+ setCurrentOption(option);
33
+ }, []);
29
34
  useEffect(() => {
30
35
  if (selectOptions && Object.keys(choices).length === 0) {
31
36
  return;
@@ -54,30 +59,30 @@ const DynamicAutocomplete = (props) => {
54
59
  loadedValuesRef.current.add(value);
55
60
  selectOptions({
56
61
  callback: (options) => {
57
- const option = options[0];
62
+ var _a;
63
+ const allChoices = options;
64
+ const option = (_a = allChoices.find((item) => item.id == value)) !== null && _a !== void 0 ? _a : allChoices[0];
58
65
  if (option) {
66
+ updateCurrentOption(option);
59
67
  setArrayChoices((prev) => {
60
68
  const exists = prev.some((item) => item.id == option.id);
61
69
  return exists ? prev : [...prev, option];
62
70
  });
63
71
  }
64
72
  },
65
- }, {
66
- id: value,
67
- });
73
+ }, { id: value });
68
74
  }, [value, selectOptions]);
69
75
  const setOptions = useCallback((options) => {
70
- const isCurrentOptionIncluded = options.some((option) => option.id == (currentOption === null || currentOption === void 0 ? void 0 : currentOption.id));
71
- if (!isCurrentOptionIncluded &&
72
- currentOption &&
73
- currentOption.id !== '__null__') {
74
- options.unshift(currentOption);
76
+ const co = currentOptionRef.current;
77
+ const isCurrentOptionIncluded = options.some((option) => option.id == (co === null || co === void 0 ? void 0 : co.id));
78
+ if (!isCurrentOptionIncluded && co && co.id !== '__null__') {
79
+ options.unshift(co);
75
80
  }
76
81
  if (nullOptionObject) {
77
82
  options.unshift(nullOptionObject);
78
83
  }
79
84
  setArrayChoices(options);
80
- }, [nullOptionObject, currentOption]);
85
+ }, [nullOptionObject]);
81
86
  const clearSearch = useCallback(() => {
82
87
  if (debounceTimeoutRef.current) {
83
88
  clearTimeout(debounceTimeoutRef.current);
@@ -96,14 +101,12 @@ const DynamicAutocomplete = (props) => {
96
101
  setLoading(false);
97
102
  setOptions(options);
98
103
  },
99
- }, {
100
- searchTerm: searchValue,
101
- });
104
+ }, { searchTerm: searchValue });
102
105
  }, 500);
103
- }, [searchTerm, selectOptions]);
106
+ }, [selectOptions, setOptions]);
104
107
  useEffect(() => {
105
108
  clearSearch();
106
- const searchTermMatchNullOption = getOptionLabel(nullOptionObject) === searchTerm;
109
+ const searchTermMatchNullOption = searchTerm !== '' && getOptionLabel(nullOptionObject) === searchTerm;
107
110
  if (searchTermMatchNullOption) {
108
111
  return;
109
112
  }
@@ -144,7 +147,7 @@ const DynamicAutocomplete = (props) => {
144
147
  ? '__null__'
145
148
  : null;
146
149
  }
147
- setCurrentOption(option);
150
+ updateCurrentOption(option);
148
151
  onChange({
149
152
  target: {
150
153
  name: name,
@@ -50,7 +50,7 @@
50
50
  "Yes, delete it": "Si, eliminar",
51
51
  "You are about to remove": "Esteu a punt d'eliminar-lo",
52
52
  "You are about to update": "Estàs a punt d'actualitzar",
53
- "You havent created any {{entity}} yet.": "Aún no has creado ningún {{entity}}",
53
+ "You haven't created any {{entity}} yet.": "Aún no has creado ningún {{entity}}",
54
54
  "entities": "entitats",
55
55
  "invalid pattern": "Patrón invalido",
56
56
  "required value": "valor requerido",
@@ -50,7 +50,7 @@
50
50
  "Yes, delete it": "Yes, delete it",
51
51
  "You are about to remove": "Stai per rimuovere",
52
52
  "You are about to update": "Stai per aggiornare ",
53
- "You havent created any {{entity}} yet.": "You havent created any {{entity}} yet.",
53
+ "You haven't created any {{entity}} yet.": "You haven't created any {{entity}} yet.",
54
54
  "entities": "entità",
55
55
  "invalid pattern": "invalid pattern",
56
56
  "required value": "required value",