@threekit-tools/treble 0.0.49 → 0.0.53
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/Snapshots.js +0 -26
- package/dist/Treble/Treble.d.ts +7 -2
- package/dist/Treble/Treble.js +20 -3
- package/dist/Treble/Wishlist.d.ts +3 -2
- package/dist/Treble/Wishlist.js +12 -12
- package/dist/api/catalog.d.ts +1 -0
- package/dist/api/catalog.js +86 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/components/Accordion/index.d.ts +1 -1
- package/dist/components/FlatForm/index.js +9 -3
- package/dist/components/ThreekitProvider/index.d.ts +3 -1
- package/dist/components/ThreekitProvider/index.js +3 -3
- package/dist/components/Upload/index.d.ts +12 -0
- package/dist/components/Upload/index.js +114 -0
- package/dist/components/Upload/upload.styles.d.ts +6 -0
- package/dist/components/Upload/upload.styles.js +15 -0
- package/dist/components/containers/formInputContainer.d.ts +8 -16
- package/dist/components/formComponents.d.ts +2 -0
- package/dist/components/formComponents.js +5 -1
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +5 -1
- package/dist/hooks/useArrayAttribute/index.d.ts +2 -0
- package/dist/hooks/useArrayAttribute/index.js +184 -0
- package/dist/hooks/useAttribute/index.d.ts +3 -3
- package/dist/hooks/useAttribute/index.js +67 -8
- package/dist/hooks/useConfigurator/index.js +3 -3
- package/dist/hooks/useMetadata/index.js +2 -2
- package/dist/hooks/useName/index.js +2 -2
- package/dist/hooks/usePlayerLoadingStatus/index.js +2 -2
- package/dist/hooks/usePlayerPortal/index.js +2 -2
- package/dist/hooks/usePrice/index.d.ts +1 -1
- package/dist/hooks/usePrice/index.js +2 -2
- package/dist/hooks/useShare/index.js +2 -2
- package/dist/hooks/useSnapshot/index.js +2 -2
- package/dist/hooks/useThreekitInitStatus/index.js +2 -2
- package/dist/hooks/useWishlist/index.d.ts +1 -1
- package/dist/hooks/useWishlist/index.js +8 -7
- package/dist/http/catalog.d.ts +53 -2
- package/dist/http/catalog.js +3 -3
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.js +2 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/store/attributes.d.ts +20 -0
- package/dist/store/attributes.js +139 -0
- package/dist/store/index.d.ts +67 -7
- package/dist/store/index.js +36 -4
- package/dist/store/price.d.ts +33 -0
- package/dist/store/price.js +116 -0
- package/dist/store/product.d.ts +22 -0
- package/dist/store/product.js +65 -0
- package/dist/store/translations.d.ts +22 -0
- package/dist/store/translations.js +100 -0
- package/dist/store/treble.d.ts +41 -0
- package/dist/store/treble.js +259 -0
- package/dist/store/wishlist.d.ts +23 -0
- package/dist/store/wishlist.js +114 -0
- package/dist/threekit.d.ts +18 -3
- package/dist/utils.d.ts +4 -3
- package/package.json +1 -1
- package/dist/store/threekit.d.ts +0 -68
- package/dist/store/threekit.js +0 -453
package/dist/Treble/Snapshots.js
CHANGED
|
@@ -129,32 +129,6 @@ var Snapshots = /** @class */ (function () {
|
|
|
129
129
|
}, Promise.resolve(snapshots));
|
|
130
130
|
};
|
|
131
131
|
this.takeSnapshots = function (camerasList, snapshotsConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
132
|
-
// function getSnapshot() {
|
|
133
|
-
// return window.threekit.player.snapshotAsync({
|
|
134
|
-
// size,
|
|
135
|
-
// mimeType: `image/${SNAPSHOT_FORMATS[format]}`,
|
|
136
|
-
// })
|
|
137
|
-
// }
|
|
138
|
-
// function getSnapshots(
|
|
139
|
-
// cameras: Array<string | undefined>,
|
|
140
|
-
// camerasMap: CamerasMap
|
|
141
|
-
// ) {
|
|
142
|
-
// let snapshots: Array<string> = []
|
|
143
|
-
// return cameras.reduce((snapshotPromise, camera) => {
|
|
144
|
-
// return snapshotPromise.then(
|
|
145
|
-
// () =>
|
|
146
|
-
// new Promise(async (resolve) => {
|
|
147
|
-
// if (camera)
|
|
148
|
-
// await window.threekit.configurator.setConfiguration({
|
|
149
|
-
// [attributeName]: camerasMap[camera],
|
|
150
|
-
// })
|
|
151
|
-
// const snapshotStr = await getSnapshot()
|
|
152
|
-
// snapshots.push(snapshotStr)
|
|
153
|
-
// resolve(snapshots)
|
|
154
|
-
// })
|
|
155
|
-
// )
|
|
156
|
-
// }, Promise.resolve(snapshots))
|
|
157
|
-
// }
|
|
158
132
|
function saveSnapshotToPlatform(snapshot, filename) {
|
|
159
133
|
return __awaiter(this, void 0, void 0, function () {
|
|
160
134
|
var files, response;
|
package/dist/Treble/Treble.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import threekitAPI from '../api';
|
|
2
|
-
import { IThreekitPlayer, IMetadata } from '../threekit';
|
|
2
|
+
import { IThreekitPlayer, IMetadata, IConfiguration, ISetConfiguration } from '../threekit';
|
|
3
3
|
import { IWishlist } from './Wishlist';
|
|
4
4
|
import Snapshots from './Snapshots';
|
|
5
5
|
interface ITreble {
|
|
6
6
|
player: IThreekitPlayer;
|
|
7
|
+
orgId: string;
|
|
8
|
+
initialConfiguration: IConfiguration;
|
|
7
9
|
}
|
|
8
10
|
export interface ISaveConfigurationConfig {
|
|
9
11
|
customerId?: string;
|
|
@@ -14,13 +16,16 @@ declare class Treble {
|
|
|
14
16
|
_api: typeof threekitAPI;
|
|
15
17
|
_player: IThreekitPlayer;
|
|
16
18
|
wishlist: IWishlist;
|
|
19
|
+
private _initialConfiguration;
|
|
17
20
|
private _snapshots;
|
|
18
21
|
takeSnapshots: Snapshots['takeSnapshots'];
|
|
19
|
-
constructor({ player }: ITreble);
|
|
22
|
+
constructor({ player, orgId, initialConfiguration }: ITreble);
|
|
20
23
|
saveConfiguration: (config?: ISaveConfigurationConfig | undefined) => Promise<{
|
|
21
24
|
resumableUrl: string;
|
|
22
25
|
} & import("../http/configurations").IConfigurationResponse & {
|
|
23
26
|
thumbnail: string;
|
|
24
27
|
}>;
|
|
28
|
+
getNestedConfigurator: (address: string | Array<string>) => any;
|
|
29
|
+
resetConfiguration: (configuration?: ISetConfiguration | undefined) => void;
|
|
25
30
|
}
|
|
26
31
|
export default Treble;
|
package/dist/Treble/Treble.js
CHANGED
|
@@ -48,7 +48,7 @@ var Snapshots_1 = __importDefault(require("./Snapshots"));
|
|
|
48
48
|
var Treble = /** @class */ (function () {
|
|
49
49
|
function Treble(_a) {
|
|
50
50
|
var _this = this;
|
|
51
|
-
var player = _a.player;
|
|
51
|
+
var player = _a.player, orgId = _a.orgId, initialConfiguration = _a.initialConfiguration;
|
|
52
52
|
this.saveConfiguration = function (config) { return __awaiter(_this, void 0, void 0, function () {
|
|
53
53
|
var threekitDomain, _a, customerId, metadata, productVersion, files, response, params, url;
|
|
54
54
|
var _b;
|
|
@@ -83,13 +83,30 @@ var Treble = /** @class */ (function () {
|
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
}); };
|
|
86
|
+
this.getNestedConfigurator = function (address) {
|
|
87
|
+
var player = window.threekit.player.enableApi('player');
|
|
88
|
+
var addressArr = Array.isArray(address) ? address : [address];
|
|
89
|
+
return addressArr.reduce(function (configurator, attributeName) {
|
|
90
|
+
var itemId = configurator.getAppliedConfiguration(attributeName);
|
|
91
|
+
return window.threekit.player.scene.get({
|
|
92
|
+
id: itemId,
|
|
93
|
+
evalNode: true,
|
|
94
|
+
}).configurator;
|
|
95
|
+
}, player.getConfigurator());
|
|
96
|
+
};
|
|
97
|
+
this.resetConfiguration = function (configuration) {
|
|
98
|
+
var initialConfiguration = JSON.parse(_this._initialConfiguration);
|
|
99
|
+
var updateConfiguration = Object.assign(initialConfiguration, configuration);
|
|
100
|
+
window.threekit.configurator.setConfiguration(updateConfiguration);
|
|
101
|
+
};
|
|
86
102
|
// Threekit API
|
|
87
103
|
this._api = api_1.default;
|
|
88
104
|
this._player = player;
|
|
89
|
-
this.wishlist = (0, Wishlist_1.default)();
|
|
105
|
+
this.wishlist = (0, Wishlist_1.default)(orgId);
|
|
90
106
|
this._snapshots = new Snapshots_1.default();
|
|
91
107
|
this.takeSnapshots = this._snapshots.takeSnapshots;
|
|
92
|
-
// this._player = player.enableApi('player')
|
|
108
|
+
// this._player = player.enableApi('player');
|
|
109
|
+
this._initialConfiguration = JSON.stringify(initialConfiguration);
|
|
93
110
|
}
|
|
94
111
|
return Treble;
|
|
95
112
|
}());
|
|
@@ -8,11 +8,12 @@ export interface IWishlist {
|
|
|
8
8
|
clearWishlist(): Array<IConfigurationResponse>;
|
|
9
9
|
}
|
|
10
10
|
declare class Wishlist implements IWishlist {
|
|
11
|
-
|
|
11
|
+
_wishlistKey: string;
|
|
12
|
+
constructor(orgId: string);
|
|
12
13
|
getWishlist: () => Promise<WishlistArray>;
|
|
13
14
|
addItem: (config?: ISaveConfigurationConfig | undefined) => Promise<WishlistArray>;
|
|
14
15
|
removeItemByIdx: (idx: number) => WishlistArray;
|
|
15
16
|
clearWishlist: () => WishlistArray;
|
|
16
17
|
}
|
|
17
|
-
export default function createWishlist(): Wishlist;
|
|
18
|
+
export default function createWishlist(orgId: string): Wishlist;
|
|
18
19
|
export {};
|
package/dist/Treble/Wishlist.js
CHANGED
|
@@ -53,7 +53,7 @@ var connection_1 = __importDefault(require("../connection"));
|
|
|
53
53
|
var constants_1 = require("../constants");
|
|
54
54
|
var wishlistData;
|
|
55
55
|
var Wishlist = /** @class */ (function () {
|
|
56
|
-
function Wishlist() {
|
|
56
|
+
function Wishlist(orgId) {
|
|
57
57
|
var _this = this;
|
|
58
58
|
this.getWishlist = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
59
59
|
var threekitDomain, wishlistListStr, wishlistList, wishlistDataRaw;
|
|
@@ -63,7 +63,7 @@ var Wishlist = /** @class */ (function () {
|
|
|
63
63
|
if (wishlistData)
|
|
64
64
|
return [2 /*return*/, wishlistData];
|
|
65
65
|
threekitDomain = connection_1.default.getConnection().threekitDomain;
|
|
66
|
-
wishlistListStr = localStorage.getItem(
|
|
66
|
+
wishlistListStr = localStorage.getItem(this._wishlistKey);
|
|
67
67
|
wishlistList = JSON.parse(wishlistListStr || '[]');
|
|
68
68
|
return [4 /*yield*/, Promise.all(wishlistList.map(function (el) { return api_1.default.configurations.fetch(el); }))];
|
|
69
69
|
case 1:
|
|
@@ -87,20 +87,19 @@ var Wishlist = /** @class */ (function () {
|
|
|
87
87
|
case 0:
|
|
88
88
|
if (!wishlistData) {
|
|
89
89
|
wishlistData = [];
|
|
90
|
-
localStorage.setItem(
|
|
90
|
+
localStorage.setItem(this._wishlistKey, JSON.stringify([]));
|
|
91
91
|
}
|
|
92
92
|
configPrepped = Object.assign({ snapshot: true }, config);
|
|
93
93
|
return [4 /*yield*/, window.threekit.treble.saveConfiguration(configPrepped)];
|
|
94
94
|
case 1:
|
|
95
95
|
savedConfiguration = _a.sent();
|
|
96
|
-
// const savedConfiguration = await this.saveConfiguration(configPrepped)
|
|
97
96
|
if (!savedConfiguration)
|
|
98
97
|
return [2 /*return*/, wishlistData];
|
|
99
98
|
wishlistData = __spreadArray(__spreadArray([], wishlistData, true), [savedConfiguration], false);
|
|
100
|
-
wishlistListStr = localStorage.getItem(
|
|
99
|
+
wishlistListStr = localStorage.getItem(this._wishlistKey);
|
|
101
100
|
wishlistList = JSON.parse(wishlistListStr || '[]');
|
|
102
101
|
wishlistList.push(savedConfiguration.shortId);
|
|
103
|
-
localStorage.setItem(
|
|
102
|
+
localStorage.setItem(this._wishlistKey, JSON.stringify(wishlistList));
|
|
104
103
|
return [2 /*return*/, this.getWishlist()];
|
|
105
104
|
}
|
|
106
105
|
});
|
|
@@ -108,7 +107,7 @@ var Wishlist = /** @class */ (function () {
|
|
|
108
107
|
this.removeItemByIdx = function (idx) {
|
|
109
108
|
if (!(wishlistData === null || wishlistData === void 0 ? void 0 : wishlistData.length)) {
|
|
110
109
|
wishlistData = [];
|
|
111
|
-
localStorage.setItem(
|
|
110
|
+
localStorage.setItem(_this._wishlistKey, JSON.stringify([]));
|
|
112
111
|
return wishlistData;
|
|
113
112
|
}
|
|
114
113
|
if (idx > (wishlistData === null || wishlistData === void 0 ? void 0 : wishlistData.length) - 1)
|
|
@@ -116,22 +115,23 @@ var Wishlist = /** @class */ (function () {
|
|
|
116
115
|
var updatedWishlist = __spreadArray([], wishlistData, true);
|
|
117
116
|
updatedWishlist.splice(idx, 1);
|
|
118
117
|
wishlistData = updatedWishlist;
|
|
119
|
-
var wishlistListStr = localStorage.getItem(
|
|
118
|
+
var wishlistListStr = localStorage.getItem(_this._wishlistKey);
|
|
120
119
|
var wishlistList = JSON.parse(wishlistListStr || '[]');
|
|
121
120
|
wishlistList.splice(idx, 1);
|
|
122
|
-
localStorage.setItem(
|
|
121
|
+
localStorage.setItem(_this._wishlistKey, JSON.stringify(wishlistList));
|
|
123
122
|
return wishlistData;
|
|
124
123
|
};
|
|
125
124
|
this.clearWishlist = function () {
|
|
126
125
|
wishlistData = [];
|
|
127
|
-
localStorage.setItem(
|
|
126
|
+
localStorage.setItem(_this._wishlistKey, JSON.stringify([]));
|
|
128
127
|
return wishlistData;
|
|
129
128
|
};
|
|
129
|
+
this._wishlistKey = "".concat(constants_1.WISHLIST_LOCALSTORAGE_KEY, "_").concat(orgId);
|
|
130
130
|
this.getWishlist();
|
|
131
131
|
}
|
|
132
132
|
return Wishlist;
|
|
133
133
|
}());
|
|
134
|
-
function createWishlist() {
|
|
135
|
-
return new Wishlist();
|
|
134
|
+
function createWishlist(orgId) {
|
|
135
|
+
return new Wishlist(orgId);
|
|
136
136
|
}
|
|
137
137
|
exports.default = createWishlist;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const uploadAsset: (file: File) => Promise<string | undefined>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.uploadAsset = void 0;
|
|
43
|
+
var http_1 = __importDefault(require("../http"));
|
|
44
|
+
var uploadAsset = function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
+
var error, formData, uploadResponse, jobId, assetId, count, checkRes, output;
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0:
|
|
49
|
+
if (!file)
|
|
50
|
+
error = 'Requires a File';
|
|
51
|
+
if (error)
|
|
52
|
+
throw new Error(error);
|
|
53
|
+
formData = new FormData();
|
|
54
|
+
formData.append('files', file, file.name);
|
|
55
|
+
return [4 /*yield*/, http_1.default.catalog.uploadAsset(formData)];
|
|
56
|
+
case 1:
|
|
57
|
+
uploadResponse = _a.sent();
|
|
58
|
+
jobId = uploadResponse.data[0].jobId;
|
|
59
|
+
count = 30;
|
|
60
|
+
_a.label = 2;
|
|
61
|
+
case 2:
|
|
62
|
+
if (!(count > 1 && !assetId)) return [3 /*break*/, 5];
|
|
63
|
+
return [4 /*yield*/, new Promise(function (resolve) {
|
|
64
|
+
return setTimeout(function () { return resolve(undefined); }, 0.5 * 1000);
|
|
65
|
+
})];
|
|
66
|
+
case 3:
|
|
67
|
+
_a.sent();
|
|
68
|
+
return [4 /*yield*/, http_1.default.catalog.getJobStatus(jobId)];
|
|
69
|
+
case 4:
|
|
70
|
+
checkRes = _a.sent();
|
|
71
|
+
++count;
|
|
72
|
+
if (checkRes.data.output) {
|
|
73
|
+
output = checkRes.data.output;
|
|
74
|
+
if (output.texture.length) {
|
|
75
|
+
assetId = output.texture[0].assetId;
|
|
76
|
+
}
|
|
77
|
+
else if (output.vector.length) {
|
|
78
|
+
assetId = output.vector[0].assetId;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return [3 /*break*/, 2];
|
|
82
|
+
case 5: return [2 /*return*/, assetId];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}); };
|
|
86
|
+
exports.uploadAsset = uploadAsset;
|
package/dist/api/index.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ import * as products from './products';
|
|
|
2
2
|
import * as configurations from './configurations';
|
|
3
3
|
import * as price from './price';
|
|
4
4
|
import * as orders from './orders';
|
|
5
|
+
import * as catalog from './catalog';
|
|
5
6
|
declare const _default: {
|
|
6
7
|
products: typeof products;
|
|
7
8
|
configurations: typeof configurations;
|
|
8
9
|
price: typeof price;
|
|
9
10
|
orders: typeof orders;
|
|
11
|
+
catalog: typeof catalog;
|
|
10
12
|
};
|
|
11
13
|
export default _default;
|
package/dist/api/index.js
CHANGED
|
@@ -23,9 +23,11 @@ var products = __importStar(require("./products"));
|
|
|
23
23
|
var configurations = __importStar(require("./configurations"));
|
|
24
24
|
var price = __importStar(require("./price"));
|
|
25
25
|
var orders = __importStar(require("./orders"));
|
|
26
|
+
var catalog = __importStar(require("./catalog"));
|
|
26
27
|
exports.default = {
|
|
27
28
|
products: products,
|
|
28
29
|
configurations: configurations,
|
|
29
30
|
price: price,
|
|
30
31
|
orders: orders,
|
|
32
|
+
catalog: catalog,
|
|
31
33
|
};
|
|
@@ -6,7 +6,7 @@ interface AccordionItemProps extends React.FC {
|
|
|
6
6
|
onClick: () => void;
|
|
7
7
|
}
|
|
8
8
|
interface AccordionProps<T> {
|
|
9
|
-
children: React.FunctionComponentElement<T
|
|
9
|
+
children: React.FunctionComponentElement<T> | Array<React.FunctionComponentElement<T>>;
|
|
10
10
|
}
|
|
11
11
|
export declare const Accordion: {
|
|
12
12
|
(props: AccordionProps<AccordionItemProps>): React.FunctionComponentElement<AccordionItemProps>[] | null;
|
|
@@ -23,6 +23,7 @@ var ProductDescription_1 = __importDefault(require("../ProductDescription"));
|
|
|
23
23
|
var formComponents_1 = __importDefault(require("../formComponents"));
|
|
24
24
|
var utils_1 = require("../../utils");
|
|
25
25
|
var useConfigurator_1 = __importDefault(require("../../hooks/useConfigurator"));
|
|
26
|
+
var constants_1 = require("../../constants");
|
|
26
27
|
var FlatForm = function (props) {
|
|
27
28
|
var _a = Object.assign({
|
|
28
29
|
alignTitle: 'center',
|
|
@@ -43,18 +44,23 @@ var FlatForm = function (props) {
|
|
|
43
44
|
var _a, _b, _c, _d, _e, _f;
|
|
44
45
|
var Component;
|
|
45
46
|
var props = ((_b = (_a = (attributes || {})) === null || _a === void 0 ? void 0 : _a[attr.name]) === null || _b === void 0 ? void 0 : _b.props) || {};
|
|
47
|
+
var type = attr.type;
|
|
48
|
+
if (type === 'Asset' &&
|
|
49
|
+
attr.assetType === constants_1.ASSET_TYPES.upload) {
|
|
50
|
+
type = attr.assetType;
|
|
51
|
+
}
|
|
46
52
|
if ((_d = (_c = (attributes || {})) === null || _c === void 0 ? void 0 : _c[attr.name]) === null || _d === void 0 ? void 0 : _d.component) {
|
|
47
|
-
Component = (_e = Object.entries(formComponents_1.default[
|
|
53
|
+
Component = (_e = Object.entries(formComponents_1.default[type] || {}).find(function (_a) {
|
|
48
54
|
var _b, _c;
|
|
49
55
|
var key = _a[0];
|
|
50
56
|
return key === ((_c = (_b = (attributes || {})) === null || _b === void 0 ? void 0 : _b[attr.name]) === null || _c === void 0 ? void 0 : _c.component.toLowerCase());
|
|
51
57
|
})) === null || _e === void 0 ? void 0 : _e[1];
|
|
52
58
|
}
|
|
53
59
|
if (!Component) {
|
|
54
|
-
Component = (_f = Object.values(formComponents_1.default[
|
|
60
|
+
Component = (_f = Object.values(formComponents_1.default[type] || {})) === null || _f === void 0 ? void 0 : _f[0];
|
|
55
61
|
}
|
|
56
62
|
if (!Component) {
|
|
57
|
-
console.log("No default component available for ".concat(
|
|
63
|
+
console.log("No default component available for ".concat(type, " type Attributes"));
|
|
58
64
|
return null;
|
|
59
65
|
}
|
|
60
66
|
return (react_1.default.createElement(Component, __assign({ key: i, className: customClassName, attribute: attr.name }, props)));
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Reducer } from 'redux';
|
|
3
|
+
import { ILaunchConfig } from '../../store/treble';
|
|
3
4
|
interface Theme {
|
|
4
5
|
[key: string]: string | number;
|
|
5
6
|
}
|
|
6
7
|
export interface ThreekitProviderProps extends Partial<ILaunchConfig> {
|
|
7
8
|
theme?: Theme;
|
|
9
|
+
reducer?: Record<string, Reducer>;
|
|
8
10
|
children: React.ReactNode;
|
|
9
11
|
}
|
|
10
12
|
declare const ThreekitProvider: (props: ThreekitProviderProps) => JSX.Element;
|
|
@@ -24,7 +24,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
var react_1 = __importStar(require("react"));
|
|
26
26
|
var store_1 = __importStar(require("../../store"));
|
|
27
|
-
var
|
|
27
|
+
var treble_1 = require("../../store/treble");
|
|
28
28
|
var react_redux_1 = require("react-redux");
|
|
29
29
|
var styled_components_1 = require("styled-components");
|
|
30
30
|
var theme_1 = __importDefault(require("../../theme"));
|
|
@@ -34,7 +34,7 @@ var App = function (props) {
|
|
|
34
34
|
(0, react_1.useEffect)(function () {
|
|
35
35
|
var init = function () {
|
|
36
36
|
var playerConfig = props.playerConfig, project = props.project, locale = props.locale, threekitEnv = props.threekitEnv, eventHandlers = props.eventHandlers;
|
|
37
|
-
dispatch((0,
|
|
37
|
+
dispatch((0, treble_1.launch)({ playerConfig: playerConfig, project: project, locale: locale, threekitEnv: threekitEnv, eventHandlers: eventHandlers }));
|
|
38
38
|
};
|
|
39
39
|
init();
|
|
40
40
|
return;
|
|
@@ -42,7 +42,7 @@ var App = function (props) {
|
|
|
42
42
|
return react_1.default.createElement(react_1.default.Fragment, null, props.children);
|
|
43
43
|
};
|
|
44
44
|
var ThreekitProvider = function (props) {
|
|
45
|
-
return (react_1.default.createElement(react_redux_1.Provider, { store: store_1.default },
|
|
45
|
+
return (react_1.default.createElement(react_redux_1.Provider, { store: (0, store_1.default)(props.reducer) },
|
|
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
48
|
react_1.default.createElement(App, { locale: props.locale, project: props.project, playerConfig: props.playerConfig, threekitEnv: props.threekitEnv, eventHandlers: props.eventHandlers }, props.children))));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IFormComponentProps, IOptionShared } from '../containers/formInputContainer';
|
|
3
|
+
export interface IUpload extends Pick<IFormComponentProps<IOptionShared>, 'title' | 'description' | 'className' | 'value'> {
|
|
4
|
+
onChange: (file: File) => Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare const Upload: {
|
|
7
|
+
(props: IUpload): JSX.Element;
|
|
8
|
+
componentName: string;
|
|
9
|
+
compatibleAttributes: Set<string>;
|
|
10
|
+
};
|
|
11
|
+
declare const _default: (props: IUpload) => JSX.Element | null;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
31
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
32
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
33
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34
|
+
function step(op) {
|
|
35
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
36
|
+
while (_) try {
|
|
37
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
38
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
39
|
+
switch (op[0]) {
|
|
40
|
+
case 0: case 1: t = op; break;
|
|
41
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
42
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
43
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
44
|
+
default:
|
|
45
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
46
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
47
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
48
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
49
|
+
if (t[2]) _.ops.pop();
|
|
50
|
+
_.trys.pop(); continue;
|
|
51
|
+
}
|
|
52
|
+
op = body.call(thisArg, _);
|
|
53
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
54
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
58
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
|
+
};
|
|
60
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
+
exports.Upload = void 0;
|
|
62
|
+
var react_1 = __importStar(require("react"));
|
|
63
|
+
var upload_styles_1 = require("./upload.styles");
|
|
64
|
+
var constants_1 = require("../../constants");
|
|
65
|
+
var FormComponentTitle_1 = __importDefault(require("../FormComponentTitle"));
|
|
66
|
+
var FormComponentDescription_1 = __importDefault(require("../FormComponentDescription"));
|
|
67
|
+
var shared_styles_1 = require("../shared.styles");
|
|
68
|
+
var utils_1 = require("../../utils");
|
|
69
|
+
var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
|
|
70
|
+
var Upload = function (props) {
|
|
71
|
+
var title = props.title, description = props.description, value = props.value, onChange = props.onChange, customClassName = props.className;
|
|
72
|
+
var _a = (0, react_1.useState)(false), uploading = _a[0], setUploading = _a[1];
|
|
73
|
+
var inputRef = (0, react_1.createRef)();
|
|
74
|
+
var cls = (0, utils_1.generateInputClassName)('upload', customClassName, title);
|
|
75
|
+
var handleClick = function () {
|
|
76
|
+
var _a;
|
|
77
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
78
|
+
};
|
|
79
|
+
var handleUpload = function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
switch (_a.label) {
|
|
82
|
+
case 0:
|
|
83
|
+
setUploading(true);
|
|
84
|
+
return [4 /*yield*/, onChange(file)];
|
|
85
|
+
case 1:
|
|
86
|
+
_a.sent();
|
|
87
|
+
setUploading(false);
|
|
88
|
+
return [2 /*return*/];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}); };
|
|
92
|
+
return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, null,
|
|
93
|
+
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
94
|
+
react_1.default.createElement(FormComponentDescription_1.default, { description: description, className: cls }),
|
|
95
|
+
react_1.default.createElement(upload_styles_1.UploadWrapper, { className: cls },
|
|
96
|
+
react_1.default.createElement("input", { type: "file", ref: inputRef, onChange: function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
+
var _a;
|
|
98
|
+
return __generator(this, function (_b) {
|
|
99
|
+
if (!((_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0]) || !onChange)
|
|
100
|
+
return [2 /*return*/];
|
|
101
|
+
handleUpload(e.target.files[0]);
|
|
102
|
+
return [2 /*return*/];
|
|
103
|
+
});
|
|
104
|
+
}); } }),
|
|
105
|
+
react_1.default.createElement("button", { type: "button", onClick: handleClick }, (value === null || value === void 0 ? void 0 : value.length)
|
|
106
|
+
? 'Uploaded'
|
|
107
|
+
: uploading
|
|
108
|
+
? 'Uploading...'
|
|
109
|
+
: 'Upload a file'))));
|
|
110
|
+
};
|
|
111
|
+
exports.Upload = Upload;
|
|
112
|
+
exports.Upload.componentName = 'upload';
|
|
113
|
+
exports.Upload.compatibleAttributes = new Set([constants_1.ATTRIBUTE_TYPES.asset]);
|
|
114
|
+
exports.default = (0, formInputContainer_1.default)(exports.Upload);
|
|
@@ -0,0 +1,15 @@
|
|
|
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.UploadWrapper = void 0;
|
|
11
|
+
var styled_components_1 = __importDefault(require("styled-components"));
|
|
12
|
+
exports.UploadWrapper = styled_components_1.default.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n overflow: hidden;\n display: inline-block;\n\n & button {\n height: 40px;\n width: ", ";\n padding: ", ";\n overflow: hidden;\n font-family: ", ";\n font-size: ", ";\n color: ", ";\n background: white;\n cursor: pointer;\n border-radius: ", ";\n border: 1px solid ", ";\n transition: all 0.16s ease-in-out;\n }\n\n & button:hover {\n border: 1px solid ", ";\n color: ", ";\n }\n\n & input[type='file'] {\n display: none;\n }\n"], ["\n position: relative;\n overflow: hidden;\n display: inline-block;\n\n & button {\n height: 40px;\n width: ", ";\n padding: ", ";\n overflow: hidden;\n font-family: ", ";\n font-size: ", ";\n color: ", ";\n background: white;\n cursor: pointer;\n border-radius: ", ";\n border: 1px solid ", ";\n transition: all 0.16s ease-in-out;\n }\n\n & button:hover {\n border: 1px solid ", ";\n color: ", ";\n }\n\n & input[type='file'] {\n display: none;\n }\n"])), function (props) {
|
|
13
|
+
return props.fullWidth ? '100%' : props.iconOnly ? '40px' : 'max-content';
|
|
14
|
+
}, function (props) { return (props.iconOnly ? '0px' : '10px 16px'); }, function (props) { return props.theme.fontFamily; }, function (props) { return props.theme.fontBaseSize; }, function (props) { return props.theme.textColor; }, function (props) { return props.theme.borderRadius || '2px'; }, function (props) { return props.theme.textColor; }, function (props) { return props.theme.primaryColor; }, function (props) { return props.theme.primaryColor; });
|
|
15
|
+
var templateObject_1;
|
|
@@ -10,11 +10,14 @@ export interface IOption extends IOptionShared {
|
|
|
10
10
|
color?: string;
|
|
11
11
|
imageUrl?: string;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
interface MetadataKeys {
|
|
14
|
+
imgBaseUrl?: string;
|
|
15
15
|
metadataKeyThumbnail?: string;
|
|
16
|
-
metadataKeyDescription?: string;
|
|
17
16
|
metadataKeyPrice?: string;
|
|
17
|
+
metadataKeyDescription?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface IFormContainerProps extends Pick<MetadataKeys, 'metadataKeyThumbnail' | 'metadataKeyPrice' | 'metadataKeyDescription'> {
|
|
20
|
+
attribute?: string;
|
|
18
21
|
hideAttributeTitle?: string;
|
|
19
22
|
sort?: string;
|
|
20
23
|
title?: string;
|
|
@@ -23,29 +26,18 @@ export interface IFormContainerProps {
|
|
|
23
26
|
onClick?: (value: string) => void;
|
|
24
27
|
className?: string;
|
|
25
28
|
}
|
|
26
|
-
export interface IFormComponentProps<T extends IOptionShared> {
|
|
27
|
-
title?: string;
|
|
28
|
-
description?: string;
|
|
29
|
-
value?: string;
|
|
30
|
-
onClick?: (value: string) => void;
|
|
31
|
-
className?: string;
|
|
29
|
+
export interface IFormComponentProps<T extends IOptionShared | undefined> extends Pick<IFormContainerProps, 'title' | 'description' | 'value' | 'onClick' | 'className'> {
|
|
32
30
|
options: null | undefined | Array<T>;
|
|
33
31
|
}
|
|
34
32
|
export interface IFormComponent<P> extends FunctionComponent<P> {
|
|
35
33
|
compatibleAttributes: Set<string>;
|
|
36
34
|
}
|
|
37
|
-
interface MetadataKeys {
|
|
38
|
-
imgBaseUrl?: string;
|
|
39
|
-
metadataKeyThumbnail?: string;
|
|
40
|
-
metadataKeyPrice?: string;
|
|
41
|
-
metadataKeyDescription?: string;
|
|
42
|
-
}
|
|
43
35
|
interface IPrepAttributeConfig {
|
|
44
36
|
metadataKeys: MetadataKeys;
|
|
45
37
|
sort?: string;
|
|
46
38
|
}
|
|
47
39
|
export declare const prepAttributeForComponent: (attribute: IThreekitDisplayAttribute, config: IPrepAttributeConfig) => {
|
|
48
|
-
selected: string | number | import("../../threekit").
|
|
40
|
+
selected: string | number | import("../../threekit").IConfigurationAsset | import("../../threekit").IConfigurationColor;
|
|
49
41
|
options: IDisplayAttributeAssetValue[] | {
|
|
50
42
|
name: string;
|
|
51
43
|
label: string;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export declare const formComponents: {
|
|
3
3
|
[x: string]: {
|
|
4
4
|
[x: string]: ((props: import("./Cards").ICards) => JSX.Element | null) | ((props: import("./Tiles").ITiles) => JSX.Element | null);
|
|
5
|
+
} | {
|
|
6
|
+
[x: string]: (props: import("./Upload").IUpload) => JSX.Element | null;
|
|
5
7
|
};
|
|
6
8
|
};
|
|
7
9
|
export default formComponents;
|