@threekit-tools/treble 0.0.58 → 0.0.60-next.2

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.
Files changed (54) hide show
  1. package/dist/Treble/Treble.d.ts +8 -2
  2. package/dist/Treble/Treble.js +23 -2
  3. package/dist/api/index.d.ts +2 -0
  4. package/dist/api/index.js +2 -0
  5. package/dist/api/server.d.ts +2 -0
  6. package/dist/api/server.js +11 -0
  7. package/dist/components/Cards/index.js +3 -4
  8. package/dist/components/Dropdown/index.js +6 -10
  9. package/dist/components/Strips/index.js +3 -4
  10. package/dist/components/Swatch/index.js +3 -4
  11. package/dist/components/TextInput/index.d.ts +1 -0
  12. package/dist/components/TextInput/index.js +2 -2
  13. package/dist/components/TextInput/textInput.styles.js +1 -1
  14. package/dist/components/ThreekitProvider/index.d.ts +1 -0
  15. package/dist/components/ThreekitProvider/index.js +10 -3
  16. package/dist/components/Tiles/index.js +3 -4
  17. package/dist/components/TilesGroup/index.js +3 -4
  18. package/dist/components/TrebleApp/index.d.ts +1 -0
  19. package/dist/components/TrebleApp/index.js +16 -6
  20. package/dist/components/Wishlist/index.js +6 -11
  21. package/dist/components/containers/formInputContainer.d.ts +9 -5
  22. package/dist/components/containers/formInputContainer.js +14 -19
  23. package/dist/connection.d.ts +4 -1
  24. package/dist/connection.js +4 -0
  25. package/dist/hooks/useAttribute/index.d.ts +2 -2
  26. package/dist/hooks/useAttribute/index.js +6 -5
  27. package/dist/hooks/useConfigurator/index.d.ts +2 -2
  28. package/dist/hooks/useConfigurator/index.js +7 -3
  29. package/dist/hooks/useNestedConfigurator/index.d.ts +8 -0
  30. package/dist/hooks/useNestedConfigurator/index.js +93 -0
  31. package/dist/hooks/useProductCache/index.d.ts +22 -0
  32. package/dist/hooks/useProductCache/index.js +28 -0
  33. package/dist/hooks/useWishlist/index.d.ts +8 -6
  34. package/dist/hooks/useWishlist/index.js +16 -22
  35. package/dist/http/index.d.ts +2 -0
  36. package/dist/http/index.js +2 -0
  37. package/dist/http/server.d.ts +14 -0
  38. package/dist/http/server.js +17 -0
  39. package/dist/index.d.ts +3 -1
  40. package/dist/index.js +5 -1
  41. package/dist/store/attributes.d.ts +14 -1
  42. package/dist/store/attributes.js +6 -45
  43. package/dist/store/product.d.ts +47 -2
  44. package/dist/store/product.js +267 -12
  45. package/dist/store/translations.d.ts +4 -2
  46. package/dist/store/translations.js +4 -12
  47. package/dist/store/treble.d.ts +36 -2
  48. package/dist/store/treble.js +214 -52
  49. package/dist/threekit.d.ts +16 -1
  50. package/dist/utils.d.ts +7 -10
  51. package/dist/utils.js +22 -23
  52. package/package.json +1 -1
  53. package/dist/hooks/useArrayAttribute/index.d.ts +0 -2
  54. 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));