@threekit-tools/treble 0.0.58 → 0.0.60-next.2
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 +8 -2
- package/dist/Treble/Treble.js +23 -2
- 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/ThreekitProvider/index.d.ts +1 -0
- package/dist/components/ThreekitProvider/index.js +10 -3
- package/dist/components/Tiles/index.js +3 -4
- package/dist/components/TilesGroup/index.js +3 -4
- package/dist/components/TrebleApp/index.d.ts +1 -0
- package/dist/components/TrebleApp/index.js +16 -6
- package/dist/components/Wishlist/index.js +6 -11
- package/dist/components/containers/formInputContainer.d.ts +9 -5
- package/dist/components/containers/formInputContainer.js +14 -19
- 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 +6 -5
- package/dist/hooks/useConfigurator/index.d.ts +2 -2
- package/dist/hooks/useConfigurator/index.js +7 -3
- package/dist/hooks/useNestedConfigurator/index.d.ts +8 -0
- package/dist/hooks/useNestedConfigurator/index.js +93 -0
- package/dist/hooks/useProductCache/index.d.ts +22 -0
- package/dist/hooks/useProductCache/index.js +28 -0
- package/dist/hooks/useWishlist/index.d.ts +8 -6
- package/dist/hooks/useWishlist/index.js +16 -22
- 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 +3 -1
- package/dist/index.js +5 -1
- package/dist/store/attributes.d.ts +14 -1
- package/dist/store/attributes.js +6 -45
- package/dist/store/product.d.ts +47 -2
- package/dist/store/product.js +267 -12
- package/dist/store/translations.d.ts +4 -2
- package/dist/store/translations.js +4 -12
- package/dist/store/treble.d.ts +36 -2
- package/dist/store/treble.js +214 -52
- package/dist/threekit.d.ts +16 -1
- package/dist/utils.d.ts +7 -10
- package/dist/utils.js +22 -23
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import threekitAPI from '../api';
|
|
2
|
-
import { IThreekitPlayer, IConfiguration, ISetConfiguration } from '../threekit';
|
|
2
|
+
import { IThreekitPlayer, IConfiguration, ISetConfiguration, IThreekitPrivateConfigurator } from '../threekit';
|
|
3
3
|
import { IWishlist } from './Wishlist';
|
|
4
4
|
import Snapshots from './Snapshots';
|
|
5
5
|
import { ISaveConfiguration } from '../api/configurations';
|
|
@@ -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;
|
|
@@ -21,7 +26,8 @@ declare class Treble {
|
|
|
21
26
|
} & import("../http/configurations").IConfigurationResponse & {
|
|
22
27
|
thumbnail: string;
|
|
23
28
|
}>;
|
|
24
|
-
getNestedConfigurator: (address: string | Array<string>) =>
|
|
29
|
+
getNestedConfigurator: (address: string | Array<string>) => undefined | IThreekitPrivateConfigurator;
|
|
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
|
@@ -83,14 +83,19 @@ var Treble = /** @class */ (function () {
|
|
|
83
83
|
});
|
|
84
84
|
}); };
|
|
85
85
|
this.getNestedConfigurator = function (address) {
|
|
86
|
+
if (!address)
|
|
87
|
+
return undefined;
|
|
86
88
|
var player = window.threekit.player.enableApi('player');
|
|
87
89
|
var addressArr = Array.isArray(address) ? address : [address];
|
|
88
90
|
return addressArr.reduce(function (configurator, attributeName) {
|
|
91
|
+
var _a;
|
|
92
|
+
if (!configurator)
|
|
93
|
+
return undefined;
|
|
89
94
|
var itemId = configurator.getAppliedConfiguration(attributeName);
|
|
90
|
-
return window.threekit.player.scene.get({
|
|
95
|
+
return (_a = window.threekit.player.scene.get({
|
|
91
96
|
id: itemId,
|
|
92
97
|
evalNode: true,
|
|
93
|
-
}).configurator;
|
|
98
|
+
})) === null || _a === void 0 ? void 0 : _a.configurator;
|
|
94
99
|
}, player.getConfigurator());
|
|
95
100
|
};
|
|
96
101
|
this.resetConfiguration = function (configuration) {
|
|
@@ -98,6 +103,22 @@ var Treble = /** @class */ (function () {
|
|
|
98
103
|
var updateConfiguration = Object.assign(initialConfiguration, configuration);
|
|
99
104
|
window.threekit.configurator.setConfiguration(updateConfiguration);
|
|
100
105
|
};
|
|
106
|
+
this.sendEmail = function (credentials, templateData) {
|
|
107
|
+
if (!credentials)
|
|
108
|
+
throw new Error('sendEmail is missing credentials object');
|
|
109
|
+
if (!credentials.from.length)
|
|
110
|
+
throw new Error('sendEmail is missing sender email - "From"');
|
|
111
|
+
if (!credentials.to.length)
|
|
112
|
+
throw new Error('sendEmail is missing receivers email - "To"');
|
|
113
|
+
if (!credentials.templateId.length)
|
|
114
|
+
throw new Error('sendEmail is missing the templateId to use - "TemplateId"');
|
|
115
|
+
var data = Object.assign({
|
|
116
|
+
To: credentials.to,
|
|
117
|
+
From: credentials.from,
|
|
118
|
+
TemplateId: credentials.templateId,
|
|
119
|
+
}, { TemplateModel: templateData });
|
|
120
|
+
return api_1.default.server.sendEmail(data);
|
|
121
|
+
};
|
|
101
122
|
// Threekit API
|
|
102
123
|
this._api = api_1.default;
|
|
103
124
|
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;
|
|
@@ -31,10 +31,17 @@ var theme_1 = __importDefault(require("../../theme"));
|
|
|
31
31
|
var GlobalStyles_styles_1 = __importDefault(require("./GlobalStyles.styles"));
|
|
32
32
|
var App = function (props) {
|
|
33
33
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
34
|
+
var playerConfig = props.playerConfig, productId = props.productId, project = props.project, locale = props.locale, threekitEnv = props.threekitEnv, eventHandlers = props.eventHandlers;
|
|
34
35
|
(0, react_1.useEffect)(function () {
|
|
35
36
|
var init = function () {
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
dispatch((0, treble_1.launch)({
|
|
38
|
+
playerConfig: playerConfig,
|
|
39
|
+
productId: productId,
|
|
40
|
+
project: project,
|
|
41
|
+
locale: locale,
|
|
42
|
+
threekitEnv: threekitEnv,
|
|
43
|
+
eventHandlers: eventHandlers,
|
|
44
|
+
}));
|
|
38
45
|
};
|
|
39
46
|
init();
|
|
40
47
|
return;
|
|
@@ -45,6 +52,6 @@ var ThreekitProvider = function (props) {
|
|
|
45
52
|
return (react_1.default.createElement(react_redux_1.Provider, { store: (0, store_1.default)(props.reducer) },
|
|
46
53
|
react_1.default.createElement(styled_components_1.ThemeProvider, { theme: theme_1.default },
|
|
47
54
|
react_1.default.createElement(GlobalStyles_styles_1.default, null),
|
|
48
|
-
react_1.default.createElement(App, { locale: props.locale, project: props.project, playerConfig: props.playerConfig, threekitEnv: props.threekitEnv, eventHandlers: props.eventHandlers }, props.children))));
|
|
55
|
+
react_1.default.createElement(App, { locale: props.locale, productId: props.productId, project: props.project, playerConfig: props.playerConfig, threekitEnv: props.threekitEnv, eventHandlers: props.eventHandlers }, props.children))));
|
|
49
56
|
};
|
|
50
57
|
exports.default = ThreekitProvider;
|
|
@@ -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
|
};
|
|
@@ -3,5 +3,6 @@ import { ThreekitProviderProps } from '../ThreekitProvider';
|
|
|
3
3
|
interface TrebleAppProps extends Omit<ThreekitProviderProps, 'children'> {
|
|
4
4
|
productId?: string;
|
|
5
5
|
}
|
|
6
|
+
export declare const Products: () => JSX.Element | null;
|
|
6
7
|
export default function TrebleApp(props: TrebleAppProps): JSX.Element | null;
|
|
7
8
|
export {};
|
|
@@ -22,13 +22,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.Products = void 0;
|
|
25
26
|
var react_1 = __importStar(require("react"));
|
|
27
|
+
var store_1 = require("../../store");
|
|
26
28
|
var ThreekitProvider_1 = __importDefault(require("../ThreekitProvider"));
|
|
27
29
|
var utils_1 = require("../../utils");
|
|
28
30
|
var constants_1 = require("../../constants");
|
|
31
|
+
var product_1 = require("../../store/product");
|
|
29
32
|
var productsMap = {};
|
|
30
33
|
var productComponents = [];
|
|
31
34
|
var productToComponentMap = {};
|
|
35
|
+
var Products = function () {
|
|
36
|
+
var productId = (0, store_1.useThreekitSelector)(product_1.getProductId);
|
|
37
|
+
if (!productId)
|
|
38
|
+
return null;
|
|
39
|
+
var Product = productComponents[productToComponentMap[productId]];
|
|
40
|
+
if (!Product)
|
|
41
|
+
return null;
|
|
42
|
+
return react_1.default.createElement(Product, null);
|
|
43
|
+
};
|
|
44
|
+
exports.Products = Products;
|
|
32
45
|
function TrebleApp(props) {
|
|
33
46
|
var _a;
|
|
34
47
|
var project = props.project, productId = props.productId, playerConfig = props.playerConfig, threekitEnv = props.threekitEnv, locale = props.locale, theme = props.theme, eventHandlers = props.eventHandlers;
|
|
@@ -69,13 +82,10 @@ function TrebleApp(props) {
|
|
|
69
82
|
}
|
|
70
83
|
if (!id)
|
|
71
84
|
return null;
|
|
72
|
-
var Product = productComponents[productToComponentMap[id]];
|
|
73
|
-
if (!Product)
|
|
74
|
-
return null;
|
|
75
85
|
var preppedProject = Object.assign({}, project, {
|
|
76
|
-
products: productsMap
|
|
86
|
+
products: productsMap,
|
|
77
87
|
});
|
|
78
|
-
return (react_1.default.createElement(ThreekitProvider_1.default, { project: preppedProject, locale: locale, playerConfig: playerConfig, theme: theme, threekitEnv: threekitEnv, eventHandlers: eventHandlers },
|
|
79
|
-
react_1.default.createElement(
|
|
88
|
+
return (react_1.default.createElement(ThreekitProvider_1.default, { productId: id, project: preppedProject, locale: locale, playerConfig: playerConfig, theme: theme, threekitEnv: threekitEnv, eventHandlers: eventHandlers },
|
|
89
|
+
react_1.default.createElement(exports.Products, null)));
|
|
80
90
|
}
|
|
81
91
|
exports.default = TrebleApp;
|
|
@@ -81,16 +81,12 @@ var WishlistButton = function (props) {
|
|
|
81
81
|
exports.WishlistButton = WishlistButton;
|
|
82
82
|
var Wishlist = function (props) {
|
|
83
83
|
var _a = (0, react_1.useState)(false), showWishlist = _a[0], setShowWishlist = _a[1];
|
|
84
|
-
var _b = (0, useWishlist_1.default)(), wishlist = _b[0], addToWishlist = _b[1]
|
|
84
|
+
var _b = (0, useWishlist_1.default)(), wishlist = _b[0], addToWishlist = _b[1];
|
|
85
85
|
var className = props.className, showLabel = props.showLabel;
|
|
86
86
|
var shape = props.shape || 'round';
|
|
87
87
|
var type = props.type || 'threekit';
|
|
88
88
|
var cls = (0, utils_1.generateWidgetClassName)('wishlist', className);
|
|
89
|
-
if (!wishlist ||
|
|
90
|
-
!addToWishlist ||
|
|
91
|
-
!resumeWishlistItem ||
|
|
92
|
-
!removeFromWishlist ||
|
|
93
|
-
!shareWishlistItem)
|
|
89
|
+
if (!wishlist || !addToWishlist)
|
|
94
90
|
return null;
|
|
95
91
|
var handleAddToWishlist = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
96
92
|
return __generator(this, function (_a) {
|
|
@@ -103,16 +99,15 @@ var Wishlist = function (props) {
|
|
|
103
99
|
}
|
|
104
100
|
});
|
|
105
101
|
}); };
|
|
106
|
-
var handleClickResume = function (idx) {
|
|
107
|
-
resumeWishlistItem(idx);
|
|
108
|
-
setShowWishlist(false);
|
|
109
|
-
};
|
|
110
102
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
111
103
|
react_1.default.createElement(shared_styles_1.TwinButtonWrapper, null,
|
|
112
104
|
react_1.default.createElement(exports.AddWishlistButton, { title: showLabel ? 'Add to Wishlist' : undefined, className: cls, onClick: handleAddToWishlist, type: type, shape: shape }),
|
|
113
105
|
react_1.default.createElement(exports.WishlistButton, { title: showLabel ? 'Open Wishlist' : undefined, className: cls, onClick: function () { return setShowWishlist(true); }, type: type, shape: shape })),
|
|
114
106
|
react_1.default.createElement(Drawer_1.default, { title: "Wishlist", show: showWishlist, handleClose: function () { return setShowWishlist(false); } },
|
|
115
|
-
react_1.default.createElement(wishlist_styles_1.WishlistWrapper, null, wishlist.map(function (el, i) { return (react_1.default.createElement(WishlistItem_1.default, { key: i, thumbnail: el.thumbnail || undefined, metadata: el.metadata || undefined, onDelete:
|
|
107
|
+
react_1.default.createElement(wishlist_styles_1.WishlistWrapper, null, wishlist.map(function (el, i) { return (react_1.default.createElement(WishlistItem_1.default, { key: i, thumbnail: el.thumbnail || undefined, metadata: el.metadata || undefined, onDelete: el.handleRemove, onResume: function () {
|
|
108
|
+
el.handleSelect();
|
|
109
|
+
setShowWishlist(false);
|
|
110
|
+
}, onShare: el.handleShare })); })))));
|
|
116
111
|
};
|
|
117
112
|
exports.Wishlist = Wishlist;
|
|
118
113
|
exports.Wishlist.propTypes = {
|
|
@@ -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;
|
|
@@ -34,17 +36,19 @@ export interface IFormComponentProps<T extends IOptionShared | undefined> extend
|
|
|
34
36
|
export interface IFormComponent<P> extends FunctionComponent<P> {
|
|
35
37
|
compatibleAttributes: Set<string>;
|
|
36
38
|
}
|
|
37
|
-
interface
|
|
39
|
+
interface IhydrateAttributeConfig {
|
|
38
40
|
metadataKeys: MetadataKeys;
|
|
39
41
|
sort?: string;
|
|
40
42
|
}
|
|
41
|
-
export declare const
|
|
43
|
+
export declare const hydrateAttributeForComponent: (attribute: IHydratedAttribute, config: IhydrateAttributeConfig) => {
|
|
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;
|
|
@@ -14,13 +14,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.hydrateAttributeForComponent = void 0;
|
|
18
18
|
var react_1 = __importDefault(require("react"));
|
|
19
19
|
var useAttribute_1 = __importDefault(require("../../hooks/useAttribute"));
|
|
20
20
|
var usePlayerLoadingStatus_1 = __importDefault(require("../../hooks/usePlayerLoadingStatus"));
|
|
21
21
|
var utils_1 = require("../../utils");
|
|
22
22
|
var constants_1 = require("../../constants");
|
|
23
|
-
var
|
|
23
|
+
var hydrateAttributeForComponent = function (attribute, config) {
|
|
24
24
|
var _a;
|
|
25
25
|
var _b = config.metadataKeys, metadataKeyThumbnail = _b.metadataKeyThumbnail, metadataKeyPrice = _b.metadataKeyPrice, metadataKeyDescription = _b.metadataKeyDescription;
|
|
26
26
|
var sort = config.sort;
|
|
@@ -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;
|
|
@@ -79,10 +76,8 @@ var prepAttributeForComponent = function (attribute, config) {
|
|
|
79
76
|
}
|
|
80
77
|
return { selected: selected, options: options };
|
|
81
78
|
};
|
|
82
|
-
exports.
|
|
83
|
-
function formComponentContainer(FormComponent
|
|
84
|
-
// FormComponent: IFormComponent<P>
|
|
85
|
-
) {
|
|
79
|
+
exports.hydrateAttributeForComponent = hydrateAttributeForComponent;
|
|
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)();
|
|
@@ -95,7 +90,7 @@ function formComponentContainer(FormComponent
|
|
|
95
90
|
console.log('Incompatible attribute type for this component');
|
|
96
91
|
return null;
|
|
97
92
|
}
|
|
98
|
-
var _b = (0, exports.
|
|
93
|
+
var _b = (0, exports.hydrateAttributeForComponent)(attributeData, {
|
|
99
94
|
metadataKeys: {
|
|
100
95
|
metadataKeyThumbnail: metadataKeyThumbnail,
|
|
101
96
|
metadataKeyDescription: metadataKeyDescription,
|
|
@@ -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;
|