@enmera/panel-kit 0.2.0 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1
4
+
5
+ - `SectionCard`: on phones (below `sm`) the header wraps, so actions that do not fit move under the title instead of
6
+ squeezing it into a narrow column. Nothing changes from `sm` up.
7
+ - `Button` / `LinkButton` accept `aria-keyshortcuts`. react-aria drops this attribute from DOM props; it is now written to
8
+ the element through the `render` prop (a `render` you pass yourself still works).
9
+ - `Button` `variant="floating"`: in dark mode it uses the card colour with a light ring instead of the primary colour, so the
10
+ floating button does not look like the page's main action.
11
+
3
12
  ## 0.2.0
4
13
 
5
14
  - `Button` `variant="destructive-ghost"`: row delete/remove icons; red text, background only on hover.
@@ -2,6 +2,7 @@ import { type ReactNode } from 'react';
2
2
  /**
3
3
  * Bölüm kartı: başlık, açıklama, sağda seçenekler.
4
4
  * `flush` gövdeyi kenar boşluksuz bırakır (liste, ızgara, tablo için).
5
+ * Telefonda başlık satırı sarılır: sığmayan seçenekler başlığın altına iner, başlık dar bir sütuna sıkışmaz.
5
6
  */
6
7
  export declare function SectionCard({ title, description, actions, flush, highlighted, className, contentClassName, children, }: {
7
8
  title?: ReactNode;
@@ -4,9 +4,10 @@ import { cn } from './utils.js';
4
4
  /**
5
5
  * Bölüm kartı: başlık, açıklama, sağda seçenekler.
6
6
  * `flush` gövdeyi kenar boşluksuz bırakır (liste, ızgara, tablo için).
7
+ * Telefonda başlık satırı sarılır: sığmayan seçenekler başlığın altına iner, başlık dar bir sütuna sıkışmaz.
7
8
  */
8
9
  export function SectionCard({ title, description, actions, flush = false, highlighted = false, className, contentClassName, children, }) {
9
- return (_jsxs("section", { className: cn('flex flex-col overflow-hidden rounded-3xl bg-card text-card-foreground shadow-sm ring-1 ring-foreground/5 dark:ring-foreground/10', highlighted && 'ring-2 ring-primary/40 dark:ring-primary/40', className), children: [(title || actions) && (_jsxs("header", { className: cn('flex items-start gap-3 px-4 py-3 sm:px-6 sm:py-4', hasContent(children) && 'border-b'), children: [_jsxs("div", { className: "min-w-0 flex-1", children: [title && _jsx("h2", { className: "text-sm font-semibold sm:text-base", children: title }), description && _jsx("p", { className: "mt-0.5 text-xs text-muted-foreground sm:text-sm", children: description })] }), actions && _jsx("div", { className: "flex shrink-0 items-center gap-2", children: actions })] })), hasContent(children) && _jsx("div", { className: cn('flex-1', !flush && 'p-4 sm:p-6', contentClassName), children: children })] }));
10
+ return (_jsxs("section", { className: cn('flex flex-col overflow-hidden rounded-3xl bg-card text-card-foreground shadow-sm ring-1 ring-foreground/5 dark:ring-foreground/10', highlighted && 'ring-2 ring-primary/40 dark:ring-primary/40', className), children: [(title || actions) && (_jsxs("header", { className: cn('flex items-start gap-3 max-sm:flex-wrap px-4 py-3 sm:px-6 sm:py-4', hasContent(children) && 'border-b'), children: [_jsxs("div", { className: "min-w-0 flex-1 max-sm:min-w-[min(100%,12rem)]", children: [title && _jsx("h2", { className: "text-sm font-semibold sm:text-base", children: title }), description && _jsx("p", { className: "mt-0.5 text-xs text-muted-foreground sm:text-sm", children: description })] }), actions && _jsx("div", { className: "flex shrink-0 items-center gap-2 max-sm:max-w-full max-sm:flex-wrap", children: actions })] })), hasContent(children) && _jsx("div", { className: cn('flex-1', !flush && 'p-4 sm:p-6', contentClassName), children: children })] }));
10
11
  }
11
12
  function hasContent(children) {
12
13
  return Children.toArray(children).length > 0;
@@ -5,10 +5,14 @@ declare const buttonVariants: (props?: ({
5
5
  variant?: "caution" | "default" | "destructive" | "destructive-ghost" | "floating" | "ghost" | "inverse" | "light" | "link" | "on-brand" | "on-brand-soft" | "outline" | "secondary" | "warning" | null | undefined;
6
6
  size?: "default" | "icon" | "icon-lg" | "icon-sm" | "icon-xs" | "lg" | "sm" | "xs" | null | undefined;
7
7
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
- declare function Button({ className, variant, size, children, ...props }: Omit<ButtonPrimitiveProps, "className"> & React.RefAttributes<HTMLButtonElement> & VariantProps<typeof buttonVariants> & {
8
+ declare function Button({ className, variant, size, children, "aria-keyshortcuts": keyShortcuts, render, ...props }: Omit<ButtonPrimitiveProps, "className"> & React.RefAttributes<HTMLButtonElement> & VariantProps<typeof buttonVariants> & {
9
9
  className?: string;
10
+ /** Klavye kısayolu, ör. "Meta+K Control+K"; öğeye `aria-keyshortcuts` olarak yazılır. */
11
+ "aria-keyshortcuts"?: string;
10
12
  }): React.JSX.Element;
11
- declare function LinkButton({ className, variant, size, ...props }: Omit<LinkPrimitiveProps, "className"> & VariantProps<typeof buttonVariants> & {
13
+ declare function LinkButton({ className, variant, size, "aria-keyshortcuts": keyShortcuts, render, ...props }: Omit<LinkPrimitiveProps, "className"> & VariantProps<typeof buttonVariants> & {
12
14
  className?: string;
15
+ /** Klavye kısayolu, ör. "Meta+K Control+K"; öğeye `aria-keyshortcuts` olarak yazılır. */
16
+ "aria-keyshortcuts"?: string;
13
17
  }): React.JSX.Element;
14
18
  export { Button, LinkButton, buttonVariants };
package/dist/ui/button.js CHANGED
@@ -21,8 +21,8 @@ const buttonVariants = cva("group/button inline-flex shrink-0 items-center justi
21
21
  link: "text-primary underline-offset-4 hover:underline",
22
22
  // Açık zeminde koyu düğme (sitede ikinci çağrı, yüzen "Searvia'ya sor"); koyu temada marka rengi.
23
23
  inverse: "bg-ink text-white hover:bg-ink/85 dark:bg-primary dark:text-primary-foreground dark:hover:bg-primary/85",
24
- // Sayfanın üstünde yüzen koyu düğme ("Searvia'ya sor").
25
- floating: "bg-ink text-white shadow-lg hover:bg-ink/85 dark:bg-primary dark:text-primary-foreground dark:hover:bg-primary/85",
24
+ // Sayfanın üstünde yüzen koyu düğme ("Searvia'ya sor"); koyu temada kart rengi, sayfanın birincil düğmesiyle karışmaz.
25
+ floating: "bg-ink text-white shadow-lg hover:bg-ink/85 dark:bg-card dark:text-foreground dark:ring-1 dark:ring-foreground/15 dark:hover:bg-muted",
26
26
  // Marka renkli zeminin üstündeki düğmeler (ana sayfa, blog çağrısı): dolu ve saydam.
27
27
  "on-brand": "bg-on-brand text-on-brand-ink hover:bg-on-brand/90",
28
28
  "on-brand-soft": "bg-on-brand/10 text-on-brand ring-1 ring-on-brand/30 hover:bg-on-brand/20",
@@ -58,10 +58,19 @@ function withPendingIcon(children) {
58
58
  }
59
59
  return [_jsx(LoaderCircleIcon, { className: "animate-spin" }, "pending"), ...items];
60
60
  }
61
- function Button({ className, variant = "default", size = "default", children, ...props }) {
62
- return (_jsx(ButtonPrimitive, { "data-slot": "button", "data-variant": variant, "data-size": size, className: cn(buttonVariants({ variant, size, className })), ...props, children: props.isPending && typeof children !== "function" ? withPendingIcon(children) : children }));
61
+ function withKeyShortcuts(tag, shortcuts, render) {
62
+ if (!shortcuts)
63
+ return render;
64
+ return (props, renderProps) => render
65
+ ? React.cloneElement(render(props, renderProps), { "aria-keyshortcuts": shortcuts })
66
+ : React.createElement(tag, { ...props, "aria-keyshortcuts": shortcuts });
63
67
  }
64
- function LinkButton({ className, variant = "default", size = "default", ...props }) {
65
- return (_jsx(LinkPrimitive, { "data-slot": "button", "data-variant": variant, "data-size": size, className: cn(buttonVariants({ variant, size, className })), ...props }));
68
+ function Button({ className, variant = "default", size = "default", children, "aria-keyshortcuts": keyShortcuts, render, ...props }) {
69
+ return (_jsx(ButtonPrimitive, { "data-slot": "button", "data-variant": variant, "data-size": size, className: cn(buttonVariants({ variant, size, className })), render: withKeyShortcuts("button", keyShortcuts, render), ...props, children: props.isPending && typeof children !== "function" ? withPendingIcon(children) : children }));
70
+ }
71
+ function LinkButton({ className, variant = "default", size = "default", "aria-keyshortcuts": keyShortcuts, render, ...props }) {
72
+ // react-aria bağlantısı adres yoksa ya da kapalıysa <span> çizer.
73
+ const tag = props.href && !props.isDisabled ? "a" : "span";
74
+ return (_jsx(LinkPrimitive, { "data-slot": "button", "data-variant": variant, "data-size": size, className: cn(buttonVariants({ variant, size, className })), render: withKeyShortcuts(tag, keyShortcuts, render), ...props }));
66
75
  }
67
76
  export { Button, LinkButton, buttonVariants };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enmera/panel-kit",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Shared components for admin panels built with React, react-aria and Tailwind CSS: one look for every button, badge, box and heading.",
5
5
  "type": "module",
6
6
  "license": "MIT",