the-omelet-ui 1.7.1 → 1.7.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.
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-6GLPXMGB.js';import {memo,useId}from'react';import {jsx,jsxs}from'react/jsx-runtime';var m=memo(({label:s,name:u,value:b,checked:e=false,disabled:i=false,onChange:c,className:f="",size:p="md",error:o=false,radioClassName:l,required:x})=>{let a$1=useId(),n={sm:{radio:"w-4 h-4",dot:"w-1.5 h-1.5",label:"text-sm",description:"text-xs"},md:{radio:"w-5 h-5",dot:"w-2.5 h-2.5",label:"text-base",description:"text-sm"},lg:{radio:"w-6 h-6",dot:"w-3 h-3",label:"text-lg",description:"text-base"}}[p];return jsx("div",{className:`inline-flex flex-col ${f}`,children:jsxs("label",{htmlFor:a$1,className:a("inline-flex items-center gap-2 cursor-pointer",i&&"opacity-50 cursor-not-allowed"),children:[jsxs("div",{className:"relative flex items-center justify-center flex-shrink-0 mt-0.5",children:[jsx("input",{type:"radio",id:a$1,name:u,value:b,checked:e,disabled:i,onChange:c,className:"sr-only peer"}),jsx("div",{className:a(n.radio,"rounded-full border-2 transition-all duration-200 flex items-center justify-center",o&&"border-red-500",!o&&e&&!l&&"border-blue-500 bg-blue-500",!o&&!e&&"border-gray-300 bg-white",!o&&!i&&!e&&"peer-hover:border-blue-400",i&&"bg-gray-100","peer-focus-visible:ring-2 peer-focus-visible:ring-blue-500 peer-focus-visible:ring-offset-2",e&&l),children:e&&jsx("div",{className:a(n.dot,"rounded-full bg-white transition-all duration-200")})})]}),s&&jsx("div",{className:"flex flex-col",children:jsx("label",{className:"block text-sm text-[#444] font-medium",children:s})})]})})});m.displayName="RadioButton";var y=m;export{y as a};
@@ -0,0 +1,35 @@
1
+ import * as class_variance_authority_types from 'class-variance-authority/types';
2
+ import React__default from 'react';
3
+ import { VariantProps } from 'class-variance-authority';
4
+
5
+ declare const fileUploadVariants: (props?: ({
6
+ size?: "sm" | "md" | "lg" | null | undefined;
7
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
8
+ interface FileUploadProps extends VariantProps<typeof fileUploadVariants> {
9
+ /** URL ของรูปภาพที่จะแสดง (controlled value) */
10
+ src?: string;
11
+ /** defaultSrc เอาไว้โชวเวลาไม่มี src */
12
+ defaultSrc?: string;
13
+ label?: string;
14
+ /** Text to display on the upload button
15
+ * @default 'อัปโหลดรูปภาพ'
16
+ */
17
+ uploadButtonText?: string;
18
+ /** Text to display below the upload button
19
+ * @default '""'
20
+ */
21
+ acceptedFormatsText?: string;
22
+ error?: string;
23
+ accept?: string;
24
+ onChange?: (file: File | null, preview: string | null) => void;
25
+ /** Max file size in MB */
26
+ maxSizeMB?: number;
27
+ disabled?: boolean;
28
+ className?: string;
29
+ required?: boolean;
30
+ buttonVariant?: 'default' | 'outline' | 'ghost';
31
+ buttonClassName?: string;
32
+ }
33
+ declare const FileUpload: React__default.FC<FileUploadProps>;
34
+
35
+ export { FileUpload, type FileUploadProps, FileUpload as default };
@@ -0,0 +1,2 @@
1
+ import {a as a$2}from'../chunk-QRYSV225.js';import {a as a$1}from'../chunk-FK7R34ZH.js';import {a}from'../chunk-6GLPXMGB.js';import {forwardRef,memo,useState,useRef}from'react';import {jsxs,jsx}from'react/jsx-runtime';import {cva}from'class-variance-authority';var K=({title:l,titleId:o,...i},g)=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em",ref:g,"aria-labelledby":o,...i,children:[l?jsx("title",{id:o,children:l}):null,jsx("path",{fill:"currentColor",d:"M0 13.687c0-.36.325-.653.727-.653s.727.293.727.653v.84c.195.107.423.167.66.167h11.771c.238 0 .466-.06.66-.167v-.84c0-.36.326-.653.728-.653s.727.293.727.653v1.156c0 .176-.08.345-.22.467a2.88 2.88 0 0 1-1.895.69H2.115c-.708 0-1.39-.246-1.896-.69A.62.62 0 0 1 0 14.843zm7.274-3.285V2.146L4.01 4.857a.786.786 0 0 1-1.027-.035.608.608 0 0 1 .04-.924L7.507.174l.111-.077a.79.79 0 0 1 .877.077l4.484 3.724a.608.608 0 0 1 .04.924.786.786 0 0 1-1.027.035l-3.264-2.71v8.255c0 .36-.325.653-.727.653s-.727-.292-.727-.653"})]}),Q=forwardRef(K),W=memo(Q),L=W;var Y=cva("w-full space-y-2",{variants:{size:{sm:"",md:"",lg:""}},defaultVariants:{size:"md"}}),Z=cva("relative overflow-hidden flex-shrink-0 transition-all duration-200 ",{variants:{size:{sm:"w-20 h-20 rounded-lg",md:"w-30 h-30 rounded-xl",lg:"w-40 h-40 rounded-2xl"},state:{default:"bg-blue-50 border-2 border-blue-100",dragging:"bg-blue-50 border-2 border-blue-100 ring-2 ring-blue-400 ring-offset-2",error:"bg-red-50 border-2 border-red-200",disabled:"bg-gray-50 border-2 border-gray-200 opacity-50 cursor-not-allowed"},cursor:{pointer:"cursor-pointer",notAllowed:"cursor-not-allowed"}},defaultVariants:{size:"md",state:"default",cursor:"pointer"}}),_=cva("inline-flex items-center gap-2 font-medium border-2 transition-colors duration-200",{variants:{size:{sm:"py-1 px-2 text-sm rounded-md",md:"py-1 px-3 text-base rounded-lg",lg:"py-1 px-4 text-lg rounded-xl"},variant:{default:"text-blue-600 border-blue-600 hover:bg-blue-50 active:bg-blue-100",outline:"text-gray-700 border-gray-300 hover:bg-gray-50 active:bg-gray-100",ghost:"text-blue-600 border-transparent hover:bg-blue-50 active:bg-blue-100"},state:{default:"",disabled:"cursor-not-allowed opacity-50"}},defaultVariants:{size:"md",variant:"default",state:"default"}}),$=cva("",{variants:{size:{sm:"w-16 h-16",md:"w-32 h-32",lg:"w-40 h-40"}},defaultVariants:{size:"md"}}),ee=({src:l,defaultSrc:o,label:i,uploadButtonText:g="\u0E2D\u0E31\u0E1B\u0E42\u0E2B\u0E25\u0E14\u0E23\u0E39\u0E1B\u0E20\u0E32\u0E1E",acceptedFormatsText:N,error:p,accept:b="image/jpeg,image/jpg,image/png",onChange:f,maxSizeMB:P=5,disabled:r=false,className:R,required:C=false,size:s="md",buttonVariant:F="default",buttonClassName:B})=>{let[I,M]=useState(null),[S,m]=useState(false),h=useRef(null),x=l||I||o,T=e=>{let a=e.target.files?.[0];w(a);},w=e=>{if(!e)return;let a=b.split(",").map(d=>d.trim()),q=e.type;if(!a.includes(q)){f?.(null,null);return}if(e.size/(1024*1024)>P){f?.(null,null);return}let v=new FileReader;v.onloadend=()=>{let d=v.result;M(d),f?.(e,d);},v.readAsDataURL(e);},y=()=>{h.current?.click();},U=e=>{e.preventDefault(),e.stopPropagation(),r||m(true);},j=e=>{e.preventDefault(),e.stopPropagation(),m(false);},k=e=>{e.preventDefault(),e.stopPropagation();},A=e=>{if(e.preventDefault(),e.stopPropagation(),m(false),r)return;let a=e.dataTransfer.files?.[0];w(a);},H=()=>r?"disabled":S?"dragging":p?"error":"default";return jsxs("div",{className:a(Y({size:s}),R),children:[i&&jsx(a$1,{label:i,required:C}),jsxs("div",{className:"flex items-center gap-4",children:[jsxs("div",{className:a(Z({size:s,state:H(),cursor:r?"notAllowed":"pointer"})),onDragEnter:U,onDragOver:k,onDragLeave:j,onDrop:A,onClick:r?void 0:y,children:[jsx("input",{ref:h,type:"file",accept:b,onChange:T,className:"hidden",disabled:r}),jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:x?jsx("img",{src:x,alt:"Preview",className:"w-full h-full object-cover"}):jsx("svg",{className:a($({size:s}),"text-blue-200"),fill:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})})]}),jsx("div",{children:jsxs("button",{type:"button",onClick:y,disabled:r,className:a(_({size:s,variant:F,state:r?"disabled":"default"}),"mt-2",B),children:[jsx(L,{fontSize:14}),g]})})]}),jsx("p",{className:"text-sm text-gray-500",children:N}),p&&jsx(a$2,{message:p})]})},te=ee;
2
+ export{ee as FileUpload,te as default};
@@ -1 +1 @@
1
- export{a as default}from'../chunk-ZFVK2AWO.js';import'../chunk-FK7R34ZH.js';import'../chunk-6GLPXMGB.js';
1
+ export{a as default}from'../chunk-P7O33B4C.js';import'../chunk-6GLPXMGB.js';
@@ -1 +1 @@
1
- import {a as a$1}from'../chunk-ZFVK2AWO.js';import {a as a$2}from'../chunk-QRYSV225.js';import {a}from'../chunk-FK7R34ZH.js';import'../chunk-6GLPXMGB.js';import {memo,useCallback}from'react';import {jsxs,jsx}from'react/jsx-runtime';function p(...r){return r.filter(Boolean).join(" ")}var u=memo(({name:r,options:m,value:f,onChange:o,size:c="md",direction:g="vertical",error:i,label:l,required:t=false,className:v="",disabled:b=false,radioClassName:R})=>{let x=useCallback(e=>{o&&o(e.target.value);},[o]);return jsxs("div",{className:p("flex flex-col gap-2",v),children:[l&&jsx(a,{label:l,required:t}),jsx("div",{className:p("flex gap-4",g==="vertical"?"flex-col":"flex-row flex-wrap"),role:"radiogroup","aria-label":l,"aria-required":t,children:m.map(e=>jsx(a$1,{name:r,label:e.label,value:e.value,description:e.description,checked:f===e.value,disabled:b||e.disabled,onChange:x,size:c,radioClassName:R,error:!!i},e.value))}),i&&jsx(a$2,{message:i})]})});u.displayName="RadioGroup";var C=u;export{C as default};
1
+ import {a as a$1}from'../chunk-P7O33B4C.js';import {a as a$2}from'../chunk-QRYSV225.js';import {a}from'../chunk-FK7R34ZH.js';import'../chunk-6GLPXMGB.js';import {memo,useCallback}from'react';import {jsxs,jsx}from'react/jsx-runtime';function p(...r){return r.filter(Boolean).join(" ")}var u=memo(({name:r,options:m,value:f,onChange:o,size:c="md",direction:g="vertical",error:i,label:l,required:t=false,className:v="",disabled:b=false,radioClassName:R})=>{let x=useCallback(e=>{o&&o(e.target.value);},[o]);return jsxs("div",{className:p("flex flex-col gap-2",v),children:[l&&jsx(a,{label:l,required:t}),jsx("div",{className:p("flex gap-4",g==="vertical"?"flex-col":"flex-row flex-wrap"),role:"radiogroup","aria-label":l,"aria-required":t,children:m.map(e=>jsx(a$1,{name:r,label:e.label,value:e.value,description:e.description,checked:f===e.value,disabled:b||e.disabled,onChange:x,size:c,radioClassName:R,error:!!i},e.value))}),i&&jsx(a$2,{message:i})]})});u.displayName="RadioGroup";var C=u;export{C as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "the-omelet-ui",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- import {a as a$1}from'./chunk-FK7R34ZH.js';import {a}from'./chunk-6GLPXMGB.js';import {memo,useId}from'react';import {jsx,jsxs}from'react/jsx-runtime';var u=memo(({label:s,name:b,value:f,checked:e=false,disabled:i=false,onChange:p,className:c="",size:g="md",error:o=false,radioClassName:a$2,required:v})=>{let l=useId(),n={sm:{radio:"w-4 h-4",dot:"w-1.5 h-1.5",label:"text-sm",description:"text-xs"},md:{radio:"w-5 h-5",dot:"w-2.5 h-2.5",label:"text-base",description:"text-sm"},lg:{radio:"w-6 h-6",dot:"w-3 h-3",label:"text-lg",description:"text-base"}}[g];return jsx("div",{className:`inline-flex flex-col ${c}`,children:jsxs("label",{htmlFor:l,className:a("inline-flex items-start gap-2 cursor-pointer",i&&"opacity-50 cursor-not-allowed"),children:[jsxs("div",{className:"relative flex items-center justify-center flex-shrink-0 mt-0.5",children:[jsx("input",{type:"radio",id:l,name:b,value:f,checked:e,disabled:i,onChange:p,className:"sr-only peer"}),jsx("div",{className:a(n.radio,"rounded-full border-2 transition-all duration-200 flex items-center justify-center",o&&"border-red-500",!o&&e&&!a$2&&"border-blue-500 bg-blue-500",!o&&!e&&"border-gray-300 bg-white",!o&&!i&&!e&&"peer-hover:border-blue-400",i&&"bg-gray-100","peer-focus-visible:ring-2 peer-focus-visible:ring-blue-500 peer-focus-visible:ring-offset-2",e&&a$2),children:e&&jsx("div",{className:a(n.dot,"rounded-full bg-white transition-all duration-200")})})]}),jsx("div",{className:"flex flex-col",children:s&&jsx(a$1,{label:s,required:v})})]})})});u.displayName="RadioButton";var C=u;export{C as a};