@duskmoon-dev/components 0.3.1 → 0.4.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/README.md +61 -2
- package/dist/{chunk-r9wkv7xd.js → chunk-fwjzvsrx.js} +3 -3
- package/dist/classes/chat.d.ts +43 -0
- package/dist/classes/console-page.d.ts +16 -0
- package/dist/classes/dropdown.d.ts +5 -5
- package/dist/classes/fab.d.ts +11 -0
- package/dist/classes/index.d.ts +6 -0
- package/dist/classes/index.js +1443 -1210
- package/dist/classes/megamenu.d.ts +10 -0
- package/dist/classes/otp-input.d.ts +12 -0
- package/dist/classes/popover.d.ts +1 -3
- package/dist/classes/swap.d.ts +12 -0
- package/dist/classes/tree-select.d.ts +6 -6
- package/dist/components/anchor/index.js +2 -2
- package/dist/components/app/index.js +211 -151
- package/dist/components/avatar/Avatar.types.d.ts +1 -1
- package/dist/components/avatar/index.js +2 -1
- package/dist/components/badge/index.js +1 -1
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/button/Button.types.d.ts +8 -0
- package/dist/components/button/index.js +253 -24
- package/dist/components/calendar/index.js +44 -19
- package/dist/components/cascader/index.js +2 -2
- package/dist/components/chat/Chat.d.ts +22 -0
- package/dist/components/chat/Chat.types.d.ts +73 -0
- package/dist/components/chat/index.d.ts +2 -0
- package/dist/components/chat/index.js +309 -0
- package/dist/components/color-picker/ColorPicker.types.d.ts +2 -1
- package/dist/components/color-picker/index.js +210 -13
- package/dist/components/config-provider/index.js +2 -2
- package/dist/components/console-page/ConsolePage.d.ts +2 -0
- package/dist/components/console-page/ConsolePage.types.d.ts +29 -0
- package/dist/components/console-page/index.d.ts +2 -0
- package/dist/components/console-page/index.js +205 -0
- package/dist/components/date-picker/DatePicker.types.d.ts +1 -0
- package/dist/components/date-picker/index.js +537 -35
- package/dist/components/date-picker/usePickerDropdown.d.ts +17 -0
- package/dist/components/dm-breadcrumb/index.js +18 -18
- package/dist/components/dm-date-picker/index.js +635 -133
- package/dist/components/dm-drawer/index.js +269 -40
- package/dist/components/dm-layout/index.js +575 -208
- package/dist/components/dm-menu/index.js +399 -32
- package/dist/components/dm-message/index.js +18 -18
- package/dist/components/dm-page-header/index.js +537 -247
- package/dist/components/dm-pagination/index.js +39 -39
- package/dist/components/dm-pro-table/index.js +2374 -1559
- package/dist/components/dm-provider/index.js +94 -94
- package/dist/components/dm-query/DmQuery.types.d.ts +1 -1
- package/dist/components/dm-query/index.js +955 -210
- package/dist/components/dm-search/DmSearch.types.d.ts +4 -0
- package/dist/components/dm-search/index.js +937 -183
- package/dist/components/dm-splitter/index.js +32 -32
- package/dist/components/dm-status/index.js +25 -25
- package/dist/components/dm-table/index.js +1430 -676
- package/dist/components/dm-tabs/index.js +34 -34
- package/dist/components/dm-toolbar/index.js +423 -133
- package/dist/components/dm-tree/index.js +92 -92
- package/dist/components/dm-truncate/index.js +145 -65
- package/dist/components/dropdown/Dropdown.types.d.ts +1 -1
- package/dist/components/dropdown/index.js +467 -177
- package/dist/components/fab/Fab.d.ts +4 -0
- package/dist/components/fab/Fab.types.d.ts +25 -0
- package/dist/components/fab/index.d.ts +2 -0
- package/dist/components/fab/index.js +480 -0
- package/dist/components/form/Form.types.d.ts +1 -0
- package/dist/components/form/index.js +16 -5
- package/dist/components/grid/index.js +2 -2
- package/dist/components/input/index.js +4 -4
- package/dist/components/markdown/index.js +1 -1
- package/dist/components/megamenu/Megamenu.d.ts +2 -0
- package/dist/components/megamenu/Megamenu.types.d.ts +32 -0
- package/dist/components/megamenu/index.d.ts +2 -0
- package/dist/components/megamenu/index.js +214 -0
- package/dist/components/message/index.js +5 -5
- package/dist/components/modal/index.js +128 -68
- package/dist/components/notification/index.js +2 -2
- package/dist/components/otp-input/OtpInput.d.ts +2 -0
- package/dist/components/otp-input/OtpInput.types.d.ts +16 -0
- package/dist/components/otp-input/index.d.ts +2 -0
- package/dist/components/otp-input/index.js +112 -0
- package/dist/components/popconfirm/index.js +297 -68
- package/dist/components/popover/index.js +24 -4
- package/dist/components/skeleton/index.js +5 -5
- package/dist/components/spin/index.js +2 -2
- package/dist/components/steps/index.js +2 -2
- package/dist/components/swap/Swap.d.ts +3 -0
- package/dist/components/swap/Swap.types.d.ts +22 -0
- package/dist/components/swap/index.d.ts +2 -0
- package/dist/components/swap/index.js +109 -0
- package/dist/components/table/index.js +2 -2
- package/dist/components/tabs/index.js +2 -2
- package/dist/components/tag/index.js +2 -2
- package/dist/components/time-picker/TimePicker.types.d.ts +1 -0
- package/dist/components/time-picker/index.js +167 -29
- package/dist/components/tooltip/Tooltip.types.d.ts +4 -0
- package/dist/components/tooltip/index.js +107 -27
- package/dist/components/tour/index.js +315 -86
- package/dist/components/tree-select/index.js +8 -8
- package/dist/components/typography/index.js +4 -4
- package/dist/components/upload/Upload.types.d.ts +1 -0
- package/dist/components/upload/index.js +7 -5
- package/dist/generated/version.d.ts +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4023 -2134
- package/dist/infrastructure.js +11 -11
- package/dist/styles.css +13677 -9811
- package/dist/theme/index.js +3 -3
- package/dist/utils/index.js +5 -5
- package/package.json +30 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
// src/components/date-picker/
|
|
4
|
-
import { forwardRef
|
|
3
|
+
// src/components/dm-date-picker/DmDatePicker.tsx
|
|
4
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
5
5
|
|
|
6
6
|
// ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
7
7
|
function r(e) {
|
|
@@ -28,6 +28,510 @@ function clsx() {
|
|
|
28
28
|
function cn(...inputs) {
|
|
29
29
|
return clsx(inputs);
|
|
30
30
|
}
|
|
31
|
+
// src/classes/dm-date-picker.ts
|
|
32
|
+
var dmDatePickerClass = "dm-date-picker";
|
|
33
|
+
function getDmDatePickerClasses({ className }) {
|
|
34
|
+
return cn(dmDatePickerClass, className);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/infrastructure.ts
|
|
38
|
+
import { useCallback, useState } from "react";
|
|
39
|
+
var primaryColor = "#0065ff";
|
|
40
|
+
var prefixCls = "dm";
|
|
41
|
+
var datePickerLocale = "en";
|
|
42
|
+
var themeUpdateCallbacks = new Set;
|
|
43
|
+
function emitThemeUpdate() {
|
|
44
|
+
for (const callback of themeUpdateCallbacks) {
|
|
45
|
+
callback();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function setDmPrefixCls(nextPrefixCls) {
|
|
49
|
+
prefixCls = nextPrefixCls;
|
|
50
|
+
emitThemeUpdate();
|
|
51
|
+
}
|
|
52
|
+
function setDmPrimaryColor(color) {
|
|
53
|
+
primaryColor = color;
|
|
54
|
+
emitThemeUpdate();
|
|
55
|
+
}
|
|
56
|
+
function onDmThemeUpdate(callback) {
|
|
57
|
+
themeUpdateCallbacks.add(callback);
|
|
58
|
+
return () => {
|
|
59
|
+
themeUpdateCallbacks.delete(callback);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function getDmTheme() {
|
|
63
|
+
return {
|
|
64
|
+
prefixCls,
|
|
65
|
+
token: {
|
|
66
|
+
colorInfo: primaryColor,
|
|
67
|
+
colorPrimary: primaryColor,
|
|
68
|
+
colorLink: primaryColor
|
|
69
|
+
},
|
|
70
|
+
components: {
|
|
71
|
+
Table: {
|
|
72
|
+
cellFontSizeSM: 12,
|
|
73
|
+
cellPaddingBlockSM: 10,
|
|
74
|
+
headerColor: "#5a607f"
|
|
75
|
+
},
|
|
76
|
+
Breadcrumb: {
|
|
77
|
+
linkColor: "#5a607f",
|
|
78
|
+
linkHoverColor: "#5a607f",
|
|
79
|
+
itemColor: "#5a607f",
|
|
80
|
+
lastItemColor: "#2f2e3f",
|
|
81
|
+
separatorColor: "#5a607f"
|
|
82
|
+
},
|
|
83
|
+
Menu: {
|
|
84
|
+
collapsedWidth: 60,
|
|
85
|
+
itemMarginBlock: 8,
|
|
86
|
+
itemMarginInline: 10,
|
|
87
|
+
itemPaddingInline: 10
|
|
88
|
+
},
|
|
89
|
+
Input: {
|
|
90
|
+
activeBorderColor: primaryColor
|
|
91
|
+
},
|
|
92
|
+
Tabs: {
|
|
93
|
+
inkBarColor: primaryColor,
|
|
94
|
+
itemSelectedColor: primaryColor
|
|
95
|
+
},
|
|
96
|
+
DatePicker: {
|
|
97
|
+
activeBorderColor: primaryColor
|
|
98
|
+
},
|
|
99
|
+
Tree: {
|
|
100
|
+
directoryNodeSelectedBg: primaryColor
|
|
101
|
+
},
|
|
102
|
+
Radio: {
|
|
103
|
+
buttonSolidCheckedBg: primaryColor
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function setDmDatePickerLocale(locale) {
|
|
109
|
+
datePickerLocale = locale;
|
|
110
|
+
}
|
|
111
|
+
function getDmDatePickerLocale() {
|
|
112
|
+
return datePickerLocale;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/components/date-picker/DatePicker.tsx
|
|
116
|
+
import { forwardRef as forwardRef2, useMemo as useMemo2, useState as useState4 } from "react";
|
|
117
|
+
|
|
118
|
+
// src/components/calendar/Calendar.tsx
|
|
119
|
+
import { forwardRef, useMemo, useState as useState2 } from "react";
|
|
120
|
+
|
|
121
|
+
// src/classes/calendar.ts
|
|
122
|
+
var calendarBaseClass = "datepicker calendar";
|
|
123
|
+
var calendarHeaderClass = "calendar-header";
|
|
124
|
+
var calendarTitleClass = "calendar-title";
|
|
125
|
+
var calendarControlsClass = "calendar-controls";
|
|
126
|
+
var calendarNavClass = "calendar-nav";
|
|
127
|
+
var calendarModeClass = "calendar-mode";
|
|
128
|
+
var calendarWeekdaysClass = "calendar-weekdays";
|
|
129
|
+
var calendarWeekdayClass = "calendar-weekday";
|
|
130
|
+
var calendarBodyClass = "calendar-body";
|
|
131
|
+
var calendarDateGridClass = "calendar-date-grid";
|
|
132
|
+
var calendarMonthGridClass = "calendar-month-grid";
|
|
133
|
+
var calendarCellContentClass = "calendar-cell-content";
|
|
134
|
+
function getCalendarClasses({
|
|
135
|
+
fullscreen = true,
|
|
136
|
+
mode = "month",
|
|
137
|
+
className
|
|
138
|
+
}) {
|
|
139
|
+
return cn(calendarBaseClass, fullscreen ? "calendar-fullscreen" : "calendar-card", mode === "year" && "calendar-year-mode", className);
|
|
140
|
+
}
|
|
141
|
+
function getCalendarCellClasses({
|
|
142
|
+
selected,
|
|
143
|
+
today,
|
|
144
|
+
outside,
|
|
145
|
+
disabled,
|
|
146
|
+
className
|
|
147
|
+
}) {
|
|
148
|
+
return cn("calendar-cell", selected && "calendar-cell-selected", today && "calendar-cell-today", outside && "calendar-cell-outside", disabled && "calendar-cell-disabled", className);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// src/components/calendar/Calendar.tsx
|
|
152
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
153
|
+
var WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
154
|
+
var MONTHS = [
|
|
155
|
+
"Jan",
|
|
156
|
+
"Feb",
|
|
157
|
+
"Mar",
|
|
158
|
+
"Apr",
|
|
159
|
+
"May",
|
|
160
|
+
"Jun",
|
|
161
|
+
"Jul",
|
|
162
|
+
"Aug",
|
|
163
|
+
"Sep",
|
|
164
|
+
"Oct",
|
|
165
|
+
"Nov",
|
|
166
|
+
"Dec"
|
|
167
|
+
];
|
|
168
|
+
function pad(value) {
|
|
169
|
+
return String(value).padStart(2, "0");
|
|
170
|
+
}
|
|
171
|
+
function formatDate(date) {
|
|
172
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
173
|
+
}
|
|
174
|
+
function formatMonth(date) {
|
|
175
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-01`;
|
|
176
|
+
}
|
|
177
|
+
function parseDate(value) {
|
|
178
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) {
|
|
179
|
+
return new Date(value.getFullYear(), value.getMonth(), value.getDate());
|
|
180
|
+
}
|
|
181
|
+
if (typeof value === "string" && value.length > 0) {
|
|
182
|
+
const [year, month = "1", day = "1"] = value.split("-");
|
|
183
|
+
const parsed = new Date(Number(year), Number(month) - 1, Number(day));
|
|
184
|
+
if (!Number.isNaN(parsed.getTime())) {
|
|
185
|
+
return parsed;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const today = new Date;
|
|
189
|
+
return new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
190
|
+
}
|
|
191
|
+
function addMonths(date, amount) {
|
|
192
|
+
return new Date(date.getFullYear(), date.getMonth() + amount, 1);
|
|
193
|
+
}
|
|
194
|
+
function addYears(date, amount) {
|
|
195
|
+
return new Date(date.getFullYear() + amount, date.getMonth(), 1);
|
|
196
|
+
}
|
|
197
|
+
function startOfCalendarGrid(panelDate) {
|
|
198
|
+
const firstOfMonth = new Date(panelDate.getFullYear(), panelDate.getMonth(), 1);
|
|
199
|
+
const start = new Date(firstOfMonth);
|
|
200
|
+
start.setDate(firstOfMonth.getDate() - firstOfMonth.getDay());
|
|
201
|
+
return start;
|
|
202
|
+
}
|
|
203
|
+
function buildDateGrid(panelDate) {
|
|
204
|
+
const start = startOfCalendarGrid(panelDate);
|
|
205
|
+
return Array.from({ length: 42 }, (_, index) => {
|
|
206
|
+
const date = new Date(start);
|
|
207
|
+
date.setDate(start.getDate() + index);
|
|
208
|
+
return date;
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function isSameMonth(left, right) {
|
|
212
|
+
return left.getFullYear() === right.getFullYear() && left.getMonth() === right.getMonth();
|
|
213
|
+
}
|
|
214
|
+
function isOutsideRange(date, validRange) {
|
|
215
|
+
if (!validRange) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
const current = formatDate(date);
|
|
219
|
+
const start = formatDate(parseDate(validRange[0]));
|
|
220
|
+
const end = formatDate(parseDate(validRange[1]));
|
|
221
|
+
return current < start || current > end;
|
|
222
|
+
}
|
|
223
|
+
function Header({
|
|
224
|
+
panelDate,
|
|
225
|
+
mode,
|
|
226
|
+
setPanelDate,
|
|
227
|
+
setMode
|
|
228
|
+
}) {
|
|
229
|
+
const title = mode === "year" ? String(panelDate.getFullYear()) : `${MONTHS[panelDate.getMonth()]} ${panelDate.getFullYear()}`;
|
|
230
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
231
|
+
className: calendarHeaderClass,
|
|
232
|
+
children: [
|
|
233
|
+
/* @__PURE__ */ jsx("button", {
|
|
234
|
+
type: "button",
|
|
235
|
+
className: calendarNavClass,
|
|
236
|
+
"aria-label": "Previous panel",
|
|
237
|
+
onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, -1) : addMonths(panelDate, -1), mode),
|
|
238
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
239
|
+
"aria-hidden": "true",
|
|
240
|
+
focusable: "false",
|
|
241
|
+
width: "16",
|
|
242
|
+
height: "16",
|
|
243
|
+
viewBox: "0 0 24 24",
|
|
244
|
+
fill: "none",
|
|
245
|
+
stroke: "currentColor",
|
|
246
|
+
strokeWidth: "2",
|
|
247
|
+
strokeLinecap: "round",
|
|
248
|
+
strokeLinejoin: "round",
|
|
249
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
250
|
+
d: "m15 18-6-6 6-6"
|
|
251
|
+
})
|
|
252
|
+
})
|
|
253
|
+
}),
|
|
254
|
+
/* @__PURE__ */ jsxs("div", {
|
|
255
|
+
className: calendarControlsClass,
|
|
256
|
+
children: [
|
|
257
|
+
/* @__PURE__ */ jsx("div", {
|
|
258
|
+
className: calendarTitleClass,
|
|
259
|
+
children: title
|
|
260
|
+
}),
|
|
261
|
+
/* @__PURE__ */ jsxs("div", {
|
|
262
|
+
className: calendarModeClass,
|
|
263
|
+
children: [
|
|
264
|
+
/* @__PURE__ */ jsx("button", {
|
|
265
|
+
type: "button",
|
|
266
|
+
"aria-pressed": mode === "month",
|
|
267
|
+
onClick: () => setMode("month"),
|
|
268
|
+
children: "Month"
|
|
269
|
+
}),
|
|
270
|
+
/* @__PURE__ */ jsx("button", {
|
|
271
|
+
type: "button",
|
|
272
|
+
"aria-pressed": mode === "year",
|
|
273
|
+
onClick: () => setMode("year"),
|
|
274
|
+
children: "Year"
|
|
275
|
+
})
|
|
276
|
+
]
|
|
277
|
+
})
|
|
278
|
+
]
|
|
279
|
+
}),
|
|
280
|
+
/* @__PURE__ */ jsx("button", {
|
|
281
|
+
type: "button",
|
|
282
|
+
className: calendarNavClass,
|
|
283
|
+
"aria-label": "Next panel",
|
|
284
|
+
onClick: () => setPanelDate(mode === "year" ? addYears(panelDate, 1) : addMonths(panelDate, 1), mode),
|
|
285
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
286
|
+
"aria-hidden": "true",
|
|
287
|
+
focusable: "false",
|
|
288
|
+
width: "16",
|
|
289
|
+
height: "16",
|
|
290
|
+
viewBox: "0 0 24 24",
|
|
291
|
+
fill: "none",
|
|
292
|
+
stroke: "currentColor",
|
|
293
|
+
strokeWidth: "2",
|
|
294
|
+
strokeLinecap: "round",
|
|
295
|
+
strokeLinejoin: "round",
|
|
296
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
297
|
+
d: "m9 18 6-6-6-6"
|
|
298
|
+
})
|
|
299
|
+
})
|
|
300
|
+
})
|
|
301
|
+
]
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
var Calendar = forwardRef(({
|
|
305
|
+
className,
|
|
306
|
+
value,
|
|
307
|
+
defaultValue,
|
|
308
|
+
mode,
|
|
309
|
+
defaultMode = "month",
|
|
310
|
+
fullscreen = true,
|
|
311
|
+
validRange,
|
|
312
|
+
disabledDate,
|
|
313
|
+
dateCellRender,
|
|
314
|
+
dateFullCellRender,
|
|
315
|
+
monthCellRender,
|
|
316
|
+
monthFullCellRender,
|
|
317
|
+
cellRender,
|
|
318
|
+
fullCellRender,
|
|
319
|
+
headerRender,
|
|
320
|
+
onChange,
|
|
321
|
+
onSelect,
|
|
322
|
+
onPanelChange,
|
|
323
|
+
...props
|
|
324
|
+
}, ref) => {
|
|
325
|
+
const selectedDate = parseDate(value ?? defaultValue);
|
|
326
|
+
const [innerValue, setInnerValue] = useState2(() => formatDate(selectedDate));
|
|
327
|
+
const [panelDate, setInnerPanelDate] = useState2(selectedDate);
|
|
328
|
+
const [innerMode, setInnerMode] = useState2(mode ?? defaultMode);
|
|
329
|
+
const currentMode = mode ?? innerMode;
|
|
330
|
+
const currentValue = value === undefined ? innerValue : formatDate(parseDate(value));
|
|
331
|
+
const today = useMemo(() => formatDate(new Date), []);
|
|
332
|
+
const dateGrid = useMemo(() => buildDateGrid(panelDate), [panelDate]);
|
|
333
|
+
function emitPanelChange(nextDate, nextMode = currentMode) {
|
|
334
|
+
setInnerPanelDate(nextDate);
|
|
335
|
+
onPanelChange?.(formatDate(nextDate), nextMode);
|
|
336
|
+
}
|
|
337
|
+
function setCalendarMode(nextMode) {
|
|
338
|
+
if (mode === undefined) {
|
|
339
|
+
setInnerMode(nextMode);
|
|
340
|
+
}
|
|
341
|
+
onPanelChange?.(formatDate(panelDate), nextMode);
|
|
342
|
+
}
|
|
343
|
+
function commitValue(nextDate, source) {
|
|
344
|
+
const nextValue = source === "month" ? formatMonth(nextDate) : formatDate(nextDate);
|
|
345
|
+
if (disabledDate?.(nextValue) || isOutsideRange(nextDate, validRange)) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (value === undefined) {
|
|
349
|
+
setInnerValue(nextValue);
|
|
350
|
+
}
|
|
351
|
+
setInnerPanelDate(nextDate);
|
|
352
|
+
onSelect?.(nextValue, { source });
|
|
353
|
+
onChange?.(nextValue);
|
|
354
|
+
}
|
|
355
|
+
function renderDateCell(date) {
|
|
356
|
+
const dateValue = formatDate(date);
|
|
357
|
+
const originNode = /* @__PURE__ */ jsxs("div", {
|
|
358
|
+
className: calendarCellContentClass,
|
|
359
|
+
children: [
|
|
360
|
+
/* @__PURE__ */ jsx("span", {
|
|
361
|
+
children: date.getDate()
|
|
362
|
+
}),
|
|
363
|
+
dateCellRender?.(dateValue)
|
|
364
|
+
]
|
|
365
|
+
});
|
|
366
|
+
const info = {
|
|
367
|
+
originNode,
|
|
368
|
+
today,
|
|
369
|
+
type: "month"
|
|
370
|
+
};
|
|
371
|
+
const content = fullCellRender?.(dateValue, info) ?? dateFullCellRender?.(dateValue) ?? cellRender?.(dateValue, info) ?? originNode;
|
|
372
|
+
const disabled = disabledDate?.(dateValue) || isOutsideRange(date, validRange);
|
|
373
|
+
return /* @__PURE__ */ jsx("button", {
|
|
374
|
+
type: "button",
|
|
375
|
+
"aria-label": dateValue,
|
|
376
|
+
disabled,
|
|
377
|
+
className: getCalendarCellClasses({
|
|
378
|
+
selected: dateValue === currentValue,
|
|
379
|
+
today: dateValue === today,
|
|
380
|
+
outside: !isSameMonth(date, panelDate),
|
|
381
|
+
disabled
|
|
382
|
+
}),
|
|
383
|
+
onClick: () => commitValue(date, "date"),
|
|
384
|
+
children: content
|
|
385
|
+
}, dateValue);
|
|
386
|
+
}
|
|
387
|
+
function renderMonthCell(month) {
|
|
388
|
+
const date = new Date(panelDate.getFullYear(), month, 1);
|
|
389
|
+
const dateValue = formatMonth(date);
|
|
390
|
+
const originNode = /* @__PURE__ */ jsxs("div", {
|
|
391
|
+
className: calendarCellContentClass,
|
|
392
|
+
children: [
|
|
393
|
+
/* @__PURE__ */ jsx("span", {
|
|
394
|
+
children: MONTHS[month]
|
|
395
|
+
}),
|
|
396
|
+
monthCellRender?.(dateValue)
|
|
397
|
+
]
|
|
398
|
+
});
|
|
399
|
+
const info = {
|
|
400
|
+
originNode,
|
|
401
|
+
today,
|
|
402
|
+
type: "year"
|
|
403
|
+
};
|
|
404
|
+
const content = fullCellRender?.(dateValue, info) ?? monthFullCellRender?.(dateValue) ?? cellRender?.(dateValue, info) ?? originNode;
|
|
405
|
+
const disabled = disabledDate?.(dateValue) || isOutsideRange(date, validRange);
|
|
406
|
+
return /* @__PURE__ */ jsx("button", {
|
|
407
|
+
type: "button",
|
|
408
|
+
"aria-label": dateValue,
|
|
409
|
+
disabled,
|
|
410
|
+
className: getCalendarCellClasses({
|
|
411
|
+
selected: dateValue === formatMonth(parseDate(currentValue)),
|
|
412
|
+
today: dateValue === formatMonth(new Date),
|
|
413
|
+
disabled
|
|
414
|
+
}),
|
|
415
|
+
onClick: () => commitValue(date, "month"),
|
|
416
|
+
children: content
|
|
417
|
+
}, dateValue);
|
|
418
|
+
}
|
|
419
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
420
|
+
...props,
|
|
421
|
+
ref,
|
|
422
|
+
className: getCalendarClasses({
|
|
423
|
+
fullscreen,
|
|
424
|
+
mode: currentMode,
|
|
425
|
+
className
|
|
426
|
+
}),
|
|
427
|
+
children: [
|
|
428
|
+
headerRender ? headerRender({
|
|
429
|
+
value: formatDate(panelDate),
|
|
430
|
+
type: currentMode,
|
|
431
|
+
onChange: (nextValue) => emitPanelChange(parseDate(nextValue)),
|
|
432
|
+
onTypeChange: setCalendarMode
|
|
433
|
+
}) : /* @__PURE__ */ jsx(Header, {
|
|
434
|
+
panelDate,
|
|
435
|
+
mode: currentMode,
|
|
436
|
+
setPanelDate: emitPanelChange,
|
|
437
|
+
setMode: setCalendarMode
|
|
438
|
+
}),
|
|
439
|
+
/* @__PURE__ */ jsx("div", {
|
|
440
|
+
className: calendarBodyClass,
|
|
441
|
+
children: currentMode === "month" ? /* @__PURE__ */ jsxs(Fragment, {
|
|
442
|
+
children: [
|
|
443
|
+
/* @__PURE__ */ jsx("div", {
|
|
444
|
+
className: calendarWeekdaysClass,
|
|
445
|
+
"aria-hidden": "true",
|
|
446
|
+
children: WEEKDAYS.map((weekday) => /* @__PURE__ */ jsx("span", {
|
|
447
|
+
className: calendarWeekdayClass,
|
|
448
|
+
children: weekday
|
|
449
|
+
}, weekday))
|
|
450
|
+
}),
|
|
451
|
+
/* @__PURE__ */ jsx("div", {
|
|
452
|
+
className: calendarDateGridClass,
|
|
453
|
+
children: dateGrid.map(renderDateCell)
|
|
454
|
+
})
|
|
455
|
+
]
|
|
456
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
457
|
+
className: calendarMonthGridClass,
|
|
458
|
+
children: MONTHS.map((_, month) => renderMonthCell(month))
|
|
459
|
+
})
|
|
460
|
+
})
|
|
461
|
+
]
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
Calendar.displayName = "Calendar";
|
|
465
|
+
// src/components/date-picker/usePickerDropdown.ts
|
|
466
|
+
import { useEffect, useId, useImperativeHandle, useRef, useState as useState3 } from "react";
|
|
467
|
+
function usePickerDropdown({
|
|
468
|
+
open,
|
|
469
|
+
defaultOpen,
|
|
470
|
+
disabled,
|
|
471
|
+
onOpenChange,
|
|
472
|
+
ref
|
|
473
|
+
}) {
|
|
474
|
+
const rootRef = useRef(null);
|
|
475
|
+
const inputRef = useRef(null);
|
|
476
|
+
const skipFocus = useRef(false);
|
|
477
|
+
const panelId = useId();
|
|
478
|
+
const [innerOpen, setInnerOpen] = useState3(Boolean(defaultOpen));
|
|
479
|
+
const visible = !disabled && (open ?? innerOpen);
|
|
480
|
+
useImperativeHandle(ref, () => rootRef.current, []);
|
|
481
|
+
function setVisible(next) {
|
|
482
|
+
if (disabled || next === visible)
|
|
483
|
+
return;
|
|
484
|
+
if (open === undefined)
|
|
485
|
+
setInnerOpen(next);
|
|
486
|
+
onOpenChange?.(next);
|
|
487
|
+
}
|
|
488
|
+
function closeAndFocus() {
|
|
489
|
+
skipFocus.current = true;
|
|
490
|
+
inputRef.current?.focus();
|
|
491
|
+
skipFocus.current = false;
|
|
492
|
+
setVisible(false);
|
|
493
|
+
}
|
|
494
|
+
useEffect(() => {
|
|
495
|
+
function handleOutside(event) {
|
|
496
|
+
if (visible && !rootRef.current?.contains(event.target))
|
|
497
|
+
setVisible(false);
|
|
498
|
+
}
|
|
499
|
+
function handleKeyDown(event) {
|
|
500
|
+
if (event.defaultPrevented || !rootRef.current?.contains(event.target))
|
|
501
|
+
return;
|
|
502
|
+
if (event.key === "Escape" && visible) {
|
|
503
|
+
event.preventDefault();
|
|
504
|
+
closeAndFocus();
|
|
505
|
+
} else if (event.key === "ArrowDown" && event.target === inputRef.current) {
|
|
506
|
+
event.preventDefault();
|
|
507
|
+
setVisible(true);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
document.addEventListener("pointerdown", handleOutside);
|
|
511
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
512
|
+
return () => {
|
|
513
|
+
document.removeEventListener("pointerdown", handleOutside);
|
|
514
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
515
|
+
};
|
|
516
|
+
});
|
|
517
|
+
return {
|
|
518
|
+
rootRef,
|
|
519
|
+
inputRef,
|
|
520
|
+
panelId,
|
|
521
|
+
visible,
|
|
522
|
+
setVisible,
|
|
523
|
+
closeAndFocus,
|
|
524
|
+
onInputFocus: () => {
|
|
525
|
+
if (!skipFocus.current)
|
|
526
|
+
setVisible(true);
|
|
527
|
+
},
|
|
528
|
+
onRootBlur: (event) => {
|
|
529
|
+
if (!event.currentTarget.contains(event.relatedTarget))
|
|
530
|
+
setVisible(false);
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
|
|
31
535
|
// src/classes/date-picker.ts
|
|
32
536
|
var datePickerBaseClass = "datepicker";
|
|
33
537
|
var datePickerInputClass = "datepicker-input";
|
|
@@ -75,7 +579,7 @@ function getDatePickerDropdownClasses({
|
|
|
75
579
|
}
|
|
76
580
|
|
|
77
581
|
// src/components/date-picker/DatePicker.tsx
|
|
78
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
582
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
79
583
|
function todayValue(picker) {
|
|
80
584
|
const today = new Date;
|
|
81
585
|
const year = today.getFullYear();
|
|
@@ -114,9 +618,10 @@ function placeholderForPicker(picker) {
|
|
|
114
618
|
function normalizeDateValue(value) {
|
|
115
619
|
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
116
620
|
}
|
|
117
|
-
var DatePickerRoot =
|
|
621
|
+
var DatePickerRoot = forwardRef2(({
|
|
118
622
|
allowClear,
|
|
119
623
|
className,
|
|
624
|
+
inputProps,
|
|
120
625
|
defaultOpen,
|
|
121
626
|
defaultValue,
|
|
122
627
|
disabled,
|
|
@@ -135,19 +640,19 @@ var DatePickerRoot = forwardRef(({
|
|
|
135
640
|
value,
|
|
136
641
|
...props
|
|
137
642
|
}, ref) => {
|
|
643
|
+
const [calendarMode, setCalendarMode] = useState4("month");
|
|
138
644
|
const isValueControlled = value !== undefined;
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
|
|
645
|
+
const [innerValue, setInnerValue] = useState4(() => normalizeDateValue(defaultValue));
|
|
646
|
+
const dropdown = usePickerDropdown({
|
|
647
|
+
open,
|
|
648
|
+
defaultOpen,
|
|
649
|
+
disabled,
|
|
650
|
+
onOpenChange,
|
|
651
|
+
ref
|
|
652
|
+
});
|
|
142
653
|
const currentValue = isValueControlled ? normalizeDateValue(value) : innerValue;
|
|
143
|
-
const visible
|
|
654
|
+
const { visible, setVisible } = dropdown;
|
|
144
655
|
const inputType = inputTypeForPicker(picker);
|
|
145
|
-
function setVisible(nextOpen) {
|
|
146
|
-
if (!isOpenControlled) {
|
|
147
|
-
setInnerOpen(nextOpen);
|
|
148
|
-
}
|
|
149
|
-
onOpenChange?.(nextOpen);
|
|
150
|
-
}
|
|
151
656
|
function emitChange(nextValue) {
|
|
152
657
|
if (nextValue && disabledDate?.(nextValue)) {
|
|
153
658
|
return;
|
|
@@ -157,10 +662,17 @@ var DatePickerRoot = forwardRef(({
|
|
|
157
662
|
}
|
|
158
663
|
onChange?.(nextValue, nextValue ?? "");
|
|
159
664
|
}
|
|
160
|
-
|
|
161
|
-
|
|
665
|
+
function selectValue(nextValue) {
|
|
666
|
+
if (disabledDate?.(nextValue))
|
|
667
|
+
return;
|
|
668
|
+
emitChange(nextValue);
|
|
669
|
+
dropdown.closeAndFocus();
|
|
670
|
+
}
|
|
671
|
+
const presetItems = useMemo2(() => presets ?? [], [presets]);
|
|
672
|
+
return /* @__PURE__ */ jsxs2("div", {
|
|
162
673
|
...props,
|
|
163
|
-
ref,
|
|
674
|
+
ref: dropdown.rootRef,
|
|
675
|
+
onBlur: dropdown.onRootBlur,
|
|
164
676
|
className: getDatePickerClasses({
|
|
165
677
|
size,
|
|
166
678
|
status,
|
|
@@ -170,7 +682,11 @@ var DatePickerRoot = forwardRef(({
|
|
|
170
682
|
className
|
|
171
683
|
}),
|
|
172
684
|
children: [
|
|
173
|
-
/* @__PURE__ */
|
|
685
|
+
/* @__PURE__ */ jsx2("input", {
|
|
686
|
+
...inputProps,
|
|
687
|
+
ref: dropdown.inputRef,
|
|
688
|
+
"aria-haspopup": "dialog",
|
|
689
|
+
"aria-controls": visible ? dropdown.panelId : undefined,
|
|
174
690
|
className: datePickerInputClass,
|
|
175
691
|
disabled,
|
|
176
692
|
type: inputType,
|
|
@@ -178,15 +694,15 @@ var DatePickerRoot = forwardRef(({
|
|
|
178
694
|
placeholder: placeholder ?? placeholderForPicker(picker),
|
|
179
695
|
onFocus: (event) => {
|
|
180
696
|
onFocus?.(event);
|
|
181
|
-
|
|
697
|
+
dropdown.onInputFocus();
|
|
182
698
|
},
|
|
183
699
|
onBlur: (event) => {
|
|
184
700
|
onBlur?.(event);
|
|
185
|
-
setVisible(false);
|
|
186
701
|
},
|
|
702
|
+
onClick: () => setVisible(true),
|
|
187
703
|
onChange: (event) => emitChange(event.currentTarget.value || undefined)
|
|
188
704
|
}),
|
|
189
|
-
allowClear && currentValue && !disabled ? /* @__PURE__ */
|
|
705
|
+
allowClear && currentValue && !disabled ? /* @__PURE__ */ jsx2("button", {
|
|
190
706
|
type: "button",
|
|
191
707
|
className: datePickerClearClass,
|
|
192
708
|
"aria-label": "Clear date",
|
|
@@ -194,26 +710,95 @@ var DatePickerRoot = forwardRef(({
|
|
|
194
710
|
onClick: () => emitChange(undefined),
|
|
195
711
|
children: "x"
|
|
196
712
|
}) : null,
|
|
197
|
-
/* @__PURE__ */
|
|
713
|
+
/* @__PURE__ */ jsx2("button", {
|
|
714
|
+
type: "button",
|
|
198
715
|
className: datePickerIconClass,
|
|
199
|
-
"aria-
|
|
716
|
+
"aria-label": "Open date picker",
|
|
717
|
+
"aria-haspopup": "dialog",
|
|
718
|
+
"aria-expanded": visible,
|
|
719
|
+
"aria-controls": visible ? dropdown.panelId : undefined,
|
|
720
|
+
disabled,
|
|
721
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
722
|
+
onClick: () => setVisible(!visible),
|
|
723
|
+
children: /* @__PURE__ */ jsxs2("svg", {
|
|
724
|
+
"aria-hidden": "true",
|
|
725
|
+
focusable: "false",
|
|
726
|
+
width: "18",
|
|
727
|
+
height: "18",
|
|
728
|
+
viewBox: "0 0 24 24",
|
|
729
|
+
fill: "none",
|
|
730
|
+
stroke: "currentColor",
|
|
731
|
+
strokeWidth: "1.75",
|
|
732
|
+
strokeLinecap: "round",
|
|
733
|
+
strokeLinejoin: "round",
|
|
734
|
+
children: [
|
|
735
|
+
/* @__PURE__ */ jsx2("rect", {
|
|
736
|
+
x: "3",
|
|
737
|
+
y: "5",
|
|
738
|
+
width: "18",
|
|
739
|
+
height: "16",
|
|
740
|
+
rx: "2"
|
|
741
|
+
}),
|
|
742
|
+
/* @__PURE__ */ jsx2("path", {
|
|
743
|
+
d: "M8 3v4M16 3v4M3 10h18"
|
|
744
|
+
})
|
|
745
|
+
]
|
|
746
|
+
})
|
|
200
747
|
}),
|
|
201
|
-
|
|
748
|
+
visible ? /* @__PURE__ */ jsxs2("div", {
|
|
749
|
+
id: dropdown.panelId,
|
|
750
|
+
role: "dialog",
|
|
751
|
+
"aria-label": "Choose date",
|
|
202
752
|
className: getDatePickerDropdownClasses({ open: visible }),
|
|
203
753
|
children: [
|
|
204
|
-
|
|
754
|
+
picker === "date" || picker === "month" ? /* @__PURE__ */ jsx2(Calendar, {
|
|
755
|
+
fullscreen: false,
|
|
756
|
+
value: currentValue,
|
|
757
|
+
mode: picker === "month" ? "year" : calendarMode,
|
|
758
|
+
onPanelChange: (_, mode) => {
|
|
759
|
+
if (picker === "date")
|
|
760
|
+
setCalendarMode(mode);
|
|
761
|
+
},
|
|
762
|
+
disabledDate: (date) => {
|
|
763
|
+
if (!disabledDate)
|
|
764
|
+
return false;
|
|
765
|
+
if (picker === "month")
|
|
766
|
+
return disabledDate(date.slice(0, 7));
|
|
767
|
+
if (calendarMode === "year") {
|
|
768
|
+
const [year, month] = date.split("-").map(Number);
|
|
769
|
+
const days = new Date(year, month, 0).getDate();
|
|
770
|
+
return Array.from({ length: days }, (_, index) => `${date.slice(0, 7)}-${String(index + 1).padStart(2, "0")}`).every((day) => disabledDate(day));
|
|
771
|
+
}
|
|
772
|
+
return disabledDate(date);
|
|
773
|
+
},
|
|
774
|
+
onSelect: (date, info) => {
|
|
775
|
+
if (picker === "date" && info.source === "month") {
|
|
776
|
+
setCalendarMode("month");
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
selectValue(picker === "month" ? date.slice(0, 7) : date);
|
|
780
|
+
}
|
|
781
|
+
}) : /* @__PURE__ */ jsx2("input", {
|
|
782
|
+
type: inputType,
|
|
783
|
+
"aria-label": placeholderForPicker(picker),
|
|
784
|
+
value: currentValue ?? "",
|
|
785
|
+
onChange: (event) => selectValue(event.currentTarget.value)
|
|
786
|
+
}),
|
|
787
|
+
presetItems.map((preset, index) => /* @__PURE__ */ jsx2("button", {
|
|
205
788
|
type: "button",
|
|
206
789
|
className: datePickerPresetClass,
|
|
207
790
|
onMouseDown: (event) => event.preventDefault(),
|
|
208
|
-
|
|
791
|
+
disabled: Boolean(disabledDate?.(preset.value)),
|
|
792
|
+
onClick: () => selectValue(preset.value),
|
|
209
793
|
children: preset.label
|
|
210
794
|
}, index)),
|
|
211
|
-
showNow ? /* @__PURE__ */
|
|
795
|
+
showNow ? /* @__PURE__ */ jsx2("div", {
|
|
212
796
|
className: datePickerFooterClass,
|
|
213
|
-
children: /* @__PURE__ */
|
|
797
|
+
children: /* @__PURE__ */ jsx2("button", {
|
|
214
798
|
type: "button",
|
|
215
799
|
onMouseDown: (event) => event.preventDefault(),
|
|
216
|
-
|
|
800
|
+
disabled: Boolean(disabledDate?.(todayValue(picker))),
|
|
801
|
+
onClick: () => selectValue(todayValue(picker)),
|
|
217
802
|
children: "Now"
|
|
218
803
|
})
|
|
219
804
|
}) : null
|
|
@@ -223,9 +808,10 @@ var DatePickerRoot = forwardRef(({
|
|
|
223
808
|
});
|
|
224
809
|
});
|
|
225
810
|
DatePickerRoot.displayName = "DatePicker";
|
|
226
|
-
var RangePicker =
|
|
811
|
+
var RangePicker = forwardRef2(({
|
|
227
812
|
allowClear,
|
|
228
813
|
className,
|
|
814
|
+
inputProps,
|
|
229
815
|
defaultValue,
|
|
230
816
|
disabled,
|
|
231
817
|
disabledDate,
|
|
@@ -239,7 +825,7 @@ var RangePicker = forwardRef(({
|
|
|
239
825
|
...props
|
|
240
826
|
}, ref) => {
|
|
241
827
|
const isControlled = value !== undefined;
|
|
242
|
-
const [innerValue, setInnerValue] =
|
|
828
|
+
const [innerValue, setInnerValue] = useState4(defaultValue ?? [undefined, undefined]);
|
|
243
829
|
const currentValue = isControlled ? value : innerValue;
|
|
244
830
|
const inputType = inputTypeForPicker(picker);
|
|
245
831
|
function emitChange(nextValue) {
|
|
@@ -254,7 +840,7 @@ var RangePicker = forwardRef(({
|
|
|
254
840
|
function updateIndex(index, nextItem) {
|
|
255
841
|
emitChange(index === 0 ? [nextItem, currentValue?.[1]] : [currentValue?.[0], nextItem]);
|
|
256
842
|
}
|
|
257
|
-
return /* @__PURE__ */
|
|
843
|
+
return /* @__PURE__ */ jsxs2("div", {
|
|
258
844
|
...props,
|
|
259
845
|
ref,
|
|
260
846
|
className: getDatePickerClasses({
|
|
@@ -266,7 +852,8 @@ var RangePicker = forwardRef(({
|
|
|
266
852
|
className
|
|
267
853
|
}),
|
|
268
854
|
children: [
|
|
269
|
-
/* @__PURE__ */
|
|
855
|
+
/* @__PURE__ */ jsx2("input", {
|
|
856
|
+
...inputProps,
|
|
270
857
|
className: datePickerInputClass,
|
|
271
858
|
disabled,
|
|
272
859
|
type: inputType,
|
|
@@ -274,11 +861,13 @@ var RangePicker = forwardRef(({
|
|
|
274
861
|
placeholder: Array.isArray(placeholder) ? placeholder[0] : "Start date",
|
|
275
862
|
onChange: (event) => updateIndex(0, event.currentTarget.value || undefined)
|
|
276
863
|
}),
|
|
277
|
-
/* @__PURE__ */
|
|
864
|
+
/* @__PURE__ */ jsx2("span", {
|
|
278
865
|
className: datePickerSeparatorClass,
|
|
279
866
|
children: separator
|
|
280
867
|
}),
|
|
281
|
-
/* @__PURE__ */
|
|
868
|
+
/* @__PURE__ */ jsx2("input", {
|
|
869
|
+
...inputProps,
|
|
870
|
+
id: inputProps?.id ? `${inputProps.id}-end` : undefined,
|
|
282
871
|
className: datePickerInputClass,
|
|
283
872
|
disabled,
|
|
284
873
|
type: inputType,
|
|
@@ -286,7 +875,7 @@ var RangePicker = forwardRef(({
|
|
|
286
875
|
placeholder: Array.isArray(placeholder) ? placeholder[1] : "End date",
|
|
287
876
|
onChange: (event) => updateIndex(1, event.currentTarget.value || undefined)
|
|
288
877
|
}),
|
|
289
|
-
allowClear && (currentValue?.[0] || currentValue?.[1]) && !disabled ? /* @__PURE__ */
|
|
878
|
+
allowClear && (currentValue?.[0] || currentValue?.[1]) && !disabled ? /* @__PURE__ */ jsx2("button", {
|
|
290
879
|
type: "button",
|
|
291
880
|
className: datePickerClearClass,
|
|
292
881
|
"aria-label": "Clear date range",
|
|
@@ -298,7 +887,7 @@ var RangePicker = forwardRef(({
|
|
|
298
887
|
});
|
|
299
888
|
RangePicker.displayName = "DatePicker.RangePicker";
|
|
300
889
|
function withPicker(picker, displayName) {
|
|
301
|
-
const Picker =
|
|
890
|
+
const Picker = forwardRef2((props, ref) => /* @__PURE__ */ jsx2(DatePickerRoot, {
|
|
302
891
|
...props,
|
|
303
892
|
ref,
|
|
304
893
|
picker
|
|
@@ -314,94 +903,7 @@ var DatePicker = Object.assign(DatePickerRoot, {
|
|
|
314
903
|
YearPicker: withPicker("year", "DatePicker.YearPicker")
|
|
315
904
|
});
|
|
316
905
|
// src/components/dm-date-picker/DmDatePicker.tsx
|
|
317
|
-
import {
|
|
318
|
-
|
|
319
|
-
// src/classes/dm-date-picker.ts
|
|
320
|
-
var dmDatePickerClass = "dm-date-picker";
|
|
321
|
-
function getDmDatePickerClasses({ className }) {
|
|
322
|
-
return cn(dmDatePickerClass, className);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// src/infrastructure.ts
|
|
326
|
-
import { useCallback, useState as useState2 } from "react";
|
|
327
|
-
var primaryColor = "#0065ff";
|
|
328
|
-
var prefixCls = "dm";
|
|
329
|
-
var datePickerLocale = "en";
|
|
330
|
-
var themeUpdateCallbacks = new Set;
|
|
331
|
-
function emitThemeUpdate() {
|
|
332
|
-
for (const callback of themeUpdateCallbacks) {
|
|
333
|
-
callback();
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
function setDmPrefixCls(nextPrefixCls) {
|
|
337
|
-
prefixCls = nextPrefixCls;
|
|
338
|
-
emitThemeUpdate();
|
|
339
|
-
}
|
|
340
|
-
function setDmPrimaryColor(color) {
|
|
341
|
-
primaryColor = color;
|
|
342
|
-
emitThemeUpdate();
|
|
343
|
-
}
|
|
344
|
-
function onDmThemeUpdate(callback) {
|
|
345
|
-
themeUpdateCallbacks.add(callback);
|
|
346
|
-
return () => {
|
|
347
|
-
themeUpdateCallbacks.delete(callback);
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
function getDmTheme() {
|
|
351
|
-
return {
|
|
352
|
-
prefixCls,
|
|
353
|
-
token: {
|
|
354
|
-
colorInfo: primaryColor,
|
|
355
|
-
colorPrimary: primaryColor,
|
|
356
|
-
colorLink: primaryColor
|
|
357
|
-
},
|
|
358
|
-
components: {
|
|
359
|
-
Table: {
|
|
360
|
-
cellFontSizeSM: 12,
|
|
361
|
-
cellPaddingBlockSM: 10,
|
|
362
|
-
headerColor: "#5a607f"
|
|
363
|
-
},
|
|
364
|
-
Breadcrumb: {
|
|
365
|
-
linkColor: "#5a607f",
|
|
366
|
-
linkHoverColor: "#5a607f",
|
|
367
|
-
itemColor: "#5a607f",
|
|
368
|
-
lastItemColor: "#2f2e3f",
|
|
369
|
-
separatorColor: "#5a607f"
|
|
370
|
-
},
|
|
371
|
-
Menu: {
|
|
372
|
-
collapsedWidth: 60,
|
|
373
|
-
itemMarginBlock: 8,
|
|
374
|
-
itemMarginInline: 10,
|
|
375
|
-
itemPaddingInline: 10
|
|
376
|
-
},
|
|
377
|
-
Input: {
|
|
378
|
-
activeBorderColor: primaryColor
|
|
379
|
-
},
|
|
380
|
-
Tabs: {
|
|
381
|
-
inkBarColor: primaryColor,
|
|
382
|
-
itemSelectedColor: primaryColor
|
|
383
|
-
},
|
|
384
|
-
DatePicker: {
|
|
385
|
-
activeBorderColor: primaryColor
|
|
386
|
-
},
|
|
387
|
-
Tree: {
|
|
388
|
-
directoryNodeSelectedBg: primaryColor
|
|
389
|
-
},
|
|
390
|
-
Radio: {
|
|
391
|
-
buttonSolidCheckedBg: primaryColor
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
function setDmDatePickerLocale(locale) {
|
|
397
|
-
datePickerLocale = locale;
|
|
398
|
-
}
|
|
399
|
-
function getDmDatePickerLocale() {
|
|
400
|
-
return datePickerLocale;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// src/components/dm-date-picker/DmDatePicker.tsx
|
|
404
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
906
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
405
907
|
function getDefaultPlaceholder(picker) {
|
|
406
908
|
const locale = getDmDatePickerLocale();
|
|
407
909
|
if (locale === "zh") {
|
|
@@ -417,7 +919,7 @@ function getDefaultPlaceholder(picker) {
|
|
|
417
919
|
}
|
|
418
920
|
return;
|
|
419
921
|
}
|
|
420
|
-
var DmDatePickerRoot =
|
|
922
|
+
var DmDatePickerRoot = forwardRef3(({ className, placeholder, picker, ...props }, ref) => /* @__PURE__ */ jsx3(DatePicker, {
|
|
421
923
|
...props,
|
|
422
924
|
ref,
|
|
423
925
|
picker,
|
|
@@ -425,7 +927,7 @@ var DmDatePickerRoot = forwardRef2(({ className, placeholder, picker, ...props }
|
|
|
425
927
|
className: getDmDatePickerClasses({ className })
|
|
426
928
|
}));
|
|
427
929
|
DmDatePickerRoot.displayName = "DmDatePicker";
|
|
428
|
-
var DmRangePicker =
|
|
930
|
+
var DmRangePicker = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(DatePicker.RangePicker, {
|
|
429
931
|
...props,
|
|
430
932
|
ref,
|
|
431
933
|
className: getDmDatePickerClasses({ className })
|
|
@@ -433,27 +935,27 @@ var DmRangePicker = forwardRef2(({ className, ...props }, ref) => /* @__PURE__ *
|
|
|
433
935
|
DmRangePicker.displayName = "DmDatePicker.RangePicker";
|
|
434
936
|
var DmDatePicker = DmDatePickerRoot;
|
|
435
937
|
DmDatePicker.RangePicker = DmRangePicker;
|
|
436
|
-
DmDatePicker.WeekPicker =
|
|
938
|
+
DmDatePicker.WeekPicker = forwardRef3((props, ref) => /* @__PURE__ */ jsx3(DmDatePicker, {
|
|
437
939
|
...props,
|
|
438
940
|
ref,
|
|
439
941
|
picker: "week"
|
|
440
942
|
}));
|
|
441
|
-
DmDatePicker.MonthPicker =
|
|
943
|
+
DmDatePicker.MonthPicker = forwardRef3((props, ref) => /* @__PURE__ */ jsx3(DmDatePicker, {
|
|
442
944
|
...props,
|
|
443
945
|
ref,
|
|
444
946
|
picker: "month"
|
|
445
947
|
}));
|
|
446
|
-
DmDatePicker.QuarterPicker =
|
|
948
|
+
DmDatePicker.QuarterPicker = forwardRef3((props, ref) => /* @__PURE__ */ jsx3(DmDatePicker, {
|
|
447
949
|
...props,
|
|
448
950
|
ref,
|
|
449
951
|
picker: "quarter"
|
|
450
952
|
}));
|
|
451
|
-
DmDatePicker.YearPicker =
|
|
953
|
+
DmDatePicker.YearPicker = forwardRef3((props, ref) => /* @__PURE__ */ jsx3(DmDatePicker, {
|
|
452
954
|
...props,
|
|
453
955
|
ref,
|
|
454
956
|
picker: "year"
|
|
455
957
|
}));
|
|
456
958
|
export {
|
|
457
|
-
|
|
458
|
-
|
|
959
|
+
DmDatePicker,
|
|
960
|
+
setDmDatePickerLocale
|
|
459
961
|
};
|