@asanchez-sa/abby 0.2.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/alert/alert.d.ts +1 -1
- package/dist/components/alert/alert.js +2 -1
- package/dist/components/alert-dialog/alert-dialog.d.ts +10 -1
- package/dist/components/alert-dialog/alert-dialog.js +80 -3
- package/dist/components/badge/badge.d.ts +3 -2
- package/dist/components/badge/badge.js +27 -11
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.js +3 -2
- 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/dialog/dialog.d.ts +9 -1
- package/dist/components/dialog/dialog.js +82 -3
- package/dist/components/field/field.d.ts +5 -1
- package/dist/components/field/field.js +25 -21
- 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/input/input.d.ts +8 -1
- package/dist/components/input/input.js +2 -2
- package/dist/components/meter/meter.d.ts +52 -3
- package/dist/components/meter/meter.js +535 -33
- package/dist/components/model-selector/model-selector.d.ts +38 -3
- package/dist/components/model-selector/model-selector.js +331 -73
- package/dist/components/note-editor/parts/suggestions.js +2 -2
- package/dist/components/number-input/number-input.d.ts +14 -3
- package/dist/components/number-input/number-input.js +193 -34
- package/dist/components/otp-input/otp-input.d.ts +6 -2
- package/dist/components/otp-input/otp-input.js +40 -20
- package/dist/components/sheet/sheet.js +1 -1
- package/dist/components/spinner/spinner.d.ts +7 -1
- package/dist/components/spinner/spinner.js +86 -26
- package/dist/components/switch/switch.d.ts +9 -2
- package/dist/components/switch/switch.js +23 -17
- 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 +97 -10
- 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
|
@@ -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 };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ChartFrameProps } from "./parts/frame.js";
|
|
2
|
+
import { ChartColor, ChartRow, ChartSeries, ChartToken } from "./parts/types.js";
|
|
3
|
+
import { ChartLegend } from "./parts/legend.js";
|
|
4
|
+
type BarChartProps = ChartFrameProps & {
|
|
5
|
+
/**
|
|
6
|
+
* Stacks the series in one bar per category, the first at the bottom. With a
|
|
7
|
+
* single series it draws the same as without it.
|
|
8
|
+
*/
|
|
9
|
+
stacked?: boolean;
|
|
10
|
+
/** Shows each category's sum over its bar, and in the table when stacked. */
|
|
11
|
+
totals?: boolean;
|
|
12
|
+
/** A short text beside one bar, like "7 por cerrar". */
|
|
13
|
+
note?: {
|
|
14
|
+
/** The category it belongs to: its `id` or `label`. */
|
|
15
|
+
category: string;
|
|
16
|
+
text: string;
|
|
17
|
+
/** Defaults to `muted-foreground`. */
|
|
18
|
+
color?: ChartColor;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Bars by day or by week: one column per category, one bar per series in it,
|
|
23
|
+
* in the order of `series`. `highlight` names the current category (today, this
|
|
24
|
+
* week): its bars take the full color and the rest their faint tint. A series
|
|
25
|
+
* with `variant: "forecast"` is drawn as an outline in the column of the first
|
|
26
|
+
* series.
|
|
27
|
+
*
|
|
28
|
+
* Each bar is an image named "category: value" that shows the same text in a
|
|
29
|
+
* tooltip on hover and focus; the chart is one tab stop and the arrows move
|
|
30
|
+
* between bars. A table for a screen reader holds all the values. The chart's
|
|
31
|
+
* name (`aria-label` or `aria-labelledby`) is required.
|
|
32
|
+
*/
|
|
33
|
+
declare function BarChart({ series, data, highlight, stacked, totals, note, ...props }: BarChartProps): import("react").JSX.Element;
|
|
34
|
+
type LineReference = {
|
|
35
|
+
/** Where the line goes, in the chart's own unit. */
|
|
36
|
+
value: number;
|
|
37
|
+
/** The text at the line's start. Defaults to the value, formatted. */
|
|
38
|
+
label?: string;
|
|
39
|
+
/** Defaults to `border`, a hairline. */
|
|
40
|
+
color?: ChartColor;
|
|
41
|
+
};
|
|
42
|
+
type LineChartProps = ChartFrameProps & {
|
|
43
|
+
/**
|
|
44
|
+
* Which points get a dot and their value: `ends` the first and the last,
|
|
45
|
+
* `last` only the last. A small chart always marks only the last.
|
|
46
|
+
*/
|
|
47
|
+
mark?: "ends" | "last";
|
|
48
|
+
/** Horizontal lines to compare against, each with its label at the start. */
|
|
49
|
+
references?: LineReference[];
|
|
50
|
+
/**
|
|
51
|
+
* `sm` is a chart to put side by side with others: no axes and no grid, only
|
|
52
|
+
* the line with its last point and its value to the right.
|
|
53
|
+
*/
|
|
54
|
+
size?: "default" | "sm";
|
|
55
|
+
/**
|
|
56
|
+
* The scale's minimum and maximum, used exactly. Charts that get the same
|
|
57
|
+
* `domain` (and `height`) draw the same value at the same height. Without it
|
|
58
|
+
* the scale runs from 0 to a round number above the largest value.
|
|
59
|
+
*/
|
|
60
|
+
domain?: [number, number];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* A trend by day or by week: one line over one series, one point per
|
|
64
|
+
* category. `mark` dots the first and last points and writes their values;
|
|
65
|
+
* `references` draws lines to compare against; `size="sm"` is the small chart
|
|
66
|
+
* for a grid of them, which get the same scale from `domain`. A missing value
|
|
67
|
+
* breaks the line.
|
|
68
|
+
*
|
|
69
|
+
* Like `BarChart`, each point is an image named "category: value" with the
|
|
70
|
+
* same text in a tooltip on hover and focus, the chart is one tab stop and the
|
|
71
|
+
* arrows move between points, and a table holds all the values. The chart's
|
|
72
|
+
* name (`aria-label` or `aria-labelledby`) is required. Only the first series
|
|
73
|
+
* is drawn: a chart has one line.
|
|
74
|
+
*/
|
|
75
|
+
declare function LineChart({ series, data, highlight, mark, references, size, domain, height, ...props }: LineChartProps): import("react").JSX.Element;
|
|
76
|
+
export { BarChart, type BarChartProps, type ChartColor, ChartLegend, type ChartRow, type ChartSeries, type ChartToken, LineChart, type LineChartProps, type LineReference };
|