@net-advantage/nabs-ui-dynamicform 0.23.0 → 0.24.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.
|
@@ -1,6 +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})),
|
|
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={right:`nabs-ui-checkbox--label-right`,left:`nabs-ui-checkbox--label-left`,top:`nabs-ui-checkbox--label-top`,bottom:`nabs-ui-checkbox--label-bottom`},r=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})),i=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
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)}})()})),
|
|
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)}})()})),a=e(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=r():t.exports=i()}))(),o=(0,t.forwardRef)(function({label:e=`Checkbox`,labelPosition:r=`right`,className:i=``,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`:``,n[r]??n.right,i].filter(Boolean).join(` `),h=[`nabs-ui-checkbox__input`,o].filter(Boolean).join(` `),g=[`nabs-ui-checkbox__label`,s].filter(Boolean).join(` `);return(0,a.jsxs)(`label`,{className:m,htmlFor:p,children:[(0,a.jsx)(`input`,{ref:d,id:p,className:h,type:`checkbox`,disabled:l,...u}),(0,a.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:i=``,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`,i].filter(Boolean).join(` `),h=[`nabs-ui-radiobutton__label`,o].filter(Boolean).join(` `);return(0,a.jsxs)(`label`,{className:p,htmlFor:f,children:[(0,a.jsx)(`input`,{id:f,className:m,type:`radio`,...l}),(0,a.jsx)(`span`,{className:h,children:e})]})}var l=(0,t.forwardRef)(({label:e,className:n=``,inputClassName:r=``,labelClassName:i=``,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`,i].filter(Boolean).join(` `);return(0,a.jsxs)(`div`,{className:p,children:[e?(0,a.jsx)(`label`,{className:h,htmlFor:f,children:e}):null,(0,a.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:i=``,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`,i].filter(Boolean).join(` `),g=[`nabs-ui-textbox__label`,o].filter(Boolean).join(` `);return(0,a.jsxs)(`div`,{className:m,children:[e?(0,a.jsx)(`label`,{className:g,htmlFor:p,children:e}):null,(0,a.jsx)(`input`,{ref:d,id:p,className:h,type:c,...l})]})});d.displayName=`Textbox`;function f(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function p(e){return!e||e.type!==`object`||!f(e.properties)?{}:Object.fromEntries(Object.entries(e.properties).map(([e,t])=>[e,m(t)]))}function m(e){if(!e||!f(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 p(e);default:return``}}function h(e,t){if(!e||!f(e))return t;if(e.type===`object`&&f(e.properties)){let n=f(t)?t:{};return Object.fromEntries(Object.entries(e.properties).map(([e,t])=>[e,h(t,n[e]===void 0?m(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 g(e){return!e||!f(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`}var _={type:`object`,properties:{}};function v({schema:e,name:t,value:n,onChange:r}){let i=e.title??t,s=e.description,u=g(e),f=n??m(e);if(u===`radio`){let n=Array.isArray(e.enum)?e.enum:[];return(0,a.jsxs)(`fieldset`,{className:`nabs-ui-dynamicform__fieldset`,children:[(0,a.jsx)(`legend`,{className:`nabs-ui-dynamicform__legend`,children:i}),s?(0,a.jsx)(`p`,{className:`nabs-ui-dynamicform__description`,children:s}):null,(0,a.jsx)(`div`,{className:`nabs-ui-dynamicform__radioGroup`,children:n.map(e=>(0,a.jsx)(c,{label:String(e),name:t,checked:f===e,onChange:()=>r(e)},String(e)))})]})}return u===`textarea`?(0,a.jsx)(l,{label:i,rows:5,value:String(f??``),placeholder:String(e.default??``),onChange:e=>r(e.target.value)}):u===`bool`?(0,a.jsx)(o,{label:i,checked:f===!0,onChange:e=>r(e.target.checked)}):(0,a.jsx)(d,{label:i,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:i=``,id:o,disabled:s=!1,...c},l){let u=(0,t.useId)(),d=o??`nabs-ui-dynamicform-${u.replace(/:/g,``)}`,m=e&&e.type===`object`?e:_,[g,y]=(0,t.useState)(()=>h(m,n??p(m)));(0,t.useEffect)(()=>{y(h(m,n??p(m)))},[m,n]);let b=f(g)?g:{},x=m.title??`Dynamic form`,S=m.description,C=[`nabs-ui-dynamicform`,s?`nabs-ui-dynamicform--disabled`:``,i].filter(Boolean).join(` `),w=e=>{y(e),r?.(e)};return s?(0,a.jsxs)(`div`,{ref:l,id:d,className:C,"aria-disabled":`true`,...c,children:[(0,a.jsxs)(`div`,{className:`nabs-ui-dynamicform__header`,children:[(0,a.jsx)(`div`,{className:`nabs-ui-dynamicform__title`,children:x}),S?(0,a.jsx)(`div`,{className:`nabs-ui-dynamicform__description`,children:S}):null]}),(0,a.jsx)(`div`,{className:`nabs-ui-dynamicform__fields`,children:Object.entries(m.properties??{}).map(([e,t])=>(0,a.jsx)(`div`,{className:`nabs-ui-dynamicform__field`,children:(0,a.jsx)(v,{schema:t,name:e,value:b[e],onChange:n=>w({...b,[e]:h(t,n)})})},e))})]}):(0,a.jsxs)(`div`,{ref:l,id:d,className:C,...c,children:[(0,a.jsxs)(`div`,{className:`nabs-ui-dynamicform__header`,children:[(0,a.jsx)(`div`,{className:`nabs-ui-dynamicform__title`,children:x}),S?(0,a.jsx)(`div`,{className:`nabs-ui-dynamicform__description`,children:S}):null]}),(0,a.jsx)(`div`,{className:`nabs-ui-dynamicform__fields`,children:Object.entries(m.properties??{}).map(([e,t])=>(0,a.jsx)(`div`,{className:`nabs-ui-dynamicform__field`,children:(0,a.jsx)(v,{schema:t,name:e,value:b[e],onChange:n=>w({...b,[e]:h(t,n)})})},e))})]})});y.displayName=`DynamicForm`,exports.DynamicForm=y;
|
|
@@ -3,7 +3,12 @@ import { forwardRef as e, useEffect as t, useId as n, useState as r } from "reac
|
|
|
3
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
4
|
if (typeof require < "u") return require.apply(this, arguments);
|
|
5
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 =
|
|
6
|
+
}), o = {
|
|
7
|
+
right: "nabs-ui-checkbox--label-right",
|
|
8
|
+
left: "nabs-ui-checkbox--label-left",
|
|
9
|
+
top: "nabs-ui-checkbox--label-top",
|
|
10
|
+
bottom: "nabs-ui-checkbox--label-bottom"
|
|
11
|
+
}, s = /* @__PURE__ */ i(((e) => {
|
|
7
12
|
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
8
13
|
function r(e, n, r) {
|
|
9
14
|
var i = null;
|
|
@@ -18,7 +23,7 @@ var i = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
18
23
|
};
|
|
19
24
|
}
|
|
20
25
|
e.Fragment = n, e.jsx = r, e.jsxs = r;
|
|
21
|
-
})),
|
|
26
|
+
})), c = /* @__PURE__ */ i(((e) => {
|
|
22
27
|
process.env.NODE_ENV !== "production" && (function() {
|
|
23
28
|
function t(e) {
|
|
24
29
|
if (e == null) return null;
|
|
@@ -176,31 +181,26 @@ var i = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
176
181
|
return f(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
|
|
177
182
|
};
|
|
178
183
|
})();
|
|
179
|
-
})),
|
|
180
|
-
process.env.NODE_ENV === "production" ? t.exports =
|
|
181
|
-
})))(),
|
|
182
|
-
|
|
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 = [
|
|
184
|
+
})), l = (/* @__PURE__ */ i(((e, t) => {
|
|
185
|
+
process.env.NODE_ENV === "production" ? t.exports = s() : t.exports = c();
|
|
186
|
+
})))(), u = e(function({ label: e = "Checkbox", labelPosition: t = "right", className: r = "", inputClassName: i = "", labelClassName: a = "", id: s, disabled: c, ...u }, d) {
|
|
187
|
+
let f = n(), p = s ?? `nabs-ui-checkbox-${f.replace(/:/g, "")}`, m = [
|
|
188
188
|
"nabs-ui-checkbox",
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
c ? "nabs-ui-checkbox--disabled" : "",
|
|
190
|
+
o[t] ?? o.right,
|
|
191
191
|
r
|
|
192
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,
|
|
193
|
+
return /* @__PURE__ */ (0, l.jsxs)("label", {
|
|
194
194
|
className: m,
|
|
195
195
|
htmlFor: p,
|
|
196
|
-
children: [/* @__PURE__ */ (0,
|
|
196
|
+
children: [/* @__PURE__ */ (0, l.jsx)("input", {
|
|
197
197
|
ref: d,
|
|
198
198
|
id: p,
|
|
199
199
|
className: h,
|
|
200
200
|
type: "checkbox",
|
|
201
|
-
disabled:
|
|
201
|
+
disabled: c,
|
|
202
202
|
...u
|
|
203
|
-
}), /* @__PURE__ */ (0,
|
|
203
|
+
}), /* @__PURE__ */ (0, l.jsx)("span", {
|
|
204
204
|
className: g,
|
|
205
205
|
children: e
|
|
206
206
|
})]
|
|
@@ -208,29 +208,31 @@ var i = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t
|
|
|
208
208
|
});
|
|
209
209
|
u.displayName = "Checkbox";
|
|
210
210
|
//#endregion
|
|
211
|
-
//#region ../nabs-ui-radiobutton/src/
|
|
211
|
+
//#region ../nabs-ui-radiobutton/src/radiobutton.utils.ts
|
|
212
212
|
var d = {
|
|
213
213
|
right: "nabs-ui-radiobutton--label-right",
|
|
214
214
|
left: "nabs-ui-radiobutton--label-left",
|
|
215
215
|
top: "nabs-ui-radiobutton--label-top",
|
|
216
216
|
bottom: "nabs-ui-radiobutton--label-bottom"
|
|
217
217
|
};
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region ../nabs-ui-radiobutton/src/RadioButton.tsx
|
|
218
220
|
function f({ label: e = "Radio button", labelPosition: t = "right", className: r = "", inputClassName: i = "", labelClassName: a = "", id: o, ...s }) {
|
|
219
|
-
let
|
|
221
|
+
let c = s.disabled === !0, u = n(), f = o ?? `nabs-ui-radiobutton-${u.replace(/:/g, "")}`, p = [
|
|
220
222
|
"nabs-ui-radiobutton",
|
|
221
|
-
|
|
223
|
+
c ? "nabs-ui-radiobutton--disabled" : "",
|
|
222
224
|
d[t] ?? d.right,
|
|
223
225
|
r
|
|
224
226
|
].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,
|
|
227
|
+
return /* @__PURE__ */ (0, l.jsxs)("label", {
|
|
226
228
|
className: p,
|
|
227
229
|
htmlFor: f,
|
|
228
|
-
children: [/* @__PURE__ */ (0,
|
|
230
|
+
children: [/* @__PURE__ */ (0, l.jsx)("input", {
|
|
229
231
|
id: f,
|
|
230
232
|
className: m,
|
|
231
233
|
type: "radio",
|
|
232
234
|
...s
|
|
233
|
-
}), /* @__PURE__ */ (0,
|
|
235
|
+
}), /* @__PURE__ */ (0, l.jsx)("span", {
|
|
234
236
|
className: h,
|
|
235
237
|
children: e
|
|
236
238
|
})]
|
|
@@ -238,82 +240,78 @@ function f({ label: e = "Radio button", labelPosition: t = "right", className: r
|
|
|
238
240
|
}
|
|
239
241
|
//#endregion
|
|
240
242
|
//#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", ...
|
|
243
|
+
var p = e(({ label: e, className: t = "", inputClassName: r = "", labelClassName: i = "", id: a, rows: o = 4, resize: s = "vertical", ...c }, u) => {
|
|
242
244
|
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,
|
|
245
|
+
return /* @__PURE__ */ (0, l.jsxs)("div", {
|
|
244
246
|
className: p,
|
|
245
|
-
children: [e ? /* @__PURE__ */ (0,
|
|
247
|
+
children: [e ? /* @__PURE__ */ (0, l.jsx)("label", {
|
|
246
248
|
className: h,
|
|
247
249
|
htmlFor: f,
|
|
248
250
|
children: e
|
|
249
|
-
}) : null, /* @__PURE__ */ (0,
|
|
251
|
+
}) : null, /* @__PURE__ */ (0, l.jsx)("textarea", {
|
|
250
252
|
ref: u,
|
|
251
253
|
id: f,
|
|
252
254
|
className: m,
|
|
253
255
|
rows: o,
|
|
254
256
|
"data-resize": s,
|
|
255
|
-
...
|
|
257
|
+
...c
|
|
256
258
|
})]
|
|
257
259
|
});
|
|
258
260
|
});
|
|
259
261
|
p.displayName = "Textarea";
|
|
260
262
|
//#endregion
|
|
261
|
-
//#region ../nabs-ui-textbox/src/
|
|
263
|
+
//#region ../nabs-ui-textbox/src/textbox.utils.ts
|
|
262
264
|
var m = {
|
|
263
265
|
none: "",
|
|
264
266
|
top: "nabs-ui-textbox--label-top",
|
|
265
267
|
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", ...
|
|
268
|
+
}, h = e(({ label: e, labelPosition: t = "top", className: r = "", inputClassName: i = "", labelClassName: a = "", id: o, type: s = "text", ...c }, u) => {
|
|
267
269
|
let d = n(), f = o ?? `nabs-ui-textbox-${d.replace(/:/g, "")}`, p = [
|
|
268
270
|
"nabs-ui-textbox",
|
|
269
271
|
e ? m[t] ?? m.top : "",
|
|
270
272
|
r
|
|
271
273
|
].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,
|
|
274
|
+
return /* @__PURE__ */ (0, l.jsxs)("div", {
|
|
273
275
|
className: p,
|
|
274
|
-
children: [e ? /* @__PURE__ */ (0,
|
|
276
|
+
children: [e ? /* @__PURE__ */ (0, l.jsx)("label", {
|
|
275
277
|
className: g,
|
|
276
278
|
htmlFor: f,
|
|
277
279
|
children: e
|
|
278
|
-
}) : null, /* @__PURE__ */ (0,
|
|
280
|
+
}) : null, /* @__PURE__ */ (0, l.jsx)("input", {
|
|
279
281
|
ref: u,
|
|
280
282
|
id: f,
|
|
281
283
|
className: h,
|
|
282
284
|
type: s,
|
|
283
|
-
...
|
|
285
|
+
...c
|
|
284
286
|
})]
|
|
285
287
|
});
|
|
286
288
|
});
|
|
287
289
|
h.displayName = "Textbox";
|
|
288
290
|
//#endregion
|
|
289
|
-
//#region src/
|
|
290
|
-
|
|
291
|
-
type: "object",
|
|
292
|
-
properties: {}
|
|
293
|
-
};
|
|
294
|
-
function _(e) {
|
|
291
|
+
//#region src/dynamicform.utils.ts
|
|
292
|
+
function g(e) {
|
|
295
293
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
296
294
|
}
|
|
297
|
-
function
|
|
298
|
-
return !e || e.type !== "object" || !
|
|
295
|
+
function _(e) {
|
|
296
|
+
return !e || e.type !== "object" || !g(e.properties) ? {} : Object.fromEntries(Object.entries(e.properties).map(([e, t]) => [e, v(t)]));
|
|
299
297
|
}
|
|
300
|
-
function
|
|
301
|
-
if (!e || !
|
|
298
|
+
function v(e) {
|
|
299
|
+
if (!e || !g(e)) return "";
|
|
302
300
|
if (e.default !== void 0) return e.default;
|
|
303
301
|
if (Array.isArray(e.enum) && e.enum.length > 0) return e.enum[0];
|
|
304
302
|
switch (e.type) {
|
|
305
303
|
case "boolean": return !1;
|
|
306
304
|
case "integer":
|
|
307
305
|
case "number": return "";
|
|
308
|
-
case "object": return
|
|
306
|
+
case "object": return _(e);
|
|
309
307
|
default: return "";
|
|
310
308
|
}
|
|
311
309
|
}
|
|
312
|
-
function
|
|
313
|
-
if (!e || !
|
|
314
|
-
if (e.type === "object" &&
|
|
315
|
-
let n =
|
|
316
|
-
return Object.fromEntries(Object.entries(e.properties).map(([e, t]) => [e,
|
|
310
|
+
function y(e, t) {
|
|
311
|
+
if (!e || !g(e)) return t;
|
|
312
|
+
if (e.type === "object" && g(e.properties)) {
|
|
313
|
+
let n = g(t) ? t : {};
|
|
314
|
+
return Object.fromEntries(Object.entries(e.properties).map(([e, t]) => [e, y(t, n[e] === void 0 ? v(t) : n[e])]));
|
|
317
315
|
}
|
|
318
316
|
if (e.type === "boolean") return t === !0;
|
|
319
317
|
if (e.type === "integer") {
|
|
@@ -328,27 +326,33 @@ function b(e, t) {
|
|
|
328
326
|
}
|
|
329
327
|
return t ?? "";
|
|
330
328
|
}
|
|
331
|
-
function
|
|
332
|
-
return !e || !
|
|
329
|
+
function b(e) {
|
|
330
|
+
return !e || !g(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
331
|
}
|
|
332
|
+
//#endregion
|
|
333
|
+
//#region src/DynamicForm.tsx
|
|
334
|
+
var x = {
|
|
335
|
+
type: "object",
|
|
336
|
+
properties: {}
|
|
337
|
+
};
|
|
334
338
|
function S({ schema: e, name: t, value: n, onChange: r }) {
|
|
335
|
-
let i = e.title ?? t, a = e.description, o =
|
|
339
|
+
let i = e.title ?? t, a = e.description, o = b(e), s = n ?? v(e);
|
|
336
340
|
if (o === "radio") {
|
|
337
341
|
let n = Array.isArray(e.enum) ? e.enum : [];
|
|
338
|
-
return /* @__PURE__ */ (0,
|
|
342
|
+
return /* @__PURE__ */ (0, l.jsxs)("fieldset", {
|
|
339
343
|
className: "nabs-ui-dynamicform__fieldset",
|
|
340
344
|
children: [
|
|
341
|
-
/* @__PURE__ */ (0,
|
|
345
|
+
/* @__PURE__ */ (0, l.jsx)("legend", {
|
|
342
346
|
className: "nabs-ui-dynamicform__legend",
|
|
343
347
|
children: i
|
|
344
348
|
}),
|
|
345
|
-
a ? /* @__PURE__ */ (0,
|
|
349
|
+
a ? /* @__PURE__ */ (0, l.jsx)("p", {
|
|
346
350
|
className: "nabs-ui-dynamicform__description",
|
|
347
351
|
children: a
|
|
348
352
|
}) : null,
|
|
349
|
-
/* @__PURE__ */ (0,
|
|
353
|
+
/* @__PURE__ */ (0, l.jsx)("div", {
|
|
350
354
|
className: "nabs-ui-dynamicform__radioGroup",
|
|
351
|
-
children: n.map((e) => /* @__PURE__ */ (0,
|
|
355
|
+
children: n.map((e) => /* @__PURE__ */ (0, l.jsx)(f, {
|
|
352
356
|
label: String(e),
|
|
353
357
|
name: t,
|
|
354
358
|
checked: s === e,
|
|
@@ -358,17 +362,17 @@ function S({ schema: e, name: t, value: n, onChange: r }) {
|
|
|
358
362
|
]
|
|
359
363
|
});
|
|
360
364
|
}
|
|
361
|
-
return o === "textarea" ? /* @__PURE__ */ (0,
|
|
365
|
+
return o === "textarea" ? /* @__PURE__ */ (0, l.jsx)(p, {
|
|
362
366
|
label: i,
|
|
363
367
|
rows: 5,
|
|
364
368
|
value: String(s ?? ""),
|
|
365
369
|
placeholder: String(e.default ?? ""),
|
|
366
370
|
onChange: (e) => r(e.target.value)
|
|
367
|
-
}) : o === "bool" ? /* @__PURE__ */ (0,
|
|
371
|
+
}) : o === "bool" ? /* @__PURE__ */ (0, l.jsx)(u, {
|
|
368
372
|
label: i,
|
|
369
373
|
checked: s === !0,
|
|
370
374
|
onChange: (e) => r(e.target.checked)
|
|
371
|
-
}) : /* @__PURE__ */ (0,
|
|
375
|
+
}) : /* @__PURE__ */ (0, l.jsx)(h, {
|
|
372
376
|
label: i,
|
|
373
377
|
type: o === "int" || o === "decimal" || o === "double" ? "number" : "text",
|
|
374
378
|
step: o === "int" ? 1 : o === "decimal" || o === "double" ? "any" : void 0,
|
|
@@ -388,73 +392,73 @@ function S({ schema: e, name: t, value: n, onChange: r }) {
|
|
|
388
392
|
}
|
|
389
393
|
});
|
|
390
394
|
}
|
|
391
|
-
var C = e(function({ schema: e, value: i, onChange: a, className: o = "", id: s, disabled:
|
|
392
|
-
let f = n(), p = s ?? `nabs-ui-dynamicform-${f.replace(/:/g, "")}`, m = e && e.type === "object" ? e :
|
|
395
|
+
var C = e(function({ schema: e, value: i, onChange: a, className: o = "", id: s, disabled: c = !1, ...u }, d) {
|
|
396
|
+
let f = n(), p = s ?? `nabs-ui-dynamicform-${f.replace(/:/g, "")}`, m = e && e.type === "object" ? e : x, [h, v] = r(() => y(m, i ?? _(m)));
|
|
393
397
|
t(() => {
|
|
394
|
-
y(
|
|
398
|
+
v(y(m, i ?? _(m)));
|
|
395
399
|
}, [m, i]);
|
|
396
|
-
let
|
|
400
|
+
let b = g(h) ? h : {}, C = m.title ?? "Dynamic form", w = m.description, T = [
|
|
397
401
|
"nabs-ui-dynamicform",
|
|
398
|
-
|
|
402
|
+
c ? "nabs-ui-dynamicform--disabled" : "",
|
|
399
403
|
o
|
|
400
404
|
].filter(Boolean).join(" "), E = (e) => {
|
|
401
|
-
|
|
405
|
+
v(e), a?.(e);
|
|
402
406
|
};
|
|
403
|
-
return
|
|
407
|
+
return c ? /* @__PURE__ */ (0, l.jsxs)("div", {
|
|
404
408
|
ref: d,
|
|
405
409
|
id: p,
|
|
406
410
|
className: T,
|
|
407
411
|
"aria-disabled": "true",
|
|
408
412
|
...u,
|
|
409
|
-
children: [/* @__PURE__ */ (0,
|
|
413
|
+
children: [/* @__PURE__ */ (0, l.jsxs)("div", {
|
|
410
414
|
className: "nabs-ui-dynamicform__header",
|
|
411
|
-
children: [/* @__PURE__ */ (0,
|
|
415
|
+
children: [/* @__PURE__ */ (0, l.jsx)("div", {
|
|
412
416
|
className: "nabs-ui-dynamicform__title",
|
|
413
417
|
children: C
|
|
414
|
-
}), w ? /* @__PURE__ */ (0,
|
|
418
|
+
}), w ? /* @__PURE__ */ (0, l.jsx)("div", {
|
|
415
419
|
className: "nabs-ui-dynamicform__description",
|
|
416
420
|
children: w
|
|
417
421
|
}) : null]
|
|
418
|
-
}), /* @__PURE__ */ (0,
|
|
422
|
+
}), /* @__PURE__ */ (0, l.jsx)("div", {
|
|
419
423
|
className: "nabs-ui-dynamicform__fields",
|
|
420
|
-
children: Object.entries(m.properties ?? {}).map(([e, t]) => /* @__PURE__ */ (0,
|
|
424
|
+
children: Object.entries(m.properties ?? {}).map(([e, t]) => /* @__PURE__ */ (0, l.jsx)("div", {
|
|
421
425
|
className: "nabs-ui-dynamicform__field",
|
|
422
|
-
children: /* @__PURE__ */ (0,
|
|
426
|
+
children: /* @__PURE__ */ (0, l.jsx)(S, {
|
|
423
427
|
schema: t,
|
|
424
428
|
name: e,
|
|
425
|
-
value:
|
|
429
|
+
value: b[e],
|
|
426
430
|
onChange: (n) => E({
|
|
427
|
-
...
|
|
428
|
-
[e]:
|
|
431
|
+
...b,
|
|
432
|
+
[e]: y(t, n)
|
|
429
433
|
})
|
|
430
434
|
})
|
|
431
435
|
}, e))
|
|
432
436
|
})]
|
|
433
|
-
}) : /* @__PURE__ */ (0,
|
|
437
|
+
}) : /* @__PURE__ */ (0, l.jsxs)("div", {
|
|
434
438
|
ref: d,
|
|
435
439
|
id: p,
|
|
436
440
|
className: T,
|
|
437
441
|
...u,
|
|
438
|
-
children: [/* @__PURE__ */ (0,
|
|
442
|
+
children: [/* @__PURE__ */ (0, l.jsxs)("div", {
|
|
439
443
|
className: "nabs-ui-dynamicform__header",
|
|
440
|
-
children: [/* @__PURE__ */ (0,
|
|
444
|
+
children: [/* @__PURE__ */ (0, l.jsx)("div", {
|
|
441
445
|
className: "nabs-ui-dynamicform__title",
|
|
442
446
|
children: C
|
|
443
|
-
}), w ? /* @__PURE__ */ (0,
|
|
447
|
+
}), w ? /* @__PURE__ */ (0, l.jsx)("div", {
|
|
444
448
|
className: "nabs-ui-dynamicform__description",
|
|
445
449
|
children: w
|
|
446
450
|
}) : null]
|
|
447
|
-
}), /* @__PURE__ */ (0,
|
|
451
|
+
}), /* @__PURE__ */ (0, l.jsx)("div", {
|
|
448
452
|
className: "nabs-ui-dynamicform__fields",
|
|
449
|
-
children: Object.entries(m.properties ?? {}).map(([e, t]) => /* @__PURE__ */ (0,
|
|
453
|
+
children: Object.entries(m.properties ?? {}).map(([e, t]) => /* @__PURE__ */ (0, l.jsx)("div", {
|
|
450
454
|
className: "nabs-ui-dynamicform__field",
|
|
451
|
-
children: /* @__PURE__ */ (0,
|
|
455
|
+
children: /* @__PURE__ */ (0, l.jsx)(S, {
|
|
452
456
|
schema: t,
|
|
453
457
|
name: e,
|
|
454
|
-
value:
|
|
458
|
+
value: b[e],
|
|
455
459
|
onChange: (n) => E({
|
|
456
|
-
...
|
|
457
|
-
[e]:
|
|
460
|
+
...b,
|
|
461
|
+
[e]: y(t, n)
|
|
458
462
|
})
|
|
459
463
|
})
|
|
460
464
|
}, e))
|
package/package.json
CHANGED