@athoscommerce/snap-preact 1.2.3-beta.4 → 1.2.3-beta.6
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/README.md +16 -0
- package/dist/cjs/components/src/components/Atoms/TemplateSelect/TemplateSelect.d.ts +3 -3
- package/dist/cjs/components/src/components/Atoms/TemplateSelect/TemplateSelect.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Atoms/TemplateSelect/TemplateSelect.js +7 -8
- package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts +1 -1
- package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.js +3 -3
- package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts +2 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +24 -25
- package/dist/cjs/components/src/components/Molecules/Filter/Filter.d.ts +1 -1
- package/dist/cjs/components/src/components/Molecules/Filter/Filter.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/Result/Result.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/Result/Result.js +11 -6
- package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.d.ts +4 -1
- package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.js +3 -3
- package/dist/cjs/components/src/components/Molecules/TemplatesEditor/Components/AbstractedControls.js +5 -5
- package/dist/cjs/components/src/components/Molecules/TemplatesEditor/Components/Control.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/TemplatesEditor/Components/Control.js +31 -31
- package/dist/cjs/components/src/components/Molecules/TemplatesEditor/TemplatesEditor.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/TemplatesEditor/TemplatesEditor.js +22 -36
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.d.ts +7 -0
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.js +638 -431
- package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.js +4 -3
- package/dist/cjs/components/src/components/Organisms/Chat/MessageText.d.ts +3 -1
- package/dist/cjs/components/src/components/Organisms/Chat/MessageText.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Organisms/Chat/MessageText.js +22 -19
- package/dist/cjs/components/src/components/Organisms/Chat/MessageUser.d.ts +3 -1
- package/dist/cjs/components/src/components/Organisms/Chat/MessageUser.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Organisms/Chat/MessageUser.js +39 -21
- package/dist/cjs/components/src/components/Organisms/Chat/ResultsDisplay.d.ts +1 -1
- package/dist/cjs/components/src/components/Organisms/Chat/ResultsDisplay.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Organisms/Chat/ResultsDisplay.js +7 -11
- package/dist/cjs/components/src/components/Organisms/FilterSummary/FilterSummary.d.ts +2 -2
- package/dist/cjs/components/src/components/Organisms/FilterSummary/FilterSummary.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Organisms/ProductQuickView/ProductQuickView.d.ts +11 -0
- package/dist/cjs/components/src/components/Organisms/ProductQuickView/ProductQuickView.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Organisms/ProductQuickView/ProductQuickView.js +461 -0
- package/dist/cjs/components/src/components/Organisms/ProductQuickView/index.d.ts +2 -0
- package/dist/cjs/components/src/components/Organisms/ProductQuickView/index.d.ts.map +1 -0
- package/dist/cjs/components/src/components/Organisms/ProductQuickView/index.js +17 -0
- package/dist/cjs/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Templates/AutocompleteModal/AutocompleteModal.js +0 -2
- package/dist/cjs/components/src/hooks/useAcRenderedInput.d.ts.map +1 -1
- package/dist/cjs/components/src/hooks/useAcRenderedInput.js +65 -15
- package/dist/cjs/components/src/hooks/useMediaQuery.d.ts.map +1 -1
- package/dist/cjs/components/src/hooks/useMediaQuery.js +3 -1
- package/dist/cjs/components/src/index.d.ts +1 -0
- package/dist/cjs/components/src/index.d.ts.map +1 -1
- package/dist/cjs/components/src/index.js +1 -0
- package/dist/cjs/components/src/providers/theme.d.ts +1 -1
- package/dist/cjs/components/src/providers/theme.d.ts.map +1 -1
- package/dist/cjs/components/src/themes/base/base.js +3 -3
- package/dist/cjs/components/src/utilities/Colour/Colour.d.ts +11 -0
- package/dist/cjs/components/src/utilities/Colour/Colour.d.ts.map +1 -1
- package/dist/cjs/components/src/utilities/Colour/Colour.js +32 -0
- package/dist/cjs/src/Instantiators/RecommendationInstantiator.d.ts +3 -1
- package/dist/cjs/src/Instantiators/RecommendationInstantiator.d.ts.map +1 -1
- package/dist/cjs/src/Instantiators/RecommendationInstantiator.js +162 -123
- package/dist/cjs/src/Snap.d.ts +1 -1
- package/dist/cjs/src/Snap.d.ts.map +1 -1
- package/dist/cjs/src/Snap.js +18 -6
- package/dist/cjs/src/SnapHybrid.d.ts.map +1 -1
- package/dist/cjs/src/Templates/SnapTemplates.d.ts +13 -72
- package/dist/cjs/src/Templates/SnapTemplates.d.ts.map +1 -1
- package/dist/cjs/src/Templates/SnapTemplates.js +123 -72
- package/dist/cjs/src/Templates/Stores/TargetStore.d.ts +7 -6
- package/dist/cjs/src/Templates/Stores/TargetStore.d.ts.map +1 -1
- package/dist/cjs/src/Templates/Stores/TargetStore.js +14 -8
- package/dist/cjs/src/Templates/Stores/TemplateEditor/TemplateEditorStore.d.ts +58 -8
- package/dist/cjs/src/Templates/Stores/TemplateEditor/TemplateEditorStore.d.ts.map +1 -1
- package/dist/cjs/src/Templates/Stores/TemplateEditor/TemplateEditorStore.js +467 -96
- package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/autocompleteControllerUI.d.ts +1 -0
- package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/autocompleteControllerUI.d.ts.map +1 -1
- package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/autocompleteControllerUI.js +123 -70
- package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/configUI.d.ts.map +1 -1
- package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/configUI.js +9 -3
- package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/searchControllerUI.d.ts +1 -0
- package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/searchControllerUI.d.ts.map +1 -1
- package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/searchControllerUI.js +86 -1
- package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/themeUI.d.ts.map +1 -1
- package/dist/cjs/src/Templates/Stores/TemplateEditor/uiAbstractions/themeUI.js +33 -14
- package/dist/cjs/src/Templates/Stores/TemplateStore.d.ts +93 -30
- package/dist/cjs/src/Templates/Stores/TemplateStore.d.ts.map +1 -1
- package/dist/cjs/src/Templates/Stores/TemplateStore.js +33 -41
- package/dist/cjs/src/Templates/Stores/ThemeStore.d.ts +2 -8
- package/dist/cjs/src/Templates/Stores/ThemeStore.d.ts.map +1 -1
- package/dist/cjs/src/Templates/Stores/ThemeStore.js +3 -28
- package/dist/cjs/src/Templates/index.d.ts +1 -1
- package/dist/cjs/src/Templates/index.d.ts.map +1 -1
- package/dist/cjs/src/create/createChatController.js +1 -1
- package/dist/cjs/src/index.d.ts +1 -0
- package/dist/cjs/src/index.d.ts.map +1 -1
- package/dist/cjs/src/setupEvents.d.ts +13 -0
- package/dist/cjs/src/setupEvents.d.ts.map +1 -1
- package/dist/cjs/src/setupEvents.js +56 -8
- package/dist/cjs/src/types.d.ts +3 -1
- package/dist/cjs/src/types.d.ts.map +1 -1
- package/dist/cjs/src/utils/combineMerge.d.ts +2 -0
- package/dist/cjs/src/utils/combineMerge.d.ts.map +1 -0
- package/dist/cjs/src/utils/combineMerge.js +22 -0
- package/dist/cjs/src/utils/index.d.ts +1 -0
- package/dist/cjs/src/utils/index.d.ts.map +1 -1
- package/dist/cjs/src/utils/index.js +3 -1
- package/dist/esm/components/src/components/Atoms/TemplateSelect/TemplateSelect.d.ts +3 -3
- package/dist/esm/components/src/components/Atoms/TemplateSelect/TemplateSelect.d.ts.map +1 -1
- package/dist/esm/components/src/components/Atoms/TemplateSelect/TemplateSelect.js +7 -8
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts +1 -1
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.js +3 -3
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts +2 -0
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +24 -26
- package/dist/esm/components/src/components/Molecules/Filter/Filter.d.ts +1 -1
- package/dist/esm/components/src/components/Molecules/Filter/Filter.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/Result/Result.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/Result/Result.js +9 -4
- package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.d.ts +4 -1
- package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.js +3 -3
- package/dist/esm/components/src/components/Molecules/TemplatesEditor/Components/AbstractedControls.js +5 -5
- package/dist/esm/components/src/components/Molecules/TemplatesEditor/Components/Control.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/TemplatesEditor/Components/Control.js +29 -29
- package/dist/esm/components/src/components/Molecules/TemplatesEditor/TemplatesEditor.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/TemplatesEditor/TemplatesEditor.js +22 -35
- package/dist/esm/components/src/components/Organisms/Chat/Chat.d.ts +7 -0
- package/dist/esm/components/src/components/Organisms/Chat/Chat.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/Chat.js +557 -359
- package/dist/esm/components/src/components/Organisms/Chat/ChatResult.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/ChatResult.js +4 -3
- package/dist/esm/components/src/components/Organisms/Chat/MessageText.d.ts +3 -1
- package/dist/esm/components/src/components/Organisms/Chat/MessageText.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/MessageText.js +21 -19
- package/dist/esm/components/src/components/Organisms/Chat/MessageUser.d.ts +3 -1
- package/dist/esm/components/src/components/Organisms/Chat/MessageUser.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/MessageUser.js +36 -21
- package/dist/esm/components/src/components/Organisms/Chat/ResultsDisplay.d.ts +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/ResultsDisplay.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/ResultsDisplay.js +7 -11
- package/dist/esm/components/src/components/Organisms/FilterSummary/FilterSummary.d.ts +2 -2
- package/dist/esm/components/src/components/Organisms/FilterSummary/FilterSummary.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/ProductQuickView/ProductQuickView.d.ts +11 -0
- package/dist/esm/components/src/components/Organisms/ProductQuickView/ProductQuickView.d.ts.map +1 -0
- package/dist/esm/components/src/components/Organisms/ProductQuickView/ProductQuickView.js +436 -0
- package/dist/esm/components/src/components/Organisms/ProductQuickView/index.d.ts +2 -0
- package/dist/esm/components/src/components/Organisms/ProductQuickView/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Organisms/ProductQuickView/index.js +1 -0
- package/dist/esm/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts.map +1 -1
- package/dist/esm/components/src/components/Templates/AutocompleteModal/AutocompleteModal.js +0 -2
- package/dist/esm/components/src/hooks/useAcRenderedInput.d.ts.map +1 -1
- package/dist/esm/components/src/hooks/useAcRenderedInput.js +61 -11
- package/dist/esm/components/src/hooks/useMediaQuery.d.ts.map +1 -1
- package/dist/esm/components/src/hooks/useMediaQuery.js +3 -1
- package/dist/esm/components/src/index.d.ts +1 -0
- package/dist/esm/components/src/index.d.ts.map +1 -1
- package/dist/esm/components/src/index.js +1 -0
- package/dist/esm/components/src/providers/theme.d.ts +1 -1
- package/dist/esm/components/src/providers/theme.d.ts.map +1 -1
- package/dist/esm/components/src/themes/base/base.js +3 -3
- package/dist/esm/components/src/utilities/Colour/Colour.d.ts +11 -0
- package/dist/esm/components/src/utilities/Colour/Colour.d.ts.map +1 -1
- package/dist/esm/components/src/utilities/Colour/Colour.js +30 -0
- package/dist/esm/src/Instantiators/RecommendationInstantiator.d.ts +3 -1
- package/dist/esm/src/Instantiators/RecommendationInstantiator.d.ts.map +1 -1
- package/dist/esm/src/Instantiators/RecommendationInstantiator.js +131 -84
- package/dist/esm/src/Snap.d.ts +1 -1
- package/dist/esm/src/Snap.d.ts.map +1 -1
- package/dist/esm/src/Snap.js +21 -6
- package/dist/esm/src/SnapHybrid.d.ts.map +1 -1
- package/dist/esm/src/Templates/SnapTemplates.d.ts +13 -72
- package/dist/esm/src/Templates/SnapTemplates.d.ts.map +1 -1
- package/dist/esm/src/Templates/SnapTemplates.js +137 -78
- package/dist/esm/src/Templates/Stores/TargetStore.d.ts +7 -6
- package/dist/esm/src/Templates/Stores/TargetStore.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/TargetStore.js +14 -8
- package/dist/esm/src/Templates/Stores/TemplateEditor/TemplateEditorStore.d.ts +58 -8
- package/dist/esm/src/Templates/Stores/TemplateEditor/TemplateEditorStore.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/TemplateEditor/TemplateEditorStore.js +447 -89
- package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/autocompleteControllerUI.d.ts +1 -0
- package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/autocompleteControllerUI.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/autocompleteControllerUI.js +118 -66
- package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/configUI.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/configUI.js +9 -3
- package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/searchControllerUI.d.ts +1 -0
- package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/searchControllerUI.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/searchControllerUI.js +82 -1
- package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/themeUI.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/TemplateEditor/uiAbstractions/themeUI.js +27 -8
- package/dist/esm/src/Templates/Stores/TemplateStore.d.ts +93 -30
- package/dist/esm/src/Templates/Stores/TemplateStore.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/TemplateStore.js +29 -38
- package/dist/esm/src/Templates/Stores/ThemeStore.d.ts +2 -8
- package/dist/esm/src/Templates/Stores/ThemeStore.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/ThemeStore.js +3 -26
- package/dist/esm/src/Templates/index.d.ts +1 -1
- package/dist/esm/src/Templates/index.d.ts.map +1 -1
- package/dist/esm/src/create/createChatController.js +1 -1
- package/dist/esm/src/index.d.ts +1 -0
- package/dist/esm/src/index.d.ts.map +1 -1
- package/dist/esm/src/setupEvents.d.ts +13 -0
- package/dist/esm/src/setupEvents.d.ts.map +1 -1
- package/dist/esm/src/setupEvents.js +25 -8
- package/dist/esm/src/types.d.ts +3 -1
- package/dist/esm/src/types.d.ts.map +1 -1
- package/dist/esm/src/utils/combineMerge.d.ts +2 -0
- package/dist/esm/src/utils/combineMerge.d.ts.map +1 -0
- package/dist/esm/src/utils/combineMerge.js +16 -0
- package/dist/esm/src/utils/index.d.ts +1 -0
- package/dist/esm/src/utils/index.d.ts.map +1 -1
- package/dist/esm/src/utils/index.js +1 -0
- package/package.json +20 -14
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ProductQuickView = void 0;
|
|
18
|
+
var jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
19
|
+
var hooks_1 = require("preact/hooks");
|
|
20
|
+
var mobx_react_lite_1 = require("mobx-react-lite");
|
|
21
|
+
var react_1 = require("@emotion/react");
|
|
22
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
23
|
+
var Overlay_1 = require("../../Atoms/Overlay");
|
|
24
|
+
var Image_1 = require("../../Atoms/Image");
|
|
25
|
+
var Button_1 = require("../../Atoms/Button");
|
|
26
|
+
var Price_1 = require("../../Atoms/Price");
|
|
27
|
+
var Icon_1 = require("../../Atoms/Icon");
|
|
28
|
+
var providers_1 = require("../../../providers");
|
|
29
|
+
var utilities_1 = require("../../../utilities");
|
|
30
|
+
// Fields that have dedicated rendering on the product card; skip them in the info table.
|
|
31
|
+
var CARD_FIELDS = new Set([
|
|
32
|
+
'name',
|
|
33
|
+
'brand',
|
|
34
|
+
'price',
|
|
35
|
+
'msrp',
|
|
36
|
+
'imageUrl',
|
|
37
|
+
'thumbnailImageUrl',
|
|
38
|
+
'secureImageUrl',
|
|
39
|
+
'secureThumbnailImageUrl',
|
|
40
|
+
'url',
|
|
41
|
+
'addToCartUrl',
|
|
42
|
+
'uid',
|
|
43
|
+
'sku',
|
|
44
|
+
'parentId',
|
|
45
|
+
'parentImageUrl',
|
|
46
|
+
'description',
|
|
47
|
+
'caption',
|
|
48
|
+
'popularity',
|
|
49
|
+
'stockMessage',
|
|
50
|
+
]);
|
|
51
|
+
// Preferred ordering for the structured info table — anything else is appended after.
|
|
52
|
+
var PREFERRED_INFO_ORDER = ['material', 'fit', 'color', 'sizes', 'size', 'category', 'rating', 'availability'];
|
|
53
|
+
var FEATURE_KEYS = ['features', 'feature_list', 'productFeatures', 'product_features', 'highlights'];
|
|
54
|
+
var formatLabel = function (key) {
|
|
55
|
+
return key
|
|
56
|
+
.replace(/[_-]+/g, ' ')
|
|
57
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
58
|
+
.trim();
|
|
59
|
+
};
|
|
60
|
+
var stripHtml = function (str) { return str.replace(/<[^>]*>/g, ''); };
|
|
61
|
+
var formatValue = function (value) {
|
|
62
|
+
if (Array.isArray(value)) {
|
|
63
|
+
return stripHtml(value.filter(function (v) { return v != null && v !== ''; }).join(', '));
|
|
64
|
+
}
|
|
65
|
+
if (value == null)
|
|
66
|
+
return '';
|
|
67
|
+
// Upstream sometimes ships array fields as JSON-encoded strings (e.g. `'["VersaWearCo"]'`).
|
|
68
|
+
// Detect and unwrap before stringifying so the raw brackets/quotes don't leak into the UI.
|
|
69
|
+
if (typeof value === 'string') {
|
|
70
|
+
var trimmed = value.trim();
|
|
71
|
+
if ((trimmed.startsWith('[') && trimmed.endsWith(']')) || (trimmed.startsWith('{') && trimmed.endsWith('}'))) {
|
|
72
|
+
try {
|
|
73
|
+
var parsed = JSON.parse(trimmed);
|
|
74
|
+
if (Array.isArray(parsed)) {
|
|
75
|
+
return stripHtml(parsed.filter(function (v) { return v != null && v !== ''; }).join(', '));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (_a) {
|
|
79
|
+
// fall through — value wasn't valid JSON, just treat it as a string
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return stripHtml(String(value));
|
|
84
|
+
};
|
|
85
|
+
var collectFeatures = function (display) {
|
|
86
|
+
var attributes = (display === null || display === void 0 ? void 0 : display.attributes) || {};
|
|
87
|
+
for (var _i = 0, FEATURE_KEYS_1 = FEATURE_KEYS; _i < FEATURE_KEYS_1.length; _i++) {
|
|
88
|
+
var key = FEATURE_KEYS_1[_i];
|
|
89
|
+
var raw = attributes[key];
|
|
90
|
+
if (Array.isArray(raw) && raw.length > 0) {
|
|
91
|
+
return raw.map(function (v) { return String(v); }).filter(Boolean);
|
|
92
|
+
}
|
|
93
|
+
if (typeof raw === 'string' && raw.trim()) {
|
|
94
|
+
return raw
|
|
95
|
+
.split(/\r?\n|,/)
|
|
96
|
+
.map(function (v) { return v.trim(); })
|
|
97
|
+
.filter(Boolean);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return [];
|
|
101
|
+
};
|
|
102
|
+
var collectInfoRows = function (display, displayFields) {
|
|
103
|
+
var _a;
|
|
104
|
+
var core = ((_a = display === null || display === void 0 ? void 0 : display.mappings) === null || _a === void 0 ? void 0 : _a.core) || {};
|
|
105
|
+
var attributes = (display === null || display === void 0 ? void 0 : display.attributes) || {};
|
|
106
|
+
var filterByDisplayFields = displayFields && displayFields.length > 0;
|
|
107
|
+
var displayFieldsLower = filterByDisplayFields ? displayFields.map(function (f) { return f.toLowerCase(); }) : [];
|
|
108
|
+
var merged = {};
|
|
109
|
+
// When displayFields is specified, include matching core fields that are normally skipped.
|
|
110
|
+
if (filterByDisplayFields) {
|
|
111
|
+
Object.entries(core).forEach(function (_a) {
|
|
112
|
+
var key = _a[0], value = _a[1];
|
|
113
|
+
if (displayFieldsLower.includes(key.toLowerCase()) && value != null) {
|
|
114
|
+
merged[key] = value;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
// Pull selected core fields (rating + availability) regardless.
|
|
119
|
+
if (core.rating != null) {
|
|
120
|
+
var rating = core.rating;
|
|
121
|
+
var ratingCount = core.ratingCount;
|
|
122
|
+
merged.rating = ratingCount ? "".concat(rating, "/5.0 (").concat(ratingCount, " reviews)") : "".concat(rating, "/5.0");
|
|
123
|
+
}
|
|
124
|
+
if (core.available != null) {
|
|
125
|
+
merged.availability = core.available ? 'In Stock' : 'Out of Stock';
|
|
126
|
+
}
|
|
127
|
+
// Merge product attributes, skipping ones already shown on the card and the feature lists.
|
|
128
|
+
Object.entries(attributes).forEach(function (_a) {
|
|
129
|
+
var key = _a[0], value = _a[1];
|
|
130
|
+
if (!filterByDisplayFields && CARD_FIELDS.has(key))
|
|
131
|
+
return;
|
|
132
|
+
if (FEATURE_KEYS.includes(key))
|
|
133
|
+
return;
|
|
134
|
+
var formatted = formatValue(value);
|
|
135
|
+
if (!formatted)
|
|
136
|
+
return;
|
|
137
|
+
merged[key] = formatted;
|
|
138
|
+
});
|
|
139
|
+
var seen = new Set();
|
|
140
|
+
var ordered = [];
|
|
141
|
+
PREFERRED_INFO_ORDER.forEach(function (preferred) {
|
|
142
|
+
var match = Object.keys(merged).find(function (k) { return k.toLowerCase() === preferred; });
|
|
143
|
+
if (match && !seen.has(match)) {
|
|
144
|
+
seen.add(match);
|
|
145
|
+
ordered.push({ key: match, rawKey: match, label: formatLabel(match), value: formatValue(merged[match]) });
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
Object.keys(merged).forEach(function (key) {
|
|
149
|
+
if (seen.has(key))
|
|
150
|
+
return;
|
|
151
|
+
seen.add(key);
|
|
152
|
+
ordered.push({ key: key, rawKey: key, label: formatLabel(key), value: formatValue(merged[key]) });
|
|
153
|
+
});
|
|
154
|
+
if (filterByDisplayFields) {
|
|
155
|
+
var filtered = ordered.filter(function (row) { return displayFieldsLower.includes(row.rawKey.toLowerCase()); });
|
|
156
|
+
filtered.sort(function (a, b) { return displayFieldsLower.indexOf(a.rawKey.toLowerCase()) - displayFieldsLower.indexOf(b.rawKey.toLowerCase()); });
|
|
157
|
+
return filtered;
|
|
158
|
+
}
|
|
159
|
+
return ordered;
|
|
160
|
+
};
|
|
161
|
+
var defaultStyles = function () {
|
|
162
|
+
return (0, react_1.css)({
|
|
163
|
+
// Fixed viewport-level wrapper that hosts both the backdrop and the centered panel.
|
|
164
|
+
position: 'fixed',
|
|
165
|
+
inset: 0,
|
|
166
|
+
zIndex: 10004,
|
|
167
|
+
display: 'flex',
|
|
168
|
+
alignItems: 'center',
|
|
169
|
+
justifyContent: 'center',
|
|
170
|
+
'.ss__product-quick-view__panel': {
|
|
171
|
+
background: '#fff',
|
|
172
|
+
borderRadius: '8px',
|
|
173
|
+
padding: '1.5em',
|
|
174
|
+
maxWidth: '760px',
|
|
175
|
+
width: '90vw',
|
|
176
|
+
maxHeight: '85vh',
|
|
177
|
+
overflowY: 'auto',
|
|
178
|
+
position: 'relative',
|
|
179
|
+
boxShadow: '0 10px 40px rgba(0, 0, 0, 0.2)',
|
|
180
|
+
zIndex: 10004,
|
|
181
|
+
display: 'flex',
|
|
182
|
+
flexDirection: 'column',
|
|
183
|
+
gap: '1em',
|
|
184
|
+
},
|
|
185
|
+
'.ss__product-quick-view__close': {
|
|
186
|
+
position: 'absolute',
|
|
187
|
+
top: '0.75em',
|
|
188
|
+
right: '0.75em',
|
|
189
|
+
cursor: 'pointer',
|
|
190
|
+
padding: '4px',
|
|
191
|
+
zIndex: 1,
|
|
192
|
+
},
|
|
193
|
+
'.ss__product-quick-view__error': {
|
|
194
|
+
padding: '0.75em 1em',
|
|
195
|
+
background: '#fee',
|
|
196
|
+
color: '#a00',
|
|
197
|
+
borderRadius: '4px',
|
|
198
|
+
},
|
|
199
|
+
'.ss__product-quick-view__loading': {
|
|
200
|
+
padding: '2em',
|
|
201
|
+
textAlign: 'center',
|
|
202
|
+
color: '#6A7282',
|
|
203
|
+
},
|
|
204
|
+
'.ss__product-quick-view__body': {
|
|
205
|
+
display: 'flex',
|
|
206
|
+
gap: '1.5em',
|
|
207
|
+
alignItems: 'flex-start',
|
|
208
|
+
flexWrap: 'wrap',
|
|
209
|
+
},
|
|
210
|
+
'.ss__product-quick-view__left': {
|
|
211
|
+
flex: '0 0 auto',
|
|
212
|
+
width: '40%',
|
|
213
|
+
maxWidth: '280px',
|
|
214
|
+
minWidth: '180px',
|
|
215
|
+
display: 'flex',
|
|
216
|
+
flexDirection: 'column',
|
|
217
|
+
gap: '0.75em',
|
|
218
|
+
// On narrow viewports the body wraps to stack vertically — let the image column
|
|
219
|
+
// stretch full-width so the image doesn't sit awkwardly at a fixed 40%/280px.
|
|
220
|
+
// The flex wraps once the panel can't fit the 280px left + gap + 320px right basis,
|
|
221
|
+
// which lands around a 680px viewport given the 90vw panel and 1.5em padding.
|
|
222
|
+
'@media (max-width: 700px)': {
|
|
223
|
+
width: '100%',
|
|
224
|
+
maxWidth: 'none',
|
|
225
|
+
minWidth: 0,
|
|
226
|
+
},
|
|
227
|
+
'.ss__product-quick-view__left__image': {
|
|
228
|
+
width: '100%',
|
|
229
|
+
objectFit: 'contain',
|
|
230
|
+
borderRadius: '0.33em',
|
|
231
|
+
overflow: 'hidden',
|
|
232
|
+
},
|
|
233
|
+
'.ss__product-quick-view__left__actions': {
|
|
234
|
+
display: 'flex',
|
|
235
|
+
flexDirection: 'column',
|
|
236
|
+
gap: '0.5em',
|
|
237
|
+
'.ss__product-quick-view__left__actions__go-to-product': {
|
|
238
|
+
textAlign: 'center',
|
|
239
|
+
a: {
|
|
240
|
+
fontSize: '1em',
|
|
241
|
+
textDecoration: 'underline',
|
|
242
|
+
cursor: 'pointer',
|
|
243
|
+
color: '#374151',
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
'.ss__product-quick-view__left__actions__add-to-cart .ss__button': {
|
|
247
|
+
width: '100%',
|
|
248
|
+
// Center the button text — the Button atom defaults to inline-flex with
|
|
249
|
+
// alignItems:center only, so longer labels would otherwise stay left-aligned.
|
|
250
|
+
justifyContent: 'center',
|
|
251
|
+
textAlign: 'center',
|
|
252
|
+
background: '#253B80',
|
|
253
|
+
color: '#fff',
|
|
254
|
+
border: '1px solid #253B80',
|
|
255
|
+
fontWeight: 'bold',
|
|
256
|
+
padding: '0.6em 0.75em',
|
|
257
|
+
'&:not(.ss__button--disabled):hover': {
|
|
258
|
+
background: '#1e3068',
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
'.ss__product-quick-view__right': {
|
|
264
|
+
flex: '1 1 320px',
|
|
265
|
+
minWidth: 0,
|
|
266
|
+
display: 'flex',
|
|
267
|
+
flexDirection: 'column',
|
|
268
|
+
gap: '1em',
|
|
269
|
+
'.ss__product-quick-view__title': {
|
|
270
|
+
display: 'flex',
|
|
271
|
+
flexDirection: 'column',
|
|
272
|
+
gap: '0.25em',
|
|
273
|
+
'.ss__product-quick-view__title__name': {
|
|
274
|
+
fontWeight: 'bold',
|
|
275
|
+
fontSize: '1.25em',
|
|
276
|
+
lineHeight: 1.3,
|
|
277
|
+
a: { color: 'inherit', textDecoration: 'none', '&:hover': { textDecoration: 'underline' } },
|
|
278
|
+
},
|
|
279
|
+
'.ss__product-quick-view__title__brand': {
|
|
280
|
+
fontSize: '0.9em',
|
|
281
|
+
color: '#6A7282',
|
|
282
|
+
},
|
|
283
|
+
'.ss__product-quick-view__title__price': {
|
|
284
|
+
fontWeight: 'bold',
|
|
285
|
+
fontSize: '1.15em',
|
|
286
|
+
display: 'flex',
|
|
287
|
+
gap: '0.5em',
|
|
288
|
+
alignItems: 'center',
|
|
289
|
+
marginTop: '0.25em',
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
'.ss__product-quick-view__variants': {
|
|
294
|
+
'.ss__product-quick-view__variants__label': {
|
|
295
|
+
fontWeight: 600,
|
|
296
|
+
fontSize: '0.9em',
|
|
297
|
+
color: '#374151',
|
|
298
|
+
textTransform: 'uppercase',
|
|
299
|
+
marginBottom: '0.5em',
|
|
300
|
+
},
|
|
301
|
+
'.ss__product-quick-view__variants__swatches': {
|
|
302
|
+
display: 'flex',
|
|
303
|
+
flexWrap: 'wrap',
|
|
304
|
+
gap: '0.5em',
|
|
305
|
+
'.ss__product-quick-view__variants__swatch': {
|
|
306
|
+
display: 'flex',
|
|
307
|
+
flexDirection: 'column',
|
|
308
|
+
alignItems: 'center',
|
|
309
|
+
gap: '0.25em',
|
|
310
|
+
cursor: 'pointer',
|
|
311
|
+
padding: '0.25em',
|
|
312
|
+
borderRadius: '0.5em',
|
|
313
|
+
border: '2px solid transparent',
|
|
314
|
+
transition: 'border-color 0.15s ease',
|
|
315
|
+
'&:hover': { borderColor: '#253B80' },
|
|
316
|
+
'&.ss__product-quick-view__variants__swatch--selected': {
|
|
317
|
+
borderColor: '#253B80',
|
|
318
|
+
borderWidth: '3px',
|
|
319
|
+
padding: '0.15em',
|
|
320
|
+
},
|
|
321
|
+
'&.ss__product-quick-view__variants__swatch--unavailable': {
|
|
322
|
+
opacity: 0.4,
|
|
323
|
+
},
|
|
324
|
+
'.ss__product-quick-view__variants__swatch__image': {
|
|
325
|
+
width: '48px',
|
|
326
|
+
height: '48px',
|
|
327
|
+
objectFit: 'cover',
|
|
328
|
+
borderRadius: '50%',
|
|
329
|
+
border: '1px solid #E5E7EB',
|
|
330
|
+
},
|
|
331
|
+
'.ss__product-quick-view__variants__swatch__value': {
|
|
332
|
+
fontSize: '0.75em',
|
|
333
|
+
color: '#374151',
|
|
334
|
+
textAlign: 'center',
|
|
335
|
+
maxWidth: '60px',
|
|
336
|
+
overflow: 'hidden',
|
|
337
|
+
textOverflow: 'ellipsis',
|
|
338
|
+
whiteSpace: 'nowrap',
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
'.ss__product-quick-view__section': {
|
|
344
|
+
'.ss__product-quick-view__section__title': {
|
|
345
|
+
fontWeight: 600,
|
|
346
|
+
fontSize: '0.9em',
|
|
347
|
+
color: '#374151',
|
|
348
|
+
marginBottom: '0.4em',
|
|
349
|
+
},
|
|
350
|
+
'.ss__product-quick-view__section__table': {
|
|
351
|
+
width: '100%',
|
|
352
|
+
borderCollapse: 'collapse',
|
|
353
|
+
fontSize: '0.9em',
|
|
354
|
+
tr: {
|
|
355
|
+
borderBottom: '1px solid #E5E7EB',
|
|
356
|
+
},
|
|
357
|
+
td: {
|
|
358
|
+
padding: '0.4em 0',
|
|
359
|
+
verticalAlign: 'top',
|
|
360
|
+
wordBreak: 'break-word',
|
|
361
|
+
overflowWrap: 'anywhere',
|
|
362
|
+
},
|
|
363
|
+
'td:first-of-type': {
|
|
364
|
+
color: '#6A7282',
|
|
365
|
+
width: '40%',
|
|
366
|
+
},
|
|
367
|
+
'td:last-of-type': {
|
|
368
|
+
textAlign: 'right',
|
|
369
|
+
color: '#374151',
|
|
370
|
+
},
|
|
371
|
+
'.ss__product-quick-view__section__table__availability--in-stock': {
|
|
372
|
+
color: '#10B981',
|
|
373
|
+
},
|
|
374
|
+
'.ss__product-quick-view__section__table__availability--out-of-stock': {
|
|
375
|
+
color: '#DC2626',
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
'.ss__product-quick-view__section__description': {
|
|
379
|
+
fontSize: '0.9em',
|
|
380
|
+
color: '#374151',
|
|
381
|
+
lineHeight: 1.5,
|
|
382
|
+
},
|
|
383
|
+
'.ss__product-quick-view__section__features': {
|
|
384
|
+
margin: 0,
|
|
385
|
+
padding: '0 0 0 1.25em',
|
|
386
|
+
fontSize: '0.9em',
|
|
387
|
+
listStyle: 'disc',
|
|
388
|
+
li: {
|
|
389
|
+
padding: '0.2em 0',
|
|
390
|
+
color: '#374151',
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
});
|
|
395
|
+
};
|
|
396
|
+
exports.ProductQuickView = (0, mobx_react_lite_1.observer)(function (properties) {
|
|
397
|
+
var _a;
|
|
398
|
+
var globalTheme = (0, providers_1.useTheme)();
|
|
399
|
+
var globalTreePath = (0, providers_1.useTreePath)();
|
|
400
|
+
var defaultProps = {
|
|
401
|
+
treePath: globalTreePath,
|
|
402
|
+
};
|
|
403
|
+
var props = (0, utilities_1.mergeProps)('productQuickView', globalTheme, defaultProps, properties);
|
|
404
|
+
var controller = props.controller, displayFields = props.displayFields, className = props.className, internalClassName = props.internalClassName;
|
|
405
|
+
var store = (_a = controller === null || controller === void 0 ? void 0 : controller.store) === null || _a === void 0 ? void 0 : _a.productQuickView;
|
|
406
|
+
if (!store)
|
|
407
|
+
return null;
|
|
408
|
+
var product = store.product;
|
|
409
|
+
var error = store.error;
|
|
410
|
+
var loading = store.loading;
|
|
411
|
+
var open = product !== null;
|
|
412
|
+
var close = function () { return store.clear(); };
|
|
413
|
+
var styling = (0, utilities_1.mergeStyles)(props, defaultStyles);
|
|
414
|
+
// Lock body scroll while the quickview is open.
|
|
415
|
+
(0, hooks_1.useEffect)(function () {
|
|
416
|
+
if (!open)
|
|
417
|
+
return;
|
|
418
|
+
var previousOverflow = document.body.style.overflow;
|
|
419
|
+
document.body.style.overflow = 'hidden';
|
|
420
|
+
return function () {
|
|
421
|
+
document.body.style.overflow = previousOverflow;
|
|
422
|
+
};
|
|
423
|
+
}, [open]);
|
|
424
|
+
if (!open)
|
|
425
|
+
return null;
|
|
426
|
+
return ((0, jsx_runtime_1.jsxs)("div", __assign({ className: (0, classnames_1.default)('ss__product-quick-view', className, internalClassName) }, styling, { children: [(0, jsx_runtime_1.jsx)(Overlay_1.Overlay, { active: true, color: "rgba(0,0,0,0.7)", onClick: close }), (0, jsx_runtime_1.jsxs)("div", { className: "ss__product-quick-view__panel", children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__close", onClick: close, role: "button", "aria-label": "Close", children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: "close-thin", size: "16px" }) }), product ? ((0, jsx_runtime_1.jsx)(ProductQuickViewBody, { product: product, loading: loading, error: error, controller: controller, displayFields: displayFields })) : ((0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__loading", children: "Loading..." }))] })] })));
|
|
427
|
+
});
|
|
428
|
+
var ProductQuickViewBody = (0, mobx_react_lite_1.observer)(function (props) {
|
|
429
|
+
var _a;
|
|
430
|
+
var product = props.product, loading = props.loading, error = props.error, controller = props.controller, displayFields = props.displayFields;
|
|
431
|
+
var displayed = product.display;
|
|
432
|
+
var displayedCore = ((_a = displayed.mappings) === null || _a === void 0 ? void 0 : _a.core) || {};
|
|
433
|
+
var variants = product.variants;
|
|
434
|
+
var selections = (variants === null || variants === void 0 ? void 0 : variants.selections) || [];
|
|
435
|
+
var displayedData = {
|
|
436
|
+
mappings: displayed.mappings,
|
|
437
|
+
attributes: displayed.attributes || {},
|
|
438
|
+
};
|
|
439
|
+
var allInfoRows = collectInfoRows(displayedData, displayFields);
|
|
440
|
+
var descriptionRow = allInfoRows.find(function (row) { return row.rawKey.toLowerCase() === 'description'; });
|
|
441
|
+
var infoRows = allInfoRows.filter(function (row) { return row.rawKey.toLowerCase() !== 'description'; });
|
|
442
|
+
var features = collectFeatures(displayedData);
|
|
443
|
+
// `addToCart` exists on Recommendation/Chat controllers but not on Search/Autocomplete.
|
|
444
|
+
var supportsAddToCart = typeof (controller === null || controller === void 0 ? void 0 : controller.addToCart) === 'function';
|
|
445
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [error && (0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__error", children: error }), (0, jsx_runtime_1.jsxs)("div", { className: "ss__product-quick-view__body", children: [(0, jsx_runtime_1.jsxs)("div", { className: "ss__product-quick-view__left", children: [displayedCore.imageUrl ? ((0, jsx_runtime_1.jsx)(Image_1.Image, { className: "ss__product-quick-view__left__image", src: displayedCore.imageUrl, alt: displayedCore.name || '' })) : null, (0, jsx_runtime_1.jsxs)("div", { className: "ss__product-quick-view__left__actions", children: [supportsAddToCart && ((0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__left__actions__add-to-cart", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { content: 'Add to Cart', onClick: function () {
|
|
446
|
+
var _a, _b, _c;
|
|
447
|
+
(_c = (_b = (_a = controller === null || controller === void 0 ? void 0 : controller.track) === null || _a === void 0 ? void 0 : _a.product) === null || _b === void 0 ? void 0 : _b.addToCart) === null || _c === void 0 ? void 0 : _c.call(_b, product);
|
|
448
|
+
controller.addToCart(product);
|
|
449
|
+
} }) })), displayedCore.url && ((0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__left__actions__go-to-product", children: (0, jsx_runtime_1.jsx)("a", { href: displayedCore.url, onClick: function (e) { var _a, _b, _c; return (_c = (_b = (_a = controller === null || controller === void 0 ? void 0 : controller.track) === null || _a === void 0 ? void 0 : _a.product) === null || _b === void 0 ? void 0 : _b.click) === null || _c === void 0 ? void 0 : _c.call(_b, e, product); }, target: "_blank", rel: "noopener noreferrer", children: "Go to product" }) }))] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "ss__product-quick-view__right", children: [(0, jsx_runtime_1.jsxs)("div", { className: "ss__product-quick-view__title", children: [displayedCore.name && ((0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__title__name", children: displayedCore.url ? ((0, jsx_runtime_1.jsx)("a", { href: displayedCore.url, onClick: function (e) { var _a, _b, _c; return (_c = (_b = (_a = controller === null || controller === void 0 ? void 0 : controller.track) === null || _a === void 0 ? void 0 : _a.product) === null || _b === void 0 ? void 0 : _b.click) === null || _c === void 0 ? void 0 : _c.call(_b, e, product); }, target: "_blank", rel: "noopener noreferrer", children: formatValue(displayedCore.name) })) : (formatValue(displayedCore.name)) })), displayedCore.brand != null && formatValue(displayedCore.brand) && ((0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__title__brand", children: formatValue(displayedCore.brand) })), displayedCore.price != null && ((0, jsx_runtime_1.jsxs)("div", { className: "ss__product-quick-view__title__price", children: [displayedCore.msrp != null && Number(displayedCore.msrp) > Number(displayedCore.price) && ((0, jsx_runtime_1.jsx)(Price_1.Price, { value: displayedCore.msrp, lineThrough: true })), (0, jsx_runtime_1.jsx)(Price_1.Price, { value: displayedCore.price })] }))] }), selections.length > 0 && ((0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__variants", children: selections.map(function (selection) { return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "ss__product-quick-view__variants__label", children: [formatLabel(selection.field), " (", selection.values.length, ")"] }), (0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__variants__swatches", children: selection.values.map(function (selectionValue) {
|
|
450
|
+
var _a;
|
|
451
|
+
var isUnavailable = !selectionValue.available;
|
|
452
|
+
var isSelected = ((_a = selection.selected) === null || _a === void 0 ? void 0 : _a.value) === selectionValue.value;
|
|
453
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('ss__product-quick-view__variants__swatch', {
|
|
454
|
+
'ss__product-quick-view__variants__swatch--selected': isSelected,
|
|
455
|
+
'ss__product-quick-view__variants__swatch--unavailable': isUnavailable,
|
|
456
|
+
}), title: selectionValue.value, onClick: function () { return selection.select(selectionValue.value); }, children: [selectionValue.thumbnailImageUrl ? ((0, jsx_runtime_1.jsx)(Image_1.Image, { className: "ss__product-quick-view__variants__swatch__image", src: selectionValue.thumbnailImageUrl, alt: selectionValue.value })) : null, (0, jsx_runtime_1.jsx)("span", { className: "ss__product-quick-view__variants__swatch__value", children: selectionValue.value })] }, selectionValue.value));
|
|
457
|
+
}) })] }, selection.field)); }) })), infoRows.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: "ss__product-quick-view__section", children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__section__title", children: "Product Information" }), (0, jsx_runtime_1.jsx)("table", { className: "ss__product-quick-view__section__table", children: (0, jsx_runtime_1.jsx)("tbody", { children: infoRows.map(function (row) { return ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("td", { children: row.label }), (0, jsx_runtime_1.jsx)("td", { children: row.rawKey === 'availability' ? ((0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)({
|
|
458
|
+
'ss__product-quick-view__section__table__availability--in-stock': row.value === 'In Stock',
|
|
459
|
+
'ss__product-quick-view__section__table__availability--out-of-stock': row.value === 'Out of Stock',
|
|
460
|
+
}), children: row.value === 'In Stock' ? "\u2713 ".concat(row.value) : row.value })) : row.rawKey.toLowerCase() === 'price' ? ((0, jsx_runtime_1.jsxs)("span", { style: { display: 'flex', gap: '0.5em', alignItems: 'center', justifyContent: 'flex-end' }, children: [displayedCore.msrp != null && Number(displayedCore.msrp) > Number(row.value) && ((0, jsx_runtime_1.jsx)(Price_1.Price, { value: Number(displayedCore.msrp), lineThrough: true })), (0, jsx_runtime_1.jsx)(Price_1.Price, { value: Number(row.value) })] })) : (row.value) })] }, row.key)); }) }) })] })), descriptionRow && ((0, jsx_runtime_1.jsxs)("div", { className: "ss__product-quick-view__section", children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__section__title", children: "Description" }), (0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__section__description", children: descriptionRow.value })] })), features.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: "ss__product-quick-view__section", children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__section__title", children: "Features" }), (0, jsx_runtime_1.jsx)("ul", { className: "ss__product-quick-view__section__features", children: features.map(function (feature, idx) { return ((0, jsx_runtime_1.jsx)("li", { children: feature }, idx)); }) })] })), loading && selections.length === 0 && infoRows.length === 0 && !descriptionRow && features.length === 0 && ((0, jsx_runtime_1.jsx)("div", { className: "ss__product-quick-view__loading", children: "Loading product details..." }))] })] })] }));
|
|
461
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Organisms/ProductQuickView/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ProductQuickView"), exports);
|
package/dist/cjs/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteModal.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Templates/AutocompleteModal/AutocompleteModal.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAAE,cAAc,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAsB,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"AutocompleteModal.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Templates/AutocompleteModal/AutocompleteModal.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAAE,cAAc,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAsB,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AA4DjG,eAAO,MAAM,iBAAiB,gBAAyB,sBAAsB;;CAiK3E,CAAC;AAQH,MAAM,MAAM,sBAAsB,GAAG;IACpC,UAAU,EAAE,sBAAsB,CAAC;IACnC,eAAe,CAAC,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC;CAC7C,GAAG,oCAAoC,GACvC,IAAI,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;AAEzC,MAAM,MAAM,oCAAoC,GAAG;IAClD,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,uBAAuB,CAAC"}
|
|
@@ -40,7 +40,6 @@ var defaultStyles = function (_a) {
|
|
|
40
40
|
right: '0',
|
|
41
41
|
top: '0',
|
|
42
42
|
zIndex: 1001,
|
|
43
|
-
pointerEvents: 'none',
|
|
44
43
|
'& .ss__autocomplete-modal__inner': {
|
|
45
44
|
position: 'absolute',
|
|
46
45
|
left: 0,
|
|
@@ -55,7 +54,6 @@ var defaultStyles = function (_a) {
|
|
|
55
54
|
width: width,
|
|
56
55
|
height: height,
|
|
57
56
|
maxWidth: '100vw',
|
|
58
|
-
pointerEvents: 'auto',
|
|
59
57
|
},
|
|
60
58
|
'& .ss__overlay': {
|
|
61
59
|
zIndex: 1000,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAcRenderedInput.d.ts","sourceRoot":"","sources":["../../../../../components/src/hooks/useAcRenderedInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAY,UAAU,EAAa,MAAM,cAAc,CAAC;AAE/D,wBAAgB,kBAAkB,CAAC,EAClC,KAAK,EACL,UAAU,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,SAAS,GACT,EAAE;IACF,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,sBAAsB,CAAC;IACnC,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACtD,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACtC,
|
|
1
|
+
{"version":3,"file":"useAcRenderedInput.d.ts","sourceRoot":"","sources":["../../../../../components/src/hooks/useAcRenderedInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAY,UAAU,EAAa,MAAM,cAAc,CAAC;AAE/D,wBAAgB,kBAAkB,CAAC,EAClC,KAAK,EACL,UAAU,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,SAAS,GACT,EAAE;IACF,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,sBAAsB,CAAC;IACnC,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACtD,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACtC,kBAkHA"}
|
|
@@ -69,40 +69,90 @@ function useAcRenderedInput(_a) {
|
|
|
69
69
|
}); });
|
|
70
70
|
};
|
|
71
71
|
(0, hooks_1.useEffect)(function () {
|
|
72
|
+
// track pointer-initiated focus to avoid rendering the overlay between mousedown and mouseup,
|
|
73
|
+
// which splits the click target to the nearest common ancestor instead of the input element
|
|
74
|
+
var pointerFocus = false;
|
|
75
|
+
var clearPointerFocus = function () {
|
|
76
|
+
pointerFocus = false;
|
|
77
|
+
};
|
|
72
78
|
if (renderInput && buttonSelector) {
|
|
73
|
-
var
|
|
79
|
+
var button_1;
|
|
74
80
|
if (typeof buttonSelector == 'string') {
|
|
75
|
-
|
|
81
|
+
button_1 = document.querySelector(buttonSelector);
|
|
76
82
|
}
|
|
77
83
|
else {
|
|
78
|
-
|
|
84
|
+
button_1 = buttonSelector;
|
|
79
85
|
}
|
|
80
|
-
if (
|
|
81
|
-
|
|
86
|
+
if (button_1) {
|
|
87
|
+
var onMousedown_1 = function () {
|
|
88
|
+
pointerFocus = true;
|
|
89
|
+
};
|
|
90
|
+
var onClickBtn_1 = function (e) {
|
|
91
|
+
pointerFocus = false;
|
|
82
92
|
e.stopPropagation();
|
|
83
93
|
onClick();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
};
|
|
95
|
+
var onFocusBtn_1 = function () {
|
|
96
|
+
if (!pointerFocus) {
|
|
97
|
+
onClick();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
var onSelectBtn_1 = function () { return onClick(); };
|
|
101
|
+
button_1.addEventListener('mousedown', onMousedown_1);
|
|
102
|
+
document.addEventListener('mouseup', clearPointerFocus, true);
|
|
103
|
+
button_1.addEventListener('click', onClickBtn_1);
|
|
104
|
+
button_1.addEventListener('focus', onFocusBtn_1);
|
|
105
|
+
button_1.addEventListener('select', onSelectBtn_1);
|
|
106
|
+
return function () {
|
|
107
|
+
button_1.removeEventListener('mousedown', onMousedown_1);
|
|
108
|
+
document.removeEventListener('mouseup', clearPointerFocus, true);
|
|
109
|
+
button_1.removeEventListener('click', onClickBtn_1);
|
|
110
|
+
button_1.removeEventListener('focus', onFocusBtn_1);
|
|
111
|
+
button_1.removeEventListener('select', onSelectBtn_1);
|
|
112
|
+
};
|
|
87
113
|
}
|
|
88
114
|
}
|
|
89
115
|
else {
|
|
90
116
|
if (setActive) {
|
|
91
|
-
|
|
117
|
+
var onMousedown_2 = function () {
|
|
118
|
+
pointerFocus = true;
|
|
119
|
+
};
|
|
120
|
+
var onClickInput_1 = function (e) {
|
|
121
|
+
pointerFocus = false;
|
|
92
122
|
e.stopPropagation();
|
|
93
123
|
setActive(true);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
124
|
+
};
|
|
125
|
+
var onFocusInput_1 = function () {
|
|
126
|
+
if (!pointerFocus) {
|
|
127
|
+
setActive(true);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
var onSelectInput_1 = function () { return setActive(true); };
|
|
131
|
+
input.addEventListener('mousedown', onMousedown_2);
|
|
132
|
+
document.addEventListener('mouseup', clearPointerFocus, true);
|
|
133
|
+
input.addEventListener('click', onClickInput_1);
|
|
134
|
+
input.addEventListener('focus', onFocusInput_1);
|
|
135
|
+
input.addEventListener('select', onSelectInput_1);
|
|
136
|
+
return function () {
|
|
137
|
+
input.removeEventListener('mousedown', onMousedown_2);
|
|
138
|
+
document.removeEventListener('mouseup', clearPointerFocus, true);
|
|
139
|
+
input.removeEventListener('click', onClickInput_1);
|
|
140
|
+
input.removeEventListener('focus', onFocusInput_1);
|
|
141
|
+
input.removeEventListener('select', onSelectInput_1);
|
|
142
|
+
};
|
|
97
143
|
}
|
|
98
144
|
}
|
|
99
145
|
}, []);
|
|
100
146
|
// this is used to keep the values consistent between the native input and the rendered input
|
|
101
147
|
(0, hooks_1.useEffect)(function () {
|
|
102
|
-
if (input !== _input) {
|
|
103
|
-
|
|
148
|
+
if (input !== _input && _input) {
|
|
149
|
+
var onInput_1 = function () {
|
|
104
150
|
input.value = _input.value;
|
|
105
|
-
}
|
|
151
|
+
};
|
|
152
|
+
_input.addEventListener('input', onInput_1);
|
|
153
|
+
return function () {
|
|
154
|
+
_input.removeEventListener('input', onInput_1);
|
|
155
|
+
};
|
|
106
156
|
}
|
|
107
157
|
}, [_input]);
|
|
108
158
|
return _input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../../../../components/src/hooks/useMediaQuery.tsx"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../../../../components/src/hooks/useMediaQuery.tsx"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAmB/E"}
|
|
@@ -8,12 +8,14 @@ function useMediaQuery(query, runOnCleanup) {
|
|
|
8
8
|
var mediaQuery = window.matchMedia(query);
|
|
9
9
|
var _a = (0, hooks_1.useState)(!!mediaQuery.matches), match = _a[0], setMatch = _a[1];
|
|
10
10
|
(0, hooks_1.useEffect)(function () {
|
|
11
|
+
// sync state immediately in case query changed
|
|
12
|
+
setMatch(!!mediaQuery.matches);
|
|
11
13
|
var handler = function () { return setMatch(!!mediaQuery.matches); };
|
|
12
14
|
mediaQuery.addListener(handler);
|
|
13
15
|
return function () {
|
|
14
16
|
runOnCleanup instanceof Function && runOnCleanup();
|
|
15
17
|
mediaQuery.removeListener(handler);
|
|
16
18
|
};
|
|
17
|
-
}, []);
|
|
19
|
+
}, [query]);
|
|
18
20
|
return match;
|
|
19
21
|
}
|