@threekit-tools/treble 0.0.39 → 0.0.43
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/components/Accordion/index.d.ts +2 -1
- package/dist/components/Accordion/index.js +7 -3
- package/dist/components/ProductName/index.js +1 -1
- package/dist/components/Tabs/index.d.ts +1 -2
- package/dist/components/Tabs/index.js +7 -8
- package/dist/components/ThreekitProvider/index.js +3 -3
- package/dist/store/threekit.d.ts +4 -0
- package/dist/store/threekit.js +14 -1
- package/package.json +1 -1
|
@@ -2,7 +2,8 @@ import React from 'react';
|
|
|
2
2
|
interface AccordionItemProps extends React.FC {
|
|
3
3
|
selected: boolean;
|
|
4
4
|
label: string;
|
|
5
|
-
|
|
5
|
+
handleSelect: () => void;
|
|
6
|
+
onClick: () => void;
|
|
6
7
|
}
|
|
7
8
|
interface AccordionProps<T> {
|
|
8
9
|
children: React.FunctionComponentElement<T>;
|
|
@@ -27,9 +27,9 @@ var react_1 = __importStar(require("react"));
|
|
|
27
27
|
var accordion_styles_1 = require("./accordion.styles");
|
|
28
28
|
var CaretDown_1 = __importDefault(require("../../icons/CaretDown"));
|
|
29
29
|
var AccordionItem = function (props) {
|
|
30
|
-
var selected = props.selected,
|
|
30
|
+
var selected = props.selected, handleSelect = props.handleSelect, label = props.label, children = props.children;
|
|
31
31
|
return (react_1.default.createElement(accordion_styles_1.Wrapper, { selected: selected },
|
|
32
|
-
react_1.default.createElement("div", { onClick:
|
|
32
|
+
react_1.default.createElement("div", { onClick: handleSelect },
|
|
33
33
|
react_1.default.createElement("div", null, label),
|
|
34
34
|
react_1.default.createElement("div", null),
|
|
35
35
|
react_1.default.createElement("div", null,
|
|
@@ -54,7 +54,11 @@ var Accordion = function (props) {
|
|
|
54
54
|
return null;
|
|
55
55
|
return react_1.default.cloneElement(child, {
|
|
56
56
|
selected: selected === idx,
|
|
57
|
-
|
|
57
|
+
handleSelect: function () {
|
|
58
|
+
if (child.props.onClick)
|
|
59
|
+
child.props.onClick();
|
|
60
|
+
handleSelect(idx);
|
|
61
|
+
},
|
|
58
62
|
});
|
|
59
63
|
});
|
|
60
64
|
};
|
|
@@ -15,7 +15,7 @@ var ProductName = function (props) {
|
|
|
15
15
|
if (!(title === null || title === void 0 ? void 0 : title.length) && !name)
|
|
16
16
|
return null;
|
|
17
17
|
var cls = (0, utils_1.generateDisplayClassName)('title', customClassName);
|
|
18
|
-
return (react_1.default.createElement(productName_styles_1.Wrapper, { align: align, className: cls },
|
|
18
|
+
return (react_1.default.createElement(productName_styles_1.Wrapper, { align: align, className: cls }, title || name));
|
|
19
19
|
};
|
|
20
20
|
exports.ProductName = ProductName;
|
|
21
21
|
exports.ProductName.propTypes = {
|
|
@@ -26,26 +26,25 @@ var TabPane = function (props) { return react_1.default.createElement(react_1.de
|
|
|
26
26
|
var Tabs = function (_a) {
|
|
27
27
|
var children = _a.children;
|
|
28
28
|
var _b = (0, react_1.useState)(0), selected = _b[0], setSelected = _b[1];
|
|
29
|
-
var handleSelect = function (idx) {
|
|
30
|
-
return setSelected(idx === selected ? undefined : idx);
|
|
31
|
-
};
|
|
29
|
+
var handleSelect = function (idx) { return setSelected(idx); };
|
|
32
30
|
if (!children)
|
|
33
31
|
return null;
|
|
34
32
|
return (react_1.default.createElement(tabs_styles_1.Wrapper, null,
|
|
35
33
|
react_1.default.createElement(tabs_styles_1.TabsWrapper, null, react_1.default.Children.map(children, function (child, idx) {
|
|
36
34
|
if (child.type !== TabPane)
|
|
37
35
|
return null;
|
|
38
|
-
return (react_1.default.createElement(tabs_styles_1.Tab, { selected: selected === idx, onClick: function () {
|
|
36
|
+
return (react_1.default.createElement(tabs_styles_1.Tab, { selected: selected === idx, onClick: function () {
|
|
37
|
+
if (child.props.onClick)
|
|
38
|
+
child.props.onClick();
|
|
39
|
+
handleSelect(idx);
|
|
40
|
+
} }, child.props.label));
|
|
39
41
|
})),
|
|
40
42
|
react_1.default.createElement(tabs_styles_1.TabContent, null, react_1.default.Children.map(children, function (child, idx) {
|
|
41
43
|
if (child.type !== TabPane)
|
|
42
44
|
return null;
|
|
43
45
|
if (selected !== idx)
|
|
44
46
|
return null;
|
|
45
|
-
return
|
|
46
|
-
selected: selected === idx,
|
|
47
|
-
handleClick: function () { return handleSelect(idx); },
|
|
48
|
-
});
|
|
47
|
+
return child;
|
|
49
48
|
}))));
|
|
50
49
|
};
|
|
51
50
|
exports.Tabs = Tabs;
|
|
@@ -33,8 +33,8 @@ var App = function (props) {
|
|
|
33
33
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
34
34
|
(0, react_1.useEffect)(function () {
|
|
35
35
|
var init = function () {
|
|
36
|
-
var playerConfig = props.playerConfig, project = props.project, locale = props.locale, threekitEnv = props.threekitEnv;
|
|
37
|
-
dispatch((0, threekit_1.launch)({ playerConfig: playerConfig, project: project, locale: locale, threekitEnv: threekitEnv }));
|
|
36
|
+
var playerConfig = props.playerConfig, project = props.project, locale = props.locale, threekitEnv = props.threekitEnv, eventHandlers = props.eventHandlers;
|
|
37
|
+
dispatch((0, threekit_1.launch)({ playerConfig: playerConfig, project: project, locale: locale, threekitEnv: threekitEnv, eventHandlers: eventHandlers }));
|
|
38
38
|
};
|
|
39
39
|
init();
|
|
40
40
|
return;
|
|
@@ -45,6 +45,6 @@ var ThreekitProvider = function (props) {
|
|
|
45
45
|
return (react_1.default.createElement(react_redux_1.Provider, { store: store_1.default },
|
|
46
46
|
react_1.default.createElement(styled_components_1.ThemeProvider, { theme: theme_1.default },
|
|
47
47
|
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 }, props.children))));
|
|
48
|
+
react_1.default.createElement(App, { locale: props.locale, project: props.project, playerConfig: props.playerConfig, threekitEnv: props.threekitEnv, eventHandlers: props.eventHandlers }, props.children))));
|
|
49
49
|
};
|
|
50
50
|
exports.default = ThreekitProvider;
|
package/dist/store/threekit.d.ts
CHANGED
|
@@ -5,11 +5,15 @@ import { ISaveConfigurationConfig, WishlistArray } from '../Treble';
|
|
|
5
5
|
/*****************************************************
|
|
6
6
|
* Types and Interfaces
|
|
7
7
|
****************************************************/
|
|
8
|
+
interface EventHandlers {
|
|
9
|
+
postConfigurationChange?: (updatedAttributes: Array<IThreekitDisplayAttribute>, configurationChange: ISetConfiguration, previousConfiguration: Array<IThreekitDisplayAttribute>) => void | Promise<void>;
|
|
10
|
+
}
|
|
8
11
|
export interface ILaunchConfig {
|
|
9
12
|
threekitEnv: string;
|
|
10
13
|
locale: string;
|
|
11
14
|
project: IProject;
|
|
12
15
|
playerConfig: IPlayerConfig;
|
|
16
|
+
eventHandlers: EventHandlers;
|
|
13
17
|
}
|
|
14
18
|
interface IPriceConfig {
|
|
15
19
|
id: string;
|
package/dist/store/threekit.js
CHANGED
|
@@ -84,6 +84,10 @@ var createPlayerLoaderEl = function (elementId) {
|
|
|
84
84
|
document.body.appendChild(playerLoader);
|
|
85
85
|
return playerElement;
|
|
86
86
|
};
|
|
87
|
+
/*****************************************************
|
|
88
|
+
* Constants and Event Handlers
|
|
89
|
+
****************************************************/
|
|
90
|
+
var EVENTS = {};
|
|
87
91
|
var initialState = {
|
|
88
92
|
// Player HTML element
|
|
89
93
|
playerElId: undefined,
|
|
@@ -357,6 +361,8 @@ var launch = function (launchConfig) {
|
|
|
357
361
|
dispatch(setLanguage(launchConfig.locale));
|
|
358
362
|
dispatch(setTranslations(translations));
|
|
359
363
|
}
|
|
364
|
+
if (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.eventHandlers)
|
|
365
|
+
EVENTS = Object.assign(EVENTS, launchConfig.eventHandlers);
|
|
360
366
|
if (pricebook.length) {
|
|
361
367
|
priceConfig = {
|
|
362
368
|
id: pricebook[0].id,
|
|
@@ -384,15 +390,22 @@ var launch = function (launchConfig) {
|
|
|
384
390
|
exports.launch = launch;
|
|
385
391
|
// Configurator
|
|
386
392
|
var setConfiguration = function (config) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
387
|
-
var updatedAttributes;
|
|
393
|
+
var previousConfiguration, updatedAttributes;
|
|
388
394
|
return __generator(this, function (_a) {
|
|
389
395
|
switch (_a.label) {
|
|
390
396
|
case 0:
|
|
397
|
+
previousConfiguration = window.threekit.configurator.getDisplayAttributes();
|
|
391
398
|
dispatch(setPlayerLoading(true));
|
|
392
399
|
return [4 /*yield*/, window.threekit.configurator.setConfiguration(config)];
|
|
393
400
|
case 1:
|
|
394
401
|
_a.sent();
|
|
395
402
|
updatedAttributes = window.threekit.configurator.getDisplayAttributes();
|
|
403
|
+
if (!EVENTS.postConfigurationChange) return [3 /*break*/, 3];
|
|
404
|
+
return [4 /*yield*/, EVENTS.postConfigurationChange(updatedAttributes, config, previousConfiguration)];
|
|
405
|
+
case 2:
|
|
406
|
+
_a.sent();
|
|
407
|
+
_a.label = 3;
|
|
408
|
+
case 3:
|
|
396
409
|
dispatch(setAttributes(updatedAttributes));
|
|
397
410
|
dispatch(setPlayerLoading(false));
|
|
398
411
|
return [2 /*return*/];
|