@guillotinaweb/react-gmi 0.29.2-alpha.2 → 0.29.2-alpha.3

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 (69) 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/index.d.ts +2 -0
  14. package/dist/components/input/email.d.ts +1 -1
  15. package/dist/components/input/form_builder.d.ts +2 -2
  16. package/dist/components/input/input.d.ts +1 -1
  17. package/dist/components/input/search_input.d.ts +1 -1
  18. package/dist/components/input/search_input_list.d.ts +2 -2
  19. package/dist/components/input/select_vocabulary.d.ts +2 -2
  20. package/dist/components/input/upload.d.ts +1 -2
  21. package/dist/components/pagination.d.ts +1 -1
  22. package/dist/components/panel/permissions.d.ts +1 -1
  23. package/dist/components/panel/permissions_prinperm.d.ts +2 -2
  24. package/dist/components/panel/permissions_prinrole.d.ts +1 -1
  25. package/dist/components/panel/permissions_roleperm.d.ts +1 -1
  26. package/dist/components/path.d.ts +1 -1
  27. package/dist/components/properties_view.d.ts +2 -2
  28. package/dist/components/search_labels.d.ts +1 -1
  29. package/dist/components/search_options_labels.d.ts +1 -1
  30. package/dist/components/search_vocabulary_labels.d.ts +2 -2
  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/index.d.ts +0 -2
  44. package/dist/lib/auth.d.ts +14 -19
  45. package/dist/lib/client.d.ts +49 -36
  46. package/dist/lib/helpers.d.ts +10 -18
  47. package/dist/lib/processResponse.d.ts +9 -0
  48. package/dist/lib/rest.d.ts +9 -16
  49. package/dist/lib/utils.d.ts +3 -2
  50. package/dist/lib/validators.d.ts +1 -1
  51. package/dist/locales/generic_messages.d.ts +248 -0
  52. package/dist/models/index.d.ts +5 -5
  53. package/dist/models/sharing.d.ts +5 -5
  54. package/dist/react-gmi.esm.js +1215 -1041
  55. package/dist/react-gmi.esm.js.map +1 -1
  56. package/dist/react-gmi.js +1214 -1041
  57. package/dist/react-gmi.js.map +1 -1
  58. package/dist/react-gmi.modern.js +1182 -983
  59. package/dist/react-gmi.modern.js.map +1 -1
  60. package/dist/react-gmi.umd.js +1214 -1041
  61. package/dist/react-gmi.umd.js.map +1 -1
  62. package/dist/reducers/guillotina.d.ts +22 -8
  63. package/dist/types/global.d.ts +9 -0
  64. package/dist/types/guillotina.d.ts +153 -19
  65. package/dist/views/folder.d.ts +1 -1
  66. package/dist/views/groups.d.ts +1 -1
  67. package/dist/views/item.d.ts +1 -1
  68. package/dist/views/users.d.ts +1 -1
  69. package/package.json +2 -1
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import React, { createContext, useContext, useState, useCallback, useRef, useEffect, forwardRef, Children, isValidElement, cloneElement, Fragment as Fragment$1, Component, useReducer } from 'react';
2
+ import React, { createContext, useContext, useState, useCallback, useRef, useEffect, forwardRef, Children, isValidElement, cloneElement, Fragment as Fragment$1, useMemo, Component, useReducer } from 'react';
3
3
  import usePortal from 'react-useportal';
4
4
  import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
5
5
  import PropTypes from 'prop-types';
@@ -104,6 +104,97 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
104
104
  return it.next.bind(it);
105
105
  }
106
106
 
107
+ var initialState = {
108
+ path: '',
109
+ loading: false,
110
+ context: undefined,
111
+ flash: {
112
+ message: undefined,
113
+ type: undefined
114
+ },
115
+ action: {
116
+ action: undefined,
117
+ params: undefined
118
+ },
119
+ permissions: [],
120
+ errorStatus: undefined,
121
+ registry: {},
122
+ refresh: undefined
123
+ };
124
+ var GuillotinaReducerActionTypes;
125
+
126
+ (function (GuillotinaReducerActionTypes) {
127
+ GuillotinaReducerActionTypes["SET_PATH"] = "SET_PATH";
128
+ GuillotinaReducerActionTypes["SET_CONTEXT"] = "SET_CONTEXT";
129
+ GuillotinaReducerActionTypes["SET_ERROR"] = "SET_ERROR";
130
+ GuillotinaReducerActionTypes["SET_FLASH"] = "SET_FLASH";
131
+ GuillotinaReducerActionTypes["CLEAR_FLASH"] = "CLEAR_FLASH";
132
+ GuillotinaReducerActionTypes["SET_ACTION"] = "SET_ACTION";
133
+ GuillotinaReducerActionTypes["CLEAR_ACTION"] = "CLEAR_ACTION";
134
+ GuillotinaReducerActionTypes["REFRESH"] = "REFRESH";
135
+ GuillotinaReducerActionTypes["APPLY"] = "APPLY";
136
+ })(GuillotinaReducerActionTypes || (GuillotinaReducerActionTypes = {}));
137
+
138
+ function guillotinaReducer(state, action) {
139
+ switch (action.type) {
140
+ case GuillotinaReducerActionTypes.SET_PATH:
141
+ return _extends({}, state, {
142
+ path: action.payload.path,
143
+ loading: true
144
+ });
145
+
146
+ case GuillotinaReducerActionTypes.SET_CONTEXT:
147
+ return _extends({}, state, action.payload, {
148
+ errorStatus: undefined,
149
+ loading: false
150
+ });
151
+
152
+ case GuillotinaReducerActionTypes.SET_ERROR:
153
+ return _extends({}, state, {
154
+ errorStatus: action.payload.errorStatus,
155
+ loading: false
156
+ });
157
+
158
+ case GuillotinaReducerActionTypes.SET_FLASH:
159
+ return _extends({}, state, action.payload);
160
+
161
+ case GuillotinaReducerActionTypes.CLEAR_FLASH:
162
+ return _extends({}, state, {
163
+ flash: {
164
+ message: undefined,
165
+ type: undefined
166
+ }
167
+ });
168
+
169
+ case GuillotinaReducerActionTypes.SET_ACTION:
170
+ return _extends({}, state, {
171
+ action: action.payload
172
+ });
173
+
174
+ case GuillotinaReducerActionTypes.CLEAR_ACTION:
175
+ return _extends({}, state, {
176
+ action: {
177
+ action: undefined,
178
+ params: undefined
179
+ }
180
+ });
181
+
182
+ case GuillotinaReducerActionTypes.REFRESH:
183
+ return _extends({}, state, {
184
+ refresh: Date.now(),
185
+ loading: !action.payload.transparent
186
+ });
187
+
188
+ case GuillotinaReducerActionTypes.APPLY:
189
+ return _extends({}, state, {
190
+ context: _extends({}, state.context, action.payload.context)
191
+ });
192
+
193
+ default:
194
+ return state;
195
+ }
196
+ }
197
+
107
198
  var AuthContext = createContext({});
108
199
  var ClientContext = createContext(null);
109
200
  var Traversal = /*#__PURE__*/function () {
@@ -134,7 +225,7 @@ var Traversal = /*#__PURE__*/function () {
134
225
  transparent = _ref2$transparent === void 0 ? false : _ref2$transparent;
135
226
 
136
227
  this.dispatch({
137
- type: 'REFRESH',
228
+ type: GuillotinaReducerActionTypes.REFRESH,
138
229
  payload: {
139
230
  transparent: transparent
140
231
  }
@@ -144,14 +235,16 @@ var Traversal = /*#__PURE__*/function () {
144
235
  _proto.apply = function apply(data) {
145
236
  // apply a optimistic update to context
146
237
  this.dispatch({
147
- type: 'APPLY',
148
- payload: data
238
+ type: GuillotinaReducerActionTypes.APPLY,
239
+ payload: {
240
+ context: data
241
+ }
149
242
  });
150
243
  };
151
244
 
152
245
  _proto.flash = function flash(message, type) {
153
246
  this.dispatch({
154
- type: 'SET_FLASH',
247
+ type: GuillotinaReducerActionTypes.SET_FLASH,
155
248
  payload: {
156
249
  flash: {
157
250
  message: message,
@@ -168,7 +261,8 @@ var Traversal = /*#__PURE__*/function () {
168
261
 
169
262
  _proto.clearFlash = function clearFlash() {
170
263
  this.dispatch({
171
- type: 'CLEAR_FLASH'
264
+ type: GuillotinaReducerActionTypes.CLEAR_FLASH,
265
+ payload: {}
172
266
  });
173
267
  };
174
268
 
@@ -178,7 +272,7 @@ var Traversal = /*#__PURE__*/function () {
178
272
  }
179
273
 
180
274
  this.dispatch({
181
- type: 'SET_ACTION',
275
+ type: GuillotinaReducerActionTypes.SET_ACTION,
182
276
  payload: {
183
277
  action: action,
184
278
  params: params
@@ -188,7 +282,8 @@ var Traversal = /*#__PURE__*/function () {
188
282
 
189
283
  _proto.cancelAction = function cancelAction() {
190
284
  this.dispatch({
191
- type: 'CLEAR_ACTION'
285
+ type: GuillotinaReducerActionTypes.CLEAR_ACTION,
286
+ payload: {}
192
287
  });
193
288
  };
194
289
 
@@ -225,6 +320,10 @@ var Traversal = /*#__PURE__*/function () {
225
320
  }, {
226
321
  key: "context",
227
322
  get: function get() {
323
+ if (this.state.context === undefined) {
324
+ throw new Error('Context is not loaded');
325
+ }
326
+
228
327
  return this.state.context;
229
328
  }
230
329
  }, {
@@ -247,7 +346,13 @@ function TraversalProvider(_ref3) {
247
346
  });
248
347
  }
249
348
  function useTraversal() {
250
- return useContext(TraversalContext);
349
+ var traversal = useContext(TraversalContext);
350
+
351
+ if (!traversal) {
352
+ throw new Error('useTraversal must be used within a TraversalProvider');
353
+ }
354
+
355
+ return traversal;
251
356
  }
252
357
  function ClientProvider(_ref4) {
253
358
  var children = _ref4.children,
@@ -258,7 +363,13 @@ function ClientProvider(_ref4) {
258
363
  });
259
364
  }
260
365
  function useGuillotinaClient() {
261
- return useContext(ClientContext);
366
+ var client = useContext(ClientContext);
367
+
368
+ if (!client) {
369
+ throw new Error('useGuillotinaClient must be used within a ClientProvider');
370
+ }
371
+
372
+ return client;
262
373
  }
263
374
 
264
375
  var genericMessages = defineMessages({
@@ -785,7 +896,7 @@ function stringToSlug(str) {
785
896
  function sleep(ms) {
786
897
  return new Promise(function (resolve) {
787
898
  setTimeout(function () {
788
- resolve(null);
899
+ resolve();
789
900
  }, ms);
790
901
  });
791
902
  }
@@ -814,8 +925,6 @@ var getActionsObject = function getActionsObject(intl, multiple) {
814
925
  };
815
926
 
816
927
  var Button = function Button(_ref) {
817
- var _ref2;
818
-
819
928
  var children = _ref.children,
820
929
  _ref$className = _ref.className,
821
930
  className = _ref$className === void 0 ? 'is-primary' : _ref$className,
@@ -827,9 +936,7 @@ var Button = function Button(_ref) {
827
936
  _ref$disabled = _ref.disabled,
828
937
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
829
938
  dataTest = _ref.dataTest;
830
-
831
- var css = (_ref2 = []).concat.apply(_ref2, ['button'].concat(className.split(' ')));
832
-
939
+ var css = [].concat(className.split(' '), ['button']);
833
940
  if (loading) css = css.concat('is-loading');
834
941
  return jsx("p", {
835
942
  className: "control",
@@ -844,6 +951,50 @@ var Button = function Button(_ref) {
844
951
  });
845
952
  };
846
953
 
954
+ var formatDate = function formatDate(str) {
955
+ var d = new Date(str);
956
+ var minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
957
+ return d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear() + " " + d.getHours() + ":" + minutes;
958
+ };
959
+ var get = function get(obj, path, defValue) {
960
+ var _pathArray$reduce;
961
+
962
+ // If path is not defined or it has false value
963
+ if (!path) return defValue; // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.
964
+ // Regex explained: https://regexr.com/58j0k
965
+
966
+ var pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g); // Find value if exist return otherwise return undefined value;
967
+
968
+ if (pathArray === null) return defValue;
969
+ return (_pathArray$reduce = pathArray.reduce(function (prevObj, key) {
970
+ return prevObj && prevObj[key];
971
+ }, obj)) != null ? _pathArray$reduce : defValue;
972
+ };
973
+ function getNewId(id) {
974
+ if (id === void 0) {
975
+ id = '';
976
+ }
977
+
978
+ var suffix = '-copy-';
979
+ var rgx = new RegExp("($|" + suffix + "\\d*)");
980
+ return stringToSlug(id).replace(rgx, function (r) {
981
+ var num = parseInt(r.replace(suffix, '') || '0');
982
+ return "" + suffix + (num + 1);
983
+ });
984
+ }
985
+ function debounce(callback, wait) {
986
+ var timer;
987
+ return function () {
988
+ var _arguments = arguments;
989
+ clearTimeout(timer);
990
+ return new Promise(function (resolve) {
991
+ timer = setTimeout(function () {
992
+ return resolve(callback.apply(void 0, [].slice.call(_arguments)));
993
+ }, wait);
994
+ });
995
+ };
996
+ }
997
+
847
998
  function Modal(props) {
848
999
  var isActive = props.isActive,
849
1000
  setActive = props.setActive,
@@ -940,7 +1091,7 @@ function PathTree(_ref2) {
940
1091
  }), jsxs("form", {
941
1092
  onSubmit: function onSubmit(e) {
942
1093
  e.preventDefault();
943
- onConfirm(e.target[0].value, e.target);
1094
+ onConfirm(get(e, 'target.0.value', ''), e.target);
944
1095
  },
945
1096
  children: [jsx("small", {
946
1097
  style: {
@@ -972,51 +1123,6 @@ function PathTree(_ref2) {
972
1123
  });
973
1124
  }
974
1125
 
975
- function useSetState(initialState) {
976
- var _useState = useState(initialState),
977
- state = _useState[0],
978
- set = _useState[1];
979
-
980
- var setState = 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
1126
  var processResponse = function processResponse(res, ready_body) {
1021
1127
  if (ready_body === void 0) {
1022
1128
  ready_body = true;
@@ -1036,7 +1142,7 @@ var processResponse = function processResponse(res, ready_body) {
1036
1142
  return {
1037
1143
  isError: true,
1038
1144
  loading: false,
1039
- errorMessage: getErrorMessage(_res$json2, res.status),
1145
+ errorMessage: getErrorMessage(_res$json2, res.status).toString(),
1040
1146
  response: res
1041
1147
  };
1042
1148
  });
@@ -1045,10 +1151,66 @@ var processResponse = function processResponse(res, ready_body) {
1045
1151
  }
1046
1152
  };
1047
1153
 
1048
- var patch = function patch(setState, Ctx) {
1154
+ var getErrorMessage = function getErrorMessage(dataError, defaultValue) {
1155
+ if (dataError && dataError.details) {
1156
+ return dataError.details;
1157
+ } else if (dataError && dataError.reason) {
1158
+ return dataError.reason;
1159
+ }
1160
+
1161
+ return defaultValue;
1162
+ };
1163
+
1164
+ /**
1165
+ * Do setState like react class component.
1166
+ */
1167
+
1168
+ function useSetState(initialState) {
1169
+ var _useState = useState(initialState),
1170
+ state = _useState[0],
1171
+ setState = _useState[1]; // Function which accepts a partial state to merge
1172
+
1173
+
1174
+ var setCustomState = useCallback(function (newPartialState) {
1175
+ try {
1176
+ setState(function (prevState) {
1177
+ return _extends({}, prevState, newPartialState);
1178
+ });
1179
+ } catch (error) {
1180
+ // eslint-disable-next-line no-console
1181
+ console.error(error);
1182
+ }
1183
+ }, []); // Return
1184
+
1185
+ return [state, setCustomState];
1186
+ } // **** Export Default **** //
1187
+
1188
+ function _catch(body, recover) {
1189
+ try {
1190
+ var result = body();
1191
+ } catch (e) {
1192
+ return recover(e);
1193
+ }
1194
+
1195
+ if (result && result.then) {
1196
+ return result.then(void 0, recover);
1197
+ }
1198
+
1199
+ return result;
1200
+ }
1201
+
1202
+ var initial = {
1203
+ loading: undefined,
1204
+ isError: false,
1205
+ errorMessage: undefined,
1206
+ result: undefined,
1207
+ response: undefined
1208
+ };
1209
+
1210
+ function patch(setState, Ctx) {
1049
1211
  return function (data, endpoint, body) {
1050
- if (endpoint === void 0) {
1051
- endpoint = undefined;
1212
+ if (data === void 0) {
1213
+ data = {};
1052
1214
  }
1053
1215
 
1054
1216
  if (body === void 0) {
@@ -1056,7 +1218,7 @@ var patch = function patch(setState, Ctx) {
1056
1218
  }
1057
1219
 
1058
1220
  try {
1059
- function _temp5() {
1221
+ function _temp3() {
1060
1222
  setState(newState);
1061
1223
  return newState;
1062
1224
  }
@@ -1066,7 +1228,7 @@ var patch = function patch(setState, Ctx) {
1066
1228
  });
1067
1229
  var newState = {};
1068
1230
 
1069
- var _temp6 = _catch(function () {
1231
+ var _temp4 = _catch(function () {
1070
1232
  var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
1071
1233
  return Promise.resolve(Ctx.client.patch(path, data)).then(function (res) {
1072
1234
  return Promise.resolve(processResponse(res, body)).then(function (_processResponse) {
@@ -1081,29 +1243,25 @@ var patch = function patch(setState, Ctx) {
1081
1243
  };
1082
1244
  });
1083
1245
 
1084
- return Promise.resolve(_temp6 && _temp6.then ? _temp6.then(_temp5) : _temp5(_temp6));
1246
+ return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(_temp3) : _temp3(_temp4));
1085
1247
  } catch (e) {
1086
1248
  return Promise.reject(e);
1087
1249
  }
1088
1250
  };
1089
- };
1251
+ }
1090
1252
 
1091
- var del = function del(setState, Ctx) {
1253
+ function del(setState, Ctx) {
1092
1254
  return function (data, endpoint, body) {
1093
1255
  if (data === void 0) {
1094
1256
  data = {};
1095
1257
  }
1096
1258
 
1097
- if (endpoint === void 0) {
1098
- endpoint = undefined;
1099
- }
1100
-
1101
1259
  if (body === void 0) {
1102
1260
  body = false;
1103
1261
  }
1104
1262
 
1105
1263
  try {
1106
- function _temp9() {
1264
+ function _temp7() {
1107
1265
  setState(newState);
1108
1266
  return newState;
1109
1267
  }
@@ -1113,7 +1271,7 @@ var del = function del(setState, Ctx) {
1113
1271
  });
1114
1272
  var newState = {};
1115
1273
 
1116
- var _temp10 = _catch(function () {
1274
+ var _temp8 = _catch(function () {
1117
1275
  var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
1118
1276
  return Promise.resolve(Ctx.client.delete(path, data)).then(function (res) {
1119
1277
  return Promise.resolve(processResponse(res, body)).then(function (_processResponse2) {
@@ -1128,17 +1286,17 @@ var del = function del(setState, Ctx) {
1128
1286
  };
1129
1287
  });
1130
1288
 
1131
- return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(_temp9) : _temp9(_temp10));
1289
+ return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8));
1132
1290
  } catch (e) {
1133
1291
  return Promise.reject(e);
1134
1292
  }
1135
1293
  };
1136
- };
1294
+ }
1137
1295
 
1138
- var post = function post(setState, Ctx) {
1296
+ function post(setState, Ctx) {
1139
1297
  return function (data, endpoint, body) {
1140
- if (endpoint === void 0) {
1141
- endpoint = undefined;
1298
+ if (data === void 0) {
1299
+ data = {};
1142
1300
  }
1143
1301
 
1144
1302
  if (body === void 0) {
@@ -1146,7 +1304,7 @@ var post = function post(setState, Ctx) {
1146
1304
  }
1147
1305
 
1148
1306
  try {
1149
- function _temp13() {
1307
+ function _temp11() {
1150
1308
  setState(newState);
1151
1309
  return newState;
1152
1310
  }
@@ -1156,7 +1314,7 @@ var post = function post(setState, Ctx) {
1156
1314
  });
1157
1315
  var newState = {};
1158
1316
 
1159
- var _temp14 = _catch(function () {
1317
+ var _temp12 = _catch(function () {
1160
1318
  var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
1161
1319
  return Promise.resolve(Ctx.client.post(path, data)).then(function (res) {
1162
1320
  return Promise.resolve(processResponse(res, body)).then(function (_processResponse3) {
@@ -1171,21 +1329,17 @@ var post = function post(setState, Ctx) {
1171
1329
  };
1172
1330
  });
1173
1331
 
1174
- return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(_temp13) : _temp13(_temp14));
1332
+ return Promise.resolve(_temp12 && _temp12.then ? _temp12.then(_temp11) : _temp11(_temp12));
1175
1333
  } catch (e) {
1176
1334
  return Promise.reject(e);
1177
1335
  }
1178
1336
  };
1179
- };
1337
+ }
1180
1338
 
1181
- var get = function get(setState, Ctx) {
1339
+ function get$1(setState, Ctx) {
1182
1340
  return function (endpoint) {
1183
- if (endpoint === void 0) {
1184
- endpoint = undefined;
1185
- }
1186
-
1187
1341
  try {
1188
- function _temp17() {
1342
+ function _temp15() {
1189
1343
  setState(newState);
1190
1344
  return newState;
1191
1345
  }
@@ -1195,7 +1349,7 @@ var get = function get(setState, Ctx) {
1195
1349
  });
1196
1350
  var newState = {};
1197
1351
 
1198
- var _temp18 = _catch(function () {
1352
+ var _temp16 = _catch(function () {
1199
1353
  var path = endpoint ? "" + Ctx.path + endpoint : Ctx.path;
1200
1354
  return Promise.resolve(Ctx.client.get(path)).then(function (res) {
1201
1355
  return Promise.resolve(processResponse(res, true)).then(function (_processResponse4) {
@@ -1210,12 +1364,16 @@ var get = function get(setState, Ctx) {
1210
1364
  };
1211
1365
  });
1212
1366
 
1213
- return Promise.resolve(_temp18 && _temp18.then ? _temp18.then(_temp17) : _temp17(_temp18));
1367
+ return Promise.resolve(_temp16 && _temp16.then ? _temp16.then(_temp15) : _temp15(_temp16));
1214
1368
  } catch (e) {
1215
1369
  return Promise.reject(e);
1216
1370
  }
1217
1371
  };
1218
- };
1372
+ } // const get = (
1373
+ // setState: (value: Partial<State>) => void,
1374
+ // Ctx: Traversal
1375
+ // ) =>
1376
+
1219
1377
 
1220
1378
  function useCrudContext() {
1221
1379
  var Ctx = useTraversal();
@@ -1229,7 +1387,7 @@ function useCrudContext() {
1229
1387
  patch: patch(setState, Ctx),
1230
1388
  del: del(setState, Ctx),
1231
1389
  post: post(setState, Ctx),
1232
- get: get(setState, Ctx)
1390
+ get: get$1(setState, Ctx)
1233
1391
  });
1234
1392
  }
1235
1393
 
@@ -1277,9 +1435,6 @@ function AddItem(props) {
1277
1435
  children: jsx(Form, {
1278
1436
  loading: loading,
1279
1437
  onSubmit: doSubmit,
1280
- onError: function onError(err) {
1281
- return console.log(err);
1282
- },
1283
1438
  actionName: 'Add ' + type,
1284
1439
  title: 'Add ' + type,
1285
1440
  type: type,
@@ -1289,7 +1444,7 @@ function AddItem(props) {
1289
1444
  }
1290
1445
 
1291
1446
  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 = {
1447
+ var defaultConfig = {
1293
1448
  DisabledTypes: ['UserManager', 'GroupManager'],
1294
1449
  PageSize: 10,
1295
1450
  DelayActions: 200,
@@ -1300,21 +1455,41 @@ var Config = {
1300
1455
  return (schema == null ? void 0 : schema.widget) === 'file' || (schema == null ? void 0 : schema.widget) === 'select' || (schema == null ? void 0 : schema.type) === 'array';
1301
1456
  }
1302
1457
  };
1303
- var calculated = Object.assign({}, Config);
1304
-
1305
- var addConfig = function addConfig(additional, original) {
1306
- var rest = Object.assign({}, original);
1307
- Object.keys(additional).forEach(function (item) {
1308
- if (typeof Config[item] === 'object' && Array.isArray(Config[item])) {
1309
- rest[item] = [].concat(Config[item], additional[item]);
1310
- } else if (typeof Config[item] === 'object') {
1311
- rest[item] = Object.assign({}, Config[item], additional[item]);
1458
+ var calculated = Object.assign({}, defaultConfig);
1459
+
1460
+ function addConfig(updates, currentConfig) {
1461
+ var updatedConfig = _extends({}, currentConfig);
1462
+
1463
+ Object.entries(updates).forEach(function (_ref) {
1464
+ var key = _ref[0],
1465
+ value = _ref[1];
1466
+ var currentKey = key;
1467
+ var currentValue = currentConfig[currentKey];
1468
+
1469
+ if (Array.isArray(value) && Array.isArray(currentValue)) {
1470
+ var _extends2;
1471
+
1472
+ // Correctly type the array concatenation
1473
+ updatedConfig = _extends({}, updatedConfig, (_extends2 = {}, _extends2[currentKey] = [].concat(currentValue, value), _extends2));
1474
+ } else if (isPlainObject(value) && isPlainObject(currentValue)) {
1475
+ var _extends3;
1476
+
1477
+ // Correctly type the object merging
1478
+ updatedConfig = _extends({}, updatedConfig, (_extends3 = {}, _extends3[currentKey] = _extends({}, currentValue, value), _extends3));
1312
1479
  } else {
1313
- rest[item] = additional[item];
1480
+ var _extends4;
1481
+
1482
+ // Directly assign all other types
1483
+ updatedConfig = _extends({}, updatedConfig, (_extends4 = {}, _extends4[currentKey] = value, _extends4));
1314
1484
  }
1315
1485
  });
1316
- return rest;
1317
- };
1486
+ return updatedConfig;
1487
+ } // Helper function to check if a value is a plain object (and not a React node, etc.)
1488
+
1489
+
1490
+ function isPlainObject(value) {
1491
+ return Object.prototype.toString.call(value) === '[object Object]';
1492
+ }
1318
1493
 
1319
1494
  function useConfig(cfg) {
1320
1495
  if (cfg === void 0) {
@@ -1338,7 +1513,7 @@ function RemoveItems(props) {
1338
1513
  setLoading(true);
1339
1514
  var actions = items.map(function (item) {
1340
1515
  try {
1341
- return Promise.resolve(Ctx.client.delete("" + Ctx.path + item['@name'])).then(function (res) {
1516
+ return Promise.resolve(Ctx.client.delete("" + Ctx.path + item.id, {})).then(function (res) {
1342
1517
  var _temp = function () {
1343
1518
  if (!res.ok) {
1344
1519
  return Promise.resolve(res.json()).then(function (err) {
@@ -1384,9 +1559,9 @@ function RemoveItems(props) {
1384
1559
 
1385
1560
  var _props$items = props.items,
1386
1561
  items = _props$items === void 0 ? [] : _props$items;
1387
- var last = items[items.length - 1]['@name'];
1562
+ var last = items[items.length - 1].id;
1388
1563
  var itemsNames = items.map(function (item) {
1389
- return item['@name'];
1564
+ return item.id;
1390
1565
  }).join(', ').replace(", " + last, " and " + last);
1391
1566
  return jsx(Confirm, {
1392
1567
  loading: loading,
@@ -1413,7 +1588,7 @@ var Checkbox = function Checkbox(_ref) {
1413
1588
  dataTest = _ref.dataTest;
1414
1589
  var inputRef = useRef(null);
1415
1590
 
1416
- var _useState = useState(checked),
1591
+ var _useState = useState(!!checked),
1417
1592
  state = _useState[0],
1418
1593
  setState = _useState[1];
1419
1594
 
@@ -1432,13 +1607,13 @@ var Checkbox = function Checkbox(_ref) {
1432
1607
  className: "field",
1433
1608
  children: jsxs("label", {
1434
1609
  htmlFor: id,
1435
- className: classnames(['checkbox', className]),
1610
+ className: classnames(['checkbox', className != null ? className : '']),
1436
1611
  children: [jsx("input", {
1437
1612
  ref: inputRef,
1438
1613
  disabled: disabled || loading,
1439
1614
  id: id,
1440
1615
  type: "checkbox",
1441
- className: classnames(['checkbox', classNameInput]),
1616
+ className: classnames(['checkbox', classNameInput != null ? classNameInput : '']),
1442
1617
  checked: state,
1443
1618
  onChange: updateState,
1444
1619
  "data-test": dataTest
@@ -1476,7 +1651,7 @@ var applyValidators = function applyValidators(value, validators) {
1476
1651
  return result;
1477
1652
  };
1478
1653
 
1479
- var useInput = function useInput(onChange, value, validator) {
1654
+ var useInput = function useInput(onChange, value, validators) {
1480
1655
  var _useState = useState({
1481
1656
  hasError: false,
1482
1657
  value: value
@@ -1485,7 +1660,7 @@ var useInput = function useInput(onChange, value, validator) {
1485
1660
  setState = _useState[1];
1486
1661
 
1487
1662
  var onUpdate = function onUpdate(ev) {
1488
- var value = ev && ev.target ? ev.target.value : ev ? ev : '';
1663
+ var value = ev && ev.target ? ev.target.value : '';
1489
1664
  setState({
1490
1665
  value: value,
1491
1666
  hasError: false
@@ -1494,7 +1669,7 @@ var useInput = function useInput(onChange, value, validator) {
1494
1669
  };
1495
1670
 
1496
1671
  var onBlur = function onBlur() {
1497
- var hasError = applyValidators(state.value, validator) === false;
1672
+ var hasError = applyValidators(state.value, validators) === false;
1498
1673
  if (hasError) setState({
1499
1674
  value: state.value,
1500
1675
  hasError: hasError
@@ -1627,10 +1802,10 @@ var Input = forwardRef(function (_ref, ref) {
1627
1802
  dataTest = _ref$dataTest === void 0 ? 'testInput' : _ref$dataTest,
1628
1803
  disabled = _ref.disabled,
1629
1804
  onKeyUp = _ref.onKeyUp;
1630
- var validatorFn = null;
1805
+ var validatorFn = [];
1631
1806
 
1632
1807
  if (required) {
1633
- validatorFn = Array.isArray(validator) ? validator.push(notEmpty) : [validator, notEmpty];
1808
+ validatorFn = Array.isArray(validator) ? [].concat(validator, [notEmpty]) : [validator, notEmpty];
1634
1809
  }
1635
1810
 
1636
1811
  var _useInput = useInput(onChange, value != null ? value : '', validatorFn),
@@ -1645,15 +1820,15 @@ var Input = forwardRef(function (_ref, ref) {
1645
1820
  setMounted = _useState2[1]; // eslint-disable-next-line
1646
1821
 
1647
1822
 
1648
- ref = ref || useRef();
1823
+ var newRef = ref || useRef();
1649
1824
  useEffect(function () {
1650
1825
  setMounted(true);
1651
1826
  }, []);
1652
1827
  useEffect(function () {
1653
- if (autofocus && !error && ref != null && typeof ref !== 'function') {
1654
- ref.current.focus();
1828
+ if (autofocus && !error && newRef != null && typeof newRef !== 'function' && newRef.current) {
1829
+ newRef.current.focus();
1655
1830
  }
1656
- }, [mounted, autofocus, ref, error]);
1831
+ }, [mounted, autofocus, newRef, error]);
1657
1832
  var theError = state.hasError ? errorMessage || 'invalid field' : '';
1658
1833
  var statusClasses = state.hasError ? 'is-danger' : '';
1659
1834
 
@@ -1694,7 +1869,8 @@ Input.displayName = 'Input';
1694
1869
 
1695
1870
  var Icon = function Icon(_ref) {
1696
1871
  var icon = _ref.icon,
1697
- className = _ref.className,
1872
+ _ref$className = _ref.className,
1873
+ className = _ref$className === void 0 ? '' : _ref$className,
1698
1874
  align = _ref.align;
1699
1875
  var addClass = className ? className.split(' ') : [className];
1700
1876
  align = align || 'is-right';
@@ -1805,7 +1981,7 @@ function FormBuilder(_ref) {
1805
1981
  remotes = _ref$remotes === void 0 ? {} : _ref$remotes,
1806
1982
  _ref$submitButton = _ref.submitButton,
1807
1983
  submitButton = _ref$submitButton === void 0 ? true : _ref$submitButton;
1808
- var ref = useRef();
1984
+ var ref = useRef(null);
1809
1985
  var properties = schema.properties,
1810
1986
  required = schema.required;
1811
1987
  var values = Object.assign({}, formData || {}); // build initial state
@@ -1818,7 +1994,7 @@ function FormBuilder(_ref) {
1818
1994
  initialState[element] = values[element] || undefined;
1819
1995
  }); // Register remotes
1820
1996
 
1821
- if (!ref.current) {
1997
+ if (ref.current === null) {
1822
1998
  ref.current = {};
1823
1999
  Object.keys(remotes).forEach(function (item) {
1824
2000
  return ref.current[item] = remotes[item];
@@ -1835,15 +2011,16 @@ function FormBuilder(_ref) {
1835
2011
  ref.current = ref.current || {};
1836
2012
 
1837
2013
  var onUpdate = function onUpdate(field) {
1838
- return function (ev) {
1839
- ref.current[field] = ev.target ? ev.target.value : ev.value || ev;
2014
+ return function (value) {
2015
+ ref.current[field] = value;
1840
2016
  };
1841
2017
  };
1842
2018
 
1843
2019
  var GetTag = function GetTag(_ref2) {
1844
2020
  var field = _ref2.field;
1845
2021
  var property = properties[field];
1846
- var Tag = formComponents[property.widget || property.type];
2022
+ var key = property.widget || property.type;
2023
+ var Tag = formComponents[key];
1847
2024
  var props = {
1848
2025
  value: initialState[field],
1849
2026
  onChange: onUpdate(field),
@@ -1858,7 +2035,6 @@ function FormBuilder(_ref) {
1858
2035
  props.placeholder += ' *';
1859
2036
  }
1860
2037
 
1861
- Tag.displayName = field + "Field";
1862
2038
  return jsx(Tag, _extends({}, props));
1863
2039
  };
1864
2040
 
@@ -1927,9 +2103,13 @@ var Select = forwardRef(function (_ref, ref) {
1927
2103
  selectValue = selectValue.concat([ev.target.selectedOptions[i].value]);
1928
2104
  }
1929
2105
 
1930
- onChange(selectValue);
2106
+ if (onChange) {
2107
+ onChange(selectValue);
2108
+ }
1931
2109
  } else {
1932
- onChange(ev.target.value);
2110
+ if (onChange) {
2111
+ onChange(ev.target.value);
2112
+ }
1933
2113
  }
1934
2114
  };
1935
2115
 
@@ -1978,19 +2158,151 @@ var Select = forwardRef(function (_ref, ref) {
1978
2158
  });
1979
2159
  Select.displayName = 'Select';
1980
2160
 
1981
- // https://github.com/molefrog/wouter
2161
+ function _catch$1(body, recover) {
2162
+ try {
2163
+ var result = body();
2164
+ } catch (e) {
2165
+ return recover(e);
2166
+ }
1982
2167
 
1983
- var setURLParams = function setURLParams(p) {
1984
- return window.history.pushState(0, '0', '' + '?' + p.toString().replace(/%2F/g, '/'));
1985
- };
2168
+ if (result && result.then) {
2169
+ return result.then(void 0, recover);
2170
+ }
1986
2171
 
1987
- var clean = function clean(to) {
1988
- var current = new URLSearchParams();
1989
- Object.keys(to).forEach(function (_key) {
1990
- return current.set(_key, to[_key]);
1991
- });
1992
- setURLParams(current);
1993
- };
2172
+ return result;
2173
+ }
2174
+
2175
+ function useVocabulary(vocabularyName, path) {
2176
+ var traversal = useTraversal();
2177
+
2178
+ var _useSetState = useSetState({
2179
+ data: undefined,
2180
+ loading: false,
2181
+ error: undefined
2182
+ }),
2183
+ vocabulary = _useSetState[0],
2184
+ setVocabulary = _useSetState[1];
2185
+
2186
+ var getPath = function getPath() {
2187
+ if (path) return path;
2188
+ return traversal.path + "@vocabularies/" + vocabularyName;
2189
+ };
2190
+
2191
+ useEffect(function () {
2192
+ var getVocabulary = function getVocabulary() {
2193
+ try {
2194
+ var _temp3 = function () {
2195
+ if (vocabularyName && vocabulary.data === undefined && !vocabulary.loading) {
2196
+ var _temp4 = _catch$1(function () {
2197
+ setVocabulary({
2198
+ loading: true
2199
+ });
2200
+ return Promise.resolve(traversal.client.get(getPath())).then(function (data) {
2201
+ return Promise.resolve(data.json()).then(function (dataJson) {
2202
+ setVocabulary({
2203
+ loading: false,
2204
+ data: dataJson
2205
+ });
2206
+ });
2207
+ });
2208
+ }, function (err) {
2209
+ setVocabulary({
2210
+ loading: false,
2211
+ error: err,
2212
+ data: undefined
2213
+ });
2214
+ });
2215
+
2216
+ if (_temp4 && _temp4.then) return _temp4.then(function () {});
2217
+ }
2218
+ }();
2219
+
2220
+ return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
2221
+ } catch (e) {
2222
+ return Promise.reject(e);
2223
+ }
2224
+ };
2225
+
2226
+ getVocabulary();
2227
+ }, [vocabularyName, vocabulary, path]);
2228
+ return vocabulary;
2229
+ }
2230
+
2231
+ var SelectVocabulary = forwardRef(function (_ref, ref) {
2232
+ var vocabularyName = _ref.vocabularyName,
2233
+ className = _ref.className,
2234
+ classWrap = _ref.classWrap,
2235
+ val = _ref.val,
2236
+ dataTest = _ref.dataTest,
2237
+ multiple = _ref.multiple,
2238
+ onChange = _ref.onChange,
2239
+ id = _ref.id,
2240
+ placeholder = _ref.placeholder;
2241
+ var vocabulary = useVocabulary(vocabularyName);
2242
+
2243
+ var getOptions = function getOptions() {
2244
+ if (get(vocabulary, 'data.items', null)) {
2245
+ var _vocabulary$data$item, _vocabulary$data;
2246
+
2247
+ 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) {
2248
+ return {
2249
+ text: item.title,
2250
+ value: item.token
2251
+ };
2252
+ });
2253
+ return vocData;
2254
+ }
2255
+
2256
+ return [];
2257
+ };
2258
+
2259
+ var getProps = function getProps() {
2260
+ if (multiple) {
2261
+ var currentValue = val || [];
2262
+ return {
2263
+ multiple: true,
2264
+ size: 5,
2265
+ value: currentValue,
2266
+ options: getOptions()
2267
+ };
2268
+ }
2269
+
2270
+ return {
2271
+ value: val != null ? val : '',
2272
+ appendDefault: true,
2273
+ options: getOptions()
2274
+ };
2275
+ };
2276
+
2277
+ if (vocabulary.data === undefined || vocabulary.loading) {
2278
+ return jsx("div", {});
2279
+ }
2280
+
2281
+ return jsx(Select, _extends({}, getProps(), {
2282
+ className: className,
2283
+ classWrap: classWrap || 'is-fullwidth',
2284
+ dataTest: dataTest,
2285
+ ref: ref,
2286
+ onChange: onChange,
2287
+ id: id,
2288
+ placeholder: placeholder
2289
+ }));
2290
+ });
2291
+ SelectVocabulary.displayName = 'SelectVocabulary';
2292
+
2293
+ // https://github.com/molefrog/wouter
2294
+
2295
+ var setURLParams = function setURLParams(p) {
2296
+ return window.history.pushState(0, '0', '' + '?' + p.toString().replace(/%2F/g, '/'));
2297
+ };
2298
+
2299
+ var clean = function clean(to) {
2300
+ var current = new URLSearchParams();
2301
+ Object.keys(to).forEach(function (_key) {
2302
+ return current.set(_key, to[_key]);
2303
+ });
2304
+ setURLParams(current);
2305
+ };
1994
2306
 
1995
2307
  var useLocation = function useLocation() {
1996
2308
  var _useState = useState(currentSearchParams()),
@@ -2056,19 +2368,30 @@ var patched = 0;
2056
2368
 
2057
2369
  var patchHistoryEvents = function patchHistoryEvents() {
2058
2370
  if (patched) return;
2059
- ['pushState', 'replaceState'].map(function (type) {
2060
- var original = window.history[type];
2371
+ var originalPushState = window.history.pushState;
2061
2372
 
2062
- window.history[type] = function () {
2063
- var args = [].slice.call(arguments);
2064
- var result = original.apply(this, args); // eslint-disable-next-line @typescript-eslint/no-explicit-any
2373
+ window.history.pushState = function () {
2374
+ var args = [].slice.call(arguments);
2375
+ var result = originalPushState.apply(this, args); // eslint-disable-next-line @typescript-eslint/no-explicit-any
2376
+
2377
+ var event = new Event('pushState');
2378
+ event.arguments = args;
2379
+ dispatchEvent(event);
2380
+ return result;
2381
+ };
2382
+
2383
+ var originalReplaceState = window.history.replaceState;
2384
+
2385
+ window.history.replaceState = function () {
2386
+ var args = [].slice.call(arguments);
2387
+ var result = originalReplaceState.apply(this, args); // eslint-disable-next-line @typescript-eslint/no-explicit-any
2388
+
2389
+ var event = new Event('replaceState');
2390
+ event.arguments = args;
2391
+ dispatchEvent(event);
2392
+ return result;
2393
+ };
2065
2394
 
2066
- var event = new Event(type);
2067
- event.arguments = args;
2068
- dispatchEvent(event);
2069
- return result;
2070
- };
2071
- });
2072
2395
  return patched = 1;
2073
2396
  };
2074
2397
 
@@ -2123,7 +2446,7 @@ function TdLink(_ref) {
2123
2446
  children = _ref.children,
2124
2447
  _ref$style = _ref.style,
2125
2448
  style = _ref$style === void 0 ? {} : _ref$style;
2126
- var link = useRef();
2449
+ var link = useRef(null);
2127
2450
 
2128
2451
  function onClick() {
2129
2452
  if (link && link.current) {
@@ -2230,15 +2553,7 @@ var RestClient = /*#__PURE__*/function () {
2230
2553
 
2231
2554
  var _proto = RestClient.prototype;
2232
2555
 
2233
- _proto.request = function request(path, data, headers) {
2234
- if (data === void 0) {
2235
- data = undefined;
2236
- }
2237
-
2238
- if (headers === void 0) {
2239
- headers = undefined;
2240
- }
2241
-
2556
+ _proto.request = function request(path, data, headers, signal) {
2242
2557
  try {
2243
2558
  var _this2 = this;
2244
2559
 
@@ -2254,9 +2569,18 @@ var RestClient = /*#__PURE__*/function () {
2254
2569
  path = "/" + path;
2255
2570
  }
2256
2571
 
2257
- data = data || {};
2258
- data.headers = headers || _this2.getHeaders();
2259
- return Promise.resolve(fetch("" + _this2.url + path, data));
2572
+ var dataRequest = data || {};
2573
+ dataRequest.headers = _this2.getHeaders();
2574
+
2575
+ if (headers) {
2576
+ dataRequest.headers = _extends({}, dataRequest.headers, headers);
2577
+ }
2578
+
2579
+ if (signal) {
2580
+ dataRequest.signal = signal;
2581
+ }
2582
+
2583
+ return Promise.resolve(fetch("" + _this2.url + path, dataRequest));
2260
2584
  } catch (e) {
2261
2585
  return Promise.reject(e);
2262
2586
  }
@@ -2264,12 +2588,12 @@ var RestClient = /*#__PURE__*/function () {
2264
2588
 
2265
2589
  _proto.getHeaders = function getHeaders() {
2266
2590
  var authToken = this.auth.getToken();
2267
- if (!authToken) return {};
2268
- return {
2269
- Accept: 'application/json',
2270
- 'Content-Type': 'application/json',
2271
- Authorization: 'Bearer ' + authToken
2272
- };
2591
+ var headersInit = {};
2592
+ if (!authToken) return headersInit;
2593
+ headersInit.Accept = 'application/json';
2594
+ headersInit['Content-Type'] = 'application/json';
2595
+ headersInit.Authorization = 'Bearer ' + authToken;
2596
+ return headersInit;
2273
2597
  };
2274
2598
 
2275
2599
  _proto.post = function post(path, data) {
@@ -2285,11 +2609,11 @@ var RestClient = /*#__PURE__*/function () {
2285
2609
  }
2286
2610
  };
2287
2611
 
2288
- _proto.get = function get(path) {
2612
+ _proto.get = function get(path, signal) {
2289
2613
  try {
2290
2614
  var _this6 = this;
2291
2615
 
2292
- return Promise.resolve(_this6.request(path));
2616
+ return Promise.resolve(_this6.request(path, undefined, undefined, signal));
2293
2617
  } catch (e) {
2294
2618
  return Promise.reject(e);
2295
2619
  }
@@ -2327,24 +2651,20 @@ var RestClient = /*#__PURE__*/function () {
2327
2651
 
2328
2652
  var headers = _this12.getHeaders();
2329
2653
 
2330
- delete headers['Content-Type'];
2331
- headers['Content-Type'] = data['content-type'];
2332
- headers['X-UPLOAD-FILENAME'] = data.filename;
2333
- headers['Content-Encoding'] = 'base64';
2654
+ var newHeaders = {};
2655
+ newHeaders['Content-Type'] = data['content-type'];
2656
+ newHeaders['X-UPLOAD-FILENAME'] = data.filename;
2657
+ newHeaders['Content-Encoding'] = 'base64';
2334
2658
  return Promise.resolve(_this12.request(path, {
2335
2659
  method: 'PATCH',
2336
2660
  body: data.data
2337
- }, headers));
2661
+ }, _extends({}, headers, newHeaders)));
2338
2662
  } catch (e) {
2339
2663
  return Promise.reject(e);
2340
2664
  }
2341
2665
  };
2342
2666
 
2343
2667
  _proto.delete = function _delete(path, data) {
2344
- if (data === void 0) {
2345
- data = undefined;
2346
- }
2347
-
2348
2668
  try {
2349
2669
  var _this14 = this;
2350
2670
 
@@ -2485,6 +2805,14 @@ var GuillotinaClient = /*#__PURE__*/function () {
2485
2805
  }
2486
2806
  };
2487
2807
 
2808
+ _proto.getQueryParamsSearchFunction = function getQueryParamsSearchFunction(name) {
2809
+ if (name === 'getQueryParamsElasticsearch') {
2810
+ return this.getQueryParamsElasticsearch;
2811
+ }
2812
+
2813
+ return this.getQueryParamsPostresql;
2814
+ };
2815
+
2488
2816
  _proto.getQueryParamsPostresql = function getQueryParamsPostresql(_ref) {
2489
2817
  var _ref$start = _ref.start,
2490
2818
  start = _ref$start === void 0 ? 0 : _ref$start,
@@ -2576,7 +2904,7 @@ var GuillotinaClient = /*#__PURE__*/function () {
2576
2904
  label: 'id/name',
2577
2905
  key: 'title',
2578
2906
  isSortable: true,
2579
- child: function child(m, navigate, search) {
2907
+ child: function child(m, _navigate, search) {
2580
2908
  return jsxs(TdLink, {
2581
2909
  model: m,
2582
2910
  children: [m.name, search && jsxs(React.Fragment, {
@@ -2614,12 +2942,15 @@ var GuillotinaClient = /*#__PURE__*/function () {
2614
2942
  ;
2615
2943
 
2616
2944
  _proto.applyCompat = function applyCompat(data) {
2617
- data.member = data.items;
2618
- data.items_count = data.items_total;
2619
- return data;
2945
+ var result = _extends({}, data, {
2946
+ member: data.items,
2947
+ items_count: data.items_total
2948
+ });
2949
+
2950
+ return result;
2620
2951
  };
2621
2952
 
2622
- _proto.search = function search(path, params, container, prepare) {
2953
+ _proto.search = function search(path, params, container, prepare, signal) {
2623
2954
  if (container === void 0) {
2624
2955
  container = false;
2625
2956
  }
@@ -2641,7 +2972,7 @@ var GuillotinaClient = /*#__PURE__*/function () {
2641
2972
 
2642
2973
  var query = prepare ? toQueryString(params) : params;
2643
2974
  var url = path + "@search?" + query;
2644
- return Promise.resolve(_this7.rest.get(url)).then(function (res) {
2975
+ return Promise.resolve(_this7.rest.get(url, signal)).then(function (res) {
2645
2976
  return Promise.resolve(res.json()).then(function (data) {
2646
2977
  return _this7.applyCompat(data);
2647
2978
  });
@@ -2853,23 +3184,53 @@ var GuillotinaClient = /*#__PURE__*/function () {
2853
3184
  var users = _this37.getUsers(path);
2854
3185
 
2855
3186
  return Promise.resolve(Promise.all([groups, users])).then(function (_ref3) {
2856
- var gr = _ref3[0],
2857
- usr = _ref3[1];
3187
+ var responseGroups = _ref3[0],
3188
+ responseUsers = _ref3[1];
2858
3189
 
2859
- function _temp6(_gr$json) {
2860
- function _temp5(_usr$json) {
3190
+ function _temp8() {
3191
+ function _temp6() {
2861
3192
  return {
2862
- groups: _gr$json,
2863
- users: _usr$json
3193
+ groups: groupsData,
3194
+ users: usersData
2864
3195
  };
2865
3196
  }
2866
3197
 
2867
- var _usr$ok = usr.ok;
2868
- return _usr$ok ? Promise.resolve(usr.json()).then(_temp5) : _temp5([]);
3198
+ var _temp5 = function () {
3199
+ if (responseUsers) {
3200
+ return Promise.resolve(responseUsers.json()).then(function (usersDataResponse) {
3201
+ usersData = usersDataResponse.map(function (user) {
3202
+ return {
3203
+ '@name': user.id,
3204
+ user_roles: user.roles,
3205
+ fullname: user.fullname,
3206
+ email: user.email
3207
+ };
3208
+ });
3209
+ });
3210
+ }
3211
+ }();
3212
+
3213
+ return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
2869
3214
  }
2870
3215
 
2871
- var _gr$ok = gr.ok;
2872
- return _gr$ok ? Promise.resolve(gr.json()).then(_temp6) : _temp6([]);
3216
+ var groupsData = [];
3217
+ var usersData = [];
3218
+
3219
+ var _temp7 = function () {
3220
+ if (responseGroups.ok) {
3221
+ return Promise.resolve(responseGroups.json()).then(function (groupsDataResponse) {
3222
+ groupsData = groupsDataResponse.map(function (group) {
3223
+ return {
3224
+ '@name': group.id,
3225
+ user_roles: group.roles,
3226
+ users: group.users
3227
+ };
3228
+ });
3229
+ });
3230
+ }
3231
+ }();
3232
+
3233
+ return _temp7 && _temp7.then ? _temp7.then(_temp8) : _temp8(_temp7);
2873
3234
  });
2874
3235
  } catch (e) {
2875
3236
  return Promise.reject(e);
@@ -2911,7 +3272,7 @@ var GuillotinaClient = /*#__PURE__*/function () {
2911
3272
  try {
2912
3273
  var _this43 = this;
2913
3274
 
2914
- function _temp10() {
3275
+ function _temp12() {
2915
3276
  return cacheTypes[path];
2916
3277
  }
2917
3278
 
@@ -2919,10 +3280,10 @@ var GuillotinaClient = /*#__PURE__*/function () {
2919
3280
  path = path.slice(1);
2920
3281
  }
2921
3282
 
2922
- var _temp11 = function () {
3283
+ var _temp13 = function () {
2923
3284
  if (!cacheTypes[path]) {
2924
3285
  return Promise.resolve(_this43.rest.get(path + '@addable-types')).then(function (types) {
2925
- var _temp7 = function () {
3286
+ var _temp9 = function () {
2926
3287
  if (types.status === 401 || types.status === 404) {
2927
3288
  cacheTypes[path] = [];
2928
3289
  } else {
@@ -2932,12 +3293,12 @@ var GuillotinaClient = /*#__PURE__*/function () {
2932
3293
  }
2933
3294
  }();
2934
3295
 
2935
- if (_temp7 && _temp7.then) return _temp7.then(function () {});
3296
+ if (_temp9 && _temp9.then) return _temp9.then(function () {});
2936
3297
  });
2937
3298
  }
2938
3299
  }();
2939
3300
 
2940
- return Promise.resolve(_temp11 && _temp11.then ? _temp11.then(_temp10) : _temp10(_temp11));
3301
+ return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(_temp12) : _temp12(_temp13));
2941
3302
  } catch (e) {
2942
3303
  return Promise.reject(e);
2943
3304
  }
@@ -2949,17 +3310,24 @@ function getClient(url, container, auth) {
2949
3310
  return new GuillotinaClient(new RestClient(url, container, auth), container === '/');
2950
3311
  }
2951
3312
  var lightFileReader = function lightFileReader(file) {
2952
- return new Promise(function (resolve) {
3313
+ return new Promise(function (resolve, reject) {
2953
3314
  var reader = new FileReader();
2954
3315
  reader.readAsArrayBuffer(file);
2955
3316
 
2956
3317
  reader.onloadend = function (e) {
2957
- var fileData = e.target.result;
2958
- resolve({
2959
- filename: file.name.normalize('NFD').replace(/[\u0300-\u036f]/g, ''),
2960
- data: fileData,
2961
- 'content-type': file.type
2962
- });
3318
+ var _e$target;
3319
+
3320
+ var fileData = e == null ? void 0 : (_e$target = e.target) == null ? void 0 : _e$target.result;
3321
+
3322
+ if (fileData) {
3323
+ resolve({
3324
+ filename: file.name.normalize('NFD').replace(/[\u0300-\u036f]/g, ''),
3325
+ data: fileData,
3326
+ 'content-type': file.type
3327
+ });
3328
+ } else {
3329
+ reject('Error reading file');
3330
+ }
2963
3331
  };
2964
3332
  });
2965
3333
  };
@@ -2990,9 +3358,15 @@ function FileUpload(_ref) {
2990
3358
 
2991
3359
  var changed = function changed(event) {
2992
3360
  try {
2993
- return Promise.resolve(lightFileReader(event.target.files[0])).then(function (fileToUpload) {
2994
- onChange(fileToUpload);
2995
- });
3361
+ var _temp2 = function () {
3362
+ if (event.target.files) {
3363
+ return Promise.resolve(lightFileReader(event.target.files[0])).then(function (fileToUpload) {
3364
+ onChange(fileToUpload);
3365
+ });
3366
+ }
3367
+ }();
3368
+
3369
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
2996
3370
  } catch (e) {
2997
3371
  return Promise.reject(e);
2998
3372
  }
@@ -3083,12 +3457,12 @@ Textarea.displayName = 'Textarea';
3083
3457
 
3084
3458
  var defaultEvents = ['mousedown', 'touchstart'];
3085
3459
 
3086
- var on = function on(obj) {
3087
- return obj.addEventListener.apply(obj, [].slice.call(arguments, 1));
3460
+ var on = function on(obj, type, handler) {
3461
+ return obj.addEventListener(type, handler);
3088
3462
  };
3089
3463
 
3090
- var off = function off(obj) {
3091
- return obj.removeEventListener.apply(obj, [].slice.call(arguments, 1));
3464
+ var off = function off(obj, type, handler) {
3465
+ return obj.removeEventListener(type, handler);
3092
3466
  };
3093
3467
 
3094
3468
  function useClickAway(ref, onClickAway, events) {
@@ -3120,56 +3494,7 @@ function useClickAway(ref, onClickAway, events) {
3120
3494
  }, [events, ref]);
3121
3495
  }
3122
3496
 
3123
- var formatDate = function formatDate(str) {
3124
- var d = new Date(str);
3125
- var minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
3126
- return d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear() + " " + d.getHours() + ":" + minutes;
3127
- };
3128
- var get$1 = function get(obj, path, defValue) {
3129
- var _pathArray$reduce;
3130
-
3131
- // If path is not defined or it has false value
3132
- if (!path) return undefined; // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.
3133
- // Regex explained: https://regexr.com/58j0k
3134
-
3135
- var pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g); // Find value if exist return otherwise return undefined value;
3136
-
3137
- return (_pathArray$reduce = pathArray.reduce(function (prevObj, key) {
3138
- return prevObj && prevObj[key];
3139
- }, obj)) != null ? _pathArray$reduce : defValue;
3140
- };
3141
- function getNewId(id) {
3142
- if (id === void 0) {
3143
- id = '';
3144
- }
3145
-
3146
- var suffix = '-copy-';
3147
- var rgx = new RegExp("($|" + suffix + "\\d*)");
3148
- return stringToSlug(id).replace(rgx, function (r) {
3149
- var num = parseInt(r.replace(suffix, '') || '0');
3150
- return "" + suffix + (num + 1);
3151
- });
3152
- }
3153
-
3154
- function debounce(func, wait) {
3155
- var timeout;
3156
- return function () {
3157
- // eslint-disable-next-line @typescript-eslint/no-this-alias
3158
- var context = this; // eslint-disable-next-line prefer-rest-params
3159
-
3160
- var args = arguments;
3161
-
3162
- var later = function later() {
3163
- timeout = null;
3164
- func.apply(context, args);
3165
- };
3166
-
3167
- clearTimeout(timeout);
3168
- timeout = setTimeout(later, wait);
3169
- };
3170
- }
3171
-
3172
- var initialState = {
3497
+ var initialState$1 = {
3173
3498
  page: 0,
3174
3499
  items: undefined,
3175
3500
  loading: false,
@@ -3179,10 +3504,9 @@ var SearchInput = function SearchInput(_ref) {
3179
3504
  var onChange = _ref.onChange,
3180
3505
  error = _ref.error,
3181
3506
  errorZoneClassName = _ref.errorZoneClassName,
3182
- _ref$traversal = _ref.traversal,
3183
- traversal = _ref$traversal === void 0 ? null : _ref$traversal,
3507
+ traversal = _ref.traversal,
3184
3508
  _ref$path = _ref.path,
3185
- path = _ref$path === void 0 ? null : _ref$path,
3509
+ path = _ref$path === void 0 ? undefined : _ref$path,
3186
3510
  _ref$qs = _ref.qs,
3187
3511
  qs = _ref$qs === void 0 ? [] : _ref$qs,
3188
3512
  _ref$queryCondition = _ref.queryCondition,
@@ -3197,14 +3521,14 @@ var SearchInput = function SearchInput(_ref) {
3197
3521
  _ref$dataTestItem = _ref.dataTestItem,
3198
3522
  dataTestItem = _ref$dataTestItem === void 0 ? 'searchInputItemTest' : _ref$dataTestItem,
3199
3523
  _ref$renderTextItemOp = _ref.renderTextItemOption,
3200
- renderTextItemOption = _ref$renderTextItemOp === void 0 ? null : _ref$renderTextItemOp,
3524
+ renderTextItemOption = _ref$renderTextItemOp === void 0 ? undefined : _ref$renderTextItemOp,
3201
3525
  _ref$typeNameQuery = _ref.typeNameQuery,
3202
- typeNameQuery = _ref$typeNameQuery === void 0 ? null : _ref$typeNameQuery,
3526
+ typeNameQuery = _ref$typeNameQuery === void 0 ? undefined : _ref$typeNameQuery,
3203
3527
  _ref$labelProperty = _ref.labelProperty,
3204
3528
  labelProperty = _ref$labelProperty === void 0 ? 'id' : _ref$labelProperty;
3205
3529
  var intl = useIntl();
3206
3530
 
3207
- var _useSetState = useSetState(initialState),
3531
+ var _useSetState = useSetState(initialState$1),
3208
3532
  options = _useSetState[0],
3209
3533
  setOptions = _useSetState[1];
3210
3534
 
@@ -3258,7 +3582,7 @@ var SearchInput = function SearchInput(_ref) {
3258
3582
  var searchTermParsed = ["id", value];
3259
3583
  var getSearch = traversal.registry.get;
3260
3584
  var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
3261
- var qsParsed = traversal.client[fnName]({
3585
+ var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
3262
3586
  path: traversal.path,
3263
3587
  start: 0,
3264
3588
  pageSize: PageSize,
@@ -3276,7 +3600,7 @@ var SearchInput = function SearchInput(_ref) {
3276
3600
 
3277
3601
  return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
3278
3602
  var newValuesLabel = data.items.reduce(function (result, item) {
3279
- result[item.id] = get$1(item, labelProperty, item.id);
3603
+ result[item.id] = get(item, labelProperty, item.id);
3280
3604
  return result;
3281
3605
  }, {});
3282
3606
  setValueLabel(newValuesLabel);
@@ -3304,6 +3628,7 @@ var SearchInput = function SearchInput(_ref) {
3304
3628
  }
3305
3629
 
3306
3630
  try {
3631
+ console.log('handle search input');
3307
3632
  setOptions({
3308
3633
  loading: true
3309
3634
  });
@@ -3318,7 +3643,7 @@ var SearchInput = function SearchInput(_ref) {
3318
3643
 
3319
3644
  var fnName = _get('searchEngineQueryParamsFunction', SearchEngine);
3320
3645
 
3321
- var qsParsed = traversal.client[fnName]({
3646
+ var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
3322
3647
  path: traversal.path,
3323
3648
  start: page * PageSize,
3324
3649
  pageSize: PageSize,
@@ -3331,7 +3656,7 @@ var SearchInput = function SearchInput(_ref) {
3331
3656
  typeNameParsed = parser("type_name__in=" + typeNameQuery);
3332
3657
  }
3333
3658
 
3334
- if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
3659
+ if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0 || sortParsed.length > 0) {
3335
3660
  searchTermQs = buildQs([].concat(qs, searchTermParsed, qsParsed, typeNameParsed, sortParsed));
3336
3661
  }
3337
3662
 
@@ -3356,7 +3681,7 @@ var SearchInput = function SearchInput(_ref) {
3356
3681
  return renderTextItemOption(item);
3357
3682
  }
3358
3683
 
3359
- return get$1(item, labelProperty, item.title) || item['@name'];
3684
+ return get(item, labelProperty, item.title) || item['@name'];
3360
3685
  };
3361
3686
 
3362
3687
  useEffect(function () {
@@ -3382,7 +3707,7 @@ var SearchInput = function SearchInput(_ref) {
3382
3707
  if (!ev.currentTarget.contains(ev.relatedTarget)) {
3383
3708
  if (searchTerm !== '') {
3384
3709
  setSearchTerm('');
3385
- setOptions(initialState);
3710
+ setOptions(initialState$1);
3386
3711
  }
3387
3712
 
3388
3713
  setIsOpen(false);
@@ -3400,6 +3725,7 @@ var SearchInput = function SearchInput(_ref) {
3400
3725
  }
3401
3726
 
3402
3727
  setIsOpen(!isOpen);
3728
+ console.log('on clic btn', options);
3403
3729
 
3404
3730
  if (!options.loading && !options.items) {
3405
3731
  handleSearch(options.page);
@@ -3408,7 +3734,7 @@ var SearchInput = function SearchInput(_ref) {
3408
3734
  "aria-haspopup": "true",
3409
3735
  "aria-controls": "dropdown-menu",
3410
3736
  children: [jsx("span", {
3411
- children: value ? get$1(valueLabel, value, value) : intl.formatMessage(genericMessages.choose)
3737
+ children: value ? get(valueLabel, value, value) : intl.formatMessage(genericMessages.choose)
3412
3738
  }), jsx("span", {
3413
3739
  className: "icon",
3414
3740
  children: jsx("i", {
@@ -3482,25 +3808,7 @@ var SearchInput = function SearchInput(_ref) {
3482
3808
  });
3483
3809
  };
3484
3810
 
3485
- function debounce$1(func, wait) {
3486
- var timeout;
3487
- return function () {
3488
- // eslint-disable-next-line @typescript-eslint/no-this-alias
3489
- var context = this; // eslint-disable-next-line prefer-rest-params
3490
-
3491
- var args = arguments;
3492
-
3493
- var later = function later() {
3494
- timeout = null;
3495
- func.apply(context, args);
3496
- };
3497
-
3498
- clearTimeout(timeout);
3499
- timeout = setTimeout(later, wait);
3500
- };
3501
- }
3502
-
3503
- var initialState$1 = {
3811
+ var initialState$2 = {
3504
3812
  page: 0,
3505
3813
  items: undefined,
3506
3814
  loading: false,
@@ -3510,10 +3818,9 @@ var SearchInputList = function SearchInputList(_ref) {
3510
3818
  var onChange = _ref.onChange,
3511
3819
  error = _ref.error,
3512
3820
  errorZoneClassName = _ref.errorZoneClassName,
3513
- _ref$traversal = _ref.traversal,
3514
- traversal = _ref$traversal === void 0 ? null : _ref$traversal,
3821
+ traversal = _ref.traversal,
3515
3822
  _ref$path = _ref.path,
3516
- path = _ref$path === void 0 ? null : _ref$path,
3823
+ path = _ref$path === void 0 ? undefined : _ref$path,
3517
3824
  _ref$qs = _ref.qs,
3518
3825
  qs = _ref$qs === void 0 ? [] : _ref$qs,
3519
3826
  _ref$queryCondition = _ref.queryCondition,
@@ -3528,14 +3835,14 @@ var SearchInputList = function SearchInputList(_ref) {
3528
3835
  _ref$dataTestItem = _ref.dataTestItem,
3529
3836
  dataTestItem = _ref$dataTestItem === void 0 ? 'searchInputItemTest' : _ref$dataTestItem,
3530
3837
  _ref$renderTextItemOp = _ref.renderTextItemOption,
3531
- renderTextItemOption = _ref$renderTextItemOp === void 0 ? null : _ref$renderTextItemOp,
3838
+ renderTextItemOption = _ref$renderTextItemOp === void 0 ? undefined : _ref$renderTextItemOp,
3532
3839
  _ref$typeNameQuery = _ref.typeNameQuery,
3533
- typeNameQuery = _ref$typeNameQuery === void 0 ? null : _ref$typeNameQuery,
3840
+ typeNameQuery = _ref$typeNameQuery === void 0 ? undefined : _ref$typeNameQuery,
3534
3841
  _ref$labelProperty = _ref.labelProperty,
3535
3842
  labelProperty = _ref$labelProperty === void 0 ? 'id' : _ref$labelProperty;
3536
3843
  var intl = useIntl();
3537
3844
 
3538
- var _useSetState = useSetState(initialState$1),
3845
+ var _useSetState = useSetState(initialState$2),
3539
3846
  options = _useSetState[0],
3540
3847
  setOptions = _useSetState[1];
3541
3848
 
@@ -3581,7 +3888,7 @@ var SearchInputList = function SearchInputList(_ref) {
3581
3888
  };
3582
3889
  };
3583
3890
 
3584
- var delayedQuery = useCallback(debounce$1(function (value) {
3891
+ var delayedQuery = useCallback(debounce(function (value) {
3585
3892
  return handleSearch(0, false, value);
3586
3893
  }, 500), []);
3587
3894
 
@@ -3613,7 +3920,7 @@ var SearchInputList = function SearchInputList(_ref) {
3613
3920
 
3614
3921
  var fnName = _get('searchEngineQueryParamsFunction', SearchEngine);
3615
3922
 
3616
- var qsParsed = traversal.client[fnName]({
3923
+ var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
3617
3924
  path: traversal.path,
3618
3925
  start: page * PageSize,
3619
3926
  pageSize: PageSize,
@@ -3655,7 +3962,7 @@ var SearchInputList = function SearchInputList(_ref) {
3655
3962
  var searchTermParsed = ['__or', "id=" + value.join('%26id=')];
3656
3963
  var getSearch = traversal.registry.get;
3657
3964
  var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
3658
- var qsParsed = traversal.client[fnName]({
3965
+ var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
3659
3966
  path: traversal.path,
3660
3967
  start: 0,
3661
3968
  pageSize: 100,
@@ -3671,9 +3978,9 @@ var SearchInputList = function SearchInputList(_ref) {
3671
3978
  searchTermQs = buildQs([].concat(qs, [searchTermParsed], qsParsed, typeNameParsed));
3672
3979
  }
3673
3980
 
3674
- return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false, 0, 100)).then(function (data) {
3981
+ return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
3675
3982
  var newValuesLabel = data.items.reduce(function (result, item) {
3676
- result[item.id] = get$1(item, labelProperty, item.id);
3983
+ result[item.id] = get(item, labelProperty, item.id);
3677
3984
  return result;
3678
3985
  }, {});
3679
3986
  setValuesLabels(newValuesLabel);
@@ -3693,7 +4000,7 @@ var SearchInputList = function SearchInputList(_ref) {
3693
4000
  return renderTextItemOption(item);
3694
4001
  }
3695
4002
 
3696
- return get$1(item, labelProperty, item.title) || item['@name'];
4003
+ return get(item, labelProperty, item.title) || item['@name'];
3697
4004
  };
3698
4005
 
3699
4006
  useEffect(function () {
@@ -3716,7 +4023,7 @@ var SearchInputList = function SearchInputList(_ref) {
3716
4023
  children: value.map(function (tag, index) {
3717
4024
  return jsxs("div", {
3718
4025
  className: "tag is-info is-medium",
3719
- children: [get$1(valuesLabel, tag, tag), jsx("button", {
4026
+ children: [get(valuesLabel, tag, tag), jsx("button", {
3720
4027
  className: "delete is-small",
3721
4028
  onClick: function onClick(ev) {
3722
4029
  ev.stopPropagation();
@@ -3736,7 +4043,7 @@ var SearchInputList = function SearchInputList(_ref) {
3736
4043
  if (!ev.currentTarget.contains(ev.relatedTarget)) {
3737
4044
  if (searchTerm !== '') {
3738
4045
  setSearchTerm('');
3739
- setOptions(initialState$1);
4046
+ setOptions(initialState$2);
3740
4047
  }
3741
4048
 
3742
4049
  setIsOpen(false);
@@ -3800,7 +4107,7 @@ var SearchInputList = function SearchInputList(_ref) {
3800
4107
  if (onChange && !value.includes(item.id)) {
3801
4108
  var _extends2;
3802
4109
 
3803
- setValuesLabels(_extends({}, valuesLabel, (_extends2 = {}, _extends2[item.id] = get$1(item, labelProperty, item.id), _extends2)));
4110
+ setValuesLabels(_extends({}, valuesLabel, (_extends2 = {}, _extends2[item.id] = get(item, labelProperty, item.id), _extends2)));
3804
4111
  onChange([].concat(value, [item.id]));
3805
4112
  }
3806
4113
  },
@@ -3988,7 +4295,7 @@ function EditableField(_ref) {
3988
4295
  ref.current.focus();
3989
4296
  }
3990
4297
  });
3991
- var canModified = modifyContent && !get$1(schema, 'readonly', false);
4298
+ var canModified = schema !== undefined && modifyContent && !get(schema, 'readonly', false);
3992
4299
 
3993
4300
  var saveField = function saveField(ev) {
3994
4301
  try {
@@ -4054,7 +4361,7 @@ function EditableField(_ref) {
4054
4361
  var deleteField = function deleteField(ev) {
4055
4362
  try {
4056
4363
  if (ev) ev.preventDefault();
4057
- return Promise.resolve(function () {
4364
+ return Promise.resolve(function (_schema$items) {
4058
4365
  if ((schema == null ? void 0 : schema.widget) === 'file') {
4059
4366
  var _ns2, _ref4, _ref5;
4060
4367
 
@@ -4082,7 +4389,7 @@ function EditableField(_ref) {
4082
4389
  });
4083
4390
  } else if ((schema == null ? void 0 : schema.type) === 'string' && schema != null && schema.enum) {
4084
4391
  setValue(null);
4085
- } else if ((schema == null ? void 0 : schema.type) === 'array' && (schema == null ? void 0 : schema.items.type) === 'string') {
4392
+ } else if ((schema == null ? void 0 : schema.type) === 'array' && (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.type) === 'string') {
4086
4393
  setValue([]);
4087
4394
  }
4088
4395
  }());
@@ -4139,7 +4446,7 @@ function EditableField(_ref) {
4139
4446
  dataTest: "editableFieldBtnCancelTest",
4140
4447
  children: intl.formatMessage(genericMessages.cancel)
4141
4448
  })
4142
- }), !required && fieldHaveDeleteButton(schema) && jsx("div", {
4449
+ }), !required && schema && fieldHaveDeleteButton(schema) && jsx("div", {
4143
4450
  className: "control",
4144
4451
  children: jsx(Button, {
4145
4452
  className: "is-small is-danger",
@@ -4239,80 +4546,6 @@ var DownloadField = function DownloadField(_ref) {
4239
4546
  });
4240
4547
  };
4241
4548
 
4242
- function _catch$1(body, recover) {
4243
- try {
4244
- var result = body();
4245
- } catch (e) {
4246
- return recover(e);
4247
- }
4248
-
4249
- if (result && result.then) {
4250
- return result.then(void 0, recover);
4251
- }
4252
-
4253
- return result;
4254
- }
4255
-
4256
- function useVocabulary(vocabularyName, path) {
4257
- if (path === void 0) {
4258
- path = null;
4259
- }
4260
-
4261
- var traversal = useTraversal();
4262
-
4263
- var _useSetState = useSetState({
4264
- data: undefined,
4265
- loading: false,
4266
- error: undefined
4267
- }),
4268
- vocabulary = _useSetState[0],
4269
- setVocabulary = _useSetState[1];
4270
-
4271
- var getPath = function getPath() {
4272
- if (path) return path;
4273
- return traversal.path + "@vocabularies/" + vocabularyName;
4274
- };
4275
-
4276
- useEffect(function () {
4277
- var getVocabulary = function getVocabulary() {
4278
- try {
4279
- var _temp3 = function () {
4280
- if (vocabularyName && vocabulary.data === undefined && !vocabulary.loading) {
4281
- var _temp4 = _catch$1(function () {
4282
- setVocabulary({
4283
- loading: true
4284
- });
4285
- return Promise.resolve(traversal.client.get(getPath())).then(function (data) {
4286
- return Promise.resolve(data.json()).then(function (dataJson) {
4287
- setVocabulary({
4288
- loading: false,
4289
- data: dataJson
4290
- });
4291
- });
4292
- });
4293
- }, function (err) {
4294
- setVocabulary({
4295
- loading: false,
4296
- error: err,
4297
- data: undefined
4298
- });
4299
- });
4300
-
4301
- if (_temp4 && _temp4.then) return _temp4.then(function () {});
4302
- }
4303
- }();
4304
-
4305
- return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
4306
- } catch (e) {
4307
- return Promise.reject(e);
4308
- }
4309
- };
4310
-
4311
- getVocabulary();
4312
- }, [vocabularyName, vocabulary, path]);
4313
- return vocabulary;
4314
- }
4315
-
4316
4549
  var plain = ['string', 'number', 'boolean'];
4317
4550
  function RenderField(_ref) {
4318
4551
  var value = _ref.value,
@@ -4334,23 +4567,27 @@ function RenderField(_ref) {
4334
4567
  }
4335
4568
 
4336
4569
  if (type === 'object') {
4570
+ var _schema$properties;
4571
+
4337
4572
  if (Array.isArray(value)) {
4338
- return value.map(function (item) {
4573
+ return value.map(function (item, index) {
4339
4574
  return jsx("div", {
4340
4575
  children: jsx(RenderField, {
4341
4576
  value: item
4342
4577
  })
4343
- }, item);
4578
+ }, "renderField_" + index + "_" + (schema == null ? void 0 : schema.title));
4344
4579
  });
4345
4580
  }
4346
4581
 
4347
- return Object.keys(value).map(function (key) {
4348
- return jsx(FieldValue, {
4349
- field: get$1(schema, "properties." + key + ".title", key),
4350
- schema: get$1(schema, "properties." + key, {}),
4351
- value: value[key]
4352
- }, key);
4353
- });
4582
+ if ((schema == null ? void 0 : (_schema$properties = schema.properties) == null ? void 0 : _schema$properties.key) !== undefined) {
4583
+ return Object.keys(value).map(function (key) {
4584
+ return jsx(FieldValue, {
4585
+ field: get(schema, "properties." + key + ".title", key),
4586
+ schema: schema.properties.key,
4587
+ value: get(value, key, {})
4588
+ }, key);
4589
+ });
4590
+ }
4354
4591
  }
4355
4592
 
4356
4593
  return jsxs("p", {
@@ -4394,6 +4631,7 @@ var SearchRenderField = function SearchRenderField(_ref3) {
4394
4631
  var schema = _ref3.schema,
4395
4632
  value = _ref3.value,
4396
4633
  modifyContent = _ref3.modifyContent;
4634
+ console.log('search render fields');
4397
4635
  var intl = useIntl();
4398
4636
 
4399
4637
  var _useState = useState([]),
@@ -4418,7 +4656,7 @@ var SearchRenderField = function SearchRenderField(_ref3) {
4418
4656
  var searchTermParsed = ['__or', "id=" + valuesToSearch.join('%26id=')];
4419
4657
  var getSearch = traversal.registry.get;
4420
4658
  var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
4421
- var qsParsed = traversal.client[fnName]({
4659
+ var qsParsed = traversal.client.getQueryParamsSearchFunction(fnName)({
4422
4660
  path: traversal.path,
4423
4661
  start: 0,
4424
4662
  pageSize: 100,
@@ -4429,11 +4667,11 @@ var SearchRenderField = function SearchRenderField(_ref3) {
4429
4667
  searchTermQs = buildQs([searchTermParsed].concat(qsParsed));
4430
4668
  }
4431
4669
 
4432
- return Promise.resolve(traversal.client.search(traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false, 0, 100)).then(function (data) {
4670
+ return Promise.resolve(traversal.client.search(traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
4433
4671
  var newValuesLabel = data.items.map(function (item) {
4434
4672
  var _schema$labelProperty;
4435
4673
 
4436
- return get$1(item, (_schema$labelProperty = schema == null ? void 0 : schema.labelProperty) != null ? _schema$labelProperty : 'title', item.id);
4674
+ return get(item, (_schema$labelProperty = schema == null ? void 0 : schema.labelProperty) != null ? _schema$labelProperty : 'title', item.id);
4437
4675
  });
4438
4676
  setValuesLabels(newValuesLabel);
4439
4677
  setIsLoadingData(false);
@@ -4443,13 +4681,15 @@ var SearchRenderField = function SearchRenderField(_ref3) {
4443
4681
  }
4444
4682
  };
4445
4683
 
4446
- var valuesToSearch = value;
4684
+ var valuesToSearch = [];
4447
4685
 
4448
- if (typeof valuesToSearch === 'string') {
4449
- valuesToSearch = [valuesToSearch];
4686
+ if (typeof value === 'string' && value) {
4687
+ valuesToSearch = [value];
4688
+ } else if (Array.isArray(value)) {
4689
+ valuesToSearch = value;
4450
4690
  }
4451
4691
 
4452
- if (valuesToSearch !== undefined && valuesToSearch.length > 0) {
4692
+ if (valuesToSearch.length > 0) {
4453
4693
  fetchData(valuesToSearch);
4454
4694
  } else {
4455
4695
  setValuesLabels([]);
@@ -4484,7 +4724,7 @@ var VocabularyRenderField = function VocabularyRenderField(_ref4) {
4484
4724
  modifyContent = _ref4.modifyContent;
4485
4725
  var intl = useIntl();
4486
4726
  var DEFAULT_VALUE_EDITABLE_FIELD = getDefaultValueEditableField(intl);
4487
- var vocabularyName = (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.vocabularyName) || (schema == null ? void 0 : schema.vocabularyName);
4727
+ var vocabularyName = (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.vocabularyName) || (schema == null ? void 0 : schema.vocabularyName) || '';
4488
4728
  var vocabulary = useVocabulary(vocabularyName);
4489
4729
 
4490
4730
  var getRenderProps = function getRenderProps() {
@@ -4495,7 +4735,7 @@ var VocabularyRenderField = function VocabularyRenderField(_ref4) {
4495
4735
  if (schema != null && schema.vocabularyName) {
4496
4736
  var _vocabularyValue$titl;
4497
4737
 
4498
- var vocabularyValue = get$1(vocabulary, 'data.items', []).find(function (item) {
4738
+ var vocabularyValue = get(vocabulary, 'data.items', []).find(function (item) {
4499
4739
  return item.token === value;
4500
4740
  });
4501
4741
  renderProps['value'] = (_vocabularyValue$titl = vocabularyValue == null ? void 0 : vocabularyValue.title) != null ? _vocabularyValue$titl : '';
@@ -4505,7 +4745,7 @@ var VocabularyRenderField = function VocabularyRenderField(_ref4) {
4505
4745
  renderProps['value'] = ((_renderProps$value = renderProps['value']) != null ? _renderProps$value : []).map(function (value) {
4506
4746
  var _get$find$title, _get$find;
4507
4747
 
4508
- return (_get$find$title = (_get$find = get$1(vocabulary, 'data.items', []).find(function (item) {
4748
+ return (_get$find$title = (_get$find = get(vocabulary, 'data.items', []).find(function (item) {
4509
4749
  return item.token === value;
4510
4750
  })) == null ? void 0 : _get$find.title) != null ? _get$find$title : '';
4511
4751
  });
@@ -4557,66 +4797,6 @@ function RenderFieldComponent(_ref5) {
4557
4797
  return jsx(RenderField, _extends({}, getRenderProps()));
4558
4798
  }
4559
4799
 
4560
- var SelectVocabulary = forwardRef(function (_ref, ref) {
4561
- var vocabularyName = _ref.vocabularyName,
4562
- className = _ref.className,
4563
- classWrap = _ref.classWrap,
4564
- val = _ref.val,
4565
- dataTest = _ref.dataTest,
4566
- multiple = _ref.multiple,
4567
- onChange = _ref.onChange,
4568
- id = _ref.id,
4569
- placeholder = _ref.placeholder;
4570
- var vocabulary = useVocabulary(vocabularyName);
4571
-
4572
- var getOptions = function getOptions() {
4573
- if (get$1(vocabulary, 'data.items', null)) {
4574
- var vocData = vocabulary.data.items.map(function (item) {
4575
- return {
4576
- text: item.title,
4577
- value: item.token
4578
- };
4579
- });
4580
- return vocData;
4581
- }
4582
-
4583
- return [];
4584
- };
4585
-
4586
- var getProps = function getProps() {
4587
- if (multiple) {
4588
- var currentValue = val || [];
4589
- return {
4590
- multiple: true,
4591
- size: 5,
4592
- value: currentValue,
4593
- options: getOptions()
4594
- };
4595
- }
4596
-
4597
- return {
4598
- value: val != null ? val : '',
4599
- appendDefault: true,
4600
- options: getOptions()
4601
- };
4602
- };
4603
-
4604
- if (vocabulary.data === undefined || vocabulary.loading) {
4605
- return jsx("div", {});
4606
- }
4607
-
4608
- return jsx(Select, _extends({}, getProps(), {
4609
- className: className,
4610
- classWrap: classWrap || 'is-fullwidth',
4611
- dataTest: dataTest,
4612
- ref: ref,
4613
- onChange: onChange,
4614
- id: id,
4615
- placeholder: placeholder
4616
- }));
4617
- });
4618
- SelectVocabulary.displayName = 'SelectVocabulary';
4619
-
4620
4800
  var EditComponent = forwardRef(function (_ref, ref) {
4621
4801
  var schema = _ref.schema,
4622
4802
  val = _ref.val,
@@ -4642,7 +4822,7 @@ var EditComponent = forwardRef(function (_ref, ref) {
4642
4822
  queryCondition: schema != null && schema.queryCondition ? schema.queryCondition : 'title__in',
4643
4823
  path: schema.queryPath,
4644
4824
  labelProperty: schema != null && schema.labelProperty ? schema.labelProperty : 'title',
4645
- typeNameQuery: schema != null && schema.typeNameQuery ? schema.typeNameQuery : null
4825
+ typeNameQuery: schema == null ? void 0 : schema.typeNameQuery
4646
4826
  })]
4647
4827
  });
4648
4828
  } else if ((schema == null ? void 0 : schema.widget) === 'search') {
@@ -4659,7 +4839,7 @@ var EditComponent = forwardRef(function (_ref, ref) {
4659
4839
  queryCondition: schema != null && schema.queryCondition ? schema.queryCondition : 'title__in',
4660
4840
  path: schema.queryPath,
4661
4841
  labelProperty: schema != null && schema.labelProperty ? schema.labelProperty : 'title',
4662
- typeNameQuery: schema != null && schema.typeNameQuery ? schema.typeNameQuery : null
4842
+ typeNameQuery: schema == null ? void 0 : schema.typeNameQuery
4663
4843
  })]
4664
4844
  });
4665
4845
  } else if ((schema == null ? void 0 : schema.widget) === 'textarea' || (schema == null ? void 0 : schema.widget) === 'richtext') {
@@ -4689,7 +4869,7 @@ var EditComponent = forwardRef(function (_ref, ref) {
4689
4869
 
4690
4870
  if (schema.items.vocabularyName) {
4691
4871
  return jsx(SelectVocabulary, {
4692
- vocabularyName: get$1(schema, 'items.vocabularyName', null),
4872
+ vocabularyName: get(schema, 'items.vocabularyName', ''),
4693
4873
  val: val || [],
4694
4874
  className: className,
4695
4875
  classWrap: "is-fullwidth",
@@ -4726,22 +4906,25 @@ var EditComponent = forwardRef(function (_ref, ref) {
4726
4906
  }), jsx(InputList, {
4727
4907
  value: val || [],
4728
4908
  className: className,
4729
- onChange: function onChange(ev) {
4730
- return _setValue(ev);
4909
+ onChange: function onChange(val) {
4910
+ return _setValue(val);
4731
4911
  },
4732
4912
  ref: ref,
4733
4913
  dataTest: dataTest
4734
4914
  })]
4735
4915
  });
4736
4916
  } else if ((schema == null ? void 0 : schema.widget) === 'file') {
4917
+ var value = val;
4737
4918
  return jsx(FileUpload, {
4738
4919
  onChange: function onChange(ev) {
4739
4920
  return _setValue(ev);
4740
4921
  },
4741
- label: get$1(val, 'filename', null),
4922
+ label: get(value, 'filename', undefined),
4742
4923
  dataTest: dataTest
4743
4924
  });
4744
4925
  } else if ((schema == null ? void 0 : schema.widget) === 'select' && schema.type === 'string') {
4926
+ var _schema$vocabulary;
4927
+
4745
4928
  if (schema != null && schema.vocabularyName) {
4746
4929
  return jsx(SelectVocabulary, {
4747
4930
  val: val || '',
@@ -4750,7 +4933,7 @@ var EditComponent = forwardRef(function (_ref, ref) {
4750
4933
  classWrap: "is-fullwidth",
4751
4934
  dataTest: dataTest,
4752
4935
  onChange: _setValue,
4753
- vocabularyName: get$1(schema, 'vocabularyName', null),
4936
+ vocabularyName: get(schema, 'vocabularyName', ''),
4754
4937
  placeholder: placeholder,
4755
4938
  id: id
4756
4939
  });
@@ -4762,7 +4945,7 @@ var EditComponent = forwardRef(function (_ref, ref) {
4762
4945
  appendDefault: true,
4763
4946
  classWrap: "is-fullwidth",
4764
4947
  dataTest: dataTest,
4765
- options: schema == null ? void 0 : schema.vocabulary.map(function (item) {
4948
+ options: ((_schema$vocabulary = schema == null ? void 0 : schema.vocabulary) != null ? _schema$vocabulary : []).map(function (item) {
4766
4949
  return {
4767
4950
  text: item,
4768
4951
  value: item
@@ -4773,26 +4956,27 @@ var EditComponent = forwardRef(function (_ref, ref) {
4773
4956
  id: id
4774
4957
  });
4775
4958
  } else if ((schema == null ? void 0 : schema.type) === 'object' && schema.widget !== 'file') {
4776
- var value = val;
4959
+ var _value = val;
4777
4960
  return jsxs(Fragment, {
4778
4961
  children: [schema.title && jsx("h4", {
4779
4962
  className: "subtitle mt-2",
4780
4963
  children: schema.title
4781
- }), Object.keys(get$1(schema, 'properties', {})).map(function (key) {
4964
+ }), Object.keys(get(schema, 'properties', {})).map(function (key) {
4782
4965
  var _subSchema$title;
4783
4966
 
4784
- var subSchema = get$1(schema, 'properties', {})[key];
4785
- var requiredFields = get$1(schema, 'required', []);
4967
+ var subSchema = get(schema, "properties." + key, null);
4968
+ var requiredFields = get(schema, 'required', []);
4969
+ if (!subSchema) return null;
4786
4970
  return jsx(EditComponent, {
4787
4971
  id: id + "[" + key + "]",
4788
4972
  schema: subSchema,
4789
- val: value && key in value ? value[key] : '',
4973
+ val: _value && key in _value ? _value[key] : '',
4790
4974
  placeholder: (_subSchema$title = subSchema == null ? void 0 : subSchema.title) != null ? _subSchema$title : '',
4791
4975
  required: requiredFields.includes(key),
4792
4976
  setValue: function setValue(ev) {
4793
4977
  var _extends2;
4794
4978
 
4795
- _setValue(_extends({}, value, (_extends2 = {}, _extends2[key] = ev, _extends2)));
4979
+ _setValue(_extends({}, _value, (_extends2 = {}, _extends2[key] = ev, _extends2)));
4796
4980
  },
4797
4981
  dataTest: key + "TestInput"
4798
4982
  }, id + "[" + key + "]");
@@ -4854,9 +5038,9 @@ function IAttachment(_ref) {
4854
5038
  }, 1), jsx("td", {
4855
5039
  children: jsx(EditableField, {
4856
5040
  field: key,
4857
- value: values[key],
5041
+ value: values.file,
4858
5042
  ns: "guillotina.behaviors.attachment.IAttachment",
4859
- schema: properties[key],
5043
+ schema: properties.file,
4860
5044
  modifyContent: modifyContent && ['file'].includes(key)
4861
5045
  })
4862
5046
  }, 2)]
@@ -4906,6 +5090,11 @@ function IMultiAttachment(_ref) {
4906
5090
 
4907
5091
  setLoading(true);
4908
5092
  setError(undefined);
5093
+
5094
+ if (!file) {
5095
+ return Promise.resolve();
5096
+ }
5097
+
4909
5098
  var endpoint = Ctx.path + "@upload/files/" + fileKey;
4910
5099
  return Promise.resolve(Ctx.client.upload(endpoint, file)).then(function (req) {
4911
5100
  if (req.status !== 200) {
@@ -4974,7 +5163,7 @@ function IMultiAttachment(_ref) {
4974
5163
  field: "files/" + key,
4975
5164
  value: values['files'][key],
4976
5165
  ns: "guillotina.behaviors.attachment.IMultiAttachment.files",
4977
- schema: properties['files']['additionalProperties'],
5166
+ schema: get(properties, 'files.additionalProperties', {}),
4978
5167
  modifyContent: false
4979
5168
  }), jsx("div", {
4980
5169
  className: "ml-5",
@@ -5198,13 +5387,18 @@ function IImageAttachment(_ref) {
5198
5387
  ev.preventDefault();
5199
5388
  setLoading(true);
5200
5389
  setError(undefined);
5390
+
5391
+ if (!file) {
5392
+ return Promise.resolve();
5393
+ }
5394
+
5201
5395
  var endpoint = Ctx.path + "@upload/image";
5202
5396
  return Promise.resolve(Ctx.client.upload(endpoint, file)).then(function (req) {
5203
5397
  var _exit;
5204
5398
 
5205
5399
  function _temp4(_result) {
5206
5400
  if (_exit) return _result;
5207
- setFile(undefined);
5401
+ setFile(null);
5208
5402
  setLoading(false);
5209
5403
  Ctx.flash(intl.formatMessage(genericFileMessages.image_uploaded), 'success');
5210
5404
  Ctx.refresh();
@@ -5485,7 +5679,7 @@ function IMultiImageAttachment(_ref) {
5485
5679
  fileKey = _useState[0],
5486
5680
  setFileKey = _useState[1];
5487
5681
 
5488
- var _useState2 = useState(null),
5682
+ var _useState2 = useState(undefined),
5489
5683
  file = _useState2[0],
5490
5684
  setFile = _useState2[1];
5491
5685
 
@@ -5518,6 +5712,11 @@ function IMultiImageAttachment(_ref) {
5518
5712
 
5519
5713
  setLoading(true);
5520
5714
  setError(undefined);
5715
+
5716
+ if (!file) {
5717
+ return Promise.resolve();
5718
+ }
5719
+
5521
5720
  var endpoint = Ctx.path + "@upload/images/" + fileKey;
5522
5721
  return Promise.resolve(Ctx.client.upload(endpoint, file)).then(function (req) {
5523
5722
  var _exit;
@@ -5620,7 +5819,7 @@ function IMultiImageAttachment(_ref) {
5620
5819
  field: "images/" + key,
5621
5820
  value: values['images'][key],
5622
5821
  ns: "guillotina.contrib.image.behaviors.IMultiImageAttachment.images",
5623
- schema: properties['images']['additionalProperties'],
5822
+ schema: get(properties, 'images.additionalProperties', {}),
5624
5823
  modifyContent: false,
5625
5824
  required: false
5626
5825
  }), jsx("div", {
@@ -5910,7 +6109,7 @@ function IMultiImageOrderedAttachment(_ref2) {
5910
6109
  sortedList = _useState2[0],
5911
6110
  setSortedList = _useState2[1];
5912
6111
 
5913
- var _useState3 = useState(null),
6112
+ var _useState3 = useState(undefined),
5914
6113
  file = _useState3[0],
5915
6114
  setFile = _useState3[1];
5916
6115
 
@@ -6054,7 +6253,7 @@ function IMultiImageOrderedAttachment(_ref2) {
6054
6253
  field: "images/" + key,
6055
6254
  value: values['images'][key],
6056
6255
  ns: "guillotina.contrib.image.behaviors.IMultiImageAttachment.images",
6057
- schema: properties['images']['additionalProperties'],
6256
+ schema: get(properties, 'images.additionalProperties', {}),
6058
6257
  modifyContent: false,
6059
6258
  required: false
6060
6259
  }), jsx("div", {
@@ -6109,165 +6308,6 @@ function IMultiImageOrderedAttachment(_ref2) {
6109
6308
  });
6110
6309
  }
6111
6310
 
6112
- var base = {
6113
- local: {
6114
- roleperm: {},
6115
- prinperm: {},
6116
- prinrole: {}
6117
- },
6118
- inherit: []
6119
- };
6120
- var Sharing = /*#__PURE__*/function () {
6121
- function Sharing(element) {
6122
- this.local = void 0;
6123
- this.inherit = void 0;
6124
- Object.assign(this, element || base);
6125
- }
6126
-
6127
- var _proto = Sharing.prototype;
6128
-
6129
- _proto.getRole = function getRole(role) {
6130
- return this.local.roleperm[role];
6131
- };
6132
-
6133
- _proto.getPrincipals = function getPrincipals(principal) {
6134
- return this.local.prinperm[principal];
6135
- };
6136
-
6137
- _proto.getPrinroles = function getPrinroles(role) {
6138
- return this.local.prinrole[role];
6139
- };
6140
-
6141
- _createClass(Sharing, [{
6142
- key: "roles",
6143
- get: function get() {
6144
- return Object.keys(this.local.roleperm);
6145
- }
6146
- }, {
6147
- key: "principals",
6148
- get: function get() {
6149
- return Object.keys(this.local.prinperm);
6150
- }
6151
- }, {
6152
- key: "prinrole",
6153
- get: function get() {
6154
- return Object.keys(this.local.prinrole);
6155
- }
6156
- }]);
6157
-
6158
- return Sharing;
6159
- }();
6160
-
6161
- var ItemModel = /*#__PURE__*/function () {
6162
- function ItemModel(item, url) {
6163
- if (url === void 0) {
6164
- url = '';
6165
- }
6166
-
6167
- this.item = void 0;
6168
- this.url = void 0;
6169
- this.item = item;
6170
- this.url = url;
6171
- }
6172
-
6173
- _createClass(ItemModel, [{
6174
- key: "path",
6175
- get: function get() {
6176
- // Compat
6177
- var item = this.item['@id'] ? this.item['@id'] : this.item['@absolute_url'];
6178
- var path = item.split('//')[1].split('/').splice(1).join('/');
6179
- path = "/" + path + "/";
6180
-
6181
- if (this.url.length > 0) {
6182
- if (this.url.startsWith('/')) {
6183
- path = path.replace(this.url.substring(1), '');
6184
- } else {
6185
- path = path.replace(this.url, '');
6186
- }
6187
- }
6188
-
6189
- return path;
6190
- }
6191
- }, {
6192
- key: "name",
6193
- get: function get() {
6194
- return this.item.title || this.item['@name'];
6195
- }
6196
- }, {
6197
- key: "icon",
6198
- get: function get() {
6199
- // eslint-disable-next-line
6200
- var cfg = useConfig();
6201
-
6202
- if (cfg.icons && cfg.icons[this.type]) {
6203
- return cfg.icons[this.type];
6204
- }
6205
-
6206
- switch (this.type) {
6207
- case 'GroupManager':
6208
- return 'fas fa-users-cog';
6209
-
6210
- case 'UserManager':
6211
- return 'fas fa-user-cog';
6212
-
6213
- case 'User':
6214
- return 'fas fa-user';
6215
-
6216
- case 'Group':
6217
- return 'fas fa-users';
6218
-
6219
- case 'Folder':
6220
- return 'fas fa-folder';
6221
-
6222
- default:
6223
- return 'fas fa-file';
6224
- }
6225
- }
6226
- }, {
6227
- key: "fullPath",
6228
- get: function get() {
6229
- return this.url + this.item.id;
6230
- }
6231
- }, {
6232
- key: "id",
6233
- get: function get() {
6234
- if (this.item.id) {
6235
- return this.item.id;
6236
- }
6237
-
6238
- var id = this.item['@id'].split('&')[0].split('/');
6239
- return id[id.length - 1];
6240
- }
6241
- }, {
6242
- key: "uid",
6243
- get: function get() {
6244
- return this.item['@uid'];
6245
- }
6246
- }, {
6247
- key: "type",
6248
- get: function get() {
6249
- return this.item['@type'] || this.item.type_name;
6250
- }
6251
- }, {
6252
- key: "title",
6253
- get: function get() {
6254
- return this.item.title;
6255
- }
6256
- }, {
6257
- key: "created",
6258
- get: function get() {
6259
- return this.item.creation_date ? formatDate(this.item.creation_date) : '';
6260
- }
6261
- }, {
6262
- key: "updated",
6263
- get: function get() {
6264
- return this.item.modification_date ? formatDate(this.item.modification_date) : '';
6265
- }
6266
- }]);
6267
-
6268
- return ItemModel;
6269
- }();
6270
-
6271
6311
  var messages$1 = defineMessages({
6272
6312
  status_changed_ok: {
6273
6313
  id: "status_changed_ok",
@@ -6343,13 +6383,12 @@ function IWorkflow() {
6343
6383
  definition = _useState[0],
6344
6384
  setDefinition = _useState[1];
6345
6385
 
6346
- var _useState2 = useState(null),
6386
+ var _useState2 = useState(undefined),
6347
6387
  workflowAction = _useState2[0],
6348
6388
  setWorkflowAction = _useState2[1];
6349
6389
 
6350
- var model = new ItemModel(Ctx.context);
6351
6390
  var vocabulary = useVocabulary('workflow_states');
6352
- var currentState = model.item['guillotina.contrib.workflows.interfaces.IWorkflowBehavior']['review_state'];
6391
+ var currentState = Ctx.context['guillotina.contrib.workflows.interfaces.IWorkflowBehavior']['review_state'];
6353
6392
  useEffect(function () {
6354
6393
  loadDefinition();
6355
6394
  }, [Ctx.path]);
@@ -6369,7 +6408,7 @@ function IWorkflow() {
6369
6408
  }
6370
6409
 
6371
6410
  Ctx.refresh();
6372
- setWorkflowAction(null);
6411
+ setWorkflowAction(undefined);
6373
6412
  });
6374
6413
  });
6375
6414
  } catch (e) {
@@ -6378,21 +6417,23 @@ function IWorkflow() {
6378
6417
  };
6379
6418
 
6380
6419
  var getStateTitle = function getStateTitle() {
6381
- var _vocabulary$data, _vocabulary$data$item;
6420
+ var _vocabulary$data$item, _vocabulary$data;
6382
6421
 
6383
- if (((_vocabulary$data = vocabulary.data) == null ? void 0 : (_vocabulary$data$item = _vocabulary$data.items) == null ? void 0 : _vocabulary$data$item.length) > 0) {
6384
- var vocabularyValue = vocabulary.data.items.find(function (item) {
6422
+ if (((_vocabulary$data$item = (_vocabulary$data = vocabulary.data) == null ? void 0 : _vocabulary$data.items) != null ? _vocabulary$data$item : []).length > 0) {
6423
+ var _vocabulary$data2;
6424
+
6425
+ var vocabularyValue = vocabulary == null ? void 0 : (_vocabulary$data2 = vocabulary.data) == null ? void 0 : _vocabulary$data2.items.find(function (item) {
6385
6426
  return item.token === currentState;
6386
6427
  });
6387
6428
 
6388
6429
  if (vocabularyValue) {
6389
- var translatedValue = get$1(vocabularyValue, "title.translated_title." + intl.locale, null);
6430
+ var translatedValue = get(vocabularyValue, "title.translated_title." + intl.locale, null);
6390
6431
 
6391
6432
  if (translatedValue !== null) {
6392
6433
  return translatedValue;
6393
6434
  }
6394
6435
 
6395
- var titleValue = get$1(vocabularyValue, "title.title." + intl.locale, null);
6436
+ var titleValue = get(vocabularyValue, "title.title." + intl.locale, null);
6396
6437
 
6397
6438
  if (titleValue !== null) {
6398
6439
  return titleValue;
@@ -6408,7 +6449,7 @@ function IWorkflow() {
6408
6449
  children: [workflowAction && jsx(Confirm, {
6409
6450
  loading: loading,
6410
6451
  onCancel: function onCancel() {
6411
- return setWorkflowAction(null);
6452
+ return setWorkflowAction(undefined);
6412
6453
  },
6413
6454
  onConfirm: doWorkflowAction,
6414
6455
  message: intl.formatMessage(messages$1.confirm_message, {
@@ -6434,7 +6475,7 @@ function IWorkflow() {
6434
6475
  onClick: function onClick() {
6435
6476
  return setWorkflowAction(transition['@id'].split('@workflow')[1].slice(1));
6436
6477
  },
6437
- children: get$1(transition, "metadata.translated_title." + intl.locale, transition.title)
6478
+ children: get(transition, "metadata.translated_title." + intl.locale, transition.title)
6438
6479
  }, transition['@id']);
6439
6480
  })]
6440
6481
  })]
@@ -6460,14 +6501,17 @@ function PanelActions() {
6460
6501
 
6461
6502
  return jsx(Fragment$1, {
6462
6503
  children: Object.keys(ACTIONS_OBJECT).map(function (actionKey) {
6463
- if (hasPerm(ACTIONS_OBJECT[actionKey].perms)) {
6504
+ var actionKeyTyped = actionKey;
6505
+ var actionObject = ACTIONS_OBJECT[actionKeyTyped];
6506
+
6507
+ if (hasPerm(actionObject.perms)) {
6464
6508
  return jsx("button", {
6465
6509
  className: "button mr-4",
6466
6510
  onClick: function onClick() {
6467
- onAction(actionKey);
6511
+ onAction(actionKeyTyped);
6468
6512
  },
6469
- children: ACTIONS_OBJECT[actionKey].text
6470
- }, "panel_action_" + ACTIONS_OBJECT[actionKey].text);
6513
+ children: actionObject.text
6514
+ }, "panel_action_" + actionObject.text);
6471
6515
  }
6472
6516
  })
6473
6517
  });
@@ -6665,8 +6709,9 @@ var prepareData = function prepareData(result) {
6665
6709
 
6666
6710
  var arrayToObject = function arrayToObject(array) {
6667
6711
  return array.reduce(function (obj, item) {
6668
- obj[item.id] = item;
6669
- return obj;
6712
+ var _extends2;
6713
+
6714
+ return _extends({}, obj, (_extends2 = {}, _extends2[item.id] = item, _extends2));
6670
6715
  }, {});
6671
6716
  };
6672
6717
 
@@ -6828,8 +6873,9 @@ function ItemsActionsProvider(_ref) {
6828
6873
 
6829
6874
  function onSelectAllItems(checked) {
6830
6875
  setSelected(items.reduce(function (obj, item) {
6831
- obj[item.path + "/" + item.id] = checked;
6832
- return obj;
6876
+ var _extends2;
6877
+
6878
+ return _extends({}, obj, (_extends2 = {}, _extends2[item.path + "/" + item.id] = checked, _extends2));
6833
6879
  }, {
6834
6880
  all: checked
6835
6881
  }));
@@ -6837,11 +6883,11 @@ function ItemsActionsProvider(_ref) {
6837
6883
 
6838
6884
  function onSelectOneItem(item) {
6839
6885
  setSelected(function (state) {
6840
- var _extends2;
6886
+ var _extends3;
6841
6887
 
6842
- return _extends({}, state, (_extends2 = {
6888
+ return _extends({}, state, (_extends3 = {
6843
6889
  all: false
6844
- }, _extends2[item.path + "/" + item.id] = !state[item.path + "/" + item.id], _extends2));
6890
+ }, _extends3[item.path + "/" + item.id] = !state[item.path + "/" + item.id], _extends3));
6845
6891
  });
6846
6892
  }
6847
6893
 
@@ -6863,17 +6909,37 @@ function ItemsActionsProvider(_ref) {
6863
6909
  children: children
6864
6910
  });
6865
6911
  }
6912
+
6913
+ var useItemsActions = function useItemsActions() {
6914
+ var _useContext = useContext(ItemsActionsCtx),
6915
+ onAction = _useContext.onAction,
6916
+ onSelectOneItem = _useContext.onSelectOneItem,
6917
+ onSelectAllItems = _useContext.onSelectAllItems,
6918
+ selected = _useContext.selected;
6919
+
6920
+ if (!onAction || !onSelectOneItem || !onSelectAllItems || !selected) {
6921
+ throw new Error('useItemsActions must be used inside ItemsActionsProvider');
6922
+ }
6923
+
6924
+ return {
6925
+ onAction: onAction,
6926
+ onSelectOneItem: onSelectOneItem,
6927
+ onSelectAllItems: onSelectAllItems,
6928
+ selected: selected
6929
+ };
6930
+ };
6866
6931
  /**
6867
6932
  * Checkbox component without props that consume the ItemsActionsContext
6868
6933
  * and it select/unselect all items of the page.
6869
6934
  */
6870
6935
 
6936
+
6871
6937
  function AllItemsCheckbox(_ref2) {
6872
6938
  var dataTest = _ref2.dataTest;
6873
6939
 
6874
- var _useContext = useContext(ItemsActionsCtx),
6875
- onSelectAllItems = _useContext.onSelectAllItems,
6876
- selected = _useContext.selected;
6940
+ var _useItemsActions = useItemsActions(),
6941
+ onSelectAllItems = _useItemsActions.onSelectAllItems,
6942
+ selected = _useItemsActions.selected;
6877
6943
 
6878
6944
  return jsx(Checkbox, {
6879
6945
  onChange: onSelectAllItems,
@@ -6885,9 +6951,9 @@ function ItemCheckbox(_ref3) {
6885
6951
  var item = _ref3.item,
6886
6952
  dataTest = _ref3.dataTest;
6887
6953
 
6888
- var _useContext2 = useContext(ItemsActionsCtx),
6889
- selected = _useContext2.selected,
6890
- onSelectOneItem = _useContext2.onSelectOneItem;
6954
+ var _useItemsActions2 = useItemsActions(),
6955
+ selected = _useItemsActions2.selected,
6956
+ onSelectOneItem = _useItemsActions2.onSelectOneItem;
6891
6957
 
6892
6958
  var absId = item.path + "/" + item.id;
6893
6959
  var value = selected[absId];
@@ -6908,9 +6974,9 @@ function ItemsActionsDropdown() {
6908
6974
  var ACTIONS_OBJECT = getActionsObject(intl, true);
6909
6975
  var traversal = useTraversal();
6910
6976
 
6911
- var _useContext3 = useContext(ItemsActionsCtx),
6912
- selected = _useContext3.selected,
6913
- onAction = _useContext3.onAction;
6977
+ var _useItemsActions3 = useItemsActions(),
6978
+ selected = _useItemsActions3.selected,
6979
+ onAction = _useItemsActions3.onAction;
6914
6980
 
6915
6981
  var disabled = Object.values(selected).every(function (v) {
6916
6982
  return !v;
@@ -7021,6 +7087,170 @@ function Pagination(_ref) {
7021
7087
  });
7022
7088
  }
7023
7089
 
7090
+ var base = {
7091
+ local: {
7092
+ roleperm: {},
7093
+ prinperm: {},
7094
+ prinrole: {}
7095
+ },
7096
+ inherit: []
7097
+ };
7098
+ var Sharing = /*#__PURE__*/function () {
7099
+ function Sharing(element) {
7100
+ this.local = void 0;
7101
+ this.inherit = void 0;
7102
+
7103
+ if (element === undefined) {
7104
+ throw new Error('Sharing element is undefined');
7105
+ }
7106
+
7107
+ this.local = element.local || base.local;
7108
+ this.inherit = element.inherit || base.inherit;
7109
+ }
7110
+
7111
+ var _proto = Sharing.prototype;
7112
+
7113
+ _proto.getRole = function getRole(role) {
7114
+ return this.local.roleperm[role];
7115
+ };
7116
+
7117
+ _proto.getPrincipals = function getPrincipals(principal) {
7118
+ return this.local.prinperm[principal];
7119
+ };
7120
+
7121
+ _proto.getPrinroles = function getPrinroles(role) {
7122
+ return this.local.prinrole[role];
7123
+ };
7124
+
7125
+ _createClass(Sharing, [{
7126
+ key: "roles",
7127
+ get: function get() {
7128
+ return Object.keys(this.local.roleperm);
7129
+ }
7130
+ }, {
7131
+ key: "principals",
7132
+ get: function get() {
7133
+ return Object.keys(this.local.prinperm);
7134
+ }
7135
+ }, {
7136
+ key: "prinrole",
7137
+ get: function get() {
7138
+ return Object.keys(this.local.prinrole);
7139
+ }
7140
+ }]);
7141
+
7142
+ return Sharing;
7143
+ }();
7144
+
7145
+ var ItemModel = /*#__PURE__*/function () {
7146
+ function ItemModel(item, url) {
7147
+ if (url === void 0) {
7148
+ url = '';
7149
+ }
7150
+
7151
+ this.item = void 0;
7152
+ this.url = void 0;
7153
+ this.item = item;
7154
+ this.url = url;
7155
+ }
7156
+
7157
+ _createClass(ItemModel, [{
7158
+ key: "path",
7159
+ get: function get() {
7160
+ // Compat
7161
+ var item = this.item['@id'] ? this.item['@id'] : this.item['@absolute_url'];
7162
+ var path = item.split('//')[1].split('/').splice(1).join('/');
7163
+ path = "/" + path + "/";
7164
+
7165
+ if (this.url.length > 0) {
7166
+ if (this.url.startsWith('/')) {
7167
+ path = path.replace(this.url.substring(1), '');
7168
+ } else {
7169
+ path = path.replace(this.url, '');
7170
+ }
7171
+ }
7172
+
7173
+ return path;
7174
+ }
7175
+ }, {
7176
+ key: "name",
7177
+ get: function get() {
7178
+ return this.item.title || this.item['@name'];
7179
+ }
7180
+ }, {
7181
+ key: "icon",
7182
+ get: function get() {
7183
+ var cfg = useConfig();
7184
+
7185
+ if (cfg.icons && cfg.icons[this.type]) {
7186
+ return cfg.icons[this.type];
7187
+ }
7188
+
7189
+ switch (this.type) {
7190
+ case 'GroupManager':
7191
+ return 'fas fa-users-cog';
7192
+
7193
+ case 'UserManager':
7194
+ return 'fas fa-user-cog';
7195
+
7196
+ case 'User':
7197
+ return 'fas fa-user';
7198
+
7199
+ case 'Group':
7200
+ return 'fas fa-users';
7201
+
7202
+ case 'Folder':
7203
+ return 'fas fa-folder';
7204
+
7205
+ default:
7206
+ return 'fas fa-file';
7207
+ }
7208
+ }
7209
+ }, {
7210
+ key: "fullPath",
7211
+ get: function get() {
7212
+ return this.url + this.id;
7213
+ }
7214
+ }, {
7215
+ key: "id",
7216
+ get: function get() {
7217
+ if ('id' in this.item) {
7218
+ return this.item.id;
7219
+ }
7220
+
7221
+ var id = this.item['@id'].split('&')[0].split('/');
7222
+ return id[id.length - 1];
7223
+ }
7224
+ }, {
7225
+ key: "uid",
7226
+ get: function get() {
7227
+ return this.item['@uid'];
7228
+ }
7229
+ }, {
7230
+ key: "type",
7231
+ get: function get() {
7232
+ return this.item['@type'] || this.item.type_name;
7233
+ }
7234
+ }, {
7235
+ key: "title",
7236
+ get: function get() {
7237
+ return this.item.title;
7238
+ }
7239
+ }, {
7240
+ key: "created",
7241
+ get: function get() {
7242
+ return this.item.creation_date ? formatDate(this.item.creation_date) : '';
7243
+ }
7244
+ }, {
7245
+ key: "updated",
7246
+ get: function get() {
7247
+ return this.item.modification_date ? formatDate(this.item.modification_date) : '';
7248
+ }
7249
+ }]);
7250
+
7251
+ return ItemModel;
7252
+ }();
7253
+
7024
7254
  function Item(_ref) {
7025
7255
  var item = _ref.item,
7026
7256
  icon = _ref.icon;
@@ -7161,11 +7391,11 @@ function SearchOptionsLabels(_ref) {
7161
7391
  renderValue = _useState[0],
7162
7392
  setRenderValue = _useState[1];
7163
7393
 
7164
- var defaultRenderValue = location.get(query);
7394
+ var defaultRenderValue = location.get(query) || '';
7165
7395
  useEffect(function () {
7166
7396
  var value = defaultRenderValue;
7167
7397
 
7168
- if ((options != null ? options : []).length > 0) {
7398
+ if (options && (options != null ? options : []).length > 0) {
7169
7399
  var option = options.find(function (item) {
7170
7400
  return item.value === value;
7171
7401
  });
@@ -7214,14 +7444,16 @@ function SearchVocabularyLabels(_ref) {
7214
7444
  setRenderValue = _useState[1];
7215
7445
 
7216
7446
  var vocabulary = useVocabulary(vocabularyName);
7217
- var defaultRenderValue = location.get(query);
7447
+ var defaultRenderValue = location.get(query) || '';
7218
7448
  useEffect(function () {
7219
7449
  var _vocabulary$data$item, _vocabulary$data;
7220
7450
 
7221
7451
  var value = defaultRenderValue;
7222
7452
 
7223
7453
  if (((_vocabulary$data$item = vocabulary == null ? void 0 : (_vocabulary$data = vocabulary.data) == null ? void 0 : _vocabulary$data.items) != null ? _vocabulary$data$item : []).length > 0) {
7224
- var vocabularyValue = vocabulary.data.items.find(function (item) {
7454
+ var _vocabulary$data2;
7455
+
7456
+ var vocabularyValue = vocabulary == null ? void 0 : (_vocabulary$data2 = vocabulary.data) == null ? void 0 : _vocabulary$data2.items.find(function (item) {
7225
7457
  return item.token === value;
7226
7458
  });
7227
7459
 
@@ -7255,7 +7487,7 @@ function SearchVocabularyLabels(_ref) {
7255
7487
  return null;
7256
7488
  }
7257
7489
 
7258
- var initialState$2 = {
7490
+ var initialState$3 = {
7259
7491
  page: 0,
7260
7492
  items: [],
7261
7493
  loading: true,
@@ -7274,7 +7506,7 @@ function PanelItems() {
7274
7506
  var intl = useIntl();
7275
7507
  var Ctx = useTraversal();
7276
7508
 
7277
- var _useSetState = useSetState(initialState$2),
7509
+ var _useSetState = useSetState(initialState$3),
7278
7510
  state = _useSetState[0],
7279
7511
  setState = _useSetState[1];
7280
7512
 
@@ -7290,7 +7522,7 @@ function PanelItems() {
7290
7522
  var page;
7291
7523
 
7292
7524
  try {
7293
- page = parseInt(location.get('page')) || 0;
7525
+ page = parseInt(location.get('page') || '0');
7294
7526
  } catch (_unused) {
7295
7527
  page = 0;
7296
7528
  }
@@ -7337,7 +7569,7 @@ function PanelItems() {
7337
7569
  var resultQueryParams = [];
7338
7570
  var resultDynamicLocation = [];
7339
7571
  filterSchema.forEach(function (filter) {
7340
- var itemParam = location.get(filter.attribute_key);
7572
+ var itemParam = location.get(filter.attribute_key) || '';
7341
7573
  resultDynamicLocation.push(itemParam);
7342
7574
 
7343
7575
  if (itemParam) {
@@ -7349,53 +7581,51 @@ function PanelItems() {
7349
7581
  var controller = new AbortController();
7350
7582
  if (Ctx.state.loading) return;
7351
7583
 
7352
- try {
7353
- setState({
7354
- loading: true,
7355
- total: Ctx.context.length
7356
- });
7357
- var get = Ctx.registry.get;
7358
- var fnName = get('searchEngineQueryParamsFunction', SearchEngine);
7359
-
7360
- if (sortParsed === undefined) {
7361
- var defaultSortValue = Ctx.registry.getDefaultSortValue(Ctx.context['@type'], {
7362
- key: 'id',
7363
- direction: 'des'
7584
+ var getData = function getData() {
7585
+ try {
7586
+ setState({
7587
+ loading: true,
7588
+ total: Ctx.context.length
7364
7589
  });
7365
- sortParsed = parser("_sort_" + defaultSortValue.direction + "=" + defaultSortValue.key);
7366
- }
7590
+ var get = Ctx.registry.get;
7591
+ var fnName = get('searchEngineQueryParamsFunction', SearchEngine);
7367
7592
 
7368
- var qsParsed = Ctx.client[fnName]({
7369
- path: Ctx.path,
7370
- start: page * PageSize,
7371
- pageSize: PageSize
7372
- });
7373
- var qs = '';
7593
+ if (sortParsed === undefined) {
7594
+ var defaultSortValue = Ctx.registry.getDefaultSortValue(Ctx.context['@type']);
7595
+ sortParsed = parser("_sort_" + defaultSortValue.direction + "=" + defaultSortValue.key);
7596
+ }
7374
7597
 
7375
- if (search || type || resultQueryParams.length > 0) {
7376
- var _searchParsed, _typeParsed, _sortParsed;
7598
+ var qsParsed = Ctx.client.getQueryParamsSearchFunction(fnName)({
7599
+ path: Ctx.path,
7600
+ start: page * PageSize,
7601
+ pageSize: PageSize
7602
+ });
7603
+ var qs = '';
7377
7604
 
7378
- qs = buildQs([].concat(qsParsed, (_searchParsed = searchParsed) != null ? _searchParsed : [], (_typeParsed = typeParsed) != null ? _typeParsed : [], (_sortParsed = sortParsed) != null ? _sortParsed : [], resultQueryParams));
7379
- } else {
7380
- var _sortParsed2;
7605
+ if (search || type || resultQueryParams.length > 0) {
7606
+ var _searchParsed, _typeParsed, _sortParsed;
7381
7607
 
7382
- qs = buildQs([].concat(qsParsed, (_sortParsed2 = sortParsed) != null ? _sortParsed2 : []));
7383
- }
7608
+ qs = buildQs([].concat(qsParsed, (_searchParsed = searchParsed) != null ? _searchParsed : [], (_typeParsed = typeParsed) != null ? _typeParsed : [], (_sortParsed = sortParsed) != null ? _sortParsed : [], resultQueryParams));
7609
+ } else {
7610
+ var _sortParsed2;
7384
7611
 
7385
- var signal = controller.signal;
7386
- return Promise.resolve(Ctx.client.search(Ctx.path, qs, false, false, {
7387
- signal: signal
7388
- })).then(function (data) {
7389
- setState({
7390
- items: data.member,
7391
- loading: false,
7392
- total: data.items_count
7612
+ qs = buildQs([].concat(qsParsed, (_sortParsed2 = sortParsed) != null ? _sortParsed2 : []));
7613
+ }
7614
+
7615
+ var signal = controller.signal;
7616
+ return Promise.resolve(Ctx.client.search(Ctx.path, qs, false, false, signal)).then(function (data) {
7617
+ setState({
7618
+ items: data.items,
7619
+ loading: false,
7620
+ total: data.items_count
7621
+ });
7393
7622
  });
7394
- });
7395
- } catch (e) {
7396
- Promise.reject(e);
7397
- }
7623
+ } catch (e) {
7624
+ return Promise.reject(e);
7625
+ }
7626
+ };
7398
7627
 
7628
+ getData();
7399
7629
  return function () {
7400
7630
  controller.abort();
7401
7631
  };
@@ -7440,12 +7670,14 @@ function PanelItems() {
7440
7670
  var _filter$values;
7441
7671
 
7442
7672
  if (filter.type === 'select' && ((_filter$values = filter.values) != null ? _filter$values : []).length > 0) {
7673
+ var _filter$values2;
7674
+
7443
7675
  return jsx(Select, {
7444
7676
  id: filter.attribute_key,
7445
7677
  placeholder: filter.label,
7446
7678
  appendDefault: true,
7447
7679
  classWrap: "is-size-7 is-fullwidth",
7448
- options: filter.values,
7680
+ options: (_filter$values2 = filter.values) != null ? _filter$values2 : [],
7449
7681
  value: location.get(filter.attribute_key) || '',
7450
7682
  dataTest: "filterInput" + filter.attribute_key,
7451
7683
  onChange: function onChange(value) {
@@ -7512,7 +7744,7 @@ function PanelItems() {
7512
7744
  var filterData = location.get(filter.attribute_key);
7513
7745
 
7514
7746
  if (filterData) {
7515
- var _filter$values2;
7747
+ var _filter$values3;
7516
7748
 
7517
7749
  if (filter.type === 'select' && filter.vocabulary) {
7518
7750
  return jsx("div", {
@@ -7521,7 +7753,7 @@ function PanelItems() {
7521
7753
  vocabularyName: filter == null ? void 0 : filter.vocabulary
7522
7754
  })
7523
7755
  }, filter.attribute_key);
7524
- } else if (filter.type === 'select' && ((_filter$values2 = filter.values) != null ? _filter$values2 : []).length > 0) {
7756
+ } else if (filter.type === 'select' && ((_filter$values3 = filter.values) != null ? _filter$values3 : []).length > 0) {
7525
7757
  return jsx("div", {
7526
7758
  children: jsx(SearchOptionsLabels, {
7527
7759
  query: filter.attribute_key,
@@ -7567,7 +7799,7 @@ function PanelItems() {
7567
7799
  className: "has-text-info is-flex is-align-items-center",
7568
7800
  children: [jsx("span", {
7569
7801
  children: column.label
7570
- }), getIcon(column.key, column.isSortable)]
7802
+ }), getIcon(column.key, !!column.isSortable)]
7571
7803
  })
7572
7804
  }, "table-col-" + column.label);
7573
7805
  }), jsx("th", {
@@ -7578,7 +7810,7 @@ function PanelItems() {
7578
7810
  children: [items && items.map(function (item) {
7579
7811
  return jsx(RItem, {
7580
7812
  item: item,
7581
- search: search,
7813
+ search: search != null ? search : '',
7582
7814
  columns: columns
7583
7815
  }, item['@uid']);
7584
7816
  }), items && items.length === 0 && jsx("tr", {
@@ -7602,17 +7834,19 @@ function PanelItems() {
7602
7834
  }
7603
7835
 
7604
7836
  function BehaviorsView(_ref) {
7837
+ var _context$__behaviors_;
7838
+
7605
7839
  var context = _ref.context,
7606
7840
  schema = _ref.schema;
7607
7841
  var Ctx = useTraversal();
7608
7842
  var getBehavior = Ctx.registry.getBehavior;
7609
- var behaviors = [].concat(context.__behaviors__, context['@static_behaviors']);
7843
+ var behaviors = [].concat((_context$__behaviors_ = context.__behaviors__) != null ? _context$__behaviors_ : [], Object(context['@static_behaviors']));
7610
7844
 
7611
- var GetBehavior = function GetBehavior(b) {
7612
- var Cls = getBehavior(b, BehaviorNotImplemented);
7845
+ var GetBehavior = function GetBehavior(behaviorName) {
7846
+ var Cls = getBehavior(behaviorName, BehaviorNotImplemented);
7613
7847
  return jsx(Cls, {
7614
- values: context[b],
7615
- properties: get$1(schema, ['definitions', b, 'properties'], {})
7848
+ values: context[behaviorName],
7849
+ properties: get(schema, ['definitions', behaviorName, 'properties'], {})
7616
7850
  });
7617
7851
  };
7618
7852
 
@@ -7708,9 +7942,11 @@ function PanelProperties() {
7708
7942
  var properties = Object.keys((schema == null ? void 0 : (_schema$data = schema.data) == null ? void 0 : _schema$data.properties) || []).filter(function (key) {
7709
7943
  return !ignoreFields.includes(key);
7710
7944
  }).map(function (key) {
7945
+ var _schema$data2;
7946
+
7711
7947
  return {
7712
7948
  key: key,
7713
- value: schema.data.properties[key]
7949
+ value: schema == null ? void 0 : (_schema$data2 = schema.data) == null ? void 0 : _schema$data2.properties[key]
7714
7950
  };
7715
7951
  });
7716
7952
  useEffect(function () {
@@ -7722,7 +7958,7 @@ function PanelProperties() {
7722
7958
  setSchema({
7723
7959
  loading: true
7724
7960
  });
7725
- return Promise.resolve(Ctx.client.getTypeSchema(Ctx.path, model.type)).then(function (dataJson) {
7961
+ return Promise.resolve(Ctx.client.getTypeSchema(Ctx.path, Ctx.context.type_name)).then(function (dataJson) {
7726
7962
  setSchema({
7727
7963
  loading: false,
7728
7964
  data: dataJson
@@ -7797,7 +8033,7 @@ function PanelProperties() {
7797
8033
  }), jsx("td", {
7798
8034
  children: jsx(EditableField, {
7799
8035
  field: prop,
7800
- value: Ctx.context[prop],
8036
+ value: get(Ctx.context, prop, ''),
7801
8037
  modifyContent: false
7802
8038
  })
7803
8039
  })]
@@ -7821,7 +8057,7 @@ function PanelProperties() {
7821
8057
  })
7822
8058
  }), jsx("tbody", {
7823
8059
  children: properties.map(function (_ref) {
7824
- var _schema$data$required, _schema$data2;
8060
+ var _schema$data$required, _schema$data3;
7825
8061
 
7826
8062
  var key = _ref.key,
7827
8063
  value = _ref.value;
@@ -7834,10 +8070,10 @@ function PanelProperties() {
7834
8070
  }), jsx("td", {
7835
8071
  children: jsx(EditableField, {
7836
8072
  field: key,
7837
- value: Ctx.context[key],
8073
+ value: get(Ctx.context, key, ''),
7838
8074
  schema: value,
7839
8075
  modifyContent: modifyContent,
7840
- required: ((_schema$data$required = (_schema$data2 = schema.data) == null ? void 0 : _schema$data2.required) != null ? _schema$data$required : []).includes(key)
8076
+ required: ((_schema$data$required = (_schema$data3 = schema.data) == null ? void 0 : _schema$data3.required) != null ? _schema$data$required : []).includes(key)
7841
8077
  })
7842
8078
  })]
7843
8079
  }, 'prop' + key);
@@ -7873,14 +8109,6 @@ function PermissionPrinperm(_ref) {
7873
8109
  state = _useSetState[0],
7874
8110
  setState = _useSetState[1];
7875
8111
 
7876
- var getMultiples = function getMultiples(field, setter) {
7877
- return function (values) {
7878
- var _setter;
7879
-
7880
- setter((_setter = {}, _setter[field] = values, _setter));
7881
- };
7882
- };
7883
-
7884
8112
  var savePermission = function savePermission() {
7885
8113
  try {
7886
8114
  if (!state.principal || !state.setting || state.permission.length === 0) {
@@ -7930,7 +8158,7 @@ function PermissionPrinperm(_ref) {
7930
8158
  children: intl.formatMessage(genericMessages.select_principal)
7931
8159
  }), jsx(Select, {
7932
8160
  appendDefault: true,
7933
- options: principals,
8161
+ options: principals != null ? principals : [],
7934
8162
  onChange: function onChange(value) {
7935
8163
  return setState({
7936
8164
  principal: value
@@ -7944,8 +8172,12 @@ function PermissionPrinperm(_ref) {
7944
8172
  className: "label",
7945
8173
  children: intl.formatMessage(genericMessages.select_permissions)
7946
8174
  }), jsx(Select, {
7947
- options: permissions,
7948
- onChange: getMultiples('permission', setState),
8175
+ options: permissions != null ? permissions : [],
8176
+ onChange: function onChange(values) {
8177
+ setState({
8178
+ permission: values
8179
+ });
8180
+ },
7949
8181
  size: 5,
7950
8182
  multiple: true,
7951
8183
  dataTest: "selectPermissionsTest"
@@ -7996,14 +8228,6 @@ function PermissionPrinrole(_ref) {
7996
8228
  state = _useSetState[0],
7997
8229
  setState = _useSetState[1];
7998
8230
 
7999
- var getMultiples = function getMultiples(field, setter) {
8000
- return function (values) {
8001
- var _setter;
8002
-
8003
- setter((_setter = {}, _setter[field] = values, _setter));
8004
- };
8005
- };
8006
-
8007
8231
  var savePermission = function savePermission() {
8008
8232
  try {
8009
8233
  if (!state.principal || !state.setting || state.roles.length === 0) {
@@ -8053,7 +8277,7 @@ function PermissionPrinrole(_ref) {
8053
8277
  children: intl.formatMessage(genericMessages.select_principal)
8054
8278
  }), jsx(Select, {
8055
8279
  appendDefault: true,
8056
- options: principals,
8280
+ options: principals != null ? principals : [],
8057
8281
  onChange: function onChange(value) {
8058
8282
  return setState({
8059
8283
  principal: value
@@ -8068,7 +8292,11 @@ function PermissionPrinrole(_ref) {
8068
8292
  children: intl.formatMessage(genericMessages.select_role)
8069
8293
  }), jsx(Select, {
8070
8294
  options: roles,
8071
- onChange: getMultiples('roles', setState),
8295
+ onChange: function onChange(values) {
8296
+ setState({
8297
+ roles: values
8298
+ });
8299
+ },
8072
8300
  size: 5,
8073
8301
  multiple: true,
8074
8302
  dataTest: "selectRoleTest"
@@ -8119,14 +8347,6 @@ function PermissionRoleperm(_ref) {
8119
8347
  state = _useSetState[0],
8120
8348
  setState = _useSetState[1];
8121
8349
 
8122
- var getMultiples = function getMultiples(field, setter) {
8123
- return function (values) {
8124
- var _setter;
8125
-
8126
- setter((_setter = {}, _setter[field] = values, _setter));
8127
- };
8128
- };
8129
-
8130
8350
  var savePermission = function savePermission() {
8131
8351
  try {
8132
8352
  if (!state.role || !state.setting || state.permission.length === 0) {
@@ -8190,8 +8410,12 @@ function PermissionRoleperm(_ref) {
8190
8410
  className: "label",
8191
8411
  children: intl.formatMessage(genericMessages.select_permissions)
8192
8412
  }), jsx(Select, {
8193
- options: permissions,
8194
- onChange: getMultiples('permission', setState),
8413
+ options: permissions != null ? permissions : [],
8414
+ onChange: function onChange(values) {
8415
+ setState({
8416
+ permission: values
8417
+ });
8418
+ },
8195
8419
  dataTest: "selectPermissionsTest",
8196
8420
  size: 5,
8197
8421
  multiple: true
@@ -8324,7 +8548,18 @@ function PanelPermissions() {
8324
8548
  useEffect(function () {
8325
8549
  get('@sharing');
8326
8550
  }, [reset]);
8327
- var perms = new Sharing(result);
8551
+ var perms = useMemo(function () {
8552
+ if (result) {
8553
+ return new Sharing(result);
8554
+ }
8555
+
8556
+ return null;
8557
+ }, [result]);
8558
+
8559
+ if (perms === null) {
8560
+ return null;
8561
+ }
8562
+
8328
8563
  return jsxs("div", {
8329
8564
  className: "columns",
8330
8565
  children: [!loading && jsxs("div", {
@@ -8482,14 +8717,14 @@ function AddPermission(_ref) {
8482
8717
  return Promise.resolve(Ctx.client.getPrincipals(Ctx.path)).then(function (principalsData) {
8483
8718
  var groups = principalsData.groups.map(function (group) {
8484
8719
  return {
8485
- text: group.id,
8486
- value: group.id
8720
+ text: group['@name'],
8721
+ value: group['@name']
8487
8722
  };
8488
8723
  });
8489
8724
  var users = principalsData.users.map(function (user) {
8490
8725
  return {
8491
- text: user.fullname || user.id,
8492
- value: user.id
8726
+ text: user.fullname || user['@name'],
8727
+ value: user['@name']
8493
8728
  };
8494
8729
  });
8495
8730
  principals = [].concat(groups, users);
@@ -8560,18 +8795,6 @@ var prepareAvailable = function prepareAvailable(items, already, title) {
8560
8795
  text: "Add " + title
8561
8796
  };
8562
8797
  if (items.length === 0) return [];
8563
-
8564
- if (items[0] && typeof items[0] === 'string') {
8565
- return [def].concat(items.map(function (x) {
8566
- return {
8567
- value: x,
8568
- text: x
8569
- };
8570
- })).filter(function (item) {
8571
- return !already.includes(item.value);
8572
- });
8573
- }
8574
-
8575
8798
  return [def].concat(items).filter(function (item) {
8576
8799
  return !already.includes(item.value);
8577
8800
  });
@@ -8584,7 +8807,7 @@ function TagsWidget(_ref) {
8584
8807
  noData = _ref.noData,
8585
8808
  onChange = _ref.onChange,
8586
8809
  loading = _ref.loading;
8587
- var selectRef = useRef();
8810
+ var selectRef = useRef(null);
8588
8811
 
8589
8812
  var _useState = useState(items),
8590
8813
  result = _useState[0],
@@ -8632,7 +8855,7 @@ function TagsWidget(_ref) {
8632
8855
  marginBottom: '20px'
8633
8856
  },
8634
8857
  children: noData
8635
- }), available.length > 1 && jsx("li", {
8858
+ }), (available != null ? available : []).length > 1 && jsx("li", {
8636
8859
  className: "widget-list-add select is-small",
8637
8860
  children: jsx(Select, {
8638
8861
  options: availableData,
@@ -8650,13 +8873,13 @@ function TagsWidget(_ref) {
8650
8873
  });
8651
8874
  }
8652
8875
 
8653
- var initialState$3 = {
8654
- types: undefined
8876
+ var initialState$4 = {
8877
+ types: []
8655
8878
  };
8656
8879
  function CreateButton() {
8657
8880
  var intl = useIntl();
8658
8881
 
8659
- var _useSetState = useSetState(initialState$3),
8882
+ var _useSetState = useSetState(initialState$4),
8660
8883
  state = _useSetState[0],
8661
8884
  setState = _useSetState[1];
8662
8885
 
@@ -8744,7 +8967,7 @@ function ContextToolbar(_ref) {
8744
8967
  var AddButton = _ref.AddButton;
8745
8968
  var intl = useIntl();
8746
8969
 
8747
- var _useSetState2 = useSetState(initialState$3),
8970
+ var _useSetState2 = useSetState(initialState$4),
8748
8971
  state = _useSetState2[0],
8749
8972
  setState = _useSetState2[1];
8750
8973
 
@@ -8755,7 +8978,7 @@ function ContextToolbar(_ref) {
8755
8978
 
8756
8979
  var traversal = useTraversal();
8757
8980
  var Config = useConfig();
8758
- var searchText = location.get('q');
8981
+ var searchText = location.get('q') || '';
8759
8982
 
8760
8983
  var _useState = useState(searchText || ''),
8761
8984
  searchValue = _useState[0],
@@ -8768,14 +8991,13 @@ function ContextToolbar(_ref) {
8768
8991
  setSearchValue(searchText);
8769
8992
  }, [searchText]);
8770
8993
 
8771
- var onSearchQuery = function onSearchQuery(ev) {
8772
- var search = ev.target[0].value;
8994
+ var onSearchQuery = function onSearchQuery(event) {
8995
+ event.preventDefault();
8773
8996
  setLocation({
8774
- q: search,
8997
+ q: event.currentTarget.elements.filterInput.value,
8775
8998
  tab: 'Items',
8776
8999
  page: 0
8777
9000
  });
8778
- ev.preventDefault();
8779
9001
  };
8780
9002
 
8781
9003
  var onSearchByType = function onSearchByType(typeText) {
@@ -8809,7 +9031,8 @@ function ContextToolbar(_ref) {
8809
9031
  type: "text",
8810
9032
  className: "input is-size-7",
8811
9033
  placeholder: intl.formatMessage(genericMessages.search),
8812
- "data-test": "inputFilterTest"
9034
+ "data-test": "inputFilterTest",
9035
+ id: "filterInput"
8813
9036
  })
8814
9037
  }), jsx("div", {
8815
9038
  className: "control",
@@ -8836,7 +9059,9 @@ function ContextToolbar(_ref) {
8836
9059
  value: item
8837
9060
  };
8838
9061
  }),
8839
- onChange: onSearchByType
9062
+ onChange: function onChange(value) {
9063
+ return onSearchByType(value);
9064
+ }
8840
9065
  })
8841
9066
  }), traversal.hasPerm('guillotina.AddContent') && jsx("div", {
8842
9067
  className: "level-item",
@@ -8877,17 +9102,12 @@ function TabsPanel(_ref2) {
8877
9102
  location = _useLocation[0],
8878
9103
  setLocation = _useLocation[1];
8879
9104
 
8880
- if (location.get('tab')) {
8881
- currentTab = location.get('tab');
8882
- } else {
8883
- currentTab = currentTab || Object.keys(tabs)[0];
8884
- }
9105
+ currentTab = location.get('tab') || Object.keys(tabs)[0];
8885
9106
  /*if (!Object.keys(tabs).includes(currentTab)) {
8886
9107
  setLocation(defaultTab)
8887
9108
  currentTab = defaultTab
8888
9109
  }*/
8889
9110
 
8890
-
8891
9111
  var _useState = useState(currentTab),
8892
9112
  current = _useState[0],
8893
9113
  setTab = _useState[1];
@@ -8954,14 +9174,14 @@ var tabsPermissions = {
8954
9174
  Behaviors: 'guillotina.ModifyContent',
8955
9175
  Permissions: 'guillotina.SeePermissions'
8956
9176
  };
8957
- function FolderCtx(props) {
9177
+ function FolderCtx() {
8958
9178
  var ctx = useTraversal();
8959
9179
  var calculated = ctx.filterTabs(tabs, tabsPermissions);
8960
- return jsx(TabsPanel, _extends({
9180
+ return jsx(TabsPanel, {
8961
9181
  tabs: calculated,
8962
9182
  currentTab: "Items",
8963
- rightToolbar: jsx(ContextToolbar, _extends({}, props))
8964
- }, props));
9183
+ rightToolbar: jsx(ContextToolbar, {})
9184
+ });
8965
9185
  }
8966
9186
 
8967
9187
  var tabs$1 = {
@@ -8975,13 +9195,13 @@ var tabsPermissions$1 = {
8975
9195
  Behaviors: 'guillotina.ModifyContent',
8976
9196
  Permissions: 'guillotina.SeePermissions'
8977
9197
  };
8978
- function ItemCtx(props) {
9198
+ function ItemCtx() {
8979
9199
  var ctx = useTraversal();
8980
9200
  var calculated = ctx.filterTabs(tabs$1, tabsPermissions$1);
8981
- return jsx(TabsPanel, _extends({
9201
+ return jsx(TabsPanel, {
8982
9202
  tabs: calculated,
8983
9203
  currentTab: "Properties"
8984
- }, props));
9204
+ });
8985
9205
  }
8986
9206
 
8987
9207
  function _catch$7(body, recover) {
@@ -9000,8 +9220,9 @@ function _catch$7(body, recover) {
9000
9220
 
9001
9221
  function ApplicationCtx() {
9002
9222
  var intl = useIntl();
9003
- var context = useTraversal();
9004
- var databases = context.state.context.databases;
9223
+ var traversal = useTraversal();
9224
+ var appContext = traversal.state.context;
9225
+ var databases = appContext.databases;
9005
9226
  return jsxs(Fragment, {
9006
9227
  children: [jsx("h3", {
9007
9228
  children: intl.formatMessage({
@@ -9015,22 +9236,26 @@ function ApplicationCtx() {
9015
9236
  className: "container",
9016
9237
  children: [jsx(ItemTitle, {
9017
9238
  title: "Objects"
9018
- }), databases.map(function (db) {
9019
- return jsx(Item, {
9020
- item: {
9021
- id: db,
9022
- path: "/" + db + "/"
9023
- },
9024
- icon: 'fas fa-database'
9025
- }, db);
9239
+ }), jsx("table", {
9240
+ children: jsx("tbody", {
9241
+ children: databases.map(function (db) {
9242
+ return jsx(Item, {
9243
+ item: {
9244
+ id: db,
9245
+ path: "/" + db + "/"
9246
+ },
9247
+ icon: 'fas fa-database'
9248
+ }, db);
9249
+ })
9250
+ })
9026
9251
  })]
9027
9252
  })]
9028
9253
  });
9029
9254
  }
9030
9255
  function DatabaseCtx() {
9031
- var context = useTraversal();
9032
- var containers = context.state.context.containers;
9033
- var path = context.state.path;
9256
+ var traversal = useTraversal();
9257
+ var containers = traversal.state.context.containers;
9258
+ var path = traversal.state.path;
9034
9259
  return jsx(Fragment, {
9035
9260
  children: jsxs("div", {
9036
9261
  className: "container",
@@ -9318,18 +9543,17 @@ function UsersToolbar() {
9318
9543
 
9319
9544
  var searchText = location.get('q');
9320
9545
 
9321
- var onSearchQuery = function onSearchQuery(ev) {
9322
- var search = ev.target[0].value;
9546
+ var onSearchQuery = function onSearchQuery(event) {
9547
+ event.preventDefault();
9323
9548
  setLocation({
9324
- q: search,
9549
+ q: event.currentTarget.elements.filterInput.value,
9325
9550
  page: 0
9326
9551
  });
9327
- ev.preventDefault();
9328
9552
  }; // cleanup form on state.search change
9329
9553
 
9330
9554
 
9331
9555
  useEffect(function () {
9332
- if (!searchText || searchText === '') {
9556
+ if (ref.current && (!searchText || searchText === '')) {
9333
9557
  ref.current.value = '';
9334
9558
  }
9335
9559
  }, [searchText]);
@@ -9349,7 +9573,8 @@ function UsersToolbar() {
9349
9573
  type: "text",
9350
9574
  className: "input is-size-7",
9351
9575
  placeholder: intl.formatMessage(genericMessages.search),
9352
- "data-test": "inputFilterTest"
9576
+ "data-test": "inputFilterTest",
9577
+ id: "filterInput"
9353
9578
  })
9354
9579
  }), jsx("div", {
9355
9580
  className: "control",
@@ -9381,12 +9606,12 @@ function UsersToolbar() {
9381
9606
  })]
9382
9607
  });
9383
9608
  }
9384
- function UsersCtx(props) {
9385
- return jsx(TabsPanel, _extends({
9609
+ function UsersCtx() {
9610
+ return jsx(TabsPanel, {
9386
9611
  tabs: tabs$3,
9387
9612
  currentTab: "Users",
9388
9613
  rightToolbar: jsx(UsersToolbar, {})
9389
- }, props));
9614
+ });
9390
9615
  }
9391
9616
  function UserCtx() {
9392
9617
  var intl = useIntl();
@@ -9403,9 +9628,10 @@ function UserCtx() {
9403
9628
  state = _useState[0],
9404
9629
  setState = _useState[1];
9405
9630
 
9631
+ var userDataContext = Ctx.context;
9406
9632
  var fields = {
9407
9633
  user_groups: [],
9408
- user_roles: Ctx.context.user_roles
9634
+ user_roles: userDataContext.user_roles
9409
9635
  };
9410
9636
 
9411
9637
  var _useRemoteField = useRemoteField(fields),
@@ -9509,7 +9735,7 @@ function UserCtx() {
9509
9735
  "value": "Username"
9510
9736
  }]
9511
9737
  }), ":", ' ']
9512
- }), ' ', Ctx.context.username, " (", Ctx.context.email, ")"]
9738
+ }), ' ', userDataContext.username, " (", userDataContext.email, ")"]
9513
9739
  }), jsxs("p", {
9514
9740
  children: [jsxs("label", {
9515
9741
  children: [' ', intl.formatMessage({
@@ -9519,7 +9745,7 @@ function UserCtx() {
9519
9745
  "value": "Creation Date"
9520
9746
  }]
9521
9747
  }), ":", ' ']
9522
- }), ' ', formatDate(Ctx.context.creation_date)]
9748
+ }), ' ', formatDate(userDataContext.creation_date)]
9523
9749
  }), jsxs("p", {
9524
9750
  children: [jsxs("label", {
9525
9751
  children: [' ', intl.formatMessage({
@@ -9529,7 +9755,7 @@ function UserCtx() {
9529
9755
  "value": "Modification Date"
9530
9756
  }]
9531
9757
  }), ":", ' ']
9532
- }), ' ', formatDate(Ctx.context.modification_date)]
9758
+ }), ' ', formatDate(userDataContext.modification_date)]
9533
9759
  }), jsx(Button, {
9534
9760
  className: "is-size-7 is-info",
9535
9761
  onClick: function onClick() {
@@ -9548,7 +9774,7 @@ function UserCtx() {
9548
9774
  onSubmit: function onSubmit(ev) {
9549
9775
  return updateObject(ev);
9550
9776
  },
9551
- formData: Ctx.context,
9777
+ formData: userDataContext,
9552
9778
  exclude: ['password'],
9553
9779
  remotes: remotes,
9554
9780
  submitButton: false,
@@ -9562,7 +9788,7 @@ function UserCtx() {
9562
9788
  className: "column",
9563
9789
  children: [jsx(TagsWidget, {
9564
9790
  onChange: updateRemote('user_groups'),
9565
- items: Ctx.context.user_groups,
9791
+ items: userDataContext.user_groups,
9566
9792
  title: "Groups",
9567
9793
  noData: intl.formatMessage({
9568
9794
  id: "there_is_no_groups_for_this_user",
@@ -9583,7 +9809,12 @@ function UserCtx() {
9583
9809
  "value": "The user doesn't have any role"
9584
9810
  }]
9585
9811
  }),
9586
- available: state.roles
9812
+ available: state.roles.map(function (x) {
9813
+ return {
9814
+ value: x,
9815
+ text: x
9816
+ };
9817
+ })
9587
9818
  })]
9588
9819
  })]
9589
9820
  })]
@@ -9599,7 +9830,7 @@ function CopyItems(props) {
9599
9830
  try {
9600
9831
  return Promise.resolve(Promise.all(items.map(function (item, i) {
9601
9832
  var input = form[i + 1] || {};
9602
- return Ctx.client.post("" + Ctx.path + item['@name'] + "/@duplicate", {
9833
+ return Ctx.client.post("" + Ctx.path + item.id + "/@duplicate", {
9603
9834
  destination: path,
9604
9835
  new_id: input.value || getNewId(item.id)
9605
9836
  });
@@ -9645,7 +9876,7 @@ function CopyItems(props) {
9645
9876
  }), jsx("input", {
9646
9877
  type: "text",
9647
9878
  className: "input",
9648
- "data-test": "inputCopyIdTest-" + item['@name'],
9879
+ "data-test": "inputCopyIdTest-" + item.id,
9649
9880
  defaultValue: getNewId(item.id)
9650
9881
  })]
9651
9882
  }, item.id);
@@ -9718,9 +9949,9 @@ function MoveItems(props) {
9718
9949
  var moveItems = function moveItems(path) {
9719
9950
  try {
9720
9951
  return Promise.resolve(Promise.all(items.map(function (item) {
9721
- return Ctx.client.post("" + Ctx.path + item['@name'] + "/@move", {
9952
+ return Ctx.client.post("" + Ctx.path + item.id + "/@move", {
9722
9953
  destination: path,
9723
- new_id: item['@name']
9954
+ new_id: item.id
9724
9955
  });
9725
9956
  }))).then(function (responses) {
9726
9957
  Ctx.refresh();
@@ -10057,18 +10288,17 @@ function GroupToolbar() {
10057
10288
 
10058
10289
  var searchText = location.get('q');
10059
10290
 
10060
- var onSearchQuery = function onSearchQuery(ev) {
10061
- var search = ev.target[0].value;
10291
+ var onSearchQuery = function onSearchQuery(event) {
10292
+ event.preventDefault();
10062
10293
  setLocation({
10063
- q: search,
10294
+ q: event.currentTarget.elements.filterInput.value,
10064
10295
  page: 0
10065
10296
  });
10066
- ev.preventDefault();
10067
10297
  }; // cleanup form on state.search change
10068
10298
 
10069
10299
 
10070
10300
  useEffect(function () {
10071
- if (!searchText || searchText === '') {
10301
+ if (ref.current && (!searchText || searchText === '')) {
10072
10302
  ref.current.value = '';
10073
10303
  }
10074
10304
  }, [searchText]);
@@ -10088,7 +10318,8 @@ function GroupToolbar() {
10088
10318
  type: "text",
10089
10319
  className: "input is-size-7",
10090
10320
  placeholder: intl.formatMessage(genericMessages.search),
10091
- "data-test": "inputFilterTest"
10321
+ "data-test": "inputFilterTest",
10322
+ id: "filterInput"
10092
10323
  })
10093
10324
  }), jsx("div", {
10094
10325
  className: "control",
@@ -10126,12 +10357,12 @@ function GroupToolbar() {
10126
10357
  })]
10127
10358
  });
10128
10359
  }
10129
- function GroupsCtx(props) {
10130
- return jsx(TabsPanel, _extends({
10360
+ function GroupsCtx() {
10361
+ return jsx(TabsPanel, {
10131
10362
  tabs: tabs$4,
10132
10363
  currentTab: "Groups",
10133
10364
  rightToolbar: jsx(GroupToolbar, {})
10134
- }, props));
10365
+ });
10135
10366
  }
10136
10367
  var sortParsed = parser("_sort_asc=id");
10137
10368
  var searchParsed = parser('type_name=User');
@@ -10146,6 +10377,7 @@ function GroupCtx() {
10146
10377
  roles = _useState[0],
10147
10378
  setRoles = _useState[1];
10148
10379
 
10380
+ var groupDataContext = Ctx.context;
10149
10381
  useEffect(function () {
10150
10382
  var getRoles = function getRoles() {
10151
10383
  try {
@@ -10199,11 +10431,11 @@ function GroupCtx() {
10199
10431
  var addRole = function addRole(role) {
10200
10432
  try {
10201
10433
  return Promise.resolve(patch({
10202
- user_roles: Ctx.context.user_roles.concat(role)
10434
+ user_roles: groupDataContext.user_roles.concat(role)
10203
10435
  })).then(function (_ref) {
10204
10436
  var isError = _ref.isError,
10205
10437
  errorMessage = _ref.errorMessage;
10206
- handleResponse(isError, intl.formatMessage({
10438
+ handleResponse(!!isError, intl.formatMessage({
10207
10439
  id: "role_added_to_group",
10208
10440
  defaultMessage: [{
10209
10441
  "type": 0,
@@ -10217,7 +10449,7 @@ function GroupCtx() {
10217
10449
  }]
10218
10450
  }, {
10219
10451
  role: role
10220
- }), errorMessage);
10452
+ }), errorMessage != null ? errorMessage : '');
10221
10453
  });
10222
10454
  } catch (e) {
10223
10455
  return Promise.reject(e);
@@ -10227,13 +10459,13 @@ function GroupCtx() {
10227
10459
  var removeRole = function removeRole(role) {
10228
10460
  try {
10229
10461
  return Promise.resolve(patch({
10230
- user_roles: Ctx.context.user_roles.filter(function (r) {
10462
+ user_roles: groupDataContext.user_roles.filter(function (r) {
10231
10463
  return r !== role;
10232
10464
  })
10233
10465
  })).then(function (_ref2) {
10234
10466
  var isError = _ref2.isError,
10235
10467
  errorMessage = _ref2.errorMessage;
10236
- handleResponse(isError, intl.formatMessage({
10468
+ handleResponse(!!isError, intl.formatMessage({
10237
10469
  id: "role_removed_from_group",
10238
10470
  defaultMessage: [{
10239
10471
  "type": 0,
@@ -10247,7 +10479,7 @@ function GroupCtx() {
10247
10479
  }]
10248
10480
  }, {
10249
10481
  role: role
10250
- }), errorMessage);
10482
+ }), errorMessage != null ? errorMessage : '');
10251
10483
  });
10252
10484
  } catch (e) {
10253
10485
  return Promise.reject(e);
@@ -10257,30 +10489,32 @@ function GroupCtx() {
10257
10489
  var addUser = function addUser(newUserId) {
10258
10490
  try {
10259
10491
  var data = {};
10260
- Ctx.context.users.forEach(function (user) {
10492
+ groupDataContext.users.forEach(function (user) {
10261
10493
  data[user] = true;
10262
10494
  });
10263
10495
  data[newUserId] = true;
10264
10496
  return Promise.resolve(Ctx.client.rest.patch(Ctx.containerPath + "@groups/" + Ctx.context['@name'], {
10265
10497
  users: data
10266
- })).then(function (_ref3) {
10267
- var isError = _ref3.isError,
10268
- errorMessage = _ref3.errorMessage;
10269
- handleResponse(isError, intl.formatMessage({
10270
- id: "user_added_to_group",
10271
- defaultMessage: [{
10272
- "type": 0,
10273
- "value": "User "
10274
- }, {
10275
- "type": 1,
10276
- "value": "user"
10498
+ })).then(function (response) {
10499
+ return Promise.resolve(processResponse(response)).then(function (_ref3) {
10500
+ var isError = _ref3.isError,
10501
+ errorMessage = _ref3.errorMessage;
10502
+ handleResponse(isError, intl.formatMessage({
10503
+ id: "user_added_to_group",
10504
+ defaultMessage: [{
10505
+ "type": 0,
10506
+ "value": "User "
10507
+ }, {
10508
+ "type": 1,
10509
+ "value": "user"
10510
+ }, {
10511
+ "type": 0,
10512
+ "value": " added to group"
10513
+ }]
10277
10514
  }, {
10278
- "type": 0,
10279
- "value": " added to group"
10280
- }]
10281
- }, {
10282
- user: newUserId
10283
- }), errorMessage);
10515
+ user: newUserId
10516
+ }), errorMessage != null ? errorMessage : '');
10517
+ });
10284
10518
  });
10285
10519
  } catch (e) {
10286
10520
  return Promise.reject(e);
@@ -10290,29 +10524,31 @@ function GroupCtx() {
10290
10524
  var removeUser = function removeUser(userToRemove) {
10291
10525
  try {
10292
10526
  var data = {};
10293
- Ctx.context.users.forEach(function (user) {
10527
+ groupDataContext.users.forEach(function (user) {
10294
10528
  data[user] = userToRemove !== user;
10295
10529
  });
10296
10530
  return Promise.resolve(Ctx.client.rest.patch(Ctx.containerPath + "@groups/" + Ctx.context['@name'], {
10297
10531
  users: data
10298
- })).then(function (_ref4) {
10299
- var isError = _ref4.isError,
10300
- errorMessage = _ref4.errorMessage;
10301
- handleResponse(isError, intl.formatMessage({
10302
- id: "user_removed_from_group",
10303
- defaultMessage: [{
10304
- "type": 0,
10305
- "value": "User "
10306
- }, {
10307
- "type": 1,
10308
- "value": "user"
10532
+ })).then(function (response) {
10533
+ return Promise.resolve(processResponse(response)).then(function (_ref4) {
10534
+ var isError = _ref4.isError,
10535
+ errorMessage = _ref4.errorMessage;
10536
+ handleResponse(isError, intl.formatMessage({
10537
+ id: "user_removed_from_group",
10538
+ defaultMessage: [{
10539
+ "type": 0,
10540
+ "value": "User "
10541
+ }, {
10542
+ "type": 1,
10543
+ "value": "user"
10544
+ }, {
10545
+ "type": 0,
10546
+ "value": " removed from group"
10547
+ }]
10309
10548
  }, {
10310
- "type": 0,
10311
- "value": " removed from group"
10312
- }]
10313
- }, {
10314
- user: userToRemove
10315
- }), errorMessage);
10549
+ user: userToRemove
10550
+ }), errorMessage != null ? errorMessage : '');
10551
+ });
10316
10552
  });
10317
10553
  } catch (e) {
10318
10554
  return Promise.reject(e);
@@ -10367,11 +10603,13 @@ function GroupCtx() {
10367
10603
  })
10368
10604
  }), jsx(Select, {
10369
10605
  options: roles.filter(function (role) {
10370
- return !Ctx.context.user_roles.includes(role.value);
10606
+ return !groupDataContext.user_roles.includes(role.value);
10371
10607
  }),
10372
10608
  appendDefault: true,
10373
- onChange: addRole
10374
- }), jsx("hr", {}), Ctx.context.user_roles.map(function (urole) {
10609
+ onChange: function onChange(value) {
10610
+ return addRole(value);
10611
+ }
10612
+ }), jsx("hr", {}), groupDataContext.user_roles.map(function (urole) {
10375
10613
  return jsx("p", {
10376
10614
  className: "control",
10377
10615
  children: jsx(Tag, {
@@ -10403,7 +10641,7 @@ function GroupCtx() {
10403
10641
  traversal: Ctx,
10404
10642
  onChange: addUser,
10405
10643
  btnClass: "is-small"
10406
- }), jsx("hr", {}), Ctx.context.users.map(function (user) {
10644
+ }), jsx("hr", {}), groupDataContext.users.map(function (user) {
10407
10645
  return jsx("p", {
10408
10646
  className: "control",
10409
10647
  children: jsx(Tag, {
@@ -10552,7 +10790,7 @@ function Path() {
10552
10790
  var links = buildPaths(segments);
10553
10791
 
10554
10792
  if (segments.length === 1) {
10555
- return false;
10793
+ return null;
10556
10794
  }
10557
10795
 
10558
10796
  return jsx("nav", {
@@ -10715,19 +10953,15 @@ var getItemsColumn = function getItemsColumn(type) {
10715
10953
  return undefined;
10716
10954
  };
10717
10955
 
10718
- var getForm = function getForm(type, fallback) {
10719
- if (fallback === void 0) {
10720
- fallback = BaseForm;
10721
- }
10956
+ var getView = function getView(name) {
10957
+ return registry.views[name];
10958
+ };
10722
10959
 
10723
- return registry.forms[type] || fallback;
10960
+ var getForm = function getForm(type, fallback) {
10961
+ return registry.forms[type] || fallback || BaseForm;
10724
10962
  };
10725
10963
 
10726
10964
  var getAction = function getAction(type, fallback) {
10727
- if (fallback === void 0) {
10728
- fallback = undefined;
10729
- }
10730
-
10731
10965
  return registry.actions[type] || fallback;
10732
10966
  };
10733
10967
 
@@ -10741,24 +10975,24 @@ var getProperties = function getProperties(type) {
10741
10975
 
10742
10976
  var getSchemas = function getSchemas(type) {
10743
10977
  return registry.schemas[type] || {};
10744
- /*
10745
- filters: [
10746
- {
10747
- attribute_key: string,
10748
- label: string,
10749
- type: 'select' | 'input'
10750
- vocabulary: string | undefined
10751
- values: {[key:string]:any}[]
10752
- }
10753
- ]
10754
- */
10755
10978
  };
10756
10979
 
10757
10980
  var getFieldsToFilter = function getFieldsToFilter(type, fallback) {
10981
+ if (fallback === void 0) {
10982
+ fallback = ['title'];
10983
+ }
10984
+
10758
10985
  return registry.fieldsToFilter[type] || fallback;
10759
10986
  };
10760
10987
 
10761
10988
  var getDefaultSortValue = function getDefaultSortValue(type, fallback) {
10989
+ if (fallback === void 0) {
10990
+ fallback = {
10991
+ key: 'id',
10992
+ direction: 'des'
10993
+ };
10994
+ }
10995
+
10762
10996
  return registry.defaultSortValue[type] || fallback;
10763
10997
  };
10764
10998
 
@@ -10772,7 +11006,8 @@ function useRegistry(data) {
10772
11006
  if (data && !ref.current) {
10773
11007
  ref.current = true;
10774
11008
  Object.keys(data).map(function (key) {
10775
- return registry[key] = _extends({}, registry[key], data[key]);
11009
+ var registryKey = key;
11010
+ registry[registryKey] = _extends({}, registry[registryKey], data[registryKey]);
10776
11011
  });
10777
11012
  }
10778
11013
 
@@ -10787,7 +11022,8 @@ function useRegistry(data) {
10787
11022
  getItemsColumn: getItemsColumn,
10788
11023
  getFieldsToFilter: getFieldsToFilter,
10789
11024
  getDefaultSortValue: getDefaultSortValue,
10790
- getSchemas: getSchemas
11025
+ getSchemas: getSchemas,
11026
+ getView: getView
10791
11027
  };
10792
11028
  }
10793
11029
  /*
@@ -10807,83 +11043,6 @@ const registry = {
10807
11043
 
10808
11044
  */
10809
11045
 
10810
- var initialState$4 = {
10811
- path: '',
10812
- loading: false,
10813
- context: undefined,
10814
- flash: {
10815
- message: undefined,
10816
- type: undefined
10817
- },
10818
- action: {
10819
- action: undefined,
10820
- params: undefined
10821
- },
10822
- permissions: undefined,
10823
- errorStatus: undefined,
10824
- registry: {},
10825
- refresh: undefined
10826
- };
10827
- function guillotinaReducer(state, action) {
10828
- switch (action.type) {
10829
- case 'SET_PATH':
10830
- return _extends({}, state, {
10831
- path: action.payload,
10832
- loading: true
10833
- });
10834
-
10835
- case 'SET_CONTEXT':
10836
- return _extends({}, state, action.payload, {
10837
- errorStatus: undefined,
10838
- loading: false
10839
- });
10840
-
10841
- case 'SET_ERROR':
10842
- return _extends({}, state, {
10843
- errorStatus: action.payload,
10844
- loading: false
10845
- });
10846
-
10847
- case 'SET_FLASH':
10848
- return _extends({}, state, action.payload);
10849
-
10850
- case 'CLEAR_FLASH':
10851
- return _extends({}, state, {
10852
- flash: {
10853
- message: undefined,
10854
- type: undefined
10855
- }
10856
- });
10857
-
10858
- case 'SET_ACTION':
10859
- return _extends({}, state, {
10860
- action: action.payload
10861
- });
10862
-
10863
- case 'CLEAR_ACTION':
10864
- return _extends({}, state, {
10865
- action: {
10866
- action: undefined,
10867
- params: undefined
10868
- }
10869
- });
10870
-
10871
- case 'REFRESH':
10872
- return _extends({}, state, {
10873
- refresh: Date.now(),
10874
- loading: !action.payload.transparent
10875
- });
10876
-
10877
- case 'APPLY':
10878
- return _extends({}, state, {
10879
- context: _extends({}, state.context, action.payload)
10880
- });
10881
-
10882
- default:
10883
- return state;
10884
- }
10885
- }
10886
-
10887
11046
  var actions = [
10888
11047
  {
10889
11048
  type: 0,
@@ -13701,7 +13860,7 @@ function Guillotina(_ref) {
13701
13860
  var _useConfig = useConfig(config),
13702
13861
  Permissions = _useConfig.Permissions;
13703
13862
 
13704
- var registry = useRegistry(props.registry || {}); // Location is cooked routing solution (only uses search params)
13863
+ var registry = useRegistry(props.registry); // Location is cooked routing solution (only uses search params)
13705
13864
 
13706
13865
  var _useLocation = useLocation(),
13707
13866
  location = _useLocation[0]; // if there is no path provided just go to root
@@ -13710,10 +13869,10 @@ function Guillotina(_ref) {
13710
13869
  var searchPath = location.get('path') || '/';
13711
13870
 
13712
13871
  if (searchPath && searchPath !== '') {
13713
- initialState$4.path = searchPath;
13872
+ initialState.path = searchPath;
13714
13873
  }
13715
13874
 
13716
- var _useReducer = useReducer(guillotinaReducer, initialState$4),
13875
+ var _useReducer = useReducer(guillotinaReducer, initialState),
13717
13876
  state = _useReducer[0],
13718
13877
  dispatch = _useReducer[1];
13719
13878
 
@@ -13721,8 +13880,10 @@ function Guillotina(_ref) {
13721
13880
  refresh = state.refresh;
13722
13881
  useEffect(function () {
13723
13882
  dispatch({
13724
- type: 'SET_PATH',
13725
- payload: searchPath
13883
+ type: GuillotinaReducerActionTypes.SET_PATH,
13884
+ payload: {
13885
+ path: searchPath
13886
+ }
13726
13887
  });
13727
13888
  }, [searchPath]);
13728
13889
  useEffect(function () {
@@ -13731,14 +13892,18 @@ function Guillotina(_ref) {
13731
13892
  return Promise.resolve(client.getContext(path)).then(function (data) {
13732
13893
  if (data.status === 401) {
13733
13894
  dispatch({
13734
- type: 'SET_ERROR',
13735
- payload: 'notallowed'
13895
+ type: GuillotinaReducerActionTypes.SET_ERROR,
13896
+ payload: {
13897
+ errorStatus: 'notallowed'
13898
+ }
13736
13899
  });
13737
13900
  return;
13738
13901
  } else if (data.status === 404) {
13739
13902
  dispatch({
13740
- type: 'SET_ERROR',
13741
- payload: 'notfound'
13903
+ type: GuillotinaReducerActionTypes.SET_ERROR,
13904
+ payload: {
13905
+ errorStatus: 'notallowed'
13906
+ }
13742
13907
  });
13743
13908
  return;
13744
13909
  }
@@ -13747,7 +13912,7 @@ function Guillotina(_ref) {
13747
13912
  return Promise.resolve(client.canido(path, Permissions)).then(function (pr) {
13748
13913
  return Promise.resolve(pr.json()).then(function (permissions) {
13749
13914
  dispatch({
13750
- type: 'SET_CONTEXT',
13915
+ type: GuillotinaReducerActionTypes.SET_CONTEXT,
13751
13916
  payload: {
13752
13917
  context: context,
13753
13918
  permissions: permissions
@@ -13764,9 +13929,9 @@ function Guillotina(_ref) {
13764
13929
 
13765
13930
  initContext();
13766
13931
  }, [path, refresh, client]);
13767
- var ErrorBoundary = registry.get('views', 'ErrorBoundary');
13768
- var NotAllowed = registry.get('views', 'NotAllowed');
13769
- var NotFound = registry.get('views', 'NotFound');
13932
+ var ErrorBoundary = registry.getView('ErrorBoundary');
13933
+ var NotAllowed = registry.getView('NotAllowed');
13934
+ var NotFound = registry.getView('NotFound');
13770
13935
  var Path = registry.get('components', 'Path');
13771
13936
  var contextData = {
13772
13937
  url: url,
@@ -13789,7 +13954,7 @@ function Guillotina(_ref) {
13789
13954
  children: jsxs(ErrorBoundary, {
13790
13955
  children: [!errorStatus && jsx(TraversalProvider, _extends({}, contextData, {
13791
13956
  children: permissions && jsxs(React.Fragment, {
13792
- children: [action.action && jsx(Action, _extends({}, action.params)), jsx("div", {
13957
+ children: [action.action && Action !== null && jsx(Action, _extends({}, action.params)), jsx("div", {
13793
13958
  className: "level",
13794
13959
  children: jsx("div", {
13795
13960
  className: "level-left",
@@ -13798,7 +13963,7 @@ function Guillotina(_ref) {
13798
13963
  children: jsx(Path, {})
13799
13964
  })
13800
13965
  })
13801
- }), jsx(Flash, {}), Main && jsx(ErrorBoundary, {
13966
+ }), jsx(Flash, {}), Main !== undefined && jsx(ErrorBoundary, {
13802
13967
  children: jsxs("div", {
13803
13968
  className: "box main-panel",
13804
13969
  children: [state.loading && jsx(Loading, {}), !state.loading && jsx(Main, {
@@ -13908,7 +14073,7 @@ var ERRORS = {
13908
14073
  var initialState$5 = {
13909
14074
  username: '',
13910
14075
  password: '',
13911
- loading: undefined,
14076
+ loading: false,
13912
14077
  errors: undefined
13913
14078
  };
13914
14079
  var Login = function Login(_ref) {
@@ -13924,7 +14089,7 @@ var Login = function Login(_ref) {
13924
14089
 
13925
14090
  var inputRef = useRef(null);
13926
14091
  useEffect(function () {
13927
- if (inputRef) {
14092
+ if (inputRef && inputRef.current) {
13928
14093
  inputRef.current.focus();
13929
14094
  }
13930
14095
  }, [inputRef]);
@@ -14145,30 +14310,30 @@ function RequiredFieldsForm(_ref) {
14145
14310
  dataTest: dataTest,
14146
14311
  children: [schema && schema.data && !schema.loading && schema.formFields.map(function (key) {
14147
14312
  if (!ignoreFiels.includes(key)) {
14148
- var _value$title;
14313
+ var _schema$data, _value$title, _schema$data2;
14149
14314
 
14150
- var value = schema.data.properties[key];
14315
+ var value = (_schema$data = schema.data) == null ? void 0 : _schema$data.properties[key];
14151
14316
  return jsx(EditComponent, {
14152
14317
  id: key,
14153
14318
  placeholder: (_value$title = value == null ? void 0 : value.title) != null ? _value$title : '',
14154
14319
  className: "",
14155
14320
  required: true,
14156
- schema: schema.data.properties[key],
14157
- setValue: function setValue(ev) {
14321
+ schema: (_schema$data2 = schema.data) == null ? void 0 : _schema$data2.properties[key],
14322
+ setValue: function setValue(value) {
14158
14323
  if (key === 'title') {
14159
14324
  var _extends2;
14160
14325
 
14161
14326
  setFormData(_extends({}, formData, (_extends2 = {
14162
- uuid: stringToSlug(ev)
14163
- }, _extends2[key] = ev, _extends2)));
14327
+ uuid: stringToSlug(value)
14328
+ }, _extends2[key] = value, _extends2)));
14164
14329
  } else if (key === 'uuid') {
14165
14330
  setFormData(_extends({}, formData, {
14166
- uuid: stringToSlug(ev)
14331
+ uuid: stringToSlug(value)
14167
14332
  }));
14168
14333
  } else {
14169
14334
  var _extends3;
14170
14335
 
14171
- setFormData(_extends({}, formData, (_extends3 = {}, _extends3[key] = ev, _extends3)));
14336
+ setFormData(_extends({}, formData, (_extends3 = {}, _extends3[key] = value, _extends3)));
14172
14337
  }
14173
14338
  },
14174
14339
  error: errors[key],
@@ -14362,7 +14527,7 @@ var Auth = /*#__PURE__*/function () {
14362
14527
 
14363
14528
  if (!authToken) return {};
14364
14529
 
14365
- if (this.willExpire(expires) && this.retryRefresh < this.maxRetry) {
14530
+ if (this.willExpire(expires != null ? expires : '') && this.retryRefresh < this.maxRetry) {
14366
14531
 
14367
14532
  (function () {
14368
14533
  try {
@@ -14420,5 +14585,14 @@ var Auth = /*#__PURE__*/function () {
14420
14585
  return Auth;
14421
14586
  }();
14422
14587
 
14423
- export { AddItem, AddPermission, AllItemsCheckbox, ApplicationCtx, Auth, AuthContext, BaseForm, BehaviorNotImplemented, BehaviorsView, Button, Checkbox, ClientContext, ClientProvider, Config, Confirm, ContainerCtx, ContextToolbar, CreateButton, CreateContainer, DatabaseCtx, Delete, DownloadField, EditComponent, EditableField, EmailInput, FileUpload, Flash, FolderCtx, Form, FormBuilder, GroupCtx, GroupToolbar, GroupsCtx, Guillotina, GuillotinaClient, IAttachment, IImageAttachment, IMultiAttachment, IMultiImageAttachment, IMultiImageOrderedAttachment, IWorkflow, Icon, Input, InputList, Item, ItemCheckbox, ItemCtx, ItemModel, ItemTitle, ItemsActionsDropdown, ItemsActionsProvider, Layout, Link, Loading, Login, Modal, NotAllowed, Notification, Pagination, PanelActions, PanelAddons, PanelBehaviors, PanelItems, PanelNotImplemented, PanelPermissions, PanelProperties, PasswordInput, Path, PathTree, PermissionPrinperm, PermissionPrinrole, PermissionRoleperm, Permissions, PropertiesButtonView, PropertiesView, REGEX_EMAIL, REGEX_HEX_COLOR, REGEX_NUMBER, REGEX_URL, RItem, RemoveItems, RenderField, RenderFieldComponent, RequiredFieldsForm, RestClient, SearchInput, SearchInputList, SearchLabels, SearchOptionsLabels, SearchRenderField, SearchVocabularyLabels, Select, SelectVocabulary, Sharing, Table, TabsPanel, Tag, TagsWidget, TdLink, Textarea, Traversal, TraversalContext, TraversalProvider, UserCtx, UserForm, UsersCtx, UsersToolbar, VocabularyRenderField, base64ToArrayBuffer, buildQs, classnames, defaultComponent, formatDate, generateUID, genericFileMessages, genericMessages, get$1 as get, getActionsObject, getClient, getNewId, isEmail, isEmpty, isHexColor, isNumber, isURL, lightFileReader, maxLength, messages$4 as messages, minLength, noop, notEmpty, parser, sleep, stringToSlug, toQueryString, useConfig, useCrudContext, useGuillotinaClient, useLocation, useRegistry, useRemoteField, useTraversal, useVocabulary };
14588
+ var Setting;
14589
+
14590
+ (function (Setting) {
14591
+ Setting["Allow"] = "Allow";
14592
+ Setting["AllowSingle"] = "AllowSingle";
14593
+ Setting["Deny"] = "Deny";
14594
+ Setting["Unset"] = "Unset";
14595
+ })(Setting || (Setting = {}));
14596
+
14597
+ export { AddItem, AddPermission, AllItemsCheckbox, ApplicationCtx, Auth, AuthContext, BaseForm, BehaviorNotImplemented, BehaviorsView, Button, Checkbox, ClientContext, ClientProvider, Confirm, ContainerCtx, ContextToolbar, CreateButton, CreateContainer, DatabaseCtx, Delete, DownloadField, EditComponent, EditableField, EmailInput, FileUpload, Flash, FolderCtx, Form, FormBuilder, GroupCtx, GroupToolbar, GroupsCtx, Guillotina, GuillotinaClient, IAttachment, IImageAttachment, IMultiAttachment, IMultiImageAttachment, IMultiImageOrderedAttachment, IWorkflow, Icon, Input, InputList, Item, ItemCheckbox, ItemCtx, ItemModel, ItemTitle, ItemsActionsDropdown, ItemsActionsProvider, Layout, Link, Loading, Login, Modal, NotAllowed, Notification, Pagination, PanelActions, PanelAddons, PanelBehaviors, PanelItems, PanelNotImplemented, PanelPermissions, PanelProperties, PasswordInput, Path, PathTree, PermissionPrinperm, PermissionPrinrole, PermissionRoleperm, Permissions, PropertiesButtonView, PropertiesView, REGEX_EMAIL, REGEX_HEX_COLOR, REGEX_NUMBER, REGEX_URL, RItem, RemoveItems, RenderField, RenderFieldComponent, RequiredFieldsForm, RestClient, SearchInput, SearchInputList, SearchLabels, SearchOptionsLabels, SearchRenderField, SearchVocabularyLabels, Select, SelectVocabulary, Setting, Sharing, Table, TabsPanel, Tag, TagsWidget, TdLink, Textarea, Traversal, TraversalContext, TraversalProvider, UserCtx, UserForm, UsersCtx, UsersToolbar, VocabularyRenderField, base64ToArrayBuffer, buildQs, classnames, debounce, defaultComponent, defaultConfig, formatDate, generateUID, genericFileMessages, genericMessages, get, getActionsObject, getClient, getNewId, isEmail, isEmpty, isHexColor, isNumber, isURL, lightFileReader, maxLength, messages$4 as messages, minLength, noop, notEmpty, parser, sleep, stringToSlug, toQueryString, useConfig, useCrudContext, useGuillotinaClient, useLocation, useRegistry, useRemoteField, useTraversal, useVocabulary };
14424
14598
  //# sourceMappingURL=react-gmi.esm.js.map