@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.
- package/ai/content-drawer.md +101 -160
- package/ai/sheet.md +32 -47
- package/dist/ai/content-drawer.md +101 -160
- package/dist/ai/sheet.md +32 -47
- package/dist/area.component-DAPQYHtN.cjs.map +1 -1
- package/dist/area.component-DUGxsL2-.js.map +1 -1
- package/dist/{avatar-C6l64slz.js → avatar-hoEk1kwv.js} +56 -61
- package/dist/avatar-hoEk1kwv.js.map +1 -0
- package/dist/{avatar-wheGmG83.cjs → avatar-hzSHTXXv.cjs} +8 -8
- package/dist/avatar-hzSHTXXv.cjs.map +1 -0
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +1 -1
- package/dist/content-drawer.cjs +1 -1
- package/dist/content-drawer.js +1 -1
- package/dist/{email-recipients-C-5ER5TU.js → email-recipients-DPpv0qRr.js} +4 -4
- package/dist/email-recipients-DPpv0qRr.js.map +1 -0
- package/dist/{email-recipients-DRxGI7gT.cjs → email-recipients-Uogc-X_3.cjs} +3 -3
- package/dist/email-recipients-Uogc-X_3.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/mailbox.cjs +1 -1
- package/dist/mailbox.js +1 -1
- package/dist/nav-drawer.cjs +1 -1
- package/dist/nav-drawer.js +1 -1
- package/dist/navigation-bar.cjs +1 -1
- package/dist/navigation-bar.js +1 -1
- package/dist/{sheet-vJ5lJw8A.cjs → sheet-CcVGEdfr.cjs} +10 -6
- package/dist/sheet-CcVGEdfr.cjs.map +1 -0
- package/dist/{sheet-PXddkPIR.js → sheet-D5-XmZs5.js} +36 -28
- package/dist/sheet-D5-XmZs5.js.map +1 -0
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.js +2 -2
- package/dist/sheet.service-C66WNur0.js +80 -0
- package/dist/sheet.service-C66WNur0.js.map +1 -0
- package/dist/sheet.service-iUShtJp1.cjs +2 -0
- package/dist/sheet.service-iUShtJp1.cjs.map +1 -0
- package/dist/teleport.cjs +1 -1
- package/dist/teleport.js +1 -1
- package/package.json +1 -1
- package/types/src/area/router.types.d.ts +5 -1
- package/types/src/content-drawer/drawer.service.d.ts +18 -6
- package/types/src/mailbox/email-editor.d.ts +1 -1
- package/types/src/sheet/sheet.service.d.ts +2 -11
- package/dist/avatar-C6l64slz.js.map +0 -1
- package/dist/avatar-wheGmG83.cjs.map +0 -1
- package/dist/email-recipients-C-5ER5TU.js.map +0 -1
- package/dist/email-recipients-DRxGI7gT.cjs.map +0 -1
- package/dist/sheet-PXddkPIR.js.map +0 -1
- package/dist/sheet-vJ5lJw8A.cjs.map +0 -1
- package/dist/sheet.service-BxvWBGsJ.cjs +0 -2
- package/dist/sheet.service-BxvWBGsJ.cjs.map +0 -1
- package/dist/sheet.service-lXqUf6n5.js +0 -87
- package/dist/sheet.service-lXqUf6n5.js.map +0 -1
package/ai/content-drawer.md
CHANGED
|
@@ -1,198 +1,139 @@
|
|
|
1
1
|
# Content Drawer
|
|
2
2
|
|
|
3
|
-
Responsive sliding panel that
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
11
|
+
### `push(options)`
|
|
37
12
|
|
|
38
|
-
|
|
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
|
-
|
|
15
|
+
**Parameters:**
|
|
49
16
|
|
|
50
|
-
|
|
51
|
-
|
|
17
|
+
- `options: ComponentType | DrawerPushOptions`
|
|
18
|
+
|
|
19
|
+
**ComponentType formats (matches area router API):**
|
|
52
20
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
62
|
-
schmancyContentDrawer.render(ref, component, title?)
|
|
26
|
+
**DrawerPushOptions object:**
|
|
63
27
|
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
37
|
+
**Usage:**
|
|
69
38
|
|
|
70
|
-
|
|
39
|
+
```typescript
|
|
40
|
+
// String tag
|
|
41
|
+
schmancyContentDrawer.push('demo-button')
|
|
71
42
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const myComponent = new MyComponent()
|
|
75
|
-
myComponent.variant = 'filled'
|
|
43
|
+
// HTMLElement instance
|
|
44
|
+
schmancyContentDrawer.push(new UserDetail())
|
|
76
45
|
|
|
77
|
-
//
|
|
78
|
-
schmancyContentDrawer.push(
|
|
46
|
+
// Component class (constructor)
|
|
47
|
+
schmancyContentDrawer.push(UserDetails)
|
|
79
48
|
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
49
|
+
// With options object (recommended)
|
|
50
|
+
schmancyContentDrawer.push({
|
|
51
|
+
component: UserDetails,
|
|
52
|
+
props: { userId: '123' }
|
|
53
|
+
})
|
|
84
54
|
|
|
85
|
-
|
|
55
|
+
// Lazy import
|
|
56
|
+
import { lazy } from '@schmancy/area'
|
|
57
|
+
schmancyContentDrawer.push(lazy(() => import('./my-component')))
|
|
58
|
+
```
|
|
86
59
|
|
|
87
|
-
###
|
|
60
|
+
### `render(ref, component, title?)`
|
|
88
61
|
|
|
89
|
-
|
|
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
|
-
|
|
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
|
-
|
|
66
|
+
- `ref: Element | Window` - Element to dispatch events from
|
|
67
|
+
- `component: HTMLElement` - Component instance
|
|
68
|
+
- `title?: string` - Optional title
|
|
115
69
|
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
|
|
70
|
+
```typescript
|
|
71
|
+
schmancyContentDrawer.render(window, new UserDetail(), 'User Details')
|
|
72
|
+
```
|
|
119
73
|
|
|
120
|
-
|
|
121
|
-
const button = new DemoButton()
|
|
122
|
-
button.variant = 'filled'
|
|
123
|
-
schmancyContentDrawer.push(button)
|
|
74
|
+
### `dimiss(ref)`
|
|
124
75
|
|
|
125
|
-
|
|
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
|
-
|
|
133
|
-
schmancyContentDrawer.
|
|
134
|
-
const module = await import('./lazy-component')
|
|
135
|
-
return new module.default()
|
|
136
|
-
})
|
|
78
|
+
```typescript
|
|
79
|
+
schmancyContentDrawer.dimiss(window)
|
|
137
80
|
```
|
|
138
81
|
|
|
139
|
-
|
|
82
|
+
## Component Structure
|
|
140
83
|
|
|
141
84
|
```html
|
|
142
85
|
<schmancy-content-drawer>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
<div>Main application content</div>
|
|
86
|
+
<schmancy-content-drawer-main>
|
|
87
|
+
<!-- Main content area -->
|
|
146
88
|
</schmancy-content-drawer-main>
|
|
147
89
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
##
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
-
|
|
159
|
-
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
<schmancy-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
**
|
|
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:
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
<!--
|
|
50
|
-
|
|
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.
|
|
64
|
+
// 1. HTMLElement Instance (backward compatible)
|
|
63
65
|
const formContent = document.createElement('div');
|
|
64
66
|
formContent.className = 'p-6';
|
|
65
|
-
formContent.innerHTML =
|
|
66
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
//
|
|
82
|
-
|
|
82
|
+
// 4. Lazy Import (NEW!)
|
|
83
|
+
import { lazy } from '@schmancy/area';
|
|
83
84
|
$sheet.open({
|
|
84
|
-
component:
|
|
85
|
-
uid: '
|
|
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
|
-
//
|
|
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,
|