@a-ludi/rjsf-formulas 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/dist/index.cjs +22 -0
- package/dist/index.d.cts +42 -0
- package/dist/index.d.mts +42 -0
- package/dist/index.mjs +654 -0
- package/package.json +56 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),pe=require("@rjsf/core"),H=Symbol("arrayIndex");function le(r,t){const o=(t==null?void 0:t.formulaKey)??"x-formula",s=(t==null?void 0:t.formulaContextKey)??"x-formula-context",n=[];return B(r,[],n,o,s),n}const me=["$ref","oneOf","anyOf","allOf"];function ye(r,t){return r===void 0||r==="siblings"?"siblings":r==="extended"?"extended":(console.warn(`[rjsf-formulas] Unknown x-formula-context value "${r}" at path [${re(t)}], treating as "siblings"`),"siblings")}function re(r){return r.map(t=>typeof t=="symbol"?"[*]":String(t)).join(", ")}function B(r,t,o,s,n){for(const a of me)a in r&&console.warn(`[rjsf-formulas] Schema composition operator "${a}" at path [${re(t)}] is not supported and will be skipped. See issue 06.`);if(s in r){const a=r[s];if(typeof a!="string"){console.warn(`[rjsf-formulas] Formula at path [${re(t)}] is not a string (got ${typeof a}), skipping.`);return}o.push({path:t,formula:a,contextMode:ye(r[n],t)});return}if(r.type==="object"&&r.properties)for(const[a,c]of Object.entries(r.properties))B(c,[...t,a],o,s,n);if(r.type==="array"){const a=r;Array.isArray(a.prefixItems)&&a.prefixItems.forEach((i,f)=>{B(i,[...t,f],o,s,n)}),r.items&&!Array.isArray(r.items)&&B(r.items,[...t,H],o,s,n)}}function _e(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var G={exports:{}},U={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var ae;function Re(){if(ae)return U;ae=1;var r=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(s,n,a){var c=null;if(a!==void 0&&(c=""+a),n.key!==void 0&&(c=""+n.key),"key"in n){a={};for(var i in n)i!=="key"&&(a[i]=n[i])}else a=n;return n=a.ref,{$$typeof:r,type:s,key:c,ref:n!==void 0?n:null,props:a}}return U.Fragment=t,U.jsx=o,U.jsxs=o,U}var W={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var ue;function be(){return ue||(ue=1,process.env.NODE_ENV!=="production"&&(function(){function r(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===$?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case g:return"Fragment";case D:return"Profiler";case I:return"StrictMode";case S:return"Suspense";case O:return"SuspenseList";case P: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 A:return"Portal";case w:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case j:var u=e.render;return e=e.displayName,e||(e=u.displayName||u.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case C:return u=e.displayName||null,u!==null?u:r(e.type)||"Memo";case M:u=e._payload,e=e._init;try{return r(e(u))}catch{}}return null}function t(e){return""+e}function o(e){try{t(e);var u=!1}catch{u=!0}if(u){u=console;var m=u.error,y=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return m.call(u,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",y),t(e)}}function s(e){if(e===g)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===M)return"<...>";try{var u=r(e);return u?"<"+u+">":"<...>"}catch{return"<...>"}}function n(){var e=x.A;return e===null?null:e.getOwner()}function a(){return Error("react-stack-top-frame")}function c(e){if(K.call(e,"key")){var u=Object.getOwnPropertyDescriptor(e,"key").get;if(u&&u.isReactWarning)return!1}return e.key!==void 0}function i(e,u){function m(){J||(J=!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)",u))}m.isReactWarning=!0,Object.defineProperty(e,"key",{get:m,configurable:!0})}function f(){var e=r(this.type);return V[e]||(V[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?e:null}function d(e,u,m,y,X,Z){var _=m.ref;return e={$$typeof:E,type:e,key:u,props:m,_owner:y},(_!==void 0?_:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:f}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),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:X}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Z}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function p(e,u,m,y,X,Z){var _=u.children;if(_!==void 0)if(y)if(N(_)){for(y=0;y<_.length;y++)R(_[y]);Object.freeze&&Object.freeze(_)}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 R(_);if(K.call(u,"key")){_=r(e);var Y=Object.keys(u).filter(function(de){return de!=="key"});y=0<Y.length?"{key: someKey, "+Y.join(": ..., ")+": ...}":"{key: someKey}",se[_+y]||(Y=0<Y.length?"{"+Y.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,y,_,Y,_),se[_+y]=!0)}if(_=null,m!==void 0&&(o(m),_=""+m),c(u)&&(o(u.key),_=""+u.key),"key"in u){m={};for(var Q in u)Q!=="key"&&(m[Q]=u[Q])}else m=u;return _&&i(m,typeof e=="function"?e.displayName||e.name||"Unknown":e),d(e,_,m,n(),X,Z)}function R(e){b(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===M&&(e._payload.status==="fulfilled"?b(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function b(e){return typeof e=="object"&&e!==null&&e.$$typeof===E}var v=l,E=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),w=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),x=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K=Object.prototype.hasOwnProperty,N=Array.isArray,h=console.createTask?console.createTask:function(){return null};v={react_stack_bottom_frame:function(e){return e()}};var J,V={},k=v.react_stack_bottom_frame.bind(v,a)(),L=h(s(a)),se={};W.Fragment=g,W.jsx=function(e,u,m){var y=1e4>x.recentlyCreatedOwnerStacks++;return p(e,u,m,!1,y?Error("react-stack-top-frame"):k,y?h(s(e)):L)},W.jsxs=function(e,u,m){var y=1e4>x.recentlyCreatedOwnerStacks++;return p(e,u,m,!0,y?Error("react-stack-top-frame"):k,y?h(s(e)):L)}})()),W}var ce;function Ee(){return ce||(ce=1,process.env.NODE_ENV==="production"?G.exports=Re():G.exports=be()),G.exports}var ge=Ee(),ee,fe;function ve(){return fe||(fe=1,ee=function r(t,o){if(t===o)return!0;if(t&&o&&typeof t=="object"&&typeof o=="object"){if(t.constructor!==o.constructor)return!1;var s,n,a;if(Array.isArray(t)){if(s=t.length,s!=o.length)return!1;for(n=s;n--!==0;)if(!r(t[n],o[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===o.source&&t.flags===o.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===o.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===o.toString();if(a=Object.keys(t),s=a.length,s!==Object.keys(o).length)return!1;for(n=s;n--!==0;)if(!Object.prototype.hasOwnProperty.call(o,a[n]))return!1;for(n=s;n--!==0;){var c=a[n];if(!r(t[c],o[c]))return!1}return!0}return t!==t&&o!==o}),ee}var Oe=ve();const je=_e(Oe);function Ae(r,t,o,s){const a=t.slice(0,-1).reduce((i,f)=>{if(!(i==null||typeof i!="object"))return i[f]},o),c=a!=null&&typeof a=="object"&&!Array.isArray(a)?{...a}:{};return r.contextMode==="extended"?((s.formulaDataKey in c||s.formulaPathKey in c)&&console.warn(`[rjsf-formulas] Extended context key collision: sibling field named "${s.formulaDataKey in c?s.formulaDataKey:s.formulaPathKey}" will be overwritten by the injected context. Use formulaDataKey/formulaPathKey props to choose a different key.`),{...c,[s.formulaDataKey]:o,[s.formulaPathKey]:[...t]}):c}function q(r,t){return t.reduce((o,s)=>{if(!(o==null||typeof o!="object"))return o[s]},r)}function te(r,t,o){if(t.length===0)return;const s=q(r,t.slice(0,-1));s!=null&&typeof s=="object"&&(s[t[t.length-1]]=o)}function F(r,t,o=[]){if(r.length===0)return[o];const[s,...n]=r;if(s===H){const a=q(t,o);if(!Array.isArray(a))return[];const c=[];for(let i=0;i<a.length;i++)c.push(...F(n,t,[...o,i]));return c}return F(n,t,[...o,s])}function oe(r,t){return je(r,t)}async function ie(r,t,o,s){const n=structuredClone(r),a=[];for(const f of t)for(const d of F(f.path,n)){const p=Ae(f,d,n,s);a.push({field:f,concretePath:d,context:p})}const c=await Promise.allSettled(a.map(({field:f,context:d})=>new Promise(p=>p(o(f.formula,d))))),i=[];for(let f=0;f<a.length;f++){const{concretePath:d}=a[f],p=c[f];if(p.status==="fulfilled")te(n,d,p.value);else{const R=p.reason instanceof Error?p.reason:new Error(String(p.reason));i.push({path:d,error:R}),te(n,d,void 0)}}return{data:n,errors:i}}function Te(r,t,o){for(const s of o)for(const n of F(s.path,t))if(!oe(q(r,n),q(t,n)))return!1;return!0}async function xe(r,t,o,s,n,a="__formData__",c="__path__"){if(t.length===0)return r;const i={formulaDataKey:a,formulaPathKey:c};let f=r;for(let R=0;R<s;R++){const{data:b,errors:v}=await ie(f,t,o,i);if(Te(f,b,t)){for(const{path:E,error:A}of v)n==null||n(E,A);return b}f=b}const{data:d}=await ie(f,t,o,i),p=structuredClone(d);for(const R of t)for(const b of F(R.path,d))oe(q(f,b),q(d,b))||(n==null||n(b,new Error(`[rjsf-formulas] Formula at [${b.join(", ")}] did not converge after ${s} passes`)),te(p,b,void 0));return p}function he(r){return JSON.stringify(r)}function ke(r,t,o,s,n,a,c,i){const[f,d]=l.useState(r),p=l.useRef(r),R=l.useRef(r),b=l.useRef(new Map),v=l.useRef(null),E=l.useRef(!1),A=l.useRef(a),g=l.useRef(c),I=l.useRef(o),D=l.useRef(t),T=l.useRef(n),w=l.useRef(i);l.useEffect(()=>{A.current=a},[a]),l.useEffect(()=>{g.current=c},[c]),l.useEffect(()=>{I.current=o},[o]),l.useEffect(()=>{D.current=t},[t]),l.useEffect(()=>{T.current=n},[n]),l.useEffect(()=>{w.current=i},[i]);const j=l.useCallback(()=>{if(E.current)return;(async()=>{var P,$;E.current=!0;try{for(;;){const x=p.current,K=D.current,N=[];for(const k of K)for(const L of F(k.path,x))N.push(L);const h=b.current;h.clear();for(const k of N)h.set(he(k),"running");N.length>0&&((P=g.current)==null||P.call(g,N));const J=await xe(x,K,I.current,T.current,A.current,w.current.formulaDataKey,w.current.formulaPathKey);if(C.current)break;const V=[...h.values()].some(k=>k==="dirty");if(h.clear(),!V){d(J),N.length>0&&(($=g.current)==null||$.call(g,[]));break}}}finally{E.current=!1}})()},[]),S=l.useCallback(M=>{p.current=M;const P=b.current;for(const[$,x]of P)x==="running"&&P.set($,"dirty");E.current||(v.current!==null&&clearTimeout(v.current),v.current=setTimeout(()=>{v.current=null,j()},s))},[s,j]),O=l.useRef(!1),C=l.useRef(!1);return l.useEffect(()=>{O.current?oe(r,R.current)||(R.current=r,S(r)):(O.current=!0,R.current=r,S(r))}),l.useEffect(()=>()=>{C.current=!0,v.current!==null&&clearTimeout(v.current)},[]),{enrichedFormData:f,handleInput:S}}function we(r,t){const o=structuredClone(r??{}),s=Se(t);for(const n of t)z(o,n.path,s);return o}function Se(r){const t=new Set;for(let o=0;o<r.length;o++){const s=r[o].path;for(let n=0;n<s.length;n++){const a=s[n];if(typeof a!="number"&&a!==H)continue;const c=ne(s.slice(0,n)),i=typeof a=="number";r.some((d,p)=>{if(p===o||d.path.length<=n||ne(d.path.slice(0,n))!==c)return!1;const R=d.path[n];return i?R===H:typeof R=="number"})&&t.add(c)}}return t}function ne(r){return JSON.stringify(r.map(t=>typeof t=="symbol"?"__ARRAY_INDEX__":t))}function z(r,t,o,s=[]){if(t.length===0){r["ui:readonly"]=!0;return}const[n,...a]=t;if(typeof n=="string"){(!r[n]||typeof r[n]!="object"||Array.isArray(r[n]))&&(r[n]={}),z(r[n],a,o,[...s,n]);return}if(typeof n=="number"){if(r.items!==void 0&&!Array.isArray(r.items)){console.warn("[rjsf-formulas] mergeReadOnly: cannot inject ui:readonly at tuple index because existing uiSchema has items as an object. Skipping.");return}Array.isArray(r.items)||(r.items=[]);const f=r.items;(!f[n]||typeof f[n]!="object")&&(f[n]={}),z(f[n],a,o,[...s,n]);return}const c=ne(s);if(o.has(c))(!r.additionalItems||typeof r.additionalItems!="object")&&(r.additionalItems={}),z(r.additionalItems,a,o,[...s,n]);else{if(Array.isArray(r.items)){console.warn("[rjsf-formulas] mergeReadOnly: cannot inject ui:readonly for uniform array because existing uiSchema has items as an array. Skipping.");return}(!r.items||typeof r.items!="object")&&(r.items={}),z(r.items,a,o,[...s,n])}}function Pe(r){const{schema:t,formData:o,uiSchema:s,evaluator:n,Form:a=pe,formulaKey:c="x-formula",formulaContextKey:i="x-formula-context",formulaDataKey:f="__formData__",formulaPathKey:d="__path__",maxConvergencePasses:p=10,debounceMs:R=300,onFormulaError:b,onLoadingChange:v,onChange:E,...A}=r,g=l.useMemo(()=>le(t,{formulaKey:c,formulaContextKey:i}),[t,c,i]),I=l.useMemo(()=>({formulaDataKey:f,formulaPathKey:d}),[f,d]),D=l.useMemo(()=>we(s,g),[s,g]),{enrichedFormData:T,handleInput:w}=ke(o,g,n,R,p,b,v,I),j=l.useRef(E);l.useEffect(()=>{j.current=E},[E]),l.useEffect(()=>{var O;g.length!==0&&((O=j.current)==null||O.call(j,{formData:T},void 0))},[T]);const S=(O,C)=>{w(O.formData),E==null||E(O,C)};return ge.jsx(a,{...A,schema:t,formData:T,uiSchema:D,onChange:S})}exports.FormulaForm=Pe;exports.analyzeSchema=le;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import { FormContextType } from '@rjsf/utils';
|
|
3
|
+
import { FormProps } from '@rjsf/utils';
|
|
4
|
+
import { RJSFSchema } from '@rjsf/utils';
|
|
5
|
+
import { StrictRJSFSchema } from '@rjsf/utils';
|
|
6
|
+
|
|
7
|
+
export declare function analyzeSchema(schema: RJSFSchema, options?: AnalyzeSchemaOptions): FormulaField[];
|
|
8
|
+
|
|
9
|
+
export declare type AnalyzeSchemaOptions = {
|
|
10
|
+
formulaKey?: string;
|
|
11
|
+
formulaContextKey?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** Package-internal — not re-exported from the public entry point. Used by enrich.ts and mergeReadOnly.ts. */
|
|
15
|
+
declare const ARRAY_INDEX: unique symbol;
|
|
16
|
+
|
|
17
|
+
declare type ArrayIndex = typeof ARRAY_INDEX;
|
|
18
|
+
|
|
19
|
+
export declare type ContextMode = 'siblings' | 'extended';
|
|
20
|
+
|
|
21
|
+
export declare type FormulaField = {
|
|
22
|
+
path: (string | number | ArrayIndex)[];
|
|
23
|
+
formula: string;
|
|
24
|
+
contextMode: ContextMode;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export declare function FormulaForm<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FormulaFormProps<T, S, F>): JSX.Element;
|
|
28
|
+
|
|
29
|
+
export declare type FormulaFormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = FormProps<T, S, F> & {
|
|
30
|
+
evaluator: (formula: string, context: object) => unknown | Promise<unknown>;
|
|
31
|
+
Form?: default_2.ComponentType<FormProps<T, S, F>>;
|
|
32
|
+
formulaKey?: string;
|
|
33
|
+
formulaContextKey?: string;
|
|
34
|
+
formulaDataKey?: string;
|
|
35
|
+
formulaPathKey?: string;
|
|
36
|
+
maxConvergencePasses?: number;
|
|
37
|
+
debounceMs?: number;
|
|
38
|
+
onFormulaError?: (path: (string | number)[], error: Error) => void;
|
|
39
|
+
onLoadingChange?: (loadingPaths: (string | number)[][]) => void;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { }
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import { FormContextType } from '@rjsf/utils';
|
|
3
|
+
import { FormProps } from '@rjsf/utils';
|
|
4
|
+
import { RJSFSchema } from '@rjsf/utils';
|
|
5
|
+
import { StrictRJSFSchema } from '@rjsf/utils';
|
|
6
|
+
|
|
7
|
+
export declare function analyzeSchema(schema: RJSFSchema, options?: AnalyzeSchemaOptions): FormulaField[];
|
|
8
|
+
|
|
9
|
+
export declare type AnalyzeSchemaOptions = {
|
|
10
|
+
formulaKey?: string;
|
|
11
|
+
formulaContextKey?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** Package-internal — not re-exported from the public entry point. Used by enrich.ts and mergeReadOnly.ts. */
|
|
15
|
+
declare const ARRAY_INDEX: unique symbol;
|
|
16
|
+
|
|
17
|
+
declare type ArrayIndex = typeof ARRAY_INDEX;
|
|
18
|
+
|
|
19
|
+
export declare type ContextMode = 'siblings' | 'extended';
|
|
20
|
+
|
|
21
|
+
export declare type FormulaField = {
|
|
22
|
+
path: (string | number | ArrayIndex)[];
|
|
23
|
+
formula: string;
|
|
24
|
+
contextMode: ContextMode;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export declare function FormulaForm<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FormulaFormProps<T, S, F>): JSX.Element;
|
|
28
|
+
|
|
29
|
+
export declare type FormulaFormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = FormProps<T, S, F> & {
|
|
30
|
+
evaluator: (formula: string, context: object) => unknown | Promise<unknown>;
|
|
31
|
+
Form?: default_2.ComponentType<FormProps<T, S, F>>;
|
|
32
|
+
formulaKey?: string;
|
|
33
|
+
formulaContextKey?: string;
|
|
34
|
+
formulaDataKey?: string;
|
|
35
|
+
formulaPathKey?: string;
|
|
36
|
+
maxConvergencePasses?: number;
|
|
37
|
+
debounceMs?: number;
|
|
38
|
+
onFormulaError?: (path: (string | number)[], error: Error) => void;
|
|
39
|
+
onLoadingChange?: (loadingPaths: (string | number)[][]) => void;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { }
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,654 @@
|
|
|
1
|
+
import ye, { useState as _e, useRef as v, useEffect as j, useCallback as ce, useMemo as re } from "react";
|
|
2
|
+
import be from "@rjsf/core";
|
|
3
|
+
const Z = Symbol("arrayIndex");
|
|
4
|
+
function Re(r, t) {
|
|
5
|
+
const o = (t == null ? void 0 : t.formulaKey) ?? "x-formula", s = (t == null ? void 0 : t.formulaContextKey) ?? "x-formula-context", n = [];
|
|
6
|
+
return H(r, [], n, o, s), n;
|
|
7
|
+
}
|
|
8
|
+
const Ee = ["$ref", "oneOf", "anyOf", "allOf"];
|
|
9
|
+
function ge(r, t) {
|
|
10
|
+
return r === void 0 || r === "siblings" ? "siblings" : r === "extended" ? "extended" : (console.warn(
|
|
11
|
+
`[rjsf-formulas] Unknown x-formula-context value "${r}" at path [${ne(t)}], treating as "siblings"`
|
|
12
|
+
), "siblings");
|
|
13
|
+
}
|
|
14
|
+
function ne(r) {
|
|
15
|
+
return r.map((t) => typeof t == "symbol" ? "[*]" : String(t)).join(", ");
|
|
16
|
+
}
|
|
17
|
+
function H(r, t, o, s, n) {
|
|
18
|
+
for (const a of Ee)
|
|
19
|
+
a in r && console.warn(
|
|
20
|
+
`[rjsf-formulas] Schema composition operator "${a}" at path [${ne(t)}] is not supported and will be skipped. See issue 06.`
|
|
21
|
+
);
|
|
22
|
+
if (s in r) {
|
|
23
|
+
const a = r[s];
|
|
24
|
+
if (typeof a != "string") {
|
|
25
|
+
console.warn(
|
|
26
|
+
`[rjsf-formulas] Formula at path [${ne(t)}] is not a string (got ${typeof a}), skipping.`
|
|
27
|
+
);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
o.push({
|
|
31
|
+
path: t,
|
|
32
|
+
formula: a,
|
|
33
|
+
contextMode: ge(
|
|
34
|
+
r[n],
|
|
35
|
+
t
|
|
36
|
+
)
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (r.type === "object" && r.properties)
|
|
41
|
+
for (const [a, c] of Object.entries(r.properties))
|
|
42
|
+
H(
|
|
43
|
+
c,
|
|
44
|
+
[...t, a],
|
|
45
|
+
o,
|
|
46
|
+
s,
|
|
47
|
+
n
|
|
48
|
+
);
|
|
49
|
+
if (r.type === "array") {
|
|
50
|
+
const a = r;
|
|
51
|
+
Array.isArray(a.prefixItems) && a.prefixItems.forEach((f, i) => {
|
|
52
|
+
H(f, [...t, i], o, s, n);
|
|
53
|
+
}), r.items && !Array.isArray(r.items) && H(
|
|
54
|
+
r.items,
|
|
55
|
+
[...t, Z],
|
|
56
|
+
o,
|
|
57
|
+
s,
|
|
58
|
+
n
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function ve(r) {
|
|
63
|
+
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
64
|
+
}
|
|
65
|
+
var B = { exports: {} }, W = {};
|
|
66
|
+
/**
|
|
67
|
+
* @license React
|
|
68
|
+
* react-jsx-runtime.production.js
|
|
69
|
+
*
|
|
70
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
71
|
+
*
|
|
72
|
+
* This source code is licensed under the MIT license found in the
|
|
73
|
+
* LICENSE file in the root directory of this source tree.
|
|
74
|
+
*/
|
|
75
|
+
var ie;
|
|
76
|
+
function Oe() {
|
|
77
|
+
if (ie) return W;
|
|
78
|
+
ie = 1;
|
|
79
|
+
var r = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
|
|
80
|
+
function o(s, n, a) {
|
|
81
|
+
var c = null;
|
|
82
|
+
if (a !== void 0 && (c = "" + a), n.key !== void 0 && (c = "" + n.key), "key" in n) {
|
|
83
|
+
a = {};
|
|
84
|
+
for (var f in n)
|
|
85
|
+
f !== "key" && (a[f] = n[f]);
|
|
86
|
+
} else a = n;
|
|
87
|
+
return n = a.ref, {
|
|
88
|
+
$$typeof: r,
|
|
89
|
+
type: s,
|
|
90
|
+
key: c,
|
|
91
|
+
ref: n !== void 0 ? n : null,
|
|
92
|
+
props: a
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return W.Fragment = t, W.jsx = o, W.jsxs = o, W;
|
|
96
|
+
}
|
|
97
|
+
var J = {};
|
|
98
|
+
/**
|
|
99
|
+
* @license React
|
|
100
|
+
* react-jsx-runtime.development.js
|
|
101
|
+
*
|
|
102
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
103
|
+
*
|
|
104
|
+
* This source code is licensed under the MIT license found in the
|
|
105
|
+
* LICENSE file in the root directory of this source tree.
|
|
106
|
+
*/
|
|
107
|
+
var fe;
|
|
108
|
+
function je() {
|
|
109
|
+
return fe || (fe = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
110
|
+
function r(e) {
|
|
111
|
+
if (e == null) return null;
|
|
112
|
+
if (typeof e == "function")
|
|
113
|
+
return e.$$typeof === Y ? null : e.displayName || e.name || null;
|
|
114
|
+
if (typeof e == "string") return e;
|
|
115
|
+
switch (e) {
|
|
116
|
+
case E:
|
|
117
|
+
return "Fragment";
|
|
118
|
+
case $:
|
|
119
|
+
return "Profiler";
|
|
120
|
+
case D:
|
|
121
|
+
return "StrictMode";
|
|
122
|
+
case P:
|
|
123
|
+
return "Suspense";
|
|
124
|
+
case O:
|
|
125
|
+
return "SuspenseList";
|
|
126
|
+
case N:
|
|
127
|
+
return "Activity";
|
|
128
|
+
}
|
|
129
|
+
if (typeof e == "object")
|
|
130
|
+
switch (typeof e.tag == "number" && console.error(
|
|
131
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
132
|
+
), e.$$typeof) {
|
|
133
|
+
case x:
|
|
134
|
+
return "Portal";
|
|
135
|
+
case S:
|
|
136
|
+
return e.displayName || "Context";
|
|
137
|
+
case T:
|
|
138
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
139
|
+
case A:
|
|
140
|
+
var u = e.render;
|
|
141
|
+
return e = e.displayName, e || (e = u.displayName || u.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
142
|
+
case C:
|
|
143
|
+
return u = e.displayName || null, u !== null ? u : r(e.type) || "Memo";
|
|
144
|
+
case M:
|
|
145
|
+
u = e._payload, e = e._init;
|
|
146
|
+
try {
|
|
147
|
+
return r(e(u));
|
|
148
|
+
} catch {
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
function t(e) {
|
|
154
|
+
return "" + e;
|
|
155
|
+
}
|
|
156
|
+
function o(e) {
|
|
157
|
+
try {
|
|
158
|
+
t(e);
|
|
159
|
+
var u = !1;
|
|
160
|
+
} catch {
|
|
161
|
+
u = !0;
|
|
162
|
+
}
|
|
163
|
+
if (u) {
|
|
164
|
+
u = console;
|
|
165
|
+
var p = u.error, m = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
166
|
+
return p.call(
|
|
167
|
+
u,
|
|
168
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
169
|
+
m
|
|
170
|
+
), t(e);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function s(e) {
|
|
174
|
+
if (e === E) return "<>";
|
|
175
|
+
if (typeof e == "object" && e !== null && e.$$typeof === M)
|
|
176
|
+
return "<...>";
|
|
177
|
+
try {
|
|
178
|
+
var u = r(e);
|
|
179
|
+
return u ? "<" + u + ">" : "<...>";
|
|
180
|
+
} catch {
|
|
181
|
+
return "<...>";
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function n() {
|
|
185
|
+
var e = h.A;
|
|
186
|
+
return e === null ? null : e.getOwner();
|
|
187
|
+
}
|
|
188
|
+
function a() {
|
|
189
|
+
return Error("react-stack-top-frame");
|
|
190
|
+
}
|
|
191
|
+
function c(e) {
|
|
192
|
+
if (F.call(e, "key")) {
|
|
193
|
+
var u = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
194
|
+
if (u && u.isReactWarning) return !1;
|
|
195
|
+
}
|
|
196
|
+
return e.key !== void 0;
|
|
197
|
+
}
|
|
198
|
+
function f(e, u) {
|
|
199
|
+
function p() {
|
|
200
|
+
V || (V = !0, console.error(
|
|
201
|
+
"%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)",
|
|
202
|
+
u
|
|
203
|
+
));
|
|
204
|
+
}
|
|
205
|
+
p.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
206
|
+
get: p,
|
|
207
|
+
configurable: !0
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
function i() {
|
|
211
|
+
var e = r(this.type);
|
|
212
|
+
return L[e] || (L[e] = !0, console.error(
|
|
213
|
+
"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."
|
|
214
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
215
|
+
}
|
|
216
|
+
function l(e, u, p, m, G, Q) {
|
|
217
|
+
var y = p.ref;
|
|
218
|
+
return e = {
|
|
219
|
+
$$typeof: R,
|
|
220
|
+
type: e,
|
|
221
|
+
key: u,
|
|
222
|
+
props: p,
|
|
223
|
+
_owner: m
|
|
224
|
+
}, (y !== void 0 ? y : null) !== null ? Object.defineProperty(e, "ref", {
|
|
225
|
+
enumerable: !1,
|
|
226
|
+
get: i
|
|
227
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
228
|
+
configurable: !1,
|
|
229
|
+
enumerable: !1,
|
|
230
|
+
writable: !0,
|
|
231
|
+
value: 0
|
|
232
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
233
|
+
configurable: !1,
|
|
234
|
+
enumerable: !1,
|
|
235
|
+
writable: !0,
|
|
236
|
+
value: null
|
|
237
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
238
|
+
configurable: !1,
|
|
239
|
+
enumerable: !1,
|
|
240
|
+
writable: !0,
|
|
241
|
+
value: G
|
|
242
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
243
|
+
configurable: !1,
|
|
244
|
+
enumerable: !1,
|
|
245
|
+
writable: !0,
|
|
246
|
+
value: Q
|
|
247
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
248
|
+
}
|
|
249
|
+
function d(e, u, p, m, G, Q) {
|
|
250
|
+
var y = u.children;
|
|
251
|
+
if (y !== void 0)
|
|
252
|
+
if (m)
|
|
253
|
+
if (I(y)) {
|
|
254
|
+
for (m = 0; m < y.length; m++)
|
|
255
|
+
_(y[m]);
|
|
256
|
+
Object.freeze && Object.freeze(y);
|
|
257
|
+
} else
|
|
258
|
+
console.error(
|
|
259
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
260
|
+
);
|
|
261
|
+
else _(y);
|
|
262
|
+
if (F.call(u, "key")) {
|
|
263
|
+
y = r(e);
|
|
264
|
+
var q = Object.keys(u).filter(function(me) {
|
|
265
|
+
return me !== "key";
|
|
266
|
+
});
|
|
267
|
+
m = 0 < q.length ? "{key: someKey, " + q.join(": ..., ") + ": ...}" : "{key: someKey}", ue[y + m] || (q = 0 < q.length ? "{" + q.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
268
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
269
|
+
let props = %s;
|
|
270
|
+
<%s {...props} />
|
|
271
|
+
React keys must be passed directly to JSX without using spread:
|
|
272
|
+
let props = %s;
|
|
273
|
+
<%s key={someKey} {...props} />`,
|
|
274
|
+
m,
|
|
275
|
+
y,
|
|
276
|
+
q,
|
|
277
|
+
y
|
|
278
|
+
), ue[y + m] = !0);
|
|
279
|
+
}
|
|
280
|
+
if (y = null, p !== void 0 && (o(p), y = "" + p), c(u) && (o(u.key), y = "" + u.key), "key" in u) {
|
|
281
|
+
p = {};
|
|
282
|
+
for (var ee in u)
|
|
283
|
+
ee !== "key" && (p[ee] = u[ee]);
|
|
284
|
+
} else p = u;
|
|
285
|
+
return y && f(
|
|
286
|
+
p,
|
|
287
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
288
|
+
), l(
|
|
289
|
+
e,
|
|
290
|
+
y,
|
|
291
|
+
p,
|
|
292
|
+
n(),
|
|
293
|
+
G,
|
|
294
|
+
Q
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
function _(e) {
|
|
298
|
+
b(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === M && (e._payload.status === "fulfilled" ? b(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
299
|
+
}
|
|
300
|
+
function b(e) {
|
|
301
|
+
return typeof e == "object" && e !== null && e.$$typeof === R;
|
|
302
|
+
}
|
|
303
|
+
var g = ye, R = Symbol.for("react.transitional.element"), x = Symbol.for("react.portal"), E = Symbol.for("react.fragment"), D = Symbol.for("react.strict_mode"), $ = Symbol.for("react.profiler"), T = Symbol.for("react.consumer"), S = Symbol.for("react.context"), A = Symbol.for("react.forward_ref"), P = Symbol.for("react.suspense"), O = Symbol.for("react.suspense_list"), C = Symbol.for("react.memo"), M = Symbol.for("react.lazy"), N = Symbol.for("react.activity"), Y = Symbol.for("react.client.reference"), h = g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, F = Object.prototype.hasOwnProperty, I = Array.isArray, k = console.createTask ? console.createTask : function() {
|
|
304
|
+
return null;
|
|
305
|
+
};
|
|
306
|
+
g = {
|
|
307
|
+
react_stack_bottom_frame: function(e) {
|
|
308
|
+
return e();
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
var V, L = {}, w = g.react_stack_bottom_frame.bind(
|
|
312
|
+
g,
|
|
313
|
+
a
|
|
314
|
+
)(), X = k(s(a)), ue = {};
|
|
315
|
+
J.Fragment = E, J.jsx = function(e, u, p) {
|
|
316
|
+
var m = 1e4 > h.recentlyCreatedOwnerStacks++;
|
|
317
|
+
return d(
|
|
318
|
+
e,
|
|
319
|
+
u,
|
|
320
|
+
p,
|
|
321
|
+
!1,
|
|
322
|
+
m ? Error("react-stack-top-frame") : w,
|
|
323
|
+
m ? k(s(e)) : X
|
|
324
|
+
);
|
|
325
|
+
}, J.jsxs = function(e, u, p) {
|
|
326
|
+
var m = 1e4 > h.recentlyCreatedOwnerStacks++;
|
|
327
|
+
return d(
|
|
328
|
+
e,
|
|
329
|
+
u,
|
|
330
|
+
p,
|
|
331
|
+
!0,
|
|
332
|
+
m ? Error("react-stack-top-frame") : w,
|
|
333
|
+
m ? k(s(e)) : X
|
|
334
|
+
);
|
|
335
|
+
};
|
|
336
|
+
})()), J;
|
|
337
|
+
}
|
|
338
|
+
var le;
|
|
339
|
+
function Ae() {
|
|
340
|
+
return le || (le = 1, process.env.NODE_ENV === "production" ? B.exports = Oe() : B.exports = je()), B.exports;
|
|
341
|
+
}
|
|
342
|
+
var xe = Ae(), te, de;
|
|
343
|
+
function Te() {
|
|
344
|
+
return de || (de = 1, te = function r(t, o) {
|
|
345
|
+
if (t === o) return !0;
|
|
346
|
+
if (t && o && typeof t == "object" && typeof o == "object") {
|
|
347
|
+
if (t.constructor !== o.constructor) return !1;
|
|
348
|
+
var s, n, a;
|
|
349
|
+
if (Array.isArray(t)) {
|
|
350
|
+
if (s = t.length, s != o.length) return !1;
|
|
351
|
+
for (n = s; n-- !== 0; )
|
|
352
|
+
if (!r(t[n], o[n])) return !1;
|
|
353
|
+
return !0;
|
|
354
|
+
}
|
|
355
|
+
if (t.constructor === RegExp) return t.source === o.source && t.flags === o.flags;
|
|
356
|
+
if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === o.valueOf();
|
|
357
|
+
if (t.toString !== Object.prototype.toString) return t.toString() === o.toString();
|
|
358
|
+
if (a = Object.keys(t), s = a.length, s !== Object.keys(o).length) return !1;
|
|
359
|
+
for (n = s; n-- !== 0; )
|
|
360
|
+
if (!Object.prototype.hasOwnProperty.call(o, a[n])) return !1;
|
|
361
|
+
for (n = s; n-- !== 0; ) {
|
|
362
|
+
var c = a[n];
|
|
363
|
+
if (!r(t[c], o[c])) return !1;
|
|
364
|
+
}
|
|
365
|
+
return !0;
|
|
366
|
+
}
|
|
367
|
+
return t !== t && o !== o;
|
|
368
|
+
}), te;
|
|
369
|
+
}
|
|
370
|
+
var he = Te();
|
|
371
|
+
const ke = /* @__PURE__ */ ve(he);
|
|
372
|
+
function we(r, t, o, s) {
|
|
373
|
+
const a = t.slice(0, -1).reduce((f, i) => {
|
|
374
|
+
if (!(f == null || typeof f != "object"))
|
|
375
|
+
return f[i];
|
|
376
|
+
}, o), c = a != null && typeof a == "object" && !Array.isArray(a) ? { ...a } : {};
|
|
377
|
+
return r.contextMode === "extended" ? ((s.formulaDataKey in c || s.formulaPathKey in c) && console.warn(
|
|
378
|
+
`[rjsf-formulas] Extended context key collision: sibling field named "${s.formulaDataKey in c ? s.formulaDataKey : s.formulaPathKey}" will be overwritten by the injected context. Use formulaDataKey/formulaPathKey props to choose a different key.`
|
|
379
|
+
), {
|
|
380
|
+
...c,
|
|
381
|
+
[s.formulaDataKey]: o,
|
|
382
|
+
[s.formulaPathKey]: [...t]
|
|
383
|
+
}) : c;
|
|
384
|
+
}
|
|
385
|
+
function K(r, t) {
|
|
386
|
+
return t.reduce((o, s) => {
|
|
387
|
+
if (!(o == null || typeof o != "object"))
|
|
388
|
+
return o[s];
|
|
389
|
+
}, r);
|
|
390
|
+
}
|
|
391
|
+
function oe(r, t, o) {
|
|
392
|
+
if (t.length === 0) return;
|
|
393
|
+
const s = K(r, t.slice(0, -1));
|
|
394
|
+
s != null && typeof s == "object" && (s[t[t.length - 1]] = o);
|
|
395
|
+
}
|
|
396
|
+
function U(r, t, o = []) {
|
|
397
|
+
if (r.length === 0) return [o];
|
|
398
|
+
const [s, ...n] = r;
|
|
399
|
+
if (s === Z) {
|
|
400
|
+
const a = K(t, o);
|
|
401
|
+
if (!Array.isArray(a)) return [];
|
|
402
|
+
const c = [];
|
|
403
|
+
for (let f = 0; f < a.length; f++)
|
|
404
|
+
c.push(...U(n, t, [...o, f]));
|
|
405
|
+
return c;
|
|
406
|
+
}
|
|
407
|
+
return U(n, t, [...o, s]);
|
|
408
|
+
}
|
|
409
|
+
function ae(r, t) {
|
|
410
|
+
return ke(r, t);
|
|
411
|
+
}
|
|
412
|
+
async function pe(r, t, o, s) {
|
|
413
|
+
const n = structuredClone(r), a = [];
|
|
414
|
+
for (const i of t)
|
|
415
|
+
for (const l of U(i.path, n)) {
|
|
416
|
+
const d = we(i, l, n, s);
|
|
417
|
+
a.push({ field: i, concretePath: l, context: d });
|
|
418
|
+
}
|
|
419
|
+
const c = await Promise.allSettled(
|
|
420
|
+
a.map(({ field: i, context: l }) => new Promise((d) => d(o(i.formula, l))))
|
|
421
|
+
), f = [];
|
|
422
|
+
for (let i = 0; i < a.length; i++) {
|
|
423
|
+
const { concretePath: l } = a[i], d = c[i];
|
|
424
|
+
if (d.status === "fulfilled")
|
|
425
|
+
oe(n, l, d.value);
|
|
426
|
+
else {
|
|
427
|
+
const _ = d.reason instanceof Error ? d.reason : new Error(String(d.reason));
|
|
428
|
+
f.push({ path: l, error: _ }), oe(n, l, void 0);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return { data: n, errors: f };
|
|
432
|
+
}
|
|
433
|
+
function Se(r, t, o) {
|
|
434
|
+
for (const s of o)
|
|
435
|
+
for (const n of U(s.path, t))
|
|
436
|
+
if (!ae(K(r, n), K(t, n)))
|
|
437
|
+
return !1;
|
|
438
|
+
return !0;
|
|
439
|
+
}
|
|
440
|
+
async function Pe(r, t, o, s, n, a = "__formData__", c = "__path__") {
|
|
441
|
+
if (t.length === 0) return r;
|
|
442
|
+
const f = { formulaDataKey: a, formulaPathKey: c };
|
|
443
|
+
let i = r;
|
|
444
|
+
for (let _ = 0; _ < s; _++) {
|
|
445
|
+
const { data: b, errors: g } = await pe(i, t, o, f);
|
|
446
|
+
if (Se(i, b, t)) {
|
|
447
|
+
for (const { path: R, error: x } of g)
|
|
448
|
+
n == null || n(R, x);
|
|
449
|
+
return b;
|
|
450
|
+
}
|
|
451
|
+
i = b;
|
|
452
|
+
}
|
|
453
|
+
const { data: l } = await pe(i, t, o, f), d = structuredClone(l);
|
|
454
|
+
for (const _ of t)
|
|
455
|
+
for (const b of U(_.path, l))
|
|
456
|
+
ae(K(i, b), K(l, b)) || (n == null || n(
|
|
457
|
+
b,
|
|
458
|
+
new Error(
|
|
459
|
+
`[rjsf-formulas] Formula at [${b.join(", ")}] did not converge after ${s} passes`
|
|
460
|
+
)
|
|
461
|
+
), oe(d, b, void 0));
|
|
462
|
+
return d;
|
|
463
|
+
}
|
|
464
|
+
function Ne(r) {
|
|
465
|
+
return JSON.stringify(r);
|
|
466
|
+
}
|
|
467
|
+
function Ie(r, t, o, s, n, a, c, f) {
|
|
468
|
+
const [i, l] = _e(r), d = v(r), _ = v(r), b = v(/* @__PURE__ */ new Map()), g = v(null), R = v(!1), x = v(a), E = v(c), D = v(o), $ = v(t), T = v(n), S = v(f);
|
|
469
|
+
j(() => {
|
|
470
|
+
x.current = a;
|
|
471
|
+
}, [a]), j(() => {
|
|
472
|
+
E.current = c;
|
|
473
|
+
}, [c]), j(() => {
|
|
474
|
+
D.current = o;
|
|
475
|
+
}, [o]), j(() => {
|
|
476
|
+
$.current = t;
|
|
477
|
+
}, [t]), j(() => {
|
|
478
|
+
T.current = n;
|
|
479
|
+
}, [n]), j(() => {
|
|
480
|
+
S.current = f;
|
|
481
|
+
}, [f]);
|
|
482
|
+
const A = ce(() => {
|
|
483
|
+
if (R.current) return;
|
|
484
|
+
(async () => {
|
|
485
|
+
var N, Y;
|
|
486
|
+
R.current = !0;
|
|
487
|
+
try {
|
|
488
|
+
for (; ; ) {
|
|
489
|
+
const h = d.current, F = $.current, I = [];
|
|
490
|
+
for (const w of F)
|
|
491
|
+
for (const X of U(w.path, h))
|
|
492
|
+
I.push(X);
|
|
493
|
+
const k = b.current;
|
|
494
|
+
k.clear();
|
|
495
|
+
for (const w of I) k.set(Ne(w), "running");
|
|
496
|
+
I.length > 0 && ((N = E.current) == null || N.call(E, I));
|
|
497
|
+
const V = await Pe(
|
|
498
|
+
h,
|
|
499
|
+
F,
|
|
500
|
+
D.current,
|
|
501
|
+
T.current,
|
|
502
|
+
x.current,
|
|
503
|
+
S.current.formulaDataKey,
|
|
504
|
+
S.current.formulaPathKey
|
|
505
|
+
);
|
|
506
|
+
if (C.current) break;
|
|
507
|
+
const L = [...k.values()].some((w) => w === "dirty");
|
|
508
|
+
if (k.clear(), !L) {
|
|
509
|
+
l(V), I.length > 0 && ((Y = E.current) == null || Y.call(E, []));
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
} finally {
|
|
514
|
+
R.current = !1;
|
|
515
|
+
}
|
|
516
|
+
})();
|
|
517
|
+
}, []), P = ce(
|
|
518
|
+
(M) => {
|
|
519
|
+
d.current = M;
|
|
520
|
+
const N = b.current;
|
|
521
|
+
for (const [Y, h] of N)
|
|
522
|
+
h === "running" && N.set(Y, "dirty");
|
|
523
|
+
R.current || (g.current !== null && clearTimeout(g.current), g.current = setTimeout(() => {
|
|
524
|
+
g.current = null, A();
|
|
525
|
+
}, s));
|
|
526
|
+
},
|
|
527
|
+
[s, A]
|
|
528
|
+
), O = v(!1), C = v(!1);
|
|
529
|
+
return j(() => {
|
|
530
|
+
O.current ? ae(r, _.current) || (_.current = r, P(r)) : (O.current = !0, _.current = r, P(r));
|
|
531
|
+
}), j(
|
|
532
|
+
() => () => {
|
|
533
|
+
C.current = !0, g.current !== null && clearTimeout(g.current);
|
|
534
|
+
},
|
|
535
|
+
[]
|
|
536
|
+
), { enrichedFormData: i, handleInput: P };
|
|
537
|
+
}
|
|
538
|
+
function De(r, t) {
|
|
539
|
+
const o = structuredClone(r ?? {}), s = $e(t);
|
|
540
|
+
for (const n of t)
|
|
541
|
+
z(o, n.path, s);
|
|
542
|
+
return o;
|
|
543
|
+
}
|
|
544
|
+
function $e(r) {
|
|
545
|
+
const t = /* @__PURE__ */ new Set();
|
|
546
|
+
for (let o = 0; o < r.length; o++) {
|
|
547
|
+
const s = r[o].path;
|
|
548
|
+
for (let n = 0; n < s.length; n++) {
|
|
549
|
+
const a = s[n];
|
|
550
|
+
if (typeof a != "number" && a !== Z) continue;
|
|
551
|
+
const c = se(s.slice(0, n)), f = typeof a == "number";
|
|
552
|
+
r.some((l, d) => {
|
|
553
|
+
if (d === o || l.path.length <= n || se(l.path.slice(0, n)) !== c) return !1;
|
|
554
|
+
const _ = l.path[n];
|
|
555
|
+
return f ? _ === Z : typeof _ == "number";
|
|
556
|
+
}) && t.add(c);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return t;
|
|
560
|
+
}
|
|
561
|
+
function se(r) {
|
|
562
|
+
return JSON.stringify(r.map((t) => typeof t == "symbol" ? "__ARRAY_INDEX__" : t));
|
|
563
|
+
}
|
|
564
|
+
function z(r, t, o, s = []) {
|
|
565
|
+
if (t.length === 0) {
|
|
566
|
+
r["ui:readonly"] = !0;
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
const [n, ...a] = t;
|
|
570
|
+
if (typeof n == "string") {
|
|
571
|
+
(!r[n] || typeof r[n] != "object" || Array.isArray(r[n])) && (r[n] = {}), z(r[n], a, o, [...s, n]);
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
if (typeof n == "number") {
|
|
575
|
+
if (r.items !== void 0 && !Array.isArray(r.items)) {
|
|
576
|
+
console.warn("[rjsf-formulas] mergeReadOnly: cannot inject ui:readonly at tuple index because existing uiSchema has items as an object. Skipping.");
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
Array.isArray(r.items) || (r.items = []);
|
|
580
|
+
const i = r.items;
|
|
581
|
+
(!i[n] || typeof i[n] != "object") && (i[n] = {}), z(i[n], a, o, [...s, n]);
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
const c = se(s);
|
|
585
|
+
if (o.has(c))
|
|
586
|
+
(!r.additionalItems || typeof r.additionalItems != "object") && (r.additionalItems = {}), z(r.additionalItems, a, o, [...s, n]);
|
|
587
|
+
else {
|
|
588
|
+
if (Array.isArray(r.items)) {
|
|
589
|
+
console.warn("[rjsf-formulas] mergeReadOnly: cannot inject ui:readonly for uniform array because existing uiSchema has items as an array. Skipping.");
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
(!r.items || typeof r.items != "object") && (r.items = {}), z(r.items, a, o, [...s, n]);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function Ye(r) {
|
|
596
|
+
const {
|
|
597
|
+
schema: t,
|
|
598
|
+
formData: o,
|
|
599
|
+
uiSchema: s,
|
|
600
|
+
evaluator: n,
|
|
601
|
+
Form: a = be,
|
|
602
|
+
formulaKey: c = "x-formula",
|
|
603
|
+
formulaContextKey: f = "x-formula-context",
|
|
604
|
+
formulaDataKey: i = "__formData__",
|
|
605
|
+
formulaPathKey: l = "__path__",
|
|
606
|
+
maxConvergencePasses: d = 10,
|
|
607
|
+
debounceMs: _ = 300,
|
|
608
|
+
onFormulaError: b,
|
|
609
|
+
onLoadingChange: g,
|
|
610
|
+
onChange: R,
|
|
611
|
+
...x
|
|
612
|
+
} = r, E = re(
|
|
613
|
+
() => Re(t, { formulaKey: c, formulaContextKey: f }),
|
|
614
|
+
[t, c, f]
|
|
615
|
+
), D = re(
|
|
616
|
+
() => ({ formulaDataKey: i, formulaPathKey: l }),
|
|
617
|
+
[i, l]
|
|
618
|
+
), $ = re(
|
|
619
|
+
() => De(s, E),
|
|
620
|
+
[s, E]
|
|
621
|
+
), { enrichedFormData: T, handleInput: S } = Ie(
|
|
622
|
+
o,
|
|
623
|
+
E,
|
|
624
|
+
n,
|
|
625
|
+
_,
|
|
626
|
+
d,
|
|
627
|
+
b,
|
|
628
|
+
g,
|
|
629
|
+
D
|
|
630
|
+
), A = v(R);
|
|
631
|
+
j(() => {
|
|
632
|
+
A.current = R;
|
|
633
|
+
}, [R]), j(() => {
|
|
634
|
+
var O;
|
|
635
|
+
E.length !== 0 && ((O = A.current) == null || O.call(A, { formData: T }, void 0));
|
|
636
|
+
}, [T]);
|
|
637
|
+
const P = (O, C) => {
|
|
638
|
+
S(O.formData), R == null || R(O, C);
|
|
639
|
+
};
|
|
640
|
+
return /* @__PURE__ */ xe.jsx(
|
|
641
|
+
a,
|
|
642
|
+
{
|
|
643
|
+
...x,
|
|
644
|
+
schema: t,
|
|
645
|
+
formData: T,
|
|
646
|
+
uiSchema: $,
|
|
647
|
+
onChange: P
|
|
648
|
+
}
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
export {
|
|
652
|
+
Ye as FormulaForm,
|
|
653
|
+
Re as analyzeSchema
|
|
654
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@a-ludi/rjsf-formulas",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist/"
|
|
7
|
+
],
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=18"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.mts",
|
|
14
|
+
"default": "./dist/index.mjs"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.cts",
|
|
18
|
+
"default": "./dist/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "vite build && cp dist/index.d.mts dist/index.d.cts",
|
|
23
|
+
"dev": "vite --config demo/vite.config.ts",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"prepare": "true",
|
|
26
|
+
"prepublishOnly": "bun run build && bunx publint"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@rjsf/core": ">=5",
|
|
30
|
+
"@rjsf/utils": ">=5",
|
|
31
|
+
"react": ">=17"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@rjsf/core": "^6",
|
|
35
|
+
"@rjsf/utils": "^6",
|
|
36
|
+
"@rjsf/validator-ajv8": "^6",
|
|
37
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
38
|
+
"@testing-library/react": "^16.3.2",
|
|
39
|
+
"@types/react": "^18",
|
|
40
|
+
"fast-deep-equal": "^3.1.3",
|
|
41
|
+
"husky": "^9",
|
|
42
|
+
"jsdom": "^29.1.1",
|
|
43
|
+
"publint": "^0.3",
|
|
44
|
+
"react": "^19",
|
|
45
|
+
"rjsf-core-v5": "npm:@rjsf/core@^5",
|
|
46
|
+
"rjsf-utils-v5": "npm:@rjsf/utils@^5",
|
|
47
|
+
"rjsf-validator-v5": "npm:@rjsf/validator-ajv8@^5",
|
|
48
|
+
"typescript": "^5",
|
|
49
|
+
"vite": "^6",
|
|
50
|
+
"vite-plugin-dts": "^4",
|
|
51
|
+
"vitest": "^3"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"react-dom": "^19"
|
|
55
|
+
}
|
|
56
|
+
}
|