@object-ui/fields 5.0.1 → 5.0.2
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 +12 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/package.json +7 -7
- package/src/index.tsx +13 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @object-ui/fields
|
|
2
2
|
|
|
3
|
+
## 5.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [cab6a93]
|
|
8
|
+
- @object-ui/i18n@5.0.2
|
|
9
|
+
- @object-ui/components@5.0.2
|
|
10
|
+
- @object-ui/react@5.0.2
|
|
11
|
+
- @object-ui/types@5.0.2
|
|
12
|
+
- @object-ui/core@5.0.2
|
|
13
|
+
- @object-ui/providers@5.0.2
|
|
14
|
+
|
|
3
15
|
## 5.0.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -5,4 +5,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
5
5
|
${b?`border-primary bg-primary/5 text-primary`:`border-muted-foreground/25 hover:border-primary/50 text-muted-foreground hover:text-foreground`}
|
|
6
6
|
`,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a.current?.click())},children:[(0,h.jsx)(p.Upload,{className:`size-8 ${b?`text-primary`:`text-muted-foreground`}`}),(0,h.jsxs)(`div`,{className:`text-center`,children:[(0,h.jsx)(`p`,{className:`text-sm font-medium`,children:b?`Drop files here`:`Drag & drop files here`}),(0,h.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`or click to browse`,y?` • use the camera button below`:``]})]})]}),y&&(0,h.jsxs)(f.Button,{type:`button`,variant:`outline`,size:`sm`,className:`w-full`,onClick:e=>{e.stopPropagation(),o.current?.click()},"data-testid":`file-field-camera-button`,children:[(0,h.jsx)(p.Camera,{className:`size-4 mr-2`}),y===`user`?`Take selfie`:`Take photo`]}),D&&(0,h.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,"data-testid":`file-field-uploading`,children:[(0,h.jsx)(p.Loader2,{className:`size-3 animate-spin`}),(0,h.jsxs)(`span`,{children:[`Uploading…`,Object.keys(T).length>0&&` (${Math.round(Object.values(T).reduce((e,t)=>e+t,0)/Object.keys(T).length*100)}%)`]})]}),S.length>0&&(0,h.jsx)(`div`,{className:`space-y-0.5`,children:S.map((e,t)=>(0,h.jsx)(`p`,{className:`text-xs text-destructive`,children:e},t))}),O.length>0&&(0,h.jsx)(`div`,{className:`space-y-1`,children:O.map((e,t)=>(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2 p-2 bg-muted/50 rounded-md border`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[P(e)&&e.url?(0,h.jsx)(`img`,{src:e.url,alt:e.name,className:`size-8 object-cover rounded shrink-0`}):P(e)?(0,h.jsx)(p.ImageIcon,{className:`size-4 text-muted-foreground shrink-0`}):(0,h.jsx)(p.File,{className:`size-4 text-muted-foreground shrink-0`}),(0,h.jsx)(`span`,{className:`text-sm truncate`,children:e.name||e.original_name||`File`}),e.size&&(0,h.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,(e.size/1024).toFixed(1),` KB)`]})]}),(0,h.jsx)(f.Button,{type:`button`,variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),N(t)},className:`h-6 w-6 p-0`,children:(0,h.jsx)(p.X,{className:`size-3`})})]},t))})]})]})}var Re=o((()=>{})),ze=s({ImageCropperDialog:()=>Be}),Be,Ve=o((()=>{Be=({open:e,onOpenChange:t,src:n,outputType:r=`image/png`,outputName:i=`cropped.png`,onConfirm:a})=>{let o=(0,u.useRef)(null),s=(0,u.useRef)(null),[c,l]=(0,u.useState)(0),[d,m]=(0,u.useState)({x:0,y:0,width:100,height:100}),[g,_]=(0,u.useState)(null),[v,y]=(0,u.useState)(!1);(0,u.useEffect)(()=>{if(!e||!n)return;y(!1);let t=new Image;t.crossOrigin=`anonymous`,t.onload=()=>{s.current=t;let e=t.naturalWidth*.8,n=t.naturalHeight*.8;m({x:(t.naturalWidth-e)/2,y:(t.naturalHeight-n)/2,width:e,height:n}),l(0),y(!0)},t.onerror=()=>y(!1),t.src=n},[e,n]),(0,u.useEffect)(()=>{if(!v||!s.current||!o.current)return;let e=s.current,t=o.current,n=t.getContext(`2d`);if(!n)return;let r=480/e.naturalWidth,i=e.naturalHeight*r;t.width=480,t.height=i,n.clearRect(0,0,480,i),n.save(),n.translate(480/2,i/2),n.rotate(c*Math.PI/180);let a=c%180==0?480:i,l=c%180==0?i:480;n.drawImage(e,-a/2,-l/2,a,l),n.restore();let u=d.x*r,f=d.y*r,p=d.width*r,m=d.height*r;n.fillStyle=`rgba(0,0,0,0.45)`,n.fillRect(0,0,480,f),n.fillRect(0,f+m,480,i-f-m),n.fillRect(0,f,u,m),n.fillRect(u+p,f,480-u-p,m),n.strokeStyle=`#3b82f6`,n.lineWidth=2,n.strokeRect(u,f,p,m)},[v,d,c]);let b=(0,u.useCallback)(e=>{if(!s.current||!o.current)return;let t=o.current.getBoundingClientRect(),n=s.current.naturalWidth/t.width;_({ox:(e.clientX-t.left)*n,oy:(e.clientY-t.top)*n,cx:d.x,cy:d.y}),e.target.setPointerCapture(e.pointerId)},[d]),x=(0,u.useCallback)(e=>{if(!g||!s.current||!o.current)return;let t=o.current.getBoundingClientRect(),n=s.current.naturalWidth/t.width,r=(e.clientX-t.left)*n-g.ox,i=(e.clientY-t.top)*n-g.oy,a=Math.max(0,Math.min(g.cx+r,s.current.naturalWidth-d.width)),c=Math.max(0,Math.min(g.cy+i,s.current.naturalHeight-d.height));m(e=>({...e,x:a,y:c}))},[g,d.width,d.height]),S=(0,u.useCallback)(()=>_(null),[]),C=(0,u.useCallback)(()=>l(e=>(e+90)%360),[]),w=(0,u.useCallback)(async()=>{if(!s.current)return;let e=s.current,n=document.createElement(`canvas`),o=d.width,l=d.height;n.width=c%180==0?o:l,n.height=c%180==0?l:o;let u=n.getContext(`2d`);if(!u)return;u.save(),u.translate(n.width/2,n.height/2),u.rotate(c*Math.PI/180),u.drawImage(e,d.x,d.y,o,l,-o/2,-l/2,o,l),u.restore();let f=await new Promise(e=>n.toBlob(e,r));f&&(a(f,i),t(!1))},[d,c,i,r,a,t]);return(0,h.jsx)(f.Dialog,{open:e,onOpenChange:t,children:(0,h.jsxs)(f.DialogContent,{className:`max-w-xl`,children:[(0,h.jsxs)(f.DialogHeader,{children:[(0,h.jsx)(f.DialogTitle,{children:`Crop & rotate image`}),(0,h.jsx)(f.DialogDescription,{children:`Drag the highlighted box to reposition the crop. Use the rotate button to spin the image in 90° increments.`})]}),(0,h.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[v?(0,h.jsx)(`canvas`,{ref:o,"data-testid":`image-cropper-canvas`,role:`img`,"aria-label":`Image crop preview`,className:`border rounded-md cursor-move touch-none max-w-full`,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:S}):(0,h.jsx)(`div`,{className:`flex h-[270px] w-full items-center justify-center text-sm text-muted-foreground`,children:`Loading image…`}),(0,h.jsxs)(`div`,{className:`flex w-full items-center justify-between text-xs text-muted-foreground`,children:[(0,h.jsxs)(`span`,{children:[`Crop: `,Math.round(d.width),` × `,Math.round(d.height),` px`]}),(0,h.jsxs)(`span`,{children:[`Rotation: `,c,`°`]})]})]}),(0,h.jsxs)(f.DialogFooter,{className:`flex justify-between sm:justify-between`,children:[(0,h.jsxs)(f.Button,{type:`button`,variant:`outline`,onClick:C,"data-testid":`image-cropper-rotate`,children:[(0,h.jsx)(p.RotateCw,{className:`size-4 mr-2`}),`Rotate 90°`]}),(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(f.Button,{type:`button`,variant:`ghost`,onClick:()=>t(!1),children:`Cancel`}),(0,h.jsxs)(f.Button,{type:`button`,onClick:w,disabled:!v,"data-testid":`image-cropper-confirm`,children:[(0,h.jsx)(p.Crop,{className:`size-4 mr-2`}),`Apply crop`]})]})]})]})})}})),He=s({ImageField:()=>Ue});function Ue({value:e,onChange:t,field:n,readonly:r,...i}){let a=(0,u.useRef)(null),o=n||i.schema,s=o?.multiple||!1,c=o?.accept?o.accept.join(`,`):`image/*`,l=o?.crop!==!1,[d,m]=(0,u.useState)(null),{upload:g}=(0,_.useUpload)(),[v,y]=(0,u.useState)(!1);if(r)return e?(0,h.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(Array.isArray(e)?e:[e]).map((e,t)=>(0,h.jsx)(`img`,{src:e.url||``,alt:e.name||`Image ${t+1}`,className:`size-20 rounded-md object-cover border border-gray-200`},t))}):(0,h.jsx)(f.EmptyValue,{});let b=e?Array.isArray(e)?e:[e]:[],x=async e=>{let n=Array.from(e.target.files||[]);if(n.length!==0){y(!0);try{let e=await Promise.all(n.map(async e=>{let t=await g(e);return{name:t.name,original_name:e.name,size:t.size,mime_type:t.mimeType,url:t.url}}));t(s?[...b,...e]:e[0])}finally{y(!1),a.current&&(a.current.value=``)}}},S=e=>{if(s){let n=b.filter((t,n)=>n!==e);t(n.length>0?n:null)}else t(null)},C=(0,u.useCallback)(async(e,n)=>{if(d){y(!0);try{let r=await g(e),i={name:r.name||n,original_name:n,size:r.size,mime_type:r.mimeType,url:r.url};if(s){let e=[...b];e[d.index]=i,t(e)}else t(i)}finally{y(!1),m(null)}}},[d,b,s,t,g]),w=(0,u.useCallback)(e=>{let t=b[e];t?.url&&m({index:e,src:t.url,name:t.name||`image-${e}.png`})},[b]);return(0,h.jsxs)(`div`,{className:i.className,children:[(0,h.jsx)(`input`,{ref:a,type:`file`,multiple:s,accept:c,onChange:x,className:`hidden`}),(0,h.jsxs)(`div`,{className:`space-y-2`,children:[b.length>0&&(0,h.jsx)(`div`,{className:`grid grid-cols-4 gap-2`,children:b.map((e,t)=>(0,h.jsxs)(`div`,{className:`relative group`,children:[(0,h.jsx)(`img`,{src:e.url||``,alt:e.name||`Image ${t+1}`,className:`size-20 rounded-md object-cover border border-gray-200`}),(0,h.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[l&&(0,h.jsx)(f.Button,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>w(t),className:`h-6 w-6 p-0`,"aria-label":`Crop image ${t+1}`,"data-testid":`image-field-crop-${t}`,children:(0,h.jsx)(p.Crop,{className:`size-3`})}),(0,h.jsx)(f.Button,{type:`button`,variant:`destructive`,size:`sm`,onClick:()=>S(t),className:`h-6 w-6 p-0`,children:(0,h.jsx)(p.X,{className:`size-3`})})]})]},t))}),(0,h.jsxs)(f.Button,{type:`button`,variant:`outline`,onClick:()=>a.current?.click(),className:`w-full`,disabled:v,"data-testid":`image-field-upload-button`,children:[v?(0,h.jsx)(p.Loader2,{className:`size-4 mr-2 animate-spin`}):(0,h.jsx)(p.Image,{className:`size-4 mr-2`}),v?`Uploading…`:b.length>0?`Add More Images`:`Upload Image`]})]}),l&&d&&(0,h.jsx)(u.Suspense,{fallback:null,children:(0,h.jsx)(We,{open:!0,onOpenChange:e=>!e&&m(null),src:d.src,outputName:d.name,onConfirm:C})})]})}var We,Ge=o((()=>{We=(0,u.lazy)(()=>Promise.resolve().then(()=>(Ve(),ze)).then(e=>({default:e.ImageCropperDialog})))})),Ke=s({LocationField:()=>qe});function qe({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema,o=e&&typeof e==`object`?`${e.latitude||0}, ${e.longitude||0}`:``;return r?(0,h.jsx)(`span`,{className:`text-sm`,children:o||(0,h.jsx)(f.EmptyValue,{})}):(0,h.jsx)(f.Input,{type:`text`,value:o,onChange:e=>{let n=e.target.value;if(!n.trim()){t(null);return}let r=n.split(`,`).map(e=>e.trim());if(r.length===2){let e=parseFloat(r[0]),n=parseFloat(r[1]);!isNaN(e)&&!isNaN(n)&&t({latitude:e,longitude:n})}},placeholder:a?.placeholder||`latitude, longitude`,disabled:r||i.disabled,className:i.className})}var Je=o((()=>{})),Ye=s({FormulaField:()=>Xe});function Xe({value:e,field:t,...n}){let r=(t||n.schema)?.return_type||`text`;if(e==null)return(0,h.jsx)(f.EmptyValue,{className:n.className});let i;return i=r===`number`||r===`currency`?typeof e==`number`?e.toFixed(2):String(e):r===`boolean`?e?`Yes`:`No`:r===`date`?new Date(e).toLocaleDateString():String(e),(0,h.jsx)(`span`,{className:`text-sm font-mono text-gray-700 ${n.className||``}`,children:i})}var Ze=o((()=>{})),Qe=s({SummaryField:()=>$e});function $e({value:e,field:t,...n}){let r=(t||n.schema)?.summary_type||`count`;if(e==null)return(0,h.jsx)(f.EmptyValue,{className:n.className});let i;return i=r===`count`?String(e):[`sum`,`avg`,`min`,`max`].includes(r)&&typeof e==`number`?e.toFixed(2):String(e),(0,h.jsx)(`span`,{className:`text-sm font-medium tabular-nums text-gray-700 ${n.className||``}`,children:i})}var et=o((()=>{})),tt=s({AutoNumberField:()=>nt});function nt({value:e,field:t,...n}){return e==null?(0,h.jsx)(f.EmptyValue,{className:n.className}):(0,h.jsx)(`span`,{className:`text-sm font-mono text-gray-700 ${n.className||``}`,children:String(e)})}var rt=o((()=>{})),it=s({UserField:()=>at});function at({value:e,onChange:t,field:n,readonly:r,...i}){let a=(n||i.schema)?.multiple||!1;if(r){if(!e)return(0,h.jsx)(f.EmptyValue,{});let t=Array.isArray(e)?e:[e];return(0,h.jsxs)(`div`,{className:`flex -space-x-2`,children:[t.slice(0,3).map((e,t)=>{let n=e.name||e.username||`User`;return(0,h.jsx)(f.Avatar,{className:`size-8 border-2 border-white`,title:n,children:(0,h.jsx)(f.AvatarFallback,{className:`bg-blue-500 text-white text-xs`,children:n.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)})},t)}),t.length>3&&(0,h.jsx)(f.Avatar,{className:`size-8 border-2 border-white`,children:(0,h.jsxs)(f.AvatarFallback,{className:`bg-gray-200 text-gray-600 text-xs`,children:[`+`,t.length-3]})})]})}let o=e?Array.isArray(e)?e:[e]:[],s=e=>{if(a){let n=o.filter((t,n)=>n!==e);t(n.length>0?n:null)}else t(null)};return(0,h.jsxs)(`div`,{className:i.className,children:[o.length>0&&(0,h.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-2`,children:o.map((e,t)=>{let n=e.name||e.username||`User`;return(0,h.jsxs)(f.Badge,{variant:`outline`,className:`gap-2 pr-1`,children:[(0,h.jsx)(f.Avatar,{className:`size-5`,children:(0,h.jsx)(f.AvatarFallback,{className:`bg-blue-500 text-white text-xs`,children:n.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)})}),(0,h.jsx)(`span`,{className:`text-sm`,children:n}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`ml-1 rounded-full hover:bg-gray-200 p-0.5`,children:(0,h.jsx)(p.X,{className:`size-3`})})]},t)})}),(0,h.jsx)(`div`,{className:`text-sm text-gray-500 italic`,children:`User selection component requires integration with user management system`})]})}var ot=o((()=>{})),st=s({ObjectField:()=>ct});function ct({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema,[o,s]=(0,u.useState)(()=>e==null?``:JSON.stringify(e,null,2)),[c,l]=(0,u.useState)(null);return(0,u.useEffect)(()=>{try{if(e==null){s(``);return}let t=o?JSON.parse(o):null;JSON.stringify(t)!==JSON.stringify(e)&&s(JSON.stringify(e,null,2))}catch{s(JSON.stringify(e,null,2))}},[e,o]),r?e?(0,h.jsx)(`pre`,{className:(0,f.cn)(`text-xs bg-gray-50 p-2 rounded border border-gray-200 overflow-auto max-h-40`,i.className),children:JSON.stringify(e,null,2)}):(0,h.jsx)(f.EmptyValue,{}):(0,h.jsxs)(`div`,{className:`space-y-1`,children:[(0,h.jsx)(f.Textarea,{value:o,onChange:e=>{let n=e.target.value;if(s(n),l(null),!n.trim()){t(null);return}try{t(JSON.parse(n))}catch{l(`Invalid JSON`)}},placeholder:a?.placeholder||`{
|
|
7
7
|
"key": "value"
|
|
8
|
-
}`,disabled:r||i.disabled,className:(0,f.cn)(`font-mono text-xs`,c?`border-red-500 focus-visible:ring-red-500`:``,i.className),rows:6}),c&&(0,h.jsx)(`p`,{className:`text-xs text-red-500`,children:c})]})}var lt=o((()=>{})),ut=s({VectorField:()=>dt});function dt({value:e,field:t,...n}){let r=(t||n.schema)?.dimensions||(Array.isArray(e)?e.length:0);if(!e||!Array.isArray(e))return(0,h.jsx)(f.EmptyValue,{});let i=e.slice(0,3).map(e=>{let t=Number(e);return isNaN(t)?`0`:t.toFixed(4)}).join(`, `);return(0,h.jsxs)(`div`,{className:`text-sm ${n.className||``}`,children:[(0,h.jsxs)(`span`,{className:`font-mono text-gray-700`,children:[`[`,i,`...]`]}),(0,h.jsxs)(`span`,{className:`text-gray-500 ml-2`,children:[`(`,r,`D)`]})]})}var ft=o((()=>{})),pt=s({GridField:()=>mt});function mt({value:e,field:t,readonly:n,...r}){let i=(t||r.schema)?.columns||[];return!e||!Array.isArray(e)?(0,h.jsx)(f.EmptyValue,{}):n?(0,h.jsx)(`div`,{className:(0,f.cn)(`text-sm`,r.className),children:(0,h.jsxs)(`span`,{className:`text-foreground`,children:[e.length,` rows`]})}):(0,h.jsxs)(`div`,{className:(0,f.cn)(`border border-border rounded-lg overflow-hidden`,r.className),children:[(0,h.jsx)(`div`,{className:`overflow-auto max-h-60`,children:(0,h.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,h.jsx)(`thead`,{className:`bg-muted border-b border-border`,children:(0,h.jsx)(`tr`,{children:i.map((e,t)=>(0,h.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:e.label||e.name},t))})}),(0,h.jsx)(`tbody`,{className:`divide-y divide-border`,children:e.slice(0,5).map((e,t)=>(0,h.jsx)(`tr`,{className:`hover:bg-muted/50 transition-colors`,children:i.map((t,n)=>(0,h.jsx)(`td`,{className:`px-3 py-2 text-foreground`,children:e[t.name]==null?(0,h.jsx)(f.EmptyValue,{}):String(e[t.name])},n))},t))})]})}),e.length>5&&(0,h.jsxs)(`div`,{className:`bg-muted px-3 py-2 text-xs text-muted-foreground border-t border-border`,children:[`Showing 5 of `,e.length,` rows`]})]})}var ht=o((()=>{})),gt=s({ColorField:()=>_t});function _t({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema;return r?(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`div`,{className:`w-6 h-6 rounded border border-input`,style:{backgroundColor:e||`#000000`}}),(0,h.jsx)(`span`,{className:`text-sm`,children:e||(0,h.jsx)(f.EmptyValue,{})})]}):(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`input`,{type:`color`,value:e||`#000000`,onChange:e=>t(e.target.value),disabled:r||i.disabled,className:`w-10 h-10 rounded border border-input cursor-pointer`}),(0,h.jsx)(f.Input,{type:`text`,value:e||``,onChange:e=>t(e.target.value),placeholder:a?.placeholder||`#000000`,disabled:r||i.disabled,className:i.className,pattern:`^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$`})]})}var vt=o((()=>{})),yt=s({SliderField:()=>bt});function bt({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema,o=a?.min??0,s=a?.max??100,c=a?.step??1;return r?(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-sm font-medium`,children:e??o}),(0,h.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,s]})]}):(0,h.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,h.jsx)(f.Slider,{value:[e??o],onValueChange:e=>t(e[0]),min:o,max:s,step:c,disabled:r||i.disabled,className:i.className}),(0,h.jsx)(`span`,{className:`text-sm font-medium w-12 text-right`,children:e??o})]})}var xt=o((()=>{})),St=s({RatingField:()=>Ct});function Ct({value:e,onChange:t,field:n,readonly:r,className:i,...a}){let o=(n||a.schema)?.max??5,s=e??0,[c,l]=u.default.useState(null),d=c===null?s:c;return r?(0,h.jsxs)(`div`,{className:(0,f.cn)(`flex items-center gap-1`,i),children:[Array.from({length:o},(e,t)=>(0,h.jsx)(p.Star,{className:`w-5 h-5 ${t<s?`fill-yellow-400 text-yellow-400`:`text-muted-foreground`}`},t)),(0,h.jsxs)(`span`,{className:`ml-2 text-sm text-muted-foreground`,children:[s,` / `,o]})]}):(0,h.jsxs)(`div`,{className:(0,f.cn)(`flex items-center gap-1`,i),children:[Array.from({length:o},(e,n)=>(0,h.jsx)(`button`,{type:`button`,onClick:()=>t(n+1),onMouseEnter:()=>l(n+1),onMouseLeave:()=>l(null),className:`focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded`,disabled:r||a.disabled,children:(0,h.jsx)(p.Star,{className:`w-5 h-5 transition-colors ${n<d?`fill-yellow-400 text-yellow-400 hover:fill-yellow-500 hover:text-yellow-500`:`text-muted-foreground hover:text-yellow-400`}`})},n)),(0,h.jsxs)(`span`,{className:`ml-2 text-sm text-muted-foreground`,children:[s,` / `,o]})]})}var wt=o((()=>{})),Tt=s({CodeField:()=>Et});function Et({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema,o=a?.language??`javascript`;return r?(0,h.jsx)(`pre`,{className:(0,f.cn)(`text-sm bg-muted p-2 rounded overflow-x-auto border`,i.className),children:(0,h.jsx)(`code`,{children:e||(0,h.jsx)(f.EmptyValue,{})})}):(0,h.jsx)(f.Textarea,{value:e||``,onChange:e=>t(e.target.value),placeholder:a?.placeholder||`// Write ${o} code here...`,disabled:r||i.disabled,className:(0,f.cn)(`font-mono text-sm`,i.className),rows:12,spellCheck:!1})}var Dt=o((()=>{})),Ot=s({AvatarField:()=>kt});function kt({value:e,onChange:t,field:n,readonly:r,...i}){let[a,o]=u.default.useState(!1),s=u.default.useRef(null),c=n||i.schema,l=e=>{let n=e.target.files?.[0];if(!n)return;if(!n.type.startsWith(`image/`)){console.error(`Please select an image file`);return}if(n.size>5*1024*1024){console.error(`File size must be less than 5MB`);return}let r=new FileReader;r.onloadend=()=>{t(r.result)},r.readAsDataURL(n)},d=()=>{t(``)},m=()=>(c?.defaultName||c?.label||`User`).split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return r?(0,h.jsxs)(f.Avatar,{className:`w-16 h-16`,children:[e&&(0,h.jsx)(f.AvatarImage,{src:e,alt:c?.label}),(0,h.jsx)(f.AvatarFallback,{children:m()})]}):(0,h.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,h.jsxs)(`div`,{className:`relative`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[(0,h.jsxs)(f.Avatar,{className:`w-16 h-16`,children:[e&&(0,h.jsx)(f.AvatarImage,{src:e,alt:c?.label}),(0,h.jsx)(f.AvatarFallback,{children:m()})]}),!r&&a&&e&&(0,h.jsx)(`button`,{type:`button`,onClick:d,className:`absolute -top-1 -right-1 bg-destructive text-destructive-foreground rounded-full p-1 hover:bg-destructive/90`,children:(0,h.jsx)(p.X,{className:`w-3 h-3`})})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`input`,{ref:s,type:`file`,accept:`image/*`,onChange:l,className:`hidden`}),(0,h.jsxs)(f.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>s.current?.click(),disabled:r||i.disabled,children:[(0,h.jsx)(p.Upload,{className:`w-4 h-4 mr-2`}),e?`Change`:`Upload`,` Avatar`]}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`PNG, JPG up to 5MB`})]})]})}var At=o((()=>{})),jt=s({AddressField:()=>Mt});function Mt({value:e,onChange:t,field:n,readonly:r,...i}){let a=e||{},o=(e,n)=>{t({...a,[e]:n})},s=e=>[e.street,e.city,[e.state,e.zipCode].filter(Boolean).join(` `),e.country].filter(Boolean).join(`, `);if(r){let e=s(a);return e?(0,h.jsx)(`span`,{className:`text-sm`,children:e}):(0,h.jsx)(f.EmptyValue,{})}return(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`street`,className:`text-xs`,children:`Street Address`}),(0,h.jsx)(f.Input,{id:`street`,type:`text`,value:a.street||``,onChange:e=>o(`street`,e.target.value),placeholder:`123 Main St`,disabled:r||i.disabled,className:i.className})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`city`,className:`text-xs`,children:`City`}),(0,h.jsx)(f.Input,{id:`city`,type:`text`,value:a.city||``,onChange:e=>o(`city`,e.target.value),placeholder:`San Francisco`,disabled:r||i.disabled})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`state`,className:`text-xs`,children:`State / Province`}),(0,h.jsx)(f.Input,{id:`state`,type:`text`,value:a.state||``,onChange:e=>o(`state`,e.target.value),placeholder:`CA`,disabled:r||i.disabled})]})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`zipCode`,className:`text-xs`,children:`ZIP / Postal Code`}),(0,h.jsx)(f.Input,{id:`zipCode`,type:`text`,value:a.zipCode||``,onChange:e=>o(`zipCode`,e.target.value),placeholder:`94102`,disabled:r||i.disabled})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`country`,className:`text-xs`,children:`Country`}),(0,h.jsx)(f.Input,{id:`country`,type:`text`,value:a.country||``,onChange:e=>o(`country`,e.target.value),placeholder:`United States`,disabled:r||i.disabled})]})]})]})}var Nt=o((()=>{})),Pt=s({GeolocationField:()=>Ft});function Ft({value:e,onChange:t,field:n,readonly:r,...i}){let[a,o]=u.default.useState(!1),s=e||{},c=(e,n)=>{t({...s,[e]:n?Number(n):void 0})},l=()=>{if(!navigator.geolocation){console.error(`Geolocation is not supported by this browser`);return}o(!0),navigator.geolocation.getCurrentPosition(e=>{t({latitude:e.coords.latitude,longitude:e.coords.longitude,accuracy:e.coords.accuracy}),o(!1)},e=>{console.error(`Error getting location:`,e.message),o(!1)},{enableHighAccuracy:!0,timeout:5e3,maximumAge:0})},d=e=>!e.latitude||!e.longitude?``:`${e.latitude.toFixed(6)}, ${e.longitude.toFixed(6)}`,m=()=>{if(!s.latitude||!s.longitude)return;let e=`https://www.google.com/maps?q=${s.latitude},${s.longitude}`;window.open(e,`_blank`)};if(r){let e=d(s);return(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(p.MapPin,{className:`w-4 h-4 text-muted-foreground`}),e?(0,h.jsx)(`span`,{className:`text-sm`,children:e}):(0,h.jsx)(f.EmptyValue,{}),s.latitude&&s.longitude&&(0,h.jsx)(f.Button,{type:`button`,variant:`link`,size:`sm`,onClick:m,className:`p-0 h-auto`,children:`View on map`})]})}return(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsxs)(f.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:l,disabled:r||a,children:[(0,h.jsx)(p.Crosshair,{className:`w-4 h-4 mr-2`}),a?`Getting location...`:`Use Current Location`]}),s.latitude&&s.longitude&&(0,h.jsxs)(f.Button,{type:`button`,variant:`link`,size:`sm`,onClick:m,children:[(0,h.jsx)(p.MapPin,{className:`w-4 h-4 mr-2`}),`View on map`]})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`latitude`,className:`text-xs`,children:`Latitude`}),(0,h.jsx)(f.Input,{id:`latitude`,type:`number`,value:s.latitude??``,onChange:e=>c(`latitude`,e.target.value),placeholder:`37.7749`,disabled:r||i.disabled,step:`any`,className:i.className})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`longitude`,className:`text-xs`,children:`Longitude`}),(0,h.jsx)(f.Input,{id:`longitude`,type:`number`,value:s.longitude??``,onChange:e=>c(`longitude`,e.target.value),placeholder:`-122.4194`,disabled:r||i.disabled,step:`any`})]})]}),s.accuracy&&(0,h.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Accuracy: ±`,s.accuracy.toFixed(0),`m`]})]})}var It=o((()=>{})),Lt=s({SignatureField:()=>Rt});function Rt({value:e,onChange:t,readonly:n}){let r=(0,u.useRef)(null),[i,a]=u.default.useState(!1),[o,s]=u.default.useState(!e);(0,u.useEffect)(()=>{if(e&&r.current){let t=r.current.getContext(`2d`);if(t){let n=new Image;n.onload=()=>{t.drawImage(n,0,0),s(!1)},n.src=e}}},[e]);let c=e=>{if(n)return;a(!0),s(!1);let t=r.current;if(!t)return;let i=t.getContext(`2d`);if(!i)return;let o=t.getBoundingClientRect(),c=`touches`in e?e.touches[0].clientX-o.left:e.clientX-o.left,l=`touches`in e?e.touches[0].clientY-o.top:e.clientY-o.top;i.beginPath(),i.moveTo(c,l)},l=e=>{if(!i||n)return;let t=r.current;if(!t)return;let a=t.getContext(`2d`);if(!a)return;let o=t.getBoundingClientRect(),s=`touches`in e?e.touches[0].clientX-o.left:e.clientX-o.left,c=`touches`in e?e.touches[0].clientY-o.top:e.clientY-o.top;a.lineTo(s,c),a.strokeStyle=`#000`,a.lineWidth=2,a.lineCap=`round`,a.lineJoin=`round`,a.stroke()},d=()=>{if(!i)return;a(!1);let e=r.current;e&&t(e.toDataURL(`image/png`))};return n&&e?(0,h.jsx)(`div`,{className:`border rounded p-2 bg-white`,children:(0,h.jsx)(`img`,{src:e,alt:`Signature`,loading:`lazy`,className:`max-w-full h-auto`})}):n&&!e?(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`No signature`}):(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`div`,{className:`border rounded bg-white`,children:(0,h.jsx)(`canvas`,{ref:r,width:400,height:200,className:`w-full touch-none cursor-crosshair`,onMouseDown:c,onMouseMove:l,onMouseUp:d,onMouseLeave:d,onTouchStart:c,onTouchMove:l,onTouchEnd:d})}),(0,h.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?`Sign above`:`Signature captured`}),(0,h.jsxs)(f.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{let e=r.current;if(!e)return;let n=e.getContext(`2d`);n&&(n.clearRect(0,0,e.width,e.height),s(!0),t(``))},disabled:n||o,children:[(0,h.jsx)(p.Eraser,{className:`w-4 h-4 mr-2`}),`Clear`]})]})]})}var zt=o((()=>{})),Bt=s({QRCodeField:()=>Vt});function Vt({value:e,onChange:t,field:n,readonly:r,...i}){let[a,o]=u.default.useState(!1),s=n||i.schema;return r?(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`span`,{className:`text-sm flex-1 truncate`,children:e||(0,h.jsx)(f.EmptyValue,{})}),e&&(0,h.jsxs)(f.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(!a),children:[(0,h.jsx)(p.QrCode,{className:`w-4 h-4 mr-2`}),a?`Hide`:`Show`,` QR`]})]}):(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(f.Input,{type:`text`,value:e||``,onChange:e=>t(e.target.value),placeholder:s?.placeholder||`Enter text for QR code`,disabled:r||i.disabled,className:i.className}),e&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(f.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{e&&navigator.clipboard.writeText(e)},children:(0,h.jsx)(p.Copy,{className:`w-4 h-4`})}),(0,h.jsx)(f.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(!a),children:(0,h.jsx)(p.QrCode,{className:`w-4 h-4`})})]})]}),a&&e&&(0,h.jsx)(`div`,{className:`border rounded p-4 bg-white flex justify-center`,children:(0,h.jsx)(`img`,{src:(e=>`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(e)}`)(e),alt:`QR Code`,className:`w-48 h-48`})}),e&&(0,h.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`QR code contains: `,e.length,` characters`]})]})}var Ht=o((()=>{}));b(),C(),E(),te(),N(),I(),R(),B(),U(),oe(),se(),we(),De(),Z(),Me(),Fe(),Re(),Ge(),Je(),Ze(),et(),rt(),ot(),lt(),ft(),ht(),vt(),xt(),wt(),Dt(),At(),Nt(),It(),zt(),Ht(),Ve();function Ut({value:e,onChange:t,field:n,readonly:r,className:i,...a}){let o=e||[],s=n||a.schema,c=()=>{let e={id:`new-${Date.now()}`,label:`New Related Record`};t([...o,e])},l=e=>{t(o.filter(t=>t.id!==e))},u=e=>{console.log(`View detail:`,e)};return r?(0,h.jsxs)(`div`,{className:(0,f.cn)(`space-y-2`,i),children:[o.length===0?(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`No related records`}):o.map(e=>(0,h.jsxs)(`div`,{className:`flex items-center justify-between p-2 border rounded hover:bg-muted/50`,children:[(0,h.jsx)(`span`,{className:`text-sm`,children:e.label}),(0,h.jsx)(f.Button,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>u(e),children:(0,h.jsx)(p.ExternalLink,{className:`w-4 h-4`})})]},e.id)),(0,h.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[o.length,` `,o.length===1?`record`:`records`]})]}):(0,h.jsxs)(`div`,{className:(0,f.cn)(`space-y-3`,i),children:[(0,h.jsxs)(`div`,{className:`space-y-2`,children:[o.map(e=>(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2 p-2 border rounded hover:bg-muted/50`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,h.jsx)(f.Badge,{variant:`outline`,children:e.id}),(0,h.jsx)(`span`,{className:`text-sm flex-1`,children:e.label})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(f.Button,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>u(e),children:(0,h.jsx)(p.ExternalLink,{className:`w-4 h-4`})}),(0,h.jsx)(f.Button,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>l(e.id),disabled:a.disabled,children:(0,h.jsx)(p.X,{className:`w-4 h-4`})})]})]},e.id)),o.length===0&&(0,h.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-4 border border-dashed rounded bg-muted/20`,children:`No related records`})]}),(0,h.jsxs)(f.Button,{type:`button`,variant:`outline`,className:`w-full`,onClick:c,disabled:a.disabled,children:[(0,h.jsx)(p.Plus,{className:`w-4 h-4 mr-2`}),`Add `,s?.label||`Record`]})]})}ge(),b(),C(),E(),te(),N(),De(),Z(),I(),R(),B(),U(),Me(),Fe(),oe(),se(),we(),Y(),Re(),Ge(),Je(),Ze(),et(),rt(),ot(),lt(),ft(),ht(),vt(),xt(),wt(),Dt(),At(),Nt(),It(),zt(),Ht();var Wt=new Map;function Gt(e){if(!e||typeof e!=`object`)return;for(let t of[`name`,`full_name`,`display_name`,`label`,`title`,`subject`,`username`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim();if(typeof n==`number`)return String(n)}let t=e.first_name,n=e.last_name,r=[e.salutation,t,n].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `);if(r)return r;let i=e.email;if(typeof i==`string`&&i.trim())return i.trim()}function Kt(e){if(typeof e!=`string`||!/^[A-Za-z0-9_-]{12,32}$/.test(e))return!1;let t=/[A-Z]/.test(e),n=/[a-z]/.test(e),r=/[0-9_-]/.test(e);return t&&n||t&&r||n&&r}function qt(e,t){let n=u.default.useContext(m.SchemaRendererContext)?.dataSource,[,r]=u.default.useState(0),i=!!e&&!!n&&typeof n.find==`function`&&(typeof t==`string`||typeof t==`number`)&&t!==``,a=i?`${e}:${String(t)}`:``;if(u.default.useEffect(()=>{if(!i)return;let o=Wt.get(a);if(o&&o.state!==`pending`&&o.promise==null||o?.state===`pending`)return;let s=(async()=>{try{let r;if(typeof n.findOne==`function`)r=await n.findOne(e,t);else{let i=await n.find(e,{$filter:{id:t},options:{$top:1}});r=(Array.isArray(i)?i:i?.value||i?.data||[])[0]}let i=Gt(r);Wt.set(a,{state:`ok`,name:i})}catch{Wt.set(a,{state:`err`})}r(e=>e+1)})();Wt.set(a,{state:`pending`,promise:s})},[a,i,e,t,n]),!i)return;let o=Wt.get(a);return o?.state===`ok`?o.name:void 0}function Jt(){try{let{t:e}=(0,m.useObjectTranslation)();return(t,n)=>{let r=e(t);return!r||r===t?n:r}}catch{return(e,t)=>t}}function Q(e){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(e=>{if(typeof e==`object`&&e){let t=e;return String(t.name||t.label||t.id||t._id||`[Object]`)}return String(e)}).join(`, `);if(typeof e==`object`){let t=e;return`$numberDecimal`in t?Number(t.$numberDecimal):`$oid`in t?String(t.$oid):`$date`in t?String(t.$date):String(t.name||t.label||t.id||t._id||`[Object]`)}return String(e)}function Yt(e,t=`USD`){try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t}).format(e)}catch{return`${t} ${e.toFixed(2)}`}}function Xt(e,t=`USD`){try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t,notation:`compact`,maximumFractionDigits:1}).format(e).replace(/\.0(?=[KMBT])/,``)}catch{return`${t} ${e}`}}function Zt(e,t=2){try{return new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e)}catch{return e.toFixed(t)}}function Qt(e,t=0){return`${(e>-1&&e<1?e*100:e).toFixed(t)}%`}function $t(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function en(e){if(e==null||e===``)return`—`;let t=e instanceof Date?e:new Date(e);if(!(t instanceof Date)||isNaN(t.getTime()))return`—`;let n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()-r.getTime(),a=Math.round(i/(1e3*60*60*24));if(a===0)return`Today`;if(a===1)return`Tomorrow`;if(a===-1)return`Yesterday`;if(a<-1){let e=Math.abs(a);return e<=7?`Overdue ${e}d`:tn(t)}return a>1&&a<=7?`In ${a} days`:tn(t)}function tn(e,t){if(e==null||e===``)return`—`;let n=e instanceof Date?e:new Date(e);return!(n instanceof Date)||isNaN(n.getTime())?`—`:t===`short`?`${n.toLocaleDateString(`en-US`,{month:`short`})} ${n.getDate()}, '${String(n.getFullYear()).slice(-2)}`:t===`relative`?en(n):n.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function nn(e){if(e==null||e===``)return`—`;let t=e instanceof Date?e:new Date(e);return!(t instanceof Date)||isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function rn({value:e}){let t=Q(e);return t==null||t===``?(0,h.jsx)(f.EmptyValue,{}):(0,h.jsx)(`span`,{className:`truncate`,children:String(t)})}function an({value:e,field:t}){if(e==null)return(0,h.jsx)(f.EmptyValue,{});let n=Q(e),r=t.precision??0,i=Number(n);return(0,h.jsx)(`span`,{className:`tabular-nums`,children:isNaN(i)?String(n):new Intl.NumberFormat(`en-US`,{minimumFractionDigits:r,maximumFractionDigits:r}).format(i)})}function on({value:e,field:t}){if(e==null)return(0,h.jsx)(f.EmptyValue,{});let n=Q(e),r=t,i=r.currency||r.defaultCurrency,a=Number(n),o=r.precision??r.scale??r.decimals??2;return(0,h.jsx)(`span`,{className:`tabular-nums font-medium whitespace-nowrap`,children:isNaN(a)?String(n):i?Yt(a,i):Zt(a,o)})}var sn=/progress|completion/;function cn({value:e,field:t}){if(e==null)return(0,h.jsx)(f.EmptyValue,{});let n=Q(e),r=t.precision??0,i=Number(n);if(isNaN(i))return(0,h.jsx)(`span`,{className:`tabular-nums whitespace-nowrap`,children:String(n)});let a=sn.test(t?.name?.toLowerCase()||``),o=a?i:i>-1&&i<1?i*100:i,s=a?`${i.toFixed(r)}%`:Qt(i,r),c=Math.max(0,Math.min(100,o));return(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`div`,{className:`h-1.5 w-16 rounded-full bg-muted ring-1 ring-inset ring-border/60 overflow-hidden shrink-0`,role:`progressbar`,"aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,children:(0,h.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-all`,style:{width:`${c}%`}})}),(0,h.jsx)(`span`,{className:`tabular-nums whitespace-nowrap`,children:s})]})}var ln=new Set([`active`,`is_active`,`enabled`,`is_enabled`,`verified`,`is_verified`]);function un({value:e,field:t}){if(e==null)return(0,h.jsx)(`span`,{className:`flex items-center justify-center`,children:(0,h.jsx)(f.EmptyValue,{})});let n=t?.name?.toLowerCase()||``;return n===`completed`||n===`is_completed`||n===`done`||n===`is_done`?(0,h.jsx)(`div`,{className:`flex items-center justify-center`,children:e?(0,h.jsx)(`div`,{className:`size-5 rounded-full bg-green-500 flex items-center justify-center`,role:`img`,"aria-label":`Completed`,"data-testid":`completion-indicator`,children:(0,h.jsx)(p.Check,{className:`size-3 text-white`})}):(0,h.jsx)(`div`,{className:`size-5 rounded-full border-2 border-muted-foreground/30`,role:`img`,"aria-label":`Not completed`,"data-testid":`completion-indicator`})}):ln.has(n)&&!e?(0,h.jsxs)(f.Badge,{variant:`destructive`,className:`text-xs`,"data-testid":`boolean-warning-badge`,children:[t?.label||$t(n),` — Off`]}):(0,h.jsx)(`div`,{className:`flex items-center justify-start`,children:(0,h.jsx)(f.Checkbox,{checked:!!e,disabled:!0,className:`pointer-events-none`})})}function dn({value:e,field:t}){if(!e)return(0,h.jsx)(f.EmptyValue,{});let n=Q(e),r=t,i=tn(n,r.format||`relative`),a=n==null?null:new Date(n),o=a!==null&&!isNaN(a.getTime()),s=new Date;s.setHours(0,0,0,0);let c=String(r?.name||r?.accessorKey||r?.key||``).toLowerCase(),l=(r?.dueLike===!0||/(^|_)(due|deadline|expires?|expiry|expiration|expected_close|target_close|sla|return_by|renewal|next_action)(_|$)/.test(c))&&o&&a<s,u=o?a.toISOString():String(n);return(0,h.jsx)(`span`,{className:`tabular-nums${l?` text-red-600`:``}`,title:u,children:i})}function fn({value:e}){if(!e)return(0,h.jsx)(f.EmptyValue,{});let t=Q(e),n=t==null?null:new Date(t);if(n===null||isNaN(n.getTime()))return(0,h.jsx)(f.EmptyValue,{});let r=n.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`,year:`numeric`}),i=n.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`,hour12:!0}).toLowerCase();return(0,h.jsxs)(`span`,{className:`tabular-nums text-sm whitespace-nowrap`,children:[(0,h.jsx)(`span`,{children:r}),(0,h.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:i})]})}var pn={critical:`red`,urgent:`red`,high:`orange`,medium:`yellow`,normal:`blue`,low:`gray`,none:`gray`,paid:`green`,completed:`green`,done:`green`,active:`green`,approved:`green`,resolved:`green`,pending:`yellow`,waiting:`yellow`,on_hold:`yellow`,shipped:`blue`,in_progress:`blue`,open:`blue`,processing:`blue`,draft:`gray`,new:`gray`,inactive:`gray`,closed:`gray`,cancelled:`red`,canceled:`red`,rejected:`red`,failed:`red`,overdue:`red`,delivered:`purple`,archived:`indigo`,contacted:`blue`,qualified:`purple`,converted:`green`,won:`green`,lost:`red`,紧急:`red`,严重:`red`,高:`orange`,中:`yellow`,普通:`blue`,低:`gray`,无:`gray`,新建:`gray`,草稿:`gray`,待处理:`yellow`,待审核:`yellow`,待联系:`yellow`,挂起:`yellow`,进行中:`blue`,处理中:`blue`,已联系:`blue`,跟进中:`blue`,已发货:`blue`,打开:`blue`,已确认:`green`,已审核:`green`,已通过:`green`,已完成:`green`,已支付:`green`,已签收:`green`,已转化:`green`,成单:`green`,赢得:`green`,已签约:`green`,已交付:`purple`,已归档:`indigo`,已关闭:`gray`,已取消:`red`,已拒绝:`red`,失败:`red`,逾期:`red`,流失:`red`,丢失:`red`},mn={gray:`bg-gray-50 text-gray-700 border-gray-200 dark:bg-gray-800/50 dark:text-gray-200 dark:border-gray-700/60`,red:`bg-red-50 text-red-700 border-red-200 dark:bg-red-950/40 dark:text-red-300 dark:border-red-900/60`,orange:`bg-orange-50 text-orange-700 border-orange-200 dark:bg-orange-950/40 dark:text-orange-300 dark:border-orange-900/60`,yellow:`bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-950/40 dark:text-yellow-300 dark:border-yellow-900/60`,green:`bg-green-50 text-green-700 border-green-200 dark:bg-green-950/40 dark:text-green-300 dark:border-green-900/60`,blue:`bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-950/40 dark:text-blue-300 dark:border-blue-900/60`,indigo:`bg-indigo-50 text-indigo-700 border-indigo-200 dark:bg-indigo-950/40 dark:text-indigo-300 dark:border-indigo-900/60`,purple:`bg-purple-50 text-purple-700 border-purple-200 dark:bg-purple-950/40 dark:text-purple-300 dark:border-purple-900/60`,pink:`bg-pink-50 text-pink-700 border-pink-200 dark:bg-pink-950/40 dark:text-pink-300 dark:border-pink-900/60`},hn={gray:`bg-gray-400 dark:bg-gray-500`,red:`bg-red-500`,orange:`bg-orange-500`,yellow:`bg-yellow-500`,green:`bg-green-500`,blue:`bg-blue-500`,indigo:`bg-indigo-500`,purple:`bg-purple-500`,pink:`bg-pink-500`},gn=[`blue`,`green`,`purple`,`orange`,`pink`,`indigo`,`yellow`,`red`];function _n(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return gn[Math.abs(t)%gn.length]}function vn(e,t){if(e&&mn[e])return mn[e];if(t==null||t===``)return`bg-muted text-muted-foreground border-border`;let n=String(t).toLowerCase().replace(/[\s-]/g,`_`),r=pn[n];return r&&mn[r]?mn[r]:mn[_n(n)]}function yn(e,t){if(e&&mn[e])return e;if(t==null||t===``)return;let n=String(t).toLowerCase().replace(/[\s-]/g,`_`);return pn[n]||_n(n)}var bn={gray:`#6b7280`,red:`#ef4444`,orange:`#f97316`,yellow:`#eab308`,green:`#22c55e`,blue:`#3b82f6`,indigo:`#6366f1`,purple:`#a855f7`,pink:`#ec4899`};function xn(e,t=`#3b82f6`){return e?bn[e]??t:t}function Sn({value:e,field:t}){let n=t,r=n.options||[],i=n.appearance===`dot`?`dot`:`badge`;if(e==null||e===``)return(0,h.jsx)(f.EmptyValue,{});let a=e=>{let t=r.find(t=>t.value===e);if(t)return t;let n=String(e).toLowerCase();return r.find(e=>String(e.value).toLowerCase()===n)},o=(e,t)=>{let n=a(e),r=n?.label||$t(String(e));return i===`dot`?(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-sm`,children:[(0,h.jsx)(`span`,{className:(0,f.cn)(`h-1.5 w-1.5 rounded-full shrink-0`,hn[n?.color||pn[String(e).toLowerCase().replace(/[\s-]/g,`_`)]||_n(String(e).toLowerCase().replace(/[\s-]/g,`_`))]||hn.gray),"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`truncate`,children:r})]},t):(0,h.jsx)(f.Badge,{variant:`outline`,className:vn(n?.color,e),children:r},t)};return Array.isArray(e)?(0,h.jsx)(`div`,{className:(0,f.cn)(`flex flex-wrap`,i===`dot`?`gap-x-3 gap-y-1`:`gap-1`),children:e.map((e,t)=>o(e,t))}):o(e)}function Cn({value:e}){if(!e)return(0,h.jsx)(f.EmptyValue,{});let t=Jt(),n=String(Q(e)??``),[r,i]=u.default.useState(!1);return(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 group/email`,children:[(0,h.jsx)(f.Button,{variant:`link`,className:`p-0 h-auto font-normal text-blue-600 hover:text-blue-800`,asChild:!0,children:(0,h.jsx)(`a`,{href:`mailto:${n}`,onClick:e=>e.stopPropagation(),children:n})}),(0,h.jsx)(`button`,{type:`button`,className:`opacity-0 group-hover/email:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted`,onClick:e=>{e.stopPropagation(),e.preventDefault(),navigator.clipboard.writeText(n).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)}).catch(()=>{})},"aria-label":t(`detail.copyEmail`,`Copy email`),children:r?(0,h.jsx)(p.Check,{className:`h-3 w-3 text-green-600`}):(0,h.jsx)(p.Copy,{className:`h-3 w-3 text-muted-foreground`})})]})}function wn({value:e}){if(!e)return(0,h.jsx)(f.EmptyValue,{});let t=String(Q(e)??``);return(0,h.jsx)(f.Button,{variant:`link`,className:`p-0 h-auto font-normal text-blue-600 hover:text-blue-800`,asChild:!0,children:(0,h.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:t})})}function Tn({value:e}){if(!e)return(0,h.jsx)(f.EmptyValue,{});let t=Jt(),n=String(Q(e)??``),[r,i]=u.default.useState(!1);return(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 group/phone`,children:[(0,h.jsxs)(`a`,{href:`tel:${n}`,className:`inline-flex items-center gap-1 text-blue-600 hover:text-blue-800`,onClick:e=>e.stopPropagation(),children:[(0,h.jsx)(p.Phone,{className:`h-3 w-3`}),n]}),(0,h.jsx)(`button`,{type:`button`,className:`opacity-0 group-hover/phone:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted`,onClick:e=>{e.stopPropagation(),e.preventDefault(),navigator.clipboard.writeText(n).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)}).catch(()=>{})},"aria-label":t(`detail.copyPhone`,`Copy phone number`),children:r?(0,h.jsx)(p.Check,{className:`h-3 w-3 text-green-600`}):(0,h.jsx)(p.Copy,{className:`h-3 w-3 text-muted-foreground`})})]})}function En({value:e,field:t}){if(!e)return(0,h.jsx)(f.EmptyValue,{});if(t.multiple,Array.isArray(e)){let t=e.length;return(0,h.jsxs)(`span`,{className:`text-sm text-gray-600`,children:[t,` `,t===1?`file`:`files`]})}return(0,h.jsx)(`span`,{className:`text-sm truncate`,children:e.name||e.original_name||`File`})}function Dn({value:e}){return e?Array.isArray(e)?(0,h.jsxs)(`div`,{className:`flex -space-x-2`,children:[e.slice(0,3).map((e,t)=>(0,h.jsx)(`img`,{src:e.url||``,alt:e.name||`Image ${t+1}`,className:`size-8 rounded-md border-2 border-white object-cover`},t)),e.length>3&&(0,h.jsxs)(`div`,{className:`size-8 rounded-md border-2 border-white bg-gray-100 flex items-center justify-center text-xs font-medium text-gray-600`,children:[`+`,e.length-3]})]}):(0,h.jsx)(`img`,{src:e.url||``,alt:e.name||`Image`,className:`size-10 rounded-md object-cover`}):(0,h.jsx)(f.EmptyValue,{})}function On({value:e,field:t}){let n=t.reference_to,r=(()=>{if(Array.isArray(e))return e.find(e=>e!=null&&(typeof e==`string`||typeof e==`number`)&&e!==``);if(e!=null&&e!==``&&(typeof e==`string`||typeof e==`number`)&&typeof e!=`object`)return e})(),i=qt(n,r);if(e==null||e===``)return(0,h.jsx)(f.EmptyValue,{});if(!Array.isArray(e)&&typeof e==`object`){let t=e,n=Gt(t)||String(t.id||t._id||``);if(n)return(0,h.jsx)(`span`,{className:`truncate`,children:n})}let a=t.options||[],o=e=>{if(a.length>0){let t=a.find(t=>String(t.value)===String(e));if(t)return{text:t.label,muted:!1}}return e===r&&i?{text:i,muted:!1}:Kt(e)?{text:`—`,muted:!0}:{text:String(e),muted:!1}};if(Array.isArray(e))return(0,h.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>{let n,r=!1;if(typeof e==`object`&&e)n=Gt(e)||String(e.id||e._id||`[Object]`);else{let t=o(e);n=t.text,r=t.muted}return(0,h.jsx)(`span`,{className:(0,f.cn)(`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium`,r?`bg-muted/40 text-muted-foreground`:`bg-gray-50 text-gray-700 dark:bg-gray-800/50 dark:text-gray-200`),children:n},t)})});if(typeof e==`object`&&e)return(0,h.jsx)(`span`,{className:`truncate`,children:Gt(e)||String(e.id||e._id||`[Object]`)});let{text:s,muted:c}=o(e);return(0,h.jsx)(`span`,{className:(0,f.cn)(`truncate`,c&&`text-muted-foreground`),children:s})}function kn({value:e}){let t=Q(e);return t==null||t===``?(0,h.jsx)(f.EmptyValue,{}):(0,h.jsx)(`span`,{className:`text-gray-700 font-mono text-sm`,children:String(t)})}function An({value:e}){if(!e)return(0,h.jsx)(f.EmptyValue,{});if(typeof e!=`object`)return(0,h.jsx)(`span`,{className:`truncate`,children:String(e)});if(Array.isArray(e))return(0,h.jsxs)(`div`,{className:`flex -space-x-2`,children:[e.slice(0,3).map((e,t)=>{if(typeof e!=`object`||!e)return(0,h.jsx)(`span`,{className:`truncate text-sm`,children:String(e)},t);let n=e.name||e.username||`User`;return(0,h.jsx)(f.Avatar,{className:`size-8 border-2 border-white`,title:n,children:(0,h.jsx)(f.AvatarFallback,{className:`bg-blue-500 text-white text-xs`,children:n.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)})},t)}),e.length>3&&(0,h.jsx)(f.Avatar,{className:`size-8 border-2 border-white`,children:(0,h.jsxs)(f.AvatarFallback,{className:`bg-gray-200 text-gray-600 text-xs`,children:[`+`,e.length-3]})})]});let t=e.name||e.username||`User`;return(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(f.Avatar,{className:`size-8`,children:(0,h.jsx)(f.AvatarFallback,{className:`bg-blue-500 text-white text-xs`,children:t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)})}),(0,h.jsx)(`span`,{className:`truncate`,children:t})]})}var jn=new Map;function Mn(e,t){jn.set(e,t)}var Nn={phone:`phone`,tel:`phone`,telephone:`phone`,email:`email`,url:`url`,uri:`url`,link:`url`,currency:`currency`,money:`currency`,percent:`percent`,percentage:`percent`},Pn=new Set([`text`,`textarea`,`string`,`longtext`,``]);function Fn(e){if(!e)return`text`;if(typeof e==`string`)return e;let t=(e.type||``).toLowerCase(),n=e.format,r=typeof n==`string`?n.toLowerCase():``;return r&&Nn[r]&&Pn.has(t)?Nn[r]:e.type||`text`}function In(e){return jn.has(e)?jn.get(e):{text:rn,textarea:rn,markdown:rn,html:rn,number:an,currency:on,percent:cn,boolean:un,date:dn,datetime:fn,time:rn,select:Sn,status:Sn,lookup:On,master_detail:On,email:Cn,url:wn,phone:Tn,file:En,image:Dn,formula:kn,summary:kn,auto_number:rn,user:An,owner:An,password:()=>(0,h.jsx)(`span`,{children:`••••••`}),location:rn,object:()=>(0,h.jsx)(`span`,{className:`text-gray-500 italic`,children:`[Object]`}),vector:()=>(0,h.jsx)(`span`,{className:`text-gray-500 italic`,children:`[Vector]`}),grid:()=>(0,h.jsx)(`span`,{className:`text-gray-500 italic`,children:`[Grid]`})}[e]||rn}Mn(`lookup`,On),Mn(`master_detail`,On),Mn(`select`,Sn),Mn(`status`,Sn),Mn(`user`,An),Mn(`owner`,An),me(In);function Ln(e){return{text:`field:text`,textarea:`field:textarea`,markdown:`field:markdown`,html:`field:html`,number:`field:number`,currency:`field:currency`,percent:`field:percent`,date:`field:date`,datetime:`field:datetime`,time:`field:time`,boolean:`field:boolean`,select:`field:select`,lookup:`field:lookup`,master_detail:`field:master_detail`,email:`field:email`,phone:`field:phone`,url:`field:url`,file:`field:file`,image:`field:image`,password:`field:password`,location:`field:location`,formula:`field:formula`,summary:`field:summary`,auto_number:`field:auto_number`}[e]||`field:text`}function Rn(e){if(e<0||!Number.isFinite(e)||e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${n.toFixed(+(r>0))} ${t[r]}`}function zn(e){let t={};return e.required&&(t.required=typeof e.required_message==`string`?e.required_message:`${e.label||e.name} is required`),e.min_length&&(t.minLength={value:e.min_length,message:e.min_length_message||`Minimum length is ${e.min_length} characters`}),e.max_length&&(t.maxLength={value:e.max_length,message:e.max_length_message||`Maximum length is ${e.max_length} characters`}),e.min!==void 0&&(t.min={value:e.min,message:e.min_message||`Minimum value is ${e.min}`}),e.max!==void 0&&(t.max={value:e.max,message:e.max_message||`Maximum value is ${e.max}`}),e.pattern&&(t.pattern={value:typeof e.pattern==`string`?new RegExp(e.pattern):e.pattern,message:e.pattern_message||`Invalid format`}),e.type===`email`&&(t.pattern={value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:`Please enter a valid email address`}),e.type===`url`&&(t.pattern={value:/^https?:\/\/.+/,message:`Please enter a valid URL`}),e.validate&&(t.validate=e.validate),Object.keys(t).length>0?t:void 0}function Bn(e,t){if(!e)return!0;if(e.field&&e.value!==void 0){let n=t[e.field];if(e.operator===`=`||e.operator===`==`)return n===e.value;if(e.operator===`!=`)return n!==e.value;if(e.operator===`>`)return n>e.value;if(e.operator===`>=`)return n>=e.value;if(e.operator===`<`)return n<e.value;if(e.operator===`<=`)return n<=e.value;if(e.operator===`in`)return Array.isArray(e.value)&&e.value.includes(n)}return e.and&&Array.isArray(e.and)?e.and.every(e=>Bn(e,t)):e.or&&Array.isArray(e.or)?e.or.some(e=>Bn(e,t)):!0}function $(e){let t=({schema:t,className:n,value:r,...i})=>{let[a,o]=u.default.useState(r??t?.value??``),s={name:t?.name||`field`,label:t?.label,type:t?.type,placeholder:t?.placeholder,required:t?.required,readonly:t?.readonly||t?.readOnly,help:t?.help,description:t?.description,defaultValue:t?.defaultValue||t?.value,...t},c=u.default.useCallback(e=>{o(e),i.onChange&&i.onChange(e)},[i]),l=t?.readonly||t?.readOnly||!1;return(0,h.jsxs)(`div`,{className:`grid w-full items-center gap-1.5`,"data-obj-id":t?.id,"data-obj-type":t?.type,children:[t?.label&&(0,h.jsx)(`label`,{htmlFor:t.id,className:t.required?`after:content-['*'] after:ml-0.5 after:text-red-500`:``,children:t.label}),(0,h.jsx)(e,{value:a,onChange:c,field:s,readonly:l,className:n}),t?.description&&(0,h.jsx)(`p`,{className:`text-sm text-gray-500`,children:t.description})]})};return t.displayName=`FieldRenderer(${e.displayName||e.name||`Component`})`,t}var Vn={text:()=>Promise.resolve().then(()=>(b(),v)).then(e=>({default:e.TextField})),textarea:()=>Promise.resolve().then(()=>(oe(),W)).then(e=>({default:e.TextAreaField})),number:()=>Promise.resolve().then(()=>(C(),x)).then(e=>({default:e.NumberField})),boolean:()=>Promise.resolve().then(()=>(E(),w)).then(e=>({default:e.BooleanField})),select:()=>Promise.resolve().then(()=>(te(),k)).then(e=>({default:e.SelectField})),date:()=>Promise.resolve().then(()=>(N(),j)).then(e=>({default:e.DateField})),datetime:()=>Promise.resolve().then(()=>(De(),Te)).then(e=>({default:e.DateTimeField})),time:()=>Promise.resolve().then(()=>(Z(),Oe)).then(e=>({default:e.TimeField})),email:()=>Promise.resolve().then(()=>(I(),P)).then(e=>({default:e.EmailField})),phone:()=>Promise.resolve().then(()=>(R(),ne)).then(e=>({default:e.PhoneField})),url:()=>Promise.resolve().then(()=>(B(),re)).then(e=>({default:e.UrlField})),currency:()=>Promise.resolve().then(()=>(U(),ie)).then(e=>({default:e.CurrencyField})),percent:()=>Promise.resolve().then(()=>(Me(),Ae)).then(e=>({default:e.PercentField})),password:()=>Promise.resolve().then(()=>(Fe(),Ne)).then(e=>({default:e.PasswordField})),markdown:()=>Promise.resolve().then(()=>(se(),G)).then(e=>({default:e.RichTextField})),html:()=>Promise.resolve().then(()=>(se(),G)).then(e=>({default:e.RichTextField})),lookup:()=>Promise.resolve().then(()=>(we(),_e)).then(e=>({default:e.LookupField})),master_detail:()=>Promise.resolve().then(()=>(we(),_e)).then(e=>({default:e.LookupField})),file:()=>Promise.resolve().then(()=>(Re(),Ie)).then(e=>({default:e.FileField})),image:()=>Promise.resolve().then(()=>(Ge(),He)).then(e=>({default:e.ImageField})),location:()=>Promise.resolve().then(()=>(Je(),Ke)).then(e=>({default:e.LocationField})),formula:()=>Promise.resolve().then(()=>(Ze(),Ye)).then(e=>({default:e.FormulaField})),summary:()=>Promise.resolve().then(()=>(et(),Qe)).then(e=>({default:e.SummaryField})),auto_number:()=>Promise.resolve().then(()=>(rt(),tt)).then(e=>({default:e.AutoNumberField})),user:()=>Promise.resolve().then(()=>(ot(),it)).then(e=>({default:e.UserField})),owner:()=>Promise.resolve().then(()=>(ot(),it)).then(e=>({default:e.UserField})),object:()=>Promise.resolve().then(()=>(lt(),st)).then(e=>({default:e.ObjectField})),vector:()=>Promise.resolve().then(()=>(ft(),ut)).then(e=>({default:e.VectorField})),grid:()=>Promise.resolve().then(()=>(ht(),pt)).then(e=>({default:e.GridField})),color:()=>Promise.resolve().then(()=>(vt(),gt)).then(e=>({default:e.ColorField})),slider:()=>Promise.resolve().then(()=>(xt(),yt)).then(e=>({default:e.SliderField})),rating:()=>Promise.resolve().then(()=>(wt(),St)).then(e=>({default:e.RatingField})),code:()=>Promise.resolve().then(()=>(Dt(),Tt)).then(e=>({default:e.CodeField})),avatar:()=>Promise.resolve().then(()=>(At(),Ot)).then(e=>({default:e.AvatarField})),address:()=>Promise.resolve().then(()=>(Nt(),jt)).then(e=>({default:e.AddressField})),geolocation:()=>Promise.resolve().then(()=>(It(),Pt)).then(e=>({default:e.GeolocationField})),signature:()=>Promise.resolve().then(()=>(zt(),Lt)).then(e=>({default:e.SignatureField})),qrcode:()=>Promise.resolve().then(()=>(Ht(),Bt)).then(e=>({default:e.QRCodeField}))};function Hn(e){let t=Vn[e];if(!t){console.warn(`Unknown field type: ${e}`);return}let n=u.default.lazy(t);d.ComponentRegistry.register(e,n,{namespace:`field`})}function Un(){Object.keys(Vn).forEach(e=>{Hn(e)})}function Wn(){d.ComponentRegistry.register(`text`,$(y),{namespace:`field`}),d.ComponentRegistry.register(`textarea`,$(ae),{namespace:`field`}),d.ComponentRegistry.register(`number`,$(S),{namespace:`field`}),d.ComponentRegistry.register(`boolean`,$(T),{namespace:`field`}),d.ComponentRegistry.register(`select`,$(A),{namespace:`field`}),d.ComponentRegistry.register(`date`,$(M),{namespace:`field`}),d.ComponentRegistry.register(`datetime`,$(Ee),{namespace:`field`}),d.ComponentRegistry.register(`time`,$(ke),{namespace:`field`}),d.ComponentRegistry.register(`email`,$(F),{namespace:`field`}),d.ComponentRegistry.register(`phone`,$(L),{namespace:`field`}),d.ComponentRegistry.register(`url`,$(z),{namespace:`field`}),d.ComponentRegistry.register(`currency`,$(H),{namespace:`field`}),d.ComponentRegistry.register(`percent`,$(je),{namespace:`field`}),d.ComponentRegistry.register(`password`,$(Pe),{namespace:`field`}),d.ComponentRegistry.register(`markdown`,$(K),{namespace:`field`}),d.ComponentRegistry.register(`html`,$(K),{namespace:`field`}),d.ComponentRegistry.register(`lookup`,$(xe),{namespace:`field`}),d.ComponentRegistry.register(`master_detail`,$(xe),{namespace:`field`}),d.ComponentRegistry.register(`file`,$(Le),{namespace:`field`}),d.ComponentRegistry.register(`image`,$(Ue),{namespace:`field`}),d.ComponentRegistry.register(`location`,$(qe),{namespace:`field`}),d.ComponentRegistry.register(`formula`,$(Xe),{namespace:`field`}),d.ComponentRegistry.register(`summary`,$($e),{namespace:`field`}),d.ComponentRegistry.register(`auto_number`,$(nt),{namespace:`field`}),d.ComponentRegistry.register(`user`,$(at),{namespace:`field`}),d.ComponentRegistry.register(`owner`,$(at),{namespace:`field`}),d.ComponentRegistry.register(`object`,$(ct),{namespace:`field`}),d.ComponentRegistry.register(`vector`,$(dt),{namespace:`field`}),d.ComponentRegistry.register(`grid`,$(mt),{namespace:`field`}),d.ComponentRegistry.register(`color`,$(_t),{namespace:`field`}),d.ComponentRegistry.register(`slider`,$(bt),{namespace:`field`}),d.ComponentRegistry.register(`rating`,$(Ct),{namespace:`field`}),d.ComponentRegistry.register(`code`,$(Et),{namespace:`field`}),d.ComponentRegistry.register(`avatar`,$(kt),{namespace:`field`}),d.ComponentRegistry.register(`address`,$(Mt),{namespace:`field`}),d.ComponentRegistry.register(`geolocation`,$(Ft),{namespace:`field`}),d.ComponentRegistry.register(`signature`,$(Rt),{namespace:`field`}),d.ComponentRegistry.register(`qrcode`,$(Vt),{namespace:`field`})}Un(),exports.AddressField=Mt,exports.AutoNumberField=nt,exports.AvatarField=kt,exports.BooleanCellRenderer=un,exports.BooleanField=T,exports.CodeField=Et,exports.ColorField=_t,exports.CurrencyCellRenderer=on,exports.CurrencyField=H,exports.DateCellRenderer=dn,exports.DateField=M,exports.DateTimeCellRenderer=fn,exports.DateTimeField=Ee,exports.EmailCellRenderer=Cn,exports.EmailField=F,exports.FileCellRenderer=En,exports.FileField=Le,exports.FormulaCellRenderer=kn,exports.FormulaField=Xe,exports.GeolocationField=Ft,exports.GridField=mt,exports.ImageCellRenderer=Dn,exports.ImageCropperDialog=Be,exports.ImageField=Ue,exports.LocationField=qe,exports.LookupCellRenderer=On,exports.LookupField=xe,exports.MasterDetailField=Ut,exports.NumberCellRenderer=an,exports.NumberField=S,exports.ObjectField=ct,exports.PasswordField=Pe,exports.PercentCellRenderer=cn,exports.PercentField=je,exports.PhoneCellRenderer=Tn,exports.PhoneField=L,exports.QRCodeField=Vt,exports.RatingField=Ct,exports.RecordPickerDialog=de,exports.RichTextField=K,exports.SelectCellRenderer=Sn,exports.SelectField=A,exports.SignatureField=Rt,exports.SliderField=bt,exports.SummaryField=$e,exports.TextAreaField=ae,exports.TextCellRenderer=rn,exports.TextField=y,exports.TimeField=ke,exports.UrlCellRenderer=wn,exports.UrlField=z,exports.UserCellRenderer=An,exports.UserField=at,exports.VectorField=dt,exports.buildValidationRules=zn,exports.coerceToSafeValue=Q,exports.evaluateCondition=Bn,exports.formatCompactCurrency=Xt,exports.formatCurrency=Yt,exports.formatDate=tn,exports.formatDateTime=nn,exports.formatFileSize=Rn,exports.formatNumber=Zt,exports.formatPercent=Qt,exports.formatRelativeDate=en,exports.getBadgeColorClasses=vn,exports.getCellRenderer=In,exports.getSemanticColorName=yn,exports.getSemanticHex=xn,exports.humanizeLabel=$t,exports.isLikelyOpaqueId=Kt,exports.mapFieldTypeToFormType=Ln,exports.registerAllFields=Un,exports.registerField=Hn,exports.registerFieldRenderer=Mn,exports.registerFields=Wn,exports.resolveCellRendererType=Fn;
|
|
8
|
+
}`,disabled:r||i.disabled,className:(0,f.cn)(`font-mono text-xs`,c?`border-red-500 focus-visible:ring-red-500`:``,i.className),rows:6}),c&&(0,h.jsx)(`p`,{className:`text-xs text-red-500`,children:c})]})}var lt=o((()=>{})),ut=s({VectorField:()=>dt});function dt({value:e,field:t,...n}){let r=(t||n.schema)?.dimensions||(Array.isArray(e)?e.length:0);if(!e||!Array.isArray(e))return(0,h.jsx)(f.EmptyValue,{});let i=e.slice(0,3).map(e=>{let t=Number(e);return isNaN(t)?`0`:t.toFixed(4)}).join(`, `);return(0,h.jsxs)(`div`,{className:`text-sm ${n.className||``}`,children:[(0,h.jsxs)(`span`,{className:`font-mono text-gray-700`,children:[`[`,i,`...]`]}),(0,h.jsxs)(`span`,{className:`text-gray-500 ml-2`,children:[`(`,r,`D)`]})]})}var ft=o((()=>{})),pt=s({GridField:()=>mt});function mt({value:e,field:t,readonly:n,...r}){let i=(t||r.schema)?.columns||[];return!e||!Array.isArray(e)?(0,h.jsx)(f.EmptyValue,{}):n?(0,h.jsx)(`div`,{className:(0,f.cn)(`text-sm`,r.className),children:(0,h.jsxs)(`span`,{className:`text-foreground`,children:[e.length,` rows`]})}):(0,h.jsxs)(`div`,{className:(0,f.cn)(`border border-border rounded-lg overflow-hidden`,r.className),children:[(0,h.jsx)(`div`,{className:`overflow-auto max-h-60`,children:(0,h.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,h.jsx)(`thead`,{className:`bg-muted border-b border-border`,children:(0,h.jsx)(`tr`,{children:i.map((e,t)=>(0,h.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:e.label||e.name},t))})}),(0,h.jsx)(`tbody`,{className:`divide-y divide-border`,children:e.slice(0,5).map((e,t)=>(0,h.jsx)(`tr`,{className:`hover:bg-muted/50 transition-colors`,children:i.map((t,n)=>(0,h.jsx)(`td`,{className:`px-3 py-2 text-foreground`,children:e[t.name]==null?(0,h.jsx)(f.EmptyValue,{}):String(e[t.name])},n))},t))})]})}),e.length>5&&(0,h.jsxs)(`div`,{className:`bg-muted px-3 py-2 text-xs text-muted-foreground border-t border-border`,children:[`Showing 5 of `,e.length,` rows`]})]})}var ht=o((()=>{})),gt=s({ColorField:()=>_t});function _t({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema;return r?(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`div`,{className:`w-6 h-6 rounded border border-input`,style:{backgroundColor:e||`#000000`}}),(0,h.jsx)(`span`,{className:`text-sm`,children:e||(0,h.jsx)(f.EmptyValue,{})})]}):(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`input`,{type:`color`,value:e||`#000000`,onChange:e=>t(e.target.value),disabled:r||i.disabled,className:`w-10 h-10 rounded border border-input cursor-pointer`}),(0,h.jsx)(f.Input,{type:`text`,value:e||``,onChange:e=>t(e.target.value),placeholder:a?.placeholder||`#000000`,disabled:r||i.disabled,className:i.className,pattern:`^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$`})]})}var vt=o((()=>{})),yt=s({SliderField:()=>bt});function bt({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema,o=a?.min??0,s=a?.max??100,c=a?.step??1;return r?(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-sm font-medium`,children:e??o}),(0,h.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,s]})]}):(0,h.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,h.jsx)(f.Slider,{value:[e??o],onValueChange:e=>t(e[0]),min:o,max:s,step:c,disabled:r||i.disabled,className:i.className}),(0,h.jsx)(`span`,{className:`text-sm font-medium w-12 text-right`,children:e??o})]})}var xt=o((()=>{})),St=s({RatingField:()=>Ct});function Ct({value:e,onChange:t,field:n,readonly:r,className:i,...a}){let o=(n||a.schema)?.max??5,s=e??0,[c,l]=u.default.useState(null),d=c===null?s:c;return r?(0,h.jsxs)(`div`,{className:(0,f.cn)(`flex items-center gap-1`,i),children:[Array.from({length:o},(e,t)=>(0,h.jsx)(p.Star,{className:`w-5 h-5 ${t<s?`fill-yellow-400 text-yellow-400`:`text-muted-foreground`}`},t)),(0,h.jsxs)(`span`,{className:`ml-2 text-sm text-muted-foreground`,children:[s,` / `,o]})]}):(0,h.jsxs)(`div`,{className:(0,f.cn)(`flex items-center gap-1`,i),children:[Array.from({length:o},(e,n)=>(0,h.jsx)(`button`,{type:`button`,onClick:()=>t(n+1),onMouseEnter:()=>l(n+1),onMouseLeave:()=>l(null),className:`focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded`,disabled:r||a.disabled,children:(0,h.jsx)(p.Star,{className:`w-5 h-5 transition-colors ${n<d?`fill-yellow-400 text-yellow-400 hover:fill-yellow-500 hover:text-yellow-500`:`text-muted-foreground hover:text-yellow-400`}`})},n)),(0,h.jsxs)(`span`,{className:`ml-2 text-sm text-muted-foreground`,children:[s,` / `,o]})]})}var wt=o((()=>{})),Tt=s({CodeField:()=>Et});function Et({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema,o=a?.language??`javascript`;return r?(0,h.jsx)(`pre`,{className:(0,f.cn)(`text-sm bg-muted p-2 rounded overflow-x-auto border`,i.className),children:(0,h.jsx)(`code`,{children:e||(0,h.jsx)(f.EmptyValue,{})})}):(0,h.jsx)(f.Textarea,{value:e||``,onChange:e=>t(e.target.value),placeholder:a?.placeholder||`// Write ${o} code here...`,disabled:r||i.disabled,className:(0,f.cn)(`font-mono text-sm`,i.className),rows:12,spellCheck:!1})}var Dt=o((()=>{})),Ot=s({AvatarField:()=>kt});function kt({value:e,onChange:t,field:n,readonly:r,...i}){let[a,o]=u.default.useState(!1),s=u.default.useRef(null),c=n||i.schema,l=e=>{let n=e.target.files?.[0];if(!n)return;if(!n.type.startsWith(`image/`)){console.error(`Please select an image file`);return}if(n.size>5*1024*1024){console.error(`File size must be less than 5MB`);return}let r=new FileReader;r.onloadend=()=>{t(r.result)},r.readAsDataURL(n)},d=()=>{t(``)},m=()=>(c?.defaultName||c?.label||`User`).split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return r?(0,h.jsxs)(f.Avatar,{className:`w-16 h-16`,children:[e&&(0,h.jsx)(f.AvatarImage,{src:e,alt:c?.label}),(0,h.jsx)(f.AvatarFallback,{children:m()})]}):(0,h.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,h.jsxs)(`div`,{className:`relative`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[(0,h.jsxs)(f.Avatar,{className:`w-16 h-16`,children:[e&&(0,h.jsx)(f.AvatarImage,{src:e,alt:c?.label}),(0,h.jsx)(f.AvatarFallback,{children:m()})]}),!r&&a&&e&&(0,h.jsx)(`button`,{type:`button`,onClick:d,className:`absolute -top-1 -right-1 bg-destructive text-destructive-foreground rounded-full p-1 hover:bg-destructive/90`,children:(0,h.jsx)(p.X,{className:`w-3 h-3`})})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`input`,{ref:s,type:`file`,accept:`image/*`,onChange:l,className:`hidden`}),(0,h.jsxs)(f.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>s.current?.click(),disabled:r||i.disabled,children:[(0,h.jsx)(p.Upload,{className:`w-4 h-4 mr-2`}),e?`Change`:`Upload`,` Avatar`]}),(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`PNG, JPG up to 5MB`})]})]})}var At=o((()=>{})),jt=s({AddressField:()=>Mt});function Mt({value:e,onChange:t,field:n,readonly:r,...i}){let a=e||{},o=(e,n)=>{t({...a,[e]:n})},s=e=>[e.street,e.city,[e.state,e.zipCode].filter(Boolean).join(` `),e.country].filter(Boolean).join(`, `);if(r){let e=s(a);return e?(0,h.jsx)(`span`,{className:`text-sm`,children:e}):(0,h.jsx)(f.EmptyValue,{})}return(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`street`,className:`text-xs`,children:`Street Address`}),(0,h.jsx)(f.Input,{id:`street`,type:`text`,value:a.street||``,onChange:e=>o(`street`,e.target.value),placeholder:`123 Main St`,disabled:r||i.disabled,className:i.className})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`city`,className:`text-xs`,children:`City`}),(0,h.jsx)(f.Input,{id:`city`,type:`text`,value:a.city||``,onChange:e=>o(`city`,e.target.value),placeholder:`San Francisco`,disabled:r||i.disabled})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`state`,className:`text-xs`,children:`State / Province`}),(0,h.jsx)(f.Input,{id:`state`,type:`text`,value:a.state||``,onChange:e=>o(`state`,e.target.value),placeholder:`CA`,disabled:r||i.disabled})]})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`zipCode`,className:`text-xs`,children:`ZIP / Postal Code`}),(0,h.jsx)(f.Input,{id:`zipCode`,type:`text`,value:a.zipCode||``,onChange:e=>o(`zipCode`,e.target.value),placeholder:`94102`,disabled:r||i.disabled})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`country`,className:`text-xs`,children:`Country`}),(0,h.jsx)(f.Input,{id:`country`,type:`text`,value:a.country||``,onChange:e=>o(`country`,e.target.value),placeholder:`United States`,disabled:r||i.disabled})]})]})]})}var Nt=o((()=>{})),Pt=s({GeolocationField:()=>Ft});function Ft({value:e,onChange:t,field:n,readonly:r,...i}){let[a,o]=u.default.useState(!1),s=e||{},c=(e,n)=>{t({...s,[e]:n?Number(n):void 0})},l=()=>{if(!navigator.geolocation){console.error(`Geolocation is not supported by this browser`);return}o(!0),navigator.geolocation.getCurrentPosition(e=>{t({latitude:e.coords.latitude,longitude:e.coords.longitude,accuracy:e.coords.accuracy}),o(!1)},e=>{console.error(`Error getting location:`,e.message),o(!1)},{enableHighAccuracy:!0,timeout:5e3,maximumAge:0})},d=e=>!e.latitude||!e.longitude?``:`${e.latitude.toFixed(6)}, ${e.longitude.toFixed(6)}`,m=()=>{if(!s.latitude||!s.longitude)return;let e=`https://www.google.com/maps?q=${s.latitude},${s.longitude}`;window.open(e,`_blank`)};if(r){let e=d(s);return(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(p.MapPin,{className:`w-4 h-4 text-muted-foreground`}),e?(0,h.jsx)(`span`,{className:`text-sm`,children:e}):(0,h.jsx)(f.EmptyValue,{}),s.latitude&&s.longitude&&(0,h.jsx)(f.Button,{type:`button`,variant:`link`,size:`sm`,onClick:m,className:`p-0 h-auto`,children:`View on map`})]})}return(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsxs)(f.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:l,disabled:r||a,children:[(0,h.jsx)(p.Crosshair,{className:`w-4 h-4 mr-2`}),a?`Getting location...`:`Use Current Location`]}),s.latitude&&s.longitude&&(0,h.jsxs)(f.Button,{type:`button`,variant:`link`,size:`sm`,onClick:m,children:[(0,h.jsx)(p.MapPin,{className:`w-4 h-4 mr-2`}),`View on map`]})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`latitude`,className:`text-xs`,children:`Latitude`}),(0,h.jsx)(f.Input,{id:`latitude`,type:`number`,value:s.latitude??``,onChange:e=>c(`latitude`,e.target.value),placeholder:`37.7749`,disabled:r||i.disabled,step:`any`,className:i.className})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(f.Label,{htmlFor:`longitude`,className:`text-xs`,children:`Longitude`}),(0,h.jsx)(f.Input,{id:`longitude`,type:`number`,value:s.longitude??``,onChange:e=>c(`longitude`,e.target.value),placeholder:`-122.4194`,disabled:r||i.disabled,step:`any`})]})]}),s.accuracy&&(0,h.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Accuracy: ±`,s.accuracy.toFixed(0),`m`]})]})}var It=o((()=>{})),Lt=s({SignatureField:()=>Rt});function Rt({value:e,onChange:t,readonly:n}){let r=(0,u.useRef)(null),[i,a]=u.default.useState(!1),[o,s]=u.default.useState(!e);(0,u.useEffect)(()=>{if(e&&r.current){let t=r.current.getContext(`2d`);if(t){let n=new Image;n.onload=()=>{t.drawImage(n,0,0),s(!1)},n.src=e}}},[e]);let c=e=>{if(n)return;a(!0),s(!1);let t=r.current;if(!t)return;let i=t.getContext(`2d`);if(!i)return;let o=t.getBoundingClientRect(),c=`touches`in e?e.touches[0].clientX-o.left:e.clientX-o.left,l=`touches`in e?e.touches[0].clientY-o.top:e.clientY-o.top;i.beginPath(),i.moveTo(c,l)},l=e=>{if(!i||n)return;let t=r.current;if(!t)return;let a=t.getContext(`2d`);if(!a)return;let o=t.getBoundingClientRect(),s=`touches`in e?e.touches[0].clientX-o.left:e.clientX-o.left,c=`touches`in e?e.touches[0].clientY-o.top:e.clientY-o.top;a.lineTo(s,c),a.strokeStyle=`#000`,a.lineWidth=2,a.lineCap=`round`,a.lineJoin=`round`,a.stroke()},d=()=>{if(!i)return;a(!1);let e=r.current;e&&t(e.toDataURL(`image/png`))};return n&&e?(0,h.jsx)(`div`,{className:`border rounded p-2 bg-white`,children:(0,h.jsx)(`img`,{src:e,alt:`Signature`,loading:`lazy`,className:`max-w-full h-auto`})}):n&&!e?(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`No signature`}):(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`div`,{className:`border rounded bg-white`,children:(0,h.jsx)(`canvas`,{ref:r,width:400,height:200,className:`w-full touch-none cursor-crosshair`,onMouseDown:c,onMouseMove:l,onMouseUp:d,onMouseLeave:d,onTouchStart:c,onTouchMove:l,onTouchEnd:d})}),(0,h.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?`Sign above`:`Signature captured`}),(0,h.jsxs)(f.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{let e=r.current;if(!e)return;let n=e.getContext(`2d`);n&&(n.clearRect(0,0,e.width,e.height),s(!0),t(``))},disabled:n||o,children:[(0,h.jsx)(p.Eraser,{className:`w-4 h-4 mr-2`}),`Clear`]})]})]})}var zt=o((()=>{})),Bt=s({QRCodeField:()=>Vt});function Vt({value:e,onChange:t,field:n,readonly:r,...i}){let[a,o]=u.default.useState(!1),s=n||i.schema;return r?(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`span`,{className:`text-sm flex-1 truncate`,children:e||(0,h.jsx)(f.EmptyValue,{})}),e&&(0,h.jsxs)(f.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(!a),children:[(0,h.jsx)(p.QrCode,{className:`w-4 h-4 mr-2`}),a?`Hide`:`Show`,` QR`]})]}):(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(f.Input,{type:`text`,value:e||``,onChange:e=>t(e.target.value),placeholder:s?.placeholder||`Enter text for QR code`,disabled:r||i.disabled,className:i.className}),e&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(f.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{e&&navigator.clipboard.writeText(e)},children:(0,h.jsx)(p.Copy,{className:`w-4 h-4`})}),(0,h.jsx)(f.Button,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(!a),children:(0,h.jsx)(p.QrCode,{className:`w-4 h-4`})})]})]}),a&&e&&(0,h.jsx)(`div`,{className:`border rounded p-4 bg-white flex justify-center`,children:(0,h.jsx)(`img`,{src:(e=>`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(e)}`)(e),alt:`QR Code`,className:`w-48 h-48`})}),e&&(0,h.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`QR code contains: `,e.length,` characters`]})]})}var Ht=o((()=>{}));b(),C(),E(),te(),N(),I(),R(),B(),U(),oe(),se(),we(),De(),Z(),Me(),Fe(),Re(),Ge(),Je(),Ze(),et(),rt(),ot(),lt(),ft(),ht(),vt(),xt(),wt(),Dt(),At(),Nt(),It(),zt(),Ht(),Ve();function Ut({value:e,onChange:t,field:n,readonly:r,className:i,...a}){let o=e||[],s=n||a.schema,c=()=>{let e={id:`new-${Date.now()}`,label:`New Related Record`};t([...o,e])},l=e=>{t(o.filter(t=>t.id!==e))},u=e=>{console.log(`View detail:`,e)};return r?(0,h.jsxs)(`div`,{className:(0,f.cn)(`space-y-2`,i),children:[o.length===0?(0,h.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`No related records`}):o.map(e=>(0,h.jsxs)(`div`,{className:`flex items-center justify-between p-2 border rounded hover:bg-muted/50`,children:[(0,h.jsx)(`span`,{className:`text-sm`,children:e.label}),(0,h.jsx)(f.Button,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>u(e),children:(0,h.jsx)(p.ExternalLink,{className:`w-4 h-4`})})]},e.id)),(0,h.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[o.length,` `,o.length===1?`record`:`records`]})]}):(0,h.jsxs)(`div`,{className:(0,f.cn)(`space-y-3`,i),children:[(0,h.jsxs)(`div`,{className:`space-y-2`,children:[o.map(e=>(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-2 p-2 border rounded hover:bg-muted/50`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,h.jsx)(f.Badge,{variant:`outline`,children:e.id}),(0,h.jsx)(`span`,{className:`text-sm flex-1`,children:e.label})]}),(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(f.Button,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>u(e),children:(0,h.jsx)(p.ExternalLink,{className:`w-4 h-4`})}),(0,h.jsx)(f.Button,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>l(e.id),disabled:a.disabled,children:(0,h.jsx)(p.X,{className:`w-4 h-4`})})]})]},e.id)),o.length===0&&(0,h.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-4 border border-dashed rounded bg-muted/20`,children:`No related records`})]}),(0,h.jsxs)(f.Button,{type:`button`,variant:`outline`,className:`w-full`,onClick:c,disabled:a.disabled,children:[(0,h.jsx)(p.Plus,{className:`w-4 h-4 mr-2`}),`Add `,s?.label||`Record`]})]})}ge(),b(),C(),E(),te(),N(),De(),Z(),I(),R(),B(),U(),Me(),Fe(),oe(),se(),we(),Y(),Re(),Ge(),Je(),Ze(),et(),rt(),ot(),lt(),ft(),ht(),vt(),xt(),wt(),Dt(),At(),Nt(),It(),zt(),Ht();var Wt=new Map;function Gt(e){if(!e||typeof e!=`object`)return;for(let t of[`name`,`full_name`,`display_name`,`label`,`title`,`subject`,`username`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim();if(typeof n==`number`)return String(n)}let t=e.first_name,n=e.last_name,r=[e.salutation,t,n].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `);if(r)return r;let i=e.email;if(typeof i==`string`&&i.trim())return i.trim()}function Kt(e){if(typeof e!=`string`||!/^[A-Za-z0-9_-]{12,32}$/.test(e))return!1;let t=/[A-Z]/.test(e),n=/[a-z]/.test(e),r=/[0-9_-]/.test(e);return t&&n||t&&r||n&&r}function qt(e,t){let n=u.default.useContext(m.SchemaRendererContext)?.dataSource,[,r]=u.default.useState(0),i=!!e&&!!n&&typeof n.find==`function`&&(typeof t==`string`||typeof t==`number`)&&t!==``,a=i?`${e}:${String(t)}`:``;if(u.default.useEffect(()=>{if(!i)return;let o=Wt.get(a);if(o&&o.state!==`pending`&&o.promise==null||o?.state===`pending`)return;let s=(async()=>{try{let r;if(typeof n.findOne==`function`)r=await n.findOne(e,t);else{let i=await n.find(e,{$filter:{id:t},options:{$top:1}});r=(Array.isArray(i)?i:i?.value||i?.data||[])[0]}let i=Gt(r);Wt.set(a,{state:`ok`,name:i})}catch{Wt.set(a,{state:`err`})}r(e=>e+1)})();Wt.set(a,{state:`pending`,promise:s})},[a,i,e,t,n]),!i)return;let o=Wt.get(a);return o?.state===`ok`?o.name:void 0}function Jt(){try{let{t:e}=(0,m.useObjectTranslation)();return(t,n)=>{let r=e(t);return!r||r===t?n:r}}catch{return(e,t)=>t}}function Q(e){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(e=>{if(typeof e==`object`&&e){let t=e;return String(t.name||t.label||t.id||t._id||`[Object]`)}return String(e)}).join(`, `);if(typeof e==`object`){let t=e;return`$numberDecimal`in t?Number(t.$numberDecimal):`$oid`in t?String(t.$oid):`$date`in t?String(t.$date):String(t.name||t.label||t.id||t._id||`[Object]`)}return String(e)}function Yt(e,t=`USD`){try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t}).format(e)}catch{return`${t} ${e.toFixed(2)}`}}function Xt(e,t=`USD`){try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t,notation:`compact`,maximumFractionDigits:1}).format(e).replace(/\.0(?=[KMBT])/,``)}catch{return`${t} ${e}`}}function Zt(e,t=2){try{return new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e)}catch{return e.toFixed(t)}}function Qt(e,t=0){return`${(e>-1&&e<1?e*100:e).toFixed(t)}%`}function $t(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function en(e){if(e==null||e===``)return`—`;let t=e instanceof Date?e:new Date(e);if(!(t instanceof Date)||isNaN(t.getTime()))return`—`;let n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()-r.getTime(),a=Math.round(i/(1e3*60*60*24));if(a===0)return`Today`;if(a===1)return`Tomorrow`;if(a===-1)return`Yesterday`;if(a<-1){let e=Math.abs(a);return e<=7?`Overdue ${e}d`:tn(t)}return a>1&&a<=7?`In ${a} days`:tn(t)}function tn(e,t){if(e==null||e===``)return`—`;let n=e instanceof Date?e:new Date(e);return!(n instanceof Date)||isNaN(n.getTime())?`—`:t===`short`?`${n.toLocaleDateString(`en-US`,{month:`short`})} ${n.getDate()}, '${String(n.getFullYear()).slice(-2)}`:t===`relative`?en(n):n.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function nn(e){if(e==null||e===``)return`—`;let t=e instanceof Date?e:new Date(e);return!(t instanceof Date)||isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function rn({value:e}){let t=Q(e);return t==null||t===``?(0,h.jsx)(f.EmptyValue,{}):(0,h.jsx)(`span`,{className:`truncate`,children:String(t)})}function an({value:e,field:t}){if(e==null)return(0,h.jsx)(f.EmptyValue,{});let n=Q(e),r=t.precision??0,i=Number(n);return(0,h.jsx)(`span`,{className:`tabular-nums`,children:isNaN(i)?String(n):new Intl.NumberFormat(`en-US`,{minimumFractionDigits:r,maximumFractionDigits:r}).format(i)})}function on({value:e,field:t}){if(e==null)return(0,h.jsx)(f.EmptyValue,{});let n=Q(e),r=t,i=r.currency||r.defaultCurrency||`USD`,a=Number(n),o=r.precision??r.scale??r.decimals??2,s=isNaN(a)?String(n):Yt(a,i);return(0,h.jsx)(`span`,{className:`tabular-nums font-medium whitespace-nowrap`,children:o===0?s.replace(/[.,]00$/,``):s})}var sn=/progress|completion/;function cn({value:e,field:t}){if(e==null)return(0,h.jsx)(f.EmptyValue,{});let n=Q(e),r=t.precision??0,i=Number(n);if(isNaN(i))return(0,h.jsx)(`span`,{className:`tabular-nums whitespace-nowrap`,children:String(n)});let a=sn.test(t?.name?.toLowerCase()||``),o=a?i:i>-1&&i<1?i*100:i,s=a?`${i.toFixed(r)}%`:Qt(i,r),c=Math.max(0,Math.min(100,o));return(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`div`,{className:`h-1.5 w-16 rounded-full bg-muted ring-1 ring-inset ring-border/60 overflow-hidden shrink-0`,role:`progressbar`,"aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,children:(0,h.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-all`,style:{width:`${c}%`}})}),(0,h.jsx)(`span`,{className:`tabular-nums whitespace-nowrap`,children:s})]})}var ln=new Set([`active`,`is_active`,`enabled`,`is_enabled`,`verified`,`is_verified`]);function un({value:e,field:t}){if(e==null)return(0,h.jsx)(`span`,{className:`flex items-center justify-center`,children:(0,h.jsx)(f.EmptyValue,{})});let n=t?.name?.toLowerCase()||``;return n===`completed`||n===`is_completed`||n===`done`||n===`is_done`?(0,h.jsx)(`div`,{className:`flex items-center justify-center`,children:e?(0,h.jsx)(`div`,{className:`size-5 rounded-full bg-green-500 flex items-center justify-center`,role:`img`,"aria-label":`Completed`,"data-testid":`completion-indicator`,children:(0,h.jsx)(p.Check,{className:`size-3 text-white`})}):(0,h.jsx)(`div`,{className:`size-5 rounded-full border-2 border-muted-foreground/30`,role:`img`,"aria-label":`Not completed`,"data-testid":`completion-indicator`})}):ln.has(n)&&!e?(0,h.jsxs)(f.Badge,{variant:`destructive`,className:`text-xs`,"data-testid":`boolean-warning-badge`,children:[t?.label||$t(n),` — Off`]}):(0,h.jsx)(`div`,{className:`flex items-center justify-start`,children:(0,h.jsx)(f.Checkbox,{checked:!!e,disabled:!0,className:`pointer-events-none`})})}function dn({value:e,field:t}){if(!e)return(0,h.jsx)(f.EmptyValue,{});let n=Q(e),r=t,i=tn(n,r.format||`relative`),a=n==null?null:new Date(n),o=a!==null&&!isNaN(a.getTime()),s=new Date;s.setHours(0,0,0,0);let c=String(r?.name||r?.accessorKey||r?.key||``).toLowerCase(),l=(r?.dueLike===!0||/(^|_)(due|deadline|expires?|expiry|expiration|expected_close|target_close|sla|return_by|renewal|next_action)(_|$)/.test(c))&&o&&a<s,u=o?a.toISOString():String(n);return(0,h.jsx)(`span`,{className:`tabular-nums${l?` text-red-600`:``}`,title:u,children:i})}function fn({value:e}){if(!e)return(0,h.jsx)(f.EmptyValue,{});let t=Q(e),n=t==null?null:new Date(t);if(n===null||isNaN(n.getTime()))return(0,h.jsx)(f.EmptyValue,{});let r=n.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`,year:`numeric`}),i=n.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`,hour12:!0}).toLowerCase();return(0,h.jsxs)(`span`,{className:`tabular-nums text-sm whitespace-nowrap`,children:[(0,h.jsx)(`span`,{children:r}),(0,h.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:i})]})}var pn={critical:`red`,urgent:`red`,high:`orange`,medium:`yellow`,normal:`blue`,low:`gray`,none:`gray`,paid:`green`,completed:`green`,done:`green`,active:`green`,approved:`green`,resolved:`green`,pending:`yellow`,waiting:`yellow`,on_hold:`yellow`,shipped:`blue`,in_progress:`blue`,open:`blue`,processing:`blue`,draft:`gray`,new:`gray`,inactive:`gray`,closed:`gray`,cancelled:`red`,canceled:`red`,rejected:`red`,failed:`red`,overdue:`red`,delivered:`purple`,archived:`indigo`,contacted:`blue`,qualified:`purple`,converted:`green`,won:`green`,lost:`red`,紧急:`red`,严重:`red`,高:`orange`,中:`yellow`,普通:`blue`,低:`gray`,无:`gray`,新建:`gray`,草稿:`gray`,待处理:`yellow`,待审核:`yellow`,待联系:`yellow`,挂起:`yellow`,进行中:`blue`,处理中:`blue`,已联系:`blue`,跟进中:`blue`,已发货:`blue`,打开:`blue`,已确认:`green`,已审核:`green`,已通过:`green`,已完成:`green`,已支付:`green`,已签收:`green`,已转化:`green`,成单:`green`,赢得:`green`,已签约:`green`,已交付:`purple`,已归档:`indigo`,已关闭:`gray`,已取消:`red`,已拒绝:`red`,失败:`red`,逾期:`red`,流失:`red`,丢失:`red`},mn={gray:`bg-gray-50 text-gray-700 border-gray-200 dark:bg-gray-800/50 dark:text-gray-200 dark:border-gray-700/60`,red:`bg-red-50 text-red-700 border-red-200 dark:bg-red-950/40 dark:text-red-300 dark:border-red-900/60`,orange:`bg-orange-50 text-orange-700 border-orange-200 dark:bg-orange-950/40 dark:text-orange-300 dark:border-orange-900/60`,yellow:`bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-950/40 dark:text-yellow-300 dark:border-yellow-900/60`,green:`bg-green-50 text-green-700 border-green-200 dark:bg-green-950/40 dark:text-green-300 dark:border-green-900/60`,blue:`bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-950/40 dark:text-blue-300 dark:border-blue-900/60`,indigo:`bg-indigo-50 text-indigo-700 border-indigo-200 dark:bg-indigo-950/40 dark:text-indigo-300 dark:border-indigo-900/60`,purple:`bg-purple-50 text-purple-700 border-purple-200 dark:bg-purple-950/40 dark:text-purple-300 dark:border-purple-900/60`,pink:`bg-pink-50 text-pink-700 border-pink-200 dark:bg-pink-950/40 dark:text-pink-300 dark:border-pink-900/60`},hn={gray:`bg-gray-400 dark:bg-gray-500`,red:`bg-red-500`,orange:`bg-orange-500`,yellow:`bg-yellow-500`,green:`bg-green-500`,blue:`bg-blue-500`,indigo:`bg-indigo-500`,purple:`bg-purple-500`,pink:`bg-pink-500`},gn=[`blue`,`green`,`purple`,`orange`,`pink`,`indigo`,`yellow`,`red`];function _n(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return gn[Math.abs(t)%gn.length]}function vn(e,t){if(e&&mn[e])return mn[e];if(t==null||t===``)return`bg-muted text-muted-foreground border-border`;let n=String(t).toLowerCase().replace(/[\s-]/g,`_`),r=pn[n];return r&&mn[r]?mn[r]:mn[_n(n)]}function yn(e,t){if(e&&mn[e])return e;if(t==null||t===``)return;let n=String(t).toLowerCase().replace(/[\s-]/g,`_`);return pn[n]||_n(n)}var bn={gray:`#6b7280`,red:`#ef4444`,orange:`#f97316`,yellow:`#eab308`,green:`#22c55e`,blue:`#3b82f6`,indigo:`#6366f1`,purple:`#a855f7`,pink:`#ec4899`};function xn(e,t=`#3b82f6`){return e?bn[e]??t:t}function Sn({value:e,field:t}){let n=t,r=n.options||[],i=n.appearance===`dot`?`dot`:`badge`;if(e==null||e===``)return(0,h.jsx)(f.EmptyValue,{});let a=e=>{let t=r.find(t=>t.value===e);if(t)return t;let n=String(e).toLowerCase();return r.find(e=>String(e.value).toLowerCase()===n)},o=(e,t)=>{let n=a(e),r=n?.label||$t(String(e));return i===`dot`?(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-sm`,children:[(0,h.jsx)(`span`,{className:(0,f.cn)(`h-1.5 w-1.5 rounded-full shrink-0`,hn[n?.color||pn[String(e).toLowerCase().replace(/[\s-]/g,`_`)]||_n(String(e).toLowerCase().replace(/[\s-]/g,`_`))]||hn.gray),"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`truncate`,children:r})]},t):(0,h.jsx)(f.Badge,{variant:`outline`,className:vn(n?.color,e),children:r},t)};return Array.isArray(e)?(0,h.jsx)(`div`,{className:(0,f.cn)(`flex flex-wrap`,i===`dot`?`gap-x-3 gap-y-1`:`gap-1`),children:e.map((e,t)=>o(e,t))}):o(e)}function Cn({value:e}){if(!e)return(0,h.jsx)(f.EmptyValue,{});let t=Jt(),n=String(Q(e)??``),[r,i]=u.default.useState(!1);return(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 group/email`,children:[(0,h.jsx)(f.Button,{variant:`link`,className:`p-0 h-auto font-normal text-blue-600 hover:text-blue-800`,asChild:!0,children:(0,h.jsx)(`a`,{href:`mailto:${n}`,onClick:e=>e.stopPropagation(),children:n})}),(0,h.jsx)(`button`,{type:`button`,className:`opacity-0 group-hover/email:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted`,onClick:e=>{e.stopPropagation(),e.preventDefault(),navigator.clipboard.writeText(n).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)}).catch(()=>{})},"aria-label":t(`detail.copyEmail`,`Copy email`),children:r?(0,h.jsx)(p.Check,{className:`h-3 w-3 text-green-600`}):(0,h.jsx)(p.Copy,{className:`h-3 w-3 text-muted-foreground`})})]})}function wn({value:e}){if(!e)return(0,h.jsx)(f.EmptyValue,{});let t=String(Q(e)??``);return(0,h.jsx)(f.Button,{variant:`link`,className:`p-0 h-auto font-normal text-blue-600 hover:text-blue-800`,asChild:!0,children:(0,h.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:t})})}function Tn({value:e}){if(!e)return(0,h.jsx)(f.EmptyValue,{});let t=Jt(),n=String(Q(e)??``),[r,i]=u.default.useState(!1);return(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 group/phone`,children:[(0,h.jsxs)(`a`,{href:`tel:${n}`,className:`inline-flex items-center gap-1 text-blue-600 hover:text-blue-800`,onClick:e=>e.stopPropagation(),children:[(0,h.jsx)(p.Phone,{className:`h-3 w-3`}),n]}),(0,h.jsx)(`button`,{type:`button`,className:`opacity-0 group-hover/phone:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted`,onClick:e=>{e.stopPropagation(),e.preventDefault(),navigator.clipboard.writeText(n).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)}).catch(()=>{})},"aria-label":t(`detail.copyPhone`,`Copy phone number`),children:r?(0,h.jsx)(p.Check,{className:`h-3 w-3 text-green-600`}):(0,h.jsx)(p.Copy,{className:`h-3 w-3 text-muted-foreground`})})]})}function En({value:e,field:t}){if(!e)return(0,h.jsx)(f.EmptyValue,{});if(t.multiple,Array.isArray(e)){let t=e.length;return(0,h.jsxs)(`span`,{className:`text-sm text-gray-600`,children:[t,` `,t===1?`file`:`files`]})}return(0,h.jsx)(`span`,{className:`text-sm truncate`,children:e.name||e.original_name||`File`})}function Dn({value:e}){return e?Array.isArray(e)?(0,h.jsxs)(`div`,{className:`flex -space-x-2`,children:[e.slice(0,3).map((e,t)=>(0,h.jsx)(`img`,{src:e.url||``,alt:e.name||`Image ${t+1}`,className:`size-8 rounded-md border-2 border-white object-cover`},t)),e.length>3&&(0,h.jsxs)(`div`,{className:`size-8 rounded-md border-2 border-white bg-gray-100 flex items-center justify-center text-xs font-medium text-gray-600`,children:[`+`,e.length-3]})]}):(0,h.jsx)(`img`,{src:e.url||``,alt:e.name||`Image`,className:`size-10 rounded-md object-cover`}):(0,h.jsx)(f.EmptyValue,{})}function On({value:e,field:t}){let n=t.reference_to,r=(()=>{if(Array.isArray(e))return e.find(e=>e!=null&&(typeof e==`string`||typeof e==`number`)&&e!==``);if(e!=null&&e!==``&&(typeof e==`string`||typeof e==`number`)&&typeof e!=`object`)return e})(),i=qt(n,r);if(e==null||e===``)return(0,h.jsx)(f.EmptyValue,{});if(!Array.isArray(e)&&typeof e==`object`){let t=e,n=Gt(t)||String(t.id||t._id||``);if(n)return(0,h.jsx)(`span`,{className:`truncate`,children:n})}let a=t.options||[],o=e=>{if(a.length>0){let t=a.find(t=>String(t.value)===String(e));if(t)return{text:t.label,muted:!1}}return e===r&&i?{text:i,muted:!1}:Kt(e)?{text:`—`,muted:!0}:{text:String(e),muted:!1}};if(Array.isArray(e))return(0,h.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>{let n,r=!1;if(typeof e==`object`&&e)n=Gt(e)||String(e.id||e._id||`[Object]`);else{let t=o(e);n=t.text,r=t.muted}return(0,h.jsx)(`span`,{className:(0,f.cn)(`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium`,r?`bg-muted/40 text-muted-foreground`:`bg-gray-50 text-gray-700 dark:bg-gray-800/50 dark:text-gray-200`),children:n},t)})});if(typeof e==`object`&&e)return(0,h.jsx)(`span`,{className:`truncate`,children:Gt(e)||String(e.id||e._id||`[Object]`)});let{text:s,muted:c}=o(e);return(0,h.jsx)(`span`,{className:(0,f.cn)(`truncate`,c&&`text-muted-foreground`),children:s})}function kn({value:e}){let t=Q(e);return t==null||t===``?(0,h.jsx)(f.EmptyValue,{}):(0,h.jsx)(`span`,{className:`text-gray-700 font-mono text-sm`,children:String(t)})}function An({value:e}){if(!e)return(0,h.jsx)(f.EmptyValue,{});if(typeof e!=`object`)return(0,h.jsx)(`span`,{className:`truncate`,children:String(e)});if(Array.isArray(e))return(0,h.jsxs)(`div`,{className:`flex -space-x-2`,children:[e.slice(0,3).map((e,t)=>{if(typeof e!=`object`||!e)return(0,h.jsx)(`span`,{className:`truncate text-sm`,children:String(e)},t);let n=e.name||e.username||`User`;return(0,h.jsx)(f.Avatar,{className:`size-8 border-2 border-white`,title:n,children:(0,h.jsx)(f.AvatarFallback,{className:`bg-blue-500 text-white text-xs`,children:n.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)})},t)}),e.length>3&&(0,h.jsx)(f.Avatar,{className:`size-8 border-2 border-white`,children:(0,h.jsxs)(f.AvatarFallback,{className:`bg-gray-200 text-gray-600 text-xs`,children:[`+`,e.length-3]})})]});let t=e.name||e.username||`User`;return(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(f.Avatar,{className:`size-8`,children:(0,h.jsx)(f.AvatarFallback,{className:`bg-blue-500 text-white text-xs`,children:t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)})}),(0,h.jsx)(`span`,{className:`truncate`,children:t})]})}var jn=new Map;function Mn(e,t){jn.set(e,t)}var Nn={phone:`phone`,tel:`phone`,telephone:`phone`,email:`email`,url:`url`,uri:`url`,link:`url`,currency:`currency`,money:`currency`,percent:`percent`,percentage:`percent`},Pn=new Set([`text`,`textarea`,`string`,`longtext`,``]);function Fn(e){if(!e)return`text`;if(typeof e==`string`)return e;let t=(e.type||``).toLowerCase(),n=e.format,r=typeof n==`string`?n.toLowerCase():``;return r&&Nn[r]&&Pn.has(t)?Nn[r]:e.type||`text`}function In(e){return jn.has(e)?jn.get(e):{text:rn,textarea:rn,markdown:rn,html:rn,number:an,currency:on,percent:cn,boolean:un,date:dn,datetime:fn,time:rn,select:Sn,status:Sn,lookup:On,master_detail:On,email:Cn,url:wn,phone:Tn,file:En,image:Dn,formula:kn,summary:kn,auto_number:rn,user:An,owner:An,password:()=>(0,h.jsx)(`span`,{children:`••••••`}),location:rn,object:()=>(0,h.jsx)(`span`,{className:`text-gray-500 italic`,children:`[Object]`}),vector:()=>(0,h.jsx)(`span`,{className:`text-gray-500 italic`,children:`[Vector]`}),grid:()=>(0,h.jsx)(`span`,{className:`text-gray-500 italic`,children:`[Grid]`})}[e]||rn}Mn(`lookup`,On),Mn(`master_detail`,On),Mn(`select`,Sn),Mn(`status`,Sn),Mn(`user`,An),Mn(`owner`,An),me(In);function Ln(e){return{text:`field:text`,textarea:`field:textarea`,markdown:`field:markdown`,html:`field:html`,number:`field:number`,currency:`field:currency`,percent:`field:percent`,date:`field:date`,datetime:`field:datetime`,time:`field:time`,boolean:`field:boolean`,select:`field:select`,lookup:`field:lookup`,master_detail:`field:master_detail`,email:`field:email`,phone:`field:phone`,url:`field:url`,file:`field:file`,image:`field:image`,password:`field:password`,location:`field:location`,formula:`field:formula`,summary:`field:summary`,auto_number:`field:auto_number`}[e]||`field:text`}function Rn(e){if(e<0||!Number.isFinite(e)||e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${n.toFixed(+(r>0))} ${t[r]}`}function zn(e){let t={};return e.required&&(t.required=typeof e.required_message==`string`?e.required_message:`${e.label||e.name} is required`),e.min_length&&(t.minLength={value:e.min_length,message:e.min_length_message||`Minimum length is ${e.min_length} characters`}),e.max_length&&(t.maxLength={value:e.max_length,message:e.max_length_message||`Maximum length is ${e.max_length} characters`}),e.min!==void 0&&(t.min={value:e.min,message:e.min_message||`Minimum value is ${e.min}`}),e.max!==void 0&&(t.max={value:e.max,message:e.max_message||`Maximum value is ${e.max}`}),e.pattern&&(t.pattern={value:typeof e.pattern==`string`?new RegExp(e.pattern):e.pattern,message:e.pattern_message||`Invalid format`}),e.type===`email`&&(t.pattern={value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:`Please enter a valid email address`}),e.type===`url`&&(t.pattern={value:/^https?:\/\/.+/,message:`Please enter a valid URL`}),e.validate&&(t.validate=e.validate),Object.keys(t).length>0?t:void 0}function Bn(e,t){if(!e)return!0;if(e.field&&e.value!==void 0){let n=t[e.field];if(e.operator===`=`||e.operator===`==`)return n===e.value;if(e.operator===`!=`)return n!==e.value;if(e.operator===`>`)return n>e.value;if(e.operator===`>=`)return n>=e.value;if(e.operator===`<`)return n<e.value;if(e.operator===`<=`)return n<=e.value;if(e.operator===`in`)return Array.isArray(e.value)&&e.value.includes(n)}return e.and&&Array.isArray(e.and)?e.and.every(e=>Bn(e,t)):e.or&&Array.isArray(e.or)?e.or.some(e=>Bn(e,t)):!0}function $(e){let t=({schema:t,className:n,value:r,...i})=>{let[a,o]=u.default.useState(r??t?.value??``),s={name:t?.name||`field`,label:t?.label,type:t?.type,placeholder:t?.placeholder,required:t?.required,readonly:t?.readonly||t?.readOnly,help:t?.help,description:t?.description,defaultValue:t?.defaultValue||t?.value,...t},c=u.default.useCallback(e=>{o(e),i.onChange&&i.onChange(e)},[i]),l=t?.readonly||t?.readOnly||!1;return(0,h.jsxs)(`div`,{className:`grid w-full items-center gap-1.5`,"data-obj-id":t?.id,"data-obj-type":t?.type,children:[t?.label&&(0,h.jsx)(`label`,{htmlFor:t.id,className:t.required?`after:content-['*'] after:ml-0.5 after:text-red-500`:``,children:t.label}),(0,h.jsx)(e,{value:a,onChange:c,field:s,readonly:l,className:n}),t?.description&&(0,h.jsx)(`p`,{className:`text-sm text-gray-500`,children:t.description})]})};return t.displayName=`FieldRenderer(${e.displayName||e.name||`Component`})`,t}var Vn={text:()=>Promise.resolve().then(()=>(b(),v)).then(e=>({default:e.TextField})),textarea:()=>Promise.resolve().then(()=>(oe(),W)).then(e=>({default:e.TextAreaField})),number:()=>Promise.resolve().then(()=>(C(),x)).then(e=>({default:e.NumberField})),boolean:()=>Promise.resolve().then(()=>(E(),w)).then(e=>({default:e.BooleanField})),select:()=>Promise.resolve().then(()=>(te(),k)).then(e=>({default:e.SelectField})),date:()=>Promise.resolve().then(()=>(N(),j)).then(e=>({default:e.DateField})),datetime:()=>Promise.resolve().then(()=>(De(),Te)).then(e=>({default:e.DateTimeField})),time:()=>Promise.resolve().then(()=>(Z(),Oe)).then(e=>({default:e.TimeField})),email:()=>Promise.resolve().then(()=>(I(),P)).then(e=>({default:e.EmailField})),phone:()=>Promise.resolve().then(()=>(R(),ne)).then(e=>({default:e.PhoneField})),url:()=>Promise.resolve().then(()=>(B(),re)).then(e=>({default:e.UrlField})),currency:()=>Promise.resolve().then(()=>(U(),ie)).then(e=>({default:e.CurrencyField})),percent:()=>Promise.resolve().then(()=>(Me(),Ae)).then(e=>({default:e.PercentField})),password:()=>Promise.resolve().then(()=>(Fe(),Ne)).then(e=>({default:e.PasswordField})),markdown:()=>Promise.resolve().then(()=>(se(),G)).then(e=>({default:e.RichTextField})),html:()=>Promise.resolve().then(()=>(se(),G)).then(e=>({default:e.RichTextField})),lookup:()=>Promise.resolve().then(()=>(we(),_e)).then(e=>({default:e.LookupField})),master_detail:()=>Promise.resolve().then(()=>(we(),_e)).then(e=>({default:e.LookupField})),file:()=>Promise.resolve().then(()=>(Re(),Ie)).then(e=>({default:e.FileField})),image:()=>Promise.resolve().then(()=>(Ge(),He)).then(e=>({default:e.ImageField})),location:()=>Promise.resolve().then(()=>(Je(),Ke)).then(e=>({default:e.LocationField})),formula:()=>Promise.resolve().then(()=>(Ze(),Ye)).then(e=>({default:e.FormulaField})),summary:()=>Promise.resolve().then(()=>(et(),Qe)).then(e=>({default:e.SummaryField})),auto_number:()=>Promise.resolve().then(()=>(rt(),tt)).then(e=>({default:e.AutoNumberField})),user:()=>Promise.resolve().then(()=>(ot(),it)).then(e=>({default:e.UserField})),owner:()=>Promise.resolve().then(()=>(ot(),it)).then(e=>({default:e.UserField})),object:()=>Promise.resolve().then(()=>(lt(),st)).then(e=>({default:e.ObjectField})),vector:()=>Promise.resolve().then(()=>(ft(),ut)).then(e=>({default:e.VectorField})),grid:()=>Promise.resolve().then(()=>(ht(),pt)).then(e=>({default:e.GridField})),color:()=>Promise.resolve().then(()=>(vt(),gt)).then(e=>({default:e.ColorField})),slider:()=>Promise.resolve().then(()=>(xt(),yt)).then(e=>({default:e.SliderField})),rating:()=>Promise.resolve().then(()=>(wt(),St)).then(e=>({default:e.RatingField})),code:()=>Promise.resolve().then(()=>(Dt(),Tt)).then(e=>({default:e.CodeField})),avatar:()=>Promise.resolve().then(()=>(At(),Ot)).then(e=>({default:e.AvatarField})),address:()=>Promise.resolve().then(()=>(Nt(),jt)).then(e=>({default:e.AddressField})),geolocation:()=>Promise.resolve().then(()=>(It(),Pt)).then(e=>({default:e.GeolocationField})),signature:()=>Promise.resolve().then(()=>(zt(),Lt)).then(e=>({default:e.SignatureField})),qrcode:()=>Promise.resolve().then(()=>(Ht(),Bt)).then(e=>({default:e.QRCodeField}))};function Hn(e){let t=Vn[e];if(!t){console.warn(`Unknown field type: ${e}`);return}let n=u.default.lazy(t);d.ComponentRegistry.register(e,n,{namespace:`field`})}function Un(){Object.keys(Vn).forEach(e=>{Hn(e)})}function Wn(){d.ComponentRegistry.register(`text`,$(y),{namespace:`field`}),d.ComponentRegistry.register(`textarea`,$(ae),{namespace:`field`}),d.ComponentRegistry.register(`number`,$(S),{namespace:`field`}),d.ComponentRegistry.register(`boolean`,$(T),{namespace:`field`}),d.ComponentRegistry.register(`select`,$(A),{namespace:`field`}),d.ComponentRegistry.register(`date`,$(M),{namespace:`field`}),d.ComponentRegistry.register(`datetime`,$(Ee),{namespace:`field`}),d.ComponentRegistry.register(`time`,$(ke),{namespace:`field`}),d.ComponentRegistry.register(`email`,$(F),{namespace:`field`}),d.ComponentRegistry.register(`phone`,$(L),{namespace:`field`}),d.ComponentRegistry.register(`url`,$(z),{namespace:`field`}),d.ComponentRegistry.register(`currency`,$(H),{namespace:`field`}),d.ComponentRegistry.register(`percent`,$(je),{namespace:`field`}),d.ComponentRegistry.register(`password`,$(Pe),{namespace:`field`}),d.ComponentRegistry.register(`markdown`,$(K),{namespace:`field`}),d.ComponentRegistry.register(`html`,$(K),{namespace:`field`}),d.ComponentRegistry.register(`lookup`,$(xe),{namespace:`field`}),d.ComponentRegistry.register(`master_detail`,$(xe),{namespace:`field`}),d.ComponentRegistry.register(`file`,$(Le),{namespace:`field`}),d.ComponentRegistry.register(`image`,$(Ue),{namespace:`field`}),d.ComponentRegistry.register(`location`,$(qe),{namespace:`field`}),d.ComponentRegistry.register(`formula`,$(Xe),{namespace:`field`}),d.ComponentRegistry.register(`summary`,$($e),{namespace:`field`}),d.ComponentRegistry.register(`auto_number`,$(nt),{namespace:`field`}),d.ComponentRegistry.register(`user`,$(at),{namespace:`field`}),d.ComponentRegistry.register(`owner`,$(at),{namespace:`field`}),d.ComponentRegistry.register(`object`,$(ct),{namespace:`field`}),d.ComponentRegistry.register(`vector`,$(dt),{namespace:`field`}),d.ComponentRegistry.register(`grid`,$(mt),{namespace:`field`}),d.ComponentRegistry.register(`color`,$(_t),{namespace:`field`}),d.ComponentRegistry.register(`slider`,$(bt),{namespace:`field`}),d.ComponentRegistry.register(`rating`,$(Ct),{namespace:`field`}),d.ComponentRegistry.register(`code`,$(Et),{namespace:`field`}),d.ComponentRegistry.register(`avatar`,$(kt),{namespace:`field`}),d.ComponentRegistry.register(`address`,$(Mt),{namespace:`field`}),d.ComponentRegistry.register(`geolocation`,$(Ft),{namespace:`field`}),d.ComponentRegistry.register(`signature`,$(Rt),{namespace:`field`}),d.ComponentRegistry.register(`qrcode`,$(Vt),{namespace:`field`})}Un(),exports.AddressField=Mt,exports.AutoNumberField=nt,exports.AvatarField=kt,exports.BooleanCellRenderer=un,exports.BooleanField=T,exports.CodeField=Et,exports.ColorField=_t,exports.CurrencyCellRenderer=on,exports.CurrencyField=H,exports.DateCellRenderer=dn,exports.DateField=M,exports.DateTimeCellRenderer=fn,exports.DateTimeField=Ee,exports.EmailCellRenderer=Cn,exports.EmailField=F,exports.FileCellRenderer=En,exports.FileField=Le,exports.FormulaCellRenderer=kn,exports.FormulaField=Xe,exports.GeolocationField=Ft,exports.GridField=mt,exports.ImageCellRenderer=Dn,exports.ImageCropperDialog=Be,exports.ImageField=Ue,exports.LocationField=qe,exports.LookupCellRenderer=On,exports.LookupField=xe,exports.MasterDetailField=Ut,exports.NumberCellRenderer=an,exports.NumberField=S,exports.ObjectField=ct,exports.PasswordField=Pe,exports.PercentCellRenderer=cn,exports.PercentField=je,exports.PhoneCellRenderer=Tn,exports.PhoneField=L,exports.QRCodeField=Vt,exports.RatingField=Ct,exports.RecordPickerDialog=de,exports.RichTextField=K,exports.SelectCellRenderer=Sn,exports.SelectField=A,exports.SignatureField=Rt,exports.SliderField=bt,exports.SummaryField=$e,exports.TextAreaField=ae,exports.TextCellRenderer=rn,exports.TextField=y,exports.TimeField=ke,exports.UrlCellRenderer=wn,exports.UrlField=z,exports.UserCellRenderer=An,exports.UserField=at,exports.VectorField=dt,exports.buildValidationRules=zn,exports.coerceToSafeValue=Q,exports.evaluateCondition=Bn,exports.formatCompactCurrency=Xt,exports.formatCurrency=Yt,exports.formatDate=tn,exports.formatDateTime=nn,exports.formatFileSize=Rn,exports.formatNumber=Zt,exports.formatPercent=Qt,exports.formatRelativeDate=en,exports.getBadgeColorClasses=vn,exports.getCellRenderer=In,exports.getSemanticColorName=yn,exports.getSemanticHex=xn,exports.humanizeLabel=$t,exports.isLikelyOpaqueId=Kt,exports.mapFieldTypeToFormType=Ln,exports.registerAllFields=Un,exports.registerField=Hn,exports.registerFieldRenderer=Mn,exports.registerFields=Wn,exports.resolveCellRendererType=Fn;
|
package/dist/index.js
CHANGED
|
@@ -3039,10 +3039,10 @@ function yr({ value: e, field: t }) {
|
|
|
3039
3039
|
}
|
|
3040
3040
|
function br({ value: e, field: t }) {
|
|
3041
3041
|
if (e == null) return /* @__PURE__ */ q(S, {});
|
|
3042
|
-
let n = Q(e), r = t, i = r.currency || r.defaultCurrency, a = Number(n), o = r.precision ?? r.scale ?? r.decimals ?? 2;
|
|
3042
|
+
let n = Q(e), r = t, i = r.currency || r.defaultCurrency || "USD", a = Number(n), o = r.precision ?? r.scale ?? r.decimals ?? 2, s = isNaN(a) ? String(n) : ur(a, i);
|
|
3043
3043
|
return /* @__PURE__ */ q("span", {
|
|
3044
3044
|
className: "tabular-nums font-medium whitespace-nowrap",
|
|
3045
|
-
children:
|
|
3045
|
+
children: o === 0 ? s.replace(/[.,]00$/, "") : s
|
|
3046
3046
|
});
|
|
3047
3047
|
}
|
|
3048
3048
|
var xr = /progress|completion/;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/fields",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Field renderers and registry for Object UI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"clsx": "^2.1.1",
|
|
28
28
|
"lucide-react": "^1.16.0",
|
|
29
29
|
"tailwind-merge": "^3.6.0",
|
|
30
|
-
"@object-ui/components": "5.0.
|
|
31
|
-
"@object-ui/core": "5.0.
|
|
32
|
-
"@object-ui/i18n": "5.0.
|
|
33
|
-
"@object-ui/providers": "5.0.
|
|
34
|
-
"@object-ui/react": "5.0.
|
|
35
|
-
"@object-ui/types": "5.0.
|
|
30
|
+
"@object-ui/components": "5.0.2",
|
|
31
|
+
"@object-ui/core": "5.0.2",
|
|
32
|
+
"@object-ui/i18n": "5.0.2",
|
|
33
|
+
"@object-ui/providers": "5.0.2",
|
|
34
|
+
"@object-ui/react": "5.0.2",
|
|
35
|
+
"@object-ui/types": "5.0.2"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": "^18.0.0 || ^19.0.0",
|
package/src/index.tsx
CHANGED
|
@@ -400,15 +400,23 @@ export function CurrencyCellRenderer({ value, field }: CellRendererProps): React
|
|
|
400
400
|
const safe = coerceToSafeValue(value);
|
|
401
401
|
const currencyField = field as any;
|
|
402
402
|
// Honor both `currency` (legacy/grid configs) and `defaultCurrency`
|
|
403
|
-
// (the canonical key from `@objectstack/spec` Field.currency()).
|
|
404
|
-
|
|
403
|
+
// (the canonical key from `@objectstack/spec` Field.currency()). When
|
|
404
|
+
// neither is supplied, fall back to USD so currency-typed fields always
|
|
405
|
+
// render with a symbol — a bare "5,000,000.00" is indistinguishable from
|
|
406
|
+
// a plain number and is the #1 source of "is this dollars or what?"
|
|
407
|
+
// confusion in customer screenshots.
|
|
408
|
+
const currency: string =
|
|
409
|
+
currencyField.currency || currencyField.defaultCurrency || 'USD';
|
|
405
410
|
const num = Number(safe);
|
|
406
411
|
const decimals = currencyField.precision ?? currencyField.scale ?? currencyField.decimals ?? 2;
|
|
407
412
|
const formatted = !isNaN(num)
|
|
408
|
-
?
|
|
413
|
+
? formatCurrency(num, currency)
|
|
409
414
|
: String(safe);
|
|
410
|
-
|
|
411
|
-
|
|
415
|
+
// Hide trailing fractional digits when the field opted into integer-only
|
|
416
|
+
// precision (e.g. annual_revenue stored as whole units).
|
|
417
|
+
const display = decimals === 0 ? formatted.replace(/[.,]00$/, '') : formatted;
|
|
418
|
+
|
|
419
|
+
return <span className="tabular-nums font-medium whitespace-nowrap">{display}</span>;
|
|
412
420
|
}
|
|
413
421
|
|
|
414
422
|
// Fields that store percentage values as whole numbers (0-100) rather than fractions (0-1)
|