@guillotinaweb/react-gmi 0.24.1 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/components/fields/renderField.d.ts +5 -0
- package/dist/components/input/search_input.d.ts +14 -3
- package/dist/components/input/search_input_list.d.ts +35 -0
- package/dist/index.d.ts +1 -0
- package/dist/react-gmi.esm.js +694 -105
- package/dist/react-gmi.esm.js.map +1 -1
- package/dist/react-gmi.js +696 -104
- package/dist/react-gmi.js.map +1 -1
- package/dist/react-gmi.modern.js +592 -83
- package/dist/react-gmi.modern.js.map +1 -1
- package/dist/react-gmi.umd.js +696 -104
- package/dist/react-gmi.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/react-gmi.esm.js
CHANGED
|
@@ -3017,6 +3017,45 @@ var Textarea = React.forwardRef(function (_ref, ref) {
|
|
|
3017
3017
|
}, error ? error : ''));
|
|
3018
3018
|
});
|
|
3019
3019
|
|
|
3020
|
+
var defaultEvents = ['mousedown', 'touchstart'];
|
|
3021
|
+
|
|
3022
|
+
var on = function on(obj) {
|
|
3023
|
+
return obj.addEventListener.apply(obj, [].slice.call(arguments, 1));
|
|
3024
|
+
};
|
|
3025
|
+
|
|
3026
|
+
var off = function off(obj) {
|
|
3027
|
+
return obj.removeEventListener.apply(obj, [].slice.call(arguments, 1));
|
|
3028
|
+
};
|
|
3029
|
+
|
|
3030
|
+
function useClickAway(ref, onClickAway, events) {
|
|
3031
|
+
if (events === void 0) {
|
|
3032
|
+
events = defaultEvents;
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
var savedCallback = useRef(onClickAway);
|
|
3036
|
+
useEffect(function () {
|
|
3037
|
+
savedCallback.current = onClickAway;
|
|
3038
|
+
}, [onClickAway]);
|
|
3039
|
+
useEffect(function () {
|
|
3040
|
+
var handler = function handler(event) {
|
|
3041
|
+
var el = ref.current;
|
|
3042
|
+
el && !el.contains(event.target) && savedCallback.current(event);
|
|
3043
|
+
};
|
|
3044
|
+
|
|
3045
|
+
for (var _iterator = _createForOfIteratorHelperLoose(events), _step; !(_step = _iterator()).done;) {
|
|
3046
|
+
var eventName = _step.value;
|
|
3047
|
+
on(document, eventName, handler);
|
|
3048
|
+
}
|
|
3049
|
+
|
|
3050
|
+
return function () {
|
|
3051
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(events), _step2; !(_step2 = _iterator2()).done;) {
|
|
3052
|
+
var eventName = _step2.value;
|
|
3053
|
+
off(document, eventName, handler);
|
|
3054
|
+
}
|
|
3055
|
+
};
|
|
3056
|
+
}, [events, ref]);
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3020
3059
|
function debounce(func, wait) {
|
|
3021
3060
|
var timeout;
|
|
3022
3061
|
return function () {
|
|
@@ -3061,7 +3100,11 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3061
3100
|
_ref$dataTestItem = _ref.dataTestItem,
|
|
3062
3101
|
dataTestItem = _ref$dataTestItem === void 0 ? 'searchInputItemTest' : _ref$dataTestItem,
|
|
3063
3102
|
_ref$renderTextItemOp = _ref.renderTextItemOption,
|
|
3064
|
-
renderTextItemOption = _ref$renderTextItemOp === void 0 ? null : _ref$renderTextItemOp
|
|
3103
|
+
renderTextItemOption = _ref$renderTextItemOp === void 0 ? null : _ref$renderTextItemOp,
|
|
3104
|
+
_ref$typeNameQuery = _ref.typeNameQuery,
|
|
3105
|
+
typeNameQuery = _ref$typeNameQuery === void 0 ? null : _ref$typeNameQuery,
|
|
3106
|
+
_ref$labelProperty = _ref.labelProperty,
|
|
3107
|
+
labelProperty = _ref$labelProperty === void 0 ? 'id' : _ref$labelProperty;
|
|
3065
3108
|
var intl = useIntl();
|
|
3066
3109
|
|
|
3067
3110
|
var _useSetState = useSetState(initialState),
|
|
@@ -3083,8 +3126,19 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3083
3126
|
PageSize = _useConfig.PageSize,
|
|
3084
3127
|
SearchEngine = _useConfig.SearchEngine;
|
|
3085
3128
|
|
|
3086
|
-
var _useState = useState(
|
|
3087
|
-
|
|
3129
|
+
var _useState = useState(undefined),
|
|
3130
|
+
valueLabel = _useState[0],
|
|
3131
|
+
setValueLabel = _useState[1];
|
|
3132
|
+
|
|
3133
|
+
var _useState2 = useState(false),
|
|
3134
|
+
setIsLoadingData = _useState2[1];
|
|
3135
|
+
|
|
3136
|
+
var _useState3 = useState(generateUID('search_input')),
|
|
3137
|
+
uid = _useState3[0];
|
|
3138
|
+
|
|
3139
|
+
useClickAway(wrapperRef, function () {
|
|
3140
|
+
setIsOpen(false);
|
|
3141
|
+
});
|
|
3088
3142
|
|
|
3089
3143
|
var getHeight = function getHeight() {
|
|
3090
3144
|
if (wrapperRef && wrapperRef.current) {
|
|
@@ -3098,10 +3152,52 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3098
3152
|
};
|
|
3099
3153
|
};
|
|
3100
3154
|
|
|
3101
|
-
var delayedQuery =
|
|
3155
|
+
var delayedQuery = useCallback(debounce(function (value) {
|
|
3102
3156
|
return handleSearch(0, false, value);
|
|
3103
3157
|
}, 500), []);
|
|
3104
3158
|
|
|
3159
|
+
var inicializeLabels = function inicializeLabels() {
|
|
3160
|
+
try {
|
|
3161
|
+
var _temp2 = function () {
|
|
3162
|
+
if (labelProperty !== 'id' && value) {
|
|
3163
|
+
setIsLoadingData(true);
|
|
3164
|
+
var searchTermQs = [];
|
|
3165
|
+
var searchTermParsed = ["id", value];
|
|
3166
|
+
var getSearch = traversal.registry.get;
|
|
3167
|
+
var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
|
|
3168
|
+
var qsParsed = traversal.client[fnName]({
|
|
3169
|
+
path: traversal.path,
|
|
3170
|
+
start: 0,
|
|
3171
|
+
pageSize: PageSize,
|
|
3172
|
+
withDepth: false
|
|
3173
|
+
});
|
|
3174
|
+
var typeNameParsed = [];
|
|
3175
|
+
|
|
3176
|
+
if (typeNameQuery) {
|
|
3177
|
+
typeNameParsed = parser("type_name__in=" + typeNameQuery);
|
|
3178
|
+
}
|
|
3179
|
+
|
|
3180
|
+
if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
3181
|
+
searchTermQs = buildQs([].concat(qs, [searchTermParsed], qsParsed, typeNameParsed));
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3184
|
+
return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
|
|
3185
|
+
var newValuesLabel = data.items.reduce(function (result, item) {
|
|
3186
|
+
result[item.id] = get$1(item, labelProperty, item.id);
|
|
3187
|
+
return result;
|
|
3188
|
+
}, {});
|
|
3189
|
+
setValueLabel(newValuesLabel);
|
|
3190
|
+
setIsLoadingData(false);
|
|
3191
|
+
});
|
|
3192
|
+
}
|
|
3193
|
+
}();
|
|
3194
|
+
|
|
3195
|
+
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
|
|
3196
|
+
} catch (e) {
|
|
3197
|
+
return Promise.reject(e);
|
|
3198
|
+
}
|
|
3199
|
+
};
|
|
3200
|
+
|
|
3105
3201
|
var handleSearch = function handleSearch(page, concat, value) {
|
|
3106
3202
|
if (page === void 0) {
|
|
3107
3203
|
page = 0;
|
|
@@ -3126,19 +3222,28 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3126
3222
|
searchTermParsed = parser(queryCondition + "=" + value);
|
|
3127
3223
|
}
|
|
3128
3224
|
|
|
3129
|
-
var
|
|
3130
|
-
|
|
3225
|
+
var _get = traversal.registry.get;
|
|
3226
|
+
|
|
3227
|
+
var fnName = _get('searchEngineQueryParamsFunction', SearchEngine);
|
|
3228
|
+
|
|
3131
3229
|
var qsParsed = traversal.client[fnName]({
|
|
3132
3230
|
path: traversal.path,
|
|
3133
3231
|
start: page * PageSize,
|
|
3134
|
-
pageSize: PageSize
|
|
3232
|
+
pageSize: PageSize,
|
|
3233
|
+
withDepth: false
|
|
3135
3234
|
});
|
|
3235
|
+
var sortParsed = parser("_sort_des=title");
|
|
3236
|
+
var typeNameParsed = [];
|
|
3136
3237
|
|
|
3137
|
-
if (
|
|
3138
|
-
|
|
3238
|
+
if (typeNameQuery) {
|
|
3239
|
+
typeNameParsed = parser("type_name__in=" + typeNameQuery);
|
|
3139
3240
|
}
|
|
3140
3241
|
|
|
3141
|
-
|
|
3242
|
+
if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
3243
|
+
searchTermQs = buildQs([].concat(qs, searchTermParsed, qsParsed, typeNameParsed, sortParsed));
|
|
3244
|
+
}
|
|
3245
|
+
|
|
3246
|
+
return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
|
|
3142
3247
|
var _data$items_total;
|
|
3143
3248
|
|
|
3144
3249
|
var newItems = options.items && concat ? [].concat(options.items, data.items) : data.items;
|
|
@@ -3162,20 +3267,24 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3162
3267
|
return item.title || item['@name'];
|
|
3163
3268
|
};
|
|
3164
3269
|
|
|
3165
|
-
|
|
3166
|
-
if (
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
} catch (e) {
|
|
3171
|
-
Promise.reject(e);
|
|
3172
|
-
}
|
|
3270
|
+
useEffect(function () {
|
|
3271
|
+
if (value) {
|
|
3272
|
+
inicializeLabels();
|
|
3273
|
+
} else {
|
|
3274
|
+
setValueLabel({});
|
|
3173
3275
|
}
|
|
3174
|
-
}, [path,
|
|
3276
|
+
}, [path, value]);
|
|
3277
|
+
|
|
3278
|
+
if (valueLabel === undefined) {
|
|
3279
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
3280
|
+
className: "spinner"
|
|
3281
|
+
});
|
|
3282
|
+
}
|
|
3283
|
+
|
|
3175
3284
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
3176
3285
|
"data-test": dataTestWrapper,
|
|
3177
3286
|
ref: wrapperRef,
|
|
3178
|
-
className: "dropdown " + (isOpen ? 'is-active' : ''),
|
|
3287
|
+
className: "dropdown mb-2 " + (isOpen ? 'is-active' : ''),
|
|
3179
3288
|
onBlur: function onBlur(ev) {
|
|
3180
3289
|
if (!ev.currentTarget.contains(ev.relatedTarget)) {
|
|
3181
3290
|
if (searchTerm !== '') {
|
|
@@ -3183,7 +3292,7 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3183
3292
|
setOptions(initialState);
|
|
3184
3293
|
}
|
|
3185
3294
|
|
|
3186
|
-
setIsOpen(
|
|
3295
|
+
setIsOpen(false);
|
|
3187
3296
|
}
|
|
3188
3297
|
}
|
|
3189
3298
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -3191,12 +3300,16 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3191
3300
|
}, /*#__PURE__*/React.createElement("button", {
|
|
3192
3301
|
className: "button " + btnClass,
|
|
3193
3302
|
onClick: function onClick(ev) {
|
|
3194
|
-
ev.
|
|
3303
|
+
ev.target.blur();
|
|
3195
3304
|
setIsOpen(!isOpen);
|
|
3305
|
+
|
|
3306
|
+
if (!options.loading && !options.items) {
|
|
3307
|
+
handleSearch(options.page);
|
|
3308
|
+
}
|
|
3196
3309
|
},
|
|
3197
3310
|
"aria-haspopup": "true",
|
|
3198
3311
|
"aria-controls": "dropdown-menu"
|
|
3199
|
-
}, /*#__PURE__*/React.createElement("span", null, value
|
|
3312
|
+
}, /*#__PURE__*/React.createElement("span", null, value ? get$1(valueLabel, value, value) : intl.formatMessage(genericMessages.choose)), /*#__PURE__*/React.createElement("span", {
|
|
3200
3313
|
className: "icon"
|
|
3201
3314
|
}, /*#__PURE__*/React.createElement("i", {
|
|
3202
3315
|
className: "fas fa-angle-down",
|
|
@@ -3224,12 +3337,16 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3224
3337
|
})), /*#__PURE__*/React.createElement("hr", {
|
|
3225
3338
|
className: "dropdown-divider"
|
|
3226
3339
|
}), options.loading && /*#__PURE__*/React.createElement(Loading, null), options.items && options.items.map(function (item) {
|
|
3227
|
-
return /*#__PURE__*/React.createElement("
|
|
3228
|
-
|
|
3229
|
-
className: "dropdown-item editable " + (value && value.id === item.id ? 'is-active' : ''),
|
|
3340
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
3341
|
+
className: "dropdown-item editable " + (value === item.id ? 'is-active' : ''),
|
|
3230
3342
|
"data-test": dataTestItem + "-" + item.id,
|
|
3231
|
-
onMouseDown: function onMouseDown() {
|
|
3232
|
-
|
|
3343
|
+
onMouseDown: function onMouseDown(ev) {
|
|
3344
|
+
ev.preventDefault();
|
|
3345
|
+
|
|
3346
|
+
if (onChange) {
|
|
3347
|
+
onChange(item.id);
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3233
3350
|
setIsOpen(false);
|
|
3234
3351
|
},
|
|
3235
3352
|
key: item.path
|
|
@@ -3252,11 +3369,20 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3252
3369
|
};
|
|
3253
3370
|
SearchInput.propTypes = {
|
|
3254
3371
|
onChange: PropTypes.func,
|
|
3255
|
-
value: PropTypes.
|
|
3256
|
-
client: PropTypes.object,
|
|
3372
|
+
value: PropTypes.string,
|
|
3257
3373
|
path: PropTypes.string,
|
|
3258
|
-
|
|
3259
|
-
|
|
3374
|
+
btnClass: PropTypes.string,
|
|
3375
|
+
error: PropTypes.string,
|
|
3376
|
+
errorZoneClassName: PropTypes.string,
|
|
3377
|
+
traversal: PropTypes.object,
|
|
3378
|
+
qs: PropTypes.array,
|
|
3379
|
+
queryCondition: PropTypes.string,
|
|
3380
|
+
dataTestWrapper: PropTypes.string,
|
|
3381
|
+
dataTestSearchInput: PropTypes.string,
|
|
3382
|
+
dataTestItem: PropTypes.string,
|
|
3383
|
+
renderTextItemOption: PropTypes.func,
|
|
3384
|
+
typeNameQuery: PropTypes.string,
|
|
3385
|
+
labelProperty: PropTypes.string
|
|
3260
3386
|
};
|
|
3261
3387
|
|
|
3262
3388
|
var InputList = forwardRef(function (_ref, ref) {
|
|
@@ -3315,45 +3441,6 @@ var InputList = forwardRef(function (_ref, ref) {
|
|
|
3315
3441
|
}));
|
|
3316
3442
|
});
|
|
3317
3443
|
|
|
3318
|
-
var defaultEvents = ['mousedown', 'touchstart'];
|
|
3319
|
-
|
|
3320
|
-
var on = function on(obj) {
|
|
3321
|
-
return obj.addEventListener.apply(obj, [].slice.call(arguments, 1));
|
|
3322
|
-
};
|
|
3323
|
-
|
|
3324
|
-
var off = function off(obj) {
|
|
3325
|
-
return obj.removeEventListener.apply(obj, [].slice.call(arguments, 1));
|
|
3326
|
-
};
|
|
3327
|
-
|
|
3328
|
-
function useClickAway(ref, onClickAway, events) {
|
|
3329
|
-
if (events === void 0) {
|
|
3330
|
-
events = defaultEvents;
|
|
3331
|
-
}
|
|
3332
|
-
|
|
3333
|
-
var savedCallback = useRef(onClickAway);
|
|
3334
|
-
useEffect(function () {
|
|
3335
|
-
savedCallback.current = onClickAway;
|
|
3336
|
-
}, [onClickAway]);
|
|
3337
|
-
useEffect(function () {
|
|
3338
|
-
var handler = function handler(event) {
|
|
3339
|
-
var el = ref.current;
|
|
3340
|
-
el && !el.contains(event.target) && savedCallback.current(event);
|
|
3341
|
-
};
|
|
3342
|
-
|
|
3343
|
-
for (var _iterator = _createForOfIteratorHelperLoose(events), _step; !(_step = _iterator()).done;) {
|
|
3344
|
-
var eventName = _step.value;
|
|
3345
|
-
on(document, eventName, handler);
|
|
3346
|
-
}
|
|
3347
|
-
|
|
3348
|
-
return function () {
|
|
3349
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(events), _step2; !(_step2 = _iterator2()).done;) {
|
|
3350
|
-
var eventName = _step2.value;
|
|
3351
|
-
off(document, eventName, handler);
|
|
3352
|
-
}
|
|
3353
|
-
};
|
|
3354
|
-
}, [events, ref]);
|
|
3355
|
-
}
|
|
3356
|
-
|
|
3357
3444
|
function Dropdown(_ref) {
|
|
3358
3445
|
var children = _ref.children,
|
|
3359
3446
|
disabled = _ref.disabled,
|
|
@@ -3821,12 +3908,98 @@ var getDefaultValueEditableField = function getDefaultValueEditableField(intl) {
|
|
|
3821
3908
|
});
|
|
3822
3909
|
};
|
|
3823
3910
|
|
|
3824
|
-
var
|
|
3825
|
-
var _schema$items;
|
|
3826
|
-
|
|
3911
|
+
var SearchRenderField = function SearchRenderField(_ref3) {
|
|
3827
3912
|
var schema = _ref3.schema,
|
|
3828
3913
|
value = _ref3.value,
|
|
3829
3914
|
modifyContent = _ref3.modifyContent;
|
|
3915
|
+
|
|
3916
|
+
var _useState = useState([]),
|
|
3917
|
+
valuesLabels = _useState[0],
|
|
3918
|
+
setValuesLabels = _useState[1];
|
|
3919
|
+
|
|
3920
|
+
var _useState2 = useState(false),
|
|
3921
|
+
isLoadingData = _useState2[0],
|
|
3922
|
+
setIsLoadingData = _useState2[1];
|
|
3923
|
+
|
|
3924
|
+
var traversal = useTraversal();
|
|
3925
|
+
|
|
3926
|
+
var _useConfig = useConfig(),
|
|
3927
|
+
SearchEngine = _useConfig.SearchEngine;
|
|
3928
|
+
|
|
3929
|
+
useEffect(function () {
|
|
3930
|
+
var fetchData = function fetchData(valuesToSearch) {
|
|
3931
|
+
try {
|
|
3932
|
+
setIsLoadingData(true);
|
|
3933
|
+
var searchTermQs = [];
|
|
3934
|
+
var searchTermParsed = ['__or', "id=" + valuesToSearch.join('%26id=')];
|
|
3935
|
+
var getSearch = traversal.registry.get;
|
|
3936
|
+
var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
|
|
3937
|
+
var qsParsed = traversal.client[fnName]({
|
|
3938
|
+
path: traversal.path,
|
|
3939
|
+
start: 0,
|
|
3940
|
+
pageSize: 100,
|
|
3941
|
+
withDepth: false
|
|
3942
|
+
});
|
|
3943
|
+
|
|
3944
|
+
if (searchTermParsed.length > 0 || qsParsed.length > 0) {
|
|
3945
|
+
searchTermQs = buildQs([searchTermParsed].concat(qsParsed));
|
|
3946
|
+
}
|
|
3947
|
+
|
|
3948
|
+
return Promise.resolve(traversal.client.search(traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false, 0, 100)).then(function (data) {
|
|
3949
|
+
var newValuesLabel = data.items.map(function (item) {
|
|
3950
|
+
var _schema$labelProperty;
|
|
3951
|
+
|
|
3952
|
+
return get$1(item, (_schema$labelProperty = schema == null ? void 0 : schema.labelProperty) != null ? _schema$labelProperty : 'title', item.id);
|
|
3953
|
+
});
|
|
3954
|
+
setValuesLabels(newValuesLabel);
|
|
3955
|
+
setIsLoadingData(false);
|
|
3956
|
+
});
|
|
3957
|
+
} catch (e) {
|
|
3958
|
+
return Promise.reject(e);
|
|
3959
|
+
}
|
|
3960
|
+
};
|
|
3961
|
+
|
|
3962
|
+
var valuesToSearch = value;
|
|
3963
|
+
|
|
3964
|
+
if (typeof valuesToSearch === 'string') {
|
|
3965
|
+
valuesToSearch = [valuesToSearch];
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
if (valuesToSearch !== undefined && valuesToSearch.length > 0) {
|
|
3969
|
+
fetchData(valuesToSearch);
|
|
3970
|
+
} else {
|
|
3971
|
+
setValuesLabels([]);
|
|
3972
|
+
}
|
|
3973
|
+
}, [value]);
|
|
3974
|
+
|
|
3975
|
+
var getRenderValue = function getRenderValue() {
|
|
3976
|
+
console.log('get render values', value, valuesLabels);
|
|
3977
|
+
|
|
3978
|
+
if (value === undefined) {
|
|
3979
|
+
if (modifyContent) {
|
|
3980
|
+
return DEFAULT_VALUE_EDITABLE_FIELD;
|
|
3981
|
+
}
|
|
3982
|
+
|
|
3983
|
+
return DEFAULT_VALUE_NO_EDITABLE_FIELD;
|
|
3984
|
+
}
|
|
3985
|
+
|
|
3986
|
+
if (isLoadingData) {
|
|
3987
|
+
return 'Loading...';
|
|
3988
|
+
}
|
|
3989
|
+
|
|
3990
|
+
return valuesLabels;
|
|
3991
|
+
};
|
|
3992
|
+
|
|
3993
|
+
return /*#__PURE__*/React.createElement(RenderField, {
|
|
3994
|
+
value: getRenderValue()
|
|
3995
|
+
});
|
|
3996
|
+
};
|
|
3997
|
+
var VocabularyRenderField = function VocabularyRenderField(_ref4) {
|
|
3998
|
+
var _schema$items;
|
|
3999
|
+
|
|
4000
|
+
var schema = _ref4.schema,
|
|
4001
|
+
value = _ref4.value,
|
|
4002
|
+
modifyContent = _ref4.modifyContent;
|
|
3830
4003
|
var intl = useIntl();
|
|
3831
4004
|
var DEFAULT_VALUE_EDITABLE_FIELD = getDefaultValueEditableField(intl);
|
|
3832
4005
|
var vocabularyName = (schema == null ? void 0 : (_schema$items = schema.items) == null ? void 0 : _schema$items.vocabularyName) || (schema == null ? void 0 : schema.vocabularyName);
|
|
@@ -3861,11 +4034,11 @@ var VocabularyRenderField = function VocabularyRenderField(_ref3) {
|
|
|
3861
4034
|
|
|
3862
4035
|
return /*#__PURE__*/React.createElement(RenderField, getRenderProps());
|
|
3863
4036
|
};
|
|
3864
|
-
function RenderFieldComponent(
|
|
3865
|
-
var schema =
|
|
3866
|
-
field =
|
|
3867
|
-
val =
|
|
3868
|
-
modifyContent =
|
|
4037
|
+
function RenderFieldComponent(_ref5) {
|
|
4038
|
+
var schema = _ref5.schema,
|
|
4039
|
+
field = _ref5.field,
|
|
4040
|
+
val = _ref5.val,
|
|
4041
|
+
modifyContent = _ref5.modifyContent;
|
|
3869
4042
|
var intl = useIntl();
|
|
3870
4043
|
var DEFAULT_VALUE_EDITABLE_FIELD = getDefaultValueEditableField(intl);
|
|
3871
4044
|
|
|
@@ -3891,6 +4064,10 @@ function RenderFieldComponent(_ref4) {
|
|
|
3891
4064
|
} else if (schema != null && (_schema$items2 = schema.items) != null && _schema$items2.vocabularyName || schema != null && schema.vocabularyName) {
|
|
3892
4065
|
renderProps['Widget'] = VocabularyRenderField;
|
|
3893
4066
|
renderProps['schema'] = schema;
|
|
4067
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'search' || (schema == null ? void 0 : schema.widget) === 'search_list') {
|
|
4068
|
+
renderProps['Widget'] = SearchRenderField;
|
|
4069
|
+
renderProps['value'] = val;
|
|
4070
|
+
renderProps['schema'] = schema;
|
|
3894
4071
|
}
|
|
3895
4072
|
|
|
3896
4073
|
return renderProps;
|
|
@@ -3967,6 +4144,353 @@ Select.propTypes = {
|
|
|
3967
4144
|
vocabularyName: PropTypes.string
|
|
3968
4145
|
};
|
|
3969
4146
|
|
|
4147
|
+
var _SearchInputList$prop;
|
|
4148
|
+
|
|
4149
|
+
function debounce$1(func, wait) {
|
|
4150
|
+
var timeout;
|
|
4151
|
+
return function () {
|
|
4152
|
+
var context = this;
|
|
4153
|
+
var args = arguments;
|
|
4154
|
+
|
|
4155
|
+
var later = function later() {
|
|
4156
|
+
timeout = null;
|
|
4157
|
+
func.apply(context, args);
|
|
4158
|
+
};
|
|
4159
|
+
|
|
4160
|
+
clearTimeout(timeout);
|
|
4161
|
+
timeout = setTimeout(later, wait);
|
|
4162
|
+
};
|
|
4163
|
+
}
|
|
4164
|
+
|
|
4165
|
+
var initialState$1 = {
|
|
4166
|
+
page: 0,
|
|
4167
|
+
items: undefined,
|
|
4168
|
+
loading: false,
|
|
4169
|
+
items_total: 0
|
|
4170
|
+
};
|
|
4171
|
+
var SearchInputList = function SearchInputList(_ref) {
|
|
4172
|
+
var onChange = _ref.onChange,
|
|
4173
|
+
error = _ref.error,
|
|
4174
|
+
errorZoneClassName = _ref.errorZoneClassName,
|
|
4175
|
+
_ref$traversal = _ref.traversal,
|
|
4176
|
+
traversal = _ref$traversal === void 0 ? null : _ref$traversal,
|
|
4177
|
+
_ref$path = _ref.path,
|
|
4178
|
+
path = _ref$path === void 0 ? null : _ref$path,
|
|
4179
|
+
_ref$qs = _ref.qs,
|
|
4180
|
+
qs = _ref$qs === void 0 ? [] : _ref$qs,
|
|
4181
|
+
_ref$queryCondition = _ref.queryCondition,
|
|
4182
|
+
queryCondition = _ref$queryCondition === void 0 ? 'id__in' : _ref$queryCondition,
|
|
4183
|
+
value = _ref.value,
|
|
4184
|
+
_ref$btnClass = _ref.btnClass,
|
|
4185
|
+
btnClass = _ref$btnClass === void 0 ? '' : _ref$btnClass,
|
|
4186
|
+
_ref$dataTestWrapper = _ref.dataTestWrapper,
|
|
4187
|
+
dataTestWrapper = _ref$dataTestWrapper === void 0 ? 'wrapperSearchInputTest' : _ref$dataTestWrapper,
|
|
4188
|
+
_ref$dataTestSearchIn = _ref.dataTestSearchInput,
|
|
4189
|
+
dataTestSearchInput = _ref$dataTestSearchIn === void 0 ? 'searchInputTest' : _ref$dataTestSearchIn,
|
|
4190
|
+
_ref$dataTestItem = _ref.dataTestItem,
|
|
4191
|
+
dataTestItem = _ref$dataTestItem === void 0 ? 'searchInputItemTest' : _ref$dataTestItem,
|
|
4192
|
+
_ref$renderTextItemOp = _ref.renderTextItemOption,
|
|
4193
|
+
renderTextItemOption = _ref$renderTextItemOp === void 0 ? null : _ref$renderTextItemOp,
|
|
4194
|
+
_ref$typeNameQuery = _ref.typeNameQuery,
|
|
4195
|
+
typeNameQuery = _ref$typeNameQuery === void 0 ? null : _ref$typeNameQuery,
|
|
4196
|
+
_ref$labelProperty = _ref.labelProperty,
|
|
4197
|
+
labelProperty = _ref$labelProperty === void 0 ? 'id' : _ref$labelProperty;
|
|
4198
|
+
var intl = useIntl();
|
|
4199
|
+
|
|
4200
|
+
var _useSetState = useSetState(initialState$1),
|
|
4201
|
+
options = _useSetState[0],
|
|
4202
|
+
setOptions = _useSetState[1];
|
|
4203
|
+
|
|
4204
|
+
var _useState = useState(undefined),
|
|
4205
|
+
valuesLabel = _useState[0],
|
|
4206
|
+
setValuesLabels = _useState[1];
|
|
4207
|
+
|
|
4208
|
+
var _React$useState = React.useState(false),
|
|
4209
|
+
isOpen = _React$useState[0],
|
|
4210
|
+
setIsOpen = _React$useState[1];
|
|
4211
|
+
|
|
4212
|
+
var _React$useState2 = React.useState(''),
|
|
4213
|
+
searchTerm = _React$useState2[0],
|
|
4214
|
+
setSearchTerm = _React$useState2[1];
|
|
4215
|
+
|
|
4216
|
+
var inputRef = React.useRef(null);
|
|
4217
|
+
var wrapperRef = React.useRef(null);
|
|
4218
|
+
|
|
4219
|
+
var _useConfig = useConfig(),
|
|
4220
|
+
PageSize = _useConfig.PageSize,
|
|
4221
|
+
SearchEngine = _useConfig.SearchEngine;
|
|
4222
|
+
|
|
4223
|
+
var _useState2 = useState(false),
|
|
4224
|
+
isLoadingData = _useState2[0],
|
|
4225
|
+
setIsLoadingData = _useState2[1];
|
|
4226
|
+
|
|
4227
|
+
var _useState3 = useState(generateUID('search_input')),
|
|
4228
|
+
uid = _useState3[0];
|
|
4229
|
+
|
|
4230
|
+
useClickAway(wrapperRef, function () {
|
|
4231
|
+
setIsOpen(false);
|
|
4232
|
+
});
|
|
4233
|
+
|
|
4234
|
+
var getHeight = function getHeight() {
|
|
4235
|
+
if (wrapperRef && wrapperRef.current) {
|
|
4236
|
+
return {
|
|
4237
|
+
maxHeight: window.innerHeight - wrapperRef.current.getBoundingClientRect().top - 100 + "px"
|
|
4238
|
+
};
|
|
4239
|
+
}
|
|
4240
|
+
|
|
4241
|
+
return {
|
|
4242
|
+
maxHeight: 'auto'
|
|
4243
|
+
};
|
|
4244
|
+
};
|
|
4245
|
+
|
|
4246
|
+
var delayedQuery = useCallback(debounce$1(function (value) {
|
|
4247
|
+
return handleSearch(0, false, value);
|
|
4248
|
+
}, 500), []);
|
|
4249
|
+
|
|
4250
|
+
var handleSearch = function handleSearch(page, concat, value) {
|
|
4251
|
+
if (page === void 0) {
|
|
4252
|
+
page = 0;
|
|
4253
|
+
}
|
|
4254
|
+
|
|
4255
|
+
if (concat === void 0) {
|
|
4256
|
+
concat = false;
|
|
4257
|
+
}
|
|
4258
|
+
|
|
4259
|
+
if (value === void 0) {
|
|
4260
|
+
value = '';
|
|
4261
|
+
}
|
|
4262
|
+
|
|
4263
|
+
try {
|
|
4264
|
+
setOptions({
|
|
4265
|
+
loading: true
|
|
4266
|
+
});
|
|
4267
|
+
var searchTermQs = [];
|
|
4268
|
+
var searchTermParsed = [];
|
|
4269
|
+
|
|
4270
|
+
if (value !== '') {
|
|
4271
|
+
searchTermParsed = parser(queryCondition + "=" + value);
|
|
4272
|
+
}
|
|
4273
|
+
|
|
4274
|
+
var _get = traversal.registry.get;
|
|
4275
|
+
|
|
4276
|
+
var fnName = _get('searchEngineQueryParamsFunction', SearchEngine);
|
|
4277
|
+
|
|
4278
|
+
var qsParsed = traversal.client[fnName]({
|
|
4279
|
+
path: traversal.path,
|
|
4280
|
+
start: page * PageSize,
|
|
4281
|
+
pageSize: PageSize,
|
|
4282
|
+
withDepth: false
|
|
4283
|
+
});
|
|
4284
|
+
var sortParsed = parser("_sort_des=title");
|
|
4285
|
+
var typeNameParsed = [];
|
|
4286
|
+
|
|
4287
|
+
if (typeNameQuery) {
|
|
4288
|
+
typeNameParsed = parser("type_name__in=" + typeNameQuery);
|
|
4289
|
+
}
|
|
4290
|
+
|
|
4291
|
+
if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
4292
|
+
searchTermQs = buildQs([].concat(qs, searchTermParsed, qsParsed, typeNameParsed, sortParsed));
|
|
4293
|
+
}
|
|
4294
|
+
|
|
4295
|
+
return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false)).then(function (data) {
|
|
4296
|
+
var _data$items_total;
|
|
4297
|
+
|
|
4298
|
+
var newItems = options.items && concat ? [].concat(options.items, data.items) : data.items;
|
|
4299
|
+
setOptions({
|
|
4300
|
+
items: newItems != null ? newItems : [],
|
|
4301
|
+
loading: false,
|
|
4302
|
+
items_total: (_data$items_total = data.items_total) != null ? _data$items_total : 0,
|
|
4303
|
+
page: page
|
|
4304
|
+
});
|
|
4305
|
+
});
|
|
4306
|
+
} catch (e) {
|
|
4307
|
+
return Promise.reject(e);
|
|
4308
|
+
}
|
|
4309
|
+
};
|
|
4310
|
+
|
|
4311
|
+
var inicializeLabels = function inicializeLabels() {
|
|
4312
|
+
try {
|
|
4313
|
+
var _temp2 = function () {
|
|
4314
|
+
if (labelProperty !== 'id' && value.length > 0) {
|
|
4315
|
+
setIsLoadingData(true);
|
|
4316
|
+
var searchTermQs = [];
|
|
4317
|
+
var searchTermParsed = ['__or', "id=" + value.join('%26id=')];
|
|
4318
|
+
var getSearch = traversal.registry.get;
|
|
4319
|
+
var fnName = getSearch('searchEngineQueryParamsFunction', SearchEngine);
|
|
4320
|
+
var qsParsed = traversal.client[fnName]({
|
|
4321
|
+
path: traversal.path,
|
|
4322
|
+
start: 0,
|
|
4323
|
+
pageSize: 100,
|
|
4324
|
+
withDepth: false
|
|
4325
|
+
});
|
|
4326
|
+
var typeNameParsed = [];
|
|
4327
|
+
|
|
4328
|
+
if (typeNameQuery) {
|
|
4329
|
+
typeNameParsed = parser("type_name__in=" + typeNameQuery);
|
|
4330
|
+
}
|
|
4331
|
+
|
|
4332
|
+
if (qs.length > 0 || searchTermParsed.length > 0 || qsParsed.length > 0 || typeNameParsed.length > 0) {
|
|
4333
|
+
searchTermQs = buildQs([].concat(qs, [searchTermParsed], qsParsed, typeNameParsed));
|
|
4334
|
+
}
|
|
4335
|
+
|
|
4336
|
+
return Promise.resolve(traversal.client.search(path ? path : traversal.client.getContainerFromPath(traversal.path), searchTermQs, false, false, 0, 100)).then(function (data) {
|
|
4337
|
+
var newValuesLabel = data.items.reduce(function (result, item) {
|
|
4338
|
+
result[item.id] = get$1(item, labelProperty, item.id);
|
|
4339
|
+
return result;
|
|
4340
|
+
}, {});
|
|
4341
|
+
setValuesLabels(newValuesLabel);
|
|
4342
|
+
setIsLoadingData(false);
|
|
4343
|
+
});
|
|
4344
|
+
}
|
|
4345
|
+
}();
|
|
4346
|
+
|
|
4347
|
+
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
|
|
4348
|
+
} catch (e) {
|
|
4349
|
+
return Promise.reject(e);
|
|
4350
|
+
}
|
|
4351
|
+
};
|
|
4352
|
+
|
|
4353
|
+
var renderTextItemOptionFn = function renderTextItemOptionFn(item) {
|
|
4354
|
+
if (renderTextItemOption) {
|
|
4355
|
+
return renderTextItemOption(item);
|
|
4356
|
+
}
|
|
4357
|
+
|
|
4358
|
+
return item.title || item['@name'];
|
|
4359
|
+
};
|
|
4360
|
+
|
|
4361
|
+
React.useEffect(function () {
|
|
4362
|
+
if (!options.loading && !options.items && value.length > 0) {
|
|
4363
|
+
inicializeLabels();
|
|
4364
|
+
} else if (value.length === 0) {
|
|
4365
|
+
setValuesLabels({});
|
|
4366
|
+
}
|
|
4367
|
+
}, [path, options.loading, options.items]);
|
|
4368
|
+
|
|
4369
|
+
if (isLoadingData || valuesLabel === undefined) {
|
|
4370
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
4371
|
+
className: "spinner"
|
|
4372
|
+
});
|
|
4373
|
+
}
|
|
4374
|
+
|
|
4375
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
4376
|
+
className: "tags mb-2"
|
|
4377
|
+
}, value.map(function (tag, index) {
|
|
4378
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
4379
|
+
key: "input_list_" + tag + "_" + index,
|
|
4380
|
+
className: "tag is-info is-medium"
|
|
4381
|
+
}, get$1(valuesLabel, tag, tag), /*#__PURE__*/React.createElement("button", {
|
|
4382
|
+
className: "delete is-small",
|
|
4383
|
+
onClick: function onClick(ev) {
|
|
4384
|
+
ev.stopPropagation();
|
|
4385
|
+
ev.preventDefault();
|
|
4386
|
+
onChange([].concat(value.filter(function (tag) {
|
|
4387
|
+
return value.indexOf(tag) !== index;
|
|
4388
|
+
})));
|
|
4389
|
+
}
|
|
4390
|
+
}));
|
|
4391
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
4392
|
+
"data-test": dataTestWrapper,
|
|
4393
|
+
ref: wrapperRef,
|
|
4394
|
+
className: "dropdown mb-2 " + (isOpen ? 'is-active' : ''),
|
|
4395
|
+
onBlur: function onBlur(ev) {
|
|
4396
|
+
if (!ev.currentTarget.contains(ev.relatedTarget)) {
|
|
4397
|
+
if (searchTerm !== '') {
|
|
4398
|
+
setSearchTerm('');
|
|
4399
|
+
setOptions(initialState$1);
|
|
4400
|
+
}
|
|
4401
|
+
|
|
4402
|
+
setIsOpen(false);
|
|
4403
|
+
}
|
|
4404
|
+
}
|
|
4405
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4406
|
+
className: "dropdown-trigger"
|
|
4407
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
4408
|
+
className: "button " + btnClass,
|
|
4409
|
+
onClick: function onClick(ev) {
|
|
4410
|
+
ev.preventDefault();
|
|
4411
|
+
setIsOpen(!isOpen);
|
|
4412
|
+
|
|
4413
|
+
if (!options.loading && !options.items) {
|
|
4414
|
+
handleSearch(options.page);
|
|
4415
|
+
}
|
|
4416
|
+
},
|
|
4417
|
+
"aria-haspopup": "true",
|
|
4418
|
+
"aria-controls": "dropdown-menu"
|
|
4419
|
+
}, /*#__PURE__*/React.createElement("span", null, intl.formatMessage(genericMessages.choose)), /*#__PURE__*/React.createElement("span", {
|
|
4420
|
+
className: "icon"
|
|
4421
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
4422
|
+
className: "fas fa-angle-down",
|
|
4423
|
+
"aria-hidden": "true"
|
|
4424
|
+
})))), /*#__PURE__*/React.createElement("div", {
|
|
4425
|
+
className: "dropdown-menu",
|
|
4426
|
+
id: "dropdown-menu",
|
|
4427
|
+
role: "menu",
|
|
4428
|
+
style: getHeight()
|
|
4429
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4430
|
+
className: "dropdown-content"
|
|
4431
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
4432
|
+
className: "dropdown-item"
|
|
4433
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
4434
|
+
ref: inputRef,
|
|
4435
|
+
"data-test": dataTestSearchInput,
|
|
4436
|
+
className: "input",
|
|
4437
|
+
type: "text",
|
|
4438
|
+
placeholder: intl.formatMessage(genericMessages.search),
|
|
4439
|
+
value: searchTerm,
|
|
4440
|
+
onChange: function onChange(ev) {
|
|
4441
|
+
delayedQuery(ev.target.value);
|
|
4442
|
+
setSearchTerm(ev.target.value);
|
|
4443
|
+
}
|
|
4444
|
+
})), /*#__PURE__*/React.createElement("hr", {
|
|
4445
|
+
className: "dropdown-divider"
|
|
4446
|
+
}), options.loading && /*#__PURE__*/React.createElement(Loading, null), options.items && options.items.map(function (item) {
|
|
4447
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
4448
|
+
className: "dropdown-item editable " + (value && value.id === item.id ? 'is-active' : ''),
|
|
4449
|
+
"data-test": dataTestItem + "-" + item.id,
|
|
4450
|
+
onMouseDown: function onMouseDown(ev) {
|
|
4451
|
+
ev.stopPropagation();
|
|
4452
|
+
ev.preventDefault();
|
|
4453
|
+
|
|
4454
|
+
if (onChange && !value.includes(item.id)) {
|
|
4455
|
+
var _extends2;
|
|
4456
|
+
|
|
4457
|
+
setValuesLabels(_extends({}, valuesLabel, (_extends2 = {}, _extends2[item.id] = get$1(item, labelProperty, item.id), _extends2)));
|
|
4458
|
+
onChange([].concat(value, [item.id]));
|
|
4459
|
+
}
|
|
4460
|
+
},
|
|
4461
|
+
key: item.path
|
|
4462
|
+
}, renderTextItemOptionFn(item));
|
|
4463
|
+
}), options.items && options.items.length === 0 && /*#__PURE__*/React.createElement("div", {
|
|
4464
|
+
className: "dropdown-item"
|
|
4465
|
+
}, intl.formatMessage(genericMessages.no_results)), options.items && options.items_total > options.items.length && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("hr", {
|
|
4466
|
+
className: "dropdown-divider"
|
|
4467
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
4468
|
+
className: "dropdown-item editable",
|
|
4469
|
+
onMouseDown: function onMouseDown(ev) {
|
|
4470
|
+
ev.stopPropagation();
|
|
4471
|
+
ev.preventDefault();
|
|
4472
|
+
handleSearch(options.page + 1, true);
|
|
4473
|
+
}
|
|
4474
|
+
}, intl.formatMessage(genericMessages.load_more)))))), error && /*#__PURE__*/React.createElement(ErrorZone, {
|
|
4475
|
+
className: errorZoneClassName,
|
|
4476
|
+
id: uid
|
|
4477
|
+
}, error ? error : ''));
|
|
4478
|
+
};
|
|
4479
|
+
SearchInputList.propTypes = (_SearchInputList$prop = {
|
|
4480
|
+
onChange: PropTypes.func,
|
|
4481
|
+
path: PropTypes.string,
|
|
4482
|
+
btnClass: PropTypes.string,
|
|
4483
|
+
dataTestWrapper: PropTypes.string,
|
|
4484
|
+
dataTestSearchInput: PropTypes.string,
|
|
4485
|
+
dataTestItem: PropTypes.string,
|
|
4486
|
+
renderTextItemOption: PropTypes.func,
|
|
4487
|
+
typeNameQuery: PropTypes.string,
|
|
4488
|
+
labelProperty: PropTypes.string,
|
|
4489
|
+
error: PropTypes.string,
|
|
4490
|
+
errorZoneClassName: PropTypes.string,
|
|
4491
|
+
traversal: PropTypes.object
|
|
4492
|
+
}, _SearchInputList$prop["path"] = PropTypes.string, _SearchInputList$prop.qs = PropTypes.array, _SearchInputList$prop.queryCondition = PropTypes.string, _SearchInputList$prop);
|
|
4493
|
+
|
|
3970
4494
|
var EditComponent = React.forwardRef(function (_ref, ref) {
|
|
3971
4495
|
var schema = _ref.schema,
|
|
3972
4496
|
val = _ref.val,
|
|
@@ -3975,7 +4499,41 @@ var EditComponent = React.forwardRef(function (_ref, ref) {
|
|
|
3975
4499
|
className = _ref.className,
|
|
3976
4500
|
rest = _objectWithoutPropertiesLoose(_ref, ["schema", "val", "setValue", "dataTest", "className"]);
|
|
3977
4501
|
|
|
3978
|
-
|
|
4502
|
+
var traversal = useTraversal();
|
|
4503
|
+
|
|
4504
|
+
if ((schema == null ? void 0 : schema.widget) === 'search_list') {
|
|
4505
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, rest.placeholder && /*#__PURE__*/React.createElement("label", {
|
|
4506
|
+
className: "label"
|
|
4507
|
+
}, rest.placeholder), /*#__PURE__*/React.createElement(SearchInputList, _extends({
|
|
4508
|
+
value: val || [],
|
|
4509
|
+
traversal: traversal,
|
|
4510
|
+
className: className,
|
|
4511
|
+
onChange: function onChange(ev) {
|
|
4512
|
+
return setValue(ev);
|
|
4513
|
+
},
|
|
4514
|
+
queryCondition: schema != null && schema.queryCondition ? schema.queryCondition : 'title__in',
|
|
4515
|
+
dataTest: dataTest,
|
|
4516
|
+
path: schema.queryPath,
|
|
4517
|
+
labelProperty: schema != null && schema.labelProperty ? schema.labelProperty : 'title',
|
|
4518
|
+
typeNameQuery: schema != null && schema.typeNameQuery ? schema.typeNameQuery : null
|
|
4519
|
+
}, rest)));
|
|
4520
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'search') {
|
|
4521
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, rest.placeholder && /*#__PURE__*/React.createElement("label", {
|
|
4522
|
+
className: "label"
|
|
4523
|
+
}, rest.placeholder), /*#__PURE__*/React.createElement(SearchInput, _extends({
|
|
4524
|
+
value: val,
|
|
4525
|
+
traversal: traversal,
|
|
4526
|
+
className: className,
|
|
4527
|
+
onChange: function onChange(ev) {
|
|
4528
|
+
return setValue(ev);
|
|
4529
|
+
},
|
|
4530
|
+
queryCondition: schema != null && schema.queryCondition ? schema.queryCondition : 'title__in',
|
|
4531
|
+
dataTest: dataTest,
|
|
4532
|
+
path: schema.queryPath,
|
|
4533
|
+
labelProperty: schema != null && schema.labelProperty ? schema.labelProperty : 'title',
|
|
4534
|
+
typeNameQuery: schema != null && schema.typeNameQuery ? schema.typeNameQuery : null
|
|
4535
|
+
}, rest)));
|
|
4536
|
+
} else if ((schema == null ? void 0 : schema.widget) === 'textarea' || (schema == null ? void 0 : schema.widget) === 'richtext') {
|
|
3979
4537
|
return /*#__PURE__*/React.createElement(Textarea, _extends({
|
|
3980
4538
|
value: val || '',
|
|
3981
4539
|
className: className,
|
|
@@ -4106,15 +4664,19 @@ EditComponent.displayName = 'EditComponent';
|
|
|
4106
4664
|
function IAttachment(_ref) {
|
|
4107
4665
|
var properties = _ref.properties,
|
|
4108
4666
|
values = _ref.values;
|
|
4667
|
+
var intl = useIntl();
|
|
4109
4668
|
var Ctx = useTraversal();
|
|
4110
4669
|
var modifyContent = Ctx.hasPerm('guillotina.ModifyContent');
|
|
4111
4670
|
return /*#__PURE__*/React.createElement(Table, {
|
|
4112
|
-
headers: [
|
|
4671
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
4113
4672
|
className: "is-striped is-fullwidth is-size-7"
|
|
4114
4673
|
}, Object.keys(properties).map(function (key) {
|
|
4115
4674
|
return /*#__PURE__*/React.createElement("tr", {
|
|
4116
4675
|
key: 'attachment_' + key
|
|
4117
4676
|
}, /*#__PURE__*/React.createElement("td", {
|
|
4677
|
+
style: {
|
|
4678
|
+
width: '150px'
|
|
4679
|
+
},
|
|
4118
4680
|
key: 1
|
|
4119
4681
|
}, key), /*#__PURE__*/React.createElement("td", {
|
|
4120
4682
|
key: 2
|
|
@@ -4210,7 +4772,7 @@ function IMultiAttachment(_ref) {
|
|
|
4210
4772
|
};
|
|
4211
4773
|
|
|
4212
4774
|
return /*#__PURE__*/React.createElement(Table, {
|
|
4213
|
-
headers: [
|
|
4775
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
4214
4776
|
className: "is-striped is-fullwidth is-size-7"
|
|
4215
4777
|
}, fileKeyToDelete && /*#__PURE__*/React.createElement(Confirm, {
|
|
4216
4778
|
loading: loading,
|
|
@@ -4227,7 +4789,10 @@ function IMultiAttachment(_ref) {
|
|
|
4227
4789
|
return /*#__PURE__*/React.createElement("tr", {
|
|
4228
4790
|
key: 'multiattachment_' + key
|
|
4229
4791
|
}, /*#__PURE__*/React.createElement("td", {
|
|
4230
|
-
key: 1
|
|
4792
|
+
key: 1,
|
|
4793
|
+
style: {
|
|
4794
|
+
width: '150px'
|
|
4795
|
+
}
|
|
4231
4796
|
}, key), /*#__PURE__*/React.createElement("td", {
|
|
4232
4797
|
key: 2
|
|
4233
4798
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -4515,7 +5080,7 @@ function IImageAttachment(_ref) {
|
|
|
4515
5080
|
};
|
|
4516
5081
|
|
|
4517
5082
|
return /*#__PURE__*/React.createElement(Table, {
|
|
4518
|
-
headers: [
|
|
5083
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
4519
5084
|
className: "is-striped is-fullwidth is-size-7"
|
|
4520
5085
|
}, showConfirmToDelete && /*#__PURE__*/React.createElement(Confirm, {
|
|
4521
5086
|
loading: loading,
|
|
@@ -4527,7 +5092,10 @@ function IImageAttachment(_ref) {
|
|
|
4527
5092
|
},
|
|
4528
5093
|
message: intl.formatMessage(genericFileMessages.confirm_message_delete_image)
|
|
4529
5094
|
}), values['image'] && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
4530
|
-
key: 1
|
|
5095
|
+
key: 1,
|
|
5096
|
+
style: {
|
|
5097
|
+
width: '150px'
|
|
5098
|
+
}
|
|
4531
5099
|
}, intl.formatMessage(genericMessages.image)), /*#__PURE__*/React.createElement("td", {
|
|
4532
5100
|
key: 2
|
|
4533
5101
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -4817,7 +5385,7 @@ function IMultiImageAttachment(_ref) {
|
|
|
4817
5385
|
};
|
|
4818
5386
|
|
|
4819
5387
|
return /*#__PURE__*/React.createElement(Table, {
|
|
4820
|
-
headers: [
|
|
5388
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
4821
5389
|
className: "is-striped is-fullwidth is-size-7"
|
|
4822
5390
|
}, fileKeyToDelete && /*#__PURE__*/React.createElement(Confirm, {
|
|
4823
5391
|
loading: loading,
|
|
@@ -4834,7 +5402,10 @@ function IMultiImageAttachment(_ref) {
|
|
|
4834
5402
|
return /*#__PURE__*/React.createElement("tr", {
|
|
4835
5403
|
key: "multiimageattachment_" + key
|
|
4836
5404
|
}, /*#__PURE__*/React.createElement("td", {
|
|
4837
|
-
key: 1
|
|
5405
|
+
key: 1,
|
|
5406
|
+
style: {
|
|
5407
|
+
width: '150px'
|
|
5408
|
+
}
|
|
4838
5409
|
}, key), /*#__PURE__*/React.createElement("td", {
|
|
4839
5410
|
key: 2
|
|
4840
5411
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -6315,7 +6886,7 @@ function SearchVocabularyLabels(props) {
|
|
|
6315
6886
|
return null;
|
|
6316
6887
|
}
|
|
6317
6888
|
|
|
6318
|
-
var initialState$
|
|
6889
|
+
var initialState$2 = {
|
|
6319
6890
|
page: 0,
|
|
6320
6891
|
items: [],
|
|
6321
6892
|
loading: true,
|
|
@@ -6334,7 +6905,7 @@ function PanelItems() {
|
|
|
6334
6905
|
var intl = useIntl();
|
|
6335
6906
|
var Ctx = useTraversal();
|
|
6336
6907
|
|
|
6337
|
-
var _useSetState = useSetState(initialState$
|
|
6908
|
+
var _useSetState = useSetState(initialState$2),
|
|
6338
6909
|
state = _useSetState[0],
|
|
6339
6910
|
setState = _useSetState[1];
|
|
6340
6911
|
|
|
@@ -6784,7 +7355,7 @@ function PanelProperties() {
|
|
|
6784
7355
|
icon: model.icon,
|
|
6785
7356
|
align: "is-left",
|
|
6786
7357
|
className: "has-text-grey"
|
|
6787
|
-
}),
|
|
7358
|
+
}), "\xA0", /*#__PURE__*/React.createElement("span", null, Ctx.context.title || Ctx.context['@name']))), /*#__PURE__*/React.createElement("div", {
|
|
6788
7359
|
className: "level-right"
|
|
6789
7360
|
}, /*#__PURE__*/React.createElement(PropertiesButtonView, null))), /*#__PURE__*/React.createElement("hr", null), schema && schema.data && !schema.loading && /*#__PURE__*/React.createElement("div", {
|
|
6790
7361
|
className: "columns"
|
|
@@ -6793,13 +7364,20 @@ function PanelProperties() {
|
|
|
6793
7364
|
}, /*#__PURE__*/React.createElement("table", {
|
|
6794
7365
|
className: "table is-striped is-fullwidth is-size-7"
|
|
6795
7366
|
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
7367
|
+
style: {
|
|
7368
|
+
width: '150px'
|
|
7369
|
+
},
|
|
6796
7370
|
className: "is-2"
|
|
6797
7371
|
}, intl.formatMessage(genericMessages.property)), /*#__PURE__*/React.createElement("th", {
|
|
6798
7372
|
className: "is-8"
|
|
6799
7373
|
}, intl.formatMessage(genericMessages.value)))), /*#__PURE__*/React.createElement("tbody", null, showProperties.map(function (prop) {
|
|
6800
7374
|
return /*#__PURE__*/React.createElement("tr", {
|
|
6801
7375
|
key: 'prop' + prop
|
|
6802
|
-
}, /*#__PURE__*/React.createElement("td",
|
|
7376
|
+
}, /*#__PURE__*/React.createElement("td", {
|
|
7377
|
+
style: {
|
|
7378
|
+
width: '150px'
|
|
7379
|
+
}
|
|
7380
|
+
}, prop), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(EditableField, {
|
|
6803
7381
|
field: prop,
|
|
6804
7382
|
value: Ctx.context[prop],
|
|
6805
7383
|
modifyContent: false
|
|
@@ -6807,6 +7385,9 @@ function PanelProperties() {
|
|
|
6807
7385
|
}))), properties.length > 0 && /*#__PURE__*/React.createElement("table", {
|
|
6808
7386
|
className: "table is-striped is-fullwidth is-size-7"
|
|
6809
7387
|
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
7388
|
+
style: {
|
|
7389
|
+
width: '150px'
|
|
7390
|
+
},
|
|
6810
7391
|
className: "is-2"
|
|
6811
7392
|
}, intl.formatMessage(genericMessages.property)), /*#__PURE__*/React.createElement("th", {
|
|
6812
7393
|
className: "is-8"
|
|
@@ -6815,7 +7396,11 @@ function PanelProperties() {
|
|
|
6815
7396
|
value = _ref.value;
|
|
6816
7397
|
return /*#__PURE__*/React.createElement("tr", {
|
|
6817
7398
|
key: 'prop' + key
|
|
6818
|
-
}, /*#__PURE__*/React.createElement("td",
|
|
7399
|
+
}, /*#__PURE__*/React.createElement("td", {
|
|
7400
|
+
style: {
|
|
7401
|
+
width: '150px'
|
|
7402
|
+
}
|
|
7403
|
+
}, value.title || key), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(EditableField, {
|
|
6819
7404
|
field: key,
|
|
6820
7405
|
value: Ctx.context[key],
|
|
6821
7406
|
schema: value,
|
|
@@ -7546,13 +8131,13 @@ function TagsWidget(_ref) {
|
|
|
7546
8131
|
|
|
7547
8132
|
/* eslint jsx-a11y/anchor-is-valid: "off" */
|
|
7548
8133
|
|
|
7549
|
-
var initialState$
|
|
8134
|
+
var initialState$3 = {
|
|
7550
8135
|
types: undefined
|
|
7551
8136
|
};
|
|
7552
8137
|
function CreateButton() {
|
|
7553
8138
|
var intl = useIntl();
|
|
7554
8139
|
|
|
7555
|
-
var _useSetState = useSetState(initialState$
|
|
8140
|
+
var _useSetState = useSetState(initialState$3),
|
|
7556
8141
|
state = _useSetState[0],
|
|
7557
8142
|
setState = _useSetState[1];
|
|
7558
8143
|
|
|
@@ -7638,7 +8223,7 @@ function ContextToolbar(_ref) {
|
|
|
7638
8223
|
|
|
7639
8224
|
var intl = useIntl();
|
|
7640
8225
|
|
|
7641
|
-
var _useSetState2 = useSetState(initialState$
|
|
8226
|
+
var _useSetState2 = useSetState(initialState$3),
|
|
7642
8227
|
state = _useSetState2[0],
|
|
7643
8228
|
setState = _useSetState2[1];
|
|
7644
8229
|
|
|
@@ -8833,15 +9418,19 @@ var editableFields = ['title', 'description', 'effective_date', 'expiration_date
|
|
|
8833
9418
|
function IDublinCore(_ref) {
|
|
8834
9419
|
var properties = _ref.properties,
|
|
8835
9420
|
values = _ref.values;
|
|
9421
|
+
var intl = useIntl();
|
|
8836
9422
|
var Ctx = useTraversal();
|
|
8837
9423
|
var modifyContent = Ctx.hasPerm('guillotina.ModifyContent');
|
|
8838
9424
|
return /*#__PURE__*/React.createElement(Table, {
|
|
8839
|
-
headers: [
|
|
9425
|
+
headers: [intl.formatMessage(genericMessages.property), intl.formatMessage(genericMessages.value)],
|
|
8840
9426
|
className: "is-striped is-fullwidth is-size-7"
|
|
8841
9427
|
}, Object.keys(properties).map(function (key) {
|
|
8842
9428
|
return /*#__PURE__*/React.createElement("tr", {
|
|
8843
9429
|
key: 'dublin_' + key
|
|
8844
9430
|
}, /*#__PURE__*/React.createElement("td", {
|
|
9431
|
+
style: {
|
|
9432
|
+
width: '150px'
|
|
9433
|
+
},
|
|
8845
9434
|
key: 1
|
|
8846
9435
|
}, key), /*#__PURE__*/React.createElement("td", {
|
|
8847
9436
|
key: 2
|
|
@@ -9052,13 +9641,13 @@ function GroupCtx() {
|
|
|
9052
9641
|
}
|
|
9053
9642
|
};
|
|
9054
9643
|
|
|
9055
|
-
var addUser = function addUser(
|
|
9644
|
+
var addUser = function addUser(newUserId) {
|
|
9056
9645
|
try {
|
|
9057
9646
|
var data = {};
|
|
9058
9647
|
Ctx.context.users.forEach(function (user) {
|
|
9059
9648
|
data[user] = true;
|
|
9060
9649
|
});
|
|
9061
|
-
data[
|
|
9650
|
+
data[newUserId] = true;
|
|
9062
9651
|
return Promise.resolve(Ctx.client.rest.patch(Ctx.containerPath + "@groups/" + Ctx.context['@name'], {
|
|
9063
9652
|
users: data
|
|
9064
9653
|
})).then(function (_ref3) {
|
|
@@ -9077,7 +9666,7 @@ function GroupCtx() {
|
|
|
9077
9666
|
"value": " added to group"
|
|
9078
9667
|
}]
|
|
9079
9668
|
}, {
|
|
9080
|
-
user:
|
|
9669
|
+
user: newUserId
|
|
9081
9670
|
}), errorMessage);
|
|
9082
9671
|
});
|
|
9083
9672
|
} catch (e) {
|
|
@@ -9548,7 +10137,7 @@ const registry = {
|
|
|
9548
10137
|
|
|
9549
10138
|
*/
|
|
9550
10139
|
|
|
9551
|
-
var initialState$
|
|
10140
|
+
var initialState$4 = {
|
|
9552
10141
|
path: '',
|
|
9553
10142
|
loading: false,
|
|
9554
10143
|
context: undefined,
|
|
@@ -12451,10 +13040,10 @@ function Guillotina(_ref) {
|
|
|
12451
13040
|
var searchPath = location.get('path') || '/';
|
|
12452
13041
|
|
|
12453
13042
|
if (searchPath && searchPath !== '') {
|
|
12454
|
-
initialState$
|
|
13043
|
+
initialState$4.path = searchPath;
|
|
12455
13044
|
}
|
|
12456
13045
|
|
|
12457
|
-
var _useReducer = useReducer(guillotinaReducer, initialState$
|
|
13046
|
+
var _useReducer = useReducer(guillotinaReducer, initialState$4),
|
|
12458
13047
|
state = _useReducer[0],
|
|
12459
13048
|
dispatch = _useReducer[1];
|
|
12460
13049
|
|
|
@@ -12606,7 +13195,7 @@ var ERRORS = {
|
|
|
12606
13195
|
failed_to_fetch: 'Failed to fetch data: Backend not running?',
|
|
12607
13196
|
invalid_credentials: 'Failed! Invalid credentials'
|
|
12608
13197
|
};
|
|
12609
|
-
var initialState$
|
|
13198
|
+
var initialState$5 = {
|
|
12610
13199
|
username: '',
|
|
12611
13200
|
password: '',
|
|
12612
13201
|
loading: undefined,
|
|
@@ -12619,7 +13208,7 @@ var Login = function Login(_ref) {
|
|
|
12619
13208
|
auth = _ref.auth,
|
|
12620
13209
|
onLogin = _ref.onLogin;
|
|
12621
13210
|
|
|
12622
|
-
var _useSetState = useSetState(initialState$
|
|
13211
|
+
var _useSetState = useSetState(initialState$5),
|
|
12623
13212
|
state = _useSetState[0],
|
|
12624
13213
|
setState = _useSetState[1];
|
|
12625
13214
|
|
|
@@ -13100,5 +13689,5 @@ var Auth = /*#__PURE__*/function () {
|
|
|
13100
13689
|
return Auth;
|
|
13101
13690
|
}();
|
|
13102
13691
|
|
|
13103
|
-
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, SearchLabels, SearchOptionsLabels, SearchVocabularyLabels, Select, Sharing, Table, TabsPanel, Tag, TagsWidget, TdLink, Textarea, TraversalContext, TraversalProvider, UserCtx, UserForm, UsersCtx, UsersToolbar, VocabularyRenderField, base64ToArrayBuffer, buildQs, classnames, defaultComponent, formatDate, generateUID, 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 };
|
|
13692
|
+
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, SearchLabels, SearchOptionsLabels, SearchRenderField, SearchVocabularyLabels, Select, Sharing, Table, TabsPanel, Tag, TagsWidget, TdLink, Textarea, 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 };
|
|
13104
13693
|
//# sourceMappingURL=react-gmi.esm.js.map
|