@threekit-tools/treble 0.0.92 → 0.0.94-next-01

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 (69) hide show
  1. package/dist/Treble/Treble.d.ts +2 -2
  2. package/dist/Treble/Treble.js +2 -2
  3. package/dist/Treble/index.d.ts +1 -1
  4. package/dist/Treble/index.js +1 -1
  5. package/dist/Treble/snapshot.d.ts +2 -2
  6. package/dist/Treble/snapshot.js +1 -1
  7. package/dist/hooks/useNestedConfigurator/index.js +1 -2
  8. package/dist/hooks/useSnapshot/index.d.ts +1 -1
  9. package/dist/hooks/useSpaces/SpacesState.d.ts +15 -2
  10. package/dist/hooks/useSpaces/SpacesState.js +85 -22
  11. package/dist/hooks/useSpaces/constants.d.ts +17 -2
  12. package/dist/hooks/useSpaces/constants.js +58 -37
  13. package/dist/hooks/useSpaces/dataHandlers.d.ts +22 -4
  14. package/dist/hooks/useSpaces/dataHandlers.js +197 -40
  15. package/dist/hooks/useSpaces/draw/drawDoors.js +1 -1
  16. package/dist/hooks/useSpaces/draw/drawGrid.d.ts +1 -1
  17. package/dist/hooks/useSpaces/draw/drawGrid.js +4 -1
  18. package/dist/hooks/useSpaces/draw/drawWalls.d.ts +3 -2
  19. package/dist/hooks/useSpaces/draw/drawWalls.js +6 -4
  20. package/dist/hooks/useSpaces/index.d.ts +13 -0
  21. package/dist/hooks/useSpaces/index.js +269 -126
  22. package/dist/hooks/useSpaces/types.d.ts +52 -13
  23. package/dist/icons/Boundary.d.ts +3 -0
  24. package/dist/icons/{Ruler copy.js → Boundary.js} +7 -8
  25. package/dist/icons/Draw.js +3 -3
  26. package/dist/icons/RulerBlank.js +2 -2
  27. package/dist/icons/RulerDetailed.js +2 -2
  28. package/dist/icons/Window.js +4 -4
  29. package/dist/icons/index.js +28 -0
  30. package/dist/index.d.ts +17 -2
  31. package/dist/index.js +35 -5
  32. package/dist/store/attributes.d.ts +2 -1
  33. package/dist/store/index.d.ts +41 -10
  34. package/dist/store/index.js +3 -1
  35. package/dist/store/product.js +4 -7
  36. package/dist/store/spaces.d.ts +32 -5
  37. package/dist/store/spaces.js +164 -7
  38. package/dist/store/treble.d.ts +1 -1
  39. package/dist/store/treble.js +14 -21
  40. package/dist/store/wishlist.d.ts +2 -20
  41. package/dist/types.d.ts +3 -1
  42. package/package.json +1 -2
  43. package/dist/Treble/snapshots.d.ts +0 -22
  44. package/dist/Treble/snapshots.js +0 -247
  45. package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +0 -95
  46. package/dist/hooks/useRoomBuilder/RoomBuilderState.js +0 -1237
  47. package/dist/hooks/useRoomBuilder/constants.d.ts +0 -41
  48. package/dist/hooks/useRoomBuilder/constants.js +0 -48
  49. package/dist/hooks/useRoomBuilder/dataHandlers.d.ts +0 -18
  50. package/dist/hooks/useRoomBuilder/dataHandlers.js +0 -187
  51. package/dist/hooks/useRoomBuilder/draw.d.ts +0 -55
  52. package/dist/hooks/useRoomBuilder/draw.js +0 -573
  53. package/dist/hooks/useRoomBuilder/findLoops.d.ts +0 -5
  54. package/dist/hooks/useRoomBuilder/findLoops.js +0 -99
  55. package/dist/hooks/useRoomBuilder/geometry.d.ts +0 -33
  56. package/dist/hooks/useRoomBuilder/geometry.js +0 -325
  57. package/dist/hooks/useRoomBuilder/index.d.ts +0 -40
  58. package/dist/hooks/useRoomBuilder/index.js +0 -303
  59. package/dist/hooks/useRoomBuilder/messaging.d.ts +0 -8
  60. package/dist/hooks/useRoomBuilder/messaging.js +0 -18
  61. package/dist/hooks/useRoomBuilder/themes.d.ts +0 -12
  62. package/dist/hooks/useRoomBuilder/themes.js +0 -273
  63. package/dist/hooks/useRoomBuilder/types.d.ts +0 -238
  64. package/dist/hooks/useRoomBuilder/types.js +0 -36
  65. package/dist/hooks/useRoomBuilder/validators.d.ts +0 -36
  66. package/dist/hooks/useRoomBuilder/validators.js +0 -362
  67. package/dist/icons/Ruler copy.d.ts +0 -3
  68. package/dist/icons/RulerDetailed copy.d.ts +0 -3
  69. package/dist/icons/RulerDetailed copy.js +0 -27
@@ -10,13 +10,54 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
13
49
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.prepAreaForUser = exports.prepLengthForUser = exports.convertAreaUnit = exports.convertLengthUnit = exports.prepAttributesOutgoing = exports.getAttributeDefaults = exports.prepAttributesIncoming = void 0;
50
+ exports.getAttributeData = exports.prepAreaForUser = exports.prepLengthForUser = exports.convertAreaUnit = exports.convertLengthUnit = exports.prepAttributesOutgoing = exports.prepAttributesIncoming = void 0;
15
51
  var types_1 = require("./types");
16
52
  var constants_1 = require("./constants");
17
53
  var geometry_1 = require("./geometry");
18
54
  function filterRestConfiguration(configuration, attributeNames) {
19
- var keysToFilter = new Set(Object.values(attributeNames));
55
+ var attributes = __assign({}, attributeNames);
56
+ delete attributes.wallMode;
57
+ delete attributes.doorShowSwing;
58
+ delete attributes.doorOrientation;
59
+ delete attributes.doorOpeningDirection;
60
+ var keysToFilter = new Set(Object.values(attributes));
20
61
  var filteredConfiguration = Object.entries(configuration).reduce(function (output, _a) {
21
62
  var _b;
22
63
  var key = _a[0], value = _a[1];
@@ -33,13 +74,13 @@ function prepConnectionIncoming(connection) {
33
74
  var _a = connection.split('.'), attributeName = _a[0], indexStr = _a[1];
34
75
  return [attributeName, parseInt(indexStr)];
35
76
  }
36
- function prepWallsAndVerticesIncoming(wallsAttribute, config) {
77
+ function prepWallsAndVerticesIncoming(wallsAttribute, config, attributeDefaults) {
37
78
  var _a;
38
79
  var walls = [];
39
80
  var vertices = {};
40
81
  var attributeName = config.attributes;
41
82
  ((wallsAttribute === null || wallsAttribute === void 0 ? void 0 : wallsAttribute.value) || []).forEach(function (_a, i) {
42
- var _b, _c, _d;
83
+ var _b, _c;
43
84
  var assetId = _a.assetId, configuration = _a.configuration;
44
85
  var point1 = [
45
86
  (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.wallStartX]) / config.config.scale,
@@ -60,10 +101,11 @@ function prepWallsAndVerticesIncoming(wallsAttribute, config) {
60
101
  else
61
102
  vertices[point2Str] = [[i, 1]];
62
103
  var connections = [];
63
- var visible = ((_d = (_c = (_b = configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.WallAttributes.VISIBILITY]) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c[constants_1.SpacesMetadata.VALUE]) !== null && _d !== void 0 ? _d : 'true') === 'true';
104
+ var modeValue = (_c = (_b = configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.WallAttributes.WALL_MODE]) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c[constants_1.SpacesMetadata.VALUE];
105
+ var mode = modeValue !== null && modeValue !== void 0 ? modeValue : attributeDefaults.wallMode;
64
106
  walls.push({
65
107
  assetId: assetId,
66
- visible: visible,
108
+ mode: mode,
67
109
  line: [point1, point2],
68
110
  path: (0, geometry_1.addThicknessToLine)([point1, point2], config.config.styles.wall.thickness),
69
111
  connections: connections,
@@ -81,12 +123,12 @@ function getWallsVaidationConfig(wallsAttribute, config) {
81
123
  };
82
124
  return validation;
83
125
  }
84
- function prepFeatureIncoming(type, walls, featureAttribute, config) {
126
+ function prepFeatureIncoming(type, walls, featureAttribute, config, attributeDefaults) {
85
127
  var _a;
86
128
  var attributeName = config.attributes;
87
129
  var feature = [];
88
130
  (_a = featureAttribute === null || featureAttribute === void 0 ? void 0 : featureAttribute.value) === null || _a === void 0 ? void 0 : _a.forEach(function (_a) {
89
- var _b, _c, _d, _e, _f, _g;
131
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k;
90
132
  var assetId = _a.assetId, configuration = _a.configuration;
91
133
  var offset = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featurePositionX]) / config.config.scale;
92
134
  var length = (configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.featureLength]) / config.config.scale;
@@ -106,25 +148,23 @@ function prepFeatureIncoming(type, walls, featureAttribute, config) {
106
148
  restConfiguration: JSON.stringify(filterRestConfiguration(configuration, config.attributes)),
107
149
  };
108
150
  if (type === types_1.IElements.DOOR) {
109
- element.showSwing =
110
- (((_c = (_b = configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.DoorAttributes.SHOW_SWING]) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c[constants_1.SpacesMetadata.VALUE]) || 'true') === 'true';
111
- element.orientation =
112
- ((_e = (_d = configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.DoorAttributes.ORIENTATION]) === null || _d === void 0 ? void 0 : _d.metadata) === null || _e === void 0 ? void 0 : _e[constants_1.SpacesMetadata.VALUE]) === constants_1.DoorOrientations.LEFT
113
- ? constants_1.DoorOrientations.LEFT
114
- : constants_1.DoorOrientations.RIGHT;
115
- element.openingDirection =
116
- ((_g = (_f = configuration === null || configuration === void 0 ? void 0 : configuration[constants_1.DoorAttributes.OPENING_DIRECTION]) === null || _f === void 0 ? void 0 : _f.metadata) === null || _g === void 0 ? void 0 : _g[constants_1.SpacesMetadata.VALUE]) === constants_1.DoorOpeningDirections.INSIDE
117
- ? constants_1.DoorOpeningDirections.INSIDE
118
- : constants_1.DoorOpeningDirections.OUTSIDE;
151
+ var doorShowSwing = (_d = (_c = (_b = configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.doorShowSwing]) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c[constants_1.SpacesMetadata.VALUE]) !== null && _d !== void 0 ? _d : attributeDefaults.doorShowSwing;
152
+ var doorOrientation = (_g = (_f = (_e = configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.doorOrientation]) === null || _e === void 0 ? void 0 : _e.metadata) === null || _f === void 0 ? void 0 : _f[constants_1.SpacesMetadata.VALUE]) !== null && _g !== void 0 ? _g : attributeDefaults.doorOrientation;
153
+ var doorOpeningDirection = (_k = (_j = (_h = configuration === null || configuration === void 0 ? void 0 : configuration[attributeName.doorOpeningDirection]) === null || _h === void 0 ? void 0 : _h.metadata) === null || _j === void 0 ? void 0 : _j[constants_1.SpacesMetadata.VALUE]) !== null && _k !== void 0 ? _k : attributeDefaults.doorOpeningDirection;
154
+ Object.assign(element, {
155
+ showSwing: doorShowSwing,
156
+ orientation: doorOrientation,
157
+ openingDirection: doorOpeningDirection,
158
+ });
119
159
  }
120
160
  feature.push(element);
121
161
  });
122
162
  return feature;
123
163
  }
124
- function prepAttributesIncoming(attributes, config) {
164
+ function prepAttributesIncoming(attributes, config, attributeDefaults) {
125
165
  var _a;
126
166
  var wallsAttribute = attributes[config.attributes[types_1.IElements.WALL]];
127
- var wallsAndVertices = prepWallsAndVerticesIncoming(wallsAttribute, config);
167
+ var wallsAndVertices = prepWallsAndVerticesIncoming(wallsAttribute, config, attributeDefaults);
128
168
  var wallsValidation = getWallsVaidationConfig(wallsAttribute, config);
129
169
  var featuresList = [
130
170
  types_1.IElements.WINDOW,
@@ -132,31 +172,12 @@ function prepAttributesIncoming(attributes, config) {
132
172
  types_1.IElements.OPENING,
133
173
  ];
134
174
  var featuresData = featuresList.reduce(function (output, type) {
135
- output[type] = prepFeatureIncoming(type, wallsAndVertices[types_1.IElements.WALL], attributes[config.attributes[type]], config);
175
+ output[type] = prepFeatureIncoming(type, wallsAndVertices[types_1.IElements.WALL], attributes[config.attributes[type]], config, attributeDefaults);
136
176
  return output;
137
177
  }, {});
138
178
  return __assign(__assign({}, wallsAndVertices), (_a = { validationConfig: wallsValidation }, _a[types_1.IElements.FEATURE] = featuresData, _a));
139
179
  }
140
180
  exports.prepAttributesIncoming = prepAttributesIncoming;
141
- function getAttributeDefaults(attributes, config) {
142
- return [
143
- types_1.IElements.WALL,
144
- types_1.IElements.WINDOW,
145
- types_1.IElements.DOOR,
146
- types_1.IElements.OPENING,
147
- ].reduce(function (output, elementName) {
148
- var _a;
149
- if (!config.attributes[elementName])
150
- return output;
151
- var attribute = attributes[config.attributes[elementName]];
152
- if (!attribute)
153
- return output;
154
- return Object.assign(output, (_a = {},
155
- _a[elementName] = attribute.values[0].assetId,
156
- _a));
157
- }, {});
158
- }
159
- exports.getAttributeDefaults = getAttributeDefaults;
160
181
  function prepFeaturesOutgoing(features, config) {
161
182
  var attributeName = config.attributes;
162
183
  return features.map(function (feature) {
@@ -243,6 +264,10 @@ function prepLengthForUser(value, unit) {
243
264
  if (unit === types_1.IUnits.FEET) {
244
265
  var feet = Math.floor(value);
245
266
  var inches = 12 * (value % 1);
267
+ if (inches > 11.95) {
268
+ feet += 1;
269
+ inches = 0;
270
+ }
246
271
  return "".concat(feet).concat(constants_1.UNIT_LABELS[types_1.IUnits.FEET], " ").concat(inches.toFixed(1)).concat(constants_1.UNIT_LABELS[types_1.IUnits.INCH]);
247
272
  }
248
273
  return "".concat(value.toFixed(2), " ").concat(constants_1.UNIT_LABELS[unit]);
@@ -252,3 +277,135 @@ function prepAreaForUser(value, unit) {
252
277
  return "".concat(value.toFixed(2), " sq-").concat(constants_1.UNIT_LABELS[unit]);
253
278
  }
254
279
  exports.prepAreaForUser = prepAreaForUser;
280
+ function getAttributeData(configurator, attributeNames) {
281
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
282
+ return __awaiter(this, void 0, void 0, function () {
283
+ var attributes, wallAssetId, doorAssetId, windowAssetId, openingAssetId, i, attr, wallConfigurator, doorConfigurator, wallModeAttr, doorOrientationAttr, doorOpeningDirectionAttr, doorShowSwingAttr, doorAttributes, i, attr, options, optionsMap, wallModeOptions, wallModes, defaults;
284
+ var _p, _q, _r, _s, _t;
285
+ return __generator(this, function (_u) {
286
+ switch (_u.label) {
287
+ case 0:
288
+ attributes = configurator.getDisplayAttributes();
289
+ wallAssetId = undefined;
290
+ doorAssetId = undefined;
291
+ windowAssetId = undefined;
292
+ openingAssetId = undefined;
293
+ for (i = 0; i < attributes.length &&
294
+ (!wallAssetId || !doorAssetId || !windowAssetId || !openingAssetId); i++) {
295
+ attr = attributes[i];
296
+ switch (attr.name) {
297
+ case attributeNames[types_1.IElements.WALL]:
298
+ wallAssetId = attr.values[0].assetId;
299
+ break;
300
+ case attributeNames[types_1.IElements.DOOR]:
301
+ doorAssetId = attr.values[0].assetId;
302
+ break;
303
+ case attributeNames[types_1.IElements.WINDOW]:
304
+ windowAssetId = attr.values[0].assetId;
305
+ break;
306
+ case attributeNames[types_1.IElements.OPENING]:
307
+ openingAssetId = attr.values[0].assetId;
308
+ break;
309
+ }
310
+ }
311
+ if (!wallAssetId || !doorAssetId || !windowAssetId || !openingAssetId)
312
+ throw new Error('Missing assetId: ' +
313
+ JSON.stringify({
314
+ wallAssetId: wallAssetId,
315
+ doorAssetId: doorAssetId,
316
+ windowAssetId: windowAssetId,
317
+ openingAssetId: openingAssetId,
318
+ }));
319
+ return [4, configurator.setConfiguration((_p = {},
320
+ _p[attributeNames[types_1.IElements.WALL]] = { assetId: wallAssetId },
321
+ _p[attributeNames[types_1.IElements.DOOR]] = { assetId: doorAssetId },
322
+ _p))];
323
+ case 1:
324
+ _u.sent();
325
+ wallConfigurator = configurator.getNestedConfigurator(attributeNames[types_1.IElements.WALL], 0);
326
+ doorConfigurator = configurator.getNestedConfigurator(attributeNames[types_1.IElements.DOOR], 0);
327
+ wallModeAttr = wallConfigurator === null || wallConfigurator === void 0 ? void 0 : wallConfigurator.getDisplayAttributes().find(function (attr) { return attr.name === attributeNames.wallMode; });
328
+ doorOrientationAttr = undefined;
329
+ doorOpeningDirectionAttr = undefined;
330
+ doorShowSwingAttr = undefined;
331
+ doorAttributes = (_a = doorConfigurator === null || doorConfigurator === void 0 ? void 0 : doorConfigurator.getDisplayAttributes()) !== null && _a !== void 0 ? _a : [];
332
+ for (i = 0; i < doorAttributes.length &&
333
+ (!doorOrientationAttr || !doorOpeningDirectionAttr || !doorShowSwingAttr); i++) {
334
+ attr = doorAttributes[i];
335
+ switch (doorAttributes[i].name) {
336
+ case attributeNames.doorOrientation:
337
+ doorOrientationAttr = attr;
338
+ break;
339
+ case attributeNames.doorOpeningDirection:
340
+ doorOpeningDirectionAttr = attr;
341
+ break;
342
+ case attributeNames.doorShowSwing:
343
+ doorShowSwingAttr = attr;
344
+ break;
345
+ }
346
+ }
347
+ options = {
348
+ doorShowSwing: (_q = {},
349
+ _q[constants_1.DoorShowSwing.SHOW] = (_b = doorShowSwingAttr === null || doorShowSwingAttr === void 0 ? void 0 : doorShowSwingAttr.values.find(function (val) { return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.DoorShowSwing.SHOW; })) === null || _b === void 0 ? void 0 : _b.assetId,
350
+ _q[constants_1.DoorShowSwing.HIDE] = (_c = doorShowSwingAttr === null || doorShowSwingAttr === void 0 ? void 0 : doorShowSwingAttr.values.find(function (val) { return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.DoorShowSwing.HIDE; })) === null || _c === void 0 ? void 0 : _c.assetId,
351
+ _q),
352
+ doorOrientation: (_r = {},
353
+ _r[constants_1.DoorOrientations.LEFT] = (_d = doorOrientationAttr === null || doorOrientationAttr === void 0 ? void 0 : doorOrientationAttr.values.find(function (val) { return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.DoorOrientations.LEFT; })) === null || _d === void 0 ? void 0 : _d.assetId,
354
+ _r[constants_1.DoorOrientations.RIGHT] = (_e = doorOrientationAttr === null || doorOrientationAttr === void 0 ? void 0 : doorOrientationAttr.values.find(function (val) { return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.DoorOrientations.RIGHT; })) === null || _e === void 0 ? void 0 : _e.assetId,
355
+ _r),
356
+ doorOpeningDirection: (_s = {},
357
+ _s[constants_1.DoorOpeningDirections.INSIDE] = (_f = doorOpeningDirectionAttr === null || doorOpeningDirectionAttr === void 0 ? void 0 : doorOpeningDirectionAttr.values.find(function (val) {
358
+ return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.DoorOpeningDirections.INSIDE;
359
+ })) === null || _f === void 0 ? void 0 : _f.assetId,
360
+ _s[constants_1.DoorOpeningDirections.OUTSIDE] = (_g = doorOpeningDirectionAttr === null || doorOpeningDirectionAttr === void 0 ? void 0 : doorOpeningDirectionAttr.values.find(function (val) {
361
+ return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.DoorOpeningDirections.OUTSIDE;
362
+ })) === null || _g === void 0 ? void 0 : _g.assetId,
363
+ _s),
364
+ };
365
+ optionsMap = Object.entries(options).reduce(function (output, _a) {
366
+ var _b;
367
+ var attr = _a[0], valuesObj = _a[1];
368
+ return Object.assign(output, (_b = {},
369
+ _b[attr] = Object.entries(valuesObj).reduce(function (result, _a) {
370
+ var _b;
371
+ var val = _a[0], key = _a[1];
372
+ return Object.assign(result, (_b = {}, _b[key] = val, _b));
373
+ }, {}),
374
+ _b));
375
+ }, {});
376
+ wallModeOptions = [
377
+ {
378
+ value: constants_1.WallModes.WALL,
379
+ assetId: (_h = wallModeAttr === null || wallModeAttr === void 0 ? void 0 : wallModeAttr.values.find(function (val) { return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.WallModes.WALL; })) === null || _h === void 0 ? void 0 : _h.assetId,
380
+ },
381
+ {
382
+ value: constants_1.WallModes.BOUNDARY,
383
+ assetId: (_j = wallModeAttr === null || wallModeAttr === void 0 ? void 0 : wallModeAttr.values.find(function (val) { return val.metadata[constants_1.SpacesMetadata.VALUE] === constants_1.WallModes.BOUNDARY; })) === null || _j === void 0 ? void 0 : _j.assetId,
384
+ },
385
+ ];
386
+ wallModes = {
387
+ options: wallModeOptions.map(function (_a) {
388
+ var value = _a.value;
389
+ return value;
390
+ }),
391
+ assetIds: wallModeOptions.reduce(function (output, mode) {
392
+ var _a;
393
+ return Object.assign(output, (_a = {}, _a[mode.value] = mode.assetId, _a));
394
+ }, {}),
395
+ value: (_k = wallModeOptions.find(function (mode) { return mode.assetId === (wallModeAttr === null || wallModeAttr === void 0 ? void 0 : wallModeAttr.defaultValue.assetId); })) === null || _k === void 0 ? void 0 : _k.value,
396
+ };
397
+ defaults = (_t = {},
398
+ _t[types_1.IElements.WALL] = wallAssetId,
399
+ _t[types_1.IElements.DOOR] = doorAssetId,
400
+ _t[types_1.IElements.WINDOW] = windowAssetId,
401
+ _t[types_1.IElements.OPENING] = openingAssetId,
402
+ _t.doorShowSwing = optionsMap.doorShowSwing[(_l = doorShowSwingAttr === null || doorShowSwingAttr === void 0 ? void 0 : doorShowSwingAttr.values.find(function (val) { return val.assetId === (doorShowSwingAttr === null || doorShowSwingAttr === void 0 ? void 0 : doorShowSwingAttr.defaultValue.assetId); })) === null || _l === void 0 ? void 0 : _l.assetId],
403
+ _t.doorOrientation = optionsMap.doorOrientation[(_m = doorOrientationAttr === null || doorOrientationAttr === void 0 ? void 0 : doorOrientationAttr.values.find(function (val) { return val.assetId === (doorOrientationAttr === null || doorOrientationAttr === void 0 ? void 0 : doorOrientationAttr.defaultValue.assetId); })) === null || _m === void 0 ? void 0 : _m.assetId],
404
+ _t.doorOpeningDirection = optionsMap.doorOpeningDirection[(_o = doorOpeningDirectionAttr === null || doorOpeningDirectionAttr === void 0 ? void 0 : doorOpeningDirectionAttr.values.find(function (val) { return val.assetId === (doorOpeningDirectionAttr === null || doorOpeningDirectionAttr === void 0 ? void 0 : doorOpeningDirectionAttr.defaultValue.assetId); })) === null || _o === void 0 ? void 0 : _o.assetId],
405
+ _t);
406
+ return [2, { defaults: defaults, wallModes: wallModes }];
407
+ }
408
+ });
409
+ });
410
+ }
411
+ exports.getAttributeData = getAttributeData;
@@ -27,7 +27,7 @@ function drawDoor(canvas, wall, offset, length, showSwing, openingDirection, ori
27
27
  ctx.beginPath();
28
28
  ctx.strokeStyle = stroke || fill;
29
29
  ctx.lineWidth = 2;
30
- var swingRatio = showSwing ? 2 : 48;
30
+ var swingRatio = showSwing === constants_1.DoorShowSwing.SHOW ? 2 : 48;
31
31
  if (openingDirection === constants_1.DoorOpeningDirections.INSIDE) {
32
32
  if (orientation === constants_1.DoorOrientations.LEFT) {
33
33
  ctx.moveTo.apply(ctx, points[0]);
@@ -1,3 +1,3 @@
1
- import { IGridToDraw, IStylesGrid } from '../types';
1
+ import type { IGridToDraw, IStylesGrid } from '../types';
2
2
  declare function drawGrid(canvas: HTMLCanvasElement, grid: IGridToDraw, styles: IStylesGrid): void;
3
3
  export default drawGrid;
@@ -4,10 +4,13 @@ function drawGrid(canvas, grid, styles) {
4
4
  var ctx = canvas.getContext('2d');
5
5
  if (!ctx)
6
6
  return;
7
- var unitLength = grid.unitLength, offset = grid.offset, subdivisions = grid.subdivisions;
7
+ var unitLength = grid.unitLength, subdivisions = grid.subdivisions;
8
8
  var showSubdivisions = styles.showSubdivisions &&
9
9
  unitLength / subdivisions > styles.subdivisionThreshold;
10
10
  var length = showSubdivisions ? unitLength / subdivisions : unitLength;
11
+ var offset = showSubdivisions
12
+ ? [grid.offset[0] % length, grid.offset[1] % length]
13
+ : grid.offset;
11
14
  ctx.strokeStyle = styles.lineColor;
12
15
  var numHorizontalLines = Math.ceil(canvas.height / length) +
13
16
  1 * (showSubdivisions ? subdivisions : 1);
@@ -1,7 +1,8 @@
1
1
  import { IWall, ICoordinatesLine, ISpacesStyles, IStylesWall, IElementStyleModes } from '../types';
2
- export interface IWallToDraw extends Pick<IWall, 'line' | 'path' | 'visible'> {
2
+ import { WallModes } from '../constants';
3
+ export interface IWallToDraw extends Pick<IWall, 'line' | 'path' | 'mode'> {
3
4
  }
4
- export declare function drawNewWall(canvas: HTMLCanvasElement, line: ICoordinatesLine, styles: ISpacesStyles, mode?: IElementStyleModes.ERROR): void;
5
+ export declare function drawNewWall(canvas: HTMLCanvasElement, line: ICoordinatesLine, wallMode: WallModes, styles: ISpacesStyles, mode?: IElementStyleModes.ERROR): void;
5
6
  export declare function drawWalls(canvas: HTMLCanvasElement, walls: Array<IWallToDraw>, selections: {
6
7
  active: Array<number>;
7
8
  highlighted: Array<number>;
@@ -4,7 +4,8 @@ exports.drawWalls = exports.drawNewWall = void 0;
4
4
  var types_1 = require("../types");
5
5
  var geometry_1 = require("../geometry");
6
6
  var drawVertices_1 = require("./drawVertices");
7
- function drawInvisibleWall(canvas, wall, style, mode) {
7
+ var constants_1 = require("../constants");
8
+ function drawBoundary(canvas, wall, style, mode) {
8
9
  var ctx = canvas.getContext('2d');
9
10
  if (!ctx)
10
11
  return;
@@ -49,8 +50,9 @@ function drawWall(canvas, wall, style, mode) {
49
50
  if (style.stroke && style.strokeWidth)
50
51
  ctx.stroke();
51
52
  }
52
- function drawNewWall(canvas, line, styles, mode) {
53
- drawWall(canvas, {
53
+ function drawNewWall(canvas, line, wallMode, styles, mode) {
54
+ var draw = wallMode === constants_1.WallModes.WALL ? drawWall : drawBoundary;
55
+ draw(canvas, {
54
56
  line: line,
55
57
  path: (0, geometry_1.addThicknessToLine)(line, styles.wall.thickness),
56
58
  }, styles.wall, mode !== null && mode !== void 0 ? mode : types_1.IElementStyleModes.ACTIVE);
@@ -80,7 +82,7 @@ function drawWalls(canvas, walls, selections, styles) {
80
82
  wallsMap.forEach(function (_a) {
81
83
  var mode = _a[0], wallIndexes = _a[1];
82
84
  return wallIndexes.forEach(function (index) {
83
- var draw = walls[index].visible ? drawWall : drawInvisibleWall;
85
+ var draw = walls[index].mode === constants_1.WallModes.WALL ? drawWall : drawBoundary;
84
86
  draw(canvas, walls[index], styles, mode);
85
87
  });
86
88
  });
@@ -2,9 +2,11 @@ import React from 'react';
2
2
  import type { IHydratedAttributeArray } from '../../types';
3
3
  import { ICoordinate2D, IDimensionOptions, IElementName, IElementPublic, ISpacesHookProps } from './types';
4
4
  import { IModes, IUnits, IElements } from './types';
5
+ import { WallModes } from './constants';
5
6
  import { IThemes } from './themes';
6
7
  import SpacesLayout from './SpacesLayout';
7
8
  interface IUseSpaces {
9
+ hasLoaded: boolean;
8
10
  draw: () => void;
9
11
  canvasRef: React.RefObject<HTMLCanvasElement>;
10
12
  [IElements.WALL]?: IHydratedAttributeArray;
@@ -66,6 +68,16 @@ interface IUseSpaces {
66
68
  }>;
67
69
  handleChange: (mode: IModes) => void;
68
70
  };
71
+ wallMode: {
72
+ value: WallModes;
73
+ options: Array<{
74
+ label: string;
75
+ value: WallModes;
76
+ selected: boolean;
77
+ handleSelect: () => void;
78
+ }>;
79
+ handleChange: (wallMode: WallModes) => void;
80
+ };
69
81
  layouts: Array<{
70
82
  label: string;
71
83
  loops: Array<ICoordinate2D[]>;
@@ -77,6 +89,7 @@ declare const useSpaces: {
77
89
  themes: typeof IThemes;
78
90
  units: typeof IUnits;
79
91
  modes: typeof IModes;
92
+ wallModes: typeof WallModes;
80
93
  LayoutIcon: typeof SpacesLayout;
81
94
  };
82
95
  export default useSpaces;