@mhmo91/schmancy 0.5.45 → 0.5.47

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.
Files changed (53) hide show
  1. package/ai/content-drawer.md +101 -160
  2. package/ai/sheet.md +32 -47
  3. package/dist/ai/content-drawer.md +101 -160
  4. package/dist/ai/sheet.md +32 -47
  5. package/dist/area.component-DAPQYHtN.cjs.map +1 -1
  6. package/dist/area.component-DUGxsL2-.js.map +1 -1
  7. package/dist/{avatar-C6l64slz.js → avatar-hoEk1kwv.js} +56 -61
  8. package/dist/avatar-hoEk1kwv.js.map +1 -0
  9. package/dist/{avatar-wheGmG83.cjs → avatar-hzSHTXXv.cjs} +8 -8
  10. package/dist/avatar-hzSHTXXv.cjs.map +1 -0
  11. package/dist/badge.cjs +1 -1
  12. package/dist/badge.js +1 -1
  13. package/dist/content-drawer.cjs +1 -1
  14. package/dist/content-drawer.js +1 -1
  15. package/dist/{email-recipients-C-5ER5TU.js → email-recipients-DPpv0qRr.js} +4 -4
  16. package/dist/email-recipients-DPpv0qRr.js.map +1 -0
  17. package/dist/{email-recipients-DRxGI7gT.cjs → email-recipients-Uogc-X_3.cjs} +3 -3
  18. package/dist/email-recipients-Uogc-X_3.cjs.map +1 -0
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +4 -4
  21. package/dist/mailbox.cjs +1 -1
  22. package/dist/mailbox.js +1 -1
  23. package/dist/nav-drawer.cjs +1 -1
  24. package/dist/nav-drawer.js +1 -1
  25. package/dist/navigation-bar.cjs +1 -1
  26. package/dist/navigation-bar.js +1 -1
  27. package/dist/{sheet-vJ5lJw8A.cjs → sheet-CcVGEdfr.cjs} +10 -6
  28. package/dist/sheet-CcVGEdfr.cjs.map +1 -0
  29. package/dist/{sheet-PXddkPIR.js → sheet-D5-XmZs5.js} +36 -28
  30. package/dist/sheet-D5-XmZs5.js.map +1 -0
  31. package/dist/sheet.cjs +1 -1
  32. package/dist/sheet.js +2 -2
  33. package/dist/sheet.service-C66WNur0.js +80 -0
  34. package/dist/sheet.service-C66WNur0.js.map +1 -0
  35. package/dist/sheet.service-iUShtJp1.cjs +2 -0
  36. package/dist/sheet.service-iUShtJp1.cjs.map +1 -0
  37. package/dist/teleport.cjs +1 -1
  38. package/dist/teleport.js +1 -1
  39. package/package.json +1 -1
  40. package/types/src/area/router.types.d.ts +5 -1
  41. package/types/src/content-drawer/drawer.service.d.ts +18 -6
  42. package/types/src/mailbox/email-editor.d.ts +1 -1
  43. package/types/src/sheet/sheet.service.d.ts +2 -11
  44. package/dist/avatar-C6l64slz.js.map +0 -1
  45. package/dist/avatar-wheGmG83.cjs.map +0 -1
  46. package/dist/email-recipients-C-5ER5TU.js.map +0 -1
  47. package/dist/email-recipients-DRxGI7gT.cjs.map +0 -1
  48. package/dist/sheet-PXddkPIR.js.map +0 -1
  49. package/dist/sheet-vJ5lJw8A.cjs.map +0 -1
  50. package/dist/sheet.service-BxvWBGsJ.cjs +0 -2
  51. package/dist/sheet.service-BxvWBGsJ.cjs.map +0 -1
  52. package/dist/sheet.service-lXqUf6n5.js +0 -87
  53. package/dist/sheet.service-lXqUf6n5.js.map +0 -1
@@ -1,198 +1,139 @@
1
1
  # Content Drawer
2
2
 
3
- Responsive sliding panel that automatically switches between push and overlay modes based on screen size.
4
-
5
- ## Overview
6
-
7
- The content drawer provides a responsive panel system that adapts to different screen sizes:
8
- - **Large screens**: Panel pushes content aside (push mode)
9
- - **Small screens**: Panel overlays content (overlay mode)
10
- - **Automatic switching**: Responds to screen width changes
11
-
12
- ## Components
13
-
14
- ```js
15
- // Main container that manages responsive behavior
16
- <schmancy-content-drawer
17
- ?open="${boolean}" // Controls drawer visibility (auto-managed)
18
- .minWidth="${{main: 360, sheet: 576}}" // Min widths for main and sheet
19
- >
20
- <schmancy-content-drawer-main
21
- minWidth="${number}" // Minimum width for main content (default: 360px)
22
- >
23
- // Main content area
24
- </schmancy-content-drawer-main>
3
+ Responsive sliding panel that switches between push mode (desktop) and overlay mode (mobile).
25
4
 
26
- <schmancy-content-drawer-sheet
27
- minWidth="${number}" // Minimum width for sheet (default: 576px)
28
- >
29
- <section slot="placeholder">
30
- // Optional placeholder content when sheet is empty
31
- </section>
32
- </schmancy-content-drawer-sheet>
33
- </schmancy-content-drawer>
5
+ ## Service API
6
+
7
+ ```typescript
8
+ import { schmancyContentDrawer } from '@schmancy/content-drawer'
34
9
  ```
35
10
 
36
- ## Responsive Behavior
11
+ ### `push(options)`
37
12
 
38
- The drawer automatically switches between modes based on viewport width:
39
- - **Push mode**: When `viewport >= main.minWidth + sheet.minWidth`
40
- - Sheet panel appears inline beside main content
41
- - Content is pushed to make room for the sheet
42
- - Sheet remains visible
43
- - **Overlay mode**: When `viewport < main.minWidth + sheet.minWidth`
44
- - Sheet overlays on top of main content
45
- - Opens/closes via the service API
46
- - Shows as a modal sheet
13
+ Push a component to the drawer. Component types are passed directly to the area router - no resolution happens in the drawer service.
47
14
 
48
- ## Service API
15
+ **Parameters:**
49
16
 
50
- ```js
51
- import { schmancyContentDrawer } from '@schmancy/content-drawer'
17
+ - `options: ComponentType | DrawerPushOptions`
18
+
19
+ **ComponentType formats (matches area router API):**
52
20
 
53
- // Push API - Recommended for dynamic content rendering
54
- schmancyContentDrawer.push(component)
55
- // component can be:
56
- // - string: 'demo-button' (HTML tag name)
57
- // - HTMLElement: new DemoButton() (component instance)
58
- // - Factory: () => new DemoButton() (factory function)
59
- // - Async: async () => import('./button').then(m => new m.default())
21
+ - `string` - HTML tag name (e.g., `'demo-button'`)
22
+ - `HTMLElement` - Component instance (e.g., `new MyComponent()`)
23
+ - `CustomElementConstructor` - Component class (e.g., `UserDetails`)
24
+ - `LazyComponent<any>` - Lazy import (e.g., `lazy(() => import('./my-component'))`)
60
25
 
61
- // Legacy render API (for backward compatibility)
62
- schmancyContentDrawer.render(ref, component, title?)
26
+ **DrawerPushOptions object:**
63
27
 
64
- // Dismiss drawer (note: method has typo in implementation)
65
- schmancyContentDrawer.dimiss(ref)
28
+ ```typescript
29
+ {
30
+ component: ComponentType
31
+ props?: Record<string, unknown> // Properties to set on component
32
+ state?: Record<string, unknown> // Router state (push mode only)
33
+ params?: Record<string, unknown> // Router params (push mode only)
34
+ }
66
35
  ```
67
36
 
68
- ### Push API Features
37
+ **Usage:**
69
38
 
70
- The `push` API automatically handles re-rendering when the same component instance is pushed with updated properties:
39
+ ```typescript
40
+ // String tag
41
+ schmancyContentDrawer.push('demo-button')
71
42
 
72
- ```js
73
- // Create a component instance
74
- const myComponent = new MyComponent()
75
- myComponent.variant = 'filled'
43
+ // HTMLElement instance
44
+ schmancyContentDrawer.push(new UserDetail())
76
45
 
77
- // Push it to drawer
78
- schmancyContentDrawer.push(myComponent)
46
+ // Component class (constructor)
47
+ schmancyContentDrawer.push(UserDetails)
79
48
 
80
- // Later, update properties and push again
81
- myComponent.variant = 'outlined'
82
- schmancyContentDrawer.push(myComponent) // Automatically re-renders with new properties
83
- ```
49
+ // With options object (recommended)
50
+ schmancyContentDrawer.push({
51
+ component: UserDetails,
52
+ props: { userId: '123' }
53
+ })
84
54
 
85
- ## Examples
55
+ // Lazy import
56
+ import { lazy } from '@schmancy/area'
57
+ schmancyContentDrawer.push(lazy(() => import('./my-component')))
58
+ ```
86
59
 
87
- ### 1. Basic Responsive Drawer
60
+ ### `render(ref, component, title?)`
88
61
 
89
- ```html
90
- <schmancy-content-drawer>
91
- <schmancy-content-drawer-main>
92
- <schmancy-list class="p-0">
93
- <schmancy-list-item @click=${() => {
94
- schmancyContentDrawer.push('demo-button')
95
- }}>
96
- Show Button Demo
97
- </schmancy-list-item>
98
- <schmancy-list-item @click=${() => {
99
- schmancyContentDrawer.push(new TypographyDemo())
100
- }}>
101
- Show Typography Demo
102
- </schmancy-list-item>
103
- </schmancy-list>
104
- </schmancy-content-drawer-main>
62
+ Lower-level API for rendering. Use `push()` instead for most cases.
105
63
 
106
- <schmancy-content-drawer-sheet class="px-4">
107
- <section slot="placeholder">
108
- <schmancy-typography>Select an item to view</schmancy-typography>
109
- </section>
110
- </schmancy-content-drawer-sheet>
111
- </schmancy-content-drawer>
112
- ```
64
+ **Parameters:**
113
65
 
114
- ### 2. Using Different Push API Patterns
66
+ - `ref: Element | Window` - Element to dispatch events from
67
+ - `component: HTMLElement` - Component instance
68
+ - `title?: string` - Optional title
115
69
 
116
- ```js
117
- // String tag name
118
- schmancyContentDrawer.push('demo-button')
70
+ ```typescript
71
+ schmancyContentDrawer.render(window, new UserDetail(), 'User Details')
72
+ ```
119
73
 
120
- // Component instance
121
- const button = new DemoButton()
122
- button.variant = 'filled'
123
- schmancyContentDrawer.push(button)
74
+ ### `dimiss(ref)`
124
75
 
125
- // Factory function with custom setup
126
- schmancyContentDrawer.push(() => {
127
- const comp = new MyComponent()
128
- comp.setAttribute('theme', 'dark')
129
- return comp
130
- })
76
+ Closes the drawer. *Note: typo in actual API*
131
77
 
132
- // Async module loading
133
- schmancyContentDrawer.push(async () => {
134
- const module = await import('./lazy-component')
135
- return new module.default()
136
- })
78
+ ```typescript
79
+ schmancyContentDrawer.dimiss(window)
137
80
  ```
138
81
 
139
- ### 3. Configuring Minimum Widths
82
+ ## Component Structure
140
83
 
141
84
  ```html
142
85
  <schmancy-content-drawer>
143
- <!-- Main content requires at least 400px -->
144
- <schmancy-content-drawer-main minWidth="400">
145
- <div>Main application content</div>
86
+ <schmancy-content-drawer-main>
87
+ <!-- Main content area -->
146
88
  </schmancy-content-drawer-main>
147
89
 
148
- <!-- Sheet requires at least 600px -->
149
- <schmancy-content-drawer-sheet minWidth="600">
150
- <div>Detail panel content</div>
90
+ <schmancy-content-drawer-sheet>
91
+ <section slot="placeholder">
92
+ <!-- Empty state content -->
93
+ </section>
151
94
  </schmancy-content-drawer-sheet>
152
95
  </schmancy-content-drawer>
153
96
  ```
154
97
 
155
- ## Integration with Schmancy Systems
156
-
157
- The content drawer integrates with:
158
- - **Area router**: In push mode, uses `schmancy-area` for content routing
159
- - **Sheet system**: In overlay mode, uses the schmancy sheet for modal presentation
160
- - **Grid system**: Uses `schmancy-grid` for responsive layout
161
-
162
- ## CSS Styling
163
-
164
- The component uses standard Tailwind classes for styling:
165
- - Main container uses `overflow-scroll` for scrollable content
166
- - Sheet positioning handled automatically based on mode
167
- - Animations use Web Animations API (500ms duration)
168
-
169
- ## Common Patterns
170
-
171
- **Master-Detail View**: List of items in main, details in sheet
172
- ```js
173
- // In main area - list of items
174
- <schmancy-list-item @click=${() => {
175
- schmancyContentDrawer.push(new ItemDetail(item))
176
- }}>
177
- ${item.name}
178
- </schmancy-list-item>
179
- ```
180
-
181
- **Settings Panel**: Configuration options in the sheet
182
- ```js
183
- // Push settings component
184
- schmancyContentDrawer.push(new SettingsPanel())
185
- ```
186
-
187
- **Navigation Drawer**: Navigation links in main, content in sheet
188
- ```js
189
- // Navigation item clicks update sheet content
190
- schmancyContentDrawer.push(() => import(`./pages/${page}`))
98
+ ## Properties
99
+
100
+ - `minWidth: {main: number, sheet: number}` - Minimum widths (default: `{main: 360, sheet: 576}`)
101
+ - `open: 'open' | 'close'` - Auto-managed based on mode
102
+ - `mode: 'push' | 'overlay'` - Auto-switches at 936px breakpoint
103
+
104
+ ## How It Works
105
+
106
+ The drawer service is a simple passthrough to the area router:
107
+
108
+ 1. **Push mode (desktop)**: Calls `area.push()` with your component
109
+ 2. **Overlay mode (mobile)**: Calls `sheet.open()` with your component
110
+
111
+ Component resolution is handled entirely by the area router - the drawer service just dispatches events.
112
+
113
+ ## Example
114
+
115
+ ```typescript
116
+ html`
117
+ <schmancy-content-drawer>
118
+ <schmancy-content-drawer-main>
119
+ <schmancy-list>
120
+ ${items.map(item => html`
121
+ <schmancy-list-item @click=${() => {
122
+ // Pass component class directly - area router handles instantiation
123
+ schmancyContentDrawer.push({
124
+ component: ItemDetail,
125
+ props: { item }
126
+ })
127
+ }}>
128
+ ${item.name}
129
+ </schmancy-list-item>
130
+ `)}
131
+ </schmancy-list>
132
+ </schmancy-content-drawer-main>
133
+
134
+ <schmancy-content-drawer-sheet>
135
+ <section slot="placeholder">Select an item</section>
136
+ </schmancy-content-drawer-sheet>
137
+ </schmancy-content-drawer>
138
+ `
191
139
  ```
192
-
193
- ## Related Components
194
-
195
- - [Sheet](./sheet.md) - Modal sheet component used in overlay mode
196
- - [Area](./area.md) - Routing system used in push mode
197
- - [Grid](./grid.md) - Layout system for responsive design
198
- - [List](./list.md) - List component for navigation items
package/ai/sheet.md CHANGED
@@ -2,10 +2,7 @@
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
5
+ **Component Resolution**: The sheet service uses the area router for component resolution, supporting the same component types as `area.push()` and `schmancyContentDrawer.push()`.
9
6
 
10
7
  ```js
11
8
  // Import Options
@@ -14,17 +11,22 @@ import { sheet, $sheet } from '@schmancy/index';
14
11
 
15
12
  // Sheet Service API
16
13
  $sheet.open({
17
- component: HTMLElement, // Content to display (must be an HTMLElement)
14
+ component: ComponentType, // Component to display (same types as area router)
18
15
  uid?: string, // Unique identifier for the sheet
19
16
  position?: 'side' | 'bottom', // Position (default: responsive based on screen size)
20
17
  persist?: boolean, // Keep sheet in DOM after closing (default: false)
21
18
  close?: () => void, // Callback when sheet closes
22
19
  lock?: boolean, // Prevent dismissal via ESC/overlay click (default: false)
23
- handleHistory?: boolean, // Integrate with browser back button (default: true)
24
- title?: string, // Sheet title
25
- header?: 'hidden' | 'visible' // Header visibility (default: 'visible')
20
+ onBeforeOpen?: (component: HTMLElement) => void, // Called before sheet opens
21
+ onAfterOpen?: (component: HTMLElement) => void // Called after sheet opens
26
22
  }) -> void
27
23
 
24
+ // ComponentType (matches area router):
25
+ // - string - HTML tag name (e.g., 'my-element')
26
+ // - HTMLElement - Component instance (e.g., new MyElement())
27
+ // - CustomElementConstructor - Component class (e.g., MyElement)
28
+ // - LazyComponent<any> - Lazy import (e.g., lazy(() => import('./my-element')))
29
+
28
30
  // Service Methods
29
31
  $sheet.dismiss(uid?: string) // Close specific sheet or most recent if no uid
30
32
  $sheet.isOpen(uid: string) // Check if a sheet is open
@@ -45,9 +47,9 @@ SchmancySheetPosition.Bottom // Bottom sheet (mobile)
45
47
  title="Sheet Title"
46
48
  header="visible|hidden"
47
49
  @close=${handleClose}>
48
-
49
- <!-- Main content goes in default slot -->
50
- <div>Sheet content goes here</div>
50
+
51
+ <!-- Content managed by area router -->
52
+ <!-- Use sheet.open() to push components -->
51
53
  </schmancy-sheet>
52
54
 
53
55
  // Sheet Header Component
@@ -59,49 +61,32 @@ SchmancySheetPosition.Bottom // Bottom sheet (mobile)
59
61
 
60
62
  // Examples
61
63
 
62
- // 1. Basic Sheet with Form - Using a wrapper element for template content
64
+ // 1. HTMLElement Instance (backward compatible)
63
65
  const formContent = document.createElement('div');
64
66
  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
- `;
67
+ formContent.innerHTML = '<h1>User Details</h1>';
68
+ $sheet.open({ component: formContent });
75
69
 
76
- $sheet.open({
77
- component: formContent,
78
- title: "Edit User"
79
- });
70
+ // 2. Component Class (NEW!)
71
+ class UserDetails extends HTMLElement {
72
+ connectedCallback() {
73
+ this.innerHTML = '<div>User details content</div>';
74
+ }
75
+ }
76
+ customElements.define('user-details', UserDetails);
77
+ $sheet.open({ component: UserDetails });
78
+
79
+ // 3. String Tag (NEW!)
80
+ $sheet.open({ component: 'user-details' });
80
81
 
81
- // 2. Using HTMLElement Component
82
- const myComponent = document.createElement('my-custom-element');
82
+ // 4. Lazy Import (NEW!)
83
+ import { lazy } from '@schmancy/area';
83
84
  $sheet.open({
84
- component: myComponent,
85
- uid: 'my-custom-element', // Will reuse existing sheet if already open
86
- persist: true, // Keep in DOM after closing
87
- title: "Custom Component"
85
+ component: lazy(() => import('./components/user-details')),
86
+ uid: 'user-details-sheet'
88
87
  });
89
88
 
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
-
89
+ // 5. With Options
105
90
  $sheet.open({
106
91
  component: lockContent,
107
92
  lock: true,