@threekit-tools/treble 0.0.94-next-01 → 0.0.94-next-02
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.js +3 -2
- package/dist/api/assets.d.ts +1 -0
- package/dist/api/{products.js → assets.js} +11 -32
- package/dist/api/configurations.d.ts +1 -0
- package/dist/api/configurations.js +9 -2
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.js +2 -2
- package/dist/components/ThreekitProvider/index.d.ts +5 -2
- package/dist/components/ThreekitProvider/index.js +27 -2
- package/dist/components/TrebleApp/index.js +5 -0
- package/dist/hooks/useAttribute/index.js +2 -2
- package/dist/hooks/useConfigurator/index.js +3 -5
- package/dist/hooks/useNestedConfigurator/index.js +2 -2
- package/dist/hooks/useShare/index.js +3 -1
- package/dist/hooks/useSpaces/SpacesState.js +7 -5
- package/dist/hooks/useSpaces/dataHandlers.js +0 -4
- package/dist/hooks/useSpaces/index.js +11 -79
- package/dist/http/assets.d.ts +2 -0
- package/dist/http/assets.js +16 -0
- package/dist/http/index.d.ts +2 -2
- package/dist/http/index.js +2 -2
- package/dist/store/attributes.d.ts +2 -2
- package/dist/store/attributes.js +1 -3
- package/dist/store/translations.d.ts +9 -7
- package/dist/store/translations.js +38 -18
- package/dist/types.d.ts +2 -0
- package/dist/utils.d.ts +3 -7
- package/dist/utils.js +12 -13
- package/package.json +1 -1
- package/dist/api/products.d.ts +0 -4
- package/dist/http/products.d.ts +0 -1
- package/dist/http/products.js +0 -12
package/dist/Treble/Treble.js
CHANGED
|
@@ -80,14 +80,14 @@ var Treble = (function () {
|
|
|
80
80
|
});
|
|
81
81
|
}); };
|
|
82
82
|
this.saveConfiguration = function (config) { return __awaiter(_this, void 0, void 0, function () {
|
|
83
|
-
var threekitDomain, _a, customerId, metadata, configuration, productVersion, attachments, player, response, params, url;
|
|
83
|
+
var threekitDomain, _a, customerId, metadata, configuration, productVersion, attachments, creator, player, response, params, url;
|
|
84
84
|
var _b;
|
|
85
85
|
var _c;
|
|
86
86
|
return __generator(this, function (_d) {
|
|
87
87
|
switch (_d.label) {
|
|
88
88
|
case 0:
|
|
89
89
|
threekitDomain = connection_1.default.getConnection().threekitDomain;
|
|
90
|
-
_a = Object.assign({}, config), customerId = _a.customerId, metadata = _a.metadata, configuration = _a.configuration, productVersion = _a.productVersion, attachments = _a.attachments;
|
|
90
|
+
_a = Object.assign({}, config), customerId = _a.customerId, metadata = _a.metadata, configuration = _a.configuration, productVersion = _a.productVersion, attachments = _a.attachments, creator = _a.creator;
|
|
91
91
|
player = window.threekit.player.enableApi(types_1.PRIVATE_APIS.PLAYER);
|
|
92
92
|
return [4, api_1.default.configurations.save({
|
|
93
93
|
assetId: window.threekit.player.assetId,
|
|
@@ -96,6 +96,7 @@ var Treble = (function () {
|
|
|
96
96
|
metadata: metadata,
|
|
97
97
|
productVersion: productVersion,
|
|
98
98
|
attachments: attachments,
|
|
99
|
+
creator: creator,
|
|
99
100
|
})];
|
|
100
101
|
case 1:
|
|
101
102
|
response = _d.sent();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fetchTranslations: (locale: string) => Promise<import("../http/assets").ITranslationsMap>;
|
|
@@ -41,36 +41,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.fetchTranslations = void 0;
|
|
43
43
|
var http_1 = __importDefault(require("../http"));
|
|
44
|
-
var fetchTranslations = function () {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.map(function (el) { return el.split(','); });
|
|
56
|
-
languages = csvData[0];
|
|
57
|
-
translationMap = csvData.reduce(function (output, row, idx) {
|
|
58
|
-
if (!idx)
|
|
59
|
-
return output;
|
|
60
|
-
output[row[0]] = row.reduce(function (result, el, i) {
|
|
61
|
-
var _a;
|
|
62
|
-
if (!i)
|
|
63
|
-
return result;
|
|
64
|
-
return Object.assign(result, (_a = {},
|
|
65
|
-
_a[languages[i]] = el.length ? el : undefined,
|
|
66
|
-
_a));
|
|
67
|
-
}, {});
|
|
68
|
-
return output;
|
|
69
|
-
}, {});
|
|
70
|
-
resolve(translationMap);
|
|
71
|
-
return [2];
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}); });
|
|
75
|
-
};
|
|
44
|
+
var fetchTranslations = function (locale) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
+
var response;
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0: return [4, http_1.default.assets.getTranslationsForLocale(locale)];
|
|
49
|
+
case 1:
|
|
50
|
+
response = _a.sent();
|
|
51
|
+
return [2, response.data];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}); };
|
|
76
55
|
exports.fetchTranslations = fetchTranslations;
|
|
@@ -7,6 +7,7 @@ export interface ISaveConfiguration {
|
|
|
7
7
|
metadata?: IMetadata;
|
|
8
8
|
productVersion?: string;
|
|
9
9
|
attachments?: Record<string, File>;
|
|
10
|
+
creator?: string;
|
|
10
11
|
}
|
|
11
12
|
export declare const save: (saveConfig: ISaveConfiguration) => Promise<import("axios").AxiosResponse<IConfigurationResponse>>;
|
|
12
13
|
export declare const fetch: (configurationId: string) => Promise<import("axios").AxiosResponse<IConfigurationResponse>>;
|
|
@@ -42,9 +42,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.fetchAll = exports.fetch = exports.save = void 0;
|
|
43
43
|
var http_1 = __importDefault(require("../http"));
|
|
44
44
|
var save = function (saveConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
-
var assetId, customerId, configuration, metadata, productVersion, attachments, error, fd, attachmentsPrepped_1;
|
|
45
|
+
var assetId, customerId, configuration, metadata, productVersion, attachments, creator, error, fd, attachmentsPrepped_1;
|
|
46
46
|
return __generator(this, function (_a) {
|
|
47
|
-
assetId = saveConfig.assetId, customerId = saveConfig.customerId, configuration = saveConfig.configuration, metadata = saveConfig.metadata, productVersion = saveConfig.productVersion, attachments = saveConfig.attachments;
|
|
47
|
+
assetId = saveConfig.assetId, customerId = saveConfig.customerId, configuration = saveConfig.configuration, metadata = saveConfig.metadata, productVersion = saveConfig.productVersion, attachments = saveConfig.attachments, creator = saveConfig.creator;
|
|
48
48
|
if (!assetId)
|
|
49
49
|
error = 'Requires Asset Id';
|
|
50
50
|
if (!configuration)
|
|
@@ -71,6 +71,13 @@ var save = function (saveConfig) { return __awaiter(void 0, void 0, void 0, func
|
|
|
71
71
|
});
|
|
72
72
|
fd.append('attachments', JSON.stringify(attachmentsPrepped_1));
|
|
73
73
|
}
|
|
74
|
+
fd.append('sessionId', window.threekit.player.sessionId);
|
|
75
|
+
if (creator) {
|
|
76
|
+
fd.append('creator', creator);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
fd.append('creator', 'player api');
|
|
80
|
+
}
|
|
74
81
|
return [2, http_1.default.configurations.postConfiguration(fd)];
|
|
75
82
|
});
|
|
76
83
|
}); };
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as assets from './assets';
|
|
2
2
|
import * as configurations from './configurations';
|
|
3
3
|
import * as price from './price';
|
|
4
4
|
import * as orders from './orders';
|
|
@@ -6,7 +6,7 @@ import * as catalog from './catalog';
|
|
|
6
6
|
import * as datatables from './datatables';
|
|
7
7
|
import * as server from './server';
|
|
8
8
|
declare const _default: {
|
|
9
|
-
|
|
9
|
+
assets: typeof assets;
|
|
10
10
|
configurations: typeof configurations;
|
|
11
11
|
price: typeof price;
|
|
12
12
|
orders: typeof orders;
|
package/dist/api/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
var
|
|
26
|
+
var assets = __importStar(require("./assets"));
|
|
27
27
|
var configurations = __importStar(require("./configurations"));
|
|
28
28
|
var price = __importStar(require("./price"));
|
|
29
29
|
var orders = __importStar(require("./orders"));
|
|
@@ -31,7 +31,7 @@ var catalog = __importStar(require("./catalog"));
|
|
|
31
31
|
var datatables = __importStar(require("./datatables"));
|
|
32
32
|
var server = __importStar(require("./server"));
|
|
33
33
|
exports.default = {
|
|
34
|
-
|
|
34
|
+
assets: assets,
|
|
35
35
|
configurations: configurations,
|
|
36
36
|
price: price,
|
|
37
37
|
orders: orders,
|
|
@@ -4,11 +4,14 @@ import { ILaunchConfig } from '../../store/treble';
|
|
|
4
4
|
interface Theme {
|
|
5
5
|
[key: string]: string | number;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
interface AppProps extends Partial<ILaunchConfig> {
|
|
8
8
|
productId?: string;
|
|
9
9
|
theme?: Theme;
|
|
10
|
-
reducer?: Record<string, Reducer>;
|
|
11
10
|
children: React.ReactNode;
|
|
12
11
|
}
|
|
12
|
+
export interface ThreekitProviderProps extends AppProps {
|
|
13
|
+
reducer?: Record<string, Reducer>;
|
|
14
|
+
removeTheme?: boolean;
|
|
15
|
+
}
|
|
13
16
|
declare const ThreekitProvider: (props: ThreekitProviderProps) => JSX.Element;
|
|
14
17
|
export default ThreekitProvider;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -57,10 +68,24 @@ var App = function (props) {
|
|
|
57
68
|
return react_1.default.createElement(react_1.default.Fragment, null, props.children);
|
|
58
69
|
};
|
|
59
70
|
var ThreekitProvider = function (props) {
|
|
71
|
+
var appProps = {
|
|
72
|
+
locale: props.locale,
|
|
73
|
+
assetId: props.assetId,
|
|
74
|
+
customId: props.customId,
|
|
75
|
+
productId: props.productId,
|
|
76
|
+
project: props.project,
|
|
77
|
+
playerConfig: props.playerConfig,
|
|
78
|
+
threekitEnv: props.threekitEnv,
|
|
79
|
+
eventHandlers: props.eventHandlers,
|
|
80
|
+
};
|
|
81
|
+
if (props.removeTheme)
|
|
82
|
+
return (react_1.default.createElement(react_redux_1.Provider, { store: (0, store_1.default)(props.reducer) },
|
|
83
|
+
react_1.default.createElement(App, __assign({}, appProps), props.children),
|
|
84
|
+
constants_1.TREBLE_DEBUG ? null : react_1.default.createElement(DevTools_1.default, null)));
|
|
60
85
|
return (react_1.default.createElement(react_redux_1.Provider, { store: (0, store_1.default)(props.reducer) },
|
|
61
86
|
react_1.default.createElement(styled_components_1.ThemeProvider, { theme: theme_1.default },
|
|
62
|
-
react_1.default.createElement(GlobalStyles_styles_1.default, null),
|
|
63
|
-
react_1.default.createElement(App, {
|
|
87
|
+
props.removeTheme ? null : react_1.default.createElement(GlobalStyles_styles_1.default, null),
|
|
88
|
+
react_1.default.createElement(App, __assign({}, appProps), props.children),
|
|
64
89
|
constants_1.TREBLE_DEBUG ? null : react_1.default.createElement(DevTools_1.default, null))));
|
|
65
90
|
};
|
|
66
91
|
exports.default = ThreekitProvider;
|
|
@@ -66,6 +66,11 @@ function TrebleApp(props) {
|
|
|
66
66
|
react_1.Children.forEach(Object.values(productComponents).map(function (el) { return el({}); }), function (jsx, i) {
|
|
67
67
|
if (!jsx)
|
|
68
68
|
return;
|
|
69
|
+
if (typeof jsx === 'string' ||
|
|
70
|
+
typeof jsx === 'boolean' ||
|
|
71
|
+
typeof jsx === 'number' ||
|
|
72
|
+
!('props' in jsx))
|
|
73
|
+
return;
|
|
69
74
|
if (!jsx.props.products)
|
|
70
75
|
return;
|
|
71
76
|
var products = jsx.props.products;
|
|
@@ -45,13 +45,13 @@ var useAttribute = function (attributeName) {
|
|
|
45
45
|
if (!attributeName)
|
|
46
46
|
return [undefined, undefined];
|
|
47
47
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
48
|
-
var _b = (0, store_1.useThreekitSelector)(attributes_1.getHydrationData), attributes = _b[0], translations = _b[1]
|
|
48
|
+
var _b = (0, store_1.useThreekitSelector)(attributes_1.getHydrationData), attributes = _b[0], translations = _b[1];
|
|
49
49
|
if (!attributeName || !attributes)
|
|
50
50
|
return [undefined, undefined];
|
|
51
51
|
var attribute = attributes[attributeName];
|
|
52
52
|
if (!attribute)
|
|
53
53
|
return [undefined, undefined];
|
|
54
|
-
var preppedAttributes = (0, utils_2.hydrateAttribute)([(_a = {}, _a[attributeName] = attribute, _a), translations
|
|
54
|
+
var preppedAttributes = (0, utils_2.hydrateAttribute)([(_a = {}, _a[attributeName] = attribute, _a), translations], function (config) { return dispatch((0, attributes_1.setConfiguration)(config)); });
|
|
55
55
|
var handleChange = function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
56
|
var preppedValue, assetId;
|
|
57
57
|
var _a;
|
|
@@ -5,12 +5,10 @@ var store_1 = require("../../store");
|
|
|
5
5
|
var utils_1 = require("../../utils");
|
|
6
6
|
var useConfigurator = function () {
|
|
7
7
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
8
|
-
var
|
|
9
|
-
if (!
|
|
8
|
+
var _a = (0, store_1.useThreekitSelector)(attributes_1.getHydrationData), attributes = _a[0], translations = _a[1];
|
|
9
|
+
if (!attributes || !translations)
|
|
10
10
|
return [undefined, undefined];
|
|
11
|
-
var preppedAttributes = (0, utils_1.hydrateAttribute)(
|
|
12
|
-
return dispatch((0, attributes_1.setConfiguration)(config));
|
|
13
|
-
});
|
|
11
|
+
var preppedAttributes = (0, utils_1.hydrateAttribute)([attributes, translations], function (config) { return dispatch((0, attributes_1.setConfiguration)(config)); });
|
|
14
12
|
var handleChange = function (configuration) {
|
|
15
13
|
return dispatch((0, attributes_1.setConfiguration)(configuration));
|
|
16
14
|
};
|
|
@@ -47,7 +47,7 @@ var useNestedConfigurator = function (address) {
|
|
|
47
47
|
var hasInitialized = (0, store_1.useThreekitSelector)(treble_1.isThreekitInitialized);
|
|
48
48
|
var playerLoading = (0, store_1.useThreekitSelector)(treble_1.isPlayerLoading);
|
|
49
49
|
var priceConfig = (0, store_1.useThreekitSelector)(price_1.getPriceConfig);
|
|
50
|
-
var _a = (0, store_1.useThreekitSelector)(attributes_1.getHydrationData), _ = _a[0], translations = _a[1]
|
|
50
|
+
var _a = (0, store_1.useThreekitSelector)(attributes_1.getHydrationData), _ = _a[0], translations = _a[1];
|
|
51
51
|
var _b = (0, react_1.useState)(), attributes = _b[0], setAttributes = _b[1];
|
|
52
52
|
var metadataRef = (0, react_1.useRef)({});
|
|
53
53
|
var configurator = (0, react_1.useRef)();
|
|
@@ -89,7 +89,7 @@ var useNestedConfigurator = function (address) {
|
|
|
89
89
|
var _a;
|
|
90
90
|
return Object.assign(output, (_a = {}, _a[attr.name] = attr, _a));
|
|
91
91
|
}, {});
|
|
92
|
-
var preppedAttributes = (0, utils_1.hydrateAttribute)([attributeObj, translations,
|
|
92
|
+
var preppedAttributes = (0, utils_1.hydrateAttribute)([attributeObj, translations], handleSelect, configurator.current.getResolvedConfiguration());
|
|
93
93
|
var price = priceConfig
|
|
94
94
|
? configurator.current.getPrice(priceConfig.id, priceConfig.currency)
|
|
95
95
|
: undefined;
|
|
@@ -53,7 +53,9 @@ var useShare = function () {
|
|
|
53
53
|
var configuration;
|
|
54
54
|
return __generator(this, function (_a) {
|
|
55
55
|
switch (_a.label) {
|
|
56
|
-
case 0: return [4, window.threekit.treble.saveConfiguration(
|
|
56
|
+
case 0: return [4, window.threekit.treble.saveConfiguration({
|
|
57
|
+
creator: 'threekit share button',
|
|
58
|
+
})];
|
|
57
59
|
case 1:
|
|
58
60
|
configuration = _a.sent();
|
|
59
61
|
if (!configuration)
|
|
@@ -135,7 +135,7 @@ var SpacesState = (function () {
|
|
|
135
135
|
return;
|
|
136
136
|
var wallIndex = (_a = _this.getWallIndexInProximity(moveToPoint)) !== null && _a !== void 0 ? _a : feature.connectedTo[1];
|
|
137
137
|
var wall = _this.getWall(wallIndex);
|
|
138
|
-
if (
|
|
138
|
+
if ((wall === null || wall === void 0 ? void 0 : wall.mode) !== constants_1.WallModes.WALL)
|
|
139
139
|
return;
|
|
140
140
|
var intersection = (0, geometry_1.getTangetIntersectionAndOffset)(wall.line, moveToPoint);
|
|
141
141
|
if (!intersection)
|
|
@@ -937,11 +937,13 @@ var SpacesState = (function () {
|
|
|
937
937
|
this.pushStateToConfigurator();
|
|
938
938
|
};
|
|
939
939
|
SpacesState.prototype.getFirstVacantLocationOnWallIndex = function (length, wallIndex) {
|
|
940
|
-
var _a, _b;
|
|
941
|
-
|
|
940
|
+
var _a, _b, _c;
|
|
941
|
+
if (((_a = this.getWall(wallIndex)) === null || _a === void 0 ? void 0 : _a.mode) !== constants_1.WallModes.WALL)
|
|
942
|
+
return undefined;
|
|
943
|
+
var _d = this, walls = _d.walls, validationConfig = _d.validationConfig;
|
|
942
944
|
var padding = validationConfig.padding;
|
|
943
945
|
var wallLength = (0, geometry_1.getLengthOfLineSegment)(walls[wallIndex].line);
|
|
944
|
-
var features = (
|
|
946
|
+
var features = (_c = (_b = this.getWallConnectionsHydrated(wallIndex)) === null || _b === void 0 ? void 0 : _b.sort(function (a, b) { return a.offset - b.offset; })) !== null && _c !== void 0 ? _c : [];
|
|
945
947
|
for (var j = 0; j <= features.length; j++) {
|
|
946
948
|
var prev = features[j - 1];
|
|
947
949
|
var next = features[j];
|
|
@@ -1059,7 +1061,7 @@ var SpacesState = (function () {
|
|
|
1059
1061
|
var length = ((feature === null || feature === void 0 ? void 0 : feature.length) || constants_1.FEATURE_LENGTH) / this.scale;
|
|
1060
1062
|
if (addToWallIndex !== undefined && (feature === null || feature === void 0 ? void 0 : feature.offset) !== undefined) {
|
|
1061
1063
|
var wall = this.getWall(addToWallIndex);
|
|
1062
|
-
if (wall) {
|
|
1064
|
+
if ((wall === null || wall === void 0 ? void 0 : wall.mode) === constants_1.WallModes.WALL) {
|
|
1063
1065
|
var isColliding = (0, validators_1.isFeatureCollidingWithExistingFeature)({
|
|
1064
1066
|
wall: wall,
|
|
1065
1067
|
updatedFeature: {
|
|
@@ -264,10 +264,6 @@ function prepLengthForUser(value, unit) {
|
|
|
264
264
|
if (unit === types_1.IUnits.FEET) {
|
|
265
265
|
var feet = Math.floor(value);
|
|
266
266
|
var inches = 12 * (value % 1);
|
|
267
|
-
if (inches > 11.95) {
|
|
268
|
-
feet += 1;
|
|
269
|
-
inches = 0;
|
|
270
|
-
}
|
|
271
267
|
return "".concat(feet).concat(constants_1.UNIT_LABELS[types_1.IUnits.FEET], " ").concat(inches.toFixed(1)).concat(constants_1.UNIT_LABELS[types_1.IUnits.INCH]);
|
|
272
268
|
}
|
|
273
269
|
return "".concat(value.toFixed(2), " ").concat(constants_1.UNIT_LABELS[unit]);
|
|
@@ -60,14 +60,6 @@ var SpacesLayout_1 = __importDefault(require("./SpacesLayout"));
|
|
|
60
60
|
var store_1 = require("../../store");
|
|
61
61
|
var spaces_1 = require("../../store/spaces");
|
|
62
62
|
var useThreekitInitStatus_1 = __importDefault(require("../useThreekitInitStatus"));
|
|
63
|
-
var getLocalTouchPoint = function (touch, rect) {
|
|
64
|
-
if (touch.clientY < rect.top ||
|
|
65
|
-
rect.bottom < touch.clientY ||
|
|
66
|
-
touch.clientX < rect.left ||
|
|
67
|
-
rect.right < touch.clientX)
|
|
68
|
-
return undefined;
|
|
69
|
-
return [touch.clientX - rect.left, touch.clientY - rect.top];
|
|
70
|
-
};
|
|
71
63
|
var useSpaces = function (props) {
|
|
72
64
|
var _a, _b, _c, _d, _e;
|
|
73
65
|
var attributesState = (0, useConfigurator_1.default)()[0];
|
|
@@ -179,22 +171,14 @@ var useSpaces = function (props) {
|
|
|
179
171
|
return;
|
|
180
172
|
if (canvasRef.current) {
|
|
181
173
|
canvasRef.current.addEventListener('mousedown', handleDrawWallStart);
|
|
182
|
-
canvasRef.current.addEventListener('touchstart', handleDrawWallStart);
|
|
183
174
|
canvasRef.current.addEventListener('mousemove', handleDrawWallMouseMove);
|
|
184
|
-
canvasRef.current.addEventListener('touchmove', handleDrawWallMouseMove);
|
|
185
175
|
document.addEventListener('mouseup', handleDrawWallFinish);
|
|
186
|
-
document.addEventListener('touchend', handleDrawWallFinish);
|
|
187
176
|
canvasRef.current.addEventListener('mousemove', handleHover);
|
|
188
177
|
canvasRef.current.addEventListener('mousedown', handleSelectElement);
|
|
189
|
-
canvasRef.current.addEventListener('touchstart', handleSelectElement);
|
|
190
178
|
canvasRef.current.addEventListener('mousemove', handleMoveSelectedElement);
|
|
191
|
-
|
|
192
|
-
if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled)) {
|
|
179
|
+
if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled))
|
|
193
180
|
canvasRef.current.addEventListener('mousemove', handleMoveCanvas);
|
|
194
|
-
canvasRef.current.addEventListener('touchmove', handleMoveCanvas);
|
|
195
|
-
}
|
|
196
181
|
document.addEventListener('mouseup', handleFinishMove);
|
|
197
|
-
document.addEventListener('touchend', handleFinishMove);
|
|
198
182
|
if (!((_b = props.config) === null || _b === void 0 ? void 0 : _b.zoomDisabled))
|
|
199
183
|
canvasRef.current.addEventListener('wheel', handleScrollToZoom);
|
|
200
184
|
}
|
|
@@ -202,22 +186,14 @@ var useSpaces = function (props) {
|
|
|
202
186
|
var _a, _b;
|
|
203
187
|
if (canvasRef.current) {
|
|
204
188
|
canvasRef.current.removeEventListener('mousedown', handleDrawWallStart);
|
|
205
|
-
canvasRef.current.removeEventListener('touchstart', handleDrawWallStart);
|
|
206
189
|
canvasRef.current.removeEventListener('mousemove', handleDrawWallMouseMove);
|
|
207
|
-
canvasRef.current.removeEventListener('touchmove', handleDrawWallMouseMove);
|
|
208
190
|
document.removeEventListener('mouseup', handleDrawWallFinish);
|
|
209
|
-
document.removeEventListener('touchend', handleDrawWallFinish);
|
|
210
191
|
canvasRef.current.removeEventListener('mousemove', handleHover);
|
|
211
192
|
canvasRef.current.removeEventListener('mousedown', handleSelectElement);
|
|
212
|
-
canvasRef.current.removeEventListener('touchstart', handleSelectElement);
|
|
213
193
|
canvasRef.current.removeEventListener('mousemove', handleMoveSelectedElement);
|
|
214
|
-
|
|
215
|
-
if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled)) {
|
|
194
|
+
if (!((_a = props.config) === null || _a === void 0 ? void 0 : _a.translateDisabled))
|
|
216
195
|
canvasRef.current.removeEventListener('mousemove', handleMoveCanvas);
|
|
217
|
-
canvasRef.current.removeEventListener('touchmove', handleMoveCanvas);
|
|
218
|
-
}
|
|
219
196
|
document.removeEventListener('mouseup', handleFinishMove);
|
|
220
|
-
document.removeEventListener('touchend', handleFinishMove);
|
|
221
197
|
if (!((_b = props.config) === null || _b === void 0 ? void 0 : _b.zoomDisabled))
|
|
222
198
|
canvasRef.current.removeEventListener('wheel', handleScrollToZoom);
|
|
223
199
|
}
|
|
@@ -267,15 +243,7 @@ var useSpaces = function (props) {
|
|
|
267
243
|
return;
|
|
268
244
|
if (modeValue !== types_2.IModes.SELECT)
|
|
269
245
|
return;
|
|
270
|
-
var cursorPoint;
|
|
271
|
-
if ('offsetX' in e && 'offsetY' in e)
|
|
272
|
-
cursorPoint = [e.offsetX, e.offsetY];
|
|
273
|
-
else {
|
|
274
|
-
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
275
|
-
if (!localTouchPoint)
|
|
276
|
-
return;
|
|
277
|
-
cursorPoint = localTouchPoint;
|
|
278
|
-
}
|
|
246
|
+
var cursorPoint = [e.offsetX, e.offsetY];
|
|
279
247
|
spacesRef.current.selectElementIfInProximity(canvasRef.current, cursorPoint);
|
|
280
248
|
var element = spacesRef.current.getElementUiAtPoint(cursorPoint);
|
|
281
249
|
if (!element) {
|
|
@@ -298,15 +266,7 @@ var useSpaces = function (props) {
|
|
|
298
266
|
return;
|
|
299
267
|
if (!canvasRef.current)
|
|
300
268
|
return;
|
|
301
|
-
var point;
|
|
302
|
-
if ('offsetX' in e && 'offsetY' in e)
|
|
303
|
-
point = [e.offsetX, e.offsetY];
|
|
304
|
-
else {
|
|
305
|
-
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
306
|
-
if (!localTouchPoint)
|
|
307
|
-
return;
|
|
308
|
-
point = localTouchPoint;
|
|
309
|
-
}
|
|
269
|
+
var point = [e.offsetX, e.offsetY];
|
|
310
270
|
spacesRef.current.moveActiveElement(canvasRef.current, point);
|
|
311
271
|
selectElementPending.current = null;
|
|
312
272
|
};
|
|
@@ -319,24 +279,15 @@ var useSpaces = function (props) {
|
|
|
319
279
|
return;
|
|
320
280
|
if (spacesRef.current.selectedElement || !translationAnchorRef.current)
|
|
321
281
|
return;
|
|
322
|
-
var point;
|
|
323
|
-
if ('offsetX' in e && 'offsetY' in e)
|
|
324
|
-
point = [e.offsetX, e.offsetY];
|
|
325
|
-
else {
|
|
326
|
-
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
327
|
-
if (!localTouchPoint)
|
|
328
|
-
return;
|
|
329
|
-
point = localTouchPoint;
|
|
330
|
-
}
|
|
331
282
|
spacesRef.current.translate = [
|
|
332
283
|
spacesRef.current.translate[0] +
|
|
333
|
-
|
|
284
|
+
e.offsetX -
|
|
334
285
|
translationAnchorRef.current[0],
|
|
335
286
|
spacesRef.current.translate[1] +
|
|
336
|
-
|
|
287
|
+
e.offsetY -
|
|
337
288
|
translationAnchorRef.current[1],
|
|
338
289
|
];
|
|
339
|
-
translationAnchorRef.current =
|
|
290
|
+
translationAnchorRef.current = [e.offsetX, e.offsetY];
|
|
340
291
|
drawSpaces();
|
|
341
292
|
};
|
|
342
293
|
var handleFinishMove = function (e) {
|
|
@@ -370,38 +321,19 @@ var useSpaces = function (props) {
|
|
|
370
321
|
spacesRef.current.showGuideAtPoint(canvas, cursorPoint);
|
|
371
322
|
};
|
|
372
323
|
var handleDrawWallStart = function (e) {
|
|
373
|
-
if (!spacesRef.current
|
|
324
|
+
if (!spacesRef.current)
|
|
374
325
|
return;
|
|
375
326
|
if (modeValue !== types_2.IModes.DRAW)
|
|
376
327
|
return;
|
|
377
|
-
|
|
378
|
-
if ('offsetX' in e && 'offsetY' in e)
|
|
379
|
-
startPoint = [e.offsetX, e.offsetY];
|
|
380
|
-
else {
|
|
381
|
-
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
382
|
-
if (!localTouchPoint)
|
|
383
|
-
return;
|
|
384
|
-
startPoint = localTouchPoint;
|
|
385
|
-
}
|
|
386
|
-
spacesRef.current.startDrawNewWall(startPoint);
|
|
328
|
+
spacesRef.current.startDrawNewWall([e.offsetX, e.offsetY]);
|
|
387
329
|
};
|
|
388
330
|
var handleDrawWallMouseMove = function (e) {
|
|
389
331
|
if (!spacesRef.current || !canvasRef.current)
|
|
390
332
|
return;
|
|
391
333
|
if (modeValue !== types_2.IModes.DRAW)
|
|
392
334
|
return;
|
|
393
|
-
if (
|
|
394
|
-
|
|
395
|
-
var point;
|
|
396
|
-
if ('offsetX' in e && 'offsetY' in e)
|
|
397
|
-
point = [e.offsetX, e.offsetY];
|
|
398
|
-
else {
|
|
399
|
-
var localTouchPoint = getLocalTouchPoint(e.touches[0], canvasRef.current.getBoundingClientRect());
|
|
400
|
-
if (!localTouchPoint)
|
|
401
|
-
return;
|
|
402
|
-
point = localTouchPoint;
|
|
403
|
-
}
|
|
404
|
-
spacesRef.current.drawNewWall(canvasRef.current, point);
|
|
335
|
+
if (spacesRef.current.isDrawWallActive)
|
|
336
|
+
spacesRef.current.drawNewWall(canvasRef.current, [e.offsetX, e.offsetY]);
|
|
405
337
|
};
|
|
406
338
|
var handleDrawWallFinish = function (e) {
|
|
407
339
|
var _a;
|
|
@@ -0,0 +1,16 @@
|
|
|
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.getTranslationsForLocale = void 0;
|
|
7
|
+
var request_1 = __importDefault(require("./request"));
|
|
8
|
+
var ASSETS_API_ROUTE = "/api/assets";
|
|
9
|
+
var getTranslationsForLocale = function (locale) {
|
|
10
|
+
return request_1.default.get({
|
|
11
|
+
url: "".concat(ASSETS_API_ROUTE, "/translations"),
|
|
12
|
+
params: { locale: locale },
|
|
13
|
+
includeOrgId: true,
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
exports.getTranslationsForLocale = getTranslationsForLocale;
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import * as assets from './assets';
|
|
1
2
|
import * as orders from './orders';
|
|
2
|
-
import * as products from './products';
|
|
3
3
|
import * as configurations from './configurations';
|
|
4
4
|
import * as pricebook from './pricebook';
|
|
5
5
|
import * as catalog from './catalog';
|
|
6
6
|
import * as datatables from './datatables';
|
|
7
7
|
import * as server from './server';
|
|
8
8
|
declare const _default: {
|
|
9
|
+
assets: typeof assets;
|
|
9
10
|
orders: typeof orders;
|
|
10
|
-
products: typeof products;
|
|
11
11
|
configurations: typeof configurations;
|
|
12
12
|
pricebook: typeof pricebook;
|
|
13
13
|
catalog: typeof catalog;
|
package/dist/http/index.js
CHANGED
|
@@ -23,16 +23,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
var assets = __importStar(require("./assets"));
|
|
26
27
|
var orders = __importStar(require("./orders"));
|
|
27
|
-
var products = __importStar(require("./products"));
|
|
28
28
|
var configurations = __importStar(require("./configurations"));
|
|
29
29
|
var pricebook = __importStar(require("./pricebook"));
|
|
30
30
|
var catalog = __importStar(require("./catalog"));
|
|
31
31
|
var datatables = __importStar(require("./datatables"));
|
|
32
32
|
var server = __importStar(require("./server"));
|
|
33
33
|
exports.default = {
|
|
34
|
+
assets: assets,
|
|
34
35
|
orders: orders,
|
|
35
|
-
products: products,
|
|
36
36
|
configurations: configurations,
|
|
37
37
|
pricebook: pricebook,
|
|
38
38
|
catalog: catalog,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
2
|
import { ISetConfiguration, IThreekitDisplayAttribute } from '../types';
|
|
3
|
-
import {
|
|
3
|
+
import { ITranslationsMap } from '../http/assets';
|
|
4
4
|
export declare type AttributesState = Record<string, IThreekitDisplayAttribute>;
|
|
5
5
|
export declare const setAttributes: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[attributes: IThreekitDisplayAttribute[]], Record<string, IThreekitDisplayAttribute>, "treble/attributes/set-attributes", never, never>;
|
|
6
6
|
declare const reducer: import("redux").Reducer<AttributesState, import("redux").AnyAction>;
|
|
@@ -13,7 +13,7 @@ export declare const getHydrationData: ((state: {
|
|
|
13
13
|
wishlist: import("../Treble").WishlistArray;
|
|
14
14
|
price: import("./price").PriceState;
|
|
15
15
|
spaces: import("./spaces").SpacesState;
|
|
16
|
-
}) => [Record<string, IThreekitDisplayAttribute>,
|
|
16
|
+
}) => readonly [Record<string, IThreekitDisplayAttribute>, ITranslationsMap]) & import("reselect").OutputSelectorFields<(args_0: AttributesState, args_1: ITranslationsMap) => readonly [Record<string, IThreekitDisplayAttribute>, ITranslationsMap] & {
|
|
17
17
|
clearCache: () => void;
|
|
18
18
|
}> & {
|
|
19
19
|
clearCache: () => void;
|
package/dist/store/attributes.js
CHANGED
|
@@ -67,9 +67,7 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
67
67
|
}).reducer;
|
|
68
68
|
var getAttributes = function (state) { return state.attributes; };
|
|
69
69
|
exports.getAttributes = getAttributes;
|
|
70
|
-
exports.getHydrationData = (0, toolkit_1.createSelector)(exports.getAttributes, translations_1.
|
|
71
|
-
return [attributes, translations_1.TRANSLATIONS, language];
|
|
72
|
-
});
|
|
70
|
+
exports.getHydrationData = (0, toolkit_1.createSelector)(exports.getAttributes, translations_1.getTranslations, function (attributes, translations) { return [attributes, translations]; });
|
|
73
71
|
var setConfiguration = function (config) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
72
|
return __generator(this, function (_a) {
|
|
75
73
|
switch (_a.label) {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { RootState, ThreekitDispatch } from './index';
|
|
2
|
-
import {
|
|
2
|
+
import { ITranslationsMap } from '../http/assets';
|
|
3
3
|
export interface TranslationsState {
|
|
4
|
-
|
|
4
|
+
locale: string | undefined;
|
|
5
|
+
translationsMap: ITranslationsMap;
|
|
5
6
|
}
|
|
6
|
-
export declare
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const initTranslations: (
|
|
7
|
+
export declare const setLocale: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<string | undefined, string>;
|
|
8
|
+
export declare const setTranslationsMap: import("@reduxjs/toolkit").ActionCreatorWithPayload<ITranslationsMap, string>;
|
|
9
|
+
export declare const initTranslations: (locale?: string) => (dispatch: ThreekitDispatch) => Promise<void>;
|
|
9
10
|
declare const reducer: import("redux").Reducer<TranslationsState, import("redux").AnyAction>;
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const getLocale: (state: RootState) => undefined | string;
|
|
12
|
+
export declare const getTranslations: (state: RootState) => ITranslationsMap;
|
|
13
|
+
export declare const setTranslationForLocale: (locale: string | null) => (dispatch: ThreekitDispatch, getState: () => RootState) => void;
|
|
12
14
|
export default reducer;
|
|
@@ -39,44 +39,64 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.
|
|
42
|
+
exports.setTranslationForLocale = exports.getTranslations = exports.getLocale = exports.initTranslations = exports.setTranslationsMap = exports.setLocale = void 0;
|
|
43
43
|
var toolkit_1 = require("@reduxjs/toolkit");
|
|
44
44
|
var api_1 = __importDefault(require("../api"));
|
|
45
|
-
exports.
|
|
46
|
-
|
|
45
|
+
exports.setLocale = (0, toolkit_1.createAction)('treble/translations/set-locale');
|
|
46
|
+
exports.setTranslationsMap = (0, toolkit_1.createAction)('treble/translations/set-translations-map');
|
|
47
|
+
var initTranslations = function (locale) { return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
+
var translations;
|
|
47
49
|
return __generator(this, function (_a) {
|
|
48
50
|
switch (_a.label) {
|
|
49
|
-
case 0:
|
|
51
|
+
case 0:
|
|
52
|
+
if (!locale)
|
|
53
|
+
return [2];
|
|
54
|
+
return [4, api_1.default.assets.fetchTranslations(locale)];
|
|
50
55
|
case 1:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
translations = _a.sent();
|
|
57
|
+
dispatch((0, exports.setLocale)(locale));
|
|
58
|
+
dispatch((0, exports.setTranslationsMap)(translations));
|
|
54
59
|
return [2];
|
|
55
60
|
}
|
|
56
61
|
});
|
|
57
62
|
}); }; };
|
|
58
63
|
exports.initTranslations = initTranslations;
|
|
59
64
|
var initialState = {
|
|
60
|
-
|
|
65
|
+
locale: undefined,
|
|
66
|
+
translationsMap: {},
|
|
61
67
|
};
|
|
62
68
|
var reducer = (0, toolkit_1.createSlice)({
|
|
63
69
|
name: 'translations',
|
|
64
70
|
initialState: initialState,
|
|
65
71
|
extraReducers: function (builder) {
|
|
66
|
-
builder
|
|
67
|
-
|
|
72
|
+
builder
|
|
73
|
+
.addCase(exports.setLocale, function (state, action) {
|
|
74
|
+
state.locale = action.payload;
|
|
75
|
+
})
|
|
76
|
+
.addCase(exports.setTranslationsMap, function (state, action) {
|
|
77
|
+
state.translationsMap = action.payload;
|
|
68
78
|
});
|
|
69
79
|
},
|
|
70
80
|
reducers: {},
|
|
71
81
|
}).reducer;
|
|
72
|
-
var
|
|
73
|
-
return state.translations.
|
|
82
|
+
var getLocale = function (state) {
|
|
83
|
+
return state.translations.locale;
|
|
74
84
|
};
|
|
75
|
-
exports.
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
return [];
|
|
79
|
-
return Object.keys(Object.values(exports.TRANSLATIONS)[0]);
|
|
85
|
+
exports.getLocale = getLocale;
|
|
86
|
+
var getTranslations = function (state) {
|
|
87
|
+
return state.translations.translationsMap;
|
|
80
88
|
};
|
|
81
|
-
exports.
|
|
89
|
+
exports.getTranslations = getTranslations;
|
|
90
|
+
var setTranslationForLocale = function (locale) {
|
|
91
|
+
return function (dispatch, getState) {
|
|
92
|
+
if (!locale) {
|
|
93
|
+
dispatch((0, exports.setLocale)(undefined));
|
|
94
|
+
dispatch((0, exports.setTranslationsMap)({}));
|
|
95
|
+
}
|
|
96
|
+
if (locale === getState().translations.locale)
|
|
97
|
+
return;
|
|
98
|
+
dispatch((0, exports.initTranslations)(locale !== null && locale !== void 0 ? locale : undefined));
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
exports.setTranslationForLocale = setTranslationForLocale;
|
|
82
102
|
exports.default = reducer;
|
package/dist/types.d.ts
CHANGED
|
@@ -277,6 +277,7 @@ export interface IThreekitConfigurator {
|
|
|
277
277
|
getMetadata: () => IMetadata;
|
|
278
278
|
getAttributes: () => Array<IThreekitAttribute>;
|
|
279
279
|
getConfiguration: () => IConfiguration;
|
|
280
|
+
getResolvedConfiguration: () => IConfiguration;
|
|
280
281
|
setConfiguration: (configuration: ISetConfiguration | IConfiguration) => Promise<IConfiguration>;
|
|
281
282
|
getPrice: (pricebookId: string, currency: string) => number;
|
|
282
283
|
getDisplayAttributes: (config?: IDisplayAttributeConfig) => Array<IThreekitDisplayAttribute>;
|
|
@@ -328,6 +329,7 @@ export interface IThreekitPlayer {
|
|
|
328
329
|
unload: () => Promise<string>;
|
|
329
330
|
uploadImage: (image: File) => Promise<string>;
|
|
330
331
|
cacheParameters: ICacheParameters;
|
|
332
|
+
sessionId: string;
|
|
331
333
|
}
|
|
332
334
|
export interface IThreekitPrivateConfigurator extends IThreekitConfigurator {
|
|
333
335
|
name: string;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IThreekitCamera, IConfigurationColor, ICoordinates, IQuaternion, IThreekitDisplayAttribute, ISetConfiguration, IHydratedAttribute } from './types';
|
|
1
|
+
import { IThreekitCamera, IConfigurationColor, ICoordinates, IQuaternion, IThreekitDisplayAttribute, ISetConfiguration, IHydratedAttribute, IConfiguration } from './types';
|
|
2
2
|
import { ITrebleConfig, ATTRIBUTE_TYPES } from './types';
|
|
3
3
|
import { RawAttributeValue } from './hooks/useAttribute';
|
|
4
|
-
import {
|
|
4
|
+
import { ITranslationsMap } from './http/assets';
|
|
5
5
|
interface ICameraPosition {
|
|
6
6
|
position: ICoordinates;
|
|
7
7
|
quaternion: IQuaternion;
|
|
@@ -48,11 +48,7 @@ export declare const downloadSnapshot: (snapshot: string, filename: string) => P
|
|
|
48
48
|
export declare const copyToClipboard: (data: string | Record<string, string | number | boolean>) => void;
|
|
49
49
|
export declare const easeInOutCubic: (val: number) => number;
|
|
50
50
|
export declare const metadataValueToObject: (data: string) => Record<string, string | number>;
|
|
51
|
-
export declare const hydrateAttribute: (data: [
|
|
52
|
-
Record<string, IThreekitDisplayAttribute>,
|
|
53
|
-
undefined | ITranslationMap,
|
|
54
|
-
undefined | string
|
|
55
|
-
], optionSelectionHandler: (config: ISetConfiguration) => Promise<void>) => Record<string, IHydratedAttribute>;
|
|
51
|
+
export declare const hydrateAttribute: (data: [Record<string, IThreekitDisplayAttribute>, ITranslationsMap], optionSelectionHandler: (config: ISetConfiguration) => Promise<void>, configuration?: IConfiguration) => Record<string, IHydratedAttribute>;
|
|
56
52
|
export declare const selectionToConfiguration: (value: RawAttributeValue, attributeType: ATTRIBUTE_TYPES) => string | number | boolean | File | IConfigurationColor | {
|
|
57
53
|
assetId: RawAttributeValue;
|
|
58
54
|
} | undefined;
|
package/dist/utils.js
CHANGED
|
@@ -303,25 +303,22 @@ var metadataValueToObject = function (data) {
|
|
|
303
303
|
}, {});
|
|
304
304
|
};
|
|
305
305
|
exports.metadataValueToObject = metadataValueToObject;
|
|
306
|
-
var hydrateAttribute = function (data, optionSelectionHandler) {
|
|
307
|
-
var
|
|
308
|
-
var
|
|
306
|
+
var hydrateAttribute = function (data, optionSelectionHandler, configuration) {
|
|
307
|
+
var _a, _b;
|
|
308
|
+
var attributes = data[0], translations = data[1];
|
|
309
|
+
var resolvedConfig = configuration !== null && configuration !== void 0 ? configuration : (_b = (_a = window.threekit) === null || _a === void 0 ? void 0 : _a.configurator) === null || _b === void 0 ? void 0 : _b.getResolvedConfiguration();
|
|
309
310
|
return Object.values(attributes).reduce(function (output, attribute) {
|
|
310
311
|
var _a;
|
|
311
312
|
var _b;
|
|
312
313
|
return Object.assign(output, (_a = {},
|
|
313
314
|
_a[attribute.name] = Object.assign({}, attribute, {
|
|
314
|
-
label:
|
|
315
|
-
? ((_b = translations === null || translations === void 0 ? void 0 : translations[attribute.name]) === null || _b === void 0 ? void 0 : _b[language]) || attribute.name
|
|
316
|
-
: attribute.name,
|
|
315
|
+
label: (_b = translations[attribute.name]) !== null && _b !== void 0 ? _b : attribute.name,
|
|
317
316
|
}, attribute.type === 'String'
|
|
318
317
|
? {
|
|
319
318
|
values: attribute.values.map(function (el) {
|
|
320
319
|
var _a;
|
|
321
320
|
return Object.assign({}, el, {
|
|
322
|
-
label:
|
|
323
|
-
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.label]) === null || _a === void 0 ? void 0 : _a[language]) || el.label
|
|
324
|
-
: el.label,
|
|
321
|
+
label: (_a = translations[el.label]) !== null && _a !== void 0 ? _a : el.label,
|
|
325
322
|
handleSelect: function () {
|
|
326
323
|
var _a;
|
|
327
324
|
return optionSelectionHandler((_a = {},
|
|
@@ -337,16 +334,18 @@ var hydrateAttribute = function (data, optionSelectionHandler) {
|
|
|
337
334
|
values: attribute.values.map(function (el) {
|
|
338
335
|
var _a;
|
|
339
336
|
return Object.assign({}, el, {
|
|
340
|
-
label:
|
|
341
|
-
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.name]) === null || _a === void 0 ? void 0 : _a[language]) || el.name
|
|
342
|
-
: el.name,
|
|
337
|
+
label: (_a = translations[el.name]) !== null && _a !== void 0 ? _a : el.name,
|
|
343
338
|
handleSelect: function () {
|
|
344
339
|
var _a;
|
|
345
340
|
return optionSelectionHandler((_a = {},
|
|
346
341
|
_a[attribute.name] = { assetId: el.assetId },
|
|
347
342
|
_a));
|
|
348
343
|
},
|
|
349
|
-
selected:
|
|
344
|
+
selected: resolvedConfig
|
|
345
|
+
? el.assetId ===
|
|
346
|
+
resolvedConfig[attribute.name]
|
|
347
|
+
.assetId
|
|
348
|
+
: el.assetId === attribute.value.assetId,
|
|
350
349
|
});
|
|
351
350
|
}),
|
|
352
351
|
}
|
package/package.json
CHANGED
package/dist/api/products.d.ts
DELETED
package/dist/http/products.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getTranslations: () => Promise<import("axios").AxiosResponse<string>>;
|
package/dist/http/products.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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.getTranslations = void 0;
|
|
7
|
-
var request_1 = __importDefault(require("./request"));
|
|
8
|
-
var PRODUCTS_API_ROUTE = "/api/products";
|
|
9
|
-
var getTranslations = function () {
|
|
10
|
-
return request_1.default.get("".concat(PRODUCTS_API_ROUTE, "/translations"));
|
|
11
|
-
};
|
|
12
|
-
exports.getTranslations = getTranslations;
|