@kopexa/date-picker 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 +201 -0
- package/dist/chunk-2C5V7ODF.mjs +501 -0
- package/dist/chunk-C7GZJJIK.mjs +10 -0
- package/dist/chunk-HPM5Y2V6.mjs +35 -0
- package/dist/chunk-UD6PYKLX.mjs +96 -0
- package/dist/date-picker-BAPrYssW.d.mts +10 -0
- package/dist/date-picker-BAPrYssW.d.ts +10 -0
- package/dist/date-picker-field.d.mts +41 -0
- package/dist/date-picker-field.d.ts +41 -0
- package/dist/date-picker-field.js +531 -0
- package/dist/date-picker-field.mjs +10 -0
- package/dist/date-picker-messages.d.mts +29 -0
- package/dist/date-picker-messages.d.ts +29 -0
- package/dist/date-picker-messages.js +58 -0
- package/dist/date-picker-messages.mjs +8 -0
- package/dist/date-picker.d.mts +1 -0
- package/dist/date-picker.d.ts +1 -0
- package/dist/date-picker.js +84 -0
- package/dist/date-picker.mjs +61 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +580 -0
- package/dist/index.mjs +30 -0
- package/package.json +53 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
CalendarDate: () => import_date2.CalendarDate,
|
|
25
|
+
CalendarDateTime: () => import_date2.CalendarDateTime,
|
|
26
|
+
DateFormatter: () => import_date2.DateFormatter,
|
|
27
|
+
DatePicker: () => date_picker_exports,
|
|
28
|
+
DatePickerField: () => DatePickerField,
|
|
29
|
+
datePickerMessages: () => datePickerMessages,
|
|
30
|
+
getLocalTimeZone: () => import_date2.getLocalTimeZone,
|
|
31
|
+
parseDate: () => import_date_picker.parseDate
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
var import_date2 = require("@internationalized/date");
|
|
35
|
+
|
|
36
|
+
// src/date-picker.tsx
|
|
37
|
+
var date_picker_exports = {};
|
|
38
|
+
__export(date_picker_exports, {
|
|
39
|
+
ClearTrigger: () => import_date_picker.DatePickerClearTrigger,
|
|
40
|
+
Content: () => import_date_picker.DatePickerContent,
|
|
41
|
+
Context: () => import_date_picker.DatePickerContext,
|
|
42
|
+
Control: () => import_date_picker.DatePickerControl,
|
|
43
|
+
Input: () => import_date_picker.DatePickerInput,
|
|
44
|
+
Label: () => import_date_picker.DatePickerLabel,
|
|
45
|
+
MonthSelect: () => import_date_picker.DatePickerMonthSelect,
|
|
46
|
+
NextTrigger: () => import_date_picker.DatePickerNextTrigger,
|
|
47
|
+
Positioner: () => import_date_picker.DatePickerPositioner,
|
|
48
|
+
PresetTrigger: () => import_date_picker.DatePickerPresetTrigger,
|
|
49
|
+
PrevTrigger: () => import_date_picker.DatePickerPrevTrigger,
|
|
50
|
+
RangeText: () => import_date_picker.DatePickerRangeText,
|
|
51
|
+
Root: () => import_date_picker.DatePickerRoot,
|
|
52
|
+
Table: () => import_date_picker.DatePickerTable,
|
|
53
|
+
TableBody: () => import_date_picker.DatePickerTableBody,
|
|
54
|
+
TableCell: () => import_date_picker.DatePickerTableCell,
|
|
55
|
+
TableCellTrigger: () => import_date_picker.DatePickerTableCellTrigger,
|
|
56
|
+
TableHead: () => import_date_picker.DatePickerTableHead,
|
|
57
|
+
TableHeader: () => import_date_picker.DatePickerTableHeader,
|
|
58
|
+
TableRow: () => import_date_picker.DatePickerTableRow,
|
|
59
|
+
Trigger: () => import_date_picker.DatePickerTrigger,
|
|
60
|
+
ValueText: () => import_date_picker.DatePickerValueText,
|
|
61
|
+
View: () => import_date_picker.DatePickerView,
|
|
62
|
+
ViewControl: () => import_date_picker.DatePickerViewControl,
|
|
63
|
+
ViewTrigger: () => import_date_picker.DatePickerViewTrigger,
|
|
64
|
+
YearSelect: () => import_date_picker.DatePickerYearSelect,
|
|
65
|
+
parseDate: () => import_date_picker.parseDate
|
|
66
|
+
});
|
|
67
|
+
var import_date_picker = require("@ark-ui/react/date-picker");
|
|
68
|
+
|
|
69
|
+
// src/date-picker-field.tsx
|
|
70
|
+
var import_date_picker2 = require("@ark-ui/react/date-picker");
|
|
71
|
+
var import_portal = require("@ark-ui/react/portal");
|
|
72
|
+
var import_date = require("@internationalized/date");
|
|
73
|
+
var import_i18n2 = require("@kopexa/i18n");
|
|
74
|
+
var import_react = require("react");
|
|
75
|
+
|
|
76
|
+
// src/date-picker-messages.ts
|
|
77
|
+
var import_i18n = require("@kopexa/i18n");
|
|
78
|
+
var datePickerMessages = (0, import_i18n.defineMessages)({
|
|
79
|
+
today: {
|
|
80
|
+
id: "date-picker.today",
|
|
81
|
+
defaultMessage: "Today",
|
|
82
|
+
description: "Button to select today's date"
|
|
83
|
+
},
|
|
84
|
+
clear: {
|
|
85
|
+
id: "date-picker.clear",
|
|
86
|
+
defaultMessage: "Clear",
|
|
87
|
+
description: "Button to clear the date"
|
|
88
|
+
},
|
|
89
|
+
open_calendar: {
|
|
90
|
+
id: "date-picker.open_calendar",
|
|
91
|
+
defaultMessage: "Open calendar",
|
|
92
|
+
description: "Aria label for calendar trigger button"
|
|
93
|
+
},
|
|
94
|
+
select_date: {
|
|
95
|
+
id: "date-picker.select_date",
|
|
96
|
+
defaultMessage: "Select date",
|
|
97
|
+
description: "Placeholder for date input"
|
|
98
|
+
},
|
|
99
|
+
select_date_and_time: {
|
|
100
|
+
id: "date-picker.select_date_and_time",
|
|
101
|
+
defaultMessage: "Select date and time",
|
|
102
|
+
description: "Placeholder for date+time input"
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// src/date-picker-field.tsx
|
|
107
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
108
|
+
function CalendarIcon({ className }) {
|
|
109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
110
|
+
"svg",
|
|
111
|
+
{
|
|
112
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
113
|
+
viewBox: "0 0 24 24",
|
|
114
|
+
fill: "none",
|
|
115
|
+
stroke: "currentColor",
|
|
116
|
+
strokeWidth: "2",
|
|
117
|
+
strokeLinecap: "round",
|
|
118
|
+
strokeLinejoin: "round",
|
|
119
|
+
className,
|
|
120
|
+
"aria-hidden": "true",
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 2v4" }),
|
|
123
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M16 2v4" }),
|
|
124
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { width: "18", height: "18", x: "3", y: "4", rx: "2" }),
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 10h18" })
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
function ChevronLeftIcon({ className }) {
|
|
131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
132
|
+
"svg",
|
|
133
|
+
{
|
|
134
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
135
|
+
viewBox: "0 0 24 24",
|
|
136
|
+
fill: "none",
|
|
137
|
+
stroke: "currentColor",
|
|
138
|
+
strokeWidth: "2",
|
|
139
|
+
strokeLinecap: "round",
|
|
140
|
+
strokeLinejoin: "round",
|
|
141
|
+
className,
|
|
142
|
+
"aria-hidden": "true",
|
|
143
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m15 18-6-6 6-6" })
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
function ChevronRightIcon({ className }) {
|
|
148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
149
|
+
"svg",
|
|
150
|
+
{
|
|
151
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
152
|
+
viewBox: "0 0 24 24",
|
|
153
|
+
fill: "none",
|
|
154
|
+
stroke: "currentColor",
|
|
155
|
+
strokeWidth: "2",
|
|
156
|
+
strokeLinecap: "round",
|
|
157
|
+
strokeLinejoin: "round",
|
|
158
|
+
className,
|
|
159
|
+
"aria-hidden": "true",
|
|
160
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m9 18 6-6-6-6" })
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
function XIcon({ className }) {
|
|
165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
166
|
+
"svg",
|
|
167
|
+
{
|
|
168
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
169
|
+
viewBox: "0 0 24 24",
|
|
170
|
+
fill: "none",
|
|
171
|
+
stroke: "currentColor",
|
|
172
|
+
strokeWidth: "2",
|
|
173
|
+
strokeLinecap: "round",
|
|
174
|
+
strokeLinejoin: "round",
|
|
175
|
+
className,
|
|
176
|
+
"aria-hidden": "true",
|
|
177
|
+
children: [
|
|
178
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18 6 6 18" }),
|
|
179
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m6 6 12 12" })
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
var styles = {
|
|
185
|
+
control: "relative flex items-center",
|
|
186
|
+
input: "w-full h-9 rounded-md border bg-transparent pl-3 pr-9 text-sm outline-none focus:ring-2 focus:ring-ring",
|
|
187
|
+
inputWithClear: "w-full h-9 rounded-md border bg-transparent pl-3 pr-16 text-sm outline-none focus:ring-2 focus:ring-ring",
|
|
188
|
+
trigger: "absolute right-0 inline-flex items-center justify-center size-9 text-muted-foreground hover:text-foreground transition-colors",
|
|
189
|
+
triggerWithClear: "inline-flex items-center justify-center size-9 text-muted-foreground hover:text-foreground transition-colors",
|
|
190
|
+
clearTrigger: "inline-flex items-center justify-center size-9 text-muted-foreground hover:text-foreground transition-colors",
|
|
191
|
+
iconButtons: "absolute right-0 flex items-center",
|
|
192
|
+
content: "z-50 bg-popover text-popover-foreground rounded-lg border shadow-md p-3 outline-none",
|
|
193
|
+
viewControl: "flex items-center justify-between mb-2",
|
|
194
|
+
navButton: "inline-flex items-center justify-center size-8 rounded-md hover:bg-muted transition-colors",
|
|
195
|
+
viewTrigger: "text-sm font-medium hover:bg-muted px-2 py-1 rounded-md transition-colors",
|
|
196
|
+
table: "w-full border-collapse",
|
|
197
|
+
tableRow: "flex",
|
|
198
|
+
tableHeader: "flex-1 text-center text-xs text-muted-foreground font-medium py-1.5",
|
|
199
|
+
tableCell: "flex-1 text-center p-0",
|
|
200
|
+
tableCellTrigger: "inline-flex items-center justify-center size-9 text-sm rounded-md transition-colors hover:bg-muted data-[selected]:bg-primary data-[selected]:text-primary-foreground data-[today]:font-bold data-[outside-range]:text-muted-foreground/40 data-[disabled]:text-muted-foreground/30 data-[disabled]:line-through data-[disabled]:pointer-events-none",
|
|
201
|
+
monthCell: "flex-1 text-center p-0.5",
|
|
202
|
+
monthCellTrigger: "inline-flex items-center justify-center w-full py-2.5 px-3 text-sm rounded-md transition-colors hover:bg-muted data-[selected]:bg-primary data-[selected]:text-primary-foreground data-[disabled]:text-muted-foreground/30 data-[disabled]:pointer-events-none",
|
|
203
|
+
yearCell: "flex-1 text-center p-0.5",
|
|
204
|
+
yearCellTrigger: "inline-flex items-center justify-center w-full py-2 text-sm rounded-md transition-colors hover:bg-muted data-[selected]:bg-primary data-[selected]:text-primary-foreground data-[disabled]:text-muted-foreground/30 data-[disabled]:pointer-events-none",
|
|
205
|
+
footer: "flex items-center gap-1 pt-2 mt-2 border-t",
|
|
206
|
+
footerButton: "text-sm px-2 py-1 rounded-md hover:bg-muted transition-colors",
|
|
207
|
+
timeInput: "h-9 rounded-md border bg-transparent px-3 text-sm outline-none focus:ring-2 focus:ring-ring",
|
|
208
|
+
label: "text-sm font-medium",
|
|
209
|
+
timeTrigger: "flex-1 h-9 rounded-md border bg-transparent px-3 text-sm text-left hover:bg-muted transition-colors flex items-center justify-between"
|
|
210
|
+
};
|
|
211
|
+
function DayView() {
|
|
212
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerView, { view: "day", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerContext, { children: (api) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
213
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_date_picker2.DatePickerViewControl, { className: styles.viewControl, children: [
|
|
214
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerPrevTrigger, { className: styles.navButton, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChevronLeftIcon, { className: "size-4" }) }),
|
|
215
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerViewTrigger, { className: styles.viewTrigger, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerRangeText, {}) }),
|
|
216
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerNextTrigger, { className: styles.navButton, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChevronRightIcon, { className: "size-4" }) })
|
|
217
|
+
] }),
|
|
218
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_date_picker2.DatePickerTable, { className: styles.table, children: [
|
|
219
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerTableHead, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerTableRow, { className: styles.tableRow, children: api.weekDays.map((weekDay, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
220
|
+
import_date_picker2.DatePickerTableHeader,
|
|
221
|
+
{
|
|
222
|
+
className: styles.tableHeader,
|
|
223
|
+
children: weekDay.short
|
|
224
|
+
},
|
|
225
|
+
i
|
|
226
|
+
)) }) }),
|
|
227
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerTableBody, { children: api.weeks.map((week, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
228
|
+
import_date_picker2.DatePickerTableRow,
|
|
229
|
+
{
|
|
230
|
+
className: styles.tableRow,
|
|
231
|
+
children: week.map((day, j) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
232
|
+
import_date_picker2.DatePickerTableCell,
|
|
233
|
+
{
|
|
234
|
+
value: day,
|
|
235
|
+
className: styles.tableCell,
|
|
236
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
237
|
+
import_date_picker2.DatePickerTableCellTrigger,
|
|
238
|
+
{
|
|
239
|
+
className: styles.tableCellTrigger,
|
|
240
|
+
children: day.day
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
},
|
|
244
|
+
j
|
|
245
|
+
))
|
|
246
|
+
},
|
|
247
|
+
i
|
|
248
|
+
)) })
|
|
249
|
+
] })
|
|
250
|
+
] }) }) });
|
|
251
|
+
}
|
|
252
|
+
function MonthView() {
|
|
253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerView, { view: "month", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerContext, { children: (api) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
254
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_date_picker2.DatePickerViewControl, { className: styles.viewControl, children: [
|
|
255
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerPrevTrigger, { className: styles.navButton, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChevronLeftIcon, { className: "size-4" }) }),
|
|
256
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerViewTrigger, { className: styles.viewTrigger, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerRangeText, {}) }),
|
|
257
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerNextTrigger, { className: styles.navButton, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChevronRightIcon, { className: "size-4" }) })
|
|
258
|
+
] }),
|
|
259
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerTable, { className: styles.table, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerTableBody, { children: api.getMonthsGrid({ columns: 3, format: "short" }).map((months, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
260
|
+
import_date_picker2.DatePickerTableRow,
|
|
261
|
+
{
|
|
262
|
+
className: styles.tableRow,
|
|
263
|
+
children: months.map((month, j) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
264
|
+
import_date_picker2.DatePickerTableCell,
|
|
265
|
+
{
|
|
266
|
+
value: month.value,
|
|
267
|
+
className: styles.monthCell,
|
|
268
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
269
|
+
import_date_picker2.DatePickerTableCellTrigger,
|
|
270
|
+
{
|
|
271
|
+
className: styles.monthCellTrigger,
|
|
272
|
+
children: month.label
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
},
|
|
276
|
+
j
|
|
277
|
+
))
|
|
278
|
+
},
|
|
279
|
+
i
|
|
280
|
+
)) }) })
|
|
281
|
+
] }) }) });
|
|
282
|
+
}
|
|
283
|
+
function YearView() {
|
|
284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerView, { view: "year", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerContext, { children: (api) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
285
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_date_picker2.DatePickerViewControl, { className: styles.viewControl, children: [
|
|
286
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerPrevTrigger, { className: styles.navButton, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChevronLeftIcon, { className: "size-4" }) }),
|
|
287
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerViewTrigger, { className: styles.viewTrigger, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerRangeText, {}) }),
|
|
288
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerNextTrigger, { className: styles.navButton, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChevronRightIcon, { className: "size-4" }) })
|
|
289
|
+
] }),
|
|
290
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerTable, { className: styles.table, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerTableBody, { children: api.getYearsGrid({ columns: 4 }).map((years, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
291
|
+
import_date_picker2.DatePickerTableRow,
|
|
292
|
+
{
|
|
293
|
+
className: styles.tableRow,
|
|
294
|
+
children: years.map((year, j) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
295
|
+
import_date_picker2.DatePickerTableCell,
|
|
296
|
+
{
|
|
297
|
+
value: year.value,
|
|
298
|
+
className: styles.yearCell,
|
|
299
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
300
|
+
import_date_picker2.DatePickerTableCellTrigger,
|
|
301
|
+
{
|
|
302
|
+
className: styles.yearCellTrigger,
|
|
303
|
+
children: year.label
|
|
304
|
+
}
|
|
305
|
+
)
|
|
306
|
+
},
|
|
307
|
+
j
|
|
308
|
+
))
|
|
309
|
+
},
|
|
310
|
+
i
|
|
311
|
+
)) }) })
|
|
312
|
+
] }) }) });
|
|
313
|
+
}
|
|
314
|
+
function CalendarFooter({
|
|
315
|
+
todayLabel,
|
|
316
|
+
clearLabel
|
|
317
|
+
}) {
|
|
318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerContext, { children: (api) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.footer, children: [
|
|
319
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
320
|
+
"button",
|
|
321
|
+
{
|
|
322
|
+
type: "button",
|
|
323
|
+
onClick: () => api.selectToday(),
|
|
324
|
+
className: `${styles.footerButton} text-foreground`,
|
|
325
|
+
children: todayLabel
|
|
326
|
+
}
|
|
327
|
+
),
|
|
328
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
329
|
+
"button",
|
|
330
|
+
{
|
|
331
|
+
type: "button",
|
|
332
|
+
onClick: () => api.clearValue(),
|
|
333
|
+
className: `${styles.footerButton} text-destructive`,
|
|
334
|
+
children: clearLabel
|
|
335
|
+
}
|
|
336
|
+
)
|
|
337
|
+
] }) });
|
|
338
|
+
}
|
|
339
|
+
function DatePickerField({
|
|
340
|
+
label,
|
|
341
|
+
value,
|
|
342
|
+
defaultValue,
|
|
343
|
+
onValueChange,
|
|
344
|
+
showTime = false,
|
|
345
|
+
clearable = true,
|
|
346
|
+
locale: localeProp,
|
|
347
|
+
min,
|
|
348
|
+
max,
|
|
349
|
+
disabled,
|
|
350
|
+
readOnly,
|
|
351
|
+
placeholder: placeholderProp,
|
|
352
|
+
todayLabel: todayLabelProp,
|
|
353
|
+
clearLabel: clearLabelProp,
|
|
354
|
+
className,
|
|
355
|
+
rootProps
|
|
356
|
+
}) {
|
|
357
|
+
var _a;
|
|
358
|
+
const intl = (0, import_i18n2.useSafeIntl)();
|
|
359
|
+
const locale = (_a = localeProp != null ? localeProp : intl.locale) != null ? _a : "en-US";
|
|
360
|
+
const todayLabel = todayLabelProp != null ? todayLabelProp : intl.formatMessage(datePickerMessages.today);
|
|
361
|
+
const clearLabel = clearLabelProp != null ? clearLabelProp : intl.formatMessage(datePickerMessages.clear);
|
|
362
|
+
const placeholder = placeholderProp != null ? placeholderProp : intl.formatMessage(
|
|
363
|
+
showTime ? datePickerMessages.select_date_and_time : datePickerMessages.select_date
|
|
364
|
+
);
|
|
365
|
+
if (showTime) {
|
|
366
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
367
|
+
DateTimePickerField,
|
|
368
|
+
{
|
|
369
|
+
label,
|
|
370
|
+
value,
|
|
371
|
+
defaultValue,
|
|
372
|
+
onValueChange,
|
|
373
|
+
clearable,
|
|
374
|
+
locale,
|
|
375
|
+
min,
|
|
376
|
+
max,
|
|
377
|
+
disabled,
|
|
378
|
+
readOnly,
|
|
379
|
+
placeholder,
|
|
380
|
+
todayLabel,
|
|
381
|
+
clearLabel,
|
|
382
|
+
className,
|
|
383
|
+
rootProps
|
|
384
|
+
}
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
388
|
+
import_date_picker2.DatePickerRoot,
|
|
389
|
+
{
|
|
390
|
+
value,
|
|
391
|
+
defaultValue,
|
|
392
|
+
onValueChange,
|
|
393
|
+
locale,
|
|
394
|
+
min,
|
|
395
|
+
max,
|
|
396
|
+
disabled,
|
|
397
|
+
readOnly,
|
|
398
|
+
selectionMode: "single",
|
|
399
|
+
closeOnSelect: true,
|
|
400
|
+
className,
|
|
401
|
+
...rootProps,
|
|
402
|
+
children: [
|
|
403
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerLabel, { className: styles.label, children: label }),
|
|
404
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_date_picker2.DatePickerControl, { className: styles.control, children: [
|
|
405
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
406
|
+
import_date_picker2.DatePickerInput,
|
|
407
|
+
{
|
|
408
|
+
className: clearable ? styles.inputWithClear : styles.input,
|
|
409
|
+
placeholder
|
|
410
|
+
}
|
|
411
|
+
),
|
|
412
|
+
clearable && !disabled && !readOnly ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.iconButtons, children: [
|
|
413
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerClearTrigger, { className: styles.clearTrigger, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XIcon, { className: "size-4" }) }),
|
|
414
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerTrigger, { className: styles.triggerWithClear, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarIcon, { className: "size-4" }) })
|
|
415
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerTrigger, { className: styles.trigger, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarIcon, { className: "size-4" }) })
|
|
416
|
+
] }),
|
|
417
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerPositioner, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_date_picker2.DatePickerContent, { className: styles.content, children: [
|
|
418
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DayView, {}),
|
|
419
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MonthView, {}),
|
|
420
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(YearView, {}),
|
|
421
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarFooter, { todayLabel, clearLabel })
|
|
422
|
+
] }) }) })
|
|
423
|
+
]
|
|
424
|
+
}
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
function DateTimePickerField({
|
|
428
|
+
label,
|
|
429
|
+
value: valueProp,
|
|
430
|
+
defaultValue,
|
|
431
|
+
onValueChange,
|
|
432
|
+
clearable = true,
|
|
433
|
+
locale: localeProp,
|
|
434
|
+
min,
|
|
435
|
+
max,
|
|
436
|
+
disabled,
|
|
437
|
+
readOnly,
|
|
438
|
+
placeholder: placeholderProp,
|
|
439
|
+
todayLabel: todayLabelProp,
|
|
440
|
+
clearLabel: clearLabelProp,
|
|
441
|
+
className,
|
|
442
|
+
rootProps
|
|
443
|
+
}) {
|
|
444
|
+
var _a;
|
|
445
|
+
const intl = (0, import_i18n2.useSafeIntl)();
|
|
446
|
+
const locale = (_a = localeProp != null ? localeProp : intl.locale) != null ? _a : "en-US";
|
|
447
|
+
const todayLabel = todayLabelProp != null ? todayLabelProp : intl.formatMessage(datePickerMessages.today);
|
|
448
|
+
const clearLabel = clearLabelProp != null ? clearLabelProp : intl.formatMessage(datePickerMessages.clear);
|
|
449
|
+
const placeholder = placeholderProp != null ? placeholderProp : intl.formatMessage(datePickerMessages.select_date_and_time);
|
|
450
|
+
const [internalValue, setInternalValue] = (0, import_react.useState)(() => {
|
|
451
|
+
const initial = valueProp != null ? valueProp : defaultValue;
|
|
452
|
+
if (!initial || initial.length === 0) return [];
|
|
453
|
+
const v = initial[0];
|
|
454
|
+
if ("hour" in v) return [v];
|
|
455
|
+
return [new import_date.CalendarDateTime(v.year, v.month, v.day, 0, 0, 0)];
|
|
456
|
+
});
|
|
457
|
+
const currentValue = (0, import_react.useMemo)(() => {
|
|
458
|
+
if (valueProp === void 0) return internalValue;
|
|
459
|
+
if (!valueProp || valueProp.length === 0) return [];
|
|
460
|
+
const v = valueProp[0];
|
|
461
|
+
if ("hour" in v) return [v];
|
|
462
|
+
return [new import_date.CalendarDateTime(v.year, v.month, v.day, 0, 0, 0)];
|
|
463
|
+
}, [valueProp, internalValue]);
|
|
464
|
+
const handleDateChange = (0, import_react.useCallback)(
|
|
465
|
+
(details) => {
|
|
466
|
+
var _a2;
|
|
467
|
+
const newDate = details.value[0];
|
|
468
|
+
if (!newDate) {
|
|
469
|
+
setInternalValue([]);
|
|
470
|
+
onValueChange == null ? void 0 : onValueChange(details);
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
const prevTime = (_a2 = currentValue[0]) != null ? _a2 : { hour: 0, minute: 0, second: 0 };
|
|
474
|
+
const merged = new import_date.CalendarDateTime(
|
|
475
|
+
newDate.year,
|
|
476
|
+
newDate.month,
|
|
477
|
+
newDate.day,
|
|
478
|
+
"hour" in prevTime ? prevTime.hour : 0,
|
|
479
|
+
"minute" in prevTime ? prevTime.minute : 0,
|
|
480
|
+
"second" in prevTime ? prevTime.second : 0
|
|
481
|
+
);
|
|
482
|
+
setInternalValue([merged]);
|
|
483
|
+
onValueChange == null ? void 0 : onValueChange({ ...details, value: [merged] });
|
|
484
|
+
},
|
|
485
|
+
[currentValue, onValueChange]
|
|
486
|
+
);
|
|
487
|
+
const timeValue = currentValue[0] ? `${String(currentValue[0].hour).padStart(2, "0")}:${String(currentValue[0].minute).padStart(2, "0")}` : "";
|
|
488
|
+
const handleTimeChange = (0, import_react.useCallback)(
|
|
489
|
+
(e) => {
|
|
490
|
+
var _a2;
|
|
491
|
+
const [hours, minutes] = e.currentTarget.value.split(":").map(Number);
|
|
492
|
+
const now = /* @__PURE__ */ new Date();
|
|
493
|
+
const fallback = new import_date.CalendarDateTime(
|
|
494
|
+
now.getFullYear(),
|
|
495
|
+
now.getMonth() + 1,
|
|
496
|
+
now.getDate(),
|
|
497
|
+
0,
|
|
498
|
+
0
|
|
499
|
+
);
|
|
500
|
+
const current = (_a2 = currentValue[0]) != null ? _a2 : fallback;
|
|
501
|
+
const updated = current.set({ hour: hours, minute: minutes });
|
|
502
|
+
setInternalValue([updated]);
|
|
503
|
+
onValueChange == null ? void 0 : onValueChange({
|
|
504
|
+
value: [updated],
|
|
505
|
+
valueAsString: [updated.toString()],
|
|
506
|
+
view: "day"
|
|
507
|
+
});
|
|
508
|
+
},
|
|
509
|
+
[currentValue, onValueChange]
|
|
510
|
+
);
|
|
511
|
+
const handleClear = (0, import_react.useCallback)(() => {
|
|
512
|
+
setInternalValue([]);
|
|
513
|
+
onValueChange == null ? void 0 : onValueChange({
|
|
514
|
+
value: [],
|
|
515
|
+
valueAsString: [],
|
|
516
|
+
view: "day"
|
|
517
|
+
});
|
|
518
|
+
}, [onValueChange]);
|
|
519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
520
|
+
import_date_picker2.DatePickerRoot,
|
|
521
|
+
{
|
|
522
|
+
value: currentValue,
|
|
523
|
+
onValueChange: handleDateChange,
|
|
524
|
+
locale,
|
|
525
|
+
min,
|
|
526
|
+
max,
|
|
527
|
+
disabled,
|
|
528
|
+
readOnly,
|
|
529
|
+
selectionMode: "single",
|
|
530
|
+
closeOnSelect: false,
|
|
531
|
+
className,
|
|
532
|
+
...rootProps,
|
|
533
|
+
children: [
|
|
534
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerLabel, { className: styles.label, children: label }),
|
|
535
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_date_picker2.DatePickerControl, { className: "flex items-center gap-1", children: [
|
|
536
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative flex-1 flex items-center", children: [
|
|
537
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerInput, { className: styles.input, placeholder }),
|
|
538
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerTrigger, { className: styles.trigger, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarIcon, { className: "size-4" }) })
|
|
539
|
+
] }),
|
|
540
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
541
|
+
"input",
|
|
542
|
+
{
|
|
543
|
+
type: "time",
|
|
544
|
+
value: timeValue,
|
|
545
|
+
onChange: handleTimeChange,
|
|
546
|
+
disabled,
|
|
547
|
+
readOnly,
|
|
548
|
+
className: styles.timeInput
|
|
549
|
+
}
|
|
550
|
+
),
|
|
551
|
+
clearable && !disabled && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
552
|
+
import_date_picker2.DatePickerClearTrigger,
|
|
553
|
+
{
|
|
554
|
+
className: "inline-flex items-center justify-center size-9 rounded-md border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",
|
|
555
|
+
onClick: handleClear,
|
|
556
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(XIcon, { className: "size-4" })
|
|
557
|
+
}
|
|
558
|
+
)
|
|
559
|
+
] }),
|
|
560
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_date_picker2.DatePickerPositioner, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_date_picker2.DatePickerContent, { className: styles.content, children: [
|
|
561
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DayView, {}),
|
|
562
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MonthView, {}),
|
|
563
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(YearView, {}),
|
|
564
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CalendarFooter, { todayLabel, clearLabel })
|
|
565
|
+
] }) }) })
|
|
566
|
+
]
|
|
567
|
+
}
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
571
|
+
0 && (module.exports = {
|
|
572
|
+
CalendarDate,
|
|
573
|
+
CalendarDateTime,
|
|
574
|
+
DateFormatter,
|
|
575
|
+
DatePicker,
|
|
576
|
+
DatePickerField,
|
|
577
|
+
datePickerMessages,
|
|
578
|
+
getLocalTimeZone,
|
|
579
|
+
parseDate
|
|
580
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
DatePickerField
|
|
4
|
+
} from "./chunk-2C5V7ODF.mjs";
|
|
5
|
+
import {
|
|
6
|
+
datePickerMessages
|
|
7
|
+
} from "./chunk-HPM5Y2V6.mjs";
|
|
8
|
+
import {
|
|
9
|
+
date_picker_exports,
|
|
10
|
+
parseDate
|
|
11
|
+
} from "./chunk-UD6PYKLX.mjs";
|
|
12
|
+
import "./chunk-C7GZJJIK.mjs";
|
|
13
|
+
|
|
14
|
+
// src/index.ts
|
|
15
|
+
import {
|
|
16
|
+
CalendarDate,
|
|
17
|
+
CalendarDateTime,
|
|
18
|
+
DateFormatter,
|
|
19
|
+
getLocalTimeZone
|
|
20
|
+
} from "@internationalized/date";
|
|
21
|
+
export {
|
|
22
|
+
CalendarDate,
|
|
23
|
+
CalendarDateTime,
|
|
24
|
+
DateFormatter,
|
|
25
|
+
date_picker_exports as DatePicker,
|
|
26
|
+
DatePickerField,
|
|
27
|
+
datePickerMessages,
|
|
28
|
+
getLocalTimeZone,
|
|
29
|
+
parseDate
|
|
30
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kopexa/date-picker",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "DatePicker component for selecting dates and times",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"date-picker",
|
|
7
|
+
"datetime",
|
|
8
|
+
"calendar"
|
|
9
|
+
],
|
|
10
|
+
"author": "Kopexa <hello@kopexa.com>",
|
|
11
|
+
"homepage": "https://kopexa.com",
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/kopexa-grc/sight.git",
|
|
24
|
+
"directory": "packages/components/date-picker"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"react": ">=19.0.0-rc.0",
|
|
28
|
+
"react-dom": ">=19.0.0-rc.0"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@ark-ui/react": "^5.35.0",
|
|
32
|
+
"@internationalized/date": "^3.12.0",
|
|
33
|
+
"@kopexa/i18n": "17.13.0"
|
|
34
|
+
},
|
|
35
|
+
"clean-package": "../../../clean-package.config.json",
|
|
36
|
+
"module": "dist/index.mjs",
|
|
37
|
+
"types": "dist/index.d.ts",
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"import": "./dist/index.mjs",
|
|
42
|
+
"require": "./dist/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup src --dts",
|
|
48
|
+
"build:fast": "tsup src",
|
|
49
|
+
"dev": "pnpm build:fast --watch",
|
|
50
|
+
"clean": "rimraf dist .turbo",
|
|
51
|
+
"typecheck": "tsc --noEmit"
|
|
52
|
+
}
|
|
53
|
+
}
|