formeact 0.0.2 → 0.0.3

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.
@@ -1,7 +1,6 @@
1
- import { StaticImageData } from "next/image";
2
1
  type Props = {
3
2
  style?: string;
4
- placeholder?: StaticImageData | string;
3
+ placeholder?: string;
5
4
  value?: File;
6
5
  update?: (x: File) => void;
7
6
  disabled?: boolean;
@@ -2,7 +2,6 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useState, useRef, useEffect } from "react";
4
4
  import { cn } from "@bouko/style";
5
- import Image from "next/image";
6
5
  import Placeholder from "../../assets/icons/cover.png";
7
6
  import Camera from "../../assets/icons/camera.svg";
8
7
  export function ImageUploader({ style, placeholder, value, update, disabled = false }) {
@@ -23,7 +22,7 @@ export function ImageUploader({ style, placeholder, value, update, disabled = fa
23
22
  return;
24
23
  update?.(file);
25
24
  };
26
- return (_jsxs("div", { className: cn(styles.container, style), onClick: uploadFile, children: [_jsx("input", { type: "file", className: "hidden", onChange: handleFileChange, ref: ref }), _jsx(Image, { src: preview || placeholder || Placeholder, fill: true, alt: "Image Uploader" }), _jsx("div", { className: "flex justify-center items-center w-full h-full z-10 opacity-0 hover:opacity-50 bg-background-light/80 duration-200 cursor-pointer", children: _jsx(Camera, { className: "text-xl text-primary-light" }) })] }));
25
+ return (_jsxs("div", { className: cn(styles.container, style), onClick: uploadFile, children: [_jsx("input", { type: "file", className: "hidden", onChange: handleFileChange, ref: ref }), _jsx("img", { src: preview || placeholder || Placeholder, className: "top-0 left-0 w-full h-full", alt: "Image Uploader" }), _jsx("div", { className: "flex justify-center items-center w-full h-full z-10 opacity-0 hover:opacity-50 bg-background-light/80 duration-200 cursor-pointer", children: _jsx(Camera, { className: "text-xl text-primary-light" }) })] }));
27
26
  }
28
27
  const styles = {
29
28
  container: "relative shrink-0 border border-border rounded-md overflow-hidden",
@@ -1,4 +1,3 @@
1
- import type { FormControls } from "@bouko/form";
2
1
  import type { JsonMap } from "@bouko/ts";
3
2
  /**
4
3
  * React hook for managing form state with type-safety
@@ -14,6 +13,11 @@ import type { JsonMap } from "@bouko/ts";
14
13
  * @param {Partial<T>} init - The initial form data.
15
14
  * @returns {FormControls} Utils to control the form.
16
15
  **/
16
+ type FormControls<T, K extends keyof T> = {
17
+ data: Partial<T>;
18
+ update: (id: K, x: T[K]) => void;
19
+ clear: () => void;
20
+ };
17
21
  type JsonMapWithFiles = {
18
22
  [key: string]: JsonValueWithFile | JsonValueWithFile[];
19
23
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "formeact",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",
@@ -21,7 +21,6 @@
21
21
  },
22
22
 
23
23
  "dependencies": {
24
- "@bouko/next": "^1.6.6",
25
24
  "@bouko/notify": "^0.1.8",
26
25
  "@bouko/react": "^2.6.6",
27
26
  "@bouko/style": "^0.1.7",