@carlonicora/nextjs-jsonapi 6.18.0 → 6.19.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/{BlockNoteEditor-KSOVYIOL.mjs → BlockNoteEditor-5HSL74IX.mjs} +2 -2
- package/dist/{BlockNoteEditor-HHTAZKRO.js → BlockNoteEditor-6RZXGMSD.js} +9 -9
- package/dist/{BlockNoteEditor-HHTAZKRO.js.map → BlockNoteEditor-6RZXGMSD.js.map} +1 -1
- package/dist/billing/index.js +378 -378
- package/dist/billing/index.mjs +1 -1
- package/dist/{chunk-B6WMZXRY.js → chunk-B4ZH2FOC.js} +343 -307
- package/dist/chunk-B4ZH2FOC.js.map +1 -0
- package/dist/{chunk-MBLF236G.mjs → chunk-HEDHJAKT.mjs} +43 -7
- package/dist/chunk-HEDHJAKT.mjs.map +1 -0
- package/dist/client/index.js +2 -2
- package/dist/client/index.mjs +1 -1
- package/dist/components/index.d.mts +7 -1
- package/dist/components/index.d.ts +7 -1
- package/dist/components/index.js +2 -2
- package/dist/components/index.mjs +1 -1
- package/dist/contexts/index.js +2 -2
- package/dist/contexts/index.mjs +1 -1
- package/dist/email-automations/index.js +78 -78
- package/dist/email-automations/index.mjs +1 -1
- package/dist/features/analytics/index.js +96 -96
- package/dist/features/analytics/index.mjs +1 -1
- package/dist/features/blog/index.js +93 -93
- package/dist/features/blog/index.mjs +1 -1
- package/dist/features/help/index.js +31 -31
- package/dist/features/help/index.mjs +1 -1
- package/dist/features/tokenusage/index.js +102 -102
- package/dist/features/tokenusage/index.mjs +1 -1
- package/package.json +1 -1
- package/src/components/forms/FormDateTime.tsx +55 -3
- package/dist/chunk-B6WMZXRY.js.map +0 -1
- package/dist/chunk-MBLF236G.mjs.map +0 -1
- /package/dist/{BlockNoteEditor-KSOVYIOL.mjs.map → BlockNoteEditor-5HSL74IX.mjs.map} +0 -0
|
@@ -19,6 +19,13 @@ import {
|
|
|
19
19
|
import { cn } from "../../utils";
|
|
20
20
|
import { FormFieldWrapper } from "./FormFieldWrapper";
|
|
21
21
|
|
|
22
|
+
// Unwrapped rounding: setMinutes(60) carries into the hour, so 10:58 becomes 11:00
|
|
23
|
+
function snapToFiveMinutes(date: Date): Date {
|
|
24
|
+
const snapped = new Date(date);
|
|
25
|
+
snapped.setMinutes(Math.round(snapped.getMinutes() / 5) * 5, 0, 0);
|
|
26
|
+
return snapped;
|
|
27
|
+
}
|
|
28
|
+
|
|
22
29
|
export function FormDateTime({
|
|
23
30
|
form,
|
|
24
31
|
id,
|
|
@@ -30,6 +37,8 @@ export function FormDateTime({
|
|
|
30
37
|
placeholder,
|
|
31
38
|
isRequired,
|
|
32
39
|
description,
|
|
40
|
+
reference,
|
|
41
|
+
markedDate,
|
|
33
42
|
}: {
|
|
34
43
|
form: any;
|
|
35
44
|
id: string;
|
|
@@ -41,6 +50,10 @@ export function FormDateTime({
|
|
|
41
50
|
defaultMonth?: Date;
|
|
42
51
|
isRequired?: boolean;
|
|
43
52
|
description?: string;
|
|
53
|
+
// `date` alone: ring on the day, month fallback, empty-field initial time; no row.
|
|
54
|
+
// `label` renders the "label: date" row; `actionLabel` adds the button inside that row (ignored without `label`).
|
|
55
|
+
reference?: { date: Date; label?: string; actionLabel?: string };
|
|
56
|
+
markedDate?: Date;
|
|
44
57
|
}) {
|
|
45
58
|
const [open, setOpen] = useState<boolean>(false);
|
|
46
59
|
const t = useI18nTranslations();
|
|
@@ -49,7 +62,7 @@ export function FormDateTime({
|
|
|
49
62
|
|
|
50
63
|
const [displayMonth, setDisplayMonth] = useState<Date>(() => {
|
|
51
64
|
const currentValue = form.getValues(id);
|
|
52
|
-
return currentValue || defaultMonth || new Date();
|
|
65
|
+
return currentValue || defaultMonth || reference?.date || new Date();
|
|
53
66
|
});
|
|
54
67
|
|
|
55
68
|
// Locale-aware date-time formatter
|
|
@@ -69,8 +82,23 @@ export function FormDateTime({
|
|
|
69
82
|
// Format date-time for display
|
|
70
83
|
const formatDateTime = (date: Date): string => dateTimeFormatter.format(date);
|
|
71
84
|
|
|
72
|
-
|
|
73
|
-
|
|
85
|
+
// An empty field starts its time selects at the reference "now" when one is given
|
|
86
|
+
// Snapped as an instant (not by wrapping minutes) so 10:58 starts at 11:00
|
|
87
|
+
const initialTime = reference ? snapToFiveMinutes(reference.date) : new Date();
|
|
88
|
+
const [selectedHours, setSelectedHours] = useState<number>(initialTime.getHours());
|
|
89
|
+
const [selectedMinutes, setSelectedMinutes] = useState<number>(roundToNearestFiveMinutes(initialTime.getMinutes()));
|
|
90
|
+
|
|
91
|
+
const dayModifiers = {
|
|
92
|
+
...(reference ? { reference: reference.date } : {}),
|
|
93
|
+
...(markedDate ? { marked: markedDate } : {}),
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// Reference = outlined ring (offset so it stays visible around the selected fill);
|
|
97
|
+
// marked = underline on the day number. Both differ from today's bg-muted.
|
|
98
|
+
const dayModifiersClassNames = {
|
|
99
|
+
reference: "rounded-(--cell-radius) ring-1 ring-primary ring-offset-1 ring-offset-background",
|
|
100
|
+
marked: "[&>button]:underline [&>button]:decoration-2 [&>button]:underline-offset-4",
|
|
101
|
+
};
|
|
74
102
|
|
|
75
103
|
const hoursOptions = Array.from({ length: 24 }, (_, i) => {
|
|
76
104
|
const hour = i;
|
|
@@ -95,6 +123,16 @@ export function FormDateTime({
|
|
|
95
123
|
return (Math.round(minutes / 5) * 5) % 60;
|
|
96
124
|
}
|
|
97
125
|
|
|
126
|
+
const handleUseReference = () => {
|
|
127
|
+
if (!reference) return;
|
|
128
|
+
const referenceDate = snapToFiveMinutes(reference.date);
|
|
129
|
+
form.setValue(id, referenceDate);
|
|
130
|
+
if (onChange) onChange(referenceDate);
|
|
131
|
+
setDisplayMonth(referenceDate);
|
|
132
|
+
setSelectedHours(referenceDate.getHours());
|
|
133
|
+
setSelectedMinutes(referenceDate.getMinutes());
|
|
134
|
+
};
|
|
135
|
+
|
|
98
136
|
const handleTimeChange = (hours: number, minutes: number) => {
|
|
99
137
|
const currentDate = form.getValues(id);
|
|
100
138
|
if (currentDate) {
|
|
@@ -170,7 +208,21 @@ export function FormDateTime({
|
|
|
170
208
|
weekStartsOn={1}
|
|
171
209
|
startMonth={new Date(1900, 0)}
|
|
172
210
|
endMonth={new Date(new Date().getFullYear() + 10, 11)}
|
|
211
|
+
modifiers={dayModifiers}
|
|
212
|
+
modifiersClassNames={dayModifiersClassNames}
|
|
173
213
|
/>
|
|
214
|
+
{reference?.label && (
|
|
215
|
+
<div className="flex flex-row items-center justify-between gap-x-4 border-t pt-4">
|
|
216
|
+
<span className="text-muted-foreground text-sm">
|
|
217
|
+
{reference.label}: {formatDateTime(reference.date)}
|
|
218
|
+
</span>
|
|
219
|
+
{reference.actionLabel && (
|
|
220
|
+
<Button type="button" variant="outline" size="sm" onClick={handleUseReference}>
|
|
221
|
+
{reference.actionLabel}
|
|
222
|
+
</Button>
|
|
223
|
+
)}
|
|
224
|
+
</div>
|
|
225
|
+
)}
|
|
174
226
|
<div className="flex flex-row items-end justify-center space-x-4">
|
|
175
227
|
<div className="flex flex-col space-y-2">
|
|
176
228
|
<Label htmlFor="hours-select">{t(`common.hours`)}</Label>
|