snice 1.13.1 → 1.13.3

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.
@@ -30,4 +30,4 @@ npm run preview
30
30
  - `src/router.ts` - Router configuration
31
31
  - `src/main.ts` - Application entry point
32
32
 
33
- Built with [Snice](https://github.com/yourusername/snice)
33
+ Built with [Snice](https://gitlab.com/Hedzer/snice)
@@ -0,0 +1,233 @@
1
+ # Snice Date Picker
2
+
3
+ A comprehensive calendar-based date selection component built with Snice framework.
4
+
5
+ ## Features
6
+
7
+ - ✅ **Calendar-based date selection** with month navigation
8
+ - ✅ **Multiple date formats** (MM/DD/YYYY, DD/MM/YYYY, YYYY-MM-DD, etc.)
9
+ - ✅ **Keyboard navigation** and accessibility support
10
+ - ✅ **Min/max date constraints** for date range validation
11
+ - ✅ **Multiple sizes** (small, medium, large) and variants (outlined, filled, underlined)
12
+ - ✅ **Input validation** with custom error messages
13
+ - ✅ **Clearable** with optional clear button
14
+ - ✅ **Imperative API** for programmatic control
15
+ - ✅ **Custom events** for integration with forms and controllers
16
+
17
+ ## Basic Usage
18
+
19
+ ```html
20
+ <snice-date-picker
21
+ label="Select Date"
22
+ placeholder="Choose a date"
23
+ clearable>
24
+ </snice-date-picker>
25
+ ```
26
+
27
+ ## Properties
28
+
29
+ | Property | Type | Default | Description |
30
+ |----------|------|---------|-------------|
31
+ | `size` | `'small' \| 'medium' \| 'large'` | `'medium'` | Size of the component |
32
+ | `variant` | `'outlined' \| 'filled' \| 'underlined'` | `'outlined'` | Visual style variant |
33
+ | `value` | `string` | `''` | Current date value (in specified format) |
34
+ | `format` | `'mm/dd/yyyy' \| 'dd/mm/yyyy' \| 'yyyy-mm-dd' \| etc.` | `'mm/dd/yyyy'` | Date display format |
35
+ | `placeholder` | `string` | `''` | Input placeholder text |
36
+ | `label` | `string` | `''` | Input label |
37
+ | `helper-text` | `string` | `''` | Helper text below input |
38
+ | `error-text` | `string` | `''` | Error message (shows when invalid=true) |
39
+ | `disabled` | `boolean` | `false` | Disable the component |
40
+ | `readonly` | `boolean` | `false` | Make input read-only |
41
+ | `required` | `boolean` | `false` | Mark as required field |
42
+ | `invalid` | `boolean` | `false` | Show error state |
43
+ | `clearable` | `boolean` | `false` | Show clear button |
44
+ | `min` | `string` | `''` | Minimum allowed date (YYYY-MM-DD) |
45
+ | `max` | `string` | `''` | Maximum allowed date (YYYY-MM-DD) |
46
+ | `name` | `string` | `''` | Form field name |
47
+ | `first-day-of-week` | `number` | `0` | First day of week (0=Sunday, 1=Monday, etc.) |
48
+
49
+ ## Methods
50
+
51
+ | Method | Parameters | Description |
52
+ |--------|------------|-------------|
53
+ | `focus()` | - | Focus the input field |
54
+ | `blur()` | - | Blur the input field |
55
+ | `clear()` | - | Clear the selected date |
56
+ | `open()` | - | Open the calendar popup |
57
+ | `close()` | - | Close the calendar popup |
58
+ | `selectDate(date)` | `Date` | Select a specific date |
59
+ | `goToMonth(year, month)` | `number, number` | Navigate to specific month |
60
+ | `goToToday()` | - | Select today's date |
61
+ | `checkValidity()` | - | Check if current value is valid |
62
+ | `reportValidity()` | - | Report validity state |
63
+ | `setCustomValidity(message)` | `string` | Set custom validation message |
64
+
65
+ ## Events
66
+
67
+ | Event | Detail | Description |
68
+ |-------|--------|-------------|
69
+ | `@snice/datepicker-change` | `{ value, date, formatted, iso, datePicker }` | Fired when date value changes |
70
+ | `@snice/datepicker-input` | `{ value, datePicker }` | Fired on input changes |
71
+ | `@snice/datepicker-select` | `{ date, formatted, iso, datePicker }` | Fired when date is selected from calendar |
72
+ | `@snice/datepicker-focus` | `{ datePicker }` | Fired when input gains focus |
73
+ | `@snice/datepicker-blur` | `{ datePicker }` | Fired when input loses focus |
74
+ | `@snice/datepicker-open` | `{ datePicker }` | Fired when calendar opens |
75
+ | `@snice/datepicker-close` | `{ datePicker }` | Fired when calendar closes |
76
+ | `@snice/datepicker-clear` | `{ datePicker }` | Fired when date is cleared |
77
+
78
+ ## Examples
79
+
80
+ ### Different Formats
81
+
82
+ ```html
83
+ <!-- US Format -->
84
+ <snice-date-picker
85
+ label="US Date"
86
+ format="mm/dd/yyyy">
87
+ </snice-date-picker>
88
+
89
+ <!-- European Format -->
90
+ <snice-date-picker
91
+ label="European Date"
92
+ format="dd/mm/yyyy">
93
+ </snice-date-picker>
94
+
95
+ <!-- ISO Format -->
96
+ <snice-date-picker
97
+ label="ISO Date"
98
+ format="yyyy-mm-dd">
99
+ </snice-date-picker>
100
+ ```
101
+
102
+ ### With Constraints
103
+
104
+ ```html
105
+ <snice-date-picker
106
+ label="Date Range"
107
+ min="2024-01-01"
108
+ max="2024-12-31"
109
+ helper-text="Select a date in 2024">
110
+ </snice-date-picker>
111
+ ```
112
+
113
+ ### Different Sizes and Variants
114
+
115
+ ```html
116
+ <!-- Small filled -->
117
+ <snice-date-picker
118
+ size="small"
119
+ variant="filled"
120
+ label="Small Date">
121
+ </snice-date-picker>
122
+
123
+ <!-- Large underlined -->
124
+ <snice-date-picker
125
+ size="large"
126
+ variant="underlined"
127
+ label="Large Date">
128
+ </snice-date-picker>
129
+ ```
130
+
131
+ ### Form Integration
132
+
133
+ ```html
134
+ <form>
135
+ <snice-date-picker
136
+ name="startDate"
137
+ label="Start Date"
138
+ required
139
+ min="2024-01-01">
140
+ </snice-date-picker>
141
+
142
+ <snice-date-picker
143
+ name="endDate"
144
+ label="End Date"
145
+ required>
146
+ </snice-date-picker>
147
+ </form>
148
+ ```
149
+
150
+ ### Event Handling
151
+
152
+ ```javascript
153
+ // Listen for date changes
154
+ document.addEventListener('@snice/datepicker-change', (e) => {
155
+ console.log('New date:', e.detail.date);
156
+ console.log('Formatted:', e.detail.formatted);
157
+ console.log('ISO:', e.detail.iso);
158
+ });
159
+
160
+ // Programmatic control
161
+ const datePicker = document.querySelector('snice-date-picker');
162
+ datePicker.selectDate(new Date(2024, 11, 25)); // Select Christmas
163
+ datePicker.goToToday(); // Jump to today
164
+ ```
165
+
166
+ ### With Controllers
167
+
168
+ ```typescript
169
+ import { controller, on } from 'snice';
170
+
171
+ @controller('date-form')
172
+ class DateFormController {
173
+ element!: HTMLElement;
174
+
175
+ @on('@snice/datepicker-change')
176
+ handleDateChange(e: CustomEvent) {
177
+ const { date, formatted } = e.detail;
178
+ console.log(`Date changed to: ${formatted}`);
179
+
180
+ // Validate date range, update other fields, etc.
181
+ this.validateDateRange();
182
+ }
183
+
184
+ private validateDateRange() {
185
+ const startPicker = this.element.querySelector('[name="startDate"]');
186
+ const endPicker = this.element.querySelector('[name="endDate"]');
187
+ // Add validation logic
188
+ }
189
+ }
190
+ ```
191
+
192
+ ## Accessibility
193
+
194
+ The date picker includes comprehensive accessibility support:
195
+
196
+ - **ARIA labels** for all interactive elements
197
+ - **Keyboard navigation** (Tab, Enter, Escape, Arrow keys)
198
+ - **Screen reader** announcements
199
+ - **Focus management** within calendar
200
+ - **Semantic HTML** structure
201
+
202
+ ## Keyboard Navigation
203
+
204
+ | Key | Action |
205
+ |-----|--------|
206
+ | `Tab` | Navigate between elements |
207
+ | `Enter` / `Space` | Open calendar or select date |
208
+ | `Escape` | Close calendar |
209
+ | `Arrow Keys` | Navigate calendar days |
210
+ | `Page Up/Down` | Navigate months |
211
+ | `Home/End` | Go to start/end of week |
212
+
213
+ ## Customization
214
+
215
+ The component uses CSS custom properties for easy theming:
216
+
217
+ ```css
218
+ snice-date-picker {
219
+ --border-color: #e5e7eb;
220
+ --focus-color: #2563eb;
221
+ --background: white;
222
+ --text-color: #374151;
223
+ --error-color: #ef4444;
224
+ }
225
+ ```
226
+
227
+ ## Browser Support
228
+
229
+ - ✅ Chrome/Edge 88+
230
+ - ✅ Firefox 87+
231
+ - ✅ Safari 14+
232
+ - ✅ iOS Safari 14+
233
+ - ✅ Chrome Android 88+
@@ -0,0 +1,260 @@
1
+ # Layout Components
2
+
3
+ A collection of layout components for structuring web applications.
4
+
5
+ ## Components
6
+
7
+ ### snice-layout
8
+ Basic layout with header, main content, and footer areas.
9
+
10
+ ```html
11
+ <snice-layout>
12
+ <div slot="brand"><h1>My App</h1></div>
13
+ <nav slot="nav">
14
+ <a href="/">Home</a>
15
+ <a href="/about">About</a>
16
+ </nav>
17
+
18
+ <!-- Main content -->
19
+ <div>
20
+ <h1>Welcome</h1>
21
+ <p>This is the main content area.</p>
22
+ </div>
23
+
24
+ <div slot="footer">
25
+ <p>&copy; 2024 My Company</p>
26
+ </div>
27
+ </snice-layout>
28
+ ```
29
+
30
+ ### snice-layout-sidebar
31
+ Layout with collapsible sidebar navigation.
32
+
33
+ ```html
34
+ <snice-layout-sidebar>
35
+ <div slot="brand"><h2>Dashboard</h2></div>
36
+ <nav slot="nav">
37
+ <a href="/dashboard">Overview</a>
38
+ <a href="/users">Users</a>
39
+ <a href="/settings">Settings</a>
40
+ </nav>
41
+ <div slot="header">
42
+ <h1>Page Title</h1>
43
+ </div>
44
+
45
+ <!-- Main content -->
46
+ <div>
47
+ <p>Dashboard content goes here</p>
48
+ </div>
49
+ </snice-layout-sidebar>
50
+ ```
51
+
52
+ ### snice-layout-minimal
53
+ Clean layout with just content area.
54
+
55
+ ```html
56
+ <snice-layout-minimal>
57
+ <div>
58
+ <h1>Simple Page</h1>
59
+ <p>Minimal layout for focused content.</p>
60
+ </div>
61
+ </snice-layout-minimal>
62
+ ```
63
+
64
+ ### snice-layout-centered
65
+ Centered container perfect for forms, authentication pages.
66
+
67
+ ```html
68
+ <snice-layout-centered width="md">
69
+ <form>
70
+ <h2>Sign In</h2>
71
+ <input type="email" placeholder="Email">
72
+ <input type="password" placeholder="Password">
73
+ <button type="submit">Sign In</button>
74
+ </form>
75
+ </snice-layout-centered>
76
+ ```
77
+
78
+ #### Properties
79
+ - `width`: Container width - `"sm"` | `"md"` | `"lg"` | `"xl"` (default: `"md"`)
80
+
81
+ ### snice-layout-landing
82
+ Marketing/landing page layout with hero section.
83
+
84
+ ```html
85
+ <snice-layout-landing>
86
+ <div slot="brand"><h1>Company</h1></div>
87
+ <nav slot="nav">
88
+ <a href="#features">Features</a>
89
+ <a href="#pricing">Pricing</a>
90
+ </nav>
91
+ <button slot="cta">Get Started</button>
92
+
93
+ <div slot="hero">
94
+ <h1>Amazing Product</h1>
95
+ <p>Transform your business today</p>
96
+ </div>
97
+
98
+ <!-- Main content sections -->
99
+ <section>
100
+ <h2>Features</h2>
101
+ <p>Feature content...</p>
102
+ </section>
103
+ </snice-layout-landing>
104
+ ```
105
+
106
+ ### snice-layout-split
107
+ Two-panel layout with configurable split ratios.
108
+
109
+ ```html
110
+ <snice-layout-split direction="horizontal" ratio="60-40">
111
+ <div slot="left">
112
+ <h2>Left Panel</h2>
113
+ <p>Content for left side</p>
114
+ </div>
115
+ <div slot="right">
116
+ <h2>Right Panel</h2>
117
+ <p>Content for right side</p>
118
+ </div>
119
+ </snice-layout-split>
120
+ ```
121
+
122
+ #### Properties
123
+ - `direction`: Split direction - `"horizontal"` | `"vertical"` (default: `"horizontal"`)
124
+ - `ratio`: Panel size ratio - `"50-50"` | `"60-40"` | `"70-30"` | `"33-67"` | `"67-33"` (default: `"50-50"`)
125
+
126
+ ### snice-layout-card
127
+ Grid layout optimized for card-based content.
128
+
129
+ ```html
130
+ <snice-layout-card columns="3" gap="lg">
131
+ <div slot="header">
132
+ <h1>Product Gallery</h1>
133
+ </div>
134
+
135
+ <!-- Cards go in main slot -->
136
+ <div class="card">Product 1</div>
137
+ <div class="card">Product 2</div>
138
+ <div class="card">Product 3</div>
139
+ </snice-layout-card>
140
+ ```
141
+
142
+ #### Properties
143
+ - `columns`: Number of columns - `"1"` | `"2"` | `"3"` | `"4"` | `"6"` (default: `"3"`)
144
+ - `gap`: Grid gap size - `"sm"` | `"md"` | `"lg"` | `"xl"` (default: `"md"`)
145
+
146
+ ### snice-layout-blog
147
+ Article layout with sidebar for additional content.
148
+
149
+ ```html
150
+ <snice-layout-blog>
151
+ <div slot="brand"><h1>My Blog</h1></div>
152
+ <nav slot="nav">
153
+ <a href="/">Home</a>
154
+ <a href="/archive">Archive</a>
155
+ </nav>
156
+
157
+ <!-- Article content -->
158
+ <article>
159
+ <h1>Blog Post Title</h1>
160
+ <p>Article content goes here...</p>
161
+ </article>
162
+
163
+ <div slot="sidebar">
164
+ <h3>Recent Posts</h3>
165
+ <ul>
166
+ <li><a href="/post1">Post 1</a></li>
167
+ <li><a href="/post2">Post 2</a></li>
168
+ </ul>
169
+ </div>
170
+ </snice-layout-blog>
171
+ ```
172
+
173
+ ### snice-layout-dashboard
174
+ Complex dashboard layout with multiple content areas.
175
+
176
+ ```html
177
+ <snice-layout-dashboard>
178
+ <div slot="brand"><h1>Analytics</h1></div>
179
+ <input slot="search" type="search" placeholder="Search...">
180
+ <div slot="user">Welcome, John!</div>
181
+
182
+ <nav slot="nav">
183
+ <a href="/dashboard">Overview</a>
184
+ <a href="/analytics">Analytics</a>
185
+ </nav>
186
+
187
+ <div slot="sidebar">
188
+ <h3>Quick Actions</h3>
189
+ <button>New Report</button>
190
+ </div>
191
+
192
+ <!-- Main dashboard content -->
193
+ <div>
194
+ <h2>Dashboard Overview</h2>
195
+ <div class="metrics">...</div>
196
+ </div>
197
+
198
+ <div slot="right-sidebar">
199
+ <h3>Recent Activity</h3>
200
+ <ul>...</ul>
201
+ </div>
202
+ </snice-layout-dashboard>
203
+ ```
204
+
205
+ ### snice-layout-fullscreen
206
+ Immersive fullscreen layout for presentations, media viewers.
207
+
208
+ ```html
209
+ <snice-layout-fullscreen overlay>
210
+ <img slot="background" src="background.jpg" alt="Background">
211
+
212
+ <div slot="overlay">
213
+ <h1>Overlay Content</h1>
214
+ </div>
215
+
216
+ <!-- Main fullscreen content -->
217
+ <div>
218
+ <h2>Centered Content</h2>
219
+ </div>
220
+
221
+ <div slot="controls">
222
+ <button>Play</button>
223
+ <button>Pause</button>
224
+ <button>Fullscreen</button>
225
+ </div>
226
+ </snice-layout-fullscreen>
227
+ ```
228
+
229
+ #### Properties
230
+ - `overlay`: Show overlay background - `boolean` (default: `false`)
231
+
232
+ ## Styling
233
+
234
+ All layout components use the Snice design system CSS custom properties for consistent theming. You can override these variables to customize the appearance:
235
+
236
+ ```css
237
+ :root {
238
+ --snice-color-primary: #your-primary-color;
239
+ --snice-color-background: #your-background-color;
240
+ --snice-spacing-md: your-spacing-value;
241
+ /* ... other theme variables */
242
+ }
243
+ ```
244
+
245
+ ## Responsive Design
246
+
247
+ All layouts include responsive breakpoints and will adapt to mobile devices automatically. Most layouts stack vertically on small screens for optimal mobile experience.
248
+
249
+ ## Events
250
+
251
+ Layout components are structural and don't emit custom events. However, you can listen for standard DOM events on slotted content:
252
+
253
+ ```javascript
254
+ document.querySelector('snice-layout-sidebar')
255
+ .addEventListener('click', (e) => {
256
+ if (e.target.matches('.sidebar-toggle')) {
257
+ // Handle sidebar toggle
258
+ }
259
+ });
260
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snice",
3
- "version": "1.13.1",
3
+ "version": "1.13.3",
4
4
  "type": "module",
5
5
  "description": "Imperative TypeScript framework for building vanilla web components with decorators, routing, and controllers. No virtual DOM, no build complexity.",
6
6
  "main": "src/index.ts",
@@ -14,6 +14,7 @@
14
14
  "components",
15
15
  "bin",
16
16
  "templates",
17
+ "README.md",
17
18
  "!src/**/*.test.ts",
18
19
  "!src/**/*.spec.ts",
19
20
  "!components/**/*.test.ts",
package/src/element.ts CHANGED
@@ -805,6 +805,17 @@ export function dispose() {
805
805
  export function part(partName: string, options: PartOptions = {}) {
806
806
  return function (target: any, methodName: string, descriptor: PropertyDescriptor) {
807
807
  const constructor = target.constructor;
808
+
809
+ // Handle case where descriptor might be undefined (TypeScript experimental decorators)
810
+ if (!descriptor) {
811
+ descriptor = Object.getOwnPropertyDescriptor(target, methodName) || {
812
+ value: target[methodName],
813
+ writable: true,
814
+ enumerable: true,
815
+ configurable: true
816
+ };
817
+ }
818
+
808
819
  const originalMethod = descriptor.value;
809
820
 
810
821
  if (!constructor[PARTS]) {