@design.estate/dees-wcctools 1.0.90 โ 1.0.92
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_bundle/bundle.js +13927 -6905
- package/dist_bundle/bundle.js.map +4 -4
- package/dist_ts_demotools/demotools.d.ts +7 -0
- package/dist_ts_demotools/demotools.js +50 -0
- package/dist_ts_demotools/index.d.ts +1 -0
- package/dist_ts_demotools/index.js +2 -0
- package/dist_ts_demotools/plugins.d.ts +2 -0
- package/dist_ts_demotools/plugins.js +3 -0
- package/dist_ts_web/elements/wcc-properties.d.ts +1 -0
- package/dist_ts_web/elements/wcc-properties.js +36 -8
- package/dist_watch/bundle.js +38223 -12926
- package/dist_watch/bundle.js.map +4 -4
- package/package.json +13 -10
- package/readme.hints.md +51 -1
- package/readme.md +319 -60
- package/readme.plan.md +53 -0
- package/ts_web/elements/wcc-properties.ts +47 -7
- package/ts_web/tspublish.json +3 -0
package/package.json
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@design.estate/dees-wcctools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.92",
|
|
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
|
-
"
|
|
7
|
-
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist_ts_web/index.js",
|
|
8
|
+
"./demoTools": "./dist_ts_demotools"
|
|
9
|
+
},
|
|
8
10
|
"type": "module",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "(npm run build)",
|
|
13
|
+
"build": "(tsbuild tsfolders --allowimplicitany && tsbundle element)",
|
|
14
|
+
"watch": "tswatch element",
|
|
15
|
+
"buildDocs": "tsdoc"
|
|
16
|
+
},
|
|
9
17
|
"author": "Lossless GmbH",
|
|
10
18
|
"license": "UNLICENSED",
|
|
11
19
|
"dependencies": {
|
|
@@ -49,10 +57,5 @@
|
|
|
49
57
|
"element testing",
|
|
50
58
|
"page development"
|
|
51
59
|
],
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
"build": "(tsbuild element --web --allowimplicitany && tsbundle element)",
|
|
55
|
-
"watch": "tswatch element",
|
|
56
|
-
"buildDocs": "tsdoc"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
60
|
+
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
|
|
61
|
+
}
|
package/readme.hints.md
CHANGED
|
@@ -1 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
# Project Hints and Findings
|
|
2
|
+
|
|
3
|
+
## Properties Panel Element Detection Issue (Fixed)
|
|
4
|
+
|
|
5
|
+
### Problem
|
|
6
|
+
The properties panel had timing issues detecting rendered elements because:
|
|
7
|
+
1. Elements are rendered asynchronously via lit's `render()` function in the dashboard component
|
|
8
|
+
2. The properties panel tried to find elements immediately without waiting for render completion
|
|
9
|
+
3. Element search only looked at direct children of the viewport, missing nested elements or those inside shadow DOM
|
|
10
|
+
|
|
11
|
+
### Solution Implemented
|
|
12
|
+
1. Added a 100ms initial delay to allow render completion
|
|
13
|
+
2. Implemented recursive element search that:
|
|
14
|
+
- Searches through nested children up to 5 levels deep
|
|
15
|
+
- Checks shadow roots of elements
|
|
16
|
+
- Handles complex DOM structures
|
|
17
|
+
3. Added retry mechanism with up to 5 attempts (200ms between retries)
|
|
18
|
+
4. Improved error messages to show retry count
|
|
19
|
+
|
|
20
|
+
### Code Flow
|
|
21
|
+
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
|
|
25
|
+
|
|
26
|
+
## Demo Tools
|
|
27
|
+
|
|
28
|
+
### DeesDemoWrapper Component
|
|
29
|
+
A utility component for wrapping demo elements with post-render functionality.
|
|
30
|
+
|
|
31
|
+
**Usage:**
|
|
32
|
+
```typescript
|
|
33
|
+
import { DeesDemoWrapper } from '@design.estate/dees-wcctools/demoTools';
|
|
34
|
+
|
|
35
|
+
// In your demo function:
|
|
36
|
+
demo: () => html`
|
|
37
|
+
<dees-demowrapper .runAfterRender=${(element) => {
|
|
38
|
+
// Do something with the rendered element
|
|
39
|
+
element.setAttribute('data-demo', 'true');
|
|
40
|
+
console.log('Element rendered:', element);
|
|
41
|
+
}}>
|
|
42
|
+
<my-custom-element></my-custom-element>
|
|
43
|
+
</dees-demowrapper>
|
|
44
|
+
`
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Features:**
|
|
48
|
+
- Wraps demo elements without affecting layout (uses `display: contents`)
|
|
49
|
+
- Provides access to the rendered element instance after mounting
|
|
50
|
+
- Supports async operations in runAfterRender callback
|
|
51
|
+
- Automatically handles timing to ensure element is fully rendered
|
package/readme.md
CHANGED
|
@@ -1,101 +1,360 @@
|
|
|
1
1
|
# @design.estate/dees-wcctools
|
|
2
|
-
|
|
2
|
+
Web Component Development Tools - A powerful framework for building, testing, and documenting web components
|
|
3
3
|
|
|
4
|
-
##
|
|
5
|
-
|
|
4
|
+
## Overview
|
|
5
|
+
`@design.estate/dees-wcctools` provides a comprehensive development environment for web components, featuring:
|
|
6
|
+
- ๐จ Interactive component catalogue with live preview
|
|
7
|
+
- ๐ง Real-time property editing
|
|
8
|
+
- ๐ Theme switching (light/dark modes)
|
|
9
|
+
- ๐ฑ Responsive viewport testing
|
|
10
|
+
- ๐งช Advanced demo tools for component testing
|
|
11
|
+
- ๐ Zero-config setup with TypeScript and Lit support
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
6
14
|
|
|
7
15
|
```bash
|
|
8
|
-
|
|
16
|
+
# Using npm
|
|
17
|
+
npm install @design.estate/dees-wcctools --save-dev
|
|
18
|
+
|
|
19
|
+
# Using pnpm (recommended)
|
|
20
|
+
pnpm add -D @design.estate/dees-wcctools
|
|
9
21
|
```
|
|
10
22
|
|
|
11
|
-
##
|
|
12
|
-
The `@design.estate/dees-wcctools` package provides a set of tools for creating element catalogues using Web Components. It leverages LitElement for creating custom elements and provides a structured way to showcase and test these elements in various environments and themes.
|
|
23
|
+
## Quick Start
|
|
13
24
|
|
|
14
|
-
###
|
|
15
|
-
First, ensure that your project is set up to use TypeScript and ESM syntax. This guide assumes you have a basic understanding of TypeScript and modern JavaScript development practices.
|
|
25
|
+
### 1. Create Your Component
|
|
16
26
|
|
|
17
|
-
|
|
27
|
+
```typescript
|
|
28
|
+
import { DeesElement, customElement, html, css, property } from '@design.estate/dees-element';
|
|
29
|
+
|
|
30
|
+
@customElement('my-button')
|
|
31
|
+
export class MyButton extends DeesElement {
|
|
32
|
+
// Define a demo for the catalogue
|
|
33
|
+
public static demo = () => html`
|
|
34
|
+
<my-button .label=${'Click me!'} .variant=${'primary'}></my-button>
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
@property({ type: String })
|
|
38
|
+
public label: string = 'Button';
|
|
39
|
+
|
|
40
|
+
@property({ type: String })
|
|
41
|
+
public variant: 'primary' | 'secondary' = 'primary';
|
|
42
|
+
|
|
43
|
+
public static styles = [
|
|
44
|
+
css`
|
|
45
|
+
:host {
|
|
46
|
+
display: inline-block;
|
|
47
|
+
}
|
|
48
|
+
button {
|
|
49
|
+
padding: 8px 16px;
|
|
50
|
+
border-radius: 4px;
|
|
51
|
+
border: none;
|
|
52
|
+
font-size: 14px;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
transition: all 0.3s;
|
|
55
|
+
}
|
|
56
|
+
button.primary {
|
|
57
|
+
background: #007bff;
|
|
58
|
+
color: white;
|
|
59
|
+
}
|
|
60
|
+
button.secondary {
|
|
61
|
+
background: #6c757d;
|
|
62
|
+
color: white;
|
|
63
|
+
}
|
|
64
|
+
button:hover {
|
|
65
|
+
opacity: 0.9;
|
|
66
|
+
}
|
|
67
|
+
`
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
public render() {
|
|
71
|
+
return html`
|
|
72
|
+
<button class="${this.variant}">
|
|
73
|
+
${this.label}
|
|
74
|
+
</button>
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 2. Set Up Your Catalogue
|
|
18
81
|
|
|
19
82
|
```typescript
|
|
83
|
+
// catalogue.ts
|
|
20
84
|
import { setupWccTools } from '@design.estate/dees-wcctools';
|
|
85
|
+
import { html } from 'lit';
|
|
86
|
+
|
|
87
|
+
// Import your components
|
|
88
|
+
import './components/my-button.js';
|
|
89
|
+
import './components/my-card.js';
|
|
90
|
+
|
|
91
|
+
// Define elements for the catalogue
|
|
92
|
+
const elements = {
|
|
93
|
+
'my-button': MyButton,
|
|
94
|
+
'my-card': MyCard,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// Optionally define pages
|
|
98
|
+
const pages = {
|
|
99
|
+
'home': () => html`
|
|
100
|
+
<div style="padding: 20px;">
|
|
101
|
+
<h1>Welcome to My Component Library</h1>
|
|
102
|
+
<p>Browse components using the sidebar.</p>
|
|
103
|
+
</div>
|
|
104
|
+
`,
|
|
105
|
+
'getting-started': () => html`
|
|
106
|
+
<div style="padding: 20px;">
|
|
107
|
+
<h2>Getting Started</h2>
|
|
108
|
+
<p>Installation and usage instructions...</p>
|
|
109
|
+
</div>
|
|
110
|
+
`,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// Initialize the catalogue
|
|
114
|
+
setupWccTools(elements, pages);
|
|
21
115
|
```
|
|
22
116
|
|
|
23
|
-
###
|
|
24
|
-
|
|
117
|
+
### 3. Create an HTML Entry Point
|
|
118
|
+
|
|
119
|
+
```html
|
|
120
|
+
<!DOCTYPE html>
|
|
121
|
+
<html>
|
|
122
|
+
<head>
|
|
123
|
+
<title>Component Catalogue</title>
|
|
124
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
125
|
+
</head>
|
|
126
|
+
<body style="margin: 0; padding: 0;">
|
|
127
|
+
<script type="module" src="./catalogue.js"></script>
|
|
128
|
+
</body>
|
|
129
|
+
</html>
|
|
130
|
+
```
|
|
25
131
|
|
|
26
|
-
|
|
27
|
-
import { LitElement, html, customElement } from 'lit';
|
|
132
|
+
## Features
|
|
28
133
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
134
|
+
### ๐ฏ Live Property Editing
|
|
135
|
+
The properties panel automatically detects and allows editing of:
|
|
136
|
+
- **String** properties with text inputs
|
|
137
|
+
- **Number** properties with number inputs
|
|
138
|
+
- **Boolean** properties with checkboxes
|
|
139
|
+
- **Enum** properties with select dropdowns
|
|
140
|
+
- **Object** and **Array** properties (read-only display)
|
|
141
|
+
|
|
142
|
+
### ๐ฑ Viewport Testing
|
|
143
|
+
Test your components across different screen sizes:
|
|
144
|
+
- **Phone** (320px width)
|
|
145
|
+
- **Phablet** (600px width)
|
|
146
|
+
- **Tablet** (768px width)
|
|
147
|
+
- **Desktop** (full width)
|
|
148
|
+
|
|
149
|
+
### ๐ Theme Support
|
|
150
|
+
Components automatically adapt to light/dark themes using the `goBright` property:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
public render() {
|
|
154
|
+
return html`
|
|
155
|
+
<div class="${this.goBright ? 'light-theme' : 'dark-theme'}">
|
|
156
|
+
<!-- Your component content -->
|
|
157
|
+
</div>
|
|
158
|
+
`;
|
|
34
159
|
}
|
|
35
160
|
```
|
|
36
161
|
|
|
37
|
-
|
|
38
|
-
|
|
162
|
+
Or use CSS custom properties:
|
|
163
|
+
```typescript
|
|
164
|
+
import { cssManager } from '@design.estate/dees-element';
|
|
165
|
+
|
|
166
|
+
public static styles = [
|
|
167
|
+
css`
|
|
168
|
+
:host {
|
|
169
|
+
color: ${cssManager.bdTheme('#000', '#fff')};
|
|
170
|
+
background: ${cssManager.bdTheme('#fff', '#000')};
|
|
171
|
+
}
|
|
172
|
+
`
|
|
173
|
+
];
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### ๐งช Advanced Demo Tools
|
|
39
177
|
|
|
40
|
-
|
|
178
|
+
The demo tools provide enhanced testing capabilities:
|
|
41
179
|
|
|
42
180
|
```typescript
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
181
|
+
import * as demoTools from '@design.estate/dees-wcctools/demoTools';
|
|
182
|
+
|
|
183
|
+
@customElement('my-component')
|
|
184
|
+
export class MyComponent extends DeesElement {
|
|
185
|
+
public static demo = () => html`
|
|
186
|
+
<dees-demowrapper .runAfterRender=${async (element: MyComponent) => {
|
|
187
|
+
// Access the rendered component instance
|
|
188
|
+
console.log('Component mounted:', element);
|
|
189
|
+
|
|
190
|
+
// Simulate user interactions
|
|
191
|
+
element.value = 'Test value';
|
|
192
|
+
await element.updateComplete;
|
|
193
|
+
|
|
194
|
+
// Trigger methods
|
|
195
|
+
element.handleClick();
|
|
196
|
+
|
|
197
|
+
// Assert component state
|
|
198
|
+
if (element.isValid) {
|
|
199
|
+
console.log('Component validation passed');
|
|
200
|
+
}
|
|
201
|
+
}}>
|
|
202
|
+
<my-component></my-component>
|
|
203
|
+
</dees-demowrapper>
|
|
204
|
+
`;
|
|
56
205
|
}
|
|
57
206
|
```
|
|
58
207
|
|
|
59
|
-
|
|
208
|
+
### ๐ญ Container Queries Support
|
|
209
|
+
|
|
210
|
+
Components can respond to their container size:
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
public static styles = [
|
|
214
|
+
css`
|
|
215
|
+
@container wccToolsViewport (min-width: 768px) {
|
|
216
|
+
:host {
|
|
217
|
+
flex-direction: row;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@container wccToolsViewport (max-width: 767px) {
|
|
222
|
+
:host {
|
|
223
|
+
flex-direction: column;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
`
|
|
227
|
+
];
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Component Guidelines
|
|
60
231
|
|
|
232
|
+
### Required for Catalogue Display
|
|
233
|
+
1. Components must expose a static `demo` property returning a Lit template
|
|
234
|
+
2. Use `@property()` decorators for properties you want to be editable
|
|
235
|
+
3. Export component classes for proper detection
|
|
236
|
+
|
|
237
|
+
### Best Practices
|
|
61
238
|
```typescript
|
|
62
|
-
|
|
239
|
+
@customElement('best-practice-component')
|
|
240
|
+
export class BestPracticeComponent extends DeesElement {
|
|
241
|
+
// โ
Static demo property
|
|
242
|
+
public static demo = () => html`
|
|
243
|
+
<best-practice-component
|
|
244
|
+
.complexProp=${{ key: 'value' }}
|
|
245
|
+
simpleAttribute="test"
|
|
246
|
+
></best-practice-component>
|
|
247
|
+
`;
|
|
248
|
+
|
|
249
|
+
// โ
Typed properties with defaults
|
|
250
|
+
@property({ type: String })
|
|
251
|
+
public title: string = 'Default Title';
|
|
252
|
+
|
|
253
|
+
// โ
Complex property without attribute
|
|
254
|
+
@property({ attribute: false })
|
|
255
|
+
public complexProp: { key: string } = { key: 'default' };
|
|
256
|
+
|
|
257
|
+
// โ
Enum with proper typing
|
|
258
|
+
@property({ type: String })
|
|
259
|
+
public variant: 'small' | 'medium' | 'large' = 'medium';
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## URL Routing
|
|
264
|
+
|
|
265
|
+
The catalogue uses URL routing for deep linking:
|
|
63
266
|
```
|
|
267
|
+
/wcctools-route/:type/:name/:viewport/:theme
|
|
64
268
|
|
|
65
|
-
|
|
66
|
-
|
|
269
|
+
Example:
|
|
270
|
+
/wcctools-route/element/my-button/desktop/dark
|
|
271
|
+
/wcctools-route/page/home/tablet/bright
|
|
272
|
+
```
|
|
67
273
|
|
|
68
|
-
|
|
69
|
-
- `pages`: An optional object where keys are page identifiers and values are functions returning Lit HTML templates.
|
|
274
|
+
## Development Workflow
|
|
70
275
|
|
|
71
|
-
###
|
|
72
|
-
|
|
276
|
+
### Build and Watch
|
|
277
|
+
```json
|
|
278
|
+
{
|
|
279
|
+
"scripts": {
|
|
280
|
+
"build": "tsbuild tsfolders --allowimplicitany && tsbundle element",
|
|
281
|
+
"watch": "tswatch element",
|
|
282
|
+
"serve": "http-server ./dist"
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Project Structure
|
|
288
|
+
```
|
|
289
|
+
my-components/
|
|
290
|
+
โโโ src/
|
|
291
|
+
โ โโโ components/
|
|
292
|
+
โ โ โโโ my-button.ts
|
|
293
|
+
โ โ โโโ my-card.ts
|
|
294
|
+
โ โโโ catalogue.ts
|
|
295
|
+
โโโ dist/
|
|
296
|
+
โโโ index.html
|
|
297
|
+
โโโ package.json
|
|
298
|
+
```
|
|
73
299
|
|
|
74
|
-
|
|
75
|
-
The dashboard also provides options for testing your elements in different environments (e.g., desktop, tablet) and themes (light or dark). This helps ensure that your elements are versatile and adaptable to varying conditions.
|
|
300
|
+
## Advanced Features
|
|
76
301
|
|
|
77
|
-
###
|
|
78
|
-
|
|
302
|
+
### Custom Property Handlers
|
|
303
|
+
For complex property types, implement custom logic in your demo:
|
|
79
304
|
|
|
80
|
-
|
|
81
|
-
|
|
305
|
+
```typescript
|
|
306
|
+
public static demo = () => html`
|
|
307
|
+
<dees-demowrapper .runAfterRender=${(el) => {
|
|
308
|
+
// Set up complex property handling
|
|
309
|
+
el.addEventListener('property-change', (e) => {
|
|
310
|
+
console.log('Property changed:', e.detail);
|
|
311
|
+
});
|
|
312
|
+
}}>
|
|
313
|
+
<my-component></my-component>
|
|
314
|
+
</dees-demowrapper>
|
|
315
|
+
`;
|
|
316
|
+
```
|
|
82
317
|
|
|
318
|
+
### Responsive Testing Helpers
|
|
83
319
|
```typescript
|
|
84
|
-
import
|
|
320
|
+
import * as domtools from '@design.estate/dees-domtools';
|
|
85
321
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
322
|
+
public static styles = [
|
|
323
|
+
// Media query helpers
|
|
324
|
+
domtools.breakpoints.cssForPhone(css`
|
|
325
|
+
:host { font-size: 14px; }
|
|
326
|
+
`),
|
|
90
327
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
328
|
+
domtools.breakpoints.cssForTablet(css`
|
|
329
|
+
:host { font-size: 16px; }
|
|
330
|
+
`),
|
|
331
|
+
|
|
332
|
+
domtools.breakpoints.cssForDesktop(css`
|
|
333
|
+
:host { font-size: 18px; }
|
|
334
|
+
`)
|
|
335
|
+
];
|
|
95
336
|
```
|
|
96
337
|
|
|
97
|
-
|
|
98
|
-
|
|
338
|
+
## API Reference
|
|
339
|
+
|
|
340
|
+
### setupWccTools(elements, pages?)
|
|
341
|
+
Initialize the WCC Tools dashboard.
|
|
342
|
+
|
|
343
|
+
- `elements`: Object mapping element names to element classes
|
|
344
|
+
- `pages`: Optional object mapping page names to template functions
|
|
345
|
+
|
|
346
|
+
### DeesDemoWrapper
|
|
347
|
+
Component for wrapping demos with post-render logic.
|
|
348
|
+
|
|
349
|
+
- `runAfterRender`: Function called after the wrapped element renders
|
|
350
|
+
- Receives the first child element as parameter
|
|
351
|
+
- Supports async operations
|
|
352
|
+
|
|
353
|
+
## Browser Support
|
|
354
|
+
- Chrome/Edge (latest)
|
|
355
|
+
- Firefox (latest)
|
|
356
|
+
- Safari (latest)
|
|
357
|
+
- Mobile browsers with Web Components support
|
|
99
358
|
|
|
100
359
|
## License and Legal Information
|
|
101
360
|
|
|
@@ -114,4 +373,4 @@ Registered at District court Bremen HRB 35230 HB, Germany
|
|
|
114
373
|
|
|
115
374
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
|
116
375
|
|
|
117
|
-
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
|
376
|
+
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
package/readme.plan.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Fix Properties Panel Element Detection (COMPLETED)
|
|
2
|
+
|
|
3
|
+
To fix the element detection issue, reread CLAUDE.md first.
|
|
4
|
+
|
|
5
|
+
## Problem Analysis
|
|
6
|
+
The properties panel has timing issues detecting rendered elements because:
|
|
7
|
+
1. Elements are rendered asynchronously via lit's `render()` in the dashboard
|
|
8
|
+
2. Properties panel tries to find elements immediately without waiting for render completion
|
|
9
|
+
3. Element search only looks at direct children, missing nested/shadow DOM elements
|
|
10
|
+
|
|
11
|
+
## Implementation Plan
|
|
12
|
+
|
|
13
|
+
### 1. Add proper synchronization โ
|
|
14
|
+
- Add a delay or await render completion before element detection
|
|
15
|
+
- Use MutationObserver or lit's updateComplete promises
|
|
16
|
+
|
|
17
|
+
### 2. Improve element search algorithm โ
|
|
18
|
+
- Search recursively through all descendants, not just direct children
|
|
19
|
+
- Handle shadow DOM boundaries properly
|
|
20
|
+
- Support elements wrapped in containers
|
|
21
|
+
|
|
22
|
+
### 3. Add retry mechanism โ
|
|
23
|
+
- If element not found, retry after a delay
|
|
24
|
+
- Add maximum retry attempts to prevent infinite loops
|
|
25
|
+
- Clear error state when element is eventually found
|
|
26
|
+
|
|
27
|
+
## Code Changes Required
|
|
28
|
+
1. Modify `wcc-properties.ts` createProperties() method โ
|
|
29
|
+
2. Add element search utility function โ
|
|
30
|
+
3. Improve error handling and user feedback โ
|
|
31
|
+
|
|
32
|
+
# Demo Wrapper Implementation (COMPLETED)
|
|
33
|
+
|
|
34
|
+
## Created DeesDemoWrapper Component
|
|
35
|
+
- Location: ts_demotools/demotools.ts
|
|
36
|
+
- Allows wrapping demo elements with post-render functionality
|
|
37
|
+
- Provides runAfterRender callback that receives the rendered element
|
|
38
|
+
- Uses display: contents to not affect layout
|
|
39
|
+
- Handles timing automatically with 50ms delay after firstUpdated
|
|
40
|
+
- Supports both sync and async callbacks
|
|
41
|
+
- Exports available at @design.estate/dees-wcctools/demoTools
|
|
42
|
+
|
|
43
|
+
# Documentation Update (COMPLETED)
|
|
44
|
+
|
|
45
|
+
## Updated readme.md with:
|
|
46
|
+
- Comprehensive overview with feature highlights
|
|
47
|
+
- Quick start guide with code examples
|
|
48
|
+
- Detailed feature documentation
|
|
49
|
+
- Advanced demo tools usage
|
|
50
|
+
- Best practices and guidelines
|
|
51
|
+
- API reference
|
|
52
|
+
- Browser support information
|
|
53
|
+
- Complete examples for all major features
|
|
@@ -226,6 +226,31 @@ export class WccProperties extends DeesElement {
|
|
|
226
226
|
`;
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
private async findElementRecursively(container: Element, elementClass: any, maxDepth: number = 5): Promise<HTMLElement | null> {
|
|
230
|
+
if (maxDepth <= 0) return null;
|
|
231
|
+
|
|
232
|
+
// Check direct children
|
|
233
|
+
for (const child of Array.from(container.children)) {
|
|
234
|
+
if (child instanceof elementClass) {
|
|
235
|
+
return child as HTMLElement;
|
|
236
|
+
}
|
|
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);
|
|
243
|
+
if (found) return found;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Also check nested children
|
|
247
|
+
const found = await this.findElementRecursively(child, elementClass, maxDepth - 1);
|
|
248
|
+
if (found) return found;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
|
|
229
254
|
public async createProperties() {
|
|
230
255
|
console.log('creating properties for:');
|
|
231
256
|
console.log(this.selectedItem);
|
|
@@ -275,15 +300,30 @@ export class WccProperties extends DeesElement {
|
|
|
275
300
|
}
|
|
276
301
|
console.log(anonItem.elementProperties);
|
|
277
302
|
const wccFrame = await this.dashboardRef.wccFrame;
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
303
|
+
|
|
304
|
+
// Wait for render to complete
|
|
305
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
306
|
+
|
|
307
|
+
// Try to find the element with recursive search
|
|
308
|
+
const viewport = await wccFrame.getViewportElement();
|
|
309
|
+
let firstFoundInstantiatedElement: HTMLElement = await this.findElementRecursively(
|
|
310
|
+
viewport,
|
|
311
|
+
this.selectedItem as any
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
// Retry logic if element not found
|
|
315
|
+
let retries = 0;
|
|
316
|
+
while (!firstFoundInstantiatedElement && retries < 5) {
|
|
317
|
+
await new Promise(resolve => setTimeout(resolve, 200));
|
|
318
|
+
firstFoundInstantiatedElement = await this.findElementRecursively(
|
|
319
|
+
viewport,
|
|
320
|
+
this.selectedItem as any
|
|
321
|
+
);
|
|
322
|
+
retries++;
|
|
284
323
|
}
|
|
324
|
+
|
|
285
325
|
if (!firstFoundInstantiatedElement) {
|
|
286
|
-
this.warning = `no first instantiated element found for >>${anonItem.name}
|
|
326
|
+
this.warning = `no first instantiated element found for >>${anonItem.name}<< after ${retries} retries`;
|
|
287
327
|
return;
|
|
288
328
|
}
|
|
289
329
|
const classProperties: Map<string, any> = anonItem.elementProperties;
|