@archpublicwebsite/rangepicker 1.2.13 → 1.2.15
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 +76 -107
- package/dist/Rangepicker.vue.d.ts.map +1 -1
- package/dist/RangepickerConstraints.stories.d.ts +2 -2
- package/dist/RangepickerConstraints.stories.d.ts.map +1 -1
- package/dist/RangepickerConstraints.stories.js +25 -25
- package/dist/RangepickerFormatting.stories.d.ts +2 -2
- package/dist/RangepickerFormatting.stories.d.ts.map +1 -1
- package/dist/RangepickerFormatting.stories.js +36 -36
- package/dist/RangepickerInput.stories.d.ts +2 -2
- package/dist/RangepickerInput.stories.d.ts.map +1 -1
- package/dist/RangepickerInput.stories.js +48 -48
- package/dist/RangepickerInput.vue.d.ts +0 -1
- package/dist/RangepickerInput.vue.d.ts.map +1 -1
- package/dist/RangepickerModes.stories.d.ts +2 -2
- package/dist/RangepickerModes.stories.d.ts.map +1 -1
- package/dist/RangepickerModes.stories.js +50 -50
- package/dist/RangepickerSpecialDates.stories.d.ts +2 -2
- package/dist/RangepickerSpecialDates.stories.d.ts.map +1 -1
- package/dist/RangepickerSpecialDates.stories.js +29 -33
- package/dist/RangepickerTheming.stories.d.ts +2 -2
- package/dist/RangepickerTheming.stories.d.ts.map +1 -1
- package/dist/RangepickerTheming.stories.js +49 -49
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/rangepicker.js +54 -78
- package/dist/rangepicker.js.map +1 -1
- package/dist/rangepicker.umd.cjs +1 -1
- package/dist/rangepicker.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types.d.ts +46 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/calendar.d.ts.map +1 -1
- package/dist/utils/calendar.js +5 -9
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/position.d.ts.map +1 -1
- package/package.json +6 -4
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
import { ref } from
|
|
2
|
-
import Rangepicker from
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import Rangepicker from './Rangepicker.vue';
|
|
3
3
|
// Helper to generate dates
|
|
4
4
|
const today = new Date();
|
|
5
|
-
|
|
5
|
+
function getDate(daysFromToday) {
|
|
6
6
|
const date = new Date(today);
|
|
7
7
|
date.setDate(today.getDate() + daysFromToday);
|
|
8
8
|
return date;
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
10
|
// Generate sample disabled dates (every Tuesday for the next 2 months)
|
|
11
|
-
|
|
11
|
+
function generateDisabledDates() {
|
|
12
12
|
const dates = [];
|
|
13
13
|
for (let i = 0; i < 60; i++) {
|
|
14
14
|
const date = getDate(i);
|
|
15
|
-
if (date.getDay() === 2) {
|
|
15
|
+
if (date.getDay() === 2) {
|
|
16
|
+
// Tuesday
|
|
16
17
|
dates.push(new Date(date));
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
return dates;
|
|
20
|
-
}
|
|
21
|
+
}
|
|
21
22
|
// Generate sample holidays
|
|
22
|
-
|
|
23
|
+
function generateHolidays() {
|
|
23
24
|
return [
|
|
24
25
|
getDate(7), // A week from now
|
|
25
26
|
getDate(14), // Two weeks from now
|
|
26
27
|
getDate(21), // Three weeks from now
|
|
27
28
|
getDate(30), // One month from now
|
|
28
29
|
];
|
|
29
|
-
}
|
|
30
|
+
}
|
|
30
31
|
/**
|
|
31
32
|
* Stories demonstrating special dates functionality
|
|
32
33
|
* including holidays and disabled dates.
|
|
33
34
|
*/
|
|
34
35
|
const meta = {
|
|
35
|
-
title:
|
|
36
|
+
title: 'Components/Rangepicker/Examples',
|
|
36
37
|
component: Rangepicker,
|
|
37
38
|
tags: ['autodocs'],
|
|
38
39
|
parameters: {
|
|
@@ -59,32 +60,32 @@ These dates can be visually distinguished and/or made non-selectable.
|
|
|
59
60
|
},
|
|
60
61
|
argTypes: {
|
|
61
62
|
disabledDates: {
|
|
62
|
-
control:
|
|
63
|
-
description:
|
|
63
|
+
control: 'object',
|
|
64
|
+
description: 'Array of dates that should be disabled for selection',
|
|
64
65
|
table: {
|
|
65
|
-
type: { summary:
|
|
66
|
-
defaultValue: { summary:
|
|
66
|
+
type: { summary: '(string | Date)[]' },
|
|
67
|
+
defaultValue: { summary: '[]' },
|
|
67
68
|
},
|
|
68
69
|
},
|
|
69
70
|
holidays: {
|
|
70
|
-
control:
|
|
71
|
-
description:
|
|
71
|
+
control: 'object',
|
|
72
|
+
description: 'Array of dates to mark as holidays',
|
|
72
73
|
table: {
|
|
73
|
-
type: { summary:
|
|
74
|
-
defaultValue: { summary:
|
|
74
|
+
type: { summary: '(string | Date)[]' },
|
|
75
|
+
defaultValue: { summary: '[]' },
|
|
75
76
|
},
|
|
76
77
|
},
|
|
77
78
|
variant: {
|
|
78
|
-
control:
|
|
79
|
-
options: [
|
|
79
|
+
control: 'select',
|
|
80
|
+
options: ['desktop', 'mobile'],
|
|
80
81
|
},
|
|
81
82
|
},
|
|
82
83
|
args: {
|
|
83
84
|
isOpen: true,
|
|
84
|
-
variant:
|
|
85
|
+
variant: 'desktop',
|
|
85
86
|
valueOfMonths: 2,
|
|
86
87
|
valueOfColumns: 2,
|
|
87
|
-
format:
|
|
88
|
+
format: 'DD MMM YYYY',
|
|
88
89
|
autoApply: true,
|
|
89
90
|
showTooltip: true,
|
|
90
91
|
minDate: today,
|
|
@@ -92,7 +93,7 @@ These dates can be visually distinguished and/or made non-selectable.
|
|
|
92
93
|
render: (args) => ({
|
|
93
94
|
components: { Rangepicker },
|
|
94
95
|
setup() {
|
|
95
|
-
const modelValue = ref({ startDate:
|
|
96
|
+
const modelValue = ref({ startDate: '', endDate: '' });
|
|
96
97
|
const isOpen = ref(args.isOpen ?? true);
|
|
97
98
|
return { args, modelValue, isOpen };
|
|
98
99
|
},
|
|
@@ -107,8 +108,8 @@ These dates can be visually distinguished and/or made non-selectable.
|
|
|
107
108
|
v-model:is-open="isOpen"
|
|
108
109
|
/>
|
|
109
110
|
</div>
|
|
110
|
-
|
|
111
|
-
})
|
|
111
|
+
`,
|
|
112
|
+
}),
|
|
112
113
|
};
|
|
113
114
|
export default meta;
|
|
114
115
|
/**
|
|
@@ -224,13 +225,7 @@ Combine both props for comprehensive date management.
|
|
|
224
225
|
*/
|
|
225
226
|
export const BlockedDateRange = {
|
|
226
227
|
args: {
|
|
227
|
-
disabledDates: [
|
|
228
|
-
getDate(10),
|
|
229
|
-
getDate(11),
|
|
230
|
-
getDate(12),
|
|
231
|
-
getDate(13),
|
|
232
|
-
getDate(14),
|
|
233
|
-
],
|
|
228
|
+
disabledDates: [getDate(10), getDate(11), getDate(12), getDate(13), getDate(14)],
|
|
234
229
|
},
|
|
235
230
|
parameters: {
|
|
236
231
|
docs: {
|
|
@@ -270,7 +265,8 @@ export const HolidayWeekends = {
|
|
|
270
265
|
for (let i = 0; i < 30; i++) {
|
|
271
266
|
const date = getDate(i);
|
|
272
267
|
const day = date.getDay();
|
|
273
|
-
if (day === 5 || day === 6 || day === 0) {
|
|
268
|
+
if (day === 5 || day === 6 || day === 0) {
|
|
269
|
+
// Fri, Sat, Sun
|
|
274
270
|
dates.push(new Date(date));
|
|
275
271
|
}
|
|
276
272
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from
|
|
2
|
-
import RangepickerInput from
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
2
|
+
import RangepickerInput from './RangepickerInput.vue';
|
|
3
3
|
/**
|
|
4
4
|
* Stories demonstrating theming and color customization options
|
|
5
5
|
* for the Rangepicker component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RangepickerTheming.stories.d.ts","sourceRoot":"","sources":["../src/RangepickerTheming.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"RangepickerTheming.stories.d.ts","sourceRoot":"","sources":["../src/RangepickerTheming.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,gBAAgB,MAAM,wBAAwB,CAAA;AAErD;;;GAGG;AACH,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,gBAAgB,CAwGvC,CAAA;AAED,eAAe,IAAI,CAAA;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAE9C;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,KAmDzB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,KAsC1B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,KA0DxB,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ref, watch } from
|
|
2
|
-
import RangepickerInput from
|
|
1
|
+
import { ref, watch } from 'vue';
|
|
2
|
+
import RangepickerInput from './RangepickerInput.vue';
|
|
3
3
|
/**
|
|
4
4
|
* Stories demonstrating theming and color customization options
|
|
5
5
|
* for the Rangepicker component.
|
|
6
6
|
*/
|
|
7
7
|
const meta = {
|
|
8
|
-
title:
|
|
8
|
+
title: 'Components/Rangepicker/Examples',
|
|
9
9
|
component: RangepickerInput,
|
|
10
10
|
tags: ['autodocs'],
|
|
11
11
|
parameters: {
|
|
@@ -33,64 +33,64 @@ Each instance can have its own color scheme using HEX color values.
|
|
|
33
33
|
},
|
|
34
34
|
argTypes: {
|
|
35
35
|
primaryColor: {
|
|
36
|
-
control:
|
|
37
|
-
description:
|
|
36
|
+
control: 'color',
|
|
37
|
+
description: 'Primary color for selected dates and highlights (HEX format)',
|
|
38
38
|
table: {
|
|
39
|
-
type: { summary:
|
|
40
|
-
defaultValue: { summary:
|
|
39
|
+
type: { summary: 'string' },
|
|
40
|
+
defaultValue: { summary: 'undefined (uses default blue)' },
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
43
|
secondaryColor: {
|
|
44
|
-
control:
|
|
45
|
-
description:
|
|
44
|
+
control: 'color',
|
|
45
|
+
description: 'Secondary color for hover states (HEX format)',
|
|
46
46
|
table: {
|
|
47
|
-
type: { summary:
|
|
48
|
-
defaultValue: { summary:
|
|
47
|
+
type: { summary: 'string' },
|
|
48
|
+
defaultValue: { summary: 'undefined (uses default light blue)' },
|
|
49
49
|
},
|
|
50
50
|
},
|
|
51
51
|
borderRadius: {
|
|
52
|
-
control:
|
|
53
|
-
description:
|
|
52
|
+
control: 'text',
|
|
53
|
+
description: 'Border radius for the calendar container (CSS value)',
|
|
54
54
|
table: {
|
|
55
|
-
type: { summary:
|
|
56
|
-
defaultValue: { summary:
|
|
55
|
+
type: { summary: 'string' },
|
|
56
|
+
defaultValue: { summary: '0.75rem' },
|
|
57
57
|
},
|
|
58
58
|
},
|
|
59
59
|
fontFamily: {
|
|
60
|
-
control:
|
|
61
|
-
description:
|
|
60
|
+
control: 'text',
|
|
61
|
+
description: 'Font family for the calendar (CSS font-family value)',
|
|
62
62
|
table: {
|
|
63
|
-
type: { summary:
|
|
64
|
-
defaultValue: { summary:
|
|
63
|
+
type: { summary: 'string' },
|
|
64
|
+
defaultValue: { summary: 'inherit' },
|
|
65
65
|
},
|
|
66
66
|
},
|
|
67
67
|
variant: {
|
|
68
|
-
control:
|
|
69
|
-
options: [
|
|
68
|
+
control: 'select',
|
|
69
|
+
options: ['desktop', 'mobile'],
|
|
70
70
|
},
|
|
71
71
|
options: {
|
|
72
|
-
control:
|
|
72
|
+
control: 'object',
|
|
73
73
|
},
|
|
74
74
|
},
|
|
75
75
|
args: {
|
|
76
|
-
placeholder:
|
|
77
|
-
id:
|
|
78
|
-
name:
|
|
79
|
-
variant:
|
|
76
|
+
placeholder: 'Check in / Check out',
|
|
77
|
+
id: 'dates',
|
|
78
|
+
name: 'dates',
|
|
79
|
+
variant: 'desktop',
|
|
80
80
|
options: {
|
|
81
81
|
autoApply: true,
|
|
82
82
|
minDate: new Date(),
|
|
83
83
|
format: 'DD MMM YYYY',
|
|
84
84
|
numberOfColumns: 2,
|
|
85
85
|
numberOfMonths: 2,
|
|
86
|
-
}
|
|
86
|
+
},
|
|
87
87
|
},
|
|
88
88
|
render: (args) => ({
|
|
89
89
|
components: { RangepickerInput },
|
|
90
90
|
setup() {
|
|
91
|
-
const modelValue = ref(args.modelValue ??
|
|
91
|
+
const modelValue = ref(args.modelValue ?? '');
|
|
92
92
|
watch(() => args.modelValue, (value) => {
|
|
93
|
-
const nextValue = value ??
|
|
93
|
+
const nextValue = value ?? '';
|
|
94
94
|
if (nextValue !== modelValue.value) {
|
|
95
95
|
modelValue.value = nextValue;
|
|
96
96
|
}
|
|
@@ -101,8 +101,8 @@ Each instance can have its own color scheme using HEX color values.
|
|
|
101
101
|
<div style="padding: 2rem; background: #f5f5f5; min-height: 400px;">
|
|
102
102
|
<RangepickerInput v-bind="args" v-model="modelValue" class="form-control mb-0 shadow-none text-black lg:pl-2 border-0 w-full" />
|
|
103
103
|
</div>
|
|
104
|
-
|
|
105
|
-
})
|
|
104
|
+
`,
|
|
105
|
+
}),
|
|
106
106
|
};
|
|
107
107
|
export default meta;
|
|
108
108
|
/**
|
|
@@ -110,18 +110,18 @@ export default meta;
|
|
|
110
110
|
*/
|
|
111
111
|
export const ColorThemes = {
|
|
112
112
|
args: {
|
|
113
|
-
primaryColor:
|
|
114
|
-
secondaryColor:
|
|
115
|
-
modelValue:
|
|
113
|
+
primaryColor: '#ff00de',
|
|
114
|
+
secondaryColor: '#5a6258',
|
|
115
|
+
modelValue: '02 Feb 2026 - 04 Feb 2026',
|
|
116
116
|
},
|
|
117
117
|
argTypes: {
|
|
118
118
|
primaryColor: {
|
|
119
|
-
control:
|
|
120
|
-
description:
|
|
119
|
+
control: 'color',
|
|
120
|
+
description: 'Primary color for selected dates and highlights',
|
|
121
121
|
},
|
|
122
122
|
secondaryColor: {
|
|
123
|
-
control:
|
|
124
|
-
description:
|
|
123
|
+
control: 'color',
|
|
124
|
+
description: 'Secondary color for hover states',
|
|
125
125
|
},
|
|
126
126
|
},
|
|
127
127
|
parameters: {
|
|
@@ -165,14 +165,14 @@ Use the color pickers below to customize your theme, or try these popular preset
|
|
|
165
165
|
*/
|
|
166
166
|
export const BorderRadius = {
|
|
167
167
|
args: {
|
|
168
|
-
borderRadius:
|
|
169
|
-
modelValue:
|
|
168
|
+
borderRadius: '12px',
|
|
169
|
+
modelValue: '02 Feb 2026 - 04 Feb 2026',
|
|
170
170
|
},
|
|
171
171
|
argTypes: {
|
|
172
172
|
borderRadius: {
|
|
173
|
-
control:
|
|
174
|
-
options: [
|
|
175
|
-
description:
|
|
173
|
+
control: 'select',
|
|
174
|
+
options: ['4px', '6px', '8px', '12px'],
|
|
175
|
+
description: 'Border radius of the calendar container',
|
|
176
176
|
},
|
|
177
177
|
},
|
|
178
178
|
parameters: {
|
|
@@ -207,22 +207,22 @@ You can also use any valid CSS value like \`"0.75rem"\` or \`"16px"\`.
|
|
|
207
207
|
*/
|
|
208
208
|
export const FontFamily = {
|
|
209
209
|
args: {
|
|
210
|
-
fontFamily:
|
|
211
|
-
modelValue:
|
|
210
|
+
fontFamily: 'Georgia, serif',
|
|
211
|
+
modelValue: '02 Feb 2026 - 04 Feb 2026',
|
|
212
212
|
},
|
|
213
213
|
argTypes: {
|
|
214
214
|
fontFamily: {
|
|
215
|
-
control:
|
|
215
|
+
control: 'select',
|
|
216
216
|
options: [
|
|
217
|
-
|
|
217
|
+
'inherit',
|
|
218
218
|
"'Inter', sans-serif",
|
|
219
219
|
"'Roboto', sans-serif",
|
|
220
220
|
"'Poppins', sans-serif",
|
|
221
221
|
"'Arial', sans-serif",
|
|
222
|
-
|
|
222
|
+
'Georgia, serif',
|
|
223
223
|
"'Courier New', monospace",
|
|
224
224
|
],
|
|
225
|
-
description:
|
|
225
|
+
description: 'Font family for the calendar',
|
|
226
226
|
},
|
|
227
227
|
},
|
|
228
228
|
parameters: {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAA;AAClC,OAAO,WAAW,MAAM,mBAAmB,CAAA;AAC3C,OAAO,gBAAgB,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAGhB,eAAe,gBAAgB,CAAA;AAG/B,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAA;AAGxC,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAA;AAClC,OAAO,WAAW,MAAM,mBAAmB,CAAA;AAC3C,OAAO,gBAAgB,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAGhB,eAAe,gBAAgB,CAAA;AAG/B,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAA;AAGxC,YAAY,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA;AAGhH,wBAAgB,cAAc,CAAC,UAAU,EAAE,GAAG,EAAE,OAAO,GAAE,OAAO,CAAC,gBAAgB,CAAM;;;;;;;;;;;;;EAsBtF"}
|
package/dist/index.js
CHANGED
|
@@ -10,9 +10,15 @@ export { Rangepicker, RangepickerInput };
|
|
|
10
10
|
export function useRangepicker(triggerRef, options = {}) {
|
|
11
11
|
const isOpen = ref(false);
|
|
12
12
|
const dateRange = ref({ startDate: '', endDate: '' });
|
|
13
|
-
const open = () => {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const open = () => {
|
|
14
|
+
isOpen.value = true;
|
|
15
|
+
};
|
|
16
|
+
const close = () => {
|
|
17
|
+
isOpen.value = false;
|
|
18
|
+
};
|
|
19
|
+
const toggle = () => {
|
|
20
|
+
isOpen.value = !isOpen.value;
|
|
21
|
+
};
|
|
16
22
|
return {
|
|
17
23
|
isOpen,
|
|
18
24
|
dateRange,
|
package/dist/rangepicker.js
CHANGED
|
@@ -246,13 +246,7 @@ function generateCalendarMonths(numberOfMonths, startOffset = 0, options = {}) {
|
|
|
246
246
|
for (let i = 0; i < numberOfMonths; i++) {
|
|
247
247
|
const { month, days } = getMonthDays(startOffset + i);
|
|
248
248
|
const calendarDays = days.map(
|
|
249
|
-
(day) => createCalendarDay(
|
|
250
|
-
day.date,
|
|
251
|
-
day.isPrevMonth,
|
|
252
|
-
day.isCurrentMonth,
|
|
253
|
-
day.isNextMonth,
|
|
254
|
-
options
|
|
255
|
-
)
|
|
249
|
+
(day) => createCalendarDay(day.date, day.isPrevMonth, day.isCurrentMonth, day.isNextMonth, options)
|
|
256
250
|
);
|
|
257
251
|
months.push({
|
|
258
252
|
month,
|
|
@@ -271,8 +265,7 @@ function getWeekDays(locale = "en", format = "short") {
|
|
|
271
265
|
return days;
|
|
272
266
|
}
|
|
273
267
|
function calculatePosition(triggerElement, calendarElement, preferredPosition = "auto") {
|
|
274
|
-
if (!triggerElement || !calendarElement)
|
|
275
|
-
return { left: 0 };
|
|
268
|
+
if (!triggerElement || !calendarElement) return { left: 0 };
|
|
276
269
|
const triggerRect = triggerElement.getBoundingClientRect();
|
|
277
270
|
const calendarRect = calendarElement.getBoundingClientRect();
|
|
278
271
|
const viewportHeight = window.innerHeight;
|
|
@@ -291,10 +284,8 @@ function calculatePosition(triggerElement, calendarElement, preferredPosition =
|
|
|
291
284
|
} else {
|
|
292
285
|
position.top = triggerRect.bottom + 8;
|
|
293
286
|
}
|
|
294
|
-
if (position.left + calendarRect.width > viewportWidth)
|
|
295
|
-
|
|
296
|
-
if (position.left < 16)
|
|
297
|
-
position.left = 16;
|
|
287
|
+
if (position.left + calendarRect.width > viewportWidth) position.left = viewportWidth - calendarRect.width - 16;
|
|
288
|
+
if (position.left < 16) position.left = 16;
|
|
298
289
|
return position;
|
|
299
290
|
}
|
|
300
291
|
const _hoisted_1$1 = {
|
|
@@ -305,12 +296,12 @@ const _hoisted_2$1 = { class: "rangepicker-header" };
|
|
|
305
296
|
const _hoisted_3 = { class: "arch-flex arch-items-center arch-justify-between" };
|
|
306
297
|
const _hoisted_4 = {
|
|
307
298
|
key: 0,
|
|
308
|
-
class: "arch-text-xs arch-font-medium arch-text-gray-500
|
|
299
|
+
class: "arch-mb-1 arch-text-xs arch-font-medium arch-text-gray-500"
|
|
309
300
|
};
|
|
310
301
|
const _hoisted_5 = { class: "arch-text-sm arch-font-semibold arch-text-gray-900" };
|
|
311
302
|
const _hoisted_6 = {
|
|
312
303
|
key: 0,
|
|
313
|
-
class: "arch-text-xs arch-text-gray-500
|
|
304
|
+
class: "arch-mt-1 arch-text-xs arch-text-gray-500"
|
|
314
305
|
};
|
|
315
306
|
const _hoisted_7 = { class: "rangepicker-body" };
|
|
316
307
|
const _hoisted_8 = { class: "rangepicker-month-grid" };
|
|
@@ -334,6 +325,7 @@ const _hoisted_17 = {
|
|
|
334
325
|
};
|
|
335
326
|
const _hoisted_18 = ["disabled"];
|
|
336
327
|
const _hoisted_19 = { class: "arch-flex arch-items-center arch-gap-1" };
|
|
328
|
+
const packageVersion = 10;
|
|
337
329
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
338
330
|
__name: "Rangepicker",
|
|
339
331
|
props: {
|
|
@@ -366,12 +358,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
366
358
|
const emit = __emit;
|
|
367
359
|
const breakpoints = useBreakpoints(breakpointsTailwind);
|
|
368
360
|
const isMobile = breakpoints.smallerOrEqual("lg");
|
|
369
|
-
const numberOfMonths = computed(
|
|
370
|
-
|
|
371
|
-
);
|
|
372
|
-
computed(
|
|
373
|
-
() => isMobile.value ? 1 : props.valueOfColumns
|
|
374
|
-
);
|
|
361
|
+
const numberOfMonths = computed(() => isMobile.value ? 1 : props.valueOfMonths);
|
|
362
|
+
computed(() => isMobile.value ? 1 : props.valueOfColumns);
|
|
375
363
|
const calendarRef = ref(null);
|
|
376
364
|
const isFadingOut = ref(false);
|
|
377
365
|
const hoveredDay = ref(null);
|
|
@@ -379,28 +367,18 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
379
367
|
const localIsOpen = ref(props.isOpen);
|
|
380
368
|
const localStartDate = ref(null);
|
|
381
369
|
const localEndDate = ref(null);
|
|
382
|
-
const parsedMinDate = computed(
|
|
383
|
-
|
|
384
|
-
)
|
|
385
|
-
|
|
386
|
-
(
|
|
387
|
-
);
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
);
|
|
394
|
-
const parsedHolidays = computed(
|
|
395
|
-
() => {
|
|
396
|
-
var _a;
|
|
397
|
-
return ((_a = props.holidays) == null ? void 0 : _a.map((h) => dayjs(h))) || [];
|
|
398
|
-
}
|
|
399
|
-
);
|
|
370
|
+
const parsedMinDate = computed(() => props.minDate ? dayjs(props.minDate) : null);
|
|
371
|
+
const parsedMaxDate = computed(() => props.maxDate ? dayjs(props.maxDate) : null);
|
|
372
|
+
const parsedDisabledDates = computed(() => {
|
|
373
|
+
var _a;
|
|
374
|
+
return ((_a = props.disabledDates) == null ? void 0 : _a.map((d) => dayjs(d))) || [];
|
|
375
|
+
});
|
|
376
|
+
const parsedHolidays = computed(() => {
|
|
377
|
+
var _a;
|
|
378
|
+
return ((_a = props.holidays) == null ? void 0 : _a.map((h) => dayjs(h))) || [];
|
|
379
|
+
});
|
|
400
380
|
const weekdays = computed(() => getWeekDays("en", "narrow"));
|
|
401
|
-
const effectiveNumberOfMonths = computed(
|
|
402
|
-
() => props.variant === "mobile" ? 1 : numberOfMonths.value
|
|
403
|
-
);
|
|
381
|
+
const effectiveNumberOfMonths = computed(() => props.variant === "mobile" ? 1 : numberOfMonths.value);
|
|
404
382
|
const calendarMonths = computed(
|
|
405
383
|
() => generateCalendarMonths(effectiveNumberOfMonths.value, monthOffset.value, {
|
|
406
384
|
startDate: localStartDate.value,
|
|
@@ -417,8 +395,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
417
395
|
});
|
|
418
396
|
const formattedDateRange = computed(() => {
|
|
419
397
|
if (!localStartDate.value && !localEndDate.value) return "";
|
|
420
|
-
else if (localStartDate.value && !localEndDate.value)
|
|
421
|
-
return localStartDate.value.format(props.format);
|
|
398
|
+
else if (localStartDate.value && !localEndDate.value) return localStartDate.value.format(props.format);
|
|
422
399
|
else if (localStartDate.value && localEndDate.value)
|
|
423
400
|
return `${localStartDate.value.format(props.format)}${props.delimiter}${localEndDate.value.format(props.format)}`;
|
|
424
401
|
else return "";
|
|
@@ -443,13 +420,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
443
420
|
return;
|
|
444
421
|
}
|
|
445
422
|
nextTick(() => {
|
|
446
|
-
const position = calculatePosition(
|
|
447
|
-
props.triggerElement,
|
|
448
|
-
calendarRef.value,
|
|
449
|
-
props.position
|
|
450
|
-
);
|
|
423
|
+
const position = calculatePosition(props.triggerElement, calendarRef.value, props.position);
|
|
451
424
|
calendarStyle.value = {
|
|
452
|
-
left: `${position.left}px`,
|
|
425
|
+
"left": `${position.left}px`,
|
|
453
426
|
...position.top !== void 0 && { top: `${position.top}px` },
|
|
454
427
|
...position.bottom !== void 0 && { bottom: `${position.bottom}px` },
|
|
455
428
|
...position.transform && { transform: position.transform },
|
|
@@ -475,13 +448,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
475
448
|
if (day.isWeekend && !day.isSelected) classes.push("rangepicker-day-weekend");
|
|
476
449
|
if (day.isHoliday) classes.push("rangepicker-day-holiday");
|
|
477
450
|
if (day.isSelected) {
|
|
478
|
-
if (localStartDate.value && localEndDate.value && day.date.isSame(localStartDate.value, "day") && day.date.isSame(localEndDate.value, "day"))
|
|
451
|
+
if (localStartDate.value && localEndDate.value && day.date.isSame(localStartDate.value, "day") && day.date.isSame(localEndDate.value, "day")) {
|
|
479
452
|
classes.push("rangepicker-day-selected-single");
|
|
480
|
-
else if (localStartDate.value && day.date.isSame(localStartDate.value, "day"))
|
|
453
|
+
} else if (localStartDate.value && day.date.isSame(localStartDate.value, "day")) {
|
|
481
454
|
classes.push("rangepicker-day-selected-start");
|
|
482
|
-
else if (localEndDate.value && day.date.isSame(localEndDate.value, "day"))
|
|
455
|
+
} else if (localEndDate.value && day.date.isSame(localEndDate.value, "day")) {
|
|
483
456
|
classes.push("rangepicker-day-selected-end");
|
|
484
|
-
else
|
|
457
|
+
} else {
|
|
458
|
+
classes.push("rangepicker-day-selected");
|
|
459
|
+
}
|
|
485
460
|
}
|
|
486
461
|
if (day.isInRange) classes.push("rangepicker-day-in-range");
|
|
487
462
|
if (localStartDate.value && !localEndDate.value && hoveredDay.value) {
|
|
@@ -543,8 +518,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
543
518
|
}
|
|
544
519
|
function handleDayHover(day, event) {
|
|
545
520
|
hoveredDay.value = day;
|
|
546
|
-
if (props.showTooltip && localStartDate.value && !localEndDate.value)
|
|
547
|
-
updateTooltipPosition(event);
|
|
521
|
+
if (props.showTooltip && localStartDate.value && !localEndDate.value) updateTooltipPosition(event);
|
|
548
522
|
}
|
|
549
523
|
function updateTooltipPosition(event) {
|
|
550
524
|
const rect = event.target.getBoundingClientRect();
|
|
@@ -583,11 +557,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
583
557
|
}
|
|
584
558
|
function cancel() {
|
|
585
559
|
var _a, _b;
|
|
586
|
-
if ((_a = props.modelValue) == null ? void 0 : _a.startDate)
|
|
587
|
-
localStartDate.value = dayjs(props.modelValue.startDate);
|
|
560
|
+
if ((_a = props.modelValue) == null ? void 0 : _a.startDate) localStartDate.value = dayjs(props.modelValue.startDate);
|
|
588
561
|
else localStartDate.value = null;
|
|
589
|
-
if ((_b = props.modelValue) == null ? void 0 : _b.endDate)
|
|
590
|
-
localEndDate.value = dayjs(props.modelValue.endDate);
|
|
562
|
+
if ((_b = props.modelValue) == null ? void 0 : _b.endDate) localEndDate.value = dayjs(props.modelValue.endDate);
|
|
591
563
|
else localEndDate.value = null;
|
|
592
564
|
close();
|
|
593
565
|
}
|
|
@@ -647,6 +619,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
647
619
|
createElementVNode("div", {
|
|
648
620
|
ref_key: "calendarRef",
|
|
649
621
|
ref: calendarRef,
|
|
622
|
+
"data-version": packageVersion,
|
|
650
623
|
class: normalizeClass(["rangepicker-container", [__props.variant === "mobile" ? "rangepicker-mobile" : ""]]),
|
|
651
624
|
style: normalizeStyle({ ...calendarStyle.value, ...__props.colorStyles, borderRadius: props.borderRadius })
|
|
652
625
|
}, [
|
|
@@ -739,11 +712,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
739
712
|
]),
|
|
740
713
|
!__props.autoApply ? (openBlock(), createElementBlock("div", _hoisted_17, [
|
|
741
714
|
createElementVNode("button", {
|
|
742
|
-
class: "arch-px-4 arch-py-2 arch-text-sm arch-font-medium arch-text-gray-700 hover:arch-bg-gray-100
|
|
715
|
+
class: "arch-rounded-lg arch-px-4 arch-py-2 arch-text-sm arch-font-medium arch-text-gray-700 arch-transition-colors hover:arch-bg-gray-100",
|
|
743
716
|
onClick: cancel
|
|
744
717
|
}, " Cancel "),
|
|
745
718
|
createElementVNode("button", {
|
|
746
|
-
class: "arch-px-4 arch-py-2 arch-text-sm arch-font-medium arch-text-white arch-
|
|
719
|
+
class: "arch-rounded-lg arch-px-4 arch-py-2 arch-text-sm arch-font-medium arch-text-white arch-transition-colors disabled:arch-cursor-not-allowed disabled:arch-opacity-50",
|
|
747
720
|
style: normalizeStyle({
|
|
748
721
|
backgroundColor: ((_a = __props.colorStyles) == null ? void 0 : _a["--color-primary"]) ? `rgb(${__props.colorStyles["--color-primary"]})` : "rgb(37 99 235)"
|
|
749
722
|
}),
|
|
@@ -776,7 +749,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
776
749
|
}
|
|
777
750
|
return target;
|
|
778
751
|
};
|
|
779
|
-
const Rangepicker = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
752
|
+
const Rangepicker = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-373603fd"]]);
|
|
780
753
|
const _hoisted_1 = { class: "rangepicker-input-container" };
|
|
781
754
|
const _hoisted_2 = ["id", "value", "placeholder", "readonly", "name"];
|
|
782
755
|
const inputClass = "rangepicker-input block w-full h-full bg-transparent border-0 shadow-none outline-none cursor-pointer font-inherit text-inherit p-0";
|
|
@@ -825,10 +798,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
825
798
|
console.warn(`[Rangepicker] Invalid hex color: ${hex}`);
|
|
826
799
|
return null;
|
|
827
800
|
}
|
|
828
|
-
const r = parseInt(hex.substring(0, 2), 16);
|
|
829
|
-
const g = parseInt(hex.substring(2, 4), 16);
|
|
830
|
-
const b = parseInt(hex.substring(4, 6), 16);
|
|
831
|
-
if (isNaN(r) || isNaN(g) || isNaN(b)) {
|
|
801
|
+
const r = Number.parseInt(hex.substring(0, 2), 16);
|
|
802
|
+
const g = Number.parseInt(hex.substring(2, 4), 16);
|
|
803
|
+
const b = Number.parseInt(hex.substring(4, 6), 16);
|
|
804
|
+
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
832
805
|
return null;
|
|
833
806
|
}
|
|
834
807
|
return `${r} ${g} ${b}`;
|
|
@@ -838,8 +811,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
838
811
|
const inputRef = ref(null);
|
|
839
812
|
const isOpen = ref(false);
|
|
840
813
|
function parseValue(value) {
|
|
841
|
-
if (!value)
|
|
842
|
-
return { startDate: "", endDate: "" };
|
|
814
|
+
if (!value) return { startDate: "", endDate: "" };
|
|
843
815
|
const parts = value.split(" - ");
|
|
844
816
|
if (parts.length === 2) {
|
|
845
817
|
return {
|
|
@@ -849,10 +821,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
849
821
|
}
|
|
850
822
|
return { startDate: "", endDate: "" };
|
|
851
823
|
}
|
|
852
|
-
watch(
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
824
|
+
watch(
|
|
825
|
+
() => props == null ? void 0 : props.close,
|
|
826
|
+
(cur) => {
|
|
827
|
+
if (cur) inputRef.value.blur();
|
|
828
|
+
}
|
|
829
|
+
);
|
|
856
830
|
const localValue = ref(parseValue(props.modelValue));
|
|
857
831
|
const displayValue = computed(() => {
|
|
858
832
|
return props.modelValue || "";
|
|
@@ -874,9 +848,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
874
848
|
emit("update:modelValue", "");
|
|
875
849
|
isOpen.value = false;
|
|
876
850
|
}
|
|
877
|
-
watch(
|
|
878
|
-
|
|
879
|
-
|
|
851
|
+
watch(
|
|
852
|
+
() => props.modelValue,
|
|
853
|
+
(newVal) => {
|
|
854
|
+
localValue.value = parseValue(newVal);
|
|
855
|
+
}
|
|
856
|
+
);
|
|
880
857
|
const colorStyles = computed(() => {
|
|
881
858
|
const styles = {};
|
|
882
859
|
if (props.primaryColor) {
|
|
@@ -898,7 +875,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
898
875
|
});
|
|
899
876
|
return (_ctx, _cache) => {
|
|
900
877
|
return openBlock(), createElementBlock("div", mergeProps(_ctx.$attrs, {
|
|
901
|
-
ref: "wrapperRef",
|
|
902
878
|
class: "rangepicker-input-wrapper",
|
|
903
879
|
style: colorStyles.value
|
|
904
880
|
}), [
|
|
@@ -964,7 +940,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
964
940
|
};
|
|
965
941
|
}
|
|
966
942
|
});
|
|
967
|
-
const RangepickerInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
943
|
+
const RangepickerInput = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1132af89"]]);
|
|
968
944
|
function useRangepicker(triggerRef, options = {}) {
|
|
969
945
|
const isOpen = ref(false);
|
|
970
946
|
const dateRange = ref({ startDate: "", endDate: "" });
|