jamespot-react-core 1.1.96 → 1.1.98

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
- "use strict";(self.webpackChunkReactCore=self.webpackChunkReactCore||[]).push([[898],{898:(e,t,n)=>{n.r(t),n.d(t,{DisplayForm:()=>l,Empty:()=>c,TwoColLayout:()=>g});var a=n(363),o=n(230),r=n(181);function s(e){return a.createElement(e.components.input,Object.assign({},e))}const l=a.forwardRef(((e,t)=>{const n=(0,r.useIntl)(),l=a.useRef(null),{attributesName:c,object:i,componentsOverride:u}=e,m=J.react.useDisplay(c||[],i.type),p=J.react.registry.getLazyComponent("ValidationButton"),{handleSubmit:d,control:g,reset:b}=(0,o.useForm)({defaultValues:Object.assign({},Object.fromEntries(m.map((e=>[e.name,"checkbox"===e.widget.type?[]:""])))),criteriaMode:"all"});return a.useImperativeHandle(t,(()=>({reset:()=>{var e;null===(e=null==l?void 0:l.current)||void 0===e||e.scrollTo(0,0),b()}})),[]),a.createElement("form",{onSubmit:d(e.onSubmit),ref:l},m.map(((e,t)=>(e.components=Object.assign(Object.assign({},e.components),null==u?void 0:u[e.name]),a.createElement(s,Object.assign({key:t,control:g},e))))),a.createElement(p,{type:"submit"},n.formatMessage({id:"APP_ASEI_Modal_Creation_Title"})))})),c=()=>a.createElement(a.Fragment,null);var i=n(248),u=n(601);const m=u.default.registry.getLazyComponent("Container"),p=u.default.registry.getLazyComponent("AppColumn"),d=u.default.registry.getLazyComponent("MainColumn");function g({extensionRoute:e,routes:t,description:n,mode:o="center"}){var s;const l=(0,r.useIntl)(),{pathname:c}=(0,i.useLocation)(),u=Object.values(t),[g,b]=a.useState(null===(s=null==u?void 0:u[0])||void 0===s?void 0:s.key),f=u.map((t=>Object.assign(Object.assign({},t),{label:l.formatMessage({id:t.label}),href:`/ng/rr/${e}/${t.path}`,group:t.group?l.formatMessage({id:t.group}):void 0})));return a.useEffect((()=>{const t=u.find((t=>c===`/ng/rr/${e}/${t.path}`));t&&b(t.key)}),[c]),a.createElement(a.Suspense,{fallback:a.createElement(a.Fragment,null)},a.createElement(m,{mode:o},a.createElement(p,{mode:o,description:n,tabs:f,activeTab:g||""}),a.createElement(d,{mode:o},a.createElement(i.Outlet,null))))}}}]);
1
+ "use strict";(self.webpackChunkReactCore=self.webpackChunkReactCore||[]).push([[898],{898:(e,t,n)=>{n.r(t),n.d(t,{DisplayForm:()=>l,Empty:()=>s,TwoColLayout:()=>f});var r=n(363),a=n(230),o=n(375);const l=r.forwardRef(((e,t)=>{const n=r.useRef(null),[l,s]=(0,o.GF)(e.fields,e.type),{handleSubmit:u,control:c,reset:i}=(0,a.useForm)({defaultValues:Object.assign(Object.assign({},s),e.defaultValues),criteriaMode:"all"});return r.useImperativeHandle(t,(()=>({reset:()=>{var e;null===(e=null==n?void 0:n.current)||void 0===e||e.scrollTo(0,0),i()}})),[]),r.createElement("form",{onSubmit:u(e.onSubmit),ref:n},l.map((t=>{var{Input:n}=t,a=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]])}return n}(t,["Input"]);return r.createElement(n,Object.assign({key:a.name,control:c},a,{dataCy:`${e.dataCy}-${a.name}`}))})),e.extraInputs&&e.extraInputs(c),e.buttons)})),s=()=>r.createElement(r.Fragment,null);var u=n(248),c=n(181),i=n(675);const m=i.default.registry.getLazyComponent("Container"),p=i.default.registry.getLazyComponent("AppColumn"),d=i.default.registry.getLazyComponent("MainColumn");function f({extensionRoute:e,routes:t,description:n,mode:a="center"}){var o;const l=(0,c.useIntl)(),{pathname:s}=(0,u.useLocation)(),i=Object.values(t),[f,b]=r.useState(null===(o=null==i?void 0:i[0])||void 0===o?void 0:o.key),y=i.map((t=>Object.assign(Object.assign({},t),{label:l.formatMessage({id:t.label}),href:`/ng/rr/${e}/${t.path}`,group:t.group?l.formatMessage({id:t.group}):void 0})));return r.useEffect((()=>{const t=i.find((t=>s===`/ng/rr/${e}/${t.path}`));t&&b(t.key)}),[s]),r.createElement(r.Suspense,{fallback:r.createElement(r.Fragment,null)},r.createElement(m,{mode:a},r.createElement(p,{mode:a,description:n,tabs:y,activeTab:f||""}),r.createElement(d,{mode:a},r.createElement(u.Outlet,null))))}}}]);
2
2
  //# sourceMappingURL=898.bundle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"898.bundle.js","mappings":"oMAQA,SAASA,EAAoBC,GACzB,OAAO,gBAACA,EAAMC,WAAWC,MAAK,iBAAKF,IAgBhC,MAAMG,EAAc,cAAsC,CAACH,EAAOI,KACrE,MAAMC,GAAO,IAAAC,WAEPC,EAAU,SAA8B,OAExC,eAAEC,EAAc,OAAEC,EAAM,mBAAEC,GAAuBV,EACjDW,EAAaC,EAAEC,MAAMC,WAAWN,GAAkB,GAAIC,EAAOM,MAC7DC,EAAmBJ,EAAEC,MAAMI,SAASC,iBAAiB,qBAErD,aAAEC,EAAY,QAAEC,EAAO,MAAEC,IAAU,IAAAC,SAAQ,CAC7CC,cAAe,OAAF,UAELC,OAAeC,YACfd,EAAWe,KAAKC,GAAgB,CAACA,EAAYC,KAAkC,aAA5BD,EAAYE,OAAOd,KAAsB,GAAK,QAGzGe,aAAc,QAgBlB,OAbA,sBACI1B,GACA,KAAM,CACFiB,MAAO,K,MAEa,QAAhB,EAAAd,MAAAA,OAAO,EAAPA,EAASwB,eAAO,SAAEC,SAAS,EAAG,GAE9BX,QAGR,IAIA,wBAAMY,SAAUd,EAAanB,EAAMiC,UAAW7B,IAAKG,GAC9CI,EAAWe,KAAI,CAACC,EAAaO,KAC1BP,EAAY1B,WAAa,OAAH,wBACf0B,EAAY1B,YACZS,MAAAA,OAAkB,EAAlBA,EAAqBiB,EAAYC,OAEjC,gBAAC7B,EAAW,eAACoC,IAAKD,EAAOd,QAASA,GAAaO,OAG1D,gBAACX,EAAgB,CAACD,KAAK,UAClBV,EAAK+B,cAAc,CAAEC,GAAI,uCCjE7BC,EAAQ,IAAM,iC,sBCK3B,MAAMC,EAAY,oCAAiC,aAC7CC,EAAY,oCAAiC,aAC7CC,EAAa,oCAAiC,cAmB7C,SAASC,GAAa,eAAEC,EAAc,OAAEC,EAAM,YAAEC,EAAW,KAAEC,EAAO,W,MACvE,MAAMzC,GAAO,IAAAC,YACP,SAAEyC,IAAa,IAAAC,eAEfC,EAAezB,OAAO0B,OAAON,IAC5BO,EAAWC,GAAgB,WAAgC,QAAjB,EAAAH,MAAAA,OAAY,EAAZA,EAAe,UAAE,eAAEd,KAE9DkB,EAAOJ,EAAavB,KAAK4B,GAAS,OAAD,wBAChCA,GAAG,CACNC,MAAOlD,EAAK+B,cAAc,CAAEC,GAAIiB,EAAIC,QACpCC,KAAM,UAAUb,KAAkBW,EAAIG,OACtCC,MAAOJ,EAAII,MAAQrD,EAAK+B,cAAc,CAAEC,GAAIiB,EAAII,aAAWC,MAQ/D,OALA,aAAgB,KACZ,MAAMC,EAAcX,EAAaY,MAAMC,GAAUf,IAAa,UAAUJ,KAAkBmB,EAAML,SAC5FG,GAAaR,EAAaQ,EAAYzB,OAC3C,CAACY,IAGA,gBAAC,WAAc,CAACgB,SAAU,kCACtB,gBAACxB,EAAS,CAACO,KAAMA,GACb,gBAACN,EAAS,CAACM,KAAMA,EAAMD,YAAaA,EAAaQ,KAAMA,EAAMF,UAAWA,GAAa,KACrF,gBAACV,EAAU,CAACK,KAAMA,GACd,gBAAC,EAAAkB,OAAM","sources":["webpack://ReactCore/./src/displayer/DisplayForm.component.tsx","webpack://ReactCore/./src/displayer/Empty.tsx","webpack://ReactCore/./src/components/TwoColLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { DisplayFormRef, RenderInputProps } from './types';\nimport { useForm } from 'react-hook-form';\nimport { useIntl } from 'react-intl';\n\n/***\n * Choose the component to render according to the type of the object\n */\nfunction RenderInput<Object>(props: RenderInputProps<Object>) {\n return <props.components.input {...props} />;\n}\n\n/****\n * The jamespot model depend on the platform\n * For example a user can have the size attribute only for a given platform\n * The model specifics of a platform are stored in J.model\n *\n * This component display an array of attributes only if this attribute is activated on the platform\n *\n * @param props.object the object to display (ie the user)\n * @param props.attributesName an array of string : the list of attributes we want to display\n * @param props.componentsOverride we can override the default render of the attribute\n * @param props.componentsOverride.input the component input\n * Note :If we override the \"render\" you can't override \"wrapper\" and \"element\" because the render rewrite everything\n */\nexport const DisplayForm = React.forwardRef<DisplayFormRef, any>((props, ref) => {\n const intl = useIntl();\n\n const formRef = React.useRef<HTMLFormElement>(null);\n\n const { attributesName, object, componentsOverride } = props;\n const formConfig = J.react.useDisplay(attributesName || [], object.type);\n const ValidationButton = J.react.registry.getLazyComponent('ValidationButton');\n\n const { handleSubmit, control, reset } = useForm({\n defaultValues: {\n // initialize with empty array of checkbox, empty string otherwise\n ...(Object as any).fromEntries(\n formConfig.map((inputConfig) => [inputConfig.name, inputConfig.widget.type === 'checkbox' ? [] : '']),\n ),\n },\n criteriaMode: 'all',\n });\n\n React.useImperativeHandle(\n ref,\n () => ({\n reset: () => {\n // in case the form is scrollable\n formRef?.current?.scrollTo(0, 0);\n // reset react-hook-form form\n reset();\n },\n }),\n [],\n );\n\n return (\n <form onSubmit={handleSubmit(props.onSubmit)} ref={formRef}>\n {formConfig.map((inputConfig, index) => {\n inputConfig.components = {\n ...inputConfig.components,\n ...componentsOverride?.[inputConfig.name],\n };\n return <RenderInput key={index} control={control} {...inputConfig} />;\n })}\n\n <ValidationButton type=\"submit\">\n {intl.formatMessage({ id: 'APP_ASEI_Modal_Creation_Title' })}\n </ValidationButton>\n </form>\n );\n});\n","import * as React from 'react';\n\n// FIXME move to j-react-components + display error if dev mode\nexport const Empty = () => <></>;\n","import * as React from 'react';\nimport { Outlet } from 'react-router-dom';\nimport { useIntl } from 'react-intl';\nimport type { JRCAppColumnProps } from 'jamespot-react-components';\nimport JRCore from 'App';\nimport { useLocation } from 'react-router-dom';\nimport { LayoutMode } from 'jamespot-react-components';\n\nconst Container = JRCore.registry.getLazyComponent('Container');\nconst AppColumn = JRCore.registry.getLazyComponent('AppColumn');\nconst MainColumn = JRCore.registry.getLazyComponent('MainColumn');\n\nexport type TwoColLayoutRoute = {\n path: string;\n key: string;\n icon: string;\n label: string;\n group?: string;\n};\n\nexport type TwoColLayoutRoutes = Record<string, TwoColLayoutRoute>;\n\nexport type TwoColLayoutProps = {\n extensionRoute: string;\n routes: TwoColLayoutRoutes;\n mode?: LayoutMode;\n description: JRCAppColumnProps['description'];\n};\n\nexport function TwoColLayout({ extensionRoute, routes, description, mode = 'center' }: TwoColLayoutProps) {\n const intl = useIntl();\n const { pathname } = useLocation();\n\n const ROUTES_ARRAY = Object.values(routes);\n const [activeTab, setActiveTab] = React.useState(ROUTES_ARRAY?.[0]?.key);\n\n const tabs = ROUTES_ARRAY.map((tab) => ({\n ...tab,\n label: intl.formatMessage({ id: tab.label }),\n href: `/ng/rr/${extensionRoute}/${tab.path}`,\n group: tab.group ? intl.formatMessage({ id: tab.group }) : undefined,\n }));\n\n React.useEffect(() => {\n const activeRoute = ROUTES_ARRAY.find((route) => pathname === `/ng/rr/${extensionRoute}/${route.path}`);\n if (activeRoute) setActiveTab(activeRoute.key);\n }, [pathname]);\n\n return (\n <React.Suspense fallback={<></>}>\n <Container mode={mode}>\n <AppColumn mode={mode} description={description} tabs={tabs} activeTab={activeTab || ''} />\n <MainColumn mode={mode}>\n <Outlet />\n </MainColumn>\n </Container>\n </React.Suspense>\n );\n}\n"],"names":["RenderInput","props","components","input","DisplayForm","ref","intl","useIntl","formRef","attributesName","object","componentsOverride","formConfig","J","react","useDisplay","type","ValidationButton","registry","getLazyComponent","handleSubmit","control","reset","useForm","defaultValues","Object","fromEntries","map","inputConfig","name","widget","criteriaMode","current","scrollTo","onSubmit","index","key","formatMessage","id","Empty","Container","AppColumn","MainColumn","TwoColLayout","extensionRoute","routes","description","mode","pathname","useLocation","ROUTES_ARRAY","values","activeTab","setActiveTab","tabs","tab","label","href","path","group","undefined","activeRoute","find","route","fallback","Outlet"],"sourceRoot":""}
1
+ {"version":3,"file":"898.bundle.js","mappings":"oMAmBO,MAAMA,EAAc,cAWzB,CAACC,EAAOC,KACN,MAAMC,EAAU,SAA8B,OAEvCC,EAAeC,IAAiB,EAAAC,EAAA,IAAeL,EAAMM,OAAQN,EAAMO,OAEpE,aAAEC,EAAY,QAAEC,EAAO,MAAEC,IAAU,IAAAC,SAAQ,CAC7CP,cAAe,OAAF,wBACNA,GACAJ,EAAMI,eAEbQ,aAAc,QAgBlB,OAbA,sBACIX,GACA,KAAM,CACFS,MAAO,K,MAEa,QAAhB,EAAAR,MAAAA,OAAO,EAAPA,EAASW,eAAO,SAAEC,SAAS,EAAG,GAE9BJ,QAGR,IAIA,wBAAMK,SAAUP,EAAaR,EAAMe,UAAWd,IAAKC,GAC9CC,EAAca,KAAK,I,IAAA,MAAEC,GAAK,EAAKC,E,yUAAI,GAAhB,WAAuB,OACvC,gBAACD,EAAK,eAACE,IAAKD,EAAKE,KAAMX,QAASA,GAAaS,EAAI,CAAEG,OAAQ,GAAGrB,EAAMqB,UAAUH,EAAKE,aAEtFpB,EAAMsB,aAAetB,EAAMsB,YAAYb,GACvCT,EAAMuB,YC3DNC,EAAQ,IAAM,iC,+BCK3B,MAAMC,EAAY,oCAAiC,aAC7CC,EAAY,oCAAiC,aAC7CC,EAAa,oCAAiC,cAmB7C,SAASC,GAAa,eAAEC,EAAc,OAAEC,EAAM,YAAEC,EAAW,KAAEC,EAAO,W,MACvE,MAAMC,GAAO,IAAAC,YACP,SAAEC,IAAa,IAAAC,eAEfC,EAAeC,OAAOC,OAAOT,IAC5BU,EAAWC,GAAgB,WAAgC,QAAjB,EAAAJ,MAAAA,OAAY,EAAZA,EAAe,UAAE,eAAElB,KAE9DuB,EAAOL,EAAarB,KAAK2B,GAAS,OAAD,wBAChCA,GAAG,CACNC,MAAOX,EAAKY,cAAc,CAAEC,GAAIH,EAAIC,QACpCG,KAAM,UAAUlB,KAAkBc,EAAIK,OACtCC,MAAON,EAAIM,MAAQhB,EAAKY,cAAc,CAAEC,GAAIH,EAAIM,aAAWC,MAQ/D,OALA,aAAgB,KACZ,MAAMC,EAAcd,EAAae,MAAMC,GAAUlB,IAAa,UAAUN,KAAkBwB,EAAML,SAC5FG,GAAaV,EAAaU,EAAYhC,OAC3C,CAACgB,IAGA,gBAAC,WAAc,CAACmB,SAAU,kCACtB,gBAAC7B,EAAS,CAACO,KAAMA,GACb,gBAACN,EAAS,CAACM,KAAMA,EAAMD,YAAaA,EAAaW,KAAMA,EAAMF,UAAWA,GAAa,KACrF,gBAACb,EAAU,CAACK,KAAMA,GACd,gBAAC,EAAAuB,OAAM","sources":["webpack://ReactCore/./src/displayer/DisplayForm.component.tsx","webpack://ReactCore/./src/displayer/Empty.tsx","webpack://ReactCore/./src/components/TwoColLayout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { DisplayFormRef, FieldsWithOptionalRender } from './types';\nimport { useForm, Control } from 'react-hook-form';\nimport { useDisplayForm } from './useDisplay';\n\n/****\n * The jamespot model depend on the platform\n * For example a user can have the size attribute only for a given platform\n * The model specifics of a platform are stored in J.model\n *\n * This component display an array of attributes only if this attribute is activated on the platform\n *\n * @param type form model type (sport, mpArticle, etc.)\n * @param fields an array of string : the list of attributes we want to display\n * @param defaultValues react hook form default values\n * @param onSubmit callback provided to react hook, called after successful validation\n * @param buttons the buttons, should always include a <button type=\"submit\">\n * Note :If we override the \"render\" you can't override \"wrapper\" and \"element\" because the render rewrite everything\n */\nexport const DisplayForm = React.forwardRef<\n DisplayFormRef,\n {\n type: string;\n fields: FieldsWithOptionalRender<any, any>;\n extraInputs?: (control: Control<any>) => React.ReactNode;\n defaultValues?: any;\n onSubmit: any;\n buttons: React.ReactNode;\n dataCy?: string;\n }\n>((props, ref) => {\n const formRef = React.useRef<HTMLFormElement>(null);\n\n const [configuration, defaultValues] = useDisplayForm(props.fields, props.type);\n\n const { handleSubmit, control, reset } = useForm({\n defaultValues: {\n ...defaultValues,\n ...props.defaultValues,\n },\n criteriaMode: 'all',\n });\n\n React.useImperativeHandle(\n ref,\n () => ({\n reset: () => {\n // in case the form is scrollable\n formRef?.current?.scrollTo(0, 0);\n // reset react-hook-form form\n reset();\n },\n }),\n [],\n );\n\n return (\n <form onSubmit={handleSubmit(props.onSubmit)} ref={formRef}>\n {configuration.map(({ Input, ...conf }) => (\n <Input key={conf.name} control={control} {...conf} dataCy={`${props.dataCy}-${conf.name}`} />\n ))}\n {props.extraInputs && props.extraInputs(control)}\n {props.buttons}\n </form>\n );\n});\n","import * as React from 'react';\n\n// FIXME move to j-react-components + display error if dev mode\nexport const Empty = () => <></>;\n","import * as React from 'react';\nimport { Outlet } from 'react-router-dom';\nimport { useIntl } from 'react-intl';\nimport type { JRCAppColumnProps } from 'jamespot-react-components';\nimport JRCore from 'App';\nimport { useLocation } from 'react-router-dom';\nimport { LayoutMode } from 'jamespot-react-components';\n\nconst Container = JRCore.registry.getLazyComponent('Container');\nconst AppColumn = JRCore.registry.getLazyComponent('AppColumn');\nconst MainColumn = JRCore.registry.getLazyComponent('MainColumn');\n\nexport type TwoColLayoutRoute = {\n path: string;\n key: string;\n icon: string;\n label: string;\n group?: string;\n};\n\nexport type TwoColLayoutRoutes = Record<string, TwoColLayoutRoute>;\n\nexport type TwoColLayoutProps = {\n extensionRoute: string;\n routes: TwoColLayoutRoutes;\n mode?: LayoutMode;\n description: JRCAppColumnProps['description'];\n};\n\nexport function TwoColLayout({ extensionRoute, routes, description, mode = 'center' }: TwoColLayoutProps) {\n const intl = useIntl();\n const { pathname } = useLocation();\n\n const ROUTES_ARRAY = Object.values(routes);\n const [activeTab, setActiveTab] = React.useState(ROUTES_ARRAY?.[0]?.key);\n\n const tabs = ROUTES_ARRAY.map((tab) => ({\n ...tab,\n label: intl.formatMessage({ id: tab.label }),\n href: `/ng/rr/${extensionRoute}/${tab.path}`,\n group: tab.group ? intl.formatMessage({ id: tab.group }) : undefined,\n }));\n\n React.useEffect(() => {\n const activeRoute = ROUTES_ARRAY.find((route) => pathname === `/ng/rr/${extensionRoute}/${route.path}`);\n if (activeRoute) setActiveTab(activeRoute.key);\n }, [pathname]);\n\n return (\n <React.Suspense fallback={<></>}>\n <Container mode={mode}>\n <AppColumn mode={mode} description={description} tabs={tabs} activeTab={activeTab || ''} />\n <MainColumn mode={mode}>\n <Outlet />\n </MainColumn>\n </Container>\n </React.Suspense>\n );\n}\n"],"names":["DisplayForm","props","ref","formRef","configuration","defaultValues","useDisplay","fields","type","handleSubmit","control","reset","useForm","criteriaMode","current","scrollTo","onSubmit","map","Input","conf","key","name","dataCy","extraInputs","buttons","Empty","Container","AppColumn","MainColumn","TwoColLayout","extensionRoute","routes","description","mode","intl","useIntl","pathname","useLocation","ROUTES_ARRAY","Object","values","activeTab","setActiveTab","tabs","tab","label","formatMessage","id","href","path","group","undefined","activeRoute","find","route","fallback","Outlet"],"sourceRoot":""}