@design.estate/dees-wcctools 1.0.96 → 1.0.98

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design.estate/dees-wcctools",
3
- "version": "1.0.96",
3
+ "version": "1.0.98",
4
4
  "private": false,
5
5
  "description": "A set of web component tools for creating element catalogues, enabling the structured development and documentation of custom elements and pages.",
6
6
  "exports": {
package/readme.hints.md CHANGED
@@ -12,16 +12,24 @@ The properties panel had timing issues detecting rendered elements because:
12
12
  1. Added a 100ms initial delay to allow render completion
13
13
  2. Implemented recursive element search that:
14
14
  - Searches through nested children up to 5 levels deep
15
- - Checks shadow roots of elements
16
- - Handles complex DOM structures
15
+ - Checks both light DOM and shadow DOM for all elements
16
+ - Handles complex DOM structures generically
17
+ - Works with any wrapper elements, not specific to dees-demowrapper
17
18
  3. Added retry mechanism with up to 5 attempts (200ms between retries)
18
19
  4. Improved error messages to show retry count
20
+ 5. Comprehensive error handling:
21
+ - Errors in element search don't break the update cycle
22
+ - Individual property errors don't prevent other properties from rendering
23
+ - scheduleUpdate always completes even if createProperties fails
24
+ - Clears warnings and property content appropriately on errors
19
25
 
20
26
  ### Code Flow
21
27
  1. Dashboard renders element demo into viewport using `render(anonItem.demo(), viewport)`
22
- 2. Properties panel waits, then searches recursively for the element instance
23
- 3. If not found, retries with delays to handle async rendering
24
- 4. Once found, extracts and displays element properties
28
+ 2. Properties panel waits 200ms for demo wrappers to run and set initial values
29
+ 3. Searches recursively for the element instance
30
+ 4. If not found, retries with delays to handle async rendering
31
+ 5. Once found, extracts and displays element properties
32
+ 6. Uses property binding (`.value=`) instead of attribute binding to prevent input events during initialization
25
33
 
26
34
  ## Demo Tools
27
35
 
package/readme.plan.md CHANGED
@@ -61,4 +61,40 @@ The properties panel has timing issues detecting rendered elements because:
61
61
  - Access children via wrapper.children property
62
62
  - Updated documentation with correct import path (lowercase 'demotools')
63
63
  - Examples show how to use querySelector for powerful element selection
64
- - Added clarifying comment about querySelector working on slotted content
64
+ - Added clarifying comment about querySelector working on slotted content
65
+
66
+ ## Fixed Properties Panel Compatibility:
67
+ - Made element search generic - works with any container elements
68
+ - Searches both light DOM and shadow DOM recursively
69
+ - Improved error handling to prevent breaking the update cycle
70
+ - Errors in one property don't prevent others from rendering
71
+ - Detection continues working even after errors occur
72
+ - Maintains compatibility with all element structures
73
+
74
+ # Test Elements Created (COMPLETED)
75
+
76
+ ## Created comprehensive test elements:
77
+ 1. **test-noprops** - Element with no @property decorators
78
+ 2. **test-complextypes** - Element with arrays, objects, dates, and complex nested data
79
+ 3. **test-withwrapper** - Element that uses dees-demowrapper in its demo
80
+ 4. **test-edgecases** - Element with edge cases (null, undefined, NaN, Infinity, circular refs)
81
+ 5. **test-nested** - Element with deeply nested structure to test recursive search
82
+
83
+ These test various scenarios:
84
+ - Properties panel handling of elements without properties
85
+ - Complex data type display and editing
86
+ - Element detection inside dees-demowrapper
87
+ - Error handling for problematic values
88
+ - Deep nesting and shadow DOM traversal
89
+
90
+ # Fixed Demo Value Overwriting (COMPLETED)
91
+
92
+ ## Issue:
93
+ Properties panel was overwriting values set by demo functions
94
+
95
+ ## Solution:
96
+ 1. Changed from attribute binding (`value=`) to property binding (`.value=`)
97
+ 2. This prevents browser from firing input events during initialization
98
+ 3. Added proper number parsing for number inputs
99
+ 4. Increased initial wait to 200ms for demo wrappers to complete
100
+ 5. Simplified select element handling to use property binding
@@ -229,23 +229,28 @@ export class WccProperties extends DeesElement {
229
229
  private async findElementRecursively(container: Element, elementClass: any, maxDepth: number = 5): Promise<HTMLElement | null> {
230
230
  if (maxDepth <= 0) return null;
231
231
 
232
- // Check direct children
233
- for (const child of Array.from(container.children)) {
234
- if (child instanceof elementClass) {
235
- return child as HTMLElement;
232
+ try {
233
+ // Check direct children
234
+ for (const child of Array.from(container.children)) {
235
+ if (child instanceof elementClass) {
236
+ return child as HTMLElement;
237
+ }
236
238
  }
237
- }
238
-
239
- // Check shadow roots of children
240
- for (const child of Array.from(container.children)) {
241
- if (child.shadowRoot) {
242
- const found = await this.findElementRecursively(child.shadowRoot as any, elementClass, maxDepth - 1);
239
+
240
+ // Search in all children recursively
241
+ for (const child of Array.from(container.children)) {
242
+ // First, always check the light DOM children
243
+ const found = await this.findElementRecursively(child, elementClass, maxDepth - 1);
243
244
  if (found) return found;
245
+
246
+ // Also check shadow root if it exists
247
+ if (child.shadowRoot) {
248
+ const shadowFound = await this.findElementRecursively(child.shadowRoot as any, elementClass, maxDepth - 1);
249
+ if (shadowFound) return shadowFound;
250
+ }
244
251
  }
245
-
246
- // Also check nested children
247
- const found = await this.findElementRecursively(child, elementClass, maxDepth - 1);
248
- if (found) return found;
252
+ } catch (error) {
253
+ console.error('Error in findElementRecursively:', error);
249
254
  }
250
255
 
251
256
  return null;
@@ -254,6 +259,9 @@ export class WccProperties extends DeesElement {
254
259
  public async createProperties() {
255
260
  console.log('creating properties for:');
256
261
  console.log(this.selectedItem);
262
+
263
+ // Clear any previous warnings
264
+ this.warning = null;
257
265
  const isEnumeration = (propertyArg): boolean => {
258
266
  const keys = Object.keys(propertyArg.type);
259
267
  const values = [];
@@ -301,8 +309,8 @@ export class WccProperties extends DeesElement {
301
309
  console.log(anonItem.elementProperties);
302
310
  const wccFrame = await this.dashboardRef.wccFrame;
303
311
 
304
- // Wait for render to complete
305
- await new Promise(resolve => setTimeout(resolve, 100));
312
+ // Wait for render to complete and any demo wrappers to run
313
+ await new Promise(resolve => setTimeout(resolve, 200));
306
314
 
307
315
  // Try to find the element with recursive search
308
316
  const viewport = await wccFrame.getViewportElement();
@@ -315,15 +323,20 @@ export class WccProperties extends DeesElement {
315
323
  let retries = 0;
316
324
  while (!firstFoundInstantiatedElement && retries < 5) {
317
325
  await new Promise(resolve => setTimeout(resolve, 200));
318
- firstFoundInstantiatedElement = await this.findElementRecursively(
319
- viewport,
320
- this.selectedItem as any
321
- );
326
+ try {
327
+ firstFoundInstantiatedElement = await this.findElementRecursively(
328
+ viewport,
329
+ this.selectedItem as any
330
+ );
331
+ } catch (error) {
332
+ console.error('Error during element search retry:', error);
333
+ }
322
334
  retries++;
323
335
  }
324
336
 
325
337
  if (!firstFoundInstantiatedElement) {
326
338
  this.warning = `no first instantiated element found for >>${anonItem.name}<< after ${retries} retries`;
339
+ this.propertyContent = [];
327
340
  return;
328
341
  }
329
342
  const classProperties: Map<string, any> = anonItem.elementProperties;
@@ -337,9 +350,10 @@ export class WccProperties extends DeesElement {
337
350
  if (key === 'goBright' || key === 'domtools') {
338
351
  continue;
339
352
  }
340
- const property = classProperties.get(key);
341
- const propertyTypeString = await determinePropertyType(property);
342
- propertyArray.push(
353
+ try {
354
+ const property = classProperties.get(key);
355
+ const propertyTypeString = await determinePropertyType(property);
356
+ propertyArray.push(
343
357
  html`
344
358
  <div class="property">
345
359
  ${key} / ${propertyTypeString}<br />
@@ -356,7 +370,7 @@ export class WccProperties extends DeesElement {
356
370
  case 'String':
357
371
  return html`<input
358
372
  type="text"
359
- value=${firstFoundInstantiatedElement[key]}
373
+ .value=${firstFoundInstantiatedElement[key] || ''}
360
374
  @input="${(eventArg: any) => {
361
375
  firstFoundInstantiatedElement[key] = eventArg.target.value;
362
376
  }}"
@@ -364,14 +378,15 @@ export class WccProperties extends DeesElement {
364
378
  case 'Number':
365
379
  return html`<input
366
380
  type="number"
367
- value=${firstFoundInstantiatedElement[key]}
381
+ .value=${firstFoundInstantiatedElement[key] ?? ''}
368
382
  @input="${(eventArg: any) => {
369
- firstFoundInstantiatedElement[key] = eventArg.target.value;
383
+ firstFoundInstantiatedElement[key] = parseFloat(eventArg.target.value) || 0;
370
384
  }}"
371
385
  />`;
372
386
  case 'Enum':
373
387
  const enumValues: any[] = getEnumValues(property);
374
388
  return html`<select
389
+ .value=${firstFoundInstantiatedElement[key] || ''}
375
390
  @change="${(eventArg: any) => {
376
391
  firstFoundInstantiatedElement[key] = eventArg.target.value;
377
392
  }}"
@@ -379,8 +394,7 @@ export class WccProperties extends DeesElement {
379
394
  ${enumValues.map((valueArg) => {
380
395
  return html`
381
396
  <option
382
- ?selected=${valueArg === firstFoundInstantiatedElement[key] ? true : false}
383
- name="${valueArg}"
397
+ value="${valueArg}"
384
398
  >
385
399
  ${valueArg}
386
400
  </option>
@@ -392,6 +406,10 @@ export class WccProperties extends DeesElement {
392
406
  </div>
393
407
  `
394
408
  );
409
+ } catch (error) {
410
+ console.error(`Error processing property ${key}:`, error);
411
+ // Continue with next property even if this one fails
412
+ }
395
413
  }
396
414
  this.propertyContent = propertyArray;
397
415
  } else {
@@ -413,7 +431,14 @@ export class WccProperties extends DeesElement {
413
431
  }
414
432
 
415
433
  public async scheduleUpdate() {
416
- await this.createProperties();
434
+ try {
435
+ await this.createProperties();
436
+ } catch (error) {
437
+ console.error('Error creating properties:', error);
438
+ // Clear property content on error to show clean state
439
+ this.propertyContent = [];
440
+ }
441
+ // Always call super.scheduleUpdate to ensure component updates
417
442
  super.scheduleUpdate();
418
443
  }
419
444