@motor-hero/ui-kit 0.26.0 → 0.28.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/base-dialog.d.ts +8 -1
- package/dist/components/base-dialog.d.ts.map +1 -1
- package/dist/index.cjs +33 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/base-dialog.tsx +11 -1
package/dist/index.js
CHANGED
|
@@ -372,7 +372,24 @@ function FormField({ label, htmlFor, error, required, children, className }) {
|
|
|
372
372
|
// src/components/base-dialog.tsx
|
|
373
373
|
import * as Dialog from "@radix-ui/react-dialog";
|
|
374
374
|
import { X } from "lucide-react";
|
|
375
|
+
import * as React2 from "react";
|
|
376
|
+
|
|
377
|
+
// src/hooks/use-is-desktop.ts
|
|
375
378
|
import * as React from "react";
|
|
379
|
+
var DESKTOP_QUERY = "(min-width: 640px)";
|
|
380
|
+
function useIsDesktop() {
|
|
381
|
+
const [isDesktop, setIsDesktop] = React.useState(
|
|
382
|
+
() => typeof window !== "undefined" ? window.matchMedia(DESKTOP_QUERY).matches : true
|
|
383
|
+
);
|
|
384
|
+
React.useEffect(() => {
|
|
385
|
+
const mql = window.matchMedia(DESKTOP_QUERY);
|
|
386
|
+
const onChange = () => setIsDesktop(mql.matches);
|
|
387
|
+
onChange();
|
|
388
|
+
mql.addEventListener("change", onChange);
|
|
389
|
+
return () => mql.removeEventListener("change", onChange);
|
|
390
|
+
}, []);
|
|
391
|
+
return isDesktop;
|
|
392
|
+
}
|
|
376
393
|
|
|
377
394
|
// src/lib/utils.ts
|
|
378
395
|
import { clsx } from "clsx";
|
|
@@ -399,9 +416,11 @@ function BaseDialog({
|
|
|
399
416
|
footer,
|
|
400
417
|
size = "lg",
|
|
401
418
|
className,
|
|
419
|
+
modal,
|
|
402
420
|
contentWrapper = (content) => content
|
|
403
421
|
}) {
|
|
404
|
-
|
|
422
|
+
const isDesktop = useIsDesktop();
|
|
423
|
+
React2.useEffect(() => {
|
|
405
424
|
if (open) return;
|
|
406
425
|
const id = window.setTimeout(() => {
|
|
407
426
|
if (document.body.style.pointerEvents === "none") {
|
|
@@ -428,7 +447,7 @@ function BaseDialog({
|
|
|
428
447
|
/* @__PURE__ */ jsx10("div", { className: "min-h-0 flex-1 overflow-y-auto px-6 py-4", children }),
|
|
429
448
|
footer && /* @__PURE__ */ jsx10("div", { className: "flex shrink-0 flex-col-reverse gap-2 border-t px-6 py-3 sm:flex-row sm:justify-end", children: footer })
|
|
430
449
|
] });
|
|
431
|
-
return /* @__PURE__ */ jsx10(Dialog.Root, { open, onOpenChange, children: /* @__PURE__ */ jsxs9(Dialog.Portal, { children: [
|
|
450
|
+
return /* @__PURE__ */ jsx10(Dialog.Root, { open, onOpenChange, modal: modal ?? !isDesktop, children: /* @__PURE__ */ jsxs9(Dialog.Portal, { children: [
|
|
432
451
|
/* @__PURE__ */ jsx10(Dialog.Overlay, { className: "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" }),
|
|
433
452
|
/* @__PURE__ */ jsx10(
|
|
434
453
|
Dialog.Content,
|
|
@@ -548,9 +567,9 @@ function TableSkeleton({ rows = 5, columns = 4 }) {
|
|
|
548
567
|
}
|
|
549
568
|
|
|
550
569
|
// src/components/search-input.tsx
|
|
551
|
-
import * as
|
|
570
|
+
import * as React3 from "react";
|
|
552
571
|
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
553
|
-
var SearchInput =
|
|
572
|
+
var SearchInput = React3.forwardRef(
|
|
554
573
|
({ containerClassName, className, ...props }, ref) => {
|
|
555
574
|
return /* @__PURE__ */ jsxs13("div", { className: `relative flex-1 ${containerClassName ?? ""}`, children: [
|
|
556
575
|
/* @__PURE__ */ jsxs13(
|
|
@@ -588,10 +607,10 @@ SearchInput.displayName = "SearchInput";
|
|
|
588
607
|
|
|
589
608
|
// src/components/password-input.tsx
|
|
590
609
|
import { Eye, EyeOff } from "lucide-react";
|
|
591
|
-
import * as
|
|
610
|
+
import * as React4 from "react";
|
|
592
611
|
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
593
|
-
var PasswordInput =
|
|
594
|
-
const [visible, setVisible] =
|
|
612
|
+
var PasswordInput = React4.forwardRef(({ containerClassName, className, ...props }, ref) => {
|
|
613
|
+
const [visible, setVisible] = React4.useState(false);
|
|
595
614
|
return /* @__PURE__ */ jsxs14("div", { className: `relative ${containerClassName ?? ""}`, children: [
|
|
596
615
|
/* @__PURE__ */ jsx16(
|
|
597
616
|
"input",
|
|
@@ -625,21 +644,21 @@ import * as React6 from "react";
|
|
|
625
644
|
import { Drawer as DrawerPrimitive } from "vaul";
|
|
626
645
|
|
|
627
646
|
// src/hooks/use-infinite-scroll-sentinel.ts
|
|
628
|
-
import * as
|
|
647
|
+
import * as React5 from "react";
|
|
629
648
|
function useInfiniteScrollSentinel({
|
|
630
649
|
enabled,
|
|
631
650
|
loading,
|
|
632
651
|
onLoadMore
|
|
633
652
|
}) {
|
|
634
|
-
const listRef =
|
|
635
|
-
const sentinelRef =
|
|
636
|
-
const loadingRef =
|
|
637
|
-
const onLoadMoreRef =
|
|
638
|
-
|
|
653
|
+
const listRef = React5.useRef(null);
|
|
654
|
+
const sentinelRef = React5.useRef(null);
|
|
655
|
+
const loadingRef = React5.useRef(loading);
|
|
656
|
+
const onLoadMoreRef = React5.useRef(onLoadMore);
|
|
657
|
+
React5.useEffect(() => {
|
|
639
658
|
loadingRef.current = loading;
|
|
640
659
|
onLoadMoreRef.current = onLoadMore;
|
|
641
660
|
});
|
|
642
|
-
|
|
661
|
+
React5.useEffect(() => {
|
|
643
662
|
if (!enabled) return;
|
|
644
663
|
const root = listRef.current;
|
|
645
664
|
const sentinel = sentinelRef.current;
|
|
@@ -658,23 +677,6 @@ function useInfiniteScrollSentinel({
|
|
|
658
677
|
return { listRef, sentinelRef };
|
|
659
678
|
}
|
|
660
679
|
|
|
661
|
-
// src/hooks/use-is-desktop.ts
|
|
662
|
-
import * as React5 from "react";
|
|
663
|
-
var DESKTOP_QUERY = "(min-width: 640px)";
|
|
664
|
-
function useIsDesktop() {
|
|
665
|
-
const [isDesktop, setIsDesktop] = React5.useState(
|
|
666
|
-
() => typeof window !== "undefined" ? window.matchMedia(DESKTOP_QUERY).matches : true
|
|
667
|
-
);
|
|
668
|
-
React5.useEffect(() => {
|
|
669
|
-
const mql = window.matchMedia(DESKTOP_QUERY);
|
|
670
|
-
const onChange = () => setIsDesktop(mql.matches);
|
|
671
|
-
onChange();
|
|
672
|
-
mql.addEventListener("change", onChange);
|
|
673
|
-
return () => mql.removeEventListener("change", onChange);
|
|
674
|
-
}, []);
|
|
675
|
-
return isDesktop;
|
|
676
|
-
}
|
|
677
|
-
|
|
678
680
|
// src/components/combobox.tsx
|
|
679
681
|
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
680
682
|
function Combobox({
|