@threekit-tools/treble 0.0.57 → 0.0.60
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/useSingleAnimation/index.d.ts +17 -0
- package/dist/hooks/useSingleAnimation/index.js +264 -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.js +2 -0
- 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 +20 -2
- package/dist/utils.d.ts +2 -10
- package/dist/utils.js +62 -58
- package/package.json +17 -2
- package/dist/hooks/useArrayAttribute/index.d.ts +0 -2
- package/dist/hooks/useArrayAttribute/index.js +0 -184
|
@@ -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));
|