@object-ui/plugin-form 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +21 -1
- package/dist/index.js +109 -66
- package/dist/index.umd.cjs +2 -2
- package/dist/packages/plugin-form/src/DrawerForm.d.ts +2 -0
- package/dist/packages/plugin-form/src/autoLayout.d.ts +11 -4
- package/package.json +42 -10
- package/.turbo/turbo-build.log +0 -32
- package/src/DrawerForm.tsx +0 -410
- package/src/EmbeddableForm.tsx +0 -240
- package/src/FormAnalytics.tsx +0 -209
- package/src/FormSection.tsx +0 -152
- package/src/FormVariants.test.tsx +0 -219
- package/src/ModalForm.tsx +0 -485
- package/src/ObjectForm.msw.test.tsx +0 -156
- package/src/ObjectForm.stories.tsx +0 -85
- package/src/ObjectForm.test.tsx +0 -61
- package/src/ObjectForm.tsx +0 -609
- package/src/SplitForm.tsx +0 -300
- package/src/TabbedForm.tsx +0 -395
- package/src/WizardForm.tsx +0 -502
- package/src/__tests__/EmbeddableFormPrefill.test.tsx +0 -186
- package/src/__tests__/MobileUX.test.tsx +0 -433
- package/src/__tests__/NewVariants.test.tsx +0 -684
- package/src/__tests__/autoLayout.test.ts +0 -339
- package/src/__tests__/form-validation-submit.test.tsx +0 -286
- package/src/autoLayout.ts +0 -166
- package/src/index.tsx +0 -134
- package/tsconfig.json +0 -9
- package/vite.config.ts +0 -58
- package/vitest.config.ts +0 -12
- package/vitest.setup.ts +0 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`@object-ui/core`),require(`@object-ui/react`),require(`@object-ui/fields`),require(`@object-ui/components`),require(`lucide-react`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/core`,`@object-ui/react`,`@object-ui/fields`,`@object-ui/components`,`lucide-react`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginForm={},e.React,e._object_ui_core,e._object_ui_react,e._object_ui_fields,e._object_ui_components,e.lucide_react))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:s(d(e)),m(t||!e||!e.__esModule?c(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var h=p((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),g=p((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===O?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(typeof e.tag==`number`&&console.error(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var n=e.render;return e=e.displayName,e||=(e=n.displayName||n.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return n=e.displayName||null,n===null?t(e.type)||`Memo`:n;case E:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function n(e){return``+e}function r(e){try{n(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,i=typeof Symbol==`function`&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||`Object`;return r.call(t,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,i),n(e)}}function i(e){if(e===_)return`<>`;if(typeof e==`object`&&e&&e.$$typeof===E)return`<...>`;try{var n=t(e);return n?`<`+n+`>`:`<...>`}catch{return`<...>`}}function a(){var e=k.A;return e===null?null:e.getOwner()}function o(){return Error(`react-stack-top-frame`)}function s(e){if(A.call(e,`key`)){var t=Object.getOwnPropertyDescriptor(e,`key`).get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function c(e,t){function n(){N||(N=!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)",t))}n.isReactWarning=!0,Object.defineProperty(e,`key`,{get:n,configurable:!0})}function l(){var e=t(this.type);return P[e]||(P[e]=!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.`)),e=this.props.ref,e===void 0?null:e}function u(e,t,n,r,i,a){var o=n.ref;return e={$$typeof:h,type:e,key:t,props:n,_owner:r},(o===void 0?null:o)===null?Object.defineProperty(e,`ref`,{enumerable:!1,value:null}):Object.defineProperty(e,`ref`,{enumerable:!1,get:l}),e._store={},Object.defineProperty(e._store,`validated`,{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,`_debugInfo`,{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,`_debugStack`,{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(e,`_debugTask`,{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function d(e,n,i,o,l,d){var p=n.children;if(p!==void 0)if(o)if(j(p)){for(o=0;o<p.length;o++)f(p[o]);Object.freeze&&Object.freeze(p)}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 f(p);if(A.call(n,`key`)){p=t(e);var m=Object.keys(n).filter(function(e){return e!==`key`});o=0<m.length?`{key: someKey, `+m.join(`: ..., `)+`: ...}`:`{key: someKey}`,L[p+o]||(m=0<m.length?`{`+m.join(`: ..., `)+`: ...}`:`{}`,console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`@object-ui/core`),require(`@object-ui/react`),require(`@object-ui/fields`),require(`@object-ui/components`),require(`lucide-react`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/core`,`@object-ui/react`,`@object-ui/fields`,`@object-ui/components`,`lucide-react`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginForm={},e.React,e._object_ui_core,e._object_ui_react,e._object_ui_fields,e._object_ui_components,e.lucide_react))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:s(d(e)),m(t||!e||!e.__esModule?c(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var h=p((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),g=p((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===O?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(typeof e.tag==`number`&&console.error(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var n=e.render;return e=e.displayName,e||=(e=n.displayName||n.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return n=e.displayName||null,n===null?t(e.type)||`Memo`:n;case E:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function n(e){return``+e}function r(e){try{n(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,i=typeof Symbol==`function`&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||`Object`;return r.call(t,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,i),n(e)}}function i(e){if(e===_)return`<>`;if(typeof e==`object`&&e&&e.$$typeof===E)return`<...>`;try{var n=t(e);return n?`<`+n+`>`:`<...>`}catch{return`<...>`}}function a(){var e=k.A;return e===null?null:e.getOwner()}function o(){return Error(`react-stack-top-frame`)}function s(e){if(A.call(e,`key`)){var t=Object.getOwnPropertyDescriptor(e,`key`).get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function c(e,t){function n(){N||(N=!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)",t))}n.isReactWarning=!0,Object.defineProperty(e,`key`,{get:n,configurable:!0})}function l(){var e=t(this.type);return P[e]||(P[e]=!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.`)),e=this.props.ref,e===void 0?null:e}function u(e,t,n,r,i,a){var o=n.ref;return e={$$typeof:h,type:e,key:t,props:n,_owner:r},(o===void 0?null:o)===null?Object.defineProperty(e,`ref`,{enumerable:!1,value:null}):Object.defineProperty(e,`ref`,{enumerable:!1,get:l}),e._store={},Object.defineProperty(e._store,`validated`,{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,`_debugInfo`,{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,`_debugStack`,{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(e,`_debugTask`,{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function d(e,n,i,o,l,d){var p=n.children;if(p!==void 0)if(o)if(j(p)){for(o=0;o<p.length;o++)f(p[o]);Object.freeze&&Object.freeze(p)}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 f(p);if(A.call(n,`key`)){p=t(e);var m=Object.keys(n).filter(function(e){return e!==`key`});o=0<m.length?`{key: someKey, `+m.join(`: ..., `)+`: ...}`:`{key: someKey}`,L[p+o]||(m=0<m.length?`{`+m.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} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),_=p(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=h():t.exports=g()}))(),v=({label:e,description:n,collapsible:r=!1,collapsed:i=!1,columns:s=1,children:c,className:l,gridClassName:u})=>{let[d,f]=(0,t.useState)(i);return(0,_.jsxs)(`div`,{className:(0,a.cn)(`form-section`,l),children:[(e||n)&&(0,_.jsxs)(`div`,{className:(0,a.cn)(`flex items-start gap-2 mb-4`,r&&`cursor-pointer select-none`),onClick:()=>{r&&f(!d)},role:r?`button`:void 0,"aria-expanded":r?!d:void 0,children:[r&&(0,_.jsx)(`span`,{className:`mt-0.5 text-muted-foreground`,children:d?(0,_.jsx)(o.ChevronRight,{className:`h-4 w-4`}):(0,_.jsx)(o.ChevronDown,{className:`h-4 w-4`})}),(0,_.jsxs)(`div`,{className:`flex-1`,children:[e&&(0,_.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:e}),n&&(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:n})]})]}),!d&&(0,_.jsx)(`div`,{className:(0,a.cn)(`grid gap-4`,u||{1:`grid-cols-1`,2:`grid-cols-1 md:grid-cols-2`,3:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`,4:`grid-cols-1 md:grid-cols-2 lg:grid-cols-4`}[s]),children:c})]})},y=({schema:e,dataSource:n,className:o})=>{let{fieldLabel:s}=(0,r.useSafeFieldLabel)(),[c,l]=(0,t.useState)(null),[u,d]=(0,t.useState)({}),[f,p]=(0,t.useState)(!0),[m,h]=(0,t.useState)(null),[g,y]=(0,t.useState)(e.defaultTab||e.sections[0]?.name||e.sections[0]?.label||`tab-0`);t.default.useEffect(()=>{(async()=>{if(!n){p(!1);return}try{l(await n.getObjectSchema(e.objectName))}catch(e){h(e)}})()},[e.objectName,n]),t.default.useEffect(()=>{(c||!n)&&(async()=>{if(e.mode===`create`||!e.recordId||!n){d(e.initialData||e.initialValues||{}),p(!1);return}try{d(await n.findOne(e.objectName,e.recordId)||{})}catch(e){h(e)}finally{p(!1)}})()},[c,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);let b=(0,t.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(c?.fields?.[t]){let r=c.fields[t];n.push({name:t,label:s(e.objectName,t,r.label||t),type:(0,i.mapFieldTypeToFormType)(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:(0,i.buildValidationRules)(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[c,e.readOnly,e.mode]),x=(0,t.useCallback)(async t=>{if(!n)return e.onSuccess&&await e.onSuccess(t),t;try{let r;return e.mode===`create`?r=await n.create(e.objectName,t):e.mode===`edit`&&e.recordId&&(r=await n.update(e.objectName,e.recordId,t)),e.onSuccess&&await e.onSuccess(r),r}catch(t){throw e.onError&&e.onError(t),t}},[e,n]),S=(0,t.useCallback)(()=>{e.onCancel&&e.onCancel()},[e]),C=(e,t)=>e.name||e.label||`tab-${t}`;if(m)return(0,_.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,_.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,_.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:m.message})]});if(f)return(0,_.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,_.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});let w={type:`form`,fields:e.sections.flatMap(e=>b(e)),layout:`vertical`,defaultValues:u,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText,showSubmit:e.showSubmit!==!1&&e.mode!==`view`,showCancel:e.showCancel!==!1,onSubmit:x,onCancel:S},T=e.tabPosition===`left`||e.tabPosition===`right`;return(0,_.jsx)(`div`,{className:(0,a.cn)(`w-full`,o,e.className),children:(0,_.jsxs)(a.Tabs,{value:g,onValueChange:y,orientation:T?`vertical`:`horizontal`,className:(0,a.cn)(T&&`flex gap-4`),children:[(0,_.jsx)(a.TabsList,{className:(0,a.cn)(T?`flex-col h-auto`:``,e.tabPosition===`bottom`&&`order-last`,e.tabPosition===`right`&&`order-last`),children:e.sections.map((e,t)=>(0,_.jsx)(a.TabsTrigger,{value:C(e,t),className:T?`w-full justify-start`:``,children:e.label||`Tab ${t+1}`},C(e,t)))}),(0,_.jsx)(`div`,{className:`flex-1`,children:e.sections.map((t,n)=>(0,_.jsx)(a.TabsContent,{value:C(t,n),className:`mt-0`,children:(0,_.jsx)(v,{description:t.description,columns:t.columns||1,children:(0,_.jsx)(r.SchemaRenderer,{schema:{...w,fields:b(t),showSubmit:e.showSubmit!==!1&&e.mode!==`view`,showCancel:e.showCancel!==!1}})})},C(t,n)))})]})})},b=({schema:e,dataSource:n,className:s})=>{let{fieldLabel:c}=(0,r.useSafeFieldLabel)(),[l,u]=(0,t.useState)(null),[d,f]=(0,t.useState)({}),[p,m]=(0,t.useState)(!0),[h,g]=(0,t.useState)(null),[y,b]=(0,t.useState)(0),[x,S]=(0,t.useState)(new Set),[C,w]=(0,t.useState)(!1),T=e.sections.length,E=y===0,D=y===T-1;t.default.useEffect(()=>{(async()=>{if(!n){m(!1);return}try{u(await n.getObjectSchema(e.objectName))}catch(e){g(e)}})()},[e.objectName,n]),t.default.useEffect(()=>{(l||!n)&&(async()=>{if(e.mode===`create`||!e.recordId||!n){f(e.initialData||e.initialValues||{}),m(!1);return}try{f(await n.findOne(e.objectName,e.recordId)||{})}catch(e){g(e)}finally{m(!1)}})()},[l,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);let O=(0,t.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(l?.fields?.[t]){let r=l.fields[t];n.push({name:t,label:c(e.objectName,t,r.label||t),type:(0,i.mapFieldTypeToFormType)(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:(0,i.buildValidationRules)(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[l,e.readOnly,e.mode]),k=(0,t.useMemo)(()=>y>=0&&y<T?O(e.sections[y]):[],[y,T,e.sections,O]),A=(0,t.useCallback)(async t=>{let r={...d,...t};if(f(r),S(e=>new Set(e).add(y)),D){w(!0);try{if(!n)return e.onSuccess&&await e.onSuccess(r),r;let t;return e.mode===`create`?t=await n.create(e.objectName,r):e.mode===`edit`&&e.recordId&&(t=await n.update(e.objectName,e.recordId,r)),e.onSuccess&&await e.onSuccess(t),t}catch(t){throw e.onError&&e.onError(t),t}finally{w(!1)}}else j(y+1)},[d,y,D,e,n]),j=(0,t.useCallback)(t=>{t>=0&&t<T&&(b(t),e.onStepChange&&e.onStepChange(t))},[T,e]),M=(0,t.useCallback)(()=>{j(y-1)},[y,j]),N=(0,t.useCallback)(()=>{e.onCancel&&e.onCancel()},[e]),P=(0,t.useCallback)(t=>{(e.allowSkip||x.has(t)||t<=y)&&j(t)},[e.allowSkip,x,y,j]);if(h)return(0,_.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,_.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,_.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:h.message})]});if(p)return(0,_.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,_.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});let F=e.sections[y];return(0,_.jsxs)(`div`,{className:(0,a.cn)(`w-full`,s,e.className),children:[e.showStepIndicator!==!1&&(0,_.jsx)(`nav`,{"aria-label":`Progress`,className:`mb-8`,children:(0,_.jsx)(`ol`,{className:`flex items-center`,children:e.sections.map((t,n)=>{let r=n===y,i=x.has(n),s=e.allowSkip||i||n<=y;return(0,_.jsxs)(`li`,{className:(0,a.cn)(`relative flex-1`,n!==T-1&&`pr-8 sm:pr-12`),children:[n!==T-1&&(0,_.jsx)(`div`,{className:`absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5`,"aria-hidden":`true`,children:(0,_.jsx)(`div`,{className:(0,a.cn)(`h-full`,i?`bg-primary`:`bg-muted`)})}),(0,_.jsxs)(`button`,{type:`button`,className:(0,a.cn)(`group relative flex items-center`,s?`cursor-pointer`:`cursor-not-allowed`),onClick:()=>P(n),disabled:!s,children:[(0,_.jsx)(`span`,{className:(0,a.cn)(`flex h-6 w-6 sm:h-8 sm:w-8 items-center justify-center rounded-full text-xs sm:text-sm font-medium transition-colors`,i&&`bg-primary text-primary-foreground`,r&&!i&&`border-2 border-primary bg-background text-primary`,!r&&!i&&`border-2 border-muted bg-background text-muted-foreground`),children:i?(0,_.jsx)(o.Check,{className:`h-3 w-3 sm:h-4 sm:w-4`}):n+1}),(0,_.jsx)(`span`,{className:`ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block`,children:(0,_.jsx)(`span`,{className:(0,a.cn)(r?`text-foreground`:`text-muted-foreground`),children:t.label||`Step ${n+1}`})})]})]},n)})})}),(0,_.jsx)(`div`,{className:`min-h-[200px]`,children:F&&(0,_.jsx)(v,{label:F.label,description:F.description,columns:F.columns||1,children:k.length>0?(0,_.jsx)(r.SchemaRenderer,{schema:{type:`form`,fields:k,layout:`vertical`,defaultValues:d,showSubmit:!1,showCancel:!1,onSubmit:A}}):(0,_.jsx)(`div`,{className:`text-center py-8 text-muted-foreground`,children:`No fields configured for this step`})})}),(0,_.jsxs)(`div`,{className:`flex items-center justify-between mt-6 pt-4 border-t`,children:[(0,_.jsx)(`div`,{children:e.showCancel!==!1&&(0,_.jsx)(a.Button,{variant:`ghost`,onClick:N,children:e.cancelText||`Cancel`})}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsxs)(`span`,{className:`text-sm text-muted-foreground mr-2`,children:[`Step `,y+1,` of `,T]}),!E&&(0,_.jsxs)(a.Button,{variant:`outline`,onClick:M,children:[(0,_.jsx)(o.ChevronLeft,{className:`h-4 w-4 mr-1`}),e.prevText||`Back`]}),D?(0,_.jsx)(a.Button,{onClick:()=>A(d),disabled:C||e.mode===`view`,children:C?`Submitting...`:e.submitText||(e.mode===`create`?`Create`:`Update`)}):(0,_.jsxs)(a.Button,{onClick:()=>A(d),children:[e.nextText||`Next`,(0,_.jsx)(o.ChevronRight,{className:`h-4 w-4 ml-1`})]})]})]})]})},x=({schema:e,dataSource:n,className:o})=>{let{fieldLabel:s}=(0,r.useSafeFieldLabel)(),[c,l]=(0,t.useState)(null),[u,d]=(0,t.useState)({}),[f,p]=(0,t.useState)(!0),[m,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(async()=>{if(!n){p(!1);return}try{l(await n.getObjectSchema(e.objectName))}catch(e){h(e),p(!1)}})()},[e.objectName,n]),(0,t.useEffect)(()=>{(c||!n)&&(async()=>{if(e.mode===`create`||!e.recordId){d(e.initialData||e.initialValues||{}),p(!1);return}if(!n){d(e.initialData||e.initialValues||{}),p(!1);return}try{d(await n.findOne(e.objectName,e.recordId)||{})}catch(e){h(e)}finally{p(!1)}})()},[c,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);let g=(0,t.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(c?.fields?.[t]){let r=c.fields[t];n.push({name:t,label:s(e.objectName,t,r.label||t),type:(0,i.mapFieldTypeToFormType)(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:(0,i.buildValidationRules)(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[c,e.readOnly,e.mode]),y=(0,t.useCallback)(async t=>{if(!n)return e.onSuccess&&await e.onSuccess(t),t;try{let r;return e.mode===`create`?r=await n.create(e.objectName,t):e.mode===`edit`&&e.recordId&&(r=await n.update(e.objectName,e.recordId,t)),e.onSuccess&&await e.onSuccess(r),r}catch(t){throw e.onError&&e.onError(t),t}},[e,n]),b=(0,t.useCallback)(()=>{e.onCancel&&e.onCancel()},[e]),x=(0,t.useMemo)(()=>e.sections.slice(0,1),[e.sections]),S=(0,t.useMemo)(()=>e.sections.slice(1),[e.sections]);(0,t.useMemo)(()=>e.sections.flatMap(e=>g(e)),[e.sections,g]);let C=e.splitDirection||`horizontal`,w=e.splitSize||50;if(m)return(0,_.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,_.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,_.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:m.message})]});if(f)return(0,_.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,_.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});let T={type:`form`,layout:`vertical`,defaultValues:u,onSubmit:y,onCancel:b},E=(t,n)=>(0,_.jsx)(`div`,{className:`space-y-4 p-4`,children:t.map((t,i)=>(0,_.jsx)(v,{label:t.label,description:t.description,columns:t.columns||1,children:(0,_.jsx)(r.SchemaRenderer,{schema:{...T,fields:g(t),showSubmit:n&&e.showSubmit!==!1&&e.mode!==`view`,showCancel:n&&e.showCancel!==!1,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText}})},t.name||t.label||i))});return(0,_.jsx)(`div`,{className:(0,a.cn)(`w-full`,o,e.className),children:(0,_.jsxs)(a.ResizablePanelGroup,{orientation:C,className:`min-h-[300px] rounded-lg border`,children:[(0,_.jsx)(a.ResizablePanel,{defaultSize:w,minSize:20,children:E(x,S.length===0)}),S.length>0&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(a.ResizableHandle,{withHandle:e.splitResizable!==!1}),(0,_.jsx)(a.ResizablePanel,{defaultSize:100-w,minSize:20,children:E(S,!0)})]})]})})},S=new Set([`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`,`textarea`,`markdown`,`html`,`grid`,`rich-text`]),C=new Set([`formula`,`summary`,`auto_number`,`autonumber`]);function w(e){return S.has(e)}function T(e){return C.has(e)}function E(e){return e<=3?1:2}function D(e,t){return t<=1?e:e.map(e=>e.colSpan===void 0&&e.type&&w(e.type)?{...e,colSpan:t}:e)}function O(e,t){return t?.fields?e.filter(e=>{let n=t.fields[e.name];return n?!T(n.type):!0}):e}function k(e){return e<=1?`default`:e===2?`xl`:`full`}function A(e,t,n,r){let i=[...e];if(r===`create`&&(i=O(i,t)),n!==void 0)return i=D(i,n),{fields:i,columns:n};let a=E(i.length);return i=D(i,a),{fields:i,columns:a}}var j={1:void 0,2:`grid gap-4 grid-cols-1 @md:grid-cols-2`,3:`grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3`,4:`grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4`},M=({schema:e,dataSource:n,className:o})=>{let{fieldLabel:s}=(0,r.useSafeFieldLabel)(),[c,l]=(0,t.useState)(null),[u,d]=(0,t.useState)([]),[f,p]=(0,t.useState)({}),[m,h]=(0,t.useState)(!0),[g,y]=(0,t.useState)(null),b=e.open!==!1,x=e.drawerSide||`right`;(0,t.useEffect)(()=>{(async()=>{if(!n){h(!1);return}try{l(await n.getObjectSchema(e.objectName))}catch(e){y(e),h(!1)}})()},[e.objectName,n]),(0,t.useEffect)(()=>{(c||!n)&&(async()=>{if(e.mode===`create`||!e.recordId){p(e.initialData||e.initialValues||{}),h(!1);return}if(!n){p(e.initialData||e.initialValues||{}),h(!1);return}try{p(await n.findOne(e.objectName,e.recordId)||{})}catch(e){y(e)}finally{h(!1)}})()},[c,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);let S=(0,t.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(c?.fields?.[t]){let r=c.fields[t];n.push({name:t,label:s(e.objectName,t,r.label||t),type:(0,i.mapFieldTypeToFormType)(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:(0,i.buildValidationRules)(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[c,e.readOnly,e.mode]);(0,t.useEffect)(()=>{if(!c&&n)return;if(e.customFields?.length){d(e.customFields),h(!1);return}if(e.sections?.length){h(!1);return}if(!c)return;let t=e.fields||Object.keys(c.fields||{}),r=[];for(let n of t){let t=typeof n==`string`?n:n.name;if(!t)continue;let a=c.fields?.[t];a&&r.push({name:t,label:s(e.objectName,t,a.label||t),type:(0,i.mapFieldTypeToFormType)(a.type),required:a.required||!1,disabled:e.readOnly||e.mode===`view`||a.readonly,placeholder:a.placeholder,description:a.help||a.description,validation:(0,i.buildValidationRules)(a),field:a,options:a.options,multiple:a.multiple})}d(r),h(!1)},[c,e.fields,e.customFields,e.sections,e.readOnly,e.mode,n]);let C=(0,t.useCallback)(async t=>{if(!n)return e.onSuccess&&await e.onSuccess(t),e.onOpenChange?.(!1),t;try{let r;return e.mode===`create`?r=await n.create(e.objectName,t):e.mode===`edit`&&e.recordId&&(r=await n.update(e.objectName,e.recordId,t)),e.onSuccess&&await e.onSuccess(r),e.onOpenChange?.(!1),r}catch(t){throw e.onError&&e.onError(t),t}},[e,n]),w=(0,t.useCallback)(()=>{e.onCancel&&e.onCancel(),e.onOpenChange?.(!1)},[e]),T=(0,t.useMemo)(()=>{if(e.drawerWidth)return x===`left`||x===`right`?{width:e.drawerWidth,maxWidth:e.drawerWidth}:{height:e.drawerWidth,maxHeight:e.drawerWidth}},[e.drawerWidth,x]),E={type:`form`,layout:e.layout===`vertical`||e.layout===`horizontal`?e.layout:`vertical`,defaultValues:f,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText,showSubmit:e.showSubmit!==!1&&e.mode!==`view`,showCancel:e.showCancel!==!1,onSubmit:C,onCancel:w};return(0,_.jsx)(a.Sheet,{open:b,onOpenChange:e.onOpenChange,children:(0,_.jsxs)(a.SheetContent,{side:x,className:(0,a.cn)(`overflow-y-auto`,o,e.className),style:T,children:[(e.title||e.description)&&(0,_.jsxs)(a.SheetHeader,{children:[e.title&&(0,_.jsx)(a.SheetTitle,{children:e.title}),e.description&&(0,_.jsx)(a.SheetDescription,{children:e.description})]}),(0,_.jsx)(`div`,{className:`@container py-4`,children:(()=>{if(g)return(0,_.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,_.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,_.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:g.message})]});if(m)return(0,_.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,_.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});if(e.sections?.length)return(0,_.jsx)(`div`,{className:`space-y-6`,children:e.sections.map((t,n)=>{let i=t.columns||1;return(0,_.jsx)(v,{label:t.label,description:t.description,columns:i,gridClassName:j[i],children:(0,_.jsx)(r.SchemaRenderer,{schema:{...E,fields:S(t),showSubmit:n===e.sections.length-1&&E.showSubmit,showCancel:n===e.sections.length-1&&E.showCancel}})},t.name||t.label||n)})});let t=A(u,c,e.columns,e.mode),n=j[t.columns||1];return(0,_.jsx)(r.SchemaRenderer,{schema:{...E,fields:t.fields,columns:t.columns,...n?{fieldContainerClass:n}:{}}})})()})]})})},N={sm:`sm:max-w-sm`,default:`sm:max-w-lg`,lg:`sm:max-w-2xl`,xl:`sm:max-w-5xl`,full:`sm:max-w-[95vw] sm:w-full`},P={1:void 0,2:`grid gap-4 grid-cols-1 @md:grid-cols-2`,3:`grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3`,4:`grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4`},F=({schema:e,dataSource:n,className:s})=>{let{fieldLabel:c}=(0,r.useSafeFieldLabel)(),[l,u]=(0,t.useState)(null),[d,f]=(0,t.useState)([]),[p,m]=(0,t.useState)({}),[h,g]=(0,t.useState)(!0),[y,b]=(0,t.useState)(null),[x,S]=(0,t.useState)(!1),C=e.open!==!1,w=(0,t.useId)(),T=(0,t.useMemo)(()=>e.sections?.length||e.customFields?.length?null:A(d,l,e.columns,e.mode),[d,l,e.columns,e.mode,e.sections,e.customFields]),E=N[(0,t.useMemo)(()=>{if(e.modalSize)return e.modalSize;if(T?.columns&&T.columns>1)return k(T.columns);if(e.sections?.length){let t=Math.max(...e.sections.map(e=>Number(e.columns)||1));if(t>1)return k(t)}return`default`},[e.modalSize,T,e.sections])]||N.default;(0,t.useEffect)(()=>{(async()=>{if(!n){g(!1);return}try{u(await n.getObjectSchema(e.objectName))}catch(e){b(e),g(!1)}})()},[e.objectName,n]),(0,t.useEffect)(()=>{(l||!n)&&(async()=>{if(e.mode===`create`||!e.recordId){m(e.initialData||e.initialValues||{}),g(!1);return}if(!n){m(e.initialData||e.initialValues||{}),g(!1);return}try{m(await n.findOne(e.objectName,e.recordId)||{})}catch(e){b(e)}finally{g(!1)}})()},[l,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);let D=(0,t.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(l?.fields?.[t]){let r=l.fields[t];n.push({name:t,label:c(e.objectName,t,r.label||t),type:(0,i.mapFieldTypeToFormType)(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:(0,i.buildValidationRules)(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[l,e.readOnly,e.mode]);(0,t.useEffect)(()=>{if(!l&&n)return;if(e.customFields?.length){f(e.customFields),g(!1);return}if(e.sections?.length){g(!1);return}if(!l)return;let t=e.fields||Object.keys(l.fields||{}),r=[];for(let n of t){let t=typeof n==`string`?n:n.name;if(!t)continue;let a=l.fields?.[t];a&&r.push({name:t,label:c(e.objectName,t,a.label||t),type:(0,i.mapFieldTypeToFormType)(a.type),required:a.required||!1,disabled:e.readOnly||e.mode===`view`||a.readonly,placeholder:a.placeholder,description:a.help||a.description,validation:(0,i.buildValidationRules)(a),field:a,options:a.options,multiple:a.multiple})}f(r),g(!1)},[l,e.fields,e.customFields,e.sections,e.readOnly,e.mode,n]);let O=(0,t.useCallback)(async t=>{S(!0);try{if(!n)return e.onSuccess&&await e.onSuccess(t),e.onOpenChange?.(!1),t;let r;return e.mode===`create`?r=await n.create(e.objectName,t):e.mode===`edit`&&e.recordId&&(r=await n.update(e.objectName,e.recordId,t)),e.onSuccess&&await e.onSuccess(r),e.onOpenChange?.(!1),r}catch(t){throw e.onError&&e.onError(t),t}finally{S(!1)}},[e,n]),j=(0,t.useCallback)(()=>{e.onCancel&&e.onCancel(),e.onOpenChange?.(!1)},[e]),M=e.layout===`vertical`||e.layout===`horizontal`?e.layout:`vertical`,F=e.showSubmit!==!1&&e.mode!==`view`,I=e.showCancel!==!1,L=e.submitText||(e.mode===`create`?`Create`:`Update`),R=e.cancelText||`Cancel`,z={type:`form`,layout:M,defaultValues:p,submitLabel:L,cancelLabel:R,showSubmit:F,showCancel:I,onSubmit:O,onCancel:j,showActions:!1,id:w},B=()=>{if(y)return(0,_.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,_.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,_.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:y.message})]});if(h)return(0,_.jsx)(`div`,{className:`space-y-4`,"data-testid":`modal-form-skeleton`,children:[1,2,3].map(e=>(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(a.Skeleton,{className:`h-4 w-24`}),(0,_.jsx)(a.Skeleton,{className:`h-10 w-full`})]},e))});if(e.sections?.length)return(0,_.jsx)(`div`,{className:`space-y-6`,children:e.sections.map((e,t)=>{let n=e.columns||1;return(0,_.jsx)(v,{label:e.label,description:e.description,columns:n,gridClassName:P[n],children:(0,_.jsx)(r.SchemaRenderer,{schema:{...z,fields:D(e)}})},e.name||e.label||t)})});let t=T??A(d,l,e.columns,e.mode),n=P[t.columns||1];return(0,_.jsx)(r.SchemaRenderer,{schema:{...z,fields:t.fields,columns:t.columns,...n?{fieldContainerClass:n}:{}}})},V=!h&&!y&&(F||I);return(0,_.jsx)(a.Dialog,{open:C,onOpenChange:e.onOpenChange,children:(0,_.jsxs)(a.MobileDialogContent,{className:(0,a.cn)(E,`flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0`,s,e.className),children:[(e.title||e.description)&&(0,_.jsxs)(a.DialogHeader,{className:`shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b`,children:[e.title&&(0,_.jsx)(a.DialogTitle,{children:e.title}),e.description&&(0,_.jsx)(a.DialogDescription,{children:e.description})]}),(0,_.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-4 sm:px-6 py-4`,children:B()}),V&&(0,_.jsx)(`div`,{className:`shrink-0 border-t px-4 sm:px-6 py-3 bg-background`,"data-testid":`modal-form-footer`,children:(0,_.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2 sm:justify-end`,children:[I&&(0,_.jsx)(a.Button,{type:`button`,variant:`outline`,onClick:j,disabled:x,className:`w-full sm:w-auto`,children:R}),F&&(0,_.jsxs)(a.Button,{type:`submit`,form:w,disabled:x,className:`w-full sm:w-auto`,children:[x&&(0,_.jsx)(o.Loader2,{className:`mr-2 h-4 w-4 animate-spin`}),L]})]})})]})})},I=({schema:e,dataSource:t})=>{if(e.formType===`tabbed`&&e.sections?.length)return(0,_.jsx)(y,{schema:{...e,formType:`tabbed`,sections:e.sections.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields})),defaultTab:e.defaultTab,tabPosition:e.tabPosition},dataSource:t,className:e.className});if(e.formType===`wizard`&&e.sections?.length)return(0,_.jsx)(b,{schema:{...e,formType:`wizard`,sections:e.sections.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields})),allowSkip:e.allowSkip,showStepIndicator:e.showStepIndicator,nextText:e.nextText,prevText:e.prevText,onStepChange:e.onStepChange},dataSource:t,className:e.className});if(e.formType===`split`&&e.sections?.length)return(0,_.jsx)(x,{schema:{...e,formType:`split`,sections:e.sections.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields})),splitDirection:e.splitDirection,splitSize:e.splitSize,splitResizable:e.splitResizable},dataSource:t,className:e.className});if(e.formType===`drawer`){let{layout:n,...r}=e,i=e.layout===`vertical`||e.layout===`horizontal`?e.layout:void 0;return(0,_.jsx)(M,{schema:{...r,layout:i,formType:`drawer`,sections:e.sections?.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields})),open:e.open,onOpenChange:e.onOpenChange,drawerSide:e.drawerSide,drawerWidth:e.drawerWidth},dataSource:t,className:e.className})}if(e.formType===`modal`){let{layout:n,...r}=e,i=e.layout===`vertical`||e.layout===`horizontal`?e.layout:void 0;return(0,_.jsx)(F,{schema:{...r,layout:i,formType:`modal`,sections:e.sections?.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields})),open:e.open,onOpenChange:e.onOpenChange,modalSize:e.modalSize,modalCloseButton:e.modalCloseButton},dataSource:t,className:e.className})}return(0,_.jsx)(L,{schema:e,dataSource:t})},L=({schema:e,dataSource:n})=>{let{fieldLabel:a}=(0,r.useSafeFieldLabel)(),[o,s]=(0,t.useState)(null),[c,l]=(0,t.useState)([]),[u,d]=(0,t.useState)(null),[f,p]=(0,t.useState)(!0),[m,h]=(0,t.useState)(null),g=e.customFields&&e.customFields.length>0;(0,t.useEffect)(()=>{g&&(d(e.initialData||e.initialValues||{}),p(!1))},[g,e.initialData,e.initialValues]),(0,t.useEffect)(()=>{g?s({name:e.objectName,fields:{}}):e.objectName&&n?(async()=>{try{if(!n)throw Error(`DataSource is required when using ObjectQL schema fetching (inline fields not provided)`);let t=await n.getObjectSchema(e.objectName);if(!t)throw Error(`No schema found for object "${e.objectName}"`);s(t)}catch(e){h(e),p(!1)}})():g||p(!1)},[e.objectName,n,g]),(0,t.useEffect)(()=>{o&&!g&&(async()=>{if(!e.recordId||e.mode===`create`){d(e.initialData||e.initialValues||{}),p(!1);return}if(!g){if(!n){h(Error(`DataSource is required for fetching record data (inline data not provided)`)),p(!1);return}p(!0);try{d(await n.findOne(e.objectName,e.recordId))}catch(e){console.error(`Failed to fetch record:`,e),h(e)}finally{p(!1)}}})()},[e.objectName,e.recordId,e.mode,e.initialValues,e.initialData,n,o,g]),(0,t.useEffect)(()=>{if(g&&e.customFields){l(e.customFields),p(!1);return}if(!o)return;let t=[],r=e.fields||Object.keys(o.fields||{});(Array.isArray(r)?r:Object.keys(r)).forEach(n=>{let r=typeof n==`string`?n:n.name;if(!r)return;let s=o.fields?.[r];if(!s&&!g)return;let c=!s?.permissions||s?.permissions.write!==!1;if(e.mode!==`view`&&!c)return;let l=e.customFields?.find(e=>e.name===r);if(l)t.push(l);else if(s){let o={name:r,label:a(e.objectName,r,s.label||n),type:(0,i.mapFieldTypeToFormType)(s.type),required:s.required||!1,disabled:e.readOnly||e.mode===`view`||s.readonly,placeholder:s.placeholder,description:s.help||s.description,validation:(0,i.buildValidationRules)(s),field:s};if((s.type===`select`||s.type===`lookup`||s.type===`master_detail`)&&(o.options=s.options||[],o.multiple=s.multiple),(s.type===`number`||s.type===`currency`||s.type===`percent`)&&(o.inputType=`number`,o.min=s.min,o.max=s.max,o.step=s.precision?10**-s.precision:void 0),s.type===`date`&&(o.inputType=`date`),s.type===`datetime`&&(o.inputType=`datetime-local`),(s.type===`text`||s.type===`textarea`||s.type===`markdown`||s.type===`html`)&&(o.maxLength=s.max_length,o.minLength=s.min_length),(s.type===`file`||s.type===`image`)&&(o.inputType=`file`,o.multiple=s.multiple,o.accept=s.accept?s.accept.join(`,`):void 0,s.max_size)){let e=`Max size: ${(0,i.formatFileSize)(s.max_size)}`;o.description=o.description?`${o.description} (${e})`:e}s.type===`email`&&(o.inputType=`email`),s.type===`phone`&&(o.inputType=`tel`),s.type===`url`&&(o.inputType=`url`),s.type===`password`&&(o.inputType=`password`),s.type===`time`&&(o.inputType=`time`),(s.type===`formula`||s.type===`summary`||s.type===`auto_number`)&&(o.disabled=!0),s.visible_on&&(o.visible=e=>(0,i.evaluateCondition)(s.visible_on,e)),t.push(o)}}),l(t),!g&&e.recordId&&e.mode!==`create`&&n||p(!1)},[o,e.fields,e.customFields,e.readOnly,e.mode,g,e.recordId,n]);let y=(0,t.useCallback)(async(t,r)=>{if(t&&(t.nativeEvent||t._reactName===`onSubmit`)&&(console.warn(`ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue.`),r===void 0&&(r=t,t={})),g&&!n)return e.onSuccess&&await e.onSuccess(t),t;if(!n)throw Error(`DataSource is required for form submission (inline mode not configured)`);try{let r;if(e.mode===`create`)r=await n.create(e.objectName,t);else if(e.mode===`edit`&&e.recordId)r=await n.update(e.objectName,e.recordId,t);else throw Error(`Invalid form mode or missing record ID`);return e.onSuccess&&await e.onSuccess(r),r}catch(t){throw console.error(`Failed to submit form:`,t),e.onError&&e.onError(t),t}},[e,n,g]),b=(0,t.useCallback)(()=>{e.onCancel&&e.onCancel()},[e]),x={...t.default.useMemo(()=>{if(!o?.fields)return{};let e={};return Object.keys(o.fields).forEach(t=>{let n=o.fields[t];n.defaultValue!==void 0&&(e[t]=n.defaultValue)}),e},[o]),...u};if(m)return(0,_.jsxs)(`div`,{className:`p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,_.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,_.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:m.message})]});if(f)return(0,_.jsxs)(`div`,{className:`p-4 sm:p-8 text-center`,children:[(0,_.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});let S=e.layout===`vertical`||e.layout===`horizontal`?e.layout:`vertical`;if(e.sections?.length&&(!e.formType||e.formType===`simple`))return(0,_.jsx)(`div`,{className:`w-full space-y-6`,children:e.sections.map((t,n)=>{let i=t.fields.map(e=>typeof e==`string`?e:e.name),a=c.filter(e=>i.includes(e.name));return(0,_.jsx)(v,{label:t.label,description:t.description,collapsible:t.collapsible,collapsed:t.collapsed,columns:t.columns,children:(0,_.jsx)(r.SchemaRenderer,{schema:{type:`form`,fields:a,layout:S,defaultValues:x,showSubmit:n===e.sections.length-1&&e.showSubmit!==!1&&e.mode!==`view`,showCancel:n===e.sections.length-1&&e.showCancel!==!1,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText,onSubmit:y,onCancel:b}})},t.name||t.label||n)})});let C=e.sections?.length?{fields:c,columns:e.columns}:A(c,o,e.columns,e.mode);return(0,_.jsx)(`div`,{className:`w-full`,children:(0,_.jsx)(r.SchemaRenderer,{schema:{type:`form`,fields:C.fields,layout:S,columns:C.columns,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText,showSubmit:e.showSubmit!==!1&&e.mode!==`view`,showCancel:e.showCancel!==!1,resetOnSubmit:e.showReset,defaultValues:x,onSubmit:y,onCancel:b,className:e.className}})})},R=({config:e,dataSource:n,prefillParams:r,className:i})=>{let[a,o]=(0,t.useState)(!1),[s,c]=(0,t.useState)(!1),[l,u]=(0,t.useState)(null),d=(0,t.useMemo)(()=>{let e={};if(r)for(let[t,n]of Object.entries(r))e[t]=n;return typeof window<`u`&&new URLSearchParams(window.location.search).forEach((t,n)=>{n in e||(e[n]=t)}),Object.keys(e).length>0?e:void 0},[r]),f=(0,t.useCallback)(async t=>{c(!0),u(null);try{if(n&&await n.create(e.objectName,t),o(!0),e.thankYouPage?.redirectUrl){let t=e.thankYouPage.redirectDelay??3e3;setTimeout(()=>{window.location.href=e.thankYouPage.redirectUrl},t)}}catch(e){u(e instanceof Error?e.message:`Failed to submit form. Please try again.`)}finally{c(!1)}},[n,e]),p=(0,t.useCallback)(()=>{o(!1),u(null)},[]),m=(0,t.useMemo)(()=>{let t={};return e.branding?.backgroundColor&&(t.backgroundColor=e.branding.backgroundColor),t},[e.branding]);if(a){let t=e.thankYouPage;return(0,_.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-4 ${i||``}`,style:m,children:(0,_.jsxs)(`div`,{className:`max-w-md w-full bg-card rounded-lg shadow-lg p-8 text-center space-y-4`,children:[(0,_.jsx)(`div`,{className:`text-4xl`,children:`✓`}),(0,_.jsx)(`h2`,{className:`text-xl font-semibold text-foreground`,children:t?.title||`Thank You!`}),(0,_.jsx)(`p`,{className:`text-muted-foreground`,children:t?.message||`Your submission has been received successfully.`}),e.allowMultiple&&(0,_.jsx)(`button`,{onClick:p,className:`mt-4 px-4 py-2 text-sm font-medium rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors`,children:`Submit Another Response`}),t?.redirectUrl&&(0,_.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Redirecting in `,Math.ceil((t.redirectDelay??3e3)/1e3),` seconds...`]})]})})}return(0,_.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-4 ${i||``}`,style:m,children:(0,_.jsxs)(`div`,{className:`max-w-2xl w-full bg-card rounded-lg shadow-lg overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`p-6 border-b`,style:e.branding?.primaryColor?{borderBottomColor:e.branding.primaryColor}:void 0,children:[e.branding?.logo&&(0,_.jsx)(`img`,{src:e.branding.logo,alt:`Logo`,className:`h-8 mb-4`}),e.title&&(0,_.jsx)(`h1`,{className:`text-xl font-semibold text-foreground`,children:e.title}),e.description&&(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description})]}),(0,_.jsxs)(`div`,{className:`p-6`,children:[l&&(0,_.jsx)(`div`,{className:`mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive`,children:l}),(0,_.jsx)(I,{schema:{type:`object-form`,objectName:e.objectName,mode:`create`,fields:e.fields,customFields:e.customFields,initialData:d,onSuccess:f,submitLabel:s?`Submitting...`:`Submit`},dataSource:n})]}),(0,_.jsx)(`div`,{className:`px-6 py-3 border-t bg-muted/20 text-center`,children:(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Powered by ObjectStack`})})]})})};function z(e){return e<60?`${Math.round(e)}s`:e<3600?`${Math.floor(e/60)}m ${Math.round(e%60)}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}var B=({formId:e,formTitle:n,metrics:r,className:i})=>{let o=(0,t.useMemo)(()=>{if(!r.abandonedSubmissions)return 100;let e=r.totalSubmissions+r.abandonedSubmissions;return e===0?0:Math.round(r.totalSubmissions/e*100)},[r.totalSubmissions,r.abandonedSubmissions]),s=(0,t.useMemo)(()=>r.dailySubmissions?.length?Math.max(...r.dailySubmissions.map(e=>e.count),1):1,[r.dailySubmissions]);return(0,_.jsxs)(`div`,{className:`space-y-4 ${i||``}`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:n||`Form Analytics`}),(0,_.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Form ID: `,e]})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,_.jsx)(a.Card,{children:(0,_.jsxs)(a.CardHeader,{className:`pb-2`,children:[(0,_.jsx)(a.CardDescription,{children:`Total Submissions`}),(0,_.jsx)(a.CardTitle,{className:`text-2xl`,children:r.totalSubmissions.toLocaleString()})]})}),(0,_.jsxs)(a.Card,{children:[(0,_.jsxs)(a.CardHeader,{className:`pb-2`,children:[(0,_.jsx)(a.CardDescription,{children:`Fill Rate`}),(0,_.jsxs)(a.CardTitle,{className:`text-2xl`,children:[o,`%`]})]}),(0,_.jsx)(a.CardContent,{children:(0,_.jsx)(`div`,{className:`w-full bg-muted rounded-full h-2`,children:(0,_.jsx)(`div`,{className:`bg-primary rounded-full h-2 transition-all`,style:{width:`${o}%`}})})})]}),(0,_.jsx)(a.Card,{children:(0,_.jsxs)(a.CardHeader,{className:`pb-2`,children:[(0,_.jsx)(a.CardDescription,{children:`Avg. Completion Time`}),(0,_.jsx)(a.CardTitle,{className:`text-2xl`,children:r.avgCompletionTime?z(r.avgCompletionTime):`—`})]})})]}),r.dailySubmissions&&r.dailySubmissions.length>0&&(0,_.jsxs)(a.Card,{children:[(0,_.jsx)(a.CardHeader,{children:(0,_.jsx)(a.CardTitle,{className:`text-sm font-medium`,children:`Daily Submissions`})}),(0,_.jsx)(a.CardContent,{children:(0,_.jsx)(`div`,{className:`flex items-end gap-1 h-32`,children:r.dailySubmissions.map((e,t)=>(0,_.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-1`,children:[(0,_.jsx)(`div`,{className:`w-full bg-primary/80 rounded-t transition-all hover:bg-primary`,style:{height:`${e.count/s*100}%`,minHeight:e.count>0?`4px`:`0`},title:`${e.date}: ${e.count} submissions`}),(0,_.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate w-full text-center`,children:e.date.slice(-5)})]},t))})})]}),r.fieldDropOff&&r.fieldDropOff.length>0&&(0,_.jsxs)(a.Card,{children:[(0,_.jsxs)(a.CardHeader,{children:[(0,_.jsx)(a.CardTitle,{className:`text-sm font-medium`,children:`Field Completion Rates`}),(0,_.jsx)(a.CardDescription,{children:`Percentage of users who completed each field`})]}),(0,_.jsx)(a.CardContent,{children:(0,_.jsx)(`div`,{className:`space-y-3`,children:r.fieldDropOff.map((e,t)=>(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,_.jsx)(`span`,{className:`text-foreground`,children:e.label}),(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.completionRate,`%`]})]}),(0,_.jsx)(`div`,{className:`w-full bg-muted rounded-full h-1.5`,children:(0,_.jsx)(`div`,{className:`rounded-full h-1.5 transition-all ${e.completionRate>=80?`bg-green-500`:e.completionRate>=50?`bg-yellow-500`:`bg-destructive`}`,style:{width:`${e.completionRate}%`}})})]},t))})})]})]})},V=({schema:e})=>(0,_.jsx)(I,{schema:e});n.ComponentRegistry.register(`object-form`,V,{namespace:`plugin-form`,label:`Object Form`,category:`plugin`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`fields`,type:`array`,label:`Fields`},{name:`mode`,type:`enum`,label:`Mode`,enum:[`create`,`edit`,`view`]},{name:`formType`,type:`enum`,label:`Form Type`,enum:[`simple`,`tabbed`,`wizard`,`split`,`drawer`,`modal`]},{name:`sections`,type:`array`,label:`Sections`},{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`vertical`,`horizontal`,`inline`,`grid`]},{name:`columns`,type:`number`,label:`Columns`},{name:`defaultTab`,type:`string`,label:`Default Tab`},{name:`tabPosition`,type:`enum`,label:`Tab Position`,enum:[`top`,`bottom`,`left`,`right`]},{name:`allowSkip`,type:`boolean`,label:`Allow Skip Steps`},{name:`showStepIndicator`,type:`boolean`,label:`Show Step Indicator`},{name:`splitDirection`,type:`enum`,label:`Split Direction`,enum:[`horizontal`,`vertical`]},{name:`splitSize`,type:`number`,label:`Split Panel Size (%)`},{name:`splitResizable`,type:`boolean`,label:`Split Resizable`},{name:`drawerSide`,type:`enum`,label:`Drawer Side`,enum:[`top`,`bottom`,`left`,`right`]},{name:`drawerWidth`,type:`string`,label:`Drawer Width`},{name:`modalSize`,type:`enum`,label:`Modal Size`,enum:[`sm`,`default`,`lg`,`xl`,`full`]}]}),n.ComponentRegistry.register(`form`,V,{namespace:`view`,skipFallback:!0,label:`Data Form View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`fields`,type:`array`,label:`Fields`},{name:`mode`,type:`enum`,label:`Mode`,enum:[`create`,`edit`,`view`]}]}),n.ComponentRegistry.register(`embeddable-form`,({schema:e})=>(0,_.jsx)(R,{config:e}),{namespace:`plugin-form`,label:`Embeddable Form`,category:`plugin`,inputs:[{name:`formId`,type:`string`,label:`Form ID`,required:!0},{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`title`,type:`string`,label:`Form Title`},{name:`description`,type:`string`,label:`Description`},{name:`fields`,type:`array`,label:`Fields`},{name:`allowMultiple`,type:`boolean`,label:`Allow Multiple Submissions`}]}),n.ComponentRegistry.register(`form-analytics`,({schema:e})=>(0,_.jsx)(B,{formId:e.formId,formTitle:e.formTitle,metrics:e.metrics||{totalSubmissions:0}}),{namespace:`plugin-form`,label:`Form Analytics`,category:`plugin`,inputs:[{name:`formId`,type:`string`,label:`Form ID`,required:!0},{name:`formTitle`,type:`string`,label:`Form Title`},{name:`metrics`,type:`object`,label:`Submission Metrics`}]}),e.DrawerForm=M,e.EmbeddableForm=R,e.FormAnalytics=B,e.FormSection=v,e.ModalForm=F,e.ObjectForm=I,e.SplitForm=x,e.TabbedForm=y,e.WizardForm=b,e.applyAutoColSpan=D,e.applyAutoLayout=A,e.filterCreateModeFields=O,e.inferColumns=E,e.inferModalSize=k,e.isAutoGeneratedFieldType=T,e.isWideFieldType=w});
|
|
6
|
+
<%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),_=p(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=h():t.exports=g()}))(),v=({label:e,description:n,collapsible:r=!1,collapsed:i=!1,columns:s=1,children:c,className:l,gridClassName:u})=>{let[d,f]=(0,t.useState)(i);return(0,_.jsxs)(`div`,{className:(0,a.cn)(`form-section`,l),children:[(e||n)&&(0,_.jsxs)(`div`,{className:(0,a.cn)(`flex items-start gap-2 mb-4`,r&&`cursor-pointer select-none`),onClick:()=>{r&&f(!d)},role:r?`button`:void 0,"aria-expanded":r?!d:void 0,children:[r&&(0,_.jsx)(`span`,{className:`mt-0.5 text-muted-foreground`,children:d?(0,_.jsx)(o.ChevronRight,{className:`h-4 w-4`}):(0,_.jsx)(o.ChevronDown,{className:`h-4 w-4`})}),(0,_.jsxs)(`div`,{className:`flex-1`,children:[e&&(0,_.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:e}),n&&(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:n})]})]}),!d&&(0,_.jsx)(`div`,{className:(0,a.cn)(`grid gap-4`,u||{1:`grid-cols-1`,2:`grid-cols-1 md:grid-cols-2`,3:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`,4:`grid-cols-1 md:grid-cols-2 lg:grid-cols-4`}[s]),children:c})]})},y=({schema:e,dataSource:n,className:o})=>{let{fieldLabel:s}=(0,r.useSafeFieldLabel)(),[c,l]=(0,t.useState)(null),[u,d]=(0,t.useState)({}),[f,p]=(0,t.useState)(!0),[m,h]=(0,t.useState)(null),[g,y]=(0,t.useState)(e.defaultTab||e.sections[0]?.name||e.sections[0]?.label||`tab-0`);t.default.useEffect(()=>{(async()=>{if(!n){p(!1);return}try{l(await n.getObjectSchema(e.objectName))}catch(e){h(e)}})()},[e.objectName,n]),t.default.useEffect(()=>{(c||!n)&&(async()=>{if(e.mode===`create`||!e.recordId||!n){d(e.initialData||e.initialValues||{}),p(!1);return}try{d(await n.findOne(e.objectName,e.recordId)||{})}catch(e){h(e)}finally{p(!1)}})()},[c,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);let b=(0,t.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(c?.fields?.[t]){let r=c.fields[t];n.push({name:t,label:s(e.objectName,t,r.label||t),type:(0,i.mapFieldTypeToFormType)(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:(0,i.buildValidationRules)(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[c,e.readOnly,e.mode]),x=(0,t.useCallback)(async t=>{if(!n)return e.onSuccess&&await e.onSuccess(t),t;try{let r;return e.mode===`create`?r=await n.create(e.objectName,t):e.mode===`edit`&&e.recordId&&(r=await n.update(e.objectName,e.recordId,t)),e.onSuccess&&await e.onSuccess(r),r}catch(t){throw e.onError&&e.onError(t),t}},[e,n]),S=(0,t.useCallback)(()=>{e.onCancel&&e.onCancel()},[e]),C=(e,t)=>e.name||e.label||`tab-${t}`;if(m)return(0,_.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,_.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,_.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:m.message})]});if(f)return(0,_.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,_.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});let w={type:`form`,fields:e.sections.flatMap(e=>b(e)),layout:`vertical`,defaultValues:u,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText,showSubmit:e.showSubmit!==!1&&e.mode!==`view`,showCancel:e.showCancel!==!1,onSubmit:x,onCancel:S},T=e.tabPosition===`left`||e.tabPosition===`right`;return(0,_.jsx)(`div`,{className:(0,a.cn)(`w-full`,o,e.className),children:(0,_.jsxs)(a.Tabs,{value:g,onValueChange:y,orientation:T?`vertical`:`horizontal`,className:(0,a.cn)(T&&`flex gap-4`),children:[(0,_.jsx)(a.TabsList,{className:(0,a.cn)(T?`flex-col h-auto`:``,e.tabPosition===`bottom`&&`order-last`,e.tabPosition===`right`&&`order-last`),children:e.sections.map((e,t)=>(0,_.jsx)(a.TabsTrigger,{value:C(e,t),className:T?`w-full justify-start`:``,children:e.label||`Tab ${t+1}`},C(e,t)))}),(0,_.jsx)(`div`,{className:`flex-1`,children:e.sections.map((t,n)=>(0,_.jsx)(a.TabsContent,{value:C(t,n),className:`mt-0`,children:(0,_.jsx)(v,{description:t.description,columns:t.columns||1,children:(0,_.jsx)(r.SchemaRenderer,{schema:{...w,fields:b(t),showSubmit:e.showSubmit!==!1&&e.mode!==`view`,showCancel:e.showCancel!==!1}})})},C(t,n)))})]})})},b=({schema:e,dataSource:n,className:s})=>{let{fieldLabel:c}=(0,r.useSafeFieldLabel)(),[l,u]=(0,t.useState)(null),[d,f]=(0,t.useState)({}),[p,m]=(0,t.useState)(!0),[h,g]=(0,t.useState)(null),[y,b]=(0,t.useState)(0),[x,S]=(0,t.useState)(new Set),[C,w]=(0,t.useState)(!1),T=e.sections.length,E=y===0,D=y===T-1;t.default.useEffect(()=>{(async()=>{if(!n){m(!1);return}try{u(await n.getObjectSchema(e.objectName))}catch(e){g(e)}})()},[e.objectName,n]),t.default.useEffect(()=>{(l||!n)&&(async()=>{if(e.mode===`create`||!e.recordId||!n){f(e.initialData||e.initialValues||{}),m(!1);return}try{f(await n.findOne(e.objectName,e.recordId)||{})}catch(e){g(e)}finally{m(!1)}})()},[l,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);let O=(0,t.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(l?.fields?.[t]){let r=l.fields[t];n.push({name:t,label:c(e.objectName,t,r.label||t),type:(0,i.mapFieldTypeToFormType)(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:(0,i.buildValidationRules)(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[l,e.readOnly,e.mode]),k=(0,t.useMemo)(()=>y>=0&&y<T?O(e.sections[y]):[],[y,T,e.sections,O]),A=(0,t.useCallback)(async t=>{let r={...d,...t};if(f(r),S(e=>new Set(e).add(y)),D){w(!0);try{if(!n)return e.onSuccess&&await e.onSuccess(r),r;let t;return e.mode===`create`?t=await n.create(e.objectName,r):e.mode===`edit`&&e.recordId&&(t=await n.update(e.objectName,e.recordId,r)),e.onSuccess&&await e.onSuccess(t),t}catch(t){throw e.onError&&e.onError(t),t}finally{w(!1)}}else j(y+1)},[d,y,D,e,n]),j=(0,t.useCallback)(t=>{t>=0&&t<T&&(b(t),e.onStepChange&&e.onStepChange(t))},[T,e]),M=(0,t.useCallback)(()=>{j(y-1)},[y,j]),N=(0,t.useCallback)(()=>{e.onCancel&&e.onCancel()},[e]),P=(0,t.useCallback)(t=>{(e.allowSkip||x.has(t)||t<=y)&&j(t)},[e.allowSkip,x,y,j]);if(h)return(0,_.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,_.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,_.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:h.message})]});if(p)return(0,_.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,_.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});let F=e.sections[y];return(0,_.jsxs)(`div`,{className:(0,a.cn)(`w-full`,s,e.className),children:[e.showStepIndicator!==!1&&(0,_.jsx)(`nav`,{"aria-label":`Progress`,className:`mb-8`,children:(0,_.jsx)(`ol`,{className:`flex items-center`,children:e.sections.map((t,n)=>{let r=n===y,i=x.has(n),s=e.allowSkip||i||n<=y;return(0,_.jsxs)(`li`,{className:(0,a.cn)(`relative flex-1`,n!==T-1&&`pr-8 sm:pr-12`),children:[n!==T-1&&(0,_.jsx)(`div`,{className:`absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5`,"aria-hidden":`true`,children:(0,_.jsx)(`div`,{className:(0,a.cn)(`h-full`,i?`bg-primary`:`bg-muted`)})}),(0,_.jsxs)(`button`,{type:`button`,className:(0,a.cn)(`group relative flex items-center`,s?`cursor-pointer`:`cursor-not-allowed`),onClick:()=>P(n),disabled:!s,children:[(0,_.jsx)(`span`,{className:(0,a.cn)(`flex h-6 w-6 sm:h-8 sm:w-8 items-center justify-center rounded-full text-xs sm:text-sm font-medium transition-colors`,i&&`bg-primary text-primary-foreground`,r&&!i&&`border-2 border-primary bg-background text-primary`,!r&&!i&&`border-2 border-muted bg-background text-muted-foreground`),children:i?(0,_.jsx)(o.Check,{className:`h-3 w-3 sm:h-4 sm:w-4`}):n+1}),(0,_.jsx)(`span`,{className:`ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block`,children:(0,_.jsx)(`span`,{className:(0,a.cn)(r?`text-foreground`:`text-muted-foreground`),children:t.label||`Step ${n+1}`})})]})]},n)})})}),(0,_.jsx)(`div`,{className:`min-h-[200px]`,children:F&&(0,_.jsx)(v,{label:F.label,description:F.description,columns:F.columns||1,children:k.length>0?(0,_.jsx)(r.SchemaRenderer,{schema:{type:`form`,fields:k,layout:`vertical`,defaultValues:d,showSubmit:!1,showCancel:!1,onSubmit:A}}):(0,_.jsx)(`div`,{className:`text-center py-8 text-muted-foreground`,children:`No fields configured for this step`})})}),(0,_.jsxs)(`div`,{className:`flex items-center justify-between mt-6 pt-4 border-t`,children:[(0,_.jsx)(`div`,{children:e.showCancel!==!1&&(0,_.jsx)(a.Button,{variant:`ghost`,onClick:N,children:e.cancelText||`Cancel`})}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsxs)(`span`,{className:`text-sm text-muted-foreground mr-2`,children:[`Step `,y+1,` of `,T]}),!E&&(0,_.jsxs)(a.Button,{variant:`outline`,onClick:M,children:[(0,_.jsx)(o.ChevronLeft,{className:`h-4 w-4 mr-1`}),e.prevText||`Back`]}),D?(0,_.jsx)(a.Button,{onClick:()=>A(d),disabled:C||e.mode===`view`,children:C?`Submitting...`:e.submitText||(e.mode===`create`?`Create`:`Update`)}):(0,_.jsxs)(a.Button,{onClick:()=>A(d),children:[e.nextText||`Next`,(0,_.jsx)(o.ChevronRight,{className:`h-4 w-4 ml-1`})]})]})]})]})},x=({schema:e,dataSource:n,className:o})=>{let{fieldLabel:s}=(0,r.useSafeFieldLabel)(),[c,l]=(0,t.useState)(null),[u,d]=(0,t.useState)({}),[f,p]=(0,t.useState)(!0),[m,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(async()=>{if(!n){p(!1);return}try{l(await n.getObjectSchema(e.objectName))}catch(e){h(e),p(!1)}})()},[e.objectName,n]),(0,t.useEffect)(()=>{(c||!n)&&(async()=>{if(e.mode===`create`||!e.recordId){d(e.initialData||e.initialValues||{}),p(!1);return}if(!n){d(e.initialData||e.initialValues||{}),p(!1);return}try{d(await n.findOne(e.objectName,e.recordId)||{})}catch(e){h(e)}finally{p(!1)}})()},[c,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);let g=(0,t.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(c?.fields?.[t]){let r=c.fields[t];n.push({name:t,label:s(e.objectName,t,r.label||t),type:(0,i.mapFieldTypeToFormType)(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:(0,i.buildValidationRules)(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[c,e.readOnly,e.mode]),y=(0,t.useCallback)(async t=>{if(!n)return e.onSuccess&&await e.onSuccess(t),t;try{let r;return e.mode===`create`?r=await n.create(e.objectName,t):e.mode===`edit`&&e.recordId&&(r=await n.update(e.objectName,e.recordId,t)),e.onSuccess&&await e.onSuccess(r),r}catch(t){throw e.onError&&e.onError(t),t}},[e,n]),b=(0,t.useCallback)(()=>{e.onCancel&&e.onCancel()},[e]),x=(0,t.useMemo)(()=>e.sections.slice(0,1),[e.sections]),S=(0,t.useMemo)(()=>e.sections.slice(1),[e.sections]);(0,t.useMemo)(()=>e.sections.flatMap(e=>g(e)),[e.sections,g]);let C=e.splitDirection||`horizontal`,w=e.splitSize||50;if(m)return(0,_.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,_.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,_.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:m.message})]});if(f)return(0,_.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,_.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});let T={type:`form`,layout:`vertical`,defaultValues:u,onSubmit:y,onCancel:b},E=(t,n)=>(0,_.jsx)(`div`,{className:`space-y-4 p-4`,children:t.map((t,i)=>(0,_.jsx)(v,{label:t.label,description:t.description,columns:t.columns||1,children:(0,_.jsx)(r.SchemaRenderer,{schema:{...T,fields:g(t),showSubmit:n&&e.showSubmit!==!1&&e.mode!==`view`,showCancel:n&&e.showCancel!==!1,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText}})},t.name||t.label||i))});return(0,_.jsx)(`div`,{className:(0,a.cn)(`w-full`,o,e.className),children:(0,_.jsxs)(a.ResizablePanelGroup,{orientation:C,className:`min-h-[300px] rounded-lg border`,children:[(0,_.jsx)(a.ResizablePanel,{defaultSize:w,minSize:20,children:E(x,S.length===0)}),S.length>0&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(a.ResizableHandle,{withHandle:e.splitResizable!==!1}),(0,_.jsx)(a.ResizablePanel,{defaultSize:100-w,minSize:20,children:E(S,!0)})]})]})})},S=new Set([`field:formula`,`field:summary`,`field:auto_number`,`field:autonumber`,`field:master_detail`]),C=new Set([`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`,`textarea`,`markdown`,`html`,`grid`,`rich-text`]),w=new Set([`formula`,`summary`,`auto_number`,`autonumber`,`master_detail`,`masterDetail`]);function T(e){return C.has(e)}function E(e){return w.has(e)}function D(e){return e<=3?1:2}function O(e,t){return t<=1?e:e.map(e=>e.colSpan===void 0&&e.type&&T(e.type)?{...e,colSpan:t}:e)}var k=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`owner`,`owner_id`,`_version`,`_rev`]);function A(e,t){return e.filter(e=>{if(k.has(e.name)||e.type&&S.has(e.type))return!1;if(!t?.fields)return!0;let n=t.fields[e.name];return n?n.readonly===!0?!1:!E(n.type):!0})}function j(e){return e<=1?`default`:e===2?`xl`:`full`}function M(e,t,n,r){let i=[...e];if(r===`create`&&(i=A(i,t)),n!==void 0)return i=O(i,n),{fields:i,columns:n};let a=D(i.length);return i=O(i,a),{fields:i,columns:a}}var N={1:void 0,2:`grid gap-4 grid-cols-1 @md:grid-cols-2`,3:`grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3`,4:`grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4`},P=({schema:e,dataSource:n,className:o})=>{let{fieldLabel:s}=(0,r.useSafeFieldLabel)(),[c,l]=(0,t.useState)(null),[u,d]=(0,t.useState)([]),[f,p]=(0,t.useState)({}),[m,h]=(0,t.useState)(!0),[g,v]=(0,t.useState)(null),y=e.open!==!1,b=e.drawerSide||`right`,[x,S]=(0,t.useState)(()=>{let t={};return e.sections?.forEach((e,n)=>{let r=e.name||String(n);e.collapsed&&(t[r]=!0)}),t});(0,t.useEffect)(()=>{(async()=>{if(!n){h(!1);return}try{l(await n.getObjectSchema(e.objectName))}catch(e){v(e),h(!1)}})()},[e.objectName,n]),(0,t.useEffect)(()=>{(c||!n)&&(async()=>{if(e.mode===`create`||!e.recordId){p(e.initialData||e.initialValues||{}),h(!1);return}if(!n){p(e.initialData||e.initialValues||{}),h(!1);return}try{p(await n.findOne(e.objectName,e.recordId)||{})}catch(e){v(e)}finally{h(!1)}})()},[c,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);let C=(0,t.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(c?.fields?.[t]){let r=c.fields[t];n.push({name:t,label:s(e.objectName,t,r.label||t),type:(0,i.mapFieldTypeToFormType)(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:(0,i.buildValidationRules)(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[c,e.readOnly,e.mode]);(0,t.useEffect)(()=>{if(!c&&n)return;if(e.customFields?.length){d(e.customFields),h(!1);return}if(e.sections?.length){h(!1);return}if(!c)return;let t=e.fields||Object.keys(c.fields||{}),r=[];for(let n of t){let t=typeof n==`string`?n:n.name;if(!t)continue;let a=c.fields?.[t];a&&r.push({name:t,label:s(e.objectName,t,a.label||t),type:(0,i.mapFieldTypeToFormType)(a.type),required:a.required||!1,disabled:e.readOnly||e.mode===`view`||a.readonly,placeholder:a.placeholder,description:a.help||a.description,validation:(0,i.buildValidationRules)(a),field:a,options:a.options,multiple:a.multiple})}d(r),h(!1)},[c,e.fields,e.customFields,e.sections,e.readOnly,e.mode,n]);let w=(0,t.useCallback)(async t=>{if(!n)return e.onSuccess&&await e.onSuccess(t),e.onOpenChange?.(!1),t;try{let r;return e.mode===`create`?r=await n.create(e.objectName,t):e.mode===`edit`&&e.recordId&&(r=await n.update(e.objectName,e.recordId,t)),e.onSuccess&&await e.onSuccess(r),e.onOpenChange?.(!1),r}catch(t){throw e.onError&&e.onError(t),t}},[e,n]),T=(0,t.useCallback)(()=>{e.onCancel&&e.onCancel(),e.onOpenChange?.(!1)},[e]),E=(0,t.useMemo)(()=>{if(e.drawerWidth)return b===`left`||b===`right`?{width:e.drawerWidth,maxWidth:e.drawerWidth}:{height:e.drawerWidth,maxHeight:e.drawerWidth}},[e.drawerWidth,b]),D={type:`form`,layout:e.layout===`vertical`||e.layout===`horizontal`?e.layout:`vertical`,defaultValues:f,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText,showSubmit:e.showSubmit!==!1&&e.mode!==`view`,showCancel:e.showCancel!==!1,onSubmit:w,onCancel:T};return(0,_.jsx)(a.Sheet,{open:y,onOpenChange:e.onOpenChange,children:(0,_.jsxs)(a.SheetContent,{side:b,className:(0,a.cn)(`overflow-y-auto`,o,e.className),style:E,children:[(e.title||e.description)&&(0,_.jsxs)(a.SheetHeader,{children:[e.title&&(0,_.jsx)(a.SheetTitle,{children:e.title}),e.description&&(0,_.jsx)(a.SheetDescription,{children:e.description})]}),(0,_.jsx)(`div`,{className:`@container py-4`,children:(()=>{if(g)return(0,_.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,_.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,_.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:g.message})]});if(m)return(0,_.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,_.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});if(e.sections?.length){let t=[];return e.sections.forEach((e,n)=>{let r=e.name||String(n),i=x[r]??e.collapsed??!1;t.push({name:`__section_${r}`,label:e.label||``,type:`section-divider`,colSpan:4,collapsible:e.collapsible,collapsed:i,onToggle:e.collapsible?()=>S(e=>({...e,[r]:!i})):void 0});let a=C(e);i?t.push(...a.map(e=>({...e,hidden:!0}))):t.push(...a)}),(0,_.jsx)(r.SchemaRenderer,{schema:{...D,fields:t}})}let t=M(u,c,e.columns,e.mode),n=N[t.columns||1];return(0,_.jsx)(r.SchemaRenderer,{schema:{...D,fields:t.fields,columns:t.columns,...n?{fieldContainerClass:n}:{}}})})()})]})})},F={sm:`sm:max-w-sm`,default:`sm:max-w-lg`,lg:`sm:max-w-2xl`,xl:`sm:max-w-5xl`,full:`sm:max-w-[95vw] sm:w-full`},I={1:void 0,2:`grid gap-4 grid-cols-1 @md:grid-cols-2`,3:`grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3`,4:`grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4`},L=({schema:e,dataSource:n,className:s})=>{let{fieldLabel:c}=(0,r.useSafeFieldLabel)(),[l,u]=(0,t.useState)(null),[d,f]=(0,t.useState)([]),[p,m]=(0,t.useState)({}),[h,g]=(0,t.useState)(!0),[y,b]=(0,t.useState)(null),[x,S]=(0,t.useState)(!1),C=e.open!==!1,w=(0,t.useId)(),T=(0,t.useMemo)(()=>e.sections?.length||e.customFields?.length?null:M(d,l,e.columns,e.mode),[d,l,e.columns,e.mode,e.sections,e.customFields]),E=F[(0,t.useMemo)(()=>{if(e.modalSize)return e.modalSize;if(T?.columns&&T.columns>1)return j(T.columns);if(e.sections?.length){let t=Math.max(...e.sections.map(e=>Number(e.columns)||1));if(t>1)return j(t)}return`default`},[e.modalSize,T,e.sections])]||F.default;(0,t.useEffect)(()=>{(async()=>{if(!n){g(!1);return}try{u(await n.getObjectSchema(e.objectName))}catch(e){b(e),g(!1)}})()},[e.objectName,n]),(0,t.useEffect)(()=>{(l||!n)&&(async()=>{if(e.mode===`create`||!e.recordId){m(e.initialData||e.initialValues||{}),g(!1);return}if(!n){m(e.initialData||e.initialValues||{}),g(!1);return}try{m(await n.findOne(e.objectName,e.recordId)||{})}catch(e){b(e)}finally{g(!1)}})()},[l,e.mode,e.recordId,e.initialData,e.initialValues,n,e.objectName]);let D=(0,t.useCallback)(t=>{let n=[];for(let r of t.fields){let t=typeof r==`string`?r:r.name;if(typeof r==`object`)n.push(r);else if(l?.fields?.[t]){let r=l.fields[t];n.push({name:t,label:c(e.objectName,t,r.label||t),type:(0,i.mapFieldTypeToFormType)(r.type),required:r.required||!1,disabled:e.readOnly||e.mode===`view`||r.readonly,placeholder:r.placeholder,description:r.help||r.description,validation:(0,i.buildValidationRules)(r),field:r,options:r.options,multiple:r.multiple})}else n.push({name:t,label:t,type:`input`})}return n},[l,e.readOnly,e.mode]);(0,t.useEffect)(()=>{if(!l&&n)return;if(e.customFields?.length){f(e.customFields),g(!1);return}if(e.sections?.length){g(!1);return}if(!l)return;let t=e.fields||Object.keys(l.fields||{}),r=[];for(let n of t){let t=typeof n==`string`?n:n.name;if(!t)continue;let a=l.fields?.[t];a&&r.push({name:t,label:c(e.objectName,t,a.label||t),type:(0,i.mapFieldTypeToFormType)(a.type),required:a.required||!1,disabled:e.readOnly||e.mode===`view`||a.readonly,placeholder:a.placeholder,description:a.help||a.description,validation:(0,i.buildValidationRules)(a),field:a,options:a.options,multiple:a.multiple})}f(r),g(!1)},[l,e.fields,e.customFields,e.sections,e.readOnly,e.mode,n]);let O=(0,t.useCallback)(async t=>{S(!0);try{if(!n)return e.onSuccess&&await e.onSuccess(t),e.onOpenChange?.(!1),t;let r;return e.mode===`create`?r=await n.create(e.objectName,t):e.mode===`edit`&&e.recordId&&(r=await n.update(e.objectName,e.recordId,t)),e.onSuccess&&await e.onSuccess(r),e.onOpenChange?.(!1),r}catch(t){throw e.onError&&e.onError(t),t}finally{S(!1)}},[e,n]),k=(0,t.useCallback)(()=>{e.onCancel&&e.onCancel(),e.onOpenChange?.(!1)},[e]),A=e.layout===`vertical`||e.layout===`horizontal`?e.layout:`vertical`,N=e.showSubmit!==!1&&e.mode!==`view`,P=e.showCancel!==!1,L=e.submitText||(e.mode===`create`?`Create`:`Update`),R=e.cancelText||`Cancel`,z={type:`form`,layout:A,defaultValues:p,submitLabel:L,cancelLabel:R,showSubmit:N,showCancel:P,onSubmit:O,onCancel:k,showActions:!1,id:w},B=()=>{if(y)return(0,_.jsxs)(`div`,{className:`p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,_.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,_.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:y.message})]});if(h)return(0,_.jsx)(`div`,{className:`space-y-4`,"data-testid":`modal-form-skeleton`,children:[1,2,3].map(e=>(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(a.Skeleton,{className:`h-4 w-24`}),(0,_.jsx)(a.Skeleton,{className:`h-10 w-full`})]},e))});if(e.sections?.length)return(0,_.jsx)(`div`,{className:`space-y-6`,children:e.sections.map((e,t)=>{let n=e.columns||1;return(0,_.jsx)(v,{label:e.label,description:e.description,columns:n,gridClassName:I[n],children:(0,_.jsx)(r.SchemaRenderer,{schema:{...z,fields:D(e)}})},e.name||e.label||t)})});let t=T??M(d,l,e.columns,e.mode),n=I[t.columns||1];return(0,_.jsx)(r.SchemaRenderer,{schema:{...z,fields:t.fields,columns:t.columns,...n?{fieldContainerClass:n}:{}}})},V=!h&&!y&&(N||P);return(0,_.jsx)(a.Dialog,{open:C,onOpenChange:e.onOpenChange,children:(0,_.jsxs)(a.MobileDialogContent,{className:(0,a.cn)(E,`flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0`,s,e.className),children:[(e.title||e.description)&&(0,_.jsxs)(a.DialogHeader,{className:`shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b`,children:[e.title&&(0,_.jsx)(a.DialogTitle,{children:e.title}),e.description&&(0,_.jsx)(a.DialogDescription,{children:e.description})]}),(0,_.jsx)(`div`,{className:`@container flex-1 overflow-y-auto px-4 sm:px-6 py-4`,children:B()}),V&&(0,_.jsx)(`div`,{className:`shrink-0 border-t px-4 sm:px-6 py-3 bg-background`,"data-testid":`modal-form-footer`,children:(0,_.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2 sm:justify-end`,children:[P&&(0,_.jsx)(a.Button,{type:`button`,variant:`outline`,onClick:k,disabled:x,className:`w-full sm:w-auto`,children:R}),N&&(0,_.jsxs)(a.Button,{type:`submit`,form:w,disabled:x,className:`w-full sm:w-auto`,children:[x&&(0,_.jsx)(o.Loader2,{className:`mr-2 h-4 w-4 animate-spin`}),L]})]})})]})})},R=({schema:e,dataSource:t})=>{if(e.formType===`tabbed`&&e.sections?.length)return(0,_.jsx)(y,{schema:{...e,formType:`tabbed`,sections:e.sections.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields})),defaultTab:e.defaultTab,tabPosition:e.tabPosition},dataSource:t,className:e.className});if(e.formType===`wizard`&&e.sections?.length)return(0,_.jsx)(b,{schema:{...e,formType:`wizard`,sections:e.sections.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields})),allowSkip:e.allowSkip,showStepIndicator:e.showStepIndicator,nextText:e.nextText,prevText:e.prevText,onStepChange:e.onStepChange},dataSource:t,className:e.className});if(e.formType===`split`&&e.sections?.length)return(0,_.jsx)(x,{schema:{...e,formType:`split`,sections:e.sections.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields})),splitDirection:e.splitDirection,splitSize:e.splitSize,splitResizable:e.splitResizable},dataSource:t,className:e.className});if(e.formType===`drawer`){let{layout:n,...r}=e,i=e.layout===`vertical`||e.layout===`horizontal`?e.layout:void 0;return(0,_.jsx)(P,{schema:{...r,layout:i,formType:`drawer`,sections:e.sections?.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields,collapsible:e.collapsible,collapsed:e.collapsed})),open:e.open,onOpenChange:e.onOpenChange,drawerSide:e.drawerSide,drawerWidth:e.drawerWidth},dataSource:t,className:e.className})}if(e.formType===`modal`){let{layout:n,...r}=e,i=e.layout===`vertical`||e.layout===`horizontal`?e.layout:void 0;return(0,_.jsx)(L,{schema:{...r,layout:i,formType:`modal`,sections:e.sections?.map(e=>({name:e.name,label:e.label,description:e.description,columns:e.columns,fields:e.fields})),open:e.open,onOpenChange:e.onOpenChange,modalSize:e.modalSize,modalCloseButton:e.modalCloseButton},dataSource:t,className:e.className})}return(0,_.jsx)(z,{schema:e,dataSource:t})},z=({schema:e,dataSource:n})=>{let{fieldLabel:a}=(0,r.useSafeFieldLabel)(),[o,s]=(0,t.useState)(null),[c,l]=(0,t.useState)([]),[u,d]=(0,t.useState)(null),[f,p]=(0,t.useState)(!0),[m,h]=(0,t.useState)(null),g=e.customFields&&e.customFields.length>0;(0,t.useEffect)(()=>{g&&(d(e.initialData||e.initialValues||{}),p(!1))},[g,e.initialData,e.initialValues]),(0,t.useEffect)(()=>{g?s({name:e.objectName,fields:{}}):e.objectName&&n?(async()=>{try{if(!n)throw Error(`DataSource is required when using ObjectQL schema fetching (inline fields not provided)`);let t=await n.getObjectSchema(e.objectName);if(!t)throw Error(`No schema found for object "${e.objectName}"`);s(t)}catch(e){h(e),p(!1)}})():g||p(!1)},[e.objectName,n,g]),(0,t.useEffect)(()=>{o&&!g&&(async()=>{if(!e.recordId||e.mode===`create`){d(e.initialData||e.initialValues||{}),p(!1);return}if(!g){if(!n){h(Error(`DataSource is required for fetching record data (inline data not provided)`)),p(!1);return}p(!0);try{d(await n.findOne(e.objectName,e.recordId))}catch(e){console.error(`Failed to fetch record:`,e),h(e)}finally{p(!1)}}})()},[e.objectName,e.recordId,e.mode,e.initialValues,e.initialData,n,o,g]),(0,t.useEffect)(()=>{if(g&&e.customFields){l(e.customFields),p(!1);return}if(!o)return;let t=[],r=e.fields||Object.keys(o.fields||{});(Array.isArray(r)?r:Object.keys(r)).forEach(n=>{let r=typeof n==`string`?n:n.name;if(!r)return;let s=o.fields?.[r];if(!s&&!g)return;let c=!s?.permissions||s?.permissions.write!==!1;if(e.mode!==`view`&&!c)return;let l=e.customFields?.find(e=>e.name===r);if(l)t.push(l);else if(s){let o={name:r,label:a(e.objectName,r,s.label||n),type:(0,i.mapFieldTypeToFormType)(s.type),required:s.required||!1,disabled:e.readOnly||e.mode===`view`||s.readonly,placeholder:s.placeholder,description:s.help||s.description,validation:(0,i.buildValidationRules)(s),field:s};if((s.type===`select`||s.type===`lookup`||s.type===`master_detail`)&&(o.options=s.options||[],o.multiple=s.multiple),(s.type===`number`||s.type===`currency`||s.type===`percent`)&&(o.inputType=`number`,o.min=s.min,o.max=s.max,o.step=s.precision?10**-s.precision:void 0),s.type===`date`&&(o.inputType=`date`),s.type===`datetime`&&(o.inputType=`datetime-local`),(s.type===`text`||s.type===`textarea`||s.type===`markdown`||s.type===`html`)&&(o.maxLength=s.max_length,o.minLength=s.min_length),(s.type===`file`||s.type===`image`)&&(o.inputType=`file`,o.multiple=s.multiple,o.accept=s.accept?s.accept.join(`,`):void 0,s.max_size)){let e=`Max size: ${(0,i.formatFileSize)(s.max_size)}`;o.description=o.description?`${o.description} (${e})`:e}s.type===`email`&&(o.inputType=`email`),s.type===`phone`&&(o.inputType=`tel`),s.type===`url`&&(o.inputType=`url`),s.type===`password`&&(o.inputType=`password`),s.type===`time`&&(o.inputType=`time`),(s.type===`formula`||s.type===`summary`||s.type===`auto_number`)&&(o.disabled=!0),s.visible_on&&(o.visible=e=>(0,i.evaluateCondition)(s.visible_on,e)),t.push(o)}}),l(t),!g&&e.recordId&&e.mode!==`create`&&n||p(!1)},[o,e.fields,e.customFields,e.readOnly,e.mode,g,e.recordId,n]);let y=(0,t.useCallback)(async(t,r)=>{if(t&&(t.nativeEvent||t._reactName===`onSubmit`)&&(console.warn(`ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue.`),r===void 0&&(r=t,t={})),g&&!n)return e.onSuccess&&await e.onSuccess(t),t;if(!n)throw Error(`DataSource is required for form submission (inline mode not configured)`);try{let r;if(e.mode===`create`)r=await n.create(e.objectName,t);else if(e.mode===`edit`&&e.recordId)r=await n.update(e.objectName,e.recordId,t);else throw Error(`Invalid form mode or missing record ID`);return e.onSuccess&&await e.onSuccess(r),r}catch(t){throw console.error(`Failed to submit form:`,t),e.onError&&e.onError(t),t}},[e,n,g]),b=(0,t.useCallback)(()=>{e.onCancel&&e.onCancel()},[e]),x={...t.default.useMemo(()=>{if(!o?.fields)return{};let e={};return Object.keys(o.fields).forEach(t=>{let n=o.fields[t];n.defaultValue!==void 0&&(e[t]=n.defaultValue)}),e},[o]),...u};if(m)return(0,_.jsxs)(`div`,{className:`p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md`,children:[(0,_.jsx)(`h3`,{className:`text-red-800 font-semibold`,children:`Error loading form`}),(0,_.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:m.message})]});if(f)return(0,_.jsxs)(`div`,{className:`p-4 sm:p-8 text-center`,children:[(0,_.jsx)(`div`,{className:`inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900`}),(0,_.jsx)(`p`,{className:`mt-2 text-sm text-gray-600`,children:`Loading form...`})]});let S=e.layout===`vertical`||e.layout===`horizontal`?e.layout:`vertical`;if(e.sections?.length&&(!e.formType||e.formType===`simple`))return(0,_.jsx)(`div`,{className:`w-full space-y-6`,children:e.sections.map((t,n)=>{let i=t.fields.map(e=>typeof e==`string`?e:e.name),a=c.filter(e=>i.includes(e.name));return(0,_.jsx)(v,{label:t.label,description:t.description,collapsible:t.collapsible,collapsed:t.collapsed,columns:t.columns,children:(0,_.jsx)(r.SchemaRenderer,{schema:{type:`form`,fields:a,layout:S,defaultValues:x,showSubmit:n===e.sections.length-1&&e.showSubmit!==!1&&e.mode!==`view`,showCancel:n===e.sections.length-1&&e.showCancel!==!1,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText,onSubmit:y,onCancel:b}})},t.name||t.label||n)})});let C=e.sections?.length?{fields:c,columns:e.columns}:M(c,o,e.columns,e.mode);return(0,_.jsx)(`div`,{className:`w-full`,children:(0,_.jsx)(r.SchemaRenderer,{schema:{type:`form`,fields:C.fields,layout:S,columns:C.columns,submitLabel:e.submitText||(e.mode===`create`?`Create`:`Update`),cancelLabel:e.cancelText,showSubmit:e.showSubmit!==!1&&e.mode!==`view`,showCancel:e.showCancel!==!1,resetOnSubmit:e.showReset,defaultValues:x,onSubmit:y,onCancel:b,className:e.className}})})},B=({config:e,dataSource:n,prefillParams:r,className:i})=>{let[a,o]=(0,t.useState)(!1),[s,c]=(0,t.useState)(!1),[l,u]=(0,t.useState)(null),d=(0,t.useMemo)(()=>{let e={};if(r)for(let[t,n]of Object.entries(r))e[t]=n;return typeof window<`u`&&new URLSearchParams(window.location.search).forEach((t,n)=>{n in e||(e[n]=t)}),Object.keys(e).length>0?e:void 0},[r]),f=(0,t.useCallback)(async t=>{c(!0),u(null);try{if(n&&await n.create(e.objectName,t),o(!0),e.thankYouPage?.redirectUrl){let t=e.thankYouPage.redirectDelay??3e3;setTimeout(()=>{window.location.href=e.thankYouPage.redirectUrl},t)}}catch(e){u(e instanceof Error?e.message:`Failed to submit form. Please try again.`)}finally{c(!1)}},[n,e]),p=(0,t.useCallback)(()=>{o(!1),u(null)},[]),m=(0,t.useMemo)(()=>{let t={};return e.branding?.backgroundColor&&(t.backgroundColor=e.branding.backgroundColor),t},[e.branding]);if(a){let t=e.thankYouPage;return(0,_.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-4 ${i||``}`,style:m,children:(0,_.jsxs)(`div`,{className:`max-w-md w-full bg-card rounded-lg shadow-lg p-8 text-center space-y-4`,children:[(0,_.jsx)(`div`,{className:`text-4xl`,children:`✓`}),(0,_.jsx)(`h2`,{className:`text-xl font-semibold text-foreground`,children:t?.title||`Thank You!`}),(0,_.jsx)(`p`,{className:`text-muted-foreground`,children:t?.message||`Your submission has been received successfully.`}),e.allowMultiple&&(0,_.jsx)(`button`,{onClick:p,className:`mt-4 px-4 py-2 text-sm font-medium rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors`,children:`Submit Another Response`}),t?.redirectUrl&&(0,_.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Redirecting in `,Math.ceil((t.redirectDelay??3e3)/1e3),` seconds...`]})]})})}return(0,_.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-4 ${i||``}`,style:m,children:(0,_.jsxs)(`div`,{className:`max-w-2xl w-full bg-card rounded-lg shadow-lg overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`p-6 border-b`,style:e.branding?.primaryColor?{borderBottomColor:e.branding.primaryColor}:void 0,children:[e.branding?.logo&&(0,_.jsx)(`img`,{src:e.branding.logo,alt:`Logo`,className:`h-8 mb-4`}),e.title&&(0,_.jsx)(`h1`,{className:`text-xl font-semibold text-foreground`,children:e.title}),e.description&&(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description})]}),(0,_.jsxs)(`div`,{className:`p-6`,children:[l&&(0,_.jsx)(`div`,{className:`mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive`,children:l}),(0,_.jsx)(R,{schema:{type:`object-form`,objectName:e.objectName,mode:`create`,fields:e.fields,customFields:e.customFields,initialData:d,onSuccess:f,submitLabel:s?`Submitting...`:`Submit`},dataSource:n})]}),(0,_.jsx)(`div`,{className:`px-6 py-3 border-t bg-muted/20 text-center`,children:(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Powered by ObjectStack`})})]})})};function V(e){return e<60?`${Math.round(e)}s`:e<3600?`${Math.floor(e/60)}m ${Math.round(e%60)}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}var H=({formId:e,formTitle:n,metrics:r,className:i})=>{let o=(0,t.useMemo)(()=>{if(!r.abandonedSubmissions)return 100;let e=r.totalSubmissions+r.abandonedSubmissions;return e===0?0:Math.round(r.totalSubmissions/e*100)},[r.totalSubmissions,r.abandonedSubmissions]),s=(0,t.useMemo)(()=>r.dailySubmissions?.length?Math.max(...r.dailySubmissions.map(e=>e.count),1):1,[r.dailySubmissions]);return(0,_.jsxs)(`div`,{className:`space-y-4 ${i||``}`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:n||`Form Analytics`}),(0,_.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Form ID: `,e]})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,_.jsx)(a.Card,{children:(0,_.jsxs)(a.CardHeader,{className:`pb-2`,children:[(0,_.jsx)(a.CardDescription,{children:`Total Submissions`}),(0,_.jsx)(a.CardTitle,{className:`text-2xl`,children:r.totalSubmissions.toLocaleString()})]})}),(0,_.jsxs)(a.Card,{children:[(0,_.jsxs)(a.CardHeader,{className:`pb-2`,children:[(0,_.jsx)(a.CardDescription,{children:`Fill Rate`}),(0,_.jsxs)(a.CardTitle,{className:`text-2xl`,children:[o,`%`]})]}),(0,_.jsx)(a.CardContent,{children:(0,_.jsx)(`div`,{className:`w-full bg-muted rounded-full h-2`,children:(0,_.jsx)(`div`,{className:`bg-primary rounded-full h-2 transition-all`,style:{width:`${o}%`}})})})]}),(0,_.jsx)(a.Card,{children:(0,_.jsxs)(a.CardHeader,{className:`pb-2`,children:[(0,_.jsx)(a.CardDescription,{children:`Avg. Completion Time`}),(0,_.jsx)(a.CardTitle,{className:`text-2xl`,children:r.avgCompletionTime?V(r.avgCompletionTime):`—`})]})})]}),r.dailySubmissions&&r.dailySubmissions.length>0&&(0,_.jsxs)(a.Card,{children:[(0,_.jsx)(a.CardHeader,{children:(0,_.jsx)(a.CardTitle,{className:`text-sm font-medium`,children:`Daily Submissions`})}),(0,_.jsx)(a.CardContent,{children:(0,_.jsx)(`div`,{className:`flex items-end gap-1 h-32`,children:r.dailySubmissions.map((e,t)=>(0,_.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-1`,children:[(0,_.jsx)(`div`,{className:`w-full bg-primary/80 rounded-t transition-all hover:bg-primary`,style:{height:`${e.count/s*100}%`,minHeight:e.count>0?`4px`:`0`},title:`${e.date}: ${e.count} submissions`}),(0,_.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate w-full text-center`,children:e.date.slice(-5)})]},t))})})]}),r.fieldDropOff&&r.fieldDropOff.length>0&&(0,_.jsxs)(a.Card,{children:[(0,_.jsxs)(a.CardHeader,{children:[(0,_.jsx)(a.CardTitle,{className:`text-sm font-medium`,children:`Field Completion Rates`}),(0,_.jsx)(a.CardDescription,{children:`Percentage of users who completed each field`})]}),(0,_.jsx)(a.CardContent,{children:(0,_.jsx)(`div`,{className:`space-y-3`,children:r.fieldDropOff.map((e,t)=>(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,_.jsx)(`span`,{className:`text-foreground`,children:e.label}),(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.completionRate,`%`]})]}),(0,_.jsx)(`div`,{className:`w-full bg-muted rounded-full h-1.5`,children:(0,_.jsx)(`div`,{className:`rounded-full h-1.5 transition-all ${e.completionRate>=80?`bg-green-500`:e.completionRate>=50?`bg-yellow-500`:`bg-destructive`}`,style:{width:`${e.completionRate}%`}})})]},t))})})]})]})},U=({schema:e})=>(0,_.jsx)(R,{schema:e});n.ComponentRegistry.register(`object-form`,U,{namespace:`plugin-form`,label:`Object Form`,category:`plugin`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`fields`,type:`array`,label:`Fields`},{name:`mode`,type:`enum`,label:`Mode`,enum:[`create`,`edit`,`view`]},{name:`formType`,type:`enum`,label:`Form Type`,enum:[`simple`,`tabbed`,`wizard`,`split`,`drawer`,`modal`]},{name:`sections`,type:`array`,label:`Sections`},{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`vertical`,`horizontal`,`inline`,`grid`]},{name:`columns`,type:`number`,label:`Columns`},{name:`defaultTab`,type:`string`,label:`Default Tab`},{name:`tabPosition`,type:`enum`,label:`Tab Position`,enum:[`top`,`bottom`,`left`,`right`]},{name:`allowSkip`,type:`boolean`,label:`Allow Skip Steps`},{name:`showStepIndicator`,type:`boolean`,label:`Show Step Indicator`},{name:`splitDirection`,type:`enum`,label:`Split Direction`,enum:[`horizontal`,`vertical`]},{name:`splitSize`,type:`number`,label:`Split Panel Size (%)`},{name:`splitResizable`,type:`boolean`,label:`Split Resizable`},{name:`drawerSide`,type:`enum`,label:`Drawer Side`,enum:[`top`,`bottom`,`left`,`right`]},{name:`drawerWidth`,type:`string`,label:`Drawer Width`},{name:`modalSize`,type:`enum`,label:`Modal Size`,enum:[`sm`,`default`,`lg`,`xl`,`full`]}]}),n.ComponentRegistry.register(`form`,U,{namespace:`view`,skipFallback:!0,label:`Data Form View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`fields`,type:`array`,label:`Fields`},{name:`mode`,type:`enum`,label:`Mode`,enum:[`create`,`edit`,`view`]}]}),n.ComponentRegistry.register(`embeddable-form`,({schema:e})=>(0,_.jsx)(B,{config:e}),{namespace:`plugin-form`,label:`Embeddable Form`,category:`plugin`,inputs:[{name:`formId`,type:`string`,label:`Form ID`,required:!0},{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`title`,type:`string`,label:`Form Title`},{name:`description`,type:`string`,label:`Description`},{name:`fields`,type:`array`,label:`Fields`},{name:`allowMultiple`,type:`boolean`,label:`Allow Multiple Submissions`}]}),n.ComponentRegistry.register(`form-analytics`,({schema:e})=>(0,_.jsx)(H,{formId:e.formId,formTitle:e.formTitle,metrics:e.metrics||{totalSubmissions:0}}),{namespace:`plugin-form`,label:`Form Analytics`,category:`plugin`,inputs:[{name:`formId`,type:`string`,label:`Form ID`,required:!0},{name:`formTitle`,type:`string`,label:`Form Title`},{name:`metrics`,type:`object`,label:`Submission Metrics`}]}),e.DrawerForm=P,e.EmbeddableForm=B,e.FormAnalytics=H,e.FormSection=v,e.ModalForm=L,e.ObjectForm=R,e.SplitForm=x,e.TabbedForm=y,e.WizardForm=b,e.applyAutoColSpan=O,e.applyAutoLayout=M,e.filterCreateModeFields=A,e.inferColumns=D,e.inferModalSize=j,e.isAutoGeneratedFieldType=E,e.isWideFieldType=T});
|
|
@@ -24,15 +24,22 @@ export declare function inferColumns(fieldCount: number): number;
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function applyAutoColSpan(fields: FormField[], columns: number): FormField[];
|
|
26
26
|
/**
|
|
27
|
-
* Filter out auto-generated/readonly fields for create mode.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* Filter out auto-generated/readonly fields for create/edit mode.
|
|
28
|
+
*
|
|
29
|
+
* Dropped:
|
|
30
|
+
* - `formula`, `summary`, `autonumber`, `master_detail` field types (server-computed).
|
|
31
|
+
* - Fields with `readonly: true` on the object schema (e.g. `id`, `created_at`).
|
|
32
|
+
* - Well-known system field names (id, created_at/createdAt, updated_at/updatedAt, etc.),
|
|
33
|
+
* even when the schema omits `readonly` — these are always platform-managed.
|
|
34
|
+
*
|
|
35
|
+
* Callers can force a readonly field back into the form by marking it
|
|
36
|
+
* `hidden: false, readonly: false` in FormField overrides.
|
|
30
37
|
*
|
|
31
38
|
* @param fields - The form fields array
|
|
32
39
|
* @param objectSchema - The object schema with original field metadata
|
|
33
40
|
* @returns Filtered fields array
|
|
34
41
|
*/
|
|
35
|
-
export declare function filterCreateModeFields(fields: FormField[], objectSchema
|
|
42
|
+
export declare function filterCreateModeFields(fields: FormField[], objectSchema?: any): FormField[];
|
|
36
43
|
/**
|
|
37
44
|
* Infer an appropriate modal size based on the number of layout columns.
|
|
38
45
|
* Used to auto-upgrade the modal width when auto-layout detects multi-column forms.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-form",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Form plugin for Object UI",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"lucide-react": "^1.8.0",
|
|
19
|
-
"@object-ui/components": "3.3.
|
|
20
|
-
"@object-ui/core": "3.3.
|
|
21
|
-
"@object-ui/fields": "3.3.
|
|
22
|
-
"@object-ui/react": "3.3.
|
|
23
|
-
"@object-ui/types": "3.3.
|
|
19
|
+
"@object-ui/components": "3.3.1",
|
|
20
|
+
"@object-ui/core": "3.3.1",
|
|
21
|
+
"@object-ui/fields": "3.3.1",
|
|
22
|
+
"@object-ui/react": "3.3.1",
|
|
23
|
+
"@object-ui/types": "3.3.1"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -28,12 +28,44 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@vitejs/plugin-react": "^6.0.1",
|
|
31
|
-
"msw": "^2.
|
|
32
|
-
"typescript": "^6.0.
|
|
33
|
-
"vite": "^8.0.
|
|
31
|
+
"msw": "^2.14.2",
|
|
32
|
+
"typescript": "^6.0.3",
|
|
33
|
+
"vite": "^8.0.9",
|
|
34
34
|
"vite-plugin-dts": "^4.5.4",
|
|
35
|
-
"@object-ui/data-objectstack": "3.3.
|
|
35
|
+
"@object-ui/data-objectstack": "3.3.1"
|
|
36
36
|
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"objectui",
|
|
39
|
+
"sdui",
|
|
40
|
+
"schema-driven-ui",
|
|
41
|
+
"react",
|
|
42
|
+
"tailwind",
|
|
43
|
+
"shadcn",
|
|
44
|
+
"objectstack",
|
|
45
|
+
"plugin",
|
|
46
|
+
"form",
|
|
47
|
+
"validation",
|
|
48
|
+
"react-hook-form"
|
|
49
|
+
],
|
|
50
|
+
"author": "ObjectStack Team <team@objectstack.ai>",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/objectstack-ai/objectui.git",
|
|
54
|
+
"directory": "packages/plugin-form"
|
|
55
|
+
},
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/objectstack-ai/objectui/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://www.objectui.org/docs/plugins/plugin-form",
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
62
|
+
},
|
|
63
|
+
"files": [
|
|
64
|
+
"dist",
|
|
65
|
+
"README.md",
|
|
66
|
+
"CHANGELOG.md",
|
|
67
|
+
"LICENSE"
|
|
68
|
+
],
|
|
37
69
|
"scripts": {
|
|
38
70
|
"build": "vite build",
|
|
39
71
|
"test": "vitest run",
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @object-ui/plugin-form@3.3.0 build /home/runner/work/objectui/objectui/packages/plugin-form
|
|
3
|
-
> vite build
|
|
4
|
-
|
|
5
|
-
[36mvite v8.0.8 [32mbuilding client environment for production...[36m[39m
|
|
6
|
-
[2K
|
|
7
|
-
rendering chunks...
|
|
8
|
-
[32m
|
|
9
|
-
[36m[vite:dts][32m Start generate declaration files...[39m
|
|
10
|
-
[32m[36m[vite:dts][32m Declaration files built in 22276ms.
|
|
11
|
-
[39m
|
|
12
|
-
computing gzip size...
|
|
13
|
-
dist/index.js 62.02 kB │ gzip: 14.09 kB
|
|
14
|
-
|
|
15
|
-
[33m[33m[PLUGIN_TIMINGS] Warning:[0m Your build spent significant time in plugin `vite:dts`. See https://rolldown.rs/options/checks#plugintimings for more details.
|
|
16
|
-
[39m
|
|
17
|
-
[2K
|
|
18
|
-
rendering chunks...
|
|
19
|
-
computing gzip size...
|
|
20
|
-
dist/index.umd.cjs 47.72 kB │ gzip: 11.72 kB
|
|
21
|
-
|
|
22
|
-
[33m[33m[MISSING_GLOBAL_NAME] Warning:[0m No name was provided for external module "@object-ui/core" in "output.globals" – guessing "_object_ui_core".
|
|
23
|
-
[39m
|
|
24
|
-
[33m[33m[MISSING_GLOBAL_NAME] Warning:[0m No name was provided for external module "@object-ui/react" in "output.globals" – guessing "_object_ui_react".
|
|
25
|
-
[39m
|
|
26
|
-
[33m[33m[MISSING_GLOBAL_NAME] Warning:[0m No name was provided for external module "@object-ui/fields" in "output.globals" – guessing "_object_ui_fields".
|
|
27
|
-
[39m
|
|
28
|
-
[33m[33m[MISSING_GLOBAL_NAME] Warning:[0m No name was provided for external module "@object-ui/components" in "output.globals" – guessing "_object_ui_components".
|
|
29
|
-
[39m
|
|
30
|
-
[33m[33m[MISSING_GLOBAL_NAME] Warning:[0m No name was provided for external module "lucide-react" in "output.globals" – guessing "lucide_react".
|
|
31
|
-
[39m
|
|
32
|
-
[32m✓ built in 23.58s[39m
|