@object-ui/fields 3.0.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fields/src/__tests__/boolean-checkbox.test.d.ts +0 -0
- package/dist/fields/src/__tests__/cell-renderers.test.d.ts +0 -0
- package/dist/fields/src/__tests__/datetime-cell.test.d.ts +0 -0
- package/dist/fields/src/index.d.ts +26 -5
- package/dist/fields/src/widgets/FileField.d.ts +2 -1
- package/dist/fields/src/widgets/PercentField.d.ts +1 -0
- package/dist/index.cjs +8 -3
- package/dist/index.js +1308 -1108
- package/package.json +7 -7
- package/src/__tests__/boolean-checkbox.test.tsx +74 -0
- package/src/__tests__/cell-renderers.test.tsx +953 -0
- package/src/__tests__/datetime-cell.test.tsx +46 -0
- package/src/index.tsx +318 -75
- package/src/remaining-widgets.test.tsx +26 -0
- package/src/widgets/FileField.tsx +137 -35
- package/src/widgets/GridField.tsx +9 -9
- package/src/widgets/PercentField.tsx +43 -14
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -13,15 +13,34 @@ export interface CellRendererProps {
|
|
|
13
13
|
* Format currency value
|
|
14
14
|
*/
|
|
15
15
|
export declare function formatCurrency(value: number, currency?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Format currency value in compact form for mobile display.
|
|
18
|
+
* E.g., $150,000 → $150K, $1,200,000 → $1.2M
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatCompactCurrency(value: number, currency?: string): string;
|
|
16
21
|
/**
|
|
17
22
|
* Format percent value
|
|
18
23
|
* Handles both decimal (0.8 = 80%) and whole number (80 = 80%) inputs.
|
|
19
24
|
*/
|
|
20
25
|
export declare function formatPercent(value: number, precision?: number): string;
|
|
26
|
+
/**
|
|
27
|
+
* Humanize a snake_case or kebab-case string into Title Case.
|
|
28
|
+
* Used as fallback label when no explicit option.label exists.
|
|
29
|
+
*
|
|
30
|
+
* Examples:
|
|
31
|
+
* "in_progress" → "In Progress"
|
|
32
|
+
* "high-priority" → "High Priority"
|
|
33
|
+
* "active" → "Active"
|
|
34
|
+
*/
|
|
35
|
+
export declare function humanizeLabel(value: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Format date as relative time (e.g., "2 days ago", "Today", "Overdue 3d")
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatRelativeDate(value: string | Date): string;
|
|
21
40
|
/**
|
|
22
41
|
* Format date value
|
|
23
42
|
*/
|
|
24
|
-
export declare function formatDate(value: string | Date,
|
|
43
|
+
export declare function formatDate(value: string | Date, style?: string): string;
|
|
25
44
|
/**
|
|
26
45
|
* Format datetime value
|
|
27
46
|
*/
|
|
@@ -43,15 +62,17 @@ export declare function CurrencyCellRenderer({ value, field }: CellRendererProps
|
|
|
43
62
|
*/
|
|
44
63
|
export declare function PercentCellRenderer({ value, field }: CellRendererProps): React.ReactElement;
|
|
45
64
|
/**
|
|
46
|
-
* Boolean field cell renderer
|
|
65
|
+
* Boolean field cell renderer (Airtable-style checkbox)
|
|
66
|
+
* Supports semantic rendering for completion fields (green indicator)
|
|
67
|
+
* and warning badge for active/enabled fields when false.
|
|
47
68
|
*/
|
|
48
|
-
export declare function BooleanCellRenderer({ value }: CellRendererProps): React.ReactElement;
|
|
69
|
+
export declare function BooleanCellRenderer({ value, field }: CellRendererProps): React.ReactElement;
|
|
49
70
|
/**
|
|
50
71
|
* Date field cell renderer
|
|
51
72
|
*/
|
|
52
73
|
export declare function DateCellRenderer({ value, field }: CellRendererProps): React.ReactElement;
|
|
53
74
|
/**
|
|
54
|
-
* DateTime field cell renderer
|
|
75
|
+
* DateTime field cell renderer (Airtable-style with date and time visually separated)
|
|
55
76
|
*/
|
|
56
77
|
export declare function DateTimeCellRenderer({ value }: CellRendererProps): React.ReactElement;
|
|
57
78
|
/**
|
|
@@ -81,7 +102,7 @@ export declare function ImageCellRenderer({ value }: CellRendererProps): React.R
|
|
|
81
102
|
/**
|
|
82
103
|
* Lookup/Master-Detail field cell renderer
|
|
83
104
|
*/
|
|
84
|
-
export declare function LookupCellRenderer({ value }: CellRendererProps): React.ReactElement;
|
|
105
|
+
export declare function LookupCellRenderer({ value, field }: CellRendererProps): React.ReactElement;
|
|
85
106
|
/**
|
|
86
107
|
* Formula field cell renderer (read-only)
|
|
87
108
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FieldWidgetProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* FileField - File upload widget with drag-and-drop support
|
|
4
|
-
* Supports single and multiple file uploads with configurable accepted file types
|
|
4
|
+
* Supports single and multiple file uploads with configurable accepted file types.
|
|
5
|
+
* L2: File size validation, per-file progress indicators, error messages.
|
|
5
6
|
*/
|
|
6
7
|
export declare function FileField({ value, onChange, field, readonly, ...props }: FieldWidgetProps<any>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,5 +2,6 @@ import { FieldWidgetProps } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* PercentField - Percentage input with configurable decimal precision
|
|
4
4
|
* Stores values as decimals (0-1) and displays as percentages (0-100%)
|
|
5
|
+
* Includes a slider for interactive control.
|
|
5
6
|
*/
|
|
6
7
|
export declare function PercentField({ value, onChange, field, readonly, errorMessage, className, ...props }: FieldWidgetProps<number>): import("react/jsx-runtime").JSX.Element;
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react"),b=require("@object-ui/core"),d=require("@object-ui/components"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react"),b=require("@object-ui/core"),d=require("@object-ui/components"),_=require("lucide-react");var X={exports:{}},V={};var Ge;function gt(){if(Ge)return V;Ge=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function n(a,s,i){var l=null;if(i!==void 0&&(l=""+i),s.key!==void 0&&(l=""+s.key),"key"in s){i={};for(var o in s)o!=="key"&&(i[o]=s[o])}else i=s;return s=i.ref,{$$typeof:e,type:a,key:l,ref:s!==void 0?s:null,props:i}}return V.Fragment=r,V.jsx=n,V.jsxs=n,V}var Y={};var Je;function bt(){return Je||(Je=1,process.env.NODE_ENV!=="production"&&(function(){function e(u){if(u==null)return null;if(typeof u=="function")return u.$$typeof===I?null:u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case k:return"Fragment";case P:return"Profiler";case v:return"StrictMode";case j:return"Suspense";case S:return"SuspenseList";case O:return"Activity"}if(typeof u=="object")switch(typeof u.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),u.$$typeof){case F:return"Portal";case B:return u.displayName||"Context";case z:return(u._context.displayName||"Context")+".Consumer";case W:var y=u.render;return u=u.displayName,u||(u=y.displayName||y.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case A:return y=u.displayName||null,y!==null?y:e(u.type)||"Memo";case $:y=u._payload,u=u._init;try{return e(u(y))}catch{}}return null}function r(u){return""+u}function n(u){try{r(u);var y=!1}catch{y=!0}if(y){y=console;var w=y.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&u[Symbol.toStringTag]||u.constructor.name||"Object";return w.call(y,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),r(u)}}function a(u){if(u===k)return"<>";if(typeof u=="object"&&u!==null&&u.$$typeof===$)return"<...>";try{var y=e(u);return y?"<"+y+">":"<...>"}catch{return"<...>"}}function s(){var u=L.A;return u===null?null:u.getOwner()}function i(){return Error("react-stack-top-frame")}function l(u){if(D.call(u,"key")){var y=Object.getOwnPropertyDescriptor(u,"key").get;if(y&&y.isReactWarning)return!1}return u.key!==void 0}function o(u,y){function w(){Ue||(Ue=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",y))}w.isReactWarning=!0,Object.defineProperty(u,"key",{get:w,configurable:!0})}function c(){var u=e(this.type);return Be[u]||(Be[u]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),u=this.props.ref,u!==void 0?u:null}function f(u,y,w,R,Q,re){var T=w.ref;return u={$$typeof:g,type:u,key:y,props:w,_owner:R},(T!==void 0?T:null)!==null?Object.defineProperty(u,"ref",{enumerable:!1,get:c}):Object.defineProperty(u,"ref",{enumerable:!1,value:null}),u._store={},Object.defineProperty(u._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(u,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(u,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.defineProperty(u,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:re}),Object.freeze&&(Object.freeze(u.props),Object.freeze(u)),u}function h(u,y,w,R,Q,re){var T=y.children;if(T!==void 0)if(R)if(xt(T)){for(R=0;R<T.length;R++)p(T[R]);Object.freeze&&Object.freeze(T)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p(T);if(D.call(y,"key")){T=e(u);var U=Object.keys(y).filter(function(ht){return ht!=="key"});R=0<U.length?"{key: someKey, "+U.join(": ..., ")+": ...}":"{key: someKey}",qe[T+R]||(U=0<U.length?"{"+U.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,S,w,O,w),Me[w+S]=!0)}if(w=null,_!==void 0&&(a(_),w=""+_),i(j)&&(a(j.key),w=""+j.key),"key"in j){_={};for(var J in j)J!=="key"&&(_[J]=j[J])}else _=j;return w&&o(_,typeof m=="function"?m.displayName||m.name||"Unknown":m),f(m,w,_,n(),E,q)}function p(m){u(m)?m._store&&(m._store.validated=1):typeof m=="object"&&m!==null&&m.$$typeof===B&&(m._payload.status==="fulfilled"?u(m._payload.value)&&m._payload.value._store&&(m._payload.value._store.validated=1):m._store&&(m._store.validated=1))}function u(m){return typeof m=="object"&&m!==null&&m.$$typeof===g}var x=C,g=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),L=Symbol.for("react.context"),it=Symbol.for("react.forward_ref"),ot=Symbol.for("react.suspense"),ct=Symbol.for("react.suspense_list"),dt=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),ut=Symbol.for("react.activity"),mt=Symbol.for("react.client.reference"),V=x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ae=Object.prototype.hasOwnProperty,ft=Array.isArray,Y=console.createTask?console.createTask:function(){return null};x={react_stack_bottom_frame:function(m){return m()}};var ke,$e={},ze=x.react_stack_bottom_frame.bind(x,l)(),Ee=Y(s(l)),Me={};$.Fragment=P,$.jsx=function(m,j,_){var S=1e4>V.recentlyCreatedOwnerStacks++;return h(m,j,_,!1,S?Error("react-stack-top-frame"):ze,S?Y(s(m)):Ee)},$.jsxs=function(m,j,_){var S=1e4>V.recentlyCreatedOwnerStacks++;return h(m,j,_,!0,S?Error("react-stack-top-frame"):ze,S?Y(s(m)):Ee)}})()),$}var De;function gt(){return De||(De=1,process.env.NODE_ENV==="production"?M.exports=pt():M.exports=ht()),M.exports}var t=gt();function H({value:e,onChange:r,field:a,readonly:s,...n}){const l=a||n.schema;if(s)return t.jsx("span",{className:"text-sm",children:e||"-"});const i=l?.rows,{inputType:o,...c}=n;return i&&i>1?t.jsx(d.Textarea,{...c,value:e||"",onChange:f=>r(f.target.value),placeholder:l?.placeholder,disabled:s||c.disabled}):t.jsx(d.Input,{...c,type:l?.type==="password"?"password":"text",value:e||"",onChange:f=>r(f.target.value),placeholder:l?.placeholder,disabled:s||c.disabled})}const bt=Object.freeze(Object.defineProperty({__proto__:null,TextField:H},Symbol.toStringTag,{value:"Module"}));function Z({value:e,onChange:r,field:a,readonly:s,...n}){if(s)return t.jsx("span",{className:"text-sm",children:e??"-"});const l=a||n.schema,i=l?.precision,{inputType:o,...c}=n;return t.jsx(d.Input,{...c,type:"number",value:e??"",onChange:f=>{const h=f.target.value;r(h===""?null:Number(h))},placeholder:l?.placeholder,disabled:s||c.disabled,step:i?Math.pow(10,-i):"any"})}const jt=Object.freeze(Object.defineProperty({__proto__:null,NumberField:Z},Symbol.toStringTag,{value:"Module"}));function K({value:e,onChange:r,field:a,readonly:s,...n}){const l=a||n.schema,i=l?.widget,o=C.useId(),c=l?.name||o,f=l?.label||"Checkbox";if(s)return t.jsx("span",{className:"text-sm",children:e?"Yes":"No"});const{inputType:h,...p}=n;return i==="checkbox"?t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(d.Checkbox,{...p,id:c,checked:!!e,onCheckedChange:u=>r(!!u),disabled:s||p.disabled}),t.jsx(d.Label,{htmlFor:c,children:f})]}):t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(d.Switch,{...p,id:c,checked:!!e,onCheckedChange:r,disabled:s||p.disabled}),t.jsx(d.Label,{htmlFor:c,children:f})]})}const yt=Object.freeze(Object.defineProperty({__proto__:null,BooleanField:K},Symbol.toStringTag,{value:"Module"}));function ee({value:e,onChange:r,field:a,readonly:s,...n}){const l=a||n.schema,i=l?.options||[];if(s){const o=i.find(c=>c.value===e);return t.jsx("span",{className:"text-sm",children:o?.label||e||"-"})}return t.jsxs(d.Select,{...n,value:e,onValueChange:r,disabled:s||n.disabled,children:[t.jsx(d.SelectTrigger,{className:n.className,id:n.id,children:t.jsx(d.SelectValue,{placeholder:l?.placeholder||"Select an option"})}),t.jsx(d.SelectContent,{position:"popper",children:i.map(o=>t.jsx(d.SelectItem,{value:o.value,children:o.label},o.value))})]})}const Nt=Object.freeze(Object.defineProperty({__proto__:null,SelectField:ee},Symbol.toStringTag,{value:"Module"}));function te({value:e,onChange:r,field:a,readonly:s,...n}){if(s)return t.jsx("span",{className:"text-sm",children:e?new Date(e).toLocaleDateString():"-"});const{inputType:l,...i}=n;return t.jsx(d.Input,{...i,type:"date",value:e||"",onChange:o=>r(o.target.value),disabled:s||i.disabled})}const vt=Object.freeze(Object.defineProperty({__proto__:null,DateField:te},Symbol.toStringTag,{value:"Module"}));function re({value:e,onChange:r,field:a,readonly:s,errorMessage:n,...l}){const i=a||l.schema;if(s)return e?t.jsx("a",{href:`mailto:${e}`,className:"text-sm text-blue-600 hover:text-blue-800 hover:underline",children:e}):t.jsx("span",{className:"text-sm",children:"-"});const{inputType:o,...c}=l;return t.jsx(d.Input,{...c,type:"email",value:e||"",onChange:f=>r(f.target.value),placeholder:i?.placeholder||"email@example.com",disabled:s||c.disabled,"aria-invalid":!!n})}const Ft=Object.freeze(Object.defineProperty({__proto__:null,EmailField:re},Symbol.toStringTag,{value:"Module"}));function se({value:e,onChange:r,field:a,readonly:s,errorMessage:n,...l}){const i=a||l.schema;if(s)return e?t.jsx("a",{href:`tel:${e}`,className:"text-sm text-blue-600 hover:text-blue-800 hover:underline",children:e}):t.jsx("span",{className:"text-sm",children:"-"});const{inputType:o,...c}=l;return t.jsx(d.Input,{...c,type:"tel",value:e||"",onChange:f=>r(f.target.value),placeholder:i?.placeholder||"(555) 123-4567",disabled:s||c.disabled,"aria-invalid":!!n})}const _t=Object.freeze(Object.defineProperty({__proto__:null,PhoneField:se},Symbol.toStringTag,{value:"Module"}));function ne({value:e,onChange:r,field:a,readonly:s,errorMessage:n,...l}){const i=a||l.schema;if(s)return e?e.startsWith("http://")||e.startsWith("https://")?t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:text-blue-800 hover:underline",children:e}):t.jsx("span",{className:"text-sm",children:e}):t.jsx("span",{className:"text-sm",children:"-"});const{inputType:o,...c}=l;return t.jsx(d.Input,{...c,type:"url",value:e||"",onChange:f=>r(f.target.value),placeholder:i?.placeholder||"https://example.com",disabled:s||c.disabled,"aria-invalid":!!n})}const Ct=Object.freeze(Object.defineProperty({__proto__:null,UrlField:ne},Symbol.toStringTag,{value:"Module"}));function St(e,r="USD"){try{return new Intl.NumberFormat("en-US",{style:"currency",currency:r}).format(e)}catch{return`${r} ${e.toFixed(2)}`}}function ae({value:e,onChange:r,field:a,readonly:s,errorMessage:n,className:l,...i}){const o=a||i.schema,c=o?.currency||"USD",f=o?.precision??2;if(s)return e==null?t.jsx("span",{className:"text-sm",children:"-"}):t.jsx("span",{className:"text-sm font-medium tabular-nums",children:St(Number(e),c)});const h=p=>{const u=parseFloat(p.target.value);isNaN(u)||r(parseFloat(u.toFixed(f)))};return t.jsxs("div",{className:"relative",children:[t.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-gray-500",children:c==="USD"?"$":c}),t.jsx(d.Input,{...i,type:"number",value:e??"",onChange:p=>{const u=p.target.value===""?null:parseFloat(p.target.value);r(u)},onBlur:h,placeholder:o?.placeholder||"0.00",disabled:s||i.disabled,className:`pl-8 ${l||""}`,step:Math.pow(10,-f).toFixed(f),"aria-invalid":!!n})]})}const wt=Object.freeze(Object.defineProperty({__proto__:null,CurrencyField:ae},Symbol.toStringTag,{value:"Module"}));function le({value:e,onChange:r,field:a,readonly:s,errorMessage:n,...l}){if(s)return t.jsx("div",{className:"text-sm whitespace-pre-wrap",children:e||"-"});const i=a||l.schema,o=i?.rows||4,c=i?.max_length,{inputType:f,...h}=l;return t.jsxs("div",{className:"relative",children:[t.jsx(d.Textarea,{...h,value:e||"",onChange:p=>r(p.target.value),placeholder:i?.placeholder,disabled:s||h.disabled,rows:o,maxLength:c,"aria-invalid":!!n}),c&&t.jsxs("div",{className:"absolute bottom-2 right-2 text-xs text-gray-400","aria-live":"polite","aria-label":`Character count: ${(e||"").length} of ${c}`,children:[(e||"").length,"/",c]})]})}const Rt=Object.freeze(Object.defineProperty({__proto__:null,TextAreaField:le},Symbol.toStringTag,{value:"Module"}));function I({value:e,onChange:r,field:a,readonly:s,errorMessage:n,...l}){if(s)return t.jsx("div",{className:"text-sm prose prose-sm max-w-none",children:e||"-"});const i=a||l.schema,o=i?.rows||8,c=i?.format||"markdown";return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500",children:[t.jsxs("span",{children:["Format: ",c]}),t.jsx("span",{className:"italic",children:"Rich text editor (basic)"})]}),t.jsx(d.Textarea,{value:e||"",onChange:f=>r(f.target.value),placeholder:i?.placeholder||"Enter text...",disabled:s||l.disabled,rows:o,className:`font-mono text-sm ${l.className||""}`,"aria-invalid":!!n})]})}const Le=Object.freeze(Object.defineProperty({__proto__:null,RichTextField:I},Symbol.toStringTag,{value:"Module"}));function ie({value:e,onChange:r,field:a,readonly:s,...n}){const[l,i]=C.useState(!1),[o,c]=C.useState(""),f=a||n.schema,h=f?.options||[],p=f.multiple||!1,u=f.display_field||"label",x=h.filter(N=>N.label.toLowerCase().includes(o.toLowerCase())),g=p?(Array.isArray(e)?e:[]).map(N=>h.find(R=>R.value===N)).filter(Boolean):e?[h.find(N=>N.value===e)].filter(Boolean):[],v=N=>{if(p){const R=Array.isArray(e)?e:[],A=R.includes(N.value);r(A?R.filter(L=>L!==N.value):[...R,N.value])}else r(N.value),i(!1)},P=N=>{if(p){const R=Array.isArray(e)?e:[];r(R.filter(A=>A!==N))}else r(null)};return s?g.length?p?t.jsx("div",{className:"flex flex-wrap gap-1",children:g.map((N,R)=>t.jsx(d.Badge,{variant:"outline",children:N?.[u]||N?.label},R))}):t.jsx("span",{className:"text-sm",children:g[0]?.[u]||g[0]?.label}):t.jsx("span",{className:"text-sm",children:"-"}):t.jsxs("div",{className:"space-y-2",children:[g.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:g.map((N,R)=>t.jsxs(d.Badge,{variant:"outline",className:"gap-1",children:[N?.[u]||N?.label,t.jsx("button",{onClick:()=>P(N?.value),className:"ml-1 hover:text-destructive",type:"button","aria-label":`Remove ${N?.[u]||N?.label}`,children:t.jsx(F.X,{className:"size-3"})})]},R))}),t.jsxs(d.Dialog,{open:l,onOpenChange:i,children:[t.jsx(d.DialogTrigger,{asChild:!0,children:t.jsxs(d.Button,{variant:"outline",className:"w-full justify-start text-left font-normal",type:"button",children:[t.jsx(F.Search,{className:"mr-2 size-4"}),g.length===0?f?.placeholder||"Select...":p?`${g.length} selected`:"Change selection"]})}),t.jsxs(d.DialogContent,{className:"max-w-md",children:[t.jsx(d.DialogHeader,{children:t.jsxs(d.DialogTitle,{children:[f?.label||"Select"," ",p&&"(multiple)"]})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(d.Input,{placeholder:"Search...",value:o,onChange:N=>c(N.target.value),className:"w-full"}),t.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:x.length===0?t.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"No options found"}):x.map(N=>{const R=p?(Array.isArray(e)?e:[]).includes(N.value):e===N.value;return t.jsxs("button",{onClick:()=>v(N),className:`w-full text-left px-3 py-2 rounded-md text-sm hover:bg-gray-100 flex items-center justify-between ${R?"bg-blue-50 text-blue-700":""}`,type:"button",children:[t.jsx("span",{children:N.label}),R&&t.jsx(d.Badge,{variant:"default",className:"ml-2",children:"Selected"})]},N.value)})})]})]})]})]})}const Pt=Object.freeze(Object.defineProperty({__proto__:null,LookupField:ie},Symbol.toStringTag,{value:"Module"}));function oe({value:e,onChange:r,field:a,readonly:s,...n}){if(s){if(!e)return t.jsx("span",{className:"text-sm",children:"-"});const o=new Date(e);return t.jsxs("span",{className:"text-sm",children:[o.toLocaleDateString()," ",o.toLocaleTimeString()]})}const{inputType:l,...i}=n;return t.jsx(d.Input,{...i,type:"datetime-local",value:e||"",onChange:o=>r(o.target.value),disabled:s||i.disabled})}const Tt=Object.freeze(Object.defineProperty({__proto__:null,DateTimeField:oe},Symbol.toStringTag,{value:"Module"}));function ce({value:e,onChange:r,field:a,readonly:s,...n}){if(s)return t.jsx("span",{className:"text-sm",children:e||"-"});const{inputType:l,...i}=n;return t.jsx(d.Input,{...i,type:"time",value:e||"",onChange:o=>r(o.target.value),disabled:s||i.disabled})}const Ot=Object.freeze(Object.defineProperty({__proto__:null,TimeField:ce},Symbol.toStringTag,{value:"Module"}));function de({value:e,onChange:r,field:a,readonly:s,errorMessage:n,className:l,...i}){const o=a||i.schema,c=o?.precision??2;if(s)return e==null?t.jsx("span",{className:"text-sm",children:"-"}):t.jsxs("span",{className:"text-sm font-medium tabular-nums",children:[(e*100).toFixed(c),"%"]});const f=e!=null?e*100:"",h=p=>{if(p.target.value===""){r(null);return}const u=parseFloat(p.target.value),x=isNaN(u)?null:u/100;r(x)};return t.jsxs("div",{className:"relative",children:[t.jsx(d.Input,{...i,type:"number",value:f,onChange:h,placeholder:o?.placeholder||"0",disabled:s||i.disabled,className:`pr-8 ${l||""}`,step:Math.pow(10,-c).toFixed(c),"aria-invalid":!!n}),t.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-500",children:"%"})]})}const At=Object.freeze(Object.defineProperty({__proto__:null,PercentField:de},Symbol.toStringTag,{value:"Module"}));function ue({value:e,onChange:r,field:a,readonly:s,className:n,...l}){const[i,o]=C.useState(!1),c=a||l.schema;if(s)return t.jsx("span",{className:"text-sm",children:"••••••••"});const{inputType:f,...h}=l;return t.jsxs("div",{className:"relative",children:[t.jsx(d.Input,{...h,type:i?"text":"password",value:e||"",onChange:p=>r(p.target.value),placeholder:c?.placeholder,disabled:s||h.disabled,className:`pr-10 ${n||""}`}),t.jsx(d.Button,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>o(!i),tabIndex:-1,children:i?t.jsx(F.EyeOff,{className:"size-4 text-gray-500"}):t.jsx(F.Eye,{className:"size-4 text-gray-500"})})]})}const kt=Object.freeze(Object.defineProperty({__proto__:null,PasswordField:ue},Symbol.toStringTag,{value:"Module"}));function me({value:e,onChange:r,field:a,readonly:s,...n}){const l=C.useRef(null),i=a||n.schema,o=i?.multiple||!1,c=i?.accept?i.accept.join(","):void 0;if(s){if(!e)return t.jsx("span",{className:"text-sm",children:"-"});const u=Array.isArray(e)?e:[e];return t.jsx("div",{className:"flex flex-wrap gap-2",children:u.map((x,g)=>t.jsx("span",{className:"text-sm truncate max-w-xs",children:x.name||x.original_name||"File"},g))})}const f=e?Array.isArray(e)?e:[e]:[],h=u=>{const x=Array.from(u.target.files||[]);if(x.length===0)return;const g=x.map(v=>({name:v.name,original_name:v.name,size:v.size,mime_type:v.type,url:URL.createObjectURL(v)}));r(o?[...f,...g]:g[0])},p=u=>{if(o){const x=f.filter((g,v)=>v!==u);r(x.length>0?x:null)}else r(null)};return t.jsxs("div",{className:n.className,children:[t.jsx("input",{ref:l,type:"file",multiple:o,accept:c,onChange:h,className:"hidden"}),t.jsxs("div",{className:"space-y-2",children:[f.length>0&&t.jsx("div",{className:"space-y-1",children:f.map((u,x)=>t.jsxs("div",{className:"flex items-center justify-between gap-2 p-2 bg-gray-50 rounded-md border border-gray-200",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[t.jsx(F.File,{className:"size-4 text-gray-500 flex-shrink-0"}),t.jsx("span",{className:"text-sm truncate",children:u.name||u.original_name||"File"}),u.size&&t.jsxs("span",{className:"text-xs text-gray-500",children:["(",(u.size/1024).toFixed(1)," KB)"]})]}),t.jsx(d.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>p(x),className:"h-6 w-6 p-0",children:t.jsx(F.X,{className:"size-3"})})]},x))}),t.jsxs(d.Button,{type:"button",variant:"outline",onClick:()=>l.current?.click(),className:"w-full",children:[t.jsx(F.Upload,{className:"size-4 mr-2"}),f.length>0?"Add More Files":"Upload File"]})]})]})}const $t=Object.freeze(Object.defineProperty({__proto__:null,FileField:me},Symbol.toStringTag,{value:"Module"}));function fe({value:e,onChange:r,field:a,readonly:s,...n}){const l=C.useRef(null),i=a||n.schema,o=i?.multiple||!1,c=i?.accept?i.accept.join(","):"image/*";if(s){if(!e)return t.jsx("span",{className:"text-sm",children:"-"});const u=Array.isArray(e)?e:[e];return t.jsx("div",{className:"flex flex-wrap gap-2",children:u.map((x,g)=>t.jsx("img",{src:x.url||"",alt:x.name||`Image ${g+1}`,className:"size-20 rounded-md object-cover border border-gray-200"},g))})}const f=e?Array.isArray(e)?e:[e]:[],h=u=>{const x=Array.from(u.target.files||[]);if(x.length===0)return;const g=x.map(v=>({name:v.name,original_name:v.name,size:v.size,mime_type:v.type,url:URL.createObjectURL(v)}));r(o?[...f,...g]:g[0])},p=u=>{if(o){const x=f.filter((g,v)=>v!==u);r(x.length>0?x:null)}else r(null)};return t.jsxs("div",{className:n.className,children:[t.jsx("input",{ref:l,type:"file",multiple:o,accept:c,onChange:h,className:"hidden"}),t.jsxs("div",{className:"space-y-2",children:[f.length>0&&t.jsx("div",{className:"grid grid-cols-4 gap-2",children:f.map((u,x)=>t.jsxs("div",{className:"relative group",children:[t.jsx("img",{src:u.url||"",alt:u.name||`Image ${x+1}`,className:"size-20 rounded-md object-cover border border-gray-200"}),t.jsx(d.Button,{type:"button",variant:"destructive",size:"sm",onClick:()=>p(x),className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",children:t.jsx(F.X,{className:"size-3"})})]},x))}),t.jsxs(d.Button,{type:"button",variant:"outline",onClick:()=>l.current?.click(),className:"w-full",children:[t.jsx(F.Image,{className:"size-4 mr-2"}),f.length>0?"Add More Images":"Upload Image"]})]})]})}const zt=Object.freeze(Object.defineProperty({__proto__:null,ImageField:fe},Symbol.toStringTag,{value:"Module"}));function xe({value:e,onChange:r,field:a,readonly:s,...n}){const l=a||n.schema,i=e&&typeof e=="object"?`${e.latitude||0}, ${e.longitude||0}`:"";if(s)return t.jsx("span",{className:"text-sm",children:i||"-"});const o=c=>{const f=c.target.value;if(!f.trim()){r(null);return}const h=f.split(",").map(p=>p.trim());if(h.length===2){const p=parseFloat(h[0]),u=parseFloat(h[1]);!isNaN(p)&&!isNaN(u)&&r({latitude:p,longitude:u})}};return t.jsx(d.Input,{type:"text",value:i,onChange:o,placeholder:l?.placeholder||"latitude, longitude",disabled:s||n.disabled,className:n.className})}const Et=Object.freeze(Object.defineProperty({__proto__:null,LocationField:xe},Symbol.toStringTag,{value:"Module"}));function pe({value:e,field:r,...a}){const n=(r||a.schema)?.return_type||"text";let l="-";return e!=null&&(n==="number"||n==="currency"?l=typeof e=="number"?e.toFixed(2):String(e):n==="boolean"?l=e?"Yes":"No":n==="date"?l=new Date(e).toLocaleDateString():l=String(e)),t.jsx("span",{className:`text-sm font-mono text-gray-700 ${a.className||""}`,children:l})}const Mt=Object.freeze(Object.defineProperty({__proto__:null,FormulaField:pe},Symbol.toStringTag,{value:"Module"}));function he({value:e,field:r,...a}){const n=(r||a.schema)?.summary_type||"count";let l="-";return e!=null&&(n==="count"?l=String(e):["sum","avg","min","max"].includes(n)?l=typeof e=="number"?e.toFixed(2):String(e):l=String(e)),t.jsx("span",{className:`text-sm font-medium tabular-nums text-gray-700 ${a.className||""}`,children:l})}const It=Object.freeze(Object.defineProperty({__proto__:null,SummaryField:he},Symbol.toStringTag,{value:"Module"}));function ge({value:e,field:r,...a}){const s=e!=null?String(e):"-";return t.jsx("span",{className:`text-sm font-mono text-gray-700 ${a.className||""}`,children:s})}const Ut=Object.freeze(Object.defineProperty({__proto__:null,AutoNumberField:ge},Symbol.toStringTag,{value:"Module"}));function U({value:e,onChange:r,field:a,readonly:s,...n}){const i=(a||n.schema)?.multiple||!1;if(s){if(!e)return t.jsx("span",{className:"text-sm",children:"-"});const f=Array.isArray(e)?e:[e];return t.jsxs("div",{className:"flex -space-x-2",children:[f.slice(0,3).map((h,p)=>{const u=h.name||h.username||"User",x=u.split(" ").map(g=>g[0]).join("").toUpperCase().slice(0,2);return t.jsx(d.Avatar,{className:"size-8 border-2 border-white",title:u,children:t.jsx(d.AvatarFallback,{className:"bg-blue-500 text-white text-xs",children:x})},p)}),f.length>3&&t.jsx(d.Avatar,{className:"size-8 border-2 border-white",children:t.jsxs(d.AvatarFallback,{className:"bg-gray-200 text-gray-600 text-xs",children:["+",f.length-3]})})]})}const o=e?Array.isArray(e)?e:[e]:[],c=f=>{if(i){const h=o.filter((p,u)=>u!==f);r(h.length>0?h:null)}else r(null)};return t.jsxs("div",{className:n.className,children:[o.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:o.map((f,h)=>{const p=f.name||f.username||"User",u=p.split(" ").map(x=>x[0]).join("").toUpperCase().slice(0,2);return t.jsxs(d.Badge,{variant:"outline",className:"gap-2 pr-1",children:[t.jsx(d.Avatar,{className:"size-5",children:t.jsx(d.AvatarFallback,{className:"bg-blue-500 text-white text-xs",children:u})}),t.jsx("span",{className:"text-sm",children:p}),t.jsx("button",{type:"button",onClick:()=>c(h),className:"ml-1 rounded-full hover:bg-gray-200 p-0.5",children:t.jsx(F.X,{className:"size-3"})})]},h)})}),t.jsx("div",{className:"text-sm text-gray-500 italic",children:"User selection component requires integration with user management system"})]})}const Be=Object.freeze(Object.defineProperty({__proto__:null,UserField:U},Symbol.toStringTag,{value:"Module"}));function be({value:e,onChange:r,field:a,readonly:s,...n}){const l=a||n.schema,i=()=>e==null?"":JSON.stringify(e,null,2),[o,c]=C.useState(i),[f,h]=C.useState(null);if(C.useEffect(()=>{try{if(e==null){c("");return}const u=o?JSON.parse(o):null;JSON.stringify(u)!==JSON.stringify(e)&&c(JSON.stringify(e,null,2))}catch{c(JSON.stringify(e,null,2))}},[e,o]),s)return e?t.jsx("pre",{className:d.cn("text-xs bg-gray-50 p-2 rounded border border-gray-200 overflow-auto max-h-40",n.className),children:JSON.stringify(e,null,2)}):t.jsx("span",{className:"text-sm",children:"-"});const p=u=>{const x=u.target.value;if(c(x),h(null),!x.trim()){r(null);return}try{const g=JSON.parse(x);r(g)}catch{h("Invalid JSON")}};return t.jsxs("div",{className:"space-y-1",children:[t.jsx(d.Textarea,{value:o,onChange:p,placeholder:l?.placeholder||`{
|
|
6
|
+
<%s key={someKey} {...props} />`,R,T,U,T),qe[T+R]=!0)}if(T=null,w!==void 0&&(n(w),T=""+w),l(y)&&(n(y.key),T=""+y.key),"key"in y){w={};for(var se in y)se!=="key"&&(w[se]=y[se])}else w=y;return T&&o(w,typeof u=="function"?u.displayName||u.name||"Unknown":u),f(u,T,w,s(),Q,re)}function p(u){m(u)?u._store&&(u._store.validated=1):typeof u=="object"&&u!==null&&u.$$typeof===$&&(u._payload.status==="fulfilled"?m(u._payload.value)&&u._payload.value._store&&(u._payload.value._store.validated=1):u._store&&(u._store.validated=1))}function m(u){return typeof u=="object"&&u!==null&&u.$$typeof===g}var x=C,g=Symbol.for("react.transitional.element"),F=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),B=Symbol.for("react.context"),W=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),S=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),I=Symbol.for("react.client.reference"),L=x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=Object.prototype.hasOwnProperty,xt=Array.isArray,te=console.createTask?console.createTask:function(){return null};x={react_stack_bottom_frame:function(u){return u()}};var Ue,Be={},Ve=x.react_stack_bottom_frame.bind(x,i)(),Ye=te(a(i)),qe={};Y.Fragment=k,Y.jsx=function(u,y,w){var R=1e4>L.recentlyCreatedOwnerStacks++;return h(u,y,w,!1,R?Error("react-stack-top-frame"):Ve,R?te(a(u)):Ye)},Y.jsxs=function(u,y,w){var R=1e4>L.recentlyCreatedOwnerStacks++;return h(u,y,w,!0,R?Error("react-stack-top-frame"):Ve,R?te(a(u)):Ye)}})()),Y}var We;function jt(){return We||(We=1,process.env.NODE_ENV==="production"?X.exports=gt():X.exports=bt()),X.exports}var t=jt();function ie({value:e,onChange:r,field:n,readonly:a,...s}){const i=n||s.schema;if(a)return t.jsx("span",{className:"text-sm",children:e||"-"});const l=i?.rows,{inputType:o,...c}=s;return l&&l>1?t.jsx(d.Textarea,{...c,value:e||"",onChange:f=>r(f.target.value),placeholder:i?.placeholder,disabled:a||c.disabled}):t.jsx(d.Input,{...c,type:i?.type==="password"?"password":"text",value:e||"",onChange:f=>r(f.target.value),placeholder:i?.placeholder,disabled:a||c.disabled})}const yt=Object.freeze(Object.defineProperty({__proto__:null,TextField:ie},Symbol.toStringTag,{value:"Module"}));function oe({value:e,onChange:r,field:n,readonly:a,...s}){if(a)return t.jsx("span",{className:"text-sm",children:e??"-"});const i=n||s.schema,l=i?.precision,{inputType:o,...c}=s;return t.jsx(d.Input,{...c,type:"number",value:e??"",onChange:f=>{const h=f.target.value;r(h===""?null:Number(h))},placeholder:i?.placeholder,disabled:a||c.disabled,step:l?Math.pow(10,-l):"any"})}const Nt=Object.freeze(Object.defineProperty({__proto__:null,NumberField:oe},Symbol.toStringTag,{value:"Module"}));function ce({value:e,onChange:r,field:n,readonly:a,...s}){const i=n||s.schema,l=i?.widget,o=C.useId(),c=i?.name||o,f=i?.label||"Checkbox";if(a)return t.jsx("span",{className:"text-sm",children:e?"Yes":"No"});const{inputType:h,...p}=s;return l==="checkbox"?t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(d.Checkbox,{...p,id:c,checked:!!e,onCheckedChange:m=>r(!!m),disabled:a||p.disabled}),t.jsx(d.Label,{htmlFor:c,children:f})]}):t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(d.Switch,{...p,id:c,checked:!!e,onCheckedChange:r,disabled:a||p.disabled}),t.jsx(d.Label,{htmlFor:c,children:f})]})}const vt=Object.freeze(Object.defineProperty({__proto__:null,BooleanField:ce},Symbol.toStringTag,{value:"Module"}));function de({value:e,onChange:r,field:n,readonly:a,...s}){const i=n||s.schema,l=i?.options||[];if(a){const o=l.find(c=>c.value===e);return t.jsx("span",{className:"text-sm",children:o?.label||e||"-"})}return t.jsxs(d.Select,{...s,value:e,onValueChange:r,disabled:a||s.disabled,children:[t.jsx(d.SelectTrigger,{className:s.className,id:s.id,children:t.jsx(d.SelectValue,{placeholder:i?.placeholder||"Select an option"})}),t.jsx(d.SelectContent,{position:"popper",children:l.map(o=>t.jsx(d.SelectItem,{value:o.value,children:o.label},o.value))})]})}const Ft=Object.freeze(Object.defineProperty({__proto__:null,SelectField:de},Symbol.toStringTag,{value:"Module"}));function ue({value:e,onChange:r,field:n,readonly:a,...s}){if(a)return t.jsx("span",{className:"text-sm",children:e?new Date(e).toLocaleDateString():"-"});const{inputType:i,...l}=s;return t.jsx(d.Input,{...l,type:"date",value:e||"",onChange:o=>r(o.target.value),disabled:a||l.disabled})}const _t=Object.freeze(Object.defineProperty({__proto__:null,DateField:ue},Symbol.toStringTag,{value:"Module"}));function me({value:e,onChange:r,field:n,readonly:a,errorMessage:s,...i}){const l=n||i.schema;if(a)return e?t.jsx("a",{href:`mailto:${e}`,className:"text-sm text-blue-600 hover:text-blue-800 hover:underline",children:e}):t.jsx("span",{className:"text-sm",children:"-"});const{inputType:o,...c}=i;return t.jsx(d.Input,{...c,type:"email",value:e||"",onChange:f=>r(f.target.value),placeholder:l?.placeholder||"email@example.com",disabled:a||c.disabled,"aria-invalid":!!s})}const Ct=Object.freeze(Object.defineProperty({__proto__:null,EmailField:me},Symbol.toStringTag,{value:"Module"}));function fe({value:e,onChange:r,field:n,readonly:a,errorMessage:s,...i}){const l=n||i.schema;if(a)return e?t.jsx("a",{href:`tel:${e}`,className:"text-sm text-blue-600 hover:text-blue-800 hover:underline",children:e}):t.jsx("span",{className:"text-sm",children:"-"});const{inputType:o,...c}=i;return t.jsx(d.Input,{...c,type:"tel",value:e||"",onChange:f=>r(f.target.value),placeholder:l?.placeholder||"(555) 123-4567",disabled:a||c.disabled,"aria-invalid":!!s})}const wt=Object.freeze(Object.defineProperty({__proto__:null,PhoneField:fe},Symbol.toStringTag,{value:"Module"}));function pe({value:e,onChange:r,field:n,readonly:a,errorMessage:s,...i}){const l=n||i.schema;if(a)return e?e.startsWith("http://")||e.startsWith("https://")?t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:text-blue-800 hover:underline",children:e}):t.jsx("span",{className:"text-sm",children:e}):t.jsx("span",{className:"text-sm",children:"-"});const{inputType:o,...c}=i;return t.jsx(d.Input,{...c,type:"url",value:e||"",onChange:f=>r(f.target.value),placeholder:l?.placeholder||"https://example.com",disabled:a||c.disabled,"aria-invalid":!!s})}const St=Object.freeze(Object.defineProperty({__proto__:null,UrlField:pe},Symbol.toStringTag,{value:"Module"}));function Rt(e,r="USD"){try{return new Intl.NumberFormat("en-US",{style:"currency",currency:r}).format(e)}catch{return`${r} ${e.toFixed(2)}`}}function xe({value:e,onChange:r,field:n,readonly:a,errorMessage:s,className:i,...l}){const o=n||l.schema,c=o?.currency||"USD",f=o?.precision??2;if(a)return e==null?t.jsx("span",{className:"text-sm",children:"-"}):t.jsx("span",{className:"text-sm font-medium tabular-nums",children:Rt(Number(e),c)});const h=p=>{const m=parseFloat(p.target.value);isNaN(m)||r(parseFloat(m.toFixed(f)))};return t.jsxs("div",{className:"relative",children:[t.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-gray-500",children:c==="USD"?"$":c}),t.jsx(d.Input,{...l,type:"number",value:e??"",onChange:p=>{const m=p.target.value===""?null:parseFloat(p.target.value);r(m)},onBlur:h,placeholder:o?.placeholder||"0.00",disabled:a||l.disabled,className:`pl-8 ${i||""}`,step:Math.pow(10,-f).toFixed(f),"aria-invalid":!!s})]})}const Tt=Object.freeze(Object.defineProperty({__proto__:null,CurrencyField:xe},Symbol.toStringTag,{value:"Module"}));function he({value:e,onChange:r,field:n,readonly:a,errorMessage:s,...i}){if(a)return t.jsx("div",{className:"text-sm whitespace-pre-wrap",children:e||"-"});const l=n||i.schema,o=l?.rows||4,c=l?.max_length,{inputType:f,...h}=i;return t.jsxs("div",{className:"relative",children:[t.jsx(d.Textarea,{...h,value:e||"",onChange:p=>r(p.target.value),placeholder:l?.placeholder,disabled:a||h.disabled,rows:o,maxLength:c,"aria-invalid":!!s}),c&&t.jsxs("div",{className:"absolute bottom-2 right-2 text-xs text-gray-400","aria-live":"polite","aria-label":`Character count: ${(e||"").length} of ${c}`,children:[(e||"").length,"/",c]})]})}const Pt=Object.freeze(Object.defineProperty({__proto__:null,TextAreaField:he},Symbol.toStringTag,{value:"Module"}));function H({value:e,onChange:r,field:n,readonly:a,errorMessage:s,...i}){if(a)return t.jsx("div",{className:"text-sm prose prose-sm max-w-none",children:e||"-"});const l=n||i.schema,o=l?.rows||8,c=l?.format||"markdown";return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500",children:[t.jsxs("span",{children:["Format: ",c]}),t.jsx("span",{className:"italic",children:"Rich text editor (basic)"})]}),t.jsx(d.Textarea,{value:e||"",onChange:f=>r(f.target.value),placeholder:l?.placeholder||"Enter text...",disabled:a||i.disabled,rows:o,className:`font-mono text-sm ${i.className||""}`,"aria-invalid":!!s})]})}const Qe=Object.freeze(Object.defineProperty({__proto__:null,RichTextField:H},Symbol.toStringTag,{value:"Module"}));function ge({value:e,onChange:r,field:n,readonly:a,...s}){const[i,l]=C.useState(!1),[o,c]=C.useState(""),f=n||s.schema,h=f?.options||[],p=f.multiple||!1,m=f.display_field||"label",x=h.filter(v=>v.label.toLowerCase().includes(o.toLowerCase())),g=p?(Array.isArray(e)?e:[]).map(v=>h.find(P=>P.value===v)).filter(Boolean):e?[h.find(v=>v.value===e)].filter(Boolean):[],F=v=>{if(p){const P=Array.isArray(e)?e:[],z=P.includes(v.value);r(z?P.filter(B=>B!==v.value):[...P,v.value])}else r(v.value),l(!1)},k=v=>{if(p){const P=Array.isArray(e)?e:[];r(P.filter(z=>z!==v))}else r(null)};return a?g.length?p?t.jsx("div",{className:"flex flex-wrap gap-1",children:g.map((v,P)=>t.jsx(d.Badge,{variant:"outline",children:v?.[m]||v?.label},P))}):t.jsx("span",{className:"text-sm",children:g[0]?.[m]||g[0]?.label}):t.jsx("span",{className:"text-sm",children:"-"}):t.jsxs("div",{className:"space-y-2",children:[g.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:g.map((v,P)=>t.jsxs(d.Badge,{variant:"outline",className:"gap-1",children:[v?.[m]||v?.label,t.jsx("button",{onClick:()=>k(v?.value),className:"ml-1 hover:text-destructive",type:"button","aria-label":`Remove ${v?.[m]||v?.label}`,children:t.jsx(_.X,{className:"size-3"})})]},P))}),t.jsxs(d.Dialog,{open:i,onOpenChange:l,children:[t.jsx(d.DialogTrigger,{asChild:!0,children:t.jsxs(d.Button,{variant:"outline",className:"w-full justify-start text-left font-normal",type:"button",children:[t.jsx(_.Search,{className:"mr-2 size-4"}),g.length===0?f?.placeholder||"Select...":p?`${g.length} selected`:"Change selection"]})}),t.jsxs(d.DialogContent,{className:"max-w-md",children:[t.jsx(d.DialogHeader,{children:t.jsxs(d.DialogTitle,{children:[f?.label||"Select"," ",p&&"(multiple)"]})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(d.Input,{placeholder:"Search...",value:o,onChange:v=>c(v.target.value),className:"w-full"}),t.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:x.length===0?t.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"No options found"}):x.map(v=>{const P=p?(Array.isArray(e)?e:[]).includes(v.value):e===v.value;return t.jsxs("button",{onClick:()=>F(v),className:`w-full text-left px-3 py-2 rounded-md text-sm hover:bg-gray-100 flex items-center justify-between ${P?"bg-blue-50 text-blue-700":""}`,type:"button",children:[t.jsx("span",{children:v.label}),P&&t.jsx(d.Badge,{variant:"default",className:"ml-2",children:"Selected"})]},v.value)})})]})]})]})]})}const Ot=Object.freeze(Object.defineProperty({__proto__:null,LookupField:ge},Symbol.toStringTag,{value:"Module"}));function be({value:e,onChange:r,field:n,readonly:a,...s}){if(a){if(!e)return t.jsx("span",{className:"text-sm",children:"-"});const o=new Date(e);return t.jsxs("span",{className:"text-sm",children:[o.toLocaleDateString()," ",o.toLocaleTimeString()]})}const{inputType:i,...l}=s;return t.jsx(d.Input,{...l,type:"datetime-local",value:e||"",onChange:o=>r(o.target.value),disabled:a||l.disabled})}const kt=Object.freeze(Object.defineProperty({__proto__:null,DateTimeField:be},Symbol.toStringTag,{value:"Module"}));function je({value:e,onChange:r,field:n,readonly:a,...s}){if(a)return t.jsx("span",{className:"text-sm",children:e||"-"});const{inputType:i,...l}=s;return t.jsx(d.Input,{...l,type:"time",value:e||"",onChange:o=>r(o.target.value),disabled:a||l.disabled})}const At=Object.freeze(Object.defineProperty({__proto__:null,TimeField:je},Symbol.toStringTag,{value:"Module"}));function ye({value:e,onChange:r,field:n,readonly:a,errorMessage:s,className:i,...l}){const o=n||l.schema,c=o?.precision??2;if(a)return e==null?t.jsx("span",{className:"text-sm",children:"-"}):t.jsxs("span",{className:"text-sm font-medium tabular-nums",children:[(e*100).toFixed(c),"%"]});const f=e!=null?e*100:"",h=e!=null?e*100:0,p=g=>{if(g.target.value===""){r(null);return}const F=parseFloat(g.target.value),k=isNaN(F)?null:F/100;r(k)},m=g=>{if(a||l.disabled)return;if(!Array.isArray(g)||g.length===0){r(null);return}const F=g[0],k=typeof F=="number"?F/100:null;r(k)},x=Math.pow(10,-c);return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"relative",children:[t.jsx(d.Input,{...l,type:"number",value:f,onChange:p,placeholder:o?.placeholder||"0",disabled:a||l.disabled,className:`pr-8 ${i||""}`,step:Math.pow(10,-c).toFixed(c),"aria-invalid":!!s}),t.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-500",children:"%"})]}),t.jsx(d.Slider,{value:[h],onValueChange:m,min:0,max:100,step:x,disabled:a||l.disabled,className:"w-full","aria-label":"Percentage","data-testid":"percent-slider"})]})}const $t=Object.freeze(Object.defineProperty({__proto__:null,PercentField:ye},Symbol.toStringTag,{value:"Module"}));function Ne({value:e,onChange:r,field:n,readonly:a,className:s,...i}){const[l,o]=C.useState(!1),c=n||i.schema;if(a)return t.jsx("span",{className:"text-sm",children:"••••••••"});const{inputType:f,...h}=i;return t.jsxs("div",{className:"relative",children:[t.jsx(d.Input,{...h,type:l?"text":"password",value:e||"",onChange:p=>r(p.target.value),placeholder:c?.placeholder,disabled:a||h.disabled,className:`pr-10 ${s||""}`}),t.jsx(d.Button,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>o(!l),tabIndex:-1,children:l?t.jsx(_.EyeOff,{className:"size-4 text-gray-500"}):t.jsx(_.Eye,{className:"size-4 text-gray-500"})})]})}const Et=Object.freeze(Object.defineProperty({__proto__:null,PasswordField:Ne},Symbol.toStringTag,{value:"Module"}));function ve({value:e,onChange:r,field:n,readonly:a,...s}){const i=C.useRef(null),l=n||s.schema,o=l?.multiple||!1,c=l?.accept?l.accept.join(","):void 0,f=l?.maxSize,[h,p]=C.useState(!1),[m,x]=C.useState([]),g=e?Array.isArray(e)?e:[e]:[],F=C.useCallback(j=>{if(j.length===0)return;const S=[],A=j.filter(O=>{if(f&&O.size>f){const I=(f/1048576).toFixed(1);return S.push(`"${O.name}" exceeds max size (${I} MB)`),!1}return!0});if(x(S),A.length===0)return;const $=A.map(O=>({name:O.name,original_name:O.name,size:O.size,mime_type:O.type,url:URL.createObjectURL(O)}));r(o?[...g,...$]:$[0])},[g,o,r,f]),k=C.useCallback(j=>{j.preventDefault(),j.stopPropagation(),p(!0)},[]),v=C.useCallback(j=>{j.preventDefault(),j.stopPropagation(),p(!1)},[]),P=C.useCallback(j=>{j.preventDefault(),j.stopPropagation(),p(!1);const S=Array.from(j.dataTransfer.files);if(c){const A=c.split(",").map(O=>O.trim().toLowerCase()),$=S.filter(O=>{const I=O.name.split("."),L=I.length>1?"."+I.pop()?.toLowerCase():"";return A.some(D=>D===O.type||L&&D===L||D.endsWith("/*")&&O.type.startsWith(D.replace("/*","/")))});F($)}else F(S)},[c,F]);if(a){if(!e)return t.jsx("span",{className:"text-sm",children:"-"});const j=Array.isArray(e)?e:[e];return t.jsx("div",{className:"flex flex-wrap gap-2",children:j.map((S,A)=>t.jsx("span",{className:"text-sm truncate max-w-xs",children:S.name||S.original_name||"File"},A))})}const z=j=>{F(Array.from(j.target.files||[]))},B=j=>{if(o){const S=g.filter((A,$)=>$!==j);r(S.length>0?S:null)}else r(null)},W=j=>(j.mime_type||"").startsWith("image/");return t.jsxs("div",{className:s.className,children:[t.jsx("input",{ref:i,type:"file",multiple:o,accept:c,onChange:z,className:"hidden"}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{onDragOver:k,onDragLeave:v,onDrop:P,onClick:()=>i.current?.click(),className:`
|
|
7
|
+
flex flex-col items-center justify-center gap-2 p-6
|
|
8
|
+
border-2 border-dashed rounded-lg cursor-pointer
|
|
9
|
+
transition-colors duration-200
|
|
10
|
+
${h?"border-primary bg-primary/5 text-primary":"border-muted-foreground/25 hover:border-primary/50 text-muted-foreground hover:text-foreground"}
|
|
11
|
+
`,role:"button",tabIndex:0,onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),i.current?.click())},children:[t.jsx(_.Upload,{className:`size-8 ${h?"text-primary":"text-muted-foreground"}`}),t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-sm font-medium",children:h?"Drop files here":"Drag & drop files here"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"or click to browse"})]})]}),m.length>0&&t.jsx("div",{className:"space-y-0.5",children:m.map((j,S)=>t.jsx("p",{className:"text-xs text-destructive",children:j},S))}),g.length>0&&t.jsx("div",{className:"space-y-1",children:g.map((j,S)=>t.jsxs("div",{className:"flex items-center justify-between gap-2 p-2 bg-muted/50 rounded-md border",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[W(j)&&j.url?t.jsx("img",{src:j.url,alt:j.name,className:"size-8 object-cover rounded flex-shrink-0"}):W(j)?t.jsx(_.ImageIcon,{className:"size-4 text-muted-foreground flex-shrink-0"}):t.jsx(_.File,{className:"size-4 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"text-sm truncate",children:j.name||j.original_name||"File"}),j.size&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(j.size/1024).toFixed(1)," KB)"]})]}),t.jsx(d.Button,{type:"button",variant:"ghost",size:"sm",onClick:A=>{A.stopPropagation(),B(S)},className:"h-6 w-6 p-0",children:t.jsx(_.X,{className:"size-3"})})]},S))})]})]})}const zt=Object.freeze(Object.defineProperty({__proto__:null,FileField:ve},Symbol.toStringTag,{value:"Module"}));function Fe({value:e,onChange:r,field:n,readonly:a,...s}){const i=C.useRef(null),l=n||s.schema,o=l?.multiple||!1,c=l?.accept?l.accept.join(","):"image/*";if(a){if(!e)return t.jsx("span",{className:"text-sm",children:"-"});const m=Array.isArray(e)?e:[e];return t.jsx("div",{className:"flex flex-wrap gap-2",children:m.map((x,g)=>t.jsx("img",{src:x.url||"",alt:x.name||`Image ${g+1}`,className:"size-20 rounded-md object-cover border border-gray-200"},g))})}const f=e?Array.isArray(e)?e:[e]:[],h=m=>{const x=Array.from(m.target.files||[]);if(x.length===0)return;const g=x.map(F=>({name:F.name,original_name:F.name,size:F.size,mime_type:F.type,url:URL.createObjectURL(F)}));r(o?[...f,...g]:g[0])},p=m=>{if(o){const x=f.filter((g,F)=>F!==m);r(x.length>0?x:null)}else r(null)};return t.jsxs("div",{className:s.className,children:[t.jsx("input",{ref:i,type:"file",multiple:o,accept:c,onChange:h,className:"hidden"}),t.jsxs("div",{className:"space-y-2",children:[f.length>0&&t.jsx("div",{className:"grid grid-cols-4 gap-2",children:f.map((m,x)=>t.jsxs("div",{className:"relative group",children:[t.jsx("img",{src:m.url||"",alt:m.name||`Image ${x+1}`,className:"size-20 rounded-md object-cover border border-gray-200"}),t.jsx(d.Button,{type:"button",variant:"destructive",size:"sm",onClick:()=>p(x),className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",children:t.jsx(_.X,{className:"size-3"})})]},x))}),t.jsxs(d.Button,{type:"button",variant:"outline",onClick:()=>i.current?.click(),className:"w-full",children:[t.jsx(_.Image,{className:"size-4 mr-2"}),f.length>0?"Add More Images":"Upload Image"]})]})]})}const Dt=Object.freeze(Object.defineProperty({__proto__:null,ImageField:Fe},Symbol.toStringTag,{value:"Module"}));function _e({value:e,onChange:r,field:n,readonly:a,...s}){const i=n||s.schema,l=e&&typeof e=="object"?`${e.latitude||0}, ${e.longitude||0}`:"";if(a)return t.jsx("span",{className:"text-sm",children:l||"-"});const o=c=>{const f=c.target.value;if(!f.trim()){r(null);return}const h=f.split(",").map(p=>p.trim());if(h.length===2){const p=parseFloat(h[0]),m=parseFloat(h[1]);!isNaN(p)&&!isNaN(m)&&r({latitude:p,longitude:m})}};return t.jsx(d.Input,{type:"text",value:l,onChange:o,placeholder:i?.placeholder||"latitude, longitude",disabled:a||s.disabled,className:s.className})}const Mt=Object.freeze(Object.defineProperty({__proto__:null,LocationField:_e},Symbol.toStringTag,{value:"Module"}));function Ce({value:e,field:r,...n}){const s=(r||n.schema)?.return_type||"text";let i="-";return e!=null&&(s==="number"||s==="currency"?i=typeof e=="number"?e.toFixed(2):String(e):s==="boolean"?i=e?"Yes":"No":s==="date"?i=new Date(e).toLocaleDateString():i=String(e)),t.jsx("span",{className:`text-sm font-mono text-gray-700 ${n.className||""}`,children:i})}const It=Object.freeze(Object.defineProperty({__proto__:null,FormulaField:Ce},Symbol.toStringTag,{value:"Module"}));function we({value:e,field:r,...n}){const s=(r||n.schema)?.summary_type||"count";let i="-";return e!=null&&(s==="count"?i=String(e):["sum","avg","min","max"].includes(s)?i=typeof e=="number"?e.toFixed(2):String(e):i=String(e)),t.jsx("span",{className:`text-sm font-medium tabular-nums text-gray-700 ${n.className||""}`,children:i})}const Lt=Object.freeze(Object.defineProperty({__proto__:null,SummaryField:we},Symbol.toStringTag,{value:"Module"}));function Se({value:e,field:r,...n}){const a=e!=null?String(e):"-";return t.jsx("span",{className:`text-sm font-mono text-gray-700 ${n.className||""}`,children:a})}const Ut=Object.freeze(Object.defineProperty({__proto__:null,AutoNumberField:Se},Symbol.toStringTag,{value:"Module"}));function Z({value:e,onChange:r,field:n,readonly:a,...s}){const l=(n||s.schema)?.multiple||!1;if(a){if(!e)return t.jsx("span",{className:"text-sm",children:"-"});const f=Array.isArray(e)?e:[e];return t.jsxs("div",{className:"flex -space-x-2",children:[f.slice(0,3).map((h,p)=>{const m=h.name||h.username||"User",x=m.split(" ").map(g=>g[0]).join("").toUpperCase().slice(0,2);return t.jsx(d.Avatar,{className:"size-8 border-2 border-white",title:m,children:t.jsx(d.AvatarFallback,{className:"bg-blue-500 text-white text-xs",children:x})},p)}),f.length>3&&t.jsx(d.Avatar,{className:"size-8 border-2 border-white",children:t.jsxs(d.AvatarFallback,{className:"bg-gray-200 text-gray-600 text-xs",children:["+",f.length-3]})})]})}const o=e?Array.isArray(e)?e:[e]:[],c=f=>{if(l){const h=o.filter((p,m)=>m!==f);r(h.length>0?h:null)}else r(null)};return t.jsxs("div",{className:s.className,children:[o.length>0&&t.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:o.map((f,h)=>{const p=f.name||f.username||"User",m=p.split(" ").map(x=>x[0]).join("").toUpperCase().slice(0,2);return t.jsxs(d.Badge,{variant:"outline",className:"gap-2 pr-1",children:[t.jsx(d.Avatar,{className:"size-5",children:t.jsx(d.AvatarFallback,{className:"bg-blue-500 text-white text-xs",children:m})}),t.jsx("span",{className:"text-sm",children:p}),t.jsx("button",{type:"button",onClick:()=>c(h),className:"ml-1 rounded-full hover:bg-gray-200 p-0.5",children:t.jsx(_.X,{className:"size-3"})})]},h)})}),t.jsx("div",{className:"text-sm text-gray-500 italic",children:"User selection component requires integration with user management system"})]})}const Xe=Object.freeze(Object.defineProperty({__proto__:null,UserField:Z},Symbol.toStringTag,{value:"Module"}));function Re({value:e,onChange:r,field:n,readonly:a,...s}){const i=n||s.schema,l=()=>e==null?"":JSON.stringify(e,null,2),[o,c]=C.useState(l),[f,h]=C.useState(null);if(C.useEffect(()=>{try{if(e==null){c("");return}const m=o?JSON.parse(o):null;JSON.stringify(m)!==JSON.stringify(e)&&c(JSON.stringify(e,null,2))}catch{c(JSON.stringify(e,null,2))}},[e,o]),a)return e?t.jsx("pre",{className:d.cn("text-xs bg-gray-50 p-2 rounded border border-gray-200 overflow-auto max-h-40",s.className),children:JSON.stringify(e,null,2)}):t.jsx("span",{className:"text-sm",children:"-"});const p=m=>{const x=m.target.value;if(c(x),h(null),!x.trim()){r(null);return}try{const g=JSON.parse(x);r(g)}catch{h("Invalid JSON")}};return t.jsxs("div",{className:"space-y-1",children:[t.jsx(d.Textarea,{value:o,onChange:p,placeholder:i?.placeholder||`{
|
|
7
12
|
"key": "value"
|
|
8
|
-
}`,disabled:s||n.disabled,className:d.cn("font-mono text-xs",f?"border-red-500 focus-visible:ring-red-500":"",n.className),rows:6}),f&&t.jsx("p",{className:"text-xs text-red-500",children:f})]})}const Dt=Object.freeze(Object.defineProperty({__proto__:null,ObjectField:be},Symbol.toStringTag,{value:"Module"}));function je({value:e,field:r,...a}){const n=(r||a.schema)?.dimensions||(Array.isArray(e)?e.length:0);if(!e||!Array.isArray(e))return t.jsx("span",{className:"text-sm text-gray-500",children:"-"});const l=e.slice(0,3).map(i=>{const o=Number(i);return isNaN(o)?"0":o.toFixed(4)}).join(", ");return t.jsxs("div",{className:`text-sm ${a.className||""}`,children:[t.jsxs("span",{className:"font-mono text-gray-700",children:["[",l,"...]"]}),t.jsxs("span",{className:"text-gray-500 ml-2",children:["(",n,"D)"]})]})}const Lt=Object.freeze(Object.defineProperty({__proto__:null,VectorField:je},Symbol.toStringTag,{value:"Module"}));function ye({value:e,field:r,readonly:a,...s}){const l=(r||s.schema)?.columns||[];return!e||!Array.isArray(e)?t.jsx("span",{className:"text-sm text-gray-500",children:"-"}):a?t.jsx("div",{className:d.cn("text-sm",s.className),children:t.jsxs("span",{className:"text-gray-700",children:[e.length," rows"]})}):t.jsxs("div",{className:d.cn("border border-gray-200 rounded-md overflow-hidden",s.className),children:[t.jsx("div",{className:"overflow-auto max-h-60",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-gray-50 border-b border-gray-200",children:t.jsx("tr",{children:l.map((i,o)=>t.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-700",children:i.label||i.name},o))})}),t.jsx("tbody",{className:"divide-y divide-gray-200",children:e.slice(0,5).map((i,o)=>t.jsx("tr",{className:"hover:bg-gray-50",children:l.map((c,f)=>t.jsx("td",{className:"px-3 py-2 text-gray-900",children:i[c.name]!=null?String(i[c.name]):"-"},f))},o))})]})}),e.length>5&&t.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs text-gray-500 border-t border-gray-200",children:["Showing 5 of ",e.length," rows"]})]})}const Bt=Object.freeze(Object.defineProperty({__proto__:null,GridField:ye},Symbol.toStringTag,{value:"Module"}));function Ne({value:e,onChange:r,field:a,readonly:s,...n}){const l=a||n.schema;return s?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-6 h-6 rounded border border-input",style:{backgroundColor:e||"#000000"}}),t.jsx("span",{className:"text-sm",children:e||"-"})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"color",value:e||"#000000",onChange:i=>r(i.target.value),disabled:s||n.disabled,className:"w-10 h-10 rounded border border-input cursor-pointer"}),t.jsx(d.Input,{type:"text",value:e||"",onChange:i=>r(i.target.value),placeholder:l?.placeholder||"#000000",disabled:s||n.disabled,className:n.className,pattern:"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"})]})}const Vt=Object.freeze(Object.defineProperty({__proto__:null,ColorField:Ne},Symbol.toStringTag,{value:"Module"}));function ve({value:e,onChange:r,field:a,readonly:s,...n}){const l=a||n.schema,i=l?.min??0,o=l?.max??100,c=l?.step??1;return s?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:e??i}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["/ ",o]})]}):t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(d.Slider,{value:[e??i],onValueChange:f=>r(f[0]),min:i,max:o,step:c,disabled:s||n.disabled,className:n.className}),t.jsx("span",{className:"text-sm font-medium w-12 text-right",children:e??i})]})}const Yt=Object.freeze(Object.defineProperty({__proto__:null,SliderField:ve},Symbol.toStringTag,{value:"Module"}));function Fe({value:e,onChange:r,field:a,readonly:s,className:n,...l}){const o=(a||l.schema)?.max??5,c=e??0,[f,h]=C.useState(null),p=f!==null?f:c;return s?t.jsxs("div",{className:d.cn("flex items-center gap-1",n),children:[Array.from({length:o},(u,x)=>t.jsx(F.Star,{className:`w-5 h-5 ${x<c?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},x)),t.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[c," / ",o]})]}):t.jsxs("div",{className:d.cn("flex items-center gap-1",n),children:[Array.from({length:o},(u,x)=>t.jsx("button",{type:"button",onClick:()=>r(x+1),onMouseEnter:()=>h(x+1),onMouseLeave:()=>h(null),className:"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded",disabled:s||l.disabled,children:t.jsx(F.Star,{className:`w-5 h-5 transition-colors ${x<p?"fill-yellow-400 text-yellow-400 hover:fill-yellow-500 hover:text-yellow-500":"text-muted-foreground hover:text-yellow-400"}`})},x)),t.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[c," / ",o]})]})}const qt=Object.freeze(Object.defineProperty({__proto__:null,RatingField:Fe},Symbol.toStringTag,{value:"Module"}));function _e({value:e,onChange:r,field:a,readonly:s,...n}){const l=a||n.schema,i=l?.language??"javascript";return s?t.jsx("pre",{className:d.cn("text-sm bg-muted p-2 rounded overflow-x-auto border",n.className),children:t.jsx("code",{children:e||"-"})}):t.jsx(d.Textarea,{value:e||"",onChange:o=>r(o.target.value),placeholder:l?.placeholder||`// Write ${i} code here...`,disabled:s||n.disabled,className:d.cn("font-mono text-sm",n.className),rows:12,spellCheck:!1})}const Jt=Object.freeze(Object.defineProperty({__proto__:null,CodeField:_e},Symbol.toStringTag,{value:"Module"}));function Ce({value:e,onChange:r,field:a,readonly:s,...n}){const[l,i]=C.useState(!1),o=C.useRef(null),c=a||n.schema,f=u=>{const x=u.target.files?.[0];if(!x)return;if(!x.type.startsWith("image/")){console.error("Please select an image file");return}if(x.size>5*1024*1024){console.error("File size must be less than 5MB");return}const g=new FileReader;g.onloadend=()=>{r(g.result)},g.readAsDataURL(x)},h=()=>{r("")},p=()=>(c?.defaultName||c?.label||"User").split(" ").map(x=>x[0]).join("").toUpperCase().slice(0,2);return s?t.jsxs(d.Avatar,{className:"w-16 h-16",children:[e&&t.jsx(d.AvatarImage,{src:e,alt:c?.label}),t.jsx(d.AvatarFallback,{children:p()})]}):t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"relative",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[t.jsxs(d.Avatar,{className:"w-16 h-16",children:[e&&t.jsx(d.AvatarImage,{src:e,alt:c?.label}),t.jsx(d.AvatarFallback,{children:p()})]}),!s&&l&&e&&t.jsx("button",{type:"button",onClick:h,className:"absolute -top-1 -right-1 bg-destructive text-destructive-foreground rounded-full p-1 hover:bg-destructive/90",children:t.jsx(F.X,{className:"w-3 h-3"})})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("input",{ref:o,type:"file",accept:"image/*",onChange:f,className:"hidden"}),t.jsxs(d.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>o.current?.click(),disabled:s||n.disabled,children:[t.jsx(F.Upload,{className:"w-4 h-4 mr-2"}),e?"Change":"Upload"," Avatar"]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"PNG, JPG up to 5MB"})]})]})}const Gt=Object.freeze(Object.defineProperty({__proto__:null,AvatarField:Ce},Symbol.toStringTag,{value:"Module"}));function Se({value:e,onChange:r,field:a,readonly:s,...n}){const l=e||{},i=(c,f)=>{r({...l,[c]:f})},o=c=>[c.street,c.city,[c.state,c.zipCode].filter(Boolean).join(" "),c.country].filter(Boolean).join(", ")||"-";return s?t.jsx("span",{className:"text-sm",children:o(l)}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"street",className:"text-xs",children:"Street Address"}),t.jsx(d.Input,{id:"street",type:"text",value:l.street||"",onChange:c=>i("street",c.target.value),placeholder:"123 Main St",disabled:s||n.disabled,className:n.className})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"city",className:"text-xs",children:"City"}),t.jsx(d.Input,{id:"city",type:"text",value:l.city||"",onChange:c=>i("city",c.target.value),placeholder:"San Francisco",disabled:s||n.disabled})]}),t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"state",className:"text-xs",children:"State / Province"}),t.jsx(d.Input,{id:"state",type:"text",value:l.state||"",onChange:c=>i("state",c.target.value),placeholder:"CA",disabled:s||n.disabled})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"zipCode",className:"text-xs",children:"ZIP / Postal Code"}),t.jsx(d.Input,{id:"zipCode",type:"text",value:l.zipCode||"",onChange:c=>i("zipCode",c.target.value),placeholder:"94102",disabled:s||n.disabled})]}),t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"country",className:"text-xs",children:"Country"}),t.jsx(d.Input,{id:"country",type:"text",value:l.country||"",onChange:c=>i("country",c.target.value),placeholder:"United States",disabled:s||n.disabled})]})]})]})}const Qt=Object.freeze(Object.defineProperty({__proto__:null,AddressField:Se},Symbol.toStringTag,{value:"Module"}));function we({value:e,onChange:r,field:a,readonly:s,...n}){const[l,i]=C.useState(!1),o=e||{},c=(u,x)=>{r({...o,[u]:x?Number(x):void 0})},f=()=>{if(!navigator.geolocation){console.error("Geolocation is not supported by this browser");return}i(!0),navigator.geolocation.getCurrentPosition(u=>{r({latitude:u.coords.latitude,longitude:u.coords.longitude,accuracy:u.coords.accuracy}),i(!1)},u=>{console.error("Error getting location:",u.message),i(!1)},{enableHighAccuracy:!0,timeout:5e3,maximumAge:0})},h=u=>!u.latitude||!u.longitude?"-":`${u.latitude.toFixed(6)}, ${u.longitude.toFixed(6)}`,p=()=>{if(!o.latitude||!o.longitude)return;const u=`https://www.google.com/maps?q=${o.latitude},${o.longitude}`;window.open(u,"_blank")};return s?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(F.MapPin,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm",children:h(o)}),o.latitude&&o.longitude&&t.jsx(d.Button,{type:"button",variant:"link",size:"sm",onClick:p,className:"p-0 h-auto",children:"View on map"})]}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(d.Button,{type:"button",variant:"outline",size:"sm",onClick:f,disabled:s||l,children:[t.jsx(F.Crosshair,{className:"w-4 h-4 mr-2"}),l?"Getting location...":"Use Current Location"]}),o.latitude&&o.longitude&&t.jsxs(d.Button,{type:"button",variant:"link",size:"sm",onClick:p,children:[t.jsx(F.MapPin,{className:"w-4 h-4 mr-2"}),"View on map"]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"latitude",className:"text-xs",children:"Latitude"}),t.jsx(d.Input,{id:"latitude",type:"number",value:o.latitude??"",onChange:u=>c("latitude",u.target.value),placeholder:"37.7749",disabled:s||n.disabled,step:"any",className:n.className})]}),t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"longitude",className:"text-xs",children:"Longitude"}),t.jsx(d.Input,{id:"longitude",type:"number",value:o.longitude??"",onChange:u=>c("longitude",u.target.value),placeholder:"-122.4194",disabled:s||n.disabled,step:"any"})]})]}),o.accuracy&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Accuracy: ±",o.accuracy.toFixed(0),"m"]})]})}const Wt=Object.freeze(Object.defineProperty({__proto__:null,GeolocationField:we},Symbol.toStringTag,{value:"Module"}));function Re({value:e,onChange:r,readonly:a}){const s=C.useRef(null),[n,l]=C.useState(!1),[i,o]=C.useState(!e);C.useEffect(()=>{if(e&&s.current){const x=s.current.getContext("2d");if(x){const g=new Image;g.onload=()=>{x.drawImage(g,0,0),o(!1)},g.src=e}}},[e]);const c=u=>{if(a)return;l(!0),o(!1);const x=s.current;if(!x)return;const g=x.getContext("2d");if(!g)return;const v=x.getBoundingClientRect(),P="touches"in u?u.touches[0].clientX-v.left:u.clientX-v.left,N="touches"in u?u.touches[0].clientY-v.top:u.clientY-v.top;g.beginPath(),g.moveTo(P,N)},f=u=>{if(!n||a)return;const x=s.current;if(!x)return;const g=x.getContext("2d");if(!g)return;const v=x.getBoundingClientRect(),P="touches"in u?u.touches[0].clientX-v.left:u.clientX-v.left,N="touches"in u?u.touches[0].clientY-v.top:u.clientY-v.top;g.lineTo(P,N),g.strokeStyle="#000",g.lineWidth=2,g.lineCap="round",g.lineJoin="round",g.stroke()},h=()=>{if(!n)return;l(!1);const u=s.current;if(!u)return;const x=u.toDataURL("image/png");r(x)},p=()=>{const u=s.current;if(!u)return;const x=u.getContext("2d");x&&(x.clearRect(0,0,u.width,u.height),o(!0),r(""))};return a&&e?t.jsx("div",{className:"border rounded p-2 bg-white",children:t.jsx("img",{src:e,alt:"Signature",loading:"lazy",className:"max-w-full h-auto"})}):a&&!e?t.jsx("span",{className:"text-sm text-muted-foreground",children:"No signature"}):t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"border rounded bg-white",children:t.jsx("canvas",{ref:s,width:400,height:200,className:"w-full touch-none cursor-crosshair",onMouseDown:c,onMouseMove:f,onMouseUp:h,onMouseLeave:h,onTouchStart:c,onTouchMove:f,onTouchEnd:h})}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:i?"Sign above":"Signature captured"}),t.jsxs(d.Button,{type:"button",variant:"outline",size:"sm",onClick:p,disabled:a||i,children:[t.jsx(F.Eraser,{className:"w-4 h-4 mr-2"}),"Clear"]})]})]})}const Xt=Object.freeze(Object.defineProperty({__proto__:null,SignatureField:Re},Symbol.toStringTag,{value:"Module"}));function Pe({value:e,onChange:r,field:a,readonly:s,...n}){const[l,i]=C.useState(!1),o=a||n.schema,c=h=>`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(h)}`,f=()=>{e&&navigator.clipboard.writeText(e)};return s?t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"text-sm flex-1 truncate",children:e||"-"}),e&&t.jsxs(d.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>i(!l),children:[t.jsx(F.QrCode,{className:"w-4 h-4 mr-2"}),l?"Hide":"Show"," QR"]})]}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(d.Input,{type:"text",value:e||"",onChange:h=>r(h.target.value),placeholder:o?.placeholder||"Enter text for QR code",disabled:s||n.disabled,className:n.className}),e&&t.jsxs(t.Fragment,{children:[t.jsx(d.Button,{type:"button",variant:"outline",size:"sm",onClick:f,children:t.jsx(F.Copy,{className:"w-4 h-4"})}),t.jsx(d.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>i(!l),children:t.jsx(F.QrCode,{className:"w-4 h-4"})})]})]}),l&&e&&t.jsx("div",{className:"border rounded p-4 bg-white flex justify-center",children:t.jsx("img",{src:c(e),alt:"QR Code",className:"w-48 h-48"})}),e&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["QR code contains: ",e.length," characters"]})]})}const Ht=Object.freeze(Object.defineProperty({__proto__:null,QRCodeField:Pe},Symbol.toStringTag,{value:"Module"}));function Te({value:e,onChange:r,field:a,readonly:s,className:n,...l}){const i=e||[],o=a||l.schema,c=()=>{const p={id:`new-${Date.now()}`,label:"New Related Record"};r([...i,p])},f=p=>{r(i.filter(u=>u.id!==p))},h=p=>{console.log("View detail:",p)};return s?t.jsxs("div",{className:d.cn("space-y-2",n),children:[i.length===0?t.jsx("span",{className:"text-sm text-muted-foreground",children:"No related records"}):i.map(p=>t.jsxs("div",{className:"flex items-center justify-between p-2 border rounded hover:bg-muted/50",children:[t.jsx("span",{className:"text-sm",children:p.label}),t.jsx(d.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>h(p),children:t.jsx(F.ExternalLink,{className:"w-4 h-4"})})]},p.id)),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.length," ",i.length===1?"record":"records"]})]}):t.jsxs("div",{className:d.cn("space-y-3",n),children:[t.jsxs("div",{className:"space-y-2",children:[i.map(p=>t.jsxs("div",{className:"flex items-center justify-between gap-2 p-2 border rounded hover:bg-muted/50",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx(d.Badge,{variant:"outline",children:p.id}),t.jsx("span",{className:"text-sm flex-1",children:p.label})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(d.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>h(p),children:t.jsx(F.ExternalLink,{className:"w-4 h-4"})}),t.jsx(d.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(p.id),disabled:l.disabled,children:t.jsx(F.X,{className:"w-4 h-4"})})]})]},p.id)),i.length===0&&t.jsx("div",{className:"text-sm text-muted-foreground text-center py-4 border border-dashed rounded bg-muted/20",children:"No related records"})]}),t.jsxs(d.Button,{type:"button",variant:"outline",className:"w-full",onClick:c,disabled:l.disabled,children:[t.jsx(F.Plus,{className:"w-4 h-4 mr-2"}),"Add ",o?.label||"Record"]})]})}const Zt=Object.freeze(Object.defineProperty({__proto__:null,MasterDetailField:Te},Symbol.toStringTag,{value:"Module"}));function Ve(e,r="USD"){try{return new Intl.NumberFormat("en-US",{style:"currency",currency:r}).format(e)}catch{return`${r} ${e.toFixed(2)}`}}function Ye(e,r=0){return`${(e>-1&&e<1?e*100:e).toFixed(r)}%`}function qe(e,r){if(!e)return"-";const a=typeof e=="string"?new Date(e):e;return isNaN(a.getTime())?"-":a.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function Je(e){if(!e)return"-";const r=typeof e=="string"?new Date(e):e;return isNaN(r.getTime())?"-":r.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function T({value:e}){return t.jsx("span",{className:"truncate",children:e||"-"})}function Ge({value:e,field:r}){if(e==null)return t.jsx("span",{className:"text-muted-foreground",children:"-"});const s=r.precision??0,n=typeof e=="number"?new Intl.NumberFormat("en-US",{minimumFractionDigits:s,maximumFractionDigits:s}).format(e):e;return t.jsx("span",{className:"tabular-nums",children:n})}function Qe({value:e,field:r}){if(e==null)return t.jsx("span",{className:"text-muted-foreground",children:"-"});const s=r.currency||"USD",n=Ve(Number(e),s);return t.jsx("span",{className:"tabular-nums font-medium whitespace-nowrap",children:n})}function We({value:e,field:r}){if(e==null)return t.jsx("span",{className:"text-muted-foreground",children:"-"});const s=r.precision??0,n=Number(e),l=Ye(n,s),i=n>-1&&n<1?n*100:n,o=Math.max(0,Math.min(100,i));return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-1.5 w-16 rounded-full bg-muted overflow-hidden flex-shrink-0",role:"progressbar","aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100,children:t.jsx("div",{className:"h-full rounded-full bg-primary transition-all",style:{width:`${o}%`}})}),t.jsx("span",{className:"tabular-nums whitespace-nowrap",children:l})]})}function Xe({value:e}){return t.jsx("div",{className:"flex items-center",children:e?t.jsxs(d.Badge,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200 gap-1",children:[t.jsx(F.Check,{className:"size-3"}),"True"]}):t.jsxs(d.Badge,{variant:"outline",className:"bg-gray-50 text-gray-500 border-gray-200 gap-1",children:[t.jsx(F.X,{className:"size-3"}),"False"]})})}function He({value:e,field:r}){const s=qe(e,r.format);return t.jsx("span",{className:"tabular-nums",children:s})}function Ze({value:e}){const r=Je(e);return t.jsx("span",{className:"tabular-nums text-sm",children:r})}function z({value:e,field:r}){const s=r.options||[];if(!e)return t.jsx("span",{children:"-"});const n=c=>{const f={gray:"bg-gray-100 text-gray-800 border-gray-300",red:"bg-red-100 text-red-800 border-red-300",orange:"bg-orange-100 text-orange-800 border-orange-300",yellow:"bg-yellow-100 text-yellow-800 border-yellow-300",green:"bg-green-100 text-green-800 border-green-300",blue:"bg-blue-100 text-blue-800 border-blue-300",indigo:"bg-indigo-100 text-indigo-800 border-indigo-300",purple:"bg-purple-100 text-purple-800 border-purple-300",pink:"bg-pink-100 text-pink-800 border-pink-300"};return f[c||"blue"]||f.blue};if(Array.isArray(e))return t.jsx("div",{className:"flex flex-wrap gap-1",children:e.map((c,f)=>{const h=s.find(x=>x.value===c),p=h?.label||c,u=n(h?.color);return t.jsx(d.Badge,{variant:"outline",className:u,children:p},f)})});const l=s.find(c=>c.value===e),i=l?.label||e,o=n(l?.color);return t.jsx(d.Badge,{variant:"outline",className:o,children:i})}function Ke({value:e}){return e?t.jsx(d.Button,{variant:"link",className:"p-0 h-auto font-normal text-blue-600 hover:text-blue-800",asChild:!0,children:t.jsx("a",{href:`mailto:${e}`,onClick:r=>r.stopPropagation(),children:e})}):t.jsx("span",{children:"-"})}function et({value:e}){return e?t.jsx(d.Button,{variant:"link",className:"p-0 h-auto font-normal text-blue-600 hover:text-blue-800",asChild:!0,children:t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),children:e})}):t.jsx("span",{children:"-"})}function tt({value:e}){return e?t.jsx("a",{href:`tel:${e}`,className:"text-blue-600 hover:text-blue-800",onClick:r=>r.stopPropagation(),children:e}):t.jsx("span",{children:"-"})}function rt({value:e,field:r}){if(!e)return t.jsx("span",{children:"-"});if(r.multiple,Array.isArray(e)){const n=e.length;return t.jsxs("span",{className:"text-sm text-gray-600",children:[n," ",n===1?"file":"files"]})}const s=e.name||e.original_name||"File";return t.jsx("span",{className:"text-sm truncate",children:s})}function st({value:e}){return e?Array.isArray(e)?t.jsxs("div",{className:"flex -space-x-2",children:[e.slice(0,3).map((r,a)=>t.jsx("img",{src:r.url||"",alt:r.name||`Image ${a+1}`,className:"size-8 rounded-md border-2 border-white object-cover"},a)),e.length>3&&t.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]})]}):t.jsx("img",{src:e.url||"",alt:e.name||"Image",className:"size-10 rounded-md object-cover"}):t.jsx("span",{children:"-"})}function Oe({value:e}){if(!e)return t.jsx("span",{children:"-"});if(Array.isArray(e))return t.jsx("div",{className:"flex flex-wrap gap-1",children:e.map((r,a)=>{const s=r.name||r.label||r._id||String(r);return t.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-800",children:s},a)})});if(typeof e=="object"&&e!==null){const r=e.name||e.label||e._id||"[Object]";return t.jsx("span",{className:"truncate",children:r})}return t.jsx("span",{className:"truncate",children:String(e)})}function G({value:e}){return t.jsx("span",{className:"text-gray-700 font-mono text-sm",children:e!=null?String(e):"-"})}function Q({value:e}){if(!e)return t.jsx("span",{children:"-"});if(Array.isArray(e))return t.jsxs("div",{className:"flex -space-x-2",children:[e.slice(0,3).map((s,n)=>{const l=s.name||s.username||"User",i=l.split(" ").map(o=>o[0]).join("").toUpperCase().slice(0,2);return t.jsx(d.Avatar,{className:"size-8 border-2 border-white",title:l,children:t.jsx(d.AvatarFallback,{className:"bg-blue-500 text-white text-xs",children:i})},n)}),e.length>3&&t.jsx(d.Avatar,{className:"size-8 border-2 border-white",children:t.jsxs(d.AvatarFallback,{className:"bg-gray-200 text-gray-600 text-xs",children:["+",e.length-3]})})]});const r=e.name||e.username||"User",a=r.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(d.Avatar,{className:"size-8",children:t.jsx(d.AvatarFallback,{className:"bg-blue-500 text-white text-xs",children:a})}),t.jsx("span",{className:"truncate",children:r})]})}const W=new Map;function D(e,r){W.set(e,r)}function Kt(e){return W.has(e)?W.get(e):{text:T,textarea:T,markdown:T,html:T,number:Ge,currency:Qe,percent:We,boolean:Xe,date:He,datetime:Ze,time:T,select:z,lookup:z,master_detail:z,email:Ke,url:et,phone:tt,file:rt,image:st,formula:G,summary:G,auto_number:T,user:Q,owner:Q,password:()=>t.jsx("span",{children:"••••••"}),location:T,object:()=>t.jsx("span",{className:"text-gray-500 italic",children:"[Object]"}),vector:()=>t.jsx("span",{className:"text-gray-500 italic",children:"[Vector]"}),grid:()=>t.jsx("span",{className:"text-gray-500 italic",children:"[Grid]"})}[e]||T}D("lookup",Oe);D("master_detail",Oe);D("select",z);function er(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 tr(e){if(e<0||!Number.isFinite(e)||e===0)return"0 B";const r=["B","KB","MB","GB","TB"];let a=e,s=0;for(;a>=1024&&s<r.length-1;)a/=1024,s++;return`${a.toFixed(s>0?1:0)} ${r[s]}`}function rr(e){const r={};return e.required&&(r.required=typeof e.required_message=="string"?e.required_message:`${e.label||e.name} is required`),e.min_length&&(r.minLength={value:e.min_length,message:e.min_length_message||`Minimum length is ${e.min_length} characters`}),e.max_length&&(r.maxLength={value:e.max_length,message:e.max_length_message||`Maximum length is ${e.max_length} characters`}),e.min!==void 0&&(r.min={value:e.min,message:e.min_message||`Minimum value is ${e.min}`}),e.max!==void 0&&(r.max={value:e.max,message:e.max_message||`Maximum value is ${e.max}`}),e.pattern&&(r.pattern={value:typeof e.pattern=="string"?new RegExp(e.pattern):e.pattern,message:e.pattern_message||"Invalid format"}),e.type==="email"&&(r.pattern={value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:"Please enter a valid email address"}),e.type==="url"&&(r.pattern={value:/^https?:\/\/.+/,message:"Please enter a valid URL"}),e.validate&&(r.validate=e.validate),Object.keys(r).length>0?r:void 0}function X(e,r){if(!e)return!0;if(e.field&&e.value!==void 0){const a=r[e.field];if(e.operator==="="||e.operator==="==")return a===e.value;if(e.operator==="!=")return a!==e.value;if(e.operator===">")return a>e.value;if(e.operator===">=")return a>=e.value;if(e.operator==="<")return a<e.value;if(e.operator==="<=")return a<=e.value;if(e.operator==="in")return Array.isArray(e.value)&&e.value.includes(a)}return e.and&&Array.isArray(e.and)?e.and.every(a=>X(a,r)):e.or&&Array.isArray(e.or)?e.or.some(a=>X(a,r)):!0}function y(e){const r=({schema:a,className:s,value:n,...l})=>{const[i,o]=C.useState(n??a?.value??""),c={name:a?.name||"field",label:a?.label,type:a?.type,placeholder:a?.placeholder,required:a?.required,readonly:a?.readonly||a?.readOnly,help:a?.help,description:a?.description,defaultValue:a?.defaultValue||a?.value,...a},f=C.useCallback(p=>{o(p),l.onChange&&l.onChange(p)},[l]),h=a?.readonly||a?.readOnly||!1;return t.jsxs("div",{className:"grid w-full items-center gap-1.5","data-obj-id":a?.id,"data-obj-type":a?.type,children:[a?.label&&t.jsx("label",{htmlFor:a.id,className:a.required?"after:content-['*'] after:ml-0.5 after:text-red-500":"",children:a.label}),t.jsx(e,{value:i,onChange:f,field:c,readonly:h,className:s}),a?.description&&t.jsx("p",{className:"text-sm text-gray-500",children:a.description})]})};return r.displayName=`FieldRenderer(${e.displayName||e.name||"Component"})`,r}const nt={text:()=>Promise.resolve().then(()=>bt).then(e=>({default:e.TextField})),textarea:()=>Promise.resolve().then(()=>Rt).then(e=>({default:e.TextAreaField})),number:()=>Promise.resolve().then(()=>jt).then(e=>({default:e.NumberField})),boolean:()=>Promise.resolve().then(()=>yt).then(e=>({default:e.BooleanField})),select:()=>Promise.resolve().then(()=>Nt).then(e=>({default:e.SelectField})),date:()=>Promise.resolve().then(()=>vt).then(e=>({default:e.DateField})),datetime:()=>Promise.resolve().then(()=>Tt).then(e=>({default:e.DateTimeField})),time:()=>Promise.resolve().then(()=>Ot).then(e=>({default:e.TimeField})),email:()=>Promise.resolve().then(()=>Ft).then(e=>({default:e.EmailField})),phone:()=>Promise.resolve().then(()=>_t).then(e=>({default:e.PhoneField})),url:()=>Promise.resolve().then(()=>Ct).then(e=>({default:e.UrlField})),currency:()=>Promise.resolve().then(()=>wt).then(e=>({default:e.CurrencyField})),percent:()=>Promise.resolve().then(()=>At).then(e=>({default:e.PercentField})),password:()=>Promise.resolve().then(()=>kt).then(e=>({default:e.PasswordField})),markdown:()=>Promise.resolve().then(()=>Le).then(e=>({default:e.RichTextField})),html:()=>Promise.resolve().then(()=>Le).then(e=>({default:e.RichTextField})),lookup:()=>Promise.resolve().then(()=>Pt).then(e=>({default:e.LookupField})),master_detail:()=>Promise.resolve().then(()=>Zt).then(e=>({default:e.MasterDetailField})),file:()=>Promise.resolve().then(()=>$t).then(e=>({default:e.FileField})),image:()=>Promise.resolve().then(()=>zt).then(e=>({default:e.ImageField})),location:()=>Promise.resolve().then(()=>Et).then(e=>({default:e.LocationField})),formula:()=>Promise.resolve().then(()=>Mt).then(e=>({default:e.FormulaField})),summary:()=>Promise.resolve().then(()=>It).then(e=>({default:e.SummaryField})),auto_number:()=>Promise.resolve().then(()=>Ut).then(e=>({default:e.AutoNumberField})),user:()=>Promise.resolve().then(()=>Be).then(e=>({default:e.UserField})),owner:()=>Promise.resolve().then(()=>Be).then(e=>({default:e.UserField})),object:()=>Promise.resolve().then(()=>Dt).then(e=>({default:e.ObjectField})),vector:()=>Promise.resolve().then(()=>Lt).then(e=>({default:e.VectorField})),grid:()=>Promise.resolve().then(()=>Bt).then(e=>({default:e.GridField})),color:()=>Promise.resolve().then(()=>Vt).then(e=>({default:e.ColorField})),slider:()=>Promise.resolve().then(()=>Yt).then(e=>({default:e.SliderField})),rating:()=>Promise.resolve().then(()=>qt).then(e=>({default:e.RatingField})),code:()=>Promise.resolve().then(()=>Jt).then(e=>({default:e.CodeField})),avatar:()=>Promise.resolve().then(()=>Gt).then(e=>({default:e.AvatarField})),address:()=>Promise.resolve().then(()=>Qt).then(e=>({default:e.AddressField})),geolocation:()=>Promise.resolve().then(()=>Wt).then(e=>({default:e.GeolocationField})),signature:()=>Promise.resolve().then(()=>Xt).then(e=>({default:e.SignatureField})),qrcode:()=>Promise.resolve().then(()=>Ht).then(e=>({default:e.QRCodeField}))};function at(e){const r=nt[e];if(!r){console.warn(`Unknown field type: ${e}`);return}const a=C.lazy(r);b.ComponentRegistry.register(e,a,{namespace:"field"})}function lt(){Object.keys(nt).forEach(e=>{at(e)})}function sr(){b.ComponentRegistry.register("text",y(H),{namespace:"field"}),b.ComponentRegistry.register("textarea",y(le),{namespace:"field"}),b.ComponentRegistry.register("number",y(Z),{namespace:"field"}),b.ComponentRegistry.register("boolean",y(K),{namespace:"field"}),b.ComponentRegistry.register("select",y(ee),{namespace:"field"}),b.ComponentRegistry.register("date",y(te),{namespace:"field"}),b.ComponentRegistry.register("datetime",y(oe),{namespace:"field"}),b.ComponentRegistry.register("time",y(ce),{namespace:"field"}),b.ComponentRegistry.register("email",y(re),{namespace:"field"}),b.ComponentRegistry.register("phone",y(se),{namespace:"field"}),b.ComponentRegistry.register("url",y(ne),{namespace:"field"}),b.ComponentRegistry.register("currency",y(ae),{namespace:"field"}),b.ComponentRegistry.register("percent",y(de),{namespace:"field"}),b.ComponentRegistry.register("password",y(ue),{namespace:"field"}),b.ComponentRegistry.register("markdown",y(I),{namespace:"field"}),b.ComponentRegistry.register("html",y(I),{namespace:"field"}),b.ComponentRegistry.register("lookup",y(ie),{namespace:"field"}),b.ComponentRegistry.register("master_detail",y(Te),{namespace:"field"}),b.ComponentRegistry.register("file",y(me),{namespace:"field"}),b.ComponentRegistry.register("image",y(fe),{namespace:"field"}),b.ComponentRegistry.register("location",y(xe),{namespace:"field"}),b.ComponentRegistry.register("formula",y(pe),{namespace:"field"}),b.ComponentRegistry.register("summary",y(he),{namespace:"field"}),b.ComponentRegistry.register("auto_number",y(ge),{namespace:"field"}),b.ComponentRegistry.register("user",y(U),{namespace:"field"}),b.ComponentRegistry.register("owner",y(U),{namespace:"field"}),b.ComponentRegistry.register("object",y(be),{namespace:"field"}),b.ComponentRegistry.register("vector",y(je),{namespace:"field"}),b.ComponentRegistry.register("grid",y(ye),{namespace:"field"}),b.ComponentRegistry.register("color",y(Ne),{namespace:"field"}),b.ComponentRegistry.register("slider",y(ve),{namespace:"field"}),b.ComponentRegistry.register("rating",y(Fe),{namespace:"field"}),b.ComponentRegistry.register("code",y(_e),{namespace:"field"}),b.ComponentRegistry.register("avatar",y(Ce),{namespace:"field"}),b.ComponentRegistry.register("address",y(Se),{namespace:"field"}),b.ComponentRegistry.register("geolocation",y(we),{namespace:"field"}),b.ComponentRegistry.register("signature",y(Re),{namespace:"field"}),b.ComponentRegistry.register("qrcode",y(Pe),{namespace:"field"})}lt();exports.AddressField=Se;exports.AutoNumberField=ge;exports.AvatarField=Ce;exports.BooleanCellRenderer=Xe;exports.BooleanField=K;exports.CodeField=_e;exports.ColorField=Ne;exports.CurrencyCellRenderer=Qe;exports.CurrencyField=ae;exports.DateCellRenderer=He;exports.DateField=te;exports.DateTimeCellRenderer=Ze;exports.DateTimeField=oe;exports.EmailCellRenderer=Ke;exports.EmailField=re;exports.FileCellRenderer=rt;exports.FileField=me;exports.FormulaCellRenderer=G;exports.FormulaField=pe;exports.GeolocationField=we;exports.GridField=ye;exports.ImageCellRenderer=st;exports.ImageField=fe;exports.LocationField=xe;exports.LookupCellRenderer=Oe;exports.LookupField=ie;exports.MasterDetailField=Te;exports.NumberCellRenderer=Ge;exports.NumberField=Z;exports.ObjectField=be;exports.PasswordField=ue;exports.PercentCellRenderer=We;exports.PercentField=de;exports.PhoneCellRenderer=tt;exports.PhoneField=se;exports.QRCodeField=Pe;exports.RatingField=Fe;exports.RichTextField=I;exports.SelectCellRenderer=z;exports.SelectField=ee;exports.SignatureField=Re;exports.SliderField=ve;exports.SummaryField=he;exports.TextAreaField=le;exports.TextCellRenderer=T;exports.TextField=H;exports.TimeField=ce;exports.UrlCellRenderer=et;exports.UrlField=ne;exports.UserCellRenderer=Q;exports.UserField=U;exports.VectorField=je;exports.buildValidationRules=rr;exports.evaluateCondition=X;exports.formatCurrency=Ve;exports.formatDate=qe;exports.formatDateTime=Je;exports.formatFileSize=tr;exports.formatPercent=Ye;exports.getCellRenderer=Kt;exports.mapFieldTypeToFormType=er;exports.registerAllFields=lt;exports.registerField=at;exports.registerFieldRenderer=D;exports.registerFields=sr;
|
|
13
|
+
}`,disabled:a||s.disabled,className:d.cn("font-mono text-xs",f?"border-red-500 focus-visible:ring-red-500":"",s.className),rows:6}),f&&t.jsx("p",{className:"text-xs text-red-500",children:f})]})}const Bt=Object.freeze(Object.defineProperty({__proto__:null,ObjectField:Re},Symbol.toStringTag,{value:"Module"}));function Te({value:e,field:r,...n}){const s=(r||n.schema)?.dimensions||(Array.isArray(e)?e.length:0);if(!e||!Array.isArray(e))return t.jsx("span",{className:"text-sm text-gray-500",children:"-"});const i=e.slice(0,3).map(l=>{const o=Number(l);return isNaN(o)?"0":o.toFixed(4)}).join(", ");return t.jsxs("div",{className:`text-sm ${n.className||""}`,children:[t.jsxs("span",{className:"font-mono text-gray-700",children:["[",i,"...]"]}),t.jsxs("span",{className:"text-gray-500 ml-2",children:["(",s,"D)"]})]})}const Vt=Object.freeze(Object.defineProperty({__proto__:null,VectorField:Te},Symbol.toStringTag,{value:"Module"}));function Pe({value:e,field:r,readonly:n,...a}){const i=(r||a.schema)?.columns||[];return!e||!Array.isArray(e)?t.jsx("span",{className:"text-sm text-muted-foreground",children:"-"}):n?t.jsx("div",{className:d.cn("text-sm",a.className),children:t.jsxs("span",{className:"text-foreground",children:[e.length," rows"]})}):t.jsxs("div",{className:d.cn("border border-border rounded-lg overflow-hidden",a.className),children:[t.jsx("div",{className:"overflow-auto max-h-60",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted border-b border-border",children:t.jsx("tr",{children:i.map((l,o)=>t.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-muted-foreground",children:l.label||l.name},o))})}),t.jsx("tbody",{className:"divide-y divide-border",children:e.slice(0,5).map((l,o)=>t.jsx("tr",{className:"hover:bg-muted/50 transition-colors",children:i.map((c,f)=>t.jsx("td",{className:"px-3 py-2 text-foreground",children:l[c.name]!=null?String(l[c.name]):"-"},f))},o))})]})}),e.length>5&&t.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"]})]})}const Yt=Object.freeze(Object.defineProperty({__proto__:null,GridField:Pe},Symbol.toStringTag,{value:"Module"}));function Oe({value:e,onChange:r,field:n,readonly:a,...s}){const i=n||s.schema;return a?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-6 h-6 rounded border border-input",style:{backgroundColor:e||"#000000"}}),t.jsx("span",{className:"text-sm",children:e||"-"})]}):t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"color",value:e||"#000000",onChange:l=>r(l.target.value),disabled:a||s.disabled,className:"w-10 h-10 rounded border border-input cursor-pointer"}),t.jsx(d.Input,{type:"text",value:e||"",onChange:l=>r(l.target.value),placeholder:i?.placeholder||"#000000",disabled:a||s.disabled,className:s.className,pattern:"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"})]})}const qt=Object.freeze(Object.defineProperty({__proto__:null,ColorField:Oe},Symbol.toStringTag,{value:"Module"}));function ke({value:e,onChange:r,field:n,readonly:a,...s}){const i=n||s.schema,l=i?.min??0,o=i?.max??100,c=i?.step??1;return a?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium",children:e??l}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["/ ",o]})]}):t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(d.Slider,{value:[e??l],onValueChange:f=>r(f[0]),min:l,max:o,step:c,disabled:a||s.disabled,className:s.className}),t.jsx("span",{className:"text-sm font-medium w-12 text-right",children:e??l})]})}const Gt=Object.freeze(Object.defineProperty({__proto__:null,SliderField:ke},Symbol.toStringTag,{value:"Module"}));function Ae({value:e,onChange:r,field:n,readonly:a,className:s,...i}){const o=(n||i.schema)?.max??5,c=e??0,[f,h]=C.useState(null),p=f!==null?f:c;return a?t.jsxs("div",{className:d.cn("flex items-center gap-1",s),children:[Array.from({length:o},(m,x)=>t.jsx(_.Star,{className:`w-5 h-5 ${x<c?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},x)),t.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[c," / ",o]})]}):t.jsxs("div",{className:d.cn("flex items-center gap-1",s),children:[Array.from({length:o},(m,x)=>t.jsx("button",{type:"button",onClick:()=>r(x+1),onMouseEnter:()=>h(x+1),onMouseLeave:()=>h(null),className:"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded",disabled:a||i.disabled,children:t.jsx(_.Star,{className:`w-5 h-5 transition-colors ${x<p?"fill-yellow-400 text-yellow-400 hover:fill-yellow-500 hover:text-yellow-500":"text-muted-foreground hover:text-yellow-400"}`})},x)),t.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[c," / ",o]})]})}const Jt=Object.freeze(Object.defineProperty({__proto__:null,RatingField:Ae},Symbol.toStringTag,{value:"Module"}));function $e({value:e,onChange:r,field:n,readonly:a,...s}){const i=n||s.schema,l=i?.language??"javascript";return a?t.jsx("pre",{className:d.cn("text-sm bg-muted p-2 rounded overflow-x-auto border",s.className),children:t.jsx("code",{children:e||"-"})}):t.jsx(d.Textarea,{value:e||"",onChange:o=>r(o.target.value),placeholder:i?.placeholder||`// Write ${l} code here...`,disabled:a||s.disabled,className:d.cn("font-mono text-sm",s.className),rows:12,spellCheck:!1})}const Wt=Object.freeze(Object.defineProperty({__proto__:null,CodeField:$e},Symbol.toStringTag,{value:"Module"}));function Ee({value:e,onChange:r,field:n,readonly:a,...s}){const[i,l]=C.useState(!1),o=C.useRef(null),c=n||s.schema,f=m=>{const x=m.target.files?.[0];if(!x)return;if(!x.type.startsWith("image/")){console.error("Please select an image file");return}if(x.size>5*1024*1024){console.error("File size must be less than 5MB");return}const g=new FileReader;g.onloadend=()=>{r(g.result)},g.readAsDataURL(x)},h=()=>{r("")},p=()=>(c?.defaultName||c?.label||"User").split(" ").map(x=>x[0]).join("").toUpperCase().slice(0,2);return a?t.jsxs(d.Avatar,{className:"w-16 h-16",children:[e&&t.jsx(d.AvatarImage,{src:e,alt:c?.label}),t.jsx(d.AvatarFallback,{children:p()})]}):t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"relative",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t.jsxs(d.Avatar,{className:"w-16 h-16",children:[e&&t.jsx(d.AvatarImage,{src:e,alt:c?.label}),t.jsx(d.AvatarFallback,{children:p()})]}),!a&&i&&e&&t.jsx("button",{type:"button",onClick:h,className:"absolute -top-1 -right-1 bg-destructive text-destructive-foreground rounded-full p-1 hover:bg-destructive/90",children:t.jsx(_.X,{className:"w-3 h-3"})})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("input",{ref:o,type:"file",accept:"image/*",onChange:f,className:"hidden"}),t.jsxs(d.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>o.current?.click(),disabled:a||s.disabled,children:[t.jsx(_.Upload,{className:"w-4 h-4 mr-2"}),e?"Change":"Upload"," Avatar"]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"PNG, JPG up to 5MB"})]})]})}const Qt=Object.freeze(Object.defineProperty({__proto__:null,AvatarField:Ee},Symbol.toStringTag,{value:"Module"}));function ze({value:e,onChange:r,field:n,readonly:a,...s}){const i=e||{},l=(c,f)=>{r({...i,[c]:f})},o=c=>[c.street,c.city,[c.state,c.zipCode].filter(Boolean).join(" "),c.country].filter(Boolean).join(", ")||"-";return a?t.jsx("span",{className:"text-sm",children:o(i)}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"street",className:"text-xs",children:"Street Address"}),t.jsx(d.Input,{id:"street",type:"text",value:i.street||"",onChange:c=>l("street",c.target.value),placeholder:"123 Main St",disabled:a||s.disabled,className:s.className})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"city",className:"text-xs",children:"City"}),t.jsx(d.Input,{id:"city",type:"text",value:i.city||"",onChange:c=>l("city",c.target.value),placeholder:"San Francisco",disabled:a||s.disabled})]}),t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"state",className:"text-xs",children:"State / Province"}),t.jsx(d.Input,{id:"state",type:"text",value:i.state||"",onChange:c=>l("state",c.target.value),placeholder:"CA",disabled:a||s.disabled})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"zipCode",className:"text-xs",children:"ZIP / Postal Code"}),t.jsx(d.Input,{id:"zipCode",type:"text",value:i.zipCode||"",onChange:c=>l("zipCode",c.target.value),placeholder:"94102",disabled:a||s.disabled})]}),t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"country",className:"text-xs",children:"Country"}),t.jsx(d.Input,{id:"country",type:"text",value:i.country||"",onChange:c=>l("country",c.target.value),placeholder:"United States",disabled:a||s.disabled})]})]})]})}const Xt=Object.freeze(Object.defineProperty({__proto__:null,AddressField:ze},Symbol.toStringTag,{value:"Module"}));function De({value:e,onChange:r,field:n,readonly:a,...s}){const[i,l]=C.useState(!1),o=e||{},c=(m,x)=>{r({...o,[m]:x?Number(x):void 0})},f=()=>{if(!navigator.geolocation){console.error("Geolocation is not supported by this browser");return}l(!0),navigator.geolocation.getCurrentPosition(m=>{r({latitude:m.coords.latitude,longitude:m.coords.longitude,accuracy:m.coords.accuracy}),l(!1)},m=>{console.error("Error getting location:",m.message),l(!1)},{enableHighAccuracy:!0,timeout:5e3,maximumAge:0})},h=m=>!m.latitude||!m.longitude?"-":`${m.latitude.toFixed(6)}, ${m.longitude.toFixed(6)}`,p=()=>{if(!o.latitude||!o.longitude)return;const m=`https://www.google.com/maps?q=${o.latitude},${o.longitude}`;window.open(m,"_blank")};return a?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_.MapPin,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm",children:h(o)}),o.latitude&&o.longitude&&t.jsx(d.Button,{type:"button",variant:"link",size:"sm",onClick:p,className:"p-0 h-auto",children:"View on map"})]}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(d.Button,{type:"button",variant:"outline",size:"sm",onClick:f,disabled:a||i,children:[t.jsx(_.Crosshair,{className:"w-4 h-4 mr-2"}),i?"Getting location...":"Use Current Location"]}),o.latitude&&o.longitude&&t.jsxs(d.Button,{type:"button",variant:"link",size:"sm",onClick:p,children:[t.jsx(_.MapPin,{className:"w-4 h-4 mr-2"}),"View on map"]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"latitude",className:"text-xs",children:"Latitude"}),t.jsx(d.Input,{id:"latitude",type:"number",value:o.latitude??"",onChange:m=>c("latitude",m.target.value),placeholder:"37.7749",disabled:a||s.disabled,step:"any",className:s.className})]}),t.jsxs("div",{children:[t.jsx(d.Label,{htmlFor:"longitude",className:"text-xs",children:"Longitude"}),t.jsx(d.Input,{id:"longitude",type:"number",value:o.longitude??"",onChange:m=>c("longitude",m.target.value),placeholder:"-122.4194",disabled:a||s.disabled,step:"any"})]})]}),o.accuracy&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Accuracy: ±",o.accuracy.toFixed(0),"m"]})]})}const Ht=Object.freeze(Object.defineProperty({__proto__:null,GeolocationField:De},Symbol.toStringTag,{value:"Module"}));function Me({value:e,onChange:r,readonly:n}){const a=C.useRef(null),[s,i]=C.useState(!1),[l,o]=C.useState(!e);C.useEffect(()=>{if(e&&a.current){const x=a.current.getContext("2d");if(x){const g=new Image;g.onload=()=>{x.drawImage(g,0,0),o(!1)},g.src=e}}},[e]);const c=m=>{if(n)return;i(!0),o(!1);const x=a.current;if(!x)return;const g=x.getContext("2d");if(!g)return;const F=x.getBoundingClientRect(),k="touches"in m?m.touches[0].clientX-F.left:m.clientX-F.left,v="touches"in m?m.touches[0].clientY-F.top:m.clientY-F.top;g.beginPath(),g.moveTo(k,v)},f=m=>{if(!s||n)return;const x=a.current;if(!x)return;const g=x.getContext("2d");if(!g)return;const F=x.getBoundingClientRect(),k="touches"in m?m.touches[0].clientX-F.left:m.clientX-F.left,v="touches"in m?m.touches[0].clientY-F.top:m.clientY-F.top;g.lineTo(k,v),g.strokeStyle="#000",g.lineWidth=2,g.lineCap="round",g.lineJoin="round",g.stroke()},h=()=>{if(!s)return;i(!1);const m=a.current;if(!m)return;const x=m.toDataURL("image/png");r(x)},p=()=>{const m=a.current;if(!m)return;const x=m.getContext("2d");x&&(x.clearRect(0,0,m.width,m.height),o(!0),r(""))};return n&&e?t.jsx("div",{className:"border rounded p-2 bg-white",children:t.jsx("img",{src:e,alt:"Signature",loading:"lazy",className:"max-w-full h-auto"})}):n&&!e?t.jsx("span",{className:"text-sm text-muted-foreground",children:"No signature"}):t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"border rounded bg-white",children:t.jsx("canvas",{ref:a,width:400,height:200,className:"w-full touch-none cursor-crosshair",onMouseDown:c,onMouseMove:f,onMouseUp:h,onMouseLeave:h,onTouchStart:c,onTouchMove:f,onTouchEnd:h})}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:l?"Sign above":"Signature captured"}),t.jsxs(d.Button,{type:"button",variant:"outline",size:"sm",onClick:p,disabled:n||l,children:[t.jsx(_.Eraser,{className:"w-4 h-4 mr-2"}),"Clear"]})]})]})}const Zt=Object.freeze(Object.defineProperty({__proto__:null,SignatureField:Me},Symbol.toStringTag,{value:"Module"}));function Ie({value:e,onChange:r,field:n,readonly:a,...s}){const[i,l]=C.useState(!1),o=n||s.schema,c=h=>`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(h)}`,f=()=>{e&&navigator.clipboard.writeText(e)};return a?t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"text-sm flex-1 truncate",children:e||"-"}),e&&t.jsxs(d.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>l(!i),children:[t.jsx(_.QrCode,{className:"w-4 h-4 mr-2"}),i?"Hide":"Show"," QR"]})]}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(d.Input,{type:"text",value:e||"",onChange:h=>r(h.target.value),placeholder:o?.placeholder||"Enter text for QR code",disabled:a||s.disabled,className:s.className}),e&&t.jsxs(t.Fragment,{children:[t.jsx(d.Button,{type:"button",variant:"outline",size:"sm",onClick:f,children:t.jsx(_.Copy,{className:"w-4 h-4"})}),t.jsx(d.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>l(!i),children:t.jsx(_.QrCode,{className:"w-4 h-4"})})]})]}),i&&e&&t.jsx("div",{className:"border rounded p-4 bg-white flex justify-center",children:t.jsx("img",{src:c(e),alt:"QR Code",className:"w-48 h-48"})}),e&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["QR code contains: ",e.length," characters"]})]})}const Kt=Object.freeze(Object.defineProperty({__proto__:null,QRCodeField:Ie},Symbol.toStringTag,{value:"Module"}));function Le({value:e,onChange:r,field:n,readonly:a,className:s,...i}){const l=e||[],o=n||i.schema,c=()=>{const p={id:`new-${Date.now()}`,label:"New Related Record"};r([...l,p])},f=p=>{r(l.filter(m=>m.id!==p))},h=p=>{console.log("View detail:",p)};return a?t.jsxs("div",{className:d.cn("space-y-2",s),children:[l.length===0?t.jsx("span",{className:"text-sm text-muted-foreground",children:"No related records"}):l.map(p=>t.jsxs("div",{className:"flex items-center justify-between p-2 border rounded hover:bg-muted/50",children:[t.jsx("span",{className:"text-sm",children:p.label}),t.jsx(d.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>h(p),children:t.jsx(_.ExternalLink,{className:"w-4 h-4"})})]},p.id)),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[l.length," ",l.length===1?"record":"records"]})]}):t.jsxs("div",{className:d.cn("space-y-3",s),children:[t.jsxs("div",{className:"space-y-2",children:[l.map(p=>t.jsxs("div",{className:"flex items-center justify-between gap-2 p-2 border rounded hover:bg-muted/50",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx(d.Badge,{variant:"outline",children:p.id}),t.jsx("span",{className:"text-sm flex-1",children:p.label})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(d.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>h(p),children:t.jsx(_.ExternalLink,{className:"w-4 h-4"})}),t.jsx(d.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(p.id),disabled:i.disabled,children:t.jsx(_.X,{className:"w-4 h-4"})})]})]},p.id)),l.length===0&&t.jsx("div",{className:"text-sm text-muted-foreground text-center py-4 border border-dashed rounded bg-muted/20",children:"No related records"})]}),t.jsxs(d.Button,{type:"button",variant:"outline",className:"w-full",onClick:c,disabled:i.disabled,children:[t.jsx(_.Plus,{className:"w-4 h-4 mr-2"}),"Add ",o?.label||"Record"]})]})}const er=Object.freeze(Object.defineProperty({__proto__:null,MasterDetailField:Le},Symbol.toStringTag,{value:"Module"}));function Ze(e,r="USD"){try{return new Intl.NumberFormat("en-US",{style:"currency",currency:r}).format(e)}catch{return`${r} ${e.toFixed(2)}`}}function tr(e,r="USD"){try{return new Intl.NumberFormat("en-US",{style:"currency",currency:r,notation:"compact",maximumFractionDigits:1}).format(e).replace(/\.0(?=[KMBT])/,"")}catch{return`${r} ${e}`}}function Ke(e,r=0){return`${(e>-1&&e<1?e*100:e).toFixed(r)}%`}function K(e){return e.replace(/[_-]/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function et(e){if(!e)return"-";const r=typeof e=="string"?new Date(e):e;if(isNaN(r.getTime()))return"-";const n=new Date,a=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime()-a.getTime(),l=Math.round(i/(1e3*60*60*24));if(l===0)return"Today";if(l===1)return"Tomorrow";if(l===-1)return"Yesterday";if(l<-1){const o=Math.abs(l);return o<=7?`Overdue ${o}d`:ee(r)}return l>1&&l<=7?`In ${l} days`:ee(r)}function ee(e,r){if(!e)return"-";const n=typeof e=="string"?new Date(e):e;if(isNaN(n.getTime()))return"-";if(r==="short"){const a=n.toLocaleDateString("en-US",{month:"short"}),s=n.getDate(),i=String(n.getFullYear()).slice(-2);return`${a} ${s}, '${i}`}return r==="relative"?et(n):n.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function rr(e){if(!e)return"-";const r=typeof e=="string"?new Date(e):e;return isNaN(r.getTime())?"-":r.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function E({value:e}){return t.jsx("span",{className:"truncate",children:e!=null&&e!==""?String(e):"-"})}function tt({value:e,field:r}){if(e==null)return t.jsx("span",{className:"text-muted-foreground",children:"-"});const a=r.precision??0,s=typeof e=="number"?new Intl.NumberFormat("en-US",{minimumFractionDigits:a,maximumFractionDigits:a}).format(e):e;return t.jsx("span",{className:"tabular-nums",children:s})}function rt({value:e,field:r}){if(e==null)return t.jsx("span",{className:"text-muted-foreground",children:"-"});const a=r.currency||"USD",s=Ze(Number(e),a);return t.jsx("span",{className:"tabular-nums font-medium whitespace-nowrap",children:s})}const sr=/progress|completion/;function st({value:e,field:r}){if(e==null)return t.jsx("span",{className:"text-muted-foreground",children:"-"});const a=r.precision??0,s=Number(e),i=sr.test(r?.name?.toLowerCase()||""),l=i?s:s>-1&&s<1?s*100:s,o=i?`${s.toFixed(a)}%`:Ke(s,a),c=Math.max(0,Math.min(100,l));return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"h-1.5 w-16 rounded-full bg-muted overflow-hidden flex-shrink-0",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,children:t.jsx("div",{className:"h-full rounded-full bg-primary transition-all",style:{width:`${c}%`}})}),t.jsx("span",{className:"tabular-nums whitespace-nowrap",children:o})]})}const nr=new Set(["active","is_active","enabled","is_enabled","verified","is_verified"]);function nt({value:e,field:r}){if(e==null)return t.jsx("span",{className:"text-muted-foreground/50 text-xs italic flex items-center justify-center",children:"—"});const n=r?.name?.toLowerCase()||"";return n==="completed"||n==="is_completed"||n==="done"||n==="is_done"?t.jsx("div",{className:"flex items-center justify-center",children:e?t.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:t.jsx(_.Check,{className:"size-3 text-white"})}):t.jsx("div",{className:"size-5 rounded-full border-2 border-muted-foreground/30",role:"img","aria-label":"Not completed","data-testid":"completion-indicator"})}):nr.has(n)&&!e?t.jsxs(d.Badge,{variant:"destructive",className:"text-xs","data-testid":"boolean-warning-badge",children:[r?.label||K(n)," — Off"]}):t.jsx("div",{className:"flex items-center justify-center",children:t.jsx(d.Checkbox,{checked:!!e,disabled:!0,className:"pointer-events-none"})})}function at({value:e,field:r}){if(!e)return t.jsx("span",{className:"text-muted-foreground",children:"-"});const a=r.format||"relative",s=ee(e,a),i=typeof e=="string"?new Date(e):e,l=i instanceof Date&&!isNaN(i.getTime()),o=new Date;o.setHours(0,0,0,0);const c=l&&i<o,f=l?i.toISOString():String(e);return t.jsx("span",{className:`tabular-nums${c?" text-red-600":""}`,title:f,children:s})}function lt({value:e}){if(!e)return t.jsx("span",{className:"text-muted-foreground",children:"-"});const r=typeof e=="string"?new Date(e):e;if(isNaN(r.getTime()))return t.jsx("span",{className:"text-muted-foreground",children:"-"});const n=r.toLocaleDateString(void 0,{month:"numeric",day:"numeric",year:"numeric"}),a=r.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0}).toLowerCase();return t.jsxs("span",{className:"tabular-nums text-sm whitespace-nowrap",children:[t.jsx("span",{children:n}),t.jsx("span",{className:"ml-2 text-muted-foreground",children:a})]})}const ar={critical:"red",urgent:"red",high:"orange",medium:"yellow",normal:"blue",low:"gray",none:"gray"},lr={gray:"bg-gray-100 text-gray-800 border-gray-300",red:"bg-red-100 text-red-800 border-red-300",orange:"bg-orange-100 text-orange-800 border-orange-300",yellow:"bg-yellow-100 text-yellow-800 border-yellow-300",green:"bg-green-100 text-green-800 border-green-300",blue:"bg-blue-100 text-blue-800 border-blue-300",indigo:"bg-indigo-100 text-indigo-800 border-indigo-300",purple:"bg-purple-100 text-purple-800 border-purple-300",pink:"bg-pink-100 text-pink-800 border-pink-300"};function He(e,r){const n=e||(r?ar[String(r).toLowerCase()]:void 0);return lr[n||""]||"bg-muted text-muted-foreground border-border"}function q({value:e,field:r}){const a=r.options||[];if(!e)return t.jsx("span",{children:"-"});if(Array.isArray(e))return t.jsx("div",{className:"flex flex-wrap gap-1",children:e.map((o,c)=>{const f=a.find(m=>m.value===o),h=f?.label||K(String(o)),p=He(f?.color,o);return t.jsx(d.Badge,{variant:"outline",className:p,children:h},c)})});const s=a.find(o=>o.value===e),i=s?.label||K(String(e)),l=He(s?.color,e);return t.jsx(d.Badge,{variant:"outline",className:l,children:i})}function it({value:e}){if(!e)return t.jsx("span",{children:"-"});const[r,n]=C.useState(!1),a=s=>{s.stopPropagation(),s.preventDefault(),navigator.clipboard.writeText(String(e)).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)}).catch(()=>{})};return t.jsxs("span",{className:"inline-flex items-center gap-1 group/email",children:[t.jsx(d.Button,{variant:"link",className:"p-0 h-auto font-normal text-blue-600 hover:text-blue-800",asChild:!0,children:t.jsx("a",{href:`mailto:${e}`,onClick:s=>s.stopPropagation(),children:e})}),t.jsx("button",{type:"button",className:"opacity-0 group-hover/email:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted",onClick:a,"aria-label":"Copy email",children:r?t.jsx(_.Check,{className:"h-3 w-3 text-green-600"}):t.jsx(_.Copy,{className:"h-3 w-3 text-muted-foreground"})})]})}function ot({value:e}){return e?t.jsx(d.Button,{variant:"link",className:"p-0 h-auto font-normal text-blue-600 hover:text-blue-800",asChild:!0,children:t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),children:e})}):t.jsx("span",{children:"-"})}function ct({value:e}){if(!e)return t.jsx("span",{children:"-"});const[r,n]=C.useState(!1),a=s=>{s.stopPropagation(),s.preventDefault(),navigator.clipboard.writeText(String(e)).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)}).catch(()=>{})};return t.jsxs("span",{className:"inline-flex items-center gap-1 group/phone",children:[t.jsxs("a",{href:`tel:${e}`,className:"inline-flex items-center gap-1 text-blue-600 hover:text-blue-800",onClick:s=>s.stopPropagation(),children:[t.jsx(_.Phone,{className:"h-3 w-3"}),e]}),t.jsx("button",{type:"button",className:"opacity-0 group-hover/phone:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted",onClick:a,"aria-label":"Copy phone number",children:r?t.jsx(_.Check,{className:"h-3 w-3 text-green-600"}):t.jsx(_.Copy,{className:"h-3 w-3 text-muted-foreground"})})]})}function dt({value:e,field:r}){if(!e)return t.jsx("span",{children:"-"});if(r.multiple,Array.isArray(e)){const s=e.length;return t.jsxs("span",{className:"text-sm text-gray-600",children:[s," ",s===1?"file":"files"]})}const a=e.name||e.original_name||"File";return t.jsx("span",{className:"text-sm truncate",children:a})}function ut({value:e}){return e?Array.isArray(e)?t.jsxs("div",{className:"flex -space-x-2",children:[e.slice(0,3).map((r,n)=>t.jsx("img",{src:r.url||"",alt:r.name||`Image ${n+1}`,className:"size-8 rounded-md border-2 border-white object-cover"},n)),e.length>3&&t.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]})]}):t.jsx("img",{src:e.url||"",alt:e.name||"Image",className:"size-10 rounded-md object-cover"}):t.jsx("span",{children:"-"})}function G({value:e,field:r}){if(e==null||e==="")return t.jsx("span",{children:"-"});const n=r.options||[],a=s=>{if(n.length>0){const i=n.find(l=>String(l.value)===String(s));if(i)return i.label}return String(s)};if(Array.isArray(e))return t.jsx("div",{className:"flex flex-wrap gap-1",children:e.map((s,i)=>{let l;return s!=null&&typeof s=="object"?l=s.name||s.label||s._id||String(s):l=a(s),t.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-800",children:l},i)})});if(typeof e=="object"&&e!==null){const s=e.name||e.label||e._id||"[Object]";return t.jsx("span",{className:"truncate",children:s})}return t.jsx("span",{className:"truncate",children:a(e)})}function ne({value:e}){return t.jsx("span",{className:"text-gray-700 font-mono text-sm",children:e!=null?String(e):"-"})}function J({value:e}){if(!e)return t.jsx("span",{children:"-"});if(typeof e!="object")return t.jsx("span",{className:"truncate",children:String(e)});if(Array.isArray(e))return t.jsxs("div",{className:"flex -space-x-2",children:[e.slice(0,3).map((a,s)=>{if(typeof a!="object"||a===null)return t.jsx("span",{className:"truncate text-sm",children:String(a)},s);const i=a.name||a.username||"User",l=i.split(" ").map(o=>o[0]).join("").toUpperCase().slice(0,2);return t.jsx(d.Avatar,{className:"size-8 border-2 border-white",title:i,children:t.jsx(d.AvatarFallback,{className:"bg-blue-500 text-white text-xs",children:l})},s)}),e.length>3&&t.jsx(d.Avatar,{className:"size-8 border-2 border-white",children:t.jsxs(d.AvatarFallback,{className:"bg-gray-200 text-gray-600 text-xs",children:["+",e.length-3]})})]});const r=e.name||e.username||"User",n=r.split(" ").map(a=>a[0]).join("").toUpperCase().slice(0,2);return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(d.Avatar,{className:"size-8",children:t.jsx(d.AvatarFallback,{className:"bg-blue-500 text-white text-xs",children:n})}),t.jsx("span",{className:"truncate",children:r})]})}const ae=new Map;function M(e,r){ae.set(e,r)}function ir(e){return ae.has(e)?ae.get(e):{text:E,textarea:E,markdown:E,html:E,number:tt,currency:rt,percent:st,boolean:nt,date:at,datetime:lt,time:E,select:q,status:q,lookup:G,master_detail:G,email:it,url:ot,phone:ct,file:dt,image:ut,formula:ne,summary:ne,auto_number:E,user:J,owner:J,password:()=>t.jsx("span",{children:"••••••"}),location:E,object:()=>t.jsx("span",{className:"text-gray-500 italic",children:"[Object]"}),vector:()=>t.jsx("span",{className:"text-gray-500 italic",children:"[Vector]"}),grid:()=>t.jsx("span",{className:"text-gray-500 italic",children:"[Grid]"})}[e]||E}M("lookup",G);M("master_detail",G);M("select",q);M("status",q);M("user",J);M("owner",J);function or(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 cr(e){if(e<0||!Number.isFinite(e)||e===0)return"0 B";const r=["B","KB","MB","GB","TB"];let n=e,a=0;for(;n>=1024&&a<r.length-1;)n/=1024,a++;return`${n.toFixed(a>0?1:0)} ${r[a]}`}function dr(e){const r={};return e.required&&(r.required=typeof e.required_message=="string"?e.required_message:`${e.label||e.name} is required`),e.min_length&&(r.minLength={value:e.min_length,message:e.min_length_message||`Minimum length is ${e.min_length} characters`}),e.max_length&&(r.maxLength={value:e.max_length,message:e.max_length_message||`Maximum length is ${e.max_length} characters`}),e.min!==void 0&&(r.min={value:e.min,message:e.min_message||`Minimum value is ${e.min}`}),e.max!==void 0&&(r.max={value:e.max,message:e.max_message||`Maximum value is ${e.max}`}),e.pattern&&(r.pattern={value:typeof e.pattern=="string"?new RegExp(e.pattern):e.pattern,message:e.pattern_message||"Invalid format"}),e.type==="email"&&(r.pattern={value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:"Please enter a valid email address"}),e.type==="url"&&(r.pattern={value:/^https?:\/\/.+/,message:"Please enter a valid URL"}),e.validate&&(r.validate=e.validate),Object.keys(r).length>0?r:void 0}function le(e,r){if(!e)return!0;if(e.field&&e.value!==void 0){const n=r[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(n=>le(n,r)):e.or&&Array.isArray(e.or)?e.or.some(n=>le(n,r)):!0}function N(e){const r=({schema:n,className:a,value:s,...i})=>{const[l,o]=C.useState(s??n?.value??""),c={name:n?.name||"field",label:n?.label,type:n?.type,placeholder:n?.placeholder,required:n?.required,readonly:n?.readonly||n?.readOnly,help:n?.help,description:n?.description,defaultValue:n?.defaultValue||n?.value,...n},f=C.useCallback(p=>{o(p),i.onChange&&i.onChange(p)},[i]),h=n?.readonly||n?.readOnly||!1;return t.jsxs("div",{className:"grid w-full items-center gap-1.5","data-obj-id":n?.id,"data-obj-type":n?.type,children:[n?.label&&t.jsx("label",{htmlFor:n.id,className:n.required?"after:content-['*'] after:ml-0.5 after:text-red-500":"",children:n.label}),t.jsx(e,{value:l,onChange:f,field:c,readonly:h,className:a}),n?.description&&t.jsx("p",{className:"text-sm text-gray-500",children:n.description})]})};return r.displayName=`FieldRenderer(${e.displayName||e.name||"Component"})`,r}const mt={text:()=>Promise.resolve().then(()=>yt).then(e=>({default:e.TextField})),textarea:()=>Promise.resolve().then(()=>Pt).then(e=>({default:e.TextAreaField})),number:()=>Promise.resolve().then(()=>Nt).then(e=>({default:e.NumberField})),boolean:()=>Promise.resolve().then(()=>vt).then(e=>({default:e.BooleanField})),select:()=>Promise.resolve().then(()=>Ft).then(e=>({default:e.SelectField})),date:()=>Promise.resolve().then(()=>_t).then(e=>({default:e.DateField})),datetime:()=>Promise.resolve().then(()=>kt).then(e=>({default:e.DateTimeField})),time:()=>Promise.resolve().then(()=>At).then(e=>({default:e.TimeField})),email:()=>Promise.resolve().then(()=>Ct).then(e=>({default:e.EmailField})),phone:()=>Promise.resolve().then(()=>wt).then(e=>({default:e.PhoneField})),url:()=>Promise.resolve().then(()=>St).then(e=>({default:e.UrlField})),currency:()=>Promise.resolve().then(()=>Tt).then(e=>({default:e.CurrencyField})),percent:()=>Promise.resolve().then(()=>$t).then(e=>({default:e.PercentField})),password:()=>Promise.resolve().then(()=>Et).then(e=>({default:e.PasswordField})),markdown:()=>Promise.resolve().then(()=>Qe).then(e=>({default:e.RichTextField})),html:()=>Promise.resolve().then(()=>Qe).then(e=>({default:e.RichTextField})),lookup:()=>Promise.resolve().then(()=>Ot).then(e=>({default:e.LookupField})),master_detail:()=>Promise.resolve().then(()=>er).then(e=>({default:e.MasterDetailField})),file:()=>Promise.resolve().then(()=>zt).then(e=>({default:e.FileField})),image:()=>Promise.resolve().then(()=>Dt).then(e=>({default:e.ImageField})),location:()=>Promise.resolve().then(()=>Mt).then(e=>({default:e.LocationField})),formula:()=>Promise.resolve().then(()=>It).then(e=>({default:e.FormulaField})),summary:()=>Promise.resolve().then(()=>Lt).then(e=>({default:e.SummaryField})),auto_number:()=>Promise.resolve().then(()=>Ut).then(e=>({default:e.AutoNumberField})),user:()=>Promise.resolve().then(()=>Xe).then(e=>({default:e.UserField})),owner:()=>Promise.resolve().then(()=>Xe).then(e=>({default:e.UserField})),object:()=>Promise.resolve().then(()=>Bt).then(e=>({default:e.ObjectField})),vector:()=>Promise.resolve().then(()=>Vt).then(e=>({default:e.VectorField})),grid:()=>Promise.resolve().then(()=>Yt).then(e=>({default:e.GridField})),color:()=>Promise.resolve().then(()=>qt).then(e=>({default:e.ColorField})),slider:()=>Promise.resolve().then(()=>Gt).then(e=>({default:e.SliderField})),rating:()=>Promise.resolve().then(()=>Jt).then(e=>({default:e.RatingField})),code:()=>Promise.resolve().then(()=>Wt).then(e=>({default:e.CodeField})),avatar:()=>Promise.resolve().then(()=>Qt).then(e=>({default:e.AvatarField})),address:()=>Promise.resolve().then(()=>Xt).then(e=>({default:e.AddressField})),geolocation:()=>Promise.resolve().then(()=>Ht).then(e=>({default:e.GeolocationField})),signature:()=>Promise.resolve().then(()=>Zt).then(e=>({default:e.SignatureField})),qrcode:()=>Promise.resolve().then(()=>Kt).then(e=>({default:e.QRCodeField}))};function ft(e){const r=mt[e];if(!r){console.warn(`Unknown field type: ${e}`);return}const n=C.lazy(r);b.ComponentRegistry.register(e,n,{namespace:"field"})}function pt(){Object.keys(mt).forEach(e=>{ft(e)})}function ur(){b.ComponentRegistry.register("text",N(ie),{namespace:"field"}),b.ComponentRegistry.register("textarea",N(he),{namespace:"field"}),b.ComponentRegistry.register("number",N(oe),{namespace:"field"}),b.ComponentRegistry.register("boolean",N(ce),{namespace:"field"}),b.ComponentRegistry.register("select",N(de),{namespace:"field"}),b.ComponentRegistry.register("date",N(ue),{namespace:"field"}),b.ComponentRegistry.register("datetime",N(be),{namespace:"field"}),b.ComponentRegistry.register("time",N(je),{namespace:"field"}),b.ComponentRegistry.register("email",N(me),{namespace:"field"}),b.ComponentRegistry.register("phone",N(fe),{namespace:"field"}),b.ComponentRegistry.register("url",N(pe),{namespace:"field"}),b.ComponentRegistry.register("currency",N(xe),{namespace:"field"}),b.ComponentRegistry.register("percent",N(ye),{namespace:"field"}),b.ComponentRegistry.register("password",N(Ne),{namespace:"field"}),b.ComponentRegistry.register("markdown",N(H),{namespace:"field"}),b.ComponentRegistry.register("html",N(H),{namespace:"field"}),b.ComponentRegistry.register("lookup",N(ge),{namespace:"field"}),b.ComponentRegistry.register("master_detail",N(Le),{namespace:"field"}),b.ComponentRegistry.register("file",N(ve),{namespace:"field"}),b.ComponentRegistry.register("image",N(Fe),{namespace:"field"}),b.ComponentRegistry.register("location",N(_e),{namespace:"field"}),b.ComponentRegistry.register("formula",N(Ce),{namespace:"field"}),b.ComponentRegistry.register("summary",N(we),{namespace:"field"}),b.ComponentRegistry.register("auto_number",N(Se),{namespace:"field"}),b.ComponentRegistry.register("user",N(Z),{namespace:"field"}),b.ComponentRegistry.register("owner",N(Z),{namespace:"field"}),b.ComponentRegistry.register("object",N(Re),{namespace:"field"}),b.ComponentRegistry.register("vector",N(Te),{namespace:"field"}),b.ComponentRegistry.register("grid",N(Pe),{namespace:"field"}),b.ComponentRegistry.register("color",N(Oe),{namespace:"field"}),b.ComponentRegistry.register("slider",N(ke),{namespace:"field"}),b.ComponentRegistry.register("rating",N(Ae),{namespace:"field"}),b.ComponentRegistry.register("code",N($e),{namespace:"field"}),b.ComponentRegistry.register("avatar",N(Ee),{namespace:"field"}),b.ComponentRegistry.register("address",N(ze),{namespace:"field"}),b.ComponentRegistry.register("geolocation",N(De),{namespace:"field"}),b.ComponentRegistry.register("signature",N(Me),{namespace:"field"}),b.ComponentRegistry.register("qrcode",N(Ie),{namespace:"field"})}pt();exports.AddressField=ze;exports.AutoNumberField=Se;exports.AvatarField=Ee;exports.BooleanCellRenderer=nt;exports.BooleanField=ce;exports.CodeField=$e;exports.ColorField=Oe;exports.CurrencyCellRenderer=rt;exports.CurrencyField=xe;exports.DateCellRenderer=at;exports.DateField=ue;exports.DateTimeCellRenderer=lt;exports.DateTimeField=be;exports.EmailCellRenderer=it;exports.EmailField=me;exports.FileCellRenderer=dt;exports.FileField=ve;exports.FormulaCellRenderer=ne;exports.FormulaField=Ce;exports.GeolocationField=De;exports.GridField=Pe;exports.ImageCellRenderer=ut;exports.ImageField=Fe;exports.LocationField=_e;exports.LookupCellRenderer=G;exports.LookupField=ge;exports.MasterDetailField=Le;exports.NumberCellRenderer=tt;exports.NumberField=oe;exports.ObjectField=Re;exports.PasswordField=Ne;exports.PercentCellRenderer=st;exports.PercentField=ye;exports.PhoneCellRenderer=ct;exports.PhoneField=fe;exports.QRCodeField=Ie;exports.RatingField=Ae;exports.RichTextField=H;exports.SelectCellRenderer=q;exports.SelectField=de;exports.SignatureField=Me;exports.SliderField=ke;exports.SummaryField=we;exports.TextAreaField=he;exports.TextCellRenderer=E;exports.TextField=ie;exports.TimeField=je;exports.UrlCellRenderer=ot;exports.UrlField=pe;exports.UserCellRenderer=J;exports.UserField=Z;exports.VectorField=Te;exports.buildValidationRules=dr;exports.evaluateCondition=le;exports.formatCompactCurrency=tr;exports.formatCurrency=Ze;exports.formatDate=ee;exports.formatDateTime=rr;exports.formatFileSize=cr;exports.formatPercent=Ke;exports.formatRelativeDate=et;exports.getCellRenderer=ir;exports.humanizeLabel=K;exports.mapFieldTypeToFormType=or;exports.registerAllFields=pt;exports.registerField=ft;exports.registerFieldRenderer=M;exports.registerFields=ur;
|