@carlonicora/nextjs-jsonapi 1.97.2 → 1.98.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 (33) hide show
  1. package/dist/{BlockNoteEditor-OOZGXU6E.js → BlockNoteEditor-3SXAMY6O.js} +9 -9
  2. package/dist/{BlockNoteEditor-OOZGXU6E.js.map → BlockNoteEditor-3SXAMY6O.js.map} +1 -1
  3. package/dist/{BlockNoteEditor-LRJUTHTW.mjs → BlockNoteEditor-HWQHTLEB.mjs} +2 -2
  4. package/dist/billing/index.js +299 -299
  5. package/dist/billing/index.mjs +1 -1
  6. package/dist/{chunk-HCOX3PKM.js → chunk-S5LH5422.js} +360 -262
  7. package/dist/chunk-S5LH5422.js.map +1 -0
  8. package/dist/{chunk-XYGK26YG.mjs → chunk-TLTENUI6.mjs} +141 -43
  9. package/dist/chunk-TLTENUI6.mjs.map +1 -0
  10. package/dist/client/index.d.mts +4 -2
  11. package/dist/client/index.d.ts +4 -2
  12. package/dist/client/index.js +2 -2
  13. package/dist/client/index.mjs +1 -1
  14. package/dist/components/index.d.mts +5 -2
  15. package/dist/components/index.d.ts +5 -2
  16. package/dist/components/index.js +2 -2
  17. package/dist/components/index.mjs +1 -1
  18. package/dist/{content.fields-hzZvhlBd.d.mts → content.fields-xH3TGvVk.d.mts} +2 -0
  19. package/dist/{content.fields-hzZvhlBd.d.ts → content.fields-xH3TGvVk.d.ts} +2 -0
  20. package/dist/contexts/index.js +2 -2
  21. package/dist/contexts/index.mjs +1 -1
  22. package/dist/core/index.d.mts +1 -1
  23. package/dist/core/index.d.ts +1 -1
  24. package/dist/index.d.mts +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/package.json +1 -1
  27. package/src/components/forms/FormDate.tsx +27 -3
  28. package/src/components/forms/FormDateTime.tsx +40 -8
  29. package/src/hooks/useCustomD3Graph.tsx +91 -10
  30. package/src/interfaces/d3.node.interface.ts +2 -0
  31. package/dist/chunk-HCOX3PKM.js.map +0 -1
  32. package/dist/chunk-XYGK26YG.mjs.map +0 -1
  33. /package/dist/{BlockNoteEditor-LRJUTHTW.mjs.map → BlockNoteEditor-HWQHTLEB.mjs.map} +0 -0
@@ -6455,7 +6455,7 @@ import { Loader2 as Loader22 } from "lucide-react";
6455
6455
  import { useCallback as useCallback9, useEffect as useEffect8, useMemo as useMemo8, useRef as useRef8 } from "react";
6456
6456
  import { renderToStaticMarkup } from "react-dom/server";
6457
6457
  import { jsx as jsx49 } from "react/jsx-runtime";
6458
- function useCustomD3Graph(nodes, links, onNodeClick, visibleNodeIds, loadingNodeIds, containerKey) {
6458
+ function useCustomD3Graph(nodes, links, onNodeClick, visibleNodeIds, options, loadingNodeIds, containerKey) {
6459
6459
  const svgRef = useRef8(null);
6460
6460
  const zoomRef = useRef8(null);
6461
6461
  const zoomBehaviorRef = useRef8(null);
@@ -6543,6 +6543,9 @@ function useCustomD3Graph(nodes, links, onNodeClick, visibleNodeIds, loadingNode
6543
6543
  }, []);
6544
6544
  const getNodeColor = useCallback9(
6545
6545
  (node) => {
6546
+ if (node.color) {
6547
+ return node.washedOut ? washOutColor(node.color) : node.color;
6548
+ }
6546
6549
  const baseColor = colorScale.get(node.instanceType) || "gray";
6547
6550
  if (node.washedOut) {
6548
6551
  return washOutColor(baseColor);
@@ -6568,6 +6571,12 @@ function useCustomD3Graph(nodes, links, onNodeClick, visibleNodeIds, loadingNode
6568
6571
  const height = container.clientHeight;
6569
6572
  svg.attr("width", width).attr("height", height).attr("viewBox", `0 0 ${width} ${height}`);
6570
6573
  const graphGroup = svg.append("g").attr("class", "graph-content");
6574
+ const nodeRadius = 40;
6575
+ const directed = options?.directed === true;
6576
+ if (directed) {
6577
+ const defs = svg.append("defs");
6578
+ defs.append("marker").attr("id", "narr8-arrow").attr("viewBox", "-10 -10 20 20").attr("markerWidth", 14).attr("markerHeight", 14).attr("markerUnits", "userSpaceOnUse").attr("orient", "auto").attr("refX", 0).attr("refY", 0).append("path").attr("d", "M-10,-10 L0,0 L-10,10 z").attr("fill", "#999");
6579
+ }
6571
6580
  const zoom2 = d3.zoom().scaleExtent([0.1, 4]).on("zoom", (event) => {
6572
6581
  const transform = event.transform;
6573
6582
  graphGroup.attr("transform", transform.toString());
@@ -6575,7 +6584,6 @@ function useCustomD3Graph(nodes, links, onNodeClick, visibleNodeIds, loadingNode
6575
6584
  });
6576
6585
  zoomBehaviorRef.current = zoom2;
6577
6586
  svg.call(zoom2).on("wheel.zoom", null).on("dblclick.zoom", null);
6578
- const nodeRadius = 40;
6579
6587
  const childDistanceFromRoot = Math.min(width, height) * 0.4;
6580
6588
  const grandchildDistanceFromChild = nodeRadius * 10;
6581
6589
  const centralNodeId = nodes[0].id;
@@ -6687,7 +6695,29 @@ function useCustomD3Graph(nodes, links, onNodeClick, visibleNodeIds, loadingNode
6687
6695
  node2.fy = node2.y;
6688
6696
  }
6689
6697
  });
6690
- const link = graphGroup.append("g").attr("stroke", "#999").attr("stroke-opacity", 0.6).selectAll("line").data(visibleLinks).join("line").attr("x1", (d) => d.source.x || 0).attr("y1", (d) => d.source.y || 0).attr("x2", (d) => d.target.x || 0).attr("y2", (d) => d.target.y || 0).attr("stroke-width", 1.5);
6698
+ const linkX2 = /* @__PURE__ */ __name((sx, sy, tx, ty) => {
6699
+ if (!directed) return tx;
6700
+ const dx = tx - sx;
6701
+ const dy = ty - sy;
6702
+ const dist = Math.sqrt(dx * dx + dy * dy) || 1;
6703
+ return tx - dx / dist * nodeRadius;
6704
+ }, "linkX2");
6705
+ const linkY2 = /* @__PURE__ */ __name((sx, sy, tx, ty) => {
6706
+ if (!directed) return ty;
6707
+ const dx = tx - sx;
6708
+ const dy = ty - sy;
6709
+ const dist = Math.sqrt(dx * dx + dy * dy) || 1;
6710
+ return ty - dy / dist * nodeRadius;
6711
+ }, "linkY2");
6712
+ const link = graphGroup.append("g").attr("stroke", "#999").attr("stroke-opacity", 0.6).selectAll("line").data(visibleLinks).join("line").attr("x1", (d) => d.source.x || 0).attr("y1", (d) => d.source.y || 0).attr("x2", (d) => {
6713
+ const s = d.source;
6714
+ const t = d.target;
6715
+ return linkX2(s.x || 0, s.y || 0, t.x || 0, t.y || 0);
6716
+ }).attr("y2", (d) => {
6717
+ const s = d.source;
6718
+ const t = d.target;
6719
+ return linkY2(s.x || 0, s.y || 0, t.x || 0, t.y || 0);
6720
+ }).attr("stroke-width", 1.5).attr("marker-end", directed ? "url(#narr8-arrow)" : null);
6691
6721
  const node = graphGroup.append("g").selectAll("g").data(visibleNodes).join("g").attr("class", "node-group").attr("data-id", (d) => d.id).attr("cursor", "pointer").attr("transform", (d) => `translate(${d.x || 0}, ${d.y || 0})`).call(
6692
6722
  d3.drag().subject(function(d) {
6693
6723
  return d;
@@ -6707,11 +6737,21 @@ function useCustomD3Graph(nodes, links, onNodeClick, visibleNodeIds, loadingNode
6707
6737
  const source = l.source;
6708
6738
  return source.fy || source.y || 0;
6709
6739
  }).attr("x2", (l) => {
6740
+ const source = l.source;
6710
6741
  const target = l.target;
6711
- return target.fx || target.x || 0;
6742
+ const sx = source.fx || source.x || 0;
6743
+ const sy = source.fy || source.y || 0;
6744
+ const tx = target.fx || target.x || 0;
6745
+ const ty = target.fy || target.y || 0;
6746
+ return linkX2(sx, sy, tx, ty);
6712
6747
  }).attr("y2", (l) => {
6748
+ const source = l.source;
6713
6749
  const target = l.target;
6714
- return target.fy || target.y || 0;
6750
+ const sx = source.fx || source.x || 0;
6751
+ const sy = source.fy || source.y || 0;
6752
+ const tx = target.fx || target.x || 0;
6753
+ const ty = target.fy || target.y || 0;
6754
+ return linkY2(sx, sy, tx, ty);
6715
6755
  });
6716
6756
  }).on("end", function(event, d) {
6717
6757
  d.fx = event.x;
@@ -6732,7 +6772,7 @@ function useCustomD3Graph(nodes, links, onNodeClick, visibleNodeIds, loadingNode
6732
6772
  if (d.instanceType === "root") return;
6733
6773
  const currentNode = d3.select(this);
6734
6774
  currentNode.select("circle").transition().duration(250).ease(d3.easeExpOut).attr("r", nodeRadius).attr("filter", null);
6735
- const normalOffset = nodeRadius + 5;
6775
+ const normalOffset = nodeRadius + 5 + (d.subtitle ? 16 : 0);
6736
6776
  currentNode.select("text").transition().duration(250).ease(d3.easeExpOut).attr("dy", -normalOffset).attr("transform", `translate(0, ${-normalOffset}) scale(1) translate(0, ${normalOffset})`);
6737
6777
  });
6738
6778
  node.append("circle").attr("r", nodeRadius).attr("fill", (d) => getNodeColor(d)).attr("stroke", "#fff").attr("stroke-width", 1.5).on("click", (event, d) => {
@@ -6784,6 +6824,13 @@ function useCustomD3Graph(nodes, links, onNodeClick, visibleNodeIds, loadingNode
6784
6824
  words.forEach((word, index) => {
6785
6825
  textElement.append("tspan").attr("x", 0).attr("dy", index === 0 ? `${startY}em` : `${lineHeight}em`).text(word);
6786
6826
  });
6827
+ } else if (d.subtitle) {
6828
+ const titleSize = 16;
6829
+ const subtitleSize = 11;
6830
+ const lineGap = titleSize;
6831
+ textElement.attr("dy", -nodeRadius - 5 - lineGap).attr("fill", "currentColor");
6832
+ textElement.append("tspan").attr("x", 0).attr("font-size", titleSize).attr("font-weight", 700).text(d.name);
6833
+ textElement.append("tspan").attr("x", 0).attr("dy", lineGap).attr("font-size", subtitleSize).attr("fill-opacity", 0.7).text(d.subtitle);
6787
6834
  } else {
6788
6835
  textElement.attr("dy", -nodeRadius - 5).attr("fill", "currentColor").attr("font-size", d.bold ? 16 : 12).attr("font-weight", d.bold ? 700 : null).text(d.name);
6789
6836
  }
@@ -6791,7 +6838,7 @@ function useCustomD3Graph(nodes, links, onNodeClick, visibleNodeIds, loadingNode
6791
6838
  return () => {
6792
6839
  simulation.stop();
6793
6840
  };
6794
- }, [nodes, links, colorScale, visibleNodeIds, loadingNodeIds, onNodeClick]);
6841
+ }, [nodes, links, colorScale, visibleNodeIds, options?.directed, loadingNodeIds, onNodeClick]);
6795
6842
  const zoomIn = useCallback9(() => {
6796
6843
  if (!svgRef.current || !zoomBehaviorRef.current) return;
6797
6844
  const svg = d3.select(svgRef.current);
@@ -9226,7 +9273,7 @@ import { useRef as useRef15 } from "react";
9226
9273
  import dynamic from "next/dynamic";
9227
9274
  import React14 from "react";
9228
9275
  import { jsx as jsx73 } from "react/jsx-runtime";
9229
- var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-LRJUTHTW.mjs"), {
9276
+ var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-HWQHTLEB.mjs"), {
9230
9277
  ssr: false
9231
9278
  });
9232
9279
  var BlockNoteEditorContainer = React14.memo(/* @__PURE__ */ __name(function EditorContainer(props) {
@@ -9325,14 +9372,17 @@ function FormDate({
9325
9372
  name,
9326
9373
  minDate,
9327
9374
  onChange,
9328
- isRequired = false
9375
+ isRequired = false,
9376
+ defaultMonth,
9377
+ allowEmpty
9329
9378
  }) {
9379
+ const t = useI18nTranslations();
9330
9380
  const locale = useI18nLocale();
9331
9381
  const dateFnsLocale = useI18nDateFnsLocale();
9332
9382
  const [open, setOpen] = useState21(false);
9333
9383
  const [displayMonth, setDisplayMonth] = useState21(() => {
9334
9384
  const currentValue = form.getValues(id);
9335
- return currentValue || /* @__PURE__ */ new Date();
9385
+ return currentValue || defaultMonth || /* @__PURE__ */ new Date();
9336
9386
  });
9337
9387
  const dateFormatter = useMemo12(
9338
9388
  () => new Intl.DateTimeFormat(locale, { day: "2-digit", month: "2-digit", year: "numeric" }),
@@ -9395,7 +9445,7 @@ function FormDate({
9395
9445
  ),
9396
9446
  /* @__PURE__ */ jsxs44(InputGroupAddon, { align: "inline-end", children: [
9397
9447
  /* @__PURE__ */ jsx75(PopoverTrigger, { render: /* @__PURE__ */ jsx75("div", {}), nativeButton: false, children: /* @__PURE__ */ jsx75(InputGroupButton, { variant: "ghost", size: "icon-xs", children: /* @__PURE__ */ jsx75(CalendarIcon3, { className: "h-4 w-4 opacity-50" }) }) }),
9398
- field.value && /* @__PURE__ */ jsx75(
9448
+ field.value && allowEmpty !== false && /* @__PURE__ */ jsx75(
9399
9449
  InputGroupButton,
9400
9450
  {
9401
9451
  variant: "ghost",
@@ -9410,25 +9460,43 @@ function FormDate({
9410
9460
  )
9411
9461
  ] })
9412
9462
  ] }),
9413
- /* @__PURE__ */ jsx75(PopoverContent, { className: "w-auto p-0", align: "end", children: /* @__PURE__ */ jsx75(
9414
- Calendar,
9415
- {
9416
- mode: "single",
9417
- captionLayout: "dropdown",
9418
- selected: field.value,
9419
- onSelect: (e) => {
9420
- handleCalendarSelect(e, field);
9421
- setOpen(false);
9422
- },
9423
- disabled: (date) => minDate && date < minDate ? true : false,
9424
- locale: dateFnsLocale,
9425
- weekStartsOn: 1,
9426
- month: displayMonth,
9427
- onMonthChange: setDisplayMonth,
9428
- startMonth: new Date(1900, 0),
9429
- endMonth: new Date((/* @__PURE__ */ new Date()).getFullYear() + 10, 11)
9430
- }
9431
- ) })
9463
+ /* @__PURE__ */ jsxs44(PopoverContent, { className: "w-auto p-0", align: "end", children: [
9464
+ /* @__PURE__ */ jsx75(
9465
+ Calendar,
9466
+ {
9467
+ mode: "single",
9468
+ captionLayout: "dropdown",
9469
+ selected: field.value,
9470
+ onSelect: (e) => {
9471
+ handleCalendarSelect(e, field);
9472
+ setOpen(false);
9473
+ },
9474
+ disabled: (date) => minDate && date < minDate ? true : false,
9475
+ locale: dateFnsLocale,
9476
+ weekStartsOn: 1,
9477
+ month: displayMonth,
9478
+ onMonthChange: setDisplayMonth,
9479
+ startMonth: new Date(1900, 0),
9480
+ endMonth: new Date((/* @__PURE__ */ new Date()).getFullYear() + 10, 11)
9481
+ }
9482
+ ),
9483
+ allowEmpty !== false && /* @__PURE__ */ jsx75("div", { className: "border-t p-2", children: /* @__PURE__ */ jsx75(
9484
+ Button,
9485
+ {
9486
+ type: "button",
9487
+ variant: "outline",
9488
+ className: "w-full",
9489
+ disabled: !field.value,
9490
+ onClick: () => {
9491
+ field.onChange(void 0);
9492
+ setInputValue("");
9493
+ if (onChange) onChange(void 0);
9494
+ setOpen(false);
9495
+ },
9496
+ children: t(`ui.buttons.clear`)
9497
+ }
9498
+ ) })
9499
+ ] })
9432
9500
  ] }) }) });
9433
9501
  }
9434
9502
  __name(FormDate, "FormDate");
@@ -9443,12 +9511,17 @@ function FormDateTime({
9443
9511
  name,
9444
9512
  minDate,
9445
9513
  onChange,
9446
- allowEmpty
9514
+ allowEmpty,
9515
+ defaultMonth
9447
9516
  }) {
9448
9517
  const [open, setOpen] = useState22(false);
9449
9518
  const t = useI18nTranslations();
9450
9519
  const locale = useI18nLocale();
9451
9520
  const dateFnsLocale = useI18nDateFnsLocale();
9521
+ const [displayMonth, setDisplayMonth] = useState22(() => {
9522
+ const currentValue = form.getValues(id);
9523
+ return currentValue || defaultMonth || /* @__PURE__ */ new Date();
9524
+ });
9452
9525
  const dateTimeFormatter = useMemo13(
9453
9526
  () => new Intl.DateTimeFormat(locale, {
9454
9527
  year: "numeric",
@@ -9525,7 +9598,10 @@ function FormDateTime({
9525
9598
  Calendar,
9526
9599
  {
9527
9600
  mode: "single",
9601
+ captionLayout: "dropdown",
9528
9602
  selected: field.value,
9603
+ month: displayMonth,
9604
+ onMonthChange: setDisplayMonth,
9529
9605
  onSelect: (date) => {
9530
9606
  if (date) {
9531
9607
  const newDate = new Date(date);
@@ -9536,13 +9612,17 @@ function FormDateTime({
9536
9612
  newDate.setHours(selectedHours, selectedMinutes);
9537
9613
  }
9538
9614
  form.setValue(id, newDate);
9615
+ setDisplayMonth(newDate);
9539
9616
  if (onChange) onChange(newDate);
9540
9617
  setSelectedHours(newDate.getHours());
9541
9618
  setSelectedMinutes(roundToNearestFiveMinutes(newDate.getMinutes()));
9542
9619
  }
9543
9620
  },
9544
9621
  disabled: (date) => minDate && date < minDate ? true : false,
9545
- locale: dateFnsLocale
9622
+ locale: dateFnsLocale,
9623
+ weekStartsOn: 1,
9624
+ startMonth: new Date(1900, 0),
9625
+ endMonth: new Date((/* @__PURE__ */ new Date()).getFullYear() + 10, 11)
9546
9626
  }
9547
9627
  ),
9548
9628
  /* @__PURE__ */ jsxs45("div", { className: "flex flex-row items-end justify-center space-x-4", children: [
@@ -9591,16 +9671,34 @@ function FormDateTime({
9591
9671
  )
9592
9672
  ] })
9593
9673
  ] }),
9594
- /* @__PURE__ */ jsx76(
9595
- Button,
9596
- {
9597
- className: "mt-2",
9598
- onClick: () => {
9599
- setOpen(false);
9600
- },
9601
- children: t(`ui.buttons.select_date`)
9602
- }
9603
- )
9674
+ /* @__PURE__ */ jsxs45("div", { className: "mt-2 flex flex-row gap-x-2", children: [
9675
+ allowEmpty !== false && /* @__PURE__ */ jsx76(
9676
+ Button,
9677
+ {
9678
+ type: "button",
9679
+ variant: "outline",
9680
+ className: "flex-1",
9681
+ disabled: !field.value,
9682
+ onClick: () => {
9683
+ if (onChange) onChange(void 0);
9684
+ form.setValue(id, "");
9685
+ setOpen(false);
9686
+ },
9687
+ children: t(`ui.buttons.clear`)
9688
+ }
9689
+ ),
9690
+ /* @__PURE__ */ jsx76(
9691
+ Button,
9692
+ {
9693
+ type: "button",
9694
+ className: "flex-1",
9695
+ onClick: () => {
9696
+ setOpen(false);
9697
+ },
9698
+ children: t(`ui.buttons.select_date`)
9699
+ }
9700
+ )
9701
+ ] })
9604
9702
  ] }) })
9605
9703
  ] }) }) }) });
9606
9704
  }
@@ -22088,4 +22186,4 @@ export {
22088
22186
  useOAuthClients,
22089
22187
  useOAuthClient
22090
22188
  };
22091
- //# sourceMappingURL=chunk-XYGK26YG.mjs.map
22189
+ //# sourceMappingURL=chunk-TLTENUI6.mjs.map