@constructor-io/constructorio-ui-asa 1.0.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.
Files changed (131) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +253 -0
  3. package/dist/constructorio-ui-asa-bundled.js +33 -0
  4. package/lib/cjs/components/Button/Button.css +61 -0
  5. package/lib/cjs/components/Button/Button.js +12 -0
  6. package/lib/cjs/components/Chat/AiMessage.css +35 -0
  7. package/lib/cjs/components/Chat/AiMessage.js +34 -0
  8. package/lib/cjs/components/Chat/Chat.css +103 -0
  9. package/lib/cjs/components/Chat/Chat.js +34 -0
  10. package/lib/cjs/components/Chat/ChatHeader.css +41 -0
  11. package/lib/cjs/components/Chat/ChatHeader.js +18 -0
  12. package/lib/cjs/components/Chat/ChatInput.css +83 -0
  13. package/lib/cjs/components/Chat/ChatInput.js +30 -0
  14. package/lib/cjs/components/Chat/ChatMessageList.css +23 -0
  15. package/lib/cjs/components/Chat/ChatMessageList.js +46 -0
  16. package/lib/cjs/components/Chat/TypingIndicator.css +51 -0
  17. package/lib/cjs/components/Chat/TypingIndicator.js +14 -0
  18. package/lib/cjs/components/Chat/UserMessage.css +25 -0
  19. package/lib/cjs/components/Chat/UserMessage.js +14 -0
  20. package/lib/cjs/components/Chat/WelcomeScreen.css +205 -0
  21. package/lib/cjs/components/Chat/WelcomeScreen.js +43 -0
  22. package/lib/cjs/components/CioAsaProvider/CioAsaProvider.js +23 -0
  23. package/lib/cjs/components/ResultsBlock/ResultsBlock.css +217 -0
  24. package/lib/cjs/components/ResultsBlock/ResultsBlock.js +73 -0
  25. package/lib/cjs/components/ResultsBlock/constants.js +11 -0
  26. package/lib/cjs/components/ResultsBlock/renderProductCard.js +21 -0
  27. package/lib/cjs/components/icons/ArrowRightIcon.js +9 -0
  28. package/lib/cjs/components/icons/ChatBubbleDarkIcon.js +9 -0
  29. package/lib/cjs/components/icons/ChatBubbleLightIcon.js +9 -0
  30. package/lib/cjs/components/icons/SendArrowIcon.js +9 -0
  31. package/lib/cjs/components/icons/SendPlaneIcon.js +9 -0
  32. package/lib/cjs/components/icons/index.js +16 -0
  33. package/lib/cjs/constants.js +6 -0
  34. package/lib/cjs/hooks/asaStreamHandlers.js +34 -0
  35. package/lib/cjs/hooks/useAsaResults.js +120 -0
  36. package/lib/cjs/hooks/useCioAsaContext.js +15 -0
  37. package/lib/cjs/hooks/useCioClient.js +21 -0
  38. package/lib/cjs/hooks/useFocusTrap.js +38 -0
  39. package/lib/cjs/hooks/useMessageInput.js +22 -0
  40. package/lib/cjs/hooks/useRequestConfigs.js +27 -0
  41. package/lib/cjs/index.js +24 -0
  42. package/lib/cjs/styles.css +34 -0
  43. package/lib/cjs/types.js +6 -0
  44. package/lib/cjs/utils/formatters.js +11 -0
  45. package/lib/cjs/utils/productNormalizer.js +20 -0
  46. package/lib/cjs/utils/translate.js +30 -0
  47. package/lib/cjs/utils/typeHelpers.js +2 -0
  48. package/lib/cjs/utils/urlHelpers.js +102 -0
  49. package/lib/cjs/version.js +3 -0
  50. package/lib/mjs/components/Button/Button.css +61 -0
  51. package/lib/mjs/components/Button/Button.js +8 -0
  52. package/lib/mjs/components/Chat/AiMessage.css +35 -0
  53. package/lib/mjs/components/Chat/AiMessage.js +29 -0
  54. package/lib/mjs/components/Chat/Chat.css +103 -0
  55. package/lib/mjs/components/Chat/Chat.js +31 -0
  56. package/lib/mjs/components/Chat/ChatHeader.css +41 -0
  57. package/lib/mjs/components/Chat/ChatHeader.js +14 -0
  58. package/lib/mjs/components/Chat/ChatInput.css +83 -0
  59. package/lib/mjs/components/Chat/ChatInput.js +26 -0
  60. package/lib/mjs/components/Chat/ChatMessageList.css +23 -0
  61. package/lib/mjs/components/Chat/ChatMessageList.js +41 -0
  62. package/lib/mjs/components/Chat/TypingIndicator.css +51 -0
  63. package/lib/mjs/components/Chat/TypingIndicator.js +10 -0
  64. package/lib/mjs/components/Chat/UserMessage.css +25 -0
  65. package/lib/mjs/components/Chat/UserMessage.js +10 -0
  66. package/lib/mjs/components/Chat/WelcomeScreen.css +205 -0
  67. package/lib/mjs/components/Chat/WelcomeScreen.js +38 -0
  68. package/lib/mjs/components/CioAsaProvider/CioAsaProvider.js +19 -0
  69. package/lib/mjs/components/ResultsBlock/ResultsBlock.css +217 -0
  70. package/lib/mjs/components/ResultsBlock/ResultsBlock.js +76 -0
  71. package/lib/mjs/components/ResultsBlock/constants.js +8 -0
  72. package/lib/mjs/components/ResultsBlock/renderProductCard.js +17 -0
  73. package/lib/mjs/components/icons/ArrowRightIcon.js +5 -0
  74. package/lib/mjs/components/icons/ChatBubbleDarkIcon.js +5 -0
  75. package/lib/mjs/components/icons/ChatBubbleLightIcon.js +5 -0
  76. package/lib/mjs/components/icons/SendArrowIcon.js +5 -0
  77. package/lib/mjs/components/icons/SendPlaneIcon.js +5 -0
  78. package/lib/mjs/components/icons/index.js +5 -0
  79. package/lib/mjs/constants.js +3 -0
  80. package/lib/mjs/hooks/asaStreamHandlers.js +39 -0
  81. package/lib/mjs/hooks/useAsaResults.js +118 -0
  82. package/lib/mjs/hooks/useCioAsaContext.js +11 -0
  83. package/lib/mjs/hooks/useCioClient.js +23 -0
  84. package/lib/mjs/hooks/useFocusTrap.js +35 -0
  85. package/lib/mjs/hooks/useMessageInput.js +19 -0
  86. package/lib/mjs/hooks/useRequestConfigs.js +24 -0
  87. package/lib/mjs/index.js +11 -0
  88. package/lib/mjs/styles.css +34 -0
  89. package/lib/mjs/types.js +2 -0
  90. package/lib/mjs/utils/formatters.js +7 -0
  91. package/lib/mjs/utils/productNormalizer.js +15 -0
  92. package/lib/mjs/utils/translate.js +26 -0
  93. package/lib/mjs/utils/typeHelpers.js +1 -0
  94. package/lib/mjs/utils/urlHelpers.js +90 -0
  95. package/lib/mjs/version.js +1 -0
  96. package/lib/types/components/Button/Button.d.ts +12 -0
  97. package/lib/types/components/Chat/AiMessage.d.ts +12 -0
  98. package/lib/types/components/Chat/Chat.d.ts +38 -0
  99. package/lib/types/components/Chat/ChatHeader.d.ts +12 -0
  100. package/lib/types/components/Chat/ChatInput.d.ts +13 -0
  101. package/lib/types/components/Chat/ChatMessageList.d.ts +24 -0
  102. package/lib/types/components/Chat/TypingIndicator.d.ts +10 -0
  103. package/lib/types/components/Chat/UserMessage.d.ts +12 -0
  104. package/lib/types/components/Chat/WelcomeScreen.d.ts +16 -0
  105. package/lib/types/components/CioAsaProvider/CioAsaProvider.d.ts +3 -0
  106. package/lib/types/components/ResultsBlock/ResultsBlock.d.ts +32 -0
  107. package/lib/types/components/ResultsBlock/constants.d.ts +3 -0
  108. package/lib/types/components/ResultsBlock/renderProductCard.d.ts +12 -0
  109. package/lib/types/components/icons/ArrowRightIcon.d.ts +2 -0
  110. package/lib/types/components/icons/ChatBubbleDarkIcon.d.ts +2 -0
  111. package/lib/types/components/icons/ChatBubbleLightIcon.d.ts +2 -0
  112. package/lib/types/components/icons/SendArrowIcon.d.ts +2 -0
  113. package/lib/types/components/icons/SendPlaneIcon.d.ts +2 -0
  114. package/lib/types/components/icons/index.d.ts +5 -0
  115. package/lib/types/constants.d.ts +2 -0
  116. package/lib/types/hooks/asaStreamHandlers.d.ts +8 -0
  117. package/lib/types/hooks/useAsaResults.d.ts +2 -0
  118. package/lib/types/hooks/useCioAsaContext.d.ts +9 -0
  119. package/lib/types/hooks/useCioClient.d.ts +6 -0
  120. package/lib/types/hooks/useFocusTrap.d.ts +11 -0
  121. package/lib/types/hooks/useMessageInput.d.ts +15 -0
  122. package/lib/types/hooks/useRequestConfigs.d.ts +7 -0
  123. package/lib/types/index.d.ts +12 -0
  124. package/lib/types/types.d.ts +178 -0
  125. package/lib/types/utils/formatters.d.ts +1 -0
  126. package/lib/types/utils/productNormalizer.d.ts +14 -0
  127. package/lib/types/utils/translate.d.ts +2 -0
  128. package/lib/types/utils/typeHelpers.d.ts +4 -0
  129. package/lib/types/utils/urlHelpers.d.ts +8 -0
  130. package/lib/types/version.d.ts +2 -0
  131. package/package.json +150 -0
@@ -0,0 +1,205 @@
1
+ .cio-asa-welcome-screen {
2
+ display: flex;
3
+ flex-direction: column;
4
+ flex: 1;
5
+ padding: 20px;
6
+ position: relative;
7
+ }
8
+
9
+ .cio-asa-welcome-screen__close {
10
+ position: absolute;
11
+ top: 16px;
12
+ right: 20px;
13
+ background: none;
14
+ border: none;
15
+ cursor: pointer;
16
+ padding: 4px;
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+ color: #1a1a1a;
21
+ font-size: 20px;
22
+ line-height: 1;
23
+ z-index: 1;
24
+ }
25
+
26
+ .cio-asa-welcome-screen__close:hover {
27
+ opacity: 0.7;
28
+ }
29
+
30
+ .cio-asa-welcome-screen__content {
31
+ display: flex;
32
+ flex-direction: column;
33
+ align-items: center;
34
+ justify-content: center;
35
+ flex: 1;
36
+ width: 100%;
37
+ max-width: 504px;
38
+ margin: 0 auto;
39
+ }
40
+
41
+ @media (max-width: 768px) {
42
+ .cio-asa-welcome-screen__content {
43
+ max-width: 366px;
44
+ }
45
+ }
46
+
47
+ .cio-asa-welcome-screen__title {
48
+ font-weight: 400;
49
+ font-size: 26px;
50
+ line-height: 32px;
51
+ text-align: center;
52
+ letter-spacing: -0.005em;
53
+ font-feature-settings: 'tnum' on, 'lnum' on;
54
+ color: #000000;
55
+ margin: 0;
56
+ align-self: stretch;
57
+ }
58
+
59
+ .cio-asa-welcome-screen__input-row {
60
+ display: flex;
61
+ flex-direction: row;
62
+ align-items: center;
63
+ padding: 8px 8px 8px 12px;
64
+ gap: 12px;
65
+ width: 100%;
66
+ height: 40px;
67
+ margin-top: 32px;
68
+ background: #ffffff;
69
+ border: 1px solid #DEE0E3;
70
+ box-shadow: inset 1px 1px 2px rgba(18, 18, 105, 0.1), inset 0px 1px 4px rgba(18, 18, 105, 0.05), inset 1px 1px 1px rgba(18, 18, 105, 0.05);
71
+ border-radius: 4px;
72
+ box-sizing: border-box;
73
+ }
74
+
75
+ .cio-asa-welcome-screen__input {
76
+ flex: 1;
77
+ padding: 0;
78
+ border: none;
79
+ font-weight: 400;
80
+ font-size: 14px;
81
+ line-height: 16px;
82
+ letter-spacing: -0.005em;
83
+ color: #0F1324;
84
+ outline: none;
85
+ background: transparent;
86
+ }
87
+
88
+ .cio-asa-welcome-screen__input::placeholder {
89
+ color: rgba(15, 19, 36, 0.7);
90
+ }
91
+
92
+ /* Input states */
93
+ .cio-asa-welcome-screen__input-row:hover {
94
+ border-color: #C8CAD0;
95
+ }
96
+
97
+ .cio-asa-welcome-screen__input-row:focus-within {
98
+ border-color: #A980FF;
99
+ box-shadow: 0px 0px 0px 2px rgba(201, 176, 254, 0.7);
100
+ }
101
+
102
+ .cio-asa-welcome-screen__input-row:active {
103
+ border-color: #000000;
104
+ box-shadow: inset 0px 1px 4px rgba(18, 18, 105, 0.14), inset 2.1px 2px 2px rgba(18, 18, 105, 0.1), inset 0px 1.5px 3px rgba(18, 18, 105, 0.05);
105
+ }
106
+
107
+ .cio-asa-welcome-screen__input-row--disabled {
108
+ border-color: #E9EAEC;
109
+ box-shadow: none;
110
+ pointer-events: none;
111
+ }
112
+
113
+ .cio-asa-welcome-screen__input-row--disabled .cio-asa-welcome-screen__send-btn {
114
+ background: #E9EAEC;
115
+ box-shadow: none;
116
+ color: rgba(10, 15, 41, 0.25);
117
+ cursor: default;
118
+ }
119
+
120
+ .cio-asa-welcome-screen__input-row--disabled .cio-asa-welcome-screen__send-btn svg path {
121
+ fill: rgba(10, 15, 41, 0.25);
122
+ }
123
+
124
+ .cio-asa-welcome-screen__send-btn {
125
+ display: flex;
126
+ flex-direction: row;
127
+ justify-content: center;
128
+ align-items: center;
129
+ padding: 0 8px;
130
+ gap: 6px;
131
+ height: 24px;
132
+ background: #14151A;
133
+ box-shadow: 0px 0.4px 1px rgba(18, 18, 105, 0.13), 0px 0.9px 6px rgba(18, 18, 105, 0.05), 0px 1px 3px rgba(18, 18, 105, 0.05);
134
+ border-radius: 4px;
135
+ border: none;
136
+ cursor: pointer;
137
+ font-weight: 500;
138
+ font-size: 13px;
139
+ line-height: 16px;
140
+ letter-spacing: -0.005em;
141
+ font-feature-settings: 'tnum' on, 'lnum' on;
142
+ color: #ffffff;
143
+ white-space: nowrap;
144
+ flex-shrink: 0;
145
+ }
146
+
147
+ .cio-asa-welcome-screen__send-btn:hover {
148
+ background: #333;
149
+ }
150
+
151
+ .cio-asa-welcome-screen__suggestions {
152
+ display: grid;
153
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
154
+ column-gap: 16px;
155
+ row-gap: 11px;
156
+ width: 100%;
157
+ margin-top: 20px;
158
+ animation: cio-asa-fade-in 0.5s ease 0.5s both;
159
+ }
160
+
161
+ .cio-asa-welcome-screen__suggestion-chip {
162
+ display: flex;
163
+ flex-direction: column;
164
+ justify-content: center;
165
+ align-items: center;
166
+ padding: 18px 16px;
167
+ background: #ffffff;
168
+ box-shadow: 0px 0.4px 1px rgba(18, 18, 105, 0.13), 0px 0.9px 6px rgba(18, 18, 105, 0.05), 0px 1px 3px rgba(18, 18, 105, 0.05);
169
+ border-radius: 12px;
170
+ border: 1px solid transparent;
171
+ cursor: pointer;
172
+ font-weight: 400;
173
+ font-size: 12px;
174
+ line-height: 20px;
175
+ text-align: center;
176
+ color: #343434;
177
+ box-sizing: border-box;
178
+ transition: background-color 0.2s, box-shadow 0.2s, border-color 0.2s;
179
+ }
180
+
181
+ .cio-asa-welcome-screen__suggestion-chip:hover {
182
+ background: #ffffff;
183
+ border-color: #ffffff;
184
+ box-shadow: 0px 6px 14px rgba(18, 18, 105, 0.11), 0px 2px 4px rgba(18, 18, 105, 0.0716748), 0px 1px 2px rgba(18, 18, 105, 0.055);
185
+ }
186
+
187
+ .cio-asa-welcome-screen__suggestion-chip:active {
188
+ background: #E0E3EB;
189
+ border-color: #DEE0E3;
190
+ box-shadow: inset 1px 1px 2px rgba(18, 18, 105, 0.1), inset 0px 1px 4px rgba(18, 18, 105, 0.05), inset 1px 1px 1px rgba(18, 18, 105, 0.05);
191
+ }
192
+
193
+ .cio-asa-welcome-screen__terms {
194
+ font-size: 11px;
195
+ color: #999;
196
+ text-align: center;
197
+ padding-top: 16px;
198
+ max-width: 504px;
199
+ margin: 0 auto;
200
+ }
201
+
202
+ .cio-asa-welcome-screen__terms a {
203
+ color: #666;
204
+ text-decoration: underline;
205
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importDefault(require("react"));
5
+ const constructorio_ui_components_1 = require("@constructor-io/constructorio-ui-components");
6
+ const icons_1 = require("../icons");
7
+ const translate_1 = tslib_1.__importDefault(require("../../utils/translate"));
8
+ const useMessageInput_1 = tslib_1.__importDefault(require("../../hooks/useMessageInput"));
9
+ const DEFAULT_SUGGESTIONS = [];
10
+ function WelcomeScreen({ suggestions = DEFAULT_SUGGESTIONS, onSend, onClose, termsText, disabled = false, translations, componentOverrides, }) {
11
+ var _a, _b, _c;
12
+ const { value: inputValue, setValue: setInputValue, handleSubmit, handleKeyDown, } = (0, useMessageInput_1.default)({ onSend, isDisabled: disabled });
13
+ const titleRenderProps = {
14
+ text: (0, translate_1.default)('CioAsa.welcome.title', translations),
15
+ };
16
+ const inputRenderProps = {
17
+ value: inputValue,
18
+ onChange: setInputValue,
19
+ onSubmit: handleSubmit,
20
+ placeholder: (0, translate_1.default)('CioAsa.welcome.placeholder', translations),
21
+ isDisabled: disabled,
22
+ };
23
+ const suggestionsRenderProps = {
24
+ suggestions,
25
+ onSuggestionClick: onSend,
26
+ };
27
+ return (react_1.default.createElement("div", { className: 'cio-asa-welcome-screen' },
28
+ onClose && (react_1.default.createElement("button", { type: 'button', className: 'cio-asa-welcome-screen__close', onClick: onClose, "aria-label": (0, translate_1.default)('CioAsa.header.close', translations) }, "\u2715")),
29
+ react_1.default.createElement("div", { className: 'cio-asa-welcome-screen__content' },
30
+ react_1.default.createElement(constructorio_ui_components_1.RenderPropsWrapper, { override: (_a = componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.title) === null || _a === void 0 ? void 0 : _a.reactNode, props: titleRenderProps },
31
+ react_1.default.createElement("h2", { id: 'cio-asa-chat-title', className: 'cio-asa-welcome-screen__title' }, titleRenderProps.text)),
32
+ react_1.default.createElement(constructorio_ui_components_1.RenderPropsWrapper, { override: (_b = componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.input) === null || _b === void 0 ? void 0 : _b.reactNode, props: inputRenderProps },
33
+ react_1.default.createElement("div", { className: `cio-asa-welcome-screen__input-row${disabled ? ' cio-asa-welcome-screen__input-row--disabled' : ''}` },
34
+ react_1.default.createElement("input", { type: 'text', className: 'cio-asa-welcome-screen__input', value: inputValue, onChange: (e) => setInputValue(e.target.value), onKeyDown: handleKeyDown, placeholder: inputRenderProps.placeholder, disabled: disabled, "aria-label": (0, translate_1.default)('CioAsa.welcome.inputAriaLabel', translations) }),
35
+ react_1.default.createElement("button", { type: 'button', className: 'cio-asa-welcome-screen__send-btn', onClick: handleSubmit, disabled: disabled || !inputValue.trim(), "aria-label": (0, translate_1.default)('CioAsa.welcome.sendAriaLabel', translations) },
36
+ (0, translate_1.default)('CioAsa.welcome.sendButton', translations),
37
+ react_1.default.createElement(icons_1.SendPlaneIcon, null)))),
38
+ suggestions.length > 0 && (react_1.default.createElement(constructorio_ui_components_1.RenderPropsWrapper, { override: (_c = componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.suggestedQuestions) === null || _c === void 0 ? void 0 : _c.reactNode, props: suggestionsRenderProps },
39
+ react_1.default.createElement("nav", { className: 'cio-asa-welcome-screen__suggestions', "aria-label": (0, translate_1.default)('CioAsa.welcome.suggestionsAriaLabel', translations) }, suggestions.map((suggestion) => (react_1.default.createElement("button", { key: suggestion, type: 'button', className: 'cio-asa-welcome-screen__suggestion-chip', disabled: disabled, onClick: () => onSend(suggestion) }, suggestion))))))),
40
+ termsText && react_1.default.createElement("div", { className: 'cio-asa-welcome-screen__terms' }, termsText)));
41
+ }
42
+ exports.default = WelcomeScreen;
43
+ WelcomeScreen.displayName = 'WelcomeScreen';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
+ const useCioClient_1 = tslib_1.__importDefault(require("../../hooks/useCioClient"));
6
+ const useCioAsaContext_1 = require("../../hooks/useCioAsaContext");
7
+ const defaultFormatters = tslib_1.__importStar(require("../../utils/formatters"));
8
+ const defaultUrlHelpers = tslib_1.__importStar(require("../../utils/urlHelpers"));
9
+ function CioAsaProvider(props) {
10
+ const { apiKey, formatters, urlHelpers, staticRequestConfigs = { domain: 'chatbot' }, cioClient: customCioClient, children, } = props;
11
+ const [cioClientOptions, setCioClientOptions] = (0, react_1.useState)({});
12
+ const cioClient = (0, useCioClient_1.default)({ apiKey, cioClient: customCioClient, cioClientOptions });
13
+ const contextValue = (0, react_1.useMemo)(() => ({
14
+ cioClient,
15
+ cioClientOptions,
16
+ setCioClientOptions,
17
+ staticRequestConfigs,
18
+ formatters: Object.assign(Object.assign({}, defaultFormatters), formatters),
19
+ urlHelpers: Object.assign(Object.assign({}, defaultUrlHelpers), urlHelpers),
20
+ }), [cioClient, cioClientOptions, formatters, urlHelpers, staticRequestConfigs]);
21
+ return (react_1.default.createElement(useCioAsaContext_1.AsaContext.Provider, { value: contextValue }, typeof children === 'function' ? children(contextValue) : children));
22
+ }
23
+ exports.default = CioAsaProvider;
@@ -0,0 +1,217 @@
1
+ .cio-asa-results-block {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 20px;
5
+ width: 100%;
6
+ }
7
+
8
+ .cio-asa-results-group {
9
+ display: flex;
10
+ flex-direction: column;
11
+ gap: 12px;
12
+ }
13
+
14
+ .cio-asa-results-group__label {
15
+ font-size: 14px;
16
+ font-weight: 600;
17
+ color: #1a1a1a;
18
+ margin: 0;
19
+ }
20
+
21
+ /* Product Card - override ui-components defaults */
22
+ .cio-asa-product-card.cio-product-card {
23
+ display: flex;
24
+ flex-direction: column;
25
+ gap: 6px;
26
+ cursor: pointer;
27
+ width: 100%;
28
+ height: 100%;
29
+ min-width: unset;
30
+ max-width: unset;
31
+ border: none;
32
+ border-radius: 0;
33
+ box-shadow: none;
34
+ padding: 0;
35
+ background: transparent;
36
+ }
37
+
38
+ .cio-asa-product-card .cio-asa-product-card__image-wrapper.cio-product-card-image-section {
39
+ position: relative;
40
+ width: 100%;
41
+ aspect-ratio: var(--cio-asa-image-ratio, 3 / 4);
42
+ border-radius: 6px;
43
+ overflow: hidden;
44
+ background-color: #f3f4f6;
45
+ flex-shrink: 0;
46
+ }
47
+
48
+ .cio-asa-product-card .cio-asa-product-card__image-wrapper .cio-product-card-image {
49
+ width: 100%;
50
+ height: 100%;
51
+ object-fit: cover;
52
+ display: block;
53
+ min-height: unset;
54
+ border-radius: 0;
55
+ }
56
+
57
+ .cio-asa-product-card .cio-asa-product-card__badge {
58
+ position: absolute;
59
+ top: 8px;
60
+ left: 8px;
61
+ display: flex;
62
+ justify-content: center;
63
+ align-items: center;
64
+ padding: 0 4px;
65
+ min-width: 35px;
66
+ max-width: 120px;
67
+ height: 20px;
68
+ background: #dc2626;
69
+ color: #fff;
70
+ font-size: 13px;
71
+ font-weight: 500;
72
+ line-height: 16px;
73
+ text-align: center;
74
+ letter-spacing: -0.005em;
75
+ border-radius: 4px;
76
+ border: none;
77
+ z-index: 1;
78
+ overflow: hidden;
79
+ text-overflow: ellipsis;
80
+ white-space: nowrap;
81
+ }
82
+
83
+ .cio-asa-product-card .cio-asa-product-card__info.cio-product-card-content {
84
+ display: flex;
85
+ flex-direction: column;
86
+ gap: 2px;
87
+ flex: 1;
88
+ padding: 0;
89
+ }
90
+
91
+ .cio-asa-product-card .cio-asa-product-card__name.cio-product-card-title-section {
92
+ font-size: 12px;
93
+ line-height: 1.3;
94
+ color: #1a1a1a;
95
+ display: -webkit-box;
96
+ -webkit-line-clamp: 2;
97
+ -webkit-box-orient: vertical;
98
+ overflow: hidden;
99
+ margin: 0;
100
+ min-height: calc(2 * 12px * 1.3);
101
+ }
102
+
103
+ .cio-asa-product-card__description {
104
+ font-size: 11px;
105
+ line-height: 1.3;
106
+ color: #6b7280;
107
+ display: -webkit-box;
108
+ -webkit-line-clamp: 2;
109
+ -webkit-box-orient: vertical;
110
+ overflow: hidden;
111
+ }
112
+
113
+ .cio-asa-product-card .cio-asa-product-card__price.cio-product-card-price-section {
114
+ display: flex;
115
+ align-items: baseline;
116
+ gap: 4px;
117
+ }
118
+
119
+ .cio-asa-product-card .cio-asa-product-card__price.cio-product-card-price-section span {
120
+ word-spacing: -1ch;
121
+ }
122
+
123
+ /* Sale price (rendered first by library, displayed second) */
124
+ .cio-asa-product-card .cio-asa-product-card__price.cio-product-card-price-section span:first-child {
125
+ font-size: 14px;
126
+ font-weight: 700;
127
+ color: #1a1a1a;
128
+ }
129
+
130
+ .cio-asa-product-card .cio-asa-product-card__price.cio-product-card-price-section span:first-child:not(:only-child) {
131
+ color: #dc2626;
132
+ order: 2;
133
+ }
134
+
135
+ /* Original price (rendered second by library, displayed first) */
136
+ .cio-asa-product-card .cio-asa-product-card__price.cio-product-card-price-section span:last-child:not(:first-child) {
137
+ font-size: 12px;
138
+ color: #9ca3af;
139
+ text-decoration: line-through;
140
+ font-weight: normal;
141
+ order: 1;
142
+ }
143
+
144
+ /* Carousel overrides */
145
+ .cio-asa-results-group [data-slot="carousel-content"] {
146
+ padding: 0 !important;
147
+ }
148
+
149
+ .cio-asa-results-group [data-slot="carousel-item"] {
150
+ min-width: 0 !important;
151
+ align-self: stretch;
152
+ }
153
+
154
+ .cio-asa-results-group [data-slot="carousel-track"] {
155
+ padding-left: 0 !important;
156
+ }
157
+
158
+ /* Add to Cart (per card) */
159
+ .cio-asa-product-card .cio-asa-product-card__add-to-cart.cio-product-card-add-to-cart-btn {
160
+ display: flex;
161
+ flex-direction: row;
162
+ align-items: center;
163
+ justify-content: center;
164
+ gap: 10px;
165
+ padding: 6px 12px;
166
+ font-size: 14px;
167
+ font-weight: 500;
168
+ line-height: 16px;
169
+ letter-spacing: -0.005em;
170
+ color: #14151A;
171
+ background: #f3f4f6;
172
+ border: 1px solid #e5e7eb;
173
+ border-radius: 8px;
174
+ cursor: pointer;
175
+ width: 100%;
176
+ margin-top: auto;
177
+ padding-top: 4px;
178
+ transition: background-color 0.15s;
179
+ }
180
+
181
+ .cio-asa-product-card .cio-asa-product-card__add-to-cart.cio-product-card-add-to-cart-btn::before {
182
+ content: '';
183
+ display: inline-block;
184
+ width: 16px;
185
+ height: 16px;
186
+ flex-shrink: 0;
187
+ background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11.0311 8.66659C11.5311 8.66659 11.9711 8.39325 12.1977 7.97992L14.5844 3.65325C14.8311 3.21325 14.5111 2.66659 14.0044 2.66659H4.13772L3.51105 1.33325H1.33105V2.66659H2.66439L5.06439 7.72659L4.16439 9.35325C3.67772 10.2466 4.31772 11.3333 5.33105 11.3333H13.3311V9.99992H5.33105L6.06439 8.66659H11.0311ZM4.77105 3.99992H12.8711L11.0311 7.33325H6.35105L4.77105 3.99992ZM5.33105 11.9999C4.59772 11.9999 4.00439 12.5999 4.00439 13.3333C4.00439 14.0666 4.59772 14.6666 5.33105 14.6666C6.06439 14.6666 6.66439 14.0666 6.66439 13.3333C6.66439 12.5999 6.06439 11.9999 5.33105 11.9999ZM11.9977 11.9999C11.2644 11.9999 10.6711 12.5999 10.6711 13.3333C10.6711 14.0666 11.2644 14.6666 11.9977 14.6666C12.7311 14.6666 13.3311 14.0666 13.3311 13.3333C13.3311 12.5999 12.7311 11.9999 11.9977 11.9999Z' fill='%230F1324' fill-opacity='0.6'/%3E%3C/svg%3E");
188
+ background-repeat: no-repeat;
189
+ background-size: 16px 16px;
190
+ }
191
+
192
+ .cio-asa-product-card .cio-asa-product-card__add-to-cart.cio-product-card-add-to-cart-btn:hover {
193
+ background: #e5e7eb;
194
+ color: #14151A;
195
+ }
196
+
197
+ /* View More */
198
+ .cio-asa-results-group__view-more {
199
+ display: inline-flex;
200
+ align-items: center;
201
+ gap: 11px;
202
+ font-size: 13px;
203
+ color: #1a1a1a;
204
+ text-decoration: none;
205
+ cursor: pointer;
206
+ background: none;
207
+ border: none;
208
+ padding: 0;
209
+ font-family: inherit;
210
+ width: fit-content;
211
+ }
212
+
213
+ .cio-asa-results-group__view-more-text {
214
+ text-decoration: none;
215
+ border-bottom: 1px solid currentColor;
216
+ line-height: 1.2;
217
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
+ const constructorio_ui_components_1 = require("@constructor-io/constructorio-ui-components");
6
+ const productNormalizer_1 = require("../../utils/productNormalizer");
7
+ const icons_1 = require("../icons");
8
+ const constants_1 = require("./constants");
9
+ const renderProductCard_1 = tslib_1.__importDefault(require("./renderProductCard"));
10
+ require("./ResultsBlock.css");
11
+ function PreviousButton() {
12
+ return null;
13
+ }
14
+ function NextButton() {
15
+ return null;
16
+ }
17
+ function ResultsBlock({ groups, aspectRatio = '3:4', minCardWidth = 150, gap = 12, showTitle = true, viewMoreText = 'View more products', addToCartText = 'Add to cart', saleBadgeText = 'Sale', currency, normalizeItem = productNormalizer_1.normalizeItemToProduct, onProductClick, onAddToCart, onViewMore, componentOverrides, }) {
18
+ var _a, _b;
19
+ const containerRef = (0, react_1.useRef)(null);
20
+ const [slidesToShow, setSlidesToShow] = (0, react_1.useState)(3 + constants_1.PEEK_FRACTION);
21
+ (0, react_1.useEffect)(() => {
22
+ const el = containerRef.current;
23
+ if (!el)
24
+ return undefined;
25
+ const compute = () => {
26
+ const width = el.clientWidth;
27
+ const count = Math.max(1, Math.floor(width / (minCardWidth + gap)));
28
+ setSlidesToShow(count + constants_1.PEEK_FRACTION);
29
+ };
30
+ compute();
31
+ if (typeof ResizeObserver === 'undefined')
32
+ return undefined;
33
+ const ro = new ResizeObserver(compute);
34
+ ro.observe(el);
35
+ return () => ro.disconnect();
36
+ }, [minCardWidth, gap]);
37
+ if (!groups || groups.length === 0)
38
+ return null;
39
+ const renderProductCard = (0, renderProductCard_1.default)({
40
+ currency,
41
+ addToCartText,
42
+ onProductClick,
43
+ onAddToCart,
44
+ componentOverrides: (_b = (_a = componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.carousel) === null || _a === void 0 ? void 0 : _a.item) === null || _b === void 0 ? void 0 : _b.productCard,
45
+ });
46
+ return (react_1.default.createElement("div", { ref: containerRef, className: 'cio-asa-results-block', style: { '--cio-asa-image-ratio': constants_1.aspectRatioMap[aspectRatio] } }, groups.map((groupData, index) => {
47
+ var _a, _b, _c, _d, _e;
48
+ const label = ((_a = groupData.group) === null || _a === void 0 ? void 0 : _a.display_name) || ((_b = groupData.group) === null || _b === void 0 ? void 0 : _b.value) || '';
49
+ const groupKey = `${((_c = groupData.group) === null || _c === void 0 ? void 0 : _c.value) || label}-${index}`;
50
+ const products = groupData.searchResults.map((item) => normalizeItem(item, { saleBadgeText }));
51
+ const titleRenderProps = { label };
52
+ const viewMoreRenderProps = {
53
+ group: groupData.group,
54
+ onClick: () => onViewMore === null || onViewMore === void 0 ? void 0 : onViewMore(groupData.group),
55
+ };
56
+ const userCarousel = componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.carousel;
57
+ const carouselOverrides = Object.assign(Object.assign({ previous: { reactNode: PreviousButton }, next: { reactNode: NextButton } }, userCarousel), { item: Object.assign(Object.assign({}, userCarousel === null || userCarousel === void 0 ? void 0 : userCarousel.item), { productCard: {
58
+ reactNode: renderProductCard,
59
+ } }) });
60
+ return (react_1.default.createElement("div", { className: 'cio-asa-results-group', key: groupKey },
61
+ showTitle && label && (react_1.default.createElement(constructorio_ui_components_1.RenderPropsWrapper, { override: (_d = componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.groupTitle) === null || _d === void 0 ? void 0 : _d.reactNode, props: titleRenderProps },
62
+ react_1.default.createElement("h3", { className: 'cio-asa-results-group__label' }, label))),
63
+ react_1.default.createElement(constructorio_ui_components_1.Carousel, { items: products, loop: false, responsive: {
64
+ 0: { gap, slidesToShow },
65
+ }, componentOverrides: carouselOverrides }),
66
+ onViewMore && (react_1.default.createElement(constructorio_ui_components_1.RenderPropsWrapper, { override: (_e = componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.viewMore) === null || _e === void 0 ? void 0 : _e.reactNode, props: viewMoreRenderProps },
67
+ react_1.default.createElement("button", { type: 'button', className: 'cio-asa-results-group__view-more', onClick: () => onViewMore(groupData.group) },
68
+ react_1.default.createElement("span", { className: 'cio-asa-results-group__view-more-text' }, viewMoreText),
69
+ react_1.default.createElement(icons_1.ArrowRightIcon, null))))));
70
+ })));
71
+ }
72
+ ResultsBlock.displayName = 'ResultsBlock';
73
+ exports.default = ResultsBlock;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.aspectRatioMap = exports.PEEK_FRACTION = void 0;
4
+ exports.PEEK_FRACTION = 0.3;
5
+ exports.aspectRatioMap = {
6
+ '1:1': '1 / 1',
7
+ '3:4': '3 / 4',
8
+ '9:16': '9 / 16',
9
+ '4:3': '4 / 3',
10
+ '16:9': '16 / 9',
11
+ };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importDefault(require("react"));
5
+ const constructorio_ui_components_1 = require("@constructor-io/constructorio-ui-components");
6
+ const constants_1 = require("../../constants");
7
+ function createProductCardRenderer({ currency, addToCartText, onProductClick, onAddToCart, componentOverrides, }) {
8
+ const handleAddToCart = onAddToCart
9
+ ? (_e, product) => onAddToCart(product)
10
+ : undefined;
11
+ return function renderProductCard(renderProps) {
12
+ const product = renderProps.product;
13
+ return (react_1.default.createElement(constructorio_ui_components_1.ProductCard, { product: product, className: 'cio-asa-product-card', onProductClick: onProductClick, onAddToCart: handleAddToCart, addToCartText: addToCartText, componentOverrides: componentOverrides },
14
+ react_1.default.createElement(constructorio_ui_components_1.ProductCard.ImageSection, { className: 'cio-asa-product-card__image-wrapper', imageUrl: product.imageUrl || constants_1.PLACEHOLDER_IMAGE }, product.badge && react_1.default.createElement("span", { className: 'cio-asa-product-card__badge' }, product.badge)),
15
+ react_1.default.createElement(constructorio_ui_components_1.ProductCard.Content, { className: 'cio-asa-product-card__info' },
16
+ react_1.default.createElement(constructorio_ui_components_1.ProductCard.TitleSection, { className: 'cio-asa-product-card__name' }),
17
+ currency && (react_1.default.createElement(constructorio_ui_components_1.ProductCard.PriceSection, { className: 'cio-asa-product-card__price', priceCurrency: currency })),
18
+ onAddToCart && (react_1.default.createElement(constructorio_ui_components_1.ProductCard.AddToCartButton, { className: 'cio-asa-product-card__add-to-cart' })))));
19
+ };
20
+ }
21
+ exports.default = createProductCardRenderer;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importDefault(require("react"));
5
+ function ArrowRightIcon() {
6
+ return (react_1.default.createElement("svg", { width: '10', height: '10', viewBox: '0 0 10 10', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
7
+ react_1.default.createElement("path", { fillRule: 'evenodd', clipRule: 'evenodd', d: 'M8.25979 4.20698L4.63903 0.72032L5.33267 -1.97313e-07L9.84668 4.34682L9.84668 5.06714L5.33267 9.41396L4.63903 8.69364L8.25979 5.20698L-0.000141371 5.20698L-0.000141328 4.20698L8.25979 4.20698Z', fill: 'currentColor' })));
8
+ }
9
+ exports.default = ArrowRightIcon;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importDefault(require("react"));
5
+ function ChatBubbleDarkIcon() {
6
+ return (react_1.default.createElement("svg", { className: 'cio-asa-button__icon', width: '14', height: '14', viewBox: '0 0 14 14', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-hidden": 'true' },
7
+ react_1.default.createElement("path", { d: 'M12.667 3.16699C12.7573 3.16717 12.8328 3.24274 12.833 3.33301V12.126L10.874 10.167H3.33301C3.24263 10.1668 3.16699 10.0904 3.16699 10V9.16699H11.833V3.16699H12.667ZM0.666992 0.5H9.33301C9.42353 0.5 9.5 0.576467 9.5 0.666992V6.66699C9.49982 6.75737 9.42342 6.83301 9.33301 6.83301H2.45996L0.5 8.79297V0.666992C0.5 0.576468 0.576468 0.5 0.666992 0.5ZM0.833008 7.9873L2.32031 6.5H9.16699V0.833008H0.833008V7.9873Z', fill: 'white', stroke: 'white' })));
8
+ }
9
+ exports.default = ChatBubbleDarkIcon;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importDefault(require("react"));
5
+ function ChatBubbleLightIcon() {
6
+ return (react_1.default.createElement("svg", { className: 'cio-asa-button__icon', width: '16', height: '16', viewBox: '0 0 16 16', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-hidden": 'true' },
7
+ react_1.default.createElement("path", { d: 'M14 4.50024C14.0903 4.50043 14.1658 4.57599 14.166 4.66626V13.4592L12.207 11.5002H4.66602C4.57563 11.5001 4.5 11.4237 4.5 11.3333V10.5002H13.166V4.50024H14ZM2 1.83325H10.666C10.7565 1.83325 10.833 1.90972 10.833 2.00024V8.00024C10.8328 8.09063 10.7564 8.16626 10.666 8.16626H3.79297L1.83301 10.1262V2.00024C1.83301 1.90972 1.90948 1.83325 2 1.83325ZM2.16602 9.32056L3.65332 7.83325H10.5V2.16626H2.16602V9.32056Z', fill: 'black', stroke: 'black' })));
8
+ }
9
+ exports.default = ChatBubbleLightIcon;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importDefault(require("react"));
5
+ function SendArrowIcon() {
6
+ return (react_1.default.createElement("svg", { width: '10', height: '11', viewBox: '0 0 10 11', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-hidden": 'true' },
7
+ react_1.default.createElement("path", { d: 'M0.5 5L5 0.5L9.5 5M5 1.125V10.25', stroke: '#0F1324', strokeOpacity: '0.7', strokeLinecap: 'round', strokeLinejoin: 'round' })));
8
+ }
9
+ exports.default = SendArrowIcon;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importDefault(require("react"));
5
+ function SendPlaneIcon() {
6
+ return (react_1.default.createElement("svg", { width: '16', height: '16', viewBox: '0 0 16 16', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', "aria-hidden": 'true' },
7
+ react_1.default.createElement("path", { d: 'M14.8934 7.09539L14.8884 7.0932L1.54219 1.55758C1.42993 1.51059 1.30778 1.49217 1.18666 1.50395C1.06554 1.51573 0.949225 1.55734 0.848125 1.62508C0.741311 1.69507 0.653573 1.79052 0.592805 1.90283C0.532037 2.01515 0.500145 2.14081 0.5 2.26852V5.80883C0.50006 5.98341 0.561019 6.15249 0.67237 6.28695C0.783722 6.4214 0.938491 6.5128 1.11 6.54539L8.38906 7.89133C8.41767 7.89675 8.44348 7.91199 8.46205 7.93441C8.48062 7.95683 8.49078 7.98503 8.49078 8.01414C8.49078 8.04325 8.48062 8.07145 8.46205 8.09387C8.44348 8.11629 8.41767 8.13153 8.38906 8.13695L1.11031 9.48289C0.938851 9.51539 0.784092 9.60667 0.67269 9.741C0.561288 9.87534 0.500219 10.0443 0.5 10.2188V13.7598C0.499917 13.8817 0.530111 14.0018 0.587871 14.1092C0.645632 14.2166 0.729152 14.3079 0.830938 14.3751C0.953375 14.4564 1.09706 14.4999 1.24406 14.5001C1.34626 14.5 1.4474 14.4795 1.54156 14.4398L14.8875 8.9357L14.8934 8.93289C15.0731 8.85569 15.2262 8.72751 15.3337 8.56421C15.4413 8.40092 15.4986 8.20968 15.4986 8.01414C15.4986 7.81861 15.4413 7.62736 15.3337 7.46407C15.2262 7.30077 15.0731 7.1726 14.8934 7.09539Z', fill: 'white' })));
8
+ }
9
+ exports.default = SendPlaneIcon;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ArrowRightIcon = exports.SendPlaneIcon = exports.SendArrowIcon = exports.ChatBubbleLightIcon = exports.ChatBubbleDarkIcon = void 0;
7
+ var ChatBubbleDarkIcon_1 = require("./ChatBubbleDarkIcon");
8
+ Object.defineProperty(exports, "ChatBubbleDarkIcon", { enumerable: true, get: function () { return __importDefault(ChatBubbleDarkIcon_1).default; } });
9
+ var ChatBubbleLightIcon_1 = require("./ChatBubbleLightIcon");
10
+ Object.defineProperty(exports, "ChatBubbleLightIcon", { enumerable: true, get: function () { return __importDefault(ChatBubbleLightIcon_1).default; } });
11
+ var SendArrowIcon_1 = require("./SendArrowIcon");
12
+ Object.defineProperty(exports, "SendArrowIcon", { enumerable: true, get: function () { return __importDefault(SendArrowIcon_1).default; } });
13
+ var SendPlaneIcon_1 = require("./SendPlaneIcon");
14
+ Object.defineProperty(exports, "SendPlaneIcon", { enumerable: true, get: function () { return __importDefault(SendPlaneIcon_1).default; } });
15
+ var ArrowRightIcon_1 = require("./ArrowRightIcon");
16
+ Object.defineProperty(exports, "ArrowRightIcon", { enumerable: true, get: function () { return __importDefault(ArrowRightIcon_1).default; } });