django-npdatetime 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,345 @@
1
+ # 🗓️ Nepali Date Picker
2
+
3
+ A modern, production-ready date picker for Nepali (Bikram Sambat) and Gregorian calendars. Beautiful, accessible, and easy to use.
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+ [![Version](https://img.shields.io/badge/version-2.0.0-green.svg)]()
7
+
8
+ ## ✨ Features
9
+
10
+ - 🎨 **Modern Design** - Beautiful glassmorphism UI with smooth animations
11
+ - 🕒 **Integrated Time Picker** - Select hours and minutes alongside dates
12
+ - ⚡ **Quick Actions** - "Today", "Yesterday", and "Tomorrow" shortcuts
13
+ - 📅 **Dual Calendar** - Seamlessly switch between Bikram Sambat (BS) and Gregorian (AD)
14
+ - 🌐 **Multi-language** - Full English & Nepali (Devanagari) support
15
+ - ♿ **Accessible** - Full keyboard navigation & ARIA support
16
+ - 📱 **Responsive** - Modal "bottom sheet" layout for mobile devices
17
+ - 📍 **Smart Positioning** - Follows input on scroll and window resize
18
+ - 🟥 **Holiday Highlighting** - Saturdays (BS) and Sundays (AD) in red
19
+ - 🌙 **Dark Mode** - Automatic system theme integration
20
+ - 🚀 **Zero Dependencies** - Pure JavaScript and high-performance WASM
21
+ - ⚡ **Auto-Init** - Initialize via `type="npdate"` or `data-npdate`
22
+
23
+ ## 🚀 Quick Start
24
+
25
+ ### Installation
26
+
27
+ 1. Copy the following files to your project:
28
+ - `date_picker.js`
29
+ - `date_picker.css`
30
+ - `pkg/` directory (WASM files)
31
+
32
+ 2. Include in your HTML:
33
+
34
+ ```html
35
+ <link rel="stylesheet" href="date_picker.css">
36
+ <script type="module">
37
+ import NepaliDatePicker from './date_picker.js';
38
+ </script>
39
+ ```
40
+
41
+ ### Basic Usage
42
+
43
+ #### Automatic Initialization
44
+
45
+ Simply add `type="npdate"` or `data-npdate` to your inputs:
46
+
47
+ ```html
48
+ <!-- Nepali Date (BS) -->
49
+ <input type="npdate" data-mode="BS" data-language="en">
50
+
51
+ <!-- With Nepali numerals -->
52
+ <input type="npdate" data-mode="BS" data-language="np">
53
+
54
+ <!-- Gregorian Date (AD) -->
55
+ <input type="npdate" data-mode="AD">
56
+ ```
57
+
58
+ The library will automatically initialize all inputs on page load!
59
+
60
+ #### Manual Initialization
61
+
62
+ ```javascript
63
+ import NepaliDatePicker from './date_picker.js';
64
+
65
+ // Create instance
66
+ const picker = new NepaliDatePicker('#my-input', {
67
+ mode: 'BS',
68
+ language: 'en',
69
+ onChange: (date, picker) => {
70
+ console.log('Selected:', date.format('%Y-%m-%d'));
71
+ }
72
+ });
73
+
74
+ // Or initialize all npdate inputs manually
75
+ NepaliDatePicker.init();
76
+ ```
77
+
78
+ ## 📖 API Reference
79
+
80
+ ### Constructor
81
+
82
+ ```javascript
83
+ new NepaliDatePicker(element, options)
84
+ ```
85
+
86
+ **Parameters:**
87
+ - `element` (string | HTMLElement) - CSS selector or DOM element
88
+ - `options` (object) - Configuration options
89
+
90
+ ### Options
91
+
92
+ | Option | Type | Default | Description |
93
+ |--------|------|---------|-------------|
94
+ | `mode` | string | `'BS'` | Calendar mode: `'BS'` or `'AD'` |
95
+ | `language` | string | `'en'` | Display language: `'en'` or `'np'` |
96
+ | `format` | string | `'%Y-%m-%d'` | Date format string |
97
+ | `minDate` | NepaliDate | `null` | Minimum selectable date |
98
+ | `maxDate` | NepaliDate | `null` | Maximum selectable date |
99
+ | `disabledDates` | array | `[]` | Array of disabled dates |
100
+ | `theme` | string | `'auto'` | Theme: `'auto'`, `'light'`, `'dark'` |
101
+ | `position` | string | `'auto'` | Picker position: `'auto'`, `'top'`, `'bottom'` |
102
+ | `closeOnSelect` | boolean | `true` | Close picker after selection |
103
+ | `showTodayButton` | boolean | `true` | Show "Today" button |
104
+ | `showClearButton` | boolean | `true` | Show "Clear" button |
105
+ | `onChange` | function | `null` | Callback when date changes |
106
+ | `onOpen` | function | `null` | Callback when picker opens |
107
+ | `onClose` | function | `null` | Callback when picker closes |
108
+
109
+ ### Methods
110
+
111
+ ```javascript
112
+ // Open the picker
113
+ picker.open();
114
+
115
+ // Close the picker
116
+ picker.close();
117
+
118
+ // Select today's date
119
+ picker.selectToday();
120
+
121
+ // Clear the selection
122
+ picker.clear();
123
+
124
+ // Switch calendar mode
125
+ picker.switchMode('BS' | 'AD');
126
+
127
+ // Destroy the picker
128
+ picker.destroy();
129
+
130
+ // Get selected date
131
+ const date = picker.selectedDate; // Returns NepaliDate instance
132
+ ```
133
+
134
+ ### Static Methods
135
+
136
+ ```javascript
137
+ // Initialize all npdate inputs
138
+ NepaliDatePicker.init(selector?, options?);
139
+
140
+ // Get instance from element
141
+ const picker = NepaliDatePicker.instances.get(element);
142
+ ```
143
+
144
+ ## 🎨 Customization
145
+
146
+ ### Themes
147
+
148
+ The date picker comes with multiple color themes:
149
+
150
+ ```html
151
+ <input type="npdate" data-theme="purple">
152
+ <input type="npdate" data-theme="green">
153
+ <input type="npdate" data-theme="orange">
154
+ <input type="npdate" data-theme="red">
155
+ ```
156
+
157
+ ### Custom Styling
158
+
159
+ You can easily override CSS variables:
160
+
161
+ ```css
162
+ :root {
163
+ --npd-primary: #your-color;
164
+ --npd-primary-hover: #your-hover-color;
165
+ --npd-radius: 1rem;
166
+ }
167
+ ```
168
+
169
+ ### Dark Mode
170
+
171
+ Dark mode is automatically supported via `prefers-color-scheme` or you can force it:
172
+
173
+ ```html
174
+ <html data-theme="dark">
175
+ ```
176
+
177
+ ## 📋 Examples
178
+
179
+ ### With Validation
180
+
181
+ ```javascript
182
+ const picker = new NepaliDatePicker('#date-input', {
183
+ mode: 'BS',
184
+ minDate: new NepaliDate(2080, 1, 1),
185
+ maxDate: new NepaliDate(2081, 12, 30),
186
+ onChange: (date) => {
187
+ if (date) {
188
+ console.log('Valid date selected:', date.format('%d %B %Y'));
189
+ }
190
+ }
191
+ });
192
+ ```
193
+
194
+ ### With Custom Format
195
+
196
+ ```javascript
197
+ const picker = new NepaliDatePicker('#date-input', {
198
+ mode: 'BS',
199
+ format: '%d/%m/%Y', // DD/MM/YYYY format
200
+ onChange: (date) => {
201
+ console.log('Formatted:', date.format('%d %B %Y'));
202
+ }
203
+ });
204
+ ```
205
+
206
+ ### Nepali Language
207
+
208
+ ```javascript
209
+ const picker = new NepaliDatePicker('#date-input', {
210
+ mode: 'BS',
211
+ language: 'np', // Devanagari numerals
212
+ onChange: (date) => {
213
+ console.log('नेपाली मिति:', date.formatUnicode());
214
+ }
215
+ });
216
+ ```
217
+
218
+ ### React Integration
219
+
220
+ ```jsx
221
+ import { useEffect, useRef } from 'react';
222
+ import NepaliDatePicker from './date_picker.js';
223
+
224
+ function DateInput() {
225
+ const inputRef = useRef(null);
226
+ const pickerRef = useRef(null);
227
+
228
+ useEffect(() => {
229
+ if (inputRef.current) {
230
+ pickerRef.current = new NepaliDatePicker(inputRef.current, {
231
+ mode: 'BS',
232
+ onChange: (date) => {
233
+ console.log('Selected:', date);
234
+ }
235
+ });
236
+ }
237
+
238
+ return () => {
239
+ pickerRef.current?.destroy();
240
+ };
241
+ }, []);
242
+
243
+ return <input ref={inputRef} type="text" />;
244
+ }
245
+ ```
246
+
247
+ ## ⌨️ Keyboard Navigation
248
+
249
+ - **Enter/Space** - Open picker
250
+ - **Escape** - Close picker
251
+ - **Arrow Left** - Previous month
252
+ - **Arrow Right** - Next month
253
+ - **Tab** - Navigate through buttons
254
+
255
+ ## 🌐 Browser Support
256
+
257
+ - Chrome/Edge (latest)
258
+ - Firefox (latest)
259
+ - Safari (latest)
260
+ - Opera (latest)
261
+
262
+ **Note:** WebAssembly support required
263
+
264
+ ## 📦 File Structure
265
+
266
+ ```
267
+ npdatetime-js/
268
+ ├── date_picker.js # Main library
269
+ ├── date_picker.css # Styles
270
+ ├── pkg/ # WASM bindings
271
+ │ ├── npdatetime_wasm.js
272
+ │ ├── npdatetime_wasm_bg.wasm
273
+ │ └── ...
274
+ ├── demo/
275
+ │ └── demo.html # Demo page
276
+ └── README.md
277
+ ```
278
+
279
+ ## 🔧 Development
280
+
281
+ ### Building from Source
282
+
283
+ ```bash
284
+ # Install Rust and wasm-pack
285
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
286
+ cargo install wasm-pack
287
+
288
+ # Build WASM
289
+ cd bindings/javascript
290
+ wasm-pack build --target web
291
+
292
+ # Test
293
+ python -m http.server 8000
294
+ # Open http://localhost:8000/demo/
295
+ ```
296
+
297
+ ## 📝 Format Strings
298
+
299
+ The date picker supports the following format strings:
300
+
301
+ | Code | Description | Example |
302
+ |------|-------------|---------|
303
+ | `%Y` | 4-digit year | 2081 |
304
+ | `%m` | 2-digit month | 05 |
305
+ | `%d` | 2-digit day | 19 |
306
+ | `%B` | Full month name | Bhadra |
307
+ | `%b` | Short month name | Bha |
308
+
309
+ ## 🤝 Contributing
310
+
311
+ Contributions are welcome! Please feel free to submit a Pull Request.
312
+
313
+ 1. Fork the repository
314
+ 2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
315
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
316
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
317
+ 5. Open a Pull Request
318
+
319
+ ## 📄 License
320
+
321
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
322
+
323
+ ## 🙏 Acknowledgments
324
+
325
+ - Built with [npdatetime-rust](https://github.com/your-repo/npdatetime-rust)
326
+ - Inspired by modern date picker libraries
327
+
328
+ ## 📞 Support
329
+
330
+ - 🐛 [Report Bug](https://github.com/your-repo/issues)
331
+ - 💡 [Request Feature](https://github.com/your-repo/issues)
332
+ - 📧 Email: your-email@example.com
333
+
334
+ ## 🗺️ Roadmap
335
+
336
+ - [ ] Time picker support
337
+ - [ ] Date range selection
338
+ - [ ] More themes
339
+ - [ ] Mobile-optimized touch interactions
340
+ - [ ] NPM package
341
+ - [ ] CDN hosting
342
+
343
+ ---
344
+
345
+ Made with ❤️ for Nepal
@@ -0,0 +1,205 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Astronomical Bikram Sambat date for JavaScript
6
+ */
7
+ export class BsDate {
8
+ free(): void;
9
+ [Symbol.dispose](): void;
10
+ static fromGregorian(year: number, month: number, day: number): BsDate;
11
+ /**
12
+ * Create a new astronomical BS date
13
+ */
14
+ constructor(year: number, month: number, day: number);
15
+ /**
16
+ * Get Tithi for the date (Astronomical)
17
+ */
18
+ tithi(): string;
19
+ toGregorian(): Int32Array;
20
+ toString(): string;
21
+ readonly day: number;
22
+ readonly month: number;
23
+ readonly year: number;
24
+ }
25
+
26
+ /**
27
+ * Nepali (Bikram Sambat) date for JavaScript
28
+ */
29
+ export class NepaliDate {
30
+ free(): void;
31
+ [Symbol.dispose](): void;
32
+ /**
33
+ * Add days to the date
34
+ *
35
+ * @param {number} days - Number of days to add (can be negative)
36
+ * @returns {NepaliDate} New date after adding days
37
+ */
38
+ addDays(days: number): NepaliDate;
39
+ /**
40
+ * Format the date as a string
41
+ *
42
+ * @param {string} format - Format string (strftime-style)
43
+ * @returns {string} Formatted date string
44
+ *
45
+ * @example
46
+ * const date = new NepaliDate(2077, 5, 19);
47
+ * console.log(date.format("%d %B %Y")); // "19 Bhadra 2077"
48
+ */
49
+ format(format_str: string): string;
50
+ /**
51
+ * Format the date in Unicode Devanagari script
52
+ */
53
+ formatUnicode(): string;
54
+ /**
55
+ * Create NepaliDate from Gregorian (AD) date
56
+ *
57
+ * @param {number} year - Gregorian year
58
+ * @param {number} month - Month (1-12)
59
+ * @param {number} day - Day of month
60
+ * @returns {NepaliDate} Converted Nepali date
61
+ *
62
+ * @example
63
+ * const date = NepaliDate.fromGregorian(2020, 9, 4);
64
+ * console.log(date.toString()); // "2077-05-19"
65
+ */
66
+ static fromGregorian(year: number, month: number, day: number): NepaliDate;
67
+ /**
68
+ * Create NepaliDate from an ordinal
69
+ */
70
+ static fromOrdinal(ordinal: number): NepaliDate;
71
+ /**
72
+ * Generate a visual month calendar
73
+ */
74
+ monthCalendar(): string;
75
+ /**
76
+ * Create a new Nepali date
77
+ *
78
+ * @param {number} year - Bikram Sambat year
79
+ * @param {number} month - Month (1-12)
80
+ * @param {number} day - Day of month
81
+ * @returns {NepaliDate} New NepaliDate instance
82
+ *
83
+ * @example
84
+ * const date = new NepaliDate(2077, 5, 19);
85
+ * console.log(date.toString()); // "2077-05-19"
86
+ */
87
+ constructor(year: number, month: number, day: number);
88
+ /**
89
+ * Get Tithi for the date (Astronomical)
90
+ *
91
+ * @returns {string} Tithi name (e.g., "Shukla Pratipada")
92
+ */
93
+ tithi(): string;
94
+ /**
95
+ * Convert to Gregorian (AD) date
96
+ *
97
+ * @returns {Array<number>} [year, month, day]
98
+ *
99
+ * @example
100
+ * const date = new NepaliDate(2077, 5, 19);
101
+ * const [year, month, day] = date.toGregorian();
102
+ * console.log(`${year}-${month}-${day}`); // "2020-9-4"
103
+ */
104
+ toGregorian(): Int32Array;
105
+ /**
106
+ * Get the ordinal representation of the date (days since 1975-01-01 BS)
107
+ */
108
+ toOrdinal(): number;
109
+ /**
110
+ * String representation
111
+ */
112
+ toString(): string;
113
+ /**
114
+ * Get today's Nepali date
115
+ *
116
+ * @returns {NepaliDate} Today's date in BS
117
+ */
118
+ static today(): NepaliDate;
119
+ /**
120
+ * Get the day
121
+ */
122
+ readonly day: number;
123
+ /**
124
+ * Get the fiscal quarter (1-4)
125
+ */
126
+ readonly fiscalQuarter: number;
127
+ /**
128
+ * Get the Nepali Fiscal Year (e.g., "2080/81")
129
+ */
130
+ readonly fiscalYear: string;
131
+ /**
132
+ * Get the month (1-12)
133
+ */
134
+ readonly month: number;
135
+ /**
136
+ * Get the year
137
+ */
138
+ readonly year: number;
139
+ }
140
+
141
+ /**
142
+ * Initialize WASM module
143
+ */
144
+ export function init(): void;
145
+
146
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
147
+
148
+ export interface InitOutput {
149
+ readonly memory: WebAssembly.Memory;
150
+ readonly __wbg_bsdate_free: (a: number, b: number) => void;
151
+ readonly bsdate_day: (a: number) => number;
152
+ readonly bsdate_fromGregorian: (a: number, b: number, c: number, d: number) => void;
153
+ readonly bsdate_month: (a: number) => number;
154
+ readonly bsdate_new: (a: number, b: number, c: number, d: number) => void;
155
+ readonly bsdate_tithi: (a: number, b: number) => void;
156
+ readonly bsdate_toGregorian: (a: number, b: number) => void;
157
+ readonly bsdate_toString: (a: number, b: number) => void;
158
+ readonly bsdate_year: (a: number) => number;
159
+ readonly init: () => void;
160
+ readonly nepalidate_addDays: (a: number, b: number, c: number) => void;
161
+ readonly nepalidate_fiscalQuarter: (a: number) => number;
162
+ readonly nepalidate_fiscalYear: (a: number, b: number) => void;
163
+ readonly nepalidate_format: (a: number, b: number, c: number, d: number) => void;
164
+ readonly nepalidate_formatUnicode: (a: number, b: number) => void;
165
+ readonly nepalidate_fromGregorian: (a: number, b: number, c: number, d: number) => void;
166
+ readonly nepalidate_fromOrdinal: (a: number, b: number) => void;
167
+ readonly nepalidate_monthCalendar: (a: number, b: number) => void;
168
+ readonly nepalidate_new: (a: number, b: number, c: number, d: number) => void;
169
+ readonly nepalidate_tithi: (a: number, b: number) => void;
170
+ readonly nepalidate_toGregorian: (a: number, b: number) => void;
171
+ readonly nepalidate_toOrdinal: (a: number) => number;
172
+ readonly nepalidate_toString: (a: number, b: number) => void;
173
+ readonly nepalidate_today: (a: number) => void;
174
+ readonly nepalidate_year: (a: number) => number;
175
+ readonly nepalidate_month: (a: number) => number;
176
+ readonly nepalidate_day: (a: number) => number;
177
+ readonly __wbg_nepalidate_free: (a: number, b: number) => void;
178
+ readonly __wbindgen_export: (a: number, b: number, c: number) => void;
179
+ readonly __wbindgen_export2: (a: number, b: number) => number;
180
+ readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
181
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
182
+ readonly __wbindgen_start: () => void;
183
+ }
184
+
185
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
186
+
187
+ /**
188
+ * Instantiates the given `module`, which can either be bytes or
189
+ * a precompiled `WebAssembly.Module`.
190
+ *
191
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
192
+ *
193
+ * @returns {InitOutput}
194
+ */
195
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
196
+
197
+ /**
198
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
199
+ * for everything else, calls `WebAssembly.instantiate` directly.
200
+ *
201
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
202
+ *
203
+ * @returns {Promise<InitOutput>}
204
+ */
205
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;