@design.estate/dees-wcctools 1.1.0 → 1.2.0

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.0",
3
+ "version": "1.2.0",
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.3",
15
+ "@design.estate/dees-element": "^2.1.2",
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",
20
+ "@api.global/typedserver": "^3.0.79",
21
+ "@git.zone/tsbuild": "^2.6.8",
22
+ "@git.zone/tsbundle": "^2.5.1",
23
23
  "@git.zone/tsrun": "^1.2.44",
24
- "@git.zone/tswatch": "^2.0.23",
25
- "@push.rocks/projectinfo": "^5.0.2"
24
+ "@git.zone/tstest": "^2.3.8",
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.0',
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';
@@ -30,7 +32,10 @@ export class WccDashboard extends DeesElement {
30
32
  public selectedTheme: TTheme = 'dark';
31
33
 
32
34
  @property()
33
- public pages: { [key: string]: () => TemplateResult } = {};
35
+ public isFullscreen: boolean = false;
36
+
37
+ @property()
38
+ public pages: Record<string, TTemplateFactory> = {};
34
39
 
35
40
  @property()
36
41
  public elements: { [key: string]: DeesElement } = {};
@@ -47,7 +52,7 @@ export class WccDashboard extends DeesElement {
47
52
 
48
53
  constructor(
49
54
  elementsArg?: { [key: string]: DeesElement },
50
- pagesArg?: { [key: string]: () => TemplateResult }
55
+ pagesArg?: Record<string, TTemplateFactory>
51
56
  ) {
52
57
  super();
53
58
  if (elementsArg) {
@@ -76,6 +81,7 @@ export class WccDashboard extends DeesElement {
76
81
  <wcc-sidebar
77
82
  .dashboardRef=${this}
78
83
  .selectedItem=${this.selectedItem}
84
+ .isFullscreen=${this.isFullscreen}
79
85
  @selectedType=${(eventArg) => {
80
86
  this.selectedType = eventArg.detail;
81
87
  }}
@@ -92,6 +98,7 @@ export class WccDashboard extends DeesElement {
92
98
  .selectedItem=${this.selectedItem}
93
99
  .selectedViewport=${this.selectedViewport}
94
100
  .selectedTheme=${this.selectedTheme}
101
+ .isFullscreen=${this.isFullscreen}
95
102
  @selectedViewport=${(eventArg) => {
96
103
  this.selectedViewport = eventArg.detail;
97
104
  this.scheduleUpdate();
@@ -106,8 +113,11 @@ export class WccDashboard extends DeesElement {
106
113
  frame.requestUpdate();
107
114
  }
108
115
  }}
116
+ @toggleFullscreen=${() => {
117
+ this.toggleFullscreen();
118
+ }}
109
119
  ></wcc-properties>
110
- <wcc-frame id="wccFrame" viewport=${this.selectedViewport}>
120
+ <wcc-frame id="wccFrame" viewport=${this.selectedViewport} .isFullscreen=${this.isFullscreen}>
111
121
  </wcc-frame>
112
122
  `;
113
123
  }
@@ -122,9 +132,20 @@ export class WccDashboard extends DeesElement {
122
132
  }
123
133
  }
124
134
 
135
+ public toggleFullscreen() {
136
+ this.isFullscreen = !this.isFullscreen;
137
+ }
138
+
125
139
  public async firstUpdated() {
126
140
  this.domtools = await plugins.deesDomtools.DomTools.setupDomTools();
127
141
 
142
+ // Add ESC key handler for fullscreen mode
143
+ document.addEventListener('keydown', (event) => {
144
+ if (event.key === 'Escape' && this.isFullscreen) {
145
+ this.isFullscreen = false;
146
+ }
147
+ });
148
+
128
149
  // Set up scroll listeners after DOM is ready
129
150
  setTimeout(() => {
130
151
  this.setupScrollListeners();
@@ -182,7 +203,9 @@ export class WccDashboard extends DeesElement {
182
203
  if (typeof this.selectedItem === 'function') {
183
204
  console.log('slotting page.');
184
205
  const viewport = await wccFrame.getViewportElement();
185
- render(this.selectedItem(), viewport);
206
+ const pageFactory = this.selectedItem as TTemplateFactory;
207
+ const pageTemplate = await resolveTemplateFactory(pageFactory);
208
+ render(pageTemplate, viewport);
186
209
  console.log('rendered page.');
187
210
  } else {
188
211
  console.error('The selected item looks strange:');
@@ -203,7 +226,8 @@ export class WccDashboard extends DeesElement {
203
226
  }
204
227
  this.setWarning(null);
205
228
  const viewport = await wccFrame.getViewportElement();
206
- render(anonItem.demo(), viewport);;
229
+ const demoTemplate = await resolveTemplateFactory(() => anonItem.demo());
230
+ render(demoTemplate, viewport);
207
231
  }
208
232
  }
209
233
 
@@ -16,6 +16,9 @@ export class WccFrame extends DeesElement {
16
16
  @property({ type: Boolean })
17
17
  public advancedEditorOpen: boolean = false;
18
18
 
19
+ @property({ type: Boolean })
20
+ public isFullscreen: boolean = false;
21
+
19
22
  public static styles = [
20
23
  css`
21
24
  :host {
@@ -43,9 +46,19 @@ export class WccFrame extends DeesElement {
43
46
  return html`
44
47
  <style>
45
48
  :host {
46
- bottom: ${this.advancedEditorOpen ? '400px' : '100px'};
47
- transition: bottom 0.3s ease;
48
- ${(() => {
49
+ ${this.isFullscreen ? `
50
+ border: none !important;
51
+ left: 0px !important;
52
+ right: 0px !important;
53
+ top: 0px !important;
54
+ bottom: 0px !important;
55
+ ` : `
56
+ bottom: ${this.advancedEditorOpen ? '400px' : '100px'};
57
+ border: 10px solid #ffaeaf;
58
+ left: 200px;
59
+ `}
60
+ transition: all 0.3s ease;
61
+ ${this.isFullscreen ? 'padding: 0px;' : (() => {
49
62
  switch (this.viewport) {
50
63
  case 'desktop':
51
64
  return `
@@ -74,7 +87,7 @@ export class WccFrame extends DeesElement {
74
87
  }
75
88
 
76
89
  .viewport {
77
- ${this.viewport !== 'desktop'
90
+ ${!this.isFullscreen && this.viewport !== 'desktop'
78
91
  ? html` border-right: 1px dotted #444; border-left: 1px dotted #444; `
79
92
  : html``
80
93
  }
@@ -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';
@@ -31,6 +32,9 @@ export class WccProperties extends DeesElement {
31
32
  @property()
32
33
  public warning: string = null;
33
34
 
35
+ @property()
36
+ public isFullscreen: boolean = false;
37
+
34
38
  @state()
35
39
  propertyContent: TemplateResult[] = [];
36
40
 
@@ -80,6 +84,7 @@ export class WccProperties extends DeesElement {
80
84
  overflow: hidden;
81
85
  background: var(--background);
82
86
  color: var(--foreground);
87
+ display: ${this.isFullscreen ? 'none' : 'block'};
83
88
  }
84
89
  .grid {
85
90
  display: grid;
@@ -644,7 +649,11 @@ export class WccProperties extends DeesElement {
644
649
  </div>
645
650
  </div>
646
651
  </div>
647
- <div class="docs">Docs</div>
652
+ <div class="docs" @click=${() => this.toggleFullscreen()}>
653
+ <i class="material-symbols-outlined" style="font-size: 20px;">
654
+ ${this.isFullscreen ? 'fullscreen_exit' : 'fullscreen'}
655
+ </i>
656
+ </div>
648
657
  </div>
649
658
  ${this.warning ? html`<div class="warning">${this.warning}</div>` : null}
650
659
  </div>
@@ -977,4 +986,12 @@ export class WccProperties extends DeesElement {
977
986
  })
978
987
  );
979
988
  }
989
+
990
+ private toggleFullscreen() {
991
+ this.dispatchEvent(
992
+ new CustomEvent('toggleFullscreen', {
993
+ bubbles: true
994
+ })
995
+ );
996
+ }
980
997
  }
@@ -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;
@@ -15,6 +16,9 @@ export class WccSidebar extends DeesElement {
15
16
  @property()
16
17
  public dashboardRef: WccDashboard;
17
18
 
19
+ @property()
20
+ public isFullscreen: boolean = false;
21
+
18
22
  public render(): TemplateResult {
19
23
  return html`
20
24
  <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" rel="stylesheet" />
@@ -36,7 +40,7 @@ export class WccSidebar extends DeesElement {
36
40
  --ring: #3b82f6;
37
41
  --radius: 4px;
38
42
 
39
- display: block;
43
+ display: ${this.isFullscreen ? 'none' : 'block'};
40
44
  border-right: 1px solid rgba(255, 255, 255, 0.08);
41
45
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
42
46
  font-size: 14px;
@@ -199,7 +203,7 @@ export class WccSidebar extends DeesElement {
199
203
  `;
200
204
  }
201
205
 
202
- public selectItem(typeArg: TElementType, itemNameArg: string, itemArg: (() => TemplateResult) | DeesElement) {
206
+ public selectItem(typeArg: TElementType, itemNameArg: string, itemArg: TTemplateFactory | DeesElement) {
203
207
  console.log('selected item');
204
208
  console.log(itemNameArg);
205
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) {