@threekit-tools/treble 0.0.58 → 0.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Treble/Treble.d.ts +6 -0
- package/dist/Treble/Treble.js +16 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/server.d.ts +2 -0
- package/dist/api/server.js +11 -0
- package/dist/components/Cards/index.js +3 -4
- package/dist/components/Dropdown/index.js +6 -10
- package/dist/components/Strips/index.js +3 -4
- package/dist/components/Swatch/index.js +3 -4
- package/dist/components/TextInput/index.d.ts +1 -0
- package/dist/components/TextInput/index.js +2 -2
- package/dist/components/TextInput/textInput.styles.js +1 -1
- package/dist/components/Tiles/index.js +3 -4
- package/dist/components/TilesGroup/index.js +3 -4
- package/dist/components/containers/formInputContainer.d.ts +8 -4
- package/dist/components/containers/formInputContainer.js +10 -15
- package/dist/connection.d.ts +4 -1
- package/dist/connection.js +4 -0
- package/dist/hooks/useAttribute/index.d.ts +2 -2
- package/dist/hooks/useAttribute/index.js +2 -4
- package/dist/hooks/useConfigurator/index.d.ts +2 -2
- package/dist/hooks/useConfigurator/index.js +1 -1
- package/dist/hooks/useProductCache/index.d.ts +14 -0
- package/dist/hooks/useProductCache/index.js +35 -0
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.js +2 -0
- package/dist/http/server.d.ts +14 -0
- package/dist/http/server.js +17 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/store/attributes.d.ts +15 -2
- package/dist/store/attributes.js +20 -12
- package/dist/store/product.d.ts +38 -2
- package/dist/store/product.js +221 -10
- package/dist/store/translations.d.ts +1 -0
- package/dist/store/translations.js +3 -1
- package/dist/store/treble.d.ts +32 -2
- package/dist/store/treble.js +157 -34
- package/dist/threekit.d.ts +16 -1
- package/dist/utils.d.ts +0 -9
- package/dist/utils.js +1 -54
- package/package.json +1 -1
- package/dist/hooks/useArrayAttribute/index.d.ts +0 -2
- package/dist/hooks/useArrayAttribute/index.js +0 -184
package/dist/Treble/Treble.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ interface ITreble {
|
|
|
8
8
|
orgId: string;
|
|
9
9
|
initialConfiguration: IConfiguration;
|
|
10
10
|
}
|
|
11
|
+
interface IEmailShareCredentials {
|
|
12
|
+
to: string;
|
|
13
|
+
from: string;
|
|
14
|
+
templateId: string;
|
|
15
|
+
}
|
|
11
16
|
declare class Treble {
|
|
12
17
|
_api: typeof threekitAPI;
|
|
13
18
|
_player: IThreekitPlayer;
|
|
@@ -23,5 +28,6 @@ declare class Treble {
|
|
|
23
28
|
}>;
|
|
24
29
|
getNestedConfigurator: (address: string | Array<string>) => any;
|
|
25
30
|
resetConfiguration: (configuration?: ISetConfiguration | undefined) => void;
|
|
31
|
+
sendEmail: (credentials: IEmailShareCredentials, templateData: Record<string, any>) => Promise<import("../http/server").IPostEmailResponse>;
|
|
26
32
|
}
|
|
27
33
|
export default Treble;
|
package/dist/Treble/Treble.js
CHANGED
|
@@ -98,6 +98,22 @@ var Treble = /** @class */ (function () {
|
|
|
98
98
|
var updateConfiguration = Object.assign(initialConfiguration, configuration);
|
|
99
99
|
window.threekit.configurator.setConfiguration(updateConfiguration);
|
|
100
100
|
};
|
|
101
|
+
this.sendEmail = function (credentials, templateData) {
|
|
102
|
+
if (!credentials)
|
|
103
|
+
throw new Error('sendEmail is missing credentials object');
|
|
104
|
+
if (!credentials.from.length)
|
|
105
|
+
throw new Error('sendEmail is missing sender email - "From"');
|
|
106
|
+
if (!credentials.to.length)
|
|
107
|
+
throw new Error('sendEmail is missing receivers email - "To"');
|
|
108
|
+
if (!credentials.templateId.length)
|
|
109
|
+
throw new Error('sendEmail is missing the templateId to use - "TemplateId"');
|
|
110
|
+
var data = Object.assign({
|
|
111
|
+
To: credentials.to,
|
|
112
|
+
From: credentials.from,
|
|
113
|
+
TemplateId: credentials.templateId,
|
|
114
|
+
}, { TemplateModel: templateData });
|
|
115
|
+
return api_1.default.server.sendEmail(data);
|
|
116
|
+
};
|
|
101
117
|
// Threekit API
|
|
102
118
|
this._api = api_1.default;
|
|
103
119
|
this._player = player;
|
package/dist/api/index.d.ts
CHANGED
|
@@ -3,11 +3,13 @@ import * as configurations from './configurations';
|
|
|
3
3
|
import * as price from './price';
|
|
4
4
|
import * as orders from './orders';
|
|
5
5
|
import * as catalog from './catalog';
|
|
6
|
+
import * as server from './server';
|
|
6
7
|
declare const _default: {
|
|
7
8
|
products: typeof products;
|
|
8
9
|
configurations: typeof configurations;
|
|
9
10
|
price: typeof price;
|
|
10
11
|
orders: typeof orders;
|
|
11
12
|
catalog: typeof catalog;
|
|
13
|
+
server: typeof server;
|
|
12
14
|
};
|
|
13
15
|
export default _default;
|
package/dist/api/index.js
CHANGED
|
@@ -24,10 +24,12 @@ var configurations = __importStar(require("./configurations"));
|
|
|
24
24
|
var price = __importStar(require("./price"));
|
|
25
25
|
var orders = __importStar(require("./orders"));
|
|
26
26
|
var catalog = __importStar(require("./catalog"));
|
|
27
|
+
var server = __importStar(require("./server"));
|
|
27
28
|
exports.default = {
|
|
28
29
|
products: products,
|
|
29
30
|
configurations: configurations,
|
|
30
31
|
price: price,
|
|
31
32
|
orders: orders,
|
|
32
33
|
catalog: catalog,
|
|
34
|
+
server: server,
|
|
33
35
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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.sendEmail = void 0;
|
|
7
|
+
var http_1 = __importDefault(require("../http"));
|
|
8
|
+
var sendEmail = function (data) {
|
|
9
|
+
return http_1.default.server.postEmail(data);
|
|
10
|
+
};
|
|
11
|
+
exports.sendEmail = sendEmail;
|
|
@@ -38,7 +38,7 @@ var Price = function (props) {
|
|
|
38
38
|
return react_1.default.createElement(cards_styles_1.CardPrice, { className: "".concat(className, " option-price") }, price);
|
|
39
39
|
};
|
|
40
40
|
var Cards = function (props) {
|
|
41
|
-
var title = props.title, description = props.description, options = props.options,
|
|
41
|
+
var title = props.title, description = props.description, options = props.options, customClassName = props.className, showThumbnail = props.showThumbnail, showPrice = props.showPrice, showDescription = props.showDescription;
|
|
42
42
|
var cls = (0, utils_1.generateInputClassName)('cards', customClassName, title);
|
|
43
43
|
return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
|
|
44
44
|
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
@@ -50,10 +50,9 @@ var Cards = function (props) {
|
|
|
50
50
|
imageUrl: !showThumbnail ? undefined : el.imageUrl,
|
|
51
51
|
price: !showPrice ? undefined : el.price,
|
|
52
52
|
description: !showDescription ? undefined : el.description,
|
|
53
|
-
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue;
|
|
54
|
-
var selected = value === optionValue;
|
|
53
|
+
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue, selected = _a.selected, handleSelect = _a.handleSelect;
|
|
55
54
|
var clsOpt = "".concat(cls, "-option option-").concat(i, " ").concat(optionValue).concat(selected ? ' selected' : '');
|
|
56
|
-
return (react_1.default.createElement(cards_styles_1.CardWrapper, { key: i, onClick:
|
|
55
|
+
return (react_1.default.createElement(cards_styles_1.CardWrapper, { key: i, onClick: handleSelect, selected: selected, className: clsOpt },
|
|
57
56
|
react_1.default.createElement(Thumbnail, { imageUrl: imageUrl, color: color, name: name, className: clsOpt }),
|
|
58
57
|
react_1.default.createElement("div", null,
|
|
59
58
|
react_1.default.createElement(Title, { name: name, className: clsOpt }),
|
|
@@ -57,7 +57,7 @@ var Price = function (props) {
|
|
|
57
57
|
return (react_1.default.createElement(dropdown_styles_1.OptionPrice, { className: "".concat(className, " option-price") }, price));
|
|
58
58
|
};
|
|
59
59
|
var Dropdown = function (props) {
|
|
60
|
-
var title = props.title, description = props.description, options = props.options, value = props.value,
|
|
60
|
+
var title = props.title, description = props.description, options = props.options, value = props.value, customClassName = props.className, showThumbnail = props.showThumbnail, showPrice = props.showPrice, showDescription = props.showDescription, dropdownMaxHeight = props.dropdownMaxHeight;
|
|
61
61
|
var _a = (0, react_1.useState)(true), hide = _a[0], setHide = _a[1];
|
|
62
62
|
var ref = (0, react_1.useRef)(null);
|
|
63
63
|
(0, react_1.useEffect)(function () {
|
|
@@ -73,12 +73,6 @@ var Dropdown = function (props) {
|
|
|
73
73
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
74
74
|
};
|
|
75
75
|
}, [hide, ref]);
|
|
76
|
-
var handleClick = function (value) {
|
|
77
|
-
if (!onClick)
|
|
78
|
-
return;
|
|
79
|
-
onClick(value);
|
|
80
|
-
setHide(true);
|
|
81
|
-
};
|
|
82
76
|
var cls = (0, utils_1.generateInputClassName)('dropdown', customClassName, title);
|
|
83
77
|
var selectedOpt = options === null || options === void 0 ? void 0 : options.find(function (el) { return el.value === value; });
|
|
84
78
|
return (react_1.default.createElement("div", { className: cls },
|
|
@@ -105,10 +99,12 @@ var Dropdown = function (props) {
|
|
|
105
99
|
imageUrl: !showThumbnail ? undefined : el.imageUrl,
|
|
106
100
|
price: !showPrice ? undefined : el.price,
|
|
107
101
|
description: !showDescription ? undefined : el.description,
|
|
108
|
-
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue;
|
|
109
|
-
var selected = value === optionValue;
|
|
102
|
+
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue, selected = _a.selected, handleSelect = _a.handleSelect;
|
|
110
103
|
var clsOpt = "".concat(cls, "-option option-").concat(i, " ").concat(optionValue);
|
|
111
|
-
return (react_1.default.createElement(dropdown_styles_1.OptionWrapper, { key: i, onClick: function () {
|
|
104
|
+
return (react_1.default.createElement(dropdown_styles_1.OptionWrapper, { key: i, onClick: function () {
|
|
105
|
+
handleSelect();
|
|
106
|
+
setHide(true);
|
|
107
|
+
}, className: clsOpt, selected: selected },
|
|
112
108
|
react_1.default.createElement(Thumbnail, { imageUrl: imageUrl, color: color, name: name, className: clsOpt }),
|
|
113
109
|
react_1.default.createElement("div", null,
|
|
114
110
|
react_1.default.createElement(Title, { name: name, className: clsOpt }),
|
|
@@ -38,7 +38,7 @@ var Price = function (props) {
|
|
|
38
38
|
return (react_1.default.createElement(strips_styles_1.StripPrice, { className: "".concat(className, " option-price") }, price));
|
|
39
39
|
};
|
|
40
40
|
var Strips = function (props) {
|
|
41
|
-
var title = props.title, description = props.description, options = props.options,
|
|
41
|
+
var title = props.title, description = props.description, options = props.options, customClassName = props.className, showThumbnail = props.showThumbnail, showPrice = props.showPrice, showDescription = props.showDescription;
|
|
42
42
|
var cls = (0, utils_1.generateInputClassName)('strips', customClassName, title);
|
|
43
43
|
return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
|
|
44
44
|
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
@@ -50,10 +50,9 @@ var Strips = function (props) {
|
|
|
50
50
|
imageUrl: !showThumbnail ? undefined : el.imageUrl,
|
|
51
51
|
price: !showPrice ? undefined : el.price,
|
|
52
52
|
description: !showDescription ? undefined : el.description,
|
|
53
|
-
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue;
|
|
54
|
-
var selected = value === optionValue;
|
|
53
|
+
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue, selected = _a.selected, handleSelect = _a.handleSelect;
|
|
55
54
|
var clsOpt = "".concat(cls, "-option option-").concat(i, " ").concat(optionValue).concat(selected ? ' selected' : '');
|
|
56
|
-
return (react_1.default.createElement(strips_styles_1.StripWrapper, { key: i, onClick:
|
|
55
|
+
return (react_1.default.createElement(strips_styles_1.StripWrapper, { key: i, onClick: handleSelect, selected: selected, className: clsOpt },
|
|
57
56
|
react_1.default.createElement(Thumbnail, { imageUrl: imageUrl, color: color, name: name, className: clsOpt }),
|
|
58
57
|
react_1.default.createElement("div", null,
|
|
59
58
|
react_1.default.createElement(Title, { name: name, className: clsOpt }),
|
|
@@ -30,7 +30,7 @@ var Thumbnail = function (props) {
|
|
|
30
30
|
return (react_1.default.createElement(swatch_styles_1.OptionThumbnail, { className: "".concat(className, " option-thumbnail"), color: color, shape: shape, size: size }, imageUrl ? react_1.default.createElement("img", { src: imageUrl, alt: name || '' }) : react_1.default.createElement("span", null)));
|
|
31
31
|
};
|
|
32
32
|
var Swatch = function (props) {
|
|
33
|
-
var _a = Object.assign({ shape: 'round', size: '60px' }, props), title = _a.title, shape = _a.shape, description = _a.description, options = _a.options,
|
|
33
|
+
var _a = Object.assign({ shape: 'round', size: '60px' }, props), title = _a.title, shape = _a.shape, description = _a.description, options = _a.options, customClassName = _a.className, showThumbnail = _a.showThumbnail, showPrice = _a.showPrice, showDescription = _a.showDescription, size = _a.size;
|
|
34
34
|
var cls = (0, utils_1.generateInputClassName)('swatch', customClassName, title);
|
|
35
35
|
return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
|
|
36
36
|
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
@@ -42,10 +42,9 @@ var Swatch = function (props) {
|
|
|
42
42
|
imageUrl: !showThumbnail ? undefined : el.imageUrl,
|
|
43
43
|
price: !showPrice ? undefined : el.price,
|
|
44
44
|
description: !showDescription ? undefined : el.description,
|
|
45
|
-
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue;
|
|
46
|
-
var selected = value === optionValue;
|
|
45
|
+
}), imageUrl = _a.imageUrl, color = _a.color, name = _a.name, description = _a.description, price = _a.price, optionValue = _a.optionValue, selected = _a.selected, handleSelect = _a.handleSelect;
|
|
47
46
|
var clsOpt = "".concat(cls, "-option option-").concat(i, " ").concat(optionValue).concat(selected ? ' selected' : '');
|
|
48
|
-
return (react_1.default.createElement(swatch_styles_1.OptionWrapper, { key: i, onClick:
|
|
47
|
+
return (react_1.default.createElement(swatch_styles_1.OptionWrapper, { key: i, onClick: handleSelect, selected: selected, className: clsOpt, shape: shape, size: size },
|
|
49
48
|
react_1.default.createElement("div", null,
|
|
50
49
|
react_1.default.createElement(Thumbnail, { imageUrl: imageUrl, color: color, shape: shape, className: clsOpt, size: size })),
|
|
51
50
|
react_1.default.createElement(SwatchInfo, { title: name, price: price, description: description })));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IFormComponentProps } from '../containers/formInputContainer';
|
|
3
3
|
export interface ITextInput extends IFormComponentProps<undefined> {
|
|
4
|
+
maxLength?: number;
|
|
4
5
|
}
|
|
5
6
|
export declare const TextInput: {
|
|
6
7
|
(props: ITextInput): JSX.Element;
|
|
@@ -14,12 +14,12 @@ var utils_1 = require("../../utils");
|
|
|
14
14
|
var constants_1 = require("../../constants");
|
|
15
15
|
var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
|
|
16
16
|
var TextInput = function (props) {
|
|
17
|
-
var title = props.title, description = props.description, value = props.value, onChange = props.onChange, customClassName = props.className;
|
|
17
|
+
var title = props.title, description = props.description, value = props.value, onChange = props.onChange, maxLength = props.maxLength, customClassName = props.className;
|
|
18
18
|
var cls = (0, utils_1.generateInputClassName)('text-input', customClassName, title);
|
|
19
19
|
return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
|
|
20
20
|
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
21
21
|
react_1.default.createElement(FormComponentDescription_1.default, { description: description, className: cls }),
|
|
22
|
-
react_1.default.createElement(textInput_styles_1.Input, { type: "text", value: value, onChange: function (e) { return onChange && onChange(e.target.value); }, className: cls })));
|
|
22
|
+
react_1.default.createElement(textInput_styles_1.Input, { type: "text", maxLength: maxLength, value: value, onChange: function (e) { return onChange && onChange(e.target.value); }, className: cls })));
|
|
23
23
|
};
|
|
24
24
|
exports.TextInput = TextInput;
|
|
25
25
|
exports.TextInput.componentName = 'text-input';
|
|
@@ -9,5 +9,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.Input = void 0;
|
|
11
11
|
var styled_components_1 = __importDefault(require("styled-components"));
|
|
12
|
-
exports.Input = styled_components_1.default.input(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n margin: 0;\n padding:
|
|
12
|
+
exports.Input = styled_components_1.default.input(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n margin: 0;\n padding: 8px 7px;\n background: #fff;\n border: 1px solid #d9d9d9;\n color: ", ";\n outline: none;\n border-radius: 2px;\n font-size: 14px;\n transition: all 0.3s;\n font-family: ", ";\n\n &:hover {\n border-color: ", ";\n }\n\n &:focus {\n border-color: ", ";\n box-shadow: 0 0 0 2px ", ";\n }\n"], ["\n width: 100%;\n margin: 0;\n padding: 8px 7px;\n background: #fff;\n border: 1px solid #d9d9d9;\n color: ", ";\n outline: none;\n border-radius: 2px;\n font-size: 14px;\n transition: all 0.3s;\n font-family: ", ";\n\n &:hover {\n border-color: ", ";\n }\n\n &:focus {\n border-color: ", ";\n box-shadow: 0 0 0 2px ", ";\n }\n"])), function (props) { return props.theme.textColor; }, function (props) { return props.theme.fontFamily; }, function (props) { return props.theme.primaryColor; }, function (props) { return props.theme.primaryColor; }, function (props) { return "".concat(props.theme.primaryColor, "33"); });
|
|
13
13
|
var templateObject_1;
|
|
@@ -14,16 +14,15 @@ var utils_1 = require("../../utils");
|
|
|
14
14
|
var constants_1 = require("../../constants");
|
|
15
15
|
var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
|
|
16
16
|
var Tiles = function (props) {
|
|
17
|
-
var _a = Object.assign({ columns: 2 }, props), title = _a.title, description = _a.description, options = _a.options,
|
|
17
|
+
var _a = Object.assign({ columns: 2 }, props), title = _a.title, description = _a.description, options = _a.options, customClassName = _a.className, columns = _a.columns;
|
|
18
18
|
var cls = (0, utils_1.generateInputClassName)('tiles', customClassName, title);
|
|
19
19
|
return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
|
|
20
20
|
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
21
21
|
react_1.default.createElement(FormComponentDescription_1.default, { description: description, className: cls }),
|
|
22
22
|
react_1.default.createElement(tiles_styles_1.TilesWrapper, { columns: columns }, options === null || options === void 0 ? void 0 : options.map(function (el, i) {
|
|
23
|
-
var name = el.name, optionValue = el.value;
|
|
24
|
-
var selected = value === optionValue;
|
|
23
|
+
var name = el.name, optionValue = el.value, selected = el.selected, handleSelect = el.handleSelect;
|
|
25
24
|
var clsOpt = "".concat(cls, "-option option-").concat(i, " ").concat(optionValue).concat(selected ? ' selected' : '');
|
|
26
|
-
return (react_1.default.createElement(tiles_styles_1.TileWrapper, { key: i, onClick:
|
|
25
|
+
return (react_1.default.createElement(tiles_styles_1.TileWrapper, { key: i, onClick: handleSelect, selected: selected, className: clsOpt },
|
|
27
26
|
react_1.default.createElement("div", null, name)));
|
|
28
27
|
}))));
|
|
29
28
|
};
|
|
@@ -14,16 +14,15 @@ var utils_1 = require("../../utils");
|
|
|
14
14
|
var constants_1 = require("../../constants");
|
|
15
15
|
var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
|
|
16
16
|
var TilesGroup = function (props) {
|
|
17
|
-
var _a = Object.assign({ stretch: true }, props), stretch = _a.stretch, title = _a.title, description = _a.description, options = _a.options,
|
|
17
|
+
var _a = Object.assign({ stretch: true }, props), stretch = _a.stretch, title = _a.title, description = _a.description, options = _a.options, customClassName = _a.className;
|
|
18
18
|
var cls = (0, utils_1.generateInputClassName)('tiles-group', customClassName, title);
|
|
19
19
|
return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
|
|
20
20
|
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
21
21
|
react_1.default.createElement(FormComponentDescription_1.default, { description: description, className: cls }),
|
|
22
22
|
react_1.default.createElement(tilesGroup_styles_1.TilesGroupWrapper, { stretch: stretch }, options === null || options === void 0 ? void 0 : options.map(function (el, i) {
|
|
23
|
-
var name = el.name, optionValue = el.value;
|
|
24
|
-
var selected = value === optionValue;
|
|
23
|
+
var name = el.name, optionValue = el.value, selected = el.selected, handleSelect = el.handleSelect;
|
|
25
24
|
var clsOpt = "".concat(cls, "-option option-").concat(i, " ").concat(optionValue).concat(selected ? ' selected' : '');
|
|
26
|
-
return (react_1.default.createElement(tilesGroup_styles_1.TileWrapper, { key: i, onClick:
|
|
25
|
+
return (react_1.default.createElement(tilesGroup_styles_1.TileWrapper, { key: i, onClick: handleSelect, selected: selected, className: clsOpt },
|
|
27
26
|
react_1.default.createElement("div", null, name)));
|
|
28
27
|
}))));
|
|
29
28
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
2
|
import { RawAttributeValue } from '../../hooks/useAttribute';
|
|
3
|
-
import {
|
|
3
|
+
import { IHydratedAttribute, IHydratedAttributeAssetValue } from '../../threekit';
|
|
4
4
|
export interface IOptionShared {
|
|
5
5
|
name: string;
|
|
6
6
|
value: string;
|
|
7
|
+
handleSelect: () => Promise<void>;
|
|
8
|
+
selected: boolean;
|
|
7
9
|
}
|
|
8
10
|
export interface IOption extends IOptionShared {
|
|
9
11
|
description?: string;
|
|
@@ -38,13 +40,15 @@ interface IPrepAttributeConfig {
|
|
|
38
40
|
metadataKeys: MetadataKeys;
|
|
39
41
|
sort?: string;
|
|
40
42
|
}
|
|
41
|
-
export declare const prepAttributeForComponent: (attribute:
|
|
43
|
+
export declare const prepAttributeForComponent: (attribute: IHydratedAttribute, config: IPrepAttributeConfig) => {
|
|
42
44
|
selected: string | number | import("../../threekit").IConfigurationAsset | import("../../threekit").IConfigurationColor;
|
|
43
|
-
options:
|
|
45
|
+
options: {
|
|
44
46
|
name: string;
|
|
47
|
+
handleSelect: () => Promise<void>;
|
|
48
|
+
selected: boolean;
|
|
45
49
|
label: string;
|
|
46
50
|
value: string;
|
|
47
|
-
}[] | undefined;
|
|
51
|
+
}[] | IHydratedAttributeAssetValue[] | undefined;
|
|
48
52
|
};
|
|
49
53
|
declare function formComponentContainer<P extends IFormContainerProps>(FormComponent: IFormComponent<Omit<P, 'options'>>): (props: P) => JSX.Element | null;
|
|
50
54
|
export default formComponentContainer;
|
|
@@ -29,15 +29,13 @@ var prepAttributeForComponent = function (attribute, config) {
|
|
|
29
29
|
var descriptionKey = metadataKeyDescription || constants_1.METADATA_RESERVED.description;
|
|
30
30
|
var options;
|
|
31
31
|
var selected = attribute.value;
|
|
32
|
-
if (attribute.type ===
|
|
33
|
-
|
|
34
|
-
options = stringAttribute.values.map(function (el) { return (__assign(__assign({}, el), { name: el.label })); });
|
|
32
|
+
if (attribute.type === 'String') {
|
|
33
|
+
options = attribute.values.map(function (el) { return (__assign(__assign({}, el), { name: el.label })); });
|
|
35
34
|
}
|
|
36
|
-
else if (attribute.type ===
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
? assetAttribute.values
|
|
35
|
+
else if (attribute.type === 'Asset') {
|
|
36
|
+
selected = (_a = attribute.value) === null || _a === void 0 ? void 0 : _a.assetId;
|
|
37
|
+
options = attribute.values
|
|
38
|
+
? attribute.values
|
|
41
39
|
.map(function (el) { return prepCatalogItem(el); })
|
|
42
40
|
.sort(function (a, b) {
|
|
43
41
|
if (!sort || !Object.keys(constants_1.SORT_OPTIONS).includes(sort))
|
|
@@ -50,9 +48,8 @@ var prepAttributeForComponent = function (attribute, config) {
|
|
|
50
48
|
})
|
|
51
49
|
: [];
|
|
52
50
|
}
|
|
53
|
-
else if (attribute.type ===
|
|
54
|
-
|
|
55
|
-
selected = (0, utils_1.inflateRgb)(colorAttribute.value);
|
|
51
|
+
else if (attribute.type === 'Color') {
|
|
52
|
+
selected = (0, utils_1.inflateRgb)(attribute.value);
|
|
56
53
|
}
|
|
57
54
|
function prepCatalogItem(item) {
|
|
58
55
|
var _a, _b;
|
|
@@ -80,9 +77,7 @@ var prepAttributeForComponent = function (attribute, config) {
|
|
|
80
77
|
return { selected: selected, options: options };
|
|
81
78
|
};
|
|
82
79
|
exports.prepAttributeForComponent = prepAttributeForComponent;
|
|
83
|
-
function formComponentContainer(FormComponent
|
|
84
|
-
// FormComponent: IFormComponent<P>
|
|
85
|
-
) {
|
|
80
|
+
function formComponentContainer(FormComponent) {
|
|
86
81
|
return function (props) {
|
|
87
82
|
var attribute = props.attribute, metadataKeyThumbnail = props.metadataKeyThumbnail, metadataKeyDescription = props.metadataKeyDescription, metadataKeyPrice = props.metadataKeyPrice, hideAttributeTitle = props.hideAttributeTitle, sort = props.sort;
|
|
88
83
|
var isLoading = (0, usePlayerLoadingStatus_1.default)();
|
|
@@ -104,7 +99,7 @@ function formComponentContainer(FormComponent
|
|
|
104
99
|
sort: sort,
|
|
105
100
|
}), selected = _b.selected, options = _b.options;
|
|
106
101
|
var handleSetAttribute = function (value) {
|
|
107
|
-
return setAttribute
|
|
102
|
+
return setAttribute === null || setAttribute === void 0 ? void 0 : setAttribute(value);
|
|
108
103
|
};
|
|
109
104
|
var preppedProps = __assign({}, props);
|
|
110
105
|
if (!hideAttributeTitle && !preppedProps.title)
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
interface IConnectionConfig {
|
|
1
|
+
export interface IConnectionConfig {
|
|
2
2
|
authToken?: string;
|
|
3
3
|
orgId?: string;
|
|
4
4
|
assetId?: string;
|
|
5
5
|
threekitDomain?: string;
|
|
6
|
+
serverUrl?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare class ThreekitConnection {
|
|
8
9
|
_authToken: string;
|
|
9
10
|
_orgId: string;
|
|
10
11
|
_assetId: string;
|
|
11
12
|
_threekitDomain: string;
|
|
13
|
+
_serverUrl: string;
|
|
12
14
|
constructor();
|
|
13
15
|
connect(config: IConnectionConfig): Promise<void>;
|
|
14
16
|
getConnection(): {
|
|
@@ -16,6 +18,7 @@ export declare class ThreekitConnection {
|
|
|
16
18
|
orgId: string;
|
|
17
19
|
assetId: string;
|
|
18
20
|
threekitDomain: string;
|
|
21
|
+
serverUrl: string;
|
|
19
22
|
};
|
|
20
23
|
}
|
|
21
24
|
declare const _default: ThreekitConnection;
|
package/dist/connection.js
CHANGED
|
@@ -42,6 +42,7 @@ var ThreekitConnection = /** @class */ (function () {
|
|
|
42
42
|
this._authToken = '';
|
|
43
43
|
this._orgId = '';
|
|
44
44
|
this._assetId = '';
|
|
45
|
+
this._serverUrl = '';
|
|
45
46
|
this._threekitDomain = 'https://admin-fts.threekit.com';
|
|
46
47
|
}
|
|
47
48
|
ThreekitConnection.prototype.connect = function (config) {
|
|
@@ -53,6 +54,8 @@ var ThreekitConnection = /** @class */ (function () {
|
|
|
53
54
|
this._orgId = config.orgId;
|
|
54
55
|
if (config.assetId)
|
|
55
56
|
this._assetId = config.assetId;
|
|
57
|
+
if (config.serverUrl)
|
|
58
|
+
this._serverUrl = config.serverUrl;
|
|
56
59
|
if (config.threekitDomain)
|
|
57
60
|
this._threekitDomain = "https://".concat(config.threekitDomain);
|
|
58
61
|
return [2 /*return*/];
|
|
@@ -68,6 +71,7 @@ var ThreekitConnection = /** @class */ (function () {
|
|
|
68
71
|
orgId: this._orgId,
|
|
69
72
|
assetId: this._assetId,
|
|
70
73
|
threekitDomain: this._threekitDomain,
|
|
74
|
+
serverUrl: this._serverUrl,
|
|
71
75
|
};
|
|
72
76
|
};
|
|
73
77
|
return ThreekitConnection;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IHydratedAttribute, IConfigurationColor } from '../../threekit';
|
|
2
2
|
export declare type RawAttributeValue = string | number | boolean | IConfigurationColor | File | undefined;
|
|
3
3
|
declare type UseAttributeError = [undefined, undefined];
|
|
4
4
|
declare type UseAttributeSuccess = [
|
|
5
|
-
|
|
5
|
+
IHydratedAttribute,
|
|
6
6
|
(val: RawAttributeValue) => Promise<void>
|
|
7
7
|
];
|
|
8
8
|
declare type UseAttributeHook = UseAttributeError | UseAttributeSuccess;
|
|
@@ -42,13 +42,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
var store_1 = require("../../store");
|
|
43
43
|
var attributes_1 = require("../../store/attributes");
|
|
44
44
|
var utils_1 = require("../../utils");
|
|
45
|
-
var constants_1 = require("../../constants");
|
|
46
45
|
var api_1 = __importDefault(require("../../api"));
|
|
47
46
|
var useAttribute = function (attributeName) {
|
|
48
47
|
if (!attributeName)
|
|
49
48
|
return [undefined, undefined];
|
|
50
49
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
51
|
-
var attributes = (0, store_1.useThreekitSelector)(attributes_1.
|
|
50
|
+
var attributes = (0, store_1.useThreekitSelector)(attributes_1.getHydratedAttributes);
|
|
52
51
|
if (!attributeName || !attributes)
|
|
53
52
|
return [undefined, undefined];
|
|
54
53
|
var attribute = attributes[attributeName];
|
|
@@ -60,8 +59,7 @@ var useAttribute = function (attributeName) {
|
|
|
60
59
|
return __generator(this, function (_b) {
|
|
61
60
|
switch (_b.label) {
|
|
62
61
|
case 0:
|
|
63
|
-
if (!(attribute.type === 'Asset' &&
|
|
64
|
-
attribute.assetType === constants_1.ASSET_TYPES.upload)) return [3 /*break*/, 4];
|
|
62
|
+
if (!(attribute.type === 'Asset' && attribute.assetType === 'upload')) return [3 /*break*/, 4];
|
|
65
63
|
if (!!value) return [3 /*break*/, 1];
|
|
66
64
|
preppedValue = (0, utils_1.selectionToConfiguration)('', attribute.type);
|
|
67
65
|
return [3 /*break*/, 3];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ISetConfiguration,
|
|
1
|
+
import { ISetConfiguration, IHydratedAttribute } from '../../threekit';
|
|
2
2
|
declare type UseConfiguratorError = [undefined, undefined];
|
|
3
3
|
declare type UseConfiguratorSuccess = [
|
|
4
|
-
Record<string,
|
|
4
|
+
Record<string, IHydratedAttribute>,
|
|
5
5
|
(configuration: ISetConfiguration) => void
|
|
6
6
|
];
|
|
7
7
|
declare type UseConfiguratorHook = UseConfiguratorError | UseConfiguratorSuccess;
|
|
@@ -4,7 +4,7 @@ var attributes_1 = require("../../store/attributes");
|
|
|
4
4
|
var store_1 = require("../../store");
|
|
5
5
|
var useConfigurator = function () {
|
|
6
6
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
7
|
-
var attributes = (0, store_1.useThreekitSelector)(attributes_1.
|
|
7
|
+
var attributes = (0, store_1.useThreekitSelector)(attributes_1.getHydratedAttributes);
|
|
8
8
|
if (!attributes)
|
|
9
9
|
return [undefined, undefined];
|
|
10
10
|
var handleChange = function (configuration) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CachedProduct } from '../../store/product';
|
|
2
|
+
import { IReloadConfig } from '../../store/treble';
|
|
3
|
+
interface CacheData {
|
|
4
|
+
activeProductIdx: number;
|
|
5
|
+
cache: Array<Pick<CachedProduct, 'name' | 'label' | 'thumbnail'>>;
|
|
6
|
+
}
|
|
7
|
+
declare type UseProductCache = [
|
|
8
|
+
CacheData,
|
|
9
|
+
(config?: string | IReloadConfig) => Promise<void>,
|
|
10
|
+
(idx: number) => Promise<void>,
|
|
11
|
+
(idx: number) => Promise<void>
|
|
12
|
+
];
|
|
13
|
+
declare const useProductCache: () => UseProductCache;
|
|
14
|
+
export default useProductCache;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var product_1 = require("../../store/product");
|
|
4
|
+
var store_1 = require("../../store");
|
|
5
|
+
var useProductCache = function () {
|
|
6
|
+
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
7
|
+
var cache = (0, store_1.useThreekitSelector)(product_1.getProductCache);
|
|
8
|
+
var activeProductIdx = (0, store_1.useThreekitSelector)(product_1.getActiveProductIdx);
|
|
9
|
+
var data = {
|
|
10
|
+
cache: cache,
|
|
11
|
+
activeProductIdx: activeProductIdx,
|
|
12
|
+
};
|
|
13
|
+
var handleChangeActiveProduct = function (idx) {
|
|
14
|
+
if (idx === undefined)
|
|
15
|
+
return Promise.resolve();
|
|
16
|
+
if (idx === activeProductIdx)
|
|
17
|
+
return Promise.resolve();
|
|
18
|
+
if (!cache || idx >= (cache === null || cache === void 0 ? void 0 : cache.length))
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
return dispatch((0, product_1.changeActiveProductIdx)(idx));
|
|
21
|
+
};
|
|
22
|
+
var handleLoadNewProduct = function (config) {
|
|
23
|
+
return dispatch((0, product_1.loadNewProduct)(config));
|
|
24
|
+
};
|
|
25
|
+
var handleRemoveProduct = function (idx) {
|
|
26
|
+
return dispatch((0, product_1.removeProductIdx)(idx));
|
|
27
|
+
};
|
|
28
|
+
return [
|
|
29
|
+
data,
|
|
30
|
+
handleLoadNewProduct,
|
|
31
|
+
handleChangeActiveProduct,
|
|
32
|
+
handleRemoveProduct,
|
|
33
|
+
];
|
|
34
|
+
};
|
|
35
|
+
exports.default = useProductCache;
|
package/dist/http/index.d.ts
CHANGED
|
@@ -3,11 +3,13 @@ import * as products from './products';
|
|
|
3
3
|
import * as configurations from './configurations';
|
|
4
4
|
import * as pricebook from './pricebook';
|
|
5
5
|
import * as catalog from './catalog';
|
|
6
|
+
import * as server from './server';
|
|
6
7
|
declare const _default: {
|
|
7
8
|
orders: typeof orders;
|
|
8
9
|
products: typeof products;
|
|
9
10
|
configurations: typeof configurations;
|
|
10
11
|
pricebook: typeof pricebook;
|
|
11
12
|
catalog: typeof catalog;
|
|
13
|
+
server: typeof server;
|
|
12
14
|
};
|
|
13
15
|
export default _default;
|
package/dist/http/index.js
CHANGED
|
@@ -24,10 +24,12 @@ var products = __importStar(require("./products"));
|
|
|
24
24
|
var configurations = __importStar(require("./configurations"));
|
|
25
25
|
var pricebook = __importStar(require("./pricebook"));
|
|
26
26
|
var catalog = __importStar(require("./catalog"));
|
|
27
|
+
var server = __importStar(require("./server"));
|
|
27
28
|
exports.default = {
|
|
28
29
|
orders: orders,
|
|
29
30
|
products: products,
|
|
30
31
|
configurations: configurations,
|
|
31
32
|
pricebook: pricebook,
|
|
32
33
|
catalog: catalog,
|
|
34
|
+
server: server,
|
|
33
35
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface IPostEmailRequest {
|
|
2
|
+
From: string;
|
|
3
|
+
To: string;
|
|
4
|
+
TemplateId: string;
|
|
5
|
+
TemplateModel: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export interface IPostEmailResponse {
|
|
8
|
+
To: string;
|
|
9
|
+
SubmittedAt: string;
|
|
10
|
+
MessageID: string;
|
|
11
|
+
ErrorCode: 0;
|
|
12
|
+
Message: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const postEmail: (data: IPostEmailRequest) => Promise<IPostEmailResponse>;
|
|
@@ -0,0 +1,17 @@
|
|
|
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.postEmail = void 0;
|
|
7
|
+
var axios_1 = __importDefault(require("axios"));
|
|
8
|
+
var connection_1 = __importDefault(require("../connection"));
|
|
9
|
+
var postEmail = function (data) {
|
|
10
|
+
if (!data)
|
|
11
|
+
throw new Error('data missing');
|
|
12
|
+
var serverUrl = connection_1.default.getConnection().serverUrl;
|
|
13
|
+
if (!serverUrl)
|
|
14
|
+
throw new Error('missing server-url');
|
|
15
|
+
return axios_1.default.post("".concat(serverUrl, "/api/email"), data);
|
|
16
|
+
};
|
|
17
|
+
exports.postEmail = postEmail;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import useSnapshot from './hooks/useSnapshot';
|
|
|
10
10
|
import useWishlist from './hooks/useWishlist';
|
|
11
11
|
import useShare from './hooks/useShare';
|
|
12
12
|
import usePlayerPortal from './hooks/usePlayerPortal';
|
|
13
|
+
import useProductCache from './hooks/useProductCache';
|
|
13
14
|
import ThreekitProvider from './components/ThreekitProvider';
|
|
14
15
|
import Player from './components/Player';
|
|
15
16
|
import Button from './components/Button';
|
|
@@ -41,4 +42,4 @@ import icons from './icons';
|
|
|
41
42
|
export * from './icons';
|
|
42
43
|
import TrebleApp from './components/TrebleApp';
|
|
43
44
|
import ProductLayout from './components/ProductLayout';
|
|
44
|
-
export { useAttribute, useConfigurator, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, Upload, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, message, Modal, Drawer, Accordion, Tabs, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, icons, TrebleApp, ProductLayout, };
|
|
45
|
+
export { useAttribute, useConfigurator, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, useProductCache, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, Upload, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, message, Modal, Drawer, Accordion, Tabs, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, icons, TrebleApp, ProductLayout, };
|