@wow-two-beta/ui 0.0.68 → 0.0.70
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/dist/{chunk-HPA5BHDK.js → chunk-KD6MJOL5.js} +73 -68
- package/dist/chunk-KD6MJOL5.js.map +1 -0
- package/dist/{chunk-3BKZLK7D.js → chunk-SIAFOCT4.js} +74 -56
- package/dist/chunk-SIAFOCT4.js.map +1 -0
- package/dist/{chunk-D5QVCOX5.js → chunk-UFTKE5U7.js} +143 -151
- package/dist/chunk-UFTKE5U7.js.map +1 -0
- package/dist/display/eventCalendar/EventCalendar.d.ts +9 -6
- package/dist/display/gantt/Gantt.d.ts +6 -5
- package/dist/display/heatmapCalendar/HeatmapCalendar.d.ts +4 -2
- package/dist/display/index.js +2 -2
- package/dist/display/scheduleView/ScheduleView.d.ts +6 -4
- package/dist/forms/DateExtensions.d.ts +56 -25
- package/dist/forms/MonthGrid.d.ts +8 -7
- package/dist/forms/calendar/Calendar.d.ts +8 -7
- package/dist/forms/colorPicker/ColorPicker.d.ts +7 -0
- package/dist/forms/dateField/DateField.d.ts +6 -5
- package/dist/forms/datePicker/DatePicker.d.ts +8 -7
- package/dist/forms/dateRangePicker/DateRangePicker.d.ts +5 -4
- package/dist/forms/index.js +2 -2
- package/dist/forms/rangeCalendar/RangeCalendar.d.ts +8 -6
- package/dist/forms/recurrenceEditor/RecurrenceEditor.d.ts +3 -2
- package/dist/forms/timeField/TimeField.d.ts +4 -7
- package/dist/forms/timeField/index.d.ts +1 -1
- package/dist/forms/timePicker/TimePicker.d.ts +5 -5
- package/dist/http/ApiError.d.ts +7 -0
- package/dist/http/ApiResponse.d.ts +4 -0
- package/dist/http/DateBrands.d.ts +8 -0
- package/dist/http/ProblemDetails.d.ts +9 -0
- package/dist/http/index.d.ts +5 -0
- package/dist/http/index.js +58 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/temporalReviver.d.ts +9 -0
- package/dist/index.js +4 -4
- package/dist/layout/index.js +1 -1
- package/package.json +7 -1
- package/dist/chunk-3BKZLK7D.js.map +0 -1
- package/dist/chunk-D5QVCOX5.js.map +0 -1
- package/dist/chunk-HPA5BHDK.js.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
3
|
export type EventCalendarView = 'month' | 'week' | 'day' | 'agenda';
|
|
3
4
|
export interface EventCalendarEvent {
|
|
4
5
|
id: string;
|
|
5
6
|
title?: ReactNode;
|
|
6
|
-
start:
|
|
7
|
-
end:
|
|
7
|
+
start: Temporal.ZonedDateTime;
|
|
8
|
+
end: Temporal.ZonedDateTime;
|
|
8
9
|
color?: string;
|
|
9
10
|
isAllDay?: boolean;
|
|
10
11
|
}
|
|
@@ -13,13 +14,15 @@ export interface EventCalendarProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
13
14
|
view?: EventCalendarView;
|
|
14
15
|
defaultView?: EventCalendarView;
|
|
15
16
|
onViewChange?: (view: EventCalendarView) => void;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/** The focused instant; its calendar day drives the visible month/week/day. */
|
|
18
|
+
date?: Temporal.ZonedDateTime;
|
|
19
|
+
defaultDate?: Temporal.ZonedDateTime;
|
|
20
|
+
onDateChange?: (date: Temporal.ZonedDateTime) => void;
|
|
19
21
|
weekStart?: 0 | 1;
|
|
20
22
|
hourRange?: [number, number];
|
|
21
23
|
onEventClick?: (event: EventCalendarEvent) => void;
|
|
22
|
-
|
|
24
|
+
/** Fired on an empty slot: `day` is the clicked calendar day, `hour` the grid hour (time views). */
|
|
25
|
+
onSlotClick?: (day: Temporal.PlainDate, hour?: number) => void;
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
28
|
* First-generation EventCalendar — month / week / day / agenda views.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
3
|
export interface GanttTask {
|
|
3
4
|
id: string;
|
|
4
5
|
label: ReactNode;
|
|
5
|
-
start:
|
|
6
|
-
end:
|
|
6
|
+
start: Temporal.PlainDate;
|
|
7
|
+
end: Temporal.PlainDate;
|
|
7
8
|
color?: string;
|
|
8
9
|
/** 0..1 — fills the bar from the left. */
|
|
9
10
|
progress?: number;
|
|
@@ -15,14 +16,14 @@ export interface GanttDependency {
|
|
|
15
16
|
export interface GanttMilestone {
|
|
16
17
|
id: string;
|
|
17
18
|
label: ReactNode;
|
|
18
|
-
date:
|
|
19
|
+
date: Temporal.PlainDate;
|
|
19
20
|
}
|
|
20
21
|
export interface GanttProps extends HTMLAttributes<HTMLDivElement> {
|
|
21
22
|
tasks: GanttTask[];
|
|
22
23
|
dependencies?: GanttDependency[];
|
|
23
24
|
milestones?: GanttMilestone[];
|
|
24
|
-
from?:
|
|
25
|
-
to?:
|
|
25
|
+
from?: Temporal.PlainDate;
|
|
26
|
+
to?: Temporal.PlainDate;
|
|
26
27
|
cellWidth?: number;
|
|
27
28
|
rowHeight?: number;
|
|
28
29
|
labelWidth?: number;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type HTMLAttributes } from 'react';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
3
|
export type HeatmapCalendarTone = 'brand' | 'success' | 'warning' | 'danger' | 'muted';
|
|
3
4
|
export interface HeatmapCalendarProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
-
|
|
5
|
+
/** Per-day counts, keyed by calendar date. */
|
|
6
|
+
values: Map<Temporal.PlainDate, number>;
|
|
5
7
|
year?: number;
|
|
6
8
|
weekStart?: 0 | 1;
|
|
7
9
|
cellSize?: number;
|
|
@@ -9,7 +11,7 @@ export interface HeatmapCalendarProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
9
11
|
/** Intensity buckets (min 2, clamped). Buckets map proportionally onto the fixed 5-step tone palette — counts above 5 share palette classes between adjacent buckets. Default 5. */
|
|
10
12
|
levels?: number;
|
|
11
13
|
tone?: HeatmapCalendarTone;
|
|
12
|
-
onCellClick?: (date:
|
|
14
|
+
onCellClick?: (date: Temporal.PlainDate, value: number) => void;
|
|
13
15
|
monthLabels?: string[];
|
|
14
16
|
weekdayLabels?: string[];
|
|
15
17
|
hasLegend?: boolean;
|
package/dist/display/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActivityFeed, ActivityItem, AnimatedNumber, AnnotationMarker, AudioPlayer, AudioWaveform, Avatar, AvatarGroup, Badge, BadgeOverlay, Card, Carousel, CarouselDot, CarouselDots, CarouselNext, CarouselPrev, CarouselSlide, CarouselSlides, CarouselViewport, ChatBubble, Code, Collapsible, CollapsibleContent, CollapsibleTrigger, Comment, CommentThread, Confetti, CountBadge, CountUp, DataGrid, DataTable, DaySeparator, DescriptionList, DiffViewer, EmptyState, EventCalendar, Eyebrow, FeatureCard, Gantt, GradientText, Heading, HeatmapCalendar, Highlight, Image, InfoRow, KeyboardShortcut, List, ListItem, Mark, Marquee, MessageList, MetaInline, MetricChip, NodeEditor, NotificationDot, PDFViewer, PricingCard, Quote, ReactionBar, ScheduleView, ScrollReveal, SectionHeader, Separator, Snippet, Sortable, Sparkline, Stat, Status, StepCard, SwipeActions, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeaderCell, TableRow, Tabs, TabsList, TabsPanel, TabsTab, Text, ThreadView, Tilt, Timeline, TimelineDescription, TimelineItem, TimelineTitle, Tree, TreeGroup, TreeItem, Typewriter, VideoPlayer, avatarVariants, badgeVariants, codeVariants, headingVariants, textVariants } from '../chunk-
|
|
2
|
-
export { Kbd, Tag, tagVariants } from '../chunk-
|
|
1
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActivityFeed, ActivityItem, AnimatedNumber, AnnotationMarker, AudioPlayer, AudioWaveform, Avatar, AvatarGroup, Badge, BadgeOverlay, Card, Carousel, CarouselDot, CarouselDots, CarouselNext, CarouselPrev, CarouselSlide, CarouselSlides, CarouselViewport, ChatBubble, Code, Collapsible, CollapsibleContent, CollapsibleTrigger, Comment, CommentThread, Confetti, CountBadge, CountUp, DataGrid, DataTable, DaySeparator, DescriptionList, DiffViewer, EmptyState, EventCalendar, Eyebrow, FeatureCard, Gantt, GradientText, Heading, HeatmapCalendar, Highlight, Image, InfoRow, KeyboardShortcut, List, ListItem, Mark, Marquee, MessageList, MetaInline, MetricChip, NodeEditor, NotificationDot, PDFViewer, PricingCard, Quote, ReactionBar, ScheduleView, ScrollReveal, SectionHeader, Separator, Snippet, Sortable, Sparkline, Stat, Status, StepCard, SwipeActions, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeaderCell, TableRow, Tabs, TabsList, TabsPanel, TabsTab, Text, ThreadView, Tilt, Timeline, TimelineDescription, TimelineItem, TimelineTitle, Tree, TreeGroup, TreeItem, Typewriter, VideoPlayer, avatarVariants, badgeVariants, codeVariants, headingVariants, textVariants } from '../chunk-UFTKE5U7.js';
|
|
2
|
+
export { Kbd, Tag, tagVariants } from '../chunk-SIAFOCT4.js';
|
|
3
3
|
import '../chunk-WKVWOAQV.js';
|
|
4
4
|
export { Tooltip } from '../chunk-GPMNI5MG.js';
|
|
5
5
|
import '../chunk-RNHY33US.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
3
|
export interface ScheduleResource {
|
|
3
4
|
id: string;
|
|
4
5
|
label: ReactNode;
|
|
@@ -7,19 +8,20 @@ export interface ScheduleResource {
|
|
|
7
8
|
export interface ScheduleBooking {
|
|
8
9
|
id: string;
|
|
9
10
|
resourceId: string;
|
|
10
|
-
start:
|
|
11
|
-
end:
|
|
11
|
+
start: Temporal.ZonedDateTime;
|
|
12
|
+
end: Temporal.ZonedDateTime;
|
|
12
13
|
label?: ReactNode;
|
|
13
14
|
color?: string;
|
|
14
15
|
}
|
|
15
16
|
export interface ScheduleViewProps extends HTMLAttributes<HTMLDivElement> {
|
|
16
17
|
resources: ScheduleResource[];
|
|
17
18
|
bookings: ScheduleBooking[];
|
|
18
|
-
date
|
|
19
|
+
/** The day to render; its calendar date + time zone anchor the grid. */
|
|
20
|
+
date?: Temporal.ZonedDateTime;
|
|
19
21
|
hourRange?: [number, number];
|
|
20
22
|
slotMinutes?: number;
|
|
21
23
|
onBookingClick?: (booking: ScheduleBooking) => void;
|
|
22
|
-
onSlotClick?: (resourceId: string, time:
|
|
24
|
+
onSlotClick?: (resourceId: string, time: Temporal.ZonedDateTime) => void;
|
|
23
25
|
renderBooking?: (booking: ScheduleBooking) => ReactNode;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
@@ -1,35 +1,66 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
1
2
|
export declare const WEEKDAYS_SHORT: string[];
|
|
2
3
|
export declare const MONTHS_LONG: string[];
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
4
|
+
/** Sunday-anchored column index (0 = Sun … 6 = Sat) for a PlainDate. */
|
|
5
|
+
export declare function sundayIndex(d: Temporal.PlainDate): number;
|
|
6
|
+
/** Today as a PlainDate in the local time zone. */
|
|
7
|
+
export declare function today(): Temporal.PlainDate;
|
|
8
|
+
export declare function isSameDay(a: Temporal.PlainDate | null | undefined, b: Temporal.PlainDate | null | undefined): boolean;
|
|
9
|
+
export declare function isToday(d: Temporal.PlainDate): boolean;
|
|
10
|
+
/** Add `n` months; Temporal clamps to the target month's last day (Jan 31 +1 → Feb 28). */
|
|
11
|
+
export declare function addMonths(d: Temporal.PlainDate, n: number): Temporal.PlainDate;
|
|
12
|
+
export declare function addDays(d: Temporal.PlainDate, n: number): Temporal.PlainDate;
|
|
13
|
+
/** First day of `d`'s month. */
|
|
14
|
+
export declare function startOfMonth(d: Temporal.PlainDate): Temporal.PlainDate;
|
|
15
|
+
/** Number of days in the given year/month (1-indexed month). */
|
|
9
16
|
export declare function daysInMonth(year: number, month: number): number;
|
|
10
17
|
/**
|
|
11
18
|
* Build the 6-week (42-cell) grid that the calendar UI renders.
|
|
12
|
-
* Cells outside the target
|
|
19
|
+
* `year`/`month` are 1-indexed (Temporal convention). Cells outside the target
|
|
20
|
+
* month carry `outOfMonth: true`.
|
|
13
21
|
*/
|
|
14
22
|
export declare function buildMonthGrid(year: number, month: number): {
|
|
15
|
-
date:
|
|
23
|
+
date: Temporal.PlainDate;
|
|
16
24
|
outOfMonth: boolean;
|
|
17
25
|
}[];
|
|
18
|
-
/** Format
|
|
19
|
-
export declare function formatISODate(d:
|
|
20
|
-
/** Parse "YYYY-MM-DD" →
|
|
21
|
-
export declare function parseISODate(s: string | null | undefined):
|
|
22
|
-
/** Format
|
|
23
|
-
export declare function formatISOTime(
|
|
24
|
-
/** Parse "HH:MM" →
|
|
25
|
-
export declare function parseISOTime(s: string | null | undefined):
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
min?: Date | null;
|
|
32
|
-
max?: Date | null;
|
|
33
|
-
isDisabled?: (d: Date) => boolean;
|
|
26
|
+
/** Format PlainDate → "YYYY-MM-DD" for a native `<input type="date">` value. */
|
|
27
|
+
export declare function formatISODate(d: Temporal.PlainDate | null | undefined): string;
|
|
28
|
+
/** Parse "YYYY-MM-DD" → PlainDate. Returns null for invalid input. */
|
|
29
|
+
export declare function parseISODate(s: string | null | undefined): Temporal.PlainDate | null;
|
|
30
|
+
/** Format PlainTime → "HH:MM" for a native `<input type="time">` value. */
|
|
31
|
+
export declare function formatISOTime(t: Temporal.PlainTime | null | undefined): string;
|
|
32
|
+
/** Parse "HH:MM" → PlainTime. Returns null for invalid input. */
|
|
33
|
+
export declare function parseISOTime(s: string | null | undefined): Temporal.PlainTime | null;
|
|
34
|
+
export declare function clampDate(d: Temporal.PlainDate, min?: Temporal.PlainDate | null, max?: Temporal.PlainDate | null): Temporal.PlainDate;
|
|
35
|
+
export declare function isDateDisabled(d: Temporal.PlainDate, options: {
|
|
36
|
+
min?: Temporal.PlainDate | null;
|
|
37
|
+
max?: Temporal.PlainDate | null;
|
|
38
|
+
isDisabled?: (d: Temporal.PlainDate) => boolean;
|
|
34
39
|
}): boolean;
|
|
35
|
-
export declare function isInRange(d:
|
|
40
|
+
export declare function isInRange(d: Temporal.PlainDate, start: Temporal.PlainDate | null | undefined, end: Temporal.PlainDate | null | undefined): boolean;
|
|
41
|
+
/** Signed whole-day count from `a` to `b` (positive when `b` is later). */
|
|
42
|
+
export declare function daysBetween(a: Temporal.PlainDate, b: Temporal.PlainDate): number;
|
|
43
|
+
/** True when `d` falls on a Saturday or Sunday. */
|
|
44
|
+
export declare function isWeekend(d: Temporal.PlainDate): boolean;
|
|
45
|
+
/** Now as a ZonedDateTime in the local (system) time zone. */
|
|
46
|
+
export declare function nowZoned(): Temporal.ZonedDateTime;
|
|
47
|
+
/** The calendar day a ZonedDateTime falls on (its wall-clock PlainDate). */
|
|
48
|
+
export declare function zonedToPlainDate(z: Temporal.ZonedDateTime): Temporal.PlainDate;
|
|
49
|
+
/** True when two ZonedDateTimes land on the same wall-clock day (same zone assumed). */
|
|
50
|
+
export declare function isSameZonedDay(a: Temporal.ZonedDateTime, b: Temporal.ZonedDateTime): boolean;
|
|
51
|
+
/** True when a ZonedDateTime falls on `day` (its wall-clock date equals `day`). */
|
|
52
|
+
export declare function isZonedOnDay(z: Temporal.ZonedDateTime, day: Temporal.PlainDate): boolean;
|
|
53
|
+
/** Start-of-day (00:00, zone-correct) for `day` in `z`'s time zone. */
|
|
54
|
+
export declare function startOfZonedDay(day: Temporal.PlainDate, timeZone: Temporal.TimeZoneLike): Temporal.ZonedDateTime;
|
|
55
|
+
/** `day` at hour `hour` (minutes/seconds zeroed), zone-correct, in `timeZone`. */
|
|
56
|
+
export declare function zonedAtHour(day: Temporal.PlainDate, hour: number, timeZone: Temporal.TimeZoneLike): Temporal.ZonedDateTime;
|
|
57
|
+
/** Signed minutes from `a` to `b` (positive when `b` is later). */
|
|
58
|
+
export declare function minutesBetween(a: Temporal.ZonedDateTime, b: Temporal.ZonedDateTime): number;
|
|
59
|
+
/** Later of two instants. */
|
|
60
|
+
export declare function maxZoned(a: Temporal.ZonedDateTime, b: Temporal.ZonedDateTime): Temporal.ZonedDateTime;
|
|
61
|
+
/** Earlier of two instants. */
|
|
62
|
+
export declare function minZoned(a: Temporal.ZonedDateTime, b: Temporal.ZonedDateTime): Temporal.ZonedDateTime;
|
|
63
|
+
/** True when `z`'s calendar day lies within [start, end] (inclusive, by day). */
|
|
64
|
+
export declare function isZonedDayInRange(z: Temporal.ZonedDateTime, start: Temporal.ZonedDateTime, end: Temporal.ZonedDateTime): boolean;
|
|
65
|
+
/** Format a ZonedDateTime's time-of-day as "HH:MM" (locale-aware). */
|
|
66
|
+
export declare function formatZonedTime(z: Temporal.ZonedDateTime): string;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { type ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
3
|
export interface MonthGridDayProps extends Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'className' | 'onPointerEnter' | 'onPointerLeave' | 'aria-selected'> {
|
|
3
4
|
/** Extra `data-*` attributes (data-selected, data-range-start, etc.). */
|
|
4
5
|
[key: `data-${string}`]: string | boolean | undefined;
|
|
5
6
|
}
|
|
6
7
|
export interface MonthGridProps {
|
|
7
8
|
/** First day of the visible month (use `startOfMonth(date)`). */
|
|
8
|
-
viewMonth:
|
|
9
|
+
viewMonth: Temporal.PlainDate;
|
|
9
10
|
/** Called when prev/next steps the visible month. */
|
|
10
|
-
onViewMonthChange: (date:
|
|
11
|
+
onViewMonthChange: (date: Temporal.PlainDate) => void;
|
|
11
12
|
/** The currently focused day (cell tabIndex=0). */
|
|
12
|
-
focusedDate:
|
|
13
|
+
focusedDate: Temporal.PlainDate;
|
|
13
14
|
/** Called by keyboard navigation. */
|
|
14
|
-
onFocusedDateChange: (date:
|
|
15
|
+
onFocusedDateChange: (date: Temporal.PlainDate) => void;
|
|
15
16
|
/** Predicate marking a day as disabled. */
|
|
16
|
-
isDayDisabled?: (date:
|
|
17
|
+
isDayDisabled?: (date: Temporal.PlainDate) => boolean;
|
|
17
18
|
/** Click / Enter / Space activation. */
|
|
18
|
-
onDayActivate?: (date:
|
|
19
|
+
onDayActivate?: (date: Temporal.PlainDate, meta: {
|
|
19
20
|
outOfMonth: boolean;
|
|
20
21
|
}) => void;
|
|
21
22
|
/** Extra per-day attributes for selection styling and hover handlers. */
|
|
22
|
-
dayProps?: (date:
|
|
23
|
+
dayProps?: (date: Temporal.PlainDate, meta: {
|
|
23
24
|
outOfMonth: boolean;
|
|
24
25
|
}) => MonthGridDayProps | undefined;
|
|
25
26
|
'aria-label'?: string;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { type HTMLAttributes } from 'react';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
3
|
export interface CalendarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {
|
|
3
4
|
/** Controlled selected date. */
|
|
4
|
-
value?:
|
|
5
|
+
value?: Temporal.PlainDate | null;
|
|
5
6
|
/** Uncontrolled initial selection. */
|
|
6
|
-
defaultValue?:
|
|
7
|
+
defaultValue?: Temporal.PlainDate | null;
|
|
7
8
|
/** Selection callback. */
|
|
8
|
-
onValueChange?: (date:
|
|
9
|
+
onValueChange?: (date: Temporal.PlainDate) => void;
|
|
9
10
|
/** Initial visible month (uncontrolled). */
|
|
10
|
-
defaultMonth?:
|
|
11
|
+
defaultMonth?: Temporal.PlainDate;
|
|
11
12
|
/** Minimum selectable date. */
|
|
12
|
-
min?:
|
|
13
|
+
min?: Temporal.PlainDate | null;
|
|
13
14
|
/** Maximum selectable date. */
|
|
14
|
-
max?:
|
|
15
|
+
max?: Temporal.PlainDate | null;
|
|
15
16
|
/** Custom disable predicate. */
|
|
16
|
-
isDisabled?: (date:
|
|
17
|
+
isDisabled?: (date: Temporal.PlainDate) => boolean;
|
|
17
18
|
/** A11y label. */
|
|
18
19
|
'aria-label'?: string;
|
|
19
20
|
}
|
|
@@ -7,6 +7,13 @@ export interface ColorPickerProps {
|
|
|
7
7
|
hasAlpha?: boolean;
|
|
8
8
|
presets?: string[];
|
|
9
9
|
triggerSize?: ColorSwatchVariants['size'];
|
|
10
|
+
/**
|
|
11
|
+
* Which built-in trigger to render (ignored when `trigger` is set):
|
|
12
|
+
* - `full` *(default)* — swatch + hex-value text, framed button.
|
|
13
|
+
* - `swatch` — a bare interactive swatch, no text (compact toolbars, tiles).
|
|
14
|
+
* - `value` — hex-value text only, no swatch (dense / code contexts).
|
|
15
|
+
*/
|
|
16
|
+
triggerVariant?: 'full' | 'swatch' | 'value';
|
|
10
17
|
isDisabled?: boolean;
|
|
11
18
|
name?: string;
|
|
12
19
|
className?: string;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type InputHTMLAttributes } from 'react';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
3
|
import { type InputBaseVariants } from '../InputStyles';
|
|
3
4
|
export interface DateFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'defaultValue' | 'onChange' | 'min' | 'max' | 'size'>, InputBaseVariants {
|
|
4
|
-
value?:
|
|
5
|
-
defaultValue?:
|
|
6
|
-
onValueChange?: (date:
|
|
7
|
-
min?:
|
|
8
|
-
max?:
|
|
5
|
+
value?: Temporal.PlainDate | null;
|
|
6
|
+
defaultValue?: Temporal.PlainDate | null;
|
|
7
|
+
onValueChange?: (date: Temporal.PlainDate | null) => void;
|
|
8
|
+
min?: Temporal.PlainDate | null;
|
|
9
|
+
max?: Temporal.PlainDate | null;
|
|
9
10
|
}
|
|
10
11
|
export declare const DateField: import("react").ForwardRefExoticComponent<DateFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { type ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
3
|
import { type SelectTriggerVariants } from '../select/Select.variants';
|
|
3
4
|
export interface DatePickerProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'value' | 'defaultValue'>, SelectTriggerVariants {
|
|
4
|
-
value?:
|
|
5
|
-
defaultValue?:
|
|
6
|
-
onValueChange?: (date:
|
|
5
|
+
value?: Temporal.PlainDate | null;
|
|
6
|
+
defaultValue?: Temporal.PlainDate | null;
|
|
7
|
+
onValueChange?: (date: Temporal.PlainDate | null) => void;
|
|
7
8
|
placeholder?: string;
|
|
8
|
-
format?: (date:
|
|
9
|
-
min?:
|
|
10
|
-
max?:
|
|
11
|
-
isDisabled?: (date:
|
|
9
|
+
format?: (date: Temporal.PlainDate) => string;
|
|
10
|
+
min?: Temporal.PlainDate | null;
|
|
11
|
+
max?: Temporal.PlainDate | null;
|
|
12
|
+
isDisabled?: (date: Temporal.PlainDate) => boolean;
|
|
12
13
|
isInvalid?: boolean;
|
|
13
14
|
/** When `name` is set, a hidden input ships the ISO value with form submission. */
|
|
14
15
|
name?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
3
|
import { type SelectTriggerVariants } from '../select/Select.variants';
|
|
3
4
|
import { type DateRange } from '../rangeCalendar';
|
|
4
5
|
export interface DateRangePickerProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'value' | 'defaultValue'>, SelectTriggerVariants {
|
|
@@ -6,10 +7,10 @@ export interface DateRangePickerProps extends Omit<ButtonHTMLAttributes<HTMLButt
|
|
|
6
7
|
defaultValue?: DateRange | null;
|
|
7
8
|
onValueChange?: (range: DateRange | null) => void;
|
|
8
9
|
placeholder?: string;
|
|
9
|
-
format?: (date:
|
|
10
|
-
min?:
|
|
11
|
-
max?:
|
|
12
|
-
isDisabled?: (date:
|
|
10
|
+
format?: (date: Temporal.PlainDate) => string;
|
|
11
|
+
min?: Temporal.PlainDate | null;
|
|
12
|
+
max?: Temporal.PlainDate | null;
|
|
13
|
+
isDisabled?: (date: Temporal.PlainDate) => boolean;
|
|
13
14
|
isInvalid?: boolean;
|
|
14
15
|
/** When `name` is set, two hidden inputs (`{name}_start`, `{name}_end`) ship the ISO values. */
|
|
15
16
|
name?: string;
|
package/dist/forms/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { ADDRESS_COUNTRIES, AddressForm, BUILT_IN_EMOJI, BUILT_IN_FONTS, Calendar, CharacterCount, ChatComposer, Checkbox, CheckboxField, CheckboxGroup, ChoiceCard, CodeEditor, ColorArea, ColorField, ColorPicker, ColorSlider, ColorSwatch, ColorSwatchPicker, ColorWheel, Combobox, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxSeparator, CronInput, CurrencyInput, DateField, DatePicker, DateRangePicker, Editable, EditableCancel, EditableInput, EditablePreview, EditableSubmit, EmailInput, EmojiPicker, Field, Fieldset, FilePicker, FileUpload, FontPicker, FormErrorMessage, Field as FormField, FormHelperText, GradientPicker, IconPicker, InputAddon, InputGroup, JSONEditor, KeyboardShortcutPicker, Knob, Label, LabeledInput, Legend, Listbox, ListboxEmpty, ListboxGroup, ListboxItem, ListboxSeparator, MarkdownEditor, MaskedInput, MultiSelect, MultiSelectContent, MultiSelectItem, MultiSelectTags, MultiSelectTrigger, NumberInput, PHONE_COUNTRIES, PasswordInput, PasswordStrength, PercentInput, PhoneInput, PinInput, Radio, RadioField, RadioGroup, RangeCalendar, ReactionPicker, RecurrenceEditor, SearchInput, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Slider, Stepper, StepperList, StepperPanel, StepperStep, Switch, SwitchField, TagsInput, TelInput, TextInput, TextareaInput as Textarea, TextareaInput, TimeField, TimePicker, UrlInput, Wizard, WizardFooter, WizardStep, WizardSteps, colorSwatchVariants, gradientToCss, useWizard } from '../chunk-
|
|
1
|
+
export { ADDRESS_COUNTRIES, AddressForm, BUILT_IN_EMOJI, BUILT_IN_FONTS, Calendar, CharacterCount, ChatComposer, Checkbox, CheckboxField, CheckboxGroup, ChoiceCard, CodeEditor, ColorArea, ColorField, ColorPicker, ColorSlider, ColorSwatch, ColorSwatchPicker, ColorWheel, Combobox, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxSeparator, CronInput, CurrencyInput, DateField, DatePicker, DateRangePicker, Editable, EditableCancel, EditableInput, EditablePreview, EditableSubmit, EmailInput, EmojiPicker, Field, Fieldset, FilePicker, FileUpload, FontPicker, FormErrorMessage, Field as FormField, FormHelperText, GradientPicker, IconPicker, InputAddon, InputGroup, JSONEditor, KeyboardShortcutPicker, Knob, Label, LabeledInput, Legend, Listbox, ListboxEmpty, ListboxGroup, ListboxItem, ListboxSeparator, MarkdownEditor, MaskedInput, MultiSelect, MultiSelectContent, MultiSelectItem, MultiSelectTags, MultiSelectTrigger, NumberInput, PHONE_COUNTRIES, PasswordInput, PasswordStrength, PercentInput, PhoneInput, PinInput, Radio, RadioField, RadioGroup, RangeCalendar, ReactionPicker, RecurrenceEditor, SearchInput, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Slider, Stepper, StepperList, StepperPanel, StepperStep, Switch, SwitchField, TagsInput, TelInput, TextInput, TextareaInput as Textarea, TextareaInput, TimeField, TimePicker, UrlInput, Wizard, WizardFooter, WizardStep, WizardSteps, colorSwatchVariants, gradientToCss, useWizard } from '../chunk-KD6MJOL5.js';
|
|
2
|
+
import '../chunk-SIAFOCT4.js';
|
|
2
3
|
import '../chunk-UMRRFZ4R.js';
|
|
3
4
|
import '../chunk-XFUD3RZK.js';
|
|
4
5
|
import '../chunk-X5JSX4PU.js';
|
|
5
6
|
import '../chunk-QTHKG7MQ.js';
|
|
6
7
|
import '../chunk-OZBLEOLZ.js';
|
|
7
8
|
import '../chunk-VYFPLQPV.js';
|
|
8
|
-
import '../chunk-3BKZLK7D.js';
|
|
9
9
|
import '../chunk-RNHY33US.js';
|
|
10
10
|
import '../chunk-D7ZFCHX5.js';
|
|
11
11
|
import '../chunk-XSW3NZDD.js';
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { type HTMLAttributes } from 'react';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
3
|
+
/** A completed date range. Both ends are set; the in-progress state is internal. */
|
|
2
4
|
export interface DateRange {
|
|
3
|
-
start:
|
|
4
|
-
end:
|
|
5
|
+
start: Temporal.PlainDate;
|
|
6
|
+
end: Temporal.PlainDate;
|
|
5
7
|
}
|
|
6
8
|
export interface RangeCalendarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {
|
|
7
9
|
value?: DateRange | null;
|
|
8
10
|
defaultValue?: DateRange | null;
|
|
9
11
|
onValueChange?: (range: DateRange) => void;
|
|
10
|
-
defaultMonth?:
|
|
11
|
-
min?:
|
|
12
|
-
max?:
|
|
13
|
-
isDisabled?: (date:
|
|
12
|
+
defaultMonth?: Temporal.PlainDate;
|
|
13
|
+
min?: Temporal.PlainDate | null;
|
|
14
|
+
max?: Temporal.PlainDate | null;
|
|
15
|
+
isDisabled?: (date: Temporal.PlainDate) => boolean;
|
|
14
16
|
'aria-label'?: string;
|
|
15
17
|
}
|
|
16
18
|
export declare const RangeCalendar: import("react").ForwardRefExoticComponent<RangeCalendarProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type HTMLAttributes } from 'react';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
3
|
export type RecurrenceFreq = 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
|
|
3
4
|
export type RecurrenceWeekday = 'MO' | 'TU' | 'WE' | 'TH' | 'FR' | 'SA' | 'SU';
|
|
4
5
|
export interface RecurrenceRule {
|
|
@@ -7,13 +8,13 @@ export interface RecurrenceRule {
|
|
|
7
8
|
byDay?: RecurrenceWeekday[];
|
|
8
9
|
byMonthDay?: number;
|
|
9
10
|
count?: number;
|
|
10
|
-
until?:
|
|
11
|
+
until?: Temporal.PlainDate | null;
|
|
11
12
|
}
|
|
12
13
|
export interface RecurrenceEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue'> {
|
|
13
14
|
value?: RecurrenceRule;
|
|
14
15
|
defaultValue?: RecurrenceRule;
|
|
15
16
|
onValueChange?: (rule: RecurrenceRule) => void;
|
|
16
|
-
from?:
|
|
17
|
+
from?: Temporal.PlainDate;
|
|
17
18
|
previewCount?: number;
|
|
18
19
|
isDisabled?: boolean;
|
|
19
20
|
isReadOnly?: boolean;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { type InputHTMLAttributes } from 'react';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
3
|
import { type InputBaseVariants } from '../InputStyles';
|
|
3
|
-
export interface TimeValue {
|
|
4
|
-
hours: number;
|
|
5
|
-
minutes: number;
|
|
6
|
-
}
|
|
7
4
|
export interface TimeFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'defaultValue' | 'onChange' | 'size'>, InputBaseVariants {
|
|
8
|
-
value?:
|
|
9
|
-
defaultValue?:
|
|
10
|
-
onValueChange?: (value:
|
|
5
|
+
value?: Temporal.PlainTime | null;
|
|
6
|
+
defaultValue?: Temporal.PlainTime | null;
|
|
7
|
+
onValueChange?: (value: Temporal.PlainTime | null) => void;
|
|
11
8
|
}
|
|
12
9
|
export declare const TimeField: import("react").ForwardRefExoticComponent<TimeFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { TimeField, type TimeFieldProps
|
|
1
|
+
export { TimeField, type TimeFieldProps } from './TimeField';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
3
|
import { type SelectTriggerVariants } from '../select/Select.variants';
|
|
3
|
-
import { type TimeValue } from '../timeField';
|
|
4
4
|
export interface TimePickerProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'value' | 'defaultValue'>, SelectTriggerVariants {
|
|
5
|
-
value?:
|
|
6
|
-
defaultValue?:
|
|
7
|
-
onValueChange?: (time:
|
|
5
|
+
value?: Temporal.PlainTime | null;
|
|
6
|
+
defaultValue?: Temporal.PlainTime | null;
|
|
7
|
+
onValueChange?: (time: Temporal.PlainTime | null) => void;
|
|
8
8
|
/** Minute interval. Default 5. */
|
|
9
9
|
minuteStep?: number;
|
|
10
10
|
placeholder?: string;
|
|
11
|
-
format?: (time:
|
|
11
|
+
format?: (time: Temporal.PlainTime) => string;
|
|
12
12
|
isInvalid?: boolean;
|
|
13
13
|
name?: string;
|
|
14
14
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ProblemDetails } from './ProblemDetails';
|
|
2
|
+
/** Defines a typed transport error thrown on a non-2xx response (or network status `0`), carrying the HTTP status and parsed problem body. */
|
|
3
|
+
export declare class ApiError extends Error {
|
|
4
|
+
readonly status: number;
|
|
5
|
+
readonly problem: ProblemDetails | null;
|
|
6
|
+
constructor(status: number, problem: ProblemDetails | null, message?: string);
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Defines a branded alias for a raw ISO-8601 date-time string (`2026-07-04T12:00:00Z`) on a wire DTO. */
|
|
2
|
+
export type IsoDateTime = string & {
|
|
3
|
+
readonly __brand: 'IsoDateTime';
|
|
4
|
+
};
|
|
5
|
+
/** Defines a branded alias for a raw ISO-8601 calendar-date string (`2026-07-04`) on a wire DTO. */
|
|
6
|
+
export type IsoDate = string & {
|
|
7
|
+
readonly __brand: 'IsoDate';
|
|
8
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import '../chunk-DCHYNTHI.js';
|
|
2
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
3
|
+
|
|
4
|
+
// src/http/ApiError.ts
|
|
5
|
+
var ApiError = class _ApiError extends Error {
|
|
6
|
+
status;
|
|
7
|
+
problem;
|
|
8
|
+
constructor(status, problem, message) {
|
|
9
|
+
super(message ?? problem?.title ?? problem?.detail ?? `Request failed with status ${status}`);
|
|
10
|
+
this.name = "ApiError";
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.problem = problem;
|
|
13
|
+
Object.setPrototypeOf(this, _ApiError.prototype);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;
|
|
17
|
+
var PLAIN_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
18
|
+
var PLAIN_TIME = /^\d{2}:\d{2}(:\d{2})?(\.\d+)?$/;
|
|
19
|
+
var DURATION = /^-?P(?=[\dT])(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(\d+H)?(\d+M)?(\d+(\.\d+)?S)?)?$/;
|
|
20
|
+
function temporalReviver(_key, value) {
|
|
21
|
+
if (typeof value !== "string") return value;
|
|
22
|
+
if (INSTANT.test(value)) {
|
|
23
|
+
try {
|
|
24
|
+
return Temporal.Instant.from(value);
|
|
25
|
+
} catch {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (PLAIN_DATE.test(value)) {
|
|
30
|
+
try {
|
|
31
|
+
return Temporal.PlainDate.from(value);
|
|
32
|
+
} catch {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (PLAIN_TIME.test(value)) {
|
|
37
|
+
try {
|
|
38
|
+
return Temporal.PlainTime.from(value);
|
|
39
|
+
} catch {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (DURATION.test(value)) {
|
|
44
|
+
try {
|
|
45
|
+
return Temporal.Duration.from(value);
|
|
46
|
+
} catch {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
function parseJson(text) {
|
|
53
|
+
return JSON.parse(text, temporalReviver);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { ApiError, parseJson, temporalReviver };
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/http/ApiError.ts","../../src/http/temporalReviver.ts"],"names":[],"mappings":";;;;AAGO,IAAM,QAAA,GAAN,MAAM,SAAA,SAAiB,KAAA,CAAM;AAAA,EACzB,MAAA;AAAA,EACA,OAAA;AAAA,EAET,WAAA,CAAY,MAAA,EAAgB,OAAA,EAAgC,OAAA,EAAkB;AAC5E,IAAA,KAAA,CAAM,WAAW,OAAA,EAAS,KAAA,IAAS,SAAS,MAAA,IAAU,CAAA,2BAAA,EAA8B,MAAM,CAAA,CAAE,CAAA;AAC5F,IAAA,IAAA,CAAK,IAAA,GAAO,UAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAEf,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,SAAA,CAAS,SAAS,CAAA;AAAA,EAChD;AACF;ACXA,IAAM,OAAA,GAAU,qEAAA;AAChB,IAAM,UAAA,GAAa,qBAAA;AACnB,IAAM,UAAA,GAAa,gCAAA;AAEnB,IAAM,QAAA,GAAW,6EAAA;AAQV,SAAS,eAAA,CAAgB,MAAc,KAAA,EAAyB;AACrE,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA;AAEtC,EAAA,IAAI,OAAA,CAAQ,IAAA,CAAK,KAAK,CAAA,EAAG;AACvB,IAAA,IAAI;AACF,MAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,IAAA,CAAK,KAAK,CAAA;AAAA,IACpC,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AACA,EAAA,IAAI,UAAA,CAAW,IAAA,CAAK,KAAK,CAAA,EAAG;AAC1B,IAAA,IAAI;AACF,MAAA,OAAO,QAAA,CAAS,SAAA,CAAU,IAAA,CAAK,KAAK,CAAA;AAAA,IACtC,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AACA,EAAA,IAAI,UAAA,CAAW,IAAA,CAAK,KAAK,CAAA,EAAG;AAC1B,IAAA,IAAI;AACF,MAAA,OAAO,QAAA,CAAS,SAAA,CAAU,IAAA,CAAK,KAAK,CAAA;AAAA,IACtC,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AACA,EAAA,IAAI,QAAA,CAAS,IAAA,CAAK,KAAK,CAAA,EAAG;AACxB,IAAA,IAAI;AACF,MAAA,OAAO,QAAA,CAAS,QAAA,CAAS,IAAA,CAAK,KAAK,CAAA;AAAA,IACrC,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,UAAa,IAAA,EAAiB;AAC5C,EAAA,OAAO,IAAA,CAAK,KAAA,CAAM,IAAA,EAAM,eAAe,CAAA;AACzC","file":"index.js","sourcesContent":["import type { ProblemDetails } from './ProblemDetails';\n\n/** Defines a typed transport error thrown on a non-2xx response (or network status `0`), carrying the HTTP status and parsed problem body. */\nexport class ApiError extends Error {\n readonly status: number;\n readonly problem: ProblemDetails | null;\n\n constructor(status: number, problem: ProblemDetails | null, message?: string) {\n super(message ?? problem?.title ?? problem?.detail ?? `Request failed with status ${status}`);\n this.name = 'ApiError';\n this.status = status;\n this.problem = problem;\n // Restore prototype chain — required when subclassing built-ins under transpiled targets.\n Object.setPrototypeOf(this, ApiError.prototype);\n }\n}\n","import { Temporal } from '@js-temporal/polyfill';\n\n// Strict ISO-8601 shapes. Anchored (^…$) so partial / lenient strings never match — only a\n// wire value that is unambiguously one Temporal kind is upgraded; everything else stays a string.\nconst INSTANT = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2})?(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$/;\nconst PLAIN_DATE = /^\\d{4}-\\d{2}-\\d{2}$/;\nconst PLAIN_TIME = /^\\d{2}:\\d{2}(:\\d{2})?(\\.\\d+)?$/;\n// ISO-8601 duration: sign, `P`, then at least one designator (lookahead rejects a bare `P`).\nconst DURATION = /^-?P(?=[\\dT])(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(T(\\d+H)?(\\d+M)?(\\d+(\\.\\d+)?S)?)?$/;\n\n/**\n * Upgrades a matching ISO-8601 string to its `Temporal.*` value; returns everything else unchanged.\n * Intended as the reviver argument to `JSON.parse` so inbound date fields arrive as Temporal objects\n * (outbound is automatic via each `Temporal.*.toJSON()`). Each parse is guarded — an ISO-shaped but\n * invalid value (e.g. `2026-13-40`) falls back to the raw string rather than throwing.\n */\nexport function temporalReviver(_key: string, value: unknown): unknown {\n if (typeof value !== 'string') return value;\n\n if (INSTANT.test(value)) {\n try {\n return Temporal.Instant.from(value);\n } catch {\n return value;\n }\n }\n if (PLAIN_DATE.test(value)) {\n try {\n return Temporal.PlainDate.from(value);\n } catch {\n return value;\n }\n }\n if (PLAIN_TIME.test(value)) {\n try {\n return Temporal.PlainTime.from(value);\n } catch {\n return value;\n }\n }\n if (DURATION.test(value)) {\n try {\n return Temporal.Duration.from(value);\n } catch {\n return value;\n }\n }\n return value;\n}\n\n/** Parses a JSON string with {@link temporalReviver} applied, upgrading ISO date fields to `Temporal.*`. */\nexport function parseJson<T>(text: string): T {\n return JSON.parse(text, temporalReviver) as T;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upgrades a matching ISO-8601 string to its `Temporal.*` value; returns everything else unchanged.
|
|
3
|
+
* Intended as the reviver argument to `JSON.parse` so inbound date fields arrive as Temporal objects
|
|
4
|
+
* (outbound is automatic via each `Temporal.*.toJSON()`). Each parse is guarded — an ISO-shaped but
|
|
5
|
+
* invalid value (e.g. `2026-13-40`) falls back to the raw string rather than throwing.
|
|
6
|
+
*/
|
|
7
|
+
export declare function temporalReviver(_key: string, value: unknown): unknown;
|
|
8
|
+
/** Parses a JSON string with {@link temporalReviver} applied, upgrading ISO date fields to `Temporal.*`. */
|
|
9
|
+
export declare function parseJson<T>(text: string): T;
|