@net-advantage/nabs-ui-dynamicform 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/nabs-ui-dynamicform.cjs +6 -0
- package/dist/nabs-ui-dynamicform.css +2 -0
- package/dist/nabs-ui-dynamicform.js +466 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# nabs-ui-dynamicform
|
|
2
|
+
|
|
3
|
+
Schema-driven form control for the Nabs UI library.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import { DynamicForm } from "nabs-ui-dynamicform";
|
|
9
|
+
|
|
10
|
+
export function Example() {
|
|
11
|
+
return <DynamicForm schema={schema} value={value} onChange={setValue} />;
|
|
12
|
+
}
|
|
13
|
+
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);let t=require("react");var n=e((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})),r=e((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
|
+
let props = %s;
|
|
3
|
+
<%s {...props} />
|
|
4
|
+
React keys must be passed directly to JSX without using spread:
|
|
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)}})()})),i=e(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=n():t.exports=r()}))(),a={right:`nabs-ui-checkbox--label-right`,left:`nabs-ui-checkbox--label-left`,top:`nabs-ui-checkbox--label-top`,bottom:`nabs-ui-checkbox--label-bottom`},o=(0,t.forwardRef)(function({label:e=`Checkbox`,labelPosition:n=`right`,className:r=``,inputClassName:o=``,labelClassName:s=``,id:c,disabled:l,...u},d){let f=(0,t.useId)(),p=c??`nabs-ui-checkbox-${f.replace(/:/g,``)}`,m=[`nabs-ui-checkbox`,l?`nabs-ui-checkbox--disabled`:``,a[n]??a.right,r].filter(Boolean).join(` `),h=[`nabs-ui-checkbox__input`,o].filter(Boolean).join(` `),g=[`nabs-ui-checkbox__label`,s].filter(Boolean).join(` `);return(0,i.jsxs)(`label`,{className:m,htmlFor:p,children:[(0,i.jsx)(`input`,{ref:d,id:p,className:h,type:`checkbox`,disabled:l,...u}),(0,i.jsx)(`span`,{className:g,children:e})]})});o.displayName=`Checkbox`;var s={right:`nabs-ui-radiobutton--label-right`,left:`nabs-ui-radiobutton--label-left`,top:`nabs-ui-radiobutton--label-top`,bottom:`nabs-ui-radiobutton--label-bottom`};function c({label:e=`Radio button`,labelPosition:n=`right`,className:r=``,inputClassName:a=``,labelClassName:o=``,id:c,...l}){let u=l.disabled===!0,d=(0,t.useId)(),f=c??`nabs-ui-radiobutton-${d.replace(/:/g,``)}`,p=[`nabs-ui-radiobutton`,u?`nabs-ui-radiobutton--disabled`:``,s[n]??s.right,r].filter(Boolean).join(` `),m=[`nabs-ui-radiobutton__input`,a].filter(Boolean).join(` `),h=[`nabs-ui-radiobutton__label`,o].filter(Boolean).join(` `);return(0,i.jsxs)(`label`,{className:p,htmlFor:f,children:[(0,i.jsx)(`input`,{id:f,className:m,type:`radio`,...l}),(0,i.jsx)(`span`,{className:h,children:e})]})}var l=(0,t.forwardRef)(({label:e,className:n=``,inputClassName:r=``,labelClassName:a=``,id:o,rows:s=4,resize:c=`vertical`,...l},u)=>{let d=(0,t.useId)(),f=o??`nabs-ui-textarea-${d.replace(/:/g,``)}`,p=[`nabs-ui-textarea`,n].filter(Boolean).join(` `),m=[`nabs-ui-textarea__input`,r].filter(Boolean).join(` `),h=[`nabs-ui-textarea__label`,a].filter(Boolean).join(` `);return(0,i.jsxs)(`div`,{className:p,children:[e?(0,i.jsx)(`label`,{className:h,htmlFor:f,children:e}):null,(0,i.jsx)(`textarea`,{ref:u,id:f,className:m,rows:s,"data-resize":c,...l})]})});l.displayName=`Textarea`;var u={none:``,top:`nabs-ui-textbox--label-top`,left:`nabs-ui-textbox--label-left`},d=(0,t.forwardRef)(({label:e,labelPosition:n=`top`,className:r=``,inputClassName:a=``,labelClassName:o=``,id:s,type:c=`text`,...l},d)=>{let f=(0,t.useId)(),p=s??`nabs-ui-textbox-${f.replace(/:/g,``)}`,m=[`nabs-ui-textbox`,e?u[n]??u.top:``,r].filter(Boolean).join(` `),h=[`nabs-ui-textbox__input`,a].filter(Boolean).join(` `),g=[`nabs-ui-textbox__label`,o].filter(Boolean).join(` `);return(0,i.jsxs)(`div`,{className:m,children:[e?(0,i.jsx)(`label`,{className:g,htmlFor:p,children:e}):null,(0,i.jsx)(`input`,{ref:d,id:p,className:h,type:c,...l})]})});d.displayName=`Textbox`;var f={type:`object`,properties:{}};function p(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function m(e){return!e||e.type!==`object`||!p(e.properties)?{}:Object.fromEntries(Object.entries(e.properties).map(([e,t])=>[e,h(t)]))}function h(e){if(!e||!p(e))return``;if(e.default!==void 0)return e.default;if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];switch(e.type){case`boolean`:return!1;case`integer`:case`number`:return``;case`object`:return m(e);default:return``}}function g(e,t){if(!e||!p(e))return t;if(e.type===`object`&&p(e.properties)){let n=p(t)?t:{};return Object.fromEntries(Object.entries(e.properties).map(([e,t])=>[e,g(t,n[e]===void 0?h(t):n[e])]))}if(e.type===`boolean`)return t===!0;if(e.type===`integer`){if(t===``||t==null)return``;let e=Number.parseInt(String(t),10);return Number.isNaN(e)?``:e}if(e.type===`number`){if(t===``||t==null)return``;let e=Number.parseFloat(String(t));return Number.isNaN(e)?``:e}return t??``}function _(e){return!e||!p(e)?`textbox`:Array.isArray(e.enum)&&e.enum.length>0?`radio`:e.type===`string`?e.maxLength!==void 0&&e.maxLength>50?`textarea`:`textbox`:e.type===`integer`?`int`:e.type===`number`?String(e.format??``).toLowerCase()===`decimal`?`decimal`:`double`:e.type===`boolean`?`bool`:`textbox`}function v({schema:e,name:t,value:n,onChange:r}){let a=e.title??t,s=e.description,u=_(e),f=n??h(e);if(u===`radio`){let n=Array.isArray(e.enum)?e.enum:[];return(0,i.jsxs)(`fieldset`,{className:`nabs-ui-dynamicform__fieldset`,children:[(0,i.jsx)(`legend`,{className:`nabs-ui-dynamicform__legend`,children:a}),s?(0,i.jsx)(`p`,{className:`nabs-ui-dynamicform__description`,children:s}):null,(0,i.jsx)(`div`,{className:`nabs-ui-dynamicform__radioGroup`,children:n.map(e=>(0,i.jsx)(c,{label:String(e),name:t,checked:f===e,onChange:()=>r(e)},String(e)))})]})}return u===`textarea`?(0,i.jsx)(l,{label:a,rows:5,value:String(f??``),placeholder:String(e.default??``),onChange:e=>r(e.target.value)}):u===`bool`?(0,i.jsx)(o,{label:a,checked:f===!0,onChange:e=>r(e.target.checked)}):(0,i.jsx)(d,{label:a,type:u===`int`||u===`decimal`||u===`double`?`number`:`text`,step:u===`int`?1:u===`decimal`||u===`double`?`any`:void 0,value:String(f??``),placeholder:String(e.default??``),onChange:e=>{let t=e.target.value;if(u===`int`){r(t===``?``:Number.parseInt(t,10));return}if(u===`decimal`||u===`double`){r(t===``?``:Number.parseFloat(t));return}r(t)}})}var y=(0,t.forwardRef)(function({schema:e,value:n,onChange:r,className:a=``,id:o,disabled:s=!1,...c},l){let u=(0,t.useId)(),d=o??`nabs-ui-dynamicform-${u.replace(/:/g,``)}`,h=e&&e.type===`object`?e:f,[_,y]=(0,t.useState)(()=>g(h,n??m(h)));(0,t.useEffect)(()=>{y(g(h,n??m(h)))},[h,n]);let b=p(_)?_:{},x=h.title??`Dynamic form`,S=h.description,C=[`nabs-ui-dynamicform`,s?`nabs-ui-dynamicform--disabled`:``,a].filter(Boolean).join(` `),w=e=>{y(e),r?.(e)};return s?(0,i.jsxs)(`div`,{ref:l,id:d,className:C,"aria-disabled":`true`,...c,children:[(0,i.jsxs)(`div`,{className:`nabs-ui-dynamicform__header`,children:[(0,i.jsx)(`div`,{className:`nabs-ui-dynamicform__title`,children:x}),S?(0,i.jsx)(`div`,{className:`nabs-ui-dynamicform__description`,children:S}):null]}),(0,i.jsx)(`div`,{className:`nabs-ui-dynamicform__fields`,children:Object.entries(h.properties??{}).map(([e,t])=>(0,i.jsx)(`div`,{className:`nabs-ui-dynamicform__field`,children:(0,i.jsx)(v,{schema:t,name:e,value:b[e],onChange:n=>w({...b,[e]:g(t,n)})})},e))})]}):(0,i.jsxs)(`div`,{ref:l,id:d,className:C,...c,children:[(0,i.jsxs)(`div`,{className:`nabs-ui-dynamicform__header`,children:[(0,i.jsx)(`div`,{className:`nabs-ui-dynamicform__title`,children:x}),S?(0,i.jsx)(`div`,{className:`nabs-ui-dynamicform__description`,children:S}):null]}),(0,i.jsx)(`div`,{className:`nabs-ui-dynamicform__fields`,children:Object.entries(h.properties??{}).map(([e,t])=>(0,i.jsx)(`div`,{className:`nabs-ui-dynamicform__field`,children:(0,i.jsx)(v,{schema:t,name:e,value:b[e],onChange:n=>w({...b,[e]:g(t,n)})})},e))})]})});y.displayName=`DynamicForm`,exports.DynamicForm=y;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.nabs-ui-checkbox{box-sizing:border-box;color:#0f172a;cursor:pointer;font:inherit;border:1px solid #cbd5e1;border-radius:.875rem;align-items:center;gap:.75rem;min-width:0;padding:.8rem 1rem;transition:border-color .12s,box-shadow .12s,background-color .12s,transform .12s;display:inline-flex}.nabs-ui-checkbox:hover{background:#f8fafc;transform:translateY(-1px)}.nabs-ui-checkbox:focus-within{border-color:#0f172a;box-shadow:0 0 0 4px #0f172a1a}.nabs-ui-checkbox__input{accent-color:#0f172a;flex:none;margin:0}.nabs-ui-checkbox__label{font-size:.95rem;font-weight:600;line-height:1.2}.nabs-ui-checkbox--label-left{flex-direction:row-reverse}.nabs-ui-checkbox--label-top,.nabs-ui-checkbox--label-bottom{align-items:stretch;gap:.5rem}.nabs-ui-checkbox--label-top{flex-direction:column-reverse}.nabs-ui-checkbox--label-bottom{flex-direction:column}.nabs-ui-checkbox--label-top .nabs-ui-checkbox__label,.nabs-ui-checkbox--label-bottom .nabs-ui-checkbox__label{width:100%}.nabs-ui-checkbox--disabled{cursor:not-allowed;opacity:.6}.nabs-ui-radiobutton{box-sizing:border-box;color:#0f172a;cursor:pointer;font:inherit;border:1px solid #cbd5e1;border-radius:.875rem;align-items:center;gap:.75rem;min-width:0;padding:.8rem 1rem;transition:border-color .12s,box-shadow .12s,background-color .12s,transform .12s;display:inline-flex}.nabs-ui-radiobutton:hover{background:#f8fafc;transform:translateY(-1px)}.nabs-ui-radiobutton:focus-within{border-color:#0f172a;box-shadow:0 0 0 4px #0f172a1a}.nabs-ui-radiobutton__input{accent-color:#0f172a;flex:none;margin:0}.nabs-ui-radiobutton__label{font-size:.95rem;font-weight:600;line-height:1.2}.nabs-ui-radiobutton--label-left{flex-direction:row-reverse}.nabs-ui-radiobutton--label-top,.nabs-ui-radiobutton--label-bottom{align-items:stretch;gap:.5rem}.nabs-ui-radiobutton--label-top{flex-direction:column-reverse}.nabs-ui-radiobutton--label-bottom{flex-direction:column}.nabs-ui-radiobutton--label-top .nabs-ui-radiobutton__label,.nabs-ui-radiobutton--label-bottom .nabs-ui-radiobutton__label{width:100%}.nabs-ui-radiobutton--disabled{cursor:not-allowed;opacity:.6}.nabs-ui-textarea{gap:.5rem;min-width:0;display:grid}.nabs-ui-textarea__label{color:#0f172a;font-size:.95rem;font-weight:600;line-height:1.2}.nabs-ui-textarea__input{box-sizing:border-box;color:#0f172a;font:inherit;resize:vertical;background:#fff;border:1px solid #cbd5e1;border-radius:.875rem;width:100%;min-width:0;min-height:8rem;padding:.85rem 1rem;transition:border-color .12s,box-shadow .12s,background-color .12s}.nabs-ui-textarea__input[data-resize=none]{resize:none}.nabs-ui-textarea__input[data-resize=both]{resize:both}.nabs-ui-textarea__input[data-resize=horizontal]{resize:horizontal}.nabs-ui-textarea__input:focus{border-color:#0f172a;outline:none;box-shadow:0 0 0 4px #0f172a1a}.nabs-ui-textarea__input:disabled{cursor:not-allowed;opacity:.6}.nabs-ui-textbox{gap:.7rem;display:grid}.nabs-ui-textbox__label{color:#0f172a;font-size:.95rem;font-weight:600}.nabs-ui-textbox__input{appearance:none;box-sizing:border-box;color:#0f172a;font:inherit;background:#fff;border:1px solid #cbd5e1;border-radius:.875rem;width:100%;min-height:3rem;padding:.8rem 1rem;line-height:1.4;transition:border-color .12s,box-shadow .12s,background-color .12s}.nabs-ui-textbox__input::placeholder{color:#94a3b8}.nabs-ui-textbox__input:hover:not(:disabled){border-color:#94a3b8}.nabs-ui-textbox__input:focus{border-color:#0f172a;outline:none;box-shadow:0 0 0 4px #0f172a1a}.nabs-ui-textbox__input:disabled{color:#64748b;cursor:not-allowed;background:#f8fafc}.nabs-ui-textbox--label-left{align-items:center;gap:1rem;display:flex}.nabs-ui-textbox--label-left .nabs-ui-textbox__label{flex:0 0 9rem}.nabs-ui-textbox--label-left .nabs-ui-textbox__input{flex:auto}@media (width<=640px){.nabs-ui-textbox--label-left{flex-direction:column;align-items:stretch;gap:.7rem}.nabs-ui-textbox--label-left .nabs-ui-textbox__label{flex-basis:auto}}.nabs-ui-dynamicform{color:#0f172a;gap:1rem;display:grid}.nabs-ui-dynamicform__header{gap:.35rem;display:grid}.nabs-ui-dynamicform__title{font-size:1rem;font-weight:800;line-height:1.2}.nabs-ui-dynamicform__description{color:#475569;margin:0;font-size:.9rem;line-height:1.45}.nabs-ui-dynamicform__fields{gap:1rem;display:grid}.nabs-ui-dynamicform__field{min-width:0}.nabs-ui-dynamicform__fieldset{border:1px solid #d5d9e0;border-radius:1rem;gap:.85rem;min-width:0;margin:0;padding:1rem;display:grid}.nabs-ui-dynamicform__legend{padding:0 .25rem;font-size:.95rem;font-weight:800}.nabs-ui-dynamicform__radioGroup{gap:.65rem;display:grid}.nabs-ui-dynamicform--disabled{opacity:.72}
|
|
2
|
+
/*$vite$:1*/
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { forwardRef as e, useEffect as t, useId as n, useState as r } from "react";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var i = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), a = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
4
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
5
|
+
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
6
|
+
}), o = /* @__PURE__ */ i(((e) => {
|
|
7
|
+
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
8
|
+
function r(e, n, r) {
|
|
9
|
+
var i = null;
|
|
10
|
+
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]);
|
|
11
|
+
else r = n;
|
|
12
|
+
return n = r.ref, {
|
|
13
|
+
$$typeof: t,
|
|
14
|
+
type: e,
|
|
15
|
+
key: i,
|
|
16
|
+
ref: n === void 0 ? null : n,
|
|
17
|
+
props: r
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
e.Fragment = n, e.jsx = r, e.jsxs = r;
|
|
21
|
+
})), s = /* @__PURE__ */ i(((e) => {
|
|
22
|
+
process.env.NODE_ENV !== "production" && (function() {
|
|
23
|
+
function t(e) {
|
|
24
|
+
if (e == null) return null;
|
|
25
|
+
if (typeof e == "function") return e.$$typeof === k ? null : e.displayName || e.name || null;
|
|
26
|
+
if (typeof e == "string") return e;
|
|
27
|
+
switch (e) {
|
|
28
|
+
case v: return "Fragment";
|
|
29
|
+
case b: return "Profiler";
|
|
30
|
+
case y: return "StrictMode";
|
|
31
|
+
case w: return "Suspense";
|
|
32
|
+
case T: return "SuspenseList";
|
|
33
|
+
case O: return "Activity";
|
|
34
|
+
}
|
|
35
|
+
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) {
|
|
36
|
+
case _: return "Portal";
|
|
37
|
+
case S: return e.displayName || "Context";
|
|
38
|
+
case x: return (e._context.displayName || "Context") + ".Consumer";
|
|
39
|
+
case C:
|
|
40
|
+
var n = e.render;
|
|
41
|
+
return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
|
|
42
|
+
case E: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
|
|
43
|
+
case D:
|
|
44
|
+
n = e._payload, e = e._init;
|
|
45
|
+
try {
|
|
46
|
+
return t(e(n));
|
|
47
|
+
} catch {}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
function n(e) {
|
|
52
|
+
return "" + e;
|
|
53
|
+
}
|
|
54
|
+
function r(e) {
|
|
55
|
+
try {
|
|
56
|
+
n(e);
|
|
57
|
+
var t = !1;
|
|
58
|
+
} catch {
|
|
59
|
+
t = !0;
|
|
60
|
+
}
|
|
61
|
+
if (t) {
|
|
62
|
+
t = console;
|
|
63
|
+
var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
64
|
+
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);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function i(e) {
|
|
68
|
+
if (e === v) return "<>";
|
|
69
|
+
if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
|
|
70
|
+
try {
|
|
71
|
+
var n = t(e);
|
|
72
|
+
return n ? "<" + n + ">" : "<...>";
|
|
73
|
+
} catch {
|
|
74
|
+
return "<...>";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function o() {
|
|
78
|
+
var e = A.A;
|
|
79
|
+
return e === null ? null : e.getOwner();
|
|
80
|
+
}
|
|
81
|
+
function s() {
|
|
82
|
+
return Error("react-stack-top-frame");
|
|
83
|
+
}
|
|
84
|
+
function c(e) {
|
|
85
|
+
if (j.call(e, "key")) {
|
|
86
|
+
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
87
|
+
if (t && t.isReactWarning) return !1;
|
|
88
|
+
}
|
|
89
|
+
return e.key !== void 0;
|
|
90
|
+
}
|
|
91
|
+
function l(e, t) {
|
|
92
|
+
function n() {
|
|
93
|
+
P || (P = !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));
|
|
94
|
+
}
|
|
95
|
+
n.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
96
|
+
get: n,
|
|
97
|
+
configurable: !0
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function u() {
|
|
101
|
+
var e = t(this.type);
|
|
102
|
+
return F[e] || (F[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;
|
|
103
|
+
}
|
|
104
|
+
function d(e, t, n, r, i, a) {
|
|
105
|
+
var o = n.ref;
|
|
106
|
+
return e = {
|
|
107
|
+
$$typeof: g,
|
|
108
|
+
type: e,
|
|
109
|
+
key: t,
|
|
110
|
+
props: n,
|
|
111
|
+
_owner: r
|
|
112
|
+
}, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
|
|
113
|
+
enumerable: !1,
|
|
114
|
+
value: null
|
|
115
|
+
}) : Object.defineProperty(e, "ref", {
|
|
116
|
+
enumerable: !1,
|
|
117
|
+
get: u
|
|
118
|
+
}), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
119
|
+
configurable: !1,
|
|
120
|
+
enumerable: !1,
|
|
121
|
+
writable: !0,
|
|
122
|
+
value: 0
|
|
123
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
124
|
+
configurable: !1,
|
|
125
|
+
enumerable: !1,
|
|
126
|
+
writable: !0,
|
|
127
|
+
value: null
|
|
128
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
129
|
+
configurable: !1,
|
|
130
|
+
enumerable: !1,
|
|
131
|
+
writable: !0,
|
|
132
|
+
value: i
|
|
133
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
134
|
+
configurable: !1,
|
|
135
|
+
enumerable: !1,
|
|
136
|
+
writable: !0,
|
|
137
|
+
value: a
|
|
138
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
139
|
+
}
|
|
140
|
+
function f(e, n, i, a, s, u) {
|
|
141
|
+
var f = n.children;
|
|
142
|
+
if (f !== void 0) if (a) if (M(f)) {
|
|
143
|
+
for (a = 0; a < f.length; a++) p(f[a]);
|
|
144
|
+
Object.freeze && Object.freeze(f);
|
|
145
|
+
} 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.");
|
|
146
|
+
else p(f);
|
|
147
|
+
if (j.call(n, "key")) {
|
|
148
|
+
f = t(e);
|
|
149
|
+
var m = Object.keys(n).filter(function(e) {
|
|
150
|
+
return e !== "key";
|
|
151
|
+
});
|
|
152
|
+
a = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", R[f + a] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", a, f, m, f), R[f + a] = !0);
|
|
153
|
+
}
|
|
154
|
+
if (f = null, i !== void 0 && (r(i), f = "" + i), c(n) && (r(n.key), f = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
|
|
155
|
+
else i = n;
|
|
156
|
+
return f && l(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), d(e, f, i, o(), s, u);
|
|
157
|
+
}
|
|
158
|
+
function p(e) {
|
|
159
|
+
m(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? m(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
160
|
+
}
|
|
161
|
+
function m(e) {
|
|
162
|
+
return typeof e == "object" && !!e && e.$$typeof === g;
|
|
163
|
+
}
|
|
164
|
+
var h = a("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), k = Symbol.for("react.client.reference"), A = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
|
|
165
|
+
return null;
|
|
166
|
+
};
|
|
167
|
+
h = { react_stack_bottom_frame: function(e) {
|
|
168
|
+
return e();
|
|
169
|
+
} };
|
|
170
|
+
var P, F = {}, I = h.react_stack_bottom_frame.bind(h, s)(), L = N(i(s)), R = {};
|
|
171
|
+
e.Fragment = v, e.jsx = function(e, t, n) {
|
|
172
|
+
var r = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
173
|
+
return f(e, t, n, !1, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
|
|
174
|
+
}, e.jsxs = function(e, t, n) {
|
|
175
|
+
var r = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
176
|
+
return f(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
|
|
177
|
+
};
|
|
178
|
+
})();
|
|
179
|
+
})), c = (/* @__PURE__ */ i(((e, t) => {
|
|
180
|
+
process.env.NODE_ENV === "production" ? t.exports = o() : t.exports = s();
|
|
181
|
+
})))(), l = {
|
|
182
|
+
right: "nabs-ui-checkbox--label-right",
|
|
183
|
+
left: "nabs-ui-checkbox--label-left",
|
|
184
|
+
top: "nabs-ui-checkbox--label-top",
|
|
185
|
+
bottom: "nabs-ui-checkbox--label-bottom"
|
|
186
|
+
}, u = e(function({ label: e = "Checkbox", labelPosition: t = "right", className: r = "", inputClassName: i = "", labelClassName: a = "", id: o, disabled: s, ...u }, d) {
|
|
187
|
+
let f = n(), p = o ?? `nabs-ui-checkbox-${f.replace(/:/g, "")}`, m = [
|
|
188
|
+
"nabs-ui-checkbox",
|
|
189
|
+
s ? "nabs-ui-checkbox--disabled" : "",
|
|
190
|
+
l[t] ?? l.right,
|
|
191
|
+
r
|
|
192
|
+
].filter(Boolean).join(" "), h = ["nabs-ui-checkbox__input", i].filter(Boolean).join(" "), g = ["nabs-ui-checkbox__label", a].filter(Boolean).join(" ");
|
|
193
|
+
return /* @__PURE__ */ (0, c.jsxs)("label", {
|
|
194
|
+
className: m,
|
|
195
|
+
htmlFor: p,
|
|
196
|
+
children: [/* @__PURE__ */ (0, c.jsx)("input", {
|
|
197
|
+
ref: d,
|
|
198
|
+
id: p,
|
|
199
|
+
className: h,
|
|
200
|
+
type: "checkbox",
|
|
201
|
+
disabled: s,
|
|
202
|
+
...u
|
|
203
|
+
}), /* @__PURE__ */ (0, c.jsx)("span", {
|
|
204
|
+
className: g,
|
|
205
|
+
children: e
|
|
206
|
+
})]
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
u.displayName = "Checkbox";
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region ../nabs-ui-radiobutton/src/RadioButton.tsx
|
|
212
|
+
var d = {
|
|
213
|
+
right: "nabs-ui-radiobutton--label-right",
|
|
214
|
+
left: "nabs-ui-radiobutton--label-left",
|
|
215
|
+
top: "nabs-ui-radiobutton--label-top",
|
|
216
|
+
bottom: "nabs-ui-radiobutton--label-bottom"
|
|
217
|
+
};
|
|
218
|
+
function f({ label: e = "Radio button", labelPosition: t = "right", className: r = "", inputClassName: i = "", labelClassName: a = "", id: o, ...s }) {
|
|
219
|
+
let l = s.disabled === !0, u = n(), f = o ?? `nabs-ui-radiobutton-${u.replace(/:/g, "")}`, p = [
|
|
220
|
+
"nabs-ui-radiobutton",
|
|
221
|
+
l ? "nabs-ui-radiobutton--disabled" : "",
|
|
222
|
+
d[t] ?? d.right,
|
|
223
|
+
r
|
|
224
|
+
].filter(Boolean).join(" "), m = ["nabs-ui-radiobutton__input", i].filter(Boolean).join(" "), h = ["nabs-ui-radiobutton__label", a].filter(Boolean).join(" ");
|
|
225
|
+
return /* @__PURE__ */ (0, c.jsxs)("label", {
|
|
226
|
+
className: p,
|
|
227
|
+
htmlFor: f,
|
|
228
|
+
children: [/* @__PURE__ */ (0, c.jsx)("input", {
|
|
229
|
+
id: f,
|
|
230
|
+
className: m,
|
|
231
|
+
type: "radio",
|
|
232
|
+
...s
|
|
233
|
+
}), /* @__PURE__ */ (0, c.jsx)("span", {
|
|
234
|
+
className: h,
|
|
235
|
+
children: e
|
|
236
|
+
})]
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region ../nabs-ui-textarea/src/Textarea.tsx
|
|
241
|
+
var p = e(({ label: e, className: t = "", inputClassName: r = "", labelClassName: i = "", id: a, rows: o = 4, resize: s = "vertical", ...l }, u) => {
|
|
242
|
+
let d = n(), f = a ?? `nabs-ui-textarea-${d.replace(/:/g, "")}`, p = ["nabs-ui-textarea", t].filter(Boolean).join(" "), m = ["nabs-ui-textarea__input", r].filter(Boolean).join(" "), h = ["nabs-ui-textarea__label", i].filter(Boolean).join(" ");
|
|
243
|
+
return /* @__PURE__ */ (0, c.jsxs)("div", {
|
|
244
|
+
className: p,
|
|
245
|
+
children: [e ? /* @__PURE__ */ (0, c.jsx)("label", {
|
|
246
|
+
className: h,
|
|
247
|
+
htmlFor: f,
|
|
248
|
+
children: e
|
|
249
|
+
}) : null, /* @__PURE__ */ (0, c.jsx)("textarea", {
|
|
250
|
+
ref: u,
|
|
251
|
+
id: f,
|
|
252
|
+
className: m,
|
|
253
|
+
rows: o,
|
|
254
|
+
"data-resize": s,
|
|
255
|
+
...l
|
|
256
|
+
})]
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
p.displayName = "Textarea";
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region ../nabs-ui-textbox/src/Textbox.tsx
|
|
262
|
+
var m = {
|
|
263
|
+
none: "",
|
|
264
|
+
top: "nabs-ui-textbox--label-top",
|
|
265
|
+
left: "nabs-ui-textbox--label-left"
|
|
266
|
+
}, h = e(({ label: e, labelPosition: t = "top", className: r = "", inputClassName: i = "", labelClassName: a = "", id: o, type: s = "text", ...l }, u) => {
|
|
267
|
+
let d = n(), f = o ?? `nabs-ui-textbox-${d.replace(/:/g, "")}`, p = [
|
|
268
|
+
"nabs-ui-textbox",
|
|
269
|
+
e ? m[t] ?? m.top : "",
|
|
270
|
+
r
|
|
271
|
+
].filter(Boolean).join(" "), h = ["nabs-ui-textbox__input", i].filter(Boolean).join(" "), g = ["nabs-ui-textbox__label", a].filter(Boolean).join(" ");
|
|
272
|
+
return /* @__PURE__ */ (0, c.jsxs)("div", {
|
|
273
|
+
className: p,
|
|
274
|
+
children: [e ? /* @__PURE__ */ (0, c.jsx)("label", {
|
|
275
|
+
className: g,
|
|
276
|
+
htmlFor: f,
|
|
277
|
+
children: e
|
|
278
|
+
}) : null, /* @__PURE__ */ (0, c.jsx)("input", {
|
|
279
|
+
ref: u,
|
|
280
|
+
id: f,
|
|
281
|
+
className: h,
|
|
282
|
+
type: s,
|
|
283
|
+
...l
|
|
284
|
+
})]
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
h.displayName = "Textbox";
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region src/DynamicForm.tsx
|
|
290
|
+
var g = {
|
|
291
|
+
type: "object",
|
|
292
|
+
properties: {}
|
|
293
|
+
};
|
|
294
|
+
function _(e) {
|
|
295
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
296
|
+
}
|
|
297
|
+
function v(e) {
|
|
298
|
+
return !e || e.type !== "object" || !_(e.properties) ? {} : Object.fromEntries(Object.entries(e.properties).map(([e, t]) => [e, y(t)]));
|
|
299
|
+
}
|
|
300
|
+
function y(e) {
|
|
301
|
+
if (!e || !_(e)) return "";
|
|
302
|
+
if (e.default !== void 0) return e.default;
|
|
303
|
+
if (Array.isArray(e.enum) && e.enum.length > 0) return e.enum[0];
|
|
304
|
+
switch (e.type) {
|
|
305
|
+
case "boolean": return !1;
|
|
306
|
+
case "integer":
|
|
307
|
+
case "number": return "";
|
|
308
|
+
case "object": return v(e);
|
|
309
|
+
default: return "";
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function b(e, t) {
|
|
313
|
+
if (!e || !_(e)) return t;
|
|
314
|
+
if (e.type === "object" && _(e.properties)) {
|
|
315
|
+
let n = _(t) ? t : {};
|
|
316
|
+
return Object.fromEntries(Object.entries(e.properties).map(([e, t]) => [e, b(t, n[e] === void 0 ? y(t) : n[e])]));
|
|
317
|
+
}
|
|
318
|
+
if (e.type === "boolean") return t === !0;
|
|
319
|
+
if (e.type === "integer") {
|
|
320
|
+
if (t === "" || t == null) return "";
|
|
321
|
+
let e = Number.parseInt(String(t), 10);
|
|
322
|
+
return Number.isNaN(e) ? "" : e;
|
|
323
|
+
}
|
|
324
|
+
if (e.type === "number") {
|
|
325
|
+
if (t === "" || t == null) return "";
|
|
326
|
+
let e = Number.parseFloat(String(t));
|
|
327
|
+
return Number.isNaN(e) ? "" : e;
|
|
328
|
+
}
|
|
329
|
+
return t ?? "";
|
|
330
|
+
}
|
|
331
|
+
function x(e) {
|
|
332
|
+
return !e || !_(e) ? "textbox" : Array.isArray(e.enum) && e.enum.length > 0 ? "radio" : e.type === "string" ? e.maxLength !== void 0 && e.maxLength > 50 ? "textarea" : "textbox" : e.type === "integer" ? "int" : e.type === "number" ? String(e.format ?? "").toLowerCase() === "decimal" ? "decimal" : "double" : e.type === "boolean" ? "bool" : "textbox";
|
|
333
|
+
}
|
|
334
|
+
function S({ schema: e, name: t, value: n, onChange: r }) {
|
|
335
|
+
let i = e.title ?? t, a = e.description, o = x(e), s = n ?? y(e);
|
|
336
|
+
if (o === "radio") {
|
|
337
|
+
let n = Array.isArray(e.enum) ? e.enum : [];
|
|
338
|
+
return /* @__PURE__ */ (0, c.jsxs)("fieldset", {
|
|
339
|
+
className: "nabs-ui-dynamicform__fieldset",
|
|
340
|
+
children: [
|
|
341
|
+
/* @__PURE__ */ (0, c.jsx)("legend", {
|
|
342
|
+
className: "nabs-ui-dynamicform__legend",
|
|
343
|
+
children: i
|
|
344
|
+
}),
|
|
345
|
+
a ? /* @__PURE__ */ (0, c.jsx)("p", {
|
|
346
|
+
className: "nabs-ui-dynamicform__description",
|
|
347
|
+
children: a
|
|
348
|
+
}) : null,
|
|
349
|
+
/* @__PURE__ */ (0, c.jsx)("div", {
|
|
350
|
+
className: "nabs-ui-dynamicform__radioGroup",
|
|
351
|
+
children: n.map((e) => /* @__PURE__ */ (0, c.jsx)(f, {
|
|
352
|
+
label: String(e),
|
|
353
|
+
name: t,
|
|
354
|
+
checked: s === e,
|
|
355
|
+
onChange: () => r(e)
|
|
356
|
+
}, String(e)))
|
|
357
|
+
})
|
|
358
|
+
]
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
return o === "textarea" ? /* @__PURE__ */ (0, c.jsx)(p, {
|
|
362
|
+
label: i,
|
|
363
|
+
rows: 5,
|
|
364
|
+
value: String(s ?? ""),
|
|
365
|
+
placeholder: String(e.default ?? ""),
|
|
366
|
+
onChange: (e) => r(e.target.value)
|
|
367
|
+
}) : o === "bool" ? /* @__PURE__ */ (0, c.jsx)(u, {
|
|
368
|
+
label: i,
|
|
369
|
+
checked: s === !0,
|
|
370
|
+
onChange: (e) => r(e.target.checked)
|
|
371
|
+
}) : /* @__PURE__ */ (0, c.jsx)(h, {
|
|
372
|
+
label: i,
|
|
373
|
+
type: o === "int" || o === "decimal" || o === "double" ? "number" : "text",
|
|
374
|
+
step: o === "int" ? 1 : o === "decimal" || o === "double" ? "any" : void 0,
|
|
375
|
+
value: String(s ?? ""),
|
|
376
|
+
placeholder: String(e.default ?? ""),
|
|
377
|
+
onChange: (e) => {
|
|
378
|
+
let t = e.target.value;
|
|
379
|
+
if (o === "int") {
|
|
380
|
+
r(t === "" ? "" : Number.parseInt(t, 10));
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (o === "decimal" || o === "double") {
|
|
384
|
+
r(t === "" ? "" : Number.parseFloat(t));
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
r(t);
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
var C = e(function({ schema: e, value: i, onChange: a, className: o = "", id: s, disabled: l = !1, ...u }, d) {
|
|
392
|
+
let f = n(), p = s ?? `nabs-ui-dynamicform-${f.replace(/:/g, "")}`, m = e && e.type === "object" ? e : g, [h, y] = r(() => b(m, i ?? v(m)));
|
|
393
|
+
t(() => {
|
|
394
|
+
y(b(m, i ?? v(m)));
|
|
395
|
+
}, [m, i]);
|
|
396
|
+
let x = _(h) ? h : {}, C = m.title ?? "Dynamic form", w = m.description, T = [
|
|
397
|
+
"nabs-ui-dynamicform",
|
|
398
|
+
l ? "nabs-ui-dynamicform--disabled" : "",
|
|
399
|
+
o
|
|
400
|
+
].filter(Boolean).join(" "), E = (e) => {
|
|
401
|
+
y(e), a?.(e);
|
|
402
|
+
};
|
|
403
|
+
return l ? /* @__PURE__ */ (0, c.jsxs)("div", {
|
|
404
|
+
ref: d,
|
|
405
|
+
id: p,
|
|
406
|
+
className: T,
|
|
407
|
+
"aria-disabled": "true",
|
|
408
|
+
...u,
|
|
409
|
+
children: [/* @__PURE__ */ (0, c.jsxs)("div", {
|
|
410
|
+
className: "nabs-ui-dynamicform__header",
|
|
411
|
+
children: [/* @__PURE__ */ (0, c.jsx)("div", {
|
|
412
|
+
className: "nabs-ui-dynamicform__title",
|
|
413
|
+
children: C
|
|
414
|
+
}), w ? /* @__PURE__ */ (0, c.jsx)("div", {
|
|
415
|
+
className: "nabs-ui-dynamicform__description",
|
|
416
|
+
children: w
|
|
417
|
+
}) : null]
|
|
418
|
+
}), /* @__PURE__ */ (0, c.jsx)("div", {
|
|
419
|
+
className: "nabs-ui-dynamicform__fields",
|
|
420
|
+
children: Object.entries(m.properties ?? {}).map(([e, t]) => /* @__PURE__ */ (0, c.jsx)("div", {
|
|
421
|
+
className: "nabs-ui-dynamicform__field",
|
|
422
|
+
children: /* @__PURE__ */ (0, c.jsx)(S, {
|
|
423
|
+
schema: t,
|
|
424
|
+
name: e,
|
|
425
|
+
value: x[e],
|
|
426
|
+
onChange: (n) => E({
|
|
427
|
+
...x,
|
|
428
|
+
[e]: b(t, n)
|
|
429
|
+
})
|
|
430
|
+
})
|
|
431
|
+
}, e))
|
|
432
|
+
})]
|
|
433
|
+
}) : /* @__PURE__ */ (0, c.jsxs)("div", {
|
|
434
|
+
ref: d,
|
|
435
|
+
id: p,
|
|
436
|
+
className: T,
|
|
437
|
+
...u,
|
|
438
|
+
children: [/* @__PURE__ */ (0, c.jsxs)("div", {
|
|
439
|
+
className: "nabs-ui-dynamicform__header",
|
|
440
|
+
children: [/* @__PURE__ */ (0, c.jsx)("div", {
|
|
441
|
+
className: "nabs-ui-dynamicform__title",
|
|
442
|
+
children: C
|
|
443
|
+
}), w ? /* @__PURE__ */ (0, c.jsx)("div", {
|
|
444
|
+
className: "nabs-ui-dynamicform__description",
|
|
445
|
+
children: w
|
|
446
|
+
}) : null]
|
|
447
|
+
}), /* @__PURE__ */ (0, c.jsx)("div", {
|
|
448
|
+
className: "nabs-ui-dynamicform__fields",
|
|
449
|
+
children: Object.entries(m.properties ?? {}).map(([e, t]) => /* @__PURE__ */ (0, c.jsx)("div", {
|
|
450
|
+
className: "nabs-ui-dynamicform__field",
|
|
451
|
+
children: /* @__PURE__ */ (0, c.jsx)(S, {
|
|
452
|
+
schema: t,
|
|
453
|
+
name: e,
|
|
454
|
+
value: x[e],
|
|
455
|
+
onChange: (n) => E({
|
|
456
|
+
...x,
|
|
457
|
+
[e]: b(t, n)
|
|
458
|
+
})
|
|
459
|
+
})
|
|
460
|
+
}, e))
|
|
461
|
+
})]
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
C.displayName = "DynamicForm";
|
|
465
|
+
//#endregion
|
|
466
|
+
export { C as DynamicForm };
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@net-advantage/nabs-ui-dynamicform",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Reusable schema-driven dynamic form for the Nabs UI library.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/nabs-ui-dynamicform.cjs",
|
|
7
|
+
"module": "./dist/nabs-ui-dynamicform.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/nabs-ui-dynamicform.js",
|
|
11
|
+
"require": "./dist/nabs-ui-dynamicform.cjs"
|
|
12
|
+
},
|
|
13
|
+
"./DynamicForm": "./src/DynamicForm.tsx",
|
|
14
|
+
"./style.css": "./dist/nabs-ui-dynamicform.css"
|
|
15
|
+
},
|
|
16
|
+
"files": ["dist"],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "vite build",
|
|
19
|
+
"dev": "vite"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"react": "^19.0.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/react": "^19.0.0",
|
|
26
|
+
"@types/react-dom": "^19.0.0",
|
|
27
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
28
|
+
"react-dom": "^19.2.6",
|
|
29
|
+
"typescript": "^5.8.0",
|
|
30
|
+
"vite": "^8.0.12"
|
|
31
|
+
}
|
|
32
|
+
}
|