@asanchez-sa/abby 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/badge/badge.d.ts +3 -2
- package/dist/components/badge/badge.js +27 -11
- package/dist/components/calendar/calendar.d.ts +26 -5
- package/dist/components/calendar/calendar.js +387 -72
- package/dist/components/chart/chart.d.ts +76 -0
- package/dist/components/chart/chart.js +565 -0
- package/dist/components/chart/parts/axes.js +126 -0
- package/dist/components/chart/parts/frame.d.ts +31 -0
- package/dist/components/chart/parts/frame.js +278 -0
- package/dist/components/chart/parts/legend.d.ts +16 -0
- package/dist/components/chart/parts/legend.js +82 -0
- package/dist/components/chart/parts/points.d.ts +1 -0
- package/dist/components/chart/parts/points.js +139 -0
- package/dist/components/chart/parts/scale.js +139 -0
- package/dist/components/chart/parts/table.js +105 -0
- package/dist/components/chart/parts/types.d.ts +44 -0
- package/dist/components/chart/parts/types.js +8 -0
- package/dist/components/filter-chip/filter-chip.d.ts +36 -0
- package/dist/components/filter-chip/filter-chip.js +97 -0
- package/dist/components/graph/graph.d.ts +151 -0
- package/dist/components/graph/graph.js +959 -0
- package/dist/components/model-selector/model-selector.d.ts +38 -3
- package/dist/components/model-selector/model-selector.js +331 -73
- package/dist/components/number-input/number-input.d.ts +14 -3
- package/dist/components/number-input/number-input.js +193 -34
- package/dist/components/spinner/spinner.d.ts +7 -1
- package/dist/components/spinner/spinner.js +86 -26
- package/dist/components/toast/toast.d.ts +19 -2
- package/dist/components/toast/toast.js +211 -49
- package/dist/components/toggle/toggle.d.ts +18 -4
- package/dist/components/toggle/toggle.js +167 -32
- package/dist/components/week-strip/week-strip.d.ts +27 -5
- package/dist/components/week-strip/week-strip.js +288 -134
- package/package.json +4 -1
- package/skills/agent-ready-ui/SKILL.md +1 -1
- package/skills/blocks/SKILL.md +1 -1
- package/skills/compose-screens/SKILL.md +47 -5
- package/skills/compose-screens/references/calendar-week.md +77 -0
- package/skills/compose-screens/references/charts-and-maps.md +183 -0
- package/skills/compose-screens/references/filter-chips.md +61 -0
- package/skills/compose-screens/references/number-units.md +52 -0
- package/skills/note-editor/SKILL.md +1 -1
- package/skills/note-status/SKILL.md +1 -1
- package/skills/setup/SKILL.md +1 -1
- package/skills/theming/SKILL.md +1 -1
|
@@ -2,7 +2,8 @@ import "../../core/index.js";
|
|
|
2
2
|
import { PartProps } from "../../core/ui-sdk.js";
|
|
3
3
|
import { VariantProps } from "../../utilities/cn/index.js";
|
|
4
4
|
declare const badgeVariants: (props?: ({
|
|
5
|
-
variant?: "default" | "destructive" | "ghost" | "link" | "outline" | "secondary" | null | undefined;
|
|
5
|
+
variant?: "assistant" | "default" | "destructive" | "ghost" | "link" | "outline" | "secondary" | "success" | "warning" | null | undefined;
|
|
6
|
+
shape?: "count" | "pill" | null | undefined;
|
|
6
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
8
|
type BadgeProps = PartProps<"span"> & VariantProps<typeof badgeVariants>;
|
|
8
9
|
/**
|
|
@@ -12,5 +13,5 @@ type BadgeProps = PartProps<"span"> & VariantProps<typeof badgeVariants>;
|
|
|
12
13
|
* and a ui-sdk `Button` rendered as a link gives it nothing to press. For a
|
|
13
14
|
* button, render a ui-sdk `Button` that is a real button.
|
|
14
15
|
*/
|
|
15
|
-
declare function Badge({ variant, className, render, ...props }: BadgeProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
16
|
+
declare function Badge({ variant, shape, className, render, ...props }: BadgeProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
16
17
|
export { Badge, type BadgeProps, badgeVariants };
|
|
@@ -4,15 +4,27 @@ import "../../core/index.js";
|
|
|
4
4
|
import { cnState, cva } from "../../utilities/cn/index.js";
|
|
5
5
|
// src/components/badge/badge.tsx
|
|
6
6
|
const badgeVariants = cva("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-colors focus-ring has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&>svg]:pointer-events-none [&>svg]:size-3!", {
|
|
7
|
-
variants: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
default: "bg-primary text-primary-foreground [a,button]:hover:bg-primary/85",
|
|
10
|
+
secondary: "bg-secondary text-muted-foreground [a,button]:hover:bg-secondary/70",
|
|
11
|
+
destructive: "bg-destructive/10 text-destructive [a,button]:hover:bg-destructive [a,button]:hover:text-destructive-foreground",
|
|
12
|
+
outline: "border-border text-muted-foreground [a,button]:border-input [a,button]:hover:bg-muted [a,button]:hover:text-muted-foreground",
|
|
13
|
+
ghost: "[a,button]:hover:bg-muted [a,button]:hover:text-muted-foreground",
|
|
14
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
15
|
+
warning: "bg-warning/10 text-warning [a,button]:hover:bg-warning/20",
|
|
16
|
+
success: "bg-success/10 text-success [a,button]:hover:bg-success/20",
|
|
17
|
+
assistant: "bg-assistant/10 text-assistant [a,button]:hover:bg-assistant/20"
|
|
18
|
+
},
|
|
19
|
+
shape: {
|
|
20
|
+
pill: "",
|
|
21
|
+
count: "h-5.5 min-w-5.5 px-1.5 font-semibold tabular-nums"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
variant: "default",
|
|
26
|
+
shape: "pill"
|
|
27
|
+
}
|
|
16
28
|
});
|
|
17
29
|
/**
|
|
18
30
|
* A short label for a status or a count. `render` makes it a link or a button.
|
|
@@ -21,12 +33,16 @@ const badgeVariants = cva("group/badge inline-flex h-5 w-fit shrink-0 items-cent
|
|
|
21
33
|
* and a ui-sdk `Button` rendered as a link gives it nothing to press. For a
|
|
22
34
|
* button, render a ui-sdk `Button` that is a real button.
|
|
23
35
|
*/
|
|
24
|
-
function Badge({ variant, className, render, ...props }) {
|
|
36
|
+
function Badge({ variant, shape, className, render, ...props }) {
|
|
25
37
|
return renderElement("span", {
|
|
26
38
|
"data-slot": "badge",
|
|
27
39
|
"data-variant": variant ?? "default",
|
|
40
|
+
"data-shape": shape ?? "pill",
|
|
28
41
|
...props,
|
|
29
|
-
className: cnState(badgeVariants({
|
|
42
|
+
className: cnState(badgeVariants({
|
|
43
|
+
variant,
|
|
44
|
+
shape
|
|
45
|
+
}), className)
|
|
30
46
|
}, render);
|
|
31
47
|
}
|
|
32
48
|
export { Badge, badgeVariants };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ButtonLook } from "../button/button.js";
|
|
2
|
+
import { WeekStripMark } from "../week-strip/week-strip.js";
|
|
2
3
|
import { ComponentProps, ReactNode } from "react";
|
|
3
|
-
import { Calendar as Calendar$1, CalendarAnchorChangeReason, CalendarChangeOptions, CalendarController, CalendarDay as CalendarDay$1, CalendarDayState, CalendarFocusedChangeReason, CalendarGrid as CalendarGrid$1, CalendarGridCell, CalendarGridState, CalendarHeading as CalendarHeading$1, CalendarHeadingState, CalendarMode, CalendarMonthChangeReason, CalendarMonthSelect as CalendarMonthSelect$1, CalendarOptions, CalendarPrevious as CalendarPrevious$1, CalendarSelectOption, CalendarSelectState, CalendarState, CalendarStepState, CalendarValue, CalendarValueChangeReason, CalendarWeekday as CalendarWeekday$1, CalendarWeekdayState, CalendarWeekdays as CalendarWeekdays$1, CalendarWeeks as CalendarWeeks$1, CalendarYearSelect as CalendarYearSelect$1, DateMatcher, DateMatchers, ISOMonth, createCalendarController } from "@ui-sdk/react/calendar";
|
|
4
|
+
import { Calendar as Calendar$1, CalendarAnchorChangeReason, CalendarChangeOptions, CalendarController, CalendarDay as CalendarDay$1, CalendarDayState, CalendarFocusedChangeReason, CalendarGrid as CalendarGrid$1, CalendarGridCell, CalendarGridState, CalendarHeading as CalendarHeading$1, CalendarHeadingState, CalendarMode as CalendarMode$1, CalendarMonthChangeReason, CalendarMonthSelect as CalendarMonthSelect$1, CalendarOptions, CalendarPrevious as CalendarPrevious$1, CalendarSelectOption, CalendarSelectState, CalendarState, CalendarStepState, CalendarValue, CalendarValueChangeReason, CalendarWeekday as CalendarWeekday$1, CalendarWeekdayState, CalendarWeekdays as CalendarWeekdays$1, CalendarWeeks as CalendarWeeks$1, CalendarYearSelect as CalendarYearSelect$1, DateMatcher, DateMatchers, ISOMonth, createCalendarController } from "@ui-sdk/react/calendar";
|
|
4
5
|
/**
|
|
5
6
|
* Previous, the heading and Next share the first row, and anything else takes
|
|
6
7
|
* a row of its own. `DatePickerContent` lays its calendar out the same way.
|
|
@@ -8,8 +9,28 @@ import { Calendar as Calendar$1, CalendarAnchorChangeReason, CalendarChangeOptio
|
|
|
8
9
|
declare const calendarLayout = "grid grid-cols-[auto_1fr_auto] items-center gap-y-2 text-sm [--cell-size:--spacing(8)] [&>*:not([data-slot=calendar-previous],[data-slot=calendar-heading],[data-slot=calendar-next])]:col-span-full";
|
|
9
10
|
/** What a calendar with no children shows: the heading between Previous and Next, and a grid for each month. */
|
|
10
11
|
declare function calendarParts(months?: number): ReactNode;
|
|
11
|
-
/**
|
|
12
|
-
|
|
12
|
+
/** How a calendar selects: ui-sdk's three modes, and abby's `"week"`. */
|
|
13
|
+
type CalendarMode = CalendarMode$1 | "week";
|
|
14
|
+
type CalendarProps = Omit<ComponentProps<typeof Calendar$1>, "mode"> & {
|
|
15
|
+
/**
|
|
16
|
+
* What a press selects. `"week"` is abby's own (ui-sdk has no such mode): one
|
|
17
|
+
* press picks the whole week, and the value is the `[start, end]` range of 7
|
|
18
|
+
* days that starts on the calendar's first day of the week, however it was
|
|
19
|
+
* set. ui-sdk gets `mode="range"`.
|
|
20
|
+
*/
|
|
21
|
+
mode?: CalendarMode;
|
|
22
|
+
/**
|
|
23
|
+
* What each day says, as in `WeekStrip`: under the day number it draws the
|
|
24
|
+
* first tone of `dots`, or the `check`. `label`, `corner` and `bar` are
|
|
25
|
+
* ignored. The `description` is read after the date.
|
|
26
|
+
*/
|
|
27
|
+
marks?: (date: string) => WeekStripMark | undefined;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Without children it renders the heading, Previous, Next and a grid for each of
|
|
31
|
+
* its `months`. `mode="week"` and `marks` are abby's own on top of ui-sdk's calendar.
|
|
32
|
+
*/
|
|
33
|
+
declare function Calendar({ className, children, mode, marks, controller, value, defaultValue, onValueChange, onAnchorChange, ...props }: CalendarProps): import("react").JSX.Element;
|
|
13
34
|
declare function CalendarHeading({ className, ...props }: ComponentProps<typeof CalendarHeading$1>): import("react").JSX.Element;
|
|
14
35
|
type CalendarStepProps = ComponentProps<typeof CalendarPrevious$1> & ButtonLook;
|
|
15
36
|
/** A ghost icon button. Without children it draws an arrow, which follows the reading direction. */
|
|
@@ -25,5 +46,5 @@ declare function CalendarWeekdays({ children, ...props }: ComponentProps<typeof
|
|
|
25
46
|
declare function CalendarWeekday({ className, ...props }: ComponentProps<typeof CalendarWeekday$1>): import("react").JSX.Element;
|
|
26
47
|
/** Without children it renders a `CalendarDay` in each cell. */
|
|
27
48
|
declare function CalendarWeeks({ children, ...props }: ComponentProps<typeof CalendarWeeks$1>): import("react").JSX.Element;
|
|
28
|
-
declare function CalendarDay({ className, ...props }: ComponentProps<typeof CalendarDay$1>): import("react").JSX.Element;
|
|
29
|
-
export { Calendar, type CalendarAnchorChangeReason, type CalendarChangeOptions, type CalendarController, CalendarDay, type CalendarDayState, type CalendarFocusedChangeReason, CalendarGrid, type CalendarGridCell, type CalendarGridState, CalendarHeading, type CalendarHeadingState, type CalendarMode, type CalendarMonthChangeReason, CalendarMonthSelect, CalendarNext, type CalendarOptions, CalendarPrevious, type CalendarSelectOption, type CalendarSelectState, type CalendarState, type CalendarStepProps, type CalendarStepState, type CalendarValue, type CalendarValueChangeReason, CalendarWeekday, type CalendarWeekdayState, CalendarWeekdays, CalendarWeeks, CalendarYearSelect, type DateMatcher, type DateMatchers, type ISOMonth, calendarLayout, calendarParts, createCalendarController };
|
|
49
|
+
declare function CalendarDay({ className, children, value, "aria-describedby": describedBy, ...props }: ComponentProps<typeof CalendarDay$1>): import("react").JSX.Element;
|
|
50
|
+
export { Calendar, type CalendarAnchorChangeReason, type CalendarChangeOptions, type CalendarController, CalendarDay, type CalendarDayState, type CalendarFocusedChangeReason, CalendarGrid, type CalendarGridCell, type CalendarGridState, CalendarHeading, type CalendarHeadingState, type CalendarMode, type CalendarMonthChangeReason, CalendarMonthSelect, CalendarNext, type CalendarOptions, CalendarPrevious, type CalendarProps, type CalendarSelectOption, type CalendarSelectState, type CalendarState, type CalendarStepProps, type CalendarStepState, type CalendarValue, type CalendarValueChangeReason, CalendarWeekday, type CalendarWeekdayState, CalendarWeekdays, CalendarWeeks, CalendarYearSelect, type DateMatcher, type DateMatchers, type ISOMonth, calendarLayout, calendarParts, createCalendarController };
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cnState } from "../../utilities/cn/index.js";
|
|
2
|
+
import { cn, cnState } from "../../utilities/cn/index.js";
|
|
3
|
+
import "../../utilities/date/index.js";
|
|
4
|
+
import "../../utilities/text/index.js";
|
|
3
5
|
import { buttonLook } from "../button/button.js";
|
|
6
|
+
import { addDays, addMonths, endOfMonth, endOfWeek, firstDayOfWeek, isISODate, startOfWeek } from "../../utilities/date/ui-sdk.js";
|
|
4
7
|
import { Icon } from "../icon/icon.js";
|
|
8
|
+
import { pageLocale } from "../../utilities/text/ui-sdk.js";
|
|
5
9
|
import { inputClasses } from "../input/input.js";
|
|
6
10
|
import { c } from "react/compiler-runtime";
|
|
7
|
-
import {
|
|
11
|
+
import { createContext, use, useId, useRef, useState } from "react";
|
|
12
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
13
|
import { ArrowLeft01Icon, ArrowRight01Icon } from "@hugeicons/core-free-icons";
|
|
9
14
|
import { Calendar as Calendar$1, CalendarDay as CalendarDay$1, CalendarGrid as CalendarGrid$1, CalendarHeading as CalendarHeading$1, CalendarMonthSelect as CalendarMonthSelect$1, CalendarNext as CalendarNext$1, CalendarPrevious as CalendarPrevious$1, CalendarWeekday as CalendarWeekday$1, CalendarWeekdays as CalendarWeekdays$1, CalendarWeeks as CalendarWeeks$1, CalendarYearSelect as CalendarYearSelect$1, createCalendarController } from "@ui-sdk/react/calendar";
|
|
10
15
|
// src/components/calendar/calendar.tsx
|
|
@@ -15,7 +20,7 @@ import { Calendar as Calendar$1, CalendarDay as CalendarDay$1, CalendarGrid as C
|
|
|
15
20
|
const calendarLayout = "grid grid-cols-[auto_1fr_auto] items-center gap-y-2 text-sm [--cell-size:--spacing(8)] [&>*:not([data-slot=calendar-previous],[data-slot=calendar-heading],[data-slot=calendar-next])]:col-span-full";
|
|
16
21
|
/** What a calendar with no children shows: the heading between Previous and Next, and a grid for each month. */
|
|
17
22
|
function calendarParts(months = 1) {
|
|
18
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
23
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
19
24
|
/* @__PURE__ */ jsx(CalendarPrevious, {}),
|
|
20
25
|
/* @__PURE__ */ jsx(CalendarHeading, {}),
|
|
21
26
|
/* @__PURE__ */ jsx(CalendarNext, {}),
|
|
@@ -25,48 +30,234 @@ function calendarParts(months = 1) {
|
|
|
25
30
|
}) : /* @__PURE__ */ jsx(CalendarGrid, {})
|
|
26
31
|
] });
|
|
27
32
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
const CalendarMarksContext = createContext({
|
|
34
|
+
marks: void 0,
|
|
35
|
+
week: false,
|
|
36
|
+
descriptions: null
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Each mark's description, hidden, outside the grid: a day points at its own
|
|
40
|
+
* with `aria-describedby` whatever its children draw, and the text never joins
|
|
41
|
+
* the day's name. It covers every day the grids can show, outside days included.
|
|
42
|
+
*/
|
|
43
|
+
function MarkDescriptions(t0) {
|
|
44
|
+
const $ = c(10);
|
|
45
|
+
const { marks, month, months, prefix } = t0;
|
|
46
|
+
const t1 = `${month}-01`;
|
|
33
47
|
let t2;
|
|
48
|
+
if ($[0] !== t1) {
|
|
49
|
+
t2 = addDays(t1, -7);
|
|
50
|
+
$[0] = t1;
|
|
51
|
+
$[1] = t2;
|
|
52
|
+
} else t2 = $[1];
|
|
53
|
+
const first = t2;
|
|
34
54
|
let t3;
|
|
35
|
-
if ($[
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
t1 = cnState([calendarLayout, "w-fit rounded-xl bg-background p-2"], className);
|
|
40
|
-
$[5] = className;
|
|
41
|
-
$[6] = t1;
|
|
42
|
-
} else t1 = $[6];
|
|
43
|
-
t2 = props;
|
|
44
|
-
t3 = children ?? calendarParts(props.months);
|
|
45
|
-
$[0] = t0;
|
|
46
|
-
$[1] = T0;
|
|
47
|
-
$[2] = t1;
|
|
48
|
-
$[3] = t2;
|
|
55
|
+
if ($[2] !== month || $[3] !== months) {
|
|
56
|
+
t3 = addDays(endOfMonth(addMonths(`${month}-01`, months - 1)), 14);
|
|
57
|
+
$[2] = month;
|
|
58
|
+
$[3] = months;
|
|
49
59
|
$[4] = t3;
|
|
50
|
-
} else
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
} else t3 = $[4];
|
|
61
|
+
const last = t3;
|
|
62
|
+
let lines;
|
|
63
|
+
if ($[5] !== first || $[6] !== last || $[7] !== marks || $[8] !== prefix) {
|
|
64
|
+
lines = [];
|
|
65
|
+
for (let date = first; date <= last; date = addDays(date, 1)) {
|
|
66
|
+
const description = marks(date)?.description;
|
|
67
|
+
if (description) lines.push(/* @__PURE__ */ jsx("span", {
|
|
68
|
+
id: `${prefix}-${date}`,
|
|
69
|
+
hidden: true,
|
|
70
|
+
"aria-hidden": "true",
|
|
71
|
+
children: description
|
|
72
|
+
}, date));
|
|
73
|
+
}
|
|
74
|
+
$[5] = first;
|
|
75
|
+
$[6] = last;
|
|
76
|
+
$[7] = marks;
|
|
77
|
+
$[8] = prefix;
|
|
78
|
+
$[9] = lines;
|
|
79
|
+
} else lines = $[9];
|
|
80
|
+
return lines;
|
|
81
|
+
}
|
|
82
|
+
/** The week that holds the first valid date of a value, or null when it has none. */
|
|
83
|
+
function weekOf(value, weekStartsOn) {
|
|
84
|
+
const first = Array.isArray(value) ? value.find(isISODate) : value;
|
|
85
|
+
if (typeof first !== "string" || !isISODate(first)) return null;
|
|
86
|
+
return [startOfWeek(first, weekStartsOn), endOfWeek(first, weekStartsOn)];
|
|
87
|
+
}
|
|
88
|
+
/** Whether a value already is a whole week, starting where the calendar's weeks start. */
|
|
89
|
+
function isWeek(value, weekStartsOn) {
|
|
90
|
+
if (!Array.isArray(value) || value.length !== 2) return false;
|
|
91
|
+
const week = weekOf(value, weekStartsOn);
|
|
92
|
+
return week !== null && week[0] === value[0] && week[1] === value[1];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Without children it renders the heading, Previous, Next and a grid for each of
|
|
96
|
+
* its `months`. `mode="week"` and `marks` are abby's own on top of ui-sdk's calendar.
|
|
97
|
+
*/
|
|
98
|
+
function Calendar(t0) {
|
|
99
|
+
const $ = c(40);
|
|
100
|
+
const { className, children, mode, marks, controller, value, defaultValue, onValueChange, onAnchorChange, ...props } = t0;
|
|
101
|
+
const week = mode === "week";
|
|
102
|
+
const descriptions = useId();
|
|
103
|
+
const [own] = useState(_temp);
|
|
104
|
+
const drive = controller ?? own;
|
|
105
|
+
const [pageLang, setPageLang] = useState(null);
|
|
106
|
+
const startOf = (lang) => props.weekStartsOn === void 0 ? firstDayOfWeek(props.locale ?? lang ?? "en-US") : (props.weekStartsOn % 7 + 7) % 7;
|
|
107
|
+
const weekStartsOn = startOf(pageLang);
|
|
108
|
+
const langRead = useRef(false);
|
|
109
|
+
const refitting = useRef(false);
|
|
110
|
+
const readLang = (el) => {
|
|
111
|
+
if (!el || langRead.current) return;
|
|
112
|
+
langRead.current = true;
|
|
113
|
+
const read = () => {
|
|
114
|
+
const lang_0 = pageLocale(el) ?? null;
|
|
115
|
+
setPageLang(lang_0);
|
|
116
|
+
const start = startOf(lang_0);
|
|
117
|
+
if (start === weekStartsOn || value !== void 0) return;
|
|
118
|
+
const fitted = weekOf(defaultValue, start);
|
|
119
|
+
if (!fitted) return;
|
|
120
|
+
queueMicrotask(() => {
|
|
121
|
+
if (isWeek(drive.getValue(), start)) return;
|
|
122
|
+
refitting.current = true;
|
|
123
|
+
drive.setValue(fitted);
|
|
124
|
+
refitting.current = false;
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
if (el.isConnected) read();
|
|
128
|
+
else queueMicrotask(read);
|
|
129
|
+
};
|
|
130
|
+
const fit = (input) => input === void 0 || input === null ? input : weekOf(input, weekStartsOn) ?? null;
|
|
131
|
+
const content = children ?? calendarParts(props.months);
|
|
132
|
+
const months = Math.max(1, Math.floor(props.months ?? 1) || 1);
|
|
133
|
+
const T0 = CalendarMarksContext;
|
|
134
|
+
const t1 = marks ? descriptions : null;
|
|
135
|
+
let t2;
|
|
136
|
+
if ($[0] !== marks || $[1] !== t1 || $[2] !== week) {
|
|
137
|
+
t2 = {
|
|
138
|
+
marks,
|
|
139
|
+
week,
|
|
140
|
+
descriptions: t1
|
|
141
|
+
};
|
|
142
|
+
$[0] = marks;
|
|
143
|
+
$[1] = t1;
|
|
144
|
+
$[2] = week;
|
|
145
|
+
$[3] = t2;
|
|
146
|
+
} else t2 = $[3];
|
|
147
|
+
const T1 = Calendar$1;
|
|
148
|
+
const t3 = week && "group/week [--cell-size:--spacing(10)]";
|
|
56
149
|
let t4;
|
|
57
|
-
if ($[
|
|
58
|
-
t4 =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
150
|
+
if ($[4] !== className || $[5] !== t3) {
|
|
151
|
+
t4 = cnState([
|
|
152
|
+
calendarLayout,
|
|
153
|
+
"w-fit rounded-xl bg-background p-2",
|
|
154
|
+
t3
|
|
155
|
+
], className);
|
|
156
|
+
$[4] = className;
|
|
157
|
+
$[5] = t3;
|
|
158
|
+
$[6] = t4;
|
|
159
|
+
} else t4 = $[6];
|
|
160
|
+
const t5 = week ? "" : void 0;
|
|
161
|
+
const t6 = week ? "range" : mode;
|
|
162
|
+
const t7 = week ? drive : controller;
|
|
163
|
+
const t8 = week ? fit(value) : value;
|
|
164
|
+
const t9 = week ? fit(defaultValue) : defaultValue;
|
|
165
|
+
let t10;
|
|
166
|
+
if ($[7] !== drive || $[8] !== onValueChange || $[9] !== week || $[10] !== weekStartsOn) {
|
|
167
|
+
t10 = week ? (next, details) => {
|
|
168
|
+
if (refitting.current) return;
|
|
169
|
+
if (!isWeek(next, weekStartsOn)) {
|
|
170
|
+
details.cancel();
|
|
171
|
+
const fitted_0 = weekOf(next, weekStartsOn);
|
|
172
|
+
if (fitted_0) drive.setValue(fitted_0);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
onValueChange?.(next, details);
|
|
176
|
+
} : onValueChange;
|
|
177
|
+
$[7] = drive;
|
|
178
|
+
$[8] = onValueChange;
|
|
179
|
+
$[9] = week;
|
|
180
|
+
$[10] = weekStartsOn;
|
|
181
|
+
$[11] = t10;
|
|
182
|
+
} else t10 = $[11];
|
|
183
|
+
let t11;
|
|
184
|
+
if ($[12] !== drive || $[13] !== onAnchorChange || $[14] !== week || $[15] !== weekStartsOn) {
|
|
185
|
+
t11 = week ? (anchor, details_0) => {
|
|
186
|
+
details_0.cancel();
|
|
187
|
+
const picked = anchor ? weekOf(anchor, weekStartsOn) : null;
|
|
188
|
+
if (picked) drive.setValue(picked);
|
|
189
|
+
} : onAnchorChange;
|
|
190
|
+
$[12] = drive;
|
|
191
|
+
$[13] = onAnchorChange;
|
|
192
|
+
$[14] = week;
|
|
193
|
+
$[15] = weekStartsOn;
|
|
194
|
+
$[16] = t11;
|
|
195
|
+
} else t11 = $[16];
|
|
196
|
+
let t12;
|
|
197
|
+
if ($[17] !== content || $[18] !== descriptions || $[19] !== marks || $[20] !== months || $[21] !== readLang || $[22] !== week) {
|
|
198
|
+
t12 = week || marks ? (state) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
199
|
+
typeof content === "function" ? content(state) : content,
|
|
200
|
+
week && /* @__PURE__ */ jsx("span", {
|
|
201
|
+
ref: readLang,
|
|
202
|
+
hidden: true
|
|
203
|
+
}),
|
|
204
|
+
marks && /* @__PURE__ */ jsx(MarkDescriptions, {
|
|
205
|
+
marks,
|
|
206
|
+
month: state.month,
|
|
207
|
+
months,
|
|
208
|
+
prefix: descriptions
|
|
209
|
+
})
|
|
210
|
+
] }) : content;
|
|
211
|
+
$[17] = content;
|
|
212
|
+
$[18] = descriptions;
|
|
213
|
+
$[19] = marks;
|
|
214
|
+
$[20] = months;
|
|
215
|
+
$[21] = readLang;
|
|
216
|
+
$[22] = week;
|
|
217
|
+
$[23] = t12;
|
|
218
|
+
} else t12 = $[23];
|
|
219
|
+
let t13;
|
|
220
|
+
if ($[24] !== T1 || $[25] !== props || $[26] !== t10 || $[27] !== t11 || $[28] !== t12 || $[29] !== t4 || $[30] !== t5 || $[31] !== t6 || $[32] !== t7 || $[33] !== t8 || $[34] !== t9) {
|
|
221
|
+
t13 = /* @__PURE__ */ jsx(T1, {
|
|
222
|
+
className: t4,
|
|
223
|
+
"data-week": t5,
|
|
224
|
+
...props,
|
|
225
|
+
mode: t6,
|
|
226
|
+
controller: t7,
|
|
227
|
+
value: t8,
|
|
228
|
+
defaultValue: t9,
|
|
229
|
+
onValueChange: t10,
|
|
230
|
+
onAnchorChange: t11,
|
|
231
|
+
children: t12
|
|
62
232
|
});
|
|
63
|
-
$[
|
|
64
|
-
$[
|
|
65
|
-
$[
|
|
66
|
-
$[
|
|
67
|
-
$[
|
|
68
|
-
|
|
69
|
-
|
|
233
|
+
$[24] = T1;
|
|
234
|
+
$[25] = props;
|
|
235
|
+
$[26] = t10;
|
|
236
|
+
$[27] = t11;
|
|
237
|
+
$[28] = t12;
|
|
238
|
+
$[29] = t4;
|
|
239
|
+
$[30] = t5;
|
|
240
|
+
$[31] = t6;
|
|
241
|
+
$[32] = t7;
|
|
242
|
+
$[33] = t8;
|
|
243
|
+
$[34] = t9;
|
|
244
|
+
$[35] = t13;
|
|
245
|
+
} else t13 = $[35];
|
|
246
|
+
let t14;
|
|
247
|
+
if ($[36] !== T0 || $[37] !== t13 || $[38] !== t2) {
|
|
248
|
+
t14 = /* @__PURE__ */ jsx(T0, {
|
|
249
|
+
value: t2,
|
|
250
|
+
children: t13
|
|
251
|
+
});
|
|
252
|
+
$[36] = T0;
|
|
253
|
+
$[37] = t13;
|
|
254
|
+
$[38] = t2;
|
|
255
|
+
$[39] = t14;
|
|
256
|
+
} else t14 = $[39];
|
|
257
|
+
return t14;
|
|
258
|
+
}
|
|
259
|
+
function _temp() {
|
|
260
|
+
return createCalendarController();
|
|
70
261
|
}
|
|
71
262
|
function CalendarHeading(t0) {
|
|
72
263
|
const $ = c(8);
|
|
@@ -83,7 +274,7 @@ function CalendarHeading(t0) {
|
|
|
83
274
|
}
|
|
84
275
|
let t1;
|
|
85
276
|
if ($[3] !== className) {
|
|
86
|
-
t1 = cnState("px-2 text-center text-label select-none", className);
|
|
277
|
+
t1 = cnState("px-2 text-center text-label select-none group-data-week/week:text-start", className);
|
|
87
278
|
$[3] = className;
|
|
88
279
|
$[4] = t1;
|
|
89
280
|
} else t1 = $[4];
|
|
@@ -305,7 +496,7 @@ function CalendarGrid(t0) {
|
|
|
305
496
|
} else t1 = $[5];
|
|
306
497
|
let t2;
|
|
307
498
|
if ($[6] !== children) {
|
|
308
|
-
t2 = children ?? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CalendarWeekdays, {}), /* @__PURE__ */ jsx(CalendarWeeks, {})] });
|
|
499
|
+
t2 = children ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CalendarWeekdays, {}), /* @__PURE__ */ jsx(CalendarWeeks, {})] });
|
|
309
500
|
$[6] = children;
|
|
310
501
|
$[7] = t2;
|
|
311
502
|
} else t2 = $[7];
|
|
@@ -366,7 +557,7 @@ function CalendarWeekday(t0) {
|
|
|
366
557
|
}
|
|
367
558
|
let t1;
|
|
368
559
|
if ($[3] !== className) {
|
|
369
|
-
t1 = cnState("h-(--cell-size) w-(--cell-size) p-0 text-center text-xs font-normal text-muted-foreground select-none [&_abbr]:no-underline", className);
|
|
560
|
+
t1 = cnState(["h-(--cell-size) w-(--cell-size) p-0 text-center text-xs font-normal text-muted-foreground select-none [&_abbr]:no-underline", "group-data-week/week:h-5 group-data-week/week:text-footnote group-data-week/week:font-medium group-data-week/week:text-subtle"], className);
|
|
370
561
|
$[3] = className;
|
|
371
562
|
$[4] = t1;
|
|
372
563
|
} else t1 = $[4];
|
|
@@ -410,44 +601,168 @@ function CalendarWeeks(t0) {
|
|
|
410
601
|
} else t2 = $[5];
|
|
411
602
|
return t2;
|
|
412
603
|
}
|
|
604
|
+
const plainDay = [
|
|
605
|
+
"rounded-full data-outside:text-muted-foreground",
|
|
606
|
+
"not-data-selected:not-data-range-start:not-data-range-end:hover:bg-accent",
|
|
607
|
+
"data-today:not-data-selected:not-data-range-start:not-data-range-end:bg-muted data-today:not-data-selected:not-data-range-start:not-data-range-end:ring-1 data-today:not-data-selected:not-data-range-start:not-data-range-end:ring-input data-today:not-data-selected:not-data-range-start:not-data-range-end:ring-inset data-today:not-data-selected:not-data-range-start:not-data-range-end:text-foreground",
|
|
608
|
+
"data-range-middle:not-data-range-start:rounded-none data-range-middle:not-data-range-start:bg-muted data-range-middle:not-data-range-start:font-medium data-range-middle:not-data-range-start:text-foreground",
|
|
609
|
+
"data-selected:not-data-range-middle:bg-primary data-selected:not-data-range-middle:text-primary-foreground",
|
|
610
|
+
"data-range-start:not-data-range-middle:bg-primary data-range-start:not-data-range-middle:text-primary-foreground data-range-end:not-data-range-middle:bg-primary data-range-end:not-data-range-middle:text-primary-foreground",
|
|
611
|
+
"data-range-start:not-data-range-end:rounded-e-none data-range-end:not-data-range-start:rounded-s-none"
|
|
612
|
+
];
|
|
613
|
+
/**
|
|
614
|
+
* A week is one capsule across its row: the row lights up under the pointer or
|
|
615
|
+
* the keyboard (`:has()`, since ui-sdk only previews a range once it has an
|
|
616
|
+
* anchor), and the chosen week stays as a soft band in Alma's `track`.
|
|
617
|
+
*/
|
|
618
|
+
const weekDay = [
|
|
619
|
+
"rounded-none data-outside:text-subtle",
|
|
620
|
+
"in-[td:first-child]:rounded-s-full in-[td:last-child]:rounded-e-full",
|
|
621
|
+
"not-data-selected:not-data-range-start:not-data-range-end:not-data-range-middle:in-[tr:has(:is(:hover,:focus-visible))]:bg-muted/45",
|
|
622
|
+
"data-today:not-data-selected:not-data-range-start:not-data-range-end:not-data-range-middle:bg-muted",
|
|
623
|
+
"data-selected:bg-sidebar-accent data-selected:font-medium data-selected:text-foreground",
|
|
624
|
+
"data-range-start:bg-sidebar-accent data-range-start:font-medium data-range-start:text-foreground",
|
|
625
|
+
"data-range-middle:bg-sidebar-accent data-range-middle:font-medium data-range-middle:text-foreground",
|
|
626
|
+
"data-range-end:bg-sidebar-accent data-range-end:font-medium data-range-end:text-foreground"
|
|
627
|
+
];
|
|
628
|
+
const markTones = {
|
|
629
|
+
primary: "bg-primary",
|
|
630
|
+
muted: "bg-subtle",
|
|
631
|
+
destructive: "bg-destructive",
|
|
632
|
+
warning: "bg-warning",
|
|
633
|
+
success: "bg-success",
|
|
634
|
+
"chart-1": "bg-chart-1",
|
|
635
|
+
"chart-2": "bg-chart-2",
|
|
636
|
+
"chart-3": "bg-chart-3",
|
|
637
|
+
"chart-4": "bg-chart-4",
|
|
638
|
+
"chart-5": "bg-chart-5"
|
|
639
|
+
};
|
|
640
|
+
const checkTones = {
|
|
641
|
+
primary: "text-primary",
|
|
642
|
+
muted: "text-subtle",
|
|
643
|
+
destructive: "text-destructive",
|
|
644
|
+
warning: "text-warning",
|
|
645
|
+
success: "text-success",
|
|
646
|
+
"chart-1": "text-chart-1",
|
|
647
|
+
"chart-2": "text-chart-2",
|
|
648
|
+
"chart-3": "text-chart-3",
|
|
649
|
+
"chart-4": "text-chart-4",
|
|
650
|
+
"chart-5": "text-chart-5"
|
|
651
|
+
};
|
|
652
|
+
/** The 8px slot under a day number, kept empty without a mark so every number lines up. */
|
|
653
|
+
function DayMark(t0) {
|
|
654
|
+
const $ = c(5);
|
|
655
|
+
const { mark } = t0;
|
|
656
|
+
const check = mark?.check === true ? "success" : mark?.check || void 0;
|
|
657
|
+
const tone = mark?.dots?.[0];
|
|
658
|
+
let t1;
|
|
659
|
+
if ($[0] !== check || $[1] !== tone) {
|
|
660
|
+
t1 = check ? /* @__PURE__ */ jsx("svg", {
|
|
661
|
+
viewBox: "0 0 8 8",
|
|
662
|
+
fill: "none",
|
|
663
|
+
stroke: "currentColor",
|
|
664
|
+
strokeWidth: "1.3",
|
|
665
|
+
strokeLinecap: "round",
|
|
666
|
+
strokeLinejoin: "round",
|
|
667
|
+
className: cn("size-2", checkTones[check]),
|
|
668
|
+
children: /* @__PURE__ */ jsx("path", { d: "M1.5 4.2l1.6 1.6L6.5 2.4" })
|
|
669
|
+
}) : tone && /* @__PURE__ */ jsx("span", { className: cn("size-1.25 rounded-full", markTones[tone]) });
|
|
670
|
+
$[0] = check;
|
|
671
|
+
$[1] = tone;
|
|
672
|
+
$[2] = t1;
|
|
673
|
+
} else t1 = $[2];
|
|
674
|
+
let t2;
|
|
675
|
+
if ($[3] !== t1) {
|
|
676
|
+
t2 = /* @__PURE__ */ jsx("span", {
|
|
677
|
+
"aria-hidden": "true",
|
|
678
|
+
className: "flex size-2 shrink-0 items-center justify-center",
|
|
679
|
+
children: t1
|
|
680
|
+
});
|
|
681
|
+
$[3] = t1;
|
|
682
|
+
$[4] = t2;
|
|
683
|
+
} else t2 = $[4];
|
|
684
|
+
return t2;
|
|
685
|
+
}
|
|
413
686
|
function CalendarDay(t0) {
|
|
414
|
-
const $ = c(
|
|
687
|
+
const $ = c(27);
|
|
688
|
+
let children;
|
|
415
689
|
let className;
|
|
690
|
+
let describedBy;
|
|
416
691
|
let props;
|
|
692
|
+
let value;
|
|
417
693
|
if ($[0] !== t0) {
|
|
418
|
-
({className, ...props} = t0);
|
|
694
|
+
({className, children, value, "aria-describedby": describedBy, ...props} = t0);
|
|
419
695
|
$[0] = t0;
|
|
420
|
-
$[1] =
|
|
421
|
-
$[2] =
|
|
696
|
+
$[1] = children;
|
|
697
|
+
$[2] = className;
|
|
698
|
+
$[3] = describedBy;
|
|
699
|
+
$[4] = props;
|
|
700
|
+
$[5] = value;
|
|
422
701
|
} else {
|
|
423
|
-
|
|
424
|
-
|
|
702
|
+
children = $[1];
|
|
703
|
+
className = $[2];
|
|
704
|
+
describedBy = $[3];
|
|
705
|
+
props = $[4];
|
|
706
|
+
value = $[5];
|
|
425
707
|
}
|
|
708
|
+
const { marks, week, descriptions } = use(CalendarMarksContext);
|
|
426
709
|
let t1;
|
|
427
|
-
if ($[
|
|
428
|
-
t1 =
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
"data-selected:not-data-range-middle:bg-primary data-selected:not-data-range-middle:text-primary-foreground",
|
|
435
|
-
"data-range-start:not-data-range-middle:bg-primary data-range-start:not-data-range-middle:text-primary-foreground data-range-end:not-data-range-middle:bg-primary data-range-end:not-data-range-middle:text-primary-foreground",
|
|
436
|
-
"data-range-start:not-data-range-end:rounded-e-none data-range-end:not-data-range-start:rounded-s-none"
|
|
437
|
-
], className);
|
|
438
|
-
$[3] = className;
|
|
439
|
-
$[4] = t1;
|
|
440
|
-
} else t1 = $[4];
|
|
710
|
+
if ($[6] !== marks || $[7] !== value) {
|
|
711
|
+
t1 = marks?.(value);
|
|
712
|
+
$[6] = marks;
|
|
713
|
+
$[7] = value;
|
|
714
|
+
$[8] = t1;
|
|
715
|
+
} else t1 = $[8];
|
|
716
|
+
const mark = t1;
|
|
441
717
|
let t2;
|
|
442
|
-
if ($[
|
|
443
|
-
t2 =
|
|
444
|
-
|
|
445
|
-
|
|
718
|
+
if ($[9] !== describedBy || $[10] !== descriptions || $[11] !== mark?.description || $[12] !== value) {
|
|
719
|
+
t2 = [mark?.description && descriptions ? `${descriptions}-${value}` : void 0, describedBy].filter(Boolean).join(" ") || void 0;
|
|
720
|
+
$[9] = describedBy;
|
|
721
|
+
$[10] = descriptions;
|
|
722
|
+
$[11] = mark?.description;
|
|
723
|
+
$[12] = value;
|
|
724
|
+
$[13] = t2;
|
|
725
|
+
} else t2 = $[13];
|
|
726
|
+
const description = t2;
|
|
727
|
+
const t3 = week ? weekDay : plainDay;
|
|
728
|
+
let t4;
|
|
729
|
+
if ($[14] !== className || $[15] !== t3) {
|
|
730
|
+
t4 = cnState([
|
|
731
|
+
"relative size-(--cell-size) cursor-default p-0 text-center tabular-nums select-none focus-ring focus-visible:z-10",
|
|
732
|
+
"data-disabled:pointer-events-none data-disabled:opacity-50 data-unavailable:line-through",
|
|
733
|
+
t3
|
|
734
|
+
], className);
|
|
735
|
+
$[14] = className;
|
|
736
|
+
$[15] = t3;
|
|
737
|
+
$[16] = t4;
|
|
738
|
+
} else t4 = $[16];
|
|
739
|
+
let t5;
|
|
740
|
+
if ($[17] !== children || $[18] !== mark || $[19] !== marks) {
|
|
741
|
+
t5 = children ?? (marks ? (state) => /* @__PURE__ */ jsxs("span", {
|
|
742
|
+
className: "flex flex-col items-center gap-0.5",
|
|
743
|
+
children: [/* @__PURE__ */ jsx("span", { children: state.label }), /* @__PURE__ */ jsx(DayMark, { mark })]
|
|
744
|
+
}) : void 0);
|
|
745
|
+
$[17] = children;
|
|
746
|
+
$[18] = mark;
|
|
747
|
+
$[19] = marks;
|
|
748
|
+
$[20] = t5;
|
|
749
|
+
} else t5 = $[20];
|
|
750
|
+
let t6;
|
|
751
|
+
if ($[21] !== description || $[22] !== props || $[23] !== t4 || $[24] !== t5 || $[25] !== value) {
|
|
752
|
+
t6 = /* @__PURE__ */ jsx(CalendarDay$1, {
|
|
753
|
+
value,
|
|
754
|
+
className: t4,
|
|
755
|
+
...props,
|
|
756
|
+
"aria-describedby": description,
|
|
757
|
+
children: t5
|
|
446
758
|
});
|
|
447
|
-
$[
|
|
448
|
-
$[
|
|
449
|
-
$[
|
|
450
|
-
|
|
451
|
-
|
|
759
|
+
$[21] = description;
|
|
760
|
+
$[22] = props;
|
|
761
|
+
$[23] = t4;
|
|
762
|
+
$[24] = t5;
|
|
763
|
+
$[25] = value;
|
|
764
|
+
$[26] = t6;
|
|
765
|
+
} else t6 = $[26];
|
|
766
|
+
return t6;
|
|
452
767
|
}
|
|
453
768
|
export { Calendar, CalendarDay, CalendarGrid, CalendarHeading, CalendarMonthSelect, CalendarNext, CalendarPrevious, CalendarWeekday, CalendarWeekdays, CalendarWeeks, CalendarYearSelect, calendarLayout, calendarParts, createCalendarController };
|