@threekit-tools/treble 0.0.60 → 0.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Treble/Treble.d.ts +2 -2
- package/dist/Treble/Treble.js +7 -2
- package/dist/components/Switch/index.d.ts +66 -0
- package/dist/components/Switch/index.js +86 -0
- package/dist/components/Switch/switch.styles.d.ts +4 -0
- package/dist/components/Switch/switch.styles.js +16 -0
- package/dist/components/TextInput/index.js +2 -0
- package/dist/components/ThreekitProvider/index.d.ts +1 -0
- package/dist/components/ThreekitProvider/index.js +10 -3
- package/dist/components/TrebleApp/index.d.ts +1 -0
- package/dist/components/TrebleApp/index.js +16 -6
- package/dist/components/Upload/index.js +5 -4
- package/dist/components/UploadArea/index.js +4 -3
- package/dist/components/Wishlist/index.js +6 -11
- package/dist/components/containers/formInputContainer.d.ts +4 -4
- package/dist/components/containers/formInputContainer.js +4 -4
- package/dist/components/formComponents.js +5 -1
- package/dist/hooks/useAttribute/index.js +5 -2
- package/dist/hooks/useConfigurator/index.js +7 -3
- package/dist/hooks/useNestedConfigurator/index.d.ts +8 -0
- package/dist/hooks/useNestedConfigurator/index.js +93 -0
- package/dist/hooks/useProductCache/index.d.ts +13 -5
- package/dist/hooks/useProductCache/index.js +16 -23
- package/dist/hooks/useWishlist/index.d.ts +8 -6
- package/dist/hooks/useWishlist/index.js +16 -22
- package/dist/index.d.ts +4 -1
- package/dist/index.js +7 -2
- package/dist/store/attributes.d.ts +3 -3
- package/dist/store/attributes.js +3 -50
- package/dist/store/product.d.ts +22 -13
- package/dist/store/product.js +98 -54
- package/dist/store/translations.d.ts +4 -3
- package/dist/store/translations.js +4 -14
- package/dist/store/treble.d.ts +4 -0
- package/dist/store/treble.js +69 -30
- package/dist/threekit.d.ts +9 -5
- package/dist/utils.d.ts +7 -1
- package/dist/utils.js +53 -1
- package/package.json +1 -1
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IThreekitCamera, IConfigurationColor, ICoordinates, IQuaternion, IThreekitDisplayAttribute } from './threekit';
|
|
1
|
+
import { IThreekitCamera, IConfigurationColor, ICoordinates, IQuaternion, IThreekitDisplayAttribute, ISetConfiguration, IHydratedAttribute } from './threekit';
|
|
2
2
|
import { ITrebleConfig, IAttributeTypes } from './threekit';
|
|
3
3
|
import { RawAttributeValue } from './hooks/useAttribute';
|
|
4
|
+
import { ITranslationMap } from './api/products';
|
|
4
5
|
interface ICameraPosition {
|
|
5
6
|
position: ICoordinates;
|
|
6
7
|
quaternion: IQuaternion;
|
|
@@ -46,6 +47,11 @@ export declare const downloadSnapshot: (snapshot: string, filename: string) => P
|
|
|
46
47
|
export declare const copyToClipboard: (data: string | Record<string, string | number | boolean>) => void;
|
|
47
48
|
export declare const easeInOutCubic: (val: number) => number;
|
|
48
49
|
export declare const metadataValueToObject: (data: string) => Record<string, string | number>;
|
|
50
|
+
export declare const hydrateAttribute: (data: [
|
|
51
|
+
Record<string, IThreekitDisplayAttribute>,
|
|
52
|
+
undefined | ITranslationMap,
|
|
53
|
+
undefined | string
|
|
54
|
+
], optionSelectionHandler: (config: ISetConfiguration) => Promise<void>) => Record<string, IHydratedAttribute>;
|
|
49
55
|
export declare const selectionToConfiguration: (value: RawAttributeValue, attributeType: IAttributeTypes) => string | number | boolean | File | IConfigurationColor | {
|
|
50
56
|
assetId: RawAttributeValue;
|
|
51
57
|
} | undefined;
|
package/dist/utils.js
CHANGED
|
@@ -45,7 +45,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
45
45
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
48
|
+
exports.loadTrebleConfig = exports.isUuid = exports.filterFormAttributes = exports.selectionToConfiguration = exports.hydrateAttribute = 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;
|
|
49
49
|
var constants_1 = require("./constants");
|
|
50
50
|
var generateClassName = function (baseClass) {
|
|
51
51
|
return function (component, customClassName, title) {
|
|
@@ -309,6 +309,58 @@ var metadataValueToObject = function (data) {
|
|
|
309
309
|
}, {});
|
|
310
310
|
};
|
|
311
311
|
exports.metadataValueToObject = metadataValueToObject;
|
|
312
|
+
var hydrateAttribute = function (data, optionSelectionHandler) {
|
|
313
|
+
var attributes = data[0], translations = data[1], language = data[2];
|
|
314
|
+
var hasTranslation = !!language && !!translations;
|
|
315
|
+
return Object.values(attributes).reduce(function (output, attribute) {
|
|
316
|
+
var _a;
|
|
317
|
+
var _b;
|
|
318
|
+
return Object.assign(output, (_a = {},
|
|
319
|
+
_a[attribute.name] = Object.assign({}, attribute, {
|
|
320
|
+
label: hasTranslation
|
|
321
|
+
? ((_b = translations === null || translations === void 0 ? void 0 : translations[attribute.name]) === null || _b === void 0 ? void 0 : _b[language]) || attribute.name
|
|
322
|
+
: attribute.name,
|
|
323
|
+
}, attribute.type === 'String'
|
|
324
|
+
? {
|
|
325
|
+
values: attribute.values.map(function (el) {
|
|
326
|
+
var _a;
|
|
327
|
+
return Object.assign({}, el, {
|
|
328
|
+
label: hasTranslation
|
|
329
|
+
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.label]) === null || _a === void 0 ? void 0 : _a[language]) || el.label
|
|
330
|
+
: el.label,
|
|
331
|
+
handleSelect: function () {
|
|
332
|
+
var _a;
|
|
333
|
+
return optionSelectionHandler((_a = {},
|
|
334
|
+
_a[attribute.name] = el.value,
|
|
335
|
+
_a));
|
|
336
|
+
},
|
|
337
|
+
selected: attribute.value === el.value,
|
|
338
|
+
});
|
|
339
|
+
}),
|
|
340
|
+
}
|
|
341
|
+
: attribute.type === 'Asset'
|
|
342
|
+
? {
|
|
343
|
+
values: attribute.values.map(function (el) {
|
|
344
|
+
var _a;
|
|
345
|
+
return Object.assign({}, el, {
|
|
346
|
+
label: hasTranslation
|
|
347
|
+
? ((_a = translations === null || translations === void 0 ? void 0 : translations[el.name]) === null || _a === void 0 ? void 0 : _a[language]) || el.name
|
|
348
|
+
: el.name,
|
|
349
|
+
handleSelect: function () {
|
|
350
|
+
var _a;
|
|
351
|
+
return optionSelectionHandler((_a = {},
|
|
352
|
+
_a[attribute.name] = { assetId: el.assetId },
|
|
353
|
+
_a));
|
|
354
|
+
},
|
|
355
|
+
selected: attribute.value.assetId === el.assetId,
|
|
356
|
+
});
|
|
357
|
+
}),
|
|
358
|
+
}
|
|
359
|
+
: undefined),
|
|
360
|
+
_a));
|
|
361
|
+
}, {});
|
|
362
|
+
};
|
|
363
|
+
exports.hydrateAttribute = hydrateAttribute;
|
|
312
364
|
var selectionToConfiguration = function (value, attributeType) {
|
|
313
365
|
switch (attributeType) {
|
|
314
366
|
case constants_1.ATTRIBUTE_TYPES.number:
|