jenosize-ui 0.2.2 → 0.3.1
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 +95 -0
- package/dist/GradientPicker-Bv3V3vL_.d.ts +144 -0
- package/dist/{PaymentInput-Dn5WVQVy.d.ts → PaymentInput-s7_s3UDi.d.ts} +1 -1
- package/dist/{Select-Dt5ARIH8.d.ts → Select-r233iMaU.d.ts} +15 -1
- package/dist/{TagInput-BaBeve6L.d.ts → TagInput-w_l9Fp5i.d.ts} +1 -1
- package/dist/area-chart.d.ts +2 -2
- package/dist/area-chart.js +8 -6
- package/dist/at-least-one-BZ2dsck-.d.ts +18 -0
- package/dist/avatar.d.ts +1 -1
- package/dist/avatar.js +12 -10
- package/dist/badge.d.ts +1 -1
- package/dist/badge.js +7 -6
- package/dist/bar-chart.d.ts +2 -2
- package/dist/bar-chart.js +8 -6
- package/dist/breadcrumb.d.ts +1 -1
- package/dist/breadcrumb.js +5 -4
- package/dist/button.d.ts +1 -1
- package/dist/button.js +12 -10
- package/dist/calendar.d.ts +1 -1
- package/dist/calendar.js +16 -14
- package/dist/callout.d.ts +4 -2
- package/dist/callout.js +13 -11
- package/dist/card.d.ts +59 -3
- package/dist/card.js +4 -3
- package/dist/carousel.d.ts +169 -0
- package/dist/carousel.js +10 -0
- package/dist/catalog.json +11976 -0
- package/dist/checkbox.js +9 -7
- package/dist/{chunk-AIARANKE.js → chunk-2EUVBRKG.js} +4 -4
- package/dist/{chunk-5ZEUTSCV.js → chunk-2RRPWOKT.js} +6 -6
- package/dist/{chunk-DD5KJVFV.js → chunk-3JFSKCVU.js} +19 -19
- package/dist/{chunk-OACWA4TC.js → chunk-3ZZZPT5G.js} +6 -6
- package/dist/{chunk-LQURV7HQ.js → chunk-47EOHGXM.js} +4 -4
- package/dist/{chunk-CGHYXWTT.js → chunk-4KRCT3Q2.js} +4 -4
- package/dist/chunk-4P3JA653.js +1129 -0
- package/dist/{chunk-FWRHBMWT.js → chunk-4Y32RIC7.js} +5 -19
- package/dist/{chunk-BBKE4W3B.js → chunk-5Z26DU23.js} +7 -7
- package/dist/{chunk-7QXOGAN6.js → chunk-6CJYVYVN.js} +87 -538
- package/dist/{chunk-3HOHLQVP.js → chunk-6FGLABYH.js} +3 -3
- package/dist/{chunk-GQRSABRN.js → chunk-6Q4VVBFO.js} +4 -4
- package/dist/{chunk-MCQG4H6T.js → chunk-6T3QAO5K.js} +12 -4
- package/dist/chunk-7JOW3LEH.js +4852 -0
- package/dist/{chunk-AFYXSZGW.js → chunk-7LSUUEAF.js} +7 -5
- package/dist/{chunk-7VLYQR4D.js → chunk-7OFGPDYJ.js} +3 -3
- package/dist/{chunk-7GUPNTAH.js → chunk-7RD5RTHU.js} +7 -7
- package/dist/{chunk-X2VMIBK5.js → chunk-A36W77MQ.js} +4 -4
- package/dist/chunk-AZFHRLYF.js +67 -0
- package/dist/{chunk-CFFWYXDW.js → chunk-B6LYO33Y.js} +5 -5
- package/dist/{chunk-P6CON2R2.js → chunk-BH32X25C.js} +3 -3
- package/dist/{chunk-KHGW72BM.js → chunk-CH2XMCWX.js} +3 -3
- package/dist/{chunk-FNQJJO63.js → chunk-D46OKHTH.js} +4 -4
- package/dist/{chunk-LE44X5GS.js → chunk-D4YGYNNY.js} +9 -9
- package/dist/{chunk-T5574MXM.js → chunk-D7WD4SUC.js} +8 -8
- package/dist/{chunk-33TOK7ES.js → chunk-DCKVNHV5.js} +5 -5
- package/dist/chunk-EBZNUQ6E.js +525 -0
- package/dist/{chunk-22M75A3N.js → chunk-ED5UCYAV.js} +14 -11
- package/dist/{chunk-IQNVSQRK.js → chunk-EDVYLO2N.js} +5 -5
- package/dist/{chunk-N3RVMBPX.js → chunk-EJKQGUUM.js} +4 -4
- package/dist/{chunk-POQTE7JI.js → chunk-EKQLIUV5.js} +7 -7
- package/dist/{chunk-ULGCGKOE.js → chunk-EKV3CVTY.js} +4 -4
- package/dist/{chunk-LCG34A5T.js → chunk-EVINS473.js} +5 -3
- package/dist/{chunk-ZZSNTCCL.js → chunk-G7B2QUQP.js} +4 -4
- package/dist/{chunk-SB3DG572.js → chunk-GHRZC5LS.js} +6 -6
- package/dist/{chunk-5YWH2ANQ.js → chunk-GIC6T647.js} +11 -10
- package/dist/{chunk-7ZM7SNCZ.js → chunk-GPHGPY6T.js} +3 -3
- package/dist/chunk-GV2KTRRP.js +325 -0
- package/dist/{chunk-4RBIWI2Q.js → chunk-GYL4KOPT.js} +3 -3
- package/dist/{chunk-5KSD4WKN.js → chunk-HB6UA6EF.js} +5 -5
- package/dist/{chunk-CGZXQ7PA.js → chunk-HNNNJP3A.js} +3 -3
- package/dist/chunk-HTWGTTSF.js +1011 -0
- package/dist/chunk-IH2F5UNQ.js +109 -0
- package/dist/{chunk-QNIKRB62.js → chunk-INYUL4DX.js} +4 -4
- package/dist/{chunk-SKRR3ZMP.js → chunk-IUB5TSSH.js} +3 -3
- package/dist/chunk-JGGSRKHW.js +344 -0
- package/dist/{chunk-ZR6HNKSN.js → chunk-JHHJNIW2.js} +3 -3
- package/dist/chunk-KBI442IB.js +113 -0
- package/dist/chunk-KBQJIVUB.js +33 -0
- package/dist/{chunk-3QXLIZIX.js → chunk-KNGJ3CSB.js} +3 -3
- package/dist/chunk-KNKR5TUM.js +183 -0
- package/dist/{chunk-KZP6B6B3.js → chunk-KTWTYK5U.js} +16 -5
- package/dist/{chunk-5XPMY2LF.js → chunk-LKUAVDWP.js} +5 -5
- package/dist/{chunk-YHBI52P2.js → chunk-LPWSP523.js} +3 -3
- package/dist/{chunk-GLKFFA7N.js → chunk-LY7IJOUF.js} +5 -5
- package/dist/{chunk-R4Z7BINC.js → chunk-LYWQD5KL.js} +8 -8
- 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-T4ZFZTY6.js → chunk-N7DLNDER.js} +4 -4
- package/dist/{chunk-E2YZ7IMT.js → chunk-NDRQETOQ.js} +15 -11
- package/dist/{chunk-ZD3MOLIB.js → chunk-O7CPRU67.js} +4 -4
- package/dist/{chunk-OLLD2BZN.js → chunk-OEYKTHG7.js} +3 -3
- package/dist/{chunk-TX57TNJS.js → chunk-OG3H3RP2.js} +9 -9
- package/dist/{chunk-UGBNYSBN.js → chunk-PFKPKE6O.js} +20 -34
- package/dist/chunk-PRWPFBA5.js +619 -0
- package/dist/{chunk-QDKETK7D.js → chunk-S55JKMG7.js} +5 -5
- package/dist/{chunk-QDYE5LVT.js → chunk-SF3HCW4G.js} +45 -4
- package/dist/{chunk-6MMBQVRO.js → chunk-TDKKZA63.js} +9 -9
- package/dist/{chunk-HHYEAFCL.js → chunk-TDXHBS2C.js} +11 -11
- package/dist/{chunk-74AIU53R.js → chunk-THGGU64E.js} +3 -3
- package/dist/chunk-UHSGD4CD.js +364 -0
- package/dist/{chunk-HV2W6HUR.js → chunk-URAURI6G.js} +10 -10
- package/dist/{chunk-D6XO4JVM.js → chunk-UU6KUS5O.js} +42 -20
- package/dist/{chunk-NKG4N6HA.js → chunk-V7KEEDSF.js} +5 -4
- package/dist/{chunk-IEAWNA3V.js → chunk-VDFWWWLL.js} +3 -3
- package/dist/chunk-VHAA22YE.js +11 -0
- package/dist/chunk-WJB5GWAZ.js +20 -0
- package/dist/{chunk-KJ5JUS53.js → chunk-WM6DGNIA.js} +9 -9
- package/dist/{chunk-MFFA5MXY.js → chunk-WUXMLJEC.js} +5 -5
- package/dist/{chunk-YPNL2NBD.js → chunk-XNXBO44X.js} +33 -11
- package/dist/chunk-XPY3XT7L.js +5671 -0
- package/dist/{chunk-54SIZR63.js → chunk-XVFRDKZJ.js} +7 -7
- package/dist/{chunk-LYXPJERB.js → chunk-YDD46AX2.js} +5 -5
- package/dist/{chunk-NC63TYNW.js → chunk-YHQJGNXD.js} +7 -7
- package/dist/{chunk-I6WMNXC7.js → chunk-YKRE5NIH.js} +6 -6
- package/dist/{chunk-RJTVCA62.js → chunk-ZIEGUI25.js} +3 -3
- package/dist/{chunk-5DP7W5HX.js → chunk-ZLDWYTDA.js} +3 -3
- package/dist/color-input.d.ts +93 -0
- package/dist/color-input.js +36 -0
- package/dist/color-picker.d.ts +268 -0
- package/dist/color-picker.js +29 -0
- package/dist/color-value-DYzChVOW.d.ts +129 -0
- package/dist/combobox.d.ts +1 -1
- package/dist/combobox.js +14 -12
- package/dist/data-map.d.ts +1673 -0
- package/dist/data-map.js +36 -0
- package/dist/date-calendar.d.ts +49 -0
- package/dist/date-calendar.js +13 -0
- package/dist/date-input.d.ts +1 -1
- package/dist/date-input.js +12 -10
- package/dist/date-picker.d.ts +15 -131
- package/dist/date-picker.js +26 -21
- package/dist/date-types-CLZek3W2.d.ts +100 -0
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.js +10 -9
- package/dist/drawer.d.ts +1 -1
- package/dist/drawer.js +9 -8
- package/dist/dropdown-menu.d.ts +1 -1
- package/dist/dropdown-menu.js +5 -4
- package/dist/dropzone.d.ts +3 -3
- package/dist/dropzone.js +18 -16
- package/dist/file-trigger.js +1 -0
- package/dist/form.d.ts +15 -5
- package/dist/form.js +75 -35
- package/dist/header-navigation.d.ts +2 -2
- package/dist/header-navigation.js +20 -18
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +1 -0
- package/dist/illustration.js +1 -0
- package/dist/index.d.ts +26 -11
- package/dist/index.js +92 -77
- package/dist/indicator.js +5 -4
- package/dist/inline-banner.d.ts +68 -0
- package/dist/inline-banner.js +21 -0
- package/dist/input.d.ts +1 -1
- package/dist/input.js +11 -9
- package/dist/kanban-board.d.ts +2 -2
- package/dist/kanban-board.js +15 -13
- package/dist/labels-CuSlirP_.d.ts +1381 -0
- package/dist/line-chart.d.ts +2 -2
- package/dist/line-chart.js +8 -6
- package/dist/mcp.js +231 -0
- package/dist/number-input.d.ts +1 -1
- package/dist/number-input.js +11 -9
- package/dist/pagination.d.ts +1 -1
- package/dist/pagination.js +15 -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 +11 -9
- package/dist/picker-draft-BPV3MUPY.d.ts +9 -0
- package/dist/pie-chart.d.ts +2 -2
- package/dist/pie-chart.js +8 -6
- package/dist/popover.d.ts +65 -4
- package/dist/popover.js +9 -8
- package/dist/progress-steps.js +5 -4
- package/dist/progress.js +4 -3
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +4 -3
- package/dist/qr-code.d.ts +227 -0
- package/dist/qr-code.js +20 -0
- package/dist/radar-chart.d.ts +2 -2
- package/dist/radar-chart.js +8 -6
- package/dist/radial-chart.d.ts +2 -2
- package/dist/radial-chart.js +8 -6
- package/dist/radio.js +9 -7
- package/dist/rich-text-editor.d.ts +624 -0
- package/dist/rich-text-editor.js +52 -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 +1 -0
- package/dist/select.d.ts +2 -2
- package/dist/select.js +17 -15
- package/dist/separator.js +3 -2
- package/dist/shared-CGf2D8ZX.d.ts +20 -0
- package/dist/sidebar-navigation.d.ts +73 -32
- package/dist/sidebar-navigation.js +15 -13
- package/dist/sidebar-state.d.ts +76 -0
- package/dist/sidebar-state.js +27 -0
- package/dist/skeleton.js +3 -2
- package/dist/slider.d.ts +321 -0
- package/dist/slider.js +14 -0
- package/dist/styles.css +1 -1
- package/dist/switch.d.ts +1 -1
- package/dist/switch.js +3 -2
- package/dist/table.d.ts +3 -19
- package/dist/table.js +34 -32
- package/dist/tabs.js +3 -2
- package/dist/tag-input.d.ts +3 -3
- package/dist/tag-input.js +14 -12
- package/dist/tag.d.ts +1 -1
- package/dist/tag.js +5 -4
- package/dist/textarea.js +9 -7
- package/dist/theme.css +965 -0
- package/dist/theme.js +13 -11
- package/dist/toast.d.ts +1 -1
- package/dist/toast.js +13 -11
- package/dist/tooltip.js +5 -3
- package/dist/tree.d.ts +1 -1
- package/dist/tree.js +7 -6
- package/dist/{types-DR9rAEy1.d.ts → types-BoZ6XeLB.d.ts} +1 -1
- package/dist/{use-uploads-KaPqDklo.d.ts → use-uploads-cHo2p7Gn.d.ts} +1 -1
- package/dist/verification-code-input.js +11 -9
- package/package.json +105 -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-JGGSRKHW.js';
|
|
2
|
+
import { DEFAULT_WEEK_START_INDEX, DEFAULT_WEEK_START, toWireDate } from './chunk-4Y32RIC7.js';
|
|
3
|
+
import { DateInput } from './chunk-NDRQETOQ.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-XNXBO44X.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-3ZZZPT5G.js';
|
|
11
|
+
import { FieldShell } from './chunk-A36W77MQ.js';
|
|
12
|
+
import { useFieldValidity, FieldFrame, CONTROL_ICON } from './chunk-HB6UA6EF.js';
|
|
13
|
+
import { CalendarIcon } from './chunk-KBI442IB.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-ZIEGUI25.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,61 @@ 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(2e3, 0, 1, parts.hour ?? 0, parts.minute ?? 0, parts.second ?? 0, 0);
|
|
95
|
+
d.setFullYear(parts.year, parts.month - 1, parts.day);
|
|
96
|
+
if (!isValid(d)) return null;
|
|
97
|
+
return d.getFullYear() === parts.year && d.getMonth() === parts.month - 1 && d.getDate() === parts.day ? d : null;
|
|
98
|
+
}
|
|
99
|
+
function toDateInputBound(d) {
|
|
100
|
+
return d == null || !isValid(d) ? void 0 : toWireDate(d);
|
|
101
|
+
}
|
|
102
|
+
function hasTimeSegments(dateInputFormat) {
|
|
103
|
+
return parseFormat(dateInputFormat).hasTime;
|
|
104
|
+
}
|
|
105
|
+
function defaultDisplayFormat(dateInputFormat) {
|
|
106
|
+
return hasTimeSegments(dateInputFormat) ? "MMM d, yyyy HH:mm" : "MMM d, yyyy";
|
|
107
|
+
}
|
|
108
|
+
var DISPLAY_TIME_TOKEN = /[HhKk]/;
|
|
109
|
+
function stripQuoted(pattern) {
|
|
110
|
+
return pattern.replaceAll(/'([^']*)'/g, "");
|
|
111
|
+
}
|
|
112
|
+
function displayFormatHasTime(format) {
|
|
113
|
+
return DISPLAY_TIME_TOKEN.test(stripQuoted(format));
|
|
114
|
+
}
|
|
115
|
+
function warnFormatMismatch(component, format, dateInputFormat) {
|
|
116
|
+
if (format == null) return;
|
|
117
|
+
const typed = hasTimeSegments(dateInputFormat);
|
|
118
|
+
const printed = displayFormatHasTime(format);
|
|
119
|
+
if (typed === printed) return;
|
|
120
|
+
devWarn(
|
|
121
|
+
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\`.`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
var YEAR_RUN = /([yYRu])\1*/g;
|
|
125
|
+
function beYearPattern(pattern, ceYear) {
|
|
126
|
+
const beYear = ceYear + BE_OFFSET;
|
|
127
|
+
return pattern.split(/('[^']*')/).map(
|
|
128
|
+
(chunk, index) => (
|
|
129
|
+
// Odd chunks are the captured quoted literals — pass them through untouched.
|
|
130
|
+
index % 2 === 1 ? chunk : chunk.replaceAll(YEAR_RUN, (run) => run.length === 2 ? String(beYear).slice(-2) : String(beYear).padStart(run.length, "0"))
|
|
131
|
+
)
|
|
132
|
+
).join("");
|
|
133
|
+
}
|
|
134
|
+
function formatDateValue(d, pattern, locale, era) {
|
|
135
|
+
return format(d, era === "be" ? beYearPattern(pattern, d.getFullYear()) : pattern, { locale });
|
|
136
|
+
}
|
|
137
|
+
function toFormValue(d, hasTime) {
|
|
138
|
+
if (d == null) return "";
|
|
139
|
+
return toDateInputValue(d, hasTime) ?? "";
|
|
140
|
+
}
|
|
564
141
|
var TRIGGER_CLASS = cn(
|
|
565
142
|
"flex min-w-0 flex-1 cursor-pointer items-center justify-between gap-2 self-stretch bg-transparent text-left outline-none",
|
|
566
143
|
"disabled:cursor-not-allowed"
|
|
@@ -643,32 +220,6 @@ function PresetRail({ presets, value, onPick }) {
|
|
|
643
220
|
preset.label
|
|
644
221
|
)) });
|
|
645
222
|
}
|
|
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
223
|
function ApplyRow({ onCancel, onApply, disabled }) {
|
|
673
224
|
const t = useLabels("datePicker", DATE_PICKER_LABELS, void 0);
|
|
674
225
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -726,12 +277,12 @@ function DatePicker(props) {
|
|
|
726
277
|
const hasTime = hasTimeSegments(dateInputFormat);
|
|
727
278
|
const displayFormat = formatProp ?? defaultDisplayFormat(dateInputFormat);
|
|
728
279
|
const [rawCommitted, setCommitted] = useControllable(value, defaultValue, onValueChange);
|
|
729
|
-
const committed =
|
|
730
|
-
|
|
280
|
+
const committed = React2.useMemo(() => normalizeValue(rawCommitted, hasTime), [rawCommitted, hasTime]);
|
|
281
|
+
React2.useEffect(() => {
|
|
731
282
|
warnFormatMismatch("DatePicker", formatProp, dateInputFormat);
|
|
732
283
|
}, [formatProp, dateInputFormat]);
|
|
733
284
|
const { isInvalid, showError } = useFieldValidity(invalid, error);
|
|
734
|
-
const reactId =
|
|
285
|
+
const reactId = React2.useId();
|
|
735
286
|
const base = id ?? reactId;
|
|
736
287
|
const labelId = label == null ? void 0 : `${base}-label`;
|
|
737
288
|
const valueId = `${base}-value`;
|
|
@@ -739,7 +290,7 @@ function DatePicker(props) {
|
|
|
739
290
|
const hintId = `${base}-hint`;
|
|
740
291
|
const errorId = `${base}-error`;
|
|
741
292
|
const describedBy = showError ? errorId : hint != null && hint !== "" ? hintId : void 0;
|
|
742
|
-
const [month, setMonth] =
|
|
293
|
+
const [month, setMonth] = React2.useState(committed ?? defaultMonth);
|
|
743
294
|
const picker = usePickerDraft(committed, commit, setCommitted, (seeded) => setMonth(seeded ?? defaultMonth));
|
|
744
295
|
function onGridSelect(next) {
|
|
745
296
|
const merged = withTimeOf(next, picker.draft, hasTime);
|
|
@@ -755,7 +306,7 @@ function DatePicker(props) {
|
|
|
755
306
|
setMonth(allowed);
|
|
756
307
|
}
|
|
757
308
|
const printed = singleLabel(committed, displayFormat, locale, era);
|
|
758
|
-
const sizingCandidates =
|
|
309
|
+
const sizingCandidates = React2.useMemo(() => {
|
|
759
310
|
if (fullWidth) return [];
|
|
760
311
|
const out = /* @__PURE__ */ new Set();
|
|
761
312
|
for (let month2 = 0; month2 < 12; month2++) {
|
|
@@ -836,8 +387,7 @@ function DatePicker(props) {
|
|
|
836
387
|
trigger,
|
|
837
388
|
side,
|
|
838
389
|
align,
|
|
839
|
-
size: "
|
|
840
|
-
className: "max-h-[var(--available-height)] max-w-none",
|
|
390
|
+
size: "panel",
|
|
841
391
|
dividers: commit === "confirm" ? "line" : "none",
|
|
842
392
|
"aria-label": label ?? t.openCalendar,
|
|
843
393
|
footer: commit === "confirm" ? () => /* @__PURE__ */ jsx(ApplyRow, { onCancel: picker.close, onApply: picker.apply }) : void 0,
|
|
@@ -884,7 +434,7 @@ function DatePicker(props) {
|
|
|
884
434
|
) });
|
|
885
435
|
}
|
|
886
436
|
DatePicker.displayName = "DatePicker";
|
|
887
|
-
var
|
|
437
|
+
var EMPTY_RANGE = { start: null, end: null };
|
|
888
438
|
function DateRangePicker(props) {
|
|
889
439
|
const {
|
|
890
440
|
value,
|
|
@@ -936,16 +486,16 @@ function DateRangePicker(props) {
|
|
|
936
486
|
const weekStartsOn = weekStartsOnProp ?? app.weekStartsOn ?? DEFAULT_WEEK_START;
|
|
937
487
|
const hasTime = hasTimeSegments(dateInputFormat);
|
|
938
488
|
const displayFormat = formatProp ?? defaultDisplayFormat(dateInputFormat);
|
|
939
|
-
const [rawCommitted, setCommitted] = useControllable(value, defaultValue, (next) => onValueChange?.(next ??
|
|
940
|
-
const committed =
|
|
489
|
+
const [rawCommitted, setCommitted] = useControllable(value, defaultValue, (next) => onValueChange?.(next ?? EMPTY_RANGE));
|
|
490
|
+
const committed = React2.useMemo(
|
|
941
491
|
() => ({ start: normalizeValue(rawCommitted?.start, hasTime), end: normalizeValue(rawCommitted?.end, hasTime) }),
|
|
942
492
|
[rawCommitted?.start, rawCommitted?.end, hasTime]
|
|
943
493
|
);
|
|
944
|
-
|
|
494
|
+
React2.useEffect(() => {
|
|
945
495
|
warnFormatMismatch("DateRangePicker", formatProp, dateInputFormat);
|
|
946
496
|
}, [formatProp, dateInputFormat]);
|
|
947
497
|
const { isInvalid, showError } = useFieldValidity(invalid, error);
|
|
948
|
-
const reactId =
|
|
498
|
+
const reactId = React2.useId();
|
|
949
499
|
const base = id ?? reactId;
|
|
950
500
|
const labelId = label == null ? void 0 : `${base}-label`;
|
|
951
501
|
const valueId = `${base}-value`;
|
|
@@ -953,7 +503,7 @@ function DateRangePicker(props) {
|
|
|
953
503
|
const hintId = `${base}-hint`;
|
|
954
504
|
const errorId = `${base}-error`;
|
|
955
505
|
const describedBy = showError ? errorId : hint != null && hint !== "" ? hintId : void 0;
|
|
956
|
-
const [month, setMonth] =
|
|
506
|
+
const [month, setMonth] = React2.useState(committed.start ?? defaultMonth);
|
|
957
507
|
const picker = usePickerDraft(committed, commit, setCommitted, (seeded) => setMonth(seeded.start ?? defaultMonth));
|
|
958
508
|
function onGridSelect(next) {
|
|
959
509
|
const merged = {
|
|
@@ -1039,8 +589,7 @@ function DateRangePicker(props) {
|
|
|
1039
589
|
trigger,
|
|
1040
590
|
side,
|
|
1041
591
|
align,
|
|
1042
|
-
size: "
|
|
1043
|
-
className: "max-h-[var(--available-height)] max-w-none",
|
|
592
|
+
size: "panel",
|
|
1044
593
|
dividers: commit === "confirm" ? "line" : "none",
|
|
1045
594
|
"aria-label": label ?? t.openRange,
|
|
1046
595
|
footer: commit === "confirm" ? () => /* @__PURE__ */ jsx(ApplyRow, { onCancel: picker.close, onApply: picker.apply }) : void 0,
|
|
@@ -1113,6 +662,6 @@ function DateRangePicker(props) {
|
|
|
1113
662
|
}
|
|
1114
663
|
DateRangePicker.displayName = "DateRangePicker";
|
|
1115
664
|
|
|
1116
|
-
export { DATE_PRESETS,
|
|
1117
|
-
//# sourceMappingURL=chunk-
|
|
1118
|
-
//# sourceMappingURL=chunk-
|
|
665
|
+
export { DATE_PRESETS, DatePicker, DateRangePicker, resolvePreset };
|
|
666
|
+
//# sourceMappingURL=chunk-6CJYVYVN.js.map
|
|
667
|
+
//# sourceMappingURL=chunk-6CJYVYVN.js.map
|