jenosize-ui 0.2.1 → 0.3.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 +183 -63
- package/THIRD-PARTY-NOTICES.md +15 -0
- package/dist/GradientPicker-CQm3GT7F.d.ts +144 -0
- package/dist/{PaymentInput-Dn5WVQVy.d.ts → PaymentInput-Cz5jFB3p.d.ts} +1 -1
- package/dist/{Select-Dt5ARIH8.d.ts → Select-CXOAMlk7.d.ts} +15 -1
- package/dist/{TagInput-BaBeve6L.d.ts → TagInput-CzIrONr-.d.ts} +1 -1
- package/dist/area-chart.d.ts +2 -2
- package/dist/area-chart.js +7 -6
- package/dist/at-least-one-BZ2dsck-.d.ts +18 -0
- package/dist/avatar.d.ts +1 -1
- package/dist/avatar.js +12 -11
- package/dist/badge.d.ts +1 -1
- package/dist/badge.js +6 -6
- package/dist/bar-chart.d.ts +2 -2
- package/dist/bar-chart.js +7 -6
- package/dist/breadcrumb.d.ts +1 -1
- package/dist/breadcrumb.js +4 -4
- package/dist/button.d.ts +1 -1
- package/dist/button.js +11 -10
- package/dist/calendar.d.ts +1 -1
- package/dist/calendar.js +16 -15
- package/dist/callout.d.ts +4 -2
- package/dist/callout.js +12 -11
- package/dist/card.d.ts +59 -3
- package/dist/card.js +4 -4
- package/dist/carousel.d.ts +169 -0
- package/dist/carousel.js +9 -0
- package/dist/catalog.json +11180 -0
- package/dist/checkbox.js +8 -7
- package/dist/{chunk-MVG5MABV.js → chunk-26XQU3TC.js} +8 -8
- package/dist/{chunk-X2X7Q7NW.js → chunk-2R3QWWOT.js} +3 -3
- package/dist/{chunk-AIARANKE.js → chunk-3JQKVC2K.js} +4 -4
- package/dist/chunk-3P3QZPHV.js +109 -0
- package/dist/{chunk-GLKFFA7N.js → chunk-44AWXIQK.js} +5 -5
- package/dist/{chunk-FWRHBMWT.js → chunk-4Y32RIC7.js} +5 -19
- package/dist/{chunk-5XPMY2LF.js → chunk-5ECTNYKU.js} +5 -5
- package/dist/{chunk-6B6BWTXC.js → chunk-5GBA6X6A.js} +5 -5
- package/dist/{chunk-UGKELBNC.js → chunk-5SGF47TZ.js} +9 -9
- package/dist/{chunk-POQTE7JI.js → chunk-5XSR757T.js} +7 -7
- package/dist/{chunk-GZMDZF2V.js → chunk-6FGLABYH.js} +3 -3
- package/dist/{chunk-MCQG4H6T.js → chunk-6T3QAO5K.js} +12 -4
- package/dist/{chunk-SKRR3ZMP.js → chunk-737A4YNC.js} +3 -3
- package/dist/{chunk-AFYXSZGW.js → chunk-7LSUUEAF.js} +7 -5
- package/dist/{chunk-7VLYQR4D.js → chunk-7OFGPDYJ.js} +3 -3
- package/dist/{chunk-54SIZR63.js → chunk-7UCKFULR.js} +7 -7
- package/dist/{chunk-LQURV7HQ.js → chunk-7ZA3QZRP.js} +4 -4
- package/dist/{chunk-X2VMIBK5.js → chunk-A4YPUS6C.js} +4 -4
- package/dist/{chunk-5ZEUTSCV.js → chunk-B4OVIE2X.js} +6 -6
- package/dist/{chunk-P6CON2R2.js → chunk-BH32X25C.js} +3 -3
- package/dist/{chunk-667ZHY3T.js → chunk-BJHLW25G.js} +85 -538
- package/dist/{chunk-ULGCGKOE.js → chunk-BKBINQJZ.js} +4 -4
- package/dist/{chunk-CFFWYXDW.js → chunk-BXQFBFT7.js} +5 -5
- package/dist/{chunk-I6WMNXC7.js → chunk-CQGMOPLG.js} +6 -6
- package/dist/{chunk-FNQJJO63.js → chunk-CUONE6LA.js} +4 -4
- package/dist/{chunk-FFMTYQXE.js → chunk-CVCS5G3E.js} +43 -21
- package/dist/{chunk-33TOK7ES.js → chunk-DCKVNHV5.js} +5 -5
- package/dist/{chunk-A323V6AI.js → chunk-DYRGHXT5.js} +3 -3
- package/dist/{chunk-T4ZFZTY6.js → chunk-EHML2DLR.js} +4 -4
- package/dist/{chunk-N3RVMBPX.js → chunk-EJKQGUUM.js} +4 -4
- package/dist/{chunk-E2YZ7IMT.js → chunk-ESDSTS5N.js} +6 -6
- package/dist/{chunk-LCG34A5T.js → chunk-EVINS473.js} +5 -3
- package/dist/chunk-EXRVOGJ5.js +325 -0
- package/dist/{chunk-YHBI52P2.js → chunk-GDW6NFYN.js} +3 -3
- package/dist/chunk-GOCO45FF.js +619 -0
- package/dist/{chunk-7ZM7SNCZ.js → chunk-GPHGPY6T.js} +3 -3
- package/dist/{chunk-PO2TYK3C.js → chunk-GWYDOZGQ.js} +3 -3
- package/dist/{chunk-LO22VQL5.js → chunk-HNNNJP3A.js} +4 -4
- package/dist/{chunk-ZZSNTCCL.js → chunk-IESEBPYA.js} +4 -4
- package/dist/{chunk-3H444OJA.js → chunk-JZ4HGFWK.js} +3 -3
- package/dist/chunk-KBQJIVUB.js +33 -0
- package/dist/{chunk-CKMWBVRR.js → chunk-KCM4KEZ2.js} +4 -4
- package/dist/{chunk-3QXLIZIX.js → chunk-KNGJ3CSB.js} +3 -3
- package/dist/{chunk-FH7Z7SGQ.js → chunk-KNW3IUWX.js} +12 -11
- package/dist/{chunk-KZP6B6B3.js → chunk-KTWTYK5U.js} +16 -5
- package/dist/{chunk-LYXPJERB.js → chunk-L7Z6XGBU.js} +5 -5
- package/dist/{chunk-ZHAT2XZ4.js → chunk-LLUWBQK6.js} +10 -10
- package/dist/{chunk-QHH6AUR3.js → chunk-MDKVYC6R.js} +7 -7
- package/dist/{chunk-22M75A3N.js → chunk-MS6DY4CE.js} +14 -11
- package/dist/{chunk-LLPWQDF7.js → chunk-MTOTPAYZ.js} +3 -3
- package/dist/{chunk-AZ7DKRBY.js → chunk-MVF7FA4D.js} +5 -5
- package/dist/{chunk-AIGYMTCU.js → chunk-MVUNB43J.js} +3 -3
- package/dist/{chunk-ZMFY7WAY.js → chunk-O24HHIQG.js} +41 -39
- package/dist/{chunk-NKG4N6HA.js → chunk-O5EHNNPS.js} +4 -4
- package/dist/{chunk-5DP7W5HX.js → chunk-OIPFTJS6.js} +3 -3
- package/dist/{chunk-U4WSJAYK.js → chunk-OXNIEIOY.js} +20 -20
- package/dist/chunk-P2BGR77C.js +344 -0
- package/dist/{chunk-CGHYXWTT.js → chunk-PFAFTLN3.js} +4 -4
- package/dist/{chunk-4RBIWI2Q.js → chunk-Q2KR7PSX.js} +3 -3
- package/dist/{chunk-7GUPNTAH.js → chunk-QSOLK2I2.js} +7 -7
- package/dist/chunk-QTWRR7IS.js +1129 -0
- package/dist/{chunk-OLLD2BZN.js → chunk-QZHAL4BL.js} +3 -3
- package/dist/{chunk-OACWA4TC.js → chunk-R25NHHYT.js} +6 -6
- package/dist/{chunk-QDKETK7D.js → chunk-S55JKMG7.js} +5 -5
- package/dist/{chunk-S5TEWPWW.js → chunk-S5LLA36K.js} +10 -10
- package/dist/{chunk-QDYE5LVT.js → chunk-SF3HCW4G.js} +45 -4
- package/dist/{chunk-KHGW72BM.js → chunk-SGMVB7HD.js} +3 -3
- package/dist/{chunk-FKVPAEJ6.js → chunk-SKJC2KYD.js} +4 -3
- package/dist/chunk-SKPKL47Y.js +5671 -0
- package/dist/{chunk-6MMBQVRO.js → chunk-TCTTZHUS.js} +9 -9
- package/dist/chunk-U5X3MLM5.js +67 -0
- package/dist/chunk-UHSGD4CD.js +364 -0
- package/dist/chunk-UJ4WEQHR.js +525 -0
- package/dist/{chunk-6H4LNWQ7.js → chunk-VDFWWWLL.js} +9 -4
- package/dist/{chunk-5KSD4WKN.js → chunk-VIKV25VP.js} +5 -5
- package/dist/chunk-WJB5GWAZ.js +20 -0
- package/dist/{chunk-HHYEAFCL.js → chunk-XAQQ4LYL.js} +11 -11
- package/dist/{chunk-4VGEJG4M.js → chunk-XCFFM2C7.js} +9 -9
- package/dist/chunk-XKTD3X6Z.js +183 -0
- package/dist/{chunk-GQRSABRN.js → chunk-XWXXKEG6.js} +4 -4
- package/dist/chunk-YGFTNICV.js +110 -0
- package/dist/{chunk-T5574MXM.js → chunk-YGJL7QS7.js} +8 -8
- package/dist/{chunk-SB3DG572.js → chunk-YKPTUANT.js} +6 -6
- package/dist/{chunk-YQYVGWIC.js → chunk-YQAYAJ2T.js} +33 -11
- package/dist/chunk-YXYZW6WU.js +998 -0
- package/dist/{chunk-IQNVSQRK.js → chunk-Z6NSOC6T.js} +5 -5
- package/dist/{chunk-BBKE4W3B.js → chunk-ZAWGG4H2.js} +7 -7
- package/dist/{chunk-BFVJHH7S.js → chunk-ZF362B2X.js} +5 -5
- package/dist/{chunk-RJTVCA62.js → chunk-ZJIY642R.js} +3 -3
- package/dist/color-input.d.ts +93 -0
- package/dist/color-input.js +35 -0
- package/dist/color-picker.d.ts +268 -0
- package/dist/color-picker.js +28 -0
- package/dist/color-value-DYzChVOW.d.ts +129 -0
- package/dist/combobox.d.ts +1 -1
- package/dist/combobox.js +13 -12
- package/dist/date-calendar.d.ts +49 -0
- package/dist/date-calendar.js +12 -0
- package/dist/date-input.d.ts +1 -1
- package/dist/date-input.js +11 -10
- package/dist/date-picker.d.ts +15 -131
- package/dist/date-picker.js +26 -22
- package/dist/date-types-DrDdF6WJ.d.ts +100 -0
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.js +10 -10
- package/dist/drawer.d.ts +1 -1
- package/dist/drawer.js +9 -9
- package/dist/dropdown-menu.d.ts +1 -1
- package/dist/dropdown-menu.js +6 -6
- package/dist/dropzone.d.ts +3 -3
- package/dist/dropzone.js +17 -16
- package/dist/form.d.ts +15 -5
- package/dist/form.js +75 -36
- package/dist/header-navigation.d.ts +2 -2
- package/dist/header-navigation.js +21 -20
- package/dist/helper.d.ts +1 -1
- package/dist/index.d.ts +25 -11
- package/dist/index.js +92 -79
- package/dist/indicator.js +4 -4
- package/dist/inline-banner.d.ts +68 -0
- package/dist/inline-banner.js +20 -0
- package/dist/input.d.ts +1 -1
- package/dist/input.js +10 -9
- package/dist/kanban-board.d.ts +2 -2
- package/dist/kanban-board.js +16 -15
- package/dist/labels-C992bt7G.d.ts +1160 -0
- package/dist/line-chart.d.ts +2 -2
- package/dist/line-chart.js +7 -6
- package/dist/mcp.js +231 -0
- package/dist/number-input.d.ts +1 -1
- package/dist/number-input.js +10 -9
- package/dist/pagination.d.ts +1 -1
- package/dist/pagination.js +14 -13
- package/dist/{card-D56VxyAe.d.ts → panel-CUGm_Mxy.d.ts} +9 -57
- package/dist/payment-input.d.ts +3 -3
- package/dist/payment-input.js +10 -9
- package/dist/picker-draft-BPV3MUPY.d.ts +9 -0
- package/dist/pie-chart.d.ts +2 -2
- package/dist/pie-chart.js +7 -6
- package/dist/popover.d.ts +65 -4
- package/dist/popover.js +9 -9
- package/dist/progress-steps.js +4 -4
- package/dist/progress.js +3 -3
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +3 -3
- package/dist/qr-code.d.ts +227 -0
- package/dist/qr-code.js +19 -0
- package/dist/radar-chart.d.ts +2 -2
- package/dist/radar-chart.js +7 -6
- package/dist/radial-chart.d.ts +2 -2
- package/dist/radial-chart.js +7 -6
- package/dist/radio.js +8 -7
- package/dist/rich-text-editor.d.ts +624 -0
- package/dist/rich-text-editor.js +51 -0
- package/dist/rich-text-highlight.d.ts +11 -0
- package/dist/rich-text-highlight.js +65 -0
- package/dist/rich-text-sanitize.d.ts +17 -0
- package/dist/rich-text-sanitize.js +176 -0
- package/dist/scroll-area.js +2 -2
- package/dist/select.d.ts +2 -2
- package/dist/select.js +17 -16
- package/dist/separator.js +2 -2
- package/dist/shared-CGf2D8ZX.d.ts +20 -0
- package/dist/sidebar-navigation.d.ts +76 -27
- package/dist/sidebar-navigation.js +16 -15
- package/dist/sidebar-state.d.ts +76 -0
- package/dist/sidebar-state.js +27 -0
- package/dist/skeleton.js +2 -2
- package/dist/slider.d.ts +321 -0
- package/dist/slider.js +13 -0
- package/dist/styles.css +1 -1
- package/dist/switch.d.ts +1 -1
- package/dist/switch.js +2 -2
- package/dist/table.d.ts +3 -19
- package/dist/table.js +34 -33
- package/dist/tabs.js +2 -2
- package/dist/tag-input.d.ts +3 -3
- package/dist/tag-input.js +13 -12
- package/dist/tag.d.ts +1 -1
- package/dist/tag.js +4 -4
- package/dist/textarea.js +8 -7
- package/dist/theme.css +965 -0
- package/dist/theme.js +12 -11
- package/dist/toast.d.ts +1 -1
- package/dist/toast.js +12 -11
- package/dist/tooltip.js +4 -3
- package/dist/tree.d.ts +1 -1
- package/dist/tree.js +6 -6
- package/dist/{types-DR9rAEy1.d.ts → types-DYFl0CEB.d.ts} +1 -1
- package/dist/{use-uploads-KaPqDklo.d.ts → use-uploads-2E7n0PWT.d.ts} +1 -1
- package/dist/verification-code-input.js +10 -9
- package/package.json +92 -8
- package/dist/chunk-BLIZ3CL3.js +0 -49
- package/dist/labels-DPrh0se9.d.ts +0 -627
- package/dist/panel-El4oI68p.d.ts +0 -9
- package/dist/shared-BYXJPnsN.d.ts +0 -11
|
@@ -1,503 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { DateInput } from './chunk-
|
|
4
|
-
import { DEFAULT_FORMAT, parseFormat, fromISO, BE_OFFSET } from './chunk-
|
|
1
|
+
import { DATE_PICKER_LABELS, DayGrid } from './chunk-P2BGR77C.js';
|
|
2
|
+
import { DEFAULT_WEEK_START_INDEX, DEFAULT_WEEK_START, toWireDate } from './chunk-4Y32RIC7.js';
|
|
3
|
+
import { DateInput } from './chunk-ESDSTS5N.js';
|
|
4
|
+
import { DEFAULT_FORMAT, parseFormat, fromISO, BE_OFFSET } from './chunk-KNGJ3CSB.js';
|
|
5
|
+
import { usePickerDraft } from './chunk-KBQJIVUB.js';
|
|
6
|
+
import { useControllable } from './chunk-WJB5GWAZ.js';
|
|
7
|
+
import { Popover } from './chunk-YQAYAJ2T.js';
|
|
5
8
|
import { INTRINSIC_CELL, INTRINSIC_STACK, IntrinsicWidth } from './chunk-7S2TBALK.js';
|
|
6
9
|
import { useLocaleConfig } from './chunk-YIHKQ63K.js';
|
|
7
|
-
import { Button } from './chunk-
|
|
8
|
-
import { FieldShell } from './chunk-
|
|
9
|
-
import { useFieldValidity, FieldFrame, CONTROL_ICON } from './chunk-
|
|
10
|
-
import { CalendarIcon
|
|
10
|
+
import { Button } from './chunk-R25NHHYT.js';
|
|
11
|
+
import { FieldShell } from './chunk-A4YPUS6C.js';
|
|
12
|
+
import { useFieldValidity, FieldFrame, CONTROL_ICON } from './chunk-VIKV25VP.js';
|
|
13
|
+
import { CalendarIcon } from './chunk-YGFTNICV.js';
|
|
11
14
|
import { cn } from './chunk-ZSNJ6UA3.js';
|
|
12
|
-
import { useLabels, usePublishedLabels, LabelsContext } from './chunk-
|
|
13
|
-
import {
|
|
15
|
+
import { useLabels, usePublishedLabels, LabelsContext } from './chunk-ZJIY642R.js';
|
|
16
|
+
import { devWarn } from './chunk-SF3HCW4G.js';
|
|
17
|
+
import { startOfDay, subDays, endOfWeek, startOfWeek, endOfMonth, startOfMonth, subMonths, endOfYear, startOfYear, subYears, format, isValid } from 'date-fns';
|
|
18
|
+
import { Field } from '@base-ui/react/field';
|
|
14
19
|
import { enUS } from 'date-fns/locale';
|
|
15
|
-
import * as
|
|
16
|
-
import { startOfDay, subDays, endOfWeek, startOfWeek, endOfMonth, startOfMonth, subMonths, endOfYear, startOfYear, subYears, isValid, addYears, format } from 'date-fns';
|
|
17
|
-
import { SelectionState, DayFlag, UI, DayPicker } from 'react-day-picker';
|
|
20
|
+
import * as React2 from 'react';
|
|
18
21
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
19
|
-
import { Field } from '@base-ui/react/field';
|
|
20
22
|
|
|
21
|
-
function toDateInputValue(d, hasTime) {
|
|
22
|
-
if (d == null || !isValid(d)) return null;
|
|
23
|
-
return format(d, hasTime ? "yyyy-MM-dd'T'HH:mm" : "yyyy-MM-dd");
|
|
24
|
-
}
|
|
25
|
-
function fromDateInputValue(iso) {
|
|
26
|
-
if (iso == null || iso === "") return null;
|
|
27
|
-
const parts = fromISO(iso);
|
|
28
|
-
if (parts.year == null || parts.month == null || parts.day == null) return null;
|
|
29
|
-
const d = new Date(parts.year, parts.month - 1, parts.day, parts.hour ?? 0, parts.minute ?? 0, parts.second ?? 0, 0);
|
|
30
|
-
return isValid(d) ? d : null;
|
|
31
|
-
}
|
|
32
|
-
function toDateInputBound(d) {
|
|
33
|
-
return d == null || !isValid(d) ? void 0 : toWireDate(d);
|
|
34
|
-
}
|
|
35
|
-
function toRdpRange(v) {
|
|
36
|
-
if (v == null || v.start == null) return void 0;
|
|
37
|
-
return { from: v.start, to: v.end ?? void 0 };
|
|
38
|
-
}
|
|
39
|
-
function fromRdpRange(r) {
|
|
40
|
-
if (r == null) return { start: null, end: null };
|
|
41
|
-
return { start: r.from ?? null, end: r.to ?? null };
|
|
42
|
-
}
|
|
43
|
-
function eraFormatters(era, locale) {
|
|
44
|
-
if (era === "ce") return void 0;
|
|
45
|
-
return {
|
|
46
|
-
formatCaption: (month) => `${format(month, "LLLL", { locale })} ${month.getFullYear() + BE_OFFSET}`,
|
|
47
|
-
// rdp v10 hands the year as a `Date`, not a number (v9 passed a number) — read it from the date.
|
|
48
|
-
formatYearDropdown: (year) => String(year.getFullYear() + BE_OFFSET)
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function eraLabels(era, locale) {
|
|
52
|
-
if (era === "ce") return void 0;
|
|
53
|
-
return {
|
|
54
|
-
labelDayButton: (date) => `${format(date, "d LLLL", { locale })} ${date.getFullYear() + BE_OFFSET}`,
|
|
55
|
-
labelGrid: (date) => `${format(date, "LLLL", { locale })} ${date.getFullYear() + BE_OFFSET}`
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function hasTimeSegments(dateInputFormat) {
|
|
59
|
-
return parseFormat(dateInputFormat).hasTime;
|
|
60
|
-
}
|
|
61
|
-
function defaultDisplayFormat(dateInputFormat) {
|
|
62
|
-
return hasTimeSegments(dateInputFormat) ? "MMM d, yyyy HH:mm" : "MMM d, yyyy";
|
|
63
|
-
}
|
|
64
|
-
var DISPLAY_TIME_TOKEN = /[HhKk]/;
|
|
65
|
-
function stripQuoted(pattern) {
|
|
66
|
-
return pattern.replaceAll(/'([^']*)'/g, "");
|
|
67
|
-
}
|
|
68
|
-
function displayFormatHasTime(format) {
|
|
69
|
-
return DISPLAY_TIME_TOKEN.test(stripQuoted(format));
|
|
70
|
-
}
|
|
71
|
-
function warnFormatMismatch(component, format, dateInputFormat) {
|
|
72
|
-
if (format == null) return;
|
|
73
|
-
const typed = hasTimeSegments(dateInputFormat);
|
|
74
|
-
const printed = displayFormatHasTime(format);
|
|
75
|
-
if (typed === printed) return;
|
|
76
|
-
devWarn(
|
|
77
|
-
printed ? `<${component}> \`format="${format}"\` prints a time, but \`dateInputFormat="${dateInputFormat}"\` has no time segment to type one \u2014 the trigger will show a time the popover cannot change. Add \`HH:mm\` to \`dateInputFormat\`, or drop it from \`format\`.` : `<${component}> \`dateInputFormat="${dateInputFormat}"\` types a time, but \`format="${format}"\` never prints one \u2014 the trigger will hide the value the user just typed. Add a time token to \`format\`, or drop it from \`dateInputFormat\`.`
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
var YEAR_RUN = /([yYRu])\1*/g;
|
|
81
|
-
function beYearPattern(pattern, ceYear) {
|
|
82
|
-
const beYear = ceYear + BE_OFFSET;
|
|
83
|
-
return pattern.split(/('[^']*')/).map(
|
|
84
|
-
(chunk, index) => (
|
|
85
|
-
// Odd chunks are the captured quoted literals — pass them through untouched.
|
|
86
|
-
index % 2 === 1 ? chunk : chunk.replaceAll(YEAR_RUN, (run) => run.length === 2 ? String(beYear).slice(-2) : String(beYear).padStart(run.length, "0"))
|
|
87
|
-
)
|
|
88
|
-
).join("");
|
|
89
|
-
}
|
|
90
|
-
function formatDateValue(d, pattern, locale, era) {
|
|
91
|
-
return format(d, era === "be" ? beYearPattern(pattern, d.getFullYear()) : pattern, { locale });
|
|
92
|
-
}
|
|
93
|
-
function toCalendarDate(d) {
|
|
94
|
-
if (d == null || !isValid(d)) return null;
|
|
95
|
-
return startOfDay(d);
|
|
96
|
-
}
|
|
97
|
-
function toFormValue(d, hasTime) {
|
|
98
|
-
if (d == null) return "";
|
|
99
|
-
return toDateInputValue(d, hasTime) ?? "";
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// src/components/date-picker/shared.ts
|
|
103
|
-
var CELL_SIZE = {
|
|
104
|
-
sm: "size-8",
|
|
105
|
-
md: "size-10",
|
|
106
|
-
lg: "size-11"
|
|
107
|
-
};
|
|
108
|
-
var DAY_TEXT = { sm: "text-xs", md: "text-sm", lg: "text-sm" };
|
|
109
|
-
var CAPTION_TEXT = { sm: "text-sm", md: "text-sm", lg: "text-md" };
|
|
110
|
-
var MONTHS_GAP = { sm: "gap-4", md: "gap-6", lg: "gap-6" };
|
|
111
|
-
var FOCUS_RING = "outline-focus-ring focus-visible:outline-2 focus-visible:-outline-offset-2";
|
|
112
|
-
var DAY_RADIUS = "rounded-lg";
|
|
113
|
-
var SELECTED_FILL = cn(
|
|
114
|
-
"text-fg-white",
|
|
115
|
-
"[&>button]:bg-brand-solid [&>button]:font-medium [&>button]:text-fg-white [&>button]:hover:bg-brand-solid_hover",
|
|
116
|
-
"[&>button]:[--dot:var(--color-fg-white)]"
|
|
117
|
-
);
|
|
118
|
-
var NAV_BUTTON = cn(
|
|
119
|
-
"absolute top-0 inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-lg",
|
|
120
|
-
"text-fg-quaternary transition-colors duration-100 ease-linear hover:bg-ghost-hover hover:text-secondary",
|
|
121
|
-
// See the header: rdp uses `aria-disabled`, never the attribute.
|
|
122
|
-
"aria-disabled:pointer-events-none aria-disabled:text-fg-disabled",
|
|
123
|
-
"[&>svg]:size-5 [&>svg]:shrink-0",
|
|
124
|
-
FOCUS_RING
|
|
125
|
-
);
|
|
126
|
-
function dayGridClasses(size, months, selection) {
|
|
127
|
-
return {
|
|
128
|
-
/* The root draws NO box — see the header. It sets the type family + base colour only, so a grid
|
|
129
|
-
dropped onto an unstyled surface still inherits the library's font.
|
|
130
|
-
|
|
131
|
-
The colour is `fg-secondary` (gray-700), not `fg` (gray-900), and it is set HERE rather than on
|
|
132
|
-
the day button so that the four per-day states can keep overriding it from the `<td>` by plain
|
|
133
|
-
inheritance — a `text-*` on `day_button` would out-specify every one of them. A calendar reads
|
|
134
|
-
as a field of values to choose between, not as body copy; gray-900 numerals made the whole grid
|
|
135
|
-
shout, and it is the one colour Untitled UI's grid and ours had genuinely different. */
|
|
136
|
-
root: "text-secondary",
|
|
137
|
-
/* Two months sit side by side and **wrap** when their parent is too narrow — plain `flex-wrap`,
|
|
138
|
-
deliberately NOT a container query.
|
|
139
|
-
|
|
140
|
-
Two reasons, both load-bearing. (1) A `@container` needs `container-type: inline-size`, which is
|
|
141
|
-
inline-size CONTAINMENT: the element's own width stops depending on its contents. The grid's host
|
|
142
|
-
inside a picker is a `w-max` (shrink-to-fit) popup, so a contained grid root would collapse the
|
|
143
|
-
popup it is meant to size. (2) A query threshold is a second truth about how wide two months are
|
|
144
|
-
— and `@md` (448px) was already wrong, because two `md` months are 584px, so the row engaged and
|
|
145
|
-
then overflowed. Wrapping needs no threshold at all: it reflows at exactly the width where the
|
|
146
|
-
months stop fitting, at every `size`. */
|
|
147
|
-
months: cn("flex flex-wrap", months === 2 && MONTHS_GAP[size]),
|
|
148
|
-
/* `relative`, because the two nav arrows are absolutely positioned into this month's caption row.
|
|
149
|
-
With `navLayout: "around"` rdp puts the PREVIOUS button in the first month and the NEXT button
|
|
150
|
-
in the last one, so at `months={2}` one pair of arrows spans both grids — which is the layout a
|
|
151
|
-
range picker wants — and at `months={1}` they flank that month's own caption.
|
|
152
|
-
|
|
153
|
-
`shrink-0` is what keeps the grid honest: a month is exactly 7 cells wide, and a shrinkable flex
|
|
154
|
-
item would be squeezed below that and spill its rows over the neighbouring month (which is
|
|
155
|
-
precisely what `min-w-0` here did). */
|
|
156
|
-
month: "relative flex shrink-0 flex-col gap-3",
|
|
157
|
-
/* `px-8` reserves both arrows' width, so a long month name in a locale like Thai can never slide
|
|
158
|
-
under a chevron — keep it equal to `NAV_BUTTON`'s box. */
|
|
159
|
-
month_caption: cn("flex h-8 items-center justify-center px-8", CAPTION_TEXT[size]),
|
|
160
|
-
/* Shared by the plain caption AND the dropdown's visible label (which appends its own chevron),
|
|
161
|
-
so it has to be a flex line rather than plain text. */
|
|
162
|
-
caption_label: "inline-flex items-center gap-1 font-semibold text-secondary",
|
|
163
|
-
button_previous: cn(NAV_BUTTON, "left-0"),
|
|
164
|
-
button_next: cn(NAV_BUTTON, "right-0"),
|
|
165
|
-
/* The dropdown caption — mounted only when the min/max span makes a year list useful (see
|
|
166
|
-
`day-picker.tsx`). rdp overlays a transparent native `<select>` on the label: the label carries
|
|
167
|
-
the visible chrome, the select carries the hit area and the keyboard. */
|
|
168
|
-
dropdowns: cn("flex items-center gap-1", CAPTION_TEXT[size]),
|
|
169
|
-
dropdown_root: "relative inline-flex cursor-pointer items-center rounded-lg px-1.5 hover:bg-ghost-hover has-[:focus-visible]:outline-2 has-[:focus-visible]:-outline-offset-2 has-[:focus-visible]:outline-focus-ring",
|
|
170
|
-
dropdown: "absolute inset-0 cursor-pointer appearance-none bg-transparent opacity-0",
|
|
171
|
-
/* `w-max`, not `w-full`: the rows are fixed-width flex lines (7 cells), so the table must size to
|
|
172
|
-
them rather than to a parent that may be narrower. */
|
|
173
|
-
month_grid: "w-max",
|
|
174
|
-
/* `weekdays` is a `<tr>` and `week` is a `<tr>`; `flex` on both is what makes the columns line up
|
|
175
|
-
with the fixed-size cells instead of with table auto-layout.
|
|
176
|
-
|
|
177
|
-
The `mb-1` on both is the grid's ROW RHYTHM: 4px of air under the weekday initials and between
|
|
178
|
-
every pair of week rows, so a range band reads as a run of separate weeks rather than one solid
|
|
179
|
-
block. It is a MARGIN, not a `gap`, precisely so the band stays gapless HORIZONTALLY. */
|
|
180
|
-
weekdays: "mb-1 flex",
|
|
181
|
-
weekday: cn(
|
|
182
|
-
"flex items-center justify-center font-medium text-secondary",
|
|
183
|
-
CELL_SIZE[size],
|
|
184
|
-
// Tracks the day type scale: the initials head their columns, so a smaller step made the header
|
|
185
|
-
// read as a caption floating above the grid rather than as part of it.
|
|
186
|
-
DAY_TEXT[size]
|
|
187
|
-
),
|
|
188
|
-
week: "flex last:mb-0 mb-1",
|
|
189
|
-
/* The CELL is the range band's paint surface — a continuous band needs a gapless, un-rounded box —
|
|
190
|
-
so the wash lives here and the button on top stays transparent. `p-0` because a `<td>` would
|
|
191
|
-
otherwise take table padding and break the band.
|
|
192
|
-
|
|
193
|
-
`first:`/`last:` round the band where a WEEK ends, not only where the selection does: a band
|
|
194
|
-
that runs into Saturday and resumes on Sunday is two runs on screen, and a square cut on each
|
|
195
|
-
would read as a band clipped by the grid rather than as one that wraps. Invisible on any day
|
|
196
|
-
that carries no fill. */
|
|
197
|
-
day: cn("relative p-0 first:rounded-l-lg last:rounded-r-lg", CELL_SIZE[size]),
|
|
198
|
-
day_button: cn(
|
|
199
|
-
"relative flex size-full cursor-pointer items-center justify-center font-normal tabular-nums transition-colors duration-100 ease-linear",
|
|
200
|
-
DAY_RADIUS,
|
|
201
|
-
DAY_TEXT[size],
|
|
202
|
-
// A ghost's hover wash: the one deliberately TRANSLUCENT surface role, because a day rests with
|
|
203
|
-
// no fill and must step off an unknown host (a card, a popover, a range band). See the header's
|
|
204
|
-
// ladder — this is the same 6% step today's pill and the band wear.
|
|
205
|
-
"hover:bg-ghost-hover hover:font-medium",
|
|
206
|
-
FOCUS_RING
|
|
207
|
-
),
|
|
208
|
-
/* Today: a brand dot under the numeral, plus the weight — and **no fill of its own**. Untitled UI
|
|
209
|
-
gives it a neutral pill as well; we deliberately do not, because the grid already spends its two
|
|
210
|
-
neutral washes on the hover and the range band, and a third static one made today read as a
|
|
211
|
-
permanently-hovered cell (identical value to the hover, by construction) and as a second kind of
|
|
212
|
-
"chosen" beside the brand chip. A dot is the whole marker: it is the only mark in the grid that
|
|
213
|
-
means "now" rather than "picked", so it should not borrow the vocabulary of either.
|
|
214
|
-
|
|
215
|
-
The dot is centred explicitly (`left-1/2` + `-translate-x-1/2`) rather than left to its static
|
|
216
|
-
position — the button is a flex line, so an absolute child with no inline offset lands after the
|
|
217
|
-
numeral, not under it.
|
|
218
|
-
|
|
219
|
-
**It travels on `--dot`,** published here on the `<td>` and republished on the `<button>` by
|
|
220
|
-
`SELECTED_FILL` — see its note for why an inherited-vs-own cascade beats a specificity contest.
|
|
221
|
-
`bg-current` used to do this job and can no longer: it followed the numeral, and the numeral is
|
|
222
|
-
now the grid's plain gray rather than brand. */
|
|
223
|
-
today: cn(
|
|
224
|
-
"[--dot:var(--color-text-brand-secondary)] [&>button]:font-medium",
|
|
225
|
-
"[&>button]:after:absolute [&>button]:after:bottom-1 [&>button]:after:left-1/2 [&>button]:after:size-1",
|
|
226
|
-
"[&>button]:after:-translate-x-1/2 [&>button]:after:rounded-full [&>button]:after:bg-(color:--dot)"
|
|
227
|
-
),
|
|
228
|
-
/* A day belonging to the flanking month — **the one value NOT taken from Untitled UI.** Theirs is
|
|
229
|
-
`opacity-50` over secondary text, which measures #99A0AA: **2.58:1** on white. An outside day is
|
|
230
|
-
not disabled — it is clickable, and selecting one jumps the grid a month — so it owes AA like any
|
|
231
|
-
other control's text. `fg-subtle` (gray-500) is the faintest stop in the ramp that clears it, at
|
|
232
|
-
4.98:1, and there is nothing between it and the failing one. (An `opacity-*` was never available
|
|
233
|
-
either — see the header: it would fade the focus ring with it.) */
|
|
234
|
-
outside: "text-quaternary",
|
|
235
|
-
/* No `opacity-*` — see the header. */
|
|
236
|
-
disabled: "pointer-events-none text-fg-disabled",
|
|
237
|
-
hidden: "invisible",
|
|
238
|
-
/* The brand fill. Yielded to the three range states ONLY once a range is complete enough for them
|
|
239
|
-
to be emitted — see the `selection` param's note. */
|
|
240
|
-
selected: selection === "range-complete" ? "" : SELECTED_FILL,
|
|
241
|
-
/* The range band. The wash is on the CELL, so it is gapless and continuous across the row; the two
|
|
242
|
-
ends put the solid brand fill on their BUTTON, which sits on top at the full cell size and covers
|
|
243
|
-
the wash under it. So a single-day range (`start === end`, which takes BOTH end classes) is a
|
|
244
|
-
plain rounded brand square, with no half-rounded seam to reconcile.
|
|
245
|
-
|
|
246
|
-
**The band is NEUTRAL, and the brand belongs to the two ends alone.** It was `bg-brand-soft`, and
|
|
247
|
-
a purple band next to purple endpoints left the ends — the only two days the user actually
|
|
248
|
-
chose — with nothing to stand out against. A gray run under two brand chips says "these two, and
|
|
249
|
-
everything between" in one read. The wash and its hover are the header's 6% / 10% ladder. */
|
|
250
|
-
range_start: cn("rounded-l-lg bg-ghost-hover", SELECTED_FILL),
|
|
251
|
-
range_end: cn("rounded-r-lg bg-ghost-hover", SELECTED_FILL),
|
|
252
|
-
range_middle: "bg-ghost-hover [&>button]:font-medium [&>button]:hover:bg-selected"
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
function disabledMatchers(min, max, disabledDates) {
|
|
256
|
-
const matchers = [];
|
|
257
|
-
if (min) matchers.push({ before: min });
|
|
258
|
-
if (max) matchers.push({ after: max });
|
|
259
|
-
if (typeof disabledDates === "function") matchers.push(disabledDates);
|
|
260
|
-
else if (disabledDates) matchers.push([...disabledDates]);
|
|
261
|
-
return matchers.length > 0 ? matchers : void 0;
|
|
262
|
-
}
|
|
263
|
-
function Chevron({ orientation }) {
|
|
264
|
-
if (orientation === "left") return /* @__PURE__ */ jsx(ChevronLeftIcon, {});
|
|
265
|
-
if (orientation === "right") return /* @__PURE__ */ jsx(ChevronRightIcon, {});
|
|
266
|
-
return /* @__PURE__ */ jsx(ChevronDownIcon, {});
|
|
267
|
-
}
|
|
268
|
-
function NamedRoot({ rootRef, ...rest }) {
|
|
269
|
-
return /* @__PURE__ */ jsx("div", { ...rest, ref: rootRef, role: "group" });
|
|
270
|
-
}
|
|
271
|
-
function DayGrid(props) {
|
|
272
|
-
const {
|
|
273
|
-
mode,
|
|
274
|
-
selected,
|
|
275
|
-
onSelect,
|
|
276
|
-
months = 1,
|
|
277
|
-
min,
|
|
278
|
-
max,
|
|
279
|
-
disabledDates,
|
|
280
|
-
locale,
|
|
281
|
-
weekStartsOn,
|
|
282
|
-
era,
|
|
283
|
-
size,
|
|
284
|
-
defaultMonth,
|
|
285
|
-
month,
|
|
286
|
-
onMonthChange,
|
|
287
|
-
minNights,
|
|
288
|
-
maxNights,
|
|
289
|
-
ariaLabel,
|
|
290
|
-
className
|
|
291
|
-
} = props;
|
|
292
|
-
const component = mode === "range" ? "DateRangeCalendar / DateRangePicker" : "DateCalendar / DatePicker";
|
|
293
|
-
warnPositiveInt(component, "minNights", minNights);
|
|
294
|
-
warnPositiveInt(component, "maxNights", maxNights);
|
|
295
|
-
const range = mode === "range" ? selected : null;
|
|
296
|
-
const selection = mode === "single" ? "single" : range?.start != null && range.end != null ? "range-complete" : "range-open";
|
|
297
|
-
const classes = dayGridClasses(size, months, selection);
|
|
298
|
-
const classNames = React5.useMemo(
|
|
299
|
-
() => ({
|
|
300
|
-
[UI.Root]: cn(classes.root, className),
|
|
301
|
-
[UI.Months]: classes.months,
|
|
302
|
-
[UI.Month]: classes.month,
|
|
303
|
-
[UI.MonthCaption]: classes.month_caption,
|
|
304
|
-
[UI.CaptionLabel]: classes.caption_label,
|
|
305
|
-
[UI.PreviousMonthButton]: classes.button_previous,
|
|
306
|
-
[UI.NextMonthButton]: classes.button_next,
|
|
307
|
-
[UI.Dropdowns]: classes.dropdowns,
|
|
308
|
-
[UI.Dropdown]: classes.dropdown,
|
|
309
|
-
[UI.DropdownRoot]: classes.dropdown_root,
|
|
310
|
-
[UI.MonthGrid]: classes.month_grid,
|
|
311
|
-
[UI.Weekdays]: classes.weekdays,
|
|
312
|
-
[UI.Weekday]: classes.weekday,
|
|
313
|
-
[UI.Week]: classes.week,
|
|
314
|
-
[UI.Day]: classes.day,
|
|
315
|
-
[UI.DayButton]: classes.day_button,
|
|
316
|
-
[DayFlag.today]: classes.today,
|
|
317
|
-
[DayFlag.outside]: classes.outside,
|
|
318
|
-
[DayFlag.disabled]: classes.disabled,
|
|
319
|
-
[DayFlag.hidden]: classes.hidden,
|
|
320
|
-
[SelectionState.selected]: classes.selected,
|
|
321
|
-
[SelectionState.range_start]: classes.range_start,
|
|
322
|
-
[SelectionState.range_middle]: classes.range_middle,
|
|
323
|
-
[SelectionState.range_end]: classes.range_end
|
|
324
|
-
}),
|
|
325
|
-
[classes, className]
|
|
326
|
-
);
|
|
327
|
-
const spansYears = min != null && max != null && max.getTime() > addYears(min, 2).getTime();
|
|
328
|
-
const captionLayout = spansYears ? "dropdown" : "label";
|
|
329
|
-
const shared = {
|
|
330
|
-
numberOfMonths: months,
|
|
331
|
-
startMonth: min ? startOfMonth(min) : void 0,
|
|
332
|
-
endMonth: max ? startOfMonth(max) : void 0,
|
|
333
|
-
disabled: disabledMatchers(min, max, disabledDates),
|
|
334
|
-
locale,
|
|
335
|
-
// Explicit, and always set: rdp would otherwise read the week start off `locale`, which is the
|
|
336
|
-
// rule this prop replaced (`src/lib/date.ts`'s `WeekStart` records why).
|
|
337
|
-
weekStartsOn: weekStartIndex(weekStartsOn, locale),
|
|
338
|
-
formatters: eraFormatters(era, locale),
|
|
339
|
-
labels: eraLabels(era, locale),
|
|
340
|
-
classNames,
|
|
341
|
-
components: ariaLabel == null ? { Chevron } : { Chevron, Root: NamedRoot },
|
|
342
|
-
captionLayout,
|
|
343
|
-
// prev/next flanking the caption — the house pattern, and at `months={2}` rdp puts the two arrows
|
|
344
|
-
// in the FIRST and LAST month, so one pair spans both grids instead of repeating per month.
|
|
345
|
-
navLayout: "around",
|
|
346
|
-
// A six-row grid always, so opening a 5-row month next to a 6-row one does not jump the popover's
|
|
347
|
-
// height; the outside days are what fill it.
|
|
348
|
-
fixedWeeks: true,
|
|
349
|
-
showOutsideDays: true,
|
|
350
|
-
// Motion is ours (`overlay/motion.ts`). rdp's month slide would fight the popover's own
|
|
351
|
-
// enter/exit transform, and the two run on different timing curves.
|
|
352
|
-
animate: false,
|
|
353
|
-
defaultMonth,
|
|
354
|
-
month,
|
|
355
|
-
onMonthChange,
|
|
356
|
-
"aria-label": ariaLabel
|
|
357
|
-
};
|
|
358
|
-
if (mode === "range") {
|
|
359
|
-
const value2 = selected;
|
|
360
|
-
return /* @__PURE__ */ jsx(
|
|
361
|
-
DayPicker,
|
|
362
|
-
{
|
|
363
|
-
...shared,
|
|
364
|
-
mode: "range",
|
|
365
|
-
selected: toRdpRange(value2),
|
|
366
|
-
onSelect: (next) => onSelect(fromRdpRange(next)),
|
|
367
|
-
resetOnSelect: true,
|
|
368
|
-
min: minNights,
|
|
369
|
-
max: maxNights
|
|
370
|
-
}
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
const value = selected;
|
|
374
|
-
return /* @__PURE__ */ jsx(DayPicker, { ...shared, mode: "single", selected: value ?? void 0, onSelect: (next) => onSelect(next ?? null) });
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// src/components/date-picker/labels.ts
|
|
378
|
-
var DATE_PICKER_LABELS = {
|
|
379
|
-
/** The trigger's accessible name when the field has no `label`. */
|
|
380
|
-
openCalendar: "Choose a date",
|
|
381
|
-
openRange: "Choose a date range",
|
|
382
|
-
/** The two typed segments of a range. */
|
|
383
|
-
startDate: "Start date",
|
|
384
|
-
endDate: "End date",
|
|
385
|
-
/** The confirm footer, shown under `commit="confirm"`. */
|
|
386
|
-
cancel: "Cancel",
|
|
387
|
-
apply: "Apply",
|
|
388
|
-
/** Defaults behind the `placeholder` props — each prop still wins. */
|
|
389
|
-
placeholder: "Select date",
|
|
390
|
-
rangePlaceholder: "Select dates",
|
|
391
|
-
/** Defaults behind the standalone calendars' `aria-label`. */
|
|
392
|
-
calendarName: "Calendar",
|
|
393
|
-
rangeCalendarName: "Date range calendar",
|
|
394
|
-
/**
|
|
395
|
-
* Appended to the trigger's accessible name when the field is required, visually hidden —
|
|
396
|
-
* `aria-required` is illegal on `role="button"`, so the requirement has to travel in the NAME.
|
|
397
|
-
*
|
|
398
|
-
* Deliberately the bare word, NOT the `", required"` that `FIELD_LABELS` and `DROPZONE_LABELS`
|
|
399
|
-
* carry: this converts an existing literal and the pass's rule is that a default is byte-identical
|
|
400
|
-
* to what it replaced. The three spellings SHOULD agree — the comma is a pause a screen reader
|
|
401
|
-
* honours — but changing what a picker announces is a decision, not a conversion.
|
|
402
|
-
*/
|
|
403
|
-
required: "required"
|
|
404
|
-
};
|
|
405
|
-
function DateCalendar(props) {
|
|
406
|
-
const {
|
|
407
|
-
value,
|
|
408
|
-
defaultValue = null,
|
|
409
|
-
onValueChange,
|
|
410
|
-
min,
|
|
411
|
-
max,
|
|
412
|
-
disabledDates,
|
|
413
|
-
locale: localeProp,
|
|
414
|
-
weekStartsOn: weekStartsOnProp,
|
|
415
|
-
era: eraProp,
|
|
416
|
-
labels,
|
|
417
|
-
size = "md",
|
|
418
|
-
defaultMonth,
|
|
419
|
-
className
|
|
420
|
-
} = props;
|
|
421
|
-
const t = useLabels("datePicker", DATE_PICKER_LABELS, labels);
|
|
422
|
-
const app = useLocaleConfig();
|
|
423
|
-
const locale = localeProp ?? app.locale ?? enUS;
|
|
424
|
-
const era = eraProp ?? app.era ?? "ce";
|
|
425
|
-
const weekStartsOn = weekStartsOnProp ?? app.weekStartsOn ?? DEFAULT_WEEK_START;
|
|
426
|
-
const [selected, setSelected] = useControllable(value, defaultValue, onValueChange);
|
|
427
|
-
const normalized = React5.useMemo(() => toCalendarDate(selected), [selected]);
|
|
428
|
-
return /* @__PURE__ */ jsx(
|
|
429
|
-
DayGrid,
|
|
430
|
-
{
|
|
431
|
-
mode: "single",
|
|
432
|
-
selected: normalized,
|
|
433
|
-
onSelect: (next) => setSelected(next),
|
|
434
|
-
min,
|
|
435
|
-
max,
|
|
436
|
-
disabledDates,
|
|
437
|
-
locale,
|
|
438
|
-
weekStartsOn,
|
|
439
|
-
era,
|
|
440
|
-
size,
|
|
441
|
-
defaultMonth,
|
|
442
|
-
ariaLabel: props["aria-label"] ?? t.calendarName,
|
|
443
|
-
className
|
|
444
|
-
}
|
|
445
|
-
);
|
|
446
|
-
}
|
|
447
|
-
DateCalendar.displayName = "DateCalendar";
|
|
448
|
-
var EMPTY_RANGE = { start: null, end: null };
|
|
449
|
-
function DateRangeCalendar(props) {
|
|
450
|
-
const {
|
|
451
|
-
value,
|
|
452
|
-
defaultValue = null,
|
|
453
|
-
onValueChange,
|
|
454
|
-
months = 2,
|
|
455
|
-
minNights,
|
|
456
|
-
maxNights,
|
|
457
|
-
min,
|
|
458
|
-
max,
|
|
459
|
-
disabledDates,
|
|
460
|
-
locale: localeProp,
|
|
461
|
-
weekStartsOn: weekStartsOnProp,
|
|
462
|
-
era: eraProp,
|
|
463
|
-
labels,
|
|
464
|
-
size = "md",
|
|
465
|
-
defaultMonth,
|
|
466
|
-
className
|
|
467
|
-
} = props;
|
|
468
|
-
const t = useLabels("datePicker", DATE_PICKER_LABELS, labels);
|
|
469
|
-
const app = useLocaleConfig();
|
|
470
|
-
const locale = localeProp ?? app.locale ?? enUS;
|
|
471
|
-
const era = eraProp ?? app.era ?? "ce";
|
|
472
|
-
const weekStartsOn = weekStartsOnProp ?? app.weekStartsOn ?? DEFAULT_WEEK_START;
|
|
473
|
-
const [selected, setSelected] = useControllable(value, defaultValue, (next) => onValueChange?.(next ?? EMPTY_RANGE));
|
|
474
|
-
const normalized = React5.useMemo(
|
|
475
|
-
() => ({ start: toCalendarDate(selected?.start), end: toCalendarDate(selected?.end) }),
|
|
476
|
-
[selected?.start, selected?.end]
|
|
477
|
-
);
|
|
478
|
-
return /* @__PURE__ */ jsx(
|
|
479
|
-
DayGrid,
|
|
480
|
-
{
|
|
481
|
-
mode: "range",
|
|
482
|
-
selected: normalized,
|
|
483
|
-
onSelect: (next) => setSelected(next),
|
|
484
|
-
months,
|
|
485
|
-
minNights,
|
|
486
|
-
maxNights,
|
|
487
|
-
min,
|
|
488
|
-
max,
|
|
489
|
-
disabledDates,
|
|
490
|
-
locale,
|
|
491
|
-
weekStartsOn,
|
|
492
|
-
era,
|
|
493
|
-
size,
|
|
494
|
-
defaultMonth,
|
|
495
|
-
ariaLabel: props["aria-label"] ?? t.rangeCalendarName,
|
|
496
|
-
className
|
|
497
|
-
}
|
|
498
|
-
);
|
|
499
|
-
}
|
|
500
|
-
DateRangeCalendar.displayName = "DateRangeCalendar";
|
|
501
23
|
var HOUSE_WEEK = { weekStartsOn: DEFAULT_WEEK_START_INDEX };
|
|
502
24
|
function resolvePreset(preset) {
|
|
503
25
|
return typeof preset.range === "function" ? preset.range() : preset.range;
|
|
@@ -561,6 +83,59 @@ var DATE_PRESETS = [
|
|
|
561
83
|
},
|
|
562
84
|
{ label: "All time", range: { start: null, end: null } }
|
|
563
85
|
];
|
|
86
|
+
function toDateInputValue(d, hasTime) {
|
|
87
|
+
if (d == null || !isValid(d)) return null;
|
|
88
|
+
return format(d, hasTime ? "yyyy-MM-dd'T'HH:mm" : "yyyy-MM-dd");
|
|
89
|
+
}
|
|
90
|
+
function fromDateInputValue(iso) {
|
|
91
|
+
if (iso == null || iso === "") return null;
|
|
92
|
+
const parts = fromISO(iso);
|
|
93
|
+
if (parts.year == null || parts.month == null || parts.day == null) return null;
|
|
94
|
+
const d = new Date(parts.year, parts.month - 1, parts.day, parts.hour ?? 0, parts.minute ?? 0, parts.second ?? 0, 0);
|
|
95
|
+
return isValid(d) ? d : null;
|
|
96
|
+
}
|
|
97
|
+
function toDateInputBound(d) {
|
|
98
|
+
return d == null || !isValid(d) ? void 0 : toWireDate(d);
|
|
99
|
+
}
|
|
100
|
+
function hasTimeSegments(dateInputFormat) {
|
|
101
|
+
return parseFormat(dateInputFormat).hasTime;
|
|
102
|
+
}
|
|
103
|
+
function defaultDisplayFormat(dateInputFormat) {
|
|
104
|
+
return hasTimeSegments(dateInputFormat) ? "MMM d, yyyy HH:mm" : "MMM d, yyyy";
|
|
105
|
+
}
|
|
106
|
+
var DISPLAY_TIME_TOKEN = /[HhKk]/;
|
|
107
|
+
function stripQuoted(pattern) {
|
|
108
|
+
return pattern.replaceAll(/'([^']*)'/g, "");
|
|
109
|
+
}
|
|
110
|
+
function displayFormatHasTime(format) {
|
|
111
|
+
return DISPLAY_TIME_TOKEN.test(stripQuoted(format));
|
|
112
|
+
}
|
|
113
|
+
function warnFormatMismatch(component, format, dateInputFormat) {
|
|
114
|
+
if (format == null) return;
|
|
115
|
+
const typed = hasTimeSegments(dateInputFormat);
|
|
116
|
+
const printed = displayFormatHasTime(format);
|
|
117
|
+
if (typed === printed) return;
|
|
118
|
+
devWarn(
|
|
119
|
+
printed ? `<${component}> \`format="${format}"\` prints a time, but \`dateInputFormat="${dateInputFormat}"\` has no time segment to type one \u2014 the trigger will show a time the popover cannot change. Add \`HH:mm\` to \`dateInputFormat\`, or drop it from \`format\`.` : `<${component}> \`dateInputFormat="${dateInputFormat}"\` types a time, but \`format="${format}"\` never prints one \u2014 the trigger will hide the value the user just typed. Add a time token to \`format\`, or drop it from \`dateInputFormat\`.`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
var YEAR_RUN = /([yYRu])\1*/g;
|
|
123
|
+
function beYearPattern(pattern, ceYear) {
|
|
124
|
+
const beYear = ceYear + BE_OFFSET;
|
|
125
|
+
return pattern.split(/('[^']*')/).map(
|
|
126
|
+
(chunk, index) => (
|
|
127
|
+
// Odd chunks are the captured quoted literals — pass them through untouched.
|
|
128
|
+
index % 2 === 1 ? chunk : chunk.replaceAll(YEAR_RUN, (run) => run.length === 2 ? String(beYear).slice(-2) : String(beYear).padStart(run.length, "0"))
|
|
129
|
+
)
|
|
130
|
+
).join("");
|
|
131
|
+
}
|
|
132
|
+
function formatDateValue(d, pattern, locale, era) {
|
|
133
|
+
return format(d, era === "be" ? beYearPattern(pattern, d.getFullYear()) : pattern, { locale });
|
|
134
|
+
}
|
|
135
|
+
function toFormValue(d, hasTime) {
|
|
136
|
+
if (d == null) return "";
|
|
137
|
+
return toDateInputValue(d, hasTime) ?? "";
|
|
138
|
+
}
|
|
564
139
|
var TRIGGER_CLASS = cn(
|
|
565
140
|
"flex min-w-0 flex-1 cursor-pointer items-center justify-between gap-2 self-stretch bg-transparent text-left outline-none",
|
|
566
141
|
"disabled:cursor-not-allowed"
|
|
@@ -643,32 +218,6 @@ function PresetRail({ presets, value, onPick }) {
|
|
|
643
218
|
preset.label
|
|
644
219
|
)) });
|
|
645
220
|
}
|
|
646
|
-
function usePickerDraft(committed, commit, setCommitted, onOpen) {
|
|
647
|
-
const [open, setOpen] = React5.useState(false);
|
|
648
|
-
const [draft, setDraftState] = React5.useState(committed);
|
|
649
|
-
const onOpenChange = (next) => {
|
|
650
|
-
if (next) {
|
|
651
|
-
setDraftState(committed);
|
|
652
|
-
onOpen?.(committed);
|
|
653
|
-
}
|
|
654
|
-
setOpen(next);
|
|
655
|
-
};
|
|
656
|
-
const setDraft = (next) => {
|
|
657
|
-
setDraftState(next);
|
|
658
|
-
if (commit === "instant") setCommitted(next);
|
|
659
|
-
};
|
|
660
|
-
return {
|
|
661
|
-
open,
|
|
662
|
-
draft,
|
|
663
|
-
setDraft,
|
|
664
|
-
onOpenChange,
|
|
665
|
-
apply: () => {
|
|
666
|
-
setCommitted(draft);
|
|
667
|
-
setOpen(false);
|
|
668
|
-
},
|
|
669
|
-
close: () => setOpen(false)
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
221
|
function ApplyRow({ onCancel, onApply, disabled }) {
|
|
673
222
|
const t = useLabels("datePicker", DATE_PICKER_LABELS, void 0);
|
|
674
223
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -726,12 +275,12 @@ function DatePicker(props) {
|
|
|
726
275
|
const hasTime = hasTimeSegments(dateInputFormat);
|
|
727
276
|
const displayFormat = formatProp ?? defaultDisplayFormat(dateInputFormat);
|
|
728
277
|
const [rawCommitted, setCommitted] = useControllable(value, defaultValue, onValueChange);
|
|
729
|
-
const committed =
|
|
730
|
-
|
|
278
|
+
const committed = React2.useMemo(() => normalizeValue(rawCommitted, hasTime), [rawCommitted, hasTime]);
|
|
279
|
+
React2.useEffect(() => {
|
|
731
280
|
warnFormatMismatch("DatePicker", formatProp, dateInputFormat);
|
|
732
281
|
}, [formatProp, dateInputFormat]);
|
|
733
282
|
const { isInvalid, showError } = useFieldValidity(invalid, error);
|
|
734
|
-
const reactId =
|
|
283
|
+
const reactId = React2.useId();
|
|
735
284
|
const base = id ?? reactId;
|
|
736
285
|
const labelId = label == null ? void 0 : `${base}-label`;
|
|
737
286
|
const valueId = `${base}-value`;
|
|
@@ -739,7 +288,7 @@ function DatePicker(props) {
|
|
|
739
288
|
const hintId = `${base}-hint`;
|
|
740
289
|
const errorId = `${base}-error`;
|
|
741
290
|
const describedBy = showError ? errorId : hint != null && hint !== "" ? hintId : void 0;
|
|
742
|
-
const [month, setMonth] =
|
|
291
|
+
const [month, setMonth] = React2.useState(committed ?? defaultMonth);
|
|
743
292
|
const picker = usePickerDraft(committed, commit, setCommitted, (seeded) => setMonth(seeded ?? defaultMonth));
|
|
744
293
|
function onGridSelect(next) {
|
|
745
294
|
const merged = withTimeOf(next, picker.draft, hasTime);
|
|
@@ -755,7 +304,7 @@ function DatePicker(props) {
|
|
|
755
304
|
setMonth(allowed);
|
|
756
305
|
}
|
|
757
306
|
const printed = singleLabel(committed, displayFormat, locale, era);
|
|
758
|
-
const sizingCandidates =
|
|
307
|
+
const sizingCandidates = React2.useMemo(() => {
|
|
759
308
|
if (fullWidth) return [];
|
|
760
309
|
const out = /* @__PURE__ */ new Set();
|
|
761
310
|
for (let month2 = 0; month2 < 12; month2++) {
|
|
@@ -836,8 +385,7 @@ function DatePicker(props) {
|
|
|
836
385
|
trigger,
|
|
837
386
|
side,
|
|
838
387
|
align,
|
|
839
|
-
size: "
|
|
840
|
-
className: "max-h-[var(--available-height)] max-w-none",
|
|
388
|
+
size: "panel",
|
|
841
389
|
dividers: commit === "confirm" ? "line" : "none",
|
|
842
390
|
"aria-label": label ?? t.openCalendar,
|
|
843
391
|
footer: commit === "confirm" ? () => /* @__PURE__ */ jsx(ApplyRow, { onCancel: picker.close, onApply: picker.apply }) : void 0,
|
|
@@ -884,7 +432,7 @@ function DatePicker(props) {
|
|
|
884
432
|
) });
|
|
885
433
|
}
|
|
886
434
|
DatePicker.displayName = "DatePicker";
|
|
887
|
-
var
|
|
435
|
+
var EMPTY_RANGE = { start: null, end: null };
|
|
888
436
|
function DateRangePicker(props) {
|
|
889
437
|
const {
|
|
890
438
|
value,
|
|
@@ -936,16 +484,16 @@ function DateRangePicker(props) {
|
|
|
936
484
|
const weekStartsOn = weekStartsOnProp ?? app.weekStartsOn ?? DEFAULT_WEEK_START;
|
|
937
485
|
const hasTime = hasTimeSegments(dateInputFormat);
|
|
938
486
|
const displayFormat = formatProp ?? defaultDisplayFormat(dateInputFormat);
|
|
939
|
-
const [rawCommitted, setCommitted] = useControllable(value, defaultValue, (next) => onValueChange?.(next ??
|
|
940
|
-
const committed =
|
|
487
|
+
const [rawCommitted, setCommitted] = useControllable(value, defaultValue, (next) => onValueChange?.(next ?? EMPTY_RANGE));
|
|
488
|
+
const committed = React2.useMemo(
|
|
941
489
|
() => ({ start: normalizeValue(rawCommitted?.start, hasTime), end: normalizeValue(rawCommitted?.end, hasTime) }),
|
|
942
490
|
[rawCommitted?.start, rawCommitted?.end, hasTime]
|
|
943
491
|
);
|
|
944
|
-
|
|
492
|
+
React2.useEffect(() => {
|
|
945
493
|
warnFormatMismatch("DateRangePicker", formatProp, dateInputFormat);
|
|
946
494
|
}, [formatProp, dateInputFormat]);
|
|
947
495
|
const { isInvalid, showError } = useFieldValidity(invalid, error);
|
|
948
|
-
const reactId =
|
|
496
|
+
const reactId = React2.useId();
|
|
949
497
|
const base = id ?? reactId;
|
|
950
498
|
const labelId = label == null ? void 0 : `${base}-label`;
|
|
951
499
|
const valueId = `${base}-value`;
|
|
@@ -953,7 +501,7 @@ function DateRangePicker(props) {
|
|
|
953
501
|
const hintId = `${base}-hint`;
|
|
954
502
|
const errorId = `${base}-error`;
|
|
955
503
|
const describedBy = showError ? errorId : hint != null && hint !== "" ? hintId : void 0;
|
|
956
|
-
const [month, setMonth] =
|
|
504
|
+
const [month, setMonth] = React2.useState(committed.start ?? defaultMonth);
|
|
957
505
|
const picker = usePickerDraft(committed, commit, setCommitted, (seeded) => setMonth(seeded.start ?? defaultMonth));
|
|
958
506
|
function onGridSelect(next) {
|
|
959
507
|
const merged = {
|
|
@@ -1039,8 +587,7 @@ function DateRangePicker(props) {
|
|
|
1039
587
|
trigger,
|
|
1040
588
|
side,
|
|
1041
589
|
align,
|
|
1042
|
-
size: "
|
|
1043
|
-
className: "max-h-[var(--available-height)] max-w-none",
|
|
590
|
+
size: "panel",
|
|
1044
591
|
dividers: commit === "confirm" ? "line" : "none",
|
|
1045
592
|
"aria-label": label ?? t.openRange,
|
|
1046
593
|
footer: commit === "confirm" ? () => /* @__PURE__ */ jsx(ApplyRow, { onCancel: picker.close, onApply: picker.apply }) : void 0,
|
|
@@ -1113,6 +660,6 @@ function DateRangePicker(props) {
|
|
|
1113
660
|
}
|
|
1114
661
|
DateRangePicker.displayName = "DateRangePicker";
|
|
1115
662
|
|
|
1116
|
-
export { DATE_PRESETS,
|
|
1117
|
-
//# sourceMappingURL=chunk-
|
|
1118
|
-
//# sourceMappingURL=chunk-
|
|
663
|
+
export { DATE_PRESETS, DatePicker, DateRangePicker, resolvePreset };
|
|
664
|
+
//# sourceMappingURL=chunk-BJHLW25G.js.map
|
|
665
|
+
//# sourceMappingURL=chunk-BJHLW25G.js.map
|