@threekit-tools/treble 0.0.60 → 0.0.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/Treble/Treble.d.ts +2 -2
  2. package/dist/Treble/Treble.js +7 -2
  3. package/dist/components/Switch/index.d.ts +66 -0
  4. package/dist/components/Switch/index.js +86 -0
  5. package/dist/components/Switch/switch.styles.d.ts +4 -0
  6. package/dist/components/Switch/switch.styles.js +16 -0
  7. package/dist/components/TextInput/index.js +2 -0
  8. package/dist/components/ThreekitProvider/index.d.ts +1 -0
  9. package/dist/components/ThreekitProvider/index.js +10 -3
  10. package/dist/components/TrebleApp/index.d.ts +1 -0
  11. package/dist/components/TrebleApp/index.js +16 -6
  12. package/dist/components/Upload/index.js +5 -4
  13. package/dist/components/UploadArea/index.js +4 -3
  14. package/dist/components/Wishlist/index.js +6 -11
  15. package/dist/components/containers/formInputContainer.d.ts +4 -4
  16. package/dist/components/containers/formInputContainer.js +4 -4
  17. package/dist/components/formComponents.js +5 -1
  18. package/dist/hooks/useAttribute/index.js +5 -2
  19. package/dist/hooks/useConfigurator/index.js +7 -3
  20. package/dist/hooks/useNestedConfigurator/index.d.ts +8 -0
  21. package/dist/hooks/useNestedConfigurator/index.js +93 -0
  22. package/dist/hooks/useProductCache/index.d.ts +13 -5
  23. package/dist/hooks/useProductCache/index.js +16 -23
  24. package/dist/hooks/useWishlist/index.d.ts +8 -6
  25. package/dist/hooks/useWishlist/index.js +16 -22
  26. package/dist/index.d.ts +4 -1
  27. package/dist/index.js +7 -2
  28. package/dist/store/attributes.d.ts +3 -3
  29. package/dist/store/attributes.js +3 -50
  30. package/dist/store/product.d.ts +22 -13
  31. package/dist/store/product.js +98 -54
  32. package/dist/store/translations.d.ts +4 -3
  33. package/dist/store/translations.js +4 -14
  34. package/dist/store/treble.d.ts +4 -0
  35. package/dist/store/treble.js +69 -30
  36. package/dist/threekit.d.ts +9 -5
  37. package/dist/utils.d.ts +7 -1
  38. package/dist/utils.js +53 -1
  39. package/package.json +1 -1
@@ -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';
@@ -26,7 +26,7 @@ declare class Treble {
26
26
  } & import("../http/configurations").IConfigurationResponse & {
27
27
  thumbnail: string;
28
28
  }>;
29
- getNestedConfigurator: (address: string | Array<string>) => any;
29
+ getNestedConfigurator: (address: string | Array<string>) => undefined | IThreekitPrivateConfigurator;
30
30
  resetConfiguration: (configuration?: ISetConfiguration | undefined) => void;
31
31
  sendEmail: (credentials: IEmailShareCredentials, templateData: Record<string, any>) => Promise<import("../http/server").IPostEmailResponse>;
32
32
  }
@@ -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) {
@@ -0,0 +1,66 @@
1
+ /// <reference types="react" />
2
+ import PropTypes from 'prop-types';
3
+ import { IFormComponentProps, IOption } from '../containers/formInputContainer';
4
+ export interface ISwitch extends IFormComponentProps<IOption> {
5
+ showDescription?: boolean;
6
+ }
7
+ export declare const Switch: {
8
+ (props: ISwitch): JSX.Element;
9
+ propTypes: {
10
+ /**
11
+ * Is the attribute name on the initialized asset that we are
12
+ * using this component for. If the attribute prop is used,
13
+ * the component will ignore the props for: `value`, `options`, `onClick`.
14
+ */
15
+ attribute: PropTypes.Requireable<string>;
16
+ /**
17
+ * Used to add a title to the input
18
+ */
19
+ title: PropTypes.Requireable<string>;
20
+ /**
21
+ * Used to provide a custom description for the input component
22
+ */
23
+ description: PropTypes.Requireable<string>;
24
+ /**
25
+ * Selected value from the option set. Should match the 'value' property
26
+ * of one of the items in the options array.
27
+ */
28
+ value: PropTypes.Requireable<boolean>;
29
+ /**
30
+ * The size of the for a Switch option. The size should be a valid CSS
31
+ * height/width property.
32
+ *
33
+ */
34
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
35
+ /**
36
+ * Used to add a custom class name to each of the components html elements
37
+ */
38
+ className: PropTypes.Requireable<string>;
39
+ /**
40
+ * By default the description is soruced from the `_description` metadata
41
+ * key in the option's Catalog Item. This metadata key can be overwritten
42
+ * by passing in the prefered key value to the **metadataKeyDescription**
43
+ * prop.
44
+ */
45
+ metadataKeyDescription: PropTypes.Requireable<string>;
46
+ /**
47
+ * A boolean to set whether or all the Cards should display the description
48
+ * for the options.
49
+ */
50
+ showDescription: PropTypes.Requireable<boolean>;
51
+ };
52
+ defaultProps: {
53
+ description: undefined;
54
+ className: undefined;
55
+ attribute: undefined;
56
+ metadataKeyDescription: undefined;
57
+ showDescription: boolean;
58
+ title: undefined;
59
+ value: undefined;
60
+ onClick: undefined;
61
+ };
62
+ componentName: string;
63
+ compatibleAttributes: Set<string>;
64
+ };
65
+ declare const _default: (props: ISwitch) => JSX.Element | null;
66
+ export default _default;
@@ -0,0 +1,86 @@
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.Switch = void 0;
7
+ var react_1 = __importDefault(require("react"));
8
+ var prop_types_1 = __importDefault(require("prop-types"));
9
+ var FormComponentTitle_1 = __importDefault(require("../FormComponentTitle"));
10
+ var FormComponentDescription_1 = __importDefault(require("../FormComponentDescription"));
11
+ var switch_styles_1 = require("./switch.styles");
12
+ var shared_styles_1 = require("../shared.styles");
13
+ var utils_1 = require("../../utils");
14
+ var constants_1 = require("../../constants");
15
+ var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
16
+ var Switch = function (props) {
17
+ var title = props.title, value = props.value, onChange = props.onChange, description = props.description, customClassName = props.className, showDescription = props.showDescription;
18
+ var cls = (0, utils_1.generateInputClassName)('Switch', customClassName, title);
19
+ return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
20
+ react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
21
+ react_1.default.createElement(FormComponentDescription_1.default, { description: showDescription ? description : undefined, className: cls }),
22
+ react_1.default.createElement(switch_styles_1.SwitchWrapper, null,
23
+ react_1.default.createElement(switch_styles_1.Checkbox, { type: "checkbox", checked: !!value, onChange: function () { return onChange === null || onChange === void 0 ? void 0 : onChange(!!!value); } }),
24
+ react_1.default.createElement(switch_styles_1.Knob, null),
25
+ react_1.default.createElement(switch_styles_1.Layer, null))));
26
+ };
27
+ exports.Switch = Switch;
28
+ exports.Switch.propTypes = {
29
+ /**
30
+ * Is the attribute name on the initialized asset that we are
31
+ * using this component for. If the attribute prop is used,
32
+ * the component will ignore the props for: `value`, `options`, `onClick`.
33
+ */
34
+ attribute: prop_types_1.default.string,
35
+ /**
36
+ * Used to add a title to the input
37
+ */
38
+ title: prop_types_1.default.string,
39
+ /**
40
+ * Used to provide a custom description for the input component
41
+ */
42
+ description: prop_types_1.default.string,
43
+ /**
44
+ * Selected value from the option set. Should match the 'value' property
45
+ * of one of the items in the options array.
46
+ */
47
+ value: prop_types_1.default.bool,
48
+ /**
49
+ * The size of the for a Switch option. The size should be a valid CSS
50
+ * height/width property.
51
+ *
52
+ */
53
+ onClick: prop_types_1.default.func,
54
+ /**
55
+ * Used to add a custom class name to each of the components html elements
56
+ */
57
+ className: prop_types_1.default.string,
58
+ /**
59
+ * By default the description is soruced from the `_description` metadata
60
+ * key in the option's Catalog Item. This metadata key can be overwritten
61
+ * by passing in the prefered key value to the **metadataKeyDescription**
62
+ * prop.
63
+ */
64
+ metadataKeyDescription: prop_types_1.default.string,
65
+ /**
66
+ * A boolean to set whether or all the Cards should display the description
67
+ * for the options.
68
+ */
69
+ showDescription: prop_types_1.default.bool,
70
+ };
71
+ exports.Switch.defaultProps = {
72
+ description: undefined,
73
+ className: undefined,
74
+ // Default use
75
+ attribute: undefined,
76
+ // Default user overrides
77
+ metadataKeyDescription: undefined,
78
+ showDescription: true,
79
+ // Custom use
80
+ title: undefined,
81
+ value: undefined,
82
+ onClick: undefined,
83
+ };
84
+ exports.Switch.componentName = 'Switch';
85
+ exports.Switch.compatibleAttributes = new Set([constants_1.ATTRIBUTE_TYPES.boolean]);
86
+ exports.default = (0, formInputContainer_1.default)(exports.Switch);
@@ -0,0 +1,4 @@
1
+ export declare const Layer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
2
+ export declare const Knob: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
3
+ export declare const Checkbox: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, {}, never>;
4
+ export declare const SwitchWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SwitchWrapper = exports.Checkbox = exports.Knob = exports.Layer = void 0;
11
+ var styled_components_1 = __importDefault(require("styled-components"));
12
+ exports.Layer = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n width: 100%;\n border-radius: 100px;\n background-color: #bbb;\n transition: 0.3s ease all;\n z-index: 1;\n"], ["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n width: 100%;\n border-radius: 100px;\n background-color: #bbb;\n transition: 0.3s ease all;\n z-index: 1;\n"])));
13
+ exports.Knob = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 2;\n\n &:before {\n content: '';\n position: absolute;\n top: 4px;\n left: 4px;\n width: 20px;\n height: 10px;\n color: #fff;\n font-size: 10px;\n font-weight: bold;\n text-align: center;\n line-height: 1;\n padding: 9px 4px;\n background-color: #fff;\n border-radius: 50%;\n transition: 0.3s ease all, left 0.3s cubic-bezier(0.18, 0.89, 0.35, 1.15);\n }\n"], ["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 2;\n\n &:before {\n content: '';\n position: absolute;\n top: 4px;\n left: 4px;\n width: 20px;\n height: 10px;\n color: #fff;\n font-size: 10px;\n font-weight: bold;\n text-align: center;\n line-height: 1;\n padding: 9px 4px;\n background-color: #fff;\n border-radius: 50%;\n transition: 0.3s ease all, left 0.3s cubic-bezier(0.18, 0.89, 0.35, 1.15);\n }\n"])));
14
+ exports.Checkbox = styled_components_1.default.input(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n z-index: 3;\n"], ["\n position: relative;\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n z-index: 3;\n"])));
15
+ exports.SwitchWrapper = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: relative;\n width: 74px;\n height: 36px;\n overflow: hidden;\n\n & ", ":active + ", ":before {\n width: 46px;\n border-radius: 100px;\n }\n\n & ", ":checked + ", ":before {\n content: '';\n left: 42px;\n }\n\n & ", ":checked:active + ", ":before {\n margin-left: -26px;\n }\n\n & ", ":checked ~ ", " {\n background-color: ", ";\n }\n"], ["\n position: relative;\n width: 74px;\n height: 36px;\n overflow: hidden;\n\n & ", ":active + ", ":before {\n width: 46px;\n border-radius: 100px;\n }\n\n & ", ":checked + ", ":before {\n content: '';\n left: 42px;\n }\n\n & ", ":checked:active + ", ":before {\n margin-left: -26px;\n }\n\n & ", ":checked ~ ", " {\n background-color: ", ";\n }\n"])), exports.Checkbox, exports.Knob, exports.Checkbox, exports.Knob, exports.Checkbox, exports.Knob, exports.Checkbox, exports.Layer, function (props) { return props.theme.primaryColor; });
16
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
@@ -16,6 +16,8 @@ var formInputContainer_1 = __importDefault(require("../containers/formInputConta
16
16
  var TextInput = function (props) {
17
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
+ if (typeof value !== 'string')
20
+ return react_1.default.createElement(react_1.default.Fragment, null);
19
21
  return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, { className: cls },
20
22
  react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
21
23
  react_1.default.createElement(FormComponentDescription_1.default, { description: description, className: cls }),
@@ -5,6 +5,7 @@ interface Theme {
5
5
  [key: string]: string | number;
6
6
  }
7
7
  export interface ThreekitProviderProps extends Partial<ILaunchConfig> {
8
+ productId?: string;
8
9
  theme?: Theme;
9
10
  reducer?: Record<string, Reducer>;
10
11
  children: React.ReactNode;
@@ -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
- var playerConfig = props.playerConfig, project = props.project, locale = props.locale, threekitEnv = props.threekitEnv, eventHandlers = props.eventHandlers;
37
- dispatch((0, treble_1.launch)({ playerConfig: playerConfig, project: project, locale: locale, threekitEnv: threekitEnv, eventHandlers: eventHandlers }));
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;
@@ -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[id],
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(Product, null)));
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;
@@ -69,8 +69,9 @@ var icons_1 = require("../../icons");
69
69
  var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
70
70
  var upload_styles_1 = require("./upload.styles");
71
71
  var Upload = function (props) {
72
+ var _a, _b;
72
73
  var title = props.title, description = props.description, value = props.value, onChange = props.onChange, customClassName = props.className;
73
- var _a = (0, react_1.useState)(false), isUploading = _a[0], setIsUploading = _a[1];
74
+ var _c = (0, react_1.useState)(false), isUploading = _c[0], setIsUploading = _c[1];
74
75
  var inputRef = (0, react_1.useRef)(null);
75
76
  var imgRef = (0, react_1.useRef)(null);
76
77
  var cls = (0, utils_1.generateInputClassName)('upload', customClassName, title);
@@ -78,7 +79,7 @@ var Upload = function (props) {
78
79
  var _a;
79
80
  if (isUploading)
80
81
  return;
81
- if (value === null || value === void 0 ? void 0 : value.length)
82
+ if (typeof value === 'string' && (value === null || value === void 0 ? void 0 : value.length))
82
83
  return;
83
84
  (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
84
85
  };
@@ -109,7 +110,7 @@ var Upload = function (props) {
109
110
  return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, null,
110
111
  react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
111
112
  react_1.default.createElement(FormComponentDescription_1.default, { description: description, className: cls }),
112
- react_1.default.createElement(upload_styles_1.UploadWrapper, { className: cls, uploaded: !!(!isUploading && (value === null || value === void 0 ? void 0 : value.length)) },
113
+ react_1.default.createElement(upload_styles_1.UploadWrapper, { className: cls, uploaded: !!(!isUploading && ((_a = value) === null || _a === void 0 ? void 0 : _a.length)) },
113
114
  react_1.default.createElement("input", { type: "file", ref: inputRef, onChange: function (e) { return __awaiter(void 0, void 0, void 0, function () {
114
115
  var _a;
115
116
  return __generator(this, function (_b) {
@@ -122,7 +123,7 @@ var Upload = function (props) {
122
123
  react_1.default.createElement("button", { type: "button", onClick: handleClick }, isUploading ? (react_1.default.createElement(react_1.default.Fragment, null,
123
124
  react_1.default.createElement(upload_styles_1.IconWrapper, null,
124
125
  react_1.default.createElement(icons_1.SpinnerIcon, { size: "28px" })),
125
- react_1.default.createElement("div", null, "Uploading..."))) : (value === null || value === void 0 ? void 0 : value.length) ? (react_1.default.createElement(upload_styles_1.ImageWrapper, null,
126
+ react_1.default.createElement("div", null, "Uploading..."))) : ((_b = value) === null || _b === void 0 ? void 0 : _b.length) ? (react_1.default.createElement(upload_styles_1.ImageWrapper, null,
126
127
  react_1.default.createElement("div", null,
127
128
  react_1.default.createElement("img", { ref: imgRef, src: "#" })),
128
129
  react_1.default.createElement(upload_styles_1.ImageActionArea, null,
@@ -69,9 +69,10 @@ var icons_1 = require("../../icons");
69
69
  var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
70
70
  var uploadArea_styles_1 = require("./uploadArea.styles");
71
71
  var UploadArea = function (props) {
72
+ var _a;
72
73
  var title = props.title, description = props.description, value = props.value, onChange = props.onChange, customClassName = props.className;
73
- var _a = (0, react_1.useState)(false), isUploading = _a[0], setIsUploading = _a[1];
74
- var _b = (0, react_1.useState)(undefined), filename = _b[0], setFilename = _b[1];
74
+ var _b = (0, react_1.useState)(false), isUploading = _b[0], setIsUploading = _b[1];
75
+ var _c = (0, react_1.useState)(undefined), filename = _c[0], setFilename = _c[1];
75
76
  var inputRef = (0, react_1.useRef)(null);
76
77
  var imgRef = (0, react_1.useRef)(null);
77
78
  var cls = (0, utils_1.generateInputClassName)('upload', customClassName, title);
@@ -120,7 +121,7 @@ var UploadArea = function (props) {
120
121
  react_1.default.createElement("button", { type: "button", onClick: handleClick }, isUploading ? (react_1.default.createElement(uploadArea_styles_1.UploadingWrapper, null,
121
122
  react_1.default.createElement("div", null,
122
123
  react_1.default.createElement(icons_1.SpinnerIcon, { size: "28px" })),
123
- react_1.default.createElement("div", null, "Uploading..."))) : (value === null || value === void 0 ? void 0 : value.length) ? (react_1.default.createElement(uploadArea_styles_1.UploadingWrapper, null,
124
+ react_1.default.createElement("div", null, "Uploading..."))) : ((_a = value) === null || _a === void 0 ? void 0 : _a.length) ? (react_1.default.createElement(uploadArea_styles_1.UploadingWrapper, null,
124
125
  react_1.default.createElement("div", null,
125
126
  react_1.default.createElement("img", { ref: imgRef, src: "#" })),
126
127
  react_1.default.createElement("div", null,
@@ -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], removeFromWishlist = _b[2], resumeWishlistItem = _b[3], shareWishlistItem = _b[4];
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: function () { return removeFromWishlist(i); }, onResume: function () { return handleClickResume(i); }, onShare: function () { return shareWishlistItem(i); } })); })))));
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 = {
@@ -25,7 +25,7 @@ export interface IFormContainerProps extends Pick<MetadataKeys, 'metadataKeyThum
25
25
  sort?: string;
26
26
  title?: string;
27
27
  description?: string;
28
- value?: string;
28
+ value?: string | boolean;
29
29
  onClick?: (value: RawAttributeValue) => Promise<void>;
30
30
  onChange?: (value: RawAttributeValue) => Promise<void>;
31
31
  className?: string;
@@ -36,12 +36,12 @@ export interface IFormComponentProps<T extends IOptionShared | undefined> extend
36
36
  export interface IFormComponent<P> extends FunctionComponent<P> {
37
37
  compatibleAttributes: Set<string>;
38
38
  }
39
- interface IPrepAttributeConfig {
39
+ interface IHydrateAttributeConfig {
40
40
  metadataKeys: MetadataKeys;
41
41
  sort?: string;
42
42
  }
43
- export declare const prepAttributeForComponent: (attribute: IHydratedAttribute, config: IPrepAttributeConfig) => {
44
- selected: string | number | import("../../threekit").IConfigurationAsset | import("../../threekit").IConfigurationColor;
43
+ export declare const hydrateAttributeForComponent: (attribute: IHydratedAttribute, config: IHydrateAttributeConfig) => {
44
+ selected: string | number | boolean | import("../../threekit").IConfigurationAsset | import("../../threekit").IConfigurationColor;
45
45
  options: {
46
46
  name: string;
47
47
  handleSelect: () => Promise<void>;
@@ -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.prepAttributeForComponent = void 0;
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 prepAttributeForComponent = function (attribute, config) {
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;
@@ -76,7 +76,7 @@ var prepAttributeForComponent = function (attribute, config) {
76
76
  }
77
77
  return { selected: selected, options: options };
78
78
  };
79
- exports.prepAttributeForComponent = prepAttributeForComponent;
79
+ exports.hydrateAttributeForComponent = hydrateAttributeForComponent;
80
80
  function formComponentContainer(FormComponent) {
81
81
  return function (props) {
82
82
  var attribute = props.attribute, metadataKeyThumbnail = props.metadataKeyThumbnail, metadataKeyDescription = props.metadataKeyDescription, metadataKeyPrice = props.metadataKeyPrice, hideAttributeTitle = props.hideAttributeTitle, sort = props.sort;
@@ -90,7 +90,7 @@ function formComponentContainer(FormComponent) {
90
90
  console.log('Incompatible attribute type for this component');
91
91
  return null;
92
92
  }
93
- var _b = (0, exports.prepAttributeForComponent)(attributeData, {
93
+ var _b = (0, exports.hydrateAttributeForComponent)(attributeData, {
94
94
  metadataKeys: {
95
95
  metadataKeyThumbnail: metadataKeyThumbnail,
96
96
  metadataKeyDescription: metadataKeyDescription,
@@ -18,7 +18,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
21
- var _a, _b, _c, _d, _e;
21
+ var _a, _b, _c, _d, _e, _f;
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.formComponents = exports.FORM_COMPONENT_TYPES = void 0;
24
24
  var constants_1 = require("../constants");
@@ -31,6 +31,7 @@ var TilesGroup_1 = __importStar(require("./TilesGroup"));
31
31
  var Upload_1 = __importStar(require("./Upload"));
32
32
  // import UploadArea, { UploadArea as UploadAreaComponent } from './UploadArea';
33
33
  var TextInput_1 = __importStar(require("./TextInput"));
34
+ var Switch_1 = __importStar(require("./Switch"));
34
35
  exports.FORM_COMPONENT_TYPES = {
35
36
  stringInput: 'string-input',
36
37
  };
@@ -59,5 +60,8 @@ exports.formComponents = (_a = {},
59
60
  _a[constants_1.ASSET_TYPES.upload] = (_e = {},
60
61
  _e[Upload_1.Upload.componentName] = Upload_1.default,
61
62
  _e),
63
+ _a[constants_1.ATTRIBUTE_TYPES.boolean] = (_f = {},
64
+ _f[Switch_1.Switch.componentName] = Switch_1.default,
65
+ _f),
62
66
  _a);
63
67
  exports.default = exports.formComponents;
@@ -43,16 +43,19 @@ var store_1 = require("../../store");
43
43
  var attributes_1 = require("../../store/attributes");
44
44
  var utils_1 = require("../../utils");
45
45
  var api_1 = __importDefault(require("../../api"));
46
+ var utils_2 = require("../../utils");
46
47
  var useAttribute = function (attributeName) {
48
+ var _a;
47
49
  if (!attributeName)
48
50
  return [undefined, undefined];
49
51
  var dispatch = (0, store_1.useThreekitDispatch)();
50
- var attributes = (0, store_1.useThreekitSelector)(attributes_1.getHydratedAttributes);
52
+ var _b = (0, store_1.useThreekitSelector)(attributes_1.getHydrationData), attributes = _b[0], translations = _b[1], language = _b[2];
51
53
  if (!attributeName || !attributes)
52
54
  return [undefined, undefined];
53
55
  var attribute = attributes[attributeName];
54
56
  if (!attribute)
55
57
  return [undefined, undefined];
58
+ var preppedAttributes = (0, utils_2.hydrateAttribute)([(_a = {}, _a[attributeName] = attribute, _a), translations, language], function (config) { return dispatch((0, attributes_1.setConfiguration)(config)); });
56
59
  var handleChange = function (value) { return __awaiter(void 0, void 0, void 0, function () {
57
60
  var preppedValue, assetId;
58
61
  var _a;
@@ -81,6 +84,6 @@ var useAttribute = function (attributeName) {
81
84
  }
82
85
  });
83
86
  }); };
84
- return [attribute, handleChange];
87
+ return [preppedAttributes[attributeName], handleChange];
85
88
  };
86
89
  exports.default = useAttribute;
@@ -2,14 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var attributes_1 = require("../../store/attributes");
4
4
  var store_1 = require("../../store");
5
+ var utils_1 = require("../../utils");
5
6
  var useConfigurator = function () {
6
7
  var dispatch = (0, store_1.useThreekitDispatch)();
7
- var attributes = (0, store_1.useThreekitSelector)(attributes_1.getHydratedAttributes);
8
- if (!attributes)
8
+ var hydrationData = (0, store_1.useThreekitSelector)(attributes_1.getHydrationData);
9
+ if (!hydrationData)
9
10
  return [undefined, undefined];
11
+ var preppedAttributes = (0, utils_1.hydrateAttribute)(hydrationData, function (config) {
12
+ return dispatch((0, attributes_1.setConfiguration)(config));
13
+ });
10
14
  var handleChange = function (configuration) {
11
15
  return dispatch((0, attributes_1.setConfiguration)(configuration));
12
16
  };
13
- return [attributes, handleChange];
17
+ return [preppedAttributes, handleChange];
14
18
  };
15
19
  exports.default = useConfigurator;
@@ -0,0 +1,8 @@
1
+ import { IHydratedAttribute, ISetConfiguration } from '../../threekit';
2
+ declare type UseNestedConfiguratorError = [undefined, undefined];
3
+ declare type UseNestedConfiguratorSuccess = [
4
+ Record<string, IHydratedAttribute>,
5
+ (val: ISetConfiguration) => Promise<void>
6
+ ];
7
+ declare const useNestedConfigurator: (address: string | Array<string>) => UseNestedConfiguratorError | UseNestedConfiguratorSuccess;
8
+ export default useNestedConfigurator;