@pr0vin/np-date-picker-vue-tw 1.0.4 → 1.0.5
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/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# @pr0vin/np-date-picker-vue-tw
|
|
2
|
+
|
|
3
|
+
A Nepali Date Picker component for Vue 3 using Tailwind CSS.
|
|
4
|
+
Easy to use, lightweight, and fully compatible with modern Vue 3 projects.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- Supports Nepali (Bikram Sambat) calendar
|
|
9
|
+
- Fully responsive and Tailwind CSS styled
|
|
10
|
+
- Highlight today's date
|
|
11
|
+
- Works with `v-model`
|
|
12
|
+
- Keyboard and mouse friendly
|
|
13
|
+
- Easily customizable font & size using Tailwind
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Install via npm or yarn:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @pr0vin/np-date-picker-vue-tw
|
|
21
|
+
# or
|
|
22
|
+
yarn add @pr0vin/np-date-picker-vue-tw
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Basic Example
|
|
28
|
+
|
|
29
|
+
```vue
|
|
30
|
+
<script setup>
|
|
31
|
+
import { ref } from "vue";
|
|
32
|
+
import NPDatePicker from "@pr0vin/np-date-picker-vue-tw";
|
|
33
|
+
|
|
34
|
+
const selectedDate = ref("");
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<NPDatePicker
|
|
39
|
+
v-model="selectedDate"
|
|
40
|
+
placeholder="Select a date"
|
|
41
|
+
:todayValue="true"
|
|
42
|
+
/>
|
|
43
|
+
</template>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Props
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Default | Description |
|
|
49
|
+
| ------------- | ------- | ----------------- | -------------------------------------- |
|
|
50
|
+
| `modelValue` | String | `""` | The selected date in `YYYY-MM-DD` |
|
|
51
|
+
| `placeholder` | String | `"Select a date"` | Input placeholder text |
|
|
52
|
+
| `todayValue` | Boolean | `false` | Select today's date by default if true |
|
|
53
|
+
|
|
54
|
+
### Events
|
|
55
|
+
|
|
56
|
+
| Event | Arguments | Description |
|
|
57
|
+
| ------------------- | -------------------- | --------------------------------- |
|
|
58
|
+
| `update:modelValue` | `(newValue: string)` | Emits the selected date on change |
|
|
59
|
+
|
|
60
|
+
### Customization
|
|
61
|
+
|
|
62
|
+
You can override Tailwind classes to adjust calendar size, font, colors, etc.
|
|
63
|
+
|
|
64
|
+
```vue
|
|
65
|
+
<NPDatePicker class="np-text-xs np-w-40" />
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
You can also style the input field:
|
|
69
|
+
|
|
70
|
+
```vue
|
|
71
|
+
<NPDatePicker
|
|
72
|
+
class="np-text-sm np-w-32 np-border np-border-gray-300 np-rounded"
|
|
73
|
+
/>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Multiple Components
|
|
77
|
+
|
|
78
|
+
If you have multiple date pickers on the same page, the component automatically handles focus and closes other open calendars. No extra configuration is required.
|
|
79
|
+
|
|
80
|
+
### Example With Multiple Components
|
|
81
|
+
|
|
82
|
+
```vue
|
|
83
|
+
<script setup>
|
|
84
|
+
import { ref } from "vue";
|
|
85
|
+
import NPDatePicker from "@pr0vin/np-date-picker-vue-tw";
|
|
86
|
+
|
|
87
|
+
const date1 = ref("");
|
|
88
|
+
const date2 = ref("");
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<template>
|
|
92
|
+
<NPDatePicker v-model="date1" placeholder="Select first date" />
|
|
93
|
+
<NPDatePicker v-model="date2" placeholder="Select second date" />
|
|
94
|
+
</template>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
ISC © Pravin Chaudhary
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");class M{constructor(){this.bs=[[2e3,30,32,31,32,31,30,30,30,29,30,29,31],[2001,31,31,32,31,31,31,30,29,30,29,30,30],[2002,31,31,32,32,31,30,30,29,30,29,30,30],[2003,31,32,31,32,31,30,30,30,29,29,30,31],[2004,30,32,31,32,31,30,30,30,29,30,29,31],[2005,31,31,32,31,31,31,30,29,30,29,30,30],[2006,31,31,32,32,31,30,30,29,30,29,30,30],[2007,31,32,31,32,31,30,30,30,29,29,30,31],[2008,31,31,31,32,31,31,29,30,30,29,29,31],[2009,31,31,32,31,31,31,30,29,30,29,30,30],[2010,31,31,32,32,31,30,30,29,30,29,30,30],[2011,31,32,31,32,31,30,30,30,29,29,30,31],[2012,31,31,31,32,31,31,29,30,30,29,30,30],[2013,31,31,32,31,31,31,30,29,30,29,30,30],[2014,31,31,32,32,31,30,30,29,30,29,30,30],[2015,31,32,31,32,31,30,30,30,29,29,30,31],[2016,31,31,31,32,31,31,29,30,30,29,30,30],[2017,31,31,32,31,31,31,30,29,30,29,30,30],[2018,31,32,31,32,31,30,30,29,30,29,30,30],[2019,31,32,31,32,31,30,30,30,29,30,29,31],[2020,31,31,31,32,31,31,30,29,30,29,30,30],[2021,31,31,32,31,31,31,30,29,30,29,30,30],[2022,31,32,31,32,31,30,30,30,29,29,30,30],[2023,31,32,31,32,31,30,30,30,29,30,29,31],[2024,31,31,31,32,31,31,30,29,30,29,30,30],[2025,31,31,32,31,31,31,30,29,30,29,30,30],[2026,31,32,31,32,31,30,30,30,29,29,30,31],[2027,30,32,31,32,31,30,30,30,29,30,29,31],[2028,31,31,32,31,31,31,30,29,30,29,30,30],[2029,31,31,32,31,32,30,30,29,30,29,30,30],[2030,31,32,31,32,31,30,30,30,29,29,30,31],[2031,30,32,31,32,31,30,30,30,29,30,29,31],[2032,31,31,32,31,31,31,30,29,30,29,30,30],[2033,31,31,32,32,31,30,30,29,30,29,30,30],[2034,31,32,31,32,31,30,30,30,29,29,30,31],[2035,30,32,31,32,31,31,29,30,30,29,29,31],[2036,31,31,32,31,31,31,30,29,30,29,30,30],[2037,31,31,32,32,31,30,30,29,30,29,30,30],[2038,31,32,31,32,31,30,30,30,29,29,30,31],[2039,31,31,31,32,31,31,29,30,30,29,30,30],[2040,31,31,32,31,31,31,30,29,30,29,30,30],[2041,31,31,32,32,31,30,30,29,30,29,30,30],[2042,31,32,31,32,31,30,30,30,29,29,30,31],[2043,31,31,31,32,31,31,29,30,30,29,30,30],[2044,31,31,32,31,31,31,30,29,30,29,30,30],[2045,31,32,31,32,31,30,30,29,30,29,30,30],[2046,31,32,31,32,31,30,30,30,29,29,30,31],[2047,31,31,31,32,31,31,30,29,30,29,30,30],[2048,31,31,32,31,31,31,30,29,30,29,30,30],[2049,31,32,31,32,31,30,30,30,29,29,30,30],[2050,31,32,31,32,31,30,30,30,29,30,29,31],[2051,31,31,31,32,31,31,30,29,30,29,30,30],[2052,31,31,32,31,31,31,30,29,30,29,30,30],[2053,31,32,31,32,31,30,30,30,29,29,30,30],[2054,31,32,31,32,31,30,30,30,29,30,29,31],[2055,31,31,32,31,31,31,30,29,30,29,30,30],[2056,31,31,32,31,32,30,30,29,30,29,30,30],[2057,31,32,31,32,31,30,30,30,29,29,30,31],[2058,30,32,31,32,31,30,30,30,29,30,29,31],[2059,31,31,32,31,31,31,30,29,30,29,30,30],[2060,31,31,32,32,31,30,30,29,30,29,30,30],[2061,31,32,31,32,31,30,30,30,29,29,30,31],[2062,30,32,31,32,31,31,29,30,29,30,29,31],[2063,31,31,32,31,31,31,30,29,30,29,30,30],[2064,31,31,32,32,31,30,30,29,30,29,30,30],[2065,31,32,31,32,31,30,30,30,29,29,30,31],[2066,31,31,31,32,31,31,29,30,30,29,29,31],[2067,31,31,32,31,31,31,30,29,30,29,30,30],[2068,31,31,32,32,31,30,30,29,30,29,30,30],[2069,31,32,31,32,31,30,30,30,29,29,30,31],[2070,31,31,31,32,31,31,29,30,30,29,30,30],[2071,31,31,32,31,31,31,30,29,30,29,30,30],[2072,31,32,31,32,31,30,30,29,30,29,30,30],[2073,31,32,31,32,31,30,30,30,29,29,30,31],[2074,31,31,31,32,31,31,30,29,30,29,30,30],[2075,31,31,32,31,31,31,30,29,30,29,30,30],[2076,31,32,31,32,31,30,30,30,29,29,30,30],[2077,31,32,31,32,31,30,30,30,29,30,29,31],[2078,31,31,31,32,31,31,30,29,30,29,30,30],[2079,31,31,32,31,31,31,30,29,30,29,30,30],[2080,31,32,31,32,31,30,30,30,29,29,30,30],[2081,31,32,31,32,31,30,30,30,29,30,29,31],[2082,31,31,32,31,31,31,30,29,30,29,30,30],[2083,31,31,32,31,31,30,30,30,29,30,30,30],[2084,31,31,32,31,31,30,30,30,29,30,30,30],[2085,31,32,31,32,30,31,30,30,29,30,30,30],[2086,30,32,31,32,31,30,30,30,29,30,30,30],[2087,31,31,32,31,31,31,30,30,29,30,30,30],[2088,30,31,32,32,30,31,30,30,29,30,30,30],[2089,30,32,31,32,31,30,30,30,29,30,30,30],[2090,30,32,31,32,31,30,30,30,29,30,30,30],[2091,31,31,32,31,31,31,30,30,29,30,30,30],[2092,30,31,32,32,31,30,30,30,29,30,30,30],[2093,30,32,31,32,31,30,30,30,29,30,30,30],[2094,31,31,32,31,31,30,30,30,29,30,30,30],[2095,31,31,32,31,31,31,30,29,30,30,30,30],[2096,30,31,32,32,31,30,30,29,30,29,30,30],[2097,31,32,31,32,31,30,30,30,29,30,30,30],[2098,31,31,32,32,31,30,30,29,30,29,30,31],[2099,31,32,31,32,31,29,30,30,29,30,30,31]]}getDayOfWeek(l){return{1:"आईतवार",2:"सोमबार",3:"मंगलवार",4:"बुधबार",5:"बिहीबार",6:"शुक्रबार",7:"शनिबार"}[l]}getNepaliMonth(l){return["","बैशाख","जेष्ठ","असार","श्रावण","भाद्र","आश्विन","कार्तिक","मंसिर","पुष","माघ","फाल्गुन","चैत्र"][l]}isLeapYear(l){return l%100===0?l%400===0:l%4===0}getNepaliMonth(l){return["","बैशाख","जेष्ठ","असार","श्रावण","भाद्र","आश्विन","कार्तिक","मंसिर","पुष","माघ","फाल्गुन","चैत्र"][l]}convertToNepaliNumber(l){const d=["०","१","२","३","४","५","६","७","८","९"];return String(l).split("").map(y=>d[y]??y).join("")}engToNep(l,d,y){const c=[31,28,31,30,31,30,31,31,30,31,30,31],p=[31,29,31,30,31,30,31,31,30,31,30,31];let v=1944,n=2e3,t=9,h=16,m=6,s=0;for(let f=0;f<l-v;f++){const B=v+f;s+=this.isLeapYear(B)?p.reduce((w,E)=>w+E):c.reduce((w,E)=>w+E)}for(let f=0;f<d-1;f++)s+=this.isLeapYear(l)?p[f]:c[f];s+=y;let g=0,N=t,k=t,V=n,x=h;for(;s>0;){const f=this.bs[g][N];x++,m++,x>f&&(k++,x=1,N++),m>7&&(m=1),k>12&&(V++,k=1),N>12&&(N=1,g++),s--}return{year:V,month:k,date:x,num_day:m}}getFirstDayOfMonth(l,d){let y=1944,c=1,p=1,v=2e3,n=9,t=16,h=6;for(;v<l||v===l&&n<d||v===l&&n===d&&t<1;){p++;const m=this.isLeapYear(y)?[31,29,31,30,31,30,31,31,30,31,30,31]:[31,28,31,30,31,30,31,31,30,31,30,31];p>m[c-1]&&(p=1,c++,c>12&&(c=1,y++));const s=this.bs.find(g=>g[0]===v);t++,t>s[n]&&(t=1,n++,n>12&&(n=1,v++)),h++,h>7&&(h=1)}return h}}const C={class:"relative w-full np-nepali-calendar"},L=["value","placeholder"],F={key:0,class:"np-absolute np-bg-white np-border np-shadow np-rounded np-p-2 np-mt-1 np-w-64 np-z-50"},T={class:"np-flex np-items-center np-gap-2 np-mb-1 np-border-b border-gray-100 np-pb-1.5"},j={class:"np-flex np-items-center np-gap-1 np-w-1/2"},O=["value"],P={class:"np-flex np-items-center np-justify-between np-w-1/2"},$={class:"np-flex-1 np-flex np-justify-center"},z=["value"],I={class:"np-grid np-grid-cols-7 np-text-center np-font-semibold np-text-[11px]"},Y={class:"np-grid np-grid-cols-7 np-gap-0.5 np-mt-0.5"},U=["onClick"],S={__name:"NepaliDatePicker",props:{modelValue:String,placeholder:{type:String,default:"Select a date"},todayValue:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(_,{emit:l}){const d=_,y=l,c=new M,p=e.ref(!1),v=["आई","सोम","मंगल","बुध","बिही","शुक्र","शनि"],n=e.ref(null),t=e.ref(null),h=e.ref([]),m=e.ref(null),s=e.ref({year:0,month:0,day:0}),g=(o,r,a)=>`${o}-${String(r).padStart(2,"0")}-${String(a).padStart(2,"0")}`;function N(){const o=c.bs.find(u=>u[0]===Number(n.value));if(!o)return;const r=o[Number(t.value)];if(!r)return;const b=c.getFirstDayOfMonth(Number(n.value),Number(t.value))-1,i=[];for(let u=0;u<b;u++)i.push(null);for(let u=1;u<=r;u++)i.push(u);h.value=[];for(let u=0;u<i.length;u+=7){const D=i.slice(u,u+7);for(;D.length<7;)D.push(null);h.value.push(D)}}function k(o){if(!o)return;const r=g(n.value,t.value,o);m.value=r,y("update:modelValue",r),p.value=!1}function V(){t.value===1?(t.value=12,n.value--):t.value--}function x(){t.value===12?(t.value=1,n.value++):t.value++}function f(o){return o&&s.value.year===n.value&&s.value.month===t.value&&s.value.day===o}function B(o){return o?m.value===g(n.value,t.value,o):!1}function w(o){o.target.closest(".np-nepali-calendar")||(p.value=!1)}function E(){window.dispatchEvent(new CustomEvent("close-all-calendars")),p.value=!p.value}return e.onMounted(()=>{const o=new Date,r=c.engToNep(o.getFullYear(),o.getMonth()+1,o.getDate());if(s.value={year:r.year,month:r.month,day:r.date},d.modelValue){const[a,b,i]=d.modelValue.split("-");n.value=Number(a),t.value=Number(b),m.value=g(n.value,t.value,Number(i))}else n.value=s.value.year,t.value=s.value.month,d.todayValue&&(m.value=g(s.value.year,s.value.month,s.value.day));N(),document.addEventListener("click",w),window.addEventListener("close-all-calendars",()=>{p.value=!1})}),e.watch([n,t],N),(o,r)=>(e.openBlock(),e.createElementBlock("div",C,[e.createElementVNode("input",{type:"text",readonly:"",value:m.value,onClick:E,placeholder:_.placeholder,class:"np-w-full np-rounded-md np-border np-border-gray-300 np-px-2 np-py-1.5 np-text-sm np-cursor-pointer focus:np-outline-none focus:np-ring-1 focus:np-ring-blue-300 focus:np-border-blue-300"},null,8,L),p.value?(e.openBlock(),e.createElementBlock("div",F,[e.createElementVNode("div",T,[e.createElementVNode("div",j,[r[2]||(r[2]=e.createElementVNode("span",{class:"np-text-[10px] np-font-semibold np-text-red-600"},"वि.सं.",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":r[0]||(r[0]=a=>n.value=a),class:"np-font-semibold np-text-xs np-w-full"},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(150,a=>e.createElementVNode("option",{key:a,value:1975+a},e.toDisplayString(e.unref(c).convertToNepaliNumber(1975+a)),9,O)),64))],512),[[e.vModelSelect,n.value]])]),e.createElementVNode("div",P,[e.createElementVNode("span",{onClick:V,class:"np-cursor-pointer np-text-sm"},"«"),e.createElementVNode("div",$,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":r[1]||(r[1]=a=>t.value=a),class:"np-text-xs np-text-center np-w-[60%]"},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(12,a=>e.createElementVNode("option",{key:a,value:a},e.toDisplayString(e.unref(c).getNepaliMonth(a)),9,z)),64))],512),[[e.vModelSelect,t.value]])]),e.createElementVNode("span",{onClick:x,class:"np-cursor-pointer np-text-sm"},"»")])]),e.createElementVNode("div",I,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(v,(a,b)=>e.createElementVNode("div",{key:b,class:e.normalizeClass(b===6?"np-text-red-600":"")},e.toDisplayString(a),3)),64))]),e.createElementVNode("div",Y,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,(a,b)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:b},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a,(i,u)=>(e.openBlock(),e.createElementBlock("div",{key:u,onClick:D=>k(i),class:e.normalizeClass(["np-py-1.5 np-text-[11px] np-text-center np-rounded np-select-none np-cursor-pointer",[!i&&"np-bg-gray-50/50 np-text-gray-200 np-cursor-default",u===6&&i&&"np-text-red-600",f(i)&&"np-bg-blue-200 text-blue-600 np-font-bold",B(i)&&"np-bg-blue-600 np-text-white"]])},e.toDisplayString(i?e.unref(c).convertToNepaliNumber(i):""),11,U))),128))],64))),128))])])):e.createCommentVNode("",!0)]))}},q={install(_){_.component("NepaliDatePicker",S)}};exports.NepaliDatePicker=S;exports.default=q;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
::-webkit-scrollbar{width:3px}::-webkit-scrollbar-thumb{background:transparent;transition:background .2s}:hover::-webkit-scrollbar-thumb{background:#cbd5e1}select:focus{outline:none!important;box-shadow:none!important}select{appearance:none;-webkit-appearance:none;-moz-appearance:none;background-image:none}
|
|
1
|
+
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.np-absolute{position:absolute}.np-z-50{z-index:50}.np-mb-1{margin-bottom:.25rem}.np-mt-0\.5{margin-top:.125rem}.np-mt-1{margin-top:.25rem}.np-flex{display:flex}.np-grid{display:grid}.np-w-1\/2{width:50%}.np-w-64{width:16rem}.np-w-\[60\%\]{width:60%}.np-w-full{width:100%}.np-flex-1{flex:1 1 0%}.np-cursor-default{cursor:default}.np-cursor-pointer{cursor:pointer}.np-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.np-grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.np-items-center{align-items:center}.np-justify-center{justify-content:center}.np-justify-between{justify-content:space-between}.np-gap-0\.5{gap:.125rem}.np-gap-1{gap:.25rem}.np-gap-2{gap:.5rem}.np-rounded{border-radius:.25rem}.np-rounded-md{border-radius:.375rem}.np-border{border-width:1px}.np-border-b{border-bottom-width:1px}.np-border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.np-bg-blue-200{--tw-bg-opacity: 1;background-color:rgb(191 219 254 / var(--tw-bg-opacity, 1))}.np-bg-blue-600{--tw-bg-opacity: 1;background-color:rgb(37 99 235 / var(--tw-bg-opacity, 1))}.np-bg-gray-50\/50{background-color:#f9fafb80}.np-bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.np-p-2{padding:.5rem}.np-px-2{padding-left:.5rem;padding-right:.5rem}.np-py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.np-pb-1\.5{padding-bottom:.375rem}.np-text-center{text-align:center}.np-text-\[10px\]{font-size:10px}.np-text-\[11px\]{font-size:11px}.np-text-sm{font-size:.875rem;line-height:1.25rem}.np-text-xs{font-size:.75rem;line-height:1rem}.np-font-bold{font-weight:700}.np-font-semibold{font-weight:600}.np-text-gray-200{--tw-text-opacity: 1;color:rgb(229 231 235 / var(--tw-text-opacity, 1))}.np-text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.np-text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.np-shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}::-webkit-scrollbar{width:3px}::-webkit-scrollbar-thumb{background:transparent;-webkit-transition:background .2s;transition:background .2s}:hover::-webkit-scrollbar-thumb{background:#cbd5e1}select:focus{outline:none!important;box-shadow:none!important}select{appearance:none;-webkit-appearance:none;-moz-appearance:none;background-image:none}.focus\:np-border-blue-300:focus{--tw-border-opacity: 1;border-color:rgb(147 197 253 / var(--tw-border-opacity, 1))}.focus\:np-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:np-ring-1:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:np-ring-blue-300:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(147 197 253 / var(--tw-ring-opacity, 1))}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
class
|
|
1
|
+
import { ref as D, onMounted as P, watch as Y, createElementBlock as b, openBlock as x, createElementVNode as u, createCommentVNode as z, withDirectives as O, Fragment as S, renderList as L, toDisplayString as j, unref as F, vModelSelect as $, normalizeClass as I } from "vue";
|
|
2
|
+
class U {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.bs = [
|
|
5
5
|
[2e3, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
|
|
@@ -102,23 +102,10 @@ class j {
|
|
|
102
102
|
[2097, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
|
|
103
103
|
[2098, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 31],
|
|
104
104
|
[2099, 31, 32, 31, 32, 31, 29, 30, 30, 29, 30, 30, 31]
|
|
105
|
-
]
|
|
106
|
-
year: 0,
|
|
107
|
-
month: 0,
|
|
108
|
-
date: 0,
|
|
109
|
-
day: "",
|
|
110
|
-
nmonth: "",
|
|
111
|
-
num_day: 0
|
|
112
|
-
}, this.eng_date = {
|
|
113
|
-
year: 0,
|
|
114
|
-
month: 0,
|
|
115
|
-
date: 0,
|
|
116
|
-
day: "",
|
|
117
|
-
emonth: "",
|
|
118
|
-
num_day: 0
|
|
119
|
-
};
|
|
105
|
+
];
|
|
120
106
|
}
|
|
121
|
-
|
|
107
|
+
/* ---------- Helpers ---------- */
|
|
108
|
+
getDayOfWeek(n) {
|
|
122
109
|
return {
|
|
123
110
|
1: "आईतवार",
|
|
124
111
|
2: "सोमबार",
|
|
@@ -127,94 +114,90 @@ class j {
|
|
|
127
114
|
5: "बिहीबार",
|
|
128
115
|
6: "शुक्रबार",
|
|
129
116
|
7: "शनिबार"
|
|
130
|
-
}[
|
|
117
|
+
}[n];
|
|
131
118
|
}
|
|
132
|
-
|
|
133
|
-
return
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
119
|
+
getNepaliMonth(n) {
|
|
120
|
+
return [
|
|
121
|
+
"",
|
|
122
|
+
"बैशाख",
|
|
123
|
+
"जेष्ठ",
|
|
124
|
+
"असार",
|
|
125
|
+
"श्रावण",
|
|
126
|
+
"भाद्र",
|
|
127
|
+
"आश्विन",
|
|
128
|
+
"कार्तिक",
|
|
129
|
+
"मंसिर",
|
|
130
|
+
"पुष",
|
|
131
|
+
"माघ",
|
|
132
|
+
"फाल्गुन",
|
|
133
|
+
"चैत्र"
|
|
134
|
+
][n];
|
|
147
135
|
}
|
|
148
|
-
|
|
149
|
-
return
|
|
150
|
-
1: "बैशाख",
|
|
151
|
-
2: "जेष्ठ",
|
|
152
|
-
3: "असार",
|
|
153
|
-
4: "श्रावण",
|
|
154
|
-
5: "भाद्र",
|
|
155
|
-
6: "आश्विन",
|
|
156
|
-
7: "कार्तिक",
|
|
157
|
-
8: "मंसिर",
|
|
158
|
-
9: "पुष",
|
|
159
|
-
10: "माघ",
|
|
160
|
-
11: "फाल्गुन",
|
|
161
|
-
12: "चैत्र"
|
|
162
|
-
}[l];
|
|
136
|
+
isLeapYear(n) {
|
|
137
|
+
return n % 100 === 0 ? n % 400 === 0 : n % 4 === 0;
|
|
163
138
|
}
|
|
164
|
-
|
|
165
|
-
return
|
|
139
|
+
getNepaliMonth(n) {
|
|
140
|
+
return [
|
|
141
|
+
"",
|
|
142
|
+
"बैशाख",
|
|
143
|
+
"जेष्ठ",
|
|
144
|
+
"असार",
|
|
145
|
+
"श्रावण",
|
|
146
|
+
"भाद्र",
|
|
147
|
+
"आश्विन",
|
|
148
|
+
"कार्तिक",
|
|
149
|
+
"मंसिर",
|
|
150
|
+
"पुष",
|
|
151
|
+
"माघ",
|
|
152
|
+
"फाल्गुन",
|
|
153
|
+
"चैत्र"
|
|
154
|
+
][n];
|
|
166
155
|
}
|
|
167
|
-
convertToNepaliNumber(
|
|
156
|
+
convertToNepaliNumber(n) {
|
|
168
157
|
const d = ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"];
|
|
169
|
-
return String(
|
|
158
|
+
return String(n).split("").map((y) => d[y] ?? y).join("");
|
|
170
159
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
let f =
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
for (let p = 1; p < d; p++)
|
|
179
|
-
m += this.isLeapYear(l) ? u[p] : c[p];
|
|
180
|
-
m += v - 1;
|
|
181
|
-
let T = 1;
|
|
182
|
-
for (i = D; m > 0; ) {
|
|
183
|
-
let p = this.bs[T][x];
|
|
184
|
-
i++, h++, i > p && (i = 1, _++, x++), _ > 12 && (_ = 1, S++), x > 12 && (x = 1, T++), h > 7 && (h = 1), m--;
|
|
160
|
+
/* ---------- CORE: eng → nep (EXACT PHP PORT) ---------- */
|
|
161
|
+
engToNep(n, d, y) {
|
|
162
|
+
const i = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], c = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
163
|
+
let m = 1944, t = 2e3, e = 9, h = 16, v = 6, s = 0;
|
|
164
|
+
for (let f = 0; f < n - m; f++) {
|
|
165
|
+
const B = m + f;
|
|
166
|
+
s += this.isLeapYear(B) ? c.reduce((M, V) => M + V) : i.reduce((M, V) => M + V);
|
|
185
167
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
168
|
+
for (let f = 0; f < d - 1; f++)
|
|
169
|
+
s += this.isLeapYear(n) ? c[f] : i[f];
|
|
170
|
+
s += y;
|
|
171
|
+
let g = 0, w = e, N = e, T = t, k = h;
|
|
172
|
+
for (; s > 0; ) {
|
|
173
|
+
const f = this.bs[g][w];
|
|
174
|
+
k++, v++, k > f && (N++, k = 1, w++), v > 7 && (v = 1), N > 12 && (T++, N = 1), w > 12 && (w = 1, g++), s--;
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
year: T,
|
|
178
|
+
month: N,
|
|
179
|
+
date: k,
|
|
180
|
+
num_day: v
|
|
181
|
+
// 1–7 (Sunday–Saturday)
|
|
182
|
+
};
|
|
198
183
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
return null;
|
|
184
|
+
/* ---------- REQUIRED FOR CALENDAR ---------- */
|
|
185
|
+
getFirstDayOfMonth(n, d) {
|
|
186
|
+
let y = 1944, i = 1, c = 1, m = 2e3, t = 9, e = 16, h = 6;
|
|
187
|
+
for (; m < n || m === n && t < d || m === n && t === d && e < 1; ) {
|
|
188
|
+
c++;
|
|
189
|
+
const v = this.isLeapYear(y) ? [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] : [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
190
|
+
c > v[i - 1] && (c = 1, i++, i > 12 && (i = 1, y++));
|
|
191
|
+
const s = this.bs.find((g) => g[0] === m);
|
|
192
|
+
e++, e > s[t] && (e = 1, t++, t > 12 && (t = 1, m++)), h++, h > 7 && (h = 1);
|
|
193
|
+
}
|
|
194
|
+
return h;
|
|
212
195
|
}
|
|
213
196
|
}
|
|
214
|
-
const
|
|
197
|
+
const W = { class: "relative w-full np-nepali-calendar" }, q = ["value", "placeholder"], A = {
|
|
215
198
|
key: 0,
|
|
216
|
-
class: "absolute bg-white border shadow rounded p-
|
|
217
|
-
},
|
|
199
|
+
class: "np-absolute np-bg-white np-border np-shadow np-rounded np-p-2 np-mt-1 np-w-64 np-z-50"
|
|
200
|
+
}, G = { class: "np-flex np-items-center np-gap-2 np-mb-1 np-border-b border-gray-100 np-pb-1.5" }, H = { class: "np-flex np-items-center np-gap-1 np-w-1/2" }, J = ["value"], K = { class: "np-flex np-items-center np-justify-between np-w-1/2" }, Q = { class: "np-flex-1 np-flex np-justify-center" }, R = ["value"], X = { class: "np-grid np-grid-cols-7 np-text-center np-font-semibold np-text-[11px]" }, Z = { class: "np-grid np-grid-cols-7 np-gap-0.5 np-mt-0.5" }, e3 = ["onClick"], t3 = {
|
|
218
201
|
__name: "NepaliDatePicker",
|
|
219
202
|
props: {
|
|
220
203
|
modelValue: String,
|
|
@@ -228,137 +211,142 @@ const J = { class: "relative w-full nepali-calendar" }, z = ["value", "placehold
|
|
|
228
211
|
}
|
|
229
212
|
},
|
|
230
213
|
emits: ["update:modelValue"],
|
|
231
|
-
setup(
|
|
232
|
-
const d =
|
|
233
|
-
function
|
|
234
|
-
const
|
|
235
|
-
if (!
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
for (let
|
|
214
|
+
setup(C, { emit: n }) {
|
|
215
|
+
const d = C, y = n, i = new U(), c = D(!1), m = ["आई", "सोम", "मंगल", "बुध", "बिही", "शुक्र", "शनि"], t = D(null), e = D(null), h = D([]), v = D(null), s = D({ year: 0, month: 0, day: 0 }), g = (l, o, a) => `${l}-${String(o).padStart(2, "0")}-${String(a).padStart(2, "0")}`;
|
|
216
|
+
function w() {
|
|
217
|
+
const l = i.bs.find((r) => r[0] === Number(t.value));
|
|
218
|
+
if (!l) return;
|
|
219
|
+
const o = l[Number(e.value)];
|
|
220
|
+
if (!o) return;
|
|
221
|
+
const _ = i.getFirstDayOfMonth(Number(t.value), Number(e.value)) - 1, p = [];
|
|
222
|
+
for (let r = 0; r < _; r++) p.push(null);
|
|
223
|
+
for (let r = 1; r <= o; r++) p.push(r);
|
|
224
|
+
h.value = [];
|
|
225
|
+
for (let r = 0; r < p.length; r += 7) {
|
|
226
|
+
const E = p.slice(r, r + 7);
|
|
227
|
+
for (; E.length < 7; ) E.push(null);
|
|
228
|
+
h.value.push(E);
|
|
229
|
+
}
|
|
241
230
|
}
|
|
242
|
-
function
|
|
243
|
-
if (!
|
|
244
|
-
const
|
|
245
|
-
|
|
231
|
+
function N(l) {
|
|
232
|
+
if (!l) return;
|
|
233
|
+
const o = g(t.value, e.value, l);
|
|
234
|
+
v.value = o, y("update:modelValue", o), c.value = !1;
|
|
246
235
|
}
|
|
247
|
-
function
|
|
248
|
-
|
|
236
|
+
function T() {
|
|
237
|
+
e.value === 1 ? (e.value = 12, t.value--) : e.value--;
|
|
249
238
|
}
|
|
250
|
-
function
|
|
251
|
-
|
|
239
|
+
function k() {
|
|
240
|
+
e.value === 12 ? (e.value = 1, t.value++) : e.value++;
|
|
252
241
|
}
|
|
253
|
-
function
|
|
254
|
-
|
|
242
|
+
function f(l) {
|
|
243
|
+
return l && s.value.year === t.value && s.value.month === e.value && s.value.day === l;
|
|
255
244
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
day: r.date
|
|
262
|
-
}, d.modelValue) {
|
|
263
|
-
const [t, o, y] = d.modelValue.split("-");
|
|
264
|
-
e.value = parseInt(t), n.value = parseInt(o), m.value = h(e.value, n.value, parseInt(y));
|
|
265
|
-
} else
|
|
266
|
-
e.value = i.value.year, n.value = i.value.month, d.todayValue && (m.value = h(
|
|
267
|
-
i.value.year,
|
|
268
|
-
i.value.month,
|
|
269
|
-
i.value.day
|
|
270
|
-
));
|
|
271
|
-
S(), document.addEventListener("click", p);
|
|
272
|
-
});
|
|
273
|
-
function M() {
|
|
274
|
-
n.value === 1 ? (n.value = 12, e.value = Number(e.value) - 1) : n.value = Number(n.value) - 1;
|
|
245
|
+
function B(l) {
|
|
246
|
+
return l ? v.value === g(t.value, e.value, l) : !1;
|
|
247
|
+
}
|
|
248
|
+
function M(l) {
|
|
249
|
+
l.target.closest(".np-nepali-calendar") || (c.value = !1);
|
|
275
250
|
}
|
|
276
251
|
function V() {
|
|
277
|
-
|
|
252
|
+
window.dispatchEvent(new CustomEvent("close-all-calendars")), c.value = !c.value;
|
|
278
253
|
}
|
|
279
|
-
return P(
|
|
280
|
-
|
|
254
|
+
return P(() => {
|
|
255
|
+
const l = /* @__PURE__ */ new Date(), o = i.engToNep(l.getFullYear(), l.getMonth() + 1, l.getDate());
|
|
256
|
+
if (s.value = {
|
|
257
|
+
year: o.year,
|
|
258
|
+
month: o.month,
|
|
259
|
+
day: o.date
|
|
260
|
+
}, d.modelValue) {
|
|
261
|
+
const [a, _, p] = d.modelValue.split("-");
|
|
262
|
+
t.value = Number(a), e.value = Number(_), v.value = g(t.value, e.value, Number(p));
|
|
263
|
+
} else
|
|
264
|
+
t.value = s.value.year, e.value = s.value.month, d.todayValue && (v.value = g(
|
|
265
|
+
s.value.year,
|
|
266
|
+
s.value.month,
|
|
267
|
+
s.value.day
|
|
268
|
+
));
|
|
269
|
+
w(), document.addEventListener("click", M), window.addEventListener("close-all-calendars", () => {
|
|
270
|
+
c.value = !1;
|
|
271
|
+
});
|
|
272
|
+
}), Y([t, e], w), (l, o) => (x(), b("div", W, [
|
|
273
|
+
u("input", {
|
|
281
274
|
type: "text",
|
|
282
275
|
readonly: "",
|
|
283
|
-
value:
|
|
284
|
-
onClick:
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}, null, 8,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
276
|
+
value: v.value,
|
|
277
|
+
onClick: V,
|
|
278
|
+
placeholder: C.placeholder,
|
|
279
|
+
class: "np-w-full np-rounded-md np-border np-border-gray-300 np-px-2 np-py-1.5 np-text-sm np-cursor-pointer focus:np-outline-none focus:np-ring-1 focus:np-ring-blue-300 focus:np-border-blue-300"
|
|
280
|
+
}, null, 8, q),
|
|
281
|
+
c.value ? (x(), b("div", A, [
|
|
282
|
+
u("div", G, [
|
|
283
|
+
u("div", H, [
|
|
284
|
+
o[2] || (o[2] = u("span", { class: "np-text-[10px] np-font-semibold np-text-red-600" }, "वि.सं.", -1)),
|
|
285
|
+
O(u("select", {
|
|
286
|
+
"onUpdate:modelValue": o[0] || (o[0] = (a) => t.value = a),
|
|
287
|
+
class: "np-font-semibold np-text-xs np-w-full"
|
|
288
|
+
}, [
|
|
289
|
+
(x(), b(S, null, L(150, (a) => u("option", {
|
|
290
|
+
key: a,
|
|
291
|
+
value: 1975 + a
|
|
292
|
+
}, j(F(i).convertToNepaliNumber(1975 + a)), 9, J)), 64))
|
|
293
|
+
], 512), [
|
|
294
|
+
[$, t.value]
|
|
295
|
+
])
|
|
296
|
+
]),
|
|
297
|
+
u("div", K, [
|
|
298
|
+
u("span", {
|
|
299
|
+
onClick: T,
|
|
300
|
+
class: "np-cursor-pointer np-text-sm"
|
|
301
|
+
}, "«"),
|
|
302
|
+
u("div", Q, [
|
|
303
|
+
O(u("select", {
|
|
304
|
+
"onUpdate:modelValue": o[1] || (o[1] = (a) => e.value = a),
|
|
305
|
+
class: "np-text-xs np-text-center np-w-[60%]"
|
|
296
306
|
}, [
|
|
297
|
-
(
|
|
298
|
-
key:
|
|
299
|
-
value:
|
|
300
|
-
},
|
|
307
|
+
(x(), b(S, null, L(12, (a) => u("option", {
|
|
308
|
+
key: a,
|
|
309
|
+
value: a
|
|
310
|
+
}, j(F(i).getNepaliMonth(a)), 9, R)), 64))
|
|
301
311
|
], 512), [
|
|
302
|
-
[
|
|
312
|
+
[$, e.value]
|
|
303
313
|
])
|
|
304
|
-
])
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
onClick: M,
|
|
310
|
-
class: "px-3 py-1 select-none cursor-pointer"
|
|
311
|
-
}, " « "),
|
|
312
|
-
s("div", Q, [
|
|
313
|
-
Y(s("select", {
|
|
314
|
-
"onUpdate:modelValue": r[2] || (r[2] = (t) => n.value = t),
|
|
315
|
-
class: "appearance-none border-none rounded-lg px-3 py-2 text-sm bg-white"
|
|
316
|
-
}, [
|
|
317
|
-
(b(), g(k, null, C(12, (t) => s("option", {
|
|
318
|
-
key: t,
|
|
319
|
-
value: t
|
|
320
|
-
}, $(E(c).getNepaliMonth(t)), 9, R)), 64))
|
|
321
|
-
], 512), [
|
|
322
|
-
[B, n.value]
|
|
323
|
-
])
|
|
324
|
-
]),
|
|
325
|
-
s("div", {
|
|
326
|
-
onClick: V,
|
|
327
|
-
class: "px-3 py-1 select-none cursor-pointer"
|
|
328
|
-
}, " » ")
|
|
329
|
-
])
|
|
314
|
+
]),
|
|
315
|
+
u("span", {
|
|
316
|
+
onClick: k,
|
|
317
|
+
class: "np-cursor-pointer np-text-sm"
|
|
318
|
+
}, "»")
|
|
330
319
|
])
|
|
331
320
|
]),
|
|
332
|
-
|
|
333
|
-
(
|
|
334
|
-
key:
|
|
335
|
-
class:
|
|
336
|
-
},
|
|
321
|
+
u("div", X, [
|
|
322
|
+
(x(), b(S, null, L(m, (a, _) => u("div", {
|
|
323
|
+
key: _,
|
|
324
|
+
class: I(_ === 6 ? "np-text-red-600" : "")
|
|
325
|
+
}, j(a), 3)), 64))
|
|
337
326
|
]),
|
|
338
|
-
|
|
339
|
-
(
|
|
340
|
-
(
|
|
341
|
-
key:
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
},
|
|
327
|
+
u("div", Z, [
|
|
328
|
+
(x(!0), b(S, null, L(h.value, (a, _) => (x(), b(S, { key: _ }, [
|
|
329
|
+
(x(!0), b(S, null, L(a, (p, r) => (x(), b("div", {
|
|
330
|
+
key: r,
|
|
331
|
+
onClick: (E) => N(p),
|
|
332
|
+
class: I(["np-py-1.5 np-text-[11px] np-text-center np-rounded np-select-none np-cursor-pointer", [
|
|
333
|
+
!p && "np-bg-gray-50/50 np-text-gray-200 np-cursor-default",
|
|
334
|
+
r === 6 && p && "np-text-red-600",
|
|
335
|
+
f(p) && "np-bg-blue-200 text-blue-600 np-font-bold",
|
|
336
|
+
B(p) && "np-bg-blue-600 np-text-white"
|
|
337
|
+
]])
|
|
338
|
+
}, j(p ? F(i).convertToNepaliNumber(p) : ""), 11, e3))), 128))
|
|
350
339
|
], 64))), 128))
|
|
351
340
|
])
|
|
352
|
-
])) :
|
|
341
|
+
])) : z("", !0)
|
|
353
342
|
]));
|
|
354
343
|
}
|
|
355
|
-
},
|
|
356
|
-
install(
|
|
357
|
-
|
|
344
|
+
}, l3 = {
|
|
345
|
+
install(C) {
|
|
346
|
+
C.component("NepaliDatePicker", t3);
|
|
358
347
|
}
|
|
359
348
|
};
|
|
360
349
|
export {
|
|
361
350
|
t3 as NepaliDatePicker,
|
|
362
|
-
|
|
363
|
-
t3 as default
|
|
351
|
+
l3 as default
|
|
364
352
|
};
|
package/package.json
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pr0vin/np-date-picker-vue-tw",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "A Nepali date picker Vue 3 component using Tailwind CSS",
|
|
5
|
+
"author": "Pravin Chaudhary",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/np-date-picker-vue-tw.cjs.js",
|
|
5
9
|
"module": "dist/np-date-picker-vue-tw.es.js",
|
|
6
|
-
"style": "dist/
|
|
10
|
+
"style": "dist/style.css",
|
|
7
11
|
"files": [
|
|
8
12
|
"dist"
|
|
9
13
|
],
|
|
10
14
|
"scripts": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
15
|
+
"dev": "vite",
|
|
16
|
+
"build": "vite build"
|
|
13
17
|
},
|
|
14
|
-
"author": "Pravin Chaudahry",
|
|
15
|
-
"license": "ISC",
|
|
16
|
-
"description": "A Nepali date picker Vue 3 component using Tailwind CSS",
|
|
17
18
|
"peerDependencies": {
|
|
18
|
-
"vue": "^3.
|
|
19
|
+
"vue": "^3.3.0"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"@vitejs/plugin-vue": "^6.0.2",
|
|
22
23
|
"vite": "^7.2.6",
|
|
23
|
-
"
|
|
24
|
-
|
|
24
|
+
"tailwindcss": "^3.4.17",
|
|
25
|
+
"postcss": "^8.4.38",
|
|
26
|
+
"autoprefixer": "^10.4.20"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"vue",
|
|
30
|
+
"vue3",
|
|
31
|
+
"nepali-date-picker",
|
|
32
|
+
"tailwind",
|
|
33
|
+
"datepicker",
|
|
34
|
+
"nepali-calendar"
|
|
35
|
+
]
|
|
25
36
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(y,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(y=typeof globalThis<"u"?globalThis:y||self,e(y.NpDatePickerVueTw={},y.Vue))})(this,(function(y,e){"use strict";class B{constructor(){this.bs=[[2e3,30,32,31,32,31,30,30,30,29,30,29,31],[2001,31,31,32,31,31,31,30,29,30,29,30,30],[2002,31,31,32,32,31,30,30,29,30,29,30,30],[2003,31,32,31,32,31,30,30,30,29,29,30,31],[2004,30,32,31,32,31,30,30,30,29,30,29,31],[2005,31,31,32,31,31,31,30,29,30,29,30,30],[2006,31,31,32,32,31,30,30,29,30,29,30,30],[2007,31,32,31,32,31,30,30,30,29,29,30,31],[2008,31,31,31,32,31,31,29,30,30,29,29,31],[2009,31,31,32,31,31,31,30,29,30,29,30,30],[2010,31,31,32,32,31,30,30,29,30,29,30,30],[2011,31,32,31,32,31,30,30,30,29,29,30,31],[2012,31,31,31,32,31,31,29,30,30,29,30,30],[2013,31,31,32,31,31,31,30,29,30,29,30,30],[2014,31,31,32,32,31,30,30,29,30,29,30,30],[2015,31,32,31,32,31,30,30,30,29,29,30,31],[2016,31,31,31,32,31,31,29,30,30,29,30,30],[2017,31,31,32,31,31,31,30,29,30,29,30,30],[2018,31,32,31,32,31,30,30,29,30,29,30,30],[2019,31,32,31,32,31,30,30,30,29,30,29,31],[2020,31,31,31,32,31,31,30,29,30,29,30,30],[2021,31,31,32,31,31,31,30,29,30,29,30,30],[2022,31,32,31,32,31,30,30,30,29,29,30,30],[2023,31,32,31,32,31,30,30,30,29,30,29,31],[2024,31,31,31,32,31,31,30,29,30,29,30,30],[2025,31,31,32,31,31,31,30,29,30,29,30,30],[2026,31,32,31,32,31,30,30,30,29,29,30,31],[2027,30,32,31,32,31,30,30,30,29,30,29,31],[2028,31,31,32,31,31,31,30,29,30,29,30,30],[2029,31,31,32,31,32,30,30,29,30,29,30,30],[2030,31,32,31,32,31,30,30,30,29,29,30,31],[2031,30,32,31,32,31,30,30,30,29,30,29,31],[2032,31,31,32,31,31,31,30,29,30,29,30,30],[2033,31,31,32,32,31,30,30,29,30,29,30,30],[2034,31,32,31,32,31,30,30,30,29,29,30,31],[2035,30,32,31,32,31,31,29,30,30,29,29,31],[2036,31,31,32,31,31,31,30,29,30,29,30,30],[2037,31,31,32,32,31,30,30,29,30,29,30,30],[2038,31,32,31,32,31,30,30,30,29,29,30,31],[2039,31,31,31,32,31,31,29,30,30,29,30,30],[2040,31,31,32,31,31,31,30,29,30,29,30,30],[2041,31,31,32,32,31,30,30,29,30,29,30,30],[2042,31,32,31,32,31,30,30,30,29,29,30,31],[2043,31,31,31,32,31,31,29,30,30,29,30,30],[2044,31,31,32,31,31,31,30,29,30,29,30,30],[2045,31,32,31,32,31,30,30,29,30,29,30,30],[2046,31,32,31,32,31,30,30,30,29,29,30,31],[2047,31,31,31,32,31,31,30,29,30,29,30,30],[2048,31,31,32,31,31,31,30,29,30,29,30,30],[2049,31,32,31,32,31,30,30,30,29,29,30,30],[2050,31,32,31,32,31,30,30,30,29,30,29,31],[2051,31,31,31,32,31,31,30,29,30,29,30,30],[2052,31,31,32,31,31,31,30,29,30,29,30,30],[2053,31,32,31,32,31,30,30,30,29,29,30,30],[2054,31,32,31,32,31,30,30,30,29,30,29,31],[2055,31,31,32,31,31,31,30,29,30,29,30,30],[2056,31,31,32,31,32,30,30,29,30,29,30,30],[2057,31,32,31,32,31,30,30,30,29,29,30,31],[2058,30,32,31,32,31,30,30,30,29,30,29,31],[2059,31,31,32,31,31,31,30,29,30,29,30,30],[2060,31,31,32,32,31,30,30,29,30,29,30,30],[2061,31,32,31,32,31,30,30,30,29,29,30,31],[2062,30,32,31,32,31,31,29,30,29,30,29,31],[2063,31,31,32,31,31,31,30,29,30,29,30,30],[2064,31,31,32,32,31,30,30,29,30,29,30,30],[2065,31,32,31,32,31,30,30,30,29,29,30,31],[2066,31,31,31,32,31,31,29,30,30,29,29,31],[2067,31,31,32,31,31,31,30,29,30,29,30,30],[2068,31,31,32,32,31,30,30,29,30,29,30,30],[2069,31,32,31,32,31,30,30,30,29,29,30,31],[2070,31,31,31,32,31,31,29,30,30,29,30,30],[2071,31,31,32,31,31,31,30,29,30,29,30,30],[2072,31,32,31,32,31,30,30,29,30,29,30,30],[2073,31,32,31,32,31,30,30,30,29,29,30,31],[2074,31,31,31,32,31,31,30,29,30,29,30,30],[2075,31,31,32,31,31,31,30,29,30,29,30,30],[2076,31,32,31,32,31,30,30,30,29,29,30,30],[2077,31,32,31,32,31,30,30,30,29,30,29,31],[2078,31,31,31,32,31,31,30,29,30,29,30,30],[2079,31,31,32,31,31,31,30,29,30,29,30,30],[2080,31,32,31,32,31,30,30,30,29,29,30,30],[2081,31,32,31,32,31,30,30,30,29,30,29,31],[2082,31,31,32,31,31,31,30,29,30,29,30,30],[2083,31,31,32,31,31,30,30,30,29,30,30,30],[2084,31,31,32,31,31,30,30,30,29,30,30,30],[2085,31,32,31,32,30,31,30,30,29,30,30,30],[2086,30,32,31,32,31,30,30,30,29,30,30,30],[2087,31,31,32,31,31,31,30,30,29,30,30,30],[2088,30,31,32,32,30,31,30,30,29,30,30,30],[2089,30,32,31,32,31,30,30,30,29,30,30,30],[2090,30,32,31,32,31,30,30,30,29,30,30,30],[2091,31,31,32,31,31,31,30,30,29,30,30,30],[2092,30,31,32,32,31,30,30,30,29,30,30,30],[2093,30,32,31,32,31,30,30,30,29,30,30,30],[2094,31,31,32,31,31,30,30,30,29,30,30,30],[2095,31,31,32,31,31,31,30,29,30,30,30,30],[2096,30,31,32,32,31,30,30,29,30,29,30,30],[2097,31,32,31,32,31,30,30,30,29,30,30,30],[2098,31,31,32,32,31,30,30,29,30,29,30,31],[2099,31,32,31,32,31,29,30,30,29,30,30,31]],this.nep_date={year:0,month:0,date:0,day:"",nmonth:"",num_day:0},this.eng_date={year:0,month:0,date:0,day:"",emonth:"",num_day:0}}getDayOfWeek(o){return{1:"आईतवार",2:"सोमबार",3:"मंगलवार",4:"बुधबार",5:"बिहीबार",6:"शुक्रबार",7:"शनिबार"}[o]}getEnglishMonth(o){return{1:"January",2:"February",3:"March",4:"April",5:"May",6:"June",7:"July",8:"August",9:"September",10:"October",11:"November",12:"December"}[o]}getNepaliMonth(o){return{1:"बैशाख",2:"जेष्ठ",3:"असार",4:"श्रावण",5:"भाद्र",6:"आश्विन",7:"कार्तिक",8:"मंसिर",9:"पुष",10:"माघ",11:"फाल्गुन",12:"चैत्र"}[o]}isLeapYear(o){return o%4===0&&o%100!==0||o%400===0}convertToNepaliNumber(o){const c=["०","१","२","३","४","५","६","७","८","९"];return String(o).split("").map(p=>/[0-9]/.test(p)?c[p]:p).join("")}engToNep(o,c,p){if(o<1944||o>2033)throw new Error("Supported only between 1944-2033");const u=[0,31,28,31,30,31,30,31,31,30,31,30,31],i=[0,31,29,31,30,31,30,31,31,30,31,30,31];let g=1944,t=2e3,l=9,E=16,f=0,d=0,h=7,V=t,N=l,k=l;for(let m=g;m<o;m++)f+=this.isLeapYear(m)?i.reduce((v,D)=>v+D,0):u.reduce((v,D)=>v+D,0);for(let m=1;m<c;m++)f+=this.isLeapYear(o)?i[m]:u[m];f+=p-1;let x=1;for(d=E;f>0;){let m=this.bs[x][k];d++,h++,d>m&&(d=1,N++,k++),N>12&&(N=1,V++),k>12&&(k=1,x++),h>7&&(h=1),f--}return this.nep_date={year:V,month:N,date:d,day:this.getDayOfWeek(h),nmonth:this.getNepaliMonth(N),num_day:h},this.nep_date}adToBs(o){const[c,p,u]=o.split("-").map(Number),i=this.engToNep(c,p,u),g=i.year,t=i.month.toString().padStart(2,"0"),l=i.date.toString().padStart(2,"0");return`${g}-${t}-${l}`}getFirstDayOfMonth(o,c){let p=1944;for(let u=p;u<=2100;u++)for(let i=1;i<=12;i++)for(let g=1;g<=31;g++)try{const t=this.engToNep(u,i,g);if(t.year===o&&t.month===c&&t.date===1)return t.num_day}catch{continue}return null}}const M={class:"relative w-full nepali-calendar"},T=["value","placeholder"],C={key:0,class:"absolute bg-white border shadow rounded p-3 mt-2 w-80 z-50"},F={class:"flex items-center gap-3 mb-2 border-b border-gray-100"},L={class:"flex items-center w-36"},P={class:"relative"},$=["value"],O={class:"relative w-full"},Y={class:"flex items-center justify-between"},j={class:"relative"},I=["value"],z={class:"grid grid-cols-7 text-center font-semibold mb-1 text-gray-700 text-sm"},J={class:"grid grid-cols-7 gap-1 text-center"},A=["onClick"],S={__name:"NepaliDatePicker",props:{modelValue:String,placeholder:{type:String,default:"Select a date"},todayValue:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(_,{emit:o}){const c=_,p=o,u=new B,i=e.ref(!1),g=["आईत","सोम","मंगल","बुध","बिही","शुक्र","शनि"],t=e.ref(null),l=e.ref(null),E=e.ref([]),f=e.ref(null),d=e.ref({year:0,month:0,day:0}),h=(a,s,n)=>`${a}-${String(s).padStart(2,"0")}-${String(n).padStart(2,"0")}`;function V(){const a=u.bs.find(r=>r[0]===t.value)?.[l.value];if(!a)return;const s=u.getFirstDayOfMonth(t.value,l.value),n=[];for(let r=1;r<s;r++)n.push(null);for(let r=1;r<=a;r++)n.push(r);E.value=[];for(let r=0;r<n.length;r+=7)E.value.push(n.slice(r,r+7))}function N(a){if(!a)return;const s=h(t.value,l.value,a);f.value=s,p("update:modelValue",s),i.value=!1}function k(a){return a&&d.value.year===t.value&&d.value.month===l.value&&d.value.day===a}function x(a){return a?f.value===h(t.value,l.value,a):!1}function m(a){a.target.closest(".nepali-calendar")||(i.value=!1)}e.onMounted(()=>{const a=new Date,s=u.engToNep(a.getFullYear(),a.getMonth()+1,a.getDate());if(d.value={year:s.year,month:s.month,day:s.date},c.modelValue){const[n,r,b]=c.modelValue.split("-");t.value=parseInt(n),l.value=parseInt(r),f.value=h(t.value,l.value,parseInt(b))}else t.value=d.value.year,l.value=d.value.month,c.todayValue&&(f.value=h(d.value.year,d.value.month,d.value.day));V(),document.addEventListener("click",m)});function v(){l.value===1?(l.value=12,t.value=Number(t.value)-1):l.value=Number(l.value)-1}function D(){l.value===12?(l.value=1,t.value=Number(t.value)+1):l.value=Number(l.value)+1}return e.watch([t,l],V),(a,s)=>(e.openBlock(),e.createElementBlock("div",M,[e.createElementVNode("input",{type:"text",readonly:"",value:f.value,onClick:s[0]||(s[0]=n=>i.value=!i.value),class:"border-gray-300 w-full rounded-md px-3 py-2 cursor-pointer",placeholder:_.placeholder},null,8,T),i.value?(e.openBlock(),e.createElementBlock("div",C,[e.createElementVNode("div",F,[e.createElementVNode("div",L,[s[3]||(s[3]=e.createElementVNode("span",{class:"text-xs font-semibold text-red-600"}," वि.सं.",-1)),e.createElementVNode("div",P,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":s[1]||(s[1]=n=>t.value=n),class:"appearance-none border-none rounded-lg w-full px-3 py-2 text-sm font-bold"},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(150,n=>e.createElementVNode("option",{key:n,value:1975+n},e.toDisplayString(1975+n),9,$)),64))],512),[[e.vModelSelect,t.value]])])]),e.createElementVNode("div",O,[e.createElementVNode("div",Y,[e.createElementVNode("div",{onClick:v,class:"px-3 py-1 select-none cursor-pointer"}," « "),e.createElementVNode("div",j,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":s[2]||(s[2]=n=>l.value=n),class:"appearance-none border-none rounded-lg px-3 py-2 text-sm bg-white"},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(12,n=>e.createElementVNode("option",{key:n,value:n},e.toDisplayString(e.unref(u).getNepaliMonth(n)),9,I)),64))],512),[[e.vModelSelect,l.value]])]),e.createElementVNode("div",{onClick:D,class:"px-3 py-1 select-none cursor-pointer"}," » ")])])]),e.createElementVNode("div",z,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(g,(n,r)=>e.createElementVNode("div",{key:r,class:e.normalizeClass(r===6?"text-red-600":"")},e.toDisplayString(n),3)),64))]),e.createElementVNode("div",J,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.value,(n,r)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:r},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n,(b,w)=>(e.openBlock(),e.createElementBlock("div",{key:w,class:e.normalizeClass(["p-2 border rounded cursor-pointer select-none",[b===null?"bg-gray-100 cursor-default text-gray-400":"",w===6&&b!==null?"text-red-600":"",k(b)?"bg-blue-200 text-blue-800 font-bold":"",x(b)?"bg-blue-600 text-white font-bold":""]]),onClick:W=>N(b)},e.toDisplayString(b?e.unref(u).convertToNepaliNumber(b):""),11,A))),128))],64))),128))])])):e.createCommentVNode("",!0)]))}},U={install(_){_.component("NepaliDatePicker",S)}};y.NepaliDatePicker=S,y.NpDatePickerPlugin=U,y.default=S,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|