dinocollab-core 2.1.25 → 2.1.26

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,2 +1,2 @@
1
- import{objectSpread2 as r,asyncToGenerator as e,objectWithoutProperties as n,regenerator as o}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as t,jsx as a}from"react/jsx-runtime";import{Box as i,Typography as s,Grid as l,Button as u}from"@mui/material";import{getErrorMessage as d}from"./helpers.js";import{getFormFields as c,getFormValidators as m,getFormPreSubmit as f,isFormRegistered as p}from"./decorator.js";import v from"./validator.js";import b from"./create.input.js";import g from"./create.form-base.js";var h=["type","renderInput"],y=g({}),S=b({}),x=function(e){var o,i,s=e.type,l=e.renderInput,u=n(e,h),c=(null===(o=u.name)||void 0===o?void 0:o.toString())||"",m=(null===(i=u.data)||void 0===i?void 0:i[c])||u.defaultValue;return l?a(l,r({},u)):y.mapContext((function(e){var n=e.messageErrors,o=e.onBlur,i=d(e.messageErrors,u.name);switch(s){case String:return a(S,r(r({},u),{},{messageErrors:n,onBlur:o}));case Number:return a(S,r({slots:{textFieldProps:{type:"number"}},messageErrors:n,onBlur:o},u));case Boolean:return t("div",{children:[t("label",{children:[u.label||c,": "]}),a("input",{name:c,type:"checkbox",defaultChecked:m}),a("span",{style:{color:"red"},children:i.error?i.message:""})]});default:return t("div",{children:["Unsupported field type for ",c]})}}))},j=function(n){var d,b=c(n.configClass),g=m(n.configClass),h=f(n.configClass);if(!p(n.configClass)){var S,j=(null===(S=n.configClass)||void 0===S?void 0:S.name)||"Unknown";return t(i,{sx:{border:"1px dashed #ccc",padding:12,borderRadius:4,color:"#333",background:"#fafafa"},children:[a(s,{variant:"subtitle1",sx:{fontWeight:600,marginBottom:6},children:"Form configuration not registered"}),t(s,{variant:"body1",children:['Configuration for "',j,'" was not found. Did you forget to add ',a("code",{children:"@registerForm"})," to the class?"]})]})}var C,B,E=function(){var r=e(o().m((function r(e){var t,a;return o().w((function(r){for(;;)switch(r.n){case 0:if(t=e,r.p=1,null==h||!h.handler){r.n=3;break}return r.n=2,h.handler(e,n.data);case 2:null==(t=r.v)&&(t=e);case 3:if(!n.onSubmit){r.n=4;break}return r.n=4,n.onSubmit(t);case 4:r.n=6;break;case 5:throw r.p=5,a=r.v,n.onError&&n.onError(a),a;case 6:return r.a(2)}}),r,null,[[1,5]])})));return function(e){return r.apply(this,arguments)}}();return t(y.Form,{onSubmit:E,validate:new v(g),onError:n.onSubmitError,children:[a(l,{container:!0,spacing:2,children:b.map((function(e){return a(l,r(r({item:!0,xs:12},e.size),{},{children:a(x,r({data:n.data},e))}),e.name.toString())}))}),!1===(null===(C=n.slots)||void 0===C?void 0:C.isFooter)?null:null!==(B=n.slots)&&void 0!==B&&B.renderSubmitButton?n.slots.renderSubmitButton():a(u,{variant:"contained",color:"primary",type:"submit",sx:{mt:2},children:"Submit"}),null===(d=n.slots)||void 0===d?void 0:d.bottom]})},C=function(e,n){return function(o){return a(j,r(r({configClass:e},n),o))}};export{x as DecoratorField,j as DecoratorForm,C as createDecoratorForm,j as default};
1
+ import{objectSpread2 as r,asyncToGenerator as e,objectWithoutProperties as n,regenerator as o}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as t,jsx as a}from"react/jsx-runtime";import{Box as i,Typography as s,Grid as l,Button as u}from"@mui/material";import{getErrorMessage as d}from"./helpers.js";import{getFormFields as c,getFormValidators as m,getFormPreSubmit as f,isFormRegistered as p}from"./decorator.js";import v from"./validator.js";import g from"./create.input.js";import b from"./create.form-base.js";var h=["type","renderInput"],x=b({}),y=g({}),C=function(e){var o,i,s=e.type,l=e.renderInput,u=n(e,h),c=(null===(o=u.name)||void 0===o?void 0:o.toString())||"",m=(null===(i=u.data)||void 0===i?void 0:i[c])||u.defaultValue;return x.mapContext((function(e){var n=e.messageErrors,o=e.onBlur,i=d(e.messageErrors,u.name);if(l)return a(l,r(r({},u),{},{messageErrors:n,onBlur:o,formContext:e}));switch(s){case String:return a(y,r(r({},u),{},{messageErrors:n,onBlur:o,formContext:e}));case Number:return a(y,r(r({},u),{},{slots:r({textFieldProps:{type:"number"}},u.slots),messageErrors:n,onBlur:o,formContext:e}));case Boolean:return t("div",{children:[t("label",{children:[u.label||c,": "]}),a("input",{name:c,type:"checkbox",defaultChecked:m}),a("span",{style:{color:"red"},children:i.error?i.message:""})]});default:return t("div",{children:["Unsupported field type for ",c]})}}))},S=function(n){var d,g=c(n.configClass),b=m(n.configClass),h=f(n.configClass);if(!p(n.configClass)){var y,S=(null===(y=n.configClass)||void 0===y?void 0:y.name)||"Unknown";return t(i,{sx:{border:"1px dashed #ccc",padding:12,borderRadius:4,color:"#333",background:"#fafafa"},children:[a(s,{variant:"subtitle1",sx:{fontWeight:600,marginBottom:6},children:"Form configuration not registered"}),t(s,{variant:"body1",children:['Configuration for "',S,'" was not found. Did you forget to add ',a("code",{children:"@registerForm"})," to the class?"]})]})}var j,B,E=function(){var r=e(o().m((function r(e){var t,a;return o().w((function(r){for(;;)switch(r.n){case 0:if(t=e,r.p=1,null==h||!h.handler){r.n=3;break}return r.n=2,h.handler(e,n.data);case 2:null==(t=r.v)&&(t=e);case 3:if(!n.onSubmit){r.n=4;break}return r.n=4,n.onSubmit(t);case 4:r.n=6;break;case 5:throw r.p=5,a=r.v,n.onError&&n.onError(a),a;case 6:return r.a(2)}}),r,null,[[1,5]])})));return function(e){return r.apply(this,arguments)}}();return t(x.Form,{onSubmit:E,validate:new v(b),onError:n.onSubmitError,children:[a(l,{container:!0,spacing:2,children:g.map((function(e){return a(l,r(r({item:!0,xs:12},e.size),{},{children:a(C,r({data:n.data},e))}),e.name.toString())}))}),!1===(null===(j=n.slots)||void 0===j?void 0:j.isFooter)?null:null!==(B=n.slots)&&void 0!==B&&B.renderSubmitButton?n.slots.renderSubmitButton():a(u,{variant:"contained",color:"primary",type:"submit",sx:{mt:2},children:"Submit"}),null===(d=n.slots)||void 0===d?void 0:d.bottom]})},j=function(e,n){return function(o){return a(S,r(r({configClass:e},n),o))}};export{C as DecoratorField,S as DecoratorForm,j as createDecoratorForm,S as default};
2
2
  //# sourceMappingURL=decorator.form.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorator.form.js","sources":["../../../src/form/decorator.form.tsx"],"sourcesContent":["import { ComponentType, FC } from 'react'\r\nimport { Box, Button, Grid, Typography } from '@mui/material'\r\nimport { IFormInputBase } from './types'\r\nimport { getErrorMessage } from './helpers'\r\nimport { getFormFields, getFormPreSubmit, getFormValidators, isFormRegistered } from './decorator'\r\nimport FormValidator, { IPartialError } from './validator'\r\nimport createInput from './create.input'\r\nimport createFormBase from './create.form-base'\r\n\r\nconst FormBase = createFormBase<any>({})\r\nconst InputInstance = createInput<any>({})\r\n\r\nexport interface IDecoratorFieldProps<T = any> extends IFormInputBase<T> {\r\n type?: any\r\n renderInput?: ComponentType<IFormInputBase<T>>\r\n}\r\n\r\nexport const DecoratorField: FC<IDecoratorFieldProps> = ({ type: inputType, renderInput, ...props }) => {\r\n const name = props.name?.toString() || ''\r\n const defaultValue = props.data?.[name] || props.defaultValue\r\n if (renderInput) {\r\n const InputComp = renderInput\r\n return <InputComp {...props} />\r\n }\r\n return FormBase.mapContext((context) => {\r\n const { messageErrors, onBlur } = context\r\n const err = getErrorMessage(context.messageErrors, props.name as any)\r\n switch (inputType) {\r\n case String:\r\n return <InputInstance {...props} messageErrors={messageErrors} onBlur={onBlur} />\r\n case Number:\r\n return <InputInstance slots={{ textFieldProps: { type: 'number' } }} messageErrors={messageErrors} onBlur={onBlur} {...props} />\r\n case Boolean:\r\n return (\r\n <div>\r\n <label>{props.label || name}: </label>\r\n <input name={name} type='checkbox' defaultChecked={defaultValue} />\r\n <span style={{ color: 'red' }}>{err.error ? err.message : ''}</span>\r\n </div>\r\n )\r\n default:\r\n return <div>Unsupported field type for {name}</div>\r\n }\r\n })\r\n}\r\n\r\nexport interface IDecoratorFormSlots {\r\n bottom?: React.ReactNode\r\n isFooter?: React.ReactNode | boolean\r\n renderSubmitButton?: () => React.ReactNode\r\n}\r\n\r\nexport interface IDecoratorFormProps<T = any> {\r\n configClass: any\r\n data?: any\r\n onSubmit?: (data: any) => Promise<void>\r\n onError?: (error: any) => void\r\n onSubmitError?: (error: IPartialError<T>) => void\r\n slots?: IDecoratorFormSlots\r\n}\r\n\r\nexport const DecoratorForm: FC<IDecoratorFormProps> = (props) => {\r\n const fields = getFormFields(props.configClass)\r\n const validators = getFormValidators(props.configClass)\r\n const preSubmitConfig = getFormPreSubmit(props.configClass)\r\n\r\n // If the provided configClass isn't registered via @registerForm,\r\n // show a simple, friendly error UI instead of throwing.\r\n if (!isFormRegistered(props.configClass)) {\r\n const name = props.configClass?.name || 'Unknown'\r\n return (\r\n <Box sx={{ border: '1px dashed #ccc', padding: 12, borderRadius: 4, color: '#333', background: '#fafafa' }}>\r\n <Typography variant='subtitle1' sx={{ fontWeight: 600, marginBottom: 6 }}>\r\n Form configuration not registered\r\n </Typography>\r\n <Typography variant='body1'>\r\n Configuration for \"{name}\" was not found. Did you forget to add <code>@registerForm</code> to the class?\r\n </Typography>\r\n </Box>\r\n )\r\n }\r\n\r\n const handleSubmit = async (data: any) => {\r\n let processedData = data\r\n try {\r\n // Execute presubmit handler if exists\r\n if (preSubmitConfig?.handler) {\r\n processedData = await preSubmitConfig.handler(data, props.data)\r\n // If handler returns null/undefined, use original data\r\n if (processedData === null || processedData === undefined) {\r\n processedData = data\r\n }\r\n }\r\n\r\n // Call the original onSubmit with processed data\r\n if (props.onSubmit) {\r\n await props.onSubmit(processedData)\r\n }\r\n } catch (error) {\r\n if (props.onError) {\r\n props.onError(error)\r\n }\r\n throw error\r\n }\r\n }\r\n\r\n const renderFooter = () => {\r\n if (props.slots?.isFooter === false) return null\r\n if (props.slots?.renderSubmitButton) {\r\n return props.slots.renderSubmitButton()\r\n }\r\n return (\r\n <Button variant='contained' color='primary' type='submit' sx={{ mt: 2 }}>\r\n Submit\r\n </Button>\r\n )\r\n }\r\n\r\n return (\r\n <FormBase.Form onSubmit={handleSubmit} validate={new FormValidator(validators)} onError={props.onSubmitError}>\r\n <Grid container spacing={2}>\r\n {fields.map((field) => (\r\n <Grid item key={field.name.toString()} xs={12} {...field.size}>\r\n <DecoratorField data={props.data} {...field} />\r\n </Grid>\r\n ))}\r\n </Grid>\r\n {renderFooter()}\r\n {props.slots?.bottom}\r\n </FormBase.Form>\r\n )\r\n}\r\nexport default DecoratorForm\r\n\r\nexport const createDecoratorForm = function <T>(\r\n configClass: any,\r\n params?: Partial<Omit<IDecoratorFormProps, 'configClass'>>\r\n): ComponentType<Omit<IDecoratorFormProps, 'configClass'>> {\r\n const DecoratorFormComp: FC<Omit<IDecoratorFormProps, 'configClass'>> = (props) => {\r\n return <DecoratorForm configClass={configClass} {...params} {...props} />\r\n }\r\n return DecoratorFormComp\r\n}\r\n"],"names":["FormBase","createFormBase","InputInstance","createInput","DecoratorField","_ref","_props$name","_props$data","inputType","type","renderInput","props","_objectWithoutProperties","_excluded","name","toString","defaultValue","data","_jsx","_objectSpread","mapContext","context","messageErrors","onBlur","err","getErrorMessage","String","Number","slots","textFieldProps","Boolean","_jsxs","children","label","defaultChecked","style","color","error","message","DecoratorForm","_props$slots3","fields","getFormFields","configClass","validators","getFormValidators","preSubmitConfig","getFormPreSubmit","isFormRegistered","_props$configClass","Box","sx","border","padding","borderRadius","background","Typography","variant","fontWeight","marginBottom","_props$slots","_props$slots2","handleSubmit","_ref2","_asyncToGenerator","_regenerator","m","_callee","processedData","_t","w","_context","n","p","handler","v","onSubmit","onError","a","_x","apply","this","arguments","Form","validate","FormValidator","onSubmitError","Grid","container","spacing","map","field","item","xs","size","isFooter","renderSubmitButton","Button","mt","bottom","createDecoratorForm","params"],"mappings":"8iBASMA,EAAWC,EAAoB,IAC/BC,EAAgBC,EAAiB,IAO1BC,EAA2C,SAA7BC,GAA4E,IAAAC,EAAAC,EAAtCC,EAASH,EAAfI,KAAiBC,EAAWL,EAAXK,YAAgBC,EAAKC,EAAAP,EAAAQ,GACzFC,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ACtBhD,EAAOiD,KAAI,SAACC,GAAK,OAChBzE,EAACqE,EAAIpE,EAAAA,EAAA,CAACyE,MAAiC,EAAAC,GAAI,IAAQF,EAAMG,MAAI,GAAA,UAC3D5E,EAACd,EAAce,EAAA,CAACF,KAAMN,EAAMM,MAAU0E,MADxBA,EAAM7E,KAAKC,WAG5B,OAlByB,KAAf6C,QAAXA,EAAAjD,EAAMiB,aAANgC,IAAWA,OAAXA,EAAAA,EAAamC,UAA2B,KAC7BlC,QAAfA,EAAIlD,EAAMiB,aAANiC,IAAWA,GAAXA,EAAamC,mBACRrF,EAAMiB,MAAMoE,qBAGnB9E,EAAC+E,EAAO,CAAAxC,QAAQ,YAAYrB,MAAM,UAAU3B,KAAK,SAAS0C,GAAI,CAAE+C,GAAI,GAE3DlE,SAAA,WAcGQ,QADGA,EACd7B,EAAMiB,aAANY,IAAWA,OAAXA,EAAAA,EAAa2D,SAGpB,EAGaC,EAAsB,SACjCzD,EACA0D,GAKA,OAHwE,SAAC1F,GACvE,OAAOO,EAACqB,EAAapB,EAAAA,EAAA,CAACwB,YAAaA,GAAiB0D,GAAY1F,GACjE,CAEH"}
1
+ {"version":3,"file":"decorator.form.js","sources":["../../../src/form/decorator.form.tsx"],"sourcesContent":["import { ComponentType, FC } from 'react'\r\nimport { Box, Button, Grid, Typography } from '@mui/material'\r\nimport { IFormInputBase } from './types'\r\nimport { getErrorMessage } from './helpers'\r\nimport { getFormFields, getFormPreSubmit, getFormValidators, isFormRegistered } from './decorator'\r\nimport FormValidator, { IPartialError } from './validator'\r\nimport createInput from './create.input'\r\nimport createFormBase from './create.form-base'\r\n\r\nconst FormBase = createFormBase<any>({})\r\nconst InputInstance = createInput<any>({})\r\n\r\nexport interface IDecoratorFieldProps<T = any> extends IFormInputBase<T> {\r\n type?: any\r\n renderInput?: ComponentType<IFormInputBase<T>>\r\n}\r\n\r\nexport const DecoratorField: FC<IDecoratorFieldProps> = ({ type: inputType, renderInput, ...props }) => {\r\n const name = props.name?.toString() || ''\r\n const defaultValue = props.data?.[name] || props.defaultValue\r\n\r\n return FormBase.mapContext((context) => {\r\n const { messageErrors, onBlur } = context\r\n const err = getErrorMessage(context.messageErrors, props.name as any)\r\n if (renderInput) {\r\n const InputComp = renderInput\r\n return <InputComp {...props} messageErrors={messageErrors} onBlur={onBlur} formContext={context} />\r\n }\r\n switch (inputType) {\r\n case String:\r\n return <InputInstance {...props} messageErrors={messageErrors} onBlur={onBlur} formContext={context} />\r\n case Number:\r\n return (\r\n <InputInstance\r\n {...props}\r\n slots={{ textFieldProps: { type: 'number' }, ...props.slots }}\r\n messageErrors={messageErrors}\r\n onBlur={onBlur}\r\n formContext={context}\r\n />\r\n )\r\n case Boolean:\r\n return (\r\n <div>\r\n <label>{props.label || name}: </label>\r\n <input name={name} type='checkbox' defaultChecked={defaultValue} />\r\n <span style={{ color: 'red' }}>{err.error ? err.message : ''}</span>\r\n </div>\r\n )\r\n default:\r\n return <div>Unsupported field type for {name}</div>\r\n }\r\n })\r\n}\r\n\r\nexport interface IDecoratorFormSlots {\r\n bottom?: React.ReactNode\r\n isFooter?: React.ReactNode | boolean\r\n renderSubmitButton?: () => React.ReactNode\r\n}\r\n\r\nexport interface IDecoratorFormProps<T = any> {\r\n configClass: any\r\n data?: any\r\n onSubmit?: (data: any) => Promise<void>\r\n onError?: (error: any) => void\r\n onSubmitError?: (error: IPartialError<T>) => void\r\n slots?: IDecoratorFormSlots\r\n}\r\n\r\nexport const DecoratorForm: FC<IDecoratorFormProps> = (props) => {\r\n const fields = getFormFields(props.configClass)\r\n const validators = getFormValidators(props.configClass)\r\n const preSubmitConfig = getFormPreSubmit(props.configClass)\r\n\r\n // If the provided configClass isn't registered via @registerForm,\r\n // show a simple, friendly error UI instead of throwing.\r\n if (!isFormRegistered(props.configClass)) {\r\n const name = props.configClass?.name || 'Unknown'\r\n return (\r\n <Box sx={{ border: '1px dashed #ccc', padding: 12, borderRadius: 4, color: '#333', background: '#fafafa' }}>\r\n <Typography variant='subtitle1' sx={{ fontWeight: 600, marginBottom: 6 }}>\r\n Form configuration not registered\r\n </Typography>\r\n <Typography variant='body1'>\r\n Configuration for \"{name}\" was not found. Did you forget to add <code>@registerForm</code> to the class?\r\n </Typography>\r\n </Box>\r\n )\r\n }\r\n\r\n const handleSubmit = async (data: any) => {\r\n let processedData = data\r\n try {\r\n // Execute presubmit handler if exists\r\n if (preSubmitConfig?.handler) {\r\n processedData = await preSubmitConfig.handler(data, props.data)\r\n // If handler returns null/undefined, use original data\r\n if (processedData === null || processedData === undefined) {\r\n processedData = data\r\n }\r\n }\r\n\r\n // Call the original onSubmit with processed data\r\n if (props.onSubmit) {\r\n await props.onSubmit(processedData)\r\n }\r\n } catch (error) {\r\n if (props.onError) {\r\n props.onError(error)\r\n }\r\n throw error\r\n }\r\n }\r\n\r\n const renderFooter = () => {\r\n if (props.slots?.isFooter === false) return null\r\n if (props.slots?.renderSubmitButton) {\r\n return props.slots.renderSubmitButton()\r\n }\r\n return (\r\n <Button variant='contained' color='primary' type='submit' sx={{ mt: 2 }}>\r\n Submit\r\n </Button>\r\n )\r\n }\r\n\r\n return (\r\n <FormBase.Form onSubmit={handleSubmit} validate={new FormValidator(validators)} onError={props.onSubmitError}>\r\n <Grid container spacing={2}>\r\n {fields.map((field) => (\r\n <Grid item key={field.name.toString()} xs={12} {...field.size}>\r\n <DecoratorField data={props.data} {...field} />\r\n </Grid>\r\n ))}\r\n </Grid>\r\n {renderFooter()}\r\n {props.slots?.bottom}\r\n </FormBase.Form>\r\n )\r\n}\r\nexport default DecoratorForm\r\n\r\nexport const createDecoratorForm = function <T>(\r\n configClass: any,\r\n params?: Partial<Omit<IDecoratorFormProps, 'configClass'>>\r\n): ComponentType<Omit<IDecoratorFormProps, 'configClass'>> {\r\n const DecoratorFormComp: FC<Omit<IDecoratorFormProps, 'configClass'>> = (props) => {\r\n return <DecoratorForm configClass={configClass} {...params} {...props} />\r\n }\r\n return DecoratorFormComp\r\n}\r\n"],"names":["FormBase","createFormBase","InputInstance","createInput","DecoratorField","_ref","_props$name","_props$data","inputType","type","renderInput","props","_objectWithoutProperties","_excluded","name","toString","defaultValue","data","mapContext","context","messageErrors","onBlur","err","getErrorMessage","_jsx","_objectSpread","formContext","String","Number","slots","textFieldProps","Boolean","_jsxs","children","label","defaultChecked","style","color","error","message","DecoratorForm","_props$slots3","fields","getFormFields","configClass","validators","getFormValidators","preSubmitConfig","getFormPreSubmit","isFormRegistered","_props$configClass","Box","sx","border","padding","borderRadius","background","Typography","variant","fontWeight","marginBottom","_props$slots","_props$slots2","handleSubmit","_ref2","_asyncToGenerator","_regenerator","m","_callee","processedData","_t","w","_context","n","p","handler","v","onSubmit","onError","a","_x","apply","this","arguments","Form","validate","FormValidator","onSubmitError","Grid","container","spacing","map","field","item","xs","size","isFooter","renderSubmitButton","Button","mt","bottom","createDecoratorForm","params"],"mappings":"8iBASMA,EAAWC,EAAoB,IAC/BC,EAAgBC,EAAiB,IAO1BC,EAA2C,SAA7BC,GAA4E,IAAAC,EAAAC,EAAtCC,EAASH,EAAfI,KAAiBC,EAAWL,EAAXK,YAAgBC,EAAKC,EAAAP,EAAAQ,GACzFC,GAAiBR,QAAVA,EAAAK,EAAMG,gBAAIR,SAAVA,EAAYS,aAAc,GACjCC,GAAyB,QAAVT,EAAAI,EAAMM,YAAI,IAAAV,OAAA,EAAVA,EAAaO,KAASH,EAAMK,aAEjD,OAAOhB,EAASkB,YAAW,SAACC,GAC1B,IAAQC,EAA0BD,EAA1BC,cAAeC,EAAWF,EAAXE,OACjBC,EAAMC,EAAgBJ,EAAQC,cAAeT,EAAMG,MACzD,GAAIJ,EAEF,OAAOc,EADWd,EACDe,EAAAA,KAAKd,GAAK,GAAA,CAAES,cAAeA,EAAeC,OAAQA,EAAQK,YAAaP,KAE1F,OAAQX,GACN,KAAKmB,OACH,OAAOH,EAACtB,EAAauB,EAAAA,KAAKd,GAAK,GAAA,CAAES,cAAeA,EAAeC,OAAQA,EAAQK,YAAaP,KAC9F,KAAKS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zE,EAAC0E,EAAO,CAAAxC,QAAQ,YAAYrB,MAAM,UAAU5B,KAAK,SAAS2C,GAAI,CAAE+C,GAAI,GAE3DlE,SAAA,WAcGQ,QADGA,EACd9B,EAAMkB,aAANY,IAAWA,OAAXA,EAAAA,EAAa2D,SAGpB,EAGaC,EAAsB,SACjCzD,EACA0D,GAKA,OAHwE,SAAC3F,GACvE,OAAOa,EAACgB,EAAaf,EAAAA,EAAA,CAACmB,YAAaA,GAAiB0D,GAAY3F,GACjE,CAEH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dinocollab-core",
3
- "version": "2.1.25",
3
+ "version": "2.1.26",
4
4
  "description": "Dinocollab core - libraries for building collaborative applications with React 18",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",