@threekit-tools/treble 0.0.57-animation → 0.0.59
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 +32 -63
- package/dist/Treble/Treble.d.ts +8 -6
- package/dist/Treble/Treble.js +19 -4
- package/dist/Treble/Wishlist.d.ts +3 -3
- package/dist/Treble/Wishlist.js +1 -0
- package/dist/api/configurations.d.ts +2 -3
- package/dist/api/configurations.js +28 -22
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/server.d.ts +2 -0
- package/dist/api/server.js +11 -0
- package/dist/components/Cards/index.js +3 -4
- package/dist/components/Dropdown/index.js +6 -10
- package/dist/components/Strips/index.js +3 -4
- package/dist/components/Swatch/index.js +3 -4
- package/dist/components/TextInput/index.d.ts +1 -0
- package/dist/components/TextInput/index.js +2 -2
- package/dist/components/TextInput/textInput.styles.js +1 -1
- package/dist/components/Tiles/index.js +3 -4
- package/dist/components/TilesGroup/index.js +3 -4
- package/dist/components/containers/formInputContainer.d.ts +8 -4
- package/dist/components/containers/formInputContainer.js +10 -15
- package/dist/connection.d.ts +4 -1
- package/dist/connection.js +4 -0
- package/dist/hooks/useAttribute/index.d.ts +2 -2
- package/dist/hooks/useAttribute/index.js +2 -4
- package/dist/hooks/useConfigurator/index.d.ts +2 -2
- package/dist/hooks/useConfigurator/index.js +1 -1
- package/dist/hooks/useProductCache/index.d.ts +14 -0
- package/dist/hooks/useProductCache/index.js +35 -0
- package/dist/hooks/useWishlist/index.d.ts +3 -2
- package/dist/hooks/useWishlist/index.js +1 -3
- package/dist/http/configurations.d.ts +1 -0
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.js +2 -0
- package/dist/http/server.d.ts +14 -0
- package/dist/http/server.js +17 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/store/attributes.d.ts +15 -2
- package/dist/store/attributes.js +20 -12
- package/dist/store/price.js +2 -2
- package/dist/store/product.d.ts +38 -2
- package/dist/store/product.js +221 -10
- package/dist/store/translations.d.ts +1 -0
- package/dist/store/translations.js +3 -1
- package/dist/store/treble.d.ts +32 -2
- package/dist/store/treble.js +157 -34
- package/dist/store/wishlist.d.ts +3 -2
- package/dist/threekit.d.ts +16 -1
- package/dist/utils.d.ts +1 -9
- package/dist/utils.js +58 -54
- package/package.json +1 -1
- package/dist/hooks/useArrayAttribute/index.d.ts +0 -2
- package/dist/hooks/useArrayAttribute/index.js +0 -184
package/dist/threekit.d.ts
CHANGED
|
@@ -84,6 +84,11 @@ export interface IDisplayAttributeAssetValue extends IConfigurationAssetValue {
|
|
|
84
84
|
tags: Array<string>;
|
|
85
85
|
label: string;
|
|
86
86
|
}
|
|
87
|
+
export interface IHydratedAttributeAssetValue extends IDisplayAttributeAssetValue {
|
|
88
|
+
label: string;
|
|
89
|
+
handleSelect: () => Promise<void>;
|
|
90
|
+
selected: boolean;
|
|
91
|
+
}
|
|
87
92
|
export interface IAttributeAssetBase<V> extends IAttributeBase<'Asset', IConfigurationAsset> {
|
|
88
93
|
assetType: AssetType;
|
|
89
94
|
blacklist: [];
|
|
@@ -93,12 +98,17 @@ export interface IAttributeAssetBase<V> extends IAttributeBase<'Asset', IConfigu
|
|
|
93
98
|
values: Array<V>;
|
|
94
99
|
}
|
|
95
100
|
export declare type IDisplayAttributeAsset = IAttributeAssetBase<IDisplayAttributeAssetValue>;
|
|
101
|
+
export declare type IHydratedAttributeAsset = IAttributeAssetBase<IHydratedAttributeAssetValue>;
|
|
96
102
|
export declare type IAttributeAsset = IAttributeAssetBase<IConfigurationAssetValue>;
|
|
97
103
|
/****** String TYPE ATTRIBUTE *******/
|
|
98
104
|
export interface IDisplayAttributeStringValue {
|
|
99
105
|
label: string;
|
|
100
106
|
value: string;
|
|
101
107
|
}
|
|
108
|
+
export interface IHydratedAttributeStringValue extends IDisplayAttributeStringValue {
|
|
109
|
+
handleSelect: () => Promise<void>;
|
|
110
|
+
selected: boolean;
|
|
111
|
+
}
|
|
102
112
|
export interface IAttributeStringBase<V> extends IAttributeBase<'String', string> {
|
|
103
113
|
blacklist: [];
|
|
104
114
|
defaultValue: string;
|
|
@@ -107,6 +117,7 @@ export interface IAttributeStringBase<V> extends IAttributeBase<'String', string
|
|
|
107
117
|
values: Array<V>;
|
|
108
118
|
}
|
|
109
119
|
export declare type IDisplayAttributeString = IAttributeStringBase<IDisplayAttributeStringValue>;
|
|
120
|
+
export declare type IHydratedAttributeString = IAttributeStringBase<IHydratedAttributeStringValue>;
|
|
110
121
|
export declare type IAttributeString = IAttributeStringBase<string>;
|
|
111
122
|
/****** STRING TYPE ATTRIBUTE *******/
|
|
112
123
|
export interface IAttributeColor extends IAttributeBase<'Color', IConfigurationColor> {
|
|
@@ -123,7 +134,9 @@ export interface IAttributeNumber extends IAttributeBase<'Number', number> {
|
|
|
123
134
|
/****** getAttributes() *******/
|
|
124
135
|
export declare type IThreekitAttribute = IAttributeAsset | IAttributeColor | IAttributeString | IAttributeNumber;
|
|
125
136
|
/****** getDisplayAttributes() *******/
|
|
126
|
-
export declare type IThreekitDisplayAttribute = IDisplayAttributeAsset |
|
|
137
|
+
export declare type IThreekitDisplayAttribute = IDisplayAttributeAsset | IDisplayAttributeString | IAttributeColor | IAttributeNumber;
|
|
138
|
+
/****** Treble Hydrated Values *******/
|
|
139
|
+
export declare type IHydratedAttribute = IHydratedAttributeAsset | IHydratedAttributeString | IAttributeColor | IAttributeNumber;
|
|
127
140
|
/***************************************************
|
|
128
141
|
* Camera
|
|
129
142
|
**************************************************/
|
|
@@ -195,6 +208,7 @@ export interface IThreekitPlayer {
|
|
|
195
208
|
getConfigurator: () => Promise<IThreekitConfigurator>;
|
|
196
209
|
enableApi: (api: PRIVATE_APIS) => any;
|
|
197
210
|
snapshotAsync: (snapshotConfig: ISnapshotConfig) => Promise<string>;
|
|
211
|
+
unload: () => Promise<string>;
|
|
198
212
|
}
|
|
199
213
|
export interface IThreekitPrivateConfigurator extends IThreekitConfigurator {
|
|
200
214
|
getAppliedConfiguration: (attributeName: string) => string;
|
|
@@ -262,6 +276,7 @@ export interface IProducts extends Record<string, string | Partial<IProduct>> {
|
|
|
262
276
|
export interface IProject {
|
|
263
277
|
credentials: ICredentials;
|
|
264
278
|
products: IProducts;
|
|
279
|
+
serverUrl?: string;
|
|
265
280
|
}
|
|
266
281
|
export interface ITrebleConfig {
|
|
267
282
|
project: IProject;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ITranslationMap } from './api/products';
|
|
2
1
|
import { IThreekitCamera, IConfigurationColor, ICoordinates, IQuaternion, IThreekitDisplayAttribute } from './threekit';
|
|
3
2
|
import { ITrebleConfig, IAttributeTypes } from './threekit';
|
|
4
3
|
import { RawAttributeValue } from './hooks/useAttribute';
|
|
@@ -43,17 +42,10 @@ export declare const getCameraPosition: (cameraApi: IThreekitCamera) => {
|
|
|
43
42
|
export declare const setCameraPosition: (cameraApi: IThreekitCamera, cameraPosition: ICameraPosition) => void;
|
|
44
43
|
export declare const dataURItoBlob: (dataURI: string) => Blob;
|
|
45
44
|
export declare const dataURItoFile: (dataURI: string, filename: string) => File;
|
|
45
|
+
export declare const downloadSnapshot: (snapshot: string, filename: string) => Promise<void>;
|
|
46
46
|
export declare const copyToClipboard: (data: string | Record<string, string | number | boolean>) => void;
|
|
47
47
|
export declare const easeInOutCubic: (val: number) => number;
|
|
48
48
|
export declare const metadataValueToObject: (data: string) => Record<string, string | number>;
|
|
49
|
-
/**
|
|
50
|
-
* A function to load the Threekit JS Player API script
|
|
51
|
-
*
|
|
52
|
-
* @param threekitDomain The threekit environement to use. i.e. preview.threekit.com
|
|
53
|
-
* @returns
|
|
54
|
-
*/
|
|
55
|
-
export declare const createThreekitScriptEl: (threekitDomain: string) => Promise<void>;
|
|
56
|
-
export declare const translateAttribute: (attributes: Array<IThreekitDisplayAttribute>, translations?: ITranslationMap | undefined, language?: string | undefined) => IThreekitDisplayAttribute;
|
|
57
49
|
export declare const selectionToConfiguration: (value: RawAttributeValue, attributeType: IAttributeTypes) => string | number | boolean | File | IConfigurationColor | {
|
|
58
50
|
assetId: RawAttributeValue;
|
|
59
51
|
} | undefined;
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
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
|
+
};
|
|
2
38
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
39
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
40
|
if (ar || !(i in from)) {
|
|
@@ -9,7 +45,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
9
45
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
46
|
};
|
|
11
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.loadTrebleConfig = exports.isUuid = exports.filterFormAttributes = exports.selectionToConfiguration = exports.
|
|
48
|
+
exports.loadTrebleConfig = exports.isUuid = exports.filterFormAttributes = exports.selectionToConfiguration = exports.metadataValueToObject = exports.easeInOutCubic = exports.copyToClipboard = exports.downloadSnapshot = exports.dataURItoFile = exports.dataURItoBlob = exports.setCameraPosition = exports.getCameraPosition = exports.findHitNode = exports.deflateRgb = exports.inflateRgb = exports.rgbToHex = exports.hexToRgb = exports.regularToKebabCase = exports.deepCompare = exports.shallowCompare = exports.getResumableUrl = exports.getParams = exports.objectToQueryStr = exports.isJsonString = exports.generateFormClassName = exports.generateDisplayClassName = exports.generateToolClassName = exports.generateLayoutClassName = exports.generateWidgetClassName = exports.generateInputClassName = exports.generateClassName = void 0;
|
|
13
49
|
var constants_1 = require("./constants");
|
|
14
50
|
var generateClassName = function (baseClass) {
|
|
15
51
|
return function (component, customClassName, title) {
|
|
@@ -225,6 +261,27 @@ var dataURItoFile = function (dataURI, filename) {
|
|
|
225
261
|
return new File([u8arr], filename, { type: mime });
|
|
226
262
|
};
|
|
227
263
|
exports.dataURItoFile = dataURItoFile;
|
|
264
|
+
var downloadSnapshot = function (snapshot, filename) { return __awaiter(void 0, void 0, void 0, function () {
|
|
265
|
+
var blob, blobUrl, link, clickHandler;
|
|
266
|
+
return __generator(this, function (_a) {
|
|
267
|
+
blob = (0, exports.dataURItoBlob)(snapshot);
|
|
268
|
+
blobUrl = URL.createObjectURL(blob);
|
|
269
|
+
link = document.createElement('a');
|
|
270
|
+
link.href = blobUrl;
|
|
271
|
+
link.download = filename;
|
|
272
|
+
clickHandler = function () {
|
|
273
|
+
setTimeout(function () {
|
|
274
|
+
URL.revokeObjectURL(blobUrl);
|
|
275
|
+
link.removeEventListener('click', clickHandler);
|
|
276
|
+
}, 150);
|
|
277
|
+
};
|
|
278
|
+
link.addEventListener('click', clickHandler);
|
|
279
|
+
document.body.appendChild(link);
|
|
280
|
+
link.click();
|
|
281
|
+
return [2 /*return*/];
|
|
282
|
+
});
|
|
283
|
+
}); };
|
|
284
|
+
exports.downloadSnapshot = downloadSnapshot;
|
|
228
285
|
var copyToClipboard = function (data) {
|
|
229
286
|
if (!data)
|
|
230
287
|
return;
|
|
@@ -252,59 +309,6 @@ var metadataValueToObject = function (data) {
|
|
|
252
309
|
}, {});
|
|
253
310
|
};
|
|
254
311
|
exports.metadataValueToObject = metadataValueToObject;
|
|
255
|
-
/**
|
|
256
|
-
* A function to load the Threekit JS Player API script
|
|
257
|
-
*
|
|
258
|
-
* @param threekitDomain The threekit environement to use. i.e. preview.threekit.com
|
|
259
|
-
* @returns
|
|
260
|
-
*/
|
|
261
|
-
var createThreekitScriptEl = function (threekitDomain) {
|
|
262
|
-
return new Promise(function (resolve) {
|
|
263
|
-
var script = document.createElement('script');
|
|
264
|
-
script.src = "".concat(threekitDomain, "/app/js/threekit-player-bundle.js");
|
|
265
|
-
script.id = 'threekit-player-bundle';
|
|
266
|
-
script.onload = function () { return resolve(); };
|
|
267
|
-
document.head.appendChild(script);
|
|
268
|
-
});
|
|
269
|
-
};
|
|
270
|
-
exports.createThreekitScriptEl = createThreekitScriptEl;
|
|
271
|
-
var translateAttribute = function (attributes, translations, language) {
|
|
272
|
-
var hasTranslation = !!language && !!translations;
|
|
273
|
-
return attributes.reduce(function (output, attribute) {
|
|
274
|
-
var _a;
|
|
275
|
-
var _b;
|
|
276
|
-
return Object.assign(output, (_a = {},
|
|
277
|
-
_a[attribute.name] = Object.assign({}, attribute, {
|
|
278
|
-
label: hasTranslation
|
|
279
|
-
? ((_b = translations === null || translations === void 0 ? void 0 : translations[attribute.name]) === null || _b === void 0 ? void 0 : _b[language]) || attribute.name
|
|
280
|
-
: attribute.name,
|
|
281
|
-
}, attribute.type === 'String'
|
|
282
|
-
? {
|
|
283
|
-
values: attribute.values.map(function (el) {
|
|
284
|
-
var _a;
|
|
285
|
-
return Object.assign({}, el, {
|
|
286
|
-
label: hasTranslation
|
|
287
|
-
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.label]) === null || _a === void 0 ? void 0 : _a[language]) || el.label
|
|
288
|
-
: attribute.name,
|
|
289
|
-
});
|
|
290
|
-
}),
|
|
291
|
-
}
|
|
292
|
-
: attribute.type === 'Asset'
|
|
293
|
-
? {
|
|
294
|
-
values: attribute.values.map(function (el) {
|
|
295
|
-
var _a;
|
|
296
|
-
return Object.assign({}, el, {
|
|
297
|
-
label: hasTranslation
|
|
298
|
-
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.name]) === null || _a === void 0 ? void 0 : _a[language]) || el.name
|
|
299
|
-
: attribute.name,
|
|
300
|
-
});
|
|
301
|
-
}),
|
|
302
|
-
}
|
|
303
|
-
: undefined),
|
|
304
|
-
_a));
|
|
305
|
-
});
|
|
306
|
-
};
|
|
307
|
-
exports.translateAttribute = translateAttribute;
|
|
308
312
|
var selectionToConfiguration = function (value, attributeType) {
|
|
309
313
|
switch (attributeType) {
|
|
310
314
|
case constants_1.ATTRIBUTE_TYPES.number:
|
package/package.json
CHANGED
|
@@ -1,184 +0,0 @@
|
|
|
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));
|