@archpublicwebsite/rangepicker 1.0.0
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/LICENSE +21 -0
- package/README.md +340 -0
- package/dist/Rangepicker.vue.d.ts +58 -0
- package/dist/Rangepicker.vue.d.ts.map +1 -0
- package/dist/RangepickerInput.stories.d.ts +14 -0
- package/dist/RangepickerInput.stories.d.ts.map +1 -0
- package/dist/RangepickerInput.stories.js +117 -0
- package/dist/RangepickerInput.vue.d.ts +47 -0
- package/dist/RangepickerInput.vue.d.ts.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/rangepicker.js +986 -0
- package/dist/rangepicker.js.map +1 -0
- package/dist/rangepicker.umd.cjs +2 -0
- package/dist/rangepicker.umd.cjs.map +1 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils/calendar.d.ts +29 -0
- package/dist/utils/calendar.d.ts.map +1 -0
- package/dist/utils/calendar.js +88 -0
- package/dist/utils/date.d.ts +11 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +31 -0
- package/dist/utils/position.d.ts +8 -0
- package/dist/utils/position.d.ts.map +1 -0
- package/dist/utils/position.js +35 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Archipelago International Hotels and Resorts
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
# rangepicker
|
|
2
|
+
|
|
3
|
+
Custom, lightweight date range picker component for Vue 3.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- đ¨ **Vue 3 Composition API** - Built with modern Vue 3 and TypeScript
|
|
8
|
+
- đĻ **Framework Agnostic CSS** - Pre-compiled CSS, no Tailwind required in your project
|
|
9
|
+
- đ
**Dayjs Integration** - Powerful date manipulation without moment.js bloat
|
|
10
|
+
- đ¨ **Themeable** - Easy color customization via CSS variables
|
|
11
|
+
- đą **Mobile Responsive** - Touch-friendly with bottom sheet on mobile
|
|
12
|
+
- đ¯ **Smart Positioning** - Auto-adjusts based on available viewport space
|
|
13
|
+
- âŋ **Accessible** - Keyboard navigation and screen reader support
|
|
14
|
+
- đ **SSR Compatible** - Works perfectly with Nuxt 3
|
|
15
|
+
- đĒļ **Lightweight** - No external datepicker dependencies
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
From the monorepo root:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add rangepicker --filter @pba/nuxt
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or install dependencies in the rangepicker package:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
cd packages/rangepicker
|
|
29
|
+
pnpm install
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
```vue
|
|
35
|
+
<script setup>
|
|
36
|
+
import { ref } from 'vue'
|
|
37
|
+
import { RangepickerInput } from '@archi-ui/rangepicker'
|
|
38
|
+
import '@archi-ui/rangepicker/style.css' // Pre-compiled CSS - no Tailwind needed!
|
|
39
|
+
|
|
40
|
+
const dates = ref('')
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<RangepickerInput
|
|
45
|
+
v-model="dates"
|
|
46
|
+
primary-color="#3b82f6"
|
|
47
|
+
placeholder="Check in / Check out"
|
|
48
|
+
/>
|
|
49
|
+
</template>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**No Tailwind CSS required!** The package includes pre-compiled CSS that works with any framework.
|
|
53
|
+
|
|
54
|
+
## Color Customization
|
|
55
|
+
|
|
56
|
+
Customize colors easily by passing HEX color values as props. Each rangepicker instance can have its own color scheme:
|
|
57
|
+
|
|
58
|
+
```vue
|
|
59
|
+
<script setup>
|
|
60
|
+
import { ref } from 'vue'
|
|
61
|
+
import { RangepickerInput } from '@archi-ui/rangepicker'
|
|
62
|
+
|
|
63
|
+
const dates1 = ref('')
|
|
64
|
+
const dates2 = ref('')
|
|
65
|
+
const dates3 = ref('')
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<template>
|
|
69
|
+
<!-- Blue theme -->
|
|
70
|
+
<RangepickerInput
|
|
71
|
+
v-model="dates1"
|
|
72
|
+
primary-color="#3b82f6"
|
|
73
|
+
secondary-color="#60a5fa"
|
|
74
|
+
placeholder="Blue theme"
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
<!-- Purple theme -->
|
|
78
|
+
<RangepickerInput
|
|
79
|
+
v-model="dates2"
|
|
80
|
+
primary-color="#8b5cf6"
|
|
81
|
+
secondary-color="#a78bfa"
|
|
82
|
+
placeholder="Purple theme"
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
<!-- Red theme -->
|
|
86
|
+
<RangepickerInput
|
|
87
|
+
v-model="dates3"
|
|
88
|
+
primary-color="#ef4444"
|
|
89
|
+
secondary-color="#f87171"
|
|
90
|
+
placeholder="Red theme"
|
|
91
|
+
/>
|
|
92
|
+
</template>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Color Props
|
|
96
|
+
|
|
97
|
+
| Prop | Type | Default | Description |
|
|
98
|
+
|------|------|---------|-------------|
|
|
99
|
+
| `primary-color` | `string` | - | Main color for selected dates and buttons (HEX format, e.g., `#3b82f6`) |
|
|
100
|
+
| `secondary-color` | `string` | - | Color for hover states and secondary elements (HEX format, optional) |
|
|
101
|
+
|
|
102
|
+
**Features:**
|
|
103
|
+
- â
**Scoped per instance** - Multiple pickers can have different colors simultaneously
|
|
104
|
+
- â
**No global state** - Colors don't conflict between instances
|
|
105
|
+
- â
**HEX format** - Standard 3 or 6 digit HEX colors (e.g., `#3b82f6`, `#fff`)
|
|
106
|
+
- â
**Auto-conversion** - Automatically converts HEX to RGB for CSS variables
|
|
107
|
+
- â
**Optional** - Falls back to default theme if not provided
|
|
108
|
+
|
|
109
|
+
## Customization
|
|
110
|
+
|
|
111
|
+
Customize colors using CSS variables:
|
|
112
|
+
|
|
113
|
+
```css
|
|
114
|
+
/* Your global styles */
|
|
115
|
+
:root {
|
|
116
|
+
--color-primary: 59 130 246; /* blue-500 */
|
|
117
|
+
--color-secondary: 148 163 184; /* slate-400 */
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**đ See [CUSTOMIZATION.md](./CUSTOMIZATION.md) for complete theming guide**
|
|
122
|
+
|
|
123
|
+
## Usage
|
|
124
|
+
|
|
125
|
+
### Basic Usage
|
|
126
|
+
|
|
127
|
+
```vue
|
|
128
|
+
<template>
|
|
129
|
+
<div>
|
|
130
|
+
<input
|
|
131
|
+
ref="triggerRef"
|
|
132
|
+
type="text"
|
|
133
|
+
:value="dateRangeText"
|
|
134
|
+
placeholder="Select dates"
|
|
135
|
+
readonly
|
|
136
|
+
@click="isOpen = true"
|
|
137
|
+
/>
|
|
138
|
+
|
|
139
|
+
<Rangepicker
|
|
140
|
+
v-model="dateRange"
|
|
141
|
+
v-model:is-open="isOpen"
|
|
142
|
+
:trigger-element="triggerRef"
|
|
143
|
+
:number-of-months="2"
|
|
144
|
+
:format="'DD MMM YYYY'"
|
|
145
|
+
/>
|
|
146
|
+
</div>
|
|
147
|
+
</template>
|
|
148
|
+
|
|
149
|
+
<script setup lang="ts">
|
|
150
|
+
import { ref, computed } from 'vue'
|
|
151
|
+
import { Rangepicker } from 'rangepicker'
|
|
152
|
+
import 'rangepicker/style.css'
|
|
153
|
+
|
|
154
|
+
const triggerRef = ref<HTMLElement | null>(null)
|
|
155
|
+
const isOpen = ref(false)
|
|
156
|
+
const dateRange = ref({ startDate: '', endDate: '' })
|
|
157
|
+
|
|
158
|
+
const dateRangeText = computed(() => {
|
|
159
|
+
if (!dateRange.value.startDate || !dateRange.value.endDate) return ''
|
|
160
|
+
return `${dateRange.value.startDate} - ${dateRange.value.endDate}`
|
|
161
|
+
})
|
|
162
|
+
</script>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Using the Composable
|
|
166
|
+
|
|
167
|
+
```vue
|
|
168
|
+
<script setup lang="ts">
|
|
169
|
+
import { ref } from 'vue'
|
|
170
|
+
import { Rangepicker, useRangepicker } from 'rangepicker'
|
|
171
|
+
import 'rangepicker/style.css'
|
|
172
|
+
|
|
173
|
+
const triggerRef = ref<HTMLElement | null>(null)
|
|
174
|
+
const { isOpen, dateRange, open, close, toggle } = useRangepicker(triggerRef, {
|
|
175
|
+
numberOfMonths: 2,
|
|
176
|
+
format: 'DD MMM YYYY',
|
|
177
|
+
minDays: 1,
|
|
178
|
+
})
|
|
179
|
+
</script>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Hotel Booking Example
|
|
183
|
+
|
|
184
|
+
```vue
|
|
185
|
+
<template>
|
|
186
|
+
<div>
|
|
187
|
+
<input
|
|
188
|
+
ref="bookingInputRef"
|
|
189
|
+
type="text"
|
|
190
|
+
:value="bookingText"
|
|
191
|
+
placeholder="Check-in - Check-out"
|
|
192
|
+
readonly
|
|
193
|
+
@click="isBookingOpen = true"
|
|
194
|
+
/>
|
|
195
|
+
|
|
196
|
+
<Rangepicker
|
|
197
|
+
v-model="bookingDates"
|
|
198
|
+
v-model:is-open="isBookingOpen"
|
|
199
|
+
:trigger-element="bookingInputRef"
|
|
200
|
+
:number-of-months="2"
|
|
201
|
+
:number-of-columns="2"
|
|
202
|
+
:min-days="1"
|
|
203
|
+
:format="'DD MMM YYYY'"
|
|
204
|
+
:show-tooltip="true"
|
|
205
|
+
:holidays="holidays"
|
|
206
|
+
:min-date="today"
|
|
207
|
+
variant="desktop"
|
|
208
|
+
/>
|
|
209
|
+
</div>
|
|
210
|
+
</template>
|
|
211
|
+
|
|
212
|
+
<script setup lang="ts">
|
|
213
|
+
import { ref, computed } from 'vue'
|
|
214
|
+
import { Rangepicker } from 'rangepicker'
|
|
215
|
+
import 'rangepicker/style.css'
|
|
216
|
+
import dayjs from 'dayjs'
|
|
217
|
+
|
|
218
|
+
const bookingInputRef = ref<HTMLElement | null>(null)
|
|
219
|
+
const isBookingOpen = ref(false)
|
|
220
|
+
const bookingDates = ref({ startDate: '', endDate: '' })
|
|
221
|
+
const today = dayjs().format('YYYY-MM-DD')
|
|
222
|
+
const holidays = ref(['2025-12-25', '2025-01-01'])
|
|
223
|
+
|
|
224
|
+
const bookingText = computed(() => {
|
|
225
|
+
if (!bookingDates.value.startDate || !bookingDates.value.endDate) return ''
|
|
226
|
+
return `${bookingDates.value.startDate} - ${bookingDates.value.endDate}`
|
|
227
|
+
})
|
|
228
|
+
</script>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Props
|
|
232
|
+
|
|
233
|
+
| Prop | Type | Default | Description |
|
|
234
|
+
|------|------|---------|-------------|
|
|
235
|
+
| `modelValue` | `{ startDate?: string \| Date \| Dayjs, endDate?: string \| Date \| Dayjs }` | `{}` | Selected date range |
|
|
236
|
+
| `isOpen` | `boolean` | `false` | Controls picker visibility |
|
|
237
|
+
| `variant` | `'desktop' \| 'mobile'` | `'desktop'` | Display variant |
|
|
238
|
+
| `primaryColor` | `string` | - | Primary color in HEX format (e.g., `#3b82f6`) |
|
|
239
|
+
| `secondaryColor` | `string` | - | Secondary color in HEX format (e.g., `#60a5fa`) |
|
|
240
|
+
| `minDate` | `string \| Date \| Dayjs` | - | Minimum selectable date |
|
|
241
|
+
| `maxDate` | `string \| Date \| Dayjs` | - | Maximum selectable date |
|
|
242
|
+
| `minDays` | `number` | - | Minimum number of days in range |
|
|
243
|
+
| `maxDays` | `number` | - | Maximum number of days in range |
|
|
244
|
+
| `numberOfMonths` | `number` | `2` | Number of months to display |
|
|
245
|
+
| `numberOfColumns` | `number` | `2` | Grid columns for months |
|
|
246
|
+
| `disabledDates` | `(string \| Date)[]` | `[]` | Array of disabled dates |
|
|
247
|
+
| `holidays` | `(string \| Date)[]` | `[]` | Array of holiday dates |
|
|
248
|
+
| `format` | `string` | `'YYYY-MM-DD'` | Date format |
|
|
249
|
+
| `delimiter` | `string` | `' - '` | Delimiter between dates |
|
|
250
|
+
| `placeholder` | `string` | `'Select dates'` | Placeholder text |
|
|
251
|
+
| `label` | `string` | - | Label for the picker |
|
|
252
|
+
| `showTooltip` | `boolean` | `true` | Show night count tooltip |
|
|
253
|
+
| `autoApply` | `boolean` | `false` | Auto-apply selection |
|
|
254
|
+
| `position` | `'auto' \| 'top' \| 'bottom'` | `'auto'` | Positioning strategy |
|
|
255
|
+
| `triggerElement` | `HTMLElement \| null` | - | Trigger element for positioning |
|
|
256
|
+
|
|
257
|
+
## Events
|
|
258
|
+
|
|
259
|
+
| Event | Payload | Description |
|
|
260
|
+
|-------|---------|-------------|
|
|
261
|
+
| `update:modelValue` | `{ startDate: string, endDate: string }` | Emitted when date range changes |
|
|
262
|
+
| `update:isOpen` | `boolean` | Emitted when picker opens/closes |
|
|
263
|
+
| `dateSelected` | `Dayjs` | Emitted when a date is clicked |
|
|
264
|
+
| `rangeSelected` | `{ start: Dayjs, end: Dayjs }` | Emitted when range is complete |
|
|
265
|
+
|
|
266
|
+
## Development
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# Install dependencies
|
|
270
|
+
pnpm install
|
|
271
|
+
|
|
272
|
+
# Start dev server with demo
|
|
273
|
+
pnpm dev
|
|
274
|
+
|
|
275
|
+
# Build package
|
|
276
|
+
pnpm build
|
|
277
|
+
|
|
278
|
+
# Type check
|
|
279
|
+
pnpm type-check
|
|
280
|
+
|
|
281
|
+
# Preview build
|
|
282
|
+
pnpm preview
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Package Structure
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
packages/rangepicker/
|
|
289
|
+
âââ dist/ # Built files
|
|
290
|
+
â âââ rangepicker.js # ES module
|
|
291
|
+
â âââ rangepicker.umd.cjs # UMD module
|
|
292
|
+
â âââ style.css # Compiled styles
|
|
293
|
+
â âââ index.d.ts # TypeScript types
|
|
294
|
+
âââ src/
|
|
295
|
+
â âââ index.ts # Main entry
|
|
296
|
+
â âââ Rangepicker.vue # Component
|
|
297
|
+
â âââ types.ts # Type definitions
|
|
298
|
+
â âââ utils/
|
|
299
|
+
â â âââ calendar.ts # Calendar logic
|
|
300
|
+
â â âââ date.ts # Date utilities
|
|
301
|
+
â â âââ position.ts # Positioning
|
|
302
|
+
â âââ styles/
|
|
303
|
+
â âââ rangepicker.scss
|
|
304
|
+
âââ index.html # Demo page
|
|
305
|
+
âââ package.json
|
|
306
|
+
âââ vite.config.ts
|
|
307
|
+
âââ tsconfig.json
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Styling
|
|
311
|
+
|
|
312
|
+
The component uses Tailwind CSS for styling. You can customize the appearance by:
|
|
313
|
+
|
|
314
|
+
1. **Using Tailwind Classes**: The component uses standard Tailwind classes that can be customized via your Tailwind config
|
|
315
|
+
2. **CSS Variables**: Override CSS custom properties for colors and spacing
|
|
316
|
+
3. **Custom CSS**: Import your own styles after the component styles
|
|
317
|
+
|
|
318
|
+
Example custom styling:
|
|
319
|
+
|
|
320
|
+
```css
|
|
321
|
+
.rangepicker-day-selected {
|
|
322
|
+
@apply bg-purple-600 text-white hover:bg-purple-700;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.rangepicker-day-in-range {
|
|
326
|
+
@apply bg-purple-50 text-purple-900;
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Browser Support
|
|
331
|
+
|
|
332
|
+
- Chrome/Edge (latest 2 versions)
|
|
333
|
+
- Firefox (latest 2 versions)
|
|
334
|
+
- Safari (latest 2 versions)
|
|
335
|
+
- Mobile Safari (iOS 14+)
|
|
336
|
+
- Chrome for Android (latest)
|
|
337
|
+
|
|
338
|
+
## License
|
|
339
|
+
|
|
340
|
+
MIT
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
interface Props {
|
|
3
|
+
modelValue?: {
|
|
4
|
+
startDate?: string | Date | Dayjs;
|
|
5
|
+
endDate?: string | Date | Dayjs;
|
|
6
|
+
};
|
|
7
|
+
isOpen?: boolean;
|
|
8
|
+
variant?: 'desktop' | 'mobile';
|
|
9
|
+
minDate?: string | Date | Dayjs;
|
|
10
|
+
maxDate?: string | Date | Dayjs;
|
|
11
|
+
minDays?: number;
|
|
12
|
+
maxDays?: number;
|
|
13
|
+
close?: boolean;
|
|
14
|
+
valueOfMonths?: number;
|
|
15
|
+
valueOfColumns?: number;
|
|
16
|
+
disabledDates?: (string | Date)[];
|
|
17
|
+
holidays?: (string | Date)[];
|
|
18
|
+
format?: string;
|
|
19
|
+
delimiter?: string;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
label?: string;
|
|
22
|
+
showTooltip?: boolean;
|
|
23
|
+
autoApply?: boolean;
|
|
24
|
+
position?: 'auto' | 'top' | 'bottom';
|
|
25
|
+
triggerElement?: HTMLElement | null;
|
|
26
|
+
colorStyles?: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
29
|
+
"update:modelValue": (value: {
|
|
30
|
+
startDate: string;
|
|
31
|
+
endDate: string;
|
|
32
|
+
}) => any;
|
|
33
|
+
"update:isOpen": (value: boolean) => any;
|
|
34
|
+
dateSelected: (date: Dayjs) => any;
|
|
35
|
+
rangeSelected: (start: Dayjs, end: Dayjs) => any;
|
|
36
|
+
}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
|
|
37
|
+
"onUpdate:modelValue"?: (value: {
|
|
38
|
+
startDate: string;
|
|
39
|
+
endDate: string;
|
|
40
|
+
}) => any;
|
|
41
|
+
"onUpdate:isOpen"?: (value: boolean) => any;
|
|
42
|
+
onDateSelected?: (date: Dayjs) => any;
|
|
43
|
+
onRangeSelected?: (start: Dayjs, end: Dayjs) => any;
|
|
44
|
+
}>, {
|
|
45
|
+
isOpen: boolean;
|
|
46
|
+
variant: "desktop" | "mobile";
|
|
47
|
+
valueOfMonths: number;
|
|
48
|
+
valueOfColumns: number;
|
|
49
|
+
format: string;
|
|
50
|
+
delimiter: string;
|
|
51
|
+
showTooltip: boolean;
|
|
52
|
+
autoApply: boolean;
|
|
53
|
+
position: "auto" | "top" | "bottom";
|
|
54
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
55
|
+
calendarRef: HTMLDivElement;
|
|
56
|
+
}, any>;
|
|
57
|
+
export default _default;
|
|
58
|
+
//# sourceMappingURL=Rangepicker.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rangepicker.vue.d.ts","sourceRoot":"","sources":["../src/Rangepicker.vue"],"names":[],"mappings":"AAwiBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAiClC,UAAU,KAAK;IACb,UAAU,CAAC,EAAE;QACX,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAAA;QACjC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAAA;KAChC,CAAA;IACD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAAA;IAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAAA;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;IACjC,QAAQ,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAA;IACpC,cAAc,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACrC;;;mBAvC2C,MAAM;iBAAW,MAAM;;;;;;;mBAAvB,MAAM;iBAAW,MAAM;;;;;;YAmBxD,OAAO;aACN,SAAS,GAAG,QAAQ;mBAMd,MAAM;oBACL,MAAM;YAGd,MAAM;eACH,MAAM;iBAGJ,OAAO;eACT,OAAO;cACR,MAAM,GAAG,KAAK,GAAG,QAAQ;;;;AAqnBtC,wBAUG"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3";
|
|
2
|
+
import RangepickerInput from "./RangepickerInput.vue";
|
|
3
|
+
declare const meta: Meta<typeof RangepickerInput>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof RangepickerInput>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Mobile: Story;
|
|
8
|
+
export declare const CustomBlueColor: Story;
|
|
9
|
+
export declare const CustomPurpleColor: Story;
|
|
10
|
+
export declare const CustomRedColor: Story;
|
|
11
|
+
export declare const CustomGreenColor: Story;
|
|
12
|
+
export declare const CustomOrangeColor: Story;
|
|
13
|
+
export declare const CustomPinkColor: Story;
|
|
14
|
+
//# sourceMappingURL=RangepickerInput.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RangepickerInput.stories.d.ts","sourceRoot":"","sources":["../src/RangepickerInput.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,gBAAgB,MAAM,wBAAwB,CAAC;AAEtD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,gBAAgB,CA4EvC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE/C,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC;AAEjC,eAAO,MAAM,MAAM,EAAE,KAIpB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAK7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAK/B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAK5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAK9B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAK/B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAK7B,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ref, watch } from "vue";
|
|
2
|
+
import RangepickerInput from "./RangepickerInput.vue";
|
|
3
|
+
const meta = {
|
|
4
|
+
title: "Components/Rangepicker",
|
|
5
|
+
component: RangepickerInput,
|
|
6
|
+
argTypes: {
|
|
7
|
+
modelValue: {
|
|
8
|
+
control: "text"
|
|
9
|
+
},
|
|
10
|
+
options: {
|
|
11
|
+
control: "object"
|
|
12
|
+
},
|
|
13
|
+
variant: {
|
|
14
|
+
control: "select",
|
|
15
|
+
options: ["desktop", "mobile"]
|
|
16
|
+
},
|
|
17
|
+
primaryColor: {
|
|
18
|
+
control: "color",
|
|
19
|
+
description: "Primary color for selected dates and highlights"
|
|
20
|
+
},
|
|
21
|
+
secondaryColor: {
|
|
22
|
+
control: "color",
|
|
23
|
+
description: "Secondary color for hover states"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
args: {
|
|
27
|
+
modelValue: "",
|
|
28
|
+
placeholder: "Check in / Check out",
|
|
29
|
+
id: "dates",
|
|
30
|
+
name: "dates",
|
|
31
|
+
variant: "desktop",
|
|
32
|
+
options: {
|
|
33
|
+
autoApply: true,
|
|
34
|
+
allowRepick: true,
|
|
35
|
+
dropdowns: {
|
|
36
|
+
minYear: new Date().getFullYear(),
|
|
37
|
+
maxYear: new Date().getFullYear() + 2,
|
|
38
|
+
months: true,
|
|
39
|
+
years: true,
|
|
40
|
+
},
|
|
41
|
+
startDate: new Date(),
|
|
42
|
+
minDate: new Date(),
|
|
43
|
+
format: 'DD MMM YYYY',
|
|
44
|
+
numberOfColumns: 2,
|
|
45
|
+
numberOfMonths: 2,
|
|
46
|
+
singleMode: false,
|
|
47
|
+
tooltipText: {
|
|
48
|
+
one: 'night',
|
|
49
|
+
other: 'nights',
|
|
50
|
+
},
|
|
51
|
+
tooltipNumber: (totalDays) => {
|
|
52
|
+
return totalDays - 1;
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
render: (args) => ({
|
|
57
|
+
components: { RangepickerInput },
|
|
58
|
+
setup() {
|
|
59
|
+
const modelValue = ref(args.modelValue ?? "");
|
|
60
|
+
watch(() => args.modelValue, (value) => {
|
|
61
|
+
const nextValue = value ?? "";
|
|
62
|
+
if (nextValue !== modelValue.value) {
|
|
63
|
+
modelValue.value = nextValue;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return { args, modelValue };
|
|
67
|
+
},
|
|
68
|
+
template: `
|
|
69
|
+
<div style="padding: 2rem; background: #f5f5f5; min-height: 360px;">
|
|
70
|
+
<RangepickerInput v-bind="args" v-model="modelValue" class="form-control mb-0 shadow-none text-black lg:pl-2 border-0 w-full" />
|
|
71
|
+
</div>
|
|
72
|
+
`
|
|
73
|
+
})
|
|
74
|
+
};
|
|
75
|
+
export default meta;
|
|
76
|
+
export const Default = {};
|
|
77
|
+
export const Mobile = {
|
|
78
|
+
args: {
|
|
79
|
+
variant: "mobile"
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
export const CustomBlueColor = {
|
|
83
|
+
args: {
|
|
84
|
+
primaryColor: "#3b82f6",
|
|
85
|
+
secondaryColor: "#60a5fa"
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
export const CustomPurpleColor = {
|
|
89
|
+
args: {
|
|
90
|
+
primaryColor: "#8b5cf6",
|
|
91
|
+
secondaryColor: "#a78bfa"
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
export const CustomRedColor = {
|
|
95
|
+
args: {
|
|
96
|
+
primaryColor: "#ef4444",
|
|
97
|
+
secondaryColor: "#f87171"
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
export const CustomGreenColor = {
|
|
101
|
+
args: {
|
|
102
|
+
primaryColor: "#10b981",
|
|
103
|
+
secondaryColor: "#34d399"
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
export const CustomOrangeColor = {
|
|
107
|
+
args: {
|
|
108
|
+
primaryColor: "#f97316",
|
|
109
|
+
secondaryColor: "#fb923c"
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
export const CustomPinkColor = {
|
|
113
|
+
args: {
|
|
114
|
+
primaryColor: "#ec4899",
|
|
115
|
+
secondaryColor: "#f472b6"
|
|
116
|
+
}
|
|
117
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
interface LitepickerOptions {
|
|
2
|
+
autoApply?: boolean;
|
|
3
|
+
allowRepick?: boolean;
|
|
4
|
+
dropdowns?: any;
|
|
5
|
+
startDate?: Date | string;
|
|
6
|
+
minDate?: Date | string;
|
|
7
|
+
maxDate?: Date | string;
|
|
8
|
+
format?: string;
|
|
9
|
+
numberOfColumns?: number;
|
|
10
|
+
numberOfMonths?: number;
|
|
11
|
+
singleMode?: boolean;
|
|
12
|
+
tooltipText?: any;
|
|
13
|
+
tooltipNumber?: any;
|
|
14
|
+
inlineMode?: boolean;
|
|
15
|
+
minDays?: number;
|
|
16
|
+
maxDays?: number;
|
|
17
|
+
showTooltip?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface Props {
|
|
20
|
+
id?: string;
|
|
21
|
+
close?: boolean;
|
|
22
|
+
modelValue?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
readonly?: boolean;
|
|
26
|
+
class?: string;
|
|
27
|
+
options?: LitepickerOptions;
|
|
28
|
+
variant?: 'desktop' | 'mobile';
|
|
29
|
+
primaryColor?: string;
|
|
30
|
+
secondaryColor?: string;
|
|
31
|
+
}
|
|
32
|
+
declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
33
|
+
"update:modelValue": (value: string) => any;
|
|
34
|
+
focusin: () => any;
|
|
35
|
+
}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
|
|
36
|
+
"onUpdate:modelValue"?: (value: string) => any;
|
|
37
|
+
onFocusin?: () => any;
|
|
38
|
+
}>, {
|
|
39
|
+
variant: "desktop" | "mobile";
|
|
40
|
+
placeholder: string;
|
|
41
|
+
readonly: boolean;
|
|
42
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
43
|
+
wrapperRef: HTMLDivElement;
|
|
44
|
+
inputRef: HTMLInputElement;
|
|
45
|
+
}, HTMLDivElement>;
|
|
46
|
+
export default _default;
|
|
47
|
+
//# sourceMappingURL=RangepickerInput.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RangepickerInput.vue.d.ts","sourceRoot":"","sources":["../src/RangepickerInput.vue"],"names":[],"mappings":"AAgNA,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,SAAS,CAAC,EAAE,GAAG,CAAA;IACf,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACzB,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACvB,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,WAAW,CAAC,EAAE,GAAG,CAAA;IACjB,aAAa,CAAC,EAAE,GAAG,CAAA;IACnB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,UAAU,KAAK;IACb,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,iBAAiB,CAAA;IAC3B,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;;;;;;;;aAHW,SAAS,GAAG,QAAQ;iBAJhB,MAAM;cACT,OAAO;;;;;AAyNpB,wBAUG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Rangepicker from './Rangepicker.vue';
|
|
2
|
+
import RangepickerInput from './RangepickerInput.vue';
|
|
3
|
+
import type { DateRange, RangepickerProps } from './types';
|
|
4
|
+
export default RangepickerInput;
|
|
5
|
+
export { Rangepicker, RangepickerInput };
|
|
6
|
+
export type { RangepickerProps, DateRange };
|
|
7
|
+
export declare function useRangepicker(triggerRef: any, options?: Partial<RangepickerProps>): {
|
|
8
|
+
isOpen: import("vue").Ref<boolean, boolean>;
|
|
9
|
+
dateRange: import("vue").Ref<{
|
|
10
|
+
startDate: string;
|
|
11
|
+
endDate: string;
|
|
12
|
+
}, DateRange | {
|
|
13
|
+
startDate: string;
|
|
14
|
+
endDate: string;
|
|
15
|
+
}>;
|
|
16
|
+
open: () => void;
|
|
17
|
+
close: () => void;
|
|
18
|
+
toggle: () => void;
|
|
19
|
+
options: Partial<RangepickerProps>;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,mBAAmB,CAAA;AAC3C,OAAO,gBAAgB,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG1D,eAAe,gBAAgB,CAAA;AAG/B,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAA;AAGxC,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,CAAA;AAG3C,wBAAgB,cAAc,CAAC,UAAU,EAAE,GAAG,EAAE,OAAO,GAAE,OAAO,CAAC,gBAAgB,CAAM;;;;;;;;;;;;;EAgBtF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import Rangepicker from './Rangepicker.vue';
|
|
3
|
+
import RangepickerInput from './RangepickerInput.vue';
|
|
4
|
+
// Default export - RangepickerInput (Litepicker-compatible wrapper)
|
|
5
|
+
export default RangepickerInput;
|
|
6
|
+
// Named exports
|
|
7
|
+
export { Rangepicker, RangepickerInput };
|
|
8
|
+
// Vue 3 composable for easy integration
|
|
9
|
+
export function useRangepicker(triggerRef, options = {}) {
|
|
10
|
+
const isOpen = ref(false);
|
|
11
|
+
const dateRange = ref({ startDate: '', endDate: '' });
|
|
12
|
+
const open = () => { isOpen.value = true; };
|
|
13
|
+
const close = () => { isOpen.value = false; };
|
|
14
|
+
const toggle = () => { isOpen.value = !isOpen.value; };
|
|
15
|
+
return {
|
|
16
|
+
isOpen,
|
|
17
|
+
dateRange,
|
|
18
|
+
open,
|
|
19
|
+
close,
|
|
20
|
+
toggle,
|
|
21
|
+
options,
|
|
22
|
+
};
|
|
23
|
+
}
|