@design.estate/dees-wcctools 1.1.1 → 1.2.1

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.1.1",
3
+ "version": "1.2.1",
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": {
@@ -11,18 +11,20 @@
11
11
  "author": "Lossless GmbH",
12
12
  "license": "UNLICENSED",
13
13
  "dependencies": {
14
- "@design.estate/dees-domtools": "^2.0.57",
15
- "@design.estate/dees-element": "^2.0.34",
14
+ "@design.estate/dees-domtools": "^2.3.6",
15
+ "@design.estate/dees-element": "^2.1.3",
16
16
  "@push.rocks/smartdelay": "^3.0.5",
17
- "lit": "^3.1.3"
17
+ "lit": "^3.3.1"
18
18
  },
19
19
  "devDependencies": {
20
- "@api.global/typedserver": "^3.0.29",
21
- "@git.zone/tsbuild": "^2.1.72",
22
- "@git.zone/tsbundle": "^2.0.15",
23
- "@git.zone/tsrun": "^1.2.44",
24
- "@git.zone/tswatch": "^2.0.23",
25
- "@push.rocks/projectinfo": "^5.0.2"
20
+ "@api.global/typedserver": "^3.0.79",
21
+ "@git.zone/tsbuild": "^2.7.1",
22
+ "@git.zone/tsbundle": "^2.5.1",
23
+ "@git.zone/tsrun": "^1.6.2",
24
+ "@git.zone/tstest": "^2.7.0",
25
+ "@git.zone/tswatch": "^2.2.1",
26
+ "@push.rocks/projectinfo": "^5.0.2",
27
+ "@types/node": "^22.18.6"
26
28
  },
27
29
  "files": [
28
30
  "ts/**/*",
package/readme.md CHANGED
@@ -211,6 +211,19 @@ export class MyComponent extends DeesElement {
211
211
  }
212
212
  ```
213
213
 
214
+ ### ⏳ Async Demos
215
+
216
+ If your catalogue needs additional setup before rendering, return a `Promise` from the `demo` function. The dashboard waits for the result before inserting it into the viewport:
217
+
218
+ ```typescript
219
+ public static demo = async () => {
220
+ await Promise.resolve(); // e.g. fetch data, load fixtures, or await wrappers
221
+ return html`<my-component .value=${'Loaded asynchronously'}></my-component>`;
222
+ };
223
+ ```
224
+
225
+ The same pattern works for page factories you pass into `setupWccTools`, enabling asynchronous data preparation across the entire demo surface.
226
+
214
227
  ### 🎭 Container Queries Support
215
228
 
216
229
  Components can respond to their container size:
@@ -389,4 +402,4 @@ Registered at District court Bremen HRB 35230 HB, Germany
389
402
 
390
403
  For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
391
404
 
392
- 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.
405
+ 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 CHANGED
@@ -97,4 +97,11 @@ Properties panel was overwriting values set by demo functions
97
97
  2. This prevents browser from firing input events during initialization
98
98
  3. Added proper number parsing for number inputs
99
99
  4. Increased initial wait to 200ms for demo wrappers to complete
100
- 5. Simplified select element handling to use property binding
100
+ 5. Simplified select element handling to use property binding
101
+ # Async Demo Support (IN PROGRESS)
102
+
103
+ ## Tasks
104
+ - [ ] Allow dashboard-selected items to return Promise-based TemplateResults
105
+ - [ ] Await async demos/pages before rendering them into the viewport
106
+ - [ ] Add regression test covering async demo usage
107
+ - [ ] Document async demo pattern in README and verify with pnpm scripts
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@design.estate/dees-wcctools',
6
- version: '1.1.0',
6
+ version: '1.2.1',
7
7
  description: 'A set of web component tools for creating element catalogues, enabling the structured development and documentation of custom elements and pages.'
8
8
  }
@@ -1,4 +1,6 @@
1
1
  import { DeesElement, property, html, customElement, type TemplateResult, queryAsync, render, domtools } from '@design.estate/dees-element';
2
+ import { resolveTemplateFactory } from './wcctools.helpers.js';
3
+ import type { TTemplateFactory } from './wcctools.helpers.js';
2
4
 
3
5
  import * as plugins from '../wcctools.plugins.js';
4
6
 
@@ -21,7 +23,7 @@ export class WccDashboard extends DeesElement {
21
23
  public selectedItemName: string;
22
24
 
23
25
  @property()
24
- public selectedItem: (() => TemplateResult) | DeesElement;
26
+ public selectedItem: TTemplateFactory | DeesElement;
25
27
 
26
28
  @property()
27
29
  public selectedViewport: plugins.deesDomtools.breakpoints.TViewport = 'desktop';
@@ -33,7 +35,7 @@ export class WccDashboard extends DeesElement {
33
35
  public isFullscreen: boolean = false;
34
36
 
35
37
  @property()
36
- public pages: { [key: string]: () => TemplateResult } = {};
38
+ public pages: Record<string, TTemplateFactory> = {};
37
39
 
38
40
  @property()
39
41
  public elements: { [key: string]: DeesElement } = {};
@@ -50,7 +52,7 @@ export class WccDashboard extends DeesElement {
50
52
 
51
53
  constructor(
52
54
  elementsArg?: { [key: string]: DeesElement },
53
- pagesArg?: { [key: string]: () => TemplateResult }
55
+ pagesArg?: Record<string, TTemplateFactory>
54
56
  ) {
55
57
  super();
56
58
  if (elementsArg) {
@@ -201,7 +203,9 @@ export class WccDashboard extends DeesElement {
201
203
  if (typeof this.selectedItem === 'function') {
202
204
  console.log('slotting page.');
203
205
  const viewport = await wccFrame.getViewportElement();
204
- render(this.selectedItem(), viewport);
206
+ const pageFactory = this.selectedItem as TTemplateFactory;
207
+ const pageTemplate = await resolveTemplateFactory(pageFactory);
208
+ render(pageTemplate, viewport);
205
209
  console.log('rendered page.');
206
210
  } else {
207
211
  console.error('The selected item looks strange:');
@@ -222,7 +226,8 @@ export class WccDashboard extends DeesElement {
222
226
  }
223
227
  this.setWarning(null);
224
228
  const viewport = await wccFrame.getViewportElement();
225
- render(anonItem.demo(), viewport);;
229
+ const demoTemplate = await resolveTemplateFactory(() => anonItem.demo());
230
+ render(demoTemplate, viewport);
226
231
  }
227
232
  }
228
233
 
@@ -1,5 +1,6 @@
1
1
  import { DeesElement, property, html, customElement, type TemplateResult, state } from '@design.estate/dees-element';
2
2
  import { WccDashboard } from './wcc-dashboard.js';
3
+ import type { TTemplateFactory } from './wcctools.helpers.js';
3
4
 
4
5
  export type TPropertyType = 'String' | 'Number' | 'Boolean' | 'Object' | 'Enum' | 'Array';
5
6
 
@@ -20,7 +21,7 @@ export class WccProperties extends DeesElement {
20
21
  public dashboardRef: WccDashboard;
21
22
 
22
23
  @property()
23
- public selectedItem: (() => TemplateResult) | DeesElement;
24
+ public selectedItem: TTemplateFactory | DeesElement;
24
25
 
25
26
  @property()
26
27
  public selectedViewport: TEnvironment = 'native';
@@ -1,13 +1,14 @@
1
1
  import * as plugins from '../wcctools.plugins.js';
2
2
  import { DeesElement, property, html, customElement, type TemplateResult } from '@design.estate/dees-element';
3
3
  import { WccDashboard } from './wcc-dashboard.js';
4
+ import type { TTemplateFactory } from './wcctools.helpers.js';
4
5
 
5
6
  export type TElementType = 'element' | 'page';
6
7
 
7
8
  @customElement('wcc-sidebar')
8
9
  export class WccSidebar extends DeesElement {
9
10
  @property({ attribute: false })
10
- public selectedItem: DeesElement | (() => TemplateResult);
11
+ public selectedItem: DeesElement | TTemplateFactory;
11
12
 
12
13
  @property({ attribute: false })
13
14
  public selectedType: TElementType;
@@ -202,7 +203,7 @@ export class WccSidebar extends DeesElement {
202
203
  `;
203
204
  }
204
205
 
205
- public selectItem(typeArg: TElementType, itemNameArg: string, itemArg: (() => TemplateResult) | DeesElement) {
206
+ public selectItem(typeArg: TElementType, itemNameArg: string, itemArg: TTemplateFactory | DeesElement) {
206
207
  console.log('selected item');
207
208
  console.log(itemNameArg);
208
209
  console.log(itemArg);
@@ -0,0 +1,9 @@
1
+ import type { TemplateResult } from 'lit';
2
+
3
+ export type TTemplateFactory = () => TemplateResult | Promise<TemplateResult>;
4
+
5
+ export const resolveTemplateFactory = async (
6
+ factoryArg: TTemplateFactory
7
+ ): Promise<TemplateResult> => {
8
+ return await Promise.resolve(factoryArg());
9
+ };
package/ts_web/index.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  import { WccDashboard } from './elements/wcc-dashboard.js';
2
- import { LitElement, type TemplateResult } from 'lit';
2
+ import { LitElement } from 'lit';
3
+ import type { TTemplateFactory } from './elements/wcctools.helpers.js';
3
4
 
4
- const setupWccTools = (elementsArg?: { [key: string]: LitElement }, pagesArg?: { [key: string]: () => TemplateResult }) => {
5
+ const setupWccTools = (
6
+ elementsArg?: { [key: string]: LitElement },
7
+ pagesArg?: Record<string, TTemplateFactory>
8
+ ) => {
5
9
  let hasRun = false;
6
10
  const runWccToolsSetup = async () => {
7
11
  if (document.readyState === 'complete' && !hasRun) {