@janovix/blocks 1.0.0-rc.4 → 1.0.0-rc.5

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/index.cjs CHANGED
@@ -9656,9 +9656,11 @@ function AvatarEditor({
9656
9656
  const [dragStart, setDragStart] = React32.useState({ x: 0, y: 0 });
9657
9657
  const [showGrid, setShowGrid] = React32.useState(initialShowGrid);
9658
9658
  React32.useEffect(() => {
9659
- if (imageSource && !imageSource.startsWith("data:")) {
9659
+ if (imageSource) {
9660
9660
  const img = new Image();
9661
- img.crossOrigin = "anonymous";
9661
+ if (!imageSource.startsWith("data:")) {
9662
+ img.crossOrigin = "anonymous";
9663
+ }
9662
9664
  img.onload = () => {
9663
9665
  setImage(img);
9664
9666
  setImageLoaded(true);
@@ -9846,6 +9848,7 @@ function AvatarEditor({
9846
9848
  const handleTouchMove = React32.useCallback(
9847
9849
  (e) => {
9848
9850
  if (!isDragging) return;
9851
+ e.preventDefault();
9849
9852
  const touch = e.touches[0];
9850
9853
  setPosition({
9851
9854
  x: touch.clientX - dragStart.x,
@@ -10428,14 +10431,13 @@ function DrawerDescription({
10428
10431
  function useMediaQuery(query) {
10429
10432
  const [matches, setMatches] = React32.useState(false);
10430
10433
  React32.useEffect(() => {
10434
+ if (typeof window === "undefined") return;
10431
10435
  const media = window.matchMedia(query);
10432
- if (media.matches !== matches) {
10433
- setMatches(media.matches);
10434
- }
10436
+ setMatches(media.matches);
10435
10437
  const listener = () => setMatches(media.matches);
10436
10438
  media.addEventListener("change", listener);
10437
10439
  return () => media.removeEventListener("change", listener);
10438
- }, [matches, query]);
10440
+ }, [query]);
10439
10441
  return matches;
10440
10442
  }
10441
10443
  function AvatarEditorDialog({
@@ -10458,7 +10460,15 @@ function AvatarEditorDialog({
10458
10460
  const [editedValue, setEditedValue] = React32.useState(value ?? null);
10459
10461
  const [isSaving, setIsSaving] = React32.useState(false);
10460
10462
  const [feedback, setFeedback] = React32.useState(null);
10463
+ const [mobileEditorSize, setMobileEditorSize] = React32.useState(editorSize);
10461
10464
  const isMobile = useMediaQuery("(max-width: 640px)");
10465
+ React32.useEffect(() => {
10466
+ if (typeof window !== "undefined" && isMobile) {
10467
+ setMobileEditorSize(Math.min(editorSize + 40, window.innerWidth - 48));
10468
+ } else {
10469
+ setMobileEditorSize(editorSize);
10470
+ }
10471
+ }, [isMobile, editorSize]);
10462
10472
  const handleOpenChange = React32.useCallback(
10463
10473
  (open) => {
10464
10474
  if (open) {
@@ -10533,7 +10543,6 @@ function AvatarEditorDialog({
10533
10543
  ]
10534
10544
  }
10535
10545
  );
10536
- const mobileEditorSize = isMobile ? Math.min(editorSize + 40, window.innerWidth - 48) : editorSize;
10537
10546
  const EditorContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-4", children: [
10538
10547
  /* @__PURE__ */ jsxRuntime.jsx(
10539
10548
  AvatarEditor,
@@ -10858,7 +10867,7 @@ function NotificationsWidget({
10858
10867
  onNotificationClick,
10859
10868
  size: size4 = "md",
10860
10869
  maxVisible = 5,
10861
- playSound: _playSound = true,
10870
+ playSound = true,
10862
10871
  soundUrl,
10863
10872
  className,
10864
10873
  emptyMessage = "No notifications",
@@ -10875,10 +10884,13 @@ function NotificationsWidget({
10875
10884
  const styles = sizeConfig[size4];
10876
10885
  const dotBgColor = dotColorConfig[dotColor];
10877
10886
  const unreadCount = notifications.filter((n) => !n.read).length;
10878
- const visibleNotifications = notifications.slice(0, maxVisible);
10887
+ const visibleNotifications = React32__namespace.useMemo(
10888
+ () => notifications.slice(0, maxVisible),
10889
+ [notifications, maxVisible]
10890
+ );
10879
10891
  const hasMore = notifications.length > maxVisible;
10880
10892
  React32__namespace.useEffect(() => {
10881
- if (soundType !== "none" && unreadCount > prevCount && prevCount > 0) {
10893
+ if (playSound && soundType !== "none" && unreadCount > prevCount && prevCount > 0) {
10882
10894
  const now = Date.now();
10883
10895
  if (now - lastSoundPlayedRef.current >= soundCooldown) {
10884
10896
  playNotificationSound(soundType, soundUrl);
@@ -10886,7 +10898,7 @@ function NotificationsWidget({
10886
10898
  }
10887
10899
  }
10888
10900
  setPrevCount(unreadCount);
10889
- }, [unreadCount, prevCount, soundType, soundUrl, soundCooldown]);
10901
+ }, [unreadCount, prevCount, soundType, soundUrl, soundCooldown, playSound]);
10890
10902
  React32__namespace.useEffect(() => {
10891
10903
  if (isOpen && onMarkAsRead) {
10892
10904
  visibleNotifications.forEach((notification) => {