@commercetools-frontend/experimental-components 6.0.2 → 6.1.0
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/commercetools-frontend-experimental-components.cjs.dev.js +911 -757
- package/dist/commercetools-frontend-experimental-components.cjs.prod.js +908 -754
- package/dist/commercetools-frontend-experimental-components.esm.js +905 -756
- package/dist/styles.css +41 -41
- package/package.json +17 -17
|
@@ -26,12 +26,14 @@ import { formatLocalizedString, transformLocalizedFieldToLocalizedString, applyT
|
|
|
26
26
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
27
27
|
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
28
28
|
import camelCase from 'lodash/camelCase';
|
|
29
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
29
30
|
import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
|
|
30
31
|
import _sortInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/sort';
|
|
31
32
|
import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/index-of';
|
|
32
33
|
import { deepEqual } from 'fast-equals';
|
|
33
34
|
import { defineMessages, useIntl, injectIntl, FormattedMessage } from 'react-intl';
|
|
34
35
|
import omitEmpty from 'omit-empty-es';
|
|
36
|
+
import _taggedTemplateLiteral from '@babel/runtime-corejs3/helpers/esm/taggedTemplateLiteral';
|
|
35
37
|
import oneLine from 'common-tags/lib/oneLine';
|
|
36
38
|
import moment from 'moment-timezone';
|
|
37
39
|
import isNil$1 from 'lodash/isNil';
|
|
@@ -60,7 +62,6 @@ import { useQuery as useQuery$1 } from '@apollo/client/react/hooks';
|
|
|
60
62
|
import moment$1 from 'moment';
|
|
61
63
|
import classnames from 'classnames';
|
|
62
64
|
import 'react-required-if';
|
|
63
|
-
import _assertThisInitialized from '@babel/runtime-corejs3/helpers/esm/assertThisInitialized';
|
|
64
65
|
import Textarea from 'react-textarea-autosize';
|
|
65
66
|
import has from 'lodash/has';
|
|
66
67
|
import _toArray from '@babel/runtime-corejs3/helpers/esm/toArray';
|
|
@@ -74,6 +75,7 @@ import omit from 'lodash/omit';
|
|
|
74
75
|
import isEmpty$3 from 'lodash/isEmpty';
|
|
75
76
|
import _Object$freeze from '@babel/runtime-corejs3/core-js-stable/object/freeze';
|
|
76
77
|
import originalOmitDeep from 'omit-deep';
|
|
78
|
+
import _findIndexInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find-index';
|
|
77
79
|
import _Object$values from '@babel/runtime-corejs3/core-js-stable/object/values';
|
|
78
80
|
import _parseInt from '@babel/runtime-corejs3/core-js-stable/parse-int';
|
|
79
81
|
import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
|
|
@@ -101,14 +103,12 @@ import flatMap from 'lodash/flatMap';
|
|
|
101
103
|
import { connect } from 'react-redux';
|
|
102
104
|
import { oneLineTrim } from 'common-tags';
|
|
103
105
|
import warning from 'tiny-warning';
|
|
104
|
-
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
105
106
|
import _Math$trunc from '@babel/runtime-corejs3/core-js-stable/math/trunc';
|
|
106
107
|
import _Number$isNaN from '@babel/runtime-corejs3/core-js-stable/number/is-nan';
|
|
107
108
|
import isUndefined from 'lodash/isUndefined';
|
|
108
109
|
import isFinite from 'lodash/isFinite';
|
|
109
110
|
import Cleave from 'cleave.js/react';
|
|
110
111
|
import _Object$assign from '@babel/runtime-corejs3/core-js-stable/object/assign';
|
|
111
|
-
import _findIndexInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find-index';
|
|
112
112
|
import compact from 'lodash/compact';
|
|
113
113
|
import _Set from '@babel/runtime-corejs3/core-js-stable/set';
|
|
114
114
|
import '@babel/runtime-corejs3/helpers/get';
|
|
@@ -210,7 +210,7 @@ function filterDataAttributes(obj) {
|
|
|
210
210
|
* duplicated in original values
|
|
211
211
|
*/
|
|
212
212
|
function unique(values, properties) {
|
|
213
|
-
var
|
|
213
|
+
var _context2;
|
|
214
214
|
let ignoredValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ['', null, undefined];
|
|
215
215
|
const duplicateValues = [];
|
|
216
216
|
let realValues;
|
|
@@ -219,19 +219,20 @@ function unique(values, properties) {
|
|
|
219
219
|
realValues = _filterInstanceProperty(values).call(values, value => !_includesInstanceProperty(ignoredValues).call(ignoredValues, value));
|
|
220
220
|
if (!realValues.length) return [];
|
|
221
221
|
if (properties) realValues = _mapInstanceProperty(realValues).call(realValues, value => _reduceInstanceProperty(properties).call(properties, (prev, curr) => {
|
|
222
|
+
var _context;
|
|
222
223
|
const currentValue = value[curr] || '';
|
|
223
|
-
return
|
|
224
|
+
return _concatInstanceProperty(_context = "".concat(prev, ":")).call(_context, currentValue);
|
|
224
225
|
}, ''));else realValues = _sliceInstanceProperty(values).call(values, 0);
|
|
225
226
|
|
|
226
227
|
// TODO: checking for dupes like this is slow, find a better way
|
|
227
|
-
_reduceInstanceProperty(
|
|
228
|
+
_reduceInstanceProperty(_context2 = _sortInstanceProperty(realValues).call(realValues)).call(_context2, (prev, curr) => {
|
|
228
229
|
if (curr === null) return curr;
|
|
229
230
|
if (curr !== '' && prev === curr && _indexOfInstanceProperty(duplicateValues).call(duplicateValues, curr) === -1) duplicateValues.push(curr);
|
|
230
231
|
return curr;
|
|
231
232
|
});
|
|
232
233
|
if (properties) return _mapInstanceProperty(duplicateValues).call(duplicateValues, value => {
|
|
233
|
-
var
|
|
234
|
-
const parts = _sliceInstanceProperty(
|
|
234
|
+
var _context3;
|
|
235
|
+
const parts = _sliceInstanceProperty(_context3 = value.split(':')).call(_context3, 1);
|
|
235
236
|
return _reduceInstanceProperty(properties).call(properties, (prev, curr, index) => {
|
|
236
237
|
// eslint-disable-next-line no-param-reassign
|
|
237
238
|
prev[curr] = parts[index];
|
|
@@ -250,14 +251,14 @@ function unique(values, properties) {
|
|
|
250
251
|
* @return Array<Object> returns an array of objects with all duplicated values
|
|
251
252
|
*/
|
|
252
253
|
function uniqueObjects(items) {
|
|
253
|
-
var
|
|
254
|
+
var _context4;
|
|
254
255
|
const emptyValues = [undefined, null, ''];
|
|
255
|
-
const itemsWorkingSet = items && items.length ? _filterInstanceProperty(
|
|
256
|
+
const itemsWorkingSet = items && items.length ? _filterInstanceProperty(_context4 = _sliceInstanceProperty(items).call(items)).call(_context4, x => !_includesInstanceProperty(emptyValues).call(emptyValues, x)) : [];
|
|
256
257
|
const duplicateValues = _reduceInstanceProperty(itemsWorkingSet).call(itemsWorkingSet, (acc, item, index) => {
|
|
257
|
-
var
|
|
258
|
+
var _context5;
|
|
258
259
|
if (item === null) return acc;
|
|
259
|
-
const isDuplicate = _reduceInstanceProperty(
|
|
260
|
-
).call(
|
|
260
|
+
const isDuplicate = _reduceInstanceProperty(_context5 = _sliceInstanceProperty(itemsWorkingSet).call(itemsWorkingSet, index + 1) // get sub-array after this index
|
|
261
|
+
).call(_context5, (duplicateAcc, comparisonItem, comparisonIndex) => {
|
|
261
262
|
if (comparisonItem === null) return duplicateAcc;
|
|
262
263
|
|
|
263
264
|
// check if its a dupe
|
|
@@ -353,18 +354,16 @@ function getIndexesOfInvalidValues(values) {
|
|
|
353
354
|
|
|
354
355
|
const withoutEmptyErrorsByField = errorsByField => omitEmpty(errorsByField);
|
|
355
356
|
|
|
357
|
+
var _templateObject$4;
|
|
356
358
|
function formatDateRangeValue(value, type) {
|
|
357
359
|
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
358
360
|
locale: 'en',
|
|
359
361
|
timeZone: moment.tz.guess()
|
|
360
362
|
};
|
|
361
363
|
if (value.from === value.to) return formatDateTime$1(type, value.from, options);
|
|
362
|
-
if (value.from && value.to) return oneLine
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
`;
|
|
366
|
-
if (value.from) return `from ${formatDateTime$1(type, value.from, options)}`;
|
|
367
|
-
if (value.to) return `to ${formatDateTime$1(type, value.to, options)}`;
|
|
364
|
+
if (value.from && value.to) return oneLine(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteral(["\n ", " -\n ", "\n "])), formatDateTime$1(type, value.from, options), formatDateTime$1(type, value.to, options));
|
|
365
|
+
if (value.from) return "from ".concat(formatDateTime$1(type, value.from, options));
|
|
366
|
+
if (value.to) return "to ".concat(formatDateTime$1(type, value.to, options));
|
|
368
367
|
return '';
|
|
369
368
|
}
|
|
370
369
|
function formatDateTime$1(type, value) {
|
|
@@ -1600,13 +1599,13 @@ const getData = (code, field) => {
|
|
|
1600
1599
|
const getFractionDigit = code => getData(code, 'fractionDigit');
|
|
1601
1600
|
|
|
1602
1601
|
function ownKeys$1q(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1603
|
-
function _objectSpread$1q(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
1602
|
+
function _objectSpread$1q(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$1q(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$1q(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1604
1603
|
function formatMoneyRangeValue(value, intl) {
|
|
1604
|
+
var _context;
|
|
1605
1605
|
if (value.from === value.to) return formatMoneyValue(value.from, value.currency, intl);
|
|
1606
|
-
if (value.from && value.to) return
|
|
1607
|
-
|
|
1608
|
-
if (value.
|
|
1609
|
-
if (value.to) return `to ${formatMoneyValue(value.to, value.currency, intl)}`;
|
|
1606
|
+
if (value.from && value.to) return _concatInstanceProperty(_context = "".concat(formatMoneyValue(value.from, value.currency, intl), " -\n ")).call(_context, formatMoneyValue(value.to, value.currency, intl));
|
|
1607
|
+
if (value.from) return "from ".concat(formatMoneyValue(value.from, value.currency, intl));
|
|
1608
|
+
if (value.to) return "to ".concat(formatMoneyValue(value.to, value.currency, intl));
|
|
1610
1609
|
return '';
|
|
1611
1610
|
}
|
|
1612
1611
|
function formatMoneyValue(amount, currency, intl) {
|
|
@@ -1626,7 +1625,8 @@ function getFractionedAmount(moneyValue) {
|
|
|
1626
1625
|
return amount / 10 ** fractionDigits;
|
|
1627
1626
|
}
|
|
1628
1627
|
function formatMoney$2(moneyValue, intl, options) {
|
|
1629
|
-
|
|
1628
|
+
var _moneyValue$fractione;
|
|
1629
|
+
return intl.formatNumber((_moneyValue$fractione = moneyValue.fractionedAmount) !== null && _moneyValue$fractione !== void 0 ? _moneyValue$fractione : getFractionedAmount(moneyValue), _objectSpread$1q({
|
|
1630
1630
|
style: 'currency',
|
|
1631
1631
|
currency: moneyValue.currencyCode,
|
|
1632
1632
|
minimumFractionDigits: moneyValue.fractionDigits
|
|
@@ -1647,11 +1647,13 @@ var messages$J = defineMessages({
|
|
|
1647
1647
|
});
|
|
1648
1648
|
|
|
1649
1649
|
const formatEnum = _ref => {
|
|
1650
|
+
var _context;
|
|
1650
1651
|
let value = _ref.value,
|
|
1651
1652
|
fallbackValue = _ref.fallbackValue;
|
|
1652
|
-
return value.label ||
|
|
1653
|
+
return value.label || _concatInstanceProperty(_context = "".concat(fallbackValue, " (")).call(_context, value.key, ")");
|
|
1653
1654
|
};
|
|
1654
1655
|
const formatLenum = _ref2 => {
|
|
1656
|
+
var _context2;
|
|
1655
1657
|
let value = _ref2.value,
|
|
1656
1658
|
language = _ref2.language,
|
|
1657
1659
|
languages = _ref2.languages,
|
|
@@ -1659,7 +1661,7 @@ const formatLenum = _ref2 => {
|
|
|
1659
1661
|
return formatLocalizedString(value, {
|
|
1660
1662
|
key: 'label',
|
|
1661
1663
|
locale: language,
|
|
1662
|
-
fallback:
|
|
1664
|
+
fallback: _concatInstanceProperty(_context2 = "".concat(fallbackValue, " (")).call(_context2, value.key, ")"),
|
|
1663
1665
|
fallbackOrder: languages
|
|
1664
1666
|
});
|
|
1665
1667
|
};
|
|
@@ -1695,6 +1697,7 @@ const formatDate = _ref6 => {
|
|
|
1695
1697
|
});
|
|
1696
1698
|
};
|
|
1697
1699
|
const formatDateTime = _ref7 => {
|
|
1700
|
+
var _context3;
|
|
1698
1701
|
let value = _ref7.value,
|
|
1699
1702
|
userTimeZone = _ref7.userTimeZone,
|
|
1700
1703
|
intl = _ref7.intl;
|
|
@@ -1710,7 +1713,7 @@ const formatDateTime = _ref7 => {
|
|
|
1710
1713
|
// defaults to utc if timeZone is not provided
|
|
1711
1714
|
timeZone: userTimeZone || 'utc'
|
|
1712
1715
|
});
|
|
1713
|
-
return
|
|
1716
|
+
return _concatInstanceProperty(_context3 = "".concat(date, " (")).call(_context3, time, ")");
|
|
1714
1717
|
};
|
|
1715
1718
|
const formatBoolean = _ref8 => {
|
|
1716
1719
|
let value = _ref8.value,
|
|
@@ -1733,7 +1736,7 @@ const formatUnknown = _ref10 => {
|
|
|
1733
1736
|
fallbackValue = _ref10.fallbackValue;
|
|
1734
1737
|
// NOTE This is reporting within the render function, which is supposed to
|
|
1735
1738
|
// be pure. This is quite bad as this is a side-effect in the render fn.
|
|
1736
|
-
reportErrorToSentry(new Error(
|
|
1739
|
+
reportErrorToSentry(new Error("Unhandled custom attribute type '".concat(type.name, "' for value")), {
|
|
1737
1740
|
extra: {
|
|
1738
1741
|
value
|
|
1739
1742
|
}
|
|
@@ -1806,9 +1809,10 @@ const attributeTypeNames = {
|
|
|
1806
1809
|
Number: 'number'
|
|
1807
1810
|
};
|
|
1808
1811
|
const convertToAttributeType = customFieldType => {
|
|
1812
|
+
var _customFieldType$elem;
|
|
1809
1813
|
if (isNil$1(customFieldType)) return customFieldType;
|
|
1810
1814
|
const attributeTypeName = attributeTypeNames[customFieldType.name];
|
|
1811
|
-
const elementTypeName = attributeTypeNames[customFieldType.elementType
|
|
1815
|
+
const elementTypeName = attributeTypeNames[(_customFieldType$elem = customFieldType.elementType) === null || _customFieldType$elem === void 0 ? void 0 : _customFieldType$elem.name];
|
|
1812
1816
|
return {
|
|
1813
1817
|
name: attributeTypeName,
|
|
1814
1818
|
elementType: {
|
|
@@ -1871,21 +1875,25 @@ const setDisplayName = nextDisplayName => Component => {
|
|
|
1871
1875
|
return Component;
|
|
1872
1876
|
};
|
|
1873
1877
|
|
|
1874
|
-
const wrapDisplayName = (BaseComponent, hocName) =>
|
|
1878
|
+
const wrapDisplayName = (BaseComponent, hocName) => {
|
|
1879
|
+
var _context;
|
|
1880
|
+
return _concatInstanceProperty(_context = "".concat(hocName, "(")).call(_context, getDisplayName(BaseComponent), ")");
|
|
1881
|
+
};
|
|
1875
1882
|
|
|
1876
1883
|
function ownKeys$1p(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1877
1884
|
function _objectSpread$1p(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$1p(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$1p(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1878
1885
|
const injectDataTablePaginationState = initialValues => Component => {
|
|
1879
1886
|
const WithDataTablePaginationState = props => {
|
|
1887
|
+
var _initialValues$tableS, _initialValues$tableS2;
|
|
1880
1888
|
const _usePaginationState = usePaginationState({
|
|
1881
|
-
page: initialValues
|
|
1882
|
-
perPage: initialValues
|
|
1889
|
+
page: initialValues === null || initialValues === void 0 ? void 0 : initialValues.page,
|
|
1890
|
+
perPage: initialValues === null || initialValues === void 0 ? void 0 : initialValues.perPage
|
|
1883
1891
|
}),
|
|
1884
1892
|
page = _usePaginationState.page,
|
|
1885
1893
|
perPage = _usePaginationState.perPage;
|
|
1886
1894
|
const tableSorting = useDataTableSortingState({
|
|
1887
|
-
key: initialValues
|
|
1888
|
-
order: initialValues
|
|
1895
|
+
key: initialValues === null || initialValues === void 0 || (_initialValues$tableS = initialValues.tableSorting) === null || _initialValues$tableS === void 0 ? void 0 : _initialValues$tableS.key,
|
|
1896
|
+
order: initialValues === null || initialValues === void 0 || (_initialValues$tableS2 = initialValues.tableSorting) === null || _initialValues$tableS2 === void 0 ? void 0 : _initialValues$tableS2.order
|
|
1889
1897
|
});
|
|
1890
1898
|
return jsx(Component, _objectSpread$1p(_objectSpread$1p({}, props), {}, {
|
|
1891
1899
|
dataTablePaginationState: {
|
|
@@ -1919,7 +1927,7 @@ const injectNotifications = function () {
|
|
|
1919
1927
|
[propName]: notifications
|
|
1920
1928
|
}));
|
|
1921
1929
|
};
|
|
1922
|
-
WrappedComponent.displayName =
|
|
1930
|
+
WrappedComponent.displayName = "withNotifications(".concat(getDisplayName(Component));
|
|
1923
1931
|
return WrappedComponent;
|
|
1924
1932
|
};
|
|
1925
1933
|
};
|
|
@@ -2028,7 +2036,10 @@ const isNil = value => typeof value === 'undefined' || value === null;
|
|
|
2028
2036
|
const useStorage = (storageKey, initialStorageValue, options) => {
|
|
2029
2037
|
var _context;
|
|
2030
2038
|
const mergedOptions = _objectSpread$1j(_objectSpread$1j({}, defaultOptions$2), options);
|
|
2031
|
-
const userId = useApplicationContext(context =>
|
|
2039
|
+
const userId = useApplicationContext(context => {
|
|
2040
|
+
var _context$user;
|
|
2041
|
+
return (_context$user = context.user) === null || _context$user === void 0 ? void 0 : _context$user.id;
|
|
2042
|
+
});
|
|
2032
2043
|
const scopedStorageKey = _filterInstanceProperty(_context = [mergedOptions.segregateByUser && userId, storageKey]).call(_context, Boolean).join('/');
|
|
2033
2044
|
const readFromStorage = useCallback(() => {
|
|
2034
2045
|
const rawStorageValue = getStorage(mergedOptions.storageType).getItem(scopedStorageKey);
|
|
@@ -2047,8 +2058,9 @@ const useStorage = (storageKey, initialStorageValue, options) => {
|
|
|
2047
2058
|
return parsedStorageValue;
|
|
2048
2059
|
}, [mergedOptions.storageType, scopedStorageKey]);
|
|
2049
2060
|
const initializeStorageValue = () => {
|
|
2061
|
+
var _ref, _readFromStorage;
|
|
2050
2062
|
// default the storage value to the initial provided value when provided
|
|
2051
|
-
return readFromStorage()
|
|
2063
|
+
return (_ref = (_readFromStorage = readFromStorage()) !== null && _readFromStorage !== void 0 ? _readFromStorage : initialStorageValue) !== null && _ref !== void 0 ? _ref : null;
|
|
2052
2064
|
};
|
|
2053
2065
|
const _useState = useState(initializeStorageValue),
|
|
2054
2066
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -2147,14 +2159,16 @@ function ownKeys$1h(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertyS
|
|
|
2147
2159
|
function _objectSpread$1h(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$1h(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$1h(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2148
2160
|
var FetchStoresQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchStoresQuery" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "limit" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "offset" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "sort" } }, type: { kind: "ListType", type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "where" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "excludeExtendedStoresList" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "excludeProductSelections" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "stores" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "limit" }, value: { kind: "Variable", name: { kind: "Name", value: "limit" } } }, { kind: "Argument", name: { kind: "Name", value: "offset" }, value: { kind: "Variable", name: { kind: "Name", value: "offset" } } }, { kind: "Argument", name: { kind: "Name", value: "sort" }, value: { kind: "Variable", name: { kind: "Name", value: "sort" } } }, { kind: "Argument", name: { kind: "Name", value: "where" }, value: { kind: "Variable", name: { kind: "Name", value: "where" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "count" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "offset" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "StoreBasicInfo" }, directives: [] }, { kind: "Field", name: { kind: "Name", value: "countries" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "code" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "languages" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "skip" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "excludeExtendedStoresList" } } }] }] }, { kind: "Field", name: { kind: "Name", value: "distributionChannelsRef" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "distributionChannels" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "skip" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "excludeExtendedStoresList" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "supplyChannels" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "skip" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "excludeExtendedStoresList" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "productSelections" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "skip" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "excludeProductSelections" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "active" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "productSelection" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "mode" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }] } }, { kind: "FragmentDefinition", name: { kind: "Name", value: "StoreBasicInfo" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "Store" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "version" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "createdAt" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "lastModifiedAt" }, arguments: [], directives: [] }] } }], loc: { start: 0, end: 1089, source: { body: "#import '../../utils/graphql/fragments/store-basic-info.ctp.graphql'\n\nquery FetchStoresQuery(\n $limit: Int\n $offset: Int\n $sort: [String!]\n $where: String\n $excludeExtendedStoresList: Boolean!\n $excludeProductSelections: Boolean!\n) {\n stores(limit: $limit, offset: $offset, sort: $sort, where: $where) {\n total\n count\n offset\n results {\n ...StoreBasicInfo\n countries {\n code\n }\n languages @skip(if: $excludeExtendedStoresList)\n distributionChannelsRef {\n id\n }\n distributionChannels @skip(if: $excludeExtendedStoresList) {\n id\n key\n nameAllLocales {\n locale\n value\n }\n }\n supplyChannels @skip(if: $excludeExtendedStoresList) {\n id\n key\n nameAllLocales {\n locale\n value\n }\n }\n productSelections @skip(if: $excludeProductSelections) {\n active\n productSelection {\n id\n mode\n nameAllLocales {\n locale\n value\n }\n }\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
2149
2161
|
const filterStoresOutdatedDanglingProductSelections = storesQueryResult => {
|
|
2162
|
+
var _storesQueryResult$re;
|
|
2150
2163
|
if (!storesQueryResult) return null;
|
|
2151
2164
|
return {
|
|
2152
2165
|
total: storesQueryResult.total,
|
|
2153
2166
|
count: storesQueryResult.count,
|
|
2154
2167
|
offset: storesQueryResult.offset,
|
|
2155
|
-
results: storesQueryResult.results
|
|
2168
|
+
results: (_storesQueryResult$re = storesQueryResult.results) === null || _storesQueryResult$re === void 0 ? void 0 : _mapInstanceProperty(_storesQueryResult$re).call(_storesQueryResult$re, store => {
|
|
2169
|
+
var _store$productSelecti;
|
|
2156
2170
|
return _objectSpread$1h(_objectSpread$1h({}, store), {}, {
|
|
2157
|
-
productSelections: store.productSelections
|
|
2171
|
+
productSelections: (_store$productSelecti = store.productSelections) === null || _store$productSelecti === void 0 ? void 0 : _filterInstanceProperty(_store$productSelecti).call(_store$productSelecti, productSelectionRef => Boolean(productSelectionRef.productSelection))
|
|
2158
2172
|
});
|
|
2159
2173
|
})
|
|
2160
2174
|
};
|
|
@@ -2166,7 +2180,7 @@ const createQueryVariables$6 = ownProps => {
|
|
|
2166
2180
|
offset: ownProps.offset,
|
|
2167
2181
|
sort: _sortInstanceProperty(ownProps)
|
|
2168
2182
|
}, Boolean(ownProps.stores) && {
|
|
2169
|
-
where:
|
|
2183
|
+
where: "key in (".concat(_mapInstanceProperty(_context = ownProps.stores).call(_context, store => "\"".concat(store, "\"")).join(', '), ")")
|
|
2170
2184
|
}), {}, {
|
|
2171
2185
|
excludeExtendedStoresList: ownProps.excludeExtendedStoresList,
|
|
2172
2186
|
excludeProductSelections: ownProps.excludeProductSelections
|
|
@@ -2191,7 +2205,10 @@ const useStoresListFetcher = props => {
|
|
|
2191
2205
|
projectKey: props.projectKey
|
|
2192
2206
|
},
|
|
2193
2207
|
fetchPolicy: 'network-only',
|
|
2194
|
-
onError: graphqlErrorResponse =>
|
|
2208
|
+
onError: graphqlErrorResponse => {
|
|
2209
|
+
var _props$onError;
|
|
2210
|
+
return (_props$onError = props.onError) === null || _props$onError === void 0 ? void 0 : _props$onError.call(props, graphqlErrorResponse);
|
|
2211
|
+
}
|
|
2195
2212
|
}),
|
|
2196
2213
|
data = _useQuery.data,
|
|
2197
2214
|
refetch = _useQuery.refetch,
|
|
@@ -2199,7 +2216,7 @@ const useStoresListFetcher = props => {
|
|
|
2199
2216
|
return {
|
|
2200
2217
|
isLoading: loading,
|
|
2201
2218
|
refetch,
|
|
2202
|
-
stores: filterStoresOutdatedDanglingProductSelections(data
|
|
2219
|
+
stores: filterStoresOutdatedDanglingProductSelections(data === null || data === void 0 ? void 0 : data.stores),
|
|
2203
2220
|
refetchQuery: {
|
|
2204
2221
|
query: FetchStoresQuery,
|
|
2205
2222
|
variables: queryVariables,
|
|
@@ -2263,10 +2280,16 @@ const handlers$5 = {
|
|
|
2263
2280
|
}
|
|
2264
2281
|
};
|
|
2265
2282
|
|
|
2266
|
-
const toPermission = (permission, resourceName) =>
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2283
|
+
const toPermission = (permission, resourceName) => {
|
|
2284
|
+
var _context;
|
|
2285
|
+
return camelCase(_concatInstanceProperty(_context = "can ".concat(permission, " ")).call(_context, resourceName));
|
|
2286
|
+
};
|
|
2287
|
+
const createComposePath = resourceName => permission => {
|
|
2288
|
+
var _context2;
|
|
2289
|
+
return (// e.g applicationContext.dataFences?.store?.orders?.canViewOrders?.values
|
|
2290
|
+
_concatInstanceProperty(_context2 = "dataFences.store.".concat(resourceName, ".")).call(_context2, permission, ".values")
|
|
2291
|
+
);
|
|
2292
|
+
};
|
|
2270
2293
|
const useStoreKeysInDataFences = _ref => {
|
|
2271
2294
|
let resourceName = _ref.resourceName,
|
|
2272
2295
|
_ref$permission = _ref.permission,
|
|
@@ -2664,7 +2687,7 @@ const usePersistedTableConfiguration = props => {
|
|
|
2664
2687
|
* Therefore, if it will be missing from the local storage and hence we use the [] as default.
|
|
2665
2688
|
*/
|
|
2666
2689
|
const getVisibleColumns = useCallback(() => {
|
|
2667
|
-
if (cachedVisibleTableConfiguration
|
|
2690
|
+
if (cachedVisibleTableConfiguration !== null && cachedVisibleTableConfiguration !== void 0 && cachedVisibleTableConfiguration.columnsConfig) {
|
|
2668
2691
|
return retrieveColumnsWithCachedConfiguration({
|
|
2669
2692
|
allAvailableColumnsConfiguration,
|
|
2670
2693
|
cachedVisibleTableConfiguration: cachedVisibleTableConfiguration.columnsConfig,
|
|
@@ -2678,8 +2701,8 @@ const usePersistedTableConfiguration = props => {
|
|
|
2678
2701
|
return {
|
|
2679
2702
|
visibleColumns,
|
|
2680
2703
|
visibleColumnKeys,
|
|
2681
|
-
cachedVisibleColumnsConfiguration: cachedVisibleTableConfiguration
|
|
2682
|
-
cachedDisplaySettings: cachedVisibleTableConfiguration
|
|
2704
|
+
cachedVisibleColumnsConfiguration: cachedVisibleTableConfiguration === null || cachedVisibleTableConfiguration === void 0 ? void 0 : cachedVisibleTableConfiguration.columnsConfig,
|
|
2705
|
+
cachedDisplaySettings: cachedVisibleTableConfiguration === null || cachedVisibleTableConfiguration === void 0 ? void 0 : cachedVisibleTableConfiguration.displaySettings,
|
|
2683
2706
|
handleCachedTableConfigurationUpdate: update => handleCacheUpdate({
|
|
2684
2707
|
update,
|
|
2685
2708
|
cachedVisibleTableConfiguration,
|
|
@@ -2690,6 +2713,7 @@ const usePersistedTableConfiguration = props => {
|
|
|
2690
2713
|
|
|
2691
2714
|
var FetchProductSelectionsTotal = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchProductSelectionsTotal" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "productSelections" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 74, source: { body: "query FetchProductSelectionsTotal {\n productSelections {\n total\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
2692
2715
|
const useProductSelectionsTotalFetcher = props => {
|
|
2716
|
+
var _data$productSelectio;
|
|
2693
2717
|
const _useQuery = useQuery$1(FetchProductSelectionsTotal, {
|
|
2694
2718
|
context: {
|
|
2695
2719
|
target: GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM
|
|
@@ -2699,7 +2723,7 @@ const useProductSelectionsTotalFetcher = props => {
|
|
|
2699
2723
|
data = _useQuery.data;
|
|
2700
2724
|
return {
|
|
2701
2725
|
isLoading: loading,
|
|
2702
|
-
total: data
|
|
2726
|
+
total: data === null || data === void 0 || (_data$productSelectio = data.productSelections) === null || _data$productSelectio === void 0 ? void 0 : _data$productSelectio.total
|
|
2703
2727
|
};
|
|
2704
2728
|
};
|
|
2705
2729
|
|
|
@@ -2720,7 +2744,7 @@ function _objectSpread$1d(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
|
2720
2744
|
// eslint-disable-next-line import/prefer-default-export
|
|
2721
2745
|
const convertProductSelectionsFromGraphQl = productSelections => {
|
|
2722
2746
|
var _context;
|
|
2723
|
-
return productSelections
|
|
2747
|
+
return (productSelections === null || productSelections === void 0 ? void 0 : productSelections.results) && _objectSpread$1d(_objectSpread$1d({}, productSelections), {}, {
|
|
2724
2748
|
results: _mapInstanceProperty(_context = productSelections.results).call(_context, productSelection => _objectSpread$1d({}, applyTransformedLocalizedFields(productSelection, [{
|
|
2725
2749
|
from: 'nameAllLocales',
|
|
2726
2750
|
to: 'name'
|
|
@@ -2754,7 +2778,7 @@ const useProductSelectionsFetcher = props => {
|
|
|
2754
2778
|
refetch = _useQuery.refetch;
|
|
2755
2779
|
return {
|
|
2756
2780
|
isLoading: loading,
|
|
2757
|
-
productSelections: convertProductSelectionsFromGraphQl(data
|
|
2781
|
+
productSelections: convertProductSelectionsFromGraphQl(data === null || data === void 0 ? void 0 : data.productSelections) || emptyProductSelections,
|
|
2758
2782
|
refetch
|
|
2759
2783
|
};
|
|
2760
2784
|
};
|
|
@@ -2779,6 +2803,7 @@ function validateSingleFilter(_ref) {
|
|
|
2779
2803
|
return _includesInstanceProperty(invalidValues).call(invalidValues, value);
|
|
2780
2804
|
}
|
|
2781
2805
|
|
|
2806
|
+
var _templateObject$3, _templateObject2$2;
|
|
2782
2807
|
const dateFormatDayStart$1 = 'YYYY-MM-DDT00:00:00.000';
|
|
2783
2808
|
const dateFormatDayEnd$1 = 'YYYY-MM-DDT23:59:59.999';
|
|
2784
2809
|
const getDateTimeInUTC = (date, timezone, format) => {
|
|
@@ -2788,7 +2813,8 @@ const getDateTimeInUTC = (date, timezone, format) => {
|
|
|
2788
2813
|
const noTimeSpecified = momentDate.hours() === 0 && momentDate.minutes() === 0 && momentDate.seconds() === 0;
|
|
2789
2814
|
// if it's a date then convert it to UTC datetime based on timezone
|
|
2790
2815
|
if (noTimeSpecified) {
|
|
2791
|
-
|
|
2816
|
+
var _moment$tz;
|
|
2817
|
+
const offset = ((_moment$tz = moment$1(date).tz(timezone)) === null || _moment$tz === void 0 ? void 0 : _moment$tz.utcOffset()) || 0;
|
|
2792
2818
|
const formattedDate = momentDate.format(format);
|
|
2793
2819
|
const formattedDateWithOffset = moment$1(formattedDate).add(offset, 'minutes').format(dateFormat);
|
|
2794
2820
|
// console.log(formattedDateWithOffset);
|
|
@@ -2801,6 +2827,7 @@ const getDateTimeInUTC = (date, timezone, format) => {
|
|
|
2801
2827
|
function dateTransformer$1(filterKey, filters) {
|
|
2802
2828
|
let filterValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultFilterValidator$1;
|
|
2803
2829
|
const queries = _mapInstanceProperty(filters).call(filters, _ref => {
|
|
2830
|
+
var _context, _context2;
|
|
2804
2831
|
let type = _ref.type,
|
|
2805
2832
|
value = _ref.value,
|
|
2806
2833
|
timezone = _ref.timezone;
|
|
@@ -2810,19 +2837,13 @@ function dateTransformer$1(filterKey, filters) {
|
|
|
2810
2837
|
})) return '';
|
|
2811
2838
|
switch (type) {
|
|
2812
2839
|
case FILTER_TYPES.lessThan:
|
|
2813
|
-
return
|
|
2840
|
+
return _concatInstanceProperty(_context = "".concat(filterKey, " < \"")).call(_context, getDateTimeInUTC(value, timezone, dateFormatDayStart$1), "\"");
|
|
2814
2841
|
case FILTER_TYPES.moreThan:
|
|
2815
|
-
return
|
|
2842
|
+
return _concatInstanceProperty(_context2 = "".concat(filterKey, " > \"")).call(_context2, getDateTimeInUTC(value, timezone, dateFormatDayEnd$1), "\"");
|
|
2816
2843
|
case FILTER_TYPES.equalTo:
|
|
2817
|
-
return oneLine
|
|
2818
|
-
(${filterKey} >= "${getDateTimeInUTC(value, timezone, dateFormatDayStart$1)}"
|
|
2819
|
-
and ${filterKey} <= "${getDateTimeInUTC(value, timezone, dateFormatDayEnd$1)}")
|
|
2820
|
-
`;
|
|
2844
|
+
return oneLine(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n (", " >= \"", "\"\n and ", " <= \"", "\")\n "])), filterKey, getDateTimeInUTC(value, timezone, dateFormatDayStart$1), filterKey, getDateTimeInUTC(value, timezone, dateFormatDayEnd$1));
|
|
2821
2845
|
case FILTER_TYPES.range:
|
|
2822
|
-
return oneLine
|
|
2823
|
-
(${filterKey} >= "${getDateTimeInUTC(value.from, timezone, dateFormatDayStart$1)}"
|
|
2824
|
-
and ${filterKey} <= "${getDateTimeInUTC(value.to, timezone, dateFormatDayEnd$1)}")
|
|
2825
|
-
`;
|
|
2846
|
+
return oneLine(_templateObject2$2 || (_templateObject2$2 = _taggedTemplateLiteral(["\n (", " >= \"", "\"\n and ", " <= \"", "\")\n "])), filterKey, getDateTimeInUTC(value.from, timezone, dateFormatDayStart$1), filterKey, getDateTimeInUTC(value.to, timezone, dateFormatDayEnd$1));
|
|
2826
2847
|
default:
|
|
2827
2848
|
return '';
|
|
2828
2849
|
}
|
|
@@ -2838,7 +2859,7 @@ function dateTransformer$1(filterKey, filters) {
|
|
|
2838
2859
|
* (createdAt >= "2018-02-15T00:00:00.000+01:00" and createdAt <= "2018-02-15T23:59:59.999+01:00")
|
|
2839
2860
|
* ) or some_more_filters
|
|
2840
2861
|
*/
|
|
2841
|
-
return queryString === '' ? null :
|
|
2862
|
+
return queryString === '' ? null : "(".concat(queryString, ")");
|
|
2842
2863
|
}
|
|
2843
2864
|
function defaultFilterValidator$1(_ref2) {
|
|
2844
2865
|
let type = _ref2.type,
|
|
@@ -2854,7 +2875,10 @@ function defaultFilterValidator$1(_ref2) {
|
|
|
2854
2875
|
|
|
2855
2876
|
var localizedTextTransformer = (localizedString => {
|
|
2856
2877
|
var _context;
|
|
2857
|
-
return _mapInstanceProperty(_context = _Object$keys(localizedString)).call(_context, locale =>
|
|
2878
|
+
return _mapInstanceProperty(_context = _Object$keys(localizedString)).call(_context, locale => {
|
|
2879
|
+
var _context2;
|
|
2880
|
+
return _concatInstanceProperty(_context2 = "".concat(locale, " = \"")).call(_context2, localizedString[locale], "\"");
|
|
2881
|
+
}).join(' and ');
|
|
2858
2882
|
});
|
|
2859
2883
|
|
|
2860
2884
|
var styles$j = {
|
|
@@ -2902,8 +2926,9 @@ function _objectSpread$1c(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
|
2902
2926
|
var GetChannelsQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "GetChannelsQuery" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "where" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "sortByNamePath" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "channels" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "where" }, value: { kind: "Variable", name: { kind: "Name", value: "where" } } }, { kind: "Argument", name: { kind: "Name", value: "sort" }, value: { kind: "ListValue", values: [{ kind: "Variable", name: { kind: "Name", value: "sortByNamePath" } }, { kind: "StringValue", value: "key", block: false }] } }, { kind: "Argument", name: { kind: "Name", value: "limit" }, value: { kind: "IntValue", value: "60" } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "PickerInputChannel" }, directives: [] }] } }] } }] } }, { kind: "FragmentDefinition", name: { kind: "Name", value: "PickerInputChannel" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "Channel" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 392, source: { body: "fragment PickerInputChannel on Channel {\n id\n key\n nameAllLocales {\n locale\n value\n }\n}\n\nquery GetChannelsQuery($where: String, $sortByNamePath: String!) {\n channels(where: $where, sort: [$sortByNamePath, \"key\"], limit: 60) {\n total\n results {\n ...PickerInputChannel\n }\n }\n}\n\nquery GetChannelQuery($id: String) {\n channel(id: $id) {\n ...PickerInputChannel\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
2903
2927
|
var GetChannelQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "GetChannelQuery" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "id" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "channel" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "id" }, value: { kind: "Variable", name: { kind: "Name", value: "id" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "PickerInputChannel" }, directives: [] }] } }] } }, { kind: "FragmentDefinition", name: { kind: "Name", value: "PickerInputChannel" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "Channel" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 392, source: { body: "fragment PickerInputChannel on Channel {\n id\n key\n nameAllLocales {\n locale\n value\n }\n}\n\nquery GetChannelsQuery($where: String, $sortByNamePath: String!) {\n channels(where: $where, sort: [$sortByNamePath, \"key\"], limit: 60) {\n total\n results {\n ...PickerInputChannel\n }\n }\n}\n\nquery GetChannelQuery($id: String) {\n channel(id: $id) {\n ...PickerInputChannel\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
2904
2928
|
var PickerInputChannel = { kind: "Document", definitions: [{ kind: "FragmentDefinition", name: { kind: "Name", value: "PickerInputChannel" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "Channel" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 392, source: { body: "fragment PickerInputChannel on Channel {\n id\n key\n nameAllLocales {\n locale\n value\n }\n}\n\nquery GetChannelsQuery($where: String, $sortByNamePath: String!) {\n channels(where: $where, sort: [$sortByNamePath, \"key\"], limit: 60) {\n total\n results {\n ...PickerInputChannel\n }\n }\n}\n\nquery GetChannelQuery($id: String) {\n channel(id: $id) {\n ...PickerInputChannel\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
2905
|
-
const getRolesClause = roles => roles && roles.length > 0 ?
|
|
2929
|
+
const getRolesClause = roles => roles && roles.length > 0 ? "roles contains any (".concat(_mapInstanceProperty(roles).call(roles, role => "\"".concat(role, "\"")).join(','), ")") : undefined;
|
|
2906
2930
|
const ChannelPickerInput = _ref => {
|
|
2931
|
+
var _currentOption$data$l, _currentOption$data;
|
|
2907
2932
|
let isClearable = _ref.isClearable,
|
|
2908
2933
|
isDisabled = _ref.isDisabled,
|
|
2909
2934
|
isReadOnly = _ref.isReadOnly,
|
|
@@ -2923,7 +2948,7 @@ const ChannelPickerInput = _ref => {
|
|
|
2923
2948
|
const variables = useMemo(() => {
|
|
2924
2949
|
const rolesClause = getRolesClause(roles);
|
|
2925
2950
|
return _objectSpread$1c({
|
|
2926
|
-
sortByNamePath:
|
|
2951
|
+
sortByNamePath: "name.".concat(dataLocale)
|
|
2927
2952
|
}, rolesClause && {
|
|
2928
2953
|
extraWhere: rolesClause
|
|
2929
2954
|
});
|
|
@@ -2944,7 +2969,7 @@ const ChannelPickerInput = _ref => {
|
|
|
2944
2969
|
}
|
|
2945
2970
|
return channel;
|
|
2946
2971
|
}, [formatLocalizedFieldToString]);
|
|
2947
|
-
const prefixSearchFields = useMemo(() => [
|
|
2972
|
+
const prefixSearchFields = useMemo(() => ["name.".concat(dataLocale), 'key'], [dataLocale]);
|
|
2948
2973
|
const loadOptions = useLoadOptions({
|
|
2949
2974
|
query: GetChannelsQuery,
|
|
2950
2975
|
variables,
|
|
@@ -2979,13 +3004,13 @@ const ChannelPickerInput = _ref => {
|
|
|
2979
3004
|
setLoadingError(null);
|
|
2980
3005
|
handleInternalInputChange(event);
|
|
2981
3006
|
}, [handleInternalInputChange]);
|
|
2982
|
-
const isCurrentOptionLoadingFailed = Boolean(currentOption
|
|
3007
|
+
const isCurrentOptionLoadingFailed = Boolean(currentOption === null || currentOption === void 0 ? void 0 : currentOption.error);
|
|
2983
3008
|
useEffect(() => {
|
|
2984
3009
|
if (isCurrentOptionLoadingFailed) onError(currentOption.error);
|
|
2985
3010
|
}, [isCurrentOptionLoadingFailed, onError, currentOption]);
|
|
2986
3011
|
const isLoadingFailed = isCurrentOptionLoadingFailed || Boolean(loadingError);
|
|
2987
3012
|
const handleNoOptions = useCallback(() => loadingError ? null : formatMessage(messages$G.noChannelsFound), [loadingError, formatMessage]);
|
|
2988
|
-
const tooltipTitle = currentOption
|
|
3013
|
+
const tooltipTitle = (_currentOption$data$l = currentOption === null || currentOption === void 0 || (_currentOption$data = currentOption.data) === null || _currentOption$data === void 0 ? void 0 : _currentOption$data.label) !== null && _currentOption$data$l !== void 0 ? _currentOption$data$l : '';
|
|
2989
3014
|
return jsx(Constraints.Horizontal, {
|
|
2990
3015
|
max: "scale",
|
|
2991
3016
|
children: jsxs(Spacings.Stack, {
|
|
@@ -2995,7 +3020,7 @@ const ChannelPickerInput = _ref => {
|
|
|
2995
3020
|
children: jsx(AsyncSelectInput, {
|
|
2996
3021
|
id: name,
|
|
2997
3022
|
name: name,
|
|
2998
|
-
placeholder: placeholder
|
|
3023
|
+
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : formatMessage(messages$G.placeholder),
|
|
2999
3024
|
loadOptions: loadOptionsDebounced,
|
|
3000
3025
|
defaultOptions: true,
|
|
3001
3026
|
showOptionGroupDivider: true,
|
|
@@ -3039,26 +3064,26 @@ function _callSuper$9(_this, derived, args) {
|
|
|
3039
3064
|
return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? _Reflect$construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
|
|
3040
3065
|
}
|
|
3041
3066
|
let FormattedDateTime = /*#__PURE__*/function (_PureComponent) {
|
|
3042
|
-
_inherits(FormattedDateTime, _PureComponent);
|
|
3043
3067
|
function FormattedDateTime() {
|
|
3044
3068
|
_classCallCheck(this, FormattedDateTime);
|
|
3045
3069
|
return _callSuper$9(this, FormattedDateTime, arguments);
|
|
3046
3070
|
}
|
|
3047
|
-
|
|
3071
|
+
_inherits(FormattedDateTime, _PureComponent);
|
|
3072
|
+
return _createClass(FormattedDateTime, [{
|
|
3048
3073
|
key: "render",
|
|
3049
3074
|
value: function render() {
|
|
3050
3075
|
return jsx(ApplicationContext, {
|
|
3051
3076
|
render: _ref => {
|
|
3077
|
+
var _this$props;
|
|
3052
3078
|
let user = _ref.user;
|
|
3053
3079
|
return formatDateTime$1(this.props.type, this.props.value, {
|
|
3054
|
-
timeZone: this
|
|
3080
|
+
timeZone: (this === null || this === void 0 || (_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.timeZone) || (user === null || user === void 0 ? void 0 : user.timeZone),
|
|
3055
3081
|
locale: this.props.intl.locale
|
|
3056
3082
|
});
|
|
3057
3083
|
}
|
|
3058
3084
|
});
|
|
3059
3085
|
}
|
|
3060
3086
|
}]);
|
|
3061
|
-
return FormattedDateTime;
|
|
3062
3087
|
}(PureComponent);
|
|
3063
3088
|
FormattedDateTime.displayName = 'FormattedDateTime';
|
|
3064
3089
|
var FormattedDateTime$1 = injectIntl(FormattedDateTime);
|
|
@@ -3083,25 +3108,25 @@ function _callSuper$8(_this, derived, args) {
|
|
|
3083
3108
|
}
|
|
3084
3109
|
const withMouseOverState = BaseComponent => {
|
|
3085
3110
|
let WithMouseOverState = /*#__PURE__*/function (_Component) {
|
|
3086
|
-
_inherits(WithMouseOverState, _Component);
|
|
3087
3111
|
function WithMouseOverState() {
|
|
3088
|
-
var
|
|
3112
|
+
var _this2;
|
|
3089
3113
|
_classCallCheck(this, WithMouseOverState);
|
|
3090
3114
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3091
3115
|
args[_key] = arguments[_key];
|
|
3092
3116
|
}
|
|
3093
|
-
|
|
3094
|
-
|
|
3117
|
+
_this2 = _callSuper$8(this, WithMouseOverState, [...args]);
|
|
3118
|
+
_this2.state = {
|
|
3095
3119
|
isMouseOver: false
|
|
3096
3120
|
};
|
|
3097
|
-
|
|
3121
|
+
_this2.setMouseOver = nextMouseOver => _this2.setState({
|
|
3098
3122
|
isMouseOver: nextMouseOver
|
|
3099
3123
|
});
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
return
|
|
3124
|
+
_this2.handleMouseOver = () => _this2.setMouseOver(true);
|
|
3125
|
+
_this2.handleMouseOut = () => _this2.setMouseOver(false);
|
|
3126
|
+
return _this2;
|
|
3103
3127
|
}
|
|
3104
|
-
|
|
3128
|
+
_inherits(WithMouseOverState, _Component);
|
|
3129
|
+
return _createClass(WithMouseOverState, [{
|
|
3105
3130
|
key: "render",
|
|
3106
3131
|
value: function render() {
|
|
3107
3132
|
const injectedProps = {
|
|
@@ -3112,7 +3137,6 @@ const withMouseOverState = BaseComponent => {
|
|
|
3112
3137
|
return jsx(BaseComponent, _objectSpread$1b({}, _objectSpread$1b(_objectSpread$1b({}, this.props), injectedProps)));
|
|
3113
3138
|
}
|
|
3114
3139
|
}]);
|
|
3115
|
-
return WithMouseOverState;
|
|
3116
3140
|
}(Component);
|
|
3117
3141
|
WithMouseOverState.displayName = wrapDisplayName(BaseComponent, 'withMouseOverState');
|
|
3118
3142
|
return WithMouseOverState;
|
|
@@ -3147,74 +3171,74 @@ var styles$i = {
|
|
|
3147
3171
|
"granular": "throttled-field-module__granular___2LXJf"
|
|
3148
3172
|
};
|
|
3149
3173
|
let ThrottledField = /*#__PURE__*/function (_PureComponent) {
|
|
3150
|
-
_inherits(ThrottledField, _PureComponent);
|
|
3151
3174
|
function ThrottledField() {
|
|
3152
|
-
var
|
|
3175
|
+
var _this2;
|
|
3153
3176
|
_classCallCheck(this, ThrottledField);
|
|
3154
3177
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3155
3178
|
args[_key] = arguments[_key];
|
|
3156
3179
|
}
|
|
3157
|
-
|
|
3158
|
-
|
|
3180
|
+
_this2 = _callSuper$7(this, ThrottledField, [...args]);
|
|
3181
|
+
_this2.state = {
|
|
3159
3182
|
draftValue: '',
|
|
3160
3183
|
prevValue: ''
|
|
3161
3184
|
};
|
|
3162
|
-
|
|
3163
|
-
clearTimeout(
|
|
3164
|
-
clearTimeout(
|
|
3165
|
-
|
|
3166
|
-
|
|
3185
|
+
_this2.clearPendingUpdates = () => {
|
|
3186
|
+
clearTimeout(_this2.changeTimeout);
|
|
3187
|
+
clearTimeout(_this2.blurTimeout);
|
|
3188
|
+
_this2.changeTimeout = null;
|
|
3189
|
+
_this2.blurTimeout = null;
|
|
3167
3190
|
};
|
|
3168
|
-
|
|
3191
|
+
_this2.handleChange = event => {
|
|
3169
3192
|
// The `SyntheticEvent` is pooled by default for perf reasons.
|
|
3170
3193
|
// See https://facebook.github.io/react/docs/events.html#event-pooling
|
|
3171
3194
|
// To access the event in an async way we need to persist it.
|
|
3172
3195
|
event.persist();
|
|
3173
|
-
|
|
3196
|
+
_this2.setState({
|
|
3174
3197
|
draftValue: event.target.value
|
|
3175
3198
|
});
|
|
3176
|
-
|
|
3199
|
+
_this2.doDelayedUpdate(_this2.props.onChange, event, 'change');
|
|
3177
3200
|
};
|
|
3178
|
-
|
|
3201
|
+
_this2.handleEnter = event => {
|
|
3179
3202
|
if (event.keyCode !== 13) return;
|
|
3180
|
-
if (
|
|
3203
|
+
if (_this2.changeTimeout) {
|
|
3181
3204
|
// Since there are still are some pending updates that are not sent to the
|
|
3182
3205
|
// parent yet we need to call the update here explicitly and clear the
|
|
3183
3206
|
// pending updates
|
|
3184
|
-
|
|
3207
|
+
_this2.props.onChange({
|
|
3185
3208
|
target: {
|
|
3186
|
-
value:
|
|
3209
|
+
value: _this2.state.draftValue
|
|
3187
3210
|
}
|
|
3188
3211
|
});
|
|
3189
3212
|
// we can savely clear the timeout and thus abort all pending changes
|
|
3190
3213
|
// because we just update the parent with the current state
|
|
3191
|
-
clearTimeout(
|
|
3192
|
-
|
|
3214
|
+
clearTimeout(_this2.changeTimeout);
|
|
3215
|
+
_this2.changeTimeout = null;
|
|
3193
3216
|
}
|
|
3194
|
-
|
|
3217
|
+
_this2.props.onEnter(_this2.state.draftValue);
|
|
3195
3218
|
};
|
|
3196
|
-
|
|
3219
|
+
_this2.handleBlur = event => {
|
|
3197
3220
|
// The `SyntheticEvent` is pooled by default for perf reasons.
|
|
3198
3221
|
// See https://facebook.github.io/react/docs/events.html#event-pooling
|
|
3199
3222
|
// To access the event in an async way we need to persist it.
|
|
3200
|
-
if (
|
|
3223
|
+
if (_this2.props.onBlurValue) {
|
|
3201
3224
|
event.persist();
|
|
3202
|
-
|
|
3225
|
+
_this2.doDelayedUpdate(e => _this2.props.onBlurValue(e.target.value), event, 'blur');
|
|
3203
3226
|
}
|
|
3204
3227
|
};
|
|
3205
|
-
|
|
3206
|
-
const self =
|
|
3207
|
-
const timeoutKey =
|
|
3228
|
+
_this2.doDelayedUpdate = (updateFunction, event, eventType) => {
|
|
3229
|
+
const self = _this2;
|
|
3230
|
+
const timeoutKey = "".concat(eventType, "Timeout");
|
|
3208
3231
|
// TODO: can't we just use one variable?
|
|
3209
|
-
clearTimeout(
|
|
3210
|
-
|
|
3232
|
+
clearTimeout(_this2[timeoutKey]);
|
|
3233
|
+
_this2[timeoutKey] = _setTimeout(() => {
|
|
3211
3234
|
updateFunction.call(self, event);
|
|
3212
|
-
|
|
3213
|
-
},
|
|
3235
|
+
_this2[timeoutKey] = null;
|
|
3236
|
+
}, _this2.props.throttleMS);
|
|
3214
3237
|
};
|
|
3215
|
-
return
|
|
3238
|
+
return _this2;
|
|
3216
3239
|
}
|
|
3217
|
-
|
|
3240
|
+
_inherits(ThrottledField, _PureComponent);
|
|
3241
|
+
return _createClass(ThrottledField, [{
|
|
3218
3242
|
key: "componentWillUnmount",
|
|
3219
3243
|
value: function componentWillUnmount() {
|
|
3220
3244
|
this.clearPendingUpdates();
|
|
@@ -3234,7 +3258,7 @@ let ThrottledField = /*#__PURE__*/function (_PureComponent) {
|
|
|
3234
3258
|
}, this.props.onEnter ? {
|
|
3235
3259
|
onKeyDown: this.handleEnter
|
|
3236
3260
|
} : {}), filterDataAttributes(this.props));
|
|
3237
|
-
const inputId =
|
|
3261
|
+
const inputId = "throttled-field-".concat(this.props.name);
|
|
3238
3262
|
return jsxs(Fragment, {
|
|
3239
3263
|
children: [jsx(AccessibleHidden, {
|
|
3240
3264
|
children: jsx("label", {
|
|
@@ -3243,7 +3267,7 @@ let ThrottledField = /*#__PURE__*/function (_PureComponent) {
|
|
|
3243
3267
|
})
|
|
3244
3268
|
}), this.props.as === 'textarea' ? jsx(Textarea, _objectSpread$1a(_objectSpread$1a({}, commonProps), {}, {
|
|
3245
3269
|
id: inputId,
|
|
3246
|
-
className: classnames(styles$i.textarea, styles$i[
|
|
3270
|
+
className: classnames(styles$i.textarea, styles$i["textarea-".concat(this.props.style)], {
|
|
3247
3271
|
[styles$i.invalid]: !this.props.isValid,
|
|
3248
3272
|
[styles$i.disabled]: this.props.disabled
|
|
3249
3273
|
}),
|
|
@@ -3254,7 +3278,7 @@ let ThrottledField = /*#__PURE__*/function (_PureComponent) {
|
|
|
3254
3278
|
id: inputId,
|
|
3255
3279
|
ref: this.props.inputRef,
|
|
3256
3280
|
type: this.props.as,
|
|
3257
|
-
className: classnames(styles$i[
|
|
3281
|
+
className: classnames(styles$i["input-".concat(this.props.style)], {
|
|
3258
3282
|
[styles$i.invalid]: !this.props.isValid,
|
|
3259
3283
|
[styles$i.disabled]: this.props.disabled,
|
|
3260
3284
|
[styles$i.granular]: this.props.isGranular
|
|
@@ -3274,7 +3298,6 @@ let ThrottledField = /*#__PURE__*/function (_PureComponent) {
|
|
|
3274
3298
|
return null;
|
|
3275
3299
|
}
|
|
3276
3300
|
}]);
|
|
3277
|
-
return ThrottledField;
|
|
3278
3301
|
}(PureComponent);
|
|
3279
3302
|
ThrottledField.displayName = 'ThrottledField';
|
|
3280
3303
|
ThrottledField.defaultProps = {
|
|
@@ -3331,53 +3354,54 @@ var styles$h = {
|
|
|
3331
3354
|
"action": "search-input-module__action___1GqGT"
|
|
3332
3355
|
};
|
|
3333
3356
|
let SearchInput = /*#__PURE__*/function (_Component) {
|
|
3334
|
-
_inherits(SearchInput, _Component);
|
|
3335
3357
|
function SearchInput() {
|
|
3336
|
-
var
|
|
3358
|
+
var _this2;
|
|
3337
3359
|
_classCallCheck(this, SearchInput);
|
|
3338
3360
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3339
3361
|
args[_key] = arguments[_key];
|
|
3340
3362
|
}
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
initialValue:
|
|
3344
|
-
text:
|
|
3363
|
+
_this2 = _callSuper$6(this, SearchInput, [...args]);
|
|
3364
|
+
_this2.state = {
|
|
3365
|
+
initialValue: _this2.props.initialValue,
|
|
3366
|
+
text: _this2.props.initialValue || ''
|
|
3345
3367
|
};
|
|
3346
|
-
|
|
3368
|
+
_this2.handleInputChange = event => {
|
|
3347
3369
|
const value = event.target.value;
|
|
3348
|
-
|
|
3370
|
+
_this2.setState({
|
|
3349
3371
|
text: value
|
|
3350
3372
|
}, () => {
|
|
3351
|
-
if (
|
|
3352
|
-
if (
|
|
3373
|
+
if (_this2.props.shouldSubmitOnInputChange) _this2.props.onSubmit(value, _this2.props.searchMode);
|
|
3374
|
+
if (_this2.props.onChange) _this2.props.onChange(value);
|
|
3353
3375
|
});
|
|
3354
3376
|
};
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
text:
|
|
3377
|
+
_this2.handleEnter = value => {
|
|
3378
|
+
_this2.setState({
|
|
3379
|
+
text: _this2.props.shouldClearOnSubmit ? '' : value
|
|
3358
3380
|
});
|
|
3359
|
-
|
|
3381
|
+
_this2.props.onSubmit(value, _this2.props.searchMode);
|
|
3360
3382
|
};
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3383
|
+
_this2.handleSubmit = () => {
|
|
3384
|
+
_this2.props.onSubmit(_this2.state.text, _this2.props.searchMode);
|
|
3385
|
+
_this2.props.shouldClearOnSubmit && _this2.setState({
|
|
3364
3386
|
text: ''
|
|
3365
3387
|
});
|
|
3366
3388
|
};
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3389
|
+
_this2.handleClear = () => {
|
|
3390
|
+
var _this2$inputRef;
|
|
3391
|
+
(_this2$inputRef = _this2.inputRef) === null || _this2$inputRef === void 0 || _this2$inputRef.focus();
|
|
3392
|
+
_this2.props.onChange(null);
|
|
3393
|
+
_this2.props.onReset();
|
|
3394
|
+
_this2.setState({
|
|
3372
3395
|
text: ''
|
|
3373
3396
|
});
|
|
3374
3397
|
};
|
|
3375
|
-
|
|
3376
|
-
|
|
3398
|
+
_this2.setInputRef = inputRef => {
|
|
3399
|
+
_this2.inputRef = inputRef;
|
|
3377
3400
|
};
|
|
3378
|
-
return
|
|
3401
|
+
return _this2;
|
|
3379
3402
|
}
|
|
3380
|
-
|
|
3403
|
+
_inherits(SearchInput, _Component);
|
|
3404
|
+
return _createClass(SearchInput, [{
|
|
3381
3405
|
key: "shouldComponentUpdate",
|
|
3382
3406
|
value: function shouldComponentUpdate(nextProps, nextState) {
|
|
3383
3407
|
// ignore state, since it is only use to keep track of the text in the child
|
|
@@ -3452,7 +3476,6 @@ let SearchInput = /*#__PURE__*/function (_Component) {
|
|
|
3452
3476
|
return null;
|
|
3453
3477
|
}
|
|
3454
3478
|
}]);
|
|
3455
|
-
return SearchInput;
|
|
3456
3479
|
}(Component);
|
|
3457
3480
|
SearchInput.displayName = 'SearchInput';
|
|
3458
3481
|
SearchInput.defaultProps = {
|
|
@@ -3477,12 +3500,12 @@ const useExecuteGraphQLRequest = () => {
|
|
|
3477
3500
|
};
|
|
3478
3501
|
const createSearchProductsFromPIMAction = (searchTerm, projectKey) => actions.post({
|
|
3479
3502
|
mcApiProxyTarget: MC_API_PROXY_TARGETS.PIM_SEARCH,
|
|
3480
|
-
uri:
|
|
3503
|
+
uri: "/".concat(projectKey, "/search/product-types"),
|
|
3481
3504
|
payload: {
|
|
3482
3505
|
query: {
|
|
3483
3506
|
wildcard: {
|
|
3484
3507
|
field: 'name',
|
|
3485
|
-
value:
|
|
3508
|
+
value: "*".concat(searchTerm, "*"),
|
|
3486
3509
|
caseInsensitive: true
|
|
3487
3510
|
}
|
|
3488
3511
|
},
|
|
@@ -3496,8 +3519,9 @@ const useFetchProductTypesFromPIM = _ref => {
|
|
|
3496
3519
|
const dispatch = useAsyncDispatch();
|
|
3497
3520
|
const executeGraphQLRequest = useExecuteGraphQLRequest();
|
|
3498
3521
|
const fetchProductTypesFromPim = useCallback(async searchTerm => {
|
|
3522
|
+
var _result$hits$map, _result$hits;
|
|
3499
3523
|
const result = await dispatch(createSearchProductsFromPIMAction(searchTerm, projectKey));
|
|
3500
|
-
const ids =
|
|
3524
|
+
const ids = (_result$hits$map = result === null || result === void 0 || (_result$hits = result.hits) === null || _result$hits === void 0 ? void 0 : _mapInstanceProperty(_result$hits).call(_result$hits, hit => hit.id)) !== null && _result$hits$map !== void 0 ? _result$hits$map : [];
|
|
3501
3525
|
// Avoid sending any requests if it's clear that nothing is found
|
|
3502
3526
|
if (ids.length === 0) {
|
|
3503
3527
|
return {
|
|
@@ -3532,19 +3556,22 @@ const useFetchProductTypesFromPIM = _ref => {
|
|
|
3532
3556
|
*/
|
|
3533
3557
|
const constructNestedExpression = (reversedPath, predicate) => {
|
|
3534
3558
|
if (reversedPath.length > 0) {
|
|
3535
|
-
return _reduceInstanceProperty(reversedPath).call(reversedPath, (nextNestedValue, nestedSelection) =>
|
|
3559
|
+
return _reduceInstanceProperty(reversedPath).call(reversedPath, (nextNestedValue, nestedSelection) => {
|
|
3560
|
+
var _context;
|
|
3561
|
+
return _concatInstanceProperty(_context = "".concat(nestedSelection, "(")).call(_context, nextNestedValue, ")");
|
|
3562
|
+
}, predicate);
|
|
3536
3563
|
}
|
|
3537
3564
|
return predicate;
|
|
3538
3565
|
};
|
|
3539
3566
|
const constructPrefixSearchPredicate$1 = (prefixSearchFields, lowerBound, upperBound) => {
|
|
3540
3567
|
const constructPrefixSearchExpression = field => {
|
|
3541
|
-
var
|
|
3568
|
+
var _context2, _context3, _context4, _context5;
|
|
3542
3569
|
const parts = field.split('.');
|
|
3543
|
-
const _parts$slice$reverse = _reverseInstanceProperty(
|
|
3570
|
+
const _parts$slice$reverse = _reverseInstanceProperty(_context2 = _sliceInstanceProperty(parts).call(parts)).call(_context2),
|
|
3544
3571
|
_parts$slice$reverse2 = _toArray(_parts$slice$reverse),
|
|
3545
3572
|
valueToNest = _parts$slice$reverse2[0],
|
|
3546
3573
|
reversedPathToNestedValue = _sliceInstanceProperty(_parts$slice$reverse2).call(_parts$slice$reverse2, 1);
|
|
3547
|
-
const predicateExpression =
|
|
3574
|
+
const predicateExpression = _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = _concatInstanceProperty(_context5 = "".concat(valueToNest, " >= \"")).call(_context5, lowerBound, "\" and ")).call(_context4, valueToNest, " < \"")).call(_context3, upperBound, "\"");
|
|
3548
3575
|
return constructNestedExpression(reversedPathToNestedValue, predicateExpression);
|
|
3549
3576
|
};
|
|
3550
3577
|
return _mapInstanceProperty(prefixSearchFields).call(prefixSearchFields, constructPrefixSearchExpression).join(' or ');
|
|
@@ -3552,7 +3579,7 @@ const constructPrefixSearchPredicate$1 = (prefixSearchFields, lowerBound, upperB
|
|
|
3552
3579
|
const constructWherePredicate = (inputValue, prefixSearchFields) => {
|
|
3553
3580
|
const wherePredicate = function () {
|
|
3554
3581
|
if (inputValue.length) {
|
|
3555
|
-
if (isUUID(inputValue)) return
|
|
3582
|
+
if (isUUID(inputValue)) return "id = \"".concat(inputValue, "\"");else {
|
|
3556
3583
|
const _getPrefixSearchBound = getPrefixSearchBounds(inputValue),
|
|
3557
3584
|
_getPrefixSearchBound2 = _slicedToArray(_getPrefixSearchBound, 2),
|
|
3558
3585
|
lowerBound = _getPrefixSearchBound2[0],
|
|
@@ -3577,6 +3604,7 @@ const useFetchProductTypessFromCTP = _ref2 => {
|
|
|
3577
3604
|
}, [prefixSearchFields, executeGraphQLRequest]);
|
|
3578
3605
|
};
|
|
3579
3606
|
const usePimStatus = () => {
|
|
3607
|
+
var _data$indicesExist;
|
|
3580
3608
|
const _useQuery = useQuery(FetchIndicesExist$1, {
|
|
3581
3609
|
context: {
|
|
3582
3610
|
target: GRAPHQL_TARGETS.PIM_INDEXER
|
|
@@ -3586,17 +3614,20 @@ const usePimStatus = () => {
|
|
|
3586
3614
|
data = _useQuery.data;
|
|
3587
3615
|
return {
|
|
3588
3616
|
data,
|
|
3589
|
-
isProjectIndexed: Boolean(data
|
|
3617
|
+
isProjectIndexed: Boolean(data === null || data === void 0 || (_data$indicesExist = data.indicesExist) === null || _data$indicesExist === void 0 || (_data$indicesExist = _data$indicesExist.productTypes) === null || _data$indicesExist === void 0 ? void 0 : _data$indicesExist.searchableIndexExists)
|
|
3590
3618
|
};
|
|
3591
3619
|
};
|
|
3592
3620
|
const useProductTypeOptions = _ref3 => {
|
|
3593
3621
|
let prefixSearchFields = _ref3.prefixSearchFields;
|
|
3594
3622
|
const _usePimStatus = usePimStatus(),
|
|
3595
3623
|
isProjectIndexed = _usePimStatus.isProjectIndexed;
|
|
3596
|
-
const _useApplicationContex = useApplicationContext(context =>
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3624
|
+
const _useApplicationContex = useApplicationContext(context => {
|
|
3625
|
+
var _context$project;
|
|
3626
|
+
return {
|
|
3627
|
+
dataLocale: context.dataLocale,
|
|
3628
|
+
projectKey: (_context$project = context.project) === null || _context$project === void 0 ? void 0 : _context$project.key
|
|
3629
|
+
};
|
|
3630
|
+
}),
|
|
3600
3631
|
dataLocale = _useApplicationContex.dataLocale,
|
|
3601
3632
|
projectKey = _useApplicationContex.projectKey;
|
|
3602
3633
|
const fetchProductTypesFromPim = useFetchProductTypesFromPIM({
|
|
@@ -3660,9 +3691,10 @@ const useHandlers = onChange => {
|
|
|
3660
3691
|
setInputValue(changedValue);
|
|
3661
3692
|
}, []);
|
|
3662
3693
|
const handleChange = useEventCallback(event => {
|
|
3694
|
+
var _event$target$value;
|
|
3663
3695
|
const eventWithExtractedValue = _objectSpread$18(_objectSpread$18({}, event), {}, {
|
|
3664
3696
|
target: _objectSpread$18(_objectSpread$18({}, event.target), {}, {
|
|
3665
|
-
value: event.target.value
|
|
3697
|
+
value: (_event$target$value = event.target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.value
|
|
3666
3698
|
})
|
|
3667
3699
|
});
|
|
3668
3700
|
onChange(eventWithExtractedValue);
|
|
@@ -3672,21 +3704,24 @@ const useHandlers = onChange => {
|
|
|
3672
3704
|
|
|
3673
3705
|
const _excluded$3 = ["extraWhere"];
|
|
3674
3706
|
function ownKeys$17(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3675
|
-
function _objectSpread$17(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
3707
|
+
function _objectSpread$17(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context7 = ownKeys$17(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context8 = ownKeys$17(Object(t))).call(_context8, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3676
3708
|
const constructPrefixSearchPredicate = function () {
|
|
3677
3709
|
let prefixSearchFields = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
3678
3710
|
let lowerBound = arguments.length > 1 ? arguments[1] : undefined;
|
|
3679
3711
|
let upperBound = arguments.length > 2 ? arguments[2] : undefined;
|
|
3680
3712
|
const constructPrefixSearchExpression = field => {
|
|
3681
|
-
var _context;
|
|
3713
|
+
var _context, _context2, _context3, _context4;
|
|
3682
3714
|
const path = field.split('.');
|
|
3683
3715
|
const _path$slice$reverse = _reverseInstanceProperty(_context = _sliceInstanceProperty(path).call(path)).call(_context),
|
|
3684
3716
|
_path$slice$reverse2 = _toArray(_path$slice$reverse),
|
|
3685
3717
|
finalValueInPath = _path$slice$reverse2[0],
|
|
3686
3718
|
remainPathInReverse = _sliceInstanceProperty(_path$slice$reverse2).call(_path$slice$reverse2, 1);
|
|
3687
|
-
const comparison =
|
|
3719
|
+
const comparison = _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "".concat(finalValueInPath, " >= \"")).call(_context4, lowerBound, "\" and ")).call(_context3, finalValueInPath, " < \"")).call(_context2, upperBound, "\"");
|
|
3688
3720
|
if (remainPathInReverse.length) {
|
|
3689
|
-
return _reduceInstanceProperty(remainPathInReverse).call(remainPathInReverse, (nestedPath, nextPath) =>
|
|
3721
|
+
return _reduceInstanceProperty(remainPathInReverse).call(remainPathInReverse, (nestedPath, nextPath) => {
|
|
3722
|
+
var _context5;
|
|
3723
|
+
return _concatInstanceProperty(_context5 = "".concat(nextPath, "(")).call(_context5, nestedPath, ")");
|
|
3724
|
+
}, comparison);
|
|
3690
3725
|
}
|
|
3691
3726
|
return comparison;
|
|
3692
3727
|
};
|
|
@@ -3702,7 +3737,7 @@ const useLoadOptions = _ref => {
|
|
|
3702
3737
|
let where;
|
|
3703
3738
|
if (inputValue.length) {
|
|
3704
3739
|
if (isUUID(inputValue)) {
|
|
3705
|
-
where =
|
|
3740
|
+
where = "id = \"".concat(inputValue, "\"");
|
|
3706
3741
|
} else {
|
|
3707
3742
|
const _getPrefixSearchBound = getPrefixSearchBounds(inputValue),
|
|
3708
3743
|
_getPrefixSearchBound2 = _slicedToArray(_getPrefixSearchBound, 2),
|
|
@@ -3711,11 +3746,12 @@ const useLoadOptions = _ref => {
|
|
|
3711
3746
|
where = constructPrefixSearchPredicate(prefixSearchFields, lowerBound, upperBound);
|
|
3712
3747
|
}
|
|
3713
3748
|
}
|
|
3714
|
-
const _ref2 = variables
|
|
3749
|
+
const _ref2 = variables !== null && variables !== void 0 ? variables : {},
|
|
3715
3750
|
extraWhere = _ref2.extraWhere,
|
|
3716
3751
|
restVariables = _objectWithoutProperties(_ref2, _excluded$3);
|
|
3717
3752
|
if (typeof extraWhere === 'string') {
|
|
3718
|
-
|
|
3753
|
+
var _context6;
|
|
3754
|
+
where = where ? _concatInstanceProperty(_context6 = "(".concat(where, ") and ")).call(_context6, variables.extraWhere) : variables.extraWhere;
|
|
3719
3755
|
}
|
|
3720
3756
|
return client.query({
|
|
3721
3757
|
query,
|
|
@@ -3732,6 +3768,7 @@ const useLoadOptions = _ref => {
|
|
|
3732
3768
|
};
|
|
3733
3769
|
|
|
3734
3770
|
function useCurrentOption(_ref) {
|
|
3771
|
+
var _context;
|
|
3735
3772
|
let id = _ref.id,
|
|
3736
3773
|
typename = _ref.typename,
|
|
3737
3774
|
query = _ref.query,
|
|
@@ -3743,7 +3780,7 @@ function useCurrentOption(_ref) {
|
|
|
3743
3780
|
// load from cache when possible to speed up initial render
|
|
3744
3781
|
const canReadFromCache = id && typename && fragment;
|
|
3745
3782
|
const cacheItem = canReadFromCache ? apolloClient.readFragment({
|
|
3746
|
-
id:
|
|
3783
|
+
id: _concatInstanceProperty(_context = "".concat(typename, ":")).call(_context, id),
|
|
3747
3784
|
fragment
|
|
3748
3785
|
}) : undefined;
|
|
3749
3786
|
|
|
@@ -3761,7 +3798,7 @@ function useCurrentOption(_ref) {
|
|
|
3761
3798
|
queryData = _useQuery.data,
|
|
3762
3799
|
queryError = _useQuery.error;
|
|
3763
3800
|
const queryItem = queryData && queryDataToItem(queryData);
|
|
3764
|
-
const item = queryItem
|
|
3801
|
+
const item = queryItem !== null && queryItem !== void 0 ? queryItem : cacheItem;
|
|
3765
3802
|
const loading = item ? false : queryLoading;
|
|
3766
3803
|
const error = item ? undefined : queryError;
|
|
3767
3804
|
const data = item && itemToOption(item);
|
|
@@ -3800,6 +3837,7 @@ const convertProductTypeToOption = productType => {
|
|
|
3800
3837
|
};
|
|
3801
3838
|
};
|
|
3802
3839
|
const ProductTypePickerInput = _ref => {
|
|
3840
|
+
var _currentOption$data$l, _currentOption$data;
|
|
3803
3841
|
let isClearable = _ref.isClearable,
|
|
3804
3842
|
isDisabled = _ref.isDisabled,
|
|
3805
3843
|
isReadOnly = _ref.isReadOnly,
|
|
@@ -3831,8 +3869,9 @@ const ProductTypePickerInput = _ref => {
|
|
|
3831
3869
|
itemToOption: convertProductTypeToOption
|
|
3832
3870
|
});
|
|
3833
3871
|
const handleLoadOptions = useCallback(inputValue => loadProductTypes(inputValue).then(_ref3 => {
|
|
3872
|
+
var _data$productTypes;
|
|
3834
3873
|
let data = _ref3.data;
|
|
3835
|
-
return data.productTypes
|
|
3874
|
+
return ((_data$productTypes = data.productTypes) === null || _data$productTypes === void 0 ? void 0 : _data$productTypes.results) || [];
|
|
3836
3875
|
}).then(productTypes => _mapInstanceProperty(productTypes).call(productTypes, convertProductTypeToOption)).catch(error => {
|
|
3837
3876
|
setLoadingError(error);
|
|
3838
3877
|
onError(error);
|
|
@@ -3846,12 +3885,12 @@ const ProductTypePickerInput = _ref => {
|
|
|
3846
3885
|
setLoadingError(null);
|
|
3847
3886
|
handleInternalInputChange(event);
|
|
3848
3887
|
}, [handleInternalInputChange]);
|
|
3849
|
-
const isCurrentOptionLoadingFailed = Boolean(currentOption
|
|
3888
|
+
const isCurrentOptionLoadingFailed = Boolean(currentOption === null || currentOption === void 0 ? void 0 : currentOption.error);
|
|
3850
3889
|
useEffect(() => {
|
|
3851
3890
|
if (isCurrentOptionLoadingFailed) onError(currentOption.error);
|
|
3852
3891
|
}, [isCurrentOptionLoadingFailed, onError, currentOption]);
|
|
3853
3892
|
const isLoadingFailed = isCurrentOptionLoadingFailed || Boolean(loadingError);
|
|
3854
|
-
const tooltipTitle = currentOption
|
|
3893
|
+
const tooltipTitle = (_currentOption$data$l = currentOption === null || currentOption === void 0 || (_currentOption$data = currentOption.data) === null || _currentOption$data === void 0 ? void 0 : _currentOption$data.label) !== null && _currentOption$data$l !== void 0 ? _currentOption$data$l : '';
|
|
3855
3894
|
return jsx(Constraints.Horizontal, {
|
|
3856
3895
|
max: "scale",
|
|
3857
3896
|
children: currentOption.loading ? jsx(CenteredLoadingSpinner, {}) : jsxs(Spacings.Stack, {
|
|
@@ -3905,6 +3944,7 @@ var messages$C = defineMessages({
|
|
|
3905
3944
|
var GetStatesQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "GetStatesQuery" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "where" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "sortByNamePath" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "states" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "where" }, value: { kind: "Variable", name: { kind: "Name", value: "where" } } }, { kind: "Argument", name: { kind: "Name", value: "sort" }, value: { kind: "ListValue", values: [{ kind: "Variable", name: { kind: "Name", value: "sortByNamePath" } }, { kind: "StringValue", value: "key", block: false }] } }, { kind: "Argument", name: { kind: "Name", value: "limit" }, value: { kind: "IntValue", value: "60" } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }] } }], loc: { start: 0, end: 377, source: { body: "query GetStatesQuery($where: String, $sortByNamePath: String!) {\n states(where: $where, sort: [$sortByNamePath, \"key\"], limit: 60) {\n total\n results {\n id\n key\n nameAllLocales {\n locale\n value\n }\n }\n }\n}\n\nquery GetStateQuery($id: String) {\n state(id: $id) {\n id\n key\n nameAllLocales {\n locale\n value\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
3906
3945
|
var GetStateQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "GetStateQuery" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "id" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "state" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "id" }, value: { kind: "Variable", name: { kind: "Name", value: "id" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }], loc: { start: 0, end: 377, source: { body: "query GetStatesQuery($where: String, $sortByNamePath: String!) {\n states(where: $where, sort: [$sortByNamePath, \"key\"], limit: 60) {\n total\n results {\n id\n key\n nameAllLocales {\n locale\n value\n }\n }\n }\n}\n\nquery GetStateQuery($id: String) {\n state(id: $id) {\n id\n key\n nameAllLocales {\n locale\n value\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
3907
3946
|
const StatePickerInput = _ref => {
|
|
3947
|
+
var _currentOption$data$l, _currentOption$data;
|
|
3908
3948
|
let isClearable = _ref.isClearable,
|
|
3909
3949
|
isDisabled = _ref.isDisabled,
|
|
3910
3950
|
isReadOnly = _ref.isReadOnly,
|
|
@@ -3920,7 +3960,7 @@ const StatePickerInput = _ref => {
|
|
|
3920
3960
|
formatMessage = _useIntl.formatMessage;
|
|
3921
3961
|
const dataLocale = useApplicationContext(applicationContext => applicationContext.dataLocale);
|
|
3922
3962
|
const variables = useMemo(() => ({
|
|
3923
|
-
sortByNamePath:
|
|
3963
|
+
sortByNamePath: "name.".concat(dataLocale)
|
|
3924
3964
|
}), [dataLocale]);
|
|
3925
3965
|
const convertStateToOption = useCallback(state => {
|
|
3926
3966
|
const localizedName = formatLocalizedFieldToString(state.nameAllLocales);
|
|
@@ -3935,7 +3975,7 @@ const StatePickerInput = _ref => {
|
|
|
3935
3975
|
_useState2 = _slicedToArray(_useState, 2),
|
|
3936
3976
|
loadingError = _useState2[0],
|
|
3937
3977
|
setLoadingError = _useState2[1];
|
|
3938
|
-
const prefixSearchFields = useMemo(() => [
|
|
3978
|
+
const prefixSearchFields = useMemo(() => ["name.".concat(dataLocale), 'key'], [dataLocale]);
|
|
3939
3979
|
const loadOptions = useLoadOptions({
|
|
3940
3980
|
query: GetStatesQuery,
|
|
3941
3981
|
variables,
|
|
@@ -3968,13 +4008,13 @@ const StatePickerInput = _ref => {
|
|
|
3968
4008
|
setLoadingError(null);
|
|
3969
4009
|
handleInternalInputChange(event);
|
|
3970
4010
|
}, [handleInternalInputChange]);
|
|
3971
|
-
const isCurrentOptionLoadingFailed = Boolean(currentOption
|
|
4011
|
+
const isCurrentOptionLoadingFailed = Boolean(currentOption === null || currentOption === void 0 ? void 0 : currentOption.error);
|
|
3972
4012
|
useEffect(() => {
|
|
3973
4013
|
if (isCurrentOptionLoadingFailed) onError(currentOption.error);
|
|
3974
4014
|
}, [isCurrentOptionLoadingFailed, onError, currentOption]);
|
|
3975
4015
|
const isLoadingFailed = isCurrentOptionLoadingFailed || Boolean(loadingError);
|
|
3976
4016
|
const handleNoOptions = useCallback(() => loadingError ? null : formatMessage(messages$C.noStatesFound), [loadingError, formatMessage]);
|
|
3977
|
-
const tooltipTitle = currentOption
|
|
4017
|
+
const tooltipTitle = (_currentOption$data$l = currentOption === null || currentOption === void 0 || (_currentOption$data = currentOption.data) === null || _currentOption$data === void 0 ? void 0 : _currentOption$data.label) !== null && _currentOption$data$l !== void 0 ? _currentOption$data$l : '';
|
|
3978
4018
|
return jsx(Constraints.Horizontal, {
|
|
3979
4019
|
max: "scale",
|
|
3980
4020
|
children: currentOption.loading ? jsx(CenteredLoadingSpinner, {}) : jsxs(Spacings.Stack, {
|
|
@@ -4042,23 +4082,26 @@ const CustomFieldTooltip = _ref => {
|
|
|
4042
4082
|
|
|
4043
4083
|
const setToArray = function () {
|
|
4044
4084
|
let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
4045
|
-
return
|
|
4085
|
+
return "id in (".concat(_mapInstanceProperty(values).call(values, value => "\"".concat(value, "\"")).join(', '), ")");
|
|
4046
4086
|
};
|
|
4047
4087
|
|
|
4048
4088
|
function capitalizeFirst(text) {
|
|
4049
4089
|
return text.charAt(0).toUpperCase() + _sliceInstanceProperty(text).call(text, 1);
|
|
4050
4090
|
}
|
|
4051
4091
|
|
|
4052
|
-
const getCentAmountClause = (value, operator, locale) =>
|
|
4092
|
+
const getCentAmountClause = (value, operator, locale) => {
|
|
4093
|
+
var _context;
|
|
4094
|
+
return _concatInstanceProperty(_context = "centAmount ".concat(operator, " ")).call(_context, MoneyInput.convertToMoneyValue(value, locale).centAmount);
|
|
4095
|
+
};
|
|
4053
4096
|
function moneyTransformer(value, option, locale) {
|
|
4054
4097
|
const clauses = [];
|
|
4055
4098
|
if (option === FILTER_TYPES.range) {
|
|
4056
|
-
clauses[0] =
|
|
4099
|
+
clauses[0] = "currencyCode = \"".concat(value.from.currencyCode, "\"");
|
|
4057
4100
|
clauses[1] = getCentAmountClause(value.from, '>=', locale);
|
|
4058
4101
|
clauses[2] = getCentAmountClause(value.to, '<=', locale);
|
|
4059
4102
|
return clauses.join(' and ');
|
|
4060
4103
|
}
|
|
4061
|
-
clauses[0] =
|
|
4104
|
+
clauses[0] = "currencyCode = \"".concat(value.currencyCode, "\"");
|
|
4062
4105
|
switch (option) {
|
|
4063
4106
|
case FILTER_TYPES.lessThan:
|
|
4064
4107
|
clauses[1] = getCentAmountClause(value, '<', locale);
|
|
@@ -4075,6 +4118,7 @@ function moneyTransformer(value, option, locale) {
|
|
|
4075
4118
|
return clauses.join(' and ');
|
|
4076
4119
|
}
|
|
4077
4120
|
|
|
4121
|
+
var _templateObject$2, _templateObject2$1;
|
|
4078
4122
|
const formatTime = 'HH:mm:ss.SSS';
|
|
4079
4123
|
|
|
4080
4124
|
/* TimeInput only allows HH:mm:ss and adds the seconds as 00 and
|
|
@@ -4096,6 +4140,7 @@ const defaultFilterValidator = _ref => {
|
|
|
4096
4140
|
const timeTransformer = function (filterKey, filters) {
|
|
4097
4141
|
let filterValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultFilterValidator;
|
|
4098
4142
|
const queries = _mapInstanceProperty(filters).call(filters, _ref2 => {
|
|
4143
|
+
var _context, _context2;
|
|
4099
4144
|
let type = _ref2.type,
|
|
4100
4145
|
value = _ref2.value;
|
|
4101
4146
|
if (!filterValidator({
|
|
@@ -4104,19 +4149,13 @@ const timeTransformer = function (filterKey, filters) {
|
|
|
4104
4149
|
})) return '';
|
|
4105
4150
|
switch (type) {
|
|
4106
4151
|
case FILTER_TYPES.lessThan:
|
|
4107
|
-
return
|
|
4152
|
+
return _concatInstanceProperty(_context = "".concat(filterKey, " < \"")).call(_context, value, "\"");
|
|
4108
4153
|
case FILTER_TYPES.moreThan:
|
|
4109
|
-
return
|
|
4154
|
+
return _concatInstanceProperty(_context2 = "".concat(filterKey, " > \"")).call(_context2, value, "\"");
|
|
4110
4155
|
case FILTER_TYPES.equalTo:
|
|
4111
|
-
return oneLine
|
|
4112
|
-
(${filterKey} >= "${value}"
|
|
4113
|
-
and ${filterKey} <= "${getEndOfSecond(value)}")
|
|
4114
|
-
`;
|
|
4156
|
+
return oneLine(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n (", " >= \"", "\"\n and ", " <= \"", "\")\n "])), filterKey, value, filterKey, getEndOfSecond(value));
|
|
4115
4157
|
case FILTER_TYPES.range:
|
|
4116
|
-
return oneLine
|
|
4117
|
-
(${filterKey} >= "${value.from}"
|
|
4118
|
-
and ${filterKey} <= "${getEndOfSecond(value.to)}")
|
|
4119
|
-
`;
|
|
4158
|
+
return oneLine(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteral(["\n (", " >= \"", "\"\n and ", " <= \"", "\")\n "])), filterKey, value.from, filterKey, getEndOfSecond(value.to));
|
|
4120
4159
|
default:
|
|
4121
4160
|
return '';
|
|
4122
4161
|
}
|
|
@@ -4132,7 +4171,7 @@ const timeTransformer = function (filterKey, filters) {
|
|
|
4132
4171
|
* (pickUpTime >= "14:00" and pickUpTime <= "15:00")
|
|
4133
4172
|
* ) or some_more_filters
|
|
4134
4173
|
*/
|
|
4135
|
-
return queryString === '' ? null :
|
|
4174
|
+
return queryString === '' ? null : "(".concat(queryString, ")");
|
|
4136
4175
|
};
|
|
4137
4176
|
|
|
4138
4177
|
// FIXME: delete once prefix search is supported in ctp api
|
|
@@ -4149,8 +4188,9 @@ const timeTransformer = function (filterKey, filters) {
|
|
|
4149
4188
|
// e.g
|
|
4150
4189
|
// where: `masterData(current(name(en >= "${lowerBound}" and en < "${upperBound}")))`
|
|
4151
4190
|
const getPrefixSearchBounds = input => {
|
|
4191
|
+
var _context;
|
|
4152
4192
|
const getNextCharacter = character => String.fromCharCode(character.charCodeAt() + 1);
|
|
4153
|
-
return [input,
|
|
4193
|
+
return [input, _concatInstanceProperty(_context = "".concat(_sliceInstanceProperty(input).call(input, 0, input.length - 1))).call(_context, getNextCharacter(_sliceInstanceProperty(input).call(input, input.length - 1)))];
|
|
4154
4194
|
};
|
|
4155
4195
|
|
|
4156
4196
|
const _excluded$2 = ["action"];
|
|
@@ -4343,7 +4383,7 @@ const convertChangeValueAction = actionPayload => {
|
|
|
4343
4383
|
* as its dynamic content can not be typed in SDL for the mutation.
|
|
4344
4384
|
*/
|
|
4345
4385
|
const convertAction = (actionName, actionPayload) => {
|
|
4346
|
-
var _context3, _context4, _context5;
|
|
4386
|
+
var _actionPayload$type, _context3, _actionPayload$geoLoc, _actionPayload$geoLoc2, _actionPayload$shippi, _context4, _context5;
|
|
4347
4387
|
const getNameFromPayload = payload => {
|
|
4348
4388
|
// changeName for `Organizations`
|
|
4349
4389
|
if (typeof payload.name === 'string') return payload;
|
|
@@ -4408,7 +4448,7 @@ const convertAction = (actionName, actionPayload) => {
|
|
|
4408
4448
|
case 'setCustomType':
|
|
4409
4449
|
return {
|
|
4410
4450
|
[actionName]: {
|
|
4411
|
-
typeId: actionPayload.type
|
|
4451
|
+
typeId: (_actionPayload$type = actionPayload.type) === null || _actionPayload$type === void 0 ? void 0 : _actionPayload$type.id,
|
|
4412
4452
|
fields: actionPayload.fields ? _mapInstanceProperty(_context3 = _Object$entries(actionPayload.fields)).call(_context3, _ref => {
|
|
4413
4453
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
4414
4454
|
customField = _ref2[0],
|
|
@@ -4438,10 +4478,10 @@ const convertAction = (actionName, actionPayload) => {
|
|
|
4438
4478
|
};
|
|
4439
4479
|
case 'setGeoLocation':
|
|
4440
4480
|
return {
|
|
4441
|
-
[actionName]: actionPayload
|
|
4481
|
+
[actionName]: actionPayload !== null && actionPayload !== void 0 && actionPayload.geoLocation ? {
|
|
4442
4482
|
geoLocation: {
|
|
4443
4483
|
type: 'Point',
|
|
4444
|
-
coordinates: [_parseFloat(actionPayload.geoLocation
|
|
4484
|
+
coordinates: [_parseFloat((_actionPayload$geoLoc = actionPayload.geoLocation) === null || _actionPayload$geoLoc === void 0 ? void 0 : _actionPayload$geoLoc.longitude), _parseFloat((_actionPayload$geoLoc2 = actionPayload.geoLocation) === null || _actionPayload$geoLoc2 === void 0 ? void 0 : _actionPayload$geoLoc2.latitude)]
|
|
4445
4485
|
}
|
|
4446
4486
|
} : {
|
|
4447
4487
|
undefined
|
|
@@ -4577,7 +4617,7 @@ const convertAction = (actionName, actionPayload) => {
|
|
|
4577
4617
|
case 'setShippingRateInputType':
|
|
4578
4618
|
return {
|
|
4579
4619
|
[actionName]: {
|
|
4580
|
-
shippingRateInputType: actionPayload.shippingRateInputType
|
|
4620
|
+
shippingRateInputType: (_actionPayload$shippi = actionPayload.shippingRateInputType) !== null && _actionPayload$shippi !== void 0 && _actionPayload$shippi.type ? {
|
|
4581
4621
|
[actionPayload.shippingRateInputType.type]: {
|
|
4582
4622
|
values: actionPayload.shippingRateInputType.type === 'CartClassification' ? _mapInstanceProperty(_context4 = _valuesInstanceProperty(actionPayload.shippingRateInputType)).call(_context4, value => ({
|
|
4583
4623
|
key: value.key,
|
|
@@ -4631,8 +4671,8 @@ const convertAction = (actionName, actionPayload) => {
|
|
|
4631
4671
|
case 'addAddress':
|
|
4632
4672
|
case 'changeAddress':
|
|
4633
4673
|
{
|
|
4634
|
-
var _context6;
|
|
4635
|
-
const _ref3 = actionPayload.address
|
|
4674
|
+
var _actionPayload$addres, _context6, _actionPayload$addres2;
|
|
4675
|
+
const _ref3 = ((_actionPayload$addres = actionPayload.address) === null || _actionPayload$addres === void 0 ? void 0 : _actionPayload$addres.custom) || {},
|
|
4636
4676
|
_ref3$fields = _ref3.fields,
|
|
4637
4677
|
fields = _ref3$fields === void 0 ? {} : _ref3$fields;
|
|
4638
4678
|
const customFields = isEmpty$3(fields) ? null : _mapInstanceProperty(_context6 = _Object$entries(fields)).call(_context6, _ref4 => {
|
|
@@ -4644,7 +4684,7 @@ const convertAction = (actionName, actionPayload) => {
|
|
|
4644
4684
|
value: _JSON$stringify(value)
|
|
4645
4685
|
};
|
|
4646
4686
|
});
|
|
4647
|
-
const custom = actionPayload.address
|
|
4687
|
+
const custom = (_actionPayload$addres2 = actionPayload.address) !== null && _actionPayload$addres2 !== void 0 && (_actionPayload$addres2 = _actionPayload$addres2.custom) !== null && _actionPayload$addres2 !== void 0 && (_actionPayload$addres2 = _actionPayload$addres2.type) !== null && _actionPayload$addres2 !== void 0 && _actionPayload$addres2.id ? {
|
|
4648
4688
|
type: {
|
|
4649
4689
|
id: actionPayload.address.custom.type.id
|
|
4650
4690
|
},
|
|
@@ -4675,7 +4715,7 @@ const convertAction = (actionName, actionPayload) => {
|
|
|
4675
4715
|
value: _JSON$stringify(value)
|
|
4676
4716
|
};
|
|
4677
4717
|
});
|
|
4678
|
-
const customType = type
|
|
4718
|
+
const customType = type !== null && type !== void 0 && type.id ? {
|
|
4679
4719
|
id: type.id
|
|
4680
4720
|
} : null;
|
|
4681
4721
|
return {
|
|
@@ -4698,10 +4738,11 @@ const createGraphQlUpdateActions = actions => _reduceInstanceProperty(actions).c
|
|
|
4698
4738
|
return [...previousActions, convertAction(actionName, actionPayload)];
|
|
4699
4739
|
}, []);
|
|
4700
4740
|
const extractErrorFromGraphQlResponse = graphQlResponse => {
|
|
4701
|
-
|
|
4741
|
+
var _graphQlResponse$netw, _graphQlResponse$grap;
|
|
4742
|
+
if (((_graphQlResponse$netw = graphQlResponse.networkError) === null || _graphQlResponse$netw === void 0 || (_graphQlResponse$netw = _graphQlResponse$netw.result) === null || _graphQlResponse$netw === void 0 || (_graphQlResponse$netw = _graphQlResponse$netw.errors) === null || _graphQlResponse$netw === void 0 ? void 0 : _graphQlResponse$netw.length) > 0) {
|
|
4702
4743
|
return graphQlResponse.networkError.result.errors;
|
|
4703
4744
|
}
|
|
4704
|
-
if (graphQlResponse.graphQLErrors
|
|
4745
|
+
if (((_graphQlResponse$grap = graphQlResponse.graphQLErrors) === null || _graphQlResponse$grap === void 0 ? void 0 : _graphQlResponse$grap.length) > 0) {
|
|
4705
4746
|
return graphQlResponse.graphQLErrors;
|
|
4706
4747
|
}
|
|
4707
4748
|
return graphQlResponse;
|
|
@@ -4730,14 +4771,16 @@ function omitDeep(obj, fieldsToOmit) {
|
|
|
4730
4771
|
function ownKeys$14(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4731
4772
|
function _objectSpread$14(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$14(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$14(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4732
4773
|
function getPriceChannelName(price) {
|
|
4733
|
-
|
|
4774
|
+
var _ref, _price$channel$name, _price$channel, _price$channel2;
|
|
4775
|
+
return (_ref = (_price$channel$name = (_price$channel = price.channel) === null || _price$channel === void 0 ? void 0 : _price$channel.name) !== null && _price$channel$name !== void 0 ? _price$channel$name : (_price$channel2 = price.channel) === null || _price$channel2 === void 0 ? void 0 : _price$channel2.key) !== null && _ref !== void 0 ? _ref : null;
|
|
4734
4776
|
}
|
|
4735
4777
|
function getDiscountValue(price) {
|
|
4778
|
+
var _price$value, _price$value2, _price$discounted;
|
|
4736
4779
|
let preciseAmount;
|
|
4737
4780
|
let fractionedAmount;
|
|
4738
|
-
if (price.value
|
|
4781
|
+
if (((_price$value = price.value) === null || _price$value === void 0 ? void 0 : _price$value.type) === PRECISION_TYPES.highPrecision && price.discounted.value.type === PRECISION_TYPES.highPrecision) {
|
|
4739
4782
|
preciseAmount = price.value.preciseAmount - price.discounted.value.preciseAmount;
|
|
4740
|
-
} else if (price.value
|
|
4783
|
+
} else if (((_price$value2 = price.value) === null || _price$value2 === void 0 ? void 0 : _price$value2.type) === PRECISION_TYPES.highPrecision && ((_price$discounted = price.discounted) === null || _price$discounted === void 0 || (_price$discounted = _price$discounted.value) === null || _price$discounted === void 0 ? void 0 : _price$discounted.type) === PRECISION_TYPES.centPrecision) {
|
|
4741
4784
|
fractionedAmount = getFractionedAmount(price.value) - getFractionedAmount(price.discounted.value);
|
|
4742
4785
|
}
|
|
4743
4786
|
return price.discounted ? _objectSpread$14(_objectSpread$14({}, price.value), {}, {
|
|
@@ -4751,23 +4794,28 @@ function getDiscountValue(price) {
|
|
|
4751
4794
|
function getSelectedPrice(price) {
|
|
4752
4795
|
return price.discounted ? price.discounted : price;
|
|
4753
4796
|
}
|
|
4754
|
-
function getNetUnitPrice(
|
|
4755
|
-
|
|
4756
|
-
|
|
4797
|
+
function getNetUnitPrice(_ref2) {
|
|
4798
|
+
var _lineItem$perMethodTa, _filteredPerMethodTax;
|
|
4799
|
+
let lineItem = _ref2.lineItem,
|
|
4800
|
+
shouldRoundAmount = _ref2.shouldRoundAmount;
|
|
4757
4801
|
const price = getSelectedPrice(lineItem.price);
|
|
4758
|
-
const filteredPerMethodTaxRate = lineItem
|
|
4802
|
+
const filteredPerMethodTaxRate = lineItem === null || lineItem === void 0 || (_lineItem$perMethodTa = lineItem.perMethodTaxRate) === null || _lineItem$perMethodTa === void 0 ? void 0 : _filterInstanceProperty(_lineItem$perMethodTa).call(_lineItem$perMethodTa, perMethodTax => {
|
|
4803
|
+
var _lineItem$shippingDet;
|
|
4804
|
+
return (lineItem === null || lineItem === void 0 || (_lineItem$shippingDet = lineItem.shippingDetails) === null || _lineItem$shippingDet === void 0 || (_lineItem$shippingDet = _lineItem$shippingDet.targets) === null || _lineItem$shippingDet === void 0 ? void 0 : _findIndexInstanceProperty(_lineItem$shippingDet).call(_lineItem$shippingDet, target => (target === null || target === void 0 ? void 0 : target.shippingMethodKey) === (perMethodTax === null || perMethodTax === void 0 ? void 0 : perMethodTax.shippingMethodKey))) >= 0;
|
|
4805
|
+
});
|
|
4759
4806
|
|
|
4760
4807
|
// when shipping mode is multi with the same tax rate
|
|
4761
|
-
if (filteredPerMethodTaxRate
|
|
4808
|
+
if ((filteredPerMethodTaxRate === null || filteredPerMethodTaxRate === void 0 ? void 0 : filteredPerMethodTaxRate.length) > 0 && (_filteredPerMethodTax = filteredPerMethodTaxRate[0]) !== null && _filteredPerMethodTax !== void 0 && (_filteredPerMethodTax = _filteredPerMethodTax.taxRate) !== null && _filteredPerMethodTax !== void 0 && _filteredPerMethodTax.includedInPrice) {
|
|
4809
|
+
var _price$value3, _price$value4;
|
|
4762
4810
|
const taxRate = filteredPerMethodTaxRate[0].taxRate;
|
|
4763
4811
|
let centAmount;
|
|
4764
4812
|
// should accept 0 value
|
|
4765
|
-
if (typeof price.value
|
|
4813
|
+
if (typeof ((_price$value3 = price.value) === null || _price$value3 === void 0 ? void 0 : _price$value3.centAmount) === 'number') {
|
|
4766
4814
|
const amount = price.value.centAmount / (1 + taxRate.amount);
|
|
4767
4815
|
centAmount = shouldRoundAmount ? Math.round(amount) : amount;
|
|
4768
4816
|
}
|
|
4769
4817
|
let preciseAmount;
|
|
4770
|
-
if (price.value
|
|
4818
|
+
if (((_price$value4 = price.value) === null || _price$value4 === void 0 ? void 0 : _price$value4.type) === PRECISION_TYPES.highPrecision) preciseAmount = price.value.preciseAmount / (1 + taxRate.amount);
|
|
4771
4819
|
return _objectSpread$14(_objectSpread$14({}, price.value), {}, {
|
|
4772
4820
|
centAmount,
|
|
4773
4821
|
preciseAmount
|
|
@@ -4776,14 +4824,15 @@ function getNetUnitPrice(_ref) {
|
|
|
4776
4824
|
|
|
4777
4825
|
// when shipping mode is single
|
|
4778
4826
|
if (lineItem.taxRate && lineItem.taxRate.includedInPrice) {
|
|
4827
|
+
var _price$value5, _price$value6;
|
|
4779
4828
|
let centAmount;
|
|
4780
4829
|
// should accept 0 value
|
|
4781
|
-
if (typeof price.value
|
|
4830
|
+
if (typeof ((_price$value5 = price.value) === null || _price$value5 === void 0 ? void 0 : _price$value5.centAmount) === 'number') {
|
|
4782
4831
|
const amount = price.value.centAmount / (1 + lineItem.taxRate.amount);
|
|
4783
4832
|
centAmount = shouldRoundAmount ? Math.round(amount) : amount;
|
|
4784
4833
|
}
|
|
4785
4834
|
let preciseAmount;
|
|
4786
|
-
if (price.value
|
|
4835
|
+
if (((_price$value6 = price.value) === null || _price$value6 === void 0 ? void 0 : _price$value6.type) === PRECISION_TYPES.highPrecision) preciseAmount = price.value.preciseAmount / (1 + lineItem.taxRate.amount);
|
|
4787
4836
|
return _objectSpread$14(_objectSpread$14({}, price.value), {}, {
|
|
4788
4837
|
centAmount,
|
|
4789
4838
|
preciseAmount
|
|
@@ -4817,18 +4866,18 @@ const transformCustomFieldFromGraphQLResponse = resource => {
|
|
|
4817
4866
|
key: resource.custom.type.key,
|
|
4818
4867
|
name: transformLocalizedFieldToLocalizedString(resource.custom.type.nameAllLocales),
|
|
4819
4868
|
fieldDefinitions: _mapInstanceProperty(_context = resource.custom.type.fieldDefinitions).call(_context, fieldDefinition => {
|
|
4820
|
-
var _context2, _context3;
|
|
4869
|
+
var _fieldDefinition$type, _context2, _fieldDefinition$type2, _context3;
|
|
4821
4870
|
return {
|
|
4822
4871
|
name: fieldDefinition.name,
|
|
4823
4872
|
required: fieldDefinition.required,
|
|
4824
|
-
type: fieldDefinition.type
|
|
4873
|
+
type: ((_fieldDefinition$type = fieldDefinition.type) === null || _fieldDefinition$type === void 0 || (_fieldDefinition$type = _fieldDefinition$type.elementType) === null || _fieldDefinition$type === void 0 ? void 0 : _fieldDefinition$type.name) === 'LocalizedEnum' ? _objectSpread$13(_objectSpread$13({}, fieldDefinition.type), {}, {
|
|
4825
4874
|
elementType: _objectSpread$13(_objectSpread$13({}, fieldDefinition.type.elementType), {}, {
|
|
4826
4875
|
values: _mapInstanceProperty(_context2 = _valuesInstanceProperty(fieldDefinition.type.elementType)).call(_context2, value => ({
|
|
4827
4876
|
key: value.key,
|
|
4828
4877
|
label: transformLocalizedFieldToLocalizedString(value.labelAllLocales)
|
|
4829
4878
|
}))
|
|
4830
4879
|
})
|
|
4831
|
-
}) : fieldDefinition.type
|
|
4880
|
+
}) : ((_fieldDefinition$type2 = fieldDefinition.type) === null || _fieldDefinition$type2 === void 0 ? void 0 : _fieldDefinition$type2.name) === 'LocalizedEnum' ? _objectSpread$13(_objectSpread$13({}, fieldDefinition.type), {}, {
|
|
4832
4881
|
values: _mapInstanceProperty(_context3 = _valuesInstanceProperty(fieldDefinition.type)).call(_context3, value => ({
|
|
4833
4882
|
key: value.key,
|
|
4834
4883
|
label: transformLocalizedFieldToLocalizedString(value.labelAllLocales)
|
|
@@ -4855,7 +4904,7 @@ const convertProductSelectionFromGraphQl = productSelection => {
|
|
|
4855
4904
|
from: 'nameAllLocales',
|
|
4856
4905
|
to: 'name'
|
|
4857
4906
|
}])), {}, {
|
|
4858
|
-
custom: productSelection
|
|
4907
|
+
custom: productSelection !== null && productSelection !== void 0 && productSelection.custom ? transformCustomFieldFromGraphQLResponse(productSelection) : null
|
|
4859
4908
|
});
|
|
4860
4909
|
};
|
|
4861
4910
|
|
|
@@ -4985,17 +5034,17 @@ function _callSuper$5(_this, derived, args) {
|
|
|
4985
5034
|
var FetchTypeDefinitionsQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchTypeDefinitionsQuery" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "where" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "limit" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "offset" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "typeDefinitions" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "where" }, value: { kind: "Variable", name: { kind: "Name", value: "where" } } }, { kind: "Argument", name: { kind: "Name", value: "limit" }, value: { kind: "Variable", name: { kind: "Name", value: "limit" } } }, { kind: "Argument", name: { kind: "Name", value: "offset" }, value: { kind: "Variable", name: { kind: "Name", value: "offset" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "fieldDefinitions" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "SetType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "elementType" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "EnumType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "values" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "label" }, arguments: [], directives: [] }] } }] } }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "LocalizedEnumType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "values" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "EnumType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "values" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "label" }, arguments: [], directives: [] }] } }] } }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "LocalizedEnumType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "values" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }] } }] } }] } }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "ReferenceType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "referenceTypeId" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }], loc: { start: 0, end: 1172, source: { body: "query FetchTypeDefinitionsQuery($where: String, $limit: Int, $offset: Int) {\n typeDefinitions(where: $where, limit: $limit, offset: $offset) {\n results {\n fieldDefinitions {\n type {\n name\n ... on SetType {\n elementType {\n name\n ... on EnumType {\n values {\n key\n label\n }\n }\n ... on LocalizedEnumType {\n values {\n key\n labelAllLocales {\n value\n locale\n }\n }\n }\n }\n }\n ... on EnumType {\n values {\n key\n label\n }\n }\n ... on LocalizedEnumType {\n values {\n key\n labelAllLocales {\n value\n locale\n }\n }\n }\n ... on ReferenceType {\n referenceTypeId\n }\n }\n name\n labelAllLocales {\n value\n locale\n }\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
4986
5035
|
const customizableResources$1 = ['asset', 'category', 'channel', 'customer', 'order', 'discount-code', 'cart-discount', 'inventory-entry', 'line-item', 'custom-line-item', 'product-price', 'payment', 'payment-interface-interaction', 'shopping-list', 'shopping-list-text-line-item', 'standalone-price', 'review'];
|
|
4987
5036
|
let CustomFieldDefinitionsConnector = /*#__PURE__*/function (_Component) {
|
|
4988
|
-
_inherits(CustomFieldDefinitionsConnector, _Component);
|
|
4989
5037
|
function CustomFieldDefinitionsConnector() {
|
|
4990
5038
|
_classCallCheck(this, CustomFieldDefinitionsConnector);
|
|
4991
5039
|
return _callSuper$5(this, CustomFieldDefinitionsConnector, arguments);
|
|
4992
5040
|
}
|
|
4993
|
-
|
|
5041
|
+
_inherits(CustomFieldDefinitionsConnector, _Component);
|
|
5042
|
+
return _createClass(CustomFieldDefinitionsConnector, [{
|
|
4994
5043
|
key: "componentDidMount",
|
|
4995
5044
|
value: function componentDidMount() {
|
|
4996
5045
|
var _context;
|
|
4997
5046
|
const hasUnsupportedResource = _someInstanceProperty(_context = this.props.resources).call(_context, resource => !_includesInstanceProperty(customizableResources$1).call(customizableResources$1, resource));
|
|
4998
|
-
!!hasUnsupportedResource ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
5047
|
+
!!hasUnsupportedResource ? process.env.NODE_ENV !== "production" ? invariant(false, "core/components/custom-field-definitions-connector: some of the specified resources are not supported.") : invariant(false) : void 0;
|
|
4999
5048
|
}
|
|
5000
5049
|
}, {
|
|
5001
5050
|
key: "render",
|
|
@@ -5008,15 +5057,14 @@ let CustomFieldDefinitionsConnector = /*#__PURE__*/function (_Component) {
|
|
|
5008
5057
|
});
|
|
5009
5058
|
}
|
|
5010
5059
|
}]);
|
|
5011
|
-
return CustomFieldDefinitionsConnector;
|
|
5012
5060
|
}(Component);
|
|
5013
5061
|
CustomFieldDefinitionsConnector.displayName = 'CustomFieldDefinitionsConnector';
|
|
5014
5062
|
CustomFieldDefinitionsConnector.defaultProps = {
|
|
5015
5063
|
resources: []
|
|
5016
5064
|
};
|
|
5017
|
-
const stringifyResources$1 = resources => _mapInstanceProperty(resources).call(resources, resource =>
|
|
5065
|
+
const stringifyResources$1 = resources => _mapInstanceProperty(resources).call(resources, resource => "\"".concat(resource, "\"")).join();
|
|
5018
5066
|
const mapPropsToOptions = ownProps => {
|
|
5019
|
-
const where = ownProps.resources.length > 0 ?
|
|
5067
|
+
const where = ownProps.resources.length > 0 ? "resourceTypeIds contains any (".concat(stringifyResources$1(ownProps.resources), ")") : undefined;
|
|
5020
5068
|
return {
|
|
5021
5069
|
variables: {
|
|
5022
5070
|
where,
|
|
@@ -5085,19 +5133,19 @@ const graphQlDocToForm = typeDefinition => {
|
|
|
5085
5133
|
key: typeDefinition.key,
|
|
5086
5134
|
name: transformLocalizedFieldToLocalizedString(typeDefinition.nameAllLocales),
|
|
5087
5135
|
fieldDefinitions: _mapInstanceProperty(_context = typeDefinition.fieldDefinitions).call(_context, fieldDefinition => {
|
|
5088
|
-
var _context2, _context3;
|
|
5136
|
+
var _fieldDefinition$type, _context2, _fieldDefinition$type2, _context3;
|
|
5089
5137
|
return {
|
|
5090
5138
|
name: fieldDefinition.name,
|
|
5091
5139
|
required: fieldDefinition.required,
|
|
5092
5140
|
inputHint: fieldDefinition.inputHint,
|
|
5093
|
-
type: fieldDefinition.type
|
|
5141
|
+
type: ((_fieldDefinition$type = fieldDefinition.type) === null || _fieldDefinition$type === void 0 || (_fieldDefinition$type = _fieldDefinition$type.elementType) === null || _fieldDefinition$type === void 0 ? void 0 : _fieldDefinition$type.name) === 'LocalizedEnum' ? _objectSpread$10(_objectSpread$10({}, fieldDefinition.type), {}, {
|
|
5094
5142
|
elementType: _objectSpread$10(_objectSpread$10({}, fieldDefinition.type.elementType), {}, {
|
|
5095
5143
|
values: _mapInstanceProperty(_context2 = _valuesInstanceProperty(fieldDefinition.type.elementType)).call(_context2, value => ({
|
|
5096
5144
|
key: value.key,
|
|
5097
5145
|
label: transformLocalizedFieldToLocalizedString(value.labelAllLocales)
|
|
5098
5146
|
}))
|
|
5099
5147
|
})
|
|
5100
|
-
}) : fieldDefinition.type
|
|
5148
|
+
}) : ((_fieldDefinition$type2 = fieldDefinition.type) === null || _fieldDefinition$type2 === void 0 ? void 0 : _fieldDefinition$type2.name) === 'LocalizedEnum' ? _objectSpread$10(_objectSpread$10({}, fieldDefinition.type), {}, {
|
|
5101
5149
|
values: _mapInstanceProperty(_context3 = _valuesInstanceProperty(fieldDefinition.type)).call(_context3, value => ({
|
|
5102
5150
|
key: value.key,
|
|
5103
5151
|
label: transformLocalizedFieldToLocalizedString(value.labelAllLocales)
|
|
@@ -5129,7 +5177,7 @@ const formToGraphQlDoc = formCustomFields => ({
|
|
|
5129
5177
|
// TODO(pa3): find usages and make sure only 1 param is passed
|
|
5130
5178
|
const createEmptyCustomFields = typeDefinition => ({
|
|
5131
5179
|
fields: {},
|
|
5132
|
-
type: typeDefinition
|
|
5180
|
+
type: (typeDefinition === null || typeDefinition === void 0 ? void 0 : typeDefinition.type) || {
|
|
5133
5181
|
fieldDefinitions: []
|
|
5134
5182
|
}
|
|
5135
5183
|
});
|
|
@@ -5156,17 +5204,17 @@ const emptyTypeDefinitions = {
|
|
|
5156
5204
|
results: []
|
|
5157
5205
|
};
|
|
5158
5206
|
let CustomFieldTypeDefinitionsConnector = /*#__PURE__*/function (_Component) {
|
|
5159
|
-
_inherits(CustomFieldTypeDefinitionsConnector, _Component);
|
|
5160
5207
|
function CustomFieldTypeDefinitionsConnector() {
|
|
5161
5208
|
_classCallCheck(this, CustomFieldTypeDefinitionsConnector);
|
|
5162
5209
|
return _callSuper$4(this, CustomFieldTypeDefinitionsConnector, arguments);
|
|
5163
5210
|
}
|
|
5164
|
-
|
|
5211
|
+
_inherits(CustomFieldTypeDefinitionsConnector, _Component);
|
|
5212
|
+
return _createClass(CustomFieldTypeDefinitionsConnector, [{
|
|
5165
5213
|
key: "componentDidMount",
|
|
5166
5214
|
value: function componentDidMount() {
|
|
5167
5215
|
var _context;
|
|
5168
5216
|
const hasUnsupportedResource = _someInstanceProperty(_context = this.props.resources).call(_context, resource => !_includesInstanceProperty(customizableResources).call(customizableResources, resource));
|
|
5169
|
-
!!hasUnsupportedResource ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
5217
|
+
!!hasUnsupportedResource ? process.env.NODE_ENV !== "production" ? invariant(false, "core/components/custom-field-definitions-connector: some of the specified resources are not supported.") : invariant(false) : void 0;
|
|
5170
5218
|
}
|
|
5171
5219
|
}, {
|
|
5172
5220
|
key: "render",
|
|
@@ -5179,7 +5227,6 @@ let CustomFieldTypeDefinitionsConnector = /*#__PURE__*/function (_Component) {
|
|
|
5179
5227
|
});
|
|
5180
5228
|
}
|
|
5181
5229
|
}]);
|
|
5182
|
-
return CustomFieldTypeDefinitionsConnector;
|
|
5183
5230
|
}(Component);
|
|
5184
5231
|
CustomFieldTypeDefinitionsConnector.displayName = 'CustomFieldTypeDefinitionsConnector';
|
|
5185
5232
|
CustomFieldTypeDefinitionsConnector.defaultProps = {
|
|
@@ -5191,9 +5238,9 @@ CustomFieldTypeDefinitionsConnector.graphQlDocToForm = graphQlDocToForm;
|
|
|
5191
5238
|
CustomFieldTypeDefinitionsConnector.formToRestDoc = formToRestDoc;
|
|
5192
5239
|
CustomFieldTypeDefinitionsConnector.formToGraphQlDoc = formToGraphQlDoc;
|
|
5193
5240
|
CustomFieldTypeDefinitionsConnector.createEmptyCustomFields = createEmptyCustomFields;
|
|
5194
|
-
const stringifyResources = resources => _mapInstanceProperty(resources).call(resources, resource =>
|
|
5241
|
+
const stringifyResources = resources => _mapInstanceProperty(resources).call(resources, resource => "\"".concat(resource, "\"")).join();
|
|
5195
5242
|
const createGraphQlOptions = ownProps => {
|
|
5196
|
-
const where = ownProps.resources.length > 0 ?
|
|
5243
|
+
const where = ownProps.resources.length > 0 ? "resourceTypeIds contains any (".concat(stringifyResources(ownProps.resources), ")") : undefined;
|
|
5197
5244
|
return {
|
|
5198
5245
|
variables: {
|
|
5199
5246
|
where,
|
|
@@ -5269,7 +5316,7 @@ const extractDuplicatedValues = (values, type, language, languages) => {
|
|
|
5269
5316
|
let validatedValues = [];
|
|
5270
5317
|
if (type.name.toLowerCase() === 'money') {
|
|
5271
5318
|
validatedValues = unique(values, ['amount', 'currencyCode']);
|
|
5272
|
-
} else if (type.name.toLowerCase() === 'reference') validatedValues = unique(_filterInstanceProperty(values).call(values, value => value
|
|
5319
|
+
} else if (type.name.toLowerCase() === 'reference') validatedValues = unique(_filterInstanceProperty(values).call(values, value => value === null || value === void 0 ? void 0 : value.id), ['id']);else if (type.name.toLowerCase() === 'localizedstring') {
|
|
5273
5320
|
validatedValues = unique(values, languages);
|
|
5274
5321
|
} else validatedValues = unique(values);
|
|
5275
5322
|
return validatedValues;
|
|
@@ -5516,6 +5563,7 @@ const getSubfieldLanguage = subfieldName => {
|
|
|
5516
5563
|
return subfieldName.substring(lastDotIndex + 1);
|
|
5517
5564
|
};
|
|
5518
5565
|
function CustomLocalizedTextInput(props) {
|
|
5566
|
+
var _value$language;
|
|
5519
5567
|
const _useApplicationContex = useApplicationContext(applicationContext => ({
|
|
5520
5568
|
language: applicationContext.dataLocale,
|
|
5521
5569
|
languages: applicationContext.project.languages
|
|
@@ -5541,7 +5589,7 @@ function CustomLocalizedTextInput(props) {
|
|
|
5541
5589
|
props.renderWarnings && props.handleWarningChange(props.name, props.fieldDefinition, rawValue);
|
|
5542
5590
|
});
|
|
5543
5591
|
const InputComponent = isMultiLine ? LocalizedMultilineTextInput : LocalizedTextInput;
|
|
5544
|
-
const tooltipTitle = isMultiLine ? '' : value ? value[language]
|
|
5592
|
+
const tooltipTitle = isMultiLine ? '' : value ? (_value$language = value[language]) !== null && _value$language !== void 0 ? _value$language : '' : '';
|
|
5545
5593
|
return jsx(CustomFieldTooltip, {
|
|
5546
5594
|
title: tooltipTitle,
|
|
5547
5595
|
children: jsx(InputComponent, {
|
|
@@ -5592,7 +5640,8 @@ function CustomBooleanInput(props) {
|
|
|
5592
5640
|
CustomBooleanInput.displayName = 'CustomBooleanInput';
|
|
5593
5641
|
|
|
5594
5642
|
function CustomNumberInput(props) {
|
|
5595
|
-
|
|
5643
|
+
var _props$value;
|
|
5644
|
+
const value = (_props$value = props.value) !== null && _props$value !== void 0 ? _props$value : '';
|
|
5596
5645
|
const handleChange = makeChangeHandler(rawValue => {
|
|
5597
5646
|
props.setFieldValue(props.name, !rawValue ? undefined : Number(rawValue));
|
|
5598
5647
|
props.renderWarnings && props.handleWarningChange(props.name, props.fieldDefinition, rawValue);
|
|
@@ -5641,7 +5690,7 @@ const fixAmount = value => {
|
|
|
5641
5690
|
// data user just entered effectively preventing full data from being entered.
|
|
5642
5691
|
const fixEnteredValue = (newValue, initialValue, currencies) => {
|
|
5643
5692
|
const withFixedCurrency = fixCurrencyCode(newValue, currencies);
|
|
5644
|
-
if (!initialValue
|
|
5693
|
+
if (!(initialValue !== null && initialValue !== void 0 && initialValue.amount)) {
|
|
5645
5694
|
return fixAmount(withFixedCurrency);
|
|
5646
5695
|
}
|
|
5647
5696
|
return withFixedCurrency;
|
|
@@ -5711,12 +5760,13 @@ const convertTypeValuesToOptions$1 = defaultMemoize((type, dataLocale, languages
|
|
|
5711
5760
|
key: 'label',
|
|
5712
5761
|
locale: dataLocale,
|
|
5713
5762
|
fallbackOrder: languages,
|
|
5714
|
-
fallback:
|
|
5763
|
+
fallback: "".concat(value.key, " (key)")
|
|
5715
5764
|
}),
|
|
5716
5765
|
value: value.key
|
|
5717
5766
|
}));
|
|
5718
5767
|
});
|
|
5719
5768
|
function CustomLocalizedEnumInput(props) {
|
|
5769
|
+
var _options$find$label, _options$find;
|
|
5720
5770
|
const _useApplicationContex = useApplicationContext(applicationContext => ({
|
|
5721
5771
|
languages: applicationContext.project.languages,
|
|
5722
5772
|
dataLocale: applicationContext.dataLocale
|
|
@@ -5728,7 +5778,7 @@ function CustomLocalizedEnumInput(props) {
|
|
|
5728
5778
|
props.setFieldValue(props.name, rawValue);
|
|
5729
5779
|
props.renderWarnings && props.handleWarningChange(props.name, props.fieldDefinition, rawValue);
|
|
5730
5780
|
});
|
|
5731
|
-
const tooltipTitle = props.value ? _findInstanceProperty(options).call(options, option => option.value === props.value)
|
|
5781
|
+
const tooltipTitle = props.value ? (_options$find$label = (_options$find = _findInstanceProperty(options).call(options, option => option.value === props.value)) === null || _options$find === void 0 ? void 0 : _options$find.label) !== null && _options$find$label !== void 0 ? _options$find$label : '' : '';
|
|
5732
5782
|
return jsx(CustomFieldTooltip, {
|
|
5733
5783
|
title: tooltipTitle,
|
|
5734
5784
|
children: jsx(SelectInput, {
|
|
@@ -5751,7 +5801,8 @@ function CustomLocalizedEnumInput(props) {
|
|
|
5751
5801
|
CustomLocalizedEnumInput.displayName = 'CustomLocalizedEnumInput';
|
|
5752
5802
|
|
|
5753
5803
|
function CustomRawIdReferenceInput(props) {
|
|
5754
|
-
|
|
5804
|
+
var _props$value;
|
|
5805
|
+
const value = ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.id) || '';
|
|
5755
5806
|
return jsx(CustomFieldTooltip, {
|
|
5756
5807
|
title: value,
|
|
5757
5808
|
children: jsx(TextInput, {
|
|
@@ -5797,7 +5848,7 @@ function getCategoriesByIds(apolloClient, options) {
|
|
|
5797
5848
|
return apolloClient.query({
|
|
5798
5849
|
query: FetchCategoriesByIds,
|
|
5799
5850
|
variables: {
|
|
5800
|
-
where:
|
|
5851
|
+
where: "id in (".concat(_mapInstanceProperty(_context2 = options.ids).call(_context2, id => "\"".concat(id, "\"")).join(', '), ")")
|
|
5801
5852
|
},
|
|
5802
5853
|
context: {
|
|
5803
5854
|
target: GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM
|
|
@@ -5896,10 +5947,13 @@ const useReferenceSearchItems = _ref => {
|
|
|
5896
5947
|
};
|
|
5897
5948
|
};
|
|
5898
5949
|
function ReferenceSearch(props) {
|
|
5899
|
-
const ids = useMemo(() =>
|
|
5900
|
-
|
|
5901
|
-
return
|
|
5902
|
-
|
|
5950
|
+
const ids = useMemo(() => {
|
|
5951
|
+
var _props$value, _props$value2;
|
|
5952
|
+
return props.value ? props.isMulti ? (_props$value = props.value) === null || _props$value === void 0 ? void 0 : _mapInstanceProperty(_props$value).call(_props$value, _ref2 => {
|
|
5953
|
+
let id = _ref2.id;
|
|
5954
|
+
return id;
|
|
5955
|
+
}) : [(_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.id] : [];
|
|
5956
|
+
}, [props.value, props.isMulti]);
|
|
5903
5957
|
const _useReferenceSearchIt = useReferenceSearchItems({
|
|
5904
5958
|
loadItemsBySearchTerm: props.loadItemsBySearchTerm,
|
|
5905
5959
|
loadItemsByIds: props.loadItemsByIds,
|
|
@@ -5910,14 +5964,14 @@ function ReferenceSearch(props) {
|
|
|
5910
5964
|
areSomeItemsMissing = _useReferenceSearchIt.areSomeItemsMissing,
|
|
5911
5965
|
handleLoadItems = _useReferenceSearchIt.handleLoadItems;
|
|
5912
5966
|
if (areItemsLoading) return null;
|
|
5913
|
-
const value = props.isMulti ? items : items
|
|
5967
|
+
const value = props.isMulti ? items : items === null || items === void 0 ? void 0 : items[0];
|
|
5914
5968
|
let filterValue = null;
|
|
5915
5969
|
if (value) filterValue = props.isMulti ? _mapInstanceProperty(value).call(value, props.mapItemToOption) : props.mapItemToOption(value);
|
|
5916
5970
|
const tooltipTitle = value || props.value ? props.mapItemToOption(value || props.value).label : '';
|
|
5917
5971
|
const loadItems = value => _Promise.resolve(handleLoadItems(value)).then(items => _mapInstanceProperty(items).call(items, item => props.mapItemToOption(item)));
|
|
5918
5972
|
const handleChange = event => {
|
|
5919
|
-
var _context;
|
|
5920
|
-
const option = props.isMulti ? _mapInstanceProperty(_context = event.target.value).call(_context, item => item.value) : event.target.value
|
|
5973
|
+
var _context, _event$target$value;
|
|
5974
|
+
const option = props.isMulti ? _mapInstanceProperty(_context = event.target.value).call(_context, item => item.value) : ((_event$target$value = event.target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.value) || null;
|
|
5921
5975
|
props.onChange(option);
|
|
5922
5976
|
};
|
|
5923
5977
|
return jsxs("div", {
|
|
@@ -5991,8 +6045,9 @@ const messages$B = defineMessages({
|
|
|
5991
6045
|
});
|
|
5992
6046
|
|
|
5993
6047
|
function ownKeys$U(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5994
|
-
function _objectSpread$U(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
6048
|
+
function _objectSpread$U(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys$U(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys$U(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5995
6049
|
function Option$1(props) {
|
|
6050
|
+
var _context, _context2;
|
|
5996
6051
|
const _useApplicationContex = useApplicationContext(applicationContext => ({
|
|
5997
6052
|
language: applicationContext.dataLocale,
|
|
5998
6053
|
languages: applicationContext.project.languages
|
|
@@ -6013,19 +6068,19 @@ function Option$1(props) {
|
|
|
6013
6068
|
fallbackOrder: languages
|
|
6014
6069
|
})
|
|
6015
6070
|
}), category.parent && jsx(Text.Detail, {
|
|
6016
|
-
children:
|
|
6071
|
+
children: _concatInstanceProperty(_context = "".concat(formatMessage(messages$B.parentCategory), ": ")).call(_context, formatLocalizedString(category.parent, {
|
|
6017
6072
|
key: 'name',
|
|
6018
6073
|
locale: language,
|
|
6019
6074
|
fallbackOrder: languages
|
|
6020
|
-
})
|
|
6075
|
+
}))
|
|
6021
6076
|
}), jsx(Text.Detail, {
|
|
6022
|
-
children:
|
|
6077
|
+
children: "Slug: ".concat(formatLocalizedString(category, {
|
|
6023
6078
|
key: 'slug',
|
|
6024
6079
|
locale: language,
|
|
6025
6080
|
fallbackOrder: languages
|
|
6026
|
-
})
|
|
6081
|
+
}))
|
|
6027
6082
|
}), category.externalId && jsx(Text.Detail, {
|
|
6028
|
-
children:
|
|
6083
|
+
children: _concatInstanceProperty(_context2 = "".concat(formatMessage(messages$B.externalId), ": ")).call(_context2, category.externalId || NO_VALUE_FALLBACK)
|
|
6029
6084
|
})]
|
|
6030
6085
|
})
|
|
6031
6086
|
}));
|
|
@@ -6089,7 +6144,7 @@ var CategorySearchPickerOptionFragment$1 = { kind: "Document", definitions: [{ k
|
|
|
6089
6144
|
function useCachedCategoryOptions(ids) {
|
|
6090
6145
|
const apolloClient = useApolloClient$1();
|
|
6091
6146
|
const fragments = _mapInstanceProperty(ids).call(ids, id => apolloClient.readFragment({
|
|
6092
|
-
id:
|
|
6147
|
+
id: "CategorySearch:".concat(id),
|
|
6093
6148
|
fragment: CategorySearchPickerOptionFragment$1
|
|
6094
6149
|
}));
|
|
6095
6150
|
return _mapInstanceProperty(fragments).call(fragments, category => transformLocalizedFieldsForCategory(category, [{
|
|
@@ -6104,8 +6159,8 @@ function useCachedCategoryOptions(ids) {
|
|
|
6104
6159
|
var SearchCartDiscount = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "SearchCartDiscount" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "where" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "cartDiscounts" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "limit" }, value: { kind: "IntValue", value: "500" } }, { kind: "Argument", name: { kind: "Name", value: "where" }, value: { kind: "Variable", name: { kind: "Name", value: "where" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }] } }], loc: { start: 0, end: 425, source: { body: "query SearchCartDiscount($where: String) {\n cartDiscounts(limit: 500, where: $where) {\n total\n results {\n id\n key\n nameAllLocales {\n locale\n value\n }\n }\n }\n}\n\nquery CartDiscountsCount {\n cartDiscounts {\n total\n }\n}\n\nquery FetchCartDiscountById($cartDiscountId: String!) {\n cartDiscount(id: $cartDiscountId) {\n id\n nameAllLocales {\n locale\n value\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
6105
6160
|
var FetchCartDiscountById = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchCartDiscountById" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "cartDiscountId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "cartDiscount" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "id" }, value: { kind: "Variable", name: { kind: "Name", value: "cartDiscountId" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }], loc: { start: 0, end: 425, source: { body: "query SearchCartDiscount($where: String) {\n cartDiscounts(limit: 500, where: $where) {\n total\n results {\n id\n key\n nameAllLocales {\n locale\n value\n }\n }\n }\n}\n\nquery CartDiscountsCount {\n cartDiscounts {\n total\n }\n}\n\nquery FetchCartDiscountById($cartDiscountId: String!) {\n cartDiscount(id: $cartDiscountId) {\n id\n nameAllLocales {\n locale\n value\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
6106
6161
|
const transformCartDiscountResponse = response => {
|
|
6107
|
-
var _context;
|
|
6108
|
-
return _mapInstanceProperty(_context = response.data
|
|
6162
|
+
var _context, _response$data;
|
|
6163
|
+
return _mapInstanceProperty(_context = ((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.cartDiscounts.results) || []).call(_context, cartDiscount => transformLocalizedFieldsForCartDiscount(cartDiscount));
|
|
6109
6164
|
};
|
|
6110
6165
|
function queryCartDiscounts(apolloClient) {
|
|
6111
6166
|
return apolloClient.query({
|
|
@@ -6117,14 +6172,14 @@ function queryCartDiscounts(apolloClient) {
|
|
|
6117
6172
|
}).then(transformCartDiscountResponse);
|
|
6118
6173
|
}
|
|
6119
6174
|
const getWhereClause = function () {
|
|
6120
|
-
var _context2, _context3;
|
|
6175
|
+
var _context2, _context3, _context4;
|
|
6121
6176
|
let searchText = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
6122
6177
|
let language = arguments.length > 1 ? arguments[1] : undefined;
|
|
6123
6178
|
const query = _trimInstanceProperty(_context2 = _JSON$stringify(searchText)).call(_context2);
|
|
6124
|
-
const idQuery = isUUID(searchText) &&
|
|
6125
|
-
const nameQuery =
|
|
6126
|
-
const keyQuery =
|
|
6127
|
-
return _filterInstanceProperty(
|
|
6179
|
+
const idQuery = isUUID(searchText) && "id = ".concat(query);
|
|
6180
|
+
const nameQuery = _concatInstanceProperty(_context3 = "name(".concat(language, " = ")).call(_context3, query, ")");
|
|
6181
|
+
const keyQuery = "key = ".concat(query);
|
|
6182
|
+
return _filterInstanceProperty(_context4 = [idQuery, nameQuery, keyQuery]).call(_context4, Boolean).join(' or ');
|
|
6128
6183
|
};
|
|
6129
6184
|
function searchCartDiscountsByExactMatch(apolloClient, options) {
|
|
6130
6185
|
return apolloClient.query({
|
|
@@ -6147,7 +6202,10 @@ function getCartDiscountById(apolloClient, options) {
|
|
|
6147
6202
|
context: {
|
|
6148
6203
|
target: GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM
|
|
6149
6204
|
}
|
|
6150
|
-
}).then(response =>
|
|
6205
|
+
}).then(response => {
|
|
6206
|
+
var _response$data2;
|
|
6207
|
+
return (_response$data2 = response.data) !== null && _response$data2 !== void 0 && _response$data2.cartDiscount ? transformLocalizedFieldsForCartDiscount(response.data.cartDiscount) : null;
|
|
6208
|
+
});
|
|
6151
6209
|
}
|
|
6152
6210
|
|
|
6153
6211
|
const messages$A = defineMessages({
|
|
@@ -6224,7 +6282,7 @@ function CartDiscountReferenceSearch(props) {
|
|
|
6224
6282
|
}),
|
|
6225
6283
|
loading = _useQuery.loading,
|
|
6226
6284
|
data = _useQuery.data;
|
|
6227
|
-
const isExactMatch = data
|
|
6285
|
+
const isExactMatch = (data === null || data === void 0 ? void 0 : data.cartDiscounts.total) > QUERY_MAX_LIMIT;
|
|
6228
6286
|
const _useIntl = useIntl(),
|
|
6229
6287
|
formatMessage = _useIntl.formatMessage;
|
|
6230
6288
|
const apolloClient = useApolloClient$1();
|
|
@@ -6364,6 +6422,7 @@ const DropdownIndicator = () => jsx(SearchIcon, {
|
|
|
6364
6422
|
});
|
|
6365
6423
|
DropdownIndicator.displayName = 'DropdownIndicator';
|
|
6366
6424
|
const ProductPickerInput = _ref => {
|
|
6425
|
+
var _currentOption$data$l, _currentOption$data;
|
|
6367
6426
|
let isClearable = _ref.isClearable,
|
|
6368
6427
|
isDisabled = _ref.isDisabled,
|
|
6369
6428
|
isReadOnly = _ref.isReadOnly,
|
|
@@ -6384,19 +6443,20 @@ const ProductPickerInput = _ref => {
|
|
|
6384
6443
|
loadingError = _useState2[0],
|
|
6385
6444
|
setLoadingError = _useState2[1];
|
|
6386
6445
|
const convertProductToOption = useCallback(product => {
|
|
6446
|
+
var _masterData$current;
|
|
6387
6447
|
if (!product) return null;
|
|
6388
6448
|
const id = product.id,
|
|
6389
6449
|
key = product.key,
|
|
6390
6450
|
masterData = product.masterData;
|
|
6391
|
-
const localizedName = formatLocalizedFieldToString(masterData.current
|
|
6451
|
+
const localizedName = formatLocalizedFieldToString((_masterData$current = masterData.current) === null || _masterData$current === void 0 ? void 0 : _masterData$current.nameAllLocales);
|
|
6392
6452
|
return {
|
|
6393
|
-
label: localizedName + (key ?
|
|
6453
|
+
label: localizedName + (key ? " (key: ".concat(key, ")") : ''),
|
|
6394
6454
|
value: id,
|
|
6395
6455
|
name: localizedName,
|
|
6396
6456
|
key
|
|
6397
6457
|
};
|
|
6398
6458
|
}, [formatLocalizedFieldToString]);
|
|
6399
|
-
const prefixSearchFields = useMemo(() => [
|
|
6459
|
+
const prefixSearchFields = useMemo(() => ["masterData.current.name.".concat(dataLocale), 'key'], [dataLocale]);
|
|
6400
6460
|
const loadOptions = useLoadOptions({
|
|
6401
6461
|
query: GetProductsQuery,
|
|
6402
6462
|
prefixSearchFields
|
|
@@ -6427,12 +6487,12 @@ const ProductPickerInput = _ref => {
|
|
|
6427
6487
|
setLoadingError(null);
|
|
6428
6488
|
handleInternalInputChange(event);
|
|
6429
6489
|
}, [handleInternalInputChange]);
|
|
6430
|
-
const isCurrentOptionLoadingFailed = Boolean(currentOption
|
|
6490
|
+
const isCurrentOptionLoadingFailed = Boolean(currentOption === null || currentOption === void 0 ? void 0 : currentOption.error);
|
|
6431
6491
|
useEffect(() => {
|
|
6432
6492
|
if (isCurrentOptionLoadingFailed) onError(currentOption.error);
|
|
6433
6493
|
}, [isCurrentOptionLoadingFailed, onError, currentOption]);
|
|
6434
6494
|
const isLoadingFailed = isCurrentOptionLoadingFailed || Boolean(loadingError);
|
|
6435
|
-
const tooltipTitle = currentOption
|
|
6495
|
+
const tooltipTitle = (_currentOption$data$l = currentOption === null || currentOption === void 0 || (_currentOption$data = currentOption.data) === null || _currentOption$data === void 0 ? void 0 : _currentOption$data.label) !== null && _currentOption$data$l !== void 0 ? _currentOption$data$l : '';
|
|
6436
6496
|
return jsx(Constraints.Horizontal, {
|
|
6437
6497
|
max: "scale",
|
|
6438
6498
|
children: currentOption.loading ? jsx(CenteredLoadingSpinner, {}) : jsxs(Spacings.Stack, {
|
|
@@ -6472,7 +6532,8 @@ const ProductPickerInput = _ref => {
|
|
|
6472
6532
|
ProductPickerInput.displayName = 'ProductPickerInput';
|
|
6473
6533
|
|
|
6474
6534
|
function CustomProductReferenceInput(props) {
|
|
6475
|
-
|
|
6535
|
+
var _props$value;
|
|
6536
|
+
const value = ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.id) || '';
|
|
6476
6537
|
return jsx(ProductPickerInput, {
|
|
6477
6538
|
value: value,
|
|
6478
6539
|
name: props.name,
|
|
@@ -6490,7 +6551,8 @@ function CustomProductReferenceInput(props) {
|
|
|
6490
6551
|
CustomProductReferenceInput.displayName = 'CustomProductReferenceInput';
|
|
6491
6552
|
|
|
6492
6553
|
function CustomProductTypeReferenceInput(props) {
|
|
6493
|
-
|
|
6554
|
+
var _props$value;
|
|
6555
|
+
const value = ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.id) || '';
|
|
6494
6556
|
return jsx(ProductTypePickerInput, {
|
|
6495
6557
|
value: value,
|
|
6496
6558
|
name: props.name,
|
|
@@ -6507,7 +6569,8 @@ function CustomProductTypeReferenceInput(props) {
|
|
|
6507
6569
|
CustomProductTypeReferenceInput.displayName = 'CustomProductTypeReferenceInput';
|
|
6508
6570
|
|
|
6509
6571
|
function CustomChannelReferenceInput(props) {
|
|
6510
|
-
|
|
6572
|
+
var _props$value;
|
|
6573
|
+
const value = ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.id) || '';
|
|
6511
6574
|
return jsx(ChannelPickerInput, {
|
|
6512
6575
|
value: value,
|
|
6513
6576
|
name: props.name,
|
|
@@ -6524,7 +6587,8 @@ function CustomChannelReferenceInput(props) {
|
|
|
6524
6587
|
CustomChannelReferenceInput.displayName = 'CustomChannelReferenceInput';
|
|
6525
6588
|
|
|
6526
6589
|
function CustomStateReferenceInput(props) {
|
|
6527
|
-
|
|
6590
|
+
var _props$value;
|
|
6591
|
+
const value = ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.id) || '';
|
|
6528
6592
|
return jsx(StatePickerInput, {
|
|
6529
6593
|
value: value,
|
|
6530
6594
|
name: props.name,
|
|
@@ -6640,16 +6704,17 @@ function CustomTimeInput(props) {
|
|
|
6640
6704
|
CustomTimeInput.displayName = 'CustomTimeInput';
|
|
6641
6705
|
|
|
6642
6706
|
const convertTypeValuesToOptions = defaultMemoize(typeValues => _mapInstanceProperty(typeValues).call(typeValues, typeValue => ({
|
|
6643
|
-
label: typeValue.label ||
|
|
6707
|
+
label: typeValue.label || "".concat(typeValue.key, " (key)"),
|
|
6644
6708
|
value: typeValue.key
|
|
6645
6709
|
})));
|
|
6646
6710
|
function CustomEnumInput(props) {
|
|
6711
|
+
var _options$find$label, _options$find;
|
|
6647
6712
|
const options = convertTypeValuesToOptions(_valuesInstanceProperty(props.fieldDefinition.type));
|
|
6648
6713
|
const handleChange = makeChangeHandler(rawValue => {
|
|
6649
6714
|
props.setFieldValue(props.name, rawValue);
|
|
6650
6715
|
props.renderWarnings && props.handleWarningChange(props.name, props.fieldDefinition, rawValue);
|
|
6651
6716
|
});
|
|
6652
|
-
const tooltipTitle = props.value ? _findInstanceProperty(options).call(options, option => option.value === props.value)
|
|
6717
|
+
const tooltipTitle = props.value ? (_options$find$label = (_options$find = _findInstanceProperty(options).call(options, option => option.value === props.value)) === null || _options$find === void 0 ? void 0 : _options$find.label) !== null && _options$find$label !== void 0 ? _options$find$label : '' : '';
|
|
6653
6718
|
return jsx(CustomFieldTooltip, {
|
|
6654
6719
|
title: tooltipTitle,
|
|
6655
6720
|
children: jsx(SelectInput, {
|
|
@@ -6727,9 +6792,9 @@ function ownKeys$Q(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySy
|
|
|
6727
6792
|
function _objectSpread$Q(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context7 = ownKeys$Q(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context8 = ownKeys$Q(Object(t))).call(_context8, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6728
6793
|
const getTypeName = type => type.name.toLowerCase();
|
|
6729
6794
|
const findLabel = (enumType, key) => {
|
|
6730
|
-
var _context;
|
|
6795
|
+
var _enumType$values$find, _enumType$values$find2, _context;
|
|
6731
6796
|
const emptyValue = getTypeName(enumType) === 'enum' ? '' : {};
|
|
6732
|
-
return _findInstanceProperty(_context = _valuesInstanceProperty(enumType)).call(_context, value => value.key === key)
|
|
6797
|
+
return (_enumType$values$find = (_enumType$values$find2 = _findInstanceProperty(_context = _valuesInstanceProperty(enumType)).call(_context, value => value.key === key)) === null || _enumType$values$find2 === void 0 ? void 0 : _enumType$values$find2.label) !== null && _enumType$values$find !== void 0 ? _enumType$values$find : emptyValue;
|
|
6733
6798
|
};
|
|
6734
6799
|
const convertEnumValues = (value, attributeDefinition) => {
|
|
6735
6800
|
var _context2, _context3;
|
|
@@ -6795,7 +6860,7 @@ const attributesMapToNameValuePairs = map => {
|
|
|
6795
6860
|
const _excluded$1 = ["WrapperComponent"];
|
|
6796
6861
|
const getAttributeShortName = (fullName, attributesPrefix) => {
|
|
6797
6862
|
if (!attributesPrefix) return fullName;
|
|
6798
|
-
return fullName.replace(
|
|
6863
|
+
return fullName.replace("".concat(attributesPrefix, "."), '');
|
|
6799
6864
|
};
|
|
6800
6865
|
function ProductAttributes(_ref) {
|
|
6801
6866
|
let WrapperComponent = _ref.WrapperComponent,
|
|
@@ -6883,19 +6948,19 @@ function ownKeys$P(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySy
|
|
|
6883
6948
|
function _objectSpread$P(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys$P(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys$P(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6884
6949
|
var FetchProductTypeQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchProductTypeQuery" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "id" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "productType" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "id" }, value: { kind: "Variable", name: { kind: "Name", value: "id" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "attributeDefinitions" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "limit" }, value: { kind: "IntValue", value: "100" } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "isRequired" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "inputHint" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "inputTipAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "SetAttributeDefinitionType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "elementType" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "NestedAttributeDefinitionType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "typeRef" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "EnumAttributeDefinitionType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "values" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "label" }, arguments: [], directives: [] }] } }] } }] } }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "LocalizableEnumAttributeDefinitionType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "values" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }] } }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "ReferenceAttributeDefinitionType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "referenceTypeId" }, arguments: [], directives: [] }] } }] } }] } }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "ReferenceAttributeDefinitionType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "referenceTypeId" }, arguments: [], directives: [] }] } }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "NestedAttributeDefinitionType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "typeRef" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "EnumAttributeDefinitionType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "values" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "label" }, arguments: [], directives: [] }] } }] } }] } }, { kind: "InlineFragment", typeCondition: { kind: "NamedType", name: { kind: "Name", value: "LocalizableEnumAttributeDefinitionType" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "values" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }] } }] } }] } }] } }], loc: { start: 0, end: 1905, source: { body: "query FetchProductTypeQuery($id: String!) {\n productType(id: $id) {\n name\n attributeDefinitions(limit: 100) {\n results {\n name\n isRequired\n inputHint\n inputTipAllLocales {\n value\n locale\n }\n labelAllLocales {\n value\n locale\n }\n type {\n name\n ... on SetAttributeDefinitionType {\n elementType {\n name\n ... on NestedAttributeDefinitionType {\n typeRef {\n id\n }\n }\n ... on EnumAttributeDefinitionType {\n values {\n results {\n key\n label\n }\n }\n }\n ... on LocalizableEnumAttributeDefinitionType {\n values {\n results {\n key\n labelAllLocales {\n locale\n value\n }\n }\n }\n }\n ... on ReferenceAttributeDefinitionType {\n referenceTypeId\n }\n }\n }\n ... on ReferenceAttributeDefinitionType {\n referenceTypeId\n }\n ... on NestedAttributeDefinitionType {\n typeRef {\n id\n }\n }\n ... on EnumAttributeDefinitionType {\n values {\n results {\n key\n label\n }\n }\n }\n ... on LocalizableEnumAttributeDefinitionType {\n values {\n results {\n key\n labelAllLocales {\n locale\n value\n }\n }\n }\n }\n }\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
6885
6950
|
const mapAttributeDefinition = definition => {
|
|
6886
|
-
var _context, _context2, _context3, _context4;
|
|
6951
|
+
var _context, _definition$type, _context2, _context3, _definition$type2, _context4;
|
|
6887
6952
|
return _objectSpread$P(_objectSpread$P({}, definition), {}, {
|
|
6888
6953
|
required: definition.isRequired,
|
|
6889
6954
|
inputTip: transformLocalizedFieldToLocalizedString(definition.inputTipAllLocales),
|
|
6890
6955
|
label: transformLocalizedFieldToLocalizedString(definition.labelAllLocales),
|
|
6891
|
-
type: _includesInstanceProperty(_context = ['enum', 'lenum']).call(_context, definition.type
|
|
6956
|
+
type: _includesInstanceProperty(_context = ['enum', 'lenum']).call(_context, (_definition$type = definition.type) === null || _definition$type === void 0 || (_definition$type = _definition$type.elementType) === null || _definition$type === void 0 ? void 0 : _definition$type.name) ? _objectSpread$P(_objectSpread$P({}, definition.type), {}, {
|
|
6892
6957
|
elementType: _objectSpread$P(_objectSpread$P({}, definition.type.elementType), {}, {
|
|
6893
6958
|
values: _mapInstanceProperty(_context2 = _valuesInstanceProperty(definition.type.elementType).results).call(_context2, value => ({
|
|
6894
6959
|
key: value.key,
|
|
6895
6960
|
label: value.label || transformLocalizedFieldToLocalizedString(value.labelAllLocales)
|
|
6896
6961
|
}))
|
|
6897
6962
|
})
|
|
6898
|
-
}) : _includesInstanceProperty(_context3 = ['enum', 'lenum']).call(_context3, definition.type
|
|
6963
|
+
}) : _includesInstanceProperty(_context3 = ['enum', 'lenum']).call(_context3, (_definition$type2 = definition.type) === null || _definition$type2 === void 0 ? void 0 : _definition$type2.name) ? _objectSpread$P(_objectSpread$P({}, definition.type), {}, {
|
|
6899
6964
|
values: _mapInstanceProperty(_context4 = _valuesInstanceProperty(definition.type).results).call(_context4, value => ({
|
|
6900
6965
|
key: value.key,
|
|
6901
6966
|
label: value.label || transformLocalizedFieldToLocalizedString(value.labelAllLocales)
|
|
@@ -7248,7 +7313,7 @@ const ExpandButton = props => props.totalValues > 1 ? jsxs(Spacings.Stack, {
|
|
|
7248
7313
|
}), jsx(FlatButton, {
|
|
7249
7314
|
tone: "primary",
|
|
7250
7315
|
icon: props.isExpanded ? jsx(AngleUpIcon, {}) : jsx(AngleDownIcon, {}),
|
|
7251
|
-
label: props.isExpanded ?
|
|
7316
|
+
label: props.isExpanded ? "Hide set items (".concat(props.totalValues, ")") : "Show all set items (".concat(props.totalValues, ")"),
|
|
7252
7317
|
onClick: props.onExpand
|
|
7253
7318
|
})]
|
|
7254
7319
|
}) : null;
|
|
@@ -7283,7 +7348,7 @@ const SetButtons = props => {
|
|
|
7283
7348
|
SetButtons.displayName = 'SetButtons';
|
|
7284
7349
|
|
|
7285
7350
|
function ownKeys$N(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7286
|
-
function _objectSpread$N(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
7351
|
+
function _objectSpread$N(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys$N(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys$N(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7287
7352
|
const getDuplicateErrors = setValues => {
|
|
7288
7353
|
/* eslint-disable no-plusplus */
|
|
7289
7354
|
const result = [];
|
|
@@ -7324,10 +7389,13 @@ const getItemIndex = name => {
|
|
|
7324
7389
|
return _parseInt(rawIndex, 10);
|
|
7325
7390
|
};
|
|
7326
7391
|
const makeKeys = amount => times(amount, () => v4());
|
|
7327
|
-
const makeItemFieldName = (fieldName, index) =>
|
|
7392
|
+
const makeItemFieldName = (fieldName, index) => {
|
|
7393
|
+
var _context;
|
|
7394
|
+
return _concatInstanceProperty(_context = "".concat(fieldName, ".[")).call(_context, index, "]");
|
|
7395
|
+
};
|
|
7328
7396
|
const makeMapForAllItems = (fieldName, items, value) => _reduceInstanceProperty(items).call(items, (result, item, index) => set(result, makeItemFieldName(fieldName, index), value), {});
|
|
7329
7397
|
function CustomInputSet(props) {
|
|
7330
|
-
var
|
|
7398
|
+
var _context2;
|
|
7331
7399
|
const _useToggleState = useToggleState(false),
|
|
7332
7400
|
_useToggleState2 = _slicedToArray(_useToggleState, 2),
|
|
7333
7401
|
isExpanded = _useToggleState2[0],
|
|
@@ -7349,7 +7417,7 @@ function CustomInputSet(props) {
|
|
|
7349
7417
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
7350
7418
|
keys = _useState4[0],
|
|
7351
7419
|
setKeys = _useState4[1];
|
|
7352
|
-
const totalAmount = internalValue
|
|
7420
|
+
const totalAmount = internalValue === null || internalValue === void 0 ? void 0 : internalValue.length;
|
|
7353
7421
|
const amountToRender = isExpanded ? totalAmount : 1;
|
|
7354
7422
|
const updateInternalValue = newValue => {
|
|
7355
7423
|
const valueToSet = isEmpty$1(newValue) ? [undefined] : newValue;
|
|
@@ -7396,8 +7464,8 @@ function CustomInputSet(props) {
|
|
|
7396
7464
|
// in <CustomFieldComponent /> where proper component for given field/attribute
|
|
7397
7465
|
// type is selected.
|
|
7398
7466
|
const type = getType(props.fieldDefinition);
|
|
7399
|
-
const typeName = type
|
|
7400
|
-
const areButtonsTopAligned = _includesInstanceProperty(
|
|
7467
|
+
const typeName = type === null || type === void 0 ? void 0 : type.name.toLowerCase();
|
|
7468
|
+
const areButtonsTopAligned = _includesInstanceProperty(_context2 = [CUSTOM_FIELD_TYPES.lenum, CUSTOM_FIELD_TYPES.localizedenum, CUSTOM_FIELD_TYPES.localizedstring, CUSTOM_FIELD_TYPES.string, CUSTOM_FIELD_TYPES.text, CUSTOM_FIELD_TYPES.ltext, CUSTOM_FIELD_TYPES.reference]).call(_context2, typeName);
|
|
7401
7469
|
return jsxs(Fragment, {
|
|
7402
7470
|
children: [jsx(AccessibleHidden, {
|
|
7403
7471
|
children: jsx("label", {
|
|
@@ -7479,12 +7547,14 @@ const nonSetComponents = {
|
|
|
7479
7547
|
};
|
|
7480
7548
|
const CustomFieldInput = /*#__PURE__*/memo(props => {
|
|
7481
7549
|
const InputComponent = useMemo(() => {
|
|
7482
|
-
|
|
7550
|
+
var _props$fieldDefinitio;
|
|
7551
|
+
const typeName = (_props$fieldDefinitio = props.fieldDefinition.type) === null || _props$fieldDefinitio === void 0 ? void 0 : _props$fieldDefinitio.name.toLowerCase();
|
|
7483
7552
|
if (typeName === 'set') {
|
|
7553
|
+
var _getSetElementType;
|
|
7484
7554
|
// Boolean is the only set element with peculiarities (i.e. way more
|
|
7485
7555
|
// convenient for user to work with it as with select input with three values:
|
|
7486
7556
|
// [true], [false] and [true, false]).
|
|
7487
|
-
if (getType(props.fieldDefinition)
|
|
7557
|
+
if (((_getSetElementType = getType(props.fieldDefinition)) === null || _getSetElementType === void 0 ? void 0 : _getSetElementType.name.toLowerCase()) === CUSTOM_FIELD_TYPES.boolean) {
|
|
7488
7558
|
return CustomBooleanInputSet;
|
|
7489
7559
|
}
|
|
7490
7560
|
// All the rest sets are just a fancy wrapper around single-item components
|
|
@@ -7581,9 +7651,9 @@ const CustomFieldErrors = props => {
|
|
|
7581
7651
|
const didFormValidationFail = useDidFormValidationFail();
|
|
7582
7652
|
const errors = _Array$isArray(props.errors) ? mergeSetItemsErrors(props.errors) : props.errors;
|
|
7583
7653
|
return jsxs(Fragment, {
|
|
7584
|
-
children: [props.isTouched || didFormValidationFail && errors
|
|
7654
|
+
children: [props.isTouched || didFormValidationFail && (errors === null || errors === void 0 ? void 0 : errors.missing) && jsx(ErrorMessage, {
|
|
7585
7655
|
intlMessage: messages$K.required
|
|
7586
|
-
}), props.isTouched || didFormValidationFail && errors
|
|
7656
|
+
}), props.isTouched || didFormValidationFail && (errors === null || errors === void 0 ? void 0 : errors.duplicated) && jsx(ErrorMessage, {
|
|
7587
7657
|
intlMessage: messages$K.unique
|
|
7588
7658
|
})]
|
|
7589
7659
|
});
|
|
@@ -7633,9 +7703,10 @@ function _objectSpread$K(e) { for (var r = 1; r < arguments.length; r++) { var _
|
|
|
7633
7703
|
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
7634
7704
|
var CartDiscountsCount = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "CartDiscountsCount" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "cartDiscounts" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 61, source: { body: "query CartDiscountsCount {\n cartDiscounts {\n total\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
7635
7705
|
const CustomFieldsLabelHint = _ref2 => {
|
|
7706
|
+
var _type$name;
|
|
7636
7707
|
let fieldDefinition = _ref2.fieldDefinition;
|
|
7637
7708
|
const type = getType(fieldDefinition);
|
|
7638
|
-
const isReference = type.name
|
|
7709
|
+
const isReference = ((_type$name = type.name) === null || _type$name === void 0 ? void 0 : _type$name.toLowerCase()) === 'reference';
|
|
7639
7710
|
const referenceTypeId = type.referenceTypeId;
|
|
7640
7711
|
const isCartDiscountsReference = isReference && referenceTypeId === SEARCHABLE_REFERENCES.cartDiscount;
|
|
7641
7712
|
const _useApplicationContex = useApplicationContext(applicationContext => ({
|
|
@@ -7653,7 +7724,7 @@ const CustomFieldsLabelHint = _ref2 => {
|
|
|
7653
7724
|
data = _useQuery.data,
|
|
7654
7725
|
loading = _useQuery.loading;
|
|
7655
7726
|
if (loading) return null;
|
|
7656
|
-
if (data
|
|
7727
|
+
if ((data === null || data === void 0 ? void 0 : data.cartDiscounts.total) > QUERY_MAX_LIMIT) {
|
|
7657
7728
|
return jsxs(Spacings.Inline, {
|
|
7658
7729
|
alignItems: "center",
|
|
7659
7730
|
children: [jsx(WarningIcon, {
|
|
@@ -7680,17 +7751,17 @@ function CustomFieldsProductTypeReferenceSubtitle() {
|
|
|
7680
7751
|
// TODO(pa3): this logic may be misplaced and probably
|
|
7681
7752
|
// should belong to <CustomReferenceInput /> component instead.
|
|
7682
7753
|
function CustomFieldsLabelSubtitle(_ref3) {
|
|
7683
|
-
var _context;
|
|
7754
|
+
var _type$name2, _context;
|
|
7684
7755
|
let fieldDefinition = _ref3.fieldDefinition;
|
|
7685
7756
|
const _useIntl2 = useIntl(),
|
|
7686
7757
|
formatMessage = _useIntl2.formatMessage;
|
|
7687
7758
|
const type = getType(fieldDefinition);
|
|
7688
|
-
const isReference = type.name
|
|
7759
|
+
const isReference = ((_type$name2 = type.name) === null || _type$name2 === void 0 ? void 0 : _type$name2.toLowerCase()) === 'reference';
|
|
7689
7760
|
if (!isReference) return null;
|
|
7690
7761
|
const referenceTypeId = type.referenceTypeId;
|
|
7691
7762
|
const referenceTypeName = capitalizeFirst(referenceTypeId);
|
|
7692
7763
|
if (_includesInstanceProperty(_context = [SEARCHABLE_REFERENCES.category, SEARCHABLE_REFERENCES.cartDiscount]).call(_context, referenceTypeId)) return referenceTypeName;
|
|
7693
|
-
return referenceTypeId === SEARCHABLE_REFERENCES.product ? formatMessage(messages$v.productReferenceLabel) : referenceTypeId === SEARCHABLE_REFERENCES.productType ? jsx(CustomFieldsProductTypeReferenceSubtitle, {}) : referenceTypeId === SEARCHABLE_REFERENCES.channel ? formatMessage(messages$v.channelReferenceLabel) : referenceTypeId === SEARCHABLE_REFERENCES.state ? formatMessage(messages$v.stateReferenceLabel) :
|
|
7764
|
+
return referenceTypeId === SEARCHABLE_REFERENCES.product ? formatMessage(messages$v.productReferenceLabel) : referenceTypeId === SEARCHABLE_REFERENCES.productType ? jsx(CustomFieldsProductTypeReferenceSubtitle, {}) : referenceTypeId === SEARCHABLE_REFERENCES.channel ? formatMessage(messages$v.channelReferenceLabel) : referenceTypeId === SEARCHABLE_REFERENCES.state ? formatMessage(messages$v.stateReferenceLabel) : "".concat(referenceTypeName, " ID");
|
|
7694
7765
|
}
|
|
7695
7766
|
const Portal = props => /*#__PURE__*/ReactDOM.createPortal(props.children, document.body);
|
|
7696
7767
|
var _ref = process.env.NODE_ENV === "production" ? {
|
|
@@ -7707,7 +7778,7 @@ function CustomFieldsCountIndicator(_ref4) {
|
|
|
7707
7778
|
const formatLocalizedField = useFormatLocalizedFieldToString();
|
|
7708
7779
|
const _useIntl3 = useIntl(),
|
|
7709
7780
|
formatMessage = _useIntl3.formatMessage;
|
|
7710
|
-
return assignedAttributeGroups
|
|
7781
|
+
return (assignedAttributeGroups === null || assignedAttributeGroups === void 0 ? void 0 : assignedAttributeGroups.length) > 1 ? jsx(Tooltip, {
|
|
7711
7782
|
title: formatMessage(messages$v.attributeGroupCountTooltip, {
|
|
7712
7783
|
attributeGroups: _mapInstanceProperty(assignedAttributeGroups).call(assignedAttributeGroups, assignedAttributeGroup => formatLocalizedField(assignedAttributeGroup.nameAllLocales)).join(', '),
|
|
7713
7784
|
count: assignedAttributeGroups.length
|
|
@@ -7766,10 +7837,11 @@ CustomFieldsLabel.displayName = 'CustomFieldsTitle';
|
|
|
7766
7837
|
|
|
7767
7838
|
const _excluded = ["WrapperComponent"];
|
|
7768
7839
|
function ownKeys$J(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7769
|
-
function _objectSpread$J(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
7840
|
+
function _objectSpread$J(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys$J(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys$J(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7770
7841
|
const getFieldName = (parentName, fieldName) => {
|
|
7842
|
+
var _context;
|
|
7771
7843
|
if (!parentName) return fieldName;
|
|
7772
|
-
return
|
|
7844
|
+
return _concatInstanceProperty(_context = "".concat(parentName, ".")).call(_context, fieldName);
|
|
7773
7845
|
};
|
|
7774
7846
|
const isNested = fieldDefinition => {
|
|
7775
7847
|
const type = fieldDefinition.type;
|
|
@@ -7800,6 +7872,7 @@ const CustomFieldsInternal = _ref => {
|
|
|
7800
7872
|
return jsx(DroppableWrapper, {
|
|
7801
7873
|
onDragEnd: onDragEnd,
|
|
7802
7874
|
children: _mapInstanceProperty(fieldDefinitions).call(fieldDefinitions, (fieldDefinition, index) => {
|
|
7875
|
+
var _context2, _context3;
|
|
7803
7876
|
const fieldName = getFieldName(props.name, fieldDefinition.name);
|
|
7804
7877
|
const isTouched = Boolean(getIn(touched, fieldName));
|
|
7805
7878
|
const fieldErrors = getIn(errors, fieldName);
|
|
@@ -7824,7 +7897,7 @@ const CustomFieldsInternal = _ref => {
|
|
|
7824
7897
|
onBlur: handleBlur,
|
|
7825
7898
|
setFieldValue: props.setFieldValue,
|
|
7826
7899
|
hasError: hasError,
|
|
7827
|
-
hasWarning: props.renderWarnings && status
|
|
7900
|
+
hasWarning: props.renderWarnings && (status === null || status === void 0 ? void 0 : status.warnings[fieldName]),
|
|
7828
7901
|
handleWarningChange: props.handleWarningChange,
|
|
7829
7902
|
renderWarnings: props.renderWarnings
|
|
7830
7903
|
};
|
|
@@ -7832,33 +7905,36 @@ const CustomFieldsInternal = _ref => {
|
|
|
7832
7905
|
return jsx(FastField, {
|
|
7833
7906
|
name: fieldName,
|
|
7834
7907
|
validate: validate,
|
|
7835
|
-
children: () =>
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
children:
|
|
7842
|
-
"
|
|
7843
|
-
"
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7908
|
+
children: () => {
|
|
7909
|
+
var _context4, _context5;
|
|
7910
|
+
return jsx(DraggableWrapper, {
|
|
7911
|
+
draggableKey: _concatInstanceProperty(_context4 = "".concat(fieldName, "-")).call(_context4, index),
|
|
7912
|
+
draggableId: _concatInstanceProperty(_context5 = "".concat(fieldName, "-")).call(_context5, index),
|
|
7913
|
+
index: index,
|
|
7914
|
+
children: jsx(Spacings.Stack, {
|
|
7915
|
+
scale: "xs",
|
|
7916
|
+
children: jsxs("div", {
|
|
7917
|
+
"aria-invalid": _Object$keys(fieldErrors !== null && fieldErrors !== void 0 ? fieldErrors : {}).length > 0,
|
|
7918
|
+
"aria-errormessage": "".concat(fieldName, "-error"),
|
|
7919
|
+
id: "".concat(fieldName, "-error"),
|
|
7920
|
+
children: [jsx(CustomFieldsLabel, {
|
|
7921
|
+
name: fieldName,
|
|
7922
|
+
fieldDefinition: fieldDefinition
|
|
7923
|
+
}), jsxs(Spacings.Stack, {
|
|
7924
|
+
scale: "xs",
|
|
7925
|
+
alignItems: "stretch",
|
|
7926
|
+
children: [WrapperComponent ? jsx(WrapperComponent, {
|
|
7927
|
+
children: Field
|
|
7928
|
+
}) : Field, props.renderWarnings && (status === null || status === void 0 ? void 0 : status.warnings[fieldName]) && props.renderCustomWarnings(fieldDefinition), jsx(CustomFieldErrors, {
|
|
7929
|
+
isTouched: isTouched,
|
|
7930
|
+
errors: fieldErrors
|
|
7931
|
+
})]
|
|
7856
7932
|
})]
|
|
7857
|
-
})
|
|
7933
|
+
})
|
|
7858
7934
|
})
|
|
7859
|
-
})
|
|
7860
|
-
}
|
|
7861
|
-
},
|
|
7935
|
+
});
|
|
7936
|
+
}
|
|
7937
|
+
}, _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = "".concat(fieldName, "-")).call(_context3, index, "-")).call(_context2, fieldKey));
|
|
7862
7938
|
})
|
|
7863
7939
|
});
|
|
7864
7940
|
};
|
|
@@ -7918,7 +7994,7 @@ var pickerMessages = defineMessages({
|
|
|
7918
7994
|
});
|
|
7919
7995
|
|
|
7920
7996
|
function ownKeys$I(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7921
|
-
function _objectSpread$I(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
7997
|
+
function _objectSpread$I(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$I(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$I(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7922
7998
|
const PRODUCT_SELECTION_MODES = {
|
|
7923
7999
|
INCLUSION: 'Individual',
|
|
7924
8000
|
EXCLUSION: 'IndividualExclusion'
|
|
@@ -7929,10 +8005,11 @@ const PRODUCT_SELECTION_MODES_LABELS = {
|
|
|
7929
8005
|
};
|
|
7930
8006
|
const getMode = mode => mode === PRODUCT_SELECTION_MODES.INCLUSION || mode === PRODUCT_SELECTION_MODES_LABELS.INCLUSION ? 'inclusion' : 'exclusion';
|
|
7931
8007
|
const addModeToLabel = function (ps) {
|
|
8008
|
+
var _context;
|
|
7932
8009
|
let enableExcludingProducts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
7933
8010
|
if (!ps) return undefined;
|
|
7934
8011
|
return _objectSpread$I(_objectSpread$I({}, ps), {}, {
|
|
7935
|
-
label:
|
|
8012
|
+
label: _concatInstanceProperty(_context = "".concat(ps === null || ps === void 0 ? void 0 : ps.label)).call(_context, enableExcludingProducts ? " (type: ".concat(getMode(ps === null || ps === void 0 ? void 0 : ps.mode), ")") : '')
|
|
7936
8013
|
});
|
|
7937
8014
|
};
|
|
7938
8015
|
|
|
@@ -7944,6 +8021,7 @@ const mapProductSelectionsToOptions$1 = memoize(function () {
|
|
|
7944
8021
|
let enableExcludingProducts = arguments.length > 4 ? arguments[4] : undefined;
|
|
7945
8022
|
const selectedPSList = _Array$isArray(selectedPS) ? selectedPS : [selectedPS];
|
|
7946
8023
|
return _mapInstanceProperty(productSelections).call(productSelections, productSelection => {
|
|
8024
|
+
var _context;
|
|
7947
8025
|
const label = formatLocalizedString(productSelection, {
|
|
7948
8026
|
key: 'name',
|
|
7949
8027
|
locale: dataLocale,
|
|
@@ -7952,13 +8030,14 @@ const mapProductSelectionsToOptions$1 = memoize(function () {
|
|
|
7952
8030
|
return {
|
|
7953
8031
|
id: productSelection.id,
|
|
7954
8032
|
value: productSelection.id,
|
|
7955
|
-
label:
|
|
8033
|
+
label: _concatInstanceProperty(_context = "".concat(label)).call(_context, _includesInstanceProperty(selectedPSList).call(selectedPSList, productSelection.id) && enableExcludingProducts ? " (type: ".concat(getMode(productSelection.mode), ")") : ''),
|
|
7956
8034
|
key: productSelection.key,
|
|
7957
8035
|
mode: getMode(productSelection.mode)
|
|
7958
8036
|
};
|
|
7959
8037
|
});
|
|
7960
8038
|
});
|
|
7961
8039
|
function ProductSelectionBasicSelectDropdown(props) {
|
|
8040
|
+
var _productSelectionsFet, _productSelectionsFet2;
|
|
7962
8041
|
const intl = useIntl();
|
|
7963
8042
|
const enableExcludingProducts = useFeatureToggle(EXCLUDING_PRODUCTS);
|
|
7964
8043
|
const productSelectionsFetcher = useProductSelectionsFetcher({
|
|
@@ -7971,10 +8050,10 @@ function ProductSelectionBasicSelectDropdown(props) {
|
|
|
7971
8050
|
projectLanguages = _useApplicationContex.projectLanguages,
|
|
7972
8051
|
dataLocale = _useApplicationContex.dataLocale;
|
|
7973
8052
|
if (productSelectionsFetcher.isLoading) return jsx(CenteredLoadingSpinner, {});
|
|
7974
|
-
const productSelections = productSelectionsFetcher.productSelections
|
|
8053
|
+
const productSelections = (_productSelectionsFet = (_productSelectionsFet2 = productSelectionsFetcher.productSelections) === null || _productSelectionsFet2 === void 0 ? void 0 : _productSelectionsFet2.results) !== null && _productSelectionsFet !== void 0 ? _productSelectionsFet : [];
|
|
7975
8054
|
const filteredProductSelections = _filterInstanceProperty(productSelections).call(productSelections, ps => {
|
|
7976
|
-
var
|
|
7977
|
-
return !_includesInstanceProperty(
|
|
8055
|
+
var _context2;
|
|
8056
|
+
return !_includesInstanceProperty(_context2 = props.excludedProductSelectionIds).call(_context2, ps.id);
|
|
7978
8057
|
});
|
|
7979
8058
|
const onOptionClick = event => {
|
|
7980
8059
|
const productSelectionId = event.target.value;
|
|
@@ -8027,7 +8106,7 @@ const getValueFromOptions$3 = _ref => {
|
|
|
8027
8106
|
// handle async-select-field value transformation
|
|
8028
8107
|
if (isMulti) {
|
|
8029
8108
|
var _context;
|
|
8030
|
-
return _mapInstanceProperty(_context = _filterInstanceProperty(allProductSelectionOptions).call(allProductSelectionOptions, ps => currentlySelectedProductSelections
|
|
8109
|
+
return _mapInstanceProperty(_context = _filterInstanceProperty(allProductSelectionOptions).call(allProductSelectionOptions, ps => currentlySelectedProductSelections === null || currentlySelectedProductSelections === void 0 ? void 0 : _includesInstanceProperty(currentlySelectedProductSelections).call(currentlySelectedProductSelections, ps.value))).call(_context, ps => addModeToLabel(ps, enableExcludingProducts));
|
|
8031
8110
|
}
|
|
8032
8111
|
|
|
8033
8112
|
// in case it is not multiselect, then a single valued async-select-input is being requested and the value should have proper format
|
|
@@ -8039,6 +8118,7 @@ const emptyStoreOption$1 = intl => [{
|
|
|
8039
8118
|
isDisabled: true
|
|
8040
8119
|
}];
|
|
8041
8120
|
function ProductSelectionsAsyncSelectDropdown(props) {
|
|
8121
|
+
var _productSelectionsFet3;
|
|
8042
8122
|
const intl = useIntl();
|
|
8043
8123
|
const enableExcludingProducts = useFeatureToggle(EXCLUDING_PRODUCTS);
|
|
8044
8124
|
const productSelectionsFetcher = useProductSelectionsFetcher({
|
|
@@ -8051,13 +8131,17 @@ function ProductSelectionsAsyncSelectDropdown(props) {
|
|
|
8051
8131
|
})),
|
|
8052
8132
|
projectLanguages = _useApplicationContex.projectLanguages,
|
|
8053
8133
|
dataLocale = _useApplicationContex.dataLocale;
|
|
8054
|
-
const productSelections = useMemo(() =>
|
|
8134
|
+
const productSelections = useMemo(() => {
|
|
8135
|
+
var _productSelectionsFet, _productSelectionsFet2;
|
|
8136
|
+
return (_productSelectionsFet = (_productSelectionsFet2 = productSelectionsFetcher.productSelections) === null || _productSelectionsFet2 === void 0 ? void 0 : _productSelectionsFet2.results) !== null && _productSelectionsFet !== void 0 ? _productSelectionsFet : [];
|
|
8137
|
+
}, [(_productSelectionsFet3 = productSelectionsFetcher.productSelections) === null || _productSelectionsFet3 === void 0 ? void 0 : _productSelectionsFet3.results]);
|
|
8055
8138
|
const filteredProductSelections = _filterInstanceProperty(productSelections).call(productSelections, ps => {
|
|
8056
8139
|
var _context2;
|
|
8057
8140
|
return !_includesInstanceProperty(_context2 = props.excludedProductSelectionIds).call(_context2, ps.id);
|
|
8058
8141
|
});
|
|
8059
8142
|
const onOptionClick = event => {
|
|
8060
|
-
|
|
8143
|
+
var _event$target$value;
|
|
8144
|
+
const productSelectionId = (_event$target$value = event.target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.value;
|
|
8061
8145
|
const currentProductSelection = _findInstanceProperty(productSelections).call(productSelections, productSelection => productSelection.id === productSelectionId);
|
|
8062
8146
|
props.onChange(currentProductSelection);
|
|
8063
8147
|
};
|
|
@@ -8133,11 +8217,15 @@ function ProductSelectionsAsyncSelectDropdown(props) {
|
|
|
8133
8217
|
}
|
|
8134
8218
|
|
|
8135
8219
|
var ProductSelectionsPickerFetcher$1 = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "ProductSelectionsPickerFetcher" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "where" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "productSelections" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "where" }, value: { kind: "Variable", name: { kind: "Name", value: "where" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "version" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "mode" }, arguments: [], directives: [] }] } }] } }] } }], loc: { start: 0, end: 223, source: { body: "query ProductSelectionsPickerFetcher($where: String!) {\n productSelections(where: $where) {\n results {\n id\n key\n version\n nameAllLocales {\n locale\n value\n }\n mode\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
8136
|
-
const createQueryVariables$4 = (productSelections, predicateField) =>
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8220
|
+
const createQueryVariables$4 = (productSelections, predicateField) => {
|
|
8221
|
+
var _context;
|
|
8222
|
+
return {
|
|
8223
|
+
where: _concatInstanceProperty(_context = "".concat(predicateField, " in (")).call(_context, _mapInstanceProperty(productSelections).call(productSelections, ps => "\"".concat(ps, "\"")).join(', '), ")"),
|
|
8224
|
+
limit: 500
|
|
8225
|
+
};
|
|
8226
|
+
};
|
|
8140
8227
|
const useProductSelectionsByFieldFetcher = (productSelections, predicateField) => {
|
|
8228
|
+
var _productSelectionsQue, _productSelectionsQue2;
|
|
8141
8229
|
const productSelectionList = _Array$isArray(productSelections) ? productSelections : [productSelections];
|
|
8142
8230
|
const productSelectionsQuery = useQuery(ProductSelectionsPickerFetcher$1, {
|
|
8143
8231
|
context: {
|
|
@@ -8147,7 +8235,7 @@ const useProductSelectionsByFieldFetcher = (productSelections, predicateField) =
|
|
|
8147
8235
|
skip: productSelectionList.length === 0
|
|
8148
8236
|
});
|
|
8149
8237
|
return {
|
|
8150
|
-
productSelections: productSelectionsQuery.data
|
|
8238
|
+
productSelections: (_productSelectionsQue = (_productSelectionsQue2 = productSelectionsQuery.data) === null || _productSelectionsQue2 === void 0 ? void 0 : _productSelectionsQue2.productSelections.results) !== null && _productSelectionsQue !== void 0 ? _productSelectionsQue : [],
|
|
8151
8239
|
isLoading: productSelectionsQuery.loading
|
|
8152
8240
|
};
|
|
8153
8241
|
};
|
|
@@ -8188,8 +8276,8 @@ const createQueryVariables$3 = _ref3 => {
|
|
|
8188
8276
|
var _context;
|
|
8189
8277
|
let searchText = _ref3.searchText;
|
|
8190
8278
|
const sanitizedSearchText = sanitize(_trimInstanceProperty(searchText).call(searchText, searchText));
|
|
8191
|
-
const idQuery = isUUID(sanitizedSearchText) &&
|
|
8192
|
-
const keyQuery =
|
|
8279
|
+
const idQuery = isUUID(sanitizedSearchText) && "id = \"".concat(sanitizedSearchText, "\"");
|
|
8280
|
+
const keyQuery = "key = \"".concat(sanitizedSearchText, "\"");
|
|
8193
8281
|
const searchTextQuery = _filterInstanceProperty(_context = [idQuery, keyQuery]).call(_context, Boolean).join(' or ');
|
|
8194
8282
|
return {
|
|
8195
8283
|
where: searchTextQuery || undefined
|
|
@@ -8212,6 +8300,7 @@ function ProductSelectionsSearchSelectDropdown(props) {
|
|
|
8212
8300
|
dataLocale = _useApplicationContex.dataLocale;
|
|
8213
8301
|
const productSelectionsByFieldFetcher = useProductSelectionsByFieldFetcher(props.value, props.renderSelectInputOptionValuesByField);
|
|
8214
8302
|
const handleLoadOptions = async searchText => {
|
|
8303
|
+
var _data$productSelectio, _data$productSelectio2;
|
|
8215
8304
|
const _await$client$query = await client.query({
|
|
8216
8305
|
query: ProductSelectionsPickerFetcher,
|
|
8217
8306
|
variables: createQueryVariables$3({
|
|
@@ -8223,7 +8312,7 @@ function ProductSelectionsSearchSelectDropdown(props) {
|
|
|
8223
8312
|
fetchPolicy: 'network-only'
|
|
8224
8313
|
}),
|
|
8225
8314
|
data = _await$client$query.data;
|
|
8226
|
-
const matchedProductSelections = data
|
|
8315
|
+
const matchedProductSelections = (_data$productSelectio = data === null || data === void 0 || (_data$productSelectio2 = data.productSelections) === null || _data$productSelectio2 === void 0 ? void 0 : _data$productSelectio2.results) !== null && _data$productSelectio !== void 0 ? _data$productSelectio : [];
|
|
8227
8316
|
const updatedProductSelections = _mapInstanceProperty(matchedProductSelections).call(matchedProductSelections, convertProductSelectionFromGraphQl);
|
|
8228
8317
|
const filteredProductSelections = _filterInstanceProperty(updatedProductSelections).call(updatedProductSelections, ps => {
|
|
8229
8318
|
var _context2;
|
|
@@ -8239,7 +8328,8 @@ function ProductSelectionsSearchSelectDropdown(props) {
|
|
|
8239
8328
|
};
|
|
8240
8329
|
const loadOptionsDebounced = debounce(handleLoadOptions, 500);
|
|
8241
8330
|
const onOptionClick = event => {
|
|
8242
|
-
|
|
8331
|
+
var _event$target$value;
|
|
8332
|
+
const productSelectionId = (_event$target$value = event.target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.value;
|
|
8243
8333
|
const currentProductSelection = _findInstanceProperty(productionSelectionResults).call(productionSelectionResults, productSelection => productSelection.id === productSelectionId);
|
|
8244
8334
|
props.onChange(currentProductSelection);
|
|
8245
8335
|
};
|
|
@@ -8291,11 +8381,11 @@ function ModeSelectInputOption(props) {
|
|
|
8291
8381
|
scale: "xs",
|
|
8292
8382
|
children: [jsx(Text.Detail, {
|
|
8293
8383
|
isBold: true,
|
|
8294
|
-
children: data
|
|
8384
|
+
children: (data === null || data === void 0 ? void 0 : data.label) || noValueFallback
|
|
8295
8385
|
}), jsxs(Text.Detail, {
|
|
8296
|
-
children: ["Key: ", data
|
|
8386
|
+
children: ["Key: ", (data === null || data === void 0 ? void 0 : data.key) || noValueFallback]
|
|
8297
8387
|
}), jsxs(Text.Detail, {
|
|
8298
|
-
children: ["Type: ", data
|
|
8388
|
+
children: ["Type: ", (data === null || data === void 0 ? void 0 : data.mode) || noValueFallback]
|
|
8299
8389
|
})]
|
|
8300
8390
|
})
|
|
8301
8391
|
}));
|
|
@@ -8396,7 +8486,8 @@ function CountriesAsyncSelectDropdown(props) {
|
|
|
8396
8486
|
var _context2;
|
|
8397
8487
|
const intl = useIntl();
|
|
8398
8488
|
const handleLoadOptions = async searchTerm => {
|
|
8399
|
-
|
|
8489
|
+
var _props$options, _props$options2;
|
|
8490
|
+
const filteredOptions = (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _filterInstanceProperty(_props$options).call(_props$options, country => {
|
|
8400
8491
|
var _context;
|
|
8401
8492
|
return _includesInstanceProperty(_context = country.label.toLowerCase()).call(_context, searchTerm.toLowerCase());
|
|
8402
8493
|
});
|
|
@@ -8404,7 +8495,7 @@ function CountriesAsyncSelectDropdown(props) {
|
|
|
8404
8495
|
return _sliceInstanceProperty(filteredOptions).call(filteredOptions, 0, props.countriesAsyncLoadingLimit);
|
|
8405
8496
|
}
|
|
8406
8497
|
return [{
|
|
8407
|
-
options: props.options
|
|
8498
|
+
options: (_props$options2 = props.options) === null || _props$options2 === void 0 ? void 0 : _sliceInstanceProperty(_props$options2).call(_props$options2, 0, props.countriesAsyncLoadingLimit)
|
|
8408
8499
|
}, {
|
|
8409
8500
|
options: emptyCountryOption(intl)
|
|
8410
8501
|
}];
|
|
@@ -8413,7 +8504,10 @@ function CountriesAsyncSelectDropdown(props) {
|
|
|
8413
8504
|
const countries = event.target.value;
|
|
8414
8505
|
props.onChange({
|
|
8415
8506
|
target: _objectSpread$F(_objectSpread$F({}, event.target), {}, {
|
|
8416
|
-
value: _mapInstanceProperty(countries).call(countries, country =>
|
|
8507
|
+
value: _mapInstanceProperty(countries).call(countries, country => {
|
|
8508
|
+
var _country$value;
|
|
8509
|
+
return (_country$value = country === null || country === void 0 ? void 0 : country.value) !== null && _country$value !== void 0 ? _country$value : country;
|
|
8510
|
+
})
|
|
8417
8511
|
})
|
|
8418
8512
|
});
|
|
8419
8513
|
};
|
|
@@ -8443,7 +8537,8 @@ function CountriesAsyncSelectDropdown(props) {
|
|
|
8443
8537
|
function ownKeys$E(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8444
8538
|
function _objectSpread$E(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$E(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$E(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8445
8539
|
function CountriesPicker(props) {
|
|
8446
|
-
|
|
8540
|
+
var _props$options;
|
|
8541
|
+
const CustomCountriesPicker = ((_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.length) <= props.countriesAsyncLoadingLimit ? CountriesBasicSelectDropdown : CountriesAsyncSelectDropdown;
|
|
8447
8542
|
return jsx(Spacings.Stack, {
|
|
8448
8543
|
children: jsx(CustomCountriesPicker, _objectSpread$E({}, props))
|
|
8449
8544
|
});
|
|
@@ -8472,6 +8567,7 @@ var GetCustomerGroupsQuery = { kind: "Document", definitions: [{ kind: "Operatio
|
|
|
8472
8567
|
var GetCustomerGroupQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "GetCustomerGroupQuery" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "id" } }, type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "customerGroup" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "id" }, value: { kind: "Variable", name: { kind: "Name", value: "id" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "FragmentSpread", name: { kind: "Name", value: "PickerInputCustomerGroups" }, directives: [] }] } }] } }, { kind: "FragmentDefinition", name: { kind: "Name", value: "PickerInputCustomerGroups" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "CustomerGroup" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }], loc: { start: 0, end: 406, source: { body: "fragment PickerInputCustomerGroups on CustomerGroup {\n id\n key\n name\n}\n\nquery GetCustomerGroupsQuery($where: String, $sortByNamePath: String!) {\n customerGroups(where: $where, sort: [$sortByNamePath, \"key\"], limit: 60) {\n total\n results {\n ...PickerInputCustomerGroups\n }\n }\n}\n\nquery GetCustomerGroupQuery($id: String) {\n customerGroup(id: $id) {\n ...PickerInputCustomerGroups\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
8473
8568
|
var PickerInputCustomerGroups = { kind: "Document", definitions: [{ kind: "FragmentDefinition", name: { kind: "Name", value: "PickerInputCustomerGroups" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "CustomerGroup" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }], loc: { start: 0, end: 406, source: { body: "fragment PickerInputCustomerGroups on CustomerGroup {\n id\n key\n name\n}\n\nquery GetCustomerGroupsQuery($where: String, $sortByNamePath: String!) {\n customerGroups(where: $where, sort: [$sortByNamePath, \"key\"], limit: 60) {\n total\n results {\n ...PickerInputCustomerGroups\n }\n }\n}\n\nquery GetCustomerGroupQuery($id: String) {\n customerGroup(id: $id) {\n ...PickerInputCustomerGroups\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
8474
8569
|
const CustomerGroupPickerInput = _ref => {
|
|
8570
|
+
var _currentOption$data$l, _currentOption$data;
|
|
8475
8571
|
let isClearable = _ref.isClearable,
|
|
8476
8572
|
isDisabled = _ref.isDisabled,
|
|
8477
8573
|
isReadOnly = _ref.isReadOnly,
|
|
@@ -8540,13 +8636,13 @@ const CustomerGroupPickerInput = _ref => {
|
|
|
8540
8636
|
setLoadingError(null);
|
|
8541
8637
|
handleInternalInputChange(event);
|
|
8542
8638
|
}, [handleInternalInputChange]);
|
|
8543
|
-
const isCurrentOptionLoadingFailed = Boolean(currentOption
|
|
8639
|
+
const isCurrentOptionLoadingFailed = Boolean(currentOption === null || currentOption === void 0 ? void 0 : currentOption.error);
|
|
8544
8640
|
useEffect(() => {
|
|
8545
8641
|
if (isCurrentOptionLoadingFailed) onError(currentOption.error);
|
|
8546
8642
|
}, [isCurrentOptionLoadingFailed, onError, currentOption]);
|
|
8547
8643
|
const isLoadingFailed = isCurrentOptionLoadingFailed || Boolean(loadingError);
|
|
8548
8644
|
const handleNoOptions = useCallback(() => loadingError ? null : formatMessage(messages$t.noCustomerGroupsFound), [loadingError, formatMessage]);
|
|
8549
|
-
const tooltipTitle = currentOption
|
|
8645
|
+
const tooltipTitle = (_currentOption$data$l = currentOption === null || currentOption === void 0 || (_currentOption$data = currentOption.data) === null || _currentOption$data === void 0 ? void 0 : _currentOption$data.label) !== null && _currentOption$data$l !== void 0 ? _currentOption$data$l : '';
|
|
8550
8646
|
return jsx(Constraints.Horizontal, {
|
|
8551
8647
|
max: "scale",
|
|
8552
8648
|
children: jsxs(Spacings.Stack, {
|
|
@@ -8556,7 +8652,7 @@ const CustomerGroupPickerInput = _ref => {
|
|
|
8556
8652
|
children: jsx(AsyncSelectInput, {
|
|
8557
8653
|
id: name,
|
|
8558
8654
|
name: name,
|
|
8559
|
-
placeholder: placeholder
|
|
8655
|
+
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : formatMessage(messages$t.placeholder),
|
|
8560
8656
|
loadOptions: loadOptionsDebounced,
|
|
8561
8657
|
defaultOptions: true,
|
|
8562
8658
|
showOptionGroupDivider: true,
|
|
@@ -8585,11 +8681,12 @@ CustomerGroupPickerInput.displayName = 'CustomerGroupPickerInput';
|
|
|
8585
8681
|
const DEFAULT_LENGTH = 50;
|
|
8586
8682
|
const DEFAULT_END = '...';
|
|
8587
8683
|
function truncate (text) {
|
|
8684
|
+
var _context;
|
|
8588
8685
|
let length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_LENGTH;
|
|
8589
8686
|
let end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_END;
|
|
8590
8687
|
if (!text) return '';
|
|
8591
8688
|
if (text.length < length) return text;
|
|
8592
|
-
return
|
|
8689
|
+
return _concatInstanceProperty(_context = "".concat(text.substring(0, length))).call(_context, end);
|
|
8593
8690
|
}
|
|
8594
8691
|
|
|
8595
8692
|
const LOWER_STORES_LIMIT = 60;
|
|
@@ -8597,6 +8694,7 @@ const UPPER_STORES_LIMIT = 500;
|
|
|
8597
8694
|
|
|
8598
8695
|
// map store to options
|
|
8599
8696
|
const mapStoresToOptions = _ref => {
|
|
8697
|
+
var _store$productSelecti;
|
|
8600
8698
|
let store = _ref.store,
|
|
8601
8699
|
renderSelectInputOptionValuesByField = _ref.renderSelectInputOptionValuesByField,
|
|
8602
8700
|
dataLocale = _ref.dataLocale;
|
|
@@ -8607,14 +8705,14 @@ const mapStoresToOptions = _ref => {
|
|
|
8607
8705
|
const localizedName = formatLocalizedString(convertedStore, {
|
|
8608
8706
|
key: 'name',
|
|
8609
8707
|
locale: dataLocale,
|
|
8610
|
-
fallback:
|
|
8708
|
+
fallback: "".concat(store.key, " (key)")
|
|
8611
8709
|
});
|
|
8612
8710
|
return {
|
|
8613
8711
|
label: localizedName,
|
|
8614
8712
|
value: renderSelectInputOptionValuesByField === 'key' ? store.key : store.id,
|
|
8615
8713
|
key: store.key,
|
|
8616
8714
|
id: store.id,
|
|
8617
|
-
productSelections: store.productSelections
|
|
8715
|
+
productSelections: (_store$productSelecti = store.productSelections) === null || _store$productSelecti === void 0 ? void 0 : _mapInstanceProperty(_store$productSelecti).call(_store$productSelecti, productSelectionRef => productSelectionRef.productSelection.id)
|
|
8618
8716
|
};
|
|
8619
8717
|
};
|
|
8620
8718
|
|
|
@@ -8681,7 +8779,7 @@ const getValueFromOptions$1 = _ref => {
|
|
|
8681
8779
|
isMulti = _ref.isMulti;
|
|
8682
8780
|
// handle async-select-field value transformation
|
|
8683
8781
|
if (isMulti) {
|
|
8684
|
-
return _filterInstanceProperty(mappedStoresListOptions).call(mappedStoresListOptions, store => currentlySelectedStores
|
|
8782
|
+
return _filterInstanceProperty(mappedStoresListOptions).call(mappedStoresListOptions, store => currentlySelectedStores === null || currentlySelectedStores === void 0 ? void 0 : _includesInstanceProperty(currentlySelectedStores).call(currentlySelectedStores, store.value));
|
|
8685
8783
|
}
|
|
8686
8784
|
|
|
8687
8785
|
// return value as undefined if no options is yet selected. It is needed for cases where users sets initial values as empty string
|
|
@@ -8710,13 +8808,13 @@ const StoresAsyncSelectInput = props => {
|
|
|
8710
8808
|
sort: 'createdAt asc',
|
|
8711
8809
|
excludeExtendedStoresList: true,
|
|
8712
8810
|
excludeProductSelections: !props.shouldFetchProductSelections,
|
|
8713
|
-
stores: keysOfStores
|
|
8811
|
+
stores: (keysOfStores === null || keysOfStores === void 0 ? void 0 : keysOfStores.length) && keysOfStores,
|
|
8714
8812
|
projectKey: props.projectKey
|
|
8715
8813
|
});
|
|
8716
8814
|
const hasError = AsyncSelectInput.isTouched(props.touched) && hasErrors$2(props.errors) || props.hasError;
|
|
8717
8815
|
const mappedStoresListOptions = useMemo(() => {
|
|
8718
|
-
var _context2;
|
|
8719
|
-
return _mapInstanceProperty(_context2 = storesListFetcher.stores
|
|
8816
|
+
var _context2, _storesListFetcher$st;
|
|
8817
|
+
return _mapInstanceProperty(_context2 = ((_storesListFetcher$st = storesListFetcher.stores) === null || _storesListFetcher$st === void 0 ? void 0 : _storesListFetcher$st.results) || []).call(_context2, store => mapStoresToOptions({
|
|
8720
8818
|
store,
|
|
8721
8819
|
dataLocale,
|
|
8722
8820
|
renderSelectInputOptionValuesByField: props.renderSelectInputOptionValuesByField
|
|
@@ -8812,25 +8910,26 @@ const StoresBasicSelectInput = props => {
|
|
|
8812
8910
|
sort: 'createdAt asc',
|
|
8813
8911
|
excludeExtendedStoresList: true,
|
|
8814
8912
|
excludeProductSelections: !props.shouldFetchProductSelections,
|
|
8815
|
-
stores: keysOfStores
|
|
8913
|
+
stores: (keysOfStores === null || keysOfStores === void 0 ? void 0 : keysOfStores.length) && keysOfStores,
|
|
8816
8914
|
projectKey: props.projectKey
|
|
8817
8915
|
});
|
|
8818
8916
|
const hasError = SelectInput.isTouched(props.touched) && hasErrors$1(props.errors) || props.hasError;
|
|
8819
8917
|
const mappedStoresListOptions = useMemo(() => {
|
|
8820
|
-
var _context2;
|
|
8821
|
-
const results = _mapInstanceProperty(_context2 = storesListFetcher.stores
|
|
8918
|
+
var _context2, _storesListFetcher$st;
|
|
8919
|
+
const results = _mapInstanceProperty(_context2 = ((_storesListFetcher$st = storesListFetcher.stores) === null || _storesListFetcher$st === void 0 ? void 0 : _storesListFetcher$st.results) || []).call(_context2, store => mapStoresToOptions({
|
|
8822
8920
|
store,
|
|
8823
8921
|
dataLocale,
|
|
8824
8922
|
renderSelectInputOptionValuesByField: props.renderSelectInputOptionValuesByField
|
|
8825
8923
|
}));
|
|
8826
|
-
return props
|
|
8924
|
+
return props !== null && props !== void 0 && props.renderLabel ? [{
|
|
8827
8925
|
options: getCustomGroupLabelOption(props.renderLabel)
|
|
8828
8926
|
}, {
|
|
8829
8927
|
options: results
|
|
8830
8928
|
}] : results;
|
|
8831
|
-
}, [dataLocale, storesListFetcher.stores, props.renderSelectInputOptionValuesByField, props
|
|
8929
|
+
}, [dataLocale, storesListFetcher.stores, props.renderSelectInputOptionValuesByField, props === null || props === void 0 ? void 0 : props.renderLabel]);
|
|
8832
8930
|
const handleChange = event => {
|
|
8833
|
-
|
|
8931
|
+
var _event$target$value$v, _event$target$value;
|
|
8932
|
+
const value = (_event$target$value$v = (_event$target$value = event.target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.value) !== null && _event$target$value$v !== void 0 ? _event$target$value$v : event.target.value;
|
|
8834
8933
|
const currentStore = _findInstanceProperty(mappedStoresListOptions).call(mappedStoresListOptions, store => store.value === value);
|
|
8835
8934
|
|
|
8836
8935
|
// We need complete store info including productSelections
|
|
@@ -8888,6 +8987,7 @@ StoresBasicSelectInput.defaultProps = {
|
|
|
8888
8987
|
|
|
8889
8988
|
var TotalNumberOfStores = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "TotalNumberOfStores" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", alias: { kind: "Name", value: "totalNumberOfStores" }, name: { kind: "Name", value: "stores" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 76, source: { body: "query TotalNumberOfStores {\n totalNumberOfStores: stores {\n total\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
8890
8989
|
const useTotalNumberOfStoresFetcher = projectKey => {
|
|
8990
|
+
var _totalNumberOfStoresQ;
|
|
8891
8991
|
const totalNumberOfStoresQuery = useQuery(TotalNumberOfStores, {
|
|
8892
8992
|
context: {
|
|
8893
8993
|
target: GRAPHQL_TARGETS.COMMERCETOOLS_PLATFORM,
|
|
@@ -8896,7 +8996,7 @@ const useTotalNumberOfStoresFetcher = projectKey => {
|
|
|
8896
8996
|
fetchPolicy: 'network-only'
|
|
8897
8997
|
});
|
|
8898
8998
|
return {
|
|
8899
|
-
total: totalNumberOfStoresQuery.data
|
|
8999
|
+
total: (_totalNumberOfStoresQ = totalNumberOfStoresQuery.data) === null || _totalNumberOfStoresQ === void 0 ? void 0 : _totalNumberOfStoresQ.totalNumberOfStores.total,
|
|
8900
9000
|
isLoading: totalNumberOfStoresQuery.loading
|
|
8901
9001
|
};
|
|
8902
9002
|
};
|
|
@@ -8914,15 +9014,19 @@ const handlers$1 = {
|
|
|
8914
9014
|
};
|
|
8915
9015
|
|
|
8916
9016
|
var FetchStoresByField = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchStoresByField" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "where" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "excludeProductSelections" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "limit" } }, type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", alias: { kind: "Name", value: "storesByField" }, name: { kind: "Name", value: "stores" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "where" }, value: { kind: "Variable", name: { kind: "Name", value: "where" } } }, { kind: "Argument", name: { kind: "Name", value: "limit" }, value: { kind: "Variable", name: { kind: "Name", value: "limit" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "productSelections" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "skip" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "excludeProductSelections" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "active" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "productSelection" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }] } }], loc: { start: 0, end: 473, source: { body: "query FetchStoresByField(\n $where: String!\n $excludeProductSelections: Boolean!\n $limit: Int\n) {\n storesByField: stores(where: $where, limit: $limit) {\n results {\n id\n key\n nameAllLocales {\n locale\n value\n }\n productSelections @skip(if: $excludeProductSelections) {\n active\n productSelection {\n id\n nameAllLocales {\n locale\n value\n }\n }\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
8917
|
-
const createQueryVariables$2 = (stores, predicateField, shouldFetchProductSelections) =>
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
9017
|
+
const createQueryVariables$2 = (stores, predicateField, shouldFetchProductSelections) => {
|
|
9018
|
+
var _context;
|
|
9019
|
+
return {
|
|
9020
|
+
where: _concatInstanceProperty(_context = "".concat(predicateField, " in (")).call(_context, _mapInstanceProperty(stores).call(stores, store => "\"".concat(store, "\"")).join(', '), ")"),
|
|
9021
|
+
limit: 500,
|
|
9022
|
+
excludeProductSelections: !shouldFetchProductSelections
|
|
9023
|
+
};
|
|
9024
|
+
};
|
|
8922
9025
|
const emptyStoresQueryResult = {
|
|
8923
9026
|
results: []
|
|
8924
9027
|
};
|
|
8925
9028
|
const useStoresByFieldFetcher = function (stores, predicateField, projectKey) {
|
|
9029
|
+
var _storesQuery$data;
|
|
8926
9030
|
let shouldFetchProductSelections = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
8927
9031
|
// incase of single select input stores are sent as single string literal
|
|
8928
9032
|
const storesList = _Array$isArray(stores) ? stores : [stores];
|
|
@@ -8935,13 +9039,13 @@ const useStoresByFieldFetcher = function (stores, predicateField, projectKey) {
|
|
|
8935
9039
|
skip: storesList.length === 0
|
|
8936
9040
|
});
|
|
8937
9041
|
return {
|
|
8938
|
-
stores: storesQuery.data
|
|
9042
|
+
stores: ((_storesQuery$data = storesQuery.data) === null || _storesQuery$data === void 0 ? void 0 : _storesQuery$data.storesByField) || emptyStoresQueryResult,
|
|
8939
9043
|
isLoading: storesQuery.loading
|
|
8940
9044
|
};
|
|
8941
9045
|
};
|
|
8942
9046
|
|
|
8943
9047
|
function ownKeys$B(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8944
|
-
function _objectSpread$B(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
9048
|
+
function _objectSpread$B(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys$B(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys$B(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8945
9049
|
var FetchStoresByWherePredicate = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchStoresByWherePredicate" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "where" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "skipFetchingStores" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "excludeProductSelections" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", alias: { kind: "Name", value: "storesByWherePredicate" }, name: { kind: "Name", value: "stores" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "where" }, value: { kind: "Variable", name: { kind: "Name", value: "where" } } }], directives: [{ kind: "Directive", name: { kind: "Name", value: "skip" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "skipFetchingStores" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "key" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "productSelections" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "skip" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "excludeProductSelections" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "active" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "productSelection" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }] } }], loc: { start: 0, end: 525, source: { body: "query FetchStoresByWherePredicate(\n $where: String!\n $skipFetchingStores: Boolean!\n $excludeProductSelections: Boolean!\n) {\n storesByWherePredicate: stores(where: $where) @skip(if: $skipFetchingStores) {\n results {\n id\n key\n nameAllLocales {\n locale\n value\n }\n productSelections @skip(if: $excludeProductSelections) {\n active\n productSelection {\n id\n nameAllLocales {\n locale\n value\n }\n }\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
8946
9050
|
var styles$c = {
|
|
8947
9051
|
"renderLabelContainer": "stores-search-selector-module__renderLabelContainer___3_PBc",
|
|
@@ -8952,16 +9056,16 @@ const hasErrors = errors => {
|
|
|
8952
9056
|
return errors && _someInstanceProperty(_context = _Object$values(errors)).call(_context, Boolean);
|
|
8953
9057
|
};
|
|
8954
9058
|
const createQueryVariables$1 = _ref => {
|
|
8955
|
-
var _context2;
|
|
9059
|
+
var _context2, _context3;
|
|
8956
9060
|
let searchText = _ref.searchText,
|
|
8957
9061
|
dataLocale = _ref.dataLocale,
|
|
8958
9062
|
allAccessibleStoreKeysThroughDataFencePermissions = _ref.allAccessibleStoreKeysThroughDataFencePermissions,
|
|
8959
9063
|
shouldFetchProductSelections = _ref.shouldFetchProductSelections;
|
|
8960
9064
|
const sanitizedSearchText = sanitize(_trimInstanceProperty(searchText).call(searchText, searchText));
|
|
8961
|
-
const keyQuery =
|
|
9065
|
+
const keyQuery = "key = \"".concat(sanitizedSearchText, "\"");
|
|
8962
9066
|
|
|
8963
9067
|
// if the user has data fence permissions then we only allow stores to fetched that user has access to
|
|
8964
|
-
if (allAccessibleStoreKeysThroughDataFencePermissions
|
|
9068
|
+
if (allAccessibleStoreKeysThroughDataFencePermissions !== null && allAccessibleStoreKeysThroughDataFencePermissions !== void 0 && allAccessibleStoreKeysThroughDataFencePermissions.length) {
|
|
8965
9069
|
// if the current search term match the accessible stores keys, then proceed with fetching the store
|
|
8966
9070
|
if (_includesInstanceProperty(allAccessibleStoreKeysThroughDataFencePermissions).call(allAccessibleStoreKeysThroughDataFencePermissions, sanitizedSearchText)) {
|
|
8967
9071
|
return {
|
|
@@ -8977,9 +9081,9 @@ const createQueryVariables$1 = _ref => {
|
|
|
8977
9081
|
excludeProductSelections: !shouldFetchProductSelections
|
|
8978
9082
|
};
|
|
8979
9083
|
}
|
|
8980
|
-
const idQuery = isUUID(sanitizedSearchText) &&
|
|
8981
|
-
const nameQuery =
|
|
8982
|
-
const searchTextQuery = _filterInstanceProperty(
|
|
9084
|
+
const idQuery = isUUID(sanitizedSearchText) && "id = \"".concat(sanitizedSearchText, "\"");
|
|
9085
|
+
const nameQuery = _concatInstanceProperty(_context2 = "name(".concat(dataLocale, " = \"")).call(_context2, sanitizedSearchText, "\")");
|
|
9086
|
+
const searchTextQuery = _filterInstanceProperty(_context3 = [idQuery, nameQuery, keyQuery]).call(_context3, Boolean).join(' or ');
|
|
8983
9087
|
return {
|
|
8984
9088
|
skipFetchingStores: false,
|
|
8985
9089
|
where: searchTextQuery,
|
|
@@ -8987,6 +9091,7 @@ const createQueryVariables$1 = _ref => {
|
|
|
8987
9091
|
};
|
|
8988
9092
|
};
|
|
8989
9093
|
const getValueFromOptions = _ref2 => {
|
|
9094
|
+
var _storesByFieldFetcher, _context4;
|
|
8990
9095
|
let isMulti = _ref2.isMulti,
|
|
8991
9096
|
value = _ref2.value,
|
|
8992
9097
|
dataLocale = _ref2.dataLocale,
|
|
@@ -8995,7 +9100,7 @@ const getValueFromOptions = _ref2 => {
|
|
|
8995
9100
|
if (!value) {
|
|
8996
9101
|
return undefined;
|
|
8997
9102
|
}
|
|
8998
|
-
const selectedOptions = storesByFieldFetcher.stores
|
|
9103
|
+
const selectedOptions = (_storesByFieldFetcher = storesByFieldFetcher.stores) === null || _storesByFieldFetcher === void 0 ? void 0 : _mapInstanceProperty(_context4 = _storesByFieldFetcher.results).call(_context4, store => mapStoresToOptions({
|
|
8999
9104
|
store,
|
|
9000
9105
|
dataLocale,
|
|
9001
9106
|
renderSelectInputOptionValuesByField: renderSelectInputOptionValuesByField
|
|
@@ -9033,8 +9138,9 @@ const StoresSearchSelectInput = props => {
|
|
|
9033
9138
|
},
|
|
9034
9139
|
fetchPolicy: 'network-only'
|
|
9035
9140
|
}).then(_ref3 => {
|
|
9141
|
+
var _data$storesByWherePr, _context5;
|
|
9036
9142
|
let data = _ref3.data;
|
|
9037
|
-
const result = data.storesByWherePredicate
|
|
9143
|
+
const result = (_data$storesByWherePr = data.storesByWherePredicate) === null || _data$storesByWherePr === void 0 ? void 0 : _mapInstanceProperty(_context5 = _data$storesByWherePr.results).call(_context5, store => mapStoresToOptions({
|
|
9038
9144
|
store,
|
|
9039
9145
|
dataLocale,
|
|
9040
9146
|
renderSelectInputOptionValuesByField: props.renderSelectInputOptionValuesByField
|
|
@@ -9055,7 +9161,7 @@ const StoresSearchSelectInput = props => {
|
|
|
9055
9161
|
className: styles$c.renderLabelContainer,
|
|
9056
9162
|
children: [jsx("div", {
|
|
9057
9163
|
className: styles$c.customLabel,
|
|
9058
|
-
children: props
|
|
9164
|
+
children: (props === null || props === void 0 ? void 0 : props.renderLabel) && (props === null || props === void 0 ? void 0 : props.renderLabel)
|
|
9059
9165
|
}), jsx("div", {
|
|
9060
9166
|
children: intl.formatMessage(inputValue ? messages$s.searchSelectInputNoOptionsFoundMessage : messages$s.searchSelectInputNoValueMessage)
|
|
9061
9167
|
})]
|
|
@@ -9234,14 +9340,14 @@ var messages$r = defineMessages({
|
|
|
9234
9340
|
|
|
9235
9341
|
function formatDiscount(discount, currencyCode, intl) {
|
|
9236
9342
|
var _context;
|
|
9237
|
-
if (discount.type === 'relative') return
|
|
9343
|
+
if (discount.type === 'relative') return "".concat(discount.permyriad / 100, "%");
|
|
9238
9344
|
if (!discount.money) return null;
|
|
9239
9345
|
const moneyForCurrencyCode = _findInstanceProperty(_context = discount.money).call(_context, discountMoney => discountMoney.currencyCode === currencyCode);
|
|
9240
9346
|
return moneyForCurrencyCode ? formatMoney$2(moneyForCurrencyCode, intl) : null;
|
|
9241
9347
|
}
|
|
9242
9348
|
|
|
9243
9349
|
function formatPercentage(percentage) {
|
|
9244
|
-
return
|
|
9350
|
+
return "".concat(percentage, "%");
|
|
9245
9351
|
}
|
|
9246
9352
|
function convertRatioToPercentage(ratio) {
|
|
9247
9353
|
return _parseFloat((ratio * 100).toFixed(2));
|
|
@@ -9295,8 +9401,8 @@ function validateFilter$2(_ref, intl) {
|
|
|
9295
9401
|
};
|
|
9296
9402
|
}
|
|
9297
9403
|
if (value.option === FILTER_TYPES.range) {
|
|
9298
|
-
const from = validateValue(filterValue
|
|
9299
|
-
const to = from ? null : validateValue(filterValue
|
|
9404
|
+
const from = validateValue(filterValue === null || filterValue === void 0 ? void 0 : filterValue.from, typeName, intl);
|
|
9405
|
+
const to = from ? null : validateValue(filterValue === null || filterValue === void 0 ? void 0 : filterValue.to, typeName, intl);
|
|
9300
9406
|
return from || to ? {
|
|
9301
9407
|
input: {
|
|
9302
9408
|
from,
|
|
@@ -9333,16 +9439,16 @@ function validateFilter$1(_ref, intl) {
|
|
|
9333
9439
|
type = _ref.type;
|
|
9334
9440
|
if (type === 'range') {
|
|
9335
9441
|
if (validateSingleFilter({
|
|
9336
|
-
value: value
|
|
9442
|
+
value: value === null || value === void 0 ? void 0 : value.from
|
|
9337
9443
|
})) return {
|
|
9338
9444
|
from: intl.formatMessage(messages$p.rangeMissingValue)
|
|
9339
9445
|
};
|
|
9340
9446
|
if (validateSingleFilter({
|
|
9341
|
-
value: value
|
|
9447
|
+
value: value === null || value === void 0 ? void 0 : value.to
|
|
9342
9448
|
})) return {
|
|
9343
9449
|
to: intl.formatMessage(messages$p.rangeMissingValue)
|
|
9344
9450
|
};
|
|
9345
|
-
if (moment$1(value
|
|
9451
|
+
if (moment$1(value === null || value === void 0 ? void 0 : value.to).isBefore(value === null || value === void 0 ? void 0 : value.from)) return {
|
|
9346
9452
|
from: intl.formatMessage(messages$p.rangeToSmallerThanFrom)
|
|
9347
9453
|
};
|
|
9348
9454
|
} else if (type === 'equalTo' || type === 'lessThan' || type === 'moreThan') {
|
|
@@ -9412,8 +9518,10 @@ function isEmptyFilter(_ref) {
|
|
|
9412
9518
|
}
|
|
9413
9519
|
|
|
9414
9520
|
function numberTransformer(filterKey, filters) {
|
|
9521
|
+
var _context3;
|
|
9415
9522
|
let filterValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : isFilterValid$2;
|
|
9416
9523
|
const queries = _mapInstanceProperty(filters).call(filters, _ref => {
|
|
9524
|
+
var _context, _context2;
|
|
9417
9525
|
let type = _ref.type,
|
|
9418
9526
|
value = _ref.value;
|
|
9419
9527
|
if (!filterValidator({
|
|
@@ -9422,19 +9530,19 @@ function numberTransformer(filterKey, filters) {
|
|
|
9422
9530
|
})) return '';
|
|
9423
9531
|
switch (type) {
|
|
9424
9532
|
case 'lessThan':
|
|
9425
|
-
return
|
|
9533
|
+
return "(* to ".concat(_parseInt(value) - 1, ")");
|
|
9426
9534
|
case 'moreThan':
|
|
9427
|
-
return
|
|
9535
|
+
return "(".concat(_parseInt(value) + 1, " to *)");
|
|
9428
9536
|
case 'equalTo':
|
|
9429
|
-
return
|
|
9537
|
+
return _concatInstanceProperty(_context = "(".concat(value, " to ")).call(_context, value, ")");
|
|
9430
9538
|
case 'range':
|
|
9431
|
-
return
|
|
9539
|
+
return _concatInstanceProperty(_context2 = "(".concat(value.from, " to ")).call(_context2, value.to, ")");
|
|
9432
9540
|
default:
|
|
9433
9541
|
return '';
|
|
9434
9542
|
}
|
|
9435
9543
|
});
|
|
9436
9544
|
const queryString = _filterInstanceProperty(queries).call(queries, q => q !== '').join(', ');
|
|
9437
|
-
return queryString === '' ? null :
|
|
9545
|
+
return queryString === '' ? null : _concatInstanceProperty(_context3 = "".concat(filterKey, ": range")).call(_context3, queryString);
|
|
9438
9546
|
}
|
|
9439
9547
|
function isFilterValid$2(_ref2) {
|
|
9440
9548
|
let type = _ref2.type,
|
|
@@ -9461,9 +9569,11 @@ function graphqlCategoryLevelTransformer(filterKey, filters, filterValidator) {
|
|
|
9461
9569
|
return _filterInstanceProperty(_context = [levelFilterQuery, lastLevelFilterQuery]).call(_context, Boolean);
|
|
9462
9570
|
}
|
|
9463
9571
|
|
|
9572
|
+
var _templateObject$1, _templateObject2;
|
|
9464
9573
|
const dateFormatDayStart = 'YYYY-MM-DDT00:00:00.000Z';
|
|
9465
9574
|
const dateFormatDayEnd = 'YYYY-MM-DDT23:59:59.999Z';
|
|
9466
9575
|
function dateTransformer(filterKey, filters) {
|
|
9576
|
+
var _context;
|
|
9467
9577
|
let filterValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : isFilterValid$1;
|
|
9468
9578
|
const queries = _mapInstanceProperty(filters).call(filters, _ref => {
|
|
9469
9579
|
let type = _ref.type,
|
|
@@ -9474,25 +9584,19 @@ function dateTransformer(filterKey, filters) {
|
|
|
9474
9584
|
})) return '';
|
|
9475
9585
|
switch (type) {
|
|
9476
9586
|
case 'lessThan':
|
|
9477
|
-
return
|
|
9587
|
+
return "(* to \"".concat(moment$1(value).format(dateFormatDayStart), "\")");
|
|
9478
9588
|
case 'moreThan':
|
|
9479
|
-
return
|
|
9589
|
+
return "(\"".concat(moment$1(value).format(dateFormatDayEnd), "\" to *)");
|
|
9480
9590
|
case 'equalTo':
|
|
9481
|
-
return oneLine
|
|
9482
|
-
("${moment$1(value).format(dateFormatDayStart)}"
|
|
9483
|
-
to "${moment$1(value).format(dateFormatDayEnd)}")
|
|
9484
|
-
`;
|
|
9591
|
+
return oneLine(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n (\"", "\"\n to \"", "\")\n "])), moment$1(value).format(dateFormatDayStart), moment$1(value).format(dateFormatDayEnd));
|
|
9485
9592
|
case 'range':
|
|
9486
|
-
return oneLine
|
|
9487
|
-
("${moment$1(value.from).format(dateFormatDayStart)}"
|
|
9488
|
-
to "${moment$1(value.to).format(dateFormatDayEnd)}")
|
|
9489
|
-
`;
|
|
9593
|
+
return oneLine(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n (\"", "\"\n to \"", "\")\n "])), moment$1(value.from).format(dateFormatDayStart), moment$1(value.to).format(dateFormatDayEnd));
|
|
9490
9594
|
default:
|
|
9491
9595
|
return '';
|
|
9492
9596
|
}
|
|
9493
9597
|
});
|
|
9494
9598
|
const queryString = _filterInstanceProperty(queries).call(queries, q => q !== '').join(', ');
|
|
9495
|
-
return queryString === '' ? null :
|
|
9599
|
+
return queryString === '' ? null : _concatInstanceProperty(_context = "".concat(filterKey, ": range")).call(_context, queryString);
|
|
9496
9600
|
}
|
|
9497
9601
|
function isFilterValid$1(_ref2) {
|
|
9498
9602
|
let type = _ref2.type,
|
|
@@ -9507,18 +9611,19 @@ function isFilterValid$1(_ref2) {
|
|
|
9507
9611
|
}
|
|
9508
9612
|
|
|
9509
9613
|
function missingLocaleTransformer(filterKey, filters) {
|
|
9614
|
+
var _context;
|
|
9510
9615
|
// Note: we assume for now that there can only be 1 missing filter value,
|
|
9511
9616
|
// as the API doesn't support yet multiple OR values (for missing).
|
|
9512
9617
|
if (filters.length === 0) return null;
|
|
9513
9618
|
const missingLocale = filters[0].value.value;
|
|
9514
|
-
return
|
|
9619
|
+
return _concatInstanceProperty(_context = "".concat(filterKey, ".")).call(_context, missingLocale, ":missing");
|
|
9515
9620
|
}
|
|
9516
9621
|
|
|
9517
9622
|
function missingTransformer(filterKey, filters) {
|
|
9518
9623
|
// Note: we assume for now that there can only be 1 missing filter value,
|
|
9519
9624
|
// as the API doesn't support yet multiple OR values (for missing).
|
|
9520
9625
|
if (filters.length === 0) return null;
|
|
9521
|
-
return
|
|
9626
|
+
return "".concat(filterKey, ":missing");
|
|
9522
9627
|
}
|
|
9523
9628
|
|
|
9524
9629
|
/**
|
|
@@ -9559,6 +9664,7 @@ function graphqlQueryBuilder(_ref) {
|
|
|
9559
9664
|
}
|
|
9560
9665
|
|
|
9561
9666
|
function referenceTransformer(filterKey, filters) {
|
|
9667
|
+
var _context;
|
|
9562
9668
|
let filterValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : isFilterValid;
|
|
9563
9669
|
const queries = _mapInstanceProperty(filters).call(filters, _ref => {
|
|
9564
9670
|
let type = _ref.type,
|
|
@@ -9569,46 +9675,49 @@ function referenceTransformer(filterKey, filters) {
|
|
|
9569
9675
|
})) return '';
|
|
9570
9676
|
switch (type) {
|
|
9571
9677
|
case 'equalTo':
|
|
9572
|
-
return
|
|
9678
|
+
return "\"".concat(value, "\"");
|
|
9573
9679
|
default:
|
|
9574
9680
|
return '';
|
|
9575
9681
|
}
|
|
9576
9682
|
});
|
|
9577
9683
|
const queryString = _filterInstanceProperty(queries).call(queries, q => q !== '').join(', ');
|
|
9578
|
-
return queryString === '' ? null :
|
|
9684
|
+
return queryString === '' ? null : _concatInstanceProperty(_context = "".concat(filterKey, ".id: ")).call(_context, queryString);
|
|
9579
9685
|
}
|
|
9580
9686
|
function isFilterValid(_ref2) {
|
|
9581
|
-
var
|
|
9687
|
+
var _context2;
|
|
9582
9688
|
let type = _ref2.type,
|
|
9583
9689
|
value = _ref2.value;
|
|
9584
|
-
if (type === 'equalTo' && !_includesInstanceProperty(
|
|
9690
|
+
if (type === 'equalTo' && !_includesInstanceProperty(_context2 = [null, undefined, '']).call(_context2, value)) return true;
|
|
9585
9691
|
return false;
|
|
9586
9692
|
}
|
|
9587
9693
|
|
|
9588
9694
|
function textTransformer(filterKey, queries) {
|
|
9695
|
+
var _context;
|
|
9589
9696
|
if (queries.length === 0) return null;
|
|
9590
9697
|
|
|
9591
9698
|
// Note: we assume for now that there can only be 1 text filter.
|
|
9592
9699
|
const queryValue = queries[0].value;
|
|
9593
|
-
return queryValue ?
|
|
9700
|
+
return queryValue ? _concatInstanceProperty(_context = "".concat(filterKey, ":\"")).call(_context, queryValue, "\"") : null;
|
|
9594
9701
|
}
|
|
9595
9702
|
|
|
9596
9703
|
const composeNumberPredicateFromFilter = (target, value, option) => {
|
|
9704
|
+
var _context, _context2, _context3, _context4, _context5, _context6;
|
|
9597
9705
|
switch (option) {
|
|
9598
9706
|
case FILTER_TYPES.lessThan:
|
|
9599
|
-
return
|
|
9707
|
+
return _concatInstanceProperty(_context = "".concat(target, " < ")).call(_context, value);
|
|
9600
9708
|
case FILTER_TYPES.moreThan:
|
|
9601
|
-
return
|
|
9709
|
+
return _concatInstanceProperty(_context2 = "".concat(target, " > ")).call(_context2, value);
|
|
9602
9710
|
case FILTER_TYPES.equalTo:
|
|
9603
|
-
return
|
|
9711
|
+
return _concatInstanceProperty(_context3 = "".concat(target, " = ")).call(_context3, value);
|
|
9604
9712
|
case FILTER_TYPES.range:
|
|
9605
|
-
return
|
|
9713
|
+
return _concatInstanceProperty(_context4 = _concatInstanceProperty(_context5 = _concatInstanceProperty(_context6 = "".concat(target, " >= ")).call(_context6, value.from, " and ")).call(_context5, target, " <= ")).call(_context4, value.to);
|
|
9606
9714
|
default:
|
|
9607
9715
|
return '';
|
|
9608
9716
|
}
|
|
9609
9717
|
};
|
|
9610
9718
|
function customFields (filter, locale) {
|
|
9611
9719
|
const customFieldsPredicates = _mapInstanceProperty(filter).call(filter, customFieldFilter => {
|
|
9720
|
+
var _context7, _context8, _context9, _context10, _context11;
|
|
9612
9721
|
const _customFieldFilter$va = customFieldFilter.value,
|
|
9613
9722
|
target = _customFieldFilter$va.target,
|
|
9614
9723
|
type = _customFieldFilter$va.type,
|
|
@@ -9616,14 +9725,14 @@ function customFields (filter, locale) {
|
|
|
9616
9725
|
option = _customFieldFilter$va.option;
|
|
9617
9726
|
switch (type.name) {
|
|
9618
9727
|
case FIELD_TYPES.Boolean:
|
|
9619
|
-
return
|
|
9728
|
+
return _concatInstanceProperty(_context7 = "".concat(target, " = ")).call(_context7, value.value);
|
|
9620
9729
|
case FIELD_TYPES.String:
|
|
9621
|
-
return
|
|
9730
|
+
return _concatInstanceProperty(_context8 = "".concat(target, " = \"")).call(_context8, value, "\"");
|
|
9622
9731
|
case FIELD_TYPES.LocalizedString:
|
|
9623
|
-
return
|
|
9732
|
+
return _concatInstanceProperty(_context9 = "".concat(target, "(")).call(_context9, localizedTextTransformer(value), ")");
|
|
9624
9733
|
case FIELD_TYPES.Enum:
|
|
9625
9734
|
case FIELD_TYPES.LocalizedEnum:
|
|
9626
|
-
return
|
|
9735
|
+
return _concatInstanceProperty(_context10 = "".concat(target, " = \"")).call(_context10, value.value, "\"");
|
|
9627
9736
|
case FIELD_TYPES.Time:
|
|
9628
9737
|
return timeTransformer(target, [{
|
|
9629
9738
|
type: option,
|
|
@@ -9638,14 +9747,14 @@ function customFields (filter, locale) {
|
|
|
9638
9747
|
case FIELD_TYPES.Number:
|
|
9639
9748
|
return composeNumberPredicateFromFilter(target, value, option);
|
|
9640
9749
|
case FIELD_TYPES.Money:
|
|
9641
|
-
return
|
|
9750
|
+
return _concatInstanceProperty(_context11 = "".concat(target, "(")).call(_context11, moneyTransformer(value, option, locale), ")");
|
|
9642
9751
|
case FIELD_TYPES.Reference:
|
|
9643
9752
|
case FIELD_TYPES.Set:
|
|
9644
9753
|
default:
|
|
9645
9754
|
throw new Error('Custom field type not recognized');
|
|
9646
9755
|
}
|
|
9647
9756
|
});
|
|
9648
|
-
return
|
|
9757
|
+
return "(custom(fields(".concat(customFieldsPredicates.join(' and '), ")))");
|
|
9649
9758
|
}
|
|
9650
9759
|
|
|
9651
9760
|
// https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/btoa#Unicode_strings
|
|
@@ -9690,7 +9799,7 @@ function ownKeys$z(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySy
|
|
|
9690
9799
|
function _objectSpread$z(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys$z(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys$z(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9691
9800
|
const resourcesWithPlatformLimits = _Object$keys(RESOURCES_WITH_PLATFORM_LIMITS);
|
|
9692
9801
|
const createQueryVariables = platformLimit => _reduceInstanceProperty(resourcesWithPlatformLimits).call(resourcesWithPlatformLimits, (previousIncludedLimits, nextNameOfLimit) => _objectSpread$z({
|
|
9693
|
-
[camelCase(
|
|
9802
|
+
[camelCase("should include ".concat(nextNameOfLimit))]: platformLimit ? nextNameOfLimit === platformLimit : true
|
|
9694
9803
|
}, previousIncludedLimits), {});
|
|
9695
9804
|
|
|
9696
9805
|
var PlatformLimitsFetcherQuery = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "PlatformLimitsFetcherQuery" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeShoppingLists" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeProductDiscounts" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeCartDiscounts" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeStores" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeCustomers" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeCustomerGroups" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeZones" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeTaxCategories" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeShippingMethods" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeCarts" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "Boolean" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limits" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "shoppingLists" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeShoppingLists" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "current" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "lineItems" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "textLineItems" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "productDiscounts" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeProductDiscounts" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "totalActive" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "current" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "cartDiscounts" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeCartDiscounts" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "totalActiveWithoutDiscountCodes" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "current" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "stores" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeStores" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "current" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "inventorySupplyChannels" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "productDistributionChannels" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "customers" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeCustomers" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "current" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "customerGroups" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeCustomerGroups" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "current" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "zones" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeZones" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "current" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "taxCategories" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeTaxCategories" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "current" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "shippingMethods" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeShippingMethods" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "current" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "carts" }, arguments: [], directives: [{ kind: "Directive", name: { kind: "Name", value: "include" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "if" }, value: { kind: "Variable", name: { kind: "Name", value: "shouldIncludeCarts" } } }] }], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "limit" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "current" }, arguments: [], directives: [] }] } }] } }] } }] } }], loc: { start: 0, end: 1820, source: { body: "query PlatformLimitsFetcherQuery(\n $shouldIncludeShoppingLists: Boolean!\n $shouldIncludeProductDiscounts: Boolean!\n $shouldIncludeCartDiscounts: Boolean!\n $shouldIncludeStores: Boolean!\n $shouldIncludeCustomers: Boolean!\n $shouldIncludeCustomerGroups: Boolean!\n $shouldIncludeZones: Boolean!\n $shouldIncludeTaxCategories: Boolean!\n $shouldIncludeShippingMethods: Boolean!\n $shouldIncludeCarts: Boolean!\n) {\n limits {\n shoppingLists @include(if: $shouldIncludeShoppingLists) {\n total {\n limit\n current\n }\n lineItems {\n limit\n }\n textLineItems {\n limit\n }\n }\n productDiscounts @include(if: $shouldIncludeProductDiscounts) {\n totalActive {\n limit\n current\n }\n }\n cartDiscounts @include(if: $shouldIncludeCartDiscounts) {\n totalActiveWithoutDiscountCodes {\n limit\n current\n }\n }\n stores @include(if: $shouldIncludeStores) {\n total {\n limit\n current\n }\n inventorySupplyChannels {\n limit\n }\n productDistributionChannels {\n limit\n }\n }\n customers @include(if: $shouldIncludeCustomers) {\n total {\n limit\n current\n }\n }\n customerGroups @include(if: $shouldIncludeCustomerGroups) {\n total {\n limit\n current\n }\n }\n zones @include(if: $shouldIncludeZones) {\n total {\n limit\n current\n }\n }\n taxCategories @include(if: $shouldIncludeTaxCategories) {\n total {\n limit\n current\n }\n }\n shippingMethods @include(if: $shouldIncludeShippingMethods) {\n total {\n limit\n current\n }\n }\n carts @include(if: $shouldIncludeCarts) {\n total {\n limit\n current\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
@@ -9706,7 +9815,7 @@ const usePlatformLimitsFetcher = platformLimit => {
|
|
|
9706
9815
|
error = _useQuery.error,
|
|
9707
9816
|
data = _useQuery.data,
|
|
9708
9817
|
refetch = _useQuery.refetch;
|
|
9709
|
-
const platformLimits = !loading ? omit(data
|
|
9818
|
+
const platformLimits = !loading ? omit(data === null || data === void 0 ? void 0 : data.limits, '__typename') : {};
|
|
9710
9819
|
return {
|
|
9711
9820
|
isLoading: loading,
|
|
9712
9821
|
error,
|
|
@@ -9897,10 +10006,11 @@ const getPlatformLimitsStatus = _ref3 => {
|
|
|
9897
10006
|
total = _ref3.total,
|
|
9898
10007
|
intl = _ref3.intl;
|
|
9899
10008
|
if (limit) {
|
|
9900
|
-
|
|
10009
|
+
var _context;
|
|
10010
|
+
return _concatInstanceProperty(_context = "(".concat(intl.formatNumber(current), "/")).call(_context, intl.formatNumber(limit), ")");
|
|
9901
10011
|
}
|
|
9902
10012
|
if (total) {
|
|
9903
|
-
return
|
|
10013
|
+
return "(".concat(intl.formatNumber(total), ")");
|
|
9904
10014
|
}
|
|
9905
10015
|
return '';
|
|
9906
10016
|
};
|
|
@@ -9920,17 +10030,18 @@ const useShippingMethodsPlatformLimitsFetcher = () => {
|
|
|
9920
10030
|
};
|
|
9921
10031
|
|
|
9922
10032
|
const useShippingMethodsPlatformLimits = () => {
|
|
10033
|
+
var _platformLimits$shipp;
|
|
9923
10034
|
const _useShippingMethodsPl = useShippingMethodsPlatformLimitsFetcher(),
|
|
9924
10035
|
platformLimits = _useShippingMethodsPl.platformLimits;
|
|
9925
|
-
if (!platformLimits
|
|
10036
|
+
if (!(platformLimits !== null && platformLimits !== void 0 && (_platformLimits$shipp = platformLimits.shippingMethods) !== null && _platformLimits$shipp !== void 0 && _platformLimits$shipp.total)) {
|
|
9926
10037
|
return {
|
|
9927
10038
|
hasReachedShippingMethodsWarningLimit: false,
|
|
9928
10039
|
hasReachedShippingMethodsErrorLimit: false
|
|
9929
10040
|
};
|
|
9930
10041
|
}
|
|
9931
|
-
const _platformLimits$
|
|
9932
|
-
limit = _platformLimits$
|
|
9933
|
-
current = _platformLimits$
|
|
10042
|
+
const _platformLimits$shipp2 = platformLimits.shippingMethods.total,
|
|
10043
|
+
limit = _platformLimits$shipp2.limit,
|
|
10044
|
+
current = _platformLimits$shipp2.current;
|
|
9934
10045
|
const hasReachedShippingMethodsWarningLimit = getHasExceededWarningThreshold({
|
|
9935
10046
|
limit,
|
|
9936
10047
|
current
|
|
@@ -9946,12 +10057,13 @@ const useShippingMethodsPlatformLimits = () => {
|
|
|
9946
10057
|
};
|
|
9947
10058
|
|
|
9948
10059
|
const PlatformLimitsShippingMethodsNotifications = () => {
|
|
10060
|
+
var _platformLimits$shipp;
|
|
9949
10061
|
const _useShippingMethodsPl = useShippingMethodsPlatformLimitsFetcher(),
|
|
9950
10062
|
platformLimits = _useShippingMethodsPl.platformLimits;
|
|
9951
10063
|
const _useShippingMethodsPl2 = useShippingMethodsPlatformLimits(),
|
|
9952
10064
|
hasReachedShippingMethodsWarningLimit = _useShippingMethodsPl2.hasReachedShippingMethodsWarningLimit,
|
|
9953
10065
|
hasReachedShippingMethodsErrorLimit = _useShippingMethodsPl2.hasReachedShippingMethodsErrorLimit;
|
|
9954
|
-
if (!platformLimits
|
|
10066
|
+
if (!(platformLimits !== null && platformLimits !== void 0 && (_platformLimits$shipp = platformLimits.shippingMethods) !== null && _platformLimits$shipp !== void 0 && _platformLimits$shipp.total)) {
|
|
9955
10067
|
return null;
|
|
9956
10068
|
}
|
|
9957
10069
|
if (hasReachedShippingMethodsErrorLimit) {
|
|
@@ -9997,12 +10109,13 @@ var messages$k = defineMessages({
|
|
|
9997
10109
|
});
|
|
9998
10110
|
|
|
9999
10111
|
const PlatformLimitsShippingMethodsStatus = _ref => {
|
|
10112
|
+
var _platformLimits$shipp, _platformLimits$shipp2;
|
|
10000
10113
|
let total = _ref.total;
|
|
10001
10114
|
const intl = useIntl();
|
|
10002
10115
|
const _useShippingMethodsPl = useShippingMethodsPlatformLimitsFetcher(),
|
|
10003
10116
|
platformLimits = _useShippingMethodsPl.platformLimits;
|
|
10004
|
-
const current = platformLimits
|
|
10005
|
-
const limit = platformLimits
|
|
10117
|
+
const current = platformLimits === null || platformLimits === void 0 || (_platformLimits$shipp = platformLimits.shippingMethods) === null || _platformLimits$shipp === void 0 || (_platformLimits$shipp = _platformLimits$shipp.total) === null || _platformLimits$shipp === void 0 ? void 0 : _platformLimits$shipp.current;
|
|
10118
|
+
const limit = platformLimits === null || platformLimits === void 0 || (_platformLimits$shipp2 = platformLimits.shippingMethods) === null || _platformLimits$shipp2 === void 0 || (_platformLimits$shipp2 = _platformLimits$shipp2.total) === null || _platformLimits$shipp2 === void 0 ? void 0 : _platformLimits$shipp2.limit;
|
|
10006
10119
|
return jsx(PlatformLimitsStatusText, {
|
|
10007
10120
|
intlMessage: messages$k.shippingMethodsStatus,
|
|
10008
10121
|
children: getPlatformLimitsStatus({
|
|
@@ -10064,17 +10177,18 @@ const useTaxCategoriesPlatformLimitsFetcher = () => {
|
|
|
10064
10177
|
};
|
|
10065
10178
|
|
|
10066
10179
|
const useTaxCategoriesPlatformLimits = () => {
|
|
10180
|
+
var _platformLimits$taxCa;
|
|
10067
10181
|
const _useTaxCategoriesPlat = useTaxCategoriesPlatformLimitsFetcher(),
|
|
10068
10182
|
platformLimits = _useTaxCategoriesPlat.platformLimits;
|
|
10069
|
-
if (!platformLimits
|
|
10183
|
+
if (!(platformLimits !== null && platformLimits !== void 0 && (_platformLimits$taxCa = platformLimits.taxCategories) !== null && _platformLimits$taxCa !== void 0 && _platformLimits$taxCa.total)) {
|
|
10070
10184
|
return {
|
|
10071
10185
|
hasReachedTaxCategoriesWarningLimit: false,
|
|
10072
10186
|
hasReachedTaxCategoriesErrorLimit: false
|
|
10073
10187
|
};
|
|
10074
10188
|
}
|
|
10075
|
-
const _platformLimits$
|
|
10076
|
-
limit = _platformLimits$
|
|
10077
|
-
current = _platformLimits$
|
|
10189
|
+
const _platformLimits$taxCa2 = platformLimits.taxCategories.total,
|
|
10190
|
+
limit = _platformLimits$taxCa2.limit,
|
|
10191
|
+
current = _platformLimits$taxCa2.current;
|
|
10078
10192
|
const hasReachedTaxCategoriesWarningLimit = getHasExceededWarningThreshold({
|
|
10079
10193
|
limit,
|
|
10080
10194
|
current
|
|
@@ -10090,12 +10204,13 @@ const useTaxCategoriesPlatformLimits = () => {
|
|
|
10090
10204
|
};
|
|
10091
10205
|
|
|
10092
10206
|
const PlatformLimitsTaxCategoriesNotifications = () => {
|
|
10207
|
+
var _platformLimits$taxCa;
|
|
10093
10208
|
const _useTaxCategoriesPlat = useTaxCategoriesPlatformLimitsFetcher(),
|
|
10094
10209
|
platformLimits = _useTaxCategoriesPlat.platformLimits;
|
|
10095
10210
|
const _useTaxCategoriesPlat2 = useTaxCategoriesPlatformLimits(),
|
|
10096
10211
|
hasReachedTaxCategoriesWarningLimit = _useTaxCategoriesPlat2.hasReachedTaxCategoriesWarningLimit,
|
|
10097
10212
|
hasReachedTaxCategoriesErrorLimit = _useTaxCategoriesPlat2.hasReachedTaxCategoriesErrorLimit;
|
|
10098
|
-
if (!platformLimits
|
|
10213
|
+
if (!(platformLimits !== null && platformLimits !== void 0 && (_platformLimits$taxCa = platformLimits.taxCategories) !== null && _platformLimits$taxCa !== void 0 && _platformLimits$taxCa.total)) {
|
|
10099
10214
|
return null;
|
|
10100
10215
|
}
|
|
10101
10216
|
if (hasReachedTaxCategoriesErrorLimit) {
|
|
@@ -10141,12 +10256,13 @@ var messages$i = defineMessages({
|
|
|
10141
10256
|
});
|
|
10142
10257
|
|
|
10143
10258
|
const PlatformLimitsTaxCategoriesStatus = _ref => {
|
|
10259
|
+
var _platformLimits$taxCa, _platformLimits$taxCa2;
|
|
10144
10260
|
let total = _ref.total;
|
|
10145
10261
|
const intl = useIntl();
|
|
10146
10262
|
const _useTaxCategoriesPlat = useTaxCategoriesPlatformLimitsFetcher(),
|
|
10147
10263
|
platformLimits = _useTaxCategoriesPlat.platformLimits;
|
|
10148
|
-
const current = platformLimits
|
|
10149
|
-
const limit = platformLimits
|
|
10264
|
+
const current = platformLimits === null || platformLimits === void 0 || (_platformLimits$taxCa = platformLimits.taxCategories) === null || _platformLimits$taxCa === void 0 || (_platformLimits$taxCa = _platformLimits$taxCa.total) === null || _platformLimits$taxCa === void 0 ? void 0 : _platformLimits$taxCa.current;
|
|
10265
|
+
const limit = platformLimits === null || platformLimits === void 0 || (_platformLimits$taxCa2 = platformLimits.taxCategories) === null || _platformLimits$taxCa2 === void 0 || (_platformLimits$taxCa2 = _platformLimits$taxCa2.total) === null || _platformLimits$taxCa2 === void 0 ? void 0 : _platformLimits$taxCa2.limit;
|
|
10150
10266
|
return jsx(PlatformLimitsStatusText, {
|
|
10151
10267
|
intlMessage: messages$i.taxCategoriesStatus,
|
|
10152
10268
|
children: getPlatformLimitsStatus({
|
|
@@ -10208,17 +10324,18 @@ const useZonesPlatformLimitsFetcher = () => {
|
|
|
10208
10324
|
};
|
|
10209
10325
|
|
|
10210
10326
|
const useZonesPlatformLimits = () => {
|
|
10327
|
+
var _platformLimits$zones;
|
|
10211
10328
|
const _useZonesPlatformLimi = useZonesPlatformLimitsFetcher(),
|
|
10212
10329
|
platformLimits = _useZonesPlatformLimi.platformLimits;
|
|
10213
|
-
if (!platformLimits
|
|
10330
|
+
if (!(platformLimits !== null && platformLimits !== void 0 && (_platformLimits$zones = platformLimits.zones) !== null && _platformLimits$zones !== void 0 && _platformLimits$zones.total)) {
|
|
10214
10331
|
return {
|
|
10215
10332
|
hasReachedZonesWarningLimit: false,
|
|
10216
10333
|
hasReachedZonesErrorLimit: false
|
|
10217
10334
|
};
|
|
10218
10335
|
}
|
|
10219
|
-
const _platformLimits$
|
|
10220
|
-
limit = _platformLimits$
|
|
10221
|
-
current = _platformLimits$
|
|
10336
|
+
const _platformLimits$zones2 = platformLimits.zones.total,
|
|
10337
|
+
limit = _platformLimits$zones2.limit,
|
|
10338
|
+
current = _platformLimits$zones2.current;
|
|
10222
10339
|
const hasReachedZonesWarningLimit = getHasExceededWarningThreshold({
|
|
10223
10340
|
limit,
|
|
10224
10341
|
current
|
|
@@ -10234,12 +10351,13 @@ const useZonesPlatformLimits = () => {
|
|
|
10234
10351
|
};
|
|
10235
10352
|
|
|
10236
10353
|
const PlatformLimitsZonesNotifications = () => {
|
|
10354
|
+
var _platformLimits$zones;
|
|
10237
10355
|
const _useZonesPlatformLimi = useZonesPlatformLimitsFetcher(),
|
|
10238
10356
|
platformLimits = _useZonesPlatformLimi.platformLimits;
|
|
10239
10357
|
const _useZonesPlatformLimi2 = useZonesPlatformLimits(),
|
|
10240
10358
|
hasReachedZonesWarningLimit = _useZonesPlatformLimi2.hasReachedZonesWarningLimit,
|
|
10241
10359
|
hasReachedZonesErrorLimit = _useZonesPlatformLimi2.hasReachedZonesErrorLimit;
|
|
10242
|
-
if (!platformLimits
|
|
10360
|
+
if (!(platformLimits !== null && platformLimits !== void 0 && (_platformLimits$zones = platformLimits.zones) !== null && _platformLimits$zones !== void 0 && _platformLimits$zones.total)) {
|
|
10243
10361
|
return null;
|
|
10244
10362
|
}
|
|
10245
10363
|
if (hasReachedZonesErrorLimit) {
|
|
@@ -10285,12 +10403,13 @@ var messages$g = defineMessages({
|
|
|
10285
10403
|
});
|
|
10286
10404
|
|
|
10287
10405
|
const PlatformLimitsZonesStatus = _ref => {
|
|
10406
|
+
var _platformLimits$zones, _platformLimits$zones2;
|
|
10288
10407
|
let total = _ref.total;
|
|
10289
10408
|
const intl = useIntl();
|
|
10290
10409
|
const _useZonesPlatformLimi = useZonesPlatformLimitsFetcher(),
|
|
10291
10410
|
platformLimits = _useZonesPlatformLimi.platformLimits;
|
|
10292
|
-
const current = platformLimits
|
|
10293
|
-
const limit = platformLimits
|
|
10411
|
+
const current = platformLimits === null || platformLimits === void 0 || (_platformLimits$zones = platformLimits.zones) === null || _platformLimits$zones === void 0 || (_platformLimits$zones = _platformLimits$zones.total) === null || _platformLimits$zones === void 0 ? void 0 : _platformLimits$zones.current;
|
|
10412
|
+
const limit = platformLimits === null || platformLimits === void 0 || (_platformLimits$zones2 = platformLimits.zones) === null || _platformLimits$zones2 === void 0 || (_platformLimits$zones2 = _platformLimits$zones2.total) === null || _platformLimits$zones2 === void 0 ? void 0 : _platformLimits$zones2.limit;
|
|
10294
10413
|
return jsx(PlatformLimitsStatusText, {
|
|
10295
10414
|
intlMessage: messages$g.zonesStatus,
|
|
10296
10415
|
children: getPlatformLimitsStatus({
|
|
@@ -10352,17 +10471,18 @@ const useCustomersPlatformLimitsFetcher = () => {
|
|
|
10352
10471
|
};
|
|
10353
10472
|
|
|
10354
10473
|
const useCustomersPlatformLimits$1 = () => {
|
|
10474
|
+
var _platformLimits$custo;
|
|
10355
10475
|
const _useCustomersPlatform = useCustomersPlatformLimitsFetcher(),
|
|
10356
10476
|
platformLimits = _useCustomersPlatform.platformLimits;
|
|
10357
|
-
if (!platformLimits
|
|
10477
|
+
if (!(platformLimits !== null && platformLimits !== void 0 && (_platformLimits$custo = platformLimits.customers) !== null && _platformLimits$custo !== void 0 && _platformLimits$custo.total)) {
|
|
10358
10478
|
return {
|
|
10359
10479
|
hasReachedCustomersWarningLimit: false,
|
|
10360
10480
|
hasReachedCustomersErrorLimit: false
|
|
10361
10481
|
};
|
|
10362
10482
|
}
|
|
10363
|
-
const _platformLimits$
|
|
10364
|
-
limit = _platformLimits$
|
|
10365
|
-
current = _platformLimits$
|
|
10483
|
+
const _platformLimits$custo2 = platformLimits.customers.total,
|
|
10484
|
+
limit = _platformLimits$custo2.limit,
|
|
10485
|
+
current = _platformLimits$custo2.current;
|
|
10366
10486
|
const hasReachedCustomersWarningLimit = getHasExceededWarningThreshold({
|
|
10367
10487
|
limit,
|
|
10368
10488
|
current
|
|
@@ -10391,12 +10511,13 @@ const useCustomersPlatormLimitsModalState = () => {
|
|
|
10391
10511
|
};
|
|
10392
10512
|
|
|
10393
10513
|
const PlatformLimitsCustomersNotifications = () => {
|
|
10514
|
+
var _platformLimits$custo;
|
|
10394
10515
|
const _useCustomersPlatform = useCustomersPlatformLimitsFetcher(),
|
|
10395
10516
|
platformLimits = _useCustomersPlatform.platformLimits;
|
|
10396
10517
|
const _useCustomersPlatform2 = useCustomersPlatformLimits$1(),
|
|
10397
10518
|
hasReachedCustomersWarningLimit = _useCustomersPlatform2.hasReachedCustomersWarningLimit,
|
|
10398
10519
|
hasReachedCustomersErrorLimit = _useCustomersPlatform2.hasReachedCustomersErrorLimit;
|
|
10399
|
-
if (!platformLimits
|
|
10520
|
+
if (!(platformLimits !== null && platformLimits !== void 0 && (_platformLimits$custo = platformLimits.customers) !== null && _platformLimits$custo !== void 0 && _platformLimits$custo.total)) {
|
|
10400
10521
|
return jsx("div", {});
|
|
10401
10522
|
}
|
|
10402
10523
|
if (hasReachedCustomersErrorLimit) {
|
|
@@ -10447,15 +10568,16 @@ var styles$b = {
|
|
|
10447
10568
|
"status": "platform-limits-customers-status-module__status___3rXYM"
|
|
10448
10569
|
};
|
|
10449
10570
|
const PlatformLimitsCustomersStatus = () => {
|
|
10571
|
+
var _platformLimits$custo;
|
|
10450
10572
|
const intl = useIntl();
|
|
10451
10573
|
const _useCustomersPlatform = useCustomersPlatformLimitsFetcher(),
|
|
10452
10574
|
platformLimits = _useCustomersPlatform.platformLimits;
|
|
10453
|
-
if (!platformLimits
|
|
10575
|
+
if (!(platformLimits !== null && platformLimits !== void 0 && (_platformLimits$custo = platformLimits.customers) !== null && _platformLimits$custo !== void 0 && _platformLimits$custo.total)) {
|
|
10454
10576
|
return null;
|
|
10455
10577
|
}
|
|
10456
|
-
const _platformLimits$
|
|
10457
|
-
current = _platformLimits$
|
|
10458
|
-
limit = _platformLimits$
|
|
10578
|
+
const _platformLimits$custo2 = platformLimits.customers.total,
|
|
10579
|
+
current = _platformLimits$custo2.current,
|
|
10580
|
+
limit = _platformLimits$custo2.limit;
|
|
10459
10581
|
return jsx("div", {
|
|
10460
10582
|
className: styles$b.status,
|
|
10461
10583
|
children: jsx(Text.Detail, {
|
|
@@ -10689,17 +10811,18 @@ const useCustomerGroupsPlatformLimitsFetcher = () => {
|
|
|
10689
10811
|
};
|
|
10690
10812
|
|
|
10691
10813
|
const useCustomerGroupsPlatformLimitsStatus = () => {
|
|
10814
|
+
var _platformLimits$custo;
|
|
10692
10815
|
const _useCustomerGroupsPla = useCustomerGroupsPlatformLimitsFetcher(),
|
|
10693
10816
|
platformLimits = _useCustomerGroupsPla.platformLimits;
|
|
10694
|
-
if (!platformLimits
|
|
10817
|
+
if (!(platformLimits !== null && platformLimits !== void 0 && (_platformLimits$custo = platformLimits.customerGroups) !== null && _platformLimits$custo !== void 0 && _platformLimits$custo.total)) {
|
|
10695
10818
|
return {
|
|
10696
10819
|
hasReachedCustomerGroupsWarningLimit: false,
|
|
10697
10820
|
hasReachedCustomerGroupsErrorLimit: false
|
|
10698
10821
|
};
|
|
10699
10822
|
}
|
|
10700
|
-
const _platformLimits$
|
|
10701
|
-
limit = _platformLimits$
|
|
10702
|
-
current = _platformLimits$
|
|
10823
|
+
const _platformLimits$custo2 = platformLimits.customerGroups.total,
|
|
10824
|
+
limit = _platformLimits$custo2.limit,
|
|
10825
|
+
current = _platformLimits$custo2.current;
|
|
10703
10826
|
const hasReachedCustomerGroupsWarningLimit = getHasExceededWarningThreshold({
|
|
10704
10827
|
limit,
|
|
10705
10828
|
current
|
|
@@ -10728,12 +10851,13 @@ const useCustomerGroupsPlatormLimitsModalState = () => {
|
|
|
10728
10851
|
};
|
|
10729
10852
|
|
|
10730
10853
|
const PlatformLimitsCustomerGroupsNotifications = () => {
|
|
10854
|
+
var _platformLimits$custo;
|
|
10731
10855
|
const _useCustomerGroupsPla = useCustomerGroupsPlatformLimitsFetcher(),
|
|
10732
10856
|
platformLimits = _useCustomerGroupsPla.platformLimits;
|
|
10733
10857
|
const _useCustomerGroupsPla2 = useCustomerGroupsPlatformLimitsStatus(),
|
|
10734
10858
|
hasReachedCustomerGroupsWarningLimit = _useCustomerGroupsPla2.hasReachedCustomerGroupsWarningLimit,
|
|
10735
10859
|
hasReachedCustomerGroupsErrorLimit = _useCustomerGroupsPla2.hasReachedCustomerGroupsErrorLimit;
|
|
10736
|
-
if (!platformLimits
|
|
10860
|
+
if (!(platformLimits !== null && platformLimits !== void 0 && (_platformLimits$custo = platformLimits.customerGroups) !== null && _platformLimits$custo !== void 0 && _platformLimits$custo.total)) {
|
|
10737
10861
|
return jsx("div", {});
|
|
10738
10862
|
}
|
|
10739
10863
|
if (hasReachedCustomerGroupsErrorLimit) {
|
|
@@ -10784,15 +10908,16 @@ var styles$9 = {
|
|
|
10784
10908
|
"status": "platform-limits-customer-groups-status-module__status___6099G"
|
|
10785
10909
|
};
|
|
10786
10910
|
const PlatformLimitsCustomerGroupsStatus = () => {
|
|
10911
|
+
var _platformLimits$custo;
|
|
10787
10912
|
const intl = useIntl();
|
|
10788
10913
|
const _useCustomerGroupsPla = useCustomerGroupsPlatformLimitsFetcher(),
|
|
10789
10914
|
platformLimits = _useCustomerGroupsPla.platformLimits;
|
|
10790
|
-
if (!platformLimits
|
|
10915
|
+
if (!(platformLimits !== null && platformLimits !== void 0 && (_platformLimits$custo = platformLimits.customerGroups) !== null && _platformLimits$custo !== void 0 && _platformLimits$custo.total)) {
|
|
10791
10916
|
return null;
|
|
10792
10917
|
}
|
|
10793
|
-
const _platformLimits$
|
|
10794
|
-
current = _platformLimits$
|
|
10795
|
-
limit = _platformLimits$
|
|
10918
|
+
const _platformLimits$custo2 = platformLimits.customerGroups.total,
|
|
10919
|
+
current = _platformLimits$custo2.current,
|
|
10920
|
+
limit = _platformLimits$custo2.limit;
|
|
10796
10921
|
return jsx("div", {
|
|
10797
10922
|
className: styles$9.status,
|
|
10798
10923
|
children: jsx(Text.Detail, {
|
|
@@ -11024,7 +11149,7 @@ var fetchPimIndexStatus = ((apolloClient, projectKey) => async dispatch => {
|
|
|
11024
11149
|
try {
|
|
11025
11150
|
await dispatch(actions.head({
|
|
11026
11151
|
mcApiProxyTarget: MC_API_PROXY_TARGETS.PIM_SEARCH,
|
|
11027
|
-
uri:
|
|
11152
|
+
uri: "/".concat(projectKey, "/search/products")
|
|
11028
11153
|
}));
|
|
11029
11154
|
return {
|
|
11030
11155
|
status: 'indexed'
|
|
@@ -11127,51 +11252,50 @@ const getIndexingJobIds = _ref => {
|
|
|
11127
11252
|
products = _ref$data.products,
|
|
11128
11253
|
productTypes = _ref$data.productTypes;
|
|
11129
11254
|
return {
|
|
11130
|
-
productsJobId: products
|
|
11131
|
-
productTypesJobId: productTypes
|
|
11255
|
+
productsJobId: (products === null || products === void 0 ? void 0 : products.indexingJobId) || (products === null || products === void 0 ? void 0 : products.existingIndexingJobId),
|
|
11256
|
+
productTypesJobId: (productTypes === null || productTypes === void 0 ? void 0 : productTypes.indexingJobId) || (productTypes === null || productTypes === void 0 ? void 0 : productTypes.existingIndexingJobId)
|
|
11132
11257
|
};
|
|
11133
11258
|
};
|
|
11134
11259
|
let PimIndexerProvider = /*#__PURE__*/function (_PureComponent) {
|
|
11135
|
-
_inherits(PimIndexerProvider, _PureComponent);
|
|
11136
11260
|
function PimIndexerProvider() {
|
|
11137
|
-
var
|
|
11261
|
+
var _this2;
|
|
11138
11262
|
_classCallCheck(this, PimIndexerProvider);
|
|
11139
11263
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
11140
11264
|
args[_key] = arguments[_key];
|
|
11141
11265
|
}
|
|
11142
|
-
|
|
11143
|
-
|
|
11266
|
+
_this2 = _callSuper$3(this, PimIndexerProvider, [...args]);
|
|
11267
|
+
_this2.state = {
|
|
11144
11268
|
isLoading: true,
|
|
11145
11269
|
isPimIndexerUnreachable: false,
|
|
11146
11270
|
isProjectIndexedByPim: false,
|
|
11147
11271
|
isProjectBeingIndexedByPim: false
|
|
11148
11272
|
};
|
|
11149
|
-
|
|
11273
|
+
_this2.checkIfProjectIsIndexed = async () => {
|
|
11150
11274
|
var _context;
|
|
11151
|
-
const _await$
|
|
11152
|
-
status = _await$
|
|
11153
|
-
isIndexingProducts = _await$
|
|
11154
|
-
isIndexingProductTypes = _await$
|
|
11275
|
+
const _await$_this2$props$f = await _this2.props.fetchPimIndexStatus(_this2.props.client, _this2.props.projectKey),
|
|
11276
|
+
status = _await$_this2$props$f.status,
|
|
11277
|
+
isIndexingProducts = _await$_this2$props$f.isIndexingProducts,
|
|
11278
|
+
isIndexingProductTypes = _await$_this2$props$f.isIndexingProductTypes;
|
|
11155
11279
|
const isPimIndexerUnreachable = _includesInstanceProperty(_context = ['not-configured', 'unreachable']).call(_context, status);
|
|
11156
11280
|
if (status === 'indexing') {
|
|
11157
|
-
|
|
11281
|
+
_this2.monitorIndexingProgress({
|
|
11158
11282
|
isIndexingProducts,
|
|
11159
11283
|
isIndexingProductTypes
|
|
11160
11284
|
});
|
|
11161
11285
|
} else {
|
|
11162
|
-
|
|
11286
|
+
_this2.setState({
|
|
11163
11287
|
isLoading: false,
|
|
11164
11288
|
isPimIndexerUnreachable,
|
|
11165
11289
|
isProjectIndexedByPim: status === 'indexed'
|
|
11166
11290
|
});
|
|
11167
11291
|
}
|
|
11168
11292
|
};
|
|
11169
|
-
|
|
11170
|
-
|
|
11293
|
+
_this2.componentDidMount = () => {
|
|
11294
|
+
_this2.checkIfProjectIsIndexed();
|
|
11171
11295
|
};
|
|
11172
|
-
|
|
11173
|
-
if (
|
|
11174
|
-
return
|
|
11296
|
+
_this2.attemptToRefreshProducts = products => {
|
|
11297
|
+
if (_this2.state.isProjectIndexedByPim) {
|
|
11298
|
+
return _this2.props.refreshProductIndicesByIds({
|
|
11175
11299
|
context: pimIndexerRequestContext,
|
|
11176
11300
|
variables: {
|
|
11177
11301
|
ids: _mapInstanceProperty(products).call(products, product => product.id)
|
|
@@ -11188,26 +11312,26 @@ let PimIndexerProvider = /*#__PURE__*/function (_PureComponent) {
|
|
|
11188
11312
|
}
|
|
11189
11313
|
return _Promise.resolve();
|
|
11190
11314
|
};
|
|
11191
|
-
|
|
11192
|
-
|
|
11315
|
+
_this2.handleFailedIndexing = () => {
|
|
11316
|
+
_this2.setState({
|
|
11193
11317
|
isProjectBeingIndexedByPim: false,
|
|
11194
11318
|
isProjectIndexedByPim: false
|
|
11195
11319
|
});
|
|
11196
|
-
|
|
11320
|
+
_this2.props.notifications.showNotification({
|
|
11197
11321
|
kind: 'error',
|
|
11198
11322
|
domain: DOMAINS.SIDE,
|
|
11199
|
-
text:
|
|
11323
|
+
text: _this2.props.intl.formatMessage(messages$9.indexingFailed)
|
|
11200
11324
|
});
|
|
11201
11325
|
};
|
|
11202
|
-
|
|
11203
|
-
const result = await
|
|
11326
|
+
_this2.getIndexingProgress = async () => {
|
|
11327
|
+
const result = await _this2.props.client.query({
|
|
11204
11328
|
query: GetIndexingProgress,
|
|
11205
11329
|
context: pimIndexerRequestContext,
|
|
11206
11330
|
variables: {
|
|
11207
|
-
productsJobId:
|
|
11208
|
-
productTypesJobId:
|
|
11209
|
-
shouldIncludeProducts: !!
|
|
11210
|
-
shouldIncludeProductTypes: !!
|
|
11331
|
+
productsJobId: _this2.state.productsJobId || '',
|
|
11332
|
+
productTypesJobId: _this2.state.productTypesJobId || '',
|
|
11333
|
+
shouldIncludeProducts: !!_this2.state.productsJobId,
|
|
11334
|
+
shouldIncludeProductTypes: !!_this2.state.productTypesJobId
|
|
11211
11335
|
},
|
|
11212
11336
|
fetchPolicy: 'network-only'
|
|
11213
11337
|
});
|
|
@@ -11220,24 +11344,24 @@ let PimIndexerProvider = /*#__PURE__*/function (_PureComponent) {
|
|
|
11220
11344
|
productTypes: result.data.productTypes || completedStatus
|
|
11221
11345
|
};
|
|
11222
11346
|
};
|
|
11223
|
-
|
|
11347
|
+
_this2.handleFinishedIndexing = async () => {
|
|
11224
11348
|
try {
|
|
11225
|
-
|
|
11226
|
-
const _await$
|
|
11227
|
-
status = _await$
|
|
11349
|
+
_this2.updateIndexingStatusTimerHandler = null;
|
|
11350
|
+
const _await$_this2$props$f2 = await _this2.props.fetchPimIndexStatus(_this2.props.client, _this2.props.projectKey),
|
|
11351
|
+
status = _await$_this2$props$f2.status;
|
|
11228
11352
|
|
|
11229
11353
|
// There is a delay between indexing jobs reporting
|
|
11230
11354
|
// they are completed, and PIM realizing all the project is indexed.
|
|
11231
11355
|
// So, we have to wait to let PIM update project indexing status.
|
|
11232
11356
|
if (status === 'indexed') {
|
|
11233
|
-
|
|
11357
|
+
_this2.setState({
|
|
11234
11358
|
isProjectBeingIndexedByPim: false,
|
|
11235
11359
|
isProjectIndexedByPim: true
|
|
11236
11360
|
});
|
|
11237
|
-
|
|
11361
|
+
_this2.props.notifications.showNotification({
|
|
11238
11362
|
kind: 'success',
|
|
11239
11363
|
domain: DOMAINS.SIDE,
|
|
11240
|
-
text:
|
|
11364
|
+
text: _this2.props.intl.formatMessage(messages$9.indexingSucceed)
|
|
11241
11365
|
},
|
|
11242
11366
|
// because the indexing may take so long, the success notification
|
|
11243
11367
|
// may be dismissed without being seen by the user. Set `dismissAfter`
|
|
@@ -11246,63 +11370,64 @@ let PimIndexerProvider = /*#__PURE__*/function (_PureComponent) {
|
|
|
11246
11370
|
dismissAfter: 0
|
|
11247
11371
|
});
|
|
11248
11372
|
} else {
|
|
11249
|
-
|
|
11373
|
+
_this2.updateIndexingStatusTimerHandler = _setTimeout(_this2.handleFinishedIndexing, 5000);
|
|
11250
11374
|
}
|
|
11251
11375
|
} catch (e) {
|
|
11252
|
-
|
|
11376
|
+
_this2.handleFailedIndexing();
|
|
11253
11377
|
}
|
|
11254
11378
|
};
|
|
11255
|
-
|
|
11379
|
+
_this2.updateIndexingStatus = async () => {
|
|
11256
11380
|
try {
|
|
11257
|
-
const _await$
|
|
11258
|
-
products = _await$
|
|
11259
|
-
productTypes = _await$
|
|
11381
|
+
const _await$_this2$getInde = await _this2.getIndexingProgress(),
|
|
11382
|
+
products = _await$_this2$getInde.products,
|
|
11383
|
+
productTypes = _await$_this2$getInde.productTypes;
|
|
11260
11384
|
const isCompleted = isIndexingCompleted(products, productTypes);
|
|
11261
11385
|
const indexingProgress = calculateProgress(products, productTypes);
|
|
11262
|
-
|
|
11386
|
+
_this2.setState({
|
|
11263
11387
|
indexingProgress
|
|
11264
11388
|
});
|
|
11265
11389
|
if (!isCompleted) {
|
|
11266
|
-
|
|
11390
|
+
_this2.updateIndexingStatusTimerHandler = _setTimeout(_this2.updateIndexingStatus, 5000);
|
|
11267
11391
|
} else {
|
|
11268
|
-
|
|
11392
|
+
_this2.setState({
|
|
11269
11393
|
indexingProgress: 100
|
|
11270
11394
|
});
|
|
11271
|
-
|
|
11395
|
+
_this2.handleFinishedIndexing();
|
|
11272
11396
|
}
|
|
11273
11397
|
} catch (e) {
|
|
11274
|
-
|
|
11398
|
+
_this2.handleFailedIndexing();
|
|
11275
11399
|
}
|
|
11276
11400
|
};
|
|
11277
|
-
|
|
11401
|
+
_this2.monitorIndexingProgress = async _ref2 => {
|
|
11278
11402
|
let isIndexingProducts = _ref2.isIndexingProducts,
|
|
11279
11403
|
isIndexingProductTypes = _ref2.isIndexingProductTypes;
|
|
11280
|
-
if (
|
|
11404
|
+
if (_this2.state.isProjectBeingIndexedByPim) return;
|
|
11281
11405
|
try {
|
|
11282
|
-
const indexMutationResult = await
|
|
11406
|
+
const indexMutationResult = await _this2.props.indexProject({
|
|
11283
11407
|
context: pimIndexerRequestContext,
|
|
11284
11408
|
variables: {
|
|
11285
11409
|
shouldIndexProducts: isIndexingProducts,
|
|
11286
11410
|
shouldIndexProductTypes: isIndexingProductTypes
|
|
11287
11411
|
}
|
|
11288
11412
|
});
|
|
11289
|
-
|
|
11413
|
+
_this2.setState(_objectSpread$h(_objectSpread$h({
|
|
11290
11414
|
isLoading: false,
|
|
11291
11415
|
isProjectBeingIndexedByPim: true
|
|
11292
11416
|
}, getIndexingJobIds(indexMutationResult)), {}, {
|
|
11293
11417
|
indexingProgress: 0
|
|
11294
|
-
}), () =>
|
|
11418
|
+
}), () => _this2.updateIndexingStatus());
|
|
11295
11419
|
} catch (e) {
|
|
11296
|
-
|
|
11420
|
+
_this2.handleFailedIndexing();
|
|
11297
11421
|
}
|
|
11298
11422
|
};
|
|
11299
|
-
|
|
11423
|
+
_this2.indexProject = () => _this2.monitorIndexingProgress({
|
|
11300
11424
|
isIndexingProductTypes: true,
|
|
11301
11425
|
isIndexingProducts: true
|
|
11302
11426
|
});
|
|
11303
|
-
return
|
|
11427
|
+
return _this2;
|
|
11304
11428
|
}
|
|
11305
|
-
|
|
11429
|
+
_inherits(PimIndexerProvider, _PureComponent);
|
|
11430
|
+
return _createClass(PimIndexerProvider, [{
|
|
11306
11431
|
key: "componentWillUnmount",
|
|
11307
11432
|
value: function componentWillUnmount() {
|
|
11308
11433
|
if (this.updateIndexingStatusTimerHandler) clearTimeout(this.updateIndexingStatusTimerHandler);
|
|
@@ -11319,7 +11444,6 @@ let PimIndexerProvider = /*#__PURE__*/function (_PureComponent) {
|
|
|
11319
11444
|
});
|
|
11320
11445
|
}
|
|
11321
11446
|
}]);
|
|
11322
|
-
return PimIndexerProvider;
|
|
11323
11447
|
}(PureComponent);
|
|
11324
11448
|
PimIndexerProvider.displayName = 'PimIndexerProvider';
|
|
11325
11449
|
var pimIndexerProvider = flowRight(withApplicationContext(applicationContext => ({
|
|
@@ -11347,12 +11471,12 @@ function _callSuper$2(_this, derived, args) {
|
|
|
11347
11471
|
return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? _Reflect$construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
|
|
11348
11472
|
}
|
|
11349
11473
|
let WithPimIndexer = /*#__PURE__*/function (_PureComponent) {
|
|
11350
|
-
_inherits(WithPimIndexer, _PureComponent);
|
|
11351
11474
|
function WithPimIndexer() {
|
|
11352
11475
|
_classCallCheck(this, WithPimIndexer);
|
|
11353
11476
|
return _callSuper$2(this, WithPimIndexer, arguments);
|
|
11354
11477
|
}
|
|
11355
|
-
|
|
11478
|
+
_inherits(WithPimIndexer, _PureComponent);
|
|
11479
|
+
return _createClass(WithPimIndexer, [{
|
|
11356
11480
|
key: "render",
|
|
11357
11481
|
value: function render() {
|
|
11358
11482
|
return jsx(PimIndexerContext.Consumer, {
|
|
@@ -11360,7 +11484,6 @@ let WithPimIndexer = /*#__PURE__*/function (_PureComponent) {
|
|
|
11360
11484
|
});
|
|
11361
11485
|
}
|
|
11362
11486
|
}]);
|
|
11363
|
-
return WithPimIndexer;
|
|
11364
11487
|
}(PureComponent);
|
|
11365
11488
|
WithPimIndexer.displayName = 'WithPimIndexer';
|
|
11366
11489
|
|
|
@@ -11402,6 +11525,7 @@ const valueMapping = {
|
|
|
11402
11525
|
all: [true, false]
|
|
11403
11526
|
};
|
|
11404
11527
|
const BooleanField = props => {
|
|
11528
|
+
var _context;
|
|
11405
11529
|
let selectedValue;
|
|
11406
11530
|
if (typeof props.value === 'boolean') selectedValue = getBooleanValue(props.value);else if (props.isMulti && _Array$isArray(props.value) && props.value.length) selectedValue = props.value.length === 2 ? 'all' : getBooleanValue(props.value[0]);
|
|
11407
11531
|
const yesLabel = props.intl.formatMessage(messages$8.yes);
|
|
@@ -11415,7 +11539,7 @@ const BooleanField = props => {
|
|
|
11415
11539
|
}];
|
|
11416
11540
|
if (props.isMulti) options.push({
|
|
11417
11541
|
value: 'all',
|
|
11418
|
-
label:
|
|
11542
|
+
label: _concatInstanceProperty(_context = "".concat(yesLabel, " / ")).call(_context, noLabel)
|
|
11419
11543
|
});
|
|
11420
11544
|
return jsx(SelectInput, {
|
|
11421
11545
|
name: props.name,
|
|
@@ -11579,19 +11703,19 @@ const ScrollToFieldError = () => {
|
|
|
11579
11703
|
if (isValid) return;
|
|
11580
11704
|
const firstErrorElement = document.querySelector('[aria-invalid="true"]');
|
|
11581
11705
|
if (firstErrorElement) {
|
|
11706
|
+
var _ref, _ref2, _document$querySelect, _elementToScrollTo$sc;
|
|
11582
11707
|
// Get a reference to the label.
|
|
11583
11708
|
const firstElementId = firstErrorElement.getAttribute('id');
|
|
11584
|
-
const localizedInputIndex = _indexOfInstanceProperty(firstElementId).call(firstElementId,
|
|
11709
|
+
const localizedInputIndex = _indexOfInstanceProperty(firstElementId).call(firstElementId, ".".concat(dataLocale));
|
|
11585
11710
|
|
|
11586
11711
|
// check if locale is appended then remove it from id
|
|
11587
|
-
const id = localizedInputIndex > -1 ? firstElementId.replace(
|
|
11712
|
+
const id = localizedInputIndex > -1 ? firstElementId.replace(".".concat(dataLocale), '') : firstElementId;
|
|
11588
11713
|
|
|
11589
11714
|
// Scroll to the label (if found), otherwise to the input element itself.
|
|
11590
11715
|
|
|
11591
|
-
const elementToScrollTo =
|
|
11592
|
-
|
|
11593
|
-
|
|
11594
|
-
elementToScrollTo.scrollIntoView?.({
|
|
11716
|
+
const elementToScrollTo = // div is used only for custom fields
|
|
11717
|
+
(_ref = (_ref2 = (_document$querySelect = document.querySelector("div[aria-errormessage=\"".concat(firstElementId, "\"]"))) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector("label[for=\"".concat(id, "\"]"))) !== null && _ref2 !== void 0 ? _ref2 : document.querySelector("label#".concat(id))) !== null && _ref !== void 0 ? _ref : firstErrorElement;
|
|
11718
|
+
(_elementToScrollTo$sc = elementToScrollTo.scrollIntoView) === null || _elementToScrollTo$sc === void 0 || _elementToScrollTo$sc.call(elementToScrollTo, {
|
|
11595
11719
|
behavior: 'smooth'
|
|
11596
11720
|
});
|
|
11597
11721
|
}
|
|
@@ -11617,7 +11741,8 @@ var styles$4 = {
|
|
|
11617
11741
|
"search-mode-menu": "selectable-field-search-input-module__search-mode-menu___Od6Le"
|
|
11618
11742
|
};
|
|
11619
11743
|
const SelectableFieldSearchInput = props => {
|
|
11620
|
-
|
|
11744
|
+
var _props$initialValue, _props$placeholder;
|
|
11745
|
+
const _useState = useState((_props$initialValue = props.initialValue) !== null && _props$initialValue !== void 0 ? _props$initialValue : ''),
|
|
11621
11746
|
_useState2 = _slicedToArray(_useState, 2),
|
|
11622
11747
|
searchText = _useState2[0],
|
|
11623
11748
|
setSearchText = _useState2[1];
|
|
@@ -11653,7 +11778,7 @@ const SelectableFieldSearchInput = props => {
|
|
|
11653
11778
|
});
|
|
11654
11779
|
},
|
|
11655
11780
|
onReset: props.onReset,
|
|
11656
|
-
placeholder: props.placeholder
|
|
11781
|
+
placeholder: (_props$placeholder = props.placeholder) !== null && _props$placeholder !== void 0 ? _props$placeholder : intl.formatMessage(messages$5.placeholder),
|
|
11657
11782
|
isDisabled: props.disabled
|
|
11658
11783
|
})
|
|
11659
11784
|
});
|
|
@@ -11714,6 +11839,7 @@ StoreSelectField.defaultProps = {
|
|
|
11714
11839
|
mappedValueField: 'id'
|
|
11715
11840
|
};
|
|
11716
11841
|
|
|
11842
|
+
var _templateObject;
|
|
11717
11843
|
function ownKeys$b(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11718
11844
|
function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var _context5, _context6; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context5 = ownKeys$b(Object(t), !0)).call(_context5, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context6 = ownKeys$b(Object(t))).call(_context6, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11719
11845
|
function _callSuper$1(_this, derived, args) {
|
|
@@ -11804,10 +11930,7 @@ const VALIDATOR_INTEGER = {
|
|
|
11804
11930
|
* has emitted a warning once in the logs, not for every instance
|
|
11805
11931
|
*/
|
|
11806
11932
|
let hasWarned = false;
|
|
11807
|
-
const warningMessage = oneLineTrim`
|
|
11808
|
-
\`validatedInput\` is no longer supported.
|
|
11809
|
-
Please use \`formik\` instead.
|
|
11810
|
-
`;
|
|
11933
|
+
const warningMessage = oneLineTrim(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n `validatedInput` is no longer supported.\n Please use `formik` instead.\n"], ["\n \\`validatedInput\\` is no longer supported.\n Please use \\`formik\\` instead.\n"])));
|
|
11811
11934
|
const ToolTipWrapperComponent = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
11812
11935
|
let children = _ref.children;
|
|
11813
11936
|
return jsx(Constraints.Horizontal, {
|
|
@@ -11840,74 +11963,74 @@ function validatedInput(InnerComponent, validators) {
|
|
|
11840
11963
|
_initialValidState[v.name] = true;
|
|
11841
11964
|
});
|
|
11842
11965
|
let ValidatedInput = /*#__PURE__*/function (_PureComponent) {
|
|
11843
|
-
_inherits(ValidatedInput, _PureComponent);
|
|
11844
11966
|
function ValidatedInput() {
|
|
11845
|
-
var
|
|
11967
|
+
var _this2;
|
|
11846
11968
|
_classCallCheck(this, ValidatedInput);
|
|
11847
11969
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
11848
11970
|
args[_key] = arguments[_key];
|
|
11849
11971
|
}
|
|
11850
|
-
|
|
11851
|
-
|
|
11972
|
+
_this2 = _callSuper$1(this, ValidatedInput, [...args]);
|
|
11973
|
+
_this2.state = {
|
|
11852
11974
|
validStatus: _initialValidState
|
|
11853
11975
|
};
|
|
11854
|
-
|
|
11855
|
-
if (!deepEqual(
|
|
11856
|
-
|
|
11976
|
+
_this2.conditionalSetValidStatus = nextValidStatus => {
|
|
11977
|
+
if (!deepEqual(_this2.state.validStatus, nextValidStatus)) {
|
|
11978
|
+
_this2.setState({
|
|
11857
11979
|
validStatus: nextValidStatus
|
|
11858
11980
|
});
|
|
11859
11981
|
}
|
|
11860
11982
|
};
|
|
11861
|
-
|
|
11983
|
+
_this2.handleChange = function (event) {
|
|
11862
11984
|
let _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
11863
11985
|
_ref4$triggerUpdate = _ref4.triggerUpdate,
|
|
11864
11986
|
triggerUpdate = _ref4$triggerUpdate === void 0 ? true : _ref4$triggerUpdate;
|
|
11865
11987
|
let value = '';
|
|
11866
11988
|
const nextValidStatus = {};
|
|
11867
|
-
const onChange = changeHandler &&
|
|
11989
|
+
const onChange = changeHandler && _this2.props[changeHandler] || _this2.props.onChange;
|
|
11868
11990
|
|
|
11869
11991
|
// If the actual event is passed, validate the value
|
|
11870
11992
|
if (getIsEvent(event)) value = event.target.value;else value = event;
|
|
11871
11993
|
_forEachInstanceProperty(_validators).call(_validators, v => {
|
|
11872
|
-
if (v.validators.change) nextValidStatus[v.name] = v.validators.change.call(
|
|
11994
|
+
if (v.validators.change) nextValidStatus[v.name] = v.validators.change.call(_this2, value);else nextValidStatus[v.name] = true;
|
|
11873
11995
|
});
|
|
11874
11996
|
if (onChange && triggerUpdate) onChange(event);
|
|
11875
|
-
|
|
11997
|
+
_this2.conditionalSetValidStatus(nextValidStatus);
|
|
11876
11998
|
};
|
|
11877
11999
|
/**
|
|
11878
12000
|
* Only triggers when there is a value, but its not valid
|
|
11879
12001
|
* so it must be an invalid numeric value
|
|
11880
12002
|
*/
|
|
11881
|
-
|
|
11882
|
-
const nextValidStatus = _objectSpread$b({},
|
|
12003
|
+
_this2.handleInvalid = () => {
|
|
12004
|
+
const nextValidStatus = _objectSpread$b({}, _this2.state.validStatus);
|
|
11883
12005
|
if (has(nextValidStatus, 'numeric')) {
|
|
11884
12006
|
nextValidStatus.numeric = false;
|
|
11885
|
-
|
|
12007
|
+
_this2.conditionalSetValidStatus(nextValidStatus);
|
|
11886
12008
|
}
|
|
11887
12009
|
};
|
|
11888
|
-
|
|
12010
|
+
_this2.handleBlur = event => {
|
|
11889
12011
|
let value = '';
|
|
11890
12012
|
const nextValidStatus = {};
|
|
11891
|
-
const onBlur = blurHandler &&
|
|
12013
|
+
const onBlur = blurHandler && _this2.props[blurHandler] || _this2.props.onBlurValue;
|
|
11892
12014
|
|
|
11893
12015
|
// If the actual event is passed, validate the value
|
|
11894
12016
|
if (getIsEvent(event)) value = event.target.value;else value = event;
|
|
11895
12017
|
_forEachInstanceProperty(_validators).call(_validators, v => {
|
|
11896
|
-
if (v.validators.blur) nextValidStatus[v.name] = v.validators.blur.call(
|
|
12018
|
+
if (v.validators.blur) nextValidStatus[v.name] = v.validators.blur.call(_this2, value);else nextValidStatus[v.name] = true;
|
|
11897
12019
|
});
|
|
11898
12020
|
if (onBlur) onBlur(event);
|
|
11899
|
-
|
|
12021
|
+
_this2.conditionalSetValidStatus(nextValidStatus);
|
|
11900
12022
|
};
|
|
11901
|
-
|
|
12023
|
+
_this2.resetValidity = () => {
|
|
11902
12024
|
const nextValidStatus = {};
|
|
11903
12025
|
_forEachInstanceProperty(_validators).call(_validators, v => {
|
|
11904
12026
|
nextValidStatus[v.name] = true;
|
|
11905
12027
|
});
|
|
11906
|
-
|
|
12028
|
+
_this2.conditionalSetValidStatus(nextValidStatus);
|
|
11907
12029
|
};
|
|
11908
|
-
return
|
|
12030
|
+
return _this2;
|
|
11909
12031
|
}
|
|
11910
|
-
|
|
12032
|
+
_inherits(ValidatedInput, _PureComponent);
|
|
12033
|
+
return _createClass(ValidatedInput, [{
|
|
11911
12034
|
key: "componentDidMount",
|
|
11912
12035
|
value: function componentDidMount() {
|
|
11913
12036
|
process.env.NODE_ENV !== "production" ? warning(hasWarned, warningMessage) : void 0;
|
|
@@ -11953,9 +12076,8 @@ function validatedInput(InnerComponent, validators) {
|
|
|
11953
12076
|
});
|
|
11954
12077
|
}
|
|
11955
12078
|
}]);
|
|
11956
|
-
return ValidatedInput;
|
|
11957
12079
|
}(PureComponent);
|
|
11958
|
-
ValidatedInput.displayName =
|
|
12080
|
+
ValidatedInput.displayName = "ValidatedInput(".concat(_InnerComponent.displayName, ")");
|
|
11959
12081
|
ValidatedInput.defaultProps = {
|
|
11960
12082
|
isValid: true,
|
|
11961
12083
|
getInputRef: () => {}
|
|
@@ -11963,22 +12085,22 @@ function validatedInput(InnerComponent, validators) {
|
|
|
11963
12085
|
return injectIntl(ValidatedInput);
|
|
11964
12086
|
}
|
|
11965
12087
|
function simpleInput(type) {
|
|
11966
|
-
var
|
|
11967
|
-
return
|
|
11968
|
-
|
|
11969
|
-
|
|
11970
|
-
|
|
11971
|
-
_classCallCheck(this, _class2);
|
|
12088
|
+
var _Class;
|
|
12089
|
+
return _Class = /*#__PURE__*/function (_PureComponent2) {
|
|
12090
|
+
function _Class() {
|
|
12091
|
+
var _this3;
|
|
12092
|
+
_classCallCheck(this, _Class);
|
|
11972
12093
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
11973
12094
|
args[_key2] = arguments[_key2];
|
|
11974
12095
|
}
|
|
11975
|
-
|
|
11976
|
-
|
|
11977
|
-
if (
|
|
12096
|
+
_this3 = _callSuper$1(this, _Class, [...args]);
|
|
12097
|
+
_this3.handleBlur = event => {
|
|
12098
|
+
if (_this3.props.onBlurValue) _this3.props.onBlurValue(event.target.value);
|
|
11978
12099
|
};
|
|
11979
|
-
return
|
|
12100
|
+
return _this3;
|
|
11980
12101
|
}
|
|
11981
|
-
|
|
12102
|
+
_inherits(_Class, _PureComponent2);
|
|
12103
|
+
return _createClass(_Class, [{
|
|
11982
12104
|
key: "render",
|
|
11983
12105
|
value: function render() {
|
|
11984
12106
|
return jsx("input", {
|
|
@@ -11995,11 +12117,10 @@ function simpleInput(type) {
|
|
|
11995
12117
|
});
|
|
11996
12118
|
}
|
|
11997
12119
|
}]);
|
|
11998
|
-
|
|
11999
|
-
}(PureComponent), _class2.displayName = 'SimpleInput', _class2.defaultProps = {
|
|
12120
|
+
}(PureComponent), _Class.displayName = 'SimpleInput', _Class.defaultProps = {
|
|
12000
12121
|
getInputRef: () => {},
|
|
12001
12122
|
name: 'simple-validated-input'
|
|
12002
|
-
},
|
|
12123
|
+
}, _Class;
|
|
12003
12124
|
}
|
|
12004
12125
|
|
|
12005
12126
|
var messages$4 = defineMessages({
|
|
@@ -12096,7 +12217,7 @@ const MultiValueSelectorDropdown = props => {
|
|
|
12096
12217
|
truncate: true,
|
|
12097
12218
|
intlMessage: _objectSpread$8(_objectSpread$8({}, messages$2.filterWholeInput), {}, {
|
|
12098
12219
|
values: {
|
|
12099
|
-
values:
|
|
12220
|
+
values: "\"".concat(props.value, "\"")
|
|
12100
12221
|
}
|
|
12101
12222
|
})
|
|
12102
12223
|
})
|
|
@@ -12109,7 +12230,7 @@ const MultiValueSelectorDropdown = props => {
|
|
|
12109
12230
|
truncate: true,
|
|
12110
12231
|
intlMessage: _objectSpread$8(_objectSpread$8({}, messages$2.filterSeparateValues), {}, {
|
|
12111
12232
|
values: {
|
|
12112
|
-
values:
|
|
12233
|
+
values: "\"".concat(props.multiValue.join('", "'), "\"") || props.value
|
|
12113
12234
|
}
|
|
12114
12235
|
})
|
|
12115
12236
|
})
|
|
@@ -12244,46 +12365,46 @@ Cleave.displayName = 'Cleave';
|
|
|
12244
12365
|
// use isFinite to exclude Infitinty, -Inifinity and NaN
|
|
12245
12366
|
const isValidValue = value => isFinite(value) || isNil$1(value);
|
|
12246
12367
|
let NumericFormatInput = /*#__PURE__*/function (_PureComponent) {
|
|
12247
|
-
_inherits(NumericFormatInput, _PureComponent);
|
|
12248
12368
|
function NumericFormatInput() {
|
|
12249
|
-
var
|
|
12369
|
+
var _this2;
|
|
12250
12370
|
_classCallCheck(this, NumericFormatInput);
|
|
12251
12371
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
12252
12372
|
args[_key] = arguments[_key];
|
|
12253
12373
|
}
|
|
12254
|
-
|
|
12255
|
-
|
|
12256
|
-
parsedValue:
|
|
12374
|
+
_this2 = _callSuper(this, NumericFormatInput, [...args]);
|
|
12375
|
+
_this2.state = {
|
|
12376
|
+
parsedValue: _this2.props.value
|
|
12257
12377
|
};
|
|
12258
|
-
|
|
12378
|
+
_this2.setValue = value => {
|
|
12259
12379
|
if (!isValidValue(value)) return;
|
|
12260
|
-
const newValue = !isUndefined(value) ?
|
|
12261
|
-
|
|
12380
|
+
const newValue = !isUndefined(value) ? _this2.props.formatNumber(value) : undefined;
|
|
12381
|
+
_this2.owner.setRawValue(newValue);
|
|
12262
12382
|
};
|
|
12263
|
-
|
|
12264
|
-
|
|
12265
|
-
|
|
12383
|
+
_this2.handleInit = owner => {
|
|
12384
|
+
_this2.owner = owner;
|
|
12385
|
+
_this2.setValue(_this2.props.value);
|
|
12266
12386
|
};
|
|
12267
|
-
|
|
12387
|
+
_this2.handleChange = event => {
|
|
12268
12388
|
const value = event.target.rawValue;
|
|
12269
|
-
const parsedNumber =
|
|
12270
|
-
if (
|
|
12271
|
-
|
|
12389
|
+
const parsedNumber = _this2.props.parseNumber(value);
|
|
12390
|
+
if (_this2.state.parsedValue === parsedNumber) return;
|
|
12391
|
+
_this2.setState({
|
|
12272
12392
|
parsedValue: parsedNumber
|
|
12273
12393
|
});
|
|
12274
|
-
|
|
12275
|
-
if (!isNumberish(value) &&
|
|
12394
|
+
_this2.props.onChangeValue(parsedNumber);
|
|
12395
|
+
if (!isNumberish(value) && _this2.props.onInvalidValue) _this2.props.onInvalidValue(value);
|
|
12276
12396
|
};
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
if (
|
|
12397
|
+
_this2.handleBlur = () => {
|
|
12398
|
+
_this2.setValue(_this2.props.value);
|
|
12399
|
+
if (_this2.props.onBlurValue) _this2.props.onBlurValue(_this2.props.value);
|
|
12280
12400
|
};
|
|
12281
|
-
|
|
12282
|
-
|
|
12401
|
+
_this2.registerInputRef = ref => {
|
|
12402
|
+
_this2.textInput = ref;
|
|
12283
12403
|
};
|
|
12284
|
-
return
|
|
12404
|
+
return _this2;
|
|
12285
12405
|
}
|
|
12286
|
-
|
|
12406
|
+
_inherits(NumericFormatInput, _PureComponent);
|
|
12407
|
+
return _createClass(NumericFormatInput, [{
|
|
12287
12408
|
key: "componentDidUpdate",
|
|
12288
12409
|
value: function componentDidUpdate(prevProps) {
|
|
12289
12410
|
if (this.props.value !== prevProps.value && this.props.value !== this.state.parsedValue) {
|
|
@@ -12324,7 +12445,6 @@ let NumericFormatInput = /*#__PURE__*/function (_PureComponent) {
|
|
|
12324
12445
|
}, dataAttributes));
|
|
12325
12446
|
}
|
|
12326
12447
|
}]);
|
|
12327
|
-
return NumericFormatInput;
|
|
12328
12448
|
}(PureComponent);
|
|
12329
12449
|
NumericFormatInput.displayName = 'NumericFormatInput';
|
|
12330
12450
|
NumericFormatInput.defaultProps = {
|
|
@@ -12412,16 +12532,17 @@ function isEmpty(value) {
|
|
|
12412
12532
|
}
|
|
12413
12533
|
|
|
12414
12534
|
const buildSearchQuery = (searchQuery, searchMode, fragments) => {
|
|
12535
|
+
var _fragments$searchMode;
|
|
12415
12536
|
if (!searchQuery) return '';
|
|
12416
12537
|
const buildAllFieldsQueryString = query => {
|
|
12417
12538
|
const fragmentsArray = _Object$values(fragments);
|
|
12418
|
-
return
|
|
12539
|
+
return "( ".concat(_mapInstanceProperty(fragmentsArray).call(fragmentsArray, fragment => fragment.getQuery(query)).join(' or '), " )");
|
|
12419
12540
|
};
|
|
12420
12541
|
const trimmedSearchQuery = oneLine(searchQuery);
|
|
12421
12542
|
if (searchMode === 'allFields') {
|
|
12422
12543
|
return buildAllFieldsQueryString(trimmedSearchQuery);
|
|
12423
12544
|
}
|
|
12424
|
-
if (!fragments[searchMode] || typeof fragments[searchMode]
|
|
12545
|
+
if (!fragments[searchMode] || typeof ((_fragments$searchMode = fragments[searchMode]) === null || _fragments$searchMode === void 0 ? void 0 : _fragments$searchMode.getQuery) !== 'function') {
|
|
12425
12546
|
return '';
|
|
12426
12547
|
}
|
|
12427
12548
|
return fragments[searchMode].getQuery(trimmedSearchQuery);
|
|
@@ -12652,11 +12773,11 @@ function createResourceReducer(options) {
|
|
|
12652
12773
|
|
|
12653
12774
|
// TODO: validate constant keys
|
|
12654
12775
|
const actionsMap = {
|
|
12655
|
-
[
|
|
12776
|
+
["".concat(plural, "_FETCHED")]: (_, action) => ({
|
|
12656
12777
|
currentQueryResult: action.payload
|
|
12657
12778
|
}),
|
|
12658
|
-
[
|
|
12659
|
-
[
|
|
12779
|
+
["".concat(single, "_UPDATED_IN_LIST")]: updateStatusInList(mergeData),
|
|
12780
|
+
["".concat(single, "_DELETED_IN_LIST")]: (state, _ref) => {
|
|
12660
12781
|
let payload = _ref.payload;
|
|
12661
12782
|
const results = state.currentQueryResult.results;
|
|
12662
12783
|
return {
|
|
@@ -12668,27 +12789,27 @@ function createResourceReducer(options) {
|
|
|
12668
12789
|
})
|
|
12669
12790
|
};
|
|
12670
12791
|
},
|
|
12671
|
-
[
|
|
12792
|
+
["".concat(single, "_FETCHED")]: (_, _ref3) => {
|
|
12672
12793
|
let payload = _ref3.payload;
|
|
12673
12794
|
return {
|
|
12674
12795
|
currentVisible: payload
|
|
12675
12796
|
};
|
|
12676
12797
|
},
|
|
12677
|
-
[
|
|
12798
|
+
["".concat(single, "_CREATED")]: (_ref4, _ref5) => {
|
|
12678
12799
|
let currentVisible = _ref4.currentVisible;
|
|
12679
12800
|
let payload = _ref5.payload;
|
|
12680
12801
|
return {
|
|
12681
12802
|
currentVisible: mergeData(payload, currentVisible)
|
|
12682
12803
|
};
|
|
12683
12804
|
},
|
|
12684
|
-
[
|
|
12805
|
+
["".concat(single, "_UPDATED")]: (_ref6, _ref7) => {
|
|
12685
12806
|
let currentVisible = _ref6.currentVisible;
|
|
12686
12807
|
let payload = _ref7.payload;
|
|
12687
12808
|
return {
|
|
12688
12809
|
currentVisible: mergeData(payload, currentVisible)
|
|
12689
12810
|
};
|
|
12690
12811
|
},
|
|
12691
|
-
[
|
|
12812
|
+
["".concat(single, "_DELETED")]: () => ({
|
|
12692
12813
|
currentVisible: null
|
|
12693
12814
|
})
|
|
12694
12815
|
};
|
|
@@ -12705,11 +12826,12 @@ function formatCustomerAddress(_ref) {
|
|
|
12705
12826
|
}
|
|
12706
12827
|
|
|
12707
12828
|
function formatCustomerName(_ref) {
|
|
12829
|
+
var _context;
|
|
12708
12830
|
let firstName = _ref.firstName,
|
|
12709
12831
|
lastName = _ref.lastName;
|
|
12710
12832
|
if (firstName && !lastName) return _trimInstanceProperty(firstName).call(firstName);
|
|
12711
12833
|
if (!firstName && lastName) return _trimInstanceProperty(lastName).call(lastName);
|
|
12712
|
-
if (firstName && lastName) return
|
|
12834
|
+
if (firstName && lastName) return _concatInstanceProperty(_context = "".concat(_trimInstanceProperty(firstName).call(firstName), " ")).call(_context, _trimInstanceProperty(lastName).call(lastName));
|
|
12713
12835
|
return NO_VALUE_FALLBACK;
|
|
12714
12836
|
}
|
|
12715
12837
|
|
|
@@ -12761,7 +12883,10 @@ const validateText = function (text, intl) {
|
|
|
12761
12883
|
* @returns {boolean}
|
|
12762
12884
|
*/
|
|
12763
12885
|
const hasErrorCode = (unmappedApiErrors, errorCode) => {
|
|
12764
|
-
return _Array$isArray(unmappedApiErrors) && _someInstanceProperty(unmappedApiErrors).call(unmappedApiErrors, error =>
|
|
12886
|
+
return _Array$isArray(unmappedApiErrors) && _someInstanceProperty(unmappedApiErrors).call(unmappedApiErrors, error => {
|
|
12887
|
+
var _error$extensions;
|
|
12888
|
+
return ((_error$extensions = error.extensions) === null || _error$extensions === void 0 ? void 0 : _error$extensions.code) === errorCode;
|
|
12889
|
+
});
|
|
12765
12890
|
};
|
|
12766
12891
|
|
|
12767
12892
|
const hasInvalidInputError = errors => hasErrorCode(errors, ERROR_CODES.invalidInput);
|
|
@@ -12773,7 +12898,7 @@ function minusify(value) {
|
|
|
12773
12898
|
return minus.concat(value);
|
|
12774
12899
|
}
|
|
12775
12900
|
|
|
12776
|
-
const flattenOperator = (operator, clauses) => compact(_reduceInstanceProperty(clauses).call(clauses, (result, clause) => _concatInstanceProperty(result).call(result, clause
|
|
12901
|
+
const flattenOperator = (operator, clauses) => compact(_reduceInstanceProperty(clauses).call(clauses, (result, clause) => _concatInstanceProperty(result).call(result, (clause === null || clause === void 0 ? void 0 : clause[operator]) || clause), []));
|
|
12777
12902
|
const argsToArray = args => _reduceInstanceProperty(args).call(args, (result, item) => _concatInstanceProperty(result).call(result, item), []);
|
|
12778
12903
|
const exists = (field, attributeType) => ({
|
|
12779
12904
|
exists: {
|
|
@@ -12830,7 +12955,7 @@ const not = function () {
|
|
|
12830
12955
|
|
|
12831
12956
|
const safelyAddFallback = function (string) {
|
|
12832
12957
|
let fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NO_VALUE_FALLBACK;
|
|
12833
|
-
return string === '' ? fallback : string
|
|
12958
|
+
return string === '' ? fallback : string !== null && string !== void 0 ? string : fallback;
|
|
12834
12959
|
};
|
|
12835
12960
|
|
|
12836
12961
|
var messages$1 = defineMessages({
|
|
@@ -12965,19 +13090,19 @@ const computedProperties = {
|
|
|
12965
13090
|
// has been deleted. See MC-1925 for further information.
|
|
12966
13091
|
const filteredCategories = _filterInstanceProperty(_context6 = product.categories).call(_context6, category => category.obj !== undefined);
|
|
12967
13092
|
return _mapInstanceProperty(filteredCategories).call(filteredCategories, category => {
|
|
13093
|
+
var _context7;
|
|
12968
13094
|
const categoryPath = getPathName(category, language, languages);
|
|
12969
13095
|
const ancestors = getAncestors(category, language);
|
|
12970
|
-
const externalIdValue = category.obj.externalId ?
|
|
12971
|
-
// hardcoding "ext. ID" since this is not part of a message to be
|
|
13096
|
+
const externalIdValue = category.obj.externalId ? // hardcoding "ext. ID" since this is not part of a message to be
|
|
12972
13097
|
// translated. This has been communicated with Jenn
|
|
12973
|
-
|
|
13098
|
+
"| ext. ID: ".concat(category.obj.externalId) : '';
|
|
12974
13099
|
return {
|
|
12975
13100
|
id: category.id,
|
|
12976
|
-
name:
|
|
13101
|
+
name: _concatInstanceProperty(_context7 = "".concat(formatLocalizedString(category.obj, {
|
|
12977
13102
|
key: 'name',
|
|
12978
13103
|
locale: language,
|
|
12979
13104
|
fallbackOrder: languages
|
|
12980
|
-
})
|
|
13105
|
+
}), " ")).call(_context7, externalIdValue),
|
|
12981
13106
|
path: categoryPath,
|
|
12982
13107
|
level: ancestors.length
|
|
12983
13108
|
};
|
|
@@ -13014,13 +13139,13 @@ const getAttributeValueByType = _ref12 => {
|
|
|
13014
13139
|
value: value
|
|
13015
13140
|
});
|
|
13016
13141
|
case 'enum':
|
|
13017
|
-
return safelyAddFallback(value.label,
|
|
13142
|
+
return safelyAddFallback(value.label, "".concat(value.key, " (key)"));
|
|
13018
13143
|
case 'lenum':
|
|
13019
13144
|
return safelyAddFallback(formatLocalizedString(value, {
|
|
13020
13145
|
key: 'label',
|
|
13021
13146
|
locale: projectDataLocale,
|
|
13022
13147
|
fallbackOrder: projectLanguages
|
|
13023
|
-
}),
|
|
13148
|
+
}), "".concat(value.key, " (key)"));
|
|
13024
13149
|
case 'number':
|
|
13025
13150
|
return safelyAddFallback(value);
|
|
13026
13151
|
case 'boolean':
|
|
@@ -13043,7 +13168,7 @@ let RequestCache = /*#__PURE__*/function () {
|
|
|
13043
13168
|
this.result = null;
|
|
13044
13169
|
this.expiryDurationInSeconds = 5 * 60;
|
|
13045
13170
|
}
|
|
13046
|
-
_createClass(RequestCache, [{
|
|
13171
|
+
return _createClass(RequestCache, [{
|
|
13047
13172
|
key: "get",
|
|
13048
13173
|
value: function get(key) {
|
|
13049
13174
|
if (this.isValid(key)) {
|
|
@@ -13082,7 +13207,6 @@ let RequestCache = /*#__PURE__*/function () {
|
|
|
13082
13207
|
this.result = null;
|
|
13083
13208
|
}
|
|
13084
13209
|
}]);
|
|
13085
|
-
return RequestCache;
|
|
13086
13210
|
}();
|
|
13087
13211
|
|
|
13088
13212
|
// copied from
|
|
@@ -13143,6 +13267,7 @@ const reorderArrayItems = (array, from, to) => {
|
|
|
13143
13267
|
const mapTimeZonesToOptions = memoize(timeZones => {
|
|
13144
13268
|
var _context;
|
|
13145
13269
|
return _mapInstanceProperty(_context = _Object$entries(timeZones)).call(_context, _ref => {
|
|
13270
|
+
var _context2;
|
|
13146
13271
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
13147
13272
|
code = _ref2[0],
|
|
13148
13273
|
value = _ref2[1];
|
|
@@ -13151,7 +13276,7 @@ const mapTimeZonesToOptions = memoize(timeZones => {
|
|
|
13151
13276
|
//E.g. `(GMT +02:00) Central European Time - Berlin`
|
|
13152
13277
|
// unicode clock hex code: \u25F7
|
|
13153
13278
|
//
|
|
13154
|
-
label:
|
|
13279
|
+
label: _concatInstanceProperty(_context2 = "(GMT ".concat(value.offset, ") ")).call(_context2, value.name)
|
|
13155
13280
|
};
|
|
13156
13281
|
});
|
|
13157
13282
|
});
|
|
@@ -13159,9 +13284,12 @@ const getTimeZoneId = memoize((selectedTimeZone, timeZones) => {
|
|
|
13159
13284
|
if (timeZones[selectedTimeZone]) {
|
|
13160
13285
|
return selectedTimeZone;
|
|
13161
13286
|
} else {
|
|
13162
|
-
var
|
|
13163
|
-
const fallbackTimeZoneId = _findInstanceProperty(
|
|
13164
|
-
|
|
13287
|
+
var _context3;
|
|
13288
|
+
const fallbackTimeZoneId = _findInstanceProperty(_context3 = _Object$keys(timeZones)).call(_context3, timeZoneId => {
|
|
13289
|
+
var _timeZones$timeZoneId;
|
|
13290
|
+
return (_timeZones$timeZoneId = timeZones[timeZoneId]) === null || _timeZones$timeZoneId === void 0 || (_timeZones$timeZoneId = _timeZones$timeZoneId.translationFor) === null || _timeZones$timeZoneId === void 0 ? void 0 : _someInstanceProperty(_timeZones$timeZoneId).call(_timeZones$timeZoneId, fallbackTimeZone => fallbackTimeZone === selectedTimeZone);
|
|
13291
|
+
});
|
|
13292
|
+
if (fallbackTimeZoneId !== null && fallbackTimeZoneId !== void 0 && fallbackTimeZoneId.length) {
|
|
13165
13293
|
return fallbackTimeZoneId.toString();
|
|
13166
13294
|
} else {
|
|
13167
13295
|
return 'UTC';
|
|
@@ -13169,9 +13297,10 @@ const getTimeZoneId = memoize((selectedTimeZone, timeZones) => {
|
|
|
13169
13297
|
}
|
|
13170
13298
|
});
|
|
13171
13299
|
const getTimeZoneLabel = memoize((selectedTimeZone, timeZones) => {
|
|
13300
|
+
var _context4;
|
|
13172
13301
|
const timeZoneId = getTimeZoneId(selectedTimeZone, timeZones);
|
|
13173
13302
|
const timeZoneData = timeZones[timeZoneId];
|
|
13174
|
-
return
|
|
13303
|
+
return _concatInstanceProperty(_context4 = "(GMT ".concat(timeZoneData.offset, ") ")).call(_context4, timeZoneData.name);
|
|
13175
13304
|
});
|
|
13176
13305
|
|
|
13177
13306
|
function ownKeys$3(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -13227,20 +13356,114 @@ var messages = defineMessages({
|
|
|
13227
13356
|
const FIELD_NAME = 'custom';
|
|
13228
13357
|
|
|
13229
13358
|
function ownKeys$2(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13230
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
13359
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context7 = ownKeys$2(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context8 = ownKeys$2(Object(t))).call(_context8, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13360
|
+
const transformFieldType = fieldDefinition => {
|
|
13361
|
+
var _fieldDefinition$type, _fieldDefinition$type2;
|
|
13362
|
+
if (((_fieldDefinition$type = fieldDefinition.type) === null || _fieldDefinition$type === void 0 || (_fieldDefinition$type = _fieldDefinition$type.elementType) === null || _fieldDefinition$type === void 0 ? void 0 : _fieldDefinition$type.name) === 'LocalizedEnum') {
|
|
13363
|
+
var _context;
|
|
13364
|
+
return _objectSpread$2(_objectSpread$2({}, fieldDefinition.type), {}, {
|
|
13365
|
+
elementType: _objectSpread$2(_objectSpread$2({}, fieldDefinition.type.elementType), {}, {
|
|
13366
|
+
values: _mapInstanceProperty(_context = _valuesInstanceProperty(fieldDefinition.type.elementType)).call(_context, value => ({
|
|
13367
|
+
key: value.key,
|
|
13368
|
+
label: transformLocalizedFieldToLocalizedString(value.labelAllLocales)
|
|
13369
|
+
}))
|
|
13370
|
+
})
|
|
13371
|
+
});
|
|
13372
|
+
} else if (((_fieldDefinition$type2 = fieldDefinition.type) === null || _fieldDefinition$type2 === void 0 ? void 0 : _fieldDefinition$type2.name) === 'LocalizedEnum') {
|
|
13373
|
+
var _context2;
|
|
13374
|
+
return _objectSpread$2(_objectSpread$2({}, fieldDefinition.type), {}, {
|
|
13375
|
+
values: _mapInstanceProperty(_context2 = _valuesInstanceProperty(fieldDefinition.type)).call(_context2, value => ({
|
|
13376
|
+
key: value.key,
|
|
13377
|
+
label: transformLocalizedFieldToLocalizedString(value.labelAllLocales)
|
|
13378
|
+
}))
|
|
13379
|
+
});
|
|
13380
|
+
} else {
|
|
13381
|
+
return fieldDefinition.type;
|
|
13382
|
+
}
|
|
13383
|
+
};
|
|
13384
|
+
const convertCustomField = resource => {
|
|
13385
|
+
var _context3, _context4;
|
|
13386
|
+
return {
|
|
13387
|
+
type: {
|
|
13388
|
+
typeId: 'type',
|
|
13389
|
+
id: resource.custom.type.id,
|
|
13390
|
+
obj: {
|
|
13391
|
+
key: resource.custom.type.key,
|
|
13392
|
+
name: transformLocalizedFieldToLocalizedString(resource.custom.type.nameAllLocales),
|
|
13393
|
+
fieldDefinitions: _mapInstanceProperty(_context3 = resource.custom.type.fieldDefinitions).call(_context3, fieldDefinition => ({
|
|
13394
|
+
name: fieldDefinition.name,
|
|
13395
|
+
required: fieldDefinition.required,
|
|
13396
|
+
inputHint: fieldDefinition.inputHint,
|
|
13397
|
+
type: transformFieldType(fieldDefinition),
|
|
13398
|
+
label: transformLocalizedFieldToLocalizedString(fieldDefinition.labelAllLocales)
|
|
13399
|
+
}))
|
|
13400
|
+
}
|
|
13401
|
+
},
|
|
13402
|
+
fields: _reduceInstanceProperty(_context4 = resource.custom.customFieldsRaw).call(_context4, (fields, customField) => _objectSpread$2(_objectSpread$2({}, fields), {}, {
|
|
13403
|
+
[customField.name]: customField.value
|
|
13404
|
+
}), {})
|
|
13405
|
+
};
|
|
13406
|
+
};
|
|
13407
|
+
const createFormStateFromResource = resource => {
|
|
13408
|
+
// If there are no custom fields on the resource, don't create a form state
|
|
13409
|
+
if (!resource[FIELD_NAME]) {
|
|
13410
|
+
return {
|
|
13411
|
+
[FIELD_NAME]: undefined
|
|
13412
|
+
};
|
|
13413
|
+
}
|
|
13414
|
+
return {
|
|
13415
|
+
[FIELD_NAME]: convertCustomField(resource)
|
|
13416
|
+
};
|
|
13417
|
+
};
|
|
13418
|
+
const createGraphQlDocFromFormState = formState => {
|
|
13419
|
+
var _formState$FIELD_NAME, _context5;
|
|
13420
|
+
// Unset the custom type if it's not in the form state
|
|
13421
|
+
if (!((_formState$FIELD_NAME = formState[FIELD_NAME]) !== null && _formState$FIELD_NAME !== void 0 && (_formState$FIELD_NAME = _formState$FIELD_NAME.type) !== null && _formState$FIELD_NAME !== void 0 && _formState$FIELD_NAME.id)) {
|
|
13422
|
+
return {
|
|
13423
|
+
[FIELD_NAME]: {}
|
|
13424
|
+
};
|
|
13425
|
+
}
|
|
13426
|
+
return {
|
|
13427
|
+
[FIELD_NAME]: {
|
|
13428
|
+
type: {
|
|
13429
|
+
id: formState[FIELD_NAME].type.id,
|
|
13430
|
+
typeId: 'type'
|
|
13431
|
+
},
|
|
13432
|
+
fields: _mapInstanceProperty(_context5 = _Object$entries(formState[FIELD_NAME].fields)).call(_context5, _ref => {
|
|
13433
|
+
let _ref2 = _slicedToArray(_ref, 2),
|
|
13434
|
+
name = _ref2[0],
|
|
13435
|
+
value = _ref2[1];
|
|
13436
|
+
return {
|
|
13437
|
+
name,
|
|
13438
|
+
value: _JSON$stringify(value)
|
|
13439
|
+
};
|
|
13440
|
+
})
|
|
13441
|
+
}
|
|
13442
|
+
};
|
|
13443
|
+
};
|
|
13444
|
+
|
|
13445
|
+
// Creates a root field name accessor for `custom` form state
|
|
13446
|
+
const createRootFieldName = rootFieldName => {
|
|
13447
|
+
var _context6;
|
|
13448
|
+
return rootFieldName ? _concatInstanceProperty(_context6 = "".concat(rootFieldName, ".")).call(_context6, FIELD_NAME) : FIELD_NAME;
|
|
13449
|
+
};
|
|
13450
|
+
|
|
13451
|
+
function ownKeys$1(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13452
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys$1(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys$1(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13231
13453
|
const typeDefinitionsExist = typeDefinitions => {
|
|
13232
13454
|
return typeDefinitions.length > 0;
|
|
13233
13455
|
};
|
|
13234
|
-
const typeDefinitionSelected = formValues => {
|
|
13235
|
-
|
|
13456
|
+
const typeDefinitionSelected = (formValues, rootFieldName) => {
|
|
13457
|
+
var _getIn, _getIn2;
|
|
13458
|
+
return ((_getIn = getIn(formValues, rootFieldName)) === null || _getIn === void 0 ? void 0 : _getIn.type) && ((_getIn2 = getIn(formValues, rootFieldName)) === null || _getIn2 === void 0 || (_getIn2 = _getIn2.type) === null || _getIn2 === void 0 ? void 0 : _getIn2.obj);
|
|
13236
13459
|
};
|
|
13237
|
-
const typeDefinitionContainsFieldDefinitions = formValues => {
|
|
13238
|
-
return formValues
|
|
13460
|
+
const typeDefinitionContainsFieldDefinitions = (formValues, rootFieldName) => {
|
|
13461
|
+
return getIn(formValues, rootFieldName).type.obj.key && getIn(formValues, rootFieldName).type.obj.fieldDefinitions.length > 0;
|
|
13239
13462
|
};
|
|
13240
|
-
const fieldDefinitionsWithValues = formValues => {
|
|
13463
|
+
const fieldDefinitionsWithValues = (formValues, rootFieldName) => {
|
|
13241
13464
|
var _context;
|
|
13242
|
-
const fieldValues = formValues
|
|
13243
|
-
return _filterInstanceProperty(_context = formValues
|
|
13465
|
+
const fieldValues = getIn(formValues, rootFieldName).fields;
|
|
13466
|
+
return _filterInstanceProperty(_context = getIn(formValues, rootFieldName).type.obj.fieldDefinitions).call(_context, _ref => {
|
|
13244
13467
|
let name = _ref.name;
|
|
13245
13468
|
return fieldValues[name] !== undefined;
|
|
13246
13469
|
});
|
|
@@ -13248,34 +13471,36 @@ const fieldDefinitionsWithValues = formValues => {
|
|
|
13248
13471
|
const CustomFieldsInputWrapper = _ref2 => {
|
|
13249
13472
|
let typeDefinitions = _ref2.typeDefinitions,
|
|
13250
13473
|
isReadOnly = _ref2.isReadOnly,
|
|
13251
|
-
hideEmptyFields = _ref2.hideEmptyFields
|
|
13474
|
+
hideEmptyFields = _ref2.hideEmptyFields,
|
|
13475
|
+
rootFormStateFieldName = _ref2.rootFormStateFieldName;
|
|
13252
13476
|
const _useFormikContext = useFormikContext(),
|
|
13253
13477
|
formValues = _valuesInstanceProperty(_useFormikContext);
|
|
13478
|
+
const rootFieldName = createRootFieldName(rootFormStateFieldName);
|
|
13254
13479
|
if (!typeDefinitionsExist(typeDefinitions)) {
|
|
13255
|
-
return jsx(FormattedMessage, _objectSpread$
|
|
13480
|
+
return jsx(FormattedMessage, _objectSpread$1({}, messages.noTypes));
|
|
13256
13481
|
}
|
|
13257
|
-
if (!typeDefinitionSelected(formValues)) {
|
|
13258
|
-
return jsx(FormattedMessage, _objectSpread$
|
|
13482
|
+
if (!typeDefinitionSelected(formValues, rootFieldName)) {
|
|
13483
|
+
return jsx(FormattedMessage, _objectSpread$1({}, messages.noCustomType));
|
|
13259
13484
|
}
|
|
13260
|
-
if (!typeDefinitionContainsFieldDefinitions(formValues)) {
|
|
13261
|
-
return jsx(FormattedMessage, _objectSpread$
|
|
13485
|
+
if (!typeDefinitionContainsFieldDefinitions(formValues, rootFieldName)) {
|
|
13486
|
+
return jsx(FormattedMessage, _objectSpread$1({}, messages.noCustomFields));
|
|
13262
13487
|
}
|
|
13263
|
-
if (fieldDefinitionsWithValues(formValues).length === 0 && isReadOnly && hideEmptyFields) {
|
|
13264
|
-
return jsx(FormattedMessage, _objectSpread$
|
|
13488
|
+
if (fieldDefinitionsWithValues(formValues, rootFieldName).length === 0 && isReadOnly && hideEmptyFields) {
|
|
13489
|
+
return jsx(FormattedMessage, _objectSpread$1({}, messages.noInputValues));
|
|
13265
13490
|
}
|
|
13266
13491
|
return jsx(Constraints.Horizontal, {
|
|
13267
13492
|
max: "scale",
|
|
13268
13493
|
children: jsx(CustomFields, {
|
|
13269
13494
|
isReadOnly: isReadOnly,
|
|
13270
|
-
name:
|
|
13271
|
-
fieldDefinitions: isReadOnly && hideEmptyFields ? fieldDefinitionsWithValues(formValues) : formValues
|
|
13495
|
+
name: "".concat(rootFieldName, ".fields"),
|
|
13496
|
+
fieldDefinitions: isReadOnly && hideEmptyFields ? fieldDefinitionsWithValues(formValues, rootFieldName) : getIn(formValues, rootFieldName).type.obj.fieldDefinitions
|
|
13272
13497
|
})
|
|
13273
13498
|
});
|
|
13274
13499
|
};
|
|
13275
13500
|
CustomFieldsInputWrapper.displayName = 'CustomFieldsInputWrapper';
|
|
13276
13501
|
|
|
13277
|
-
function ownKeys
|
|
13278
|
-
function _objectSpread
|
|
13502
|
+
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13503
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13279
13504
|
const mapTypeDefinitionsToOptions = (typeDefinitions, language, languages, selectedTypeDefinitionId) => {
|
|
13280
13505
|
return _mapInstanceProperty(typeDefinitions).call(typeDefinitions, typeDefinition => ({
|
|
13281
13506
|
isDisabled: selectedTypeDefinitionId && selectedTypeDefinitionId === typeDefinition.type.id,
|
|
@@ -13302,10 +13527,13 @@ const createFormStateFromTypeDefinition = selectedTypeDefinition => {
|
|
|
13302
13527
|
};
|
|
13303
13528
|
};
|
|
13304
13529
|
const CustomTypeSubform = _ref => {
|
|
13530
|
+
var _getIn3, _getIn4;
|
|
13305
13531
|
let typeDefinitions = _ref.typeDefinitions,
|
|
13306
13532
|
isReadOnly = _ref.isReadOnly,
|
|
13307
13533
|
isCondensed = _ref.isCondensed,
|
|
13308
|
-
hideEmptyFields = _ref.hideEmptyFields
|
|
13534
|
+
hideEmptyFields = _ref.hideEmptyFields,
|
|
13535
|
+
rootFormStateFieldName = _ref.rootFormStateFieldName,
|
|
13536
|
+
panelTitle = _ref.panelTitle;
|
|
13309
13537
|
const _useFormikContext = useFormikContext(),
|
|
13310
13538
|
formValues = _valuesInstanceProperty(_useFormikContext),
|
|
13311
13539
|
setFieldValue = _useFormikContext.setFieldValue,
|
|
@@ -13318,22 +13546,24 @@ const CustomTypeSubform = _ref => {
|
|
|
13318
13546
|
})),
|
|
13319
13547
|
language = _useApplicationContex.language,
|
|
13320
13548
|
languages = _useApplicationContex.languages;
|
|
13549
|
+
const rootFieldName = createRootFieldName(rootFormStateFieldName);
|
|
13321
13550
|
const handleTypeDefinitionSelect = useCallback(event => {
|
|
13322
13551
|
const selectedTypeDefinition = _findInstanceProperty(typeDefinitions).call(typeDefinitions, typeDefinition => typeDefinition.type.key === event.target.value);
|
|
13323
13552
|
if (selectedTypeDefinition) {
|
|
13324
13553
|
const nextCustom = createFormStateFromTypeDefinition(selectedTypeDefinition);
|
|
13325
|
-
setFieldValue(
|
|
13554
|
+
setFieldValue(rootFieldName, nextCustom).then(() => {
|
|
13326
13555
|
validateForm();
|
|
13327
13556
|
});
|
|
13328
13557
|
} else {
|
|
13329
13558
|
// if the dropdown selector is cleared, remove the `custom` field from the form state entirely
|
|
13330
|
-
setFieldValue(
|
|
13559
|
+
setFieldValue(rootFieldName, undefined).then(() => {
|
|
13331
13560
|
validateForm();
|
|
13332
13561
|
});
|
|
13333
13562
|
}
|
|
13334
|
-
}, [typeDefinitions, setFieldValue, validateForm]);
|
|
13563
|
+
}, [typeDefinitions, setFieldValue, validateForm, rootFieldName]);
|
|
13335
13564
|
const typeDefinitionSelected = formValues => {
|
|
13336
|
-
|
|
13565
|
+
var _getIn, _getIn2;
|
|
13566
|
+
return ((_getIn = getIn(formValues, rootFieldName)) === null || _getIn === void 0 ? void 0 : _getIn.type) && ((_getIn2 = getIn(formValues, rootFieldName)) === null || _getIn2 === void 0 || (_getIn2 = _getIn2.type) === null || _getIn2 === void 0 ? void 0 : _getIn2.obj);
|
|
13337
13567
|
};
|
|
13338
13568
|
|
|
13339
13569
|
// if the user has read-only permissions, empty fields are hidden, and no type definition is selected, hide the component
|
|
@@ -13341,16 +13571,16 @@ const CustomTypeSubform = _ref => {
|
|
|
13341
13571
|
return jsx(CollapsiblePanel, {
|
|
13342
13572
|
header: jsx(CollapsiblePanel.Header, {
|
|
13343
13573
|
isCondensed: isCondensed,
|
|
13344
|
-
children: jsx(FormattedMessage, _objectSpread
|
|
13574
|
+
children: panelTitle || jsx(FormattedMessage, _objectSpread({}, messages.title))
|
|
13345
13575
|
}),
|
|
13346
13576
|
headerControls: typeDefinitions.length > 0 && jsx("div", {
|
|
13347
|
-
css: /*#__PURE__*/css("min-width:", designTokens.constraint11, ";" + (process.env.NODE_ENV === "production" ? "" : ";label:CustomTypeSubform;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
13577
|
+
css: /*#__PURE__*/css("min-width:", designTokens.constraint11, ";" + (process.env.NODE_ENV === "production" ? "" : ";label:CustomTypeSubform;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImN1c3RvbS10eXBlLXN1YmZvcm0uanN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXFIb0IiLCJmaWxlIjoiY3VzdG9tLXR5cGUtc3ViZm9ybS5qc3giLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyB1c2VDYWxsYmFjayB9IGZyb20gJ3JlYWN0JztcbmltcG9ydCBQcm9wVHlwZXMgZnJvbSAncHJvcC10eXBlcyc7XG5pbXBvcnQgeyB1c2VGb3JtaWtDb250ZXh0LCBnZXRJbiB9IGZyb20gJ2Zvcm1payc7XG5pbXBvcnQgeyBGb3JtYXR0ZWRNZXNzYWdlLCB1c2VJbnRsIH0gZnJvbSAncmVhY3QtaW50bCc7XG5pbXBvcnQgeyB1c2VBcHBsaWNhdGlvbkNvbnRleHQgfSBmcm9tICdAY29tbWVyY2V0b29scy1mcm9udGVuZC9hcHBsaWNhdGlvbi1zaGVsbC1jb25uZWN0b3JzJztcbmltcG9ydCB7IGZvcm1hdExvY2FsaXplZFN0cmluZyB9IGZyb20gJ0Bjb21tZXJjZXRvb2xzLWZyb250ZW5kL2wxMG4nO1xuaW1wb3J0IHtcbiAgQ29sbGFwc2libGVQYW5lbCxcbiAgU2VsZWN0SW5wdXQsXG4gIGRlc2lnblRva2Vucyxcbn0gZnJvbSAnQGNvbW1lcmNldG9vbHMtZnJvbnRlbmQvdWkta2l0JztcbmltcG9ydCBtZXNzYWdlcyBmcm9tICcuL21lc3NhZ2VzJztcbmltcG9ydCBDdXN0b21GaWVsZHNJbnB1dFdyYXBwZXIgZnJvbSAnLi9jdXN0b20tZmllbGRzLWlucHV0LXdyYXBwZXInO1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuaW1wb3J0IHsgY3JlYXRlUm9vdEZpZWxkTmFtZSB9IGZyb20gJy4vdXRpbHMnO1xuXG4vLyBDcmVhdGVzIGRyb3Bkb3duIG9wdGlvbnNcbmV4cG9ydCBjb25zdCBtYXBUeXBlRGVmaW5pdGlvbnNUb09wdGlvbnMgPSAoXG4gIHR5cGVEZWZpbml0aW9ucyxcbiAgbGFuZ3VhZ2UsXG4gIGxhbmd1YWdlcyxcbiAgc2VsZWN0ZWRUeXBlRGVmaW5pdGlvbklkXG4pID0+IHtcbiAgcmV0dXJuIHR5cGVEZWZpbml0aW9ucy5tYXAoKHR5cGVEZWZpbml0aW9uKSA9PiAoe1xuICAgIGlzRGlzYWJsZWQ6XG4gICAgICBzZWxlY3RlZFR5cGVEZWZpbml0aW9uSWQgJiZcbiAgICAgIHNlbGVjdGVkVHlwZURlZmluaXRpb25JZCA9PT0gdHlwZURlZmluaXRpb24udHlwZS5pZCxcbiAgICB2YWx1ZTogdHlwZURlZmluaXRpb24udHlwZS5rZXksXG4gICAgbGFiZWw6IGZvcm1hdExvY2FsaXplZFN0cmluZyh0eXBlRGVmaW5pdGlvbi50eXBlLCB7XG4gICAgICBrZXk6ICduYW1lJyxcbiAgICAgIGxvY2FsZTogbGFuZ3VhZ2UsXG4gICAgICBmYWxsYmFja09yZGVyOiBsYW5ndWFnZXMsXG4gICAgfSksXG4gIH0pKTtcbn07XG5cbi8vIFVzZWQgdG8gZ2VuZXJhdGUgZm9ybSBzdGF0ZSB3aGVuIHRoZSB1c2VyIHNlbGVjdHMgYSB0eXBlIGRlZmluaXRpb24gZnJvbSB0aGUgZHJvcGRvd25cbmNvbnN0IGNyZWF0ZUZvcm1TdGF0ZUZyb21UeXBlRGVmaW5pdGlvbiA9IChzZWxlY3RlZFR5cGVEZWZpbml0aW9uKSA9PiB7XG4gIHJldHVybiB7XG4gICAgdHlwZToge1xuICAgICAgaWQ6IHNlbGVjdGVkVHlwZURlZmluaXRpb24udHlwZS5pZCxcbiAgICAgIG9iajoge1xuICAgICAgICBmaWVsZERlZmluaXRpb25zOiBzZWxlY3RlZFR5cGVEZWZpbml0aW9uLnR5cGUuZmllbGREZWZpbml0aW9ucyxcbiAgICAgICAga2V5OiBzZWxlY3RlZFR5cGVEZWZpbml0aW9uLnR5cGUua2V5LFxuICAgICAgfSxcbiAgICB9LFxuICAgIGZpZWxkczoge30sXG4gIH07XG59O1xuXG5jb25zdCBDdXN0b21UeXBlU3ViZm9ybSA9ICh7XG4gIHR5cGVEZWZpbml0aW9ucyxcbiAgaXNSZWFkT25seSxcbiAgaXNDb25kZW5zZWQsXG4gIGhpZGVFbXB0eUZpZWxkcyxcbiAgcm9vdEZvcm1TdGF0ZUZpZWxkTmFtZSxcbiAgcGFuZWxUaXRsZSxcbn0pID0+IHtcbiAgY29uc3Qge1xuICAgIHZhbHVlczogZm9ybVZhbHVlcyxcbiAgICBzZXRGaWVsZFZhbHVlLFxuICAgIHZhbGlkYXRlRm9ybSxcbiAgfSA9IHVzZUZvcm1pa0NvbnRleHQoKTtcbiAgY29uc3QgeyBmb3JtYXRNZXNzYWdlIH0gPSB1c2VJbnRsKCk7XG4gIGNvbnN0IHsgbGFuZ3VhZ2UsIGxhbmd1YWdlcyB9ID0gdXNlQXBwbGljYXRpb25Db250ZXh0KFxuICAgIChhcHBsaWNhdGlvbkNvbnRleHQpID0+ICh7XG4gICAgICBsYW5ndWFnZTogYXBwbGljYXRpb25Db250ZXh0LmRhdGFMb2NhbGUsXG4gICAgICBsYW5ndWFnZXM6IGFwcGxpY2F0aW9uQ29udGV4dC5wcm9qZWN0Lmxhbmd1YWdlcyxcbiAgICB9KVxuICApO1xuICBjb25zdCByb290RmllbGROYW1lID0gY3JlYXRlUm9vdEZpZWxkTmFtZShyb290Rm9ybVN0YXRlRmllbGROYW1lKTtcblxuICBjb25zdCBoYW5kbGVUeXBlRGVmaW5pdGlvblNlbGVjdCA9IHVzZUNhbGxiYWNrKFxuICAgIChldmVudCkgPT4ge1xuICAgICAgY29uc3Qgc2VsZWN0ZWRUeXBlRGVmaW5pdGlvbiA9IHR5cGVEZWZpbml0aW9ucy5maW5kKFxuICAgICAgICAodHlwZURlZmluaXRpb24pID0+IHR5cGVEZWZpbml0aW9uLnR5cGUua2V5ID09PSBldmVudC50YXJnZXQudmFsdWVcbiAgICAgICk7XG5cbiAgICAgIGlmIChzZWxlY3RlZFR5cGVEZWZpbml0aW9uKSB7XG4gICAgICAgIGNvbnN0IG5leHRDdXN0b20gPSBjcmVhdGVGb3JtU3RhdGVGcm9tVHlwZURlZmluaXRpb24oXG4gICAgICAgICAgc2VsZWN0ZWRUeXBlRGVmaW5pdGlvblxuICAgICAgICApO1xuXG4gICAgICAgIHNldEZpZWxkVmFsdWUocm9vdEZpZWxkTmFtZSwgbmV4dEN1c3RvbSkudGhlbigoKSA9PiB7XG4gICAgICAgICAgdmFsaWRhdGVGb3JtKCk7XG4gICAgICAgIH0pO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgLy8gaWYgdGhlIGRyb3Bkb3duIHNlbGVjdG9yIGlzIGNsZWFyZWQsIHJlbW92ZSB0aGUgYGN1c3RvbWAgZmllbGQgZnJvbSB0aGUgZm9ybSBzdGF0ZSBlbnRpcmVseVxuICAgICAgICBzZXRGaWVsZFZhbHVlKHJvb3RGaWVsZE5hbWUsIHVuZGVmaW5lZCkudGhlbigoKSA9PiB7XG4gICAgICAgICAgdmFsaWRhdGVGb3JtKCk7XG4gICAgICAgIH0pO1xuICAgICAgfVxuICAgIH0sXG4gICAgW3R5cGVEZWZpbml0aW9ucywgc2V0RmllbGRWYWx1ZSwgdmFsaWRhdGVGb3JtLCByb290RmllbGROYW1lXVxuICApO1xuXG4gIGNvbnN0IHR5cGVEZWZpbml0aW9uU2VsZWN0ZWQgPSAoZm9ybVZhbHVlcykgPT4ge1xuICAgIHJldHVybiAoXG4gICAgICBnZXRJbihmb3JtVmFsdWVzLCByb290RmllbGROYW1lKT8udHlwZSAmJlxuICAgICAgZ2V0SW4oZm9ybVZhbHVlcywgcm9vdEZpZWxkTmFtZSk/LnR5cGU/Lm9ialxuICAgICk7XG4gIH07XG5cbiAgLy8gaWYgdGhlIHVzZXIgaGFzIHJlYWQtb25seSBwZXJtaXNzaW9ucywgZW1wdHkgZmllbGRzIGFyZSBoaWRkZW4sIGFuZCBubyB0eXBlIGRlZmluaXRpb24gaXMgc2VsZWN0ZWQsIGhpZGUgdGhlIGNvbXBvbmVudFxuICBpZiAoaXNSZWFkT25seSAmJiBoaWRlRW1wdHlGaWVsZHMgJiYgIXR5cGVEZWZpbml0aW9uU2VsZWN0ZWQoZm9ybVZhbHVlcykpXG4gICAgcmV0dXJuIG51bGw7XG5cbiAgcmV0dXJuIChcbiAgICA8Q29sbGFwc2libGVQYW5lbFxuICAgICAgaGVhZGVyPXtcbiAgICAgICAgPENvbGxhcHNpYmxlUGFuZWwuSGVhZGVyIGlzQ29uZGVuc2VkPXtpc0NvbmRlbnNlZH0+XG4gICAgICAgICAge3BhbmVsVGl0bGUgfHwgPEZvcm1hdHRlZE1lc3NhZ2Ugey4uLm1lc3NhZ2VzLnRpdGxlfSAvPn1cbiAgICAgICAgPC9Db2xsYXBzaWJsZVBhbmVsLkhlYWRlcj5cbiAgICAgIH1cbiAgICAgIGhlYWRlckNvbnRyb2xzPXtcbiAgICAgICAgdHlwZURlZmluaXRpb25zLmxlbmd0aCA+IDAgJiYgKFxuICAgICAgICAgIDxkaXZcbiAgICAgICAgICAgIGNzcz17Y3NzYFxuICAgICAgICAgICAgICBtaW4td2lkdGg6ICR7ZGVzaWduVG9rZW5zLmNvbnN0cmFpbnQxMX07XG4gICAgICAgICAgICBgfVxuICAgICAgICAgID5cbiAgICAgICAgICAgIDxTZWxlY3RJbnB1dFxuICAgICAgICAgICAgICBpc0NsZWFyYWJsZVxuICAgICAgICAgICAgICBkYXRhLXRlc3RpZD1cImN1c3RvbS10eXBlLXNlbGVjdFwiXG4gICAgICAgICAgICAgIG5hbWU9e2Ake3Jvb3RGaWVsZE5hbWV9LnR5cGUub2JqLmtleWB9XG4gICAgICAgICAgICAgIG9wdGlvbnM9e21hcFR5cGVEZWZpbml0aW9uc1RvT3B0aW9ucyhcbiAgICAgICAgICAgICAgICB0eXBlRGVmaW5pdGlvbnMsXG4gICAgICAgICAgICAgICAgbGFuZ3VhZ2UsXG4gICAgICAgICAgICAgICAgbGFuZ3VhZ2VzLFxuXG4gICAgICAgICAgICAgICAgZ2V0SW4oZm9ybVZhbHVlcywgcm9vdEZpZWxkTmFtZSk/LnR5cGU/LmlkXG4gICAgICAgICAgICAgICl9XG4gICAgICAgICAgICAgIHZhbHVlPXtnZXRJbihmb3JtVmFsdWVzLCByb290RmllbGROYW1lKT8udHlwZT8ub2JqPy5rZXl9XG4gICAgICAgICAgICAgIG9uQ2hhbmdlPXtoYW5kbGVUeXBlRGVmaW5pdGlvblNlbGVjdH1cbiAgICAgICAgICAgICAgcGxhY2Vob2xkZXI9e2Zvcm1hdE1lc3NhZ2UobWVzc2FnZXMudHlwZXNQbGFjZWhvbGRlcil9XG4gICAgICAgICAgICAgIGlzUmVhZE9ubHk9e2lzUmVhZE9ubHl9XG4gICAgICAgICAgICAvPlxuICAgICAgICAgIDwvZGl2PlxuICAgICAgICApXG4gICAgICB9XG4gICAgICBoZWFkZXJDb250cm9sc0FsaWdubWVudD1cInJpZ2h0XCJcbiAgICA+XG4gICAgICA8Q3VzdG9tRmllbGRzSW5wdXRXcmFwcGVyXG4gICAgICAgIHR5cGVEZWZpbml0aW9ucz17dHlwZURlZmluaXRpb25zfVxuICAgICAgICBpc1JlYWRPbmx5PXtpc1JlYWRPbmx5fVxuICAgICAgICBoaWRlRW1wdHlGaWVsZHM9e2hpZGVFbXB0eUZpZWxkc31cbiAgICAgICAgcm9vdEZvcm1TdGF0ZUZpZWxkTmFtZT17cm9vdEZvcm1TdGF0ZUZpZWxkTmFtZX1cbiAgICAgIC8+XG4gICAgPC9Db2xsYXBzaWJsZVBhbmVsPlxuICApO1xufTtcblxuQ3VzdG9tVHlwZVN1YmZvcm0uZGlzcGxheU5hbWUgPSAnQ3VzdG9tVHlwZVN1YmZvcm0nO1xuQ3VzdG9tVHlwZVN1YmZvcm0ucHJvcFR5cGVzID0ge1xuICB0eXBlRGVmaW5pdGlvbnM6IFByb3BUeXBlcy5hcnJheS5pc1JlcXVpcmVkLFxuICBpc1JlYWRPbmx5OiBQcm9wVHlwZXMuYm9vbCxcbiAgaXNDb25kZW5zZWQ6IFByb3BUeXBlcy5ib29sLFxuICBoaWRlRW1wdHlGaWVsZHM6IFByb3BUeXBlcy5ib29sLFxuICByb290Rm9ybVN0YXRlRmllbGROYW1lOiBQcm9wVHlwZXMuc3RyaW5nLFxuICBwYW5lbFRpdGxlOiBQcm9wVHlwZXMubm9kZSxcbn07XG5cbmV4cG9ydCBkZWZhdWx0IEN1c3RvbVR5cGVTdWJmb3JtO1xuIl19 */"),
|
|
13348
13578
|
children: jsx(SelectInput, {
|
|
13349
13579
|
isClearable: true,
|
|
13350
13580
|
"data-testid": "custom-type-select",
|
|
13351
|
-
name:
|
|
13352
|
-
options: mapTypeDefinitionsToOptions(typeDefinitions, language, languages, formValues
|
|
13353
|
-
value: formValues
|
|
13581
|
+
name: "".concat(rootFieldName, ".type.obj.key"),
|
|
13582
|
+
options: mapTypeDefinitionsToOptions(typeDefinitions, language, languages, (_getIn3 = getIn(formValues, rootFieldName)) === null || _getIn3 === void 0 || (_getIn3 = _getIn3.type) === null || _getIn3 === void 0 ? void 0 : _getIn3.id),
|
|
13583
|
+
value: (_getIn4 = getIn(formValues, rootFieldName)) === null || _getIn4 === void 0 || (_getIn4 = _getIn4.type) === null || _getIn4 === void 0 || (_getIn4 = _getIn4.obj) === null || _getIn4 === void 0 ? void 0 : _getIn4.key,
|
|
13354
13584
|
onChange: handleTypeDefinitionSelect,
|
|
13355
13585
|
placeholder: formatMessage(messages.typesPlaceholder),
|
|
13356
13586
|
isReadOnly: isReadOnly
|
|
@@ -13360,103 +13590,20 @@ const CustomTypeSubform = _ref => {
|
|
|
13360
13590
|
children: jsx(CustomFieldsInputWrapper, {
|
|
13361
13591
|
typeDefinitions: typeDefinitions,
|
|
13362
13592
|
isReadOnly: isReadOnly,
|
|
13363
|
-
hideEmptyFields: hideEmptyFields
|
|
13593
|
+
hideEmptyFields: hideEmptyFields,
|
|
13594
|
+
rootFormStateFieldName: rootFormStateFieldName
|
|
13364
13595
|
})
|
|
13365
13596
|
});
|
|
13366
13597
|
};
|
|
13367
13598
|
CustomTypeSubform.displayName = 'CustomTypeSubform';
|
|
13368
13599
|
|
|
13369
|
-
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13370
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context6, _context7; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context6 = ownKeys(Object(t), !0)).call(_context6, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context7 = ownKeys(Object(t))).call(_context7, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13371
|
-
const transformFieldType = fieldDefinition => {
|
|
13372
|
-
if (fieldDefinition.type?.elementType?.name === 'LocalizedEnum') {
|
|
13373
|
-
var _context;
|
|
13374
|
-
return _objectSpread(_objectSpread({}, fieldDefinition.type), {}, {
|
|
13375
|
-
elementType: _objectSpread(_objectSpread({}, fieldDefinition.type.elementType), {}, {
|
|
13376
|
-
values: _mapInstanceProperty(_context = _valuesInstanceProperty(fieldDefinition.type.elementType)).call(_context, value => ({
|
|
13377
|
-
key: value.key,
|
|
13378
|
-
label: transformLocalizedFieldToLocalizedString(value.labelAllLocales)
|
|
13379
|
-
}))
|
|
13380
|
-
})
|
|
13381
|
-
});
|
|
13382
|
-
} else if (fieldDefinition.type?.name === 'LocalizedEnum') {
|
|
13383
|
-
var _context2;
|
|
13384
|
-
return _objectSpread(_objectSpread({}, fieldDefinition.type), {}, {
|
|
13385
|
-
values: _mapInstanceProperty(_context2 = _valuesInstanceProperty(fieldDefinition.type)).call(_context2, value => ({
|
|
13386
|
-
key: value.key,
|
|
13387
|
-
label: transformLocalizedFieldToLocalizedString(value.labelAllLocales)
|
|
13388
|
-
}))
|
|
13389
|
-
});
|
|
13390
|
-
} else {
|
|
13391
|
-
return fieldDefinition.type;
|
|
13392
|
-
}
|
|
13393
|
-
};
|
|
13394
|
-
const convertCustomField = resource => {
|
|
13395
|
-
var _context3, _context4;
|
|
13396
|
-
return {
|
|
13397
|
-
type: {
|
|
13398
|
-
typeId: 'type',
|
|
13399
|
-
id: resource.custom.type.id,
|
|
13400
|
-
obj: {
|
|
13401
|
-
key: resource.custom.type.key,
|
|
13402
|
-
name: transformLocalizedFieldToLocalizedString(resource.custom.type.nameAllLocales),
|
|
13403
|
-
fieldDefinitions: _mapInstanceProperty(_context3 = resource.custom.type.fieldDefinitions).call(_context3, fieldDefinition => ({
|
|
13404
|
-
name: fieldDefinition.name,
|
|
13405
|
-
required: fieldDefinition.required,
|
|
13406
|
-
inputHint: fieldDefinition.inputHint,
|
|
13407
|
-
type: transformFieldType(fieldDefinition),
|
|
13408
|
-
label: transformLocalizedFieldToLocalizedString(fieldDefinition.labelAllLocales)
|
|
13409
|
-
}))
|
|
13410
|
-
}
|
|
13411
|
-
},
|
|
13412
|
-
fields: _reduceInstanceProperty(_context4 = resource.custom.customFieldsRaw).call(_context4, (fields, customField) => _objectSpread(_objectSpread({}, fields), {}, {
|
|
13413
|
-
[customField.name]: customField.value
|
|
13414
|
-
}), {})
|
|
13415
|
-
};
|
|
13416
|
-
};
|
|
13417
|
-
const createFormStateFromResource = resource => {
|
|
13418
|
-
// If there are no custom fields on the resource, don't create a form state
|
|
13419
|
-
if (!resource[FIELD_NAME]) {
|
|
13420
|
-
return {
|
|
13421
|
-
[FIELD_NAME]: undefined
|
|
13422
|
-
};
|
|
13423
|
-
}
|
|
13424
|
-
return {
|
|
13425
|
-
[FIELD_NAME]: convertCustomField(resource)
|
|
13426
|
-
};
|
|
13427
|
-
};
|
|
13428
|
-
const createGraphQlDocFromFormState = formState => {
|
|
13429
|
-
var _context5;
|
|
13430
|
-
// Unset the custom type if it's not in the form state
|
|
13431
|
-
if (!formState[FIELD_NAME]) {
|
|
13432
|
-
return {
|
|
13433
|
-
[FIELD_NAME]: {}
|
|
13434
|
-
};
|
|
13435
|
-
}
|
|
13436
|
-
return {
|
|
13437
|
-
[FIELD_NAME]: {
|
|
13438
|
-
type: {
|
|
13439
|
-
id: formState[FIELD_NAME].type.id,
|
|
13440
|
-
typeId: 'type'
|
|
13441
|
-
},
|
|
13442
|
-
fields: _mapInstanceProperty(_context5 = _Object$entries(formState[FIELD_NAME].fields)).call(_context5, _ref => {
|
|
13443
|
-
let _ref2 = _slicedToArray(_ref, 2),
|
|
13444
|
-
name = _ref2[0],
|
|
13445
|
-
value = _ref2[1];
|
|
13446
|
-
return {
|
|
13447
|
-
name,
|
|
13448
|
-
value: _JSON$stringify(value)
|
|
13449
|
-
};
|
|
13450
|
-
})
|
|
13451
|
-
}
|
|
13452
|
-
};
|
|
13453
|
-
};
|
|
13454
|
-
|
|
13455
13600
|
const CustomFieldsFormField = _ref => {
|
|
13456
13601
|
let resources = _ref.resources,
|
|
13457
13602
|
isReadOnly = _ref.isReadOnly,
|
|
13458
13603
|
isCondensed = _ref.isCondensed,
|
|
13459
|
-
hideEmptyFields = _ref.hideEmptyFields
|
|
13604
|
+
hideEmptyFields = _ref.hideEmptyFields,
|
|
13605
|
+
rootFormStateFieldName = _ref.rootFormStateFieldName,
|
|
13606
|
+
panelTitle = _ref.panelTitle;
|
|
13460
13607
|
const projectKey = useApplicationContext(applicationContext => applicationContext.project.key);
|
|
13461
13608
|
return jsx(CustomFieldTypeDefinitionsConnector$1, {
|
|
13462
13609
|
resources: resources,
|
|
@@ -13474,7 +13621,9 @@ const CustomFieldsFormField = _ref => {
|
|
|
13474
13621
|
typeDefinitions: typeDefinitions,
|
|
13475
13622
|
isReadOnly: isReadOnly,
|
|
13476
13623
|
isCondensed: isCondensed,
|
|
13477
|
-
hideEmptyFields: hideEmptyFields
|
|
13624
|
+
hideEmptyFields: hideEmptyFields,
|
|
13625
|
+
rootFormStateFieldName: rootFormStateFieldName,
|
|
13626
|
+
panelTitle: panelTitle
|
|
13478
13627
|
});
|
|
13479
13628
|
}
|
|
13480
13629
|
});
|
|
@@ -13484,4 +13633,4 @@ CustomFieldsFormField.createGraphQlDocFromFormState = createGraphQlDocFromFormSt
|
|
|
13484
13633
|
|
|
13485
13634
|
var CategorySearchPickerOptionFragment = { kind: "Document", definitions: [{ kind: "FragmentDefinition", name: { kind: "Name", value: "CategorySearchPickerOptionFragment" }, typeCondition: { kind: "NamedType", name: { kind: "Name", value: "CategorySearch" } }, directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "externalId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "slugAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "parent" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "ancestors" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "nameAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }], loc: { start: 0, end: 685, source: { body: "query SearchCategoryReference($locale: Locale!, $text: String!) {\n categories: categoryAutocomplete(locale: $locale, text: $text) {\n results {\n ...CategorySearchPickerOptionFragment\n }\n }\n}\n\nquery FetchCategoriesByIds($where: String!) {\n categories(where: $where) {\n results {\n id\n nameAllLocales {\n locale\n value\n }\n }\n }\n}\n\nfragment CategorySearchPickerOptionFragment on CategorySearch {\n id\n externalId\n nameAllLocales {\n locale\n value\n }\n slugAllLocales {\n locale\n value\n }\n parent {\n nameAllLocales {\n locale\n value\n }\n }\n ancestors {\n nameAllLocales {\n locale\n value\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
13486
13635
|
|
|
13487
|
-
export { booleanField as BooleanField, Button, CartDiscountReferenceSearch, CategoryReferenceSearch, CategorySearchPickerOptionFragment, CenteredLoadingSpinner, ChannelPickerInput, CountriesPicker, customFieldDefinitionsConnector as CustomFieldDefinitionsConnector, CustomFieldTypeDefinitionsConnector$1 as CustomFieldTypeDefinitionsConnector, CustomFields, CustomFieldsErrorTextNotification, CustomFieldsFormField, CustomerGroupPickerInput, DefaultPageSizes, Divider, EMAIL_REGEX, FileInput, FormattedDateTime$1 as FormattedDateTime, LabelRange, MissingValueField, MultiValueSearchInput, numericFormatInput as NumericFormatInput, PRECISION_TYPES, pimIndexerProvider as PimIndexerProvider, ProductAttributeInput, ProductAttributes, ProductPickerInput, ProductSelectionsPicker as ProductSelectionPicker, RequestCache, RequiredIndicator, ScrollToFieldError, searchInput as SearchInput, SelectableFieldSearchInput, StoreSelectField, StoreSelectInput, ThrottledField, VALIDATOR_INTEGER, VALIDATOR_NUMERIC, VALIDATOR_REQUIRED, WithPimIndexer, allowedProperties, and, attributesMapToNameValuePairs, base64ToString, messages$8 as booleanMessages, buildSearchQuery, businessRoleConstants, messages$r as businessRoleMessages, businessRoleKeys as businessRoles, capitalizeFirst, clone, coerceToInteger, computedProperties, convertApolloNetworkStatusToLoadingState, convertApolloQueryDataToConnectorData, convertProductSelectionFromGraphQl, convertRatioToPercentage, createGraphQlUpdateActions, createNextSortDefinition, createReducer, createResourceReducer, handlers$2 as customFieldDefinitionsMockHanders, customFields as customFieldsTransformer, dateTransformer$1 as dateTransformer, exact, exists, extractErrorFromGraphQlResponse, filterCustomTypeUpdateActionValues, filterDataAttributes, filterEmptyValues, formatCustomField, formatCustomerAddress, formatCustomerName, formatDateRangeValue, formatDateTime$1 as formatDateTime, formatDiscount, formatMoney$2 as formatMoney, formatMoneyRangeValue, formatMoneyValue, formatPercentage, formatAttribute as formatProductAttribute, getAncestors, getAttributeValueByType, getAttributeValueType, getBulkNotification, getCategoryLevel, getCountsFromBulkSummary, getDiscountValue, getDisplayName, getFractionedAmount, getIndexesOfInvalidValues, getMinimumPricesByCurrencyCode, getNetUnitPrice, getPathName, getPrefixSearchBounds, getPriceChannelName, getReferenceTypeId, getSelectedPrice, getTimeZoneId, getTimeZoneLabel, getTypeNameOfType, graphqlCategoryLevelTransformer, dateTransformer as graphqlDateTransformer, missingLocaleTransformer as graphqlMissingLocaleTransformer, missingTransformer as graphqlMissingTransformer, numberTransformer as graphqlNumberTransformer, graphqlQueryBuilder, referenceTransformer as graphqlReferenceTransformer, textTransformer as graphqlTextTransformer, hasInvalidInputError, hasSemanticError, injectCustomerGroupsPlatformLimits, injectCustomersPlatformLimits, injectDataTablePaginationState, injectModalState$1 as injectModalState, injectNotifications, injectPimIndexer, injectShippingMethodsPlatformLimits, injectStorage, injectTaxCategoriesPlatformLimits, injectModalState as injectToggleState, injectZonesPlatformLimits, isEmptyFilter as isEmpty, isEmptyValue, isUUID, isValidISODate, isValidISODateTime, isValidISOTime, keepDisplayName, mapStoresToOptions, mapTimeZonesToOptions, minusify, messages$7 as missingValueMessages, nameValuePairsToMap, normalizeProductSettings, not, omitDeep, omitSetsOfSets, or, commonPickerMessages as pickerMessages, handlers as platformLimitsMockHandlers, handlers$3 as productSelectionsFetcherMockHandler, handlers$4 as productSelectionsTotalFetcherMockHandler, range, reorderArrayItems, resolveStatusType, safelyAddFallback, sanitize, searchCategories, messages$F as searchInputMessages, setDisplayName, setToArray, shallowEqual, shouldUpdateAttributeInput, slugify, sortDataByIdsArray, sortRequiresLanguage, splitVariantAttributesByConstraint, handlers$5 as storesListConnectorMockHandlers, stringToBase64, swapArrayItems, transformAllToProperNounCase, transformCustomFieldsRawToCustomFields, transformLocalizedFieldsForCategory, truncate, unique, uniqueObjects, useCachedCategoryOptions, useDnDContext as useCustomFieldsDnDContext, useCustomerGroupsPlatformLimits, useCustomersPlatformLimits, useDebouncedPromiseCallback, useFormatLocalizedFieldToString, useLocalizedKeyFallback, usePendingRequests, usePersistedTableConfiguration, usePimIndexer, usePrevious, useProductSelectionsFetcher, useProductSelectionsTotalFetcher, useRoleNotificationEffect, useShippingMethodsLimits as useShippingMethodsPlatformLimits, useStorage, useStoreKeysInDataFences, useStoresListFetcher, useTaxCategoriesLimits as useTaxCategoriesPlatformLimits, useTotalNumberOfStoresFetcher, handlers$1 as useTotalNumberOfStoresFetcherHandlers, validateFilter$2 as validateCustomField, validations as validateCustomFields, validateFilter$1 as validateDate, validateMultiOptionEnum, validateFilter as validateNumber, validateSingleOptionEnum, validateText, validatedInput, messages$K as validationMessages, withPendingRequests, withProps, withRedirectTo, withoutEmptyErrorsByField, wrapDisplayName };
|
|
13636
|
+
export { booleanField as BooleanField, Button, CartDiscountReferenceSearch, CategoryReferenceSearch, CategorySearchPickerOptionFragment, CenteredLoadingSpinner, ChannelPickerInput, CountriesPicker, customFieldDefinitionsConnector as CustomFieldDefinitionsConnector, CustomFieldTooltip, CustomFieldTypeDefinitionsConnector$1 as CustomFieldTypeDefinitionsConnector, CustomFields, CustomFieldsErrorTextNotification, CustomFieldsFormField, CustomerGroupPickerInput, DefaultPageSizes, Divider, EMAIL_REGEX, FileInput, FormattedDateTime$1 as FormattedDateTime, LabelRange, MissingValueField, MultiValueSearchInput, numericFormatInput as NumericFormatInput, Option$2 as Option, PRECISION_TYPES, pimIndexerProvider as PimIndexerProvider, ProductAttributeInput, ProductAttributes, ProductPickerInput, ProductSelectionsPicker as ProductSelectionPicker, RequestCache, RequiredIndicator, ScrollToFieldError, searchInput as SearchInput, SelectableFieldSearchInput, StoreSelectField, StoreSelectInput, ThrottledField, VALIDATOR_INTEGER, VALIDATOR_NUMERIC, VALIDATOR_REQUIRED, WithPimIndexer, allowedProperties, and, attributesMapToNameValuePairs, base64ToString, messages$8 as booleanMessages, buildSearchQuery, businessRoleConstants, messages$r as businessRoleMessages, businessRoleKeys as businessRoles, capitalizeFirst, clone, coerceToInteger, computedProperties, convertApolloNetworkStatusToLoadingState, convertApolloQueryDataToConnectorData, convertProductSelectionFromGraphQl, convertRatioToPercentage, createGraphQlUpdateActions, createNextSortDefinition, createReducer, createResourceReducer, handlers$2 as customFieldDefinitionsMockHanders, customFields as customFieldsTransformer, dateTransformer$1 as dateTransformer, exact, exists, extractErrorFromGraphQlResponse, filterCustomTypeUpdateActionValues, filterDataAttributes, filterEmptyValues, formatCustomField, formatCustomerAddress, formatCustomerName, formatDateRangeValue, formatDateTime$1 as formatDateTime, formatDiscount, formatMoney$2 as formatMoney, formatMoneyRangeValue, formatMoneyValue, formatPercentage, formatAttribute as formatProductAttribute, getAncestors, getAttributeValueByType, getAttributeValueType, getBottomOption, getBulkNotification, getCategoryLevel, getCountsFromBulkSummary, getDiscountValue, getDisplayName, getFractionedAmount, getIndexesOfInvalidValues, getMinimumPricesByCurrencyCode, getNetUnitPrice, getPathName, getPrefixSearchBounds, getPriceChannelName, getReferenceTypeId, getSelectedPrice, getTimeZoneId, getTimeZoneLabel, getTypeNameOfType, graphqlCategoryLevelTransformer, dateTransformer as graphqlDateTransformer, missingLocaleTransformer as graphqlMissingLocaleTransformer, missingTransformer as graphqlMissingTransformer, numberTransformer as graphqlNumberTransformer, graphqlQueryBuilder, referenceTransformer as graphqlReferenceTransformer, textTransformer as graphqlTextTransformer, hasInvalidInputError, hasSemanticError, injectCustomerGroupsPlatformLimits, injectCustomersPlatformLimits, injectDataTablePaginationState, injectModalState$1 as injectModalState, injectNotifications, injectPimIndexer, injectShippingMethodsPlatformLimits, injectStorage, injectTaxCategoriesPlatformLimits, injectModalState as injectToggleState, injectZonesPlatformLimits, isEmptyFilter as isEmpty, isEmptyValue, isUUID, isValidISODate, isValidISODateTime, isValidISOTime, keepDisplayName, mapStoresToOptions, mapTimeZonesToOptions, minusify, messages$7 as missingValueMessages, nameValuePairsToMap, normalizeProductSettings, not, omitDeep, omitSetsOfSets, or, commonPickerMessages as pickerMessages, handlers as platformLimitsMockHandlers, handlers$3 as productSelectionsFetcherMockHandler, handlers$4 as productSelectionsTotalFetcherMockHandler, range, reorderArrayItems, resolveStatusType, safelyAddFallback, sanitize, searchCategories, messages$F as searchInputMessages, setDisplayName, setToArray, shallowEqual, shouldUpdateAttributeInput, slugify, sortDataByIdsArray, sortRequiresLanguage, splitVariantAttributesByConstraint, handlers$5 as storesListConnectorMockHandlers, stringToBase64, swapArrayItems, transformAllToProperNounCase, transformCustomFieldsRawToCustomFields, transformLocalizedFieldsForCategory, truncate, unique, uniqueObjects, useCachedCategoryOptions, useCurrentOption, useDnDContext as useCustomFieldsDnDContext, useCustomerGroupsPlatformLimits, useCustomersPlatformLimits, useDebouncedPromiseCallback, useFormatLocalizedFieldToString, useLoadOptions, useLocalizedKeyFallback, usePendingRequests, usePersistedTableConfiguration, usePimIndexer, usePrevious, useProductSelectionsFetcher, useProductSelectionsTotalFetcher, useRoleNotificationEffect, useShippingMethodsLimits as useShippingMethodsPlatformLimits, useStorage, useStoreKeysInDataFences, useStoresListFetcher, useTaxCategoriesLimits as useTaxCategoriesPlatformLimits, useTotalNumberOfStoresFetcher, handlers$1 as useTotalNumberOfStoresFetcherHandlers, validateFilter$2 as validateCustomField, validations as validateCustomFields, validateFilter$1 as validateDate, validateMultiOptionEnum, validateFilter as validateNumber, validateSingleOptionEnum, validateText, validatedInput, messages$K as validationMessages, withPendingRequests, withProps, withRedirectTo, withoutEmptyErrorsByField, wrapDisplayName };
|