@threekit-tools/treble 0.0.51 → 0.0.55
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.d.ts +5 -2
- package/dist/Treble/Treble.js +7 -1
- 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/FlatForm/index.js +9 -3
- package/dist/components/Upload/index.d.ts +12 -0
- package/dist/components/Upload/index.js +137 -0
- package/dist/components/Upload/upload.styles.d.ts +7 -0
- package/dist/components/Upload/upload.styles.js +16 -0
- package/dist/components/containers/formInputContainer.d.ts +7 -15
- 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 +65 -6
- 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/icons/Spinner.d.ts +9 -0
- package/dist/icons/Spinner.js +38 -0
- package/dist/icons/index.d.ts +3 -2
- package/dist/icons/index.js +4 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/store/treble.js +21 -19
- package/dist/threekit.d.ts +18 -3
- package/dist/utils.d.ts +4 -3
- package/package.json +1 -1
package/dist/Treble/Treble.d.ts
CHANGED
|
@@ -1,10 +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
7
|
orgId: string;
|
|
8
|
+
initialConfiguration: IConfiguration;
|
|
8
9
|
}
|
|
9
10
|
export interface ISaveConfigurationConfig {
|
|
10
11
|
customerId?: string;
|
|
@@ -15,14 +16,16 @@ declare class Treble {
|
|
|
15
16
|
_api: typeof threekitAPI;
|
|
16
17
|
_player: IThreekitPlayer;
|
|
17
18
|
wishlist: IWishlist;
|
|
19
|
+
private _initialConfiguration;
|
|
18
20
|
private _snapshots;
|
|
19
21
|
takeSnapshots: Snapshots['takeSnapshots'];
|
|
20
|
-
constructor({ player, orgId }: ITreble);
|
|
22
|
+
constructor({ player, orgId, initialConfiguration }: ITreble);
|
|
21
23
|
saveConfiguration: (config?: ISaveConfigurationConfig | undefined) => Promise<{
|
|
22
24
|
resumableUrl: string;
|
|
23
25
|
} & import("../http/configurations").IConfigurationResponse & {
|
|
24
26
|
thumbnail: string;
|
|
25
27
|
}>;
|
|
26
28
|
getNestedConfigurator: (address: string | Array<string>) => any;
|
|
29
|
+
resetConfiguration: (configuration?: ISetConfiguration | undefined) => void;
|
|
27
30
|
}
|
|
28
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, orgId = _a.orgId;
|
|
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;
|
|
@@ -94,6 +94,11 @@ var Treble = /** @class */ (function () {
|
|
|
94
94
|
}).configurator;
|
|
95
95
|
}, player.getConfigurator());
|
|
96
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
|
+
};
|
|
97
102
|
// Threekit API
|
|
98
103
|
this._api = api_1.default;
|
|
99
104
|
this._player = player;
|
|
@@ -101,6 +106,7 @@ var Treble = /** @class */ (function () {
|
|
|
101
106
|
this._snapshots = new Snapshots_1.default();
|
|
102
107
|
this.takeSnapshots = this._snapshots.takeSnapshots;
|
|
103
108
|
// this._player = player.enableApi('player');
|
|
109
|
+
this._initialConfiguration = JSON.stringify(initialConfiguration);
|
|
104
110
|
}
|
|
105
111
|
return Treble;
|
|
106
112
|
}());
|
|
@@ -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
|
};
|
|
@@ -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)));
|
|
@@ -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,137 @@
|
|
|
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 constants_1 = require("../../constants");
|
|
64
|
+
var FormComponentTitle_1 = __importDefault(require("../FormComponentTitle"));
|
|
65
|
+
var FormComponentDescription_1 = __importDefault(require("../FormComponentDescription"));
|
|
66
|
+
var shared_styles_1 = require("../shared.styles");
|
|
67
|
+
var utils_1 = require("../../utils");
|
|
68
|
+
var icons_1 = require("../../icons");
|
|
69
|
+
var formInputContainer_1 = __importDefault(require("../containers/formInputContainer"));
|
|
70
|
+
var upload_styles_1 = require("./upload.styles");
|
|
71
|
+
var Upload = function (props) {
|
|
72
|
+
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];
|
|
75
|
+
var inputRef = (0, react_1.createRef)();
|
|
76
|
+
var cls = (0, utils_1.generateInputClassName)('upload', customClassName, title);
|
|
77
|
+
var handleClick = function () {
|
|
78
|
+
var _a;
|
|
79
|
+
if (isUploading)
|
|
80
|
+
return;
|
|
81
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
82
|
+
};
|
|
83
|
+
var handleUpload = function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
84
|
+
var reader;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
setIsUploading(true);
|
|
89
|
+
return [4 /*yield*/, onChange(file)];
|
|
90
|
+
case 1:
|
|
91
|
+
_a.sent();
|
|
92
|
+
setIsUploading(false);
|
|
93
|
+
setFilename(file.name);
|
|
94
|
+
reader = new FileReader();
|
|
95
|
+
reader.onload = function () {
|
|
96
|
+
var imgEl = document.getElementById('trbl-upload-img');
|
|
97
|
+
if (!imgEl)
|
|
98
|
+
return;
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
imgEl.src = reader.result;
|
|
101
|
+
};
|
|
102
|
+
reader.readAsDataURL(file);
|
|
103
|
+
return [2 /*return*/];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}); };
|
|
107
|
+
return (react_1.default.createElement(shared_styles_1.FormComponentWrapper, null,
|
|
108
|
+
react_1.default.createElement(FormComponentTitle_1.default, { title: title, className: cls }),
|
|
109
|
+
react_1.default.createElement(FormComponentDescription_1.default, { description: description, className: cls }),
|
|
110
|
+
react_1.default.createElement(upload_styles_1.UploadWrapper, { className: cls },
|
|
111
|
+
react_1.default.createElement("input", { type: "file", ref: inputRef, onChange: function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
112
|
+
var _a;
|
|
113
|
+
return __generator(this, function (_b) {
|
|
114
|
+
if (!((_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0]) || !onChange)
|
|
115
|
+
return [2 /*return*/];
|
|
116
|
+
handleUpload(e.target.files[0]);
|
|
117
|
+
return [2 /*return*/];
|
|
118
|
+
});
|
|
119
|
+
}); } }),
|
|
120
|
+
react_1.default.createElement("button", { type: "button", onClick: handleClick }, isUploading ? (react_1.default.createElement(upload_styles_1.UploadingWrapper, null,
|
|
121
|
+
react_1.default.createElement("div", null,
|
|
122
|
+
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(upload_styles_1.UploadingWrapper, null,
|
|
124
|
+
react_1.default.createElement("div", null,
|
|
125
|
+
react_1.default.createElement("img", { src: "#", id: "trbl-upload-img" })),
|
|
126
|
+
react_1.default.createElement("div", null,
|
|
127
|
+
react_1.default.createElement("div", null, filename),
|
|
128
|
+
react_1.default.createElement("div", null, "Upload another file.")))) : (react_1.default.createElement("div", null,
|
|
129
|
+
react_1.default.createElement("div", null,
|
|
130
|
+
react_1.default.createElement(icons_1.ImageIcon, null)),
|
|
131
|
+
react_1.default.createElement("div", null, "Click to upload"),
|
|
132
|
+
react_1.default.createElement("div", null, "Supported file types: PNG, JPEG, SVG")))))));
|
|
133
|
+
};
|
|
134
|
+
exports.Upload = Upload;
|
|
135
|
+
exports.Upload.componentName = 'upload';
|
|
136
|
+
exports.Upload.compatibleAttributes = new Set([constants_1.ATTRIBUTE_TYPES.asset]);
|
|
137
|
+
exports.default = (0, formInputContainer_1.default)(exports.Upload);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface IUploadWrapper {
|
|
2
|
+
fullWidth?: boolean;
|
|
3
|
+
iconOnly?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const UploadWrapper: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, IUploadWrapper, never>;
|
|
6
|
+
export declare const UploadingWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
7
|
+
export {};
|
|
@@ -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.UploadingWrapper = 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 min-height: 40px;\n height: max-content;\n width: ", ";\n padding: ", ";\n overflow: hidden;\n font-family: ", ";\n font-size: ", ";\n color: ", ";\n text-align: center;\n background: white;\n cursor: pointer;\n border-radius: ", ";\n border: 1px solid ", ";\n transition: all 0.16s ease-in-out;\n }\n\n .tk-icon {\n transition: all 0.16s ease-in-out;\n }\n\n & button:hover {\n border: 1px solid ", ";\n color: ", ";\n\n .tk-icon {\n stroke: ", ";\n }\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 min-height: 40px;\n height: max-content;\n width: ", ";\n padding: ", ";\n overflow: hidden;\n font-family: ", ";\n font-size: ", ";\n color: ", ";\n text-align: center;\n background: white;\n cursor: pointer;\n border-radius: ", ";\n border: 1px solid ", ";\n transition: all 0.16s ease-in-out;\n }\n\n .tk-icon {\n transition: all 0.16s ease-in-out;\n }\n\n & button:hover {\n border: 1px solid ", ";\n color: ", ";\n\n .tk-icon {\n stroke: ", ";\n }\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.borderColorBase; }, function (props) { return props.theme.primaryColor; }, function (props) { return props.theme.primaryColor; }, function (props) { return props.theme.primaryColor; });
|
|
15
|
+
exports.UploadingWrapper = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: grid;\n grid-template-columns: max-content max-content;\n grid-gap: 8px;\n\n & > div {\n height: max-content;\n position: relative;\n top: 50%;\n transform: translateY(-50%);\n }\n\n img {\n height: 72px;\n }\n"], ["\n display: grid;\n grid-template-columns: max-content max-content;\n grid-gap: 8px;\n\n & > div {\n height: max-content;\n position: relative;\n top: 50%;\n transform: translateY(-50%);\n }\n\n img {\n height: 72px;\n }\n"])));
|
|
16
|
+
var templateObject_1, templateObject_2;
|
|
@@ -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,23 +26,12 @@ 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;
|
|
@@ -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;
|
|
@@ -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;
|
|
21
|
+
var _a, _b, _c, _d;
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.formComponents = void 0;
|
|
24
24
|
var constants_1 = require("../constants");
|
|
@@ -28,6 +28,7 @@ var Strips_1 = __importStar(require("./Strips"));
|
|
|
28
28
|
var Swatch_1 = __importStar(require("./Swatch"));
|
|
29
29
|
var Tiles_1 = __importStar(require("./Tiles"));
|
|
30
30
|
var TilesGroup_1 = __importStar(require("./TilesGroup"));
|
|
31
|
+
var Upload_1 = __importStar(require("./Upload"));
|
|
31
32
|
exports.formComponents = (_a = {},
|
|
32
33
|
_a[constants_1.ATTRIBUTE_TYPES.asset] = (_b = {},
|
|
33
34
|
// First option is default
|
|
@@ -47,5 +48,8 @@ exports.formComponents = (_a = {},
|
|
|
47
48
|
_c[Swatch_1.Swatch.componentName] = Swatch_1.default,
|
|
48
49
|
_c[TilesGroup_1.TilesGroup.componentName] = TilesGroup_1.default,
|
|
49
50
|
_c),
|
|
51
|
+
_a[constants_1.ASSET_TYPES.upload] = (_d = {},
|
|
52
|
+
_d[Upload_1.Upload.componentName] = Upload_1.default,
|
|
53
|
+
_d),
|
|
50
54
|
_a);
|
|
51
55
|
exports.default = exports.formComponents;
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
****************************************************/
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.WISHLIST_LOCALSTORAGE_KEY = exports.SNAPSHOT_OUTPUTS = exports.SNAPSHOT_FORMATS = exports.METADATA_RESERVED = exports.ATTRIBUTES_RESERVED = exports.SORT_OPTIONS = exports.ATTRIBUTE_TYPES = exports.DEFAULT_PLAYER_CONFIG = exports.TK_PLAYER_ROOT_DIV = exports.TK_PLAYER_LOADER_DIV = exports.TK_SAVED_CONFIG_PARAM_KEY = exports.TK_PRODUCT_ID_PARAM_KEY = exports.IS_TREBLE_SCRIPTS = exports.FORM_CLASS_NAME = exports.DISPLAY_CLASS_NAME = exports.TOOL_CLASS_NAME = exports.LAYOUT_CLASS_NAME = exports.WIDGET_CLASS_NAME = exports.INPUT_COMPONENT_CLASS_NAME = exports.CLASS_NAME_PREFIX = exports.DEFAULT_CLASS_NAME = void 0;
|
|
7
|
+
exports.WISHLIST_LOCALSTORAGE_KEY = exports.SNAPSHOT_OUTPUTS = exports.SNAPSHOT_FORMATS = exports.METADATA_RESERVED = exports.ATTRIBUTES_RESERVED = exports.SORT_OPTIONS = exports.ASSET_TYPES = exports.ATTRIBUTE_TYPES = exports.DEFAULT_PLAYER_CONFIG = exports.TK_PLAYER_ROOT_DIV = exports.TK_PLAYER_LOADER_DIV = exports.TK_SAVED_CONFIG_PARAM_KEY = exports.TK_PRODUCT_ID_PARAM_KEY = exports.IS_TREBLE_SCRIPTS = exports.FORM_CLASS_NAME = exports.DISPLAY_CLASS_NAME = exports.TOOL_CLASS_NAME = exports.LAYOUT_CLASS_NAME = exports.WIDGET_CLASS_NAME = exports.INPUT_COMPONENT_CLASS_NAME = exports.CLASS_NAME_PREFIX = exports.DEFAULT_CLASS_NAME = void 0;
|
|
8
8
|
exports.DEFAULT_CLASS_NAME = 'threekit-react';
|
|
9
9
|
exports.CLASS_NAME_PREFIX = 'tk';
|
|
10
10
|
exports.INPUT_COMPONENT_CLASS_NAME = "".concat(exports.DEFAULT_CLASS_NAME, " ").concat(exports.CLASS_NAME_PREFIX, "-input");
|
|
@@ -54,6 +54,10 @@ exports.ATTRIBUTE_TYPES = {
|
|
|
54
54
|
color: 'Color',
|
|
55
55
|
boolean: 'Boolean',
|
|
56
56
|
};
|
|
57
|
+
exports.ASSET_TYPES = {
|
|
58
|
+
item: 'item',
|
|
59
|
+
upload: 'upload',
|
|
60
|
+
};
|
|
57
61
|
exports.SORT_OPTIONS = {
|
|
58
62
|
ascending: 'ascending',
|
|
59
63
|
descending: 'descending',
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { useThreekitSelector, useThreekitDispatch } from '../../store';
|
|
3
|
+
// import { getAttributes, setConfiguration } from '../../store/attributes';
|
|
4
|
+
// import { selectionToConfiguration } from '../../utils';
|
|
5
|
+
// import {
|
|
6
|
+
// IConfigurationColor,
|
|
7
|
+
// ISetConfiguration,
|
|
8
|
+
// IThreekitDisplayAttribute,
|
|
9
|
+
// } from '../../threekit';
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.useArrayAttribute = void 0;
|
|
12
|
+
// export type AttributeValue = string | number | boolean | IConfigurationColor;
|
|
13
|
+
// type UseAttributeError = [undefined, undefined];
|
|
14
|
+
// type UseAttributeSuccess = [
|
|
15
|
+
// IThreekitDisplayAttribute,
|
|
16
|
+
// (val: AttributeValue) => void
|
|
17
|
+
// ];
|
|
18
|
+
var useArrayAttribute = function (attributeIdentifier) {
|
|
19
|
+
if (!attributeIdentifier)
|
|
20
|
+
return [];
|
|
21
|
+
return attributeIdentifier;
|
|
22
|
+
};
|
|
23
|
+
exports.useArrayAttribute = useArrayAttribute;
|
|
24
|
+
// Ordinal Configurator (Psuedo-Array type attribute)
|
|
25
|
+
// export const addItemToArray = (arrayLabel) => (
|
|
26
|
+
// assetId,
|
|
27
|
+
// addToIdx = undefined
|
|
28
|
+
// ) => async (dispatch, getState) => {
|
|
29
|
+
// if (!assetId?.length) return;
|
|
30
|
+
// const { threekit } = getState();
|
|
31
|
+
// const attributesRegExp = new RegExp(`${arrayLabel} [0-9]`);
|
|
32
|
+
// const arrayAttributes = filterAttributesArray(
|
|
33
|
+
// attributesRegExp,
|
|
34
|
+
// threekit.attributes
|
|
35
|
+
// );
|
|
36
|
+
// let updateAttrIdx = addToIdx;
|
|
37
|
+
// let attributeToUpdate;
|
|
38
|
+
// if (isNaN(updateAttrIdx))
|
|
39
|
+
// attributeToUpdate = Object.values(arrayAttributes).find((el, idx) => {
|
|
40
|
+
// if (!el.value.assetId?.length) {
|
|
41
|
+
// updateAttrIdx = idx;
|
|
42
|
+
// return true;
|
|
43
|
+
// }
|
|
44
|
+
// });
|
|
45
|
+
// else attributeToUpdate = arrayAttributes[updateAttrIdx];
|
|
46
|
+
// if (!attributeToUpdate) return message.info('Max items reached');
|
|
47
|
+
// let error;
|
|
48
|
+
// const options = Object.values(arrayAttributes)[0].values.reduce(
|
|
49
|
+
// (output, item) => Object.assign(output, { [item.assetId]: item }),
|
|
50
|
+
// {}
|
|
51
|
+
// );
|
|
52
|
+
// const updatedArray = Object.values(arrayAttributes).reduce(
|
|
53
|
+
// (output, attr, i) => {
|
|
54
|
+
// if (i !== updateAttrIdx) output.push(attr);
|
|
55
|
+
// else output.push({ ...attr, value: { assetId } });
|
|
56
|
+
// return output;
|
|
57
|
+
// },
|
|
58
|
+
// []
|
|
59
|
+
// );
|
|
60
|
+
// // Default Validator
|
|
61
|
+
// error = arrayValidator(options, updatedArray);
|
|
62
|
+
// if (error) return message.info(error);
|
|
63
|
+
// // Custom Validator
|
|
64
|
+
// if (MIDDLEWARE.arrayValidation?.[arrayLabel])
|
|
65
|
+
// error = MIDDLEWARE.arrayValidation?.[arrayLabel](options, updatedArray);
|
|
66
|
+
// if (error) return message.info(error);
|
|
67
|
+
// dispatch(setConfiguration({ [attributeToUpdate.name]: { assetId } }));
|
|
68
|
+
// };
|
|
69
|
+
// export const deleteItemFromArray = (arrayLabel) => (idx) => async (
|
|
70
|
+
// dispatch,
|
|
71
|
+
// getState
|
|
72
|
+
// ) => {
|
|
73
|
+
// if (isNaN(idx)) return;
|
|
74
|
+
// const { threekit } = getState();
|
|
75
|
+
// const attributesRegExp = new RegExp(`${arrayLabel} [0-9]`);
|
|
76
|
+
// const arrayAttributes = filterAttributesArray(
|
|
77
|
+
// attributesRegExp,
|
|
78
|
+
// threekit.attributes
|
|
79
|
+
// );
|
|
80
|
+
// let error;
|
|
81
|
+
// const options = Object.values(arrayAttributes)[0].values.reduce(
|
|
82
|
+
// (output, item) => Object.assign(output, { [item.assetId]: item }),
|
|
83
|
+
// {}
|
|
84
|
+
// );
|
|
85
|
+
// const updatedArray = Object.values(arrayAttributes).filter(
|
|
86
|
+
// (_, i) => i !== idx
|
|
87
|
+
// );
|
|
88
|
+
// // Default Validator
|
|
89
|
+
// error = arrayValidator(options, updatedArray);
|
|
90
|
+
// if (error) return message.info(error);
|
|
91
|
+
// // Custom Validator
|
|
92
|
+
// if (MIDDLEWARE.arrayValidation?.[arrayLabel])
|
|
93
|
+
// error = MIDDLEWARE.arrayValidation?.[arrayLabel](options, updatedArray);
|
|
94
|
+
// if (error) return message.info(error);
|
|
95
|
+
// const arrayConfigurationObj = filterAttributesArray(
|
|
96
|
+
// attributesRegExp,
|
|
97
|
+
// window.threekit.configurator.getConfiguration()
|
|
98
|
+
// );
|
|
99
|
+
// const arrayConfiguration = Object.entries(arrayConfigurationObj);
|
|
100
|
+
// const updatedConfiguration = arrayConfiguration.reduce(
|
|
101
|
+
// (output, [attributeName], i) => {
|
|
102
|
+
// if (i < idx) return output;
|
|
103
|
+
// if (!arrayConfiguration[i + 1])
|
|
104
|
+
// return Object.assign(output, { [attributeName]: { assetId: '' } });
|
|
105
|
+
// return Object.assign(output, {
|
|
106
|
+
// [attributeName]: arrayConfiguration[i + 1][1],
|
|
107
|
+
// });
|
|
108
|
+
// },
|
|
109
|
+
// {}
|
|
110
|
+
// );
|
|
111
|
+
// dispatch(setConfiguration(updatedConfiguration));
|
|
112
|
+
// };
|
|
113
|
+
// export const moveItemWithinArray = (arrayLabel) => (
|
|
114
|
+
// fromIdx,
|
|
115
|
+
// toIdx,
|
|
116
|
+
// config
|
|
117
|
+
// ) => async (dispatch, getState) => {
|
|
118
|
+
// if (isNaN(fromIdx) || isNaN(fromIdx)) return;
|
|
119
|
+
// const { threekit } = getState();
|
|
120
|
+
// const { method } = Object.assign({ method: 'move' }, config);
|
|
121
|
+
// const attributesRegExp =
|
|
122
|
+
// typeof arrayLabel === 'string'
|
|
123
|
+
// ? new RegExp(`${arrayLabel} [0-9]`)
|
|
124
|
+
// : arrayLabel;
|
|
125
|
+
// const arrayAttributes = filterAttributesArray(
|
|
126
|
+
// attributesRegExp,
|
|
127
|
+
// threekit.attributes
|
|
128
|
+
// );
|
|
129
|
+
// let error;
|
|
130
|
+
// const options = Object.values(arrayAttributes)[0].values.reduce(
|
|
131
|
+
// (output, item) => Object.assign(output, { [item.assetId]: item }),
|
|
132
|
+
// {}
|
|
133
|
+
// );
|
|
134
|
+
// let updatedArray;
|
|
135
|
+
// switch (method) {
|
|
136
|
+
// case 'move':
|
|
137
|
+
// updatedArray = Object.values(arrayAttributes).reduce(
|
|
138
|
+
// (output, attr, idx, srcArray) => {
|
|
139
|
+
// if (idx === fromIdx) return output;
|
|
140
|
+
// output.push(attr);
|
|
141
|
+
// if (idx === toIdx) output.push(srcArray[fromIdx]);
|
|
142
|
+
// return output;
|
|
143
|
+
// },
|
|
144
|
+
// []
|
|
145
|
+
// );
|
|
146
|
+
// break;
|
|
147
|
+
// default:
|
|
148
|
+
// break;
|
|
149
|
+
// }
|
|
150
|
+
// // Default Validator
|
|
151
|
+
// error = arrayValidator(options, updatedArray);
|
|
152
|
+
// if (error) return message.info(error);
|
|
153
|
+
// // Custom Validator
|
|
154
|
+
// if (MIDDLEWARE.arrayValidation?.[arrayLabel])
|
|
155
|
+
// error = MIDDLEWARE.arrayValidation?.[arrayLabel](options, updatedArray);
|
|
156
|
+
// if (error) return message.info(error);
|
|
157
|
+
// const arrayConfigurationObj = filterAttributesArray(
|
|
158
|
+
// attributesRegExp,
|
|
159
|
+
// window.threekit.configurator.getConfiguration()
|
|
160
|
+
// );
|
|
161
|
+
// const attributeKeys = Object.keys(arrayConfigurationObj);
|
|
162
|
+
// const arrayConfiguration = Object.values(arrayConfigurationObj);
|
|
163
|
+
// let updatedConfiguration;
|
|
164
|
+
// switch (method) {
|
|
165
|
+
// case 'move':
|
|
166
|
+
// updatedConfiguration = arrayConfiguration.reduce(
|
|
167
|
+
// (output, configuration, idx, srcArray) => {
|
|
168
|
+
// if (idx === fromIdx) return output;
|
|
169
|
+
// output = Object.assign(output, {
|
|
170
|
+
// [attributeKeys.shift()]: configuration,
|
|
171
|
+
// });
|
|
172
|
+
// if (idx === toIdx)
|
|
173
|
+
// output = Object.assign(output, {
|
|
174
|
+
// [attributeKeys.shift()]: srcArray[fromIdx],
|
|
175
|
+
// });
|
|
176
|
+
// return output;
|
|
177
|
+
// },
|
|
178
|
+
// {}
|
|
179
|
+
// );
|
|
180
|
+
// break;
|
|
181
|
+
// default:
|
|
182
|
+
// break;
|
|
183
|
+
// }
|
|
184
|
+
// dispatch(setConfiguration(updatedConfiguration));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare type
|
|
1
|
+
import { IThreekitDisplayAttribute, IConfigurationColor } from '../../threekit';
|
|
2
|
+
export declare type RawAttributeValue = string | number | boolean | IConfigurationColor | File;
|
|
3
3
|
declare type UseAttributeError = [undefined, undefined];
|
|
4
4
|
declare type UseAttributeSuccess = [
|
|
5
5
|
IThreekitDisplayAttribute,
|
|
6
|
-
(val:
|
|
6
|
+
(val: RawAttributeValue) => Promise<void>
|
|
7
7
|
];
|
|
8
8
|
declare type UseAttributeHook = UseAttributeError | UseAttributeSuccess;
|
|
9
9
|
declare const useAttribute: (attributeName?: string | undefined) => UseAttributeHook;
|
|
@@ -1,8 +1,49 @@
|
|
|
1
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
|
+
};
|
|
2
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
42
|
var store_1 = require("../../store");
|
|
4
43
|
var attributes_1 = require("../../store/attributes");
|
|
5
44
|
var utils_1 = require("../../utils");
|
|
45
|
+
var constants_1 = require("../../constants");
|
|
46
|
+
var api_1 = __importDefault(require("../../api"));
|
|
6
47
|
var useAttribute = function (attributeName) {
|
|
7
48
|
if (!attributeName)
|
|
8
49
|
return [undefined, undefined];
|
|
@@ -13,13 +54,31 @@ var useAttribute = function (attributeName) {
|
|
|
13
54
|
var attribute = attributes[attributeName];
|
|
14
55
|
if (!attribute)
|
|
15
56
|
return [undefined, undefined];
|
|
16
|
-
var handleChange = function (value) {
|
|
57
|
+
var handleChange = function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
|
+
var preppedValue, assetId;
|
|
17
59
|
var _a;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
60
|
+
return __generator(this, function (_b) {
|
|
61
|
+
switch (_b.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
if (!(attribute.type === 'Asset' &&
|
|
64
|
+
attribute.assetType === constants_1.ASSET_TYPES.upload)) return [3 /*break*/, 2];
|
|
65
|
+
return [4 /*yield*/, api_1.default.catalog.uploadAsset(value)];
|
|
66
|
+
case 1:
|
|
67
|
+
assetId = _b.sent();
|
|
68
|
+
if (assetId)
|
|
69
|
+
preppedValue = (0, utils_1.selectionToConfiguration)(assetId, attribute.type);
|
|
70
|
+
return [3 /*break*/, 3];
|
|
71
|
+
case 2:
|
|
72
|
+
preppedValue = (0, utils_1.selectionToConfiguration)(value, attribute.type);
|
|
73
|
+
_b.label = 3;
|
|
74
|
+
case 3:
|
|
75
|
+
dispatch((0, attributes_1.setConfiguration)((_a = {},
|
|
76
|
+
_a[attributeName] = preppedValue,
|
|
77
|
+
_a)));
|
|
78
|
+
return [2 /*return*/];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}); };
|
|
23
82
|
return [attribute, handleChange];
|
|
24
83
|
};
|
|
25
84
|
exports.default = useAttribute;
|
package/dist/http/catalog.d.ts
CHANGED
|
@@ -1,2 +1,53 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export interface IJob {
|
|
2
|
+
createdAt: string;
|
|
3
|
+
createdBy: string;
|
|
4
|
+
duration: null;
|
|
5
|
+
id: string;
|
|
6
|
+
orgId: string;
|
|
7
|
+
parameters: {
|
|
8
|
+
files: Array<any>;
|
|
9
|
+
image: string;
|
|
10
|
+
};
|
|
11
|
+
priority: number;
|
|
12
|
+
schedulerState: string | 'active';
|
|
13
|
+
status: string | 'pending' | 'stopped';
|
|
14
|
+
taskCount: number;
|
|
15
|
+
taskProgress: null | number;
|
|
16
|
+
taskResultFailures: number;
|
|
17
|
+
taskResultSuccesses: number;
|
|
18
|
+
taskStatusPending: number;
|
|
19
|
+
taskStatusRunning: number;
|
|
20
|
+
taskStatusStopped: number;
|
|
21
|
+
tasks: Array<any>;
|
|
22
|
+
timeElapsed: string;
|
|
23
|
+
timeRemaining: string;
|
|
24
|
+
title: string;
|
|
25
|
+
type: string | 'import';
|
|
26
|
+
updatedAt: string;
|
|
27
|
+
}
|
|
28
|
+
export interface IUploadAsset {
|
|
29
|
+
name: string;
|
|
30
|
+
assetId: string;
|
|
31
|
+
}
|
|
32
|
+
export interface IUploadResponse {
|
|
33
|
+
job: IJob;
|
|
34
|
+
jobId: string;
|
|
35
|
+
msg: string;
|
|
36
|
+
}
|
|
37
|
+
export interface IJobResponse {
|
|
38
|
+
job: IJob;
|
|
39
|
+
output?: {
|
|
40
|
+
font: Array<any>;
|
|
41
|
+
lut: Array<any>;
|
|
42
|
+
material: Array<any>;
|
|
43
|
+
model: Array<any>;
|
|
44
|
+
scene: Array<any>;
|
|
45
|
+
texture: Array<IUploadAsset>;
|
|
46
|
+
upload: Array<any>;
|
|
47
|
+
vector: Array<IUploadAsset>;
|
|
48
|
+
vfb: Array<any>;
|
|
49
|
+
video: Array<any>;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export declare const uploadAsset: (formData: FormData) => Promise<import("axios").AxiosResponse<IUploadResponse[]>>;
|
|
53
|
+
export declare const getJobStatus: (jobId: string) => Promise<import("axios").AxiosResponse<IJobResponse>>;
|
package/dist/http/catalog.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getJobStatus = exports.uploadAsset = void 0;
|
|
7
7
|
var request_1 = __importDefault(require("./request"));
|
|
8
|
-
var
|
|
8
|
+
var CATALOG_API_ROUTE = "/api/catalog";
|
|
9
9
|
var uploadAsset = function (formData) {
|
|
10
10
|
var error;
|
|
11
11
|
if (!formData)
|
|
@@ -13,7 +13,7 @@ var uploadAsset = function (formData) {
|
|
|
13
13
|
if (error)
|
|
14
14
|
throw new Error(error);
|
|
15
15
|
return request_1.default.post({
|
|
16
|
-
url: "".concat(
|
|
16
|
+
url: "".concat(CATALOG_API_ROUTE, "/assets/upload"),
|
|
17
17
|
formData: formData,
|
|
18
18
|
});
|
|
19
19
|
};
|
|
@@ -24,6 +24,6 @@ var getJobStatus = function (jobId) {
|
|
|
24
24
|
error = 'Requires a jobId';
|
|
25
25
|
if (error)
|
|
26
26
|
throw new Error(error);
|
|
27
|
-
return request_1.default.get("".concat(
|
|
27
|
+
return request_1.default.get("".concat(CATALOG_API_ROUTE, "/jobs/").concat(jobId));
|
|
28
28
|
};
|
|
29
29
|
exports.getJobStatus = getJobStatus;
|
package/dist/http/index.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ import * as orders from './orders';
|
|
|
2
2
|
import * as products from './products';
|
|
3
3
|
import * as configurations from './configurations';
|
|
4
4
|
import * as pricebook from './pricebook';
|
|
5
|
+
import * as catalog from './catalog';
|
|
5
6
|
declare const _default: {
|
|
6
7
|
orders: typeof orders;
|
|
7
8
|
products: typeof products;
|
|
8
9
|
configurations: typeof configurations;
|
|
9
10
|
pricebook: typeof pricebook;
|
|
11
|
+
catalog: typeof catalog;
|
|
10
12
|
};
|
|
11
13
|
export default _default;
|
package/dist/http/index.js
CHANGED
|
@@ -23,9 +23,11 @@ var orders = __importStar(require("./orders"));
|
|
|
23
23
|
var products = __importStar(require("./products"));
|
|
24
24
|
var configurations = __importStar(require("./configurations"));
|
|
25
25
|
var pricebook = __importStar(require("./pricebook"));
|
|
26
|
+
var catalog = __importStar(require("./catalog"));
|
|
26
27
|
exports.default = {
|
|
27
28
|
orders: orders,
|
|
28
29
|
products: products,
|
|
29
30
|
configurations: configurations,
|
|
30
31
|
pricebook: pricebook,
|
|
32
|
+
catalog: catalog,
|
|
31
33
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
var react_1 = __importDefault(require("react"));
|
|
30
|
+
var styled_components_1 = __importStar(require("styled-components"));
|
|
31
|
+
function Spinner(props) {
|
|
32
|
+
return react_1.default.createElement(Wrapper, { size: props.size });
|
|
33
|
+
}
|
|
34
|
+
var spin = (0, styled_components_1.keyframes)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\nto {\n transform: rotate(360deg);\n}\n"], ["\nto {\n transform: rotate(360deg);\n}\n"])));
|
|
35
|
+
var Wrapper = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: inline-block;\n width: ", ";\n height: ", ";\n border: 5px solid rgba(0, 0, 0, 0.3);\n border-radius: 50%;\n border-top-color: #000;\n animation: ", " 1s ease-in-out infinite;\n"], ["\n display: inline-block;\n width: ", ";\n height: ", ";\n border: 5px solid rgba(0, 0, 0, 0.3);\n border-radius: 50%;\n border-top-color: #000;\n animation: ", " 1s ease-in-out infinite;\n"])), function (props) { return props.size || '40px'; }, function (props) { return props.size || '40px'; }, spin);
|
|
36
|
+
Spinner.iconName = 'spinner';
|
|
37
|
+
exports.default = Spinner;
|
|
38
|
+
var templateObject_1, templateObject_2;
|
package/dist/icons/index.d.ts
CHANGED
|
@@ -39,11 +39,12 @@ import UndoIcon from './Undo';
|
|
|
39
39
|
import WishlistIcon from './Wishlist';
|
|
40
40
|
import ZoomInIcon from './ZoomIn';
|
|
41
41
|
import ZoomOutIcon from './ZoomOut';
|
|
42
|
+
import SpinnerIcon from './Spinner';
|
|
42
43
|
export interface IIcon extends React.FC {
|
|
43
44
|
iconName: string;
|
|
44
45
|
}
|
|
45
|
-
export { AddIcon, ArrowLeftIcon, ArrowRightIcon, CameraIcon, CaretDownIcon, CaretUpIcon, CaretLeftIcon, CaretRightIcon, CartIcon, CheckmateIcon, ClipboardIcon, ColorPickerIcon, CopyIcon, DeleteIcon, DoubleCaretLeftIcon, DoubleCaretRightIcon, DownloadIcon, DragIcon, EditIcon, HeartIcon, ImageIcon, InfoIcon, MailIcon, MenuIcon, MoreIcon, NewWindowIcon, PauseIcon, PlayIcon, RedoIcon, RemoveIcon, RulerIcon, SearchIcon, SettingsIcon, ShareIcon, SwitchIcon, TagIcon, UndoIcon, WishlistIcon, ZoomInIcon, ZoomOutIcon, };
|
|
46
|
+
export { AddIcon, ArrowLeftIcon, ArrowRightIcon, CameraIcon, CaretDownIcon, CaretUpIcon, CaretLeftIcon, CaretRightIcon, CartIcon, CheckmateIcon, ClipboardIcon, ColorPickerIcon, CopyIcon, DeleteIcon, DoubleCaretLeftIcon, DoubleCaretRightIcon, DownloadIcon, DragIcon, EditIcon, HeartIcon, ImageIcon, InfoIcon, MailIcon, MenuIcon, MoreIcon, NewWindowIcon, PauseIcon, PlayIcon, RedoIcon, RemoveIcon, RulerIcon, SearchIcon, SettingsIcon, ShareIcon, SwitchIcon, TagIcon, UndoIcon, WishlistIcon, ZoomInIcon, ZoomOutIcon, SpinnerIcon, };
|
|
46
47
|
declare const _default: {
|
|
47
|
-
[x: string]: IIcon;
|
|
48
|
+
[x: string]: IIcon | typeof SpinnerIcon;
|
|
48
49
|
};
|
|
49
50
|
export default _default;
|
package/dist/icons/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ZoomOutIcon = exports.ZoomInIcon = exports.WishlistIcon = exports.UndoIcon = exports.TagIcon = exports.SwitchIcon = exports.ShareIcon = exports.SettingsIcon = exports.SearchIcon = exports.RulerIcon = exports.RemoveIcon = exports.RedoIcon = exports.PlayIcon = exports.PauseIcon = exports.NewWindowIcon = exports.MoreIcon = exports.MenuIcon = exports.MailIcon = exports.InfoIcon = exports.ImageIcon = exports.HeartIcon = exports.EditIcon = exports.DragIcon = exports.DownloadIcon = exports.DoubleCaretRightIcon = exports.DoubleCaretLeftIcon = exports.DeleteIcon = exports.CopyIcon = exports.ColorPickerIcon = exports.ClipboardIcon = exports.CheckmateIcon = exports.CartIcon = exports.CaretRightIcon = exports.CaretLeftIcon = exports.CaretUpIcon = exports.CaretDownIcon = exports.CameraIcon = exports.ArrowRightIcon = exports.ArrowLeftIcon = exports.AddIcon = void 0;
|
|
7
|
+
exports.SpinnerIcon = exports.ZoomOutIcon = exports.ZoomInIcon = exports.WishlistIcon = exports.UndoIcon = exports.TagIcon = exports.SwitchIcon = exports.ShareIcon = exports.SettingsIcon = exports.SearchIcon = exports.RulerIcon = exports.RemoveIcon = exports.RedoIcon = exports.PlayIcon = exports.PauseIcon = exports.NewWindowIcon = exports.MoreIcon = exports.MenuIcon = exports.MailIcon = exports.InfoIcon = exports.ImageIcon = exports.HeartIcon = exports.EditIcon = exports.DragIcon = exports.DownloadIcon = exports.DoubleCaretRightIcon = exports.DoubleCaretLeftIcon = exports.DeleteIcon = exports.CopyIcon = exports.ColorPickerIcon = exports.ClipboardIcon = exports.CheckmateIcon = exports.CartIcon = exports.CaretRightIcon = exports.CaretLeftIcon = exports.CaretUpIcon = exports.CaretDownIcon = exports.CameraIcon = exports.ArrowRightIcon = exports.ArrowLeftIcon = exports.AddIcon = void 0;
|
|
8
8
|
var Add_1 = __importDefault(require("./Add"));
|
|
9
9
|
exports.AddIcon = Add_1.default;
|
|
10
10
|
var ArrowLeft_1 = __importDefault(require("./ArrowLeft"));
|
|
@@ -85,6 +85,8 @@ var ZoomIn_1 = __importDefault(require("./ZoomIn"));
|
|
|
85
85
|
exports.ZoomInIcon = ZoomIn_1.default;
|
|
86
86
|
var ZoomOut_1 = __importDefault(require("./ZoomOut"));
|
|
87
87
|
exports.ZoomOutIcon = ZoomOut_1.default;
|
|
88
|
+
var Spinner_1 = __importDefault(require("./Spinner"));
|
|
89
|
+
exports.SpinnerIcon = Spinner_1.default;
|
|
88
90
|
exports.default = (_a = {},
|
|
89
91
|
_a[Add_1.default.iconName] = Add_1.default,
|
|
90
92
|
_a[ArrowLeft_1.default.iconName] = ArrowLeft_1.default,
|
|
@@ -126,4 +128,5 @@ exports.default = (_a = {},
|
|
|
126
128
|
_a[Wishlist_1.default.iconName] = Wishlist_1.default,
|
|
127
129
|
_a[ZoomIn_1.default.iconName] = ZoomIn_1.default,
|
|
128
130
|
_a[ZoomOut_1.default.iconName] = ZoomOut_1.default,
|
|
131
|
+
_a[Spinner_1.default.iconName] = Spinner_1.default,
|
|
129
132
|
_a);
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import Strips from './components/Strips';
|
|
|
19
19
|
import Swatch from './components/Swatch';
|
|
20
20
|
import Tiles from './components/Tiles';
|
|
21
21
|
import TilesGroup from './components/TilesGroup';
|
|
22
|
+
import Upload from './components/Upload';
|
|
22
23
|
import ProductName from './components/ProductName';
|
|
23
24
|
import ProductDescription from './components/ProductDescription';
|
|
24
25
|
import AttributeTitle from './components/AttributeTitle';
|
|
@@ -40,4 +41,4 @@ import icons from './icons';
|
|
|
40
41
|
export * from './icons';
|
|
41
42
|
import TrebleApp from './components/TrebleApp';
|
|
42
43
|
import ProductLayout from './components/ProductLayout';
|
|
43
|
-
export { useAttribute, useConfigurator, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, message, Modal, Drawer, Accordion, Tabs, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, icons, TrebleApp, ProductLayout, };
|
|
44
|
+
export { useAttribute, useConfigurator, useMetadata, useName, usePlayerLoadingStatus, usePrice, useThreekitInitStatus, useZoom, useSnapshot, useWishlist, useShare, usePlayerPortal, ThreekitProvider, Player, Button, Cards, Dropdown, Strips, Swatch, Tiles, TilesGroup, Upload, ProductName, ProductDescription, AttributeTitle, AttributeValue, TotalPrice, message, Modal, Drawer, Accordion, Tabs, PortalToElement, AwaitThreekitLoad, FlatForm, Zoom, Snapshots, Wishlist, Share, icons, TrebleApp, ProductLayout, };
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.ProductLayout = exports.TrebleApp = exports.icons = exports.Share = exports.Wishlist = exports.Snapshots = exports.Zoom = exports.FlatForm = exports.AwaitThreekitLoad = exports.PortalToElement = exports.Tabs = exports.Accordion = exports.Drawer = exports.Modal = exports.message = exports.TotalPrice = exports.AttributeValue = exports.AttributeTitle = exports.ProductDescription = exports.ProductName = exports.TilesGroup = exports.Tiles = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = exports.usePlayerPortal = exports.useShare = exports.useWishlist = exports.useSnapshot = exports.useZoom = exports.useThreekitInitStatus = exports.usePrice = exports.usePlayerLoadingStatus = exports.useName = exports.useMetadata = exports.useConfigurator = exports.useAttribute = void 0;
|
|
16
|
+
exports.ProductLayout = exports.TrebleApp = exports.icons = exports.Share = exports.Wishlist = exports.Snapshots = exports.Zoom = exports.FlatForm = exports.AwaitThreekitLoad = exports.PortalToElement = exports.Tabs = exports.Accordion = exports.Drawer = exports.Modal = exports.message = exports.TotalPrice = exports.AttributeValue = exports.AttributeTitle = exports.ProductDescription = exports.ProductName = exports.Upload = exports.TilesGroup = exports.Tiles = exports.Swatch = exports.Strips = exports.Dropdown = exports.Cards = exports.Button = exports.Player = exports.ThreekitProvider = exports.usePlayerPortal = exports.useShare = exports.useWishlist = exports.useSnapshot = exports.useZoom = exports.useThreekitInitStatus = exports.usePrice = exports.usePlayerLoadingStatus = exports.useName = exports.useMetadata = exports.useConfigurator = exports.useAttribute = void 0;
|
|
17
17
|
// Hooks
|
|
18
18
|
var useAttribute_1 = __importDefault(require("./hooks/useAttribute"));
|
|
19
19
|
exports.useAttribute = useAttribute_1.default;
|
|
@@ -59,6 +59,8 @@ var Tiles_1 = __importDefault(require("./components/Tiles"));
|
|
|
59
59
|
exports.Tiles = Tiles_1.default;
|
|
60
60
|
var TilesGroup_1 = __importDefault(require("./components/TilesGroup"));
|
|
61
61
|
exports.TilesGroup = TilesGroup_1.default;
|
|
62
|
+
var Upload_1 = __importDefault(require("./components/Upload"));
|
|
63
|
+
exports.Upload = Upload_1.default;
|
|
62
64
|
// Display
|
|
63
65
|
var ProductName_1 = __importDefault(require("./components/ProductName"));
|
|
64
66
|
exports.ProductName = ProductName_1.default;
|
package/dist/store/treble.js
CHANGED
|
@@ -148,17 +148,16 @@ exports.getPlayerElementId = getPlayerElementId;
|
|
|
148
148
|
****************************************************/
|
|
149
149
|
var launch = function (launchConfig) {
|
|
150
150
|
return function (dispatch) { return __awaiter(void 0, void 0, void 0, function () {
|
|
151
|
-
var config, credentials, products, threekitEnv, playerConfig, envCredentials, product, threekitDomainRaw, orgId, authToken, initialConfigurationRaw, assetId, stageId, configurationId, el, threekitDomain, initialConfiguration, updatedAssetId, params, configId, configuration, player,
|
|
152
|
-
var _b;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
switch (_h.label) {
|
|
151
|
+
var config, credentials, products, threekitEnv, playerConfig, envCredentials, product, threekitDomainRaw, orgId, authToken, initialConfigurationRaw, assetId, stageId, configurationId, el, threekitDomain, initialConfiguration, updatedAssetId, params, configId, configuration, player, configurator;
|
|
152
|
+
var _a, _b, _c, _d, _e;
|
|
153
|
+
return __generator(this, function (_f) {
|
|
154
|
+
switch (_f.label) {
|
|
156
155
|
case 0:
|
|
157
156
|
if (window.threekit)
|
|
158
157
|
return [2 /*return*/];
|
|
159
158
|
config = (0, utils_1.loadTrebleConfig)();
|
|
160
|
-
credentials = Object.assign({}, ((
|
|
161
|
-
products = Object.assign({}, ((
|
|
159
|
+
credentials = Object.assign({}, ((_a = config.project) === null || _a === void 0 ? void 0 : _a.credentials) || {}, ((_b = launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.project) === null || _b === void 0 ? void 0 : _b.credentials) || {});
|
|
160
|
+
products = Object.assign({}, ((_c = config.project) === null || _c === void 0 ? void 0 : _c.products) || {}, ((_d = launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.project) === null || _d === void 0 ? void 0 : _d.products) || {});
|
|
162
161
|
if (!Object.keys(credentials).length || !Object.keys(products).length)
|
|
163
162
|
return [2 /*return*/, console.error('Missing credentials')];
|
|
164
163
|
threekitEnv = (launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.threekitEnv) || process.env.THREEKIT_ENV || 'preview';
|
|
@@ -202,19 +201,19 @@ var launch = function (launchConfig) {
|
|
|
202
201
|
initialConfiguration = __assign({}, initialConfigurationRaw);
|
|
203
202
|
updatedAssetId = assetId;
|
|
204
203
|
params = (0, utils_1.getParams)();
|
|
205
|
-
configId = ((
|
|
204
|
+
configId = ((_e = params[constants_1.TK_SAVED_CONFIG_PARAM_KEY]) === null || _e === void 0 ? void 0 : _e.length)
|
|
206
205
|
? params[constants_1.TK_SAVED_CONFIG_PARAM_KEY]
|
|
207
206
|
: configurationId;
|
|
208
207
|
if (!configId) return [3 /*break*/, 2];
|
|
209
208
|
return [4 /*yield*/, api_1.default.configurations.fetch(configId)];
|
|
210
209
|
case 1:
|
|
211
|
-
configuration =
|
|
210
|
+
configuration = _f.sent();
|
|
212
211
|
if (configuration) {
|
|
213
212
|
initialConfiguration = Object.assign({}, initialConfigurationRaw, configuration.data.variant);
|
|
214
213
|
connection_1.default.connect({ assetId: configuration.data.productId });
|
|
215
214
|
updatedAssetId = configuration.data.productId;
|
|
216
215
|
}
|
|
217
|
-
|
|
216
|
+
_f.label = 2;
|
|
218
217
|
case 2:
|
|
219
218
|
if (!updatedAssetId)
|
|
220
219
|
return [2 /*return*/, console.error('missing assetId')];
|
|
@@ -222,21 +221,24 @@ var launch = function (launchConfig) {
|
|
|
222
221
|
return [4 /*yield*/, (0, utils_1.createThreekitScriptEl)(threekitDomain)];
|
|
223
222
|
case 3:
|
|
224
223
|
// We create the threekit script
|
|
225
|
-
|
|
224
|
+
_f.sent();
|
|
226
225
|
return [4 /*yield*/, window.threekitPlayer(__assign(__assign({ el: el,
|
|
227
226
|
// Variables to sort out
|
|
228
227
|
authToken: authToken, stageId: stageId, assetId: updatedAssetId }, playerConfig), { initialConfiguration: initialConfiguration }))];
|
|
229
228
|
case 4:
|
|
230
|
-
player =
|
|
231
|
-
_a = window;
|
|
232
|
-
_b = {
|
|
233
|
-
player: player
|
|
234
|
-
};
|
|
229
|
+
player = _f.sent();
|
|
235
230
|
return [4 /*yield*/, player.getConfigurator()];
|
|
236
231
|
case 5:
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
232
|
+
configurator = _f.sent();
|
|
233
|
+
window.threekit = {
|
|
234
|
+
player: player,
|
|
235
|
+
configurator: configurator,
|
|
236
|
+
treble: new Treble_1.default({
|
|
237
|
+
player: player,
|
|
238
|
+
orgId: orgId,
|
|
239
|
+
initialConfiguration: configurator.getConfiguration(),
|
|
240
|
+
}),
|
|
241
|
+
};
|
|
240
242
|
dispatch((0, exports.setThreekitInitialized)());
|
|
241
243
|
dispatch((0, exports.setPlayerLoading)(false));
|
|
242
244
|
window.threekit.player.on('setConfiguration', function () {
|
package/dist/threekit.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import Treble from './Treble';
|
|
|
3
3
|
declare type SCENE_PHASES = 'LOADED' | 'PRELOADED' | 'RENDERED';
|
|
4
4
|
declare type PRIVATE_APIS = 'scene' | 'player';
|
|
5
5
|
export declare type DISPLAY_OPTIONS = 'webgl' | 'image';
|
|
6
|
-
declare type IAttributeTypes = 'String' | 'Asset' | 'Color' | 'Number';
|
|
6
|
+
export declare type IAttributeTypes = 'String' | 'Asset' | 'Color' | 'Number';
|
|
7
|
+
export declare type AssetType = 'upload' | 'item';
|
|
7
8
|
export declare type IMetadata = Record<string, string | number | null>;
|
|
8
9
|
/***************************************************
|
|
9
10
|
* Scene
|
|
@@ -83,7 +84,7 @@ export interface IDisplayAttributeAssetValue extends IConfigurationAssetValue {
|
|
|
83
84
|
label: string;
|
|
84
85
|
}
|
|
85
86
|
export interface IAttributeAssetBase<V> extends IAttributeBase<'Asset', IConfigurationAsset> {
|
|
86
|
-
assetType:
|
|
87
|
+
assetType: AssetType;
|
|
87
88
|
blacklist: [];
|
|
88
89
|
defaultValue: IConfigurationAsset;
|
|
89
90
|
hiddenValues?: Array<string>;
|
|
@@ -213,11 +214,25 @@ export interface ThreekitInitConfig {
|
|
|
213
214
|
showShare?: boolean;
|
|
214
215
|
showLoadingThumbnail?: boolean;
|
|
215
216
|
showLoadingProgress?: boolean;
|
|
216
|
-
onLoadingProgress?:
|
|
217
|
+
onLoadingProgress?: (progress: number) => void;
|
|
217
218
|
locale?: string;
|
|
218
219
|
allowMobileVerticalOrbit?: boolean;
|
|
219
220
|
publishStage?: string;
|
|
220
221
|
display?: DISPLAY_OPTIONS;
|
|
222
|
+
classnames?: {
|
|
223
|
+
loading?: string;
|
|
224
|
+
mobile?: string;
|
|
225
|
+
share?: string | {
|
|
226
|
+
button: string;
|
|
227
|
+
popup: string;
|
|
228
|
+
};
|
|
229
|
+
fullscreen?: string;
|
|
230
|
+
ar?: string | {
|
|
231
|
+
button: string;
|
|
232
|
+
popup: string;
|
|
233
|
+
};
|
|
234
|
+
help?: string;
|
|
235
|
+
};
|
|
221
236
|
}
|
|
222
237
|
/***************************************************
|
|
223
238
|
* Treble Declarations
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ITranslationMap } from './api/products';
|
|
2
2
|
import { IThreekitCamera, IConfigurationColor, ICoordinates, IQuaternion, IThreekitDisplayAttribute } from './threekit';
|
|
3
|
-
import { ITrebleConfig } from './threekit';
|
|
3
|
+
import { ITrebleConfig, IAttributeTypes } from './threekit';
|
|
4
|
+
import { RawAttributeValue } from './hooks/useAttribute';
|
|
4
5
|
interface ICameraPosition {
|
|
5
6
|
position: ICoordinates;
|
|
6
7
|
quaternion: IQuaternion;
|
|
@@ -53,8 +54,8 @@ export declare const metadataValueToObject: (data: string) => Record<string, str
|
|
|
53
54
|
*/
|
|
54
55
|
export declare const createThreekitScriptEl: (threekitDomain: string) => Promise<void>;
|
|
55
56
|
export declare const translateAttribute: (attributes: Array<IThreekitDisplayAttribute>, translations?: ITranslationMap | undefined, language?: string | undefined) => IThreekitDisplayAttribute;
|
|
56
|
-
export declare const selectionToConfiguration: (value:
|
|
57
|
-
assetId:
|
|
57
|
+
export declare const selectionToConfiguration: (value: RawAttributeValue, attributeType: IAttributeTypes) => string | number | boolean | File | IConfigurationColor | {
|
|
58
|
+
assetId: RawAttributeValue;
|
|
58
59
|
};
|
|
59
60
|
export declare const filterFormAttributes: (attributes: Record<string, IThreekitDisplayAttribute>, attributeComponentProps: IAttributesComponentProps, includeReservedAttributes: boolean) => IThreekitDisplayAttribute[];
|
|
60
61
|
export declare const isUuid: (str?: string | undefined) => boolean;
|