ordering-components-external 13.0.41 → 13.0.42
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/_bundles/{7.ordering-component.60d1e84ab037f739d802.js → 7.ordering-component.fc9b575bea137f9e1b1d.js} +1 -1
- package/_bundles/ordering-component.fc9b575bea137f9e1b1d.js +2 -0
- package/_modules/components/ProductItemAccordion/index.js +94 -0
- package/_modules/index.js +7 -0
- package/_modules/native/index.js +7 -0
- package/native/index.js +2 -0
- package/package.json +1 -1
- package/src/components/ProductItemAccordion/index.js +72 -0
- package/src/index.js +2 -0
- package/_bundles/ordering-component.60d1e84ab037f739d802.js +0 -2
- /package/_bundles/{0.ordering-component.60d1e84ab037f739d802.js → 0.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
- /package/_bundles/{1.ordering-component.60d1e84ab037f739d802.js → 1.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
- /package/_bundles/{2.ordering-component.60d1e84ab037f739d802.js → 2.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
- /package/_bundles/{4.ordering-component.60d1e84ab037f739d802.js → 4.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
- /package/_bundles/{5.ordering-component.60d1e84ab037f739d802.js → 5.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
- /package/_bundles/{6.ordering-component.60d1e84ab037f739d802.js → 6.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
- /package/_bundles/{7.ordering-component.60d1e84ab037f739d802.js.LICENSE.txt → 7.ordering-component.fc9b575bea137f9e1b1d.js.LICENSE.txt} +0 -0
- /package/_bundles/{8.ordering-component.60d1e84ab037f739d802.js → 8.ordering-component.fc9b575bea137f9e1b1d.js} +0 -0
- /package/_bundles/{ordering-component.60d1e84ab037f739d802.js.LICENSE.txt → ordering-component.fc9b575bea137f9e1b1d.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ProductItemAccordion = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
+
/**
|
|
24
|
+
* Component to render product ingredient
|
|
25
|
+
*/
|
|
26
|
+
var ProductItemAccordion = exports.ProductItemAccordion = function ProductItemAccordion(props) {
|
|
27
|
+
var UIComponent = props.UIComponent,
|
|
28
|
+
product = props.product,
|
|
29
|
+
isCartProduct = props.isCartProduct;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Run productInfo to sort product options
|
|
33
|
+
*/
|
|
34
|
+
var productInfo = function productInfo() {
|
|
35
|
+
var _product$options;
|
|
36
|
+
var options = JSON.parse(JSON.stringify(Object.values((_product$options = product.options) !== null && _product$options !== void 0 ? _product$options : {})));
|
|
37
|
+
var extraGroups = options.reduce(function (acc, option) {
|
|
38
|
+
var _option$extra$rank, _option$extra;
|
|
39
|
+
var extraRank = (_option$extra$rank = option === null || option === void 0 || (_option$extra = option.extra) === null || _option$extra === void 0 ? void 0 : _option$extra.rank) !== null && _option$extra$rank !== void 0 ? _option$extra$rank : option === null || option === void 0 ? void 0 : option.rank;
|
|
40
|
+
acc[extraRank] = acc[extraRank] || [];
|
|
41
|
+
acc[extraRank].push(option);
|
|
42
|
+
return acc;
|
|
43
|
+
}, {});
|
|
44
|
+
var sortedExtraGroups = Object.entries(extraGroups).sort(function (_ref, _ref2) {
|
|
45
|
+
var _ref3 = _slicedToArray(_ref, 1),
|
|
46
|
+
rankA = _ref3[0];
|
|
47
|
+
var _ref4 = _slicedToArray(_ref2, 1),
|
|
48
|
+
rankB = _ref4[0];
|
|
49
|
+
return rankA - rankB;
|
|
50
|
+
});
|
|
51
|
+
sortedExtraGroups.forEach(function (_ref5) {
|
|
52
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
53
|
+
_ = _ref6[0],
|
|
54
|
+
group = _ref6[1];
|
|
55
|
+
group.sort(function (a, b) {
|
|
56
|
+
return a.rank - b.rank;
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
options = sortedExtraGroups.flatMap(function (_ref7) {
|
|
60
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
61
|
+
group = _ref8[1];
|
|
62
|
+
return group;
|
|
63
|
+
});
|
|
64
|
+
if (isCartProduct) {
|
|
65
|
+
var _product$ingredients;
|
|
66
|
+
var ingredients = JSON.parse(JSON.stringify(Object.values((_product$ingredients = product.ingredients) !== null && _product$ingredients !== void 0 ? _product$ingredients : {})));
|
|
67
|
+
options = options.map(function (option) {
|
|
68
|
+
var _option$suboptions;
|
|
69
|
+
option.suboptions = Object.values((_option$suboptions = option.suboptions) !== null && _option$suboptions !== void 0 ? _option$suboptions : {});
|
|
70
|
+
return option;
|
|
71
|
+
});
|
|
72
|
+
return _objectSpread(_objectSpread({}, productInfo), {}, {
|
|
73
|
+
ingredients: ingredients,
|
|
74
|
+
options: options
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
78
|
+
options: options
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, UIComponent && /*#__PURE__*/_react.default.createElement(UIComponent, _extends({}, props, {
|
|
82
|
+
productInfo: productInfo()
|
|
83
|
+
})));
|
|
84
|
+
};
|
|
85
|
+
ProductItemAccordion.propTypes = {
|
|
86
|
+
/**
|
|
87
|
+
* UI Component, this must be containt all graphic elements and use parent props
|
|
88
|
+
*/
|
|
89
|
+
UIComponent: _propTypes.default.elementType,
|
|
90
|
+
/**
|
|
91
|
+
* product object to render UI
|
|
92
|
+
*/
|
|
93
|
+
product: _propTypes.default.object.isRequired
|
|
94
|
+
};
|
package/_modules/index.js
CHANGED
|
@@ -771,6 +771,12 @@ Object.defineProperty(exports, "ProductIngredient", {
|
|
|
771
771
|
return _ProductIngredient.ProductIngredient;
|
|
772
772
|
}
|
|
773
773
|
});
|
|
774
|
+
Object.defineProperty(exports, "ProductItemAccordion", {
|
|
775
|
+
enumerable: true,
|
|
776
|
+
get: function get() {
|
|
777
|
+
return _ProductItemAccordion.ProductItemAccordion;
|
|
778
|
+
}
|
|
779
|
+
});
|
|
774
780
|
Object.defineProperty(exports, "ProductOption", {
|
|
775
781
|
enumerable: true,
|
|
776
782
|
get: function get() {
|
|
@@ -1247,6 +1253,7 @@ var _ProductForm = require("./components/ProductForm");
|
|
|
1247
1253
|
var _ProductShare = require("./components/ProductShare");
|
|
1248
1254
|
var _ProductImages = require("./components/ProductImages");
|
|
1249
1255
|
var _ProductIngredient = require("./components/ProductIngredient");
|
|
1256
|
+
var _ProductItemAccordion = require("./components/ProductItemAccordion");
|
|
1250
1257
|
var _ProductOption = require("./components/ProductOption");
|
|
1251
1258
|
var _ProductOptionSuboption = require("./components/ProductOptionSuboption");
|
|
1252
1259
|
var _ProductsList = require("./components/ProductsList");
|
package/_modules/native/index.js
CHANGED
|
@@ -513,6 +513,12 @@ Object.defineProperty(exports, "ProductIngredient", {
|
|
|
513
513
|
return _ProductIngredient.ProductIngredient;
|
|
514
514
|
}
|
|
515
515
|
});
|
|
516
|
+
Object.defineProperty(exports, "ProductItemAccordion", {
|
|
517
|
+
enumerable: true,
|
|
518
|
+
get: function get() {
|
|
519
|
+
return _ProductItemAccordion.ProductItemAccordion;
|
|
520
|
+
}
|
|
521
|
+
});
|
|
516
522
|
Object.defineProperty(exports, "ProductOption", {
|
|
517
523
|
enumerable: true,
|
|
518
524
|
get: function get() {
|
|
@@ -901,6 +907,7 @@ var _PhoneAutocomplete = require("../src/components/PhoneAutocomplete");
|
|
|
901
907
|
var _ProductForm = require("../src/components/ProductForm");
|
|
902
908
|
var _ProductImages = require("../src/components/ProductImages");
|
|
903
909
|
var _ProductIngredient = require("../src/components/ProductIngredient");
|
|
910
|
+
var _ProductItemAccordion = require("../src/components/ProductItemAccordion");
|
|
904
911
|
var _ProductOption = require("../src/components/ProductOption");
|
|
905
912
|
var _ProductOptionSuboption = require("../src/components/ProductOptionSuboption");
|
|
906
913
|
var _ProductsList = require("../src/components/ProductsList");
|
package/native/index.js
CHANGED
|
@@ -62,6 +62,7 @@ import { PhoneAutocomplete } from '../src/components/PhoneAutocomplete'
|
|
|
62
62
|
import { ProductForm } from '../src/components/ProductForm'
|
|
63
63
|
import { ProductImages } from '../src/components/ProductImages'
|
|
64
64
|
import { ProductIngredient } from '../src/components/ProductIngredient'
|
|
65
|
+
import { ProductItemAccordion } from '../src/components/ProductItemAccordion'
|
|
65
66
|
import { ProductOption } from '../src/components/ProductOption'
|
|
66
67
|
import { ProductOptionSuboption } from '../src/components/ProductOptionSuboption'
|
|
67
68
|
import { ProductsList } from '../src/components/ProductsList'
|
|
@@ -176,6 +177,7 @@ export {
|
|
|
176
177
|
ProductForm,
|
|
177
178
|
ProductImages,
|
|
178
179
|
ProductIngredient,
|
|
180
|
+
ProductItemAccordion,
|
|
179
181
|
ProductOption,
|
|
180
182
|
ProductOptionSuboption,
|
|
181
183
|
ProductsList,
|
package/package.json
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Component to render product ingredient
|
|
6
|
+
*/
|
|
7
|
+
export const ProductItemAccordion = (props) => {
|
|
8
|
+
const {
|
|
9
|
+
UIComponent,
|
|
10
|
+
product,
|
|
11
|
+
isCartProduct
|
|
12
|
+
} = props
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Run productInfo to sort product options
|
|
16
|
+
*/
|
|
17
|
+
const productInfo = () => {
|
|
18
|
+
let options = JSON.parse(JSON.stringify(Object.values(product.options ?? {})))
|
|
19
|
+
const extraGroups = options.reduce((acc, option) => {
|
|
20
|
+
const extraRank = option?.extra?.rank ?? option?.rank
|
|
21
|
+
acc[extraRank] = acc[extraRank] || []
|
|
22
|
+
acc[extraRank].push(option)
|
|
23
|
+
return acc
|
|
24
|
+
}, {})
|
|
25
|
+
|
|
26
|
+
const sortedExtraGroups = Object.entries(extraGroups).sort(([rankA], [rankB]) => rankA - rankB)
|
|
27
|
+
|
|
28
|
+
sortedExtraGroups.forEach(([_, group]) => {
|
|
29
|
+
group.sort((a, b) => a.rank - b.rank)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
options = sortedExtraGroups.flatMap(([, group]) => group)
|
|
33
|
+
|
|
34
|
+
if (isCartProduct) {
|
|
35
|
+
const ingredients = JSON.parse(JSON.stringify(Object.values(product.ingredients ?? {})))
|
|
36
|
+
options = options.map(option => {
|
|
37
|
+
option.suboptions = Object.values(option.suboptions ?? {})
|
|
38
|
+
return option
|
|
39
|
+
})
|
|
40
|
+
return {
|
|
41
|
+
...productInfo,
|
|
42
|
+
ingredients,
|
|
43
|
+
options
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { ...product, options }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<>
|
|
51
|
+
{
|
|
52
|
+
UIComponent && (
|
|
53
|
+
<UIComponent
|
|
54
|
+
{...props}
|
|
55
|
+
productInfo={productInfo()}
|
|
56
|
+
/>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
</>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
ProductItemAccordion.propTypes = {
|
|
64
|
+
/**
|
|
65
|
+
* UI Component, this must be containt all graphic elements and use parent props
|
|
66
|
+
*/
|
|
67
|
+
UIComponent: PropTypes.elementType,
|
|
68
|
+
/**
|
|
69
|
+
* product object to render UI
|
|
70
|
+
*/
|
|
71
|
+
product: PropTypes.object.isRequired
|
|
72
|
+
}
|
package/src/index.js
CHANGED
|
@@ -60,6 +60,7 @@ import { ProductForm } from './components/ProductForm'
|
|
|
60
60
|
import { ProductShare } from './components/ProductShare'
|
|
61
61
|
import { ProductImages } from './components/ProductImages'
|
|
62
62
|
import { ProductIngredient } from './components/ProductIngredient'
|
|
63
|
+
import { ProductItemAccordion } from './components/ProductItemAccordion'
|
|
63
64
|
import { ProductOption } from './components/ProductOption'
|
|
64
65
|
import { ProductOptionSuboption } from './components/ProductOptionSuboption'
|
|
65
66
|
import { ProductsList } from './components/ProductsList'
|
|
@@ -236,6 +237,7 @@ export {
|
|
|
236
237
|
ProductShare,
|
|
237
238
|
ProductImages,
|
|
238
239
|
ProductIngredient,
|
|
240
|
+
ProductItemAccordion,
|
|
239
241
|
ProductOption,
|
|
240
242
|
ProductOptionSuboption,
|
|
241
243
|
ProductsList,
|