@mhmo91/schmancy 0.4.24 → 0.4.32

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/ai/sheet.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  The sheet component provides a sliding panel overlay that can be used for forms, details views, or any content that needs to be displayed in a drawer-style interface.
4
4
 
5
+ **Important Note about Templates**: The sheet service now only accepts HTMLElement components. If you're using Lit's `html` template literals, you need to either:
6
+ 1. Create a wrapper element and use innerHTML (for simple content)
7
+ 2. Create a custom element class (for complex interactions)
8
+ 3. Use the `render` function from Lit to render into a container element
9
+
5
10
  ```js
6
11
  // Import Options
7
12
  import { sheet } from '@mhmo91/schmancy'; // Legacy import
@@ -9,7 +14,7 @@ import { $sheet } from '@mhmo91/schmancy'; // New recommended import
9
14
 
10
15
  // Sheet Service API
11
16
  $sheet.open({
12
- component: HTMLElement | TemplateResult, // Content to display
17
+ component: HTMLElement, // Content to display (must be an HTMLElement)
13
18
  uid?: string, // Unique identifier for the sheet
14
19
  position?: 'side' | 'bottom', // Position (default: responsive based on screen size)
15
20
  persist?: boolean, // Keep sheet in DOM after closing (default: false)
@@ -54,20 +59,22 @@ SchmancySheetPosition.Bottom // Bottom sheet (mobile)
54
59
 
55
60
  // Examples
56
61
 
57
- // 1. Basic Sheet with Form
62
+ // 1. Basic Sheet with Form - Using a wrapper element for template content
63
+ const formContent = document.createElement('div');
64
+ formContent.className = 'p-6';
65
+ formContent.innerHTML = `
66
+ <schmancy-typography type="headline" token="md" class="mb-4">
67
+ User Details
68
+ </schmancy-typography>
69
+ <schmancy-form>
70
+ <schmancy-input label="Name" value="John Doe"></schmancy-input>
71
+ <schmancy-input label="Email" value="john@example.com"></schmancy-input>
72
+ <schmancy-button type="submit">Save</schmancy-button>
73
+ </schmancy-form>
74
+ `;
75
+
58
76
  $sheet.open({
59
- component: html`
60
- <div class="p-6">
61
- <schmancy-typography type="headline" token="md" class="mb-4">
62
- User Details
63
- </schmancy-typography>
64
- <schmancy-form>
65
- <schmancy-input label="Name" value="John Doe"></schmancy-input>
66
- <schmancy-input label="Email" value="john@example.com"></schmancy-input>
67
- <schmancy-button type="submit">Save</schmancy-button>
68
- </schmancy-form>
69
- </div>
70
- `,
77
+ component: formContent,
71
78
  title: "Edit User"
72
79
  });
73
80
 
@@ -80,18 +87,23 @@ $sheet.open({
80
87
  title: "Custom Component"
81
88
  });
82
89
 
83
- // 3. Sheet with Lock (cannot be dismissed by ESC or clicking outside)
90
+ // 3. Sheet with Lock (using Lit render for interactive content)
91
+ import { render, html } from 'lit';
92
+
93
+ const lockContent = document.createElement('div');
94
+ render(html`
95
+ <div class="p-6">
96
+ <schmancy-typography type="body" token="lg">
97
+ This action requires confirmation. Please complete the form.
98
+ </schmancy-typography>
99
+ <schmancy-button @click=${() => $sheet.dismiss()}>
100
+ Complete Action
101
+ </schmancy-button>
102
+ </div>
103
+ `, lockContent);
104
+
84
105
  $sheet.open({
85
- component: html`
86
- <div class="p-6">
87
- <schmancy-typography type="body" token="lg">
88
- This action requires confirmation. Please complete the form.
89
- </schmancy-typography>
90
- <schmancy-button @click=${() => $sheet.dismiss()}>
91
- Complete Action
92
- </schmancy-button>
93
- </div>
94
- `,
106
+ component: lockContent,
95
107
  lock: true,
96
108
  title: "Required Action"
97
109
  });
@@ -352,6 +364,56 @@ class WizardSheet extends LitElement {
352
364
  }
353
365
  }
354
366
 
367
+ // Template Handling Patterns
368
+
369
+ // Pattern 1: Simple content with innerHTML
370
+ function openSimpleSheet(content) {
371
+ const wrapper = document.createElement('div');
372
+ wrapper.innerHTML = content;
373
+ $sheet.open({ component: wrapper, title: "Simple Sheet" });
374
+ }
375
+
376
+ // Pattern 2: Using Lit's render for reactive content
377
+ function openReactiveSheet() {
378
+ const container = document.createElement('div');
379
+ const state = { count: 0 };
380
+
381
+ const updateContent = () => {
382
+ render(html`
383
+ <div class="p-6">
384
+ <p>Count: ${state.count}</p>
385
+ <schmancy-button @click=${() => {
386
+ state.count++;
387
+ updateContent(); // Re-render with new state
388
+ }}>
389
+ Increment
390
+ </schmancy-button>
391
+ </div>
392
+ `, container);
393
+ };
394
+
395
+ updateContent();
396
+ $sheet.open({ component: container, title: "Reactive Sheet" });
397
+ }
398
+
399
+ // Pattern 3: Custom Element (Recommended for complex components)
400
+ @customElement('my-sheet-content')
401
+ class MySheetContent extends LitElement {
402
+ @property() data = {};
403
+
404
+ render() {
405
+ return html`
406
+ <div class="p-6">
407
+ <!-- Your complex component logic here -->
408
+ </div>
409
+ `;
410
+ }
411
+ }
412
+
413
+ const myContent = document.createElement('my-sheet-content');
414
+ myContent.data = { /* your data */ };
415
+ $sheet.open({ component: myContent, title: "Complex Sheet" });
416
+
355
417
  // Best Practices
356
418
 
357
419
  // 1. Always provide a title for accessibility
package/dist/ai/sheet.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  The sheet component provides a sliding panel overlay that can be used for forms, details views, or any content that needs to be displayed in a drawer-style interface.
4
4
 
5
+ **Important Note about Templates**: The sheet service now only accepts HTMLElement components. If you're using Lit's `html` template literals, you need to either:
6
+ 1. Create a wrapper element and use innerHTML (for simple content)
7
+ 2. Create a custom element class (for complex interactions)
8
+ 3. Use the `render` function from Lit to render into a container element
9
+
5
10
  ```js
6
11
  // Import Options
7
12
  import { sheet } from '@mhmo91/schmancy'; // Legacy import
@@ -9,7 +14,7 @@ import { $sheet } from '@mhmo91/schmancy'; // New recommended import
9
14
 
10
15
  // Sheet Service API
11
16
  $sheet.open({
12
- component: HTMLElement | TemplateResult, // Content to display
17
+ component: HTMLElement, // Content to display (must be an HTMLElement)
13
18
  uid?: string, // Unique identifier for the sheet
14
19
  position?: 'side' | 'bottom', // Position (default: responsive based on screen size)
15
20
  persist?: boolean, // Keep sheet in DOM after closing (default: false)
@@ -54,20 +59,22 @@ SchmancySheetPosition.Bottom // Bottom sheet (mobile)
54
59
 
55
60
  // Examples
56
61
 
57
- // 1. Basic Sheet with Form
62
+ // 1. Basic Sheet with Form - Using a wrapper element for template content
63
+ const formContent = document.createElement('div');
64
+ formContent.className = 'p-6';
65
+ formContent.innerHTML = `
66
+ <schmancy-typography type="headline" token="md" class="mb-4">
67
+ User Details
68
+ </schmancy-typography>
69
+ <schmancy-form>
70
+ <schmancy-input label="Name" value="John Doe"></schmancy-input>
71
+ <schmancy-input label="Email" value="john@example.com"></schmancy-input>
72
+ <schmancy-button type="submit">Save</schmancy-button>
73
+ </schmancy-form>
74
+ `;
75
+
58
76
  $sheet.open({
59
- component: html`
60
- <div class="p-6">
61
- <schmancy-typography type="headline" token="md" class="mb-4">
62
- User Details
63
- </schmancy-typography>
64
- <schmancy-form>
65
- <schmancy-input label="Name" value="John Doe"></schmancy-input>
66
- <schmancy-input label="Email" value="john@example.com"></schmancy-input>
67
- <schmancy-button type="submit">Save</schmancy-button>
68
- </schmancy-form>
69
- </div>
70
- `,
77
+ component: formContent,
71
78
  title: "Edit User"
72
79
  });
73
80
 
@@ -80,18 +87,23 @@ $sheet.open({
80
87
  title: "Custom Component"
81
88
  });
82
89
 
83
- // 3. Sheet with Lock (cannot be dismissed by ESC or clicking outside)
90
+ // 3. Sheet with Lock (using Lit render for interactive content)
91
+ import { render, html } from 'lit';
92
+
93
+ const lockContent = document.createElement('div');
94
+ render(html`
95
+ <div class="p-6">
96
+ <schmancy-typography type="body" token="lg">
97
+ This action requires confirmation. Please complete the form.
98
+ </schmancy-typography>
99
+ <schmancy-button @click=${() => $sheet.dismiss()}>
100
+ Complete Action
101
+ </schmancy-button>
102
+ </div>
103
+ `, lockContent);
104
+
84
105
  $sheet.open({
85
- component: html`
86
- <div class="p-6">
87
- <schmancy-typography type="body" token="lg">
88
- This action requires confirmation. Please complete the form.
89
- </schmancy-typography>
90
- <schmancy-button @click=${() => $sheet.dismiss()}>
91
- Complete Action
92
- </schmancy-button>
93
- </div>
94
- `,
106
+ component: lockContent,
95
107
  lock: true,
96
108
  title: "Required Action"
97
109
  });
@@ -352,6 +364,56 @@ class WizardSheet extends LitElement {
352
364
  }
353
365
  }
354
366
 
367
+ // Template Handling Patterns
368
+
369
+ // Pattern 1: Simple content with innerHTML
370
+ function openSimpleSheet(content) {
371
+ const wrapper = document.createElement('div');
372
+ wrapper.innerHTML = content;
373
+ $sheet.open({ component: wrapper, title: "Simple Sheet" });
374
+ }
375
+
376
+ // Pattern 2: Using Lit's render for reactive content
377
+ function openReactiveSheet() {
378
+ const container = document.createElement('div');
379
+ const state = { count: 0 };
380
+
381
+ const updateContent = () => {
382
+ render(html`
383
+ <div class="p-6">
384
+ <p>Count: ${state.count}</p>
385
+ <schmancy-button @click=${() => {
386
+ state.count++;
387
+ updateContent(); // Re-render with new state
388
+ }}>
389
+ Increment
390
+ </schmancy-button>
391
+ </div>
392
+ `, container);
393
+ };
394
+
395
+ updateContent();
396
+ $sheet.open({ component: container, title: "Reactive Sheet" });
397
+ }
398
+
399
+ // Pattern 3: Custom Element (Recommended for complex components)
400
+ @customElement('my-sheet-content')
401
+ class MySheetContent extends LitElement {
402
+ @property() data = {};
403
+
404
+ render() {
405
+ return html`
406
+ <div class="p-6">
407
+ <!-- Your complex component logic here -->
408
+ </div>
409
+ `;
410
+ }
411
+ }
412
+
413
+ const myContent = document.createElement('my-sheet-content');
414
+ myContent.data = { /* your data */ };
415
+ $sheet.open({ component: myContent, title: "Complex Sheet" });
416
+
355
417
  // Best Practices
356
418
 
357
419
  // 1. Always provide a title for accessibility
@@ -42,8 +42,8 @@ import "./progress-BZ6AFT0f.js";
42
42
  import "./radio-button-D4Y1bWGN.js";
43
43
  import "./index-CuY8m6ta.js";
44
44
  import "./select-wui4bIUE.js";
45
- import "./sheet-DmrPnCAk.js";
46
- import { s as V } from "./sheet.service-22gvsyq8.js";
45
+ import "./sheet-BGuqw1NG.js";
46
+ import { s as V } from "./sheet.service-Dm2r1_ji.js";
47
47
  import "./slider-Dwm1KfNL.js";
48
48
  import "./schmancy-steps-container-BskkdQwD.js";
49
49
  import "./context-object-CDDP4bTk.js";
@@ -627,4 +627,4 @@ export {
627
627
  es as s,
628
628
  H as t
629
629
  };
630
- //# sourceMappingURL=avatar-Cb_cbT8R.js.map
630
+ //# sourceMappingURL=avatar-CVzlATFH.js.map