@threekit-tools/treble 0.0.40 → 0.0.41
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.
|
@@ -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
|
};
|
|
@@ -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;
|
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?: (attributes: 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,
|
|
@@ -393,6 +399,12 @@ var setConfiguration = function (config) { return function (dispatch) { return _
|
|
|
393
399
|
case 1:
|
|
394
400
|
_a.sent();
|
|
395
401
|
updatedAttributes = window.threekit.configurator.getDisplayAttributes();
|
|
402
|
+
if (!EVENTS.postConfigurationChange) return [3 /*break*/, 3];
|
|
403
|
+
return [4 /*yield*/, EVENTS.postConfigurationChange(updatedAttributes)];
|
|
404
|
+
case 2:
|
|
405
|
+
_a.sent();
|
|
406
|
+
_a.label = 3;
|
|
407
|
+
case 3:
|
|
396
408
|
dispatch(setAttributes(updatedAttributes));
|
|
397
409
|
dispatch(setPlayerLoading(false));
|
|
398
410
|
return [2 /*return*/];
|