najm-kit 2.1.27 → 2.1.28
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.d.ts +1 -1
- package/dist/index.mjs +31 -8
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -457,7 +457,7 @@ declare function DialogClose({ ...props }: React$1.ComponentProps<typeof DialogP
|
|
|
457
457
|
declare function DialogOverlay({ className, ...props }: React$1.ComponentProps<typeof DialogPrimitive.Overlay>): react_jsx_runtime.JSX.Element;
|
|
458
458
|
type DialogPadding = "none" | "sm" | "md" | "lg";
|
|
459
459
|
interface DialogContentProps extends React$1.ComponentProps<typeof DialogPrimitive.Content> {
|
|
460
|
-
/** Controls the padding of the dialog surface. `none` also collapses the header/body/footer gap. Defaults to `md`
|
|
460
|
+
/** Controls the padding of the dialog surface. `none` also collapses the header/body/footer gap. Defaults to `sm` on mobile, `md` on desktop. */
|
|
461
461
|
padding?: DialogPadding;
|
|
462
462
|
/** Hides the built-in top-right close (X). Use when the content provides its own close control (e.g. inside a page header). */
|
|
463
463
|
hideClose?: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -1913,7 +1913,29 @@ var dialogPaddingMap = {
|
|
|
1913
1913
|
md: "p-6",
|
|
1914
1914
|
lg: "p-8"
|
|
1915
1915
|
};
|
|
1916
|
-
|
|
1916
|
+
var MOBILE_PADDING_QUERY = "(max-width: 639.98px)";
|
|
1917
|
+
function getDefaultPadding() {
|
|
1918
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return "md";
|
|
1919
|
+
return window.matchMedia(MOBILE_PADDING_QUERY).matches ? "sm" : "md";
|
|
1920
|
+
}
|
|
1921
|
+
function useResponsivePadding(value) {
|
|
1922
|
+
const [resolved, setResolved] = React.useState(() => value ?? getDefaultPadding());
|
|
1923
|
+
React.useEffect(() => {
|
|
1924
|
+
if (value) {
|
|
1925
|
+
setResolved(value);
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
|
|
1929
|
+
const mql = window.matchMedia(MOBILE_PADDING_QUERY);
|
|
1930
|
+
const update = () => setResolved(mql.matches ? "sm" : "md");
|
|
1931
|
+
update();
|
|
1932
|
+
mql.addEventListener("change", update);
|
|
1933
|
+
return () => mql.removeEventListener("change", update);
|
|
1934
|
+
}, [value]);
|
|
1935
|
+
return resolved;
|
|
1936
|
+
}
|
|
1937
|
+
function DialogContent({ className, children, padding, hideClose = false, ...props }) {
|
|
1938
|
+
const resolvedPadding = useResponsivePadding(padding);
|
|
1917
1939
|
const portalClassName = useNPortalScope();
|
|
1918
1940
|
return /* @__PURE__ */ jsx(DialogPortal, { "data-slot": "dialog-portal", children: /* @__PURE__ */ jsxs("div", { className: portalClassName, children: [
|
|
1919
1941
|
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
@@ -1921,10 +1943,10 @@ function DialogContent({ className, children, padding = "md", hideClose = false,
|
|
|
1921
1943
|
SheetPrimitive.Content,
|
|
1922
1944
|
{
|
|
1923
1945
|
"data-slot": "dialog-content",
|
|
1924
|
-
"data-padding":
|
|
1946
|
+
"data-padding": resolvedPadding,
|
|
1925
1947
|
className: cn(
|
|
1926
|
-
"bg-card text-card-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-sm translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg najm-border border-border shadow-lg duration-200",
|
|
1927
|
-
dialogPaddingMap[
|
|
1948
|
+
"bg-card text-card-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-sm translate-x-[-50%] translate-y-[-50%] gap-4 rounded-none lg:rounded-lg najm-border border-border shadow-lg duration-200",
|
|
1949
|
+
dialogPaddingMap[resolvedPadding],
|
|
1928
1950
|
className
|
|
1929
1951
|
),
|
|
1930
1952
|
...props,
|
|
@@ -2444,12 +2466,12 @@ function parseDirectDialogSlots(children) {
|
|
|
2444
2466
|
return { ...parsed, body };
|
|
2445
2467
|
}
|
|
2446
2468
|
var dialogVariants = cva(
|
|
2447
|
-
"flex flex-col w-full max-w-
|
|
2469
|
+
"flex flex-col w-full max-w-full h-full max-h-screen",
|
|
2448
2470
|
{
|
|
2449
2471
|
variants: {
|
|
2450
2472
|
variant: {
|
|
2451
2473
|
default: "",
|
|
2452
|
-
window: "rounded-sm"
|
|
2474
|
+
window: "rounded-none lg:rounded-sm"
|
|
2453
2475
|
},
|
|
2454
2476
|
size: {
|
|
2455
2477
|
sm: "lg:max-w-md",
|
|
@@ -2546,10 +2568,11 @@ function DialogChrome({
|
|
|
2546
2568
|
contentRef,
|
|
2547
2569
|
children
|
|
2548
2570
|
}) {
|
|
2571
|
+
const resolvedPadding = useResponsivePadding(padding);
|
|
2549
2572
|
const noTitle = !title || title.trim() === "";
|
|
2550
2573
|
const noDescription = !description || description.trim() === "";
|
|
2551
2574
|
const noHeader = noTitle && noDescription;
|
|
2552
|
-
const flush =
|
|
2575
|
+
const flush = resolvedPadding === "none";
|
|
2553
2576
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2554
2577
|
pageHeader ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2555
2578
|
/* @__PURE__ */ jsx(DialogTitle, { className: cn("sr-only", titleClassName), children: pageHeader.title || title || "Dialog" }),
|
|
@@ -2570,7 +2593,7 @@ function DialogChrome({
|
|
|
2570
2593
|
{
|
|
2571
2594
|
className: cn(
|
|
2572
2595
|
"flex-row items-center justify-between gap-3 border-b border-border bg-secondary text-left text-secondary-foreground",
|
|
2573
|
-
windowHeaderSpacing[
|
|
2596
|
+
windowHeaderSpacing[resolvedPadding],
|
|
2574
2597
|
headerClassName
|
|
2575
2598
|
),
|
|
2576
2599
|
children: [
|