@guillotinaweb/react-gmi 0.29.2 → 0.30.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.
Files changed (70) hide show
  1. package/README.md +2 -1
  2. package/dist/actions/copy_item.d.ts +2 -2
  3. package/dist/actions/move_item.d.ts +2 -2
  4. package/dist/actions/remove_item.d.ts +2 -2
  5. package/dist/components/behaviors/iattachment.d.ts +4 -2
  6. package/dist/components/behaviors/imultiimageorderedattachment.d.ts +3 -1
  7. package/dist/components/behaviors/iworkflow.d.ts +1 -1
  8. package/dist/components/context_toolbar.d.ts +1 -1
  9. package/dist/components/fields/editComponent.d.ts +5 -4
  10. package/dist/components/fields/editableField.d.ts +4 -2
  11. package/dist/components/fields/renderField.d.ts +8 -5
  12. package/dist/components/flash.d.ts +1 -1
  13. package/dist/components/input/email.d.ts +1 -1
  14. package/dist/components/input/form_builder.d.ts +2 -2
  15. package/dist/components/input/input.d.ts +1 -1
  16. package/dist/components/input/search_input.d.ts +1 -1
  17. package/dist/components/input/search_input_list.d.ts +2 -2
  18. package/dist/components/input/select_vocabulary.d.ts +2 -2
  19. package/dist/components/input/upload.d.ts +1 -2
  20. package/dist/components/pagination.d.ts +1 -1
  21. package/dist/components/panel/permissions.d.ts +1 -1
  22. package/dist/components/panel/permissions_prinperm.d.ts +2 -2
  23. package/dist/components/panel/permissions_prinrole.d.ts +1 -1
  24. package/dist/components/panel/permissions_roleperm.d.ts +1 -1
  25. package/dist/components/path.d.ts +1 -1
  26. package/dist/components/properties_view.d.ts +2 -2
  27. package/dist/components/search_labels.d.ts +1 -1
  28. package/dist/components/search_options_labels.d.ts +1 -1
  29. package/dist/components/search_vocabulary_labels.d.ts +2 -2
  30. package/dist/components/selected_items_actions.d.ts +14 -0
  31. package/dist/components/tabs.d.ts +4 -2
  32. package/dist/components/widgets/tags.d.ts +4 -1
  33. package/dist/contexts/index.d.ts +21 -19
  34. package/dist/forms/required_fields.d.ts +2 -3
  35. package/dist/forms/users.d.ts +1 -1
  36. package/dist/hooks/useClickAway.d.ts +2 -1
  37. package/dist/hooks/useConfig.d.ts +4 -2
  38. package/dist/hooks/useCrudContext.d.ts +11 -10
  39. package/dist/hooks/useInput.d.ts +4 -3
  40. package/dist/hooks/useRegistry.d.ts +29 -29
  41. package/dist/hooks/useSetState.d.ts +6 -1
  42. package/dist/hooks/useVocabulary.d.ts +1 -1
  43. package/dist/lib/auth.d.ts +14 -19
  44. package/dist/lib/client.d.ts +49 -36
  45. package/dist/lib/helpers.d.ts +10 -18
  46. package/dist/lib/processResponse.d.ts +9 -0
  47. package/dist/lib/rest.d.ts +9 -16
  48. package/dist/lib/utils.d.ts +3 -2
  49. package/dist/lib/validators.d.ts +1 -1
  50. package/dist/locales/generic_messages.d.ts +248 -370
  51. package/dist/models/index.d.ts +5 -5
  52. package/dist/models/sharing.d.ts +5 -5
  53. package/dist/react-gmi.esm.js +1182 -905
  54. package/dist/react-gmi.esm.js.map +1 -1
  55. package/dist/react-gmi.js +1181 -905
  56. package/dist/react-gmi.js.map +1 -1
  57. package/dist/react-gmi.modern.js +1155 -852
  58. package/dist/react-gmi.modern.js.map +1 -1
  59. package/dist/react-gmi.umd.js +1181 -905
  60. package/dist/react-gmi.umd.js.map +1 -1
  61. package/dist/reducers/guillotina.d.ts +22 -8
  62. package/dist/types/global.d.ts +9 -0
  63. package/dist/types/guillotina.d.ts +192 -44
  64. package/dist/views/folder.d.ts +1 -1
  65. package/dist/views/groups.d.ts +1 -1
  66. package/dist/views/item.d.ts +1 -1
  67. package/dist/views/users.d.ts +1 -1
  68. package/package.json +3 -2
  69. package/dist/lib/search.test.d.ts +0 -1
  70. package/dist/setupTests.d.ts +0 -1
package/dist/react-gmi.js CHANGED
@@ -111,6 +111,97 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
111
111
  return it.next.bind(it);
112
112
  }
113
113
 
114
+ var initialState = {
115
+ path: '',
116
+ loading: false,
117
+ context: undefined,
118
+ flash: {
119
+ message: undefined,
120
+ type: undefined
121
+ },
122
+ action: {
123
+ action: undefined,
124
+ params: undefined
125
+ },
126
+ permissions: [],
127
+ errorStatus: undefined,
128
+ registry: {},
129
+ refresh: undefined
130
+ };
131
+ var GuillotinaReducerActionTypes;
132
+
133
+ (function (GuillotinaReducerActionTypes) {
134
+ GuillotinaReducerActionTypes["SET_PATH"] = "SET_PATH";
135
+ GuillotinaReducerActionTypes["SET_CONTEXT"] = "SET_CONTEXT";
136
+ GuillotinaReducerActionTypes["SET_ERROR"] = "SET_ERROR";
137
+ GuillotinaReducerActionTypes["SET_FLASH"] = "SET_FLASH";
138
+ GuillotinaReducerActionTypes["CLEAR_FLASH"] = "CLEAR_FLASH";
139
+ GuillotinaReducerActionTypes["SET_ACTION"] = "SET_ACTION";
140
+ GuillotinaReducerActionTypes["CLEAR_ACTION"] = "CLEAR_ACTION";
141
+ GuillotinaReducerActionTypes["REFRESH"] = "REFRESH";
142
+ GuillotinaReducerActionTypes["APPLY"] = "APPLY";
143
+ })(GuillotinaReducerActionTypes || (GuillotinaReducerActionTypes = {}));
144
+
145
+ function guillotinaReducer(state, action) {
146
+ switch (action.type) {
147
+ case GuillotinaReducerActionTypes.SET_PATH:
148
+ return _extends({}, state, {
149
+ path: action.payload.path,
150
+ loading: true
151
+ });
152
+
153
+ case GuillotinaReducerActionTypes.SET_CONTEXT:
154
+ return _extends({}, state, action.payload, {
155
+ errorStatus: undefined,
156
+ loading: false
157
+ });
158
+
159
+ case GuillotinaReducerActionTypes.SET_ERROR:
160
+ return _extends({}, state, {
161
+ errorStatus: action.payload.errorStatus,
162
+ loading: false
163
+ });
164
+
165
+ case GuillotinaReducerActionTypes.SET_FLASH:
166
+ return _extends({}, state, action.payload);
167
+
168
+ case GuillotinaReducerActionTypes.CLEAR_FLASH:
169
+ return _extends({}, state, {
170
+ flash: {
171
+ message: undefined,
172
+ type: undefined
173
+ }
174
+ });
175
+
176
+ case GuillotinaReducerActionTypes.SET_ACTION:
177
+ return _extends({}, state, {
178
+ action: action.payload
179
+ });
180
+
181
+ case GuillotinaReducerActionTypes.CLEAR_ACTION:
182
+ return _extends({}, state, {
183
+ action: {
184
+ action: undefined,
185
+ params: undefined
186
+ }
187
+ });
188
+
189
+ case GuillotinaReducerActionTypes.REFRESH:
190
+ return _extends({}, state, {
191
+ refresh: Date.now(),
192
+ loading: !action.payload.transparent
193
+ });
194
+
195
+ case GuillotinaReducerActionTypes.APPLY:
196
+ return _extends({}, state, {
197
+ context: _extends({}, state.context, action.payload.context)
198
+ });
199
+
200
+ default:
201
+ return state;
202
+ }
203
+ }
204
+
114
205
  var AuthContext = React.createContext({});
115
206
  var ClientContext = React.createContext(null);
116
207
  var Traversal = /*#__PURE__*/function () {
@@ -141,7 +232,7 @@ var Traversal = /*#__PURE__*/function () {
141
232
  transparent = _ref2$transparent === void 0 ? false : _ref2$transparent;
142
233
 
143
234
  this.dispatch({
144
- type: 'REFRESH',
235
+ type: GuillotinaReducerActionTypes.REFRESH,
145
236
  payload: {
146
237
  transparent: transparent
147
238
  }
@@ -149,15 +240,18 @@ var Traversal = /*#__PURE__*/function () {
149
240
  };
150
241
 
151
242
  _proto.apply = function apply(data) {
243
+ // apply a optimistic update to context
152
244
  this.dispatch({
153
- type: 'APPLY',
154
- payload: data
245
+ type: GuillotinaReducerActionTypes.APPLY,
246
+ payload: {
247
+ context: data
248
+ }
155
249
  });
156
250
  };
157
251
 
158
252
  _proto.flash = function flash(message, type) {
159
253
  this.dispatch({
160
- type: 'SET_FLASH',
254
+ type: GuillotinaReducerActionTypes.SET_FLASH,
161
255
  payload: {
162
256
  flash: {
163
257
  message: message,
@@ -174,7 +268,8 @@ var Traversal = /*#__PURE__*/function () {
174
268
 
175
269
  _proto.clearFlash = function clearFlash() {
176
270
  this.dispatch({
177
- type: 'CLEAR_FLASH'
271
+ type: GuillotinaReducerActionTypes.CLEAR_FLASH,
272
+ payload: {}
178
273
  });
179
274
  };
180
275
 
@@ -184,7 +279,7 @@ var Traversal = /*#__PURE__*/function () {
184
279
  }
185
280
 
186
281
  this.dispatch({
187
- type: 'SET_ACTION',
282
+ type: GuillotinaReducerActionTypes.SET_ACTION,
188
283
  payload: {
189
284
  action: action,
190
285
  params: params
@@ -194,7 +289,8 @@ var Traversal = /*#__PURE__*/function () {
194
289
 
195
290
  _proto.cancelAction = function cancelAction() {
196
291
  this.dispatch({
197
- type: 'CLEAR_ACTION'
292
+ type: GuillotinaReducerActionTypes.CLEAR_ACTION,
293
+ payload: {}
198
294
  });
199
295
  };
200
296
 
@@ -231,6 +327,10 @@ var Traversal = /*#__PURE__*/function () {
231
327
  }, {
232
328
  key: "context",
233
329
  get: function get() {
330
+ if (this.state.context === undefined) {
331
+ throw new Error('Context is not loaded');
332
+ }
333
+
234
334
  return this.state.context;
235
335
  }
236
336
  }, {
@@ -253,7 +353,13 @@ function TraversalProvider(_ref3) {
253
353
  });
254
354
  }
255
355
  function useTraversal() {
256
- return React.useContext(TraversalContext);
356
+ var traversal = React.useContext(TraversalContext);
357
+
358
+ if (!traversal) {
359
+ throw new Error('useTraversal must be used within a TraversalProvider');
360
+ }
361
+
362
+ return traversal;
257
363
  }
258
364
  function ClientProvider(_ref4) {
259
365
  var children = _ref4.children,
@@ -264,7 +370,13 @@ function ClientProvider(_ref4) {
264
370
  });
265
371
  }
266
372
  function useGuillotinaClient() {
267
- return React.useContext(ClientContext);
373
+ var client = React.useContext(ClientContext);
374
+
375
+ if (!client) {
376
+ throw new Error('useGuillotinaClient must be used within a ClientProvider');
377
+ }
378
+
379
+ return client;
268
380
  }
269
381
 
270
382
  var genericMessages = reactIntl.defineMessages({
@@ -771,8 +883,10 @@ function base64ToArrayBuffer(base64) {
771
883
  return bytes;
772
884
  }
773
885
  function stringToSlug(str) {
774
- str = str.replace(/^\s+|\s+$/g, '');
775
- str = str.toLowerCase();
886
+ str = str.replace(/^\s+|\s+$/g, ''); // trim
887
+
888
+ str = str.toLowerCase(); // remove accents, swap ñ for n, etc
889
+
776
890
  var from = 'àáäâèéëêìíïîòóöôùúüûñç·/_,:;';
777
891
  var to = 'aaaaeeeeiiiioooouuuunc------';
778
892
 
@@ -780,13 +894,16 @@ function stringToSlug(str) {
780
894
  str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
781
895
  }
782
896
 
783
- str = str.replace(/[^a-z0-9 -]/g, '').replace(/\s+/g, '-').replace(/-+/g, '-');
897
+ str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
898
+ .replace(/\s+/g, '-') // collapse whitespace and replace by -
899
+ .replace(/-+/g, '-'); // collapse dashes
900
+
784
901
  return str;
785
902
  }
786
903
  function sleep(ms) {
787
904
  return new Promise(function (resolve) {
788
905
  setTimeout(function () {
789
- resolve(null);
906
+ resolve();
790
907
  }, ms);
791
908
  });
792
909
  }
@@ -815,8 +932,6 @@ var getActionsObject = function getActionsObject(intl, multiple) {
815
932
  };
816
933
 
817
934
  var Button = function Button(_ref) {
818
- var _ref2;
819
-
820
935
  var children = _ref.children,
821
936
  _ref$className = _ref.className,
822
937
  className = _ref$className === void 0 ? 'is-primary' : _ref$className,
@@ -828,9 +943,7 @@ var Button = function Button(_ref) {
828
943
  _ref$disabled = _ref.disabled,
829
944
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
830
945
  dataTest = _ref.dataTest;
831
-
832
- var css = (_ref2 = []).concat.apply(_ref2, ['button'].concat(className.split(' ')));
833
-
946
+ var css = [].concat(className.split(' '), ['button']);
834
947
  if (loading) css = css.concat('is-loading');
835
948
  return jsxRuntime.jsx("p", {
836
949
  className: "control",
@@ -845,6 +958,50 @@ var Button = function Button(_ref) {
845
958
  });
846
959
  };
847
960
 
961
+ var formatDate = function formatDate(str) {
962
+ var d = new Date(str);
963
+ var minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
964
+ return d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear() + " " + d.getHours() + ":" + minutes;
965
+ };
966
+ var get = function get(obj, path, defValue) {
967
+ var _pathArray$reduce;
968
+
969
+ // If path is not defined or it has false value
970
+ if (!path) return defValue; // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.
971
+ // Regex explained: https://regexr.com/58j0k
972
+
973
+ var pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g); // Find value if exist return otherwise return undefined value;
974
+
975
+ if (pathArray === null) return defValue;
976
+ return (_pathArray$reduce = pathArray.reduce(function (prevObj, key) {
977
+ return prevObj && prevObj[key];
978
+ }, obj)) != null ? _pathArray$reduce : defValue;
979
+ };
980
+ function getNewId(id) {
981
+ if (id === void 0) {
982
+ id = '';
983
+ }
984
+
985
+ var suffix = '-copy-';
986
+ var rgx = new RegExp("($|" + suffix + "\\d*)");
987
+ return stringToSlug(id).replace(rgx, function (r) {
988
+ var num = parseInt(r.replace(suffix, '') || '0');
989
+ return "" + suffix + (num + 1);
990
+ });
991
+ }
992
+ function debounce(callback, wait) {
993
+ var timer;
994
+ return function () {
995
+ var _arguments = arguments;
996
+ clearTimeout(timer);
997
+ return new Promise(function (resolve) {
998
+ timer = setTimeout(function () {
999
+ return resolve(callback.apply(void 0, [].slice.call(_arguments)));
1000
+ }, wait);
1001
+ });
1002
+ };
1003
+ }
1004
+
848
1005
  function Modal(props) {
849
1006
  var isActive = props.isActive,
850
1007
  setActive = props.setActive,
@@ -924,7 +1081,8 @@ function Confirm(_ref) {
924
1081
  })]
925
1082
  })]
926
1083
  });
927
- }
1084
+ } // @todo Improve it... Replacing the inputText to a tree
1085
+
928
1086
  function PathTree(_ref2) {
929
1087
  var title = _ref2.title,
930
1088
  defaultPath = _ref2.defaultPath,
@@ -940,7 +1098,7 @@ function PathTree(_ref2) {
940
1098
  }), jsxRuntime.jsxs("form", {
941
1099
  onSubmit: function onSubmit(e) {
942
1100
  e.preventDefault();
943
- onConfirm(e.target[0].value, e.target);
1101
+ onConfirm(get(e, 'target.0.value', ''), e.target);
944
1102
  },
945
1103
  children: [jsxRuntime.jsx("small", {
946
1104
  style: {
@@ -972,51 +1130,6 @@ function PathTree(_ref2) {
972
1130
  });
973
1131
  }
974
1132
 
975
- function useSetState(initialState) {
976
- var _useState = React.useState(initialState),
977
- state = _useState[0],
978
- set = _useState[1];
979
-
980
- var setState = React.useCallback(function (patch) {
981
- set(function (prevState) {
982
- return Object.assign({}, prevState, patch instanceof Function ? patch(prevState) : patch);
983
- });
984
- }, [set]);
985
- return [state, setState];
986
- }
987
-
988
- function _catch(body, recover) {
989
- try {
990
- var result = body();
991
- } catch (e) {
992
- return recover(e);
993
- }
994
-
995
- if (result && result.then) {
996
- return result.then(void 0, recover);
997
- }
998
-
999
- return result;
1000
- }
1001
-
1002
- var initial = {
1003
- loading: undefined,
1004
- isError: false,
1005
- errorMessage: undefined,
1006
- result: undefined,
1007
- response: undefined
1008
- };
1009
-
1010
- var getErrorMessage = function getErrorMessage(dataError, defaultValue) {
1011
- if (dataError && dataError.details) {
1012
- return dataError.details;
1013
- } else if (dataError && dataError.reason) {
1014
- return dataError.reason;
1015
- }
1016
-
1017
- return defaultValue;
1018
- };
1019
-
1020
1133
  var processResponse = function processResponse(res, ready_body) {
1021
1134
  if (ready_body === void 0) {
1022
1135
  ready_body = true;
@@ -1036,7 +1149,7 @@ var processResponse = function processResponse(res, ready_body) {
1036
1149
  return {
1037
1150
  isError: true,
1038
1151
  loading: false,
1039
- errorMessage: getErrorMessage(_res$json2, res.status),
1152
+ errorMessage: getErrorMessage(_res$json2, res.status).toString(),
1040
1153
  response: res
1041
1154
  };
1042
1155
  });
@@ -1045,10 +1158,66 @@ var processResponse = function processResponse(res, ready_body) {
1045
1158
  }
1046
1159
  };
1047
1160
 
1048
- var patch = function patch(setState, Ctx) {
1161
+ var getErrorMessage = function getErrorMessage(dataError, defaultValue) {
1162
+ if (dataError && dataError.details) {
1163
+ return dataError.details;
1164
+ } else if (dataError && dataError.reason) {
1165
+ return dataError.reason;
1166
+ }
1167
+
1168
+ return defaultValue;
1169
+ };
1170
+
1171
+ /**
1172
+ * Do setState like react class component.
1173
+ */
1174
+
1175
+ function useSetState(initialState) {
1176
+ var _useState = React.useState(initialState),
1177
+ state = _useState[0],
1178
+ setState = _useState[1]; // Function which accepts a partial state to merge
1179
+
1180
+
1181
+ var setCustomState = React.useCallback(function (newPartialState) {
1182
+ try {
1183
+ setState(function (prevState) {
1184
+ return _extends({}, prevState, newPartialState);
1185
+ });
1186
+ } catch (error) {
1187
+ // eslint-disable-next-line no-console
1188
+ console.error(error);
1189
+ }
1190
+ }, []); // Return
1191
+
1192
+ return [state, setCustomState];
1193
+ } // **** Export Default **** //
1194
+
1195
+ function _catch(body, recover) {
1196
+ try {
1197
+ var result = body();
1198
+ } catch (e) {
1199
+ return recover(e);
1200
+ }
1201
+
1202
+ if (result && result.then) {
1203
+ return result.then(void 0, recover);
1204
+ }
1205
+
1206
+ return result;
1207
+ }
1208
+
1209
+ var initial = {
1210
+ loading: undefined,
1211
+ isError: false,
1212
+ errorMessage: undefined,
1213
+ result: undefined,
1214
+ response: undefined
1215
+ };
1216
+
1217
+ function patch(setState, Ctx) {
1049
1218
  return function (data, endpoint, body) {
1050
- if (endpoint === void 0) {
1051
- endpoint = undefined;
1219
+ if (data === void 0) {
1220
+ data = {};
1052
1221
  }
1053
1222
 
1054
1223
  if (body === void 0) {
@@ -1056,7 +1225,7 @@ var patch = function patch(setState, Ctx) {
1056
1225
  }
1057
1226
 
1058
1227
  try {
1059
- function _temp5() {
1228
+ function _temp3() {
1060
1229
  setState(newState);
1061
1230
  return newState;
1062
1231
  }
@@ -1066,7 +1235,7 @@ var patch = function patch(setState, Ctx) {
1066
1235
  });
1067
1236
  var newState = {};
1068
1237
 
1069
- var _temp6 = _catch(function () {
1238
+ var _temp4 = _catch(function () {
1070
1239
  var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
1071
1240
  return Promise.resolve(Ctx.client.patch(path, data)).then(function (res) {
1072
1241
  return Promise.resolve(processResponse(res, body)).then(function (_processResponse) {
@@ -1081,29 +1250,25 @@ var patch = function patch(setState, Ctx) {
1081
1250
  };
1082
1251
  });
1083
1252
 
1084
- return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp5) : _temp5(_temp6));
1253
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
1085
1254
  } catch (e) {
1086
1255
  return Promise.reject(e);
1087
1256
  }
1088
1257
  };
1089
- };
1258
+ }
1090
1259
 
1091
- var del = function del(setState, Ctx) {
1260
+ function del(setState, Ctx) {
1092
1261
  return function (data, endpoint, body) {
1093
1262
  if (data === void 0) {
1094
1263
  data = {};
1095
1264
  }
1096
1265
 
1097
- if (endpoint === void 0) {
1098
- endpoint = undefined;
1099
- }
1100
-
1101
1266
  if (body === void 0) {
1102
1267
  body = false;
1103
1268
  }
1104
1269
 
1105
1270
  try {
1106
- function _temp9() {
1271
+ function _temp7() {
1107
1272
  setState(newState);
1108
1273
  return newState;
1109
1274
  }
@@ -1113,7 +1278,7 @@ var del = function del(setState, Ctx) {
1113
1278
  });
1114
1279
  var newState = {};
1115
1280
 
1116
- var _temp10 = _catch(function () {
1281
+ var _temp8 = _catch(function () {
1117
1282
  var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
1118
1283
  return Promise.resolve(Ctx.client.delete(path, data)).then(function (res) {
1119
1284
  return Promise.resolve(processResponse(res, body)).then(function (_processResponse2) {
@@ -1128,17 +1293,17 @@ var del = function del(setState, Ctx) {
1128
1293
  };
1129
1294
  });
1130
1295
 
1131
- return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(_temp9) : _temp9(_temp10));
1296
+ return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8));
1132
1297
  } catch (e) {
1133
1298
  return Promise.reject(e);
1134
1299
  }
1135
1300
  };
1136
- };
1301
+ }
1137
1302
 
1138
- var post = function post(setState, Ctx) {
1303
+ function post(setState, Ctx) {
1139
1304
  return function (data, endpoint, body) {
1140
- if (endpoint === void 0) {
1141
- endpoint = undefined;
1305
+ if (data === void 0) {
1306
+ data = {};
1142
1307
  }
1143
1308
 
1144
1309
  if (body === void 0) {
@@ -1146,7 +1311,7 @@ var post = function post(setState, Ctx) {
1146
1311
  }
1147
1312
 
1148
1313
  try {
1149
- function _temp13() {
1314
+ function _temp11() {
1150
1315
  setState(newState);
1151
1316
  return newState;
1152
1317
  }
@@ -1156,7 +1321,7 @@ var post = function post(setState, Ctx) {
1156
1321
  });
1157
1322
  var newState = {};
1158
1323
 
1159
- var _temp14 = _catch(function () {
1324
+ var _temp12 = _catch(function () {
1160
1325
  var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
1161
1326
  return Promise.resolve(Ctx.client.post(path, data)).then(function (res) {
1162
1327
  return Promise.resolve(processResponse(res, body)).then(function (_processResponse3) {
@@ -1171,21 +1336,17 @@ var post = function post(setState, Ctx) {
1171
1336
  };
1172
1337
  });
1173
1338
 
1174
- return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(_temp13) : _temp13(_temp14));
1339
+ return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(_temp11) : _temp11(_temp12));
1175
1340
  } catch (e) {
1176
1341
  return Promise.reject(e);
1177
1342
  }
1178
1343
  };
1179
- };
1344
+ }
1180
1345
 
1181
- var get = function get(setState, Ctx) {
1346
+ function get$1(setState, Ctx) {
1182
1347
  return function (endpoint) {
1183
- if (endpoint === void 0) {
1184
- endpoint = undefined;
1185
- }
1186
-
1187
1348
  try {
1188
- function _temp17() {
1349
+ function _temp15() {
1189
1350
  setState(newState);
1190
1351
  return newState;
1191
1352
  }
@@ -1195,7 +1356,7 @@ var get = function get(setState, Ctx) {
1195
1356
  });
1196
1357
  var newState = {};
1197
1358
 
1198
- var _temp18 = _catch(function () {
1359
+ var _temp16 = _catch(function () {
1199
1360
  var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
1200
1361
  return Promise.resolve(Ctx.client.get(path)).then(function (res) {
1201
1362
  return Promise.resolve(processResponse(res, true)).then(function (_processResponse4) {
@@ -1210,12 +1371,16 @@ var get = function get(setState, Ctx) {
1210
1371
  };
1211
1372
  });
1212
1373
 
1213
- return Promise.resolve(_temp18 && _temp18.then ? _temp18.then(_temp17) : _temp17(_temp18));
1374
+ return Promise.resolve(_temp16 && _temp16.then ? _temp16.then(_temp15) : _temp15(_temp16));
1214
1375
  } catch (e) {
1215
1376
  return Promise.reject(e);
1216
1377
  }
1217
1378
  };
1218
- };
1379
+ } // const get = (
1380
+ // setState: (value: Partial<State>) => void,
1381
+ // Ctx: Traversal
1382
+ // ) =>
1383
+
1219
1384
 
1220
1385
  function useCrudContext() {
1221
1386
  var Ctx = useTraversal();
@@ -1229,7 +1394,7 @@ function useCrudContext() {
1229
1394
  patch: patch(setState, Ctx),
1230
1395
  del: del(setState, Ctx),
1231
1396
  post: post(setState, Ctx),
1232
- get: get(setState, Ctx)
1397
+ get: get$1(setState, Ctx)
1233
1398
  });
1234
1399
  }
1235
1400
 
@@ -1277,9 +1442,6 @@ function AddItem(props) {
1277
1442
  children: jsxRuntime.jsx(Form, {
1278
1443
  loading: loading,
1279
1444
  onSubmit: doSubmit,
1280
- onError: function onError(err) {
1281
- return console.log(err);
1282
- },
1283
1445
  actionName: 'Add ' + type,
1284
1446
  title: 'Add ' + type,
1285
1447
  type: type,
@@ -1289,31 +1451,52 @@ function AddItem(props) {
1289
1451
  }
1290
1452
 
1291
1453
  var Permissions = ['guillotina.AddContent', 'guillotina.ModifyContent', 'guillotina.ViewContent', 'guillotina.DeleteContent', 'guillotina.AccessContent', 'guillotina.SeePermissions', 'guillotina.ChangePermissions', 'guillotina.MoveContent', 'guillotina.DuplicateContent', 'guillotina.ReadConfiguration', 'guillotina.RegisterConfigurations', 'guillotina.WriteConfiguration', 'guillotina.ManageAddons', 'guillotina.swagger.View'];
1292
- var Config = {
1454
+ var defaultConfig = {
1293
1455
  DisabledTypes: ['UserManager', 'GroupManager'],
1294
1456
  PageSize: 10,
1295
1457
  DelayActions: 200,
1296
1458
  Permissions: Permissions,
1297
1459
  SearchEngine: 'PostreSQL',
1460
+ // Elasticsearch
1298
1461
  fieldHaveDeleteButton: function fieldHaveDeleteButton(schema) {
1299
1462
  return (schema == null ? void 0 : schema.widget) === 'file' || (schema == null ? void 0 : schema.widget) === 'select' || (schema == null ? void 0 : schema.type) === 'array';
1300
1463
  }
1301
1464
  };
1302
- var calculated = Object.assign({}, Config);
1303
-
1304
- var addConfig = function addConfig(additional, original) {
1305
- var rest = Object.assign({}, original);
1306
- Object.keys(additional).forEach(function (item) {
1307
- if (typeof Config[item] === 'object' && Array.isArray(Config[item])) {
1308
- rest[item] = [].concat(Config[item], additional[item]);
1309
- } else if (typeof Config[item] === 'object') {
1310
- rest[item] = Object.assign({}, Config[item], additional[item]);
1465
+ var calculated = Object.assign({}, defaultConfig);
1466
+
1467
+ function addConfig(updates, currentConfig) {
1468
+ var updatedConfig = _extends({}, currentConfig);
1469
+
1470
+ Object.entries(updates).forEach(function (_ref) {
1471
+ var key = _ref[0],
1472
+ value = _ref[1];
1473
+ var currentKey = key;
1474
+ var currentValue = currentConfig[currentKey];
1475
+
1476
+ if (Array.isArray(value) && Array.isArray(currentValue)) {
1477
+ var _extends2;
1478
+
1479
+ // Correctly type the array concatenation
1480
+ updatedConfig = _extends({}, updatedConfig, (_extends2 = {}, _extends2[currentKey] = [].concat(currentValue, value), _extends2));
1481
+ } else if (isPlainObject(value) && isPlainObject(currentValue)) {
1482
+ var _extends3;
1483
+
1484
+ // Correctly type the object merging
1485
+ updatedConfig = _extends({}, updatedConfig, (_extends3 = {}, _extends3[currentKey] = _extends({}, currentValue, value), _extends3));
1311
1486
  } else {
1312
- rest[item] = additional[item];
1487
+ var _extends4;
1488
+
1489
+ // Directly assign all other types
1490
+ updatedConfig = _extends({}, updatedConfig, (_extends4 = {}, _extends4[currentKey] = value, _extends4));
1313
1491
  }
1314
1492
  });
1315
- return rest;
1316
- };
1493
+ return updatedConfig;
1494
+ } // Helper function to check if a value is a plain object (and not a React node, etc.)
1495
+
1496
+
1497
+ function isPlainObject(value) {
1498
+ return Object.prototype.toString.call(value) === '[object Object]';
1499
+ }
1317
1500
 
1318
1501
  function useConfig(cfg) {
1319
1502
  if (cfg === void 0) {
@@ -1337,7 +1520,7 @@ function RemoveItems(props) {
1337
1520
  setLoading(true);
1338
1521
  var actions = items.map(function (item) {
1339
1522
  try {
1340
- return Promise.resolve(Ctx.client.delete("" + Ctx.path + item['@name'])).then(function (res) {
1523
+ return Promise.resolve(Ctx.client.delete("" + Ctx.path + item.id, {})).then(function (res) {
1341
1524
  var _temp = function () {
1342
1525
  if (!res.ok) {
1343
1526
  return Promise.resolve(res.json()).then(function (err) {
@@ -1351,7 +1534,9 @@ function RemoveItems(props) {
1351
1534
  } catch (e) {
1352
1535
  return Promise.reject(e);
1353
1536
  }
1354
- });
1537
+ }); // this sleep is here, to let elasticsearch, wait for
1538
+ // index our operations... (will work 99% of use cases)
1539
+
1355
1540
  actions.push(sleep(cfg.DelayActions));
1356
1541
  return Promise.resolve(Promise.all(actions)).then(function () {
1357
1542
  if (errors.length === 0) {
@@ -1381,9 +1566,9 @@ function RemoveItems(props) {
1381
1566
 
1382
1567
  var _props$items = props.items,
1383
1568
  items = _props$items === void 0 ? [] : _props$items;
1384
- var last = items[items.length - 1]['@name'];
1569
+ var last = items[items.length - 1].id;
1385
1570
  var itemsNames = items.map(function (item) {
1386
- return item['@name'];
1571
+ return item.id;
1387
1572
  }).join(', ').replace(", " + last, " and " + last);
1388
1573
  return jsxRuntime.jsx(Confirm, {
1389
1574
  loading: loading,
@@ -1410,7 +1595,7 @@ var Checkbox = function Checkbox(_ref) {
1410
1595
  dataTest = _ref.dataTest;
1411
1596
  var inputRef = React.useRef(null);
1412
1597
 
1413
- var _useState = React.useState(checked),
1598
+ var _useState = React.useState(!!checked),
1414
1599
  state = _useState[0],
1415
1600
  setState = _useState[1];
1416
1601
 
@@ -1429,13 +1614,13 @@ var Checkbox = function Checkbox(_ref) {
1429
1614
  className: "field",
1430
1615
  children: jsxRuntime.jsxs("label", {
1431
1616
  htmlFor: id,
1432
- className: classnames(['checkbox', className]),
1617
+ className: classnames(['checkbox', className != null ? className : '']),
1433
1618
  children: [jsxRuntime.jsx("input", {
1434
1619
  ref: inputRef,
1435
1620
  disabled: disabled || loading,
1436
1621
  id: id,
1437
1622
  type: "checkbox",
1438
- className: classnames(['checkbox', classNameInput]),
1623
+ className: classnames(['checkbox', classNameInput != null ? classNameInput : '']),
1439
1624
  checked: state,
1440
1625
  onChange: updateState,
1441
1626
  "data-test": dataTest
@@ -1473,7 +1658,7 @@ var applyValidators = function applyValidators(value, validators) {
1473
1658
  return result;
1474
1659
  };
1475
1660
 
1476
- var useInput = function useInput(onChange, value, validator) {
1661
+ var useInput = function useInput(onChange, value, validators) {
1477
1662
  var _useState = React.useState({
1478
1663
  hasError: false,
1479
1664
  value: value
@@ -1482,7 +1667,7 @@ var useInput = function useInput(onChange, value, validator) {
1482
1667
  setState = _useState[1];
1483
1668
 
1484
1669
  var onUpdate = function onUpdate(ev) {
1485
- var value = ev && ev.target ? ev.target.value : ev ? ev : '';
1670
+ var value = ev && ev.target ? ev.target.value : '';
1486
1671
  setState({
1487
1672
  value: value,
1488
1673
  hasError: false
@@ -1491,7 +1676,7 @@ var useInput = function useInput(onChange, value, validator) {
1491
1676
  };
1492
1677
 
1493
1678
  var onBlur = function onBlur() {
1494
- var hasError = applyValidators(state.value, validator) === false;
1679
+ var hasError = applyValidators(state.value, validators) === false;
1495
1680
  if (hasError) setState({
1496
1681
  value: state.value,
1497
1682
  hasError: hasError
@@ -1521,6 +1706,9 @@ var useInput = function useInput(onChange, value, validator) {
1521
1706
  };
1522
1707
  };
1523
1708
 
1709
+ // From github.com/protonmail/proton-shared
1710
+
1711
+ /* eslint-disable no-useless-escape */
1524
1712
  var REGEX_EMAIL = /(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/i;
1525
1713
  var REGEX_URL = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/;
1526
1714
  var REGEX_HEX_COLOR = /^#([a-f0-9]{3,4}|[a-f0-9]{4}(?:[a-f0-9]{2}){1,2})\b$/i;
@@ -1621,10 +1809,10 @@ var Input = React.forwardRef(function (_ref, ref) {
1621
1809
  dataTest = _ref$dataTest === void 0 ? 'testInput' : _ref$dataTest,
1622
1810
  disabled = _ref.disabled,
1623
1811
  onKeyUp = _ref.onKeyUp;
1624
- var validatorFn = null;
1812
+ var validatorFn = [];
1625
1813
 
1626
1814
  if (required) {
1627
- validatorFn = Array.isArray(validator) ? validator.push(notEmpty) : [validator, notEmpty];
1815
+ validatorFn = Array.isArray(validator) ? [].concat(validator, [notEmpty]) : [validator, notEmpty];
1628
1816
  }
1629
1817
 
1630
1818
  var _useInput = useInput(onChange, value != null ? value : '', validatorFn),
@@ -1636,17 +1824,18 @@ var Input = React.forwardRef(function (_ref, ref) {
1636
1824
 
1637
1825
  var _useState2 = React.useState(false),
1638
1826
  mounted = _useState2[0],
1639
- setMounted = _useState2[1];
1827
+ setMounted = _useState2[1]; // eslint-disable-next-line
1828
+
1640
1829
 
1641
- ref = ref || React.useRef();
1830
+ var newRef = ref || React.useRef();
1642
1831
  React.useEffect(function () {
1643
1832
  setMounted(true);
1644
1833
  }, []);
1645
1834
  React.useEffect(function () {
1646
- if (autofocus && !error && ref != null && typeof ref !== 'function') {
1647
- ref.current.focus();
1835
+ if (autofocus && !error && newRef != null && typeof newRef !== 'function' && newRef.current) {
1836
+ newRef.current.focus();
1648
1837
  }
1649
- }, [mounted, autofocus, ref, error]);
1838
+ }, [mounted, autofocus, newRef, error]);
1650
1839
  var theError = state.hasError ? errorMessage || 'invalid field' : '';
1651
1840
  var statusClasses = state.hasError ? 'is-danger' : '';
1652
1841
 
@@ -1687,7 +1876,8 @@ Input.displayName = 'Input';
1687
1876
 
1688
1877
  var Icon = function Icon(_ref) {
1689
1878
  var icon = _ref.icon,
1690
- className = _ref.className,
1879
+ _ref$className = _ref.className,
1880
+ className = _ref$className === void 0 ? '' : _ref$className,
1691
1881
  align = _ref.align;
1692
1882
  var addClass = className ? className.split(' ') : [className];
1693
1883
  align = align || 'is-right';
@@ -1798,24 +1988,26 @@ function FormBuilder(_ref) {
1798
1988
  remotes = _ref$remotes === void 0 ? {} : _ref$remotes,
1799
1989
  _ref$submitButton = _ref.submitButton,
1800
1990
  submitButton = _ref$submitButton === void 0 ? true : _ref$submitButton;
1801
- var ref = React.useRef();
1991
+ var ref = React.useRef(null);
1802
1992
  var properties = schema.properties,
1803
1993
  required = schema.required;
1804
- var values = Object.assign({}, formData || {});
1994
+ var values = Object.assign({}, formData || {}); // build initial state
1995
+
1805
1996
  var initialState = {};
1806
1997
  var fields = Object.keys(properties).filter(function (x) {
1807
1998
  return !exclude.includes(x);
1808
1999
  });
1809
2000
  fields.forEach(function (element) {
1810
2001
  initialState[element] = values[element] || undefined;
1811
- });
2002
+ }); // Register remotes
1812
2003
 
1813
- if (!ref.current) {
2004
+ if (ref.current === null) {
1814
2005
  ref.current = {};
1815
2006
  Object.keys(remotes).forEach(function (item) {
1816
2007
  return ref.current[item] = remotes[item];
1817
2008
  });
1818
2009
  } else {
2010
+ // apply remote changes
1819
2011
  Object.keys(remotes).forEach(function (key) {
1820
2012
  if (JSON.stringify(ref.current[key]) !== JSON.stringify(remotes[key])) {
1821
2013
  ref.current[key] = remotes[key];
@@ -1826,15 +2018,16 @@ function FormBuilder(_ref) {
1826
2018
  ref.current = ref.current || {};
1827
2019
 
1828
2020
  var onUpdate = function onUpdate(field) {
1829
- return function (ev) {
1830
- ref.current[field] = ev.target ? ev.target.value : ev.value || ev;
2021
+ return function (value) {
2022
+ ref.current[field] = value;
1831
2023
  };
1832
2024
  };
1833
2025
 
1834
2026
  var GetTag = function GetTag(_ref2) {
1835
2027
  var field = _ref2.field;
1836
2028
  var property = properties[field];
1837
- var Tag = formComponents[property.widget || property.type];
2029
+ var key = property.widget || property.type;
2030
+ var Tag = formComponents[key];
1838
2031
  var props = {
1839
2032
  value: initialState[field],
1840
2033
  onChange: onUpdate(field),
@@ -1849,7 +2042,6 @@ function FormBuilder(_ref) {
1849
2042
  props.placeholder += ' *';
1850
2043
  }
1851
2044
 
1852
- Tag.displayName = field + "Field";
1853
2045
  return jsxRuntime.jsx(Tag, _extends({}, props));
1854
2046
  };
1855
2047
 
@@ -1918,9 +2110,13 @@ var Select = React.forwardRef(function (_ref, ref) {
1918
2110
  selectValue = selectValue.concat([ev.target.selectedOptions[i].value]);
1919
2111
  }
1920
2112
 
1921
- onChange(selectValue);
2113
+ if (onChange) {
2114
+ onChange(selectValue);
2115
+ }
1922
2116
  } else {
1923
- onChange(ev.target.value);
2117
+ if (onChange) {
2118
+ onChange(ev.target.value);
2119
+ }
1924
2120
  }
1925
2121
  };
1926
2122
 
@@ -1969,39 +2165,12 @@ var Select = React.forwardRef(function (_ref, ref) {
1969
2165
  });
1970
2166
  Select.displayName = 'Select';
1971
2167
 
1972
- var formatDate = function formatDate(str) {
1973
- var d = new Date(str);
1974
- var minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
1975
- return d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear() + " " + d.getHours() + ":" + minutes;
1976
- };
1977
- var get$1 = function get(obj, path, defValue) {
1978
- var _pathArray$reduce;
1979
-
1980
- if (!path) return undefined;
1981
- var pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
1982
- return (_pathArray$reduce = pathArray.reduce(function (prevObj, key) {
1983
- return prevObj && prevObj[key];
1984
- }, obj)) != null ? _pathArray$reduce : defValue;
1985
- };
1986
- function getNewId(id) {
1987
- if (id === void 0) {
1988
- id = '';
1989
- }
1990
-
1991
- var suffix = '-copy-';
1992
- var rgx = new RegExp("($|" + suffix + "\\d*)");
1993
- return stringToSlug(id).replace(rgx, function (r) {
1994
- var num = parseInt(r.replace(suffix, '') || '0');
1995
- return "" + suffix + (num + 1);
1996
- });
1997
- }
1998
-
1999
- function _catch$1(body, recover) {
2000
- try {
2001
- var result = body();
2002
- } catch (e) {
2003
- return recover(e);
2004
- }
2168
+ function _catch$1(body, recover) {
2169
+ try {
2170
+ var result = body();
2171
+ } catch (e) {
2172
+ return recover(e);
2173
+ }
2005
2174
 
2006
2175
  if (result && result.then) {
2007
2176
  return result.then(void 0, recover);
@@ -2011,10 +2180,6 @@ function _catch$1(body, recover) {
2011
2180
  }
2012
2181
 
2013
2182
  function useVocabulary(vocabularyName, path) {
2014
- if (path === void 0) {
2015
- path = null;
2016
- }
2017
-
2018
2183
  var traversal = useTraversal();
2019
2184
 
2020
2185
  var _useSetState = useSetState({
@@ -2083,8 +2248,10 @@ var SelectVocabulary = React.forwardRef(function (_ref, ref) {
2083
2248
  var vocabulary = useVocabulary(vocabularyName);
2084
2249
 
2085
2250
  var getOptions = function getOptions() {
2086
- if (get$1(vocabulary, 'data.items', null)) {
2087
- var vocData = vocabulary.data.items.map(function (item) {
2251
+ if (get(vocabulary, 'data.items', null)) {
2252
+ var _vocabulary$data$item, _vocabulary$data;
2253
+
2254
+ var vocData = ((_vocabulary$data$item = vocabulary == null ? void 0 : (_vocabulary$data = vocabulary.data) == null ? void 0 : _vocabulary$data.items) != null ? _vocabulary$data$item : []).map(function (item) {
2088
2255
  return {
2089
2256
  text: item.title,
2090
2257
  value: item.token
@@ -2130,6 +2297,8 @@ var SelectVocabulary = React.forwardRef(function (_ref, ref) {
2130
2297
  });
2131
2298
  SelectVocabulary.displayName = 'SelectVocabulary';
2132
2299
 
2300
+ // https://github.com/molefrog/wouter
2301
+
2133
2302
  var setURLParams = function setURLParams(p) {
2134
2303
  return window.history.pushState(0, '0', '' + '?' + p.toString().replace(/%2F/g, '/'));
2135
2304
  };
@@ -2149,7 +2318,10 @@ var useLocation = function useLocation() {
2149
2318
 
2150
2319
  var prevPath = React.useRef(path);
2151
2320
  React.useEffect(function () {
2152
- patchHistoryEvents();
2321
+ patchHistoryEvents(); // this function checks if the location has been changed since the
2322
+ // last render and updates the state only when needed.
2323
+ // unfortunately, we can't rely on `path` value here, since it can be stale,
2324
+ // that's why we store the last pathname in a ref.
2153
2325
 
2154
2326
  var checkForUpdates = function checkForUpdates() {
2155
2327
  var pathname = currentSearchParams();
@@ -2159,14 +2331,22 @@ var useLocation = function useLocation() {
2159
2331
  var events = ['popstate', 'pushState', 'replaceState'];
2160
2332
  events.map(function (e) {
2161
2333
  return window.addEventListener(e, checkForUpdates);
2162
- });
2334
+ }); // it's possible that an update has occurred between render and the effect handler,
2335
+ // so we run additional check on mount to catch these updates. Based on:
2336
+ // https://gist.github.com/bvaughn/e25397f70e8c65b0ae0d7c90b731b189
2337
+
2163
2338
  checkForUpdates();
2164
2339
  return function () {
2165
2340
  events.map(function (e) {
2166
2341
  return window.removeEventListener(e, checkForUpdates);
2167
2342
  });
2168
2343
  };
2169
- }, []);
2344
+ }, []); // the 2nd argument of the `useLocation` return value is a function
2345
+ // that allows to perform a navigation.
2346
+ //
2347
+ // the function reference should stay the same between re-renders, so that
2348
+ // it can be passed down as an element prop without any performance concerns.
2349
+
2170
2350
  var navigate = React.useCallback(function (to, replace) {
2171
2351
  if (replace) {
2172
2352
  clean(to);
@@ -2185,23 +2365,40 @@ var useLocation = function useLocation() {
2185
2365
  setURLParams(current);
2186
2366
  }, [path]);
2187
2367
  return [path, navigate, remove];
2188
- };
2368
+ }; // While History API does have `popstate` event, the only
2369
+ // proper way to listen to changes via `push/replaceState`
2370
+ // is to monkey-patch these methods.
2371
+ //
2372
+ // See https://stackoverflow.com/a/4585031
2373
+
2189
2374
  var patched = 0;
2190
2375
 
2191
2376
  var patchHistoryEvents = function patchHistoryEvents() {
2192
2377
  if (patched) return;
2193
- ['pushState', 'replaceState'].map(function (type) {
2194
- var original = window.history[type];
2195
-
2196
- window.history[type] = function () {
2197
- var args = [].slice.call(arguments);
2198
- var result = original.apply(this, args);
2199
- var event = new Event(type);
2200
- event.arguments = args;
2201
- dispatchEvent(event);
2202
- return result;
2203
- };
2204
- });
2378
+ var originalPushState = window.history.pushState;
2379
+
2380
+ window.history.pushState = function () {
2381
+ var args = [].slice.call(arguments);
2382
+ var result = originalPushState.apply(this, args); // eslint-disable-next-line @typescript-eslint/no-explicit-any
2383
+
2384
+ var event = new Event('pushState');
2385
+ event.arguments = args;
2386
+ dispatchEvent(event);
2387
+ return result;
2388
+ };
2389
+
2390
+ var originalReplaceState = window.history.replaceState;
2391
+
2392
+ window.history.replaceState = function () {
2393
+ var args = [].slice.call(arguments);
2394
+ var result = originalReplaceState.apply(this, args); // eslint-disable-next-line @typescript-eslint/no-explicit-any
2395
+
2396
+ var event = new Event('replaceState');
2397
+ event.arguments = args;
2398
+ dispatchEvent(event);
2399
+ return result;
2400
+ };
2401
+
2205
2402
  return patched = 1;
2206
2403
  };
2207
2404
 
@@ -2256,7 +2453,7 @@ function TdLink(_ref) {
2256
2453
  children = _ref.children,
2257
2454
  _ref$style = _ref.style,
2258
2455
  style = _ref$style === void 0 ? {} : _ref$style;
2259
- var link = React.useRef();
2456
+ var link = React.useRef(null);
2260
2457
 
2261
2458
  function onClick() {
2262
2459
  if (link && link.current) {
@@ -2363,15 +2560,7 @@ var RestClient = /*#__PURE__*/function () {
2363
2560
 
2364
2561
  var _proto = RestClient.prototype;
2365
2562
 
2366
- _proto.request = function request(path, data, headers) {
2367
- if (data === void 0) {
2368
- data = undefined;
2369
- }
2370
-
2371
- if (headers === void 0) {
2372
- headers = undefined;
2373
- }
2374
-
2563
+ _proto.request = function request(path, data, headers, signal) {
2375
2564
  try {
2376
2565
  var _this2 = this;
2377
2566
 
@@ -2387,9 +2576,18 @@ var RestClient = /*#__PURE__*/function () {
2387
2576
  path = "/" + path;
2388
2577
  }
2389
2578
 
2390
- data = data || {};
2391
- data.headers = headers || _this2.getHeaders();
2392
- return Promise.resolve(fetch("" + _this2.url + path, data));
2579
+ var dataRequest = data || {};
2580
+ dataRequest.headers = _this2.getHeaders();
2581
+
2582
+ if (headers) {
2583
+ dataRequest.headers = _extends({}, dataRequest.headers, headers);
2584
+ }
2585
+
2586
+ if (signal) {
2587
+ dataRequest.signal = signal;
2588
+ }
2589
+
2590
+ return Promise.resolve(fetch("" + _this2.url + path, dataRequest));
2393
2591
  } catch (e) {
2394
2592
  return Promise.reject(e);
2395
2593
  }
@@ -2397,12 +2595,12 @@ var RestClient = /*#__PURE__*/function () {
2397
2595
 
2398
2596
  _proto.getHeaders = function getHeaders() {
2399
2597
  var authToken = this.auth.getToken();
2400
- if (!authToken) return {};
2401
- return {
2402
- Accept: 'application/json',
2403
- 'Content-Type': 'application/json',
2404
- Authorization: 'Bearer ' + authToken
2405
- };
2598
+ var headersInit = {};
2599
+ if (!authToken) return headersInit;
2600
+ headersInit.Accept = 'application/json';
2601
+ headersInit['Content-Type'] = 'application/json';
2602
+ headersInit.Authorization = 'Bearer ' + authToken;
2603
+ return headersInit;
2406
2604
  };
2407
2605
 
2408
2606
  _proto.post = function post(path, data) {
@@ -2418,11 +2616,11 @@ var RestClient = /*#__PURE__*/function () {
2418
2616
  }
2419
2617
  };
2420
2618
 
2421
- _proto.get = function get(path) {
2619
+ _proto.get = function get(path, signal) {
2422
2620
  try {
2423
2621
  var _this6 = this;
2424
2622
 
2425
- return Promise.resolve(_this6.request(path));
2623
+ return Promise.resolve(_this6.request(path, undefined, undefined, signal));
2426
2624
  } catch (e) {
2427
2625
  return Promise.reject(e);
2428
2626
  }
@@ -2460,24 +2658,20 @@ var RestClient = /*#__PURE__*/function () {
2460
2658
 
2461
2659
  var headers = _this12.getHeaders();
2462
2660
 
2463
- delete headers['Content-Type'];
2464
- headers['Content-Type'] = data['content-type'];
2465
- headers['X-UPLOAD-FILENAME'] = data.filename;
2466
- headers['Content-Encoding'] = 'base64';
2661
+ var newHeaders = {};
2662
+ newHeaders['Content-Type'] = data['content-type'];
2663
+ newHeaders['X-UPLOAD-FILENAME'] = data.filename;
2664
+ newHeaders['Content-Encoding'] = 'base64';
2467
2665
  return Promise.resolve(_this12.request(path, {
2468
2666
  method: 'PATCH',
2469
2667
  body: data.data
2470
- }, headers));
2668
+ }, _extends({}, headers, newHeaders)));
2471
2669
  } catch (e) {
2472
2670
  return Promise.reject(e);
2473
2671
  }
2474
2672
  };
2475
2673
 
2476
2674
  _proto.delete = function _delete(path, data) {
2477
- if (data === void 0) {
2478
- data = undefined;
2479
- }
2480
-
2481
2675
  try {
2482
2676
  var _this14 = this;
2483
2677
 
@@ -2618,6 +2812,14 @@ var GuillotinaClient = /*#__PURE__*/function () {
2618
2812
  }
2619
2813
  };
2620
2814
 
2815
+ _proto.getQueryParamsSearchFunction = function getQueryParamsSearchFunction(name) {
2816
+ if (name === 'getQueryParamsElasticsearch') {
2817
+ return this.getQueryParamsElasticsearch;
2818
+ }
2819
+
2820
+ return this.getQueryParamsPostresql;
2821
+ };
2822
+
2621
2823
  _proto.getQueryParamsPostresql = function getQueryParamsPostresql(_ref) {
2622
2824
  var _ref$start = _ref.start,
2623
2825
  start = _ref$start === void 0 ? 0 : _ref$start,
@@ -2658,7 +2860,7 @@ var GuillotinaClient = /*#__PURE__*/function () {
2658
2860
  objectPath = objectPath.slice(0, -1);
2659
2861
  }
2660
2862
 
2661
- result = [].concat(parser(start.toString(), '_from'), parser(pageSize.toString(), 'size'), parser('*', '_metadata'));
2863
+ result = [].concat(parser(start.toString(), '_from'), parser(pageSize.toString(), '_size'), parser('*', '_metadata'));
2662
2864
 
2663
2865
  if (withDepth) {
2664
2866
  var _parser2;
@@ -2709,7 +2911,7 @@ var GuillotinaClient = /*#__PURE__*/function () {
2709
2911
  label: 'id/name',
2710
2912
  key: 'title',
2711
2913
  isSortable: true,
2712
- child: function child(m, navigate, search) {
2914
+ child: function child(m, _navigate, search) {
2713
2915
  return jsxRuntime.jsxs(TdLink, {
2714
2916
  model: m,
2715
2917
  children: [m.name, search && jsxRuntime.jsxs(React__default['default'].Fragment, {
@@ -2743,15 +2945,19 @@ var GuillotinaClient = /*#__PURE__*/function () {
2743
2945
  });
2744
2946
  }
2745
2947
  }];
2746
- };
2948
+ } // BBB API changes. Compat G5 and G6
2949
+ ;
2747
2950
 
2748
2951
  _proto.applyCompat = function applyCompat(data) {
2749
- data.member = data.items;
2750
- data.items_count = data.items_total;
2751
- return data;
2952
+ var result = _extends({}, data, {
2953
+ member: data.items,
2954
+ items_count: data.items_total
2955
+ });
2956
+
2957
+ return result;
2752
2958
  };
2753
2959
 
2754
- _proto.search = function search(path, params, container, prepare) {
2960
+ _proto.search = function search(path, params, container, prepare, signal) {
2755
2961
  if (container === void 0) {
2756
2962
  container = false;
2757
2963
  }
@@ -2773,7 +2979,7 @@ var GuillotinaClient = /*#__PURE__*/function () {
2773
2979
 
2774
2980
  var query = prepare ? toQueryString(params) : params;
2775
2981
  var url = path + "@search?" + query;
2776
- return Promise.resolve(_this7.rest.get(url)).then(function (res) {
2982
+ return Promise.resolve(_this7.rest.get(url, signal)).then(function (res) {
2777
2983
  return Promise.resolve(res.json()).then(function (data) {
2778
2984
  return _this7.applyCompat(data);
2779
2985
  });
@@ -2903,7 +3109,8 @@ var GuillotinaClient = /*#__PURE__*/function () {
2903
3109
 
2904
3110
  var _temp4 = function () {
2905
3111
  if (!cacheSchemas[name]) {
2906
- var url = _this25.getContainerFromPath(path);
3112
+ var url = _this25.getContainerFromPath(path); // todo: handle db case (only addable containers)
3113
+
2907
3114
 
2908
3115
  return Promise.resolve(_this25.rest.get(url + "@types/" + name)).then(function (res) {
2909
3116
  return Promise.resolve(res.json()).then(function (_res$json) {
@@ -2984,23 +3191,53 @@ var GuillotinaClient = /*#__PURE__*/function () {
2984
3191
  var users = _this37.getUsers(path);
2985
3192
 
2986
3193
  return Promise.resolve(Promise.all([groups, users])).then(function (_ref3) {
2987
- var gr = _ref3[0],
2988
- usr = _ref3[1];
3194
+ var responseGroups = _ref3[0],
3195
+ responseUsers = _ref3[1];
2989
3196
 
2990
- function _temp6(_gr$json) {
2991
- function _temp5(_usr$json) {
3197
+ function _temp8() {
3198
+ function _temp6() {
2992
3199
  return {
2993
- groups: _gr$json,
2994
- users: _usr$json
3200
+ groups: groupsData,
3201
+ users: usersData
2995
3202
  };
2996
3203
  }
2997
3204
 
2998
- var _usr$ok = usr.ok;
2999
- return _usr$ok ? Promise.resolve(usr.json()).then(_temp5) : _temp5([]);
3205
+ var _temp5 = function () {
3206
+ if (responseUsers) {
3207
+ return Promise.resolve(responseUsers.json()).then(function (usersDataResponse) {
3208
+ usersData = usersDataResponse.map(function (user) {
3209
+ return {
3210
+ '@name': user.id,
3211
+ user_roles: user.roles,
3212
+ fullname: user.fullname,
3213
+ email: user.email
3214
+ };
3215
+ });
3216
+ });
3217
+ }
3218
+ }();
3219
+
3220
+ return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
3000
3221
  }
3001
3222
 
3002
- var _gr$ok = gr.ok;
3003
- return _gr$ok ? Promise.resolve(gr.json()).then(_temp6) : _temp6([]);
3223
+ var groupsData = [];
3224
+ var usersData = [];
3225
+
3226
+ var _temp7 = function () {
3227
+ if (responseGroups.ok) {
3228
+ return Promise.resolve(responseGroups.json()).then(function (groupsDataResponse) {
3229
+ groupsData = groupsDataResponse.map(function (group) {
3230
+ return {
3231
+ '@name': group.id,
3232
+ user_roles: group.roles,
3233
+ users: group.users
3234
+ };
3235
+ });
3236
+ });
3237
+ }
3238
+ }();
3239
+
3240
+ return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
3004
3241
  });
3005
3242
  } catch (e) {
3006
3243
  return Promise.reject(e);
@@ -3022,6 +3259,7 @@ var GuillotinaClient = /*#__PURE__*/function () {
3022
3259
  try {
3023
3260
  var _this41 = this;
3024
3261
 
3262
+ // paths used to query the API always has to start without a "/"
3025
3263
  if (path.startsWith('/')) {
3026
3264
  path = path.slice(1);
3027
3265
  }
@@ -3041,7 +3279,7 @@ var GuillotinaClient = /*#__PURE__*/function () {
3041
3279
  try {
3042
3280
  var _this43 = this;
3043
3281
 
3044
- function _temp10() {
3282
+ function _temp12() {
3045
3283
  return cacheTypes[path];
3046
3284
  }
3047
3285
 
@@ -3049,10 +3287,10 @@ var GuillotinaClient = /*#__PURE__*/function () {
3049
3287
  path = path.slice(1);
3050
3288
  }
3051
3289
 
3052
- var _temp11 = function () {
3290
+ var _temp13 = function () {
3053
3291
  if (!cacheTypes[path]) {
3054
3292
  return Promise.resolve(_this43.rest.get(path + '@addable-types')).then(function (types) {
3055
- var _temp7 = function () {
3293
+ var _temp9 = function () {
3056
3294
  if (types.status === 401 || types.status === 404) {
3057
3295
  cacheTypes[path] = [];
3058
3296
  } else {
@@ -3062,12 +3300,12 @@ var GuillotinaClient = /*#__PURE__*/function () {
3062
3300
  }
3063
3301
  }();
3064
3302
 
3065
- if (_temp7 && _temp7.then) return _temp7.then(function () {});
3303
+ if (_temp9 && _temp9.then) return _temp9.then(function () {});
3066
3304
  });
3067
3305
  }
3068
3306
  }();
3069
3307
 
3070
- return Promise.resolve(_temp11 && _temp11.then ? _temp11.then(_temp10) : _temp10(_temp11));
3308
+ return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(_temp12) : _temp12(_temp13));
3071
3309
  } catch (e) {
3072
3310
  return Promise.reject(e);
3073
3311
  }
@@ -3079,17 +3317,24 @@ function getClient(url, container, auth) {
3079
3317
  return new GuillotinaClient(new RestClient(url, container, auth), container === '/');
3080
3318
  }
3081
3319
  var lightFileReader = function lightFileReader(file) {
3082
- return new Promise(function (resolve) {
3320
+ return new Promise(function (resolve, reject) {
3083
3321
  var reader = new FileReader();
3084
3322
  reader.readAsArrayBuffer(file);
3085
3323
 
3086
3324
  reader.onloadend = function (e) {
3087
- var fileData = e.target.result;
3088
- resolve({
3089
- filename: file.name.normalize('NFD').replace(/[\u0300-\u036f]/g, ''),
3090
- data: fileData,
3091
- 'content-type': file.type
3092
- });
3325
+ var _e$target;
3326
+
3327
+ var fileData = e == null ? void 0 : (_e$target = e.target) == null ? void 0 : _e$target.result;
3328
+
3329
+ if (fileData) {
3330
+ resolve({
3331
+ filename: file.name.normalize('NFD').replace(/[\u0300-\u036f]/g, ''),
3332
+ data: fileData,
3333
+ 'content-type': file.type
3334
+ });
3335
+ } else {
3336
+ reject('Error reading file');
3337
+ }
3093
3338
  };
3094
3339
  });
3095
3340
  };
@@ -3120,9 +3365,15 @@ function FileUpload(_ref) {
3120
3365
 
3121
3366
  var changed = function changed(event) {
3122
3367
  try {
3123
- return Promise.resolve(lightFileReader(event.target.files[0])).then(function (fileToUpload) {
3124
- onChange(fileToUpload);
3125
- });
3368
+ var _temp2 = function () {
3369
+ if (event.target.files) {
3370
+ return Promise.resolve(lightFileReader(event.target.files[0])).then(function (fileToUpload) {
3371
+ onChange(fileToUpload);
3372
+ });
3373
+ }
3374
+ }();
3375
+
3376
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
3126
3377
  } catch (e) {
3127
3378
  return Promise.reject(e);
3128
3379
  }
@@ -3213,12 +3464,12 @@ Textarea.displayName = 'Textarea';
3213
3464
 
3214
3465
  var defaultEvents = ['mousedown', 'touchstart'];
3215
3466
 
3216
- var on = function on(obj) {
3217
- return obj.addEventListener.apply(obj, [].slice.call(arguments, 1));
3467
+ var on = function on(obj, type, handler) {
3468
+ return obj.addEventListener(type, handler);
3218
3469
  };
3219
3470
 
3220
- var off = function off(obj) {
3221
- return obj.removeEventListener.apply(obj, [].slice.call(arguments, 1));
3471
+ var off = function off(obj, type, handler) {
3472
+ return obj.removeEventListener(type, handler);
3222
3473
  };
3223
3474
 
3224
3475
  function useClickAway(ref, onClickAway, events) {
@@ -3250,23 +3501,7 @@ function useClickAway(ref, onClickAway, events) {
3250
3501
  }, [events, ref]);
3251
3502
  }
3252
3503
 
3253
- function debounce(func, wait) {
3254
- var timeout;
3255
- return function () {
3256
- var context = this;
3257
- var args = arguments;
3258
-
3259
- var later = function later() {
3260
- timeout = null;
3261
- func.apply(context, args);
3262
- };
3263
-
3264
- clearTimeout(timeout);
3265
- timeout = setTimeout(later, wait);
3266
- };
3267
- }
3268
-
3269
- var initialState = {
3504
+ var initialState$1 = {
3270
3505
  page: 0,
3271
3506
  items: undefined,
3272
3507
  loading: false,
@@ -3276,10 +3511,9 @@ var SearchInput = function SearchInput(_ref) {
3276
3511
  var onChange = _ref.onChange,
3277
3512
  error = _ref.error,
3278
3513
  errorZoneClassName = _ref.errorZoneClassName,
3279
- _ref$traversal = _ref.traversal,
3280
- traversal = _ref$traversal === void 0 ? null : _ref$traversal,
3514
+ traversal = _ref.traversal,
3281
3515
  _ref$path = _ref.path,
3282
- path = _ref$path === void 0 ? null : _ref$path,
3516
+ path = _ref$path === void 0 ? undefined : _ref$path,
3283
3517
  _ref$qs = _ref.qs,
3284
3518
  qs = _ref$qs === void 0 ? [] : _ref$qs,
3285
3519
  _ref$queryCondition = _ref.queryCondition,
@@ -3294,14 +3528,14 @@ var SearchInput = function SearchInput(_ref) {
3294
3528
  _ref$dataTestItem = _ref.dataTestItem,
3295
3529
  dataTestItem = _ref$dataTestItem === void 0 ? 'searchInputItemTest' : _ref$dataTestItem,
3296
3530
  _ref$renderTextItemOp = _ref.renderTextItemOption,
3297
- renderTextItemOption = _ref$renderTextItemOp === void 0 ? null : _ref$renderTextItemOp,
3531
+ renderTextItemOption = _ref$renderTextItemOp === void 0 ? undefined : _ref$renderTextItemOp,
3298
3532
  _ref$typeNameQuery = _ref.typeNameQuery,
3299
- typeNameQuery = _ref$typeNameQuery === void 0 ? null : _ref$typeNameQuery,
3533
+ typeNameQuery = _ref$typeNameQuery === void 0 ? undefined : _ref$typeNameQuery,
3300
3534
  _ref$labelProperty = _ref.labelProperty,
3301
3535
  labelProperty = _ref$labelProperty === void 0 ? 'id' : _ref$labelProperty;
3302
3536
  var intl = reactIntl.useIntl();
3303
3537
 
3304
- var _useSetState = useSetState(initialState),
3538
+ var _useSetState = useSetState(initialState$1),
3305
3539
  options = _useSetState[0],
3306
3540
  setOptions = _useSetState[1];
3307
3541
 
@@ -3355,7 +3589,7 @@ var SearchInput = function SearchInput(_ref) {
3355
3589
  var searchTermParsed = ["id", value];
3356
3590
  var getSearch = traversal.registry.get;
3357
3591
  var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
3358
- var qsParsed = traversal.client[fnName]({
3592
+ var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
3359
3593
  path: traversal.path,
3360
3594
  start: 0,
3361
3595
  pageSize: PageSize,
@@ -3373,7 +3607,7 @@ var SearchInput = function SearchInput(_ref) {
3373
3607
 
3374
3608
  return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
3375
3609
  var newValuesLabel = data.items.reduce(function (result, item) {
3376
- result[item.id] = get$1(item, labelProperty, item.id);
3610
+ result[item.id] = get(item, labelProperty, item.id);
3377
3611
  return result;
3378
3612
  }, {});
3379
3613
  setValueLabel(newValuesLabel);
@@ -3401,6 +3635,7 @@ var SearchInput = function SearchInput(_ref) {
3401
3635
  }
3402
3636
 
3403
3637
  try {
3638
+ console.log('handle search input');
3404
3639
  setOptions({
3405
3640
  loading: true
3406
3641
  });
@@ -3415,7 +3650,7 @@ var SearchInput = function SearchInput(_ref) {
3415
3650
 
3416
3651
  var fnName = _get('searchEngineQueryParamsFunction', SearchEngine);
3417
3652
 
3418
- var qsParsed = traversal.client[fnName]({
3653
+ var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
3419
3654
  path: traversal.path,
3420
3655
  start: page * PageSize,
3421
3656
  pageSize: PageSize,
@@ -3428,7 +3663,7 @@ var SearchInput = function SearchInput(_ref) {
3428
3663
  typeNameParsed = parser("type_name__in=" + typeNameQuery);
3429
3664
  }
3430
3665
 
3431
- if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
3666
+ if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0 || sortParsed.length > 0) {
3432
3667
  searchTermQs = buildQs([].concat(qs, searchTermParsed, qsParsed, typeNameParsed, sortParsed));
3433
3668
  }
3434
3669
 
@@ -3453,7 +3688,7 @@ var SearchInput = function SearchInput(_ref) {
3453
3688
  return renderTextItemOption(item);
3454
3689
  }
3455
3690
 
3456
- return get$1(item, labelProperty, item.title) || item['@name'];
3691
+ return get(item, labelProperty, item.title) || item['@name'];
3457
3692
  };
3458
3693
 
3459
3694
  React.useEffect(function () {
@@ -3479,7 +3714,7 @@ var SearchInput = function SearchInput(_ref) {
3479
3714
  if (!ev.currentTarget.contains(ev.relatedTarget)) {
3480
3715
  if (searchTerm !== '') {
3481
3716
  setSearchTerm('');
3482
- setOptions(initialState);
3717
+ setOptions(initialState$1);
3483
3718
  }
3484
3719
 
3485
3720
  setIsOpen(false);
@@ -3497,6 +3732,7 @@ var SearchInput = function SearchInput(_ref) {
3497
3732
  }
3498
3733
 
3499
3734
  setIsOpen(!isOpen);
3735
+ console.log('on clic btn', options);
3500
3736
 
3501
3737
  if (!options.loading && !options.items) {
3502
3738
  handleSearch(options.page);
@@ -3505,7 +3741,7 @@ var SearchInput = function SearchInput(_ref) {
3505
3741
  "aria-haspopup": "true",
3506
3742
  "aria-controls": "dropdown-menu",
3507
3743
  children: [jsxRuntime.jsx("span", {
3508
- children: value ? get$1(valueLabel, value, value) : intl.formatMessage(genericMessages.choose)
3744
+ children: value ? get(valueLabel, value, value) : intl.formatMessage(genericMessages.choose)
3509
3745
  }), jsxRuntime.jsx("span", {
3510
3746
  className: "icon",
3511
3747
  children: jsxRuntime.jsx("i", {
@@ -3579,23 +3815,7 @@ var SearchInput = function SearchInput(_ref) {
3579
3815
  });
3580
3816
  };
3581
3817
 
3582
- function debounce$1(func, wait) {
3583
- var timeout;
3584
- return function () {
3585
- var context = this;
3586
- var args = arguments;
3587
-
3588
- var later = function later() {
3589
- timeout = null;
3590
- func.apply(context, args);
3591
- };
3592
-
3593
- clearTimeout(timeout);
3594
- timeout = setTimeout(later, wait);
3595
- };
3596
- }
3597
-
3598
- var initialState$1 = {
3818
+ var initialState$2 = {
3599
3819
  page: 0,
3600
3820
  items: undefined,
3601
3821
  loading: false,
@@ -3605,10 +3825,9 @@ var SearchInputList = function SearchInputList(_ref) {
3605
3825
  var onChange = _ref.onChange,
3606
3826
  error = _ref.error,
3607
3827
  errorZoneClassName = _ref.errorZoneClassName,
3608
- _ref$traversal = _ref.traversal,
3609
- traversal = _ref$traversal === void 0 ? null : _ref$traversal,
3828
+ traversal = _ref.traversal,
3610
3829
  _ref$path = _ref.path,
3611
- path = _ref$path === void 0 ? null : _ref$path,
3830
+ path = _ref$path === void 0 ? undefined : _ref$path,
3612
3831
  _ref$qs = _ref.qs,
3613
3832
  qs = _ref$qs === void 0 ? [] : _ref$qs,
3614
3833
  _ref$queryCondition = _ref.queryCondition,
@@ -3623,14 +3842,14 @@ var SearchInputList = function SearchInputList(_ref) {
3623
3842
  _ref$dataTestItem = _ref.dataTestItem,
3624
3843
  dataTestItem = _ref$dataTestItem === void 0 ? 'searchInputItemTest' : _ref$dataTestItem,
3625
3844
  _ref$renderTextItemOp = _ref.renderTextItemOption,
3626
- renderTextItemOption = _ref$renderTextItemOp === void 0 ? null : _ref$renderTextItemOp,
3845
+ renderTextItemOption = _ref$renderTextItemOp === void 0 ? undefined : _ref$renderTextItemOp,
3627
3846
  _ref$typeNameQuery = _ref.typeNameQuery,
3628
- typeNameQuery = _ref$typeNameQuery === void 0 ? null : _ref$typeNameQuery,
3847
+ typeNameQuery = _ref$typeNameQuery === void 0 ? undefined : _ref$typeNameQuery,
3629
3848
  _ref$labelProperty = _ref.labelProperty,
3630
3849
  labelProperty = _ref$labelProperty === void 0 ? 'id' : _ref$labelProperty;
3631
3850
  var intl = reactIntl.useIntl();
3632
3851
 
3633
- var _useSetState = useSetState(initialState$1),
3852
+ var _useSetState = useSetState(initialState$2),
3634
3853
  options = _useSetState[0],
3635
3854
  setOptions = _useSetState[1];
3636
3855
 
@@ -3676,7 +3895,7 @@ var SearchInputList = function SearchInputList(_ref) {
3676
3895
  };
3677
3896
  };
3678
3897
 
3679
- var delayedQuery = React.useCallback(debounce$1(function (value) {
3898
+ var delayedQuery = React.useCallback(debounce(function (value) {
3680
3899
  return handleSearch(0, false, value);
3681
3900
  }, 500), []);
3682
3901
 
@@ -3708,7 +3927,7 @@ var SearchInputList = function SearchInputList(_ref) {
3708
3927
 
3709
3928
  var fnName = _get('searchEngineQueryParamsFunction', SearchEngine);
3710
3929
 
3711
- var qsParsed = traversal.client[fnName]({
3930
+ var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
3712
3931
  path: traversal.path,
3713
3932
  start: page * PageSize,
3714
3933
  pageSize: PageSize,
@@ -3750,7 +3969,7 @@ var SearchInputList = function SearchInputList(_ref) {
3750
3969
  var searchTermParsed = ['__or', "id=" + value.join('%26id=')];
3751
3970
  var getSearch = traversal.registry.get;
3752
3971
  var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
3753
- var qsParsed = traversal.client[fnName]({
3972
+ var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
3754
3973
  path: traversal.path,
3755
3974
  start: 0,
3756
3975
  pageSize: 100,
@@ -3766,9 +3985,9 @@ var SearchInputList = function SearchInputList(_ref) {
3766
3985
  searchTermQs = buildQs([].concat(qs, [searchTermParsed], qsParsed, typeNameParsed));
3767
3986
  }
3768
3987
 
3769
- return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false, 0, 100)).then(function (data) {
3988
+ return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
3770
3989
  var newValuesLabel = data.items.reduce(function (result, item) {
3771
- result[item.id] = get$1(item, labelProperty, item.id);
3990
+ result[item.id] = get(item, labelProperty, item.id);
3772
3991
  return result;
3773
3992
  }, {});
3774
3993
  setValuesLabels(newValuesLabel);
@@ -3788,7 +4007,7 @@ var SearchInputList = function SearchInputList(_ref) {
3788
4007
  return renderTextItemOption(item);
3789
4008
  }
3790
4009
 
3791
- return get$1(item, labelProperty, item.title) || item['@name'];
4010
+ return get(item, labelProperty, item.title) || item['@name'];
3792
4011
  };
3793
4012
 
3794
4013
  React.useEffect(function () {
@@ -3811,7 +4030,7 @@ var SearchInputList = function SearchInputList(_ref) {
3811
4030
  children: value.map(function (tag, index) {
3812
4031
  return jsxRuntime.jsxs("div", {
3813
4032
  className: "tag is-info is-medium",
3814
- children: [get$1(valuesLabel, tag, tag), jsxRuntime.jsx("button", {
4033
+ children: [get(valuesLabel, tag, tag), jsxRuntime.jsx("button", {
3815
4034
  className: "delete is-small",
3816
4035
  onClick: function onClick(ev) {
3817
4036
  ev.stopPropagation();
@@ -3831,7 +4050,7 @@ var SearchInputList = function SearchInputList(_ref) {
3831
4050
  if (!ev.currentTarget.contains(ev.relatedTarget)) {
3832
4051
  if (searchTerm !== '') {
3833
4052
  setSearchTerm('');
3834
- setOptions(initialState$1);
4053
+ setOptions(initialState$2);
3835
4054
  }
3836
4055
 
3837
4056
  setIsOpen(false);
@@ -3895,7 +4114,7 @@ var SearchInputList = function SearchInputList(_ref) {
3895
4114
  if (onChange && !value.includes(item.id)) {
3896
4115
  var _extends2;
3897
4116
 
3898
- setValuesLabels(_extends({}, valuesLabel, (_extends2 = {}, _extends2[item.id] = get$1(item, labelProperty, item.id), _extends2)));
4117
+ setValuesLabels(_extends({}, valuesLabel, (_extends2 = {}, _extends2[item.id] = get(item, labelProperty, item.id), _extends2)));
3899
4118
  onChange([].concat(value, [item.id]));
3900
4119
  }
3901
4120
  },
@@ -4083,7 +4302,7 @@ function EditableField(_ref) {
4083
4302
  ref.current.focus();
4084
4303
  }
4085
4304
  });
4086
- var canModified = modifyContent && !get$1(schema, 'readonly', false);
4305
+ var canModified = schema !== undefined && modifyContent && !get(schema, 'readonly', false);
4087
4306
 
4088
4307
  var saveField = function saveField(ev) {
4089
4308
  try {
@@ -4149,7 +4368,7 @@ function EditableField(_ref) {
4149
4368
  var deleteField = function deleteField(ev) {
4150
4369
  try {
4151
4370
  if (ev) ev.preventDefault();
4152
- return Promise.resolve(function () {
4371
+ return Promise.resolve(function (_schema$items) {
4153
4372
  if ((schema == null ? void 0 : schema.widget) === 'file') {
4154
4373
  var _ns2, _ref4, _ref5;
4155
4374
 
@@ -4177,7 +4396,7 @@ function EditableField(_ref) {
4177
4396
  });
4178
4397
  } else if ((schema == null ? void 0 : schema.type) === 'string' && schema != null && schema.enum) {
4179
4398
  setValue(null);
4180
- } else if ((schema == null ? void 0 : schema.type) === 'array' && (schema == null ? void 0 : schema.items.type) === 'string') {
4399
+ } else if ((schema == null ? void 0 : schema.type) === 'array' && (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.type) === 'string') {
4181
4400
  setValue([]);
4182
4401
  }
4183
4402
  }());
@@ -4234,7 +4453,7 @@ function EditableField(_ref) {
4234
4453
  dataTest: "editableFieldBtnCancelTest",
4235
4454
  children: intl.formatMessage(genericMessages.cancel)
4236
4455
  })
4237
- }), !required && fieldHaveDeleteButton(schema) && jsxRuntime.jsx("div", {
4456
+ }), !required && schema && fieldHaveDeleteButton(schema) && jsxRuntime.jsx("div", {
4238
4457
  className: "control",
4239
4458
  children: jsxRuntime.jsx(Button, {
4240
4459
  className: "is-small is-danger",
@@ -4263,7 +4482,8 @@ var DownloadField = function DownloadField(_ref) {
4263
4482
  var blob = new Blob([text], {
4264
4483
  type: data.content_type
4265
4484
  });
4266
- var url = window.URL.createObjectURL(blob);
4485
+ var url = window.URL.createObjectURL(blob); // Create blob link to download
4486
+
4267
4487
  var link = document.createElement('a');
4268
4488
  link.href = url;
4269
4489
 
@@ -4278,6 +4498,7 @@ var DownloadField = function DownloadField(_ref) {
4278
4498
  setTimeout(function () {
4279
4499
  var _link$parentNode;
4280
4500
 
4501
+ // For Firefox it is necessary to delay revoking the ObjectURL
4281
4502
  window.URL.revokeObjectURL(url);
4282
4503
  (_link$parentNode = link.parentNode) == null ? void 0 : _link$parentNode.removeChild(link);
4283
4504
  }, 100);
@@ -4353,23 +4574,27 @@ function RenderField(_ref) {
4353
4574
  }
4354
4575
 
4355
4576
  if (type === 'object') {
4577
+ var _schema$properties;
4578
+
4356
4579
  if (Array.isArray(value)) {
4357
- return value.map(function (item) {
4580
+ return value.map(function (item, index) {
4358
4581
  return jsxRuntime.jsx("div", {
4359
4582
  children: jsxRuntime.jsx(RenderField, {
4360
4583
  value: item
4361
4584
  })
4362
- }, item);
4585
+ }, "renderField_" + index + "_" + (schema == null ? void 0 : schema.title));
4363
4586
  });
4364
4587
  }
4365
4588
 
4366
- return Object.keys(value).map(function (key) {
4367
- return jsxRuntime.jsx(FieldValue, {
4368
- field: get$1(schema, "properties." + key + ".title", key),
4369
- schema: get$1(schema, "properties." + key, {}),
4370
- value: value[key]
4371
- }, key);
4372
- });
4589
+ if ((schema == null ? void 0 : (_schema$properties = schema.properties) == null ? void 0 : _schema$properties.key) !== undefined) {
4590
+ return Object.keys(value).map(function (key) {
4591
+ return jsxRuntime.jsx(FieldValue, {
4592
+ field: get(schema, "properties." + key + ".title", key),
4593
+ schema: schema.properties.key,
4594
+ value: get(value, key, {})
4595
+ }, key);
4596
+ });
4597
+ }
4373
4598
  }
4374
4599
 
4375
4600
  return jsxRuntime.jsxs("p", {
@@ -4413,6 +4638,7 @@ var SearchRenderField = function SearchRenderField(_ref3) {
4413
4638
  var schema = _ref3.schema,
4414
4639
  value = _ref3.value,
4415
4640
  modifyContent = _ref3.modifyContent;
4641
+ console.log('search render fields');
4416
4642
  var intl = reactIntl.useIntl();
4417
4643
 
4418
4644
  var _useState = React.useState([]),
@@ -4437,7 +4663,7 @@ var SearchRenderField = function SearchRenderField(_ref3) {
4437
4663
  var searchTermParsed = ['__or', "id=" + valuesToSearch.join('%26id=')];
4438
4664
  var getSearch = traversal.registry.get;
4439
4665
  var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
4440
- var qsParsed = traversal.client[fnName]({
4666
+ var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
4441
4667
  path: traversal.path,
4442
4668
  start: 0,
4443
4669
  pageSize: 100,
@@ -4448,11 +4674,11 @@ var SearchRenderField = function SearchRenderField(_ref3) {
4448
4674
  searchTermQs = buildQs([searchTermParsed].concat(qsParsed));
4449
4675
  }
4450
4676
 
4451
- return Promise.resolve(traversal.client.search(traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false, 0, 100)).then(function (data) {
4677
+ return Promise.resolve(traversal.client.search(traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
4452
4678
  var newValuesLabel = data.items.map(function (item) {
4453
4679
  var _schema$labelProperty;
4454
4680
 
4455
- return get$1(item, (_schema$labelProperty = schema == null ? void 0 : schema.labelProperty) != null ? _schema$labelProperty : 'title', item.id);
4681
+ return get(item, (_schema$labelProperty = schema == null ? void 0 : schema.labelProperty) != null ? _schema$labelProperty : 'title', item.id);
4456
4682
  });
4457
4683
  setValuesLabels(newValuesLabel);
4458
4684
  setIsLoadingData(false);
@@ -4462,13 +4688,15 @@ var SearchRenderField = function SearchRenderField(_ref3) {
4462
4688
  }
4463
4689
  };
4464
4690
 
4465
- var valuesToSearch = value;
4691
+ var valuesToSearch = [];
4466
4692
 
4467
- if (typeof valuesToSearch === 'string') {
4468
- valuesToSearch = [valuesToSearch];
4693
+ if (typeof value === 'string' && value) {
4694
+ valuesToSearch = [value];
4695
+ } else if (Array.isArray(value)) {
4696
+ valuesToSearch = value;
4469
4697
  }
4470
4698
 
4471
- if (valuesToSearch !== undefined && valuesToSearch.length > 0) {
4699
+ if (valuesToSearch.length > 0) {
4472
4700
  fetchData(valuesToSearch);
4473
4701
  } else {
4474
4702
  setValuesLabels([]);
@@ -4503,7 +4731,7 @@ var VocabularyRenderField = function VocabularyRenderField(_ref4) {
4503
4731
  modifyContent = _ref4.modifyContent;
4504
4732
  var intl = reactIntl.useIntl();
4505
4733
  var DEFAULT_VALUE_EDITABLE_FIELD = getDefaultValueEditableField(intl);
4506
- var vocabularyName = (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.vocabularyName) || (schema == null ? void 0 : schema.vocabularyName);
4734
+ var vocabularyName = (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.vocabularyName) || (schema == null ? void 0 : schema.vocabularyName) || '';
4507
4735
  var vocabulary = useVocabulary(vocabularyName);
4508
4736
 
4509
4737
  var getRenderProps = function getRenderProps() {
@@ -4514,7 +4742,7 @@ var VocabularyRenderField = function VocabularyRenderField(_ref4) {
4514
4742
  if (schema != null && schema.vocabularyName) {
4515
4743
  var _vocabularyValue$titl;
4516
4744
 
4517
- var vocabularyValue = get$1(vocabulary, 'data.items', []).find(function (item) {
4745
+ var vocabularyValue = get(vocabulary, 'data.items', []).find(function (item) {
4518
4746
  return item.token === value;
4519
4747
  });
4520
4748
  renderProps['value'] = (_vocabularyValue$titl = vocabularyValue == null ? void 0 : vocabularyValue.title) != null ? _vocabularyValue$titl : '';
@@ -4524,7 +4752,7 @@ var VocabularyRenderField = function VocabularyRenderField(_ref4) {
4524
4752
  renderProps['value'] = ((_renderProps$value = renderProps['value']) != null ? _renderProps$value : []).map(function (value) {
4525
4753
  var _get$find$title, _get$find;
4526
4754
 
4527
- return (_get$find$title = (_get$find = get$1(vocabulary, 'data.items', []).find(function (item) {
4755
+ return (_get$find$title = (_get$find = get(vocabulary, 'data.items', []).find(function (item) {
4528
4756
  return item.token === value;
4529
4757
  })) == null ? void 0 : _get$find.title) != null ? _get$find$title : '';
4530
4758
  });
@@ -4601,7 +4829,7 @@ var EditComponent = React.forwardRef(function (_ref, ref) {
4601
4829
  queryCondition: schema != null && schema.queryCondition ? schema.queryCondition : 'title__in',
4602
4830
  path: schema.queryPath,
4603
4831
  labelProperty: schema != null && schema.labelProperty ? schema.labelProperty : 'title',
4604
- typeNameQuery: schema != null && schema.typeNameQuery ? schema.typeNameQuery : null
4832
+ typeNameQuery: schema == null ? void 0 : schema.typeNameQuery
4605
4833
  })]
4606
4834
  });
4607
4835
  } else if ((schema == null ? void 0 : schema.widget) === 'search') {
@@ -4618,7 +4846,7 @@ var EditComponent = React.forwardRef(function (_ref, ref) {
4618
4846
  queryCondition: schema != null && schema.queryCondition ? schema.queryCondition : 'title__in',
4619
4847
  path: schema.queryPath,
4620
4848
  labelProperty: schema != null && schema.labelProperty ? schema.labelProperty : 'title',
4621
- typeNameQuery: schema != null && schema.typeNameQuery ? schema.typeNameQuery : null
4849
+ typeNameQuery: schema == null ? void 0 : schema.typeNameQuery
4622
4850
  })]
4623
4851
  });
4624
4852
  } else if ((schema == null ? void 0 : schema.widget) === 'textarea' || (schema == null ? void 0 : schema.widget) === 'richtext') {
@@ -4648,7 +4876,7 @@ var EditComponent = React.forwardRef(function (_ref, ref) {
4648
4876
 
4649
4877
  if (schema.items.vocabularyName) {
4650
4878
  return jsxRuntime.jsx(SelectVocabulary, {
4651
- vocabularyName: get$1(schema, 'items.vocabularyName', null),
4879
+ vocabularyName: get(schema, 'items.vocabularyName', ''),
4652
4880
  val: val || [],
4653
4881
  className: className,
4654
4882
  classWrap: "is-fullwidth",
@@ -4685,22 +4913,25 @@ var EditComponent = React.forwardRef(function (_ref, ref) {
4685
4913
  }), jsxRuntime.jsx(InputList, {
4686
4914
  value: val || [],
4687
4915
  className: className,
4688
- onChange: function onChange(ev) {
4689
- return _setValue(ev);
4916
+ onChange: function onChange(val) {
4917
+ return _setValue(val);
4690
4918
  },
4691
4919
  ref: ref,
4692
4920
  dataTest: dataTest
4693
4921
  })]
4694
4922
  });
4695
4923
  } else if ((schema == null ? void 0 : schema.widget) === 'file') {
4924
+ var value = val;
4696
4925
  return jsxRuntime.jsx(FileUpload, {
4697
4926
  onChange: function onChange(ev) {
4698
4927
  return _setValue(ev);
4699
4928
  },
4700
- label: get$1(val, 'filename', null),
4929
+ label: get(value, 'filename', undefined),
4701
4930
  dataTest: dataTest
4702
4931
  });
4703
4932
  } else if ((schema == null ? void 0 : schema.widget) === 'select' && schema.type === 'string') {
4933
+ var _schema$vocabulary;
4934
+
4704
4935
  if (schema != null && schema.vocabularyName) {
4705
4936
  return jsxRuntime.jsx(SelectVocabulary, {
4706
4937
  val: val || '',
@@ -4709,7 +4940,7 @@ var EditComponent = React.forwardRef(function (_ref, ref) {
4709
4940
  classWrap: "is-fullwidth",
4710
4941
  dataTest: dataTest,
4711
4942
  onChange: _setValue,
4712
- vocabularyName: get$1(schema, 'vocabularyName', null),
4943
+ vocabularyName: get(schema, 'vocabularyName', ''),
4713
4944
  placeholder: placeholder,
4714
4945
  id: id
4715
4946
  });
@@ -4721,7 +4952,7 @@ var EditComponent = React.forwardRef(function (_ref, ref) {
4721
4952
  appendDefault: true,
4722
4953
  classWrap: "is-fullwidth",
4723
4954
  dataTest: dataTest,
4724
- options: schema == null ? void 0 : schema.vocabulary.map(function (item) {
4955
+ options: ((_schema$vocabulary = schema == null ? void 0 : schema.vocabulary) != null ? _schema$vocabulary : []).map(function (item) {
4725
4956
  return {
4726
4957
  text: item,
4727
4958
  value: item
@@ -4732,26 +4963,27 @@ var EditComponent = React.forwardRef(function (_ref, ref) {
4732
4963
  id: id
4733
4964
  });
4734
4965
  } else if ((schema == null ? void 0 : schema.type) === 'object' && schema.widget !== 'file') {
4735
- var value = val;
4966
+ var _value = val;
4736
4967
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
4737
4968
  children: [schema.title && jsxRuntime.jsx("h4", {
4738
4969
  className: "subtitle mt-2",
4739
4970
  children: schema.title
4740
- }), Object.keys(get$1(schema, 'properties', {})).map(function (key) {
4971
+ }), Object.keys(get(schema, 'properties', {})).map(function (key) {
4741
4972
  var _subSchema$title;
4742
4973
 
4743
- var subSchema = get$1(schema, 'properties', {})[key];
4744
- var requiredFields = get$1(schema, 'required', []);
4974
+ var subSchema = get(schema, "properties." + key, null);
4975
+ var requiredFields = get(schema, 'required', []);
4976
+ if (!subSchema) return null;
4745
4977
  return jsxRuntime.jsx(EditComponent, {
4746
4978
  id: id + "[" + key + "]",
4747
4979
  schema: subSchema,
4748
- val: value && key in value ? value[key] : '',
4980
+ val: _value && key in _value ? _value[key] : '',
4749
4981
  placeholder: (_subSchema$title = subSchema == null ? void 0 : subSchema.title) != null ? _subSchema$title : '',
4750
4982
  required: requiredFields.includes(key),
4751
4983
  setValue: function setValue(ev) {
4752
4984
  var _extends2;
4753
4985
 
4754
- _setValue(_extends({}, value, (_extends2 = {}, _extends2[key] = ev, _extends2)));
4986
+ _setValue(_extends({}, _value, (_extends2 = {}, _extends2[key] = ev, _extends2)));
4755
4987
  },
4756
4988
  dataTest: key + "TestInput"
4757
4989
  }, id + "[" + key + "]");
@@ -4813,9 +5045,9 @@ function IAttachment(_ref) {
4813
5045
  }, 1), jsxRuntime.jsx("td", {
4814
5046
  children: jsxRuntime.jsx(EditableField, {
4815
5047
  field: key,
4816
- value: values[key],
5048
+ value: values.file,
4817
5049
  ns: "guillotina.behaviors.attachment.IAttachment",
4818
- schema: properties[key],
5050
+ schema: properties.file,
4819
5051
  modifyContent: modifyContent && ['file'].includes(key)
4820
5052
  })
4821
5053
  }, 2)]
@@ -4865,6 +5097,11 @@ function IMultiAttachment(_ref) {
4865
5097
 
4866
5098
  setLoading(true);
4867
5099
  setError(undefined);
5100
+
5101
+ if (!file) {
5102
+ return Promise.resolve();
5103
+ }
5104
+
4868
5105
  var endpoint = Ctx.path + "@upload/files/" + fileKey;
4869
5106
  return Promise.resolve(Ctx.client.upload(endpoint, file)).then(function (req) {
4870
5107
  if (req.status !== 200) {
@@ -4933,7 +5170,7 @@ function IMultiAttachment(_ref) {
4933
5170
  field: "files/" + key,
4934
5171
  value: values['files'][key],
4935
5172
  ns: "guillotina.behaviors.attachment.IMultiAttachment.files",
4936
- schema: properties['files']['additionalProperties'],
5173
+ schema: get(properties, 'files.additionalProperties', {}),
4937
5174
  modifyContent: false
4938
5175
  }), jsxRuntime.jsx("div", {
4939
5176
  className: "ml-5",
@@ -5157,13 +5394,18 @@ function IImageAttachment(_ref) {
5157
5394
  ev.preventDefault();
5158
5395
  setLoading(true);
5159
5396
  setError(undefined);
5397
+
5398
+ if (!file) {
5399
+ return Promise.resolve();
5400
+ }
5401
+
5160
5402
  var endpoint = Ctx.path + "@upload/image";
5161
5403
  return Promise.resolve(Ctx.client.upload(endpoint, file)).then(function (req) {
5162
5404
  var _exit;
5163
5405
 
5164
5406
  function _temp4(_result) {
5165
5407
  if (_exit) return _result;
5166
- setFile(undefined);
5408
+ setFile(null);
5167
5409
  setLoading(false);
5168
5410
  Ctx.flash(intl.formatMessage(genericFileMessages.image_uploaded), 'success');
5169
5411
  Ctx.refresh();
@@ -5444,7 +5686,7 @@ function IMultiImageAttachment(_ref) {
5444
5686
  fileKey = _useState[0],
5445
5687
  setFileKey = _useState[1];
5446
5688
 
5447
- var _useState2 = React.useState(null),
5689
+ var _useState2 = React.useState(undefined),
5448
5690
  file = _useState2[0],
5449
5691
  setFile = _useState2[1];
5450
5692
 
@@ -5477,6 +5719,11 @@ function IMultiImageAttachment(_ref) {
5477
5719
 
5478
5720
  setLoading(true);
5479
5721
  setError(undefined);
5722
+
5723
+ if (!file) {
5724
+ return Promise.resolve();
5725
+ }
5726
+
5480
5727
  var endpoint = Ctx.path + "@upload/images/" + fileKey;
5481
5728
  return Promise.resolve(Ctx.client.upload(endpoint, file)).then(function (req) {
5482
5729
  var _exit;
@@ -5579,7 +5826,7 @@ function IMultiImageAttachment(_ref) {
5579
5826
  field: "images/" + key,
5580
5827
  value: values['images'][key],
5581
5828
  ns: "guillotina.contrib.image.behaviors.IMultiImageAttachment.images",
5582
- schema: properties['images']['additionalProperties'],
5829
+ schema: get(properties, 'images.additionalProperties', {}),
5583
5830
  modifyContent: false,
5584
5831
  required: false
5585
5832
  }), jsxRuntime.jsx("div", {
@@ -5869,7 +6116,7 @@ function IMultiImageOrderedAttachment(_ref2) {
5869
6116
  sortedList = _useState2[0],
5870
6117
  setSortedList = _useState2[1];
5871
6118
 
5872
- var _useState3 = React.useState(null),
6119
+ var _useState3 = React.useState(undefined),
5873
6120
  file = _useState3[0],
5874
6121
  setFile = _useState3[1];
5875
6122
 
@@ -6013,7 +6260,7 @@ function IMultiImageOrderedAttachment(_ref2) {
6013
6260
  field: "images/" + key,
6014
6261
  value: values['images'][key],
6015
6262
  ns: "guillotina.contrib.image.behaviors.IMultiImageAttachment.images",
6016
- schema: properties['images']['additionalProperties'],
6263
+ schema: get(properties, 'images.additionalProperties', {}),
6017
6264
  modifyContent: false,
6018
6265
  required: false
6019
6266
  }), jsxRuntime.jsx("div", {
@@ -6068,163 +6315,6 @@ function IMultiImageOrderedAttachment(_ref2) {
6068
6315
  });
6069
6316
  }
6070
6317
 
6071
- var base = {
6072
- local: {
6073
- roleperm: {},
6074
- prinperm: {},
6075
- prinrole: {}
6076
- },
6077
- inherit: []
6078
- };
6079
- var Sharing = /*#__PURE__*/function () {
6080
- function Sharing(element) {
6081
- this.local = void 0;
6082
- this.inherit = void 0;
6083
- Object.assign(this, element || base);
6084
- }
6085
-
6086
- var _proto = Sharing.prototype;
6087
-
6088
- _proto.getRole = function getRole(role) {
6089
- return this.local.roleperm[role];
6090
- };
6091
-
6092
- _proto.getPrincipals = function getPrincipals(principal) {
6093
- return this.local.prinperm[principal];
6094
- };
6095
-
6096
- _proto.getPrinroles = function getPrinroles(role) {
6097
- return this.local.prinrole[role];
6098
- };
6099
-
6100
- _createClass(Sharing, [{
6101
- key: "roles",
6102
- get: function get() {
6103
- return Object.keys(this.local.roleperm);
6104
- }
6105
- }, {
6106
- key: "principals",
6107
- get: function get() {
6108
- return Object.keys(this.local.prinperm);
6109
- }
6110
- }, {
6111
- key: "prinrole",
6112
- get: function get() {
6113
- return Object.keys(this.local.prinrole);
6114
- }
6115
- }]);
6116
-
6117
- return Sharing;
6118
- }();
6119
-
6120
- var ItemModel = /*#__PURE__*/function () {
6121
- function ItemModel(item, url) {
6122
- if (url === void 0) {
6123
- url = '';
6124
- }
6125
-
6126
- this.item = void 0;
6127
- this.url = void 0;
6128
- this.item = item;
6129
- this.url = url;
6130
- }
6131
-
6132
- _createClass(ItemModel, [{
6133
- key: "path",
6134
- get: function get() {
6135
- var item = this.item['@id'] ? this.item['@id'] : this.item['@absolute_url'];
6136
- var path = item.split('//')[1].split('/').splice(1).join('/');
6137
- path = "/" + path + "/";
6138
-
6139
- if (this.url.length > 0) {
6140
- if (this.url.startsWith('/')) {
6141
- path = path.replace(this.url.substring(1), '');
6142
- } else {
6143
- path = path.replace(this.url, '');
6144
- }
6145
- }
6146
-
6147
- return path;
6148
- }
6149
- }, {
6150
- key: "name",
6151
- get: function get() {
6152
- return this.item.title || this.item['@name'];
6153
- }
6154
- }, {
6155
- key: "icon",
6156
- get: function get() {
6157
- var cfg = useConfig();
6158
-
6159
- if (cfg.icons && cfg.icons[this.type]) {
6160
- return cfg.icons[this.type];
6161
- }
6162
-
6163
- switch (this.type) {
6164
- case 'GroupManager':
6165
- return 'fas fa-users-cog';
6166
-
6167
- case 'UserManager':
6168
- return 'fas fa-user-cog';
6169
-
6170
- case 'User':
6171
- return 'fas fa-user';
6172
-
6173
- case 'Group':
6174
- return 'fas fa-users';
6175
-
6176
- case 'Folder':
6177
- return 'fas fa-folder';
6178
-
6179
- default:
6180
- return 'fas fa-file';
6181
- }
6182
- }
6183
- }, {
6184
- key: "fullPath",
6185
- get: function get() {
6186
- return this.url + this.item.id;
6187
- }
6188
- }, {
6189
- key: "id",
6190
- get: function get() {
6191
- if (this.item.id) {
6192
- return this.item.id;
6193
- }
6194
-
6195
- var id = this.item['@id'].split('&')[0].split('/');
6196
- return id[id.length - 1];
6197
- }
6198
- }, {
6199
- key: "uid",
6200
- get: function get() {
6201
- return this.item['@uid'];
6202
- }
6203
- }, {
6204
- key: "type",
6205
- get: function get() {
6206
- return this.item['@type'] || this.item.type_name;
6207
- }
6208
- }, {
6209
- key: "title",
6210
- get: function get() {
6211
- return this.item.title;
6212
- }
6213
- }, {
6214
- key: "created",
6215
- get: function get() {
6216
- return this.item.creation_date ? formatDate(this.item.creation_date) : '';
6217
- }
6218
- }, {
6219
- key: "updated",
6220
- get: function get() {
6221
- return this.item.modification_date ? formatDate(this.item.modification_date) : '';
6222
- }
6223
- }]);
6224
-
6225
- return ItemModel;
6226
- }();
6227
-
6228
6318
  var messages$1 = reactIntl.defineMessages({
6229
6319
  status_changed_ok: {
6230
6320
  id: "status_changed_ok",
@@ -6300,13 +6390,12 @@ function IWorkflow() {
6300
6390
  definition = _useState[0],
6301
6391
  setDefinition = _useState[1];
6302
6392
 
6303
- var _useState2 = React.useState(null),
6393
+ var _useState2 = React.useState(undefined),
6304
6394
  workflowAction = _useState2[0],
6305
6395
  setWorkflowAction = _useState2[1];
6306
6396
 
6307
- var model = new ItemModel(Ctx.context);
6308
6397
  var vocabulary = useVocabulary('workflow_states');
6309
- var currentState = model.item['guillotina.contrib.workflows.interfaces.IWorkflowBehavior']['review_state'];
6398
+ var currentState = Ctx.context['guillotina.contrib.workflows.interfaces.IWorkflowBehavior']['review_state'];
6310
6399
  React.useEffect(function () {
6311
6400
  loadDefinition();
6312
6401
  }, [Ctx.path]);
@@ -6326,7 +6415,7 @@ function IWorkflow() {
6326
6415
  }
6327
6416
 
6328
6417
  Ctx.refresh();
6329
- setWorkflowAction(null);
6418
+ setWorkflowAction(undefined);
6330
6419
  });
6331
6420
  });
6332
6421
  } catch (e) {
@@ -6335,21 +6424,23 @@ function IWorkflow() {
6335
6424
  };
6336
6425
 
6337
6426
  var getStateTitle = function getStateTitle() {
6338
- var _vocabulary$data, _vocabulary$data$item;
6427
+ var _vocabulary$data$item, _vocabulary$data;
6428
+
6429
+ if (((_vocabulary$data$item = (_vocabulary$data = vocabulary.data) == null ? void 0 : _vocabulary$data.items) != null ? _vocabulary$data$item : []).length > 0) {
6430
+ var _vocabulary$data2;
6339
6431
 
6340
- if (((_vocabulary$data = vocabulary.data) == null ? void 0 : (_vocabulary$data$item = _vocabulary$data.items) == null ? void 0 : _vocabulary$data$item.length) > 0) {
6341
- var vocabularyValue = vocabulary.data.items.find(function (item) {
6432
+ var vocabularyValue = vocabulary == null ? void 0 : (_vocabulary$data2 = vocabulary.data) == null ? void 0 : _vocabulary$data2.items.find(function (item) {
6342
6433
  return item.token === currentState;
6343
6434
  });
6344
6435
 
6345
6436
  if (vocabularyValue) {
6346
- var translatedValue = get$1(vocabularyValue, "title.translated_title." + intl.locale, null);
6437
+ var translatedValue = get(vocabularyValue, "title.translated_title." + intl.locale, null);
6347
6438
 
6348
6439
  if (translatedValue !== null) {
6349
6440
  return translatedValue;
6350
6441
  }
6351
6442
 
6352
- var titleValue = get$1(vocabularyValue, "title.title." + intl.locale, null);
6443
+ var titleValue = get(vocabularyValue, "title.title." + intl.locale, null);
6353
6444
 
6354
6445
  if (titleValue !== null) {
6355
6446
  return titleValue;
@@ -6365,7 +6456,7 @@ function IWorkflow() {
6365
6456
  children: [workflowAction && jsxRuntime.jsx(Confirm, {
6366
6457
  loading: loading,
6367
6458
  onCancel: function onCancel() {
6368
- return setWorkflowAction(null);
6459
+ return setWorkflowAction(undefined);
6369
6460
  },
6370
6461
  onConfirm: doWorkflowAction,
6371
6462
  message: intl.formatMessage(messages$1.confirm_message, {
@@ -6391,7 +6482,7 @@ function IWorkflow() {
6391
6482
  onClick: function onClick() {
6392
6483
  return setWorkflowAction(transition['@id'].split('@workflow')[1].slice(1));
6393
6484
  },
6394
- children: get$1(transition, "metadata.translated_title." + intl.locale, transition.title)
6485
+ children: get(transition, "metadata.translated_title." + intl.locale, transition.title)
6395
6486
  }, transition['@id']);
6396
6487
  })]
6397
6488
  })]
@@ -6417,14 +6508,17 @@ function PanelActions() {
6417
6508
 
6418
6509
  return jsxRuntime.jsx(React.Fragment, {
6419
6510
  children: Object.keys(ACTIONS_OBJECT).map(function (actionKey) {
6420
- if (hasPerm(ACTIONS_OBJECT[actionKey].perms)) {
6511
+ var actionKeyTyped = actionKey;
6512
+ var actionObject = ACTIONS_OBJECT[actionKeyTyped];
6513
+
6514
+ if (hasPerm(actionObject.perms)) {
6421
6515
  return jsxRuntime.jsx("button", {
6422
6516
  className: "button mr-4",
6423
6517
  onClick: function onClick() {
6424
- onAction(actionKey);
6518
+ onAction(actionKeyTyped);
6425
6519
  },
6426
- children: ACTIONS_OBJECT[actionKey].text
6427
- }, "panel_action_" + ACTIONS_OBJECT[actionKey].text);
6520
+ children: actionObject.text
6521
+ }, "panel_action_" + actionObject.text);
6428
6522
  }
6429
6523
  })
6430
6524
  });
@@ -6466,7 +6560,8 @@ var messages$2 = reactIntl.defineMessages({
6466
6560
  "value": "Installed Addons"
6467
6561
  }]
6468
6562
  }
6469
- });
6563
+ }); // TODO: Refactor without useAsync... just crudContext
6564
+
6470
6565
  function PanelAddons() {
6471
6566
  var _state$data$available, _state$data, _state$data$available2, _state$data2, _state$data$installed, _state$data3, _state$data$installed2, _state$data4;
6472
6567
 
@@ -6621,8 +6716,9 @@ var prepareData = function prepareData(result) {
6621
6716
 
6622
6717
  var arrayToObject = function arrayToObject(array) {
6623
6718
  return array.reduce(function (obj, item) {
6624
- obj[item.id] = item;
6625
- return obj;
6719
+ var _extends2;
6720
+
6721
+ return _extends({}, obj, (_extends2 = {}, _extends2[item.id] = item, _extends2));
6626
6722
  }, {});
6627
6723
  };
6628
6724
 
@@ -6784,8 +6880,9 @@ function ItemsActionsProvider(_ref) {
6784
6880
 
6785
6881
  function onSelectAllItems(checked) {
6786
6882
  setSelected(items.reduce(function (obj, item) {
6787
- obj[item.path + "/" + item.id] = checked;
6788
- return obj;
6883
+ var _extends2;
6884
+
6885
+ return _extends({}, obj, (_extends2 = {}, _extends2[item.path + "/" + item.id] = checked, _extends2));
6789
6886
  }, {
6790
6887
  all: checked
6791
6888
  }));
@@ -6793,11 +6890,11 @@ function ItemsActionsProvider(_ref) {
6793
6890
 
6794
6891
  function onSelectOneItem(item) {
6795
6892
  setSelected(function (state) {
6796
- var _extends2;
6893
+ var _extends3;
6797
6894
 
6798
- return _extends({}, state, (_extends2 = {
6895
+ return _extends({}, state, (_extends3 = {
6799
6896
  all: false
6800
- }, _extends2[item.path + "/" + item.id] = !state[item.path + "/" + item.id], _extends2));
6897
+ }, _extends3[item.path + "/" + item.id] = !state[item.path + "/" + item.id], _extends3));
6801
6898
  });
6802
6899
  }
6803
6900
 
@@ -6819,13 +6916,38 @@ function ItemsActionsProvider(_ref) {
6819
6916
  children: children
6820
6917
  });
6821
6918
  }
6822
- function AllItemsCheckbox(_ref2) {
6823
- var dataTest = _ref2.dataTest;
6824
6919
 
6920
+ var useItemsActions = function useItemsActions() {
6825
6921
  var _useContext = React.useContext(ItemsActionsCtx),
6922
+ onAction = _useContext.onAction,
6923
+ onSelectOneItem = _useContext.onSelectOneItem,
6826
6924
  onSelectAllItems = _useContext.onSelectAllItems,
6827
6925
  selected = _useContext.selected;
6828
6926
 
6927
+ if (!onAction || !onSelectOneItem || !onSelectAllItems || !selected) {
6928
+ throw new Error('useItemsActions must be used inside ItemsActionsProvider');
6929
+ }
6930
+
6931
+ return {
6932
+ onAction: onAction,
6933
+ onSelectOneItem: onSelectOneItem,
6934
+ onSelectAllItems: onSelectAllItems,
6935
+ selected: selected
6936
+ };
6937
+ };
6938
+ /**
6939
+ * Checkbox component without props that consume the ItemsActionsContext
6940
+ * and it select/unselect all items of the page.
6941
+ */
6942
+
6943
+
6944
+ function AllItemsCheckbox(_ref2) {
6945
+ var dataTest = _ref2.dataTest;
6946
+
6947
+ var _useItemsActions = useItemsActions(),
6948
+ onSelectAllItems = _useItemsActions.onSelectAllItems,
6949
+ selected = _useItemsActions.selected;
6950
+
6829
6951
  return jsxRuntime.jsx(Checkbox, {
6830
6952
  onChange: onSelectAllItems,
6831
6953
  checked: selected.all,
@@ -6836,9 +6958,9 @@ function ItemCheckbox(_ref3) {
6836
6958
  var item = _ref3.item,
6837
6959
  dataTest = _ref3.dataTest;
6838
6960
 
6839
- var _useContext2 = React.useContext(ItemsActionsCtx),
6840
- selected = _useContext2.selected,
6841
- onSelectOneItem = _useContext2.onSelectOneItem;
6961
+ var _useItemsActions2 = useItemsActions(),
6962
+ selected = _useItemsActions2.selected,
6963
+ onSelectOneItem = _useItemsActions2.onSelectOneItem;
6842
6964
 
6843
6965
  var absId = item.path + "/" + item.id;
6844
6966
  var value = selected[absId];
@@ -6850,14 +6972,18 @@ function ItemCheckbox(_ref3) {
6850
6972
  dataTest: dataTest
6851
6973
  });
6852
6974
  }
6975
+ /**
6976
+ * Dropdown to choose some action to apply to the selected items.
6977
+ */
6978
+
6853
6979
  function ItemsActionsDropdown() {
6854
6980
  var intl = reactIntl.useIntl();
6855
6981
  var ACTIONS_OBJECT = getActionsObject(intl, true);
6856
6982
  var traversal = useTraversal();
6857
6983
 
6858
- var _useContext3 = React.useContext(ItemsActionsCtx),
6859
- selected = _useContext3.selected,
6860
- onAction = _useContext3.onAction;
6984
+ var _useItemsActions3 = useItemsActions(),
6985
+ selected = _useItemsActions3.selected,
6986
+ onAction = _useItemsActions3.onAction;
6861
6987
 
6862
6988
  var disabled = Object.values(selected).every(function (v) {
6863
6989
  return !v;
@@ -6941,6 +7067,7 @@ function Pagination(_ref) {
6941
7067
  "aria-label": "pagination",
6942
7068
  children: [jsxRuntime.jsx("a", {
6943
7069
  className: "pagination-previous is-small",
7070
+ // disabled={current === 0}
6944
7071
  onClick: function onClick() {
6945
7072
  return current > 0 ? doPaginate(current - 1) : null;
6946
7073
  },
@@ -6952,6 +7079,7 @@ function Pagination(_ref) {
6952
7079
  })
6953
7080
  }), jsxRuntime.jsx("a", {
6954
7081
  className: "pagination-next is-small",
7082
+ // disabled={current >= maxPages - 1}
6955
7083
  onClick: function onClick() {
6956
7084
  return doPaginate(current + 1);
6957
7085
  },
@@ -6966,6 +7094,170 @@ function Pagination(_ref) {
6966
7094
  });
6967
7095
  }
6968
7096
 
7097
+ var base = {
7098
+ local: {
7099
+ roleperm: {},
7100
+ prinperm: {},
7101
+ prinrole: {}
7102
+ },
7103
+ inherit: []
7104
+ };
7105
+ var Sharing = /*#__PURE__*/function () {
7106
+ function Sharing(element) {
7107
+ this.local = void 0;
7108
+ this.inherit = void 0;
7109
+
7110
+ if (element === undefined) {
7111
+ throw new Error('Sharing element is undefined');
7112
+ }
7113
+
7114
+ this.local = element.local || base.local;
7115
+ this.inherit = element.inherit || base.inherit;
7116
+ }
7117
+
7118
+ var _proto = Sharing.prototype;
7119
+
7120
+ _proto.getRole = function getRole(role) {
7121
+ return this.local.roleperm[role];
7122
+ };
7123
+
7124
+ _proto.getPrincipals = function getPrincipals(principal) {
7125
+ return this.local.prinperm[principal];
7126
+ };
7127
+
7128
+ _proto.getPrinroles = function getPrinroles(role) {
7129
+ return this.local.prinrole[role];
7130
+ };
7131
+
7132
+ _createClass(Sharing, [{
7133
+ key: "roles",
7134
+ get: function get() {
7135
+ return Object.keys(this.local.roleperm);
7136
+ }
7137
+ }, {
7138
+ key: "principals",
7139
+ get: function get() {
7140
+ return Object.keys(this.local.prinperm);
7141
+ }
7142
+ }, {
7143
+ key: "prinrole",
7144
+ get: function get() {
7145
+ return Object.keys(this.local.prinrole);
7146
+ }
7147
+ }]);
7148
+
7149
+ return Sharing;
7150
+ }();
7151
+
7152
+ var ItemModel = /*#__PURE__*/function () {
7153
+ function ItemModel(item, url) {
7154
+ if (url === void 0) {
7155
+ url = '';
7156
+ }
7157
+
7158
+ this.item = void 0;
7159
+ this.url = void 0;
7160
+ this.item = item;
7161
+ this.url = url;
7162
+ }
7163
+
7164
+ _createClass(ItemModel, [{
7165
+ key: "path",
7166
+ get: function get() {
7167
+ // Compat
7168
+ var item = this.item['@id'] ? this.item['@id'] : this.item['@absolute_url'];
7169
+ var path = item.split('//')[1].split('/').splice(1).join('/');
7170
+ path = "/" + path + "/";
7171
+
7172
+ if (this.url.length > 0) {
7173
+ if (this.url.startsWith('/')) {
7174
+ path = path.replace(this.url.substring(1), '');
7175
+ } else {
7176
+ path = path.replace(this.url, '');
7177
+ }
7178
+ }
7179
+
7180
+ return path;
7181
+ }
7182
+ }, {
7183
+ key: "name",
7184
+ get: function get() {
7185
+ return this.item.title || this.item['@name'];
7186
+ }
7187
+ }, {
7188
+ key: "icon",
7189
+ get: function get() {
7190
+ var cfg = useConfig();
7191
+
7192
+ if (cfg.icons && cfg.icons[this.type]) {
7193
+ return cfg.icons[this.type];
7194
+ }
7195
+
7196
+ switch (this.type) {
7197
+ case 'GroupManager':
7198
+ return 'fas fa-users-cog';
7199
+
7200
+ case 'UserManager':
7201
+ return 'fas fa-user-cog';
7202
+
7203
+ case 'User':
7204
+ return 'fas fa-user';
7205
+
7206
+ case 'Group':
7207
+ return 'fas fa-users';
7208
+
7209
+ case 'Folder':
7210
+ return 'fas fa-folder';
7211
+
7212
+ default:
7213
+ return 'fas fa-file';
7214
+ }
7215
+ }
7216
+ }, {
7217
+ key: "fullPath",
7218
+ get: function get() {
7219
+ return this.url + this.id;
7220
+ }
7221
+ }, {
7222
+ key: "id",
7223
+ get: function get() {
7224
+ if ('id' in this.item) {
7225
+ return this.item.id;
7226
+ }
7227
+
7228
+ var id = this.item['@id'].split('&')[0].split('/');
7229
+ return id[id.length - 1];
7230
+ }
7231
+ }, {
7232
+ key: "uid",
7233
+ get: function get() {
7234
+ return this.item['@uid'];
7235
+ }
7236
+ }, {
7237
+ key: "type",
7238
+ get: function get() {
7239
+ return this.item['@type'] || this.item.type_name;
7240
+ }
7241
+ }, {
7242
+ key: "title",
7243
+ get: function get() {
7244
+ return this.item.title;
7245
+ }
7246
+ }, {
7247
+ key: "created",
7248
+ get: function get() {
7249
+ return this.item.creation_date ? formatDate(this.item.creation_date) : '';
7250
+ }
7251
+ }, {
7252
+ key: "updated",
7253
+ get: function get() {
7254
+ return this.item.modification_date ? formatDate(this.item.modification_date) : '';
7255
+ }
7256
+ }]);
7257
+
7258
+ return ItemModel;
7259
+ }();
7260
+
6969
7261
  function Item(_ref) {
6970
7262
  var item = _ref.item,
6971
7263
  icon = _ref.icon;
@@ -7106,11 +7398,11 @@ function SearchOptionsLabels(_ref) {
7106
7398
  renderValue = _useState[0],
7107
7399
  setRenderValue = _useState[1];
7108
7400
 
7109
- var defaultRenderValue = location.get(query);
7401
+ var defaultRenderValue = location.get(query) || '';
7110
7402
  React.useEffect(function () {
7111
7403
  var value = defaultRenderValue;
7112
7404
 
7113
- if ((options != null ? options : []).length > 0) {
7405
+ if (options && (options != null ? options : []).length > 0) {
7114
7406
  var option = options.find(function (item) {
7115
7407
  return item.value === value;
7116
7408
  });
@@ -7159,14 +7451,16 @@ function SearchVocabularyLabels(_ref) {
7159
7451
  setRenderValue = _useState[1];
7160
7452
 
7161
7453
  var vocabulary = useVocabulary(vocabularyName);
7162
- var defaultRenderValue = location.get(query);
7454
+ var defaultRenderValue = location.get(query) || '';
7163
7455
  React.useEffect(function () {
7164
7456
  var _vocabulary$data$item, _vocabulary$data;
7165
7457
 
7166
7458
  var value = defaultRenderValue;
7167
7459
 
7168
7460
  if (((_vocabulary$data$item = vocabulary == null ? void 0 : (_vocabulary$data = vocabulary.data) == null ? void 0 : _vocabulary$data.items) != null ? _vocabulary$data$item : []).length > 0) {
7169
- var vocabularyValue = vocabulary.data.items.find(function (item) {
7461
+ var _vocabulary$data2;
7462
+
7463
+ var vocabularyValue = vocabulary == null ? void 0 : (_vocabulary$data2 = vocabulary.data) == null ? void 0 : _vocabulary$data2.items.find(function (item) {
7170
7464
  return item.token === value;
7171
7465
  });
7172
7466
 
@@ -7200,7 +7494,7 @@ function SearchVocabularyLabels(_ref) {
7200
7494
  return null;
7201
7495
  }
7202
7496
 
7203
- var initialState$2 = {
7497
+ var initialState$3 = {
7204
7498
  page: 0,
7205
7499
  items: [],
7206
7500
  loading: true,
@@ -7219,7 +7513,7 @@ function PanelItems() {
7219
7513
  var intl = reactIntl.useIntl();
7220
7514
  var Ctx = useTraversal();
7221
7515
 
7222
- var _useSetState = useSetState(initialState$2),
7516
+ var _useSetState = useSetState(initialState$3),
7223
7517
  state = _useSetState[0],
7224
7518
  setState = _useSetState[1];
7225
7519
 
@@ -7235,7 +7529,7 @@ function PanelItems() {
7235
7529
  var page;
7236
7530
 
7237
7531
  try {
7238
- page = parseInt(location.get('page')) || 0;
7532
+ page = parseInt(location.get('page') || '0');
7239
7533
  } catch (_unused) {
7240
7534
  page = 0;
7241
7535
  }
@@ -7282,7 +7576,7 @@ function PanelItems() {
7282
7576
  var resultQueryParams = [];
7283
7577
  var resultDynamicLocation = [];
7284
7578
  filterSchema.forEach(function (filter) {
7285
- var itemParam = location.get(filter.attribute_key);
7579
+ var itemParam = location.get(filter.attribute_key) || '';
7286
7580
  resultDynamicLocation.push(itemParam);
7287
7581
 
7288
7582
  if (itemParam) {
@@ -7294,53 +7588,51 @@ function PanelItems() {
7294
7588
  var controller = new AbortController();
7295
7589
  if (Ctx.state.loading) return;
7296
7590
 
7297
- try {
7298
- setState({
7299
- loading: true,
7300
- total: Ctx.context.length
7301
- });
7302
- var get = Ctx.registry.get;
7303
- var fnName = get('searchEngineQueryParamsFunction', SearchEngine);
7304
-
7305
- if (sortParsed === undefined) {
7306
- var defaultSortValue = Ctx.registry.getDefaultSortValue(Ctx.context['@type'], {
7307
- key: 'id',
7308
- direction: 'des'
7591
+ var getData = function getData() {
7592
+ try {
7593
+ setState({
7594
+ loading: true,
7595
+ total: Ctx.context.length
7309
7596
  });
7310
- sortParsed = parser("_sort_" + defaultSortValue.direction + "=" + defaultSortValue.key);
7311
- }
7597
+ var get = Ctx.registry.get;
7598
+ var fnName = get('searchEngineQueryParamsFunction', SearchEngine);
7312
7599
 
7313
- var qsParsed = Ctx.client[fnName]({
7314
- path: Ctx.path,
7315
- start: page * PageSize,
7316
- pageSize: PageSize
7317
- });
7318
- var qs = '';
7600
+ if (sortParsed === undefined) {
7601
+ var defaultSortValue = Ctx.registry.getDefaultSortValue(Ctx.context['@type']);
7602
+ sortParsed = parser("_sort_" + defaultSortValue.direction + "=" + defaultSortValue.key);
7603
+ }
7319
7604
 
7320
- if (search || type || resultQueryParams.length > 0) {
7321
- var _searchParsed, _typeParsed, _sortParsed;
7605
+ var qsParsed = Ctx.client.getQueryParamsSearchFunction(fnName)({
7606
+ path: Ctx.path,
7607
+ start: page * PageSize,
7608
+ pageSize: PageSize
7609
+ });
7610
+ var qs = '';
7322
7611
 
7323
- qs = buildQs([].concat(qsParsed, (_searchParsed = searchParsed) != null ? _searchParsed : [], (_typeParsed = typeParsed) != null ? _typeParsed : [], (_sortParsed = sortParsed) != null ? _sortParsed : [], resultQueryParams));
7324
- } else {
7325
- var _sortParsed2;
7612
+ if (search || type || resultQueryParams.length > 0) {
7613
+ var _searchParsed, _typeParsed, _sortParsed;
7326
7614
 
7327
- qs = buildQs([].concat(qsParsed, (_sortParsed2 = sortParsed) != null ? _sortParsed2 : []));
7328
- }
7615
+ qs = buildQs([].concat(qsParsed, (_searchParsed = searchParsed) != null ? _searchParsed : [], (_typeParsed = typeParsed) != null ? _typeParsed : [], (_sortParsed = sortParsed) != null ? _sortParsed : [], resultQueryParams));
7616
+ } else {
7617
+ var _sortParsed2;
7329
7618
 
7330
- var signal = controller.signal;
7331
- return Promise.resolve(Ctx.client.search(Ctx.path, qs, false, false, {
7332
- signal: signal
7333
- })).then(function (data) {
7334
- setState({
7335
- items: data.member,
7336
- loading: false,
7337
- total: data.items_count
7619
+ qs = buildQs([].concat(qsParsed, (_sortParsed2 = sortParsed) != null ? _sortParsed2 : []));
7620
+ }
7621
+
7622
+ var signal = controller.signal;
7623
+ return Promise.resolve(Ctx.client.search(Ctx.path, qs, false, false, signal)).then(function (data) {
7624
+ setState({
7625
+ items: data.items,
7626
+ loading: false,
7627
+ total: data.items_count
7628
+ });
7338
7629
  });
7339
- });
7340
- } catch (e) {
7341
- Promise.reject(e);
7342
- }
7630
+ } catch (e) {
7631
+ return Promise.reject(e);
7632
+ }
7633
+ };
7343
7634
 
7635
+ getData();
7344
7636
  return function () {
7345
7637
  controller.abort();
7346
7638
  };
@@ -7385,12 +7677,14 @@ function PanelItems() {
7385
7677
  var _filter$values;
7386
7678
 
7387
7679
  if (filter.type === 'select' && ((_filter$values = filter.values) != null ? _filter$values : []).length > 0) {
7680
+ var _filter$values2;
7681
+
7388
7682
  return jsxRuntime.jsx(Select, {
7389
7683
  id: filter.attribute_key,
7390
7684
  placeholder: filter.label,
7391
7685
  appendDefault: true,
7392
7686
  classWrap: "is-size-7 is-fullwidth",
7393
- options: filter.values,
7687
+ options: (_filter$values2 = filter.values) != null ? _filter$values2 : [],
7394
7688
  value: location.get(filter.attribute_key) || '',
7395
7689
  dataTest: "filterInput" + filter.attribute_key,
7396
7690
  onChange: function onChange(value) {
@@ -7457,7 +7751,7 @@ function PanelItems() {
7457
7751
  var filterData = location.get(filter.attribute_key);
7458
7752
 
7459
7753
  if (filterData) {
7460
- var _filter$values2;
7754
+ var _filter$values3;
7461
7755
 
7462
7756
  if (filter.type === 'select' && filter.vocabulary) {
7463
7757
  return jsxRuntime.jsx("div", {
@@ -7466,7 +7760,7 @@ function PanelItems() {
7466
7760
  vocabularyName: filter == null ? void 0 : filter.vocabulary
7467
7761
  })
7468
7762
  }, filter.attribute_key);
7469
- } else if (filter.type === 'select' && ((_filter$values2 = filter.values) != null ? _filter$values2 : []).length > 0) {
7763
+ } else if (filter.type === 'select' && ((_filter$values3 = filter.values) != null ? _filter$values3 : []).length > 0) {
7470
7764
  return jsxRuntime.jsx("div", {
7471
7765
  children: jsxRuntime.jsx(SearchOptionsLabels, {
7472
7766
  query: filter.attribute_key,
@@ -7512,7 +7806,7 @@ function PanelItems() {
7512
7806
  className: "has-text-info is-flex is-align-items-center",
7513
7807
  children: [jsxRuntime.jsx("span", {
7514
7808
  children: column.label
7515
- }), getIcon(column.key, column.isSortable)]
7809
+ }), getIcon(column.key, !!column.isSortable)]
7516
7810
  })
7517
7811
  }, "table-col-" + column.label);
7518
7812
  }), jsxRuntime.jsx("th", {
@@ -7523,7 +7817,7 @@ function PanelItems() {
7523
7817
  children: [items && items.map(function (item) {
7524
7818
  return jsxRuntime.jsx(RItem, {
7525
7819
  item: item,
7526
- search: search,
7820
+ search: search != null ? search : '',
7527
7821
  columns: columns
7528
7822
  }, item['@uid']);
7529
7823
  }), items && items.length === 0 && jsxRuntime.jsx("tr", {
@@ -7547,17 +7841,19 @@ function PanelItems() {
7547
7841
  }
7548
7842
 
7549
7843
  function BehaviorsView(_ref) {
7844
+ var _context$__behaviors_;
7845
+
7550
7846
  var context = _ref.context,
7551
7847
  schema = _ref.schema;
7552
7848
  var Ctx = useTraversal();
7553
7849
  var getBehavior = Ctx.registry.getBehavior;
7554
- var behaviors = [].concat(context.__behaviors__, context['@static_behaviors']);
7850
+ var behaviors = [].concat((_context$__behaviors_ = context.__behaviors__) != null ? _context$__behaviors_ : [], Object(context['@static_behaviors']));
7555
7851
 
7556
- var GetBehavior = function GetBehavior(b) {
7557
- var Cls = getBehavior(b, BehaviorNotImplemented);
7852
+ var GetBehavior = function GetBehavior(behaviorName) {
7853
+ var Cls = getBehavior(behaviorName, BehaviorNotImplemented);
7558
7854
  return jsxRuntime.jsx(Cls, {
7559
- values: context[b],
7560
- properties: get$1(schema, ['definitions', b, 'properties'], {})
7855
+ values: context[behaviorName],
7856
+ properties: get(schema, ['definitions', behaviorName, 'properties'], {})
7561
7857
  });
7562
7858
  };
7563
7859
 
@@ -7653,9 +7949,11 @@ function PanelProperties() {
7653
7949
  var properties = Object.keys((schema == null ? void 0 : (_schema$data = schema.data) == null ? void 0 : _schema$data.properties) || []).filter(function (key) {
7654
7950
  return !ignoreFields.includes(key);
7655
7951
  }).map(function (key) {
7952
+ var _schema$data2;
7953
+
7656
7954
  return {
7657
7955
  key: key,
7658
- value: schema.data.properties[key]
7956
+ value: schema == null ? void 0 : (_schema$data2 = schema.data) == null ? void 0 : _schema$data2.properties[key]
7659
7957
  };
7660
7958
  });
7661
7959
  React.useEffect(function () {
@@ -7667,7 +7965,7 @@ function PanelProperties() {
7667
7965
  setSchema({
7668
7966
  loading: true
7669
7967
  });
7670
- return Promise.resolve(Ctx.client.getTypeSchema(Ctx.path, model.type)).then(function (dataJson) {
7968
+ return Promise.resolve(Ctx.client.getTypeSchema(Ctx.path, Ctx.context.type_name)).then(function (dataJson) {
7671
7969
  setSchema({
7672
7970
  loading: false,
7673
7971
  data: dataJson
@@ -7742,7 +8040,7 @@ function PanelProperties() {
7742
8040
  }), jsxRuntime.jsx("td", {
7743
8041
  children: jsxRuntime.jsx(EditableField, {
7744
8042
  field: prop,
7745
- value: Ctx.context[prop],
8043
+ value: get(Ctx.context, prop, ''),
7746
8044
  modifyContent: false
7747
8045
  })
7748
8046
  })]
@@ -7766,7 +8064,7 @@ function PanelProperties() {
7766
8064
  })
7767
8065
  }), jsxRuntime.jsx("tbody", {
7768
8066
  children: properties.map(function (_ref) {
7769
- var _schema$data$required, _schema$data2;
8067
+ var _schema$data$required, _schema$data3;
7770
8068
 
7771
8069
  var key = _ref.key,
7772
8070
  value = _ref.value;
@@ -7779,10 +8077,10 @@ function PanelProperties() {
7779
8077
  }), jsxRuntime.jsx("td", {
7780
8078
  children: jsxRuntime.jsx(EditableField, {
7781
8079
  field: key,
7782
- value: Ctx.context[key],
8080
+ value: get(Ctx.context, key, ''),
7783
8081
  schema: value,
7784
8082
  modifyContent: modifyContent,
7785
- required: ((_schema$data$required = (_schema$data2 = schema.data) == null ? void 0 : _schema$data2.required) != null ? _schema$data$required : []).includes(key)
8083
+ required: ((_schema$data$required = (_schema$data3 = schema.data) == null ? void 0 : _schema$data3.required) != null ? _schema$data$required : []).includes(key)
7786
8084
  })
7787
8085
  })]
7788
8086
  }, 'prop' + key);
@@ -7818,14 +8116,6 @@ function PermissionPrinperm(_ref) {
7818
8116
  state = _useSetState[0],
7819
8117
  setState = _useSetState[1];
7820
8118
 
7821
- var getMultiples = function getMultiples(field, setter) {
7822
- return function (values) {
7823
- var _setter;
7824
-
7825
- setter((_setter = {}, _setter[field] = values, _setter));
7826
- };
7827
- };
7828
-
7829
8119
  var savePermission = function savePermission() {
7830
8120
  try {
7831
8121
  if (!state.principal || !state.setting || state.permission.length === 0) {
@@ -7875,7 +8165,7 @@ function PermissionPrinperm(_ref) {
7875
8165
  children: intl.formatMessage(genericMessages.select_principal)
7876
8166
  }), jsxRuntime.jsx(Select, {
7877
8167
  appendDefault: true,
7878
- options: principals,
8168
+ options: principals != null ? principals : [],
7879
8169
  onChange: function onChange(value) {
7880
8170
  return setState({
7881
8171
  principal: value
@@ -7889,8 +8179,12 @@ function PermissionPrinperm(_ref) {
7889
8179
  className: "label",
7890
8180
  children: intl.formatMessage(genericMessages.select_permissions)
7891
8181
  }), jsxRuntime.jsx(Select, {
7892
- options: permissions,
7893
- onChange: getMultiples('permission', setState),
8182
+ options: permissions != null ? permissions : [],
8183
+ onChange: function onChange(values) {
8184
+ setState({
8185
+ permission: values
8186
+ });
8187
+ },
7894
8188
  size: 5,
7895
8189
  multiple: true,
7896
8190
  dataTest: "selectPermissionsTest"
@@ -7941,14 +8235,6 @@ function PermissionPrinrole(_ref) {
7941
8235
  state = _useSetState[0],
7942
8236
  setState = _useSetState[1];
7943
8237
 
7944
- var getMultiples = function getMultiples(field, setter) {
7945
- return function (values) {
7946
- var _setter;
7947
-
7948
- setter((_setter = {}, _setter[field] = values, _setter));
7949
- };
7950
- };
7951
-
7952
8238
  var savePermission = function savePermission() {
7953
8239
  try {
7954
8240
  if (!state.principal || !state.setting || state.roles.length === 0) {
@@ -7998,7 +8284,7 @@ function PermissionPrinrole(_ref) {
7998
8284
  children: intl.formatMessage(genericMessages.select_principal)
7999
8285
  }), jsxRuntime.jsx(Select, {
8000
8286
  appendDefault: true,
8001
- options: principals,
8287
+ options: principals != null ? principals : [],
8002
8288
  onChange: function onChange(value) {
8003
8289
  return setState({
8004
8290
  principal: value
@@ -8013,7 +8299,11 @@ function PermissionPrinrole(_ref) {
8013
8299
  children: intl.formatMessage(genericMessages.select_role)
8014
8300
  }), jsxRuntime.jsx(Select, {
8015
8301
  options: roles,
8016
- onChange: getMultiples('roles', setState),
8302
+ onChange: function onChange(values) {
8303
+ setState({
8304
+ roles: values
8305
+ });
8306
+ },
8017
8307
  size: 5,
8018
8308
  multiple: true,
8019
8309
  dataTest: "selectRoleTest"
@@ -8064,14 +8354,6 @@ function PermissionRoleperm(_ref) {
8064
8354
  state = _useSetState[0],
8065
8355
  setState = _useSetState[1];
8066
8356
 
8067
- var getMultiples = function getMultiples(field, setter) {
8068
- return function (values) {
8069
- var _setter;
8070
-
8071
- setter((_setter = {}, _setter[field] = values, _setter));
8072
- };
8073
- };
8074
-
8075
8357
  var savePermission = function savePermission() {
8076
8358
  try {
8077
8359
  if (!state.role || !state.setting || state.permission.length === 0) {
@@ -8135,8 +8417,12 @@ function PermissionRoleperm(_ref) {
8135
8417
  className: "label",
8136
8418
  children: intl.formatMessage(genericMessages.select_permissions)
8137
8419
  }), jsxRuntime.jsx(Select, {
8138
- options: permissions,
8139
- onChange: getMultiples('permission', setState),
8420
+ options: permissions != null ? permissions : [],
8421
+ onChange: function onChange(values) {
8422
+ setState({
8423
+ permission: values
8424
+ });
8425
+ },
8140
8426
  dataTest: "selectPermissionsTest",
8141
8427
  size: 5,
8142
8428
  multiple: true
@@ -8269,7 +8555,18 @@ function PanelPermissions() {
8269
8555
  React.useEffect(function () {
8270
8556
  get('@sharing');
8271
8557
  }, [reset]);
8272
- var perms = new Sharing(result);
8558
+ var perms = React.useMemo(function () {
8559
+ if (result) {
8560
+ return new Sharing(result);
8561
+ }
8562
+
8563
+ return null;
8564
+ }, [result]);
8565
+
8566
+ if (perms === null) {
8567
+ return null;
8568
+ }
8569
+
8273
8570
  return jsxRuntime.jsxs("div", {
8274
8571
  className: "columns",
8275
8572
  children: [!loading && jsxRuntime.jsxs("div", {
@@ -8427,14 +8724,14 @@ function AddPermission(_ref) {
8427
8724
  return Promise.resolve(Ctx.client.getPrincipals(Ctx.path)).then(function (principalsData) {
8428
8725
  var groups = principalsData.groups.map(function (group) {
8429
8726
  return {
8430
- text: group.id,
8431
- value: group.id
8727
+ text: group['@name'],
8728
+ value: group['@name']
8432
8729
  };
8433
8730
  });
8434
8731
  var users = principalsData.users.map(function (user) {
8435
8732
  return {
8436
- text: user.fullname || user.id,
8437
- value: user.id
8733
+ text: user.fullname || user['@name'],
8734
+ value: user['@name']
8438
8735
  };
8439
8736
  });
8440
8737
  principals = [].concat(groups, users);
@@ -8505,18 +8802,6 @@ var prepareAvailable = function prepareAvailable(items, already, title) {
8505
8802
  text: "Add " + title
8506
8803
  };
8507
8804
  if (items.length === 0) return [];
8508
-
8509
- if (items[0] && typeof items[0] === 'string') {
8510
- return [def].concat(items.map(function (x) {
8511
- return {
8512
- value: x,
8513
- text: x
8514
- };
8515
- })).filter(function (item) {
8516
- return !already.includes(item.value);
8517
- });
8518
- }
8519
-
8520
8805
  return [def].concat(items).filter(function (item) {
8521
8806
  return !already.includes(item.value);
8522
8807
  });
@@ -8529,7 +8814,7 @@ function TagsWidget(_ref) {
8529
8814
  noData = _ref.noData,
8530
8815
  onChange = _ref.onChange,
8531
8816
  loading = _ref.loading;
8532
- var selectRef = React.useRef();
8817
+ var selectRef = React.useRef(null);
8533
8818
 
8534
8819
  var _useState = React.useState(items),
8535
8820
  result = _useState[0],
@@ -8577,7 +8862,7 @@ function TagsWidget(_ref) {
8577
8862
  marginBottom: '20px'
8578
8863
  },
8579
8864
  children: noData
8580
- }), available.length > 1 && jsxRuntime.jsx("li", {
8865
+ }), (available != null ? available : []).length > 1 && jsxRuntime.jsx("li", {
8581
8866
  className: "widget-list-add select is-small",
8582
8867
  children: jsxRuntime.jsx(Select, {
8583
8868
  options: availableData,
@@ -8595,13 +8880,13 @@ function TagsWidget(_ref) {
8595
8880
  });
8596
8881
  }
8597
8882
 
8598
- var initialState$3 = {
8599
- types: undefined
8883
+ var initialState$4 = {
8884
+ types: []
8600
8885
  };
8601
8886
  function CreateButton() {
8602
8887
  var intl = reactIntl.useIntl();
8603
8888
 
8604
- var _useSetState = useSetState(initialState$3),
8889
+ var _useSetState = useSetState(initialState$4),
8605
8890
  state = _useSetState[0],
8606
8891
  setState = _useSetState[1];
8607
8892
 
@@ -8649,7 +8934,8 @@ function CreateButton() {
8649
8934
 
8650
8935
  if (state.types && state.types.length === 0) {
8651
8936
  return null;
8652
- }
8937
+ } // Implement some kind of filtering
8938
+
8653
8939
 
8654
8940
  return jsxRuntime.jsx(Dropdown, {
8655
8941
  id: "dropdown-menu",
@@ -8688,7 +8974,7 @@ function ContextToolbar(_ref) {
8688
8974
  var AddButton = _ref.AddButton;
8689
8975
  var intl = reactIntl.useIntl();
8690
8976
 
8691
- var _useSetState2 = useSetState(initialState$3),
8977
+ var _useSetState2 = useSetState(initialState$4),
8692
8978
  state = _useSetState2[0],
8693
8979
  setState = _useSetState2[1];
8694
8980
 
@@ -8699,7 +8985,7 @@ function ContextToolbar(_ref) {
8699
8985
 
8700
8986
  var traversal = useTraversal();
8701
8987
  var Config = useConfig();
8702
- var searchText = location.get('q');
8988
+ var searchText = location.get('q') || '';
8703
8989
 
8704
8990
  var _useState = React.useState(searchText || ''),
8705
8991
  searchValue = _useState[0],
@@ -8712,14 +8998,13 @@ function ContextToolbar(_ref) {
8712
8998
  setSearchValue(searchText);
8713
8999
  }, [searchText]);
8714
9000
 
8715
- var onSearchQuery = function onSearchQuery(ev) {
8716
- var search = ev.target[0].value;
9001
+ var onSearchQuery = function onSearchQuery(event) {
9002
+ event.preventDefault();
8717
9003
  setLocation({
8718
- q: search,
9004
+ q: event.currentTarget.elements.filterInput.value,
8719
9005
  tab: 'Items',
8720
9006
  page: 0
8721
9007
  });
8722
- ev.preventDefault();
8723
9008
  };
8724
9009
 
8725
9010
  var onSearchByType = function onSearchByType(typeText) {
@@ -8753,7 +9038,8 @@ function ContextToolbar(_ref) {
8753
9038
  type: "text",
8754
9039
  className: "input is-size-7",
8755
9040
  placeholder: intl.formatMessage(genericMessages.search),
8756
- "data-test": "inputFilterTest"
9041
+ "data-test": "inputFilterTest",
9042
+ id: "filterInput"
8757
9043
  })
8758
9044
  }), jsxRuntime.jsx("div", {
8759
9045
  className: "control",
@@ -8780,7 +9066,9 @@ function ContextToolbar(_ref) {
8780
9066
  value: item
8781
9067
  };
8782
9068
  }),
8783
- onChange: onSearchByType
9069
+ onChange: function onChange(value) {
9070
+ return onSearchByType(value);
9071
+ }
8784
9072
  })
8785
9073
  }), traversal.hasPerm('guillotina.AddContent') && jsxRuntime.jsx("div", {
8786
9074
  className: "level-item",
@@ -8821,11 +9109,11 @@ function TabsPanel(_ref2) {
8821
9109
  location = _useLocation[0],
8822
9110
  setLocation = _useLocation[1];
8823
9111
 
8824
- if (location.get('tab')) {
8825
- currentTab = location.get('tab');
8826
- } else {
8827
- currentTab = currentTab || Object.keys(tabs)[0];
8828
- }
9112
+ currentTab = location.get('tab') || Object.keys(tabs)[0];
9113
+ /*if (!Object.keys(tabs).includes(currentTab)) {
9114
+ setLocation(defaultTab)
9115
+ currentTab = defaultTab
9116
+ }*/
8829
9117
 
8830
9118
  var _useState = React.useState(currentTab),
8831
9119
  current = _useState[0],
@@ -8834,7 +9122,7 @@ function TabsPanel(_ref2) {
8834
9122
  var CurrentComp = tabs[current] || fallback;
8835
9123
  React__default['default'].useEffect(function () {
8836
9124
  if (Object.keys(tabs).includes(currentTab)) {
8837
- setTab(currentTab);
9125
+ setTab(currentTab); // setLocation({tab: currentTab})
8838
9126
  }
8839
9127
  }, [currentTab, tabs]);
8840
9128
 
@@ -8893,14 +9181,14 @@ var tabsPermissions = {
8893
9181
  Behaviors: 'guillotina.ModifyContent',
8894
9182
  Permissions: 'guillotina.SeePermissions'
8895
9183
  };
8896
- function FolderCtx(props) {
9184
+ function FolderCtx() {
8897
9185
  var ctx = useTraversal();
8898
9186
  var calculated = ctx.filterTabs(tabs, tabsPermissions);
8899
- return jsxRuntime.jsx(TabsPanel, _extends({
9187
+ return jsxRuntime.jsx(TabsPanel, {
8900
9188
  tabs: calculated,
8901
9189
  currentTab: "Items",
8902
- rightToolbar: jsxRuntime.jsx(ContextToolbar, _extends({}, props))
8903
- }, props));
9190
+ rightToolbar: jsxRuntime.jsx(ContextToolbar, {})
9191
+ });
8904
9192
  }
8905
9193
 
8906
9194
  var tabs$1 = {
@@ -8914,13 +9202,13 @@ var tabsPermissions$1 = {
8914
9202
  Behaviors: 'guillotina.ModifyContent',
8915
9203
  Permissions: 'guillotina.SeePermissions'
8916
9204
  };
8917
- function ItemCtx(props) {
9205
+ function ItemCtx() {
8918
9206
  var ctx = useTraversal();
8919
9207
  var calculated = ctx.filterTabs(tabs$1, tabsPermissions$1);
8920
- return jsxRuntime.jsx(TabsPanel, _extends({
9208
+ return jsxRuntime.jsx(TabsPanel, {
8921
9209
  tabs: calculated,
8922
9210
  currentTab: "Properties"
8923
- }, props));
9211
+ });
8924
9212
  }
8925
9213
 
8926
9214
  function _catch$7(body, recover) {
@@ -8939,8 +9227,9 @@ function _catch$7(body, recover) {
8939
9227
 
8940
9228
  function ApplicationCtx() {
8941
9229
  var intl = reactIntl.useIntl();
8942
- var context = useTraversal();
8943
- var databases = context.state.context.databases;
9230
+ var traversal = useTraversal();
9231
+ var appContext = traversal.state.context;
9232
+ var databases = appContext.databases;
8944
9233
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
8945
9234
  children: [jsxRuntime.jsx("h3", {
8946
9235
  children: intl.formatMessage({
@@ -8954,22 +9243,26 @@ function ApplicationCtx() {
8954
9243
  className: "container",
8955
9244
  children: [jsxRuntime.jsx(ItemTitle, {
8956
9245
  title: "Objects"
8957
- }), databases.map(function (db) {
8958
- return jsxRuntime.jsx(Item, {
8959
- item: {
8960
- id: db,
8961
- path: "/" + db + "/"
8962
- },
8963
- icon: 'fas fa-database'
8964
- }, db);
9246
+ }), jsxRuntime.jsx("table", {
9247
+ children: jsxRuntime.jsx("tbody", {
9248
+ children: databases.map(function (db) {
9249
+ return jsxRuntime.jsx(Item, {
9250
+ item: {
9251
+ id: db,
9252
+ path: "/" + db + "/"
9253
+ },
9254
+ icon: 'fas fa-database'
9255
+ }, db);
9256
+ })
9257
+ })
8965
9258
  })]
8966
9259
  })]
8967
9260
  });
8968
9261
  }
8969
9262
  function DatabaseCtx() {
8970
- var context = useTraversal();
8971
- var containers = context.state.context.containers;
8972
- var path = context.state.path;
9263
+ var traversal = useTraversal();
9264
+ var containers = traversal.state.context.containers;
9265
+ var path = traversal.state.path;
8973
9266
  return jsxRuntime.jsx(jsxRuntime.Fragment, {
8974
9267
  children: jsxRuntime.jsxs("div", {
8975
9268
  className: "container",
@@ -9257,17 +9550,17 @@ function UsersToolbar() {
9257
9550
 
9258
9551
  var searchText = location.get('q');
9259
9552
 
9260
- var onSearchQuery = function onSearchQuery(ev) {
9261
- var search = ev.target[0].value;
9553
+ var onSearchQuery = function onSearchQuery(event) {
9554
+ event.preventDefault();
9262
9555
  setLocation({
9263
- q: search,
9556
+ q: event.currentTarget.elements.filterInput.value,
9264
9557
  page: 0
9265
9558
  });
9266
- ev.preventDefault();
9267
- };
9559
+ }; // cleanup form on state.search change
9560
+
9268
9561
 
9269
9562
  React.useEffect(function () {
9270
- if (!searchText || searchText === '') {
9563
+ if (ref.current && (!searchText || searchText === '')) {
9271
9564
  ref.current.value = '';
9272
9565
  }
9273
9566
  }, [searchText]);
@@ -9287,7 +9580,8 @@ function UsersToolbar() {
9287
9580
  type: "text",
9288
9581
  className: "input is-size-7",
9289
9582
  placeholder: intl.formatMessage(genericMessages.search),
9290
- "data-test": "inputFilterTest"
9583
+ "data-test": "inputFilterTest",
9584
+ id: "filterInput"
9291
9585
  })
9292
9586
  }), jsxRuntime.jsx("div", {
9293
9587
  className: "control",
@@ -9319,12 +9613,12 @@ function UsersToolbar() {
9319
9613
  })]
9320
9614
  });
9321
9615
  }
9322
- function UsersCtx(props) {
9323
- return jsxRuntime.jsx(TabsPanel, _extends({
9616
+ function UsersCtx() {
9617
+ return jsxRuntime.jsx(TabsPanel, {
9324
9618
  tabs: tabs$3,
9325
9619
  currentTab: "Users",
9326
9620
  rightToolbar: jsxRuntime.jsx(UsersToolbar, {})
9327
- }, props));
9621
+ });
9328
9622
  }
9329
9623
  function UserCtx() {
9330
9624
  var intl = reactIntl.useIntl();
@@ -9341,9 +9635,10 @@ function UserCtx() {
9341
9635
  state = _useState[0],
9342
9636
  setState = _useState[1];
9343
9637
 
9638
+ var userDataContext = Ctx.context;
9344
9639
  var fields = {
9345
9640
  user_groups: [],
9346
- user_roles: Ctx.context.user_roles
9641
+ user_roles: userDataContext.user_roles
9347
9642
  };
9348
9643
 
9349
9644
  var _useRemoteField = useRemoteField(fields),
@@ -9447,7 +9742,7 @@ function UserCtx() {
9447
9742
  "value": "Username"
9448
9743
  }]
9449
9744
  }), ":", ' ']
9450
- }), ' ', Ctx.context.username, " (", Ctx.context.email, ")"]
9745
+ }), ' ', userDataContext.username, " (", userDataContext.email, ")"]
9451
9746
  }), jsxRuntime.jsxs("p", {
9452
9747
  children: [jsxRuntime.jsxs("label", {
9453
9748
  children: [' ', intl.formatMessage({
@@ -9457,7 +9752,7 @@ function UserCtx() {
9457
9752
  "value": "Creation Date"
9458
9753
  }]
9459
9754
  }), ":", ' ']
9460
- }), ' ', formatDate(Ctx.context.creation_date)]
9755
+ }), ' ', formatDate(userDataContext.creation_date)]
9461
9756
  }), jsxRuntime.jsxs("p", {
9462
9757
  children: [jsxRuntime.jsxs("label", {
9463
9758
  children: [' ', intl.formatMessage({
@@ -9467,7 +9762,7 @@ function UserCtx() {
9467
9762
  "value": "Modification Date"
9468
9763
  }]
9469
9764
  }), ":", ' ']
9470
- }), ' ', formatDate(Ctx.context.modification_date)]
9765
+ }), ' ', formatDate(userDataContext.modification_date)]
9471
9766
  }), jsxRuntime.jsx(Button, {
9472
9767
  className: "is-size-7 is-info",
9473
9768
  onClick: function onClick() {
@@ -9486,7 +9781,7 @@ function UserCtx() {
9486
9781
  onSubmit: function onSubmit(ev) {
9487
9782
  return updateObject(ev);
9488
9783
  },
9489
- formData: Ctx.context,
9784
+ formData: userDataContext,
9490
9785
  exclude: ['password'],
9491
9786
  remotes: remotes,
9492
9787
  submitButton: false,
@@ -9500,7 +9795,7 @@ function UserCtx() {
9500
9795
  className: "column",
9501
9796
  children: [jsxRuntime.jsx(TagsWidget, {
9502
9797
  onChange: updateRemote('user_groups'),
9503
- items: Ctx.context.user_groups,
9798
+ items: userDataContext.user_groups,
9504
9799
  title: "Groups",
9505
9800
  noData: intl.formatMessage({
9506
9801
  id: "there_is_no_groups_for_this_user",
@@ -9521,7 +9816,12 @@ function UserCtx() {
9521
9816
  "value": "The user doesn't have any role"
9522
9817
  }]
9523
9818
  }),
9524
- available: state.roles
9819
+ available: state.roles.map(function (x) {
9820
+ return {
9821
+ value: x,
9822
+ text: x
9823
+ };
9824
+ })
9525
9825
  })]
9526
9826
  })]
9527
9827
  })]
@@ -9537,7 +9837,7 @@ function CopyItems(props) {
9537
9837
  try {
9538
9838
  return Promise.resolve(Promise.all(items.map(function (item, i) {
9539
9839
  var input = form[i + 1] || {};
9540
- return Ctx.client.post("" + Ctx.path + item['@name'] + "/@duplicate", {
9840
+ return Ctx.client.post("" + Ctx.path + item.id + "/@duplicate", {
9541
9841
  destination: path,
9542
9842
  new_id: input.value || getNewId(item.id)
9543
9843
  });
@@ -9583,7 +9883,7 @@ function CopyItems(props) {
9583
9883
  }), jsxRuntime.jsx("input", {
9584
9884
  type: "text",
9585
9885
  className: "input",
9586
- "data-test": "inputCopyIdTest-" + item['@name'],
9886
+ "data-test": "inputCopyIdTest-" + item.id,
9587
9887
  defaultValue: getNewId(item.id)
9588
9888
  })]
9589
9889
  }, item.id);
@@ -9656,9 +9956,9 @@ function MoveItems(props) {
9656
9956
  var moveItems = function moveItems(path) {
9657
9957
  try {
9658
9958
  return Promise.resolve(Promise.all(items.map(function (item) {
9659
- return Ctx.client.post("" + Ctx.path + item['@name'] + "/@move", {
9959
+ return Ctx.client.post("" + Ctx.path + item.id + "/@move", {
9660
9960
  destination: path,
9661
- new_id: item['@name']
9961
+ new_id: item.id
9662
9962
  });
9663
9963
  }))).then(function (responses) {
9664
9964
  Ctx.refresh();
@@ -9995,17 +10295,17 @@ function GroupToolbar() {
9995
10295
 
9996
10296
  var searchText = location.get('q');
9997
10297
 
9998
- var onSearchQuery = function onSearchQuery(ev) {
9999
- var search = ev.target[0].value;
10298
+ var onSearchQuery = function onSearchQuery(event) {
10299
+ event.preventDefault();
10000
10300
  setLocation({
10001
- q: search,
10301
+ q: event.currentTarget.elements.filterInput.value,
10002
10302
  page: 0
10003
10303
  });
10004
- ev.preventDefault();
10005
- };
10304
+ }; // cleanup form on state.search change
10305
+
10006
10306
 
10007
10307
  React.useEffect(function () {
10008
- if (!searchText || searchText === '') {
10308
+ if (ref.current && (!searchText || searchText === '')) {
10009
10309
  ref.current.value = '';
10010
10310
  }
10011
10311
  }, [searchText]);
@@ -10025,7 +10325,8 @@ function GroupToolbar() {
10025
10325
  type: "text",
10026
10326
  className: "input is-size-7",
10027
10327
  placeholder: intl.formatMessage(genericMessages.search),
10028
- "data-test": "inputFilterTest"
10328
+ "data-test": "inputFilterTest",
10329
+ id: "filterInput"
10029
10330
  })
10030
10331
  }), jsxRuntime.jsx("div", {
10031
10332
  className: "control",
@@ -10063,12 +10364,12 @@ function GroupToolbar() {
10063
10364
  })]
10064
10365
  });
10065
10366
  }
10066
- function GroupsCtx(props) {
10067
- return jsxRuntime.jsx(TabsPanel, _extends({
10367
+ function GroupsCtx() {
10368
+ return jsxRuntime.jsx(TabsPanel, {
10068
10369
  tabs: tabs$4,
10069
10370
  currentTab: "Groups",
10070
10371
  rightToolbar: jsxRuntime.jsx(GroupToolbar, {})
10071
- }, props));
10372
+ });
10072
10373
  }
10073
10374
  var sortParsed = parser("_sort_asc=id");
10074
10375
  var searchParsed = parser('type_name=User');
@@ -10083,6 +10384,7 @@ function GroupCtx() {
10083
10384
  roles = _useState[0],
10084
10385
  setRoles = _useState[1];
10085
10386
 
10387
+ var groupDataContext = Ctx.context;
10086
10388
  React.useEffect(function () {
10087
10389
  var getRoles = function getRoles() {
10088
10390
  try {
@@ -10136,11 +10438,11 @@ function GroupCtx() {
10136
10438
  var addRole = function addRole(role) {
10137
10439
  try {
10138
10440
  return Promise.resolve(patch({
10139
- user_roles: Ctx.context.user_roles.concat(role)
10441
+ user_roles: groupDataContext.user_roles.concat(role)
10140
10442
  })).then(function (_ref) {
10141
10443
  var isError = _ref.isError,
10142
10444
  errorMessage = _ref.errorMessage;
10143
- handleResponse(isError, intl.formatMessage({
10445
+ handleResponse(!!isError, intl.formatMessage({
10144
10446
  id: "role_added_to_group",
10145
10447
  defaultMessage: [{
10146
10448
  "type": 0,
@@ -10154,7 +10456,7 @@ function GroupCtx() {
10154
10456
  }]
10155
10457
  }, {
10156
10458
  role: role
10157
- }), errorMessage);
10459
+ }), errorMessage != null ? errorMessage : '');
10158
10460
  });
10159
10461
  } catch (e) {
10160
10462
  return Promise.reject(e);
@@ -10164,13 +10466,13 @@ function GroupCtx() {
10164
10466
  var removeRole = function removeRole(role) {
10165
10467
  try {
10166
10468
  return Promise.resolve(patch({
10167
- user_roles: Ctx.context.user_roles.filter(function (r) {
10469
+ user_roles: groupDataContext.user_roles.filter(function (r) {
10168
10470
  return r !== role;
10169
10471
  })
10170
10472
  })).then(function (_ref2) {
10171
10473
  var isError = _ref2.isError,
10172
10474
  errorMessage = _ref2.errorMessage;
10173
- handleResponse(isError, intl.formatMessage({
10475
+ handleResponse(!!isError, intl.formatMessage({
10174
10476
  id: "role_removed_from_group",
10175
10477
  defaultMessage: [{
10176
10478
  "type": 0,
@@ -10184,7 +10486,7 @@ function GroupCtx() {
10184
10486
  }]
10185
10487
  }, {
10186
10488
  role: role
10187
- }), errorMessage);
10489
+ }), errorMessage != null ? errorMessage : '');
10188
10490
  });
10189
10491
  } catch (e) {
10190
10492
  return Promise.reject(e);
@@ -10194,30 +10496,32 @@ function GroupCtx() {
10194
10496
  var addUser = function addUser(newUserId) {
10195
10497
  try {
10196
10498
  var data = {};
10197
- Ctx.context.users.forEach(function (user) {
10499
+ groupDataContext.users.forEach(function (user) {
10198
10500
  data[user] = true;
10199
10501
  });
10200
10502
  data[newUserId] = true;
10201
10503
  return Promise.resolve(Ctx.client.rest.patch(Ctx.containerPath + "@groups/" + Ctx.context['@name'], {
10202
10504
  users: data
10203
- })).then(function (_ref3) {
10204
- var isError = _ref3.isError,
10205
- errorMessage = _ref3.errorMessage;
10206
- handleResponse(isError, intl.formatMessage({
10207
- id: "user_added_to_group",
10208
- defaultMessage: [{
10209
- "type": 0,
10210
- "value": "User "
10211
- }, {
10212
- "type": 1,
10213
- "value": "user"
10505
+ })).then(function (response) {
10506
+ return Promise.resolve(processResponse(response)).then(function (_ref3) {
10507
+ var isError = _ref3.isError,
10508
+ errorMessage = _ref3.errorMessage;
10509
+ handleResponse(isError, intl.formatMessage({
10510
+ id: "user_added_to_group",
10511
+ defaultMessage: [{
10512
+ "type": 0,
10513
+ "value": "User "
10514
+ }, {
10515
+ "type": 1,
10516
+ "value": "user"
10517
+ }, {
10518
+ "type": 0,
10519
+ "value": " added to group"
10520
+ }]
10214
10521
  }, {
10215
- "type": 0,
10216
- "value": " added to group"
10217
- }]
10218
- }, {
10219
- user: newUserId
10220
- }), errorMessage);
10522
+ user: newUserId
10523
+ }), errorMessage != null ? errorMessage : '');
10524
+ });
10221
10525
  });
10222
10526
  } catch (e) {
10223
10527
  return Promise.reject(e);
@@ -10227,29 +10531,31 @@ function GroupCtx() {
10227
10531
  var removeUser = function removeUser(userToRemove) {
10228
10532
  try {
10229
10533
  var data = {};
10230
- Ctx.context.users.forEach(function (user) {
10534
+ groupDataContext.users.forEach(function (user) {
10231
10535
  data[user] = userToRemove !== user;
10232
10536
  });
10233
10537
  return Promise.resolve(Ctx.client.rest.patch(Ctx.containerPath + "@groups/" + Ctx.context['@name'], {
10234
10538
  users: data
10235
- })).then(function (_ref4) {
10236
- var isError = _ref4.isError,
10237
- errorMessage = _ref4.errorMessage;
10238
- handleResponse(isError, intl.formatMessage({
10239
- id: "user_removed_from_group",
10240
- defaultMessage: [{
10241
- "type": 0,
10242
- "value": "User "
10243
- }, {
10244
- "type": 1,
10245
- "value": "user"
10539
+ })).then(function (response) {
10540
+ return Promise.resolve(processResponse(response)).then(function (_ref4) {
10541
+ var isError = _ref4.isError,
10542
+ errorMessage = _ref4.errorMessage;
10543
+ handleResponse(isError, intl.formatMessage({
10544
+ id: "user_removed_from_group",
10545
+ defaultMessage: [{
10546
+ "type": 0,
10547
+ "value": "User "
10548
+ }, {
10549
+ "type": 1,
10550
+ "value": "user"
10551
+ }, {
10552
+ "type": 0,
10553
+ "value": " removed from group"
10554
+ }]
10246
10555
  }, {
10247
- "type": 0,
10248
- "value": " removed from group"
10249
- }]
10250
- }, {
10251
- user: userToRemove
10252
- }), errorMessage);
10556
+ user: userToRemove
10557
+ }), errorMessage != null ? errorMessage : '');
10558
+ });
10253
10559
  });
10254
10560
  } catch (e) {
10255
10561
  return Promise.reject(e);
@@ -10304,11 +10610,13 @@ function GroupCtx() {
10304
10610
  })
10305
10611
  }), jsxRuntime.jsx(Select, {
10306
10612
  options: roles.filter(function (role) {
10307
- return !Ctx.context.user_roles.includes(role.value);
10613
+ return !groupDataContext.user_roles.includes(role.value);
10308
10614
  }),
10309
10615
  appendDefault: true,
10310
- onChange: addRole
10311
- }), jsxRuntime.jsx("hr", {}), Ctx.context.user_roles.map(function (urole) {
10616
+ onChange: function onChange(value) {
10617
+ return addRole(value);
10618
+ }
10619
+ }), jsxRuntime.jsx("hr", {}), groupDataContext.user_roles.map(function (urole) {
10312
10620
  return jsxRuntime.jsx("p", {
10313
10621
  className: "control",
10314
10622
  children: jsxRuntime.jsx(Tag, {
@@ -10340,7 +10648,7 @@ function GroupCtx() {
10340
10648
  traversal: Ctx,
10341
10649
  onChange: addUser,
10342
10650
  btnClass: "is-small"
10343
- }), jsxRuntime.jsx("hr", {}), Ctx.context.users.map(function (user) {
10651
+ }), jsxRuntime.jsx("hr", {}), groupDataContext.users.map(function (user) {
10344
10652
  return jsxRuntime.jsx("p", {
10345
10653
  className: "control",
10346
10654
  children: jsxRuntime.jsx(Tag, {
@@ -10489,7 +10797,7 @@ function Path() {
10489
10797
  var links = buildPaths(segments);
10490
10798
 
10491
10799
  if (segments.length === 1) {
10492
- return false;
10800
+ return null;
10493
10801
  }
10494
10802
 
10495
10803
  return jsxRuntime.jsx("nav", {
@@ -10623,11 +10931,13 @@ var getComponent = function getComponent(context, path, fallback) {
10623
10931
  fallback = undefined;
10624
10932
  }
10625
10933
 
10626
- if (!context) return;
10934
+ if (!context) return; // console.log("Component for path", path)
10935
+ // lookup by path
10627
10936
 
10628
10937
  if (registry.paths[path]) {
10629
10938
  return registry.paths[path];
10630
- }
10939
+ } // by type
10940
+
10631
10941
 
10632
10942
  if (registry.views[context['@type']]) {
10633
10943
  return registry.views[context['@type']];
@@ -10650,19 +10960,15 @@ var getItemsColumn = function getItemsColumn(type) {
10650
10960
  return undefined;
10651
10961
  };
10652
10962
 
10653
- var getForm = function getForm(type, fallback) {
10654
- if (fallback === void 0) {
10655
- fallback = BaseForm;
10656
- }
10963
+ var getView = function getView(name) {
10964
+ return registry.views[name];
10965
+ };
10657
10966
 
10658
- return registry.forms[type] || fallback;
10967
+ var getForm = function getForm(type, fallback) {
10968
+ return registry.forms[type] || fallback || BaseForm;
10659
10969
  };
10660
10970
 
10661
10971
  var getAction = function getAction(type, fallback) {
10662
- if (fallback === void 0) {
10663
- fallback = undefined;
10664
- }
10665
-
10666
10972
  return registry.actions[type] || fallback;
10667
10973
  };
10668
10974
 
@@ -10679,10 +10985,21 @@ var getSchemas = function getSchemas(type) {
10679
10985
  };
10680
10986
 
10681
10987
  var getFieldsToFilter = function getFieldsToFilter(type, fallback) {
10988
+ if (fallback === void 0) {
10989
+ fallback = ['title'];
10990
+ }
10991
+
10682
10992
  return registry.fieldsToFilter[type] || fallback;
10683
10993
  };
10684
10994
 
10685
10995
  var getDefaultSortValue = function getDefaultSortValue(type, fallback) {
10996
+ if (fallback === void 0) {
10997
+ fallback = {
10998
+ key: 'id',
10999
+ direction: 'des'
11000
+ };
11001
+ }
11002
+
10686
11003
  return registry.defaultSortValue[type] || fallback;
10687
11004
  };
10688
11005
 
@@ -10690,12 +11007,14 @@ var defaultComponent = function defaultComponent(context) {
10690
11007
  return context.is_folderish ? FolderCtx : ItemCtx;
10691
11008
  };
10692
11009
  function useRegistry(data) {
11010
+ // if data is provided we need to merge it into actual registry
10693
11011
  var ref = React__default['default'].useRef();
10694
11012
 
10695
11013
  if (data && !ref.current) {
10696
11014
  ref.current = true;
10697
11015
  Object.keys(data).map(function (key) {
10698
- return registry[key] = _extends({}, registry[key], data[key]);
11016
+ var registryKey = key;
11017
+ registry[registryKey] = _extends({}, registry[registryKey], data[registryKey]);
10699
11018
  });
10700
11019
  }
10701
11020
 
@@ -10710,86 +11029,26 @@ function useRegistry(data) {
10710
11029
  getItemsColumn: getItemsColumn,
10711
11030
  getFieldsToFilter: getFieldsToFilter,
10712
11031
  getDefaultSortValue: getDefaultSortValue,
10713
- getSchemas: getSchemas
11032
+ getSchemas: getSchemas,
11033
+ getView: getView
10714
11034
  };
10715
11035
  }
11036
+ /*
10716
11037
 
10717
- var initialState$4 = {
10718
- path: '',
10719
- loading: false,
10720
- context: undefined,
10721
- flash: {
10722
- message: undefined,
10723
- type: undefined
10724
- },
10725
- action: {
10726
- action: undefined,
10727
- params: undefined
11038
+ const registry = {
11039
+ paths: {
11040
+ "/db/guillotina/tags/": TagsContext
10728
11041
  },
10729
- permissions: undefined,
10730
- errorStatus: undefined,
10731
- registry: {},
10732
- refresh: undefined
10733
- };
10734
- function guillotinaReducer(state, action) {
10735
- switch (action.type) {
10736
- case 'SET_PATH':
10737
- return _extends({}, state, {
10738
- path: action.payload,
10739
- loading: true
10740
- });
10741
-
10742
- case 'SET_CONTEXT':
10743
- return _extends({}, state, action.payload, {
10744
- errorStatus: undefined,
10745
- loading: false
10746
- });
10747
-
10748
- case 'SET_ERROR':
10749
- return _extends({}, state, {
10750
- errorStatus: action.payload,
10751
- loading: false
10752
- });
10753
-
10754
- case 'SET_FLASH':
10755
- return _extends({}, state, action.payload);
10756
-
10757
- case 'CLEAR_FLASH':
10758
- return _extends({}, state, {
10759
- flash: {
10760
- message: undefined,
10761
- type: undefined
10762
- }
10763
- });
10764
-
10765
- case 'SET_ACTION':
10766
- return _extends({}, state, {
10767
- action: action.payload
10768
- });
11042
+ forms: {
11043
+ Tag: AddTagForm
11044
+ }
11045
+ }
10769
11046
 
10770
- case 'CLEAR_ACTION':
10771
- return _extends({}, state, {
10772
- action: {
10773
- action: undefined,
10774
- params: undefined
10775
- }
10776
- });
10777
11047
 
10778
- case 'REFRESH':
10779
- return _extends({}, state, {
10780
- refresh: Date.now(),
10781
- loading: !action.payload.transparent
10782
- });
11048
+ <guillotina registry={registry} />
10783
11049
 
10784
- case 'APPLY':
10785
- return _extends({}, state, {
10786
- context: _extends({}, state.context, action.payload)
10787
- });
10788
11050
 
10789
- default:
10790
- return state;
10791
- }
10792
- }
11051
+ */
10793
11052
 
10794
11053
  var actions = [
10795
11054
  {
@@ -13600,25 +13859,27 @@ function Guillotina(_ref) {
13600
13859
  props = _objectWithoutPropertiesLoose(_ref, ["auth", "locale"]);
13601
13860
 
13602
13861
  var messages = loadLocaleData(locale);
13603
- var url = props.url || 'http://localhost:8080';
13862
+ var url = props.url || 'http://localhost:8080'; // without trailing slash
13863
+
13604
13864
  var config = props.config || {};
13605
13865
  var client = useGuillotinaClient();
13606
13866
 
13607
13867
  var _useConfig = useConfig(config),
13608
13868
  Permissions = _useConfig.Permissions;
13609
13869
 
13610
- var registry = useRegistry(props.registry || {});
13870
+ var registry = useRegistry(props.registry); // Location is cooked routing solution (only uses search params)
13611
13871
 
13612
13872
  var _useLocation = useLocation(),
13613
- location = _useLocation[0];
13873
+ location = _useLocation[0]; // if there is no path provided just go to root
13874
+
13614
13875
 
13615
13876
  var searchPath = location.get('path') || '/';
13616
13877
 
13617
13878
  if (searchPath && searchPath !== '') {
13618
- initialState$4.path = searchPath;
13879
+ initialState.path = searchPath;
13619
13880
  }
13620
13881
 
13621
- var _useReducer = React.useReducer(guillotinaReducer, initialState$4),
13882
+ var _useReducer = React.useReducer(guillotinaReducer, initialState),
13622
13883
  state = _useReducer[0],
13623
13884
  dispatch = _useReducer[1];
13624
13885
 
@@ -13626,8 +13887,10 @@ function Guillotina(_ref) {
13626
13887
  refresh = state.refresh;
13627
13888
  React.useEffect(function () {
13628
13889
  dispatch({
13629
- type: 'SET_PATH',
13630
- payload: searchPath
13890
+ type: GuillotinaReducerActionTypes.SET_PATH,
13891
+ payload: {
13892
+ path: searchPath
13893
+ }
13631
13894
  });
13632
13895
  }, [searchPath]);
13633
13896
  React.useEffect(function () {
@@ -13636,14 +13899,18 @@ function Guillotina(_ref) {
13636
13899
  return Promise.resolve(client.getContext(path)).then(function (data) {
13637
13900
  if (data.status === 401) {
13638
13901
  dispatch({
13639
- type: 'SET_ERROR',
13640
- payload: 'notallowed'
13902
+ type: GuillotinaReducerActionTypes.SET_ERROR,
13903
+ payload: {
13904
+ errorStatus: 'notallowed'
13905
+ }
13641
13906
  });
13642
13907
  return;
13643
13908
  } else if (data.status === 404) {
13644
13909
  dispatch({
13645
- type: 'SET_ERROR',
13646
- payload: 'notfound'
13910
+ type: GuillotinaReducerActionTypes.SET_ERROR,
13911
+ payload: {
13912
+ errorStatus: 'notallowed'
13913
+ }
13647
13914
  });
13648
13915
  return;
13649
13916
  }
@@ -13652,7 +13919,7 @@ function Guillotina(_ref) {
13652
13919
  return Promise.resolve(client.canido(path, Permissions)).then(function (pr) {
13653
13920
  return Promise.resolve(pr.json()).then(function (permissions) {
13654
13921
  dispatch({
13655
- type: 'SET_CONTEXT',
13922
+ type: GuillotinaReducerActionTypes.SET_CONTEXT,
13656
13923
  payload: {
13657
13924
  context: context,
13658
13925
  permissions: permissions
@@ -13669,9 +13936,9 @@ function Guillotina(_ref) {
13669
13936
 
13670
13937
  initContext();
13671
13938
  }, [path, refresh, client]);
13672
- var ErrorBoundary = registry.get('views', 'ErrorBoundary');
13673
- var NotAllowed = registry.get('views', 'NotAllowed');
13674
- var NotFound = registry.get('views', 'NotFound');
13939
+ var ErrorBoundary = registry.getView('ErrorBoundary');
13940
+ var NotAllowed = registry.getView('NotAllowed');
13941
+ var NotFound = registry.getView('NotFound');
13675
13942
  var Path = registry.get('components', 'Path');
13676
13943
  var contextData = {
13677
13944
  url: url,
@@ -13694,7 +13961,7 @@ function Guillotina(_ref) {
13694
13961
  children: jsxRuntime.jsxs(ErrorBoundary, {
13695
13962
  children: [!errorStatus && jsxRuntime.jsx(TraversalProvider, _extends({}, contextData, {
13696
13963
  children: permissions && jsxRuntime.jsxs(React__default['default'].Fragment, {
13697
- children: [action.action && jsxRuntime.jsx(Action, _extends({}, action.params)), jsxRuntime.jsx("div", {
13964
+ children: [action.action && Action !== null && jsxRuntime.jsx(Action, _extends({}, action.params)), jsxRuntime.jsx("div", {
13698
13965
  className: "level",
13699
13966
  children: jsxRuntime.jsx("div", {
13700
13967
  className: "level-left",
@@ -13703,7 +13970,7 @@ function Guillotina(_ref) {
13703
13970
  children: jsxRuntime.jsx(Path, {})
13704
13971
  })
13705
13972
  })
13706
- }), jsxRuntime.jsx(Flash, {}), Main && jsxRuntime.jsx(ErrorBoundary, {
13973
+ }), jsxRuntime.jsx(Flash, {}), Main !== undefined && jsxRuntime.jsx(ErrorBoundary, {
13707
13974
  children: jsxRuntime.jsxs("div", {
13708
13975
  className: "box main-panel",
13709
13976
  children: [state.loading && jsxRuntime.jsx(Loading, {}), !state.loading && jsxRuntime.jsx(Main, {
@@ -13813,7 +14080,7 @@ var ERRORS = {
13813
14080
  var initialState$5 = {
13814
14081
  username: '',
13815
14082
  password: '',
13816
- loading: undefined,
14083
+ loading: false,
13817
14084
  errors: undefined
13818
14085
  };
13819
14086
  var Login = function Login(_ref) {
@@ -13829,7 +14096,7 @@ var Login = function Login(_ref) {
13829
14096
 
13830
14097
  var inputRef = React.useRef(null);
13831
14098
  React.useEffect(function () {
13832
- if (inputRef) {
14099
+ if (inputRef && inputRef.current) {
13833
14100
  inputRef.current.focus();
13834
14101
  }
13835
14102
  }, [inputRef]);
@@ -14050,30 +14317,30 @@ function RequiredFieldsForm(_ref) {
14050
14317
  dataTest: dataTest,
14051
14318
  children: [schema && schema.data && !schema.loading && schema.formFields.map(function (key) {
14052
14319
  if (!ignoreFiels.includes(key)) {
14053
- var _value$title;
14320
+ var _schema$data, _value$title, _schema$data2;
14054
14321
 
14055
- var value = schema.data.properties[key];
14322
+ var value = (_schema$data = schema.data) == null ? void 0 : _schema$data.properties[key];
14056
14323
  return jsxRuntime.jsx(EditComponent, {
14057
14324
  id: key,
14058
14325
  placeholder: (_value$title = value == null ? void 0 : value.title) != null ? _value$title : '',
14059
14326
  className: "",
14060
14327
  required: true,
14061
- schema: schema.data.properties[key],
14062
- setValue: function setValue(ev) {
14328
+ schema: (_schema$data2 = schema.data) == null ? void 0 : _schema$data2.properties[key],
14329
+ setValue: function setValue(value) {
14063
14330
  if (key === 'title') {
14064
14331
  var _extends2;
14065
14332
 
14066
14333
  setFormData(_extends({}, formData, (_extends2 = {
14067
- uuid: stringToSlug(ev)
14068
- }, _extends2[key] = ev, _extends2)));
14334
+ uuid: stringToSlug(value)
14335
+ }, _extends2[key] = value, _extends2)));
14069
14336
  } else if (key === 'uuid') {
14070
14337
  setFormData(_extends({}, formData, {
14071
- uuid: stringToSlug(ev)
14338
+ uuid: stringToSlug(value)
14072
14339
  }));
14073
14340
  } else {
14074
14341
  var _extends3;
14075
14342
 
14076
- setFormData(_extends({}, formData, (_extends3 = {}, _extends3[key] = ev, _extends3)));
14343
+ setFormData(_extends({}, formData, (_extends3 = {}, _extends3[key] = value, _extends3)));
14077
14344
  }
14078
14345
  },
14079
14346
  error: errors[key],
@@ -14204,6 +14471,7 @@ var Auth = /*#__PURE__*/function () {
14204
14471
  method: 'post'
14205
14472
  })).then(function (data) {
14206
14473
  if (data.status === 401) {
14474
+ // invalid token
14207
14475
  _this4.cleanAuth();
14208
14476
 
14209
14477
  _this4.logout();
@@ -14266,7 +14534,7 @@ var Auth = /*#__PURE__*/function () {
14266
14534
 
14267
14535
  if (!authToken) return {};
14268
14536
 
14269
- if (this.willExpire(expires) && this.retryRefresh < this.maxRetry) {
14537
+ if (this.willExpire(expires != null ? expires : '') && this.retryRefresh < this.maxRetry) {
14270
14538
 
14271
14539
  (function () {
14272
14540
  try {
@@ -14324,6 +14592,13 @@ var Auth = /*#__PURE__*/function () {
14324
14592
  return Auth;
14325
14593
  }();
14326
14594
 
14595
+ (function (Setting) {
14596
+ Setting["Allow"] = "Allow";
14597
+ Setting["AllowSingle"] = "AllowSingle";
14598
+ Setting["Deny"] = "Deny";
14599
+ Setting["Unset"] = "Unset";
14600
+ })(exports.Setting || (exports.Setting = {}));
14601
+
14327
14602
  exports.AddItem = AddItem;
14328
14603
  exports.AddPermission = AddPermission;
14329
14604
  exports.AllItemsCheckbox = AllItemsCheckbox;
@@ -14337,7 +14612,6 @@ exports.Button = Button;
14337
14612
  exports.Checkbox = Checkbox;
14338
14613
  exports.ClientContext = ClientContext;
14339
14614
  exports.ClientProvider = ClientProvider;
14340
- exports.Config = Config;
14341
14615
  exports.Confirm = Confirm;
14342
14616
  exports.ContainerCtx = ContainerCtx;
14343
14617
  exports.ContextToolbar = ContextToolbar;
@@ -14435,12 +14709,14 @@ exports.VocabularyRenderField = VocabularyRenderField;
14435
14709
  exports.base64ToArrayBuffer = base64ToArrayBuffer;
14436
14710
  exports.buildQs = buildQs;
14437
14711
  exports.classnames = classnames;
14712
+ exports.debounce = debounce;
14438
14713
  exports.defaultComponent = defaultComponent;
14714
+ exports.defaultConfig = defaultConfig;
14439
14715
  exports.formatDate = formatDate;
14440
14716
  exports.generateUID = generateUID;
14441
14717
  exports.genericFileMessages = genericFileMessages;
14442
14718
  exports.genericMessages = genericMessages;
14443
- exports.get = get$1;
14719
+ exports.get = get;
14444
14720
  exports.getActionsObject = getActionsObject;
14445
14721
  exports.getClient = getClient;
14446
14722
  exports.getNewId = getNewId;