@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.umd.js
CHANGED
|
@@ -145,6 +145,7 @@
|
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
_proto.apply = function apply(data) {
|
|
148
|
+
// apply a optimistic update to context
|
|
148
149
|
this.dispatch({
|
|
149
150
|
type: 'APPLY',
|
|
150
151
|
payload: data
|
|
@@ -767,8 +768,10 @@
|
|
|
767
768
|
return bytes;
|
|
768
769
|
}
|
|
769
770
|
function stringToSlug(str) {
|
|
770
|
-
str = str.replace(/^\s+|\s+$/g, '');
|
|
771
|
-
|
|
771
|
+
str = str.replace(/^\s+|\s+$/g, ''); // trim
|
|
772
|
+
|
|
773
|
+
str = str.toLowerCase(); // remove accents, swap ñ for n, etc
|
|
774
|
+
|
|
772
775
|
var from = 'àáäâèéëêìíïîòóöôùúüûñç·/_,:;';
|
|
773
776
|
var to = 'aaaaeeeeiiiioooouuuunc------';
|
|
774
777
|
|
|
@@ -776,7 +779,10 @@
|
|
|
776
779
|
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
|
|
777
780
|
}
|
|
778
781
|
|
|
779
|
-
str = str.replace(/[^a-z0-9 -]/g, '')
|
|
782
|
+
str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
|
|
783
|
+
.replace(/\s+/g, '-') // collapse whitespace and replace by -
|
|
784
|
+
.replace(/-+/g, '-'); // collapse dashes
|
|
785
|
+
|
|
780
786
|
return str;
|
|
781
787
|
}
|
|
782
788
|
function sleep(ms) {
|
|
@@ -920,7 +926,8 @@
|
|
|
920
926
|
})]
|
|
921
927
|
})]
|
|
922
928
|
});
|
|
923
|
-
}
|
|
929
|
+
} // @todo Improve it... Replacing the inputText to a tree
|
|
930
|
+
|
|
924
931
|
function PathTree(_ref2) {
|
|
925
932
|
var title = _ref2.title,
|
|
926
933
|
defaultPath = _ref2.defaultPath,
|
|
@@ -1291,6 +1298,7 @@
|
|
|
1291
1298
|
DelayActions: 200,
|
|
1292
1299
|
Permissions: Permissions,
|
|
1293
1300
|
SearchEngine: 'PostreSQL',
|
|
1301
|
+
// Elasticsearch
|
|
1294
1302
|
fieldHaveDeleteButton: function fieldHaveDeleteButton(schema) {
|
|
1295
1303
|
return (schema == null ? void 0 : schema.widget) === 'file' || (schema == null ? void 0 : schema.widget) === 'select' || (schema == null ? void 0 : schema.type) === 'array';
|
|
1296
1304
|
}
|
|
@@ -1347,7 +1355,9 @@
|
|
|
1347
1355
|
} catch (e) {
|
|
1348
1356
|
return Promise.reject(e);
|
|
1349
1357
|
}
|
|
1350
|
-
});
|
|
1358
|
+
}); // this sleep is here, to let elasticsearch, wait for
|
|
1359
|
+
// index our operations... (will work 99% of use cases)
|
|
1360
|
+
|
|
1351
1361
|
actions.push(sleep(cfg.DelayActions));
|
|
1352
1362
|
return Promise.resolve(Promise.all(actions)).then(function () {
|
|
1353
1363
|
if (errors.length === 0) {
|
|
@@ -1517,6 +1527,9 @@
|
|
|
1517
1527
|
};
|
|
1518
1528
|
};
|
|
1519
1529
|
|
|
1530
|
+
// From github.com/protonmail/proton-shared
|
|
1531
|
+
|
|
1532
|
+
/* eslint-disable no-useless-escape */
|
|
1520
1533
|
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;
|
|
1521
1534
|
var REGEX_URL = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/;
|
|
1522
1535
|
var REGEX_HEX_COLOR = /^#([a-f0-9]{3,4}|[a-f0-9]{4}(?:[a-f0-9]{2}){1,2})\b$/i;
|
|
@@ -1632,7 +1645,8 @@
|
|
|
1632
1645
|
|
|
1633
1646
|
var _useState2 = React.useState(false),
|
|
1634
1647
|
mounted = _useState2[0],
|
|
1635
|
-
setMounted = _useState2[1];
|
|
1648
|
+
setMounted = _useState2[1]; // eslint-disable-next-line
|
|
1649
|
+
|
|
1636
1650
|
|
|
1637
1651
|
ref = ref || React.useRef();
|
|
1638
1652
|
React.useEffect(function () {
|
|
@@ -1700,7 +1714,8 @@
|
|
|
1700
1714
|
value = _ref$value === void 0 ? '' : _ref$value,
|
|
1701
1715
|
dataTest = _ref.dataTest,
|
|
1702
1716
|
placeholder = _ref.placeholder,
|
|
1703
|
-
id = _ref.id
|
|
1717
|
+
id = _ref.id,
|
|
1718
|
+
onChange = _ref.onChange;
|
|
1704
1719
|
var intl = reactIntl.useIntl();
|
|
1705
1720
|
return jsxRuntime.jsx(Input, {
|
|
1706
1721
|
type: "email",
|
|
@@ -1718,7 +1733,8 @@
|
|
|
1718
1733
|
icon: "fas fa-envelope"
|
|
1719
1734
|
}),
|
|
1720
1735
|
id: id,
|
|
1721
|
-
placeholder: placeholder
|
|
1736
|
+
placeholder: placeholder,
|
|
1737
|
+
onChange: onChange
|
|
1722
1738
|
});
|
|
1723
1739
|
};
|
|
1724
1740
|
|
|
@@ -1795,14 +1811,15 @@
|
|
|
1795
1811
|
var ref = React.useRef();
|
|
1796
1812
|
var properties = schema.properties,
|
|
1797
1813
|
required = schema.required;
|
|
1798
|
-
var values = Object.assign({}, formData || {});
|
|
1814
|
+
var values = Object.assign({}, formData || {}); // build initial state
|
|
1815
|
+
|
|
1799
1816
|
var initialState = {};
|
|
1800
1817
|
var fields = Object.keys(properties).filter(function (x) {
|
|
1801
1818
|
return !exclude.includes(x);
|
|
1802
1819
|
});
|
|
1803
1820
|
fields.forEach(function (element) {
|
|
1804
1821
|
initialState[element] = values[element] || undefined;
|
|
1805
|
-
});
|
|
1822
|
+
}); // Register remotes
|
|
1806
1823
|
|
|
1807
1824
|
if (!ref.current) {
|
|
1808
1825
|
ref.current = {};
|
|
@@ -1810,6 +1827,7 @@
|
|
|
1810
1827
|
return ref.current[item] = remotes[item];
|
|
1811
1828
|
});
|
|
1812
1829
|
} else {
|
|
1830
|
+
// apply remote changes
|
|
1813
1831
|
Object.keys(remotes).forEach(function (key) {
|
|
1814
1832
|
if (JSON.stringify(ref.current[key]) !== JSON.stringify(remotes[key])) {
|
|
1815
1833
|
ref.current[key] = remotes[key];
|
|
@@ -1963,166 +1981,7 @@
|
|
|
1963
1981
|
});
|
|
1964
1982
|
Select.displayName = 'Select';
|
|
1965
1983
|
|
|
1966
|
-
|
|
1967
|
-
var d = new Date(str);
|
|
1968
|
-
var minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
|
|
1969
|
-
return d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear() + " " + d.getHours() + ":" + minutes;
|
|
1970
|
-
};
|
|
1971
|
-
var get$1 = function get(obj, path, defValue) {
|
|
1972
|
-
var _pathArray$reduce;
|
|
1973
|
-
|
|
1974
|
-
if (!path) return undefined;
|
|
1975
|
-
var pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
|
|
1976
|
-
return (_pathArray$reduce = pathArray.reduce(function (prevObj, key) {
|
|
1977
|
-
return prevObj && prevObj[key];
|
|
1978
|
-
}, obj)) != null ? _pathArray$reduce : defValue;
|
|
1979
|
-
};
|
|
1980
|
-
function getNewId(id) {
|
|
1981
|
-
if (id === void 0) {
|
|
1982
|
-
id = '';
|
|
1983
|
-
}
|
|
1984
|
-
|
|
1985
|
-
var suffix = '-copy-';
|
|
1986
|
-
var rgx = new RegExp("($|" + suffix + "\\d*)");
|
|
1987
|
-
return stringToSlug(id).replace(rgx, function (r) {
|
|
1988
|
-
var num = parseInt(r.replace(suffix, '') || '0');
|
|
1989
|
-
return "" + suffix + (num + 1);
|
|
1990
|
-
});
|
|
1991
|
-
}
|
|
1992
|
-
|
|
1993
|
-
function _catch$1(body, recover) {
|
|
1994
|
-
try {
|
|
1995
|
-
var result = body();
|
|
1996
|
-
} catch (e) {
|
|
1997
|
-
return recover(e);
|
|
1998
|
-
}
|
|
1999
|
-
|
|
2000
|
-
if (result && result.then) {
|
|
2001
|
-
return result.then(void 0, recover);
|
|
2002
|
-
}
|
|
2003
|
-
|
|
2004
|
-
return result;
|
|
2005
|
-
}
|
|
2006
|
-
|
|
2007
|
-
function useVocabulary(vocabularyName, path) {
|
|
2008
|
-
if (path === void 0) {
|
|
2009
|
-
path = null;
|
|
2010
|
-
}
|
|
2011
|
-
|
|
2012
|
-
var traversal = useTraversal();
|
|
2013
|
-
|
|
2014
|
-
var _useSetState = useSetState({
|
|
2015
|
-
data: undefined,
|
|
2016
|
-
loading: false,
|
|
2017
|
-
error: undefined
|
|
2018
|
-
}),
|
|
2019
|
-
vocabulary = _useSetState[0],
|
|
2020
|
-
setVocabulary = _useSetState[1];
|
|
2021
|
-
|
|
2022
|
-
var getPath = function getPath() {
|
|
2023
|
-
if (path) return path;
|
|
2024
|
-
return traversal.path + "@vocabularies/" + vocabularyName;
|
|
2025
|
-
};
|
|
2026
|
-
|
|
2027
|
-
React.useEffect(function () {
|
|
2028
|
-
var getVocabulary = function getVocabulary() {
|
|
2029
|
-
try {
|
|
2030
|
-
var _temp3 = function () {
|
|
2031
|
-
if (vocabularyName && vocabulary.data === undefined && !vocabulary.loading) {
|
|
2032
|
-
var _temp4 = _catch$1(function () {
|
|
2033
|
-
setVocabulary({
|
|
2034
|
-
loading: true
|
|
2035
|
-
});
|
|
2036
|
-
return Promise.resolve(traversal.client.get(getPath())).then(function (data) {
|
|
2037
|
-
return Promise.resolve(data.json()).then(function (dataJson) {
|
|
2038
|
-
setVocabulary({
|
|
2039
|
-
loading: false,
|
|
2040
|
-
data: dataJson
|
|
2041
|
-
});
|
|
2042
|
-
});
|
|
2043
|
-
});
|
|
2044
|
-
}, function (err) {
|
|
2045
|
-
setVocabulary({
|
|
2046
|
-
loading: false,
|
|
2047
|
-
error: err,
|
|
2048
|
-
data: undefined
|
|
2049
|
-
});
|
|
2050
|
-
});
|
|
2051
|
-
|
|
2052
|
-
if (_temp4 && _temp4.then) return _temp4.then(function () {});
|
|
2053
|
-
}
|
|
2054
|
-
}();
|
|
2055
|
-
|
|
2056
|
-
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
|
|
2057
|
-
} catch (e) {
|
|
2058
|
-
return Promise.reject(e);
|
|
2059
|
-
}
|
|
2060
|
-
};
|
|
2061
|
-
|
|
2062
|
-
getVocabulary();
|
|
2063
|
-
}, [vocabularyName, vocabulary, path]);
|
|
2064
|
-
return vocabulary;
|
|
2065
|
-
}
|
|
2066
|
-
|
|
2067
|
-
var SelectVocabulary = React.forwardRef(function (_ref, ref) {
|
|
2068
|
-
var vocabularyName = _ref.vocabularyName,
|
|
2069
|
-
className = _ref.className,
|
|
2070
|
-
classWrap = _ref.classWrap,
|
|
2071
|
-
val = _ref.val,
|
|
2072
|
-
dataTest = _ref.dataTest,
|
|
2073
|
-
multiple = _ref.multiple,
|
|
2074
|
-
onChange = _ref.onChange,
|
|
2075
|
-
id = _ref.id,
|
|
2076
|
-
placeholder = _ref.placeholder;
|
|
2077
|
-
var vocabulary = useVocabulary(vocabularyName);
|
|
2078
|
-
|
|
2079
|
-
var getOptions = function getOptions() {
|
|
2080
|
-
if (get$1(vocabulary, 'data.items', null)) {
|
|
2081
|
-
var vocData = vocabulary.data.items.map(function (item) {
|
|
2082
|
-
return {
|
|
2083
|
-
text: item.title,
|
|
2084
|
-
value: item.token
|
|
2085
|
-
};
|
|
2086
|
-
});
|
|
2087
|
-
return vocData;
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
return [];
|
|
2091
|
-
};
|
|
2092
|
-
|
|
2093
|
-
var getProps = function getProps() {
|
|
2094
|
-
if (multiple) {
|
|
2095
|
-
var currentValue = val || [];
|
|
2096
|
-
return {
|
|
2097
|
-
multiple: true,
|
|
2098
|
-
size: 5,
|
|
2099
|
-
value: currentValue,
|
|
2100
|
-
options: getOptions()
|
|
2101
|
-
};
|
|
2102
|
-
}
|
|
2103
|
-
|
|
2104
|
-
return {
|
|
2105
|
-
value: val != null ? val : '',
|
|
2106
|
-
appendDefault: true,
|
|
2107
|
-
options: getOptions()
|
|
2108
|
-
};
|
|
2109
|
-
};
|
|
2110
|
-
|
|
2111
|
-
if (vocabulary.data === undefined || vocabulary.loading) {
|
|
2112
|
-
return jsxRuntime.jsx("div", {});
|
|
2113
|
-
}
|
|
2114
|
-
|
|
2115
|
-
return jsxRuntime.jsx(Select, _extends({}, getProps(), {
|
|
2116
|
-
className: className,
|
|
2117
|
-
classWrap: classWrap || 'is-fullwidth',
|
|
2118
|
-
dataTest: dataTest,
|
|
2119
|
-
ref: ref,
|
|
2120
|
-
onChange: onChange,
|
|
2121
|
-
id: id,
|
|
2122
|
-
placeholder: placeholder
|
|
2123
|
-
}));
|
|
2124
|
-
});
|
|
2125
|
-
SelectVocabulary.displayName = 'SelectVocabulary';
|
|
1984
|
+
// https://github.com/molefrog/wouter
|
|
2126
1985
|
|
|
2127
1986
|
var setURLParams = function setURLParams(p) {
|
|
2128
1987
|
return window.history.pushState(0, '0', '' + '?' + p.toString().replace(/%2F/g, '/'));
|
|
@@ -2143,7 +2002,10 @@
|
|
|
2143
2002
|
|
|
2144
2003
|
var prevPath = React.useRef(path);
|
|
2145
2004
|
React.useEffect(function () {
|
|
2146
|
-
patchHistoryEvents();
|
|
2005
|
+
patchHistoryEvents(); // this function checks if the location has been changed since the
|
|
2006
|
+
// last render and updates the state only when needed.
|
|
2007
|
+
// unfortunately, we can't rely on `path` value here, since it can be stale,
|
|
2008
|
+
// that's why we store the last pathname in a ref.
|
|
2147
2009
|
|
|
2148
2010
|
var checkForUpdates = function checkForUpdates() {
|
|
2149
2011
|
var pathname = currentSearchParams();
|
|
@@ -2153,14 +2015,22 @@
|
|
|
2153
2015
|
var events = ['popstate', 'pushState', 'replaceState'];
|
|
2154
2016
|
events.map(function (e) {
|
|
2155
2017
|
return window.addEventListener(e, checkForUpdates);
|
|
2156
|
-
});
|
|
2018
|
+
}); // it's possible that an update has occurred between render and the effect handler,
|
|
2019
|
+
// so we run additional check on mount to catch these updates. Based on:
|
|
2020
|
+
// https://gist.github.com/bvaughn/e25397f70e8c65b0ae0d7c90b731b189
|
|
2021
|
+
|
|
2157
2022
|
checkForUpdates();
|
|
2158
2023
|
return function () {
|
|
2159
2024
|
events.map(function (e) {
|
|
2160
2025
|
return window.removeEventListener(e, checkForUpdates);
|
|
2161
2026
|
});
|
|
2162
2027
|
};
|
|
2163
|
-
}, []);
|
|
2028
|
+
}, []); // the 2nd argument of the `useLocation` return value is a function
|
|
2029
|
+
// that allows to perform a navigation.
|
|
2030
|
+
//
|
|
2031
|
+
// the function reference should stay the same between re-renders, so that
|
|
2032
|
+
// it can be passed down as an element prop without any performance concerns.
|
|
2033
|
+
|
|
2164
2034
|
var navigate = React.useCallback(function (to, replace) {
|
|
2165
2035
|
if (replace) {
|
|
2166
2036
|
clean(to);
|
|
@@ -2179,7 +2049,12 @@
|
|
|
2179
2049
|
setURLParams(current);
|
|
2180
2050
|
}, [path]);
|
|
2181
2051
|
return [path, navigate, remove];
|
|
2182
|
-
};
|
|
2052
|
+
}; // While History API does have `popstate` event, the only
|
|
2053
|
+
// proper way to listen to changes via `push/replaceState`
|
|
2054
|
+
// is to monkey-patch these methods.
|
|
2055
|
+
//
|
|
2056
|
+
// See https://stackoverflow.com/a/4585031
|
|
2057
|
+
|
|
2183
2058
|
var patched = 0;
|
|
2184
2059
|
|
|
2185
2060
|
var patchHistoryEvents = function patchHistoryEvents() {
|
|
@@ -2189,7 +2064,8 @@
|
|
|
2189
2064
|
|
|
2190
2065
|
window.history[type] = function () {
|
|
2191
2066
|
var args = [].slice.call(arguments);
|
|
2192
|
-
var result = original.apply(this, args);
|
|
2067
|
+
var result = original.apply(this, args); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2068
|
+
|
|
2193
2069
|
var event = new Event(type);
|
|
2194
2070
|
event.arguments = args;
|
|
2195
2071
|
dispatchEvent(event);
|
|
@@ -2737,7 +2613,8 @@
|
|
|
2737
2613
|
});
|
|
2738
2614
|
}
|
|
2739
2615
|
}];
|
|
2740
|
-
}
|
|
2616
|
+
} // BBB API changes. Compat G5 and G6
|
|
2617
|
+
;
|
|
2741
2618
|
|
|
2742
2619
|
_proto.applyCompat = function applyCompat(data) {
|
|
2743
2620
|
data.member = data.items;
|
|
@@ -2897,7 +2774,8 @@
|
|
|
2897
2774
|
|
|
2898
2775
|
var _temp4 = function () {
|
|
2899
2776
|
if (!cacheSchemas[name]) {
|
|
2900
|
-
var url = _this25.getContainerFromPath(path);
|
|
2777
|
+
var url = _this25.getContainerFromPath(path); // todo: handle db case (only addable containers)
|
|
2778
|
+
|
|
2901
2779
|
|
|
2902
2780
|
return Promise.resolve(_this25.rest.get(url + "@types/" + name)).then(function (res) {
|
|
2903
2781
|
return Promise.resolve(res.json()).then(function (_res$json) {
|
|
@@ -3016,6 +2894,7 @@
|
|
|
3016
2894
|
try {
|
|
3017
2895
|
var _this41 = this;
|
|
3018
2896
|
|
|
2897
|
+
// paths used to query the API always has to start without a "/"
|
|
3019
2898
|
if (path.startsWith('/')) {
|
|
3020
2899
|
path = path.slice(1);
|
|
3021
2900
|
}
|
|
@@ -3244,10 +3123,43 @@
|
|
|
3244
3123
|
}, [events, ref]);
|
|
3245
3124
|
}
|
|
3246
3125
|
|
|
3126
|
+
var formatDate = function formatDate(str) {
|
|
3127
|
+
var d = new Date(str);
|
|
3128
|
+
var minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
|
|
3129
|
+
return d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear() + " " + d.getHours() + ":" + minutes;
|
|
3130
|
+
};
|
|
3131
|
+
var get$1 = function get(obj, path, defValue) {
|
|
3132
|
+
var _pathArray$reduce;
|
|
3133
|
+
|
|
3134
|
+
// If path is not defined or it has false value
|
|
3135
|
+
if (!path) return undefined; // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.
|
|
3136
|
+
// Regex explained: https://regexr.com/58j0k
|
|
3137
|
+
|
|
3138
|
+
var pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g); // Find value if exist return otherwise return undefined value;
|
|
3139
|
+
|
|
3140
|
+
return (_pathArray$reduce = pathArray.reduce(function (prevObj, key) {
|
|
3141
|
+
return prevObj && prevObj[key];
|
|
3142
|
+
}, obj)) != null ? _pathArray$reduce : defValue;
|
|
3143
|
+
};
|
|
3144
|
+
function getNewId(id) {
|
|
3145
|
+
if (id === void 0) {
|
|
3146
|
+
id = '';
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3149
|
+
var suffix = '-copy-';
|
|
3150
|
+
var rgx = new RegExp("($|" + suffix + "\\d*)");
|
|
3151
|
+
return stringToSlug(id).replace(rgx, function (r) {
|
|
3152
|
+
var num = parseInt(r.replace(suffix, '') || '0');
|
|
3153
|
+
return "" + suffix + (num + 1);
|
|
3154
|
+
});
|
|
3155
|
+
}
|
|
3156
|
+
|
|
3247
3157
|
function debounce(func, wait) {
|
|
3248
3158
|
var timeout;
|
|
3249
3159
|
return function () {
|
|
3250
|
-
|
|
3160
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
3161
|
+
var context = this; // eslint-disable-next-line prefer-rest-params
|
|
3162
|
+
|
|
3251
3163
|
var args = arguments;
|
|
3252
3164
|
|
|
3253
3165
|
var later = function later() {
|
|
@@ -3576,7 +3488,9 @@
|
|
|
3576
3488
|
function debounce$1(func, wait) {
|
|
3577
3489
|
var timeout;
|
|
3578
3490
|
return function () {
|
|
3579
|
-
|
|
3491
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
3492
|
+
var context = this; // eslint-disable-next-line prefer-rest-params
|
|
3493
|
+
|
|
3580
3494
|
var args = arguments;
|
|
3581
3495
|
|
|
3582
3496
|
var later = function later() {
|
|
@@ -4257,7 +4171,8 @@
|
|
|
4257
4171
|
var blob = new Blob([text], {
|
|
4258
4172
|
type: data.content_type
|
|
4259
4173
|
});
|
|
4260
|
-
var url = window.URL.createObjectURL(blob);
|
|
4174
|
+
var url = window.URL.createObjectURL(blob); // Create blob link to download
|
|
4175
|
+
|
|
4261
4176
|
var link = document.createElement('a');
|
|
4262
4177
|
link.href = url;
|
|
4263
4178
|
|
|
@@ -4272,6 +4187,7 @@
|
|
|
4272
4187
|
setTimeout(function () {
|
|
4273
4188
|
var _link$parentNode;
|
|
4274
4189
|
|
|
4190
|
+
// For Firefox it is necessary to delay revoking the ObjectURL
|
|
4275
4191
|
window.URL.revokeObjectURL(url);
|
|
4276
4192
|
(_link$parentNode = link.parentNode) == null ? void 0 : _link$parentNode.removeChild(link);
|
|
4277
4193
|
}, 100);
|
|
@@ -4326,6 +4242,80 @@
|
|
|
4326
4242
|
});
|
|
4327
4243
|
};
|
|
4328
4244
|
|
|
4245
|
+
function _catch$1(body, recover) {
|
|
4246
|
+
try {
|
|
4247
|
+
var result = body();
|
|
4248
|
+
} catch (e) {
|
|
4249
|
+
return recover(e);
|
|
4250
|
+
}
|
|
4251
|
+
|
|
4252
|
+
if (result && result.then) {
|
|
4253
|
+
return result.then(void 0, recover);
|
|
4254
|
+
}
|
|
4255
|
+
|
|
4256
|
+
return result;
|
|
4257
|
+
}
|
|
4258
|
+
|
|
4259
|
+
function useVocabulary(vocabularyName, path) {
|
|
4260
|
+
if (path === void 0) {
|
|
4261
|
+
path = null;
|
|
4262
|
+
}
|
|
4263
|
+
|
|
4264
|
+
var traversal = useTraversal();
|
|
4265
|
+
|
|
4266
|
+
var _useSetState = useSetState({
|
|
4267
|
+
data: undefined,
|
|
4268
|
+
loading: false,
|
|
4269
|
+
error: undefined
|
|
4270
|
+
}),
|
|
4271
|
+
vocabulary = _useSetState[0],
|
|
4272
|
+
setVocabulary = _useSetState[1];
|
|
4273
|
+
|
|
4274
|
+
var getPath = function getPath() {
|
|
4275
|
+
if (path) return path;
|
|
4276
|
+
return traversal.path + "@vocabularies/" + vocabularyName;
|
|
4277
|
+
};
|
|
4278
|
+
|
|
4279
|
+
React.useEffect(function () {
|
|
4280
|
+
var getVocabulary = function getVocabulary() {
|
|
4281
|
+
try {
|
|
4282
|
+
var _temp3 = function () {
|
|
4283
|
+
if (vocabularyName && vocabulary.data === undefined && !vocabulary.loading) {
|
|
4284
|
+
var _temp4 = _catch$1(function () {
|
|
4285
|
+
setVocabulary({
|
|
4286
|
+
loading: true
|
|
4287
|
+
});
|
|
4288
|
+
return Promise.resolve(traversal.client.get(getPath())).then(function (data) {
|
|
4289
|
+
return Promise.resolve(data.json()).then(function (dataJson) {
|
|
4290
|
+
setVocabulary({
|
|
4291
|
+
loading: false,
|
|
4292
|
+
data: dataJson
|
|
4293
|
+
});
|
|
4294
|
+
});
|
|
4295
|
+
});
|
|
4296
|
+
}, function (err) {
|
|
4297
|
+
setVocabulary({
|
|
4298
|
+
loading: false,
|
|
4299
|
+
error: err,
|
|
4300
|
+
data: undefined
|
|
4301
|
+
});
|
|
4302
|
+
});
|
|
4303
|
+
|
|
4304
|
+
if (_temp4 && _temp4.then) return _temp4.then(function () {});
|
|
4305
|
+
}
|
|
4306
|
+
}();
|
|
4307
|
+
|
|
4308
|
+
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
|
|
4309
|
+
} catch (e) {
|
|
4310
|
+
return Promise.reject(e);
|
|
4311
|
+
}
|
|
4312
|
+
};
|
|
4313
|
+
|
|
4314
|
+
getVocabulary();
|
|
4315
|
+
}, [vocabularyName, vocabulary, path]);
|
|
4316
|
+
return vocabulary;
|
|
4317
|
+
}
|
|
4318
|
+
|
|
4329
4319
|
var plain = ['string', 'number', 'boolean'];
|
|
4330
4320
|
function RenderField(_ref) {
|
|
4331
4321
|
var value = _ref.value,
|
|
@@ -4570,6 +4560,66 @@
|
|
|
4570
4560
|
return jsxRuntime.jsx(RenderField, _extends({}, getRenderProps()));
|
|
4571
4561
|
}
|
|
4572
4562
|
|
|
4563
|
+
var SelectVocabulary = React.forwardRef(function (_ref, ref) {
|
|
4564
|
+
var vocabularyName = _ref.vocabularyName,
|
|
4565
|
+
className = _ref.className,
|
|
4566
|
+
classWrap = _ref.classWrap,
|
|
4567
|
+
val = _ref.val,
|
|
4568
|
+
dataTest = _ref.dataTest,
|
|
4569
|
+
multiple = _ref.multiple,
|
|
4570
|
+
onChange = _ref.onChange,
|
|
4571
|
+
id = _ref.id,
|
|
4572
|
+
placeholder = _ref.placeholder;
|
|
4573
|
+
var vocabulary = useVocabulary(vocabularyName);
|
|
4574
|
+
|
|
4575
|
+
var getOptions = function getOptions() {
|
|
4576
|
+
if (get$1(vocabulary, 'data.items', null)) {
|
|
4577
|
+
var vocData = vocabulary.data.items.map(function (item) {
|
|
4578
|
+
return {
|
|
4579
|
+
text: item.title,
|
|
4580
|
+
value: item.token
|
|
4581
|
+
};
|
|
4582
|
+
});
|
|
4583
|
+
return vocData;
|
|
4584
|
+
}
|
|
4585
|
+
|
|
4586
|
+
return [];
|
|
4587
|
+
};
|
|
4588
|
+
|
|
4589
|
+
var getProps = function getProps() {
|
|
4590
|
+
if (multiple) {
|
|
4591
|
+
var currentValue = val || [];
|
|
4592
|
+
return {
|
|
4593
|
+
multiple: true,
|
|
4594
|
+
size: 5,
|
|
4595
|
+
value: currentValue,
|
|
4596
|
+
options: getOptions()
|
|
4597
|
+
};
|
|
4598
|
+
}
|
|
4599
|
+
|
|
4600
|
+
return {
|
|
4601
|
+
value: val != null ? val : '',
|
|
4602
|
+
appendDefault: true,
|
|
4603
|
+
options: getOptions()
|
|
4604
|
+
};
|
|
4605
|
+
};
|
|
4606
|
+
|
|
4607
|
+
if (vocabulary.data === undefined || vocabulary.loading) {
|
|
4608
|
+
return jsxRuntime.jsx("div", {});
|
|
4609
|
+
}
|
|
4610
|
+
|
|
4611
|
+
return jsxRuntime.jsx(Select, _extends({}, getProps(), {
|
|
4612
|
+
className: className,
|
|
4613
|
+
classWrap: classWrap || 'is-fullwidth',
|
|
4614
|
+
dataTest: dataTest,
|
|
4615
|
+
ref: ref,
|
|
4616
|
+
onChange: onChange,
|
|
4617
|
+
id: id,
|
|
4618
|
+
placeholder: placeholder
|
|
4619
|
+
}));
|
|
4620
|
+
});
|
|
4621
|
+
SelectVocabulary.displayName = 'SelectVocabulary';
|
|
4622
|
+
|
|
4573
4623
|
var EditComponent = React.forwardRef(function (_ref, ref) {
|
|
4574
4624
|
var schema = _ref.schema,
|
|
4575
4625
|
val = _ref.val,
|
|
@@ -6126,6 +6176,7 @@
|
|
|
6126
6176
|
_createClass(ItemModel, [{
|
|
6127
6177
|
key: "path",
|
|
6128
6178
|
get: function get() {
|
|
6179
|
+
// Compat
|
|
6129
6180
|
var item = this.item['@id'] ? this.item['@id'] : this.item['@absolute_url'];
|
|
6130
6181
|
var path = item.split('//')[1].split('/').splice(1).join('/');
|
|
6131
6182
|
path = "/" + path + "/";
|
|
@@ -6148,6 +6199,7 @@
|
|
|
6148
6199
|
}, {
|
|
6149
6200
|
key: "icon",
|
|
6150
6201
|
get: function get() {
|
|
6202
|
+
// eslint-disable-next-line
|
|
6151
6203
|
var cfg = useConfig();
|
|
6152
6204
|
|
|
6153
6205
|
if (cfg.icons && cfg.icons[this.type]) {
|
|
@@ -6460,7 +6512,8 @@
|
|
|
6460
6512
|
"value": "Installed Addons"
|
|
6461
6513
|
}]
|
|
6462
6514
|
}
|
|
6463
|
-
});
|
|
6515
|
+
}); // TODO: Refactor without useAsync... just crudContext
|
|
6516
|
+
|
|
6464
6517
|
function PanelAddons() {
|
|
6465
6518
|
var _state$data$available, _state$data, _state$data$available2, _state$data2, _state$data$installed, _state$data3, _state$data$installed2, _state$data4;
|
|
6466
6519
|
|
|
@@ -6813,6 +6866,11 @@
|
|
|
6813
6866
|
children: children
|
|
6814
6867
|
});
|
|
6815
6868
|
}
|
|
6869
|
+
/**
|
|
6870
|
+
* Checkbox component without props that consume the ItemsActionsContext
|
|
6871
|
+
* and it select/unselect all items of the page.
|
|
6872
|
+
*/
|
|
6873
|
+
|
|
6816
6874
|
function AllItemsCheckbox(_ref2) {
|
|
6817
6875
|
var dataTest = _ref2.dataTest;
|
|
6818
6876
|
|
|
@@ -6844,6 +6902,10 @@
|
|
|
6844
6902
|
dataTest: dataTest
|
|
6845
6903
|
});
|
|
6846
6904
|
}
|
|
6905
|
+
/**
|
|
6906
|
+
* Dropdown to choose some action to apply to the selected items.
|
|
6907
|
+
*/
|
|
6908
|
+
|
|
6847
6909
|
function ItemsActionsDropdown() {
|
|
6848
6910
|
var intl = reactIntl.useIntl();
|
|
6849
6911
|
var ACTIONS_OBJECT = getActionsObject(intl, true);
|
|
@@ -6935,6 +6997,7 @@
|
|
|
6935
6997
|
"aria-label": "pagination",
|
|
6936
6998
|
children: [jsxRuntime.jsx("a", {
|
|
6937
6999
|
className: "pagination-previous is-small",
|
|
7000
|
+
// disabled={current === 0}
|
|
6938
7001
|
onClick: function onClick() {
|
|
6939
7002
|
return current > 0 ? doPaginate(current - 1) : null;
|
|
6940
7003
|
},
|
|
@@ -6946,6 +7009,7 @@
|
|
|
6946
7009
|
})
|
|
6947
7010
|
}), jsxRuntime.jsx("a", {
|
|
6948
7011
|
className: "pagination-next is-small",
|
|
7012
|
+
// disabled={current >= maxPages - 1}
|
|
6949
7013
|
onClick: function onClick() {
|
|
6950
7014
|
return doPaginate(current + 1);
|
|
6951
7015
|
},
|
|
@@ -8643,7 +8707,8 @@
|
|
|
8643
8707
|
|
|
8644
8708
|
if (state.types && state.types.length === 0) {
|
|
8645
8709
|
return null;
|
|
8646
|
-
}
|
|
8710
|
+
} // Implement some kind of filtering
|
|
8711
|
+
|
|
8647
8712
|
|
|
8648
8713
|
return jsxRuntime.jsx(Dropdown, {
|
|
8649
8714
|
id: "dropdown-menu",
|
|
@@ -8820,6 +8885,11 @@
|
|
|
8820
8885
|
} else {
|
|
8821
8886
|
currentTab = currentTab || Object.keys(tabs)[0];
|
|
8822
8887
|
}
|
|
8888
|
+
/*if (!Object.keys(tabs).includes(currentTab)) {
|
|
8889
|
+
setLocation(defaultTab)
|
|
8890
|
+
currentTab = defaultTab
|
|
8891
|
+
}*/
|
|
8892
|
+
|
|
8823
8893
|
|
|
8824
8894
|
var _useState = React.useState(currentTab),
|
|
8825
8895
|
current = _useState[0],
|
|
@@ -8828,7 +8898,7 @@
|
|
|
8828
8898
|
var CurrentComp = tabs[current] || fallback;
|
|
8829
8899
|
React__default['default'].useEffect(function () {
|
|
8830
8900
|
if (Object.keys(tabs).includes(currentTab)) {
|
|
8831
|
-
setTab(currentTab);
|
|
8901
|
+
setTab(currentTab); // setLocation({tab: currentTab})
|
|
8832
8902
|
}
|
|
8833
8903
|
}, [currentTab, tabs]);
|
|
8834
8904
|
|
|
@@ -9258,7 +9328,8 @@
|
|
|
9258
9328
|
page: 0
|
|
9259
9329
|
});
|
|
9260
9330
|
ev.preventDefault();
|
|
9261
|
-
};
|
|
9331
|
+
}; // cleanup form on state.search change
|
|
9332
|
+
|
|
9262
9333
|
|
|
9263
9334
|
React.useEffect(function () {
|
|
9264
9335
|
if (!searchText || searchText === '') {
|
|
@@ -9996,7 +10067,8 @@
|
|
|
9996
10067
|
page: 0
|
|
9997
10068
|
});
|
|
9998
10069
|
ev.preventDefault();
|
|
9999
|
-
};
|
|
10070
|
+
}; // cleanup form on state.search change
|
|
10071
|
+
|
|
10000
10072
|
|
|
10001
10073
|
React.useEffect(function () {
|
|
10002
10074
|
if (!searchText || searchText === '') {
|
|
@@ -10617,11 +10689,13 @@
|
|
|
10617
10689
|
fallback = undefined;
|
|
10618
10690
|
}
|
|
10619
10691
|
|
|
10620
|
-
if (!context) return;
|
|
10692
|
+
if (!context) return; // console.log("Component for path", path)
|
|
10693
|
+
// lookup by path
|
|
10621
10694
|
|
|
10622
10695
|
if (registry.paths[path]) {
|
|
10623
10696
|
return registry.paths[path];
|
|
10624
|
-
}
|
|
10697
|
+
} // by type
|
|
10698
|
+
|
|
10625
10699
|
|
|
10626
10700
|
if (registry.views[context['@type']]) {
|
|
10627
10701
|
return registry.views[context['@type']];
|
|
@@ -10670,6 +10744,17 @@
|
|
|
10670
10744
|
|
|
10671
10745
|
var getSchemas = function getSchemas(type) {
|
|
10672
10746
|
return registry.schemas[type] || {};
|
|
10747
|
+
/*
|
|
10748
|
+
filters: [
|
|
10749
|
+
{
|
|
10750
|
+
attribute_key: string,
|
|
10751
|
+
label: string,
|
|
10752
|
+
type: 'select' | 'input'
|
|
10753
|
+
vocabulary: string | undefined
|
|
10754
|
+
values: {[key:string]:any}[]
|
|
10755
|
+
}
|
|
10756
|
+
]
|
|
10757
|
+
*/
|
|
10673
10758
|
};
|
|
10674
10759
|
|
|
10675
10760
|
var getFieldsToFilter = function getFieldsToFilter(type, fallback) {
|
|
@@ -10684,6 +10769,7 @@
|
|
|
10684
10769
|
return context.is_folderish ? FolderCtx : ItemCtx;
|
|
10685
10770
|
};
|
|
10686
10771
|
function useRegistry(data) {
|
|
10772
|
+
// if data is provided we need to merge it into actual registry
|
|
10687
10773
|
var ref = React__default['default'].useRef();
|
|
10688
10774
|
|
|
10689
10775
|
if (data && !ref.current) {
|
|
@@ -10707,6 +10793,22 @@
|
|
|
10707
10793
|
getSchemas: getSchemas
|
|
10708
10794
|
};
|
|
10709
10795
|
}
|
|
10796
|
+
/*
|
|
10797
|
+
|
|
10798
|
+
const registry = {
|
|
10799
|
+
paths: {
|
|
10800
|
+
"/db/guillotina/tags/": TagsContext
|
|
10801
|
+
},
|
|
10802
|
+
forms: {
|
|
10803
|
+
Tag: AddTagForm
|
|
10804
|
+
}
|
|
10805
|
+
}
|
|
10806
|
+
|
|
10807
|
+
|
|
10808
|
+
<guillotina registry={registry} />
|
|
10809
|
+
|
|
10810
|
+
|
|
10811
|
+
*/
|
|
10710
10812
|
|
|
10711
10813
|
var initialState$4 = {
|
|
10712
10814
|
path: '',
|
|
@@ -13594,17 +13696,19 @@
|
|
|
13594
13696
|
props = _objectWithoutPropertiesLoose(_ref, ["auth", "locale"]);
|
|
13595
13697
|
|
|
13596
13698
|
var messages = loadLocaleData(locale);
|
|
13597
|
-
var url = props.url || 'http://localhost:8080';
|
|
13699
|
+
var url = props.url || 'http://localhost:8080'; // without trailing slash
|
|
13700
|
+
|
|
13598
13701
|
var config = props.config || {};
|
|
13599
13702
|
var client = useGuillotinaClient();
|
|
13600
13703
|
|
|
13601
13704
|
var _useConfig = useConfig(config),
|
|
13602
13705
|
Permissions = _useConfig.Permissions;
|
|
13603
13706
|
|
|
13604
|
-
var registry = useRegistry(props.registry || {});
|
|
13707
|
+
var registry = useRegistry(props.registry || {}); // Location is cooked routing solution (only uses search params)
|
|
13605
13708
|
|
|
13606
13709
|
var _useLocation = useLocation(),
|
|
13607
|
-
location = _useLocation[0];
|
|
13710
|
+
location = _useLocation[0]; // if there is no path provided just go to root
|
|
13711
|
+
|
|
13608
13712
|
|
|
13609
13713
|
var searchPath = location.get('path') || '/';
|
|
13610
13714
|
|
|
@@ -14198,6 +14302,7 @@
|
|
|
14198
14302
|
method: 'post'
|
|
14199
14303
|
})).then(function (data) {
|
|
14200
14304
|
if (data.status === 401) {
|
|
14305
|
+
// invalid token
|
|
14201
14306
|
_this4.cleanAuth();
|
|
14202
14307
|
|
|
14203
14308
|
_this4.logout();
|