@guillotinaweb/react-gmi 0.29.1 → 0.29.2-alpha.2
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/dist/components/index.d.ts +0 -2
- package/dist/components/input/email.d.ts +1 -1
- package/dist/components/selected_items_actions.d.ts +14 -0
- package/dist/index.d.ts +2 -0
- package/dist/react-gmi.esm.js +295 -190
- package/dist/react-gmi.esm.js.map +1 -1
- package/dist/react-gmi.js +295 -190
- package/dist/react-gmi.js.map +1 -1
- package/dist/react-gmi.modern.js +258 -152
- package/dist/react-gmi.modern.js.map +1 -1
- package/dist/react-gmi.umd.js +295 -190
- package/dist/react-gmi.umd.js.map +1 -1
- package/package.json +2 -2
- package/dist/lib/search.test.d.ts +0 -1
- package/dist/locales/generic_messages.d.ts +0 -370
- package/dist/setupTests.d.ts +0 -1
package/dist/react-gmi.esm.js
CHANGED
|
@@ -142,6 +142,7 @@ var Traversal = /*#__PURE__*/function () {
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
_proto.apply = function apply(data) {
|
|
145
|
+
// apply a optimistic update to context
|
|
145
146
|
this.dispatch({
|
|
146
147
|
type: 'APPLY',
|
|
147
148
|
payload: data
|
|
@@ -764,8 +765,10 @@ function base64ToArrayBuffer(base64) {
|
|
|
764
765
|
return bytes;
|
|
765
766
|
}
|
|
766
767
|
function stringToSlug(str) {
|
|
767
|
-
str = str.replace(/^\s+|\s+$/g, '');
|
|
768
|
-
|
|
768
|
+
str = str.replace(/^\s+|\s+$/g, ''); // trim
|
|
769
|
+
|
|
770
|
+
str = str.toLowerCase(); // remove accents, swap ñ for n, etc
|
|
771
|
+
|
|
769
772
|
var from = 'àáäâèéëêìíïîòóöôùúüûñç·/_,:;';
|
|
770
773
|
var to = 'aaaaeeeeiiiioooouuuunc------';
|
|
771
774
|
|
|
@@ -773,7 +776,10 @@ function stringToSlug(str) {
|
|
|
773
776
|
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
|
|
774
777
|
}
|
|
775
778
|
|
|
776
|
-
str = str.replace(/[^a-z0-9 -]/g, '')
|
|
779
|
+
str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
|
|
780
|
+
.replace(/\s+/g, '-') // collapse whitespace and replace by -
|
|
781
|
+
.replace(/-+/g, '-'); // collapse dashes
|
|
782
|
+
|
|
777
783
|
return str;
|
|
778
784
|
}
|
|
779
785
|
function sleep(ms) {
|
|
@@ -917,7 +923,8 @@ function Confirm(_ref) {
|
|
|
917
923
|
})]
|
|
918
924
|
})]
|
|
919
925
|
});
|
|
920
|
-
}
|
|
926
|
+
} // @todo Improve it... Replacing the inputText to a tree
|
|
927
|
+
|
|
921
928
|
function PathTree(_ref2) {
|
|
922
929
|
var title = _ref2.title,
|
|
923
930
|
defaultPath = _ref2.defaultPath,
|
|
@@ -1288,6 +1295,7 @@ var Config = {
|
|
|
1288
1295
|
DelayActions: 200,
|
|
1289
1296
|
Permissions: Permissions,
|
|
1290
1297
|
SearchEngine: 'PostreSQL',
|
|
1298
|
+
// Elasticsearch
|
|
1291
1299
|
fieldHaveDeleteButton: function fieldHaveDeleteButton(schema) {
|
|
1292
1300
|
return (schema == null ? void 0 : schema.widget) === 'file' || (schema == null ? void 0 : schema.widget) === 'select' || (schema == null ? void 0 : schema.type) === 'array';
|
|
1293
1301
|
}
|
|
@@ -1344,7 +1352,9 @@ function RemoveItems(props) {
|
|
|
1344
1352
|
} catch (e) {
|
|
1345
1353
|
return Promise.reject(e);
|
|
1346
1354
|
}
|
|
1347
|
-
});
|
|
1355
|
+
}); // this sleep is here, to let elasticsearch, wait for
|
|
1356
|
+
// index our operations... (will work 99% of use cases)
|
|
1357
|
+
|
|
1348
1358
|
actions.push(sleep(cfg.DelayActions));
|
|
1349
1359
|
return Promise.resolve(Promise.all(actions)).then(function () {
|
|
1350
1360
|
if (errors.length === 0) {
|
|
@@ -1514,6 +1524,9 @@ var useInput = function useInput(onChange, value, validator) {
|
|
|
1514
1524
|
};
|
|
1515
1525
|
};
|
|
1516
1526
|
|
|
1527
|
+
// From github.com/protonmail/proton-shared
|
|
1528
|
+
|
|
1529
|
+
/* eslint-disable no-useless-escape */
|
|
1517
1530
|
var REGEX_EMAIL = /(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/i;
|
|
1518
1531
|
var REGEX_URL = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/;
|
|
1519
1532
|
var REGEX_HEX_COLOR = /^#([a-f0-9]{3,4}|[a-f0-9]{4}(?:[a-f0-9]{2}){1,2})\b$/i;
|
|
@@ -1629,7 +1642,8 @@ var Input = forwardRef(function (_ref, ref) {
|
|
|
1629
1642
|
|
|
1630
1643
|
var _useState2 = useState(false),
|
|
1631
1644
|
mounted = _useState2[0],
|
|
1632
|
-
setMounted = _useState2[1];
|
|
1645
|
+
setMounted = _useState2[1]; // eslint-disable-next-line
|
|
1646
|
+
|
|
1633
1647
|
|
|
1634
1648
|
ref = ref || useRef();
|
|
1635
1649
|
useEffect(function () {
|
|
@@ -1697,7 +1711,8 @@ var EmailInput = function EmailInput(_ref) {
|
|
|
1697
1711
|
value = _ref$value === void 0 ? '' : _ref$value,
|
|
1698
1712
|
dataTest = _ref.dataTest,
|
|
1699
1713
|
placeholder = _ref.placeholder,
|
|
1700
|
-
id = _ref.id
|
|
1714
|
+
id = _ref.id,
|
|
1715
|
+
onChange = _ref.onChange;
|
|
1701
1716
|
var intl = useIntl();
|
|
1702
1717
|
return jsx(Input, {
|
|
1703
1718
|
type: "email",
|
|
@@ -1715,7 +1730,8 @@ var EmailInput = function EmailInput(_ref) {
|
|
|
1715
1730
|
icon: "fas fa-envelope"
|
|
1716
1731
|
}),
|
|
1717
1732
|
id: id,
|
|
1718
|
-
placeholder: placeholder
|
|
1733
|
+
placeholder: placeholder,
|
|
1734
|
+
onChange: onChange
|
|
1719
1735
|
});
|
|
1720
1736
|
};
|
|
1721
1737
|
|
|
@@ -1792,14 +1808,15 @@ function FormBuilder(_ref) {
|
|
|
1792
1808
|
var ref = useRef();
|
|
1793
1809
|
var properties = schema.properties,
|
|
1794
1810
|
required = schema.required;
|
|
1795
|
-
var values = Object.assign({}, formData || {});
|
|
1811
|
+
var values = Object.assign({}, formData || {}); // build initial state
|
|
1812
|
+
|
|
1796
1813
|
var initialState = {};
|
|
1797
1814
|
var fields = Object.keys(properties).filter(function (x) {
|
|
1798
1815
|
return !exclude.includes(x);
|
|
1799
1816
|
});
|
|
1800
1817
|
fields.forEach(function (element) {
|
|
1801
1818
|
initialState[element] = values[element] || undefined;
|
|
1802
|
-
});
|
|
1819
|
+
}); // Register remotes
|
|
1803
1820
|
|
|
1804
1821
|
if (!ref.current) {
|
|
1805
1822
|
ref.current = {};
|
|
@@ -1807,6 +1824,7 @@ function FormBuilder(_ref) {
|
|
|
1807
1824
|
return ref.current[item] = remotes[item];
|
|
1808
1825
|
});
|
|
1809
1826
|
} else {
|
|
1827
|
+
// apply remote changes
|
|
1810
1828
|
Object.keys(remotes).forEach(function (key) {
|
|
1811
1829
|
if (JSON.stringify(ref.current[key]) !== JSON.stringify(remotes[key])) {
|
|
1812
1830
|
ref.current[key] = remotes[key];
|
|
@@ -1960,166 +1978,7 @@ var Select = forwardRef(function (_ref, ref) {
|
|
|
1960
1978
|
});
|
|
1961
1979
|
Select.displayName = 'Select';
|
|
1962
1980
|
|
|
1963
|
-
|
|
1964
|
-
var d = new Date(str);
|
|
1965
|
-
var minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
|
|
1966
|
-
return d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear() + " " + d.getHours() + ":" + minutes;
|
|
1967
|
-
};
|
|
1968
|
-
var get$1 = function get(obj, path, defValue) {
|
|
1969
|
-
var _pathArray$reduce;
|
|
1970
|
-
|
|
1971
|
-
if (!path) return undefined;
|
|
1972
|
-
var pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
|
|
1973
|
-
return (_pathArray$reduce = pathArray.reduce(function (prevObj, key) {
|
|
1974
|
-
return prevObj && prevObj[key];
|
|
1975
|
-
}, obj)) != null ? _pathArray$reduce : defValue;
|
|
1976
|
-
};
|
|
1977
|
-
function getNewId(id) {
|
|
1978
|
-
if (id === void 0) {
|
|
1979
|
-
id = '';
|
|
1980
|
-
}
|
|
1981
|
-
|
|
1982
|
-
var suffix = '-copy-';
|
|
1983
|
-
var rgx = new RegExp("($|" + suffix + "\\d*)");
|
|
1984
|
-
return stringToSlug(id).replace(rgx, function (r) {
|
|
1985
|
-
var num = parseInt(r.replace(suffix, '') || '0');
|
|
1986
|
-
return "" + suffix + (num + 1);
|
|
1987
|
-
});
|
|
1988
|
-
}
|
|
1989
|
-
|
|
1990
|
-
function _catch$1(body, recover) {
|
|
1991
|
-
try {
|
|
1992
|
-
var result = body();
|
|
1993
|
-
} catch (e) {
|
|
1994
|
-
return recover(e);
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
if (result && result.then) {
|
|
1998
|
-
return result.then(void 0, recover);
|
|
1999
|
-
}
|
|
2000
|
-
|
|
2001
|
-
return result;
|
|
2002
|
-
}
|
|
2003
|
-
|
|
2004
|
-
function useVocabulary(vocabularyName, path) {
|
|
2005
|
-
if (path === void 0) {
|
|
2006
|
-
path = null;
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
var traversal = useTraversal();
|
|
2010
|
-
|
|
2011
|
-
var _useSetState = useSetState({
|
|
2012
|
-
data: undefined,
|
|
2013
|
-
loading: false,
|
|
2014
|
-
error: undefined
|
|
2015
|
-
}),
|
|
2016
|
-
vocabulary = _useSetState[0],
|
|
2017
|
-
setVocabulary = _useSetState[1];
|
|
2018
|
-
|
|
2019
|
-
var getPath = function getPath() {
|
|
2020
|
-
if (path) return path;
|
|
2021
|
-
return traversal.path + "@vocabularies/" + vocabularyName;
|
|
2022
|
-
};
|
|
2023
|
-
|
|
2024
|
-
useEffect(function () {
|
|
2025
|
-
var getVocabulary = function getVocabulary() {
|
|
2026
|
-
try {
|
|
2027
|
-
var _temp3 = function () {
|
|
2028
|
-
if (vocabularyName && vocabulary.data === undefined && !vocabulary.loading) {
|
|
2029
|
-
var _temp4 = _catch$1(function () {
|
|
2030
|
-
setVocabulary({
|
|
2031
|
-
loading: true
|
|
2032
|
-
});
|
|
2033
|
-
return Promise.resolve(traversal.client.get(getPath())).then(function (data) {
|
|
2034
|
-
return Promise.resolve(data.json()).then(function (dataJson) {
|
|
2035
|
-
setVocabulary({
|
|
2036
|
-
loading: false,
|
|
2037
|
-
data: dataJson
|
|
2038
|
-
});
|
|
2039
|
-
});
|
|
2040
|
-
});
|
|
2041
|
-
}, function (err) {
|
|
2042
|
-
setVocabulary({
|
|
2043
|
-
loading: false,
|
|
2044
|
-
error: err,
|
|
2045
|
-
data: undefined
|
|
2046
|
-
});
|
|
2047
|
-
});
|
|
2048
|
-
|
|
2049
|
-
if (_temp4 && _temp4.then) return _temp4.then(function () {});
|
|
2050
|
-
}
|
|
2051
|
-
}();
|
|
2052
|
-
|
|
2053
|
-
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
|
|
2054
|
-
} catch (e) {
|
|
2055
|
-
return Promise.reject(e);
|
|
2056
|
-
}
|
|
2057
|
-
};
|
|
2058
|
-
|
|
2059
|
-
getVocabulary();
|
|
2060
|
-
}, [vocabularyName, vocabulary, path]);
|
|
2061
|
-
return vocabulary;
|
|
2062
|
-
}
|
|
2063
|
-
|
|
2064
|
-
var SelectVocabulary = forwardRef(function (_ref, ref) {
|
|
2065
|
-
var vocabularyName = _ref.vocabularyName,
|
|
2066
|
-
className = _ref.className,
|
|
2067
|
-
classWrap = _ref.classWrap,
|
|
2068
|
-
val = _ref.val,
|
|
2069
|
-
dataTest = _ref.dataTest,
|
|
2070
|
-
multiple = _ref.multiple,
|
|
2071
|
-
onChange = _ref.onChange,
|
|
2072
|
-
id = _ref.id,
|
|
2073
|
-
placeholder = _ref.placeholder;
|
|
2074
|
-
var vocabulary = useVocabulary(vocabularyName);
|
|
2075
|
-
|
|
2076
|
-
var getOptions = function getOptions() {
|
|
2077
|
-
if (get$1(vocabulary, 'data.items', null)) {
|
|
2078
|
-
var vocData = vocabulary.data.items.map(function (item) {
|
|
2079
|
-
return {
|
|
2080
|
-
text: item.title,
|
|
2081
|
-
value: item.token
|
|
2082
|
-
};
|
|
2083
|
-
});
|
|
2084
|
-
return vocData;
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
return [];
|
|
2088
|
-
};
|
|
2089
|
-
|
|
2090
|
-
var getProps = function getProps() {
|
|
2091
|
-
if (multiple) {
|
|
2092
|
-
var currentValue = val || [];
|
|
2093
|
-
return {
|
|
2094
|
-
multiple: true,
|
|
2095
|
-
size: 5,
|
|
2096
|
-
value: currentValue,
|
|
2097
|
-
options: getOptions()
|
|
2098
|
-
};
|
|
2099
|
-
}
|
|
2100
|
-
|
|
2101
|
-
return {
|
|
2102
|
-
value: val != null ? val : '',
|
|
2103
|
-
appendDefault: true,
|
|
2104
|
-
options: getOptions()
|
|
2105
|
-
};
|
|
2106
|
-
};
|
|
2107
|
-
|
|
2108
|
-
if (vocabulary.data === undefined || vocabulary.loading) {
|
|
2109
|
-
return jsx("div", {});
|
|
2110
|
-
}
|
|
2111
|
-
|
|
2112
|
-
return jsx(Select, _extends({}, getProps(), {
|
|
2113
|
-
className: className,
|
|
2114
|
-
classWrap: classWrap || 'is-fullwidth',
|
|
2115
|
-
dataTest: dataTest,
|
|
2116
|
-
ref: ref,
|
|
2117
|
-
onChange: onChange,
|
|
2118
|
-
id: id,
|
|
2119
|
-
placeholder: placeholder
|
|
2120
|
-
}));
|
|
2121
|
-
});
|
|
2122
|
-
SelectVocabulary.displayName = 'SelectVocabulary';
|
|
1981
|
+
// https://github.com/molefrog/wouter
|
|
2123
1982
|
|
|
2124
1983
|
var setURLParams = function setURLParams(p) {
|
|
2125
1984
|
return window.history.pushState(0, '0', '' + '?' + p.toString().replace(/%2F/g, '/'));
|
|
@@ -2140,7 +1999,10 @@ var useLocation = function useLocation() {
|
|
|
2140
1999
|
|
|
2141
2000
|
var prevPath = useRef(path);
|
|
2142
2001
|
useEffect(function () {
|
|
2143
|
-
patchHistoryEvents();
|
|
2002
|
+
patchHistoryEvents(); // this function checks if the location has been changed since the
|
|
2003
|
+
// last render and updates the state only when needed.
|
|
2004
|
+
// unfortunately, we can't rely on `path` value here, since it can be stale,
|
|
2005
|
+
// that's why we store the last pathname in a ref.
|
|
2144
2006
|
|
|
2145
2007
|
var checkForUpdates = function checkForUpdates() {
|
|
2146
2008
|
var pathname = currentSearchParams();
|
|
@@ -2150,14 +2012,22 @@ var useLocation = function useLocation() {
|
|
|
2150
2012
|
var events = ['popstate', 'pushState', 'replaceState'];
|
|
2151
2013
|
events.map(function (e) {
|
|
2152
2014
|
return window.addEventListener(e, checkForUpdates);
|
|
2153
|
-
});
|
|
2015
|
+
}); // it's possible that an update has occurred between render and the effect handler,
|
|
2016
|
+
// so we run additional check on mount to catch these updates. Based on:
|
|
2017
|
+
// https://gist.github.com/bvaughn/e25397f70e8c65b0ae0d7c90b731b189
|
|
2018
|
+
|
|
2154
2019
|
checkForUpdates();
|
|
2155
2020
|
return function () {
|
|
2156
2021
|
events.map(function (e) {
|
|
2157
2022
|
return window.removeEventListener(e, checkForUpdates);
|
|
2158
2023
|
});
|
|
2159
2024
|
};
|
|
2160
|
-
}, []);
|
|
2025
|
+
}, []); // the 2nd argument of the `useLocation` return value is a function
|
|
2026
|
+
// that allows to perform a navigation.
|
|
2027
|
+
//
|
|
2028
|
+
// the function reference should stay the same between re-renders, so that
|
|
2029
|
+
// it can be passed down as an element prop without any performance concerns.
|
|
2030
|
+
|
|
2161
2031
|
var navigate = useCallback(function (to, replace) {
|
|
2162
2032
|
if (replace) {
|
|
2163
2033
|
clean(to);
|
|
@@ -2176,7 +2046,12 @@ var useLocation = function useLocation() {
|
|
|
2176
2046
|
setURLParams(current);
|
|
2177
2047
|
}, [path]);
|
|
2178
2048
|
return [path, navigate, remove];
|
|
2179
|
-
};
|
|
2049
|
+
}; // While History API does have `popstate` event, the only
|
|
2050
|
+
// proper way to listen to changes via `push/replaceState`
|
|
2051
|
+
// is to monkey-patch these methods.
|
|
2052
|
+
//
|
|
2053
|
+
// See https://stackoverflow.com/a/4585031
|
|
2054
|
+
|
|
2180
2055
|
var patched = 0;
|
|
2181
2056
|
|
|
2182
2057
|
var patchHistoryEvents = function patchHistoryEvents() {
|
|
@@ -2186,7 +2061,8 @@ var patchHistoryEvents = function patchHistoryEvents() {
|
|
|
2186
2061
|
|
|
2187
2062
|
window.history[type] = function () {
|
|
2188
2063
|
var args = [].slice.call(arguments);
|
|
2189
|
-
var result = original.apply(this, args);
|
|
2064
|
+
var result = original.apply(this, args); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2065
|
+
|
|
2190
2066
|
var event = new Event(type);
|
|
2191
2067
|
event.arguments = args;
|
|
2192
2068
|
dispatchEvent(event);
|
|
@@ -2734,7 +2610,8 @@ var GuillotinaClient = /*#__PURE__*/function () {
|
|
|
2734
2610
|
});
|
|
2735
2611
|
}
|
|
2736
2612
|
}];
|
|
2737
|
-
}
|
|
2613
|
+
} // BBB API changes. Compat G5 and G6
|
|
2614
|
+
;
|
|
2738
2615
|
|
|
2739
2616
|
_proto.applyCompat = function applyCompat(data) {
|
|
2740
2617
|
data.member = data.items;
|
|
@@ -2894,7 +2771,8 @@ var GuillotinaClient = /*#__PURE__*/function () {
|
|
|
2894
2771
|
|
|
2895
2772
|
var _temp4 = function () {
|
|
2896
2773
|
if (!cacheSchemas[name]) {
|
|
2897
|
-
var url = _this25.getContainerFromPath(path);
|
|
2774
|
+
var url = _this25.getContainerFromPath(path); // todo: handle db case (only addable containers)
|
|
2775
|
+
|
|
2898
2776
|
|
|
2899
2777
|
return Promise.resolve(_this25.rest.get(url + "@types/" + name)).then(function (res) {
|
|
2900
2778
|
return Promise.resolve(res.json()).then(function (_res$json) {
|
|
@@ -3013,6 +2891,7 @@ var GuillotinaClient = /*#__PURE__*/function () {
|
|
|
3013
2891
|
try {
|
|
3014
2892
|
var _this41 = this;
|
|
3015
2893
|
|
|
2894
|
+
// paths used to query the API always has to start without a "/"
|
|
3016
2895
|
if (path.startsWith('/')) {
|
|
3017
2896
|
path = path.slice(1);
|
|
3018
2897
|
}
|
|
@@ -3241,10 +3120,43 @@ function useClickAway(ref, onClickAway, events) {
|
|
|
3241
3120
|
}, [events, ref]);
|
|
3242
3121
|
}
|
|
3243
3122
|
|
|
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
|
+
|
|
3244
3154
|
function debounce(func, wait) {
|
|
3245
3155
|
var timeout;
|
|
3246
3156
|
return function () {
|
|
3247
|
-
|
|
3157
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
3158
|
+
var context = this; // eslint-disable-next-line prefer-rest-params
|
|
3159
|
+
|
|
3248
3160
|
var args = arguments;
|
|
3249
3161
|
|
|
3250
3162
|
var later = function later() {
|
|
@@ -3573,7 +3485,9 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3573
3485
|
function debounce$1(func, wait) {
|
|
3574
3486
|
var timeout;
|
|
3575
3487
|
return function () {
|
|
3576
|
-
|
|
3488
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
3489
|
+
var context = this; // eslint-disable-next-line prefer-rest-params
|
|
3490
|
+
|
|
3577
3491
|
var args = arguments;
|
|
3578
3492
|
|
|
3579
3493
|
var later = function later() {
|
|
@@ -4254,7 +4168,8 @@ var DownloadField = function DownloadField(_ref) {
|
|
|
4254
4168
|
var blob = new Blob([text], {
|
|
4255
4169
|
type: data.content_type
|
|
4256
4170
|
});
|
|
4257
|
-
var url = window.URL.createObjectURL(blob);
|
|
4171
|
+
var url = window.URL.createObjectURL(blob); // Create blob link to download
|
|
4172
|
+
|
|
4258
4173
|
var link = document.createElement('a');
|
|
4259
4174
|
link.href = url;
|
|
4260
4175
|
|
|
@@ -4269,6 +4184,7 @@ var DownloadField = function DownloadField(_ref) {
|
|
|
4269
4184
|
setTimeout(function () {
|
|
4270
4185
|
var _link$parentNode;
|
|
4271
4186
|
|
|
4187
|
+
// For Firefox it is necessary to delay revoking the ObjectURL
|
|
4272
4188
|
window.URL.revokeObjectURL(url);
|
|
4273
4189
|
(_link$parentNode = link.parentNode) == null ? void 0 : _link$parentNode.removeChild(link);
|
|
4274
4190
|
}, 100);
|
|
@@ -4323,6 +4239,80 @@ var DownloadField = function DownloadField(_ref) {
|
|
|
4323
4239
|
});
|
|
4324
4240
|
};
|
|
4325
4241
|
|
|
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
|
+
|
|
4326
4316
|
var plain = ['string', 'number', 'boolean'];
|
|
4327
4317
|
function RenderField(_ref) {
|
|
4328
4318
|
var value = _ref.value,
|
|
@@ -4567,6 +4557,66 @@ function RenderFieldComponent(_ref5) {
|
|
|
4567
4557
|
return jsx(RenderField, _extends({}, getRenderProps()));
|
|
4568
4558
|
}
|
|
4569
4559
|
|
|
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
|
+
|
|
4570
4620
|
var EditComponent = forwardRef(function (_ref, ref) {
|
|
4571
4621
|
var schema = _ref.schema,
|
|
4572
4622
|
val = _ref.val,
|
|
@@ -6123,6 +6173,7 @@ var ItemModel = /*#__PURE__*/function () {
|
|
|
6123
6173
|
_createClass(ItemModel, [{
|
|
6124
6174
|
key: "path",
|
|
6125
6175
|
get: function get() {
|
|
6176
|
+
// Compat
|
|
6126
6177
|
var item = this.item['@id'] ? this.item['@id'] : this.item['@absolute_url'];
|
|
6127
6178
|
var path = item.split('//')[1].split('/').splice(1).join('/');
|
|
6128
6179
|
path = "/" + path + "/";
|
|
@@ -6145,6 +6196,7 @@ var ItemModel = /*#__PURE__*/function () {
|
|
|
6145
6196
|
}, {
|
|
6146
6197
|
key: "icon",
|
|
6147
6198
|
get: function get() {
|
|
6199
|
+
// eslint-disable-next-line
|
|
6148
6200
|
var cfg = useConfig();
|
|
6149
6201
|
|
|
6150
6202
|
if (cfg.icons && cfg.icons[this.type]) {
|
|
@@ -6457,7 +6509,8 @@ var messages$2 = defineMessages({
|
|
|
6457
6509
|
"value": "Installed Addons"
|
|
6458
6510
|
}]
|
|
6459
6511
|
}
|
|
6460
|
-
});
|
|
6512
|
+
}); // TODO: Refactor without useAsync... just crudContext
|
|
6513
|
+
|
|
6461
6514
|
function PanelAddons() {
|
|
6462
6515
|
var _state$data$available, _state$data, _state$data$available2, _state$data2, _state$data$installed, _state$data3, _state$data$installed2, _state$data4;
|
|
6463
6516
|
|
|
@@ -6810,6 +6863,11 @@ function ItemsActionsProvider(_ref) {
|
|
|
6810
6863
|
children: children
|
|
6811
6864
|
});
|
|
6812
6865
|
}
|
|
6866
|
+
/**
|
|
6867
|
+
* Checkbox component without props that consume the ItemsActionsContext
|
|
6868
|
+
* and it select/unselect all items of the page.
|
|
6869
|
+
*/
|
|
6870
|
+
|
|
6813
6871
|
function AllItemsCheckbox(_ref2) {
|
|
6814
6872
|
var dataTest = _ref2.dataTest;
|
|
6815
6873
|
|
|
@@ -6841,6 +6899,10 @@ function ItemCheckbox(_ref3) {
|
|
|
6841
6899
|
dataTest: dataTest
|
|
6842
6900
|
});
|
|
6843
6901
|
}
|
|
6902
|
+
/**
|
|
6903
|
+
* Dropdown to choose some action to apply to the selected items.
|
|
6904
|
+
*/
|
|
6905
|
+
|
|
6844
6906
|
function ItemsActionsDropdown() {
|
|
6845
6907
|
var intl = useIntl();
|
|
6846
6908
|
var ACTIONS_OBJECT = getActionsObject(intl, true);
|
|
@@ -6932,6 +6994,7 @@ function Pagination(_ref) {
|
|
|
6932
6994
|
"aria-label": "pagination",
|
|
6933
6995
|
children: [jsx("a", {
|
|
6934
6996
|
className: "pagination-previous is-small",
|
|
6997
|
+
// disabled={current === 0}
|
|
6935
6998
|
onClick: function onClick() {
|
|
6936
6999
|
return current > 0 ? doPaginate(current - 1) : null;
|
|
6937
7000
|
},
|
|
@@ -6943,6 +7006,7 @@ function Pagination(_ref) {
|
|
|
6943
7006
|
})
|
|
6944
7007
|
}), jsx("a", {
|
|
6945
7008
|
className: "pagination-next is-small",
|
|
7009
|
+
// disabled={current >= maxPages - 1}
|
|
6946
7010
|
onClick: function onClick() {
|
|
6947
7011
|
return doPaginate(current + 1);
|
|
6948
7012
|
},
|
|
@@ -8640,7 +8704,8 @@ function CreateButton() {
|
|
|
8640
8704
|
|
|
8641
8705
|
if (state.types && state.types.length === 0) {
|
|
8642
8706
|
return null;
|
|
8643
|
-
}
|
|
8707
|
+
} // Implement some kind of filtering
|
|
8708
|
+
|
|
8644
8709
|
|
|
8645
8710
|
return jsx(Dropdown, {
|
|
8646
8711
|
id: "dropdown-menu",
|
|
@@ -8817,6 +8882,11 @@ function TabsPanel(_ref2) {
|
|
|
8817
8882
|
} else {
|
|
8818
8883
|
currentTab = currentTab || Object.keys(tabs)[0];
|
|
8819
8884
|
}
|
|
8885
|
+
/*if (!Object.keys(tabs).includes(currentTab)) {
|
|
8886
|
+
setLocation(defaultTab)
|
|
8887
|
+
currentTab = defaultTab
|
|
8888
|
+
}*/
|
|
8889
|
+
|
|
8820
8890
|
|
|
8821
8891
|
var _useState = useState(currentTab),
|
|
8822
8892
|
current = _useState[0],
|
|
@@ -8825,7 +8895,7 @@ function TabsPanel(_ref2) {
|
|
|
8825
8895
|
var CurrentComp = tabs[current] || fallback;
|
|
8826
8896
|
React.useEffect(function () {
|
|
8827
8897
|
if (Object.keys(tabs).includes(currentTab)) {
|
|
8828
|
-
setTab(currentTab);
|
|
8898
|
+
setTab(currentTab); // setLocation({tab: currentTab})
|
|
8829
8899
|
}
|
|
8830
8900
|
}, [currentTab, tabs]);
|
|
8831
8901
|
|
|
@@ -9255,7 +9325,8 @@ function UsersToolbar() {
|
|
|
9255
9325
|
page: 0
|
|
9256
9326
|
});
|
|
9257
9327
|
ev.preventDefault();
|
|
9258
|
-
};
|
|
9328
|
+
}; // cleanup form on state.search change
|
|
9329
|
+
|
|
9259
9330
|
|
|
9260
9331
|
useEffect(function () {
|
|
9261
9332
|
if (!searchText || searchText === '') {
|
|
@@ -9993,7 +10064,8 @@ function GroupToolbar() {
|
|
|
9993
10064
|
page: 0
|
|
9994
10065
|
});
|
|
9995
10066
|
ev.preventDefault();
|
|
9996
|
-
};
|
|
10067
|
+
}; // cleanup form on state.search change
|
|
10068
|
+
|
|
9997
10069
|
|
|
9998
10070
|
useEffect(function () {
|
|
9999
10071
|
if (!searchText || searchText === '') {
|
|
@@ -10614,11 +10686,13 @@ var getComponent = function getComponent(context, path, fallback) {
|
|
|
10614
10686
|
fallback = undefined;
|
|
10615
10687
|
}
|
|
10616
10688
|
|
|
10617
|
-
if (!context) return;
|
|
10689
|
+
if (!context) return; // console.log("Component for path", path)
|
|
10690
|
+
// lookup by path
|
|
10618
10691
|
|
|
10619
10692
|
if (registry.paths[path]) {
|
|
10620
10693
|
return registry.paths[path];
|
|
10621
|
-
}
|
|
10694
|
+
} // by type
|
|
10695
|
+
|
|
10622
10696
|
|
|
10623
10697
|
if (registry.views[context['@type']]) {
|
|
10624
10698
|
return registry.views[context['@type']];
|
|
@@ -10667,6 +10741,17 @@ var getProperties = function getProperties(type) {
|
|
|
10667
10741
|
|
|
10668
10742
|
var getSchemas = function getSchemas(type) {
|
|
10669
10743
|
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
|
+
*/
|
|
10670
10755
|
};
|
|
10671
10756
|
|
|
10672
10757
|
var getFieldsToFilter = function getFieldsToFilter(type, fallback) {
|
|
@@ -10681,6 +10766,7 @@ var defaultComponent = function defaultComponent(context) {
|
|
|
10681
10766
|
return context.is_folderish ? FolderCtx : ItemCtx;
|
|
10682
10767
|
};
|
|
10683
10768
|
function useRegistry(data) {
|
|
10769
|
+
// if data is provided we need to merge it into actual registry
|
|
10684
10770
|
var ref = React.useRef();
|
|
10685
10771
|
|
|
10686
10772
|
if (data && !ref.current) {
|
|
@@ -10704,6 +10790,22 @@ function useRegistry(data) {
|
|
|
10704
10790
|
getSchemas: getSchemas
|
|
10705
10791
|
};
|
|
10706
10792
|
}
|
|
10793
|
+
/*
|
|
10794
|
+
|
|
10795
|
+
const registry = {
|
|
10796
|
+
paths: {
|
|
10797
|
+
"/db/guillotina/tags/": TagsContext
|
|
10798
|
+
},
|
|
10799
|
+
forms: {
|
|
10800
|
+
Tag: AddTagForm
|
|
10801
|
+
}
|
|
10802
|
+
}
|
|
10803
|
+
|
|
10804
|
+
|
|
10805
|
+
<guillotina registry={registry} />
|
|
10806
|
+
|
|
10807
|
+
|
|
10808
|
+
*/
|
|
10707
10809
|
|
|
10708
10810
|
var initialState$4 = {
|
|
10709
10811
|
path: '',
|
|
@@ -13591,17 +13693,19 @@ function Guillotina(_ref) {
|
|
|
13591
13693
|
props = _objectWithoutPropertiesLoose(_ref, ["auth", "locale"]);
|
|
13592
13694
|
|
|
13593
13695
|
var messages = loadLocaleData(locale);
|
|
13594
|
-
var url = props.url || 'http://localhost:8080';
|
|
13696
|
+
var url = props.url || 'http://localhost:8080'; // without trailing slash
|
|
13697
|
+
|
|
13595
13698
|
var config = props.config || {};
|
|
13596
13699
|
var client = useGuillotinaClient();
|
|
13597
13700
|
|
|
13598
13701
|
var _useConfig = useConfig(config),
|
|
13599
13702
|
Permissions = _useConfig.Permissions;
|
|
13600
13703
|
|
|
13601
|
-
var registry = useRegistry(props.registry || {});
|
|
13704
|
+
var registry = useRegistry(props.registry || {}); // Location is cooked routing solution (only uses search params)
|
|
13602
13705
|
|
|
13603
13706
|
var _useLocation = useLocation(),
|
|
13604
|
-
location = _useLocation[0];
|
|
13707
|
+
location = _useLocation[0]; // if there is no path provided just go to root
|
|
13708
|
+
|
|
13605
13709
|
|
|
13606
13710
|
var searchPath = location.get('path') || '/';
|
|
13607
13711
|
|
|
@@ -14195,6 +14299,7 @@ var Auth = /*#__PURE__*/function () {
|
|
|
14195
14299
|
method: 'post'
|
|
14196
14300
|
})).then(function (data) {
|
|
14197
14301
|
if (data.status === 401) {
|
|
14302
|
+
// invalid token
|
|
14198
14303
|
_this4.cleanAuth();
|
|
14199
14304
|
|
|
14200
14305
|
_this4.logout();
|