najm-kit 2.1.29 → 2.1.31

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 CHANGED
@@ -2074,6 +2074,7 @@ interface ImageInputProps extends BaseProps {
2074
2074
  placeholder?: string;
2075
2075
  icon?: InputIcon;
2076
2076
  showIcon?: boolean;
2077
+ uploadIcon?: React.ReactNode;
2077
2078
  previewClassName?: string;
2078
2079
  showPreview?: boolean;
2079
2080
  previewPosition?: "top" | "bottom" | "left" | "right";
@@ -2082,6 +2083,12 @@ interface ImageInputProps extends BaseProps {
2082
2083
  defaultImage?: string;
2083
2084
  imageSize?: "sm" | "md" | "lg" | "xl";
2084
2085
  imageVersion?: string | number | null;
2086
+ title?: string;
2087
+ subtitle?: string;
2088
+ replaceTitle?: string;
2089
+ replaceSubtitle?: string;
2090
+ trigger?: "icon" | "button" | "both";
2091
+ buttonLabel?: string;
2085
2092
  }
2086
2093
  interface EmojiInputProps extends BaseProps {
2087
2094
  value: number;
@@ -2179,7 +2186,7 @@ interface NUploaderProps {
2179
2186
  }
2180
2187
  declare function NUploader({ title, subtitle, accept, multiple, disabled, items, listTitle, className, dropzoneClassName, onFilesSelected, onCancel, onRemove, }: NUploaderProps): react_jsx_runtime.JSX.Element;
2181
2188
 
2182
- declare function ImageInput({ value, onChange, previewClassName, showPreview, previewPosition, allowClear, accept, defaultImage, imageSize, imageVersion, disabled, }: ImageInputProps & {
2189
+ declare function ImageInput({ value, onChange, previewClassName, showPreview, previewPosition, allowClear, accept, defaultImage, imageSize, imageVersion, disabled, uploadIcon, title, subtitle, replaceTitle, replaceSubtitle, trigger, buttonLabel, }: ImageInputProps & {
2183
2190
  disabled?: boolean;
2184
2191
  }): react_jsx_runtime.JSX.Element;
2185
2192
 
package/dist/index.mjs CHANGED
@@ -7463,7 +7463,14 @@ function ImageInput({
7463
7463
  defaultImage,
7464
7464
  imageSize = "md",
7465
7465
  imageVersion,
7466
- disabled = false
7466
+ disabled = false,
7467
+ uploadIcon,
7468
+ title = "Click to upload",
7469
+ subtitle,
7470
+ replaceTitle = "Replace image",
7471
+ replaceSubtitle,
7472
+ trigger = "icon",
7473
+ buttonLabel = "Upload"
7467
7474
  }) {
7468
7475
  const fileInputRef = useRef(null);
7469
7476
  const [preview, setPreview] = useState(null);
@@ -7493,6 +7500,8 @@ function ImageInput({
7493
7500
  if (fileInputRef.current) fileInputRef.current.value = "";
7494
7501
  };
7495
7502
  const effectiveSize = previewClassName || IMAGE_SIZE_MAP[imageSize];
7503
+ const isDropzone = !!previewClassName;
7504
+ const effectiveReplaceSubtitle = replaceSubtitle ?? subtitle;
7496
7505
  const renderPreview = () => /* @__PURE__ */ jsx(
7497
7506
  "div",
7498
7507
  {
@@ -7500,7 +7509,24 @@ function ImageInput({
7500
7509
  "flex relative group rounded-lg overflow-hidden border-2 border-dashed border-muted-foreground/60 hover:border-primary transition-colors",
7501
7510
  effectiveSize
7502
7511
  ),
7503
- children: preview ? /* @__PURE__ */ jsxs(Fragment, { children: [
7512
+ children: preview ? isDropzone ? /* @__PURE__ */ jsxs(Fragment, { children: [
7513
+ /* @__PURE__ */ jsx("img", { src: preview, alt: "Preview", className: "absolute inset-0 w-full h-full object-cover" }),
7514
+ /* @__PURE__ */ jsxs("div", { className: "relative w-full h-full flex flex-col items-center justify-center gap-1.5 bg-black/40 text-white px-6 py-8 text-center", children: [
7515
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: replaceTitle }),
7516
+ effectiveReplaceSubtitle ? /* @__PURE__ */ jsx("span", { className: "text-xs opacity-80", children: effectiveReplaceSubtitle }) : null,
7517
+ allowClear && /* @__PURE__ */ jsx(
7518
+ "button",
7519
+ {
7520
+ type: "button",
7521
+ onClick: handleClear,
7522
+ disabled,
7523
+ className: "absolute top-2 right-2 flex h-6 w-6 items-center justify-center rounded-full bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
7524
+ "aria-label": "Remove image",
7525
+ children: /* @__PURE__ */ jsx(X, { className: "h-3.5 w-3.5" })
7526
+ }
7527
+ )
7528
+ ] })
7529
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7504
7530
  /* @__PURE__ */ jsx("img", { src: preview, alt: "Preview", className: "w-full h-full object-cover" }),
7505
7531
  /* @__PURE__ */ jsx(
7506
7532
  "div",
@@ -7530,7 +7556,26 @@ function ImageInput({
7530
7556
  children: /* @__PURE__ */ jsx(Upload, { className: "h-8 w-8 text-white" })
7531
7557
  }
7532
7558
  )
7533
- ] }) : /* @__PURE__ */ jsxs(
7559
+ ] }) : isDropzone ? /* @__PURE__ */ jsxs(
7560
+ "div",
7561
+ {
7562
+ onClick: handleClick,
7563
+ className: "w-full h-full flex flex-col items-center justify-center gap-2 cursor-pointer bg-muted/30 hover:bg-muted/50 transition-colors px-6 py-8 text-center",
7564
+ children: [
7565
+ (trigger === "icon" || trigger === "both") && /* @__PURE__ */ jsx("div", { className: "text-primary", children: uploadIcon ?? /* @__PURE__ */ jsx(Plus, { className: "h-8 w-8" }) }),
7566
+ (trigger === "button" || trigger === "both") && /* @__PURE__ */ jsx(
7567
+ "span",
7568
+ {
7569
+ role: "button",
7570
+ className: "inline-flex items-center justify-center rounded-md border border-input bg-background px-3 py-1.5 text-xs font-medium text-foreground shadow-sm hover:bg-accent hover:text-accent-foreground",
7571
+ children: buttonLabel
7572
+ }
7573
+ ),
7574
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-foreground", children: title }),
7575
+ subtitle ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: subtitle }) : null
7576
+ ]
7577
+ }
7578
+ ) : /* @__PURE__ */ jsxs(
7534
7579
  "div",
7535
7580
  {
7536
7581
  onClick: handleClick,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "najm-kit",
3
- "version": "2.1.29",
3
+ "version": "2.1.31",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Reusable React UI component package for Najm framework",