@carlonicora/nextjs-jsonapi 6.17.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.
Files changed (34) hide show
  1. package/dist/{BlockNoteEditor-IGUHTERQ.mjs → BlockNoteEditor-5HSL74IX.mjs} +2 -2
  2. package/dist/{BlockNoteEditor-FAUTV5FW.js → BlockNoteEditor-6RZXGMSD.js} +9 -9
  3. package/dist/{BlockNoteEditor-FAUTV5FW.js.map → BlockNoteEditor-6RZXGMSD.js.map} +1 -1
  4. package/dist/billing/index.js +378 -378
  5. package/dist/billing/index.mjs +1 -1
  6. package/dist/{chunk-4OCBNCKH.js → chunk-B4ZH2FOC.js} +359 -308
  7. package/dist/chunk-B4ZH2FOC.js.map +1 -0
  8. package/dist/{chunk-RINMQQZH.mjs → chunk-HEDHJAKT.mjs} +59 -8
  9. package/dist/chunk-HEDHJAKT.mjs.map +1 -0
  10. package/dist/client/index.js +2 -2
  11. package/dist/client/index.mjs +1 -1
  12. package/dist/components/index.d.mts +13 -2
  13. package/dist/components/index.d.ts +13 -2
  14. package/dist/components/index.js +2 -2
  15. package/dist/components/index.mjs +1 -1
  16. package/dist/contexts/index.js +2 -2
  17. package/dist/contexts/index.mjs +1 -1
  18. package/dist/email-automations/index.js +78 -78
  19. package/dist/email-automations/index.mjs +1 -1
  20. package/dist/features/analytics/index.js +96 -96
  21. package/dist/features/analytics/index.mjs +1 -1
  22. package/dist/features/blog/index.js +93 -93
  23. package/dist/features/blog/index.mjs +1 -1
  24. package/dist/features/help/index.js +31 -31
  25. package/dist/features/help/index.mjs +1 -1
  26. package/dist/features/tokenusage/index.js +102 -102
  27. package/dist/features/tokenusage/index.mjs +1 -1
  28. package/package.json +1 -1
  29. package/src/components/forms/EditorSheet.tsx +21 -1
  30. package/src/components/forms/FormDateTime.tsx +55 -3
  31. package/src/components/forms/__tests__/EditorSheet.spec.tsx +40 -1
  32. package/dist/chunk-4OCBNCKH.js.map +0 -1
  33. package/dist/chunk-RINMQQZH.mjs.map +0 -1
  34. /package/dist/{BlockNoteEditor-IGUHTERQ.mjs.map → BlockNoteEditor-5HSL74IX.mjs.map} +0 -0
@@ -10147,6 +10147,7 @@ var sizeClasses = {
10147
10147
  function EditorSheet({
10148
10148
  form,
10149
10149
  onSubmit,
10150
+ onBeforeSubmit,
10150
10151
  onReset,
10151
10152
  isFormDirty: isFormDirtyProp,
10152
10153
  entityType,
@@ -10205,6 +10206,7 @@ function EditorSheet({
10205
10206
  const wrappedOnSubmit = useCallback17(
10206
10207
  async (values) => {
10207
10208
  try {
10209
+ if (onBeforeSubmit && !await onBeforeSubmit(values)) return;
10208
10210
  const result = await onSubmit(values);
10209
10211
  setOpen(false);
10210
10212
  if (result && onSaved) {
@@ -10227,7 +10229,20 @@ function EditorSheet({
10227
10229
  });
10228
10230
  }
10229
10231
  },
10230
- [onSubmit, setOpen, onSuccess, onSaved, onRevalidate, onNavigate, generateUrl, module, isEdit, propagateChanges, t]
10232
+ [
10233
+ onSubmit,
10234
+ onBeforeSubmit,
10235
+ setOpen,
10236
+ onSuccess,
10237
+ onSaved,
10238
+ onRevalidate,
10239
+ onNavigate,
10240
+ generateUrl,
10241
+ module,
10242
+ isEdit,
10243
+ propagateChanges,
10244
+ t
10245
+ ]
10231
10246
  );
10232
10247
  const headerTitle = titleOverride ?? (isEdit ? t("common.edit.update.title", { type: entityType }) : t("common.edit.create.title", { type: entityType }));
10233
10248
  const headerDescription = descriptionOverride ?? (isEdit ? t("common.edit.update.description", { type: entityType, name: entityName2 ?? "" }) : t("common.edit.create.description", { type: entityType }));
@@ -10852,7 +10867,7 @@ import { useRef as useRef18 } from "react";
10852
10867
  import dynamic from "next/dynamic";
10853
10868
  import React18 from "react";
10854
10869
  import { jsx as jsx91 } from "react/jsx-runtime";
10855
- var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-IGUHTERQ.mjs"), {
10870
+ var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-5HSL74IX.mjs"), {
10856
10871
  ssr: false
10857
10872
  });
10858
10873
  var BlockNoteEditorContainer = React18.memo(/* @__PURE__ */ __name(function EditorContainer(props) {
@@ -11138,6 +11153,12 @@ __name(FormDate, "FormDate");
11138
11153
  import { Calendar as CalendarIcon4, CircleXIcon as CircleXIcon3 } from "lucide-react";
11139
11154
  import { useMemo as useMemo15, useState as useState28 } from "react";
11140
11155
  import { jsx as jsx95, jsxs as jsxs54 } from "react/jsx-runtime";
11156
+ function snapToFiveMinutes(date) {
11157
+ const snapped = new Date(date);
11158
+ snapped.setMinutes(Math.round(snapped.getMinutes() / 5) * 5, 0, 0);
11159
+ return snapped;
11160
+ }
11161
+ __name(snapToFiveMinutes, "snapToFiveMinutes");
11141
11162
  function FormDateTime({
11142
11163
  form,
11143
11164
  id,
@@ -11148,7 +11169,9 @@ function FormDateTime({
11148
11169
  defaultMonth,
11149
11170
  placeholder,
11150
11171
  isRequired,
11151
- description
11172
+ description,
11173
+ reference,
11174
+ markedDate
11152
11175
  }) {
11153
11176
  const [open, setOpen] = useState28(false);
11154
11177
  const t = useI18nTranslations();
@@ -11156,7 +11179,7 @@ function FormDateTime({
11156
11179
  const dateFnsLocale = useI18nDateFnsLocale();
11157
11180
  const [displayMonth, setDisplayMonth] = useState28(() => {
11158
11181
  const currentValue = form.getValues(id);
11159
- return currentValue || defaultMonth || /* @__PURE__ */ new Date();
11182
+ return currentValue || defaultMonth || reference?.date || /* @__PURE__ */ new Date();
11160
11183
  });
11161
11184
  const dateTimeFormatter = useMemo15(
11162
11185
  () => new Intl.DateTimeFormat(locale, {
@@ -11170,8 +11193,17 @@ function FormDateTime({
11170
11193
  [locale]
11171
11194
  );
11172
11195
  const formatDateTime = /* @__PURE__ */ __name((date) => dateTimeFormatter.format(date), "formatDateTime");
11173
- const [selectedHours, setSelectedHours] = useState28((/* @__PURE__ */ new Date()).getHours());
11174
- const [selectedMinutes, setSelectedMinutes] = useState28(roundToNearestFiveMinutes((/* @__PURE__ */ new Date()).getMinutes()));
11196
+ const initialTime = reference ? snapToFiveMinutes(reference.date) : /* @__PURE__ */ new Date();
11197
+ const [selectedHours, setSelectedHours] = useState28(initialTime.getHours());
11198
+ const [selectedMinutes, setSelectedMinutes] = useState28(roundToNearestFiveMinutes(initialTime.getMinutes()));
11199
+ const dayModifiers = {
11200
+ ...reference ? { reference: reference.date } : {},
11201
+ ...markedDate ? { marked: markedDate } : {}
11202
+ };
11203
+ const dayModifiersClassNames = {
11204
+ reference: "rounded-(--cell-radius) ring-1 ring-primary ring-offset-1 ring-offset-background",
11205
+ marked: "[&>button]:underline [&>button]:decoration-2 [&>button]:underline-offset-4"
11206
+ };
11175
11207
  const hoursOptions = Array.from({ length: 24 }, (_, i) => {
11176
11208
  const hour = i;
11177
11209
  return {
@@ -11192,6 +11224,15 @@ function FormDateTime({
11192
11224
  return Math.round(minutes / 5) * 5 % 60;
11193
11225
  }
11194
11226
  __name(roundToNearestFiveMinutes, "roundToNearestFiveMinutes");
11227
+ const handleUseReference = /* @__PURE__ */ __name(() => {
11228
+ if (!reference) return;
11229
+ const referenceDate = snapToFiveMinutes(reference.date);
11230
+ form.setValue(id, referenceDate);
11231
+ if (onChange) onChange(referenceDate);
11232
+ setDisplayMonth(referenceDate);
11233
+ setSelectedHours(referenceDate.getHours());
11234
+ setSelectedMinutes(referenceDate.getMinutes());
11235
+ }, "handleUseReference");
11195
11236
  const handleTimeChange = /* @__PURE__ */ __name((hours, minutes) => {
11196
11237
  const currentDate = form.getValues(id);
11197
11238
  if (currentDate) {
@@ -11260,9 +11301,19 @@ function FormDateTime({
11260
11301
  locale: dateFnsLocale,
11261
11302
  weekStartsOn: 1,
11262
11303
  startMonth: new Date(1900, 0),
11263
- endMonth: new Date((/* @__PURE__ */ new Date()).getFullYear() + 10, 11)
11304
+ endMonth: new Date((/* @__PURE__ */ new Date()).getFullYear() + 10, 11),
11305
+ modifiers: dayModifiers,
11306
+ modifiersClassNames: dayModifiersClassNames
11264
11307
  }
11265
11308
  ),
11309
+ reference?.label && /* @__PURE__ */ jsxs54("div", { className: "flex flex-row items-center justify-between gap-x-4 border-t pt-4", children: [
11310
+ /* @__PURE__ */ jsxs54("span", { className: "text-muted-foreground text-sm", children: [
11311
+ reference.label,
11312
+ ": ",
11313
+ formatDateTime(reference.date)
11314
+ ] }),
11315
+ reference.actionLabel && /* @__PURE__ */ jsx95(Button, { type: "button", variant: "outline", size: "sm", onClick: handleUseReference, children: reference.actionLabel })
11316
+ ] }),
11266
11317
  /* @__PURE__ */ jsxs54("div", { className: "flex flex-row items-end justify-center space-x-4", children: [
11267
11318
  /* @__PURE__ */ jsxs54("div", { className: "flex flex-col space-y-2", children: [
11268
11319
  /* @__PURE__ */ jsx95(Label, { htmlFor: "hours-select", children: t(`common.hours`) }),
@@ -30830,4 +30881,4 @@ export {
30830
30881
  useOAuthClients,
30831
30882
  useOAuthClient
30832
30883
  };
30833
- //# sourceMappingURL=chunk-RINMQQZH.mjs.map
30884
+ //# sourceMappingURL=chunk-HEDHJAKT.mjs.map