@guillotinaweb/react-gmi 0.29.0 → 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 +300 -193
- package/dist/react-gmi.esm.js.map +1 -1
- package/dist/react-gmi.js +300 -193
- package/dist/react-gmi.js.map +1 -1
- package/dist/react-gmi.modern.js +263 -155
- package/dist/react-gmi.modern.js.map +1 -1
- package/dist/react-gmi.umd.js +300 -193
- 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.js
CHANGED
|
@@ -149,6 +149,7 @@ var Traversal = /*#__PURE__*/function () {
|
|
|
149
149
|
};
|
|
150
150
|
|
|
151
151
|
_proto.apply = function apply(data) {
|
|
152
|
+
// apply a optimistic update to context
|
|
152
153
|
this.dispatch({
|
|
153
154
|
type: 'APPLY',
|
|
154
155
|
payload: data
|
|
@@ -771,8 +772,10 @@ function base64ToArrayBuffer(base64) {
|
|
|
771
772
|
return bytes;
|
|
772
773
|
}
|
|
773
774
|
function stringToSlug(str) {
|
|
774
|
-
str = str.replace(/^\s+|\s+$/g, '');
|
|
775
|
-
|
|
775
|
+
str = str.replace(/^\s+|\s+$/g, ''); // trim
|
|
776
|
+
|
|
777
|
+
str = str.toLowerCase(); // remove accents, swap ñ for n, etc
|
|
778
|
+
|
|
776
779
|
var from = 'àáäâèéëêìíïîòóöôùúüûñç·/_,:;';
|
|
777
780
|
var to = 'aaaaeeeeiiiioooouuuunc------';
|
|
778
781
|
|
|
@@ -780,7 +783,10 @@ function stringToSlug(str) {
|
|
|
780
783
|
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
|
|
781
784
|
}
|
|
782
785
|
|
|
783
|
-
str = str.replace(/[^a-z0-9 -]/g, '')
|
|
786
|
+
str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
|
|
787
|
+
.replace(/\s+/g, '-') // collapse whitespace and replace by -
|
|
788
|
+
.replace(/-+/g, '-'); // collapse dashes
|
|
789
|
+
|
|
784
790
|
return str;
|
|
785
791
|
}
|
|
786
792
|
function sleep(ms) {
|
|
@@ -924,7 +930,8 @@ function Confirm(_ref) {
|
|
|
924
930
|
})]
|
|
925
931
|
})]
|
|
926
932
|
});
|
|
927
|
-
}
|
|
933
|
+
} // @todo Improve it... Replacing the inputText to a tree
|
|
934
|
+
|
|
928
935
|
function PathTree(_ref2) {
|
|
929
936
|
var title = _ref2.title,
|
|
930
937
|
defaultPath = _ref2.defaultPath,
|
|
@@ -1295,6 +1302,7 @@ var Config = {
|
|
|
1295
1302
|
DelayActions: 200,
|
|
1296
1303
|
Permissions: Permissions,
|
|
1297
1304
|
SearchEngine: 'PostreSQL',
|
|
1305
|
+
// Elasticsearch
|
|
1298
1306
|
fieldHaveDeleteButton: function fieldHaveDeleteButton(schema) {
|
|
1299
1307
|
return (schema == null ? void 0 : schema.widget) === 'file' || (schema == null ? void 0 : schema.widget) === 'select' || (schema == null ? void 0 : schema.type) === 'array';
|
|
1300
1308
|
}
|
|
@@ -1351,7 +1359,9 @@ function RemoveItems(props) {
|
|
|
1351
1359
|
} catch (e) {
|
|
1352
1360
|
return Promise.reject(e);
|
|
1353
1361
|
}
|
|
1354
|
-
});
|
|
1362
|
+
}); // this sleep is here, to let elasticsearch, wait for
|
|
1363
|
+
// index our operations... (will work 99% of use cases)
|
|
1364
|
+
|
|
1355
1365
|
actions.push(sleep(cfg.DelayActions));
|
|
1356
1366
|
return Promise.resolve(Promise.all(actions)).then(function () {
|
|
1357
1367
|
if (errors.length === 0) {
|
|
@@ -1521,6 +1531,9 @@ var useInput = function useInput(onChange, value, validator) {
|
|
|
1521
1531
|
};
|
|
1522
1532
|
};
|
|
1523
1533
|
|
|
1534
|
+
// From github.com/protonmail/proton-shared
|
|
1535
|
+
|
|
1536
|
+
/* eslint-disable no-useless-escape */
|
|
1524
1537
|
var REGEX_EMAIL = /(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/i;
|
|
1525
1538
|
var REGEX_URL = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/;
|
|
1526
1539
|
var REGEX_HEX_COLOR = /^#([a-f0-9]{3,4}|[a-f0-9]{4}(?:[a-f0-9]{2}){1,2})\b$/i;
|
|
@@ -1636,7 +1649,8 @@ var Input = React.forwardRef(function (_ref, ref) {
|
|
|
1636
1649
|
|
|
1637
1650
|
var _useState2 = React.useState(false),
|
|
1638
1651
|
mounted = _useState2[0],
|
|
1639
|
-
setMounted = _useState2[1];
|
|
1652
|
+
setMounted = _useState2[1]; // eslint-disable-next-line
|
|
1653
|
+
|
|
1640
1654
|
|
|
1641
1655
|
ref = ref || React.useRef();
|
|
1642
1656
|
React.useEffect(function () {
|
|
@@ -1704,7 +1718,8 @@ var EmailInput = function EmailInput(_ref) {
|
|
|
1704
1718
|
value = _ref$value === void 0 ? '' : _ref$value,
|
|
1705
1719
|
dataTest = _ref.dataTest,
|
|
1706
1720
|
placeholder = _ref.placeholder,
|
|
1707
|
-
id = _ref.id
|
|
1721
|
+
id = _ref.id,
|
|
1722
|
+
onChange = _ref.onChange;
|
|
1708
1723
|
var intl = reactIntl.useIntl();
|
|
1709
1724
|
return jsxRuntime.jsx(Input, {
|
|
1710
1725
|
type: "email",
|
|
@@ -1722,7 +1737,8 @@ var EmailInput = function EmailInput(_ref) {
|
|
|
1722
1737
|
icon: "fas fa-envelope"
|
|
1723
1738
|
}),
|
|
1724
1739
|
id: id,
|
|
1725
|
-
placeholder: placeholder
|
|
1740
|
+
placeholder: placeholder,
|
|
1741
|
+
onChange: onChange
|
|
1726
1742
|
});
|
|
1727
1743
|
};
|
|
1728
1744
|
|
|
@@ -1799,14 +1815,15 @@ function FormBuilder(_ref) {
|
|
|
1799
1815
|
var ref = React.useRef();
|
|
1800
1816
|
var properties = schema.properties,
|
|
1801
1817
|
required = schema.required;
|
|
1802
|
-
var values = Object.assign({}, formData || {});
|
|
1818
|
+
var values = Object.assign({}, formData || {}); // build initial state
|
|
1819
|
+
|
|
1803
1820
|
var initialState = {};
|
|
1804
1821
|
var fields = Object.keys(properties).filter(function (x) {
|
|
1805
1822
|
return !exclude.includes(x);
|
|
1806
1823
|
});
|
|
1807
1824
|
fields.forEach(function (element) {
|
|
1808
1825
|
initialState[element] = values[element] || undefined;
|
|
1809
|
-
});
|
|
1826
|
+
}); // Register remotes
|
|
1810
1827
|
|
|
1811
1828
|
if (!ref.current) {
|
|
1812
1829
|
ref.current = {};
|
|
@@ -1814,6 +1831,7 @@ function FormBuilder(_ref) {
|
|
|
1814
1831
|
return ref.current[item] = remotes[item];
|
|
1815
1832
|
});
|
|
1816
1833
|
} else {
|
|
1834
|
+
// apply remote changes
|
|
1817
1835
|
Object.keys(remotes).forEach(function (key) {
|
|
1818
1836
|
if (JSON.stringify(ref.current[key]) !== JSON.stringify(remotes[key])) {
|
|
1819
1837
|
ref.current[key] = remotes[key];
|
|
@@ -1967,166 +1985,7 @@ var Select = React.forwardRef(function (_ref, ref) {
|
|
|
1967
1985
|
});
|
|
1968
1986
|
Select.displayName = 'Select';
|
|
1969
1987
|
|
|
1970
|
-
|
|
1971
|
-
var d = new Date(str);
|
|
1972
|
-
var minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
|
|
1973
|
-
return d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear() + " " + d.getHours() + ":" + minutes;
|
|
1974
|
-
};
|
|
1975
|
-
var get$1 = function get(obj, path, defValue) {
|
|
1976
|
-
var _pathArray$reduce;
|
|
1977
|
-
|
|
1978
|
-
if (!path) return undefined;
|
|
1979
|
-
var pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
|
|
1980
|
-
return (_pathArray$reduce = pathArray.reduce(function (prevObj, key) {
|
|
1981
|
-
return prevObj && prevObj[key];
|
|
1982
|
-
}, obj)) != null ? _pathArray$reduce : defValue;
|
|
1983
|
-
};
|
|
1984
|
-
function getNewId(id) {
|
|
1985
|
-
if (id === void 0) {
|
|
1986
|
-
id = '';
|
|
1987
|
-
}
|
|
1988
|
-
|
|
1989
|
-
var suffix = '-copy-';
|
|
1990
|
-
var rgx = new RegExp("($|" + suffix + "\\d*)");
|
|
1991
|
-
return stringToSlug(id).replace(rgx, function (r) {
|
|
1992
|
-
var num = parseInt(r.replace(suffix, '') || '0');
|
|
1993
|
-
return "" + suffix + (num + 1);
|
|
1994
|
-
});
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
function _catch$1(body, recover) {
|
|
1998
|
-
try {
|
|
1999
|
-
var result = body();
|
|
2000
|
-
} catch (e) {
|
|
2001
|
-
return recover(e);
|
|
2002
|
-
}
|
|
2003
|
-
|
|
2004
|
-
if (result && result.then) {
|
|
2005
|
-
return result.then(void 0, recover);
|
|
2006
|
-
}
|
|
2007
|
-
|
|
2008
|
-
return result;
|
|
2009
|
-
}
|
|
2010
|
-
|
|
2011
|
-
function useVocabulary(vocabularyName, path) {
|
|
2012
|
-
if (path === void 0) {
|
|
2013
|
-
path = null;
|
|
2014
|
-
}
|
|
2015
|
-
|
|
2016
|
-
var traversal = useTraversal();
|
|
2017
|
-
|
|
2018
|
-
var _useSetState = useSetState({
|
|
2019
|
-
data: undefined,
|
|
2020
|
-
loading: false,
|
|
2021
|
-
error: undefined
|
|
2022
|
-
}),
|
|
2023
|
-
vocabulary = _useSetState[0],
|
|
2024
|
-
setVocabulary = _useSetState[1];
|
|
2025
|
-
|
|
2026
|
-
var getPath = function getPath() {
|
|
2027
|
-
if (path) return path;
|
|
2028
|
-
return traversal.path + "@vocabularies/" + vocabularyName;
|
|
2029
|
-
};
|
|
2030
|
-
|
|
2031
|
-
React.useEffect(function () {
|
|
2032
|
-
var getVocabulary = function getVocabulary() {
|
|
2033
|
-
try {
|
|
2034
|
-
var _temp3 = function () {
|
|
2035
|
-
if (vocabularyName && vocabulary.data === undefined && !vocabulary.loading) {
|
|
2036
|
-
var _temp4 = _catch$1(function () {
|
|
2037
|
-
setVocabulary({
|
|
2038
|
-
loading: true
|
|
2039
|
-
});
|
|
2040
|
-
return Promise.resolve(traversal.client.get(getPath())).then(function (data) {
|
|
2041
|
-
return Promise.resolve(data.json()).then(function (dataJson) {
|
|
2042
|
-
setVocabulary({
|
|
2043
|
-
loading: false,
|
|
2044
|
-
data: dataJson
|
|
2045
|
-
});
|
|
2046
|
-
});
|
|
2047
|
-
});
|
|
2048
|
-
}, function (err) {
|
|
2049
|
-
setVocabulary({
|
|
2050
|
-
loading: false,
|
|
2051
|
-
error: err,
|
|
2052
|
-
data: undefined
|
|
2053
|
-
});
|
|
2054
|
-
});
|
|
2055
|
-
|
|
2056
|
-
if (_temp4 && _temp4.then) return _temp4.then(function () {});
|
|
2057
|
-
}
|
|
2058
|
-
}();
|
|
2059
|
-
|
|
2060
|
-
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
|
|
2061
|
-
} catch (e) {
|
|
2062
|
-
return Promise.reject(e);
|
|
2063
|
-
}
|
|
2064
|
-
};
|
|
2065
|
-
|
|
2066
|
-
getVocabulary();
|
|
2067
|
-
}, [vocabularyName, vocabulary, path]);
|
|
2068
|
-
return vocabulary;
|
|
2069
|
-
}
|
|
2070
|
-
|
|
2071
|
-
var SelectVocabulary = React.forwardRef(function (_ref, ref) {
|
|
2072
|
-
var vocabularyName = _ref.vocabularyName,
|
|
2073
|
-
className = _ref.className,
|
|
2074
|
-
classWrap = _ref.classWrap,
|
|
2075
|
-
val = _ref.val,
|
|
2076
|
-
dataTest = _ref.dataTest,
|
|
2077
|
-
multiple = _ref.multiple,
|
|
2078
|
-
onChange = _ref.onChange,
|
|
2079
|
-
id = _ref.id,
|
|
2080
|
-
placeholder = _ref.placeholder;
|
|
2081
|
-
var vocabulary = useVocabulary(vocabularyName);
|
|
2082
|
-
|
|
2083
|
-
var getOptions = function getOptions() {
|
|
2084
|
-
if (get$1(vocabulary, 'data.items', null)) {
|
|
2085
|
-
var vocData = vocabulary.data.items.map(function (item) {
|
|
2086
|
-
return {
|
|
2087
|
-
text: item.title,
|
|
2088
|
-
value: item.token
|
|
2089
|
-
};
|
|
2090
|
-
});
|
|
2091
|
-
return vocData;
|
|
2092
|
-
}
|
|
2093
|
-
|
|
2094
|
-
return [];
|
|
2095
|
-
};
|
|
2096
|
-
|
|
2097
|
-
var getProps = function getProps() {
|
|
2098
|
-
if (multiple) {
|
|
2099
|
-
var currentValue = val || [];
|
|
2100
|
-
return {
|
|
2101
|
-
multiple: true,
|
|
2102
|
-
size: 5,
|
|
2103
|
-
value: currentValue,
|
|
2104
|
-
options: getOptions()
|
|
2105
|
-
};
|
|
2106
|
-
}
|
|
2107
|
-
|
|
2108
|
-
return {
|
|
2109
|
-
value: val != null ? val : '',
|
|
2110
|
-
appendDefault: true,
|
|
2111
|
-
options: getOptions()
|
|
2112
|
-
};
|
|
2113
|
-
};
|
|
2114
|
-
|
|
2115
|
-
if (vocabulary.data === undefined || vocabulary.loading) {
|
|
2116
|
-
return jsxRuntime.jsx("div", {});
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2119
|
-
return jsxRuntime.jsx(Select, _extends({}, getProps(), {
|
|
2120
|
-
className: className,
|
|
2121
|
-
classWrap: classWrap || 'is-fullwidth',
|
|
2122
|
-
dataTest: dataTest,
|
|
2123
|
-
ref: ref,
|
|
2124
|
-
onChange: onChange,
|
|
2125
|
-
id: id,
|
|
2126
|
-
placeholder: placeholder
|
|
2127
|
-
}));
|
|
2128
|
-
});
|
|
2129
|
-
SelectVocabulary.displayName = 'SelectVocabulary';
|
|
1988
|
+
// https://github.com/molefrog/wouter
|
|
2130
1989
|
|
|
2131
1990
|
var setURLParams = function setURLParams(p) {
|
|
2132
1991
|
return window.history.pushState(0, '0', '' + '?' + p.toString().replace(/%2F/g, '/'));
|
|
@@ -2147,7 +2006,10 @@ var useLocation = function useLocation() {
|
|
|
2147
2006
|
|
|
2148
2007
|
var prevPath = React.useRef(path);
|
|
2149
2008
|
React.useEffect(function () {
|
|
2150
|
-
patchHistoryEvents();
|
|
2009
|
+
patchHistoryEvents(); // this function checks if the location has been changed since the
|
|
2010
|
+
// last render and updates the state only when needed.
|
|
2011
|
+
// unfortunately, we can't rely on `path` value here, since it can be stale,
|
|
2012
|
+
// that's why we store the last pathname in a ref.
|
|
2151
2013
|
|
|
2152
2014
|
var checkForUpdates = function checkForUpdates() {
|
|
2153
2015
|
var pathname = currentSearchParams();
|
|
@@ -2157,14 +2019,22 @@ var useLocation = function useLocation() {
|
|
|
2157
2019
|
var events = ['popstate', 'pushState', 'replaceState'];
|
|
2158
2020
|
events.map(function (e) {
|
|
2159
2021
|
return window.addEventListener(e, checkForUpdates);
|
|
2160
|
-
});
|
|
2022
|
+
}); // it's possible that an update has occurred between render and the effect handler,
|
|
2023
|
+
// so we run additional check on mount to catch these updates. Based on:
|
|
2024
|
+
// https://gist.github.com/bvaughn/e25397f70e8c65b0ae0d7c90b731b189
|
|
2025
|
+
|
|
2161
2026
|
checkForUpdates();
|
|
2162
2027
|
return function () {
|
|
2163
2028
|
events.map(function (e) {
|
|
2164
2029
|
return window.removeEventListener(e, checkForUpdates);
|
|
2165
2030
|
});
|
|
2166
2031
|
};
|
|
2167
|
-
}, []);
|
|
2032
|
+
}, []); // the 2nd argument of the `useLocation` return value is a function
|
|
2033
|
+
// that allows to perform a navigation.
|
|
2034
|
+
//
|
|
2035
|
+
// the function reference should stay the same between re-renders, so that
|
|
2036
|
+
// it can be passed down as an element prop without any performance concerns.
|
|
2037
|
+
|
|
2168
2038
|
var navigate = React.useCallback(function (to, replace) {
|
|
2169
2039
|
if (replace) {
|
|
2170
2040
|
clean(to);
|
|
@@ -2183,7 +2053,12 @@ var useLocation = function useLocation() {
|
|
|
2183
2053
|
setURLParams(current);
|
|
2184
2054
|
}, [path]);
|
|
2185
2055
|
return [path, navigate, remove];
|
|
2186
|
-
};
|
|
2056
|
+
}; // While History API does have `popstate` event, the only
|
|
2057
|
+
// proper way to listen to changes via `push/replaceState`
|
|
2058
|
+
// is to monkey-patch these methods.
|
|
2059
|
+
//
|
|
2060
|
+
// See https://stackoverflow.com/a/4585031
|
|
2061
|
+
|
|
2187
2062
|
var patched = 0;
|
|
2188
2063
|
|
|
2189
2064
|
var patchHistoryEvents = function patchHistoryEvents() {
|
|
@@ -2193,7 +2068,8 @@ var patchHistoryEvents = function patchHistoryEvents() {
|
|
|
2193
2068
|
|
|
2194
2069
|
window.history[type] = function () {
|
|
2195
2070
|
var args = [].slice.call(arguments);
|
|
2196
|
-
var result = original.apply(this, args);
|
|
2071
|
+
var result = original.apply(this, args); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2072
|
+
|
|
2197
2073
|
var event = new Event(type);
|
|
2198
2074
|
event.arguments = args;
|
|
2199
2075
|
dispatchEvent(event);
|
|
@@ -2741,7 +2617,8 @@ var GuillotinaClient = /*#__PURE__*/function () {
|
|
|
2741
2617
|
});
|
|
2742
2618
|
}
|
|
2743
2619
|
}];
|
|
2744
|
-
}
|
|
2620
|
+
} // BBB API changes. Compat G5 and G6
|
|
2621
|
+
;
|
|
2745
2622
|
|
|
2746
2623
|
_proto.applyCompat = function applyCompat(data) {
|
|
2747
2624
|
data.member = data.items;
|
|
@@ -2901,7 +2778,8 @@ var GuillotinaClient = /*#__PURE__*/function () {
|
|
|
2901
2778
|
|
|
2902
2779
|
var _temp4 = function () {
|
|
2903
2780
|
if (!cacheSchemas[name]) {
|
|
2904
|
-
var url = _this25.getContainerFromPath(path);
|
|
2781
|
+
var url = _this25.getContainerFromPath(path); // todo: handle db case (only addable containers)
|
|
2782
|
+
|
|
2905
2783
|
|
|
2906
2784
|
return Promise.resolve(_this25.rest.get(url + "@types/" + name)).then(function (res) {
|
|
2907
2785
|
return Promise.resolve(res.json()).then(function (_res$json) {
|
|
@@ -3020,6 +2898,7 @@ var GuillotinaClient = /*#__PURE__*/function () {
|
|
|
3020
2898
|
try {
|
|
3021
2899
|
var _this41 = this;
|
|
3022
2900
|
|
|
2901
|
+
// paths used to query the API always has to start without a "/"
|
|
3023
2902
|
if (path.startsWith('/')) {
|
|
3024
2903
|
path = path.slice(1);
|
|
3025
2904
|
}
|
|
@@ -3248,10 +3127,43 @@ function useClickAway(ref, onClickAway, events) {
|
|
|
3248
3127
|
}, [events, ref]);
|
|
3249
3128
|
}
|
|
3250
3129
|
|
|
3130
|
+
var formatDate = function formatDate(str) {
|
|
3131
|
+
var d = new Date(str);
|
|
3132
|
+
var minutes = d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes();
|
|
3133
|
+
return d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear() + " " + d.getHours() + ":" + minutes;
|
|
3134
|
+
};
|
|
3135
|
+
var get$1 = function get(obj, path, defValue) {
|
|
3136
|
+
var _pathArray$reduce;
|
|
3137
|
+
|
|
3138
|
+
// If path is not defined or it has false value
|
|
3139
|
+
if (!path) return undefined; // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.
|
|
3140
|
+
// Regex explained: https://regexr.com/58j0k
|
|
3141
|
+
|
|
3142
|
+
var pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g); // Find value if exist return otherwise return undefined value;
|
|
3143
|
+
|
|
3144
|
+
return (_pathArray$reduce = pathArray.reduce(function (prevObj, key) {
|
|
3145
|
+
return prevObj && prevObj[key];
|
|
3146
|
+
}, obj)) != null ? _pathArray$reduce : defValue;
|
|
3147
|
+
};
|
|
3148
|
+
function getNewId(id) {
|
|
3149
|
+
if (id === void 0) {
|
|
3150
|
+
id = '';
|
|
3151
|
+
}
|
|
3152
|
+
|
|
3153
|
+
var suffix = '-copy-';
|
|
3154
|
+
var rgx = new RegExp("($|" + suffix + "\\d*)");
|
|
3155
|
+
return stringToSlug(id).replace(rgx, function (r) {
|
|
3156
|
+
var num = parseInt(r.replace(suffix, '') || '0');
|
|
3157
|
+
return "" + suffix + (num + 1);
|
|
3158
|
+
});
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3251
3161
|
function debounce(func, wait) {
|
|
3252
3162
|
var timeout;
|
|
3253
3163
|
return function () {
|
|
3254
|
-
|
|
3164
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
3165
|
+
var context = this; // eslint-disable-next-line prefer-rest-params
|
|
3166
|
+
|
|
3255
3167
|
var args = arguments;
|
|
3256
3168
|
|
|
3257
3169
|
var later = function later() {
|
|
@@ -3580,7 +3492,9 @@ var SearchInput = function SearchInput(_ref) {
|
|
|
3580
3492
|
function debounce$1(func, wait) {
|
|
3581
3493
|
var timeout;
|
|
3582
3494
|
return function () {
|
|
3583
|
-
|
|
3495
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
3496
|
+
var context = this; // eslint-disable-next-line prefer-rest-params
|
|
3497
|
+
|
|
3584
3498
|
var args = arguments;
|
|
3585
3499
|
|
|
3586
3500
|
var later = function later() {
|
|
@@ -4261,7 +4175,8 @@ var DownloadField = function DownloadField(_ref) {
|
|
|
4261
4175
|
var blob = new Blob([text], {
|
|
4262
4176
|
type: data.content_type
|
|
4263
4177
|
});
|
|
4264
|
-
var url = window.URL.createObjectURL(blob);
|
|
4178
|
+
var url = window.URL.createObjectURL(blob); // Create blob link to download
|
|
4179
|
+
|
|
4265
4180
|
var link = document.createElement('a');
|
|
4266
4181
|
link.href = url;
|
|
4267
4182
|
|
|
@@ -4276,6 +4191,7 @@ var DownloadField = function DownloadField(_ref) {
|
|
|
4276
4191
|
setTimeout(function () {
|
|
4277
4192
|
var _link$parentNode;
|
|
4278
4193
|
|
|
4194
|
+
// For Firefox it is necessary to delay revoking the ObjectURL
|
|
4279
4195
|
window.URL.revokeObjectURL(url);
|
|
4280
4196
|
(_link$parentNode = link.parentNode) == null ? void 0 : _link$parentNode.removeChild(link);
|
|
4281
4197
|
}, 100);
|
|
@@ -4330,6 +4246,80 @@ var DownloadField = function DownloadField(_ref) {
|
|
|
4330
4246
|
});
|
|
4331
4247
|
};
|
|
4332
4248
|
|
|
4249
|
+
function _catch$1(body, recover) {
|
|
4250
|
+
try {
|
|
4251
|
+
var result = body();
|
|
4252
|
+
} catch (e) {
|
|
4253
|
+
return recover(e);
|
|
4254
|
+
}
|
|
4255
|
+
|
|
4256
|
+
if (result && result.then) {
|
|
4257
|
+
return result.then(void 0, recover);
|
|
4258
|
+
}
|
|
4259
|
+
|
|
4260
|
+
return result;
|
|
4261
|
+
}
|
|
4262
|
+
|
|
4263
|
+
function useVocabulary(vocabularyName, path) {
|
|
4264
|
+
if (path === void 0) {
|
|
4265
|
+
path = null;
|
|
4266
|
+
}
|
|
4267
|
+
|
|
4268
|
+
var traversal = useTraversal();
|
|
4269
|
+
|
|
4270
|
+
var _useSetState = useSetState({
|
|
4271
|
+
data: undefined,
|
|
4272
|
+
loading: false,
|
|
4273
|
+
error: undefined
|
|
4274
|
+
}),
|
|
4275
|
+
vocabulary = _useSetState[0],
|
|
4276
|
+
setVocabulary = _useSetState[1];
|
|
4277
|
+
|
|
4278
|
+
var getPath = function getPath() {
|
|
4279
|
+
if (path) return path;
|
|
4280
|
+
return traversal.path + "@vocabularies/" + vocabularyName;
|
|
4281
|
+
};
|
|
4282
|
+
|
|
4283
|
+
React.useEffect(function () {
|
|
4284
|
+
var getVocabulary = function getVocabulary() {
|
|
4285
|
+
try {
|
|
4286
|
+
var _temp3 = function () {
|
|
4287
|
+
if (vocabularyName && vocabulary.data === undefined && !vocabulary.loading) {
|
|
4288
|
+
var _temp4 = _catch$1(function () {
|
|
4289
|
+
setVocabulary({
|
|
4290
|
+
loading: true
|
|
4291
|
+
});
|
|
4292
|
+
return Promise.resolve(traversal.client.get(getPath())).then(function (data) {
|
|
4293
|
+
return Promise.resolve(data.json()).then(function (dataJson) {
|
|
4294
|
+
setVocabulary({
|
|
4295
|
+
loading: false,
|
|
4296
|
+
data: dataJson
|
|
4297
|
+
});
|
|
4298
|
+
});
|
|
4299
|
+
});
|
|
4300
|
+
}, function (err) {
|
|
4301
|
+
setVocabulary({
|
|
4302
|
+
loading: false,
|
|
4303
|
+
error: err,
|
|
4304
|
+
data: undefined
|
|
4305
|
+
});
|
|
4306
|
+
});
|
|
4307
|
+
|
|
4308
|
+
if (_temp4 && _temp4.then) return _temp4.then(function () {});
|
|
4309
|
+
}
|
|
4310
|
+
}();
|
|
4311
|
+
|
|
4312
|
+
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
|
|
4313
|
+
} catch (e) {
|
|
4314
|
+
return Promise.reject(e);
|
|
4315
|
+
}
|
|
4316
|
+
};
|
|
4317
|
+
|
|
4318
|
+
getVocabulary();
|
|
4319
|
+
}, [vocabularyName, vocabulary, path]);
|
|
4320
|
+
return vocabulary;
|
|
4321
|
+
}
|
|
4322
|
+
|
|
4333
4323
|
var plain = ['string', 'number', 'boolean'];
|
|
4334
4324
|
function RenderField(_ref) {
|
|
4335
4325
|
var value = _ref.value,
|
|
@@ -4574,6 +4564,66 @@ function RenderFieldComponent(_ref5) {
|
|
|
4574
4564
|
return jsxRuntime.jsx(RenderField, _extends({}, getRenderProps()));
|
|
4575
4565
|
}
|
|
4576
4566
|
|
|
4567
|
+
var SelectVocabulary = React.forwardRef(function (_ref, ref) {
|
|
4568
|
+
var vocabularyName = _ref.vocabularyName,
|
|
4569
|
+
className = _ref.className,
|
|
4570
|
+
classWrap = _ref.classWrap,
|
|
4571
|
+
val = _ref.val,
|
|
4572
|
+
dataTest = _ref.dataTest,
|
|
4573
|
+
multiple = _ref.multiple,
|
|
4574
|
+
onChange = _ref.onChange,
|
|
4575
|
+
id = _ref.id,
|
|
4576
|
+
placeholder = _ref.placeholder;
|
|
4577
|
+
var vocabulary = useVocabulary(vocabularyName);
|
|
4578
|
+
|
|
4579
|
+
var getOptions = function getOptions() {
|
|
4580
|
+
if (get$1(vocabulary, 'data.items', null)) {
|
|
4581
|
+
var vocData = vocabulary.data.items.map(function (item) {
|
|
4582
|
+
return {
|
|
4583
|
+
text: item.title,
|
|
4584
|
+
value: item.token
|
|
4585
|
+
};
|
|
4586
|
+
});
|
|
4587
|
+
return vocData;
|
|
4588
|
+
}
|
|
4589
|
+
|
|
4590
|
+
return [];
|
|
4591
|
+
};
|
|
4592
|
+
|
|
4593
|
+
var getProps = function getProps() {
|
|
4594
|
+
if (multiple) {
|
|
4595
|
+
var currentValue = val || [];
|
|
4596
|
+
return {
|
|
4597
|
+
multiple: true,
|
|
4598
|
+
size: 5,
|
|
4599
|
+
value: currentValue,
|
|
4600
|
+
options: getOptions()
|
|
4601
|
+
};
|
|
4602
|
+
}
|
|
4603
|
+
|
|
4604
|
+
return {
|
|
4605
|
+
value: val != null ? val : '',
|
|
4606
|
+
appendDefault: true,
|
|
4607
|
+
options: getOptions()
|
|
4608
|
+
};
|
|
4609
|
+
};
|
|
4610
|
+
|
|
4611
|
+
if (vocabulary.data === undefined || vocabulary.loading) {
|
|
4612
|
+
return jsxRuntime.jsx("div", {});
|
|
4613
|
+
}
|
|
4614
|
+
|
|
4615
|
+
return jsxRuntime.jsx(Select, _extends({}, getProps(), {
|
|
4616
|
+
className: className,
|
|
4617
|
+
classWrap: classWrap || 'is-fullwidth',
|
|
4618
|
+
dataTest: dataTest,
|
|
4619
|
+
ref: ref,
|
|
4620
|
+
onChange: onChange,
|
|
4621
|
+
id: id,
|
|
4622
|
+
placeholder: placeholder
|
|
4623
|
+
}));
|
|
4624
|
+
});
|
|
4625
|
+
SelectVocabulary.displayName = 'SelectVocabulary';
|
|
4626
|
+
|
|
4577
4627
|
var EditComponent = React.forwardRef(function (_ref, ref) {
|
|
4578
4628
|
var schema = _ref.schema,
|
|
4579
4629
|
val = _ref.val,
|
|
@@ -6130,6 +6180,7 @@ var ItemModel = /*#__PURE__*/function () {
|
|
|
6130
6180
|
_createClass(ItemModel, [{
|
|
6131
6181
|
key: "path",
|
|
6132
6182
|
get: function get() {
|
|
6183
|
+
// Compat
|
|
6133
6184
|
var item = this.item['@id'] ? this.item['@id'] : this.item['@absolute_url'];
|
|
6134
6185
|
var path = item.split('//')[1].split('/').splice(1).join('/');
|
|
6135
6186
|
path = "/" + path + "/";
|
|
@@ -6152,6 +6203,7 @@ var ItemModel = /*#__PURE__*/function () {
|
|
|
6152
6203
|
}, {
|
|
6153
6204
|
key: "icon",
|
|
6154
6205
|
get: function get() {
|
|
6206
|
+
// eslint-disable-next-line
|
|
6155
6207
|
var cfg = useConfig();
|
|
6156
6208
|
|
|
6157
6209
|
if (cfg.icons && cfg.icons[this.type]) {
|
|
@@ -6464,7 +6516,8 @@ var messages$2 = reactIntl.defineMessages({
|
|
|
6464
6516
|
"value": "Installed Addons"
|
|
6465
6517
|
}]
|
|
6466
6518
|
}
|
|
6467
|
-
});
|
|
6519
|
+
}); // TODO: Refactor without useAsync... just crudContext
|
|
6520
|
+
|
|
6468
6521
|
function PanelAddons() {
|
|
6469
6522
|
var _state$data$available, _state$data, _state$data$available2, _state$data2, _state$data$installed, _state$data3, _state$data$installed2, _state$data4;
|
|
6470
6523
|
|
|
@@ -6817,6 +6870,11 @@ function ItemsActionsProvider(_ref) {
|
|
|
6817
6870
|
children: children
|
|
6818
6871
|
});
|
|
6819
6872
|
}
|
|
6873
|
+
/**
|
|
6874
|
+
* Checkbox component without props that consume the ItemsActionsContext
|
|
6875
|
+
* and it select/unselect all items of the page.
|
|
6876
|
+
*/
|
|
6877
|
+
|
|
6820
6878
|
function AllItemsCheckbox(_ref2) {
|
|
6821
6879
|
var dataTest = _ref2.dataTest;
|
|
6822
6880
|
|
|
@@ -6848,6 +6906,10 @@ function ItemCheckbox(_ref3) {
|
|
|
6848
6906
|
dataTest: dataTest
|
|
6849
6907
|
});
|
|
6850
6908
|
}
|
|
6909
|
+
/**
|
|
6910
|
+
* Dropdown to choose some action to apply to the selected items.
|
|
6911
|
+
*/
|
|
6912
|
+
|
|
6851
6913
|
function ItemsActionsDropdown() {
|
|
6852
6914
|
var intl = reactIntl.useIntl();
|
|
6853
6915
|
var ACTIONS_OBJECT = getActionsObject(intl, true);
|
|
@@ -6939,6 +7001,7 @@ function Pagination(_ref) {
|
|
|
6939
7001
|
"aria-label": "pagination",
|
|
6940
7002
|
children: [jsxRuntime.jsx("a", {
|
|
6941
7003
|
className: "pagination-previous is-small",
|
|
7004
|
+
// disabled={current === 0}
|
|
6942
7005
|
onClick: function onClick() {
|
|
6943
7006
|
return current > 0 ? doPaginate(current - 1) : null;
|
|
6944
7007
|
},
|
|
@@ -6950,6 +7013,7 @@ function Pagination(_ref) {
|
|
|
6950
7013
|
})
|
|
6951
7014
|
}), jsxRuntime.jsx("a", {
|
|
6952
7015
|
className: "pagination-next is-small",
|
|
7016
|
+
// disabled={current >= maxPages - 1}
|
|
6953
7017
|
onClick: function onClick() {
|
|
6954
7018
|
return doPaginate(current + 1);
|
|
6955
7019
|
},
|
|
@@ -7305,7 +7369,7 @@ function PanelItems() {
|
|
|
7305
7369
|
key: 'id',
|
|
7306
7370
|
direction: 'des'
|
|
7307
7371
|
});
|
|
7308
|
-
sortParsed = parser("_sort_" + defaultSortValue.direction + "=" + defaultSortValue.key
|
|
7372
|
+
sortParsed = parser("_sort_" + defaultSortValue.direction + "=" + defaultSortValue.key);
|
|
7309
7373
|
}
|
|
7310
7374
|
|
|
7311
7375
|
var qsParsed = Ctx.client[fnName]({
|
|
@@ -7315,12 +7379,14 @@ function PanelItems() {
|
|
|
7315
7379
|
});
|
|
7316
7380
|
var qs = '';
|
|
7317
7381
|
|
|
7318
|
-
if (search || type ||
|
|
7382
|
+
if (search || type || resultQueryParams.length > 0) {
|
|
7319
7383
|
var _searchParsed, _typeParsed, _sortParsed;
|
|
7320
7384
|
|
|
7321
7385
|
qs = buildQs([].concat(qsParsed, (_searchParsed = searchParsed) != null ? _searchParsed : [], (_typeParsed = typeParsed) != null ? _typeParsed : [], (_sortParsed = sortParsed) != null ? _sortParsed : [], resultQueryParams));
|
|
7322
7386
|
} else {
|
|
7323
|
-
|
|
7387
|
+
var _sortParsed2;
|
|
7388
|
+
|
|
7389
|
+
qs = buildQs([].concat(qsParsed, (_sortParsed2 = sortParsed) != null ? _sortParsed2 : []));
|
|
7324
7390
|
}
|
|
7325
7391
|
|
|
7326
7392
|
var signal = controller.signal;
|
|
@@ -8645,7 +8711,8 @@ function CreateButton() {
|
|
|
8645
8711
|
|
|
8646
8712
|
if (state.types && state.types.length === 0) {
|
|
8647
8713
|
return null;
|
|
8648
|
-
}
|
|
8714
|
+
} // Implement some kind of filtering
|
|
8715
|
+
|
|
8649
8716
|
|
|
8650
8717
|
return jsxRuntime.jsx(Dropdown, {
|
|
8651
8718
|
id: "dropdown-menu",
|
|
@@ -8822,6 +8889,11 @@ function TabsPanel(_ref2) {
|
|
|
8822
8889
|
} else {
|
|
8823
8890
|
currentTab = currentTab || Object.keys(tabs)[0];
|
|
8824
8891
|
}
|
|
8892
|
+
/*if (!Object.keys(tabs).includes(currentTab)) {
|
|
8893
|
+
setLocation(defaultTab)
|
|
8894
|
+
currentTab = defaultTab
|
|
8895
|
+
}*/
|
|
8896
|
+
|
|
8825
8897
|
|
|
8826
8898
|
var _useState = React.useState(currentTab),
|
|
8827
8899
|
current = _useState[0],
|
|
@@ -8830,7 +8902,7 @@ function TabsPanel(_ref2) {
|
|
|
8830
8902
|
var CurrentComp = tabs[current] || fallback;
|
|
8831
8903
|
React__default['default'].useEffect(function () {
|
|
8832
8904
|
if (Object.keys(tabs).includes(currentTab)) {
|
|
8833
|
-
setTab(currentTab);
|
|
8905
|
+
setTab(currentTab); // setLocation({tab: currentTab})
|
|
8834
8906
|
}
|
|
8835
8907
|
}, [currentTab, tabs]);
|
|
8836
8908
|
|
|
@@ -9260,7 +9332,8 @@ function UsersToolbar() {
|
|
|
9260
9332
|
page: 0
|
|
9261
9333
|
});
|
|
9262
9334
|
ev.preventDefault();
|
|
9263
|
-
};
|
|
9335
|
+
}; // cleanup form on state.search change
|
|
9336
|
+
|
|
9264
9337
|
|
|
9265
9338
|
React.useEffect(function () {
|
|
9266
9339
|
if (!searchText || searchText === '') {
|
|
@@ -9998,7 +10071,8 @@ function GroupToolbar() {
|
|
|
9998
10071
|
page: 0
|
|
9999
10072
|
});
|
|
10000
10073
|
ev.preventDefault();
|
|
10001
|
-
};
|
|
10074
|
+
}; // cleanup form on state.search change
|
|
10075
|
+
|
|
10002
10076
|
|
|
10003
10077
|
React.useEffect(function () {
|
|
10004
10078
|
if (!searchText || searchText === '') {
|
|
@@ -10619,11 +10693,13 @@ var getComponent = function getComponent(context, path, fallback) {
|
|
|
10619
10693
|
fallback = undefined;
|
|
10620
10694
|
}
|
|
10621
10695
|
|
|
10622
|
-
if (!context) return;
|
|
10696
|
+
if (!context) return; // console.log("Component for path", path)
|
|
10697
|
+
// lookup by path
|
|
10623
10698
|
|
|
10624
10699
|
if (registry.paths[path]) {
|
|
10625
10700
|
return registry.paths[path];
|
|
10626
|
-
}
|
|
10701
|
+
} // by type
|
|
10702
|
+
|
|
10627
10703
|
|
|
10628
10704
|
if (registry.views[context['@type']]) {
|
|
10629
10705
|
return registry.views[context['@type']];
|
|
@@ -10672,6 +10748,17 @@ var getProperties = function getProperties(type) {
|
|
|
10672
10748
|
|
|
10673
10749
|
var getSchemas = function getSchemas(type) {
|
|
10674
10750
|
return registry.schemas[type] || {};
|
|
10751
|
+
/*
|
|
10752
|
+
filters: [
|
|
10753
|
+
{
|
|
10754
|
+
attribute_key: string,
|
|
10755
|
+
label: string,
|
|
10756
|
+
type: 'select' | 'input'
|
|
10757
|
+
vocabulary: string | undefined
|
|
10758
|
+
values: {[key:string]:any}[]
|
|
10759
|
+
}
|
|
10760
|
+
]
|
|
10761
|
+
*/
|
|
10675
10762
|
};
|
|
10676
10763
|
|
|
10677
10764
|
var getFieldsToFilter = function getFieldsToFilter(type, fallback) {
|
|
@@ -10686,6 +10773,7 @@ var defaultComponent = function defaultComponent(context) {
|
|
|
10686
10773
|
return context.is_folderish ? FolderCtx : ItemCtx;
|
|
10687
10774
|
};
|
|
10688
10775
|
function useRegistry(data) {
|
|
10776
|
+
// if data is provided we need to merge it into actual registry
|
|
10689
10777
|
var ref = React__default['default'].useRef();
|
|
10690
10778
|
|
|
10691
10779
|
if (data && !ref.current) {
|
|
@@ -10709,6 +10797,22 @@ function useRegistry(data) {
|
|
|
10709
10797
|
getSchemas: getSchemas
|
|
10710
10798
|
};
|
|
10711
10799
|
}
|
|
10800
|
+
/*
|
|
10801
|
+
|
|
10802
|
+
const registry = {
|
|
10803
|
+
paths: {
|
|
10804
|
+
"/db/guillotina/tags/": TagsContext
|
|
10805
|
+
},
|
|
10806
|
+
forms: {
|
|
10807
|
+
Tag: AddTagForm
|
|
10808
|
+
}
|
|
10809
|
+
}
|
|
10810
|
+
|
|
10811
|
+
|
|
10812
|
+
<guillotina registry={registry} />
|
|
10813
|
+
|
|
10814
|
+
|
|
10815
|
+
*/
|
|
10712
10816
|
|
|
10713
10817
|
var initialState$4 = {
|
|
10714
10818
|
path: '',
|
|
@@ -13596,17 +13700,19 @@ function Guillotina(_ref) {
|
|
|
13596
13700
|
props = _objectWithoutPropertiesLoose(_ref, ["auth", "locale"]);
|
|
13597
13701
|
|
|
13598
13702
|
var messages = loadLocaleData(locale);
|
|
13599
|
-
var url = props.url || 'http://localhost:8080';
|
|
13703
|
+
var url = props.url || 'http://localhost:8080'; // without trailing slash
|
|
13704
|
+
|
|
13600
13705
|
var config = props.config || {};
|
|
13601
13706
|
var client = useGuillotinaClient();
|
|
13602
13707
|
|
|
13603
13708
|
var _useConfig = useConfig(config),
|
|
13604
13709
|
Permissions = _useConfig.Permissions;
|
|
13605
13710
|
|
|
13606
|
-
var registry = useRegistry(props.registry || {});
|
|
13711
|
+
var registry = useRegistry(props.registry || {}); // Location is cooked routing solution (only uses search params)
|
|
13607
13712
|
|
|
13608
13713
|
var _useLocation = useLocation(),
|
|
13609
|
-
location = _useLocation[0];
|
|
13714
|
+
location = _useLocation[0]; // if there is no path provided just go to root
|
|
13715
|
+
|
|
13610
13716
|
|
|
13611
13717
|
var searchPath = location.get('path') || '/';
|
|
13612
13718
|
|
|
@@ -14200,6 +14306,7 @@ var Auth = /*#__PURE__*/function () {
|
|
|
14200
14306
|
method: 'post'
|
|
14201
14307
|
})).then(function (data) {
|
|
14202
14308
|
if (data.status === 401) {
|
|
14309
|
+
// invalid token
|
|
14203
14310
|
_this4.cleanAuth();
|
|
14204
14311
|
|
|
14205
14312
|
_this4.logout();
|