@strapi/admin 5.36.0 → 5.36.1

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.
Files changed (31) hide show
  1. package/dist/admin/admin/src/App.js +11 -0
  2. package/dist/admin/admin/src/App.js.map +1 -1
  3. package/dist/admin/admin/src/App.mjs +11 -0
  4. package/dist/admin/admin/src/App.mjs.map +1 -1
  5. package/dist/admin/admin/src/components/GuidedTour/Steps/Step.js +4 -0
  6. package/dist/admin/admin/src/components/GuidedTour/Steps/Step.js.map +1 -1
  7. package/dist/admin/admin/src/components/GuidedTour/Steps/Step.mjs +4 -0
  8. package/dist/admin/admin/src/components/GuidedTour/Steps/Step.mjs.map +1 -1
  9. package/dist/admin/admin/src/components/GuidedTour/Tours.js +9 -2
  10. package/dist/admin/admin/src/components/GuidedTour/Tours.js.map +1 -1
  11. package/dist/admin/admin/src/components/GuidedTour/Tours.mjs +10 -3
  12. package/dist/admin/admin/src/components/GuidedTour/Tours.mjs.map +1 -1
  13. package/dist/admin/admin/src/components/GuidedTour/utils/migrations.js +21 -1
  14. package/dist/admin/admin/src/components/GuidedTour/utils/migrations.js.map +1 -1
  15. package/dist/admin/admin/src/components/GuidedTour/utils/migrations.mjs +21 -1
  16. package/dist/admin/admin/src/components/GuidedTour/utils/migrations.mjs.map +1 -1
  17. package/dist/admin/admin/src/core/apis/router.js.map +1 -1
  18. package/dist/admin/admin/src/core/apis/router.mjs.map +1 -1
  19. package/dist/admin/admin/tests/utils.js +32 -7
  20. package/dist/admin/admin/tests/utils.js.map +1 -1
  21. package/dist/admin/admin/tests/utils.mjs +32 -7
  22. package/dist/admin/admin/tests/utils.mjs.map +1 -1
  23. package/dist/admin/src/components/GuidedTour/Steps/Step.d.ts +1 -1
  24. package/dist/admin/src/components/GuidedTour/utils/migrations.d.ts +2 -1
  25. package/dist/admin/src/core/apis/router.d.ts +1 -1
  26. package/dist/admin/src/index.d.ts +1 -1
  27. package/dist/server/ee/server/src/audit-logs/services/lifecycles.js +1 -1
  28. package/dist/server/ee/server/src/audit-logs/services/lifecycles.js.map +1 -1
  29. package/dist/server/ee/server/src/audit-logs/services/lifecycles.mjs +1 -1
  30. package/dist/server/ee/server/src/audit-logs/services/lifecycles.mjs.map +1 -1
  31. package/package.json +12 -12
@@ -15,6 +15,16 @@ const App = ({ strapi, store })=>{
15
15
  document.documentElement.lang = language;
16
16
  }
17
17
  }, []);
18
+ /**
19
+ * @internal
20
+ * @experimental
21
+ *
22
+ * The `future-global::` namespace is intended for internal use.
23
+ * It is experimental and could change or be removed in the future.
24
+ */ const globalComponents = Object.entries(strapi.library.components).filter(([name])=>name.startsWith('future-global::')).map(([name, Component])=>({
25
+ name,
26
+ Component
27
+ }));
18
28
  return /*#__PURE__*/ jsxRuntime.jsx(Providers.Providers, {
19
29
  strapi: strapi,
20
30
  store: store,
@@ -22,6 +32,7 @@ const App = ({ strapi, store })=>{
22
32
  fallback: /*#__PURE__*/ jsxRuntime.jsx(PageHelpers.Page.Loading, {}),
23
33
  children: [
24
34
  /*#__PURE__*/ jsxRuntime.jsx(GlobalNotifications.GlobalNotifications, {}),
35
+ window.strapi.future.isEnabled('unstableMediaLibrary') && globalComponents.map(({ name, Component })=>/*#__PURE__*/ jsxRuntime.jsx(Component, {}, name)),
25
36
  /*#__PURE__*/ jsxRuntime.jsx(reactRouterDom.Outlet, {})
26
37
  ]
27
38
  })
@@ -1 +1 @@
1
- {"version":3,"file":"App.js","sources":["../../../../admin/src/App.tsx"],"sourcesContent":["/**\n *\n * App.js\n *\n */\nimport { Suspense, useEffect } from 'react';\n\nimport { Outlet } from 'react-router-dom';\n\nimport { GlobalNotifications } from '../../ee/admin/src/components/GlobalNotifications';\n\nimport { Page } from './components/PageHelpers';\nimport { Providers } from './components/Providers';\nimport { LANGUAGE_LOCAL_STORAGE_KEY } from './reducer';\n\nimport type { Store } from './core/store/configure';\nimport type { StrapiApp } from './StrapiApp';\n\ninterface AppProps {\n strapi: StrapiApp;\n store: Store;\n}\n\nconst App = ({ strapi, store }: AppProps) => {\n useEffect(() => {\n const language = localStorage.getItem(LANGUAGE_LOCAL_STORAGE_KEY) || 'en';\n\n if (language) {\n document.documentElement.lang = language;\n }\n }, []);\n\n return (\n <Providers strapi={strapi} store={store}>\n <Suspense fallback={<Page.Loading />}>\n <GlobalNotifications />\n <Outlet />\n </Suspense>\n </Providers>\n );\n};\n\nexport { App };\nexport type { AppProps };\n"],"names":["App","strapi","store","useEffect","language","localStorage","getItem","LANGUAGE_LOCAL_STORAGE_KEY","document","documentElement","lang","_jsx","Providers","_jsxs","Suspense","fallback","Page","Loading","GlobalNotifications","Outlet"],"mappings":";;;;;;;;;;AAuBA,MAAMA,MAAM,CAAC,EAAEC,MAAM,EAAEC,KAAK,EAAY,GAAA;IACtCC,eAAU,CAAA,IAAA;AACR,QAAA,MAAMC,QAAWC,GAAAA,YAAAA,CAAaC,OAAO,CAACC,kCAA+B,CAAA,IAAA,IAAA;AAErE,QAAA,IAAIH,QAAU,EAAA;YACZI,QAASC,CAAAA,eAAe,CAACC,IAAI,GAAGN,QAAAA;AAClC;AACF,KAAA,EAAG,EAAE,CAAA;AAEL,IAAA,qBACEO,cAACC,CAAAA,mBAAAA,EAAAA;QAAUX,MAAQA,EAAAA,MAAAA;QAAQC,KAAOA,EAAAA,KAAAA;AAChC,QAAA,QAAA,gBAAAW,eAACC,CAAAA,cAAAA,EAAAA;YAASC,QAAU,gBAAAJ,cAAA,CAACK,iBAAKC,OAAO,EAAA,EAAA,CAAA;;8BAC/BN,cAACO,CAAAA,uCAAAA,EAAAA,EAAAA,CAAAA;8BACDP,cAACQ,CAAAA,qBAAAA,EAAAA,EAAAA;;;;AAIT;;;;"}
1
+ {"version":3,"file":"App.js","sources":["../../../../admin/src/App.tsx"],"sourcesContent":["/**\n *\n * App.js\n *\n */\nimport { Suspense, useEffect } from 'react';\n\nimport { Outlet } from 'react-router-dom';\n\nimport { GlobalNotifications } from '../../ee/admin/src/components/GlobalNotifications';\n\nimport { Page } from './components/PageHelpers';\nimport { Providers } from './components/Providers';\nimport { LANGUAGE_LOCAL_STORAGE_KEY } from './reducer';\n\nimport type { Store } from './core/store/configure';\nimport type { StrapiApp } from './StrapiApp';\n\ninterface AppProps {\n strapi: StrapiApp;\n store: Store;\n}\n\nconst App = ({ strapi, store }: AppProps) => {\n useEffect(() => {\n const language = localStorage.getItem(LANGUAGE_LOCAL_STORAGE_KEY) || 'en';\n\n if (language) {\n document.documentElement.lang = language;\n }\n }, []);\n\n /**\n * @internal\n * @experimental\n *\n * The `future-global::` namespace is intended for internal use.\n * It is experimental and could change or be removed in the future.\n */\n const globalComponents = Object.entries(strapi.library.components)\n .filter(([name]) => name.startsWith('future-global::'))\n .map(([name, Component]) => ({ name, Component }));\n\n return (\n <Providers strapi={strapi} store={store}>\n <Suspense fallback={<Page.Loading />}>\n <GlobalNotifications />\n {window.strapi.future.isEnabled('unstableMediaLibrary') &&\n globalComponents.map(({ name, Component }) => <Component key={name} />)}\n <Outlet />\n </Suspense>\n </Providers>\n );\n};\n\nexport { App };\nexport type { AppProps };\n"],"names":["App","strapi","store","useEffect","language","localStorage","getItem","LANGUAGE_LOCAL_STORAGE_KEY","document","documentElement","lang","globalComponents","Object","entries","library","components","filter","name","startsWith","map","Component","_jsx","Providers","_jsxs","Suspense","fallback","Page","Loading","GlobalNotifications","window","future","isEnabled","Outlet"],"mappings":";;;;;;;;;;AAuBA,MAAMA,MAAM,CAAC,EAAEC,MAAM,EAAEC,KAAK,EAAY,GAAA;IACtCC,eAAU,CAAA,IAAA;AACR,QAAA,MAAMC,QAAWC,GAAAA,YAAAA,CAAaC,OAAO,CAACC,kCAA+B,CAAA,IAAA,IAAA;AAErE,QAAA,IAAIH,QAAU,EAAA;YACZI,QAASC,CAAAA,eAAe,CAACC,IAAI,GAAGN,QAAAA;AAClC;AACF,KAAA,EAAG,EAAE,CAAA;AAEL;;;;;;MAOA,MAAMO,gBAAmBC,GAAAA,MAAAA,CAAOC,OAAO,CAACZ,MAAOa,CAAAA,OAAO,CAACC,UAAU,CAC9DC,CAAAA,MAAM,CAAC,CAAC,CAACC,IAAAA,CAAK,GAAKA,IAAAA,CAAKC,UAAU,CAAC,iBACnCC,CAAAA,CAAAA,CAAAA,GAAG,CAAC,CAAC,CAACF,IAAAA,EAAMG,SAAU,CAAA,IAAM;AAAEH,YAAAA,IAAAA;AAAMG,YAAAA;SAAU,CAAA,CAAA;AAEjD,IAAA,qBACEC,cAACC,CAAAA,mBAAAA,EAAAA;QAAUrB,MAAQA,EAAAA,MAAAA;QAAQC,KAAOA,EAAAA,KAAAA;AAChC,QAAA,QAAA,gBAAAqB,eAACC,CAAAA,cAAAA,EAAAA;YAASC,QAAU,gBAAAJ,cAAA,CAACK,iBAAKC,OAAO,EAAA,EAAA,CAAA;;8BAC/BN,cAACO,CAAAA,uCAAAA,EAAAA,EAAAA,CAAAA;AACAC,gBAAAA,MAAAA,CAAO5B,MAAM,CAAC6B,MAAM,CAACC,SAAS,CAAC,2BAC9BpB,gBAAiBQ,CAAAA,GAAG,CAAC,CAAC,EAAEF,IAAI,EAAEG,SAAS,EAAE,iBAAKC,eAACD,SAAeH,EAAAA,EAAAA,EAAAA,IAAAA,CAAAA,CAAAA;8BAChEI,cAACW,CAAAA,qBAAAA,EAAAA,EAAAA;;;;AAIT;;;;"}
@@ -13,6 +13,16 @@ const App = ({ strapi, store })=>{
13
13
  document.documentElement.lang = language;
14
14
  }
15
15
  }, []);
16
+ /**
17
+ * @internal
18
+ * @experimental
19
+ *
20
+ * The `future-global::` namespace is intended for internal use.
21
+ * It is experimental and could change or be removed in the future.
22
+ */ const globalComponents = Object.entries(strapi.library.components).filter(([name])=>name.startsWith('future-global::')).map(([name, Component])=>({
23
+ name,
24
+ Component
25
+ }));
16
26
  return /*#__PURE__*/ jsx(Providers, {
17
27
  strapi: strapi,
18
28
  store: store,
@@ -20,6 +30,7 @@ const App = ({ strapi, store })=>{
20
30
  fallback: /*#__PURE__*/ jsx(Page.Loading, {}),
21
31
  children: [
22
32
  /*#__PURE__*/ jsx(GlobalNotifications, {}),
33
+ window.strapi.future.isEnabled('unstableMediaLibrary') && globalComponents.map(({ name, Component })=>/*#__PURE__*/ jsx(Component, {}, name)),
23
34
  /*#__PURE__*/ jsx(Outlet, {})
24
35
  ]
25
36
  })
@@ -1 +1 @@
1
- {"version":3,"file":"App.mjs","sources":["../../../../admin/src/App.tsx"],"sourcesContent":["/**\n *\n * App.js\n *\n */\nimport { Suspense, useEffect } from 'react';\n\nimport { Outlet } from 'react-router-dom';\n\nimport { GlobalNotifications } from '../../ee/admin/src/components/GlobalNotifications';\n\nimport { Page } from './components/PageHelpers';\nimport { Providers } from './components/Providers';\nimport { LANGUAGE_LOCAL_STORAGE_KEY } from './reducer';\n\nimport type { Store } from './core/store/configure';\nimport type { StrapiApp } from './StrapiApp';\n\ninterface AppProps {\n strapi: StrapiApp;\n store: Store;\n}\n\nconst App = ({ strapi, store }: AppProps) => {\n useEffect(() => {\n const language = localStorage.getItem(LANGUAGE_LOCAL_STORAGE_KEY) || 'en';\n\n if (language) {\n document.documentElement.lang = language;\n }\n }, []);\n\n return (\n <Providers strapi={strapi} store={store}>\n <Suspense fallback={<Page.Loading />}>\n <GlobalNotifications />\n <Outlet />\n </Suspense>\n </Providers>\n );\n};\n\nexport { App };\nexport type { AppProps };\n"],"names":["App","strapi","store","useEffect","language","localStorage","getItem","LANGUAGE_LOCAL_STORAGE_KEY","document","documentElement","lang","_jsx","Providers","_jsxs","Suspense","fallback","Page","Loading","GlobalNotifications","Outlet"],"mappings":";;;;;;;;AAuBA,MAAMA,MAAM,CAAC,EAAEC,MAAM,EAAEC,KAAK,EAAY,GAAA;IACtCC,SAAU,CAAA,IAAA;AACR,QAAA,MAAMC,QAAWC,GAAAA,YAAAA,CAAaC,OAAO,CAACC,0BAA+B,CAAA,IAAA,IAAA;AAErE,QAAA,IAAIH,QAAU,EAAA;YACZI,QAASC,CAAAA,eAAe,CAACC,IAAI,GAAGN,QAAAA;AAClC;AACF,KAAA,EAAG,EAAE,CAAA;AAEL,IAAA,qBACEO,GAACC,CAAAA,SAAAA,EAAAA;QAAUX,MAAQA,EAAAA,MAAAA;QAAQC,KAAOA,EAAAA,KAAAA;AAChC,QAAA,QAAA,gBAAAW,IAACC,CAAAA,QAAAA,EAAAA;YAASC,QAAU,gBAAAJ,GAAA,CAACK,KAAKC,OAAO,EAAA,EAAA,CAAA;;8BAC/BN,GAACO,CAAAA,mBAAAA,EAAAA,EAAAA,CAAAA;8BACDP,GAACQ,CAAAA,MAAAA,EAAAA,EAAAA;;;;AAIT;;;;"}
1
+ {"version":3,"file":"App.mjs","sources":["../../../../admin/src/App.tsx"],"sourcesContent":["/**\n *\n * App.js\n *\n */\nimport { Suspense, useEffect } from 'react';\n\nimport { Outlet } from 'react-router-dom';\n\nimport { GlobalNotifications } from '../../ee/admin/src/components/GlobalNotifications';\n\nimport { Page } from './components/PageHelpers';\nimport { Providers } from './components/Providers';\nimport { LANGUAGE_LOCAL_STORAGE_KEY } from './reducer';\n\nimport type { Store } from './core/store/configure';\nimport type { StrapiApp } from './StrapiApp';\n\ninterface AppProps {\n strapi: StrapiApp;\n store: Store;\n}\n\nconst App = ({ strapi, store }: AppProps) => {\n useEffect(() => {\n const language = localStorage.getItem(LANGUAGE_LOCAL_STORAGE_KEY) || 'en';\n\n if (language) {\n document.documentElement.lang = language;\n }\n }, []);\n\n /**\n * @internal\n * @experimental\n *\n * The `future-global::` namespace is intended for internal use.\n * It is experimental and could change or be removed in the future.\n */\n const globalComponents = Object.entries(strapi.library.components)\n .filter(([name]) => name.startsWith('future-global::'))\n .map(([name, Component]) => ({ name, Component }));\n\n return (\n <Providers strapi={strapi} store={store}>\n <Suspense fallback={<Page.Loading />}>\n <GlobalNotifications />\n {window.strapi.future.isEnabled('unstableMediaLibrary') &&\n globalComponents.map(({ name, Component }) => <Component key={name} />)}\n <Outlet />\n </Suspense>\n </Providers>\n );\n};\n\nexport { App };\nexport type { AppProps };\n"],"names":["App","strapi","store","useEffect","language","localStorage","getItem","LANGUAGE_LOCAL_STORAGE_KEY","document","documentElement","lang","globalComponents","Object","entries","library","components","filter","name","startsWith","map","Component","_jsx","Providers","_jsxs","Suspense","fallback","Page","Loading","GlobalNotifications","window","future","isEnabled","Outlet"],"mappings":";;;;;;;;AAuBA,MAAMA,MAAM,CAAC,EAAEC,MAAM,EAAEC,KAAK,EAAY,GAAA;IACtCC,SAAU,CAAA,IAAA;AACR,QAAA,MAAMC,QAAWC,GAAAA,YAAAA,CAAaC,OAAO,CAACC,0BAA+B,CAAA,IAAA,IAAA;AAErE,QAAA,IAAIH,QAAU,EAAA;YACZI,QAASC,CAAAA,eAAe,CAACC,IAAI,GAAGN,QAAAA;AAClC;AACF,KAAA,EAAG,EAAE,CAAA;AAEL;;;;;;MAOA,MAAMO,gBAAmBC,GAAAA,MAAAA,CAAOC,OAAO,CAACZ,MAAOa,CAAAA,OAAO,CAACC,UAAU,CAC9DC,CAAAA,MAAM,CAAC,CAAC,CAACC,IAAAA,CAAK,GAAKA,IAAAA,CAAKC,UAAU,CAAC,iBACnCC,CAAAA,CAAAA,CAAAA,GAAG,CAAC,CAAC,CAACF,IAAAA,EAAMG,SAAU,CAAA,IAAM;AAAEH,YAAAA,IAAAA;AAAMG,YAAAA;SAAU,CAAA,CAAA;AAEjD,IAAA,qBACEC,GAACC,CAAAA,SAAAA,EAAAA;QAAUrB,MAAQA,EAAAA,MAAAA;QAAQC,KAAOA,EAAAA,KAAAA;AAChC,QAAA,QAAA,gBAAAqB,IAACC,CAAAA,QAAAA,EAAAA;YAASC,QAAU,gBAAAJ,GAAA,CAACK,KAAKC,OAAO,EAAA,EAAA,CAAA;;8BAC/BN,GAACO,CAAAA,mBAAAA,EAAAA,EAAAA,CAAAA;AACAC,gBAAAA,MAAAA,CAAO5B,MAAM,CAAC6B,MAAM,CAACC,SAAS,CAAC,2BAC9BpB,gBAAiBQ,CAAAA,GAAG,CAAC,CAAC,EAAEF,IAAI,EAAEG,SAAS,EAAE,iBAAKC,IAACD,SAAeH,EAAAA,EAAAA,EAAAA,IAAAA,CAAAA,CAAAA;8BAChEI,GAACW,CAAAA,MAAAA,EAAAA,EAAAA;;;;AAIT;;;;"}
@@ -61,6 +61,10 @@ const DefaultActions = ({ showSkip, showPrevious, to, tourName, onNextStep, onPr
61
61
  const { trackUsage } = Tracking.useTracking();
62
62
  const dispatch = Context.useGuidedTour('GuidedTourPopover', (s)=>s.dispatch);
63
63
  const state = Context.useGuidedTour('GuidedTourPopover', (s)=>s.state);
64
+ // Safety check: if tours state is missing, return null
65
+ if (!state.tours || !state.tours[tourName]) {
66
+ return null;
67
+ }
64
68
  const currentStep = state.tours[tourName].currentStep + 1;
65
69
  const actualTourLength = Tours.tours[tourName]._meta.totalStepCount;
66
70
  const handleSkip = ()=>{
@@ -1 +1 @@
1
- {"version":3,"file":"Step.js","sources":["../../../../../../../admin/src/components/GuidedTour/Steps/Step.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Popover,\n Box,\n Flex,\n Button,\n Typography,\n LinkButton,\n FlexProps,\n} from '@strapi/design-system';\nimport { FormattedMessage, useIntl, type MessageDescriptor } from 'react-intl';\nimport { To, NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { useTracking } from '../../../features/Tracking';\nimport { useGuidedTour, type ValidTourName } from '../Context';\nimport { tours } from '../Tours';\n\n/* -------------------------------------------------------------------------------------------------\n * Common Step Components\n * -----------------------------------------------------------------------------------------------*/\n\nconst StepCount = ({\n tourName,\n displayedCurrentStep,\n displayedTourLength,\n}: {\n tourName: ValidTourName;\n displayedCurrentStep?: number;\n displayedTourLength?: number;\n}) => {\n const state = useGuidedTour('GuidedTourPopover', (s) => s.state);\n const currentStep = displayedCurrentStep ?? state.tours[tourName].currentStep + 1;\n const displayedStepCount = displayedTourLength ?? tours[tourName]._meta.displayedStepCount;\n\n return (\n <Typography variant=\"omega\" fontSize=\"12px\">\n <FormattedMessage\n id=\"tours.stepCount\"\n defaultMessage=\"Step {currentStep} of {tourLength}\"\n values={{ currentStep, tourLength: displayedStepCount }}\n />\n </Typography>\n );\n};\n\nconst GotItAction = ({ onClick }: { onClick: () => void }) => {\n return (\n <Button onClick={onClick}>\n <FormattedMessage id=\"tours.gotIt\" defaultMessage=\"Got it\" />\n </Button>\n );\n};\n\nexport type DefaultActionsProps = {\n showSkip?: boolean;\n showPrevious?: boolean;\n to?: To;\n onNextStep?: () => void;\n onPreviousStep?: () => void;\n tourName: ValidTourName;\n};\nconst DefaultActions = ({\n showSkip,\n showPrevious,\n to,\n tourName,\n onNextStep,\n onPreviousStep,\n}: DefaultActionsProps) => {\n const { trackUsage } = useTracking();\n const dispatch = useGuidedTour('GuidedTourPopover', (s) => s.dispatch);\n const state = useGuidedTour('GuidedTourPopover', (s) => s.state);\n const currentStep = state.tours[tourName].currentStep + 1;\n const actualTourLength = tours[tourName]._meta.totalStepCount;\n\n const handleSkip = () => {\n trackUsage('didSkipGuidedTour', { name: tourName });\n dispatch({ type: 'skip_tour', payload: tourName });\n };\n\n const handleNextStep = () => {\n if (currentStep === actualTourLength) {\n trackUsage('didCompleteGuidedTour', { name: tourName });\n }\n\n if (onNextStep) {\n onNextStep();\n } else {\n dispatch({ type: 'next_step', payload: tourName });\n }\n };\n\n const handlePreviousStep = () => {\n if (onPreviousStep) {\n onPreviousStep();\n } else {\n dispatch({ type: 'previous_step', payload: tourName });\n }\n };\n\n return (\n <Flex gap={2}>\n {showSkip && (\n <Button variant=\"tertiary\" onClick={handleSkip}>\n <FormattedMessage id=\"tours.skip\" defaultMessage=\"Skip\" />\n </Button>\n )}\n {!showSkip && showPrevious && (\n <Button variant=\"tertiary\" onClick={handlePreviousStep}>\n <FormattedMessage id=\"tours.previous\" defaultMessage=\"Previous\" />\n </Button>\n )}\n {to ? (\n <LinkButton tag={NavLink} to={to} onClick={handleNextStep}>\n <FormattedMessage id=\"tours.next\" defaultMessage=\"Next\" />\n </LinkButton>\n ) : (\n <Button onClick={handleNextStep}>\n <FormattedMessage id=\"tours.next\" defaultMessage=\"Next\" />\n </Button>\n )}\n </Flex>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Step factory\n * -----------------------------------------------------------------------------------------------*/\n\ntype WithChildren = {\n children: React.ReactNode;\n id?: never;\n defaultMessage?: never;\n};\n\ntype WithIntl = {\n children?: undefined;\n id: MessageDescriptor['id'];\n defaultMessage: MessageDescriptor['defaultMessage'];\n withArrow?: boolean;\n};\n\ntype WithActionsChildren = {\n children: React.ReactNode;\n showStepCount?: boolean;\n showSkip?: boolean;\n showPrevious?: boolean;\n};\n\ntype WithActionsProps = {\n children?: undefined;\n showStepCount?: boolean;\n showSkip?: boolean;\n showPrevious?: boolean;\n};\n\ntype StepProps = WithChildren | WithIntl;\ntype ActionsProps = WithActionsChildren | WithActionsProps;\n\ntype Step = {\n Root: React.ForwardRefExoticComponent<\n React.ComponentProps<typeof Popover.Content> & { withArrow?: boolean }\n >;\n Title: (props: StepProps) => React.ReactNode;\n Content: (\n props: StepProps & {\n values?: Record<string, React.ReactNode | ((chunks: React.ReactNode) => React.ReactNode)>;\n }\n ) => React.ReactNode;\n Actions: (props: ActionsProps & { to?: string } & FlexProps) => React.ReactNode;\n};\n\nconst ActionsContainer = styled(Flex)`\n border-top: ${({ theme }) => `1px solid ${theme.colors.neutral150}`};\n`;\n\nconst ContentContainer = styled(Box)`\n p {\n margin-top: ${({ theme }) => theme.spaces[5]};\n }\n ul {\n list-style-type: disc;\n padding-left: ${({ theme }) => theme.spaces[4]};\n }\n`;\n\n/**\n * TODO:\n * We should probably move all arrow styles + svg to the DS\n */\nconst PopoverArrow = styled(Popover.Arrow)`\n fill: ${({ theme }) => theme.colors.neutral0};\n transform: translateY(-16px) rotate(-90deg);\n`;\n\nconst createStepComponents = (tourName: ValidTourName): Step => ({\n Root: React.forwardRef(({ withArrow = true, ...props }, ref) => {\n return (\n <Popover.Content\n ref={ref}\n aria-labelledby=\"guided-tour-title\"\n side=\"top\"\n align=\"center\"\n style={{ border: 'none' }}\n onClick={(e) => e.stopPropagation()}\n {...props}\n >\n {withArrow && (\n <PopoverArrow asChild>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"23\"\n height=\"25\"\n viewBox=\"0 0 23 25\"\n fill=\"none\"\n >\n <path d=\"M11 24.5L1.82843 15.3284C0.266332 13.7663 0.26633 11.2337 1.82843 9.67157L11 0.5L23 12.5L11 24.5Z\" />\n </svg>\n </PopoverArrow>\n )}\n <Flex width=\"360px\" direction=\"column\" alignItems=\"start\">\n {props.children}\n </Flex>\n </Popover.Content>\n );\n }),\n\n Title: (props) => {\n return (\n <Box paddingTop={5} paddingLeft={5} paddingRight={5} paddingBottom={1} width=\"100%\">\n {'children' in props ? (\n props.children\n ) : (\n <Typography tag=\"h1\" id=\"guided-tour-title\" variant=\"omega\" fontWeight=\"bold\">\n <FormattedMessage id={props.id} defaultMessage={props.defaultMessage} />\n </Typography>\n )}\n </Box>\n );\n },\n\n Content: (props) => {\n const { formatMessage } = useIntl();\n let content = '';\n if (!('children' in props)) {\n content = formatMessage({\n id: props.id,\n defaultMessage: props.defaultMessage,\n });\n }\n return (\n <Box paddingBottom={5} paddingLeft={5} paddingRight={5} width=\"100%\">\n {'children' in props ? (\n props.children\n ) : (\n <ContentContainer>\n <Typography tag=\"div\" variant=\"omega\" dangerouslySetInnerHTML={{ __html: content }} />\n </ContentContainer>\n )}\n </Box>\n );\n },\n\n Actions: ({\n showStepCount = true,\n showPrevious = true,\n showSkip = false,\n to,\n children,\n ...flexProps\n }) => {\n return (\n <ActionsContainer\n width=\"100%\"\n padding={3}\n paddingLeft={5}\n justifyContent={showStepCount ? 'space-between' : 'flex-end'}\n {...flexProps}\n >\n {children ? (\n children\n ) : (\n <>\n {showStepCount && <StepCount tourName={tourName} />}\n <DefaultActions\n tourName={tourName}\n showSkip={showSkip}\n showPrevious={!showSkip && showPrevious}\n to={to}\n />\n </>\n )}\n </ActionsContainer>\n );\n },\n});\n\nexport type { Step };\nexport { createStepComponents, GotItAction, StepCount, DefaultActions };\n"],"names":["StepCount","tourName","displayedCurrentStep","displayedTourLength","state","useGuidedTour","s","currentStep","tours","displayedStepCount","_meta","_jsx","Typography","variant","fontSize","FormattedMessage","id","defaultMessage","values","tourLength","GotItAction","onClick","Button","DefaultActions","showSkip","showPrevious","to","onNextStep","onPreviousStep","trackUsage","useTracking","dispatch","actualTourLength","totalStepCount","handleSkip","name","type","payload","handleNextStep","handlePreviousStep","_jsxs","Flex","gap","LinkButton","tag","NavLink","ActionsContainer","styled","theme","colors","neutral150","ContentContainer","Box","spaces","PopoverArrow","Popover","Arrow","neutral0","createStepComponents","Root","React","forwardRef","withArrow","props","ref","Content","aria-labelledby","side","align","style","border","e","stopPropagation","asChild","svg","xmlns","width","height","viewBox","fill","path","d","direction","alignItems","children","Title","paddingTop","paddingLeft","paddingRight","paddingBottom","fontWeight","formatMessage","useIntl","content","dangerouslySetInnerHTML","__html","Actions","showStepCount","flexProps","padding","justifyContent","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA;;qGAIA,MAAMA,YAAY,CAAC,EACjBC,QAAQ,EACRC,oBAAoB,EACpBC,mBAAmB,EAKpB,GAAA;AACC,IAAA,MAAMC,QAAQC,qBAAc,CAAA,mBAAA,EAAqB,CAACC,CAAAA,GAAMA,EAAEF,KAAK,CAAA;IAC/D,MAAMG,WAAAA,GAAcL,wBAAwBE,KAAMI,CAAAA,KAAK,CAACP,QAAS,CAAA,CAACM,WAAW,GAAG,CAAA;IAChF,MAAME,kBAAAA,GAAqBN,uBAAuBK,WAAK,CAACP,SAAS,CAACS,KAAK,CAACD,kBAAkB;AAE1F,IAAA,qBACEE,cAACC,CAAAA,uBAAAA,EAAAA;QAAWC,OAAQ,EAAA,OAAA;QAAQC,QAAS,EAAA,MAAA;AACnC,QAAA,QAAA,gBAAAH,cAACI,CAAAA,0BAAAA,EAAAA;YACCC,EAAG,EAAA,iBAAA;YACHC,cAAe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eAAA,CAAA6D,mBAAA,EAAA;;AACGJ,wBAAAA,aAAAA,kBAAiBtF,cAACX,CAAAA,SAAAA,EAAAA;4BAAUC,QAAUA,EAAAA;;sCACvCU,cAACY,CAAAA,cAAAA,EAAAA;4BACCtB,QAAUA,EAAAA,QAAAA;4BACVuB,QAAUA,EAAAA,QAAAA;AACVC,4BAAAA,YAAAA,EAAc,CAACD,QAAYC,IAAAA,YAAAA;4BAC3BC,EAAIA,EAAAA;;;;;AAMhB;KACF;;;;;;;"}
1
+ {"version":3,"file":"Step.js","sources":["../../../../../../../admin/src/components/GuidedTour/Steps/Step.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Popover,\n Box,\n Flex,\n Button,\n Typography,\n LinkButton,\n FlexProps,\n} from '@strapi/design-system';\nimport { FormattedMessage, useIntl, type MessageDescriptor } from 'react-intl';\nimport { To, NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { useTracking } from '../../../features/Tracking';\nimport { useGuidedTour, type ValidTourName } from '../Context';\nimport { tours } from '../Tours';\n\n/* -------------------------------------------------------------------------------------------------\n * Common Step Components\n * -----------------------------------------------------------------------------------------------*/\n\nconst StepCount = ({\n tourName,\n displayedCurrentStep,\n displayedTourLength,\n}: {\n tourName: ValidTourName;\n displayedCurrentStep?: number;\n displayedTourLength?: number;\n}) => {\n const state = useGuidedTour('GuidedTourPopover', (s) => s.state);\n const currentStep = displayedCurrentStep ?? state.tours[tourName].currentStep + 1;\n const displayedStepCount = displayedTourLength ?? tours[tourName]._meta.displayedStepCount;\n\n return (\n <Typography variant=\"omega\" fontSize=\"12px\">\n <FormattedMessage\n id=\"tours.stepCount\"\n defaultMessage=\"Step {currentStep} of {tourLength}\"\n values={{ currentStep, tourLength: displayedStepCount }}\n />\n </Typography>\n );\n};\n\nconst GotItAction = ({ onClick }: { onClick: () => void }) => {\n return (\n <Button onClick={onClick}>\n <FormattedMessage id=\"tours.gotIt\" defaultMessage=\"Got it\" />\n </Button>\n );\n};\n\nexport type DefaultActionsProps = {\n showSkip?: boolean;\n showPrevious?: boolean;\n to?: To;\n onNextStep?: () => void;\n onPreviousStep?: () => void;\n tourName: ValidTourName;\n};\nconst DefaultActions = ({\n showSkip,\n showPrevious,\n to,\n tourName,\n onNextStep,\n onPreviousStep,\n}: DefaultActionsProps) => {\n const { trackUsage } = useTracking();\n const dispatch = useGuidedTour('GuidedTourPopover', (s) => s.dispatch);\n const state = useGuidedTour('GuidedTourPopover', (s) => s.state);\n\n // Safety check: if tours state is missing, return null\n if (!state.tours || !state.tours[tourName]) {\n return null;\n }\n\n const currentStep = state.tours[tourName].currentStep + 1;\n const actualTourLength = tours[tourName]._meta.totalStepCount;\n\n const handleSkip = () => {\n trackUsage('didSkipGuidedTour', { name: tourName });\n dispatch({ type: 'skip_tour', payload: tourName });\n };\n\n const handleNextStep = () => {\n if (currentStep === actualTourLength) {\n trackUsage('didCompleteGuidedTour', { name: tourName });\n }\n\n if (onNextStep) {\n onNextStep();\n } else {\n dispatch({ type: 'next_step', payload: tourName });\n }\n };\n\n const handlePreviousStep = () => {\n if (onPreviousStep) {\n onPreviousStep();\n } else {\n dispatch({ type: 'previous_step', payload: tourName });\n }\n };\n\n return (\n <Flex gap={2}>\n {showSkip && (\n <Button variant=\"tertiary\" onClick={handleSkip}>\n <FormattedMessage id=\"tours.skip\" defaultMessage=\"Skip\" />\n </Button>\n )}\n {!showSkip && showPrevious && (\n <Button variant=\"tertiary\" onClick={handlePreviousStep}>\n <FormattedMessage id=\"tours.previous\" defaultMessage=\"Previous\" />\n </Button>\n )}\n {to ? (\n <LinkButton tag={NavLink} to={to} onClick={handleNextStep}>\n <FormattedMessage id=\"tours.next\" defaultMessage=\"Next\" />\n </LinkButton>\n ) : (\n <Button onClick={handleNextStep}>\n <FormattedMessage id=\"tours.next\" defaultMessage=\"Next\" />\n </Button>\n )}\n </Flex>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Step factory\n * -----------------------------------------------------------------------------------------------*/\n\ntype WithChildren = {\n children: React.ReactNode;\n id?: never;\n defaultMessage?: never;\n};\n\ntype WithIntl = {\n children?: undefined;\n id: MessageDescriptor['id'];\n defaultMessage: MessageDescriptor['defaultMessage'];\n withArrow?: boolean;\n};\n\ntype WithActionsChildren = {\n children: React.ReactNode;\n showStepCount?: boolean;\n showSkip?: boolean;\n showPrevious?: boolean;\n};\n\ntype WithActionsProps = {\n children?: undefined;\n showStepCount?: boolean;\n showSkip?: boolean;\n showPrevious?: boolean;\n};\n\ntype StepProps = WithChildren | WithIntl;\ntype ActionsProps = WithActionsChildren | WithActionsProps;\n\ntype Step = {\n Root: React.ForwardRefExoticComponent<\n React.ComponentProps<typeof Popover.Content> & { withArrow?: boolean }\n >;\n Title: (props: StepProps) => React.ReactNode;\n Content: (\n props: StepProps & {\n values?: Record<string, React.ReactNode | ((chunks: React.ReactNode) => React.ReactNode)>;\n }\n ) => React.ReactNode;\n Actions: (props: ActionsProps & { to?: string } & FlexProps) => React.ReactNode;\n};\n\nconst ActionsContainer = styled(Flex)`\n border-top: ${({ theme }) => `1px solid ${theme.colors.neutral150}`};\n`;\n\nconst ContentContainer = styled(Box)`\n p {\n margin-top: ${({ theme }) => theme.spaces[5]};\n }\n ul {\n list-style-type: disc;\n padding-left: ${({ theme }) => theme.spaces[4]};\n }\n`;\n\n/**\n * TODO:\n * We should probably move all arrow styles + svg to the DS\n */\nconst PopoverArrow = styled(Popover.Arrow)`\n fill: ${({ theme }) => theme.colors.neutral0};\n transform: translateY(-16px) rotate(-90deg);\n`;\n\nconst createStepComponents = (tourName: ValidTourName): Step => ({\n Root: React.forwardRef(({ withArrow = true, ...props }, ref) => {\n return (\n <Popover.Content\n ref={ref}\n aria-labelledby=\"guided-tour-title\"\n side=\"top\"\n align=\"center\"\n style={{ border: 'none' }}\n onClick={(e) => e.stopPropagation()}\n {...props}\n >\n {withArrow && (\n <PopoverArrow asChild>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"23\"\n height=\"25\"\n viewBox=\"0 0 23 25\"\n fill=\"none\"\n >\n <path d=\"M11 24.5L1.82843 15.3284C0.266332 13.7663 0.26633 11.2337 1.82843 9.67157L11 0.5L23 12.5L11 24.5Z\" />\n </svg>\n </PopoverArrow>\n )}\n <Flex width=\"360px\" direction=\"column\" alignItems=\"start\">\n {props.children}\n </Flex>\n </Popover.Content>\n );\n }),\n\n Title: (props) => {\n return (\n <Box paddingTop={5} paddingLeft={5} paddingRight={5} paddingBottom={1} width=\"100%\">\n {'children' in props ? (\n props.children\n ) : (\n <Typography tag=\"h1\" id=\"guided-tour-title\" variant=\"omega\" fontWeight=\"bold\">\n <FormattedMessage id={props.id} defaultMessage={props.defaultMessage} />\n </Typography>\n )}\n </Box>\n );\n },\n\n Content: (props) => {\n const { formatMessage } = useIntl();\n let content = '';\n if (!('children' in props)) {\n content = formatMessage({\n id: props.id,\n defaultMessage: props.defaultMessage,\n });\n }\n return (\n <Box paddingBottom={5} paddingLeft={5} paddingRight={5} width=\"100%\">\n {'children' in props ? (\n props.children\n ) : (\n <ContentContainer>\n <Typography tag=\"div\" variant=\"omega\" dangerouslySetInnerHTML={{ __html: content }} />\n </ContentContainer>\n )}\n </Box>\n );\n },\n\n Actions: ({\n showStepCount = true,\n showPrevious = true,\n showSkip = false,\n to,\n children,\n ...flexProps\n }) => {\n return (\n <ActionsContainer\n width=\"100%\"\n padding={3}\n paddingLeft={5}\n justifyContent={showStepCount ? 'space-between' : 'flex-end'}\n {...flexProps}\n >\n {children ? (\n children\n ) : (\n <>\n {showStepCount && <StepCount tourName={tourName} />}\n <DefaultActions\n tourName={tourName}\n showSkip={showSkip}\n showPrevious={!showSkip && showPrevious}\n to={to}\n />\n </>\n )}\n </ActionsContainer>\n );\n },\n});\n\nexport type { Step };\nexport { createStepComponents, GotItAction, StepCount, DefaultActions };\n"],"names":["StepCount","tourName","displayedCurrentStep","displayedTourLength","state","useGuidedTour","s","currentStep","tours","displayedStepCount","_meta","_jsx","Typography","variant","fontSize","FormattedMessage","id","defaultMessage","values","tourLength","GotItAction","onClick","Button","DefaultActions","showSkip","showPrevious","to","onNextStep","onPreviousStep","trackUsage","useTracking","dispatch","actualTourLength","totalStepCount","handleSkip","name","type","payload","handleNextStep","handlePreviousStep","_jsxs","Flex","gap","LinkButton","tag","NavLink","ActionsContainer","styled","theme","colors","neutral150","ContentContainer","Box","spaces","PopoverArrow","Popover","Arrow","neutral0","createStepComponents","Root","React","forwardRef","withArrow","props","ref","Content","aria-labelledby","side","align","style","border","e","stopPropagation","asChild","svg","xmlns","width","height","viewBox","fill","path","d","direction","alignItems","children","Title","paddingTop","paddingLeft","paddingRight","paddingBottom","fontWeight","formatMessage","useIntl","content","dangerouslySetInnerHTML","__html","Actions","showStepCount","flexProps","padding","justifyContent","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA;;qGAIA,MAAMA,YAAY,CAAC,EACjBC,QAAQ,EACRC,oBAAoB,EACpBC,mBAAmB,EAKpB,GAAA;AACC,IAAA,MAAMC,QAAQC,qBAAc,CAAA,mBAAA,EAAqB,CAACC,CAAAA,GAAMA,EAAEF,KAAK,CAAA;IAC/D,MAAMG,WAAAA,GAAcL,wBAAwBE,KAAMI,CAAAA,KAAK,CAACP,QAAS,CAAA,CAACM,WAAW,GAAG,CAAA;IAChF,MAAME,kBAAAA,GAAqBN,uBAAuBK,WAAK,CAACP,SAAS,CAACS,KAAK,CAACD,kBAAkB;AAE1F,IAAA,qBACEE,cAACC,CAAAA,uBAAAA,EAAAA;QAAWC,OAAQ,EAAA,OAAA;QAAQC,QAAS,EAAA,MAAA;AACnC,QAAA,QAAA,gBAAAH,cAACI,CAAAA,0BAAAA,EAAAA;YACCC,EAAG,EAAA,iBAAA;YACHC,cAAe,EAAA,oCAAA;YACfC,MAAQ,EAAA;AAAEX,gBAAAA,WAAAA;gBAAaY,UAAYV,EAAAA;AAAmB;;;AAI9D;AAEA,MAAMW,WAAc,GAAA,CAAC,EAAEC,OAAO,E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;;AACGJ,wBAAAA,aAAAA,kBAAiBtF,cAACX,CAAAA,SAAAA,EAAAA;4BAAUC,QAAUA,EAAAA;;sCACvCU,cAACY,CAAAA,cAAAA,EAAAA;4BACCtB,QAAUA,EAAAA,QAAAA;4BACVuB,QAAUA,EAAAA,QAAAA;AACVC,4BAAAA,YAAAA,EAAc,CAACD,QAAYC,IAAAA,YAAAA;4BAC3BC,EAAIA,EAAAA;;;;;AAMhB;KACF;;;;;;;"}
@@ -40,6 +40,10 @@ const DefaultActions = ({ showSkip, showPrevious, to, tourName, onNextStep, onPr
40
40
  const { trackUsage } = useTracking();
41
41
  const dispatch = useGuidedTour('GuidedTourPopover', (s)=>s.dispatch);
42
42
  const state = useGuidedTour('GuidedTourPopover', (s)=>s.state);
43
+ // Safety check: if tours state is missing, return null
44
+ if (!state.tours || !state.tours[tourName]) {
45
+ return null;
46
+ }
43
47
  const currentStep = state.tours[tourName].currentStep + 1;
44
48
  const actualTourLength = tours[tourName]._meta.totalStepCount;
45
49
  const handleSkip = ()=>{
@@ -1 +1 @@
1
- {"version":3,"file":"Step.mjs","sources":["../../../../../../../admin/src/components/GuidedTour/Steps/Step.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Popover,\n Box,\n Flex,\n Button,\n Typography,\n LinkButton,\n FlexProps,\n} from '@strapi/design-system';\nimport { FormattedMessage, useIntl, type MessageDescriptor } from 'react-intl';\nimport { To, NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { useTracking } from '../../../features/Tracking';\nimport { useGuidedTour, type ValidTourName } from '../Context';\nimport { tours } from '../Tours';\n\n/* -------------------------------------------------------------------------------------------------\n * Common Step Components\n * -----------------------------------------------------------------------------------------------*/\n\nconst StepCount = ({\n tourName,\n displayedCurrentStep,\n displayedTourLength,\n}: {\n tourName: ValidTourName;\n displayedCurrentStep?: number;\n displayedTourLength?: number;\n}) => {\n const state = useGuidedTour('GuidedTourPopover', (s) => s.state);\n const currentStep = displayedCurrentStep ?? state.tours[tourName].currentStep + 1;\n const displayedStepCount = displayedTourLength ?? tours[tourName]._meta.displayedStepCount;\n\n return (\n <Typography variant=\"omega\" fontSize=\"12px\">\n <FormattedMessage\n id=\"tours.stepCount\"\n defaultMessage=\"Step {currentStep} of {tourLength}\"\n values={{ currentStep, tourLength: displayedStepCount }}\n />\n </Typography>\n );\n};\n\nconst GotItAction = ({ onClick }: { onClick: () => void }) => {\n return (\n <Button onClick={onClick}>\n <FormattedMessage id=\"tours.gotIt\" defaultMessage=\"Got it\" />\n </Button>\n );\n};\n\nexport type DefaultActionsProps = {\n showSkip?: boolean;\n showPrevious?: boolean;\n to?: To;\n onNextStep?: () => void;\n onPreviousStep?: () => void;\n tourName: ValidTourName;\n};\nconst DefaultActions = ({\n showSkip,\n showPrevious,\n to,\n tourName,\n onNextStep,\n onPreviousStep,\n}: DefaultActionsProps) => {\n const { trackUsage } = useTracking();\n const dispatch = useGuidedTour('GuidedTourPopover', (s) => s.dispatch);\n const state = useGuidedTour('GuidedTourPopover', (s) => s.state);\n const currentStep = state.tours[tourName].currentStep + 1;\n const actualTourLength = tours[tourName]._meta.totalStepCount;\n\n const handleSkip = () => {\n trackUsage('didSkipGuidedTour', { name: tourName });\n dispatch({ type: 'skip_tour', payload: tourName });\n };\n\n const handleNextStep = () => {\n if (currentStep === actualTourLength) {\n trackUsage('didCompleteGuidedTour', { name: tourName });\n }\n\n if (onNextStep) {\n onNextStep();\n } else {\n dispatch({ type: 'next_step', payload: tourName });\n }\n };\n\n const handlePreviousStep = () => {\n if (onPreviousStep) {\n onPreviousStep();\n } else {\n dispatch({ type: 'previous_step', payload: tourName });\n }\n };\n\n return (\n <Flex gap={2}>\n {showSkip && (\n <Button variant=\"tertiary\" onClick={handleSkip}>\n <FormattedMessage id=\"tours.skip\" defaultMessage=\"Skip\" />\n </Button>\n )}\n {!showSkip && showPrevious && (\n <Button variant=\"tertiary\" onClick={handlePreviousStep}>\n <FormattedMessage id=\"tours.previous\" defaultMessage=\"Previous\" />\n </Button>\n )}\n {to ? (\n <LinkButton tag={NavLink} to={to} onClick={handleNextStep}>\n <FormattedMessage id=\"tours.next\" defaultMessage=\"Next\" />\n </LinkButton>\n ) : (\n <Button onClick={handleNextStep}>\n <FormattedMessage id=\"tours.next\" defaultMessage=\"Next\" />\n </Button>\n )}\n </Flex>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Step factory\n * -----------------------------------------------------------------------------------------------*/\n\ntype WithChildren = {\n children: React.ReactNode;\n id?: never;\n defaultMessage?: never;\n};\n\ntype WithIntl = {\n children?: undefined;\n id: MessageDescriptor['id'];\n defaultMessage: MessageDescriptor['defaultMessage'];\n withArrow?: boolean;\n};\n\ntype WithActionsChildren = {\n children: React.ReactNode;\n showStepCount?: boolean;\n showSkip?: boolean;\n showPrevious?: boolean;\n};\n\ntype WithActionsProps = {\n children?: undefined;\n showStepCount?: boolean;\n showSkip?: boolean;\n showPrevious?: boolean;\n};\n\ntype StepProps = WithChildren | WithIntl;\ntype ActionsProps = WithActionsChildren | WithActionsProps;\n\ntype Step = {\n Root: React.ForwardRefExoticComponent<\n React.ComponentProps<typeof Popover.Content> & { withArrow?: boolean }\n >;\n Title: (props: StepProps) => React.ReactNode;\n Content: (\n props: StepProps & {\n values?: Record<string, React.ReactNode | ((chunks: React.ReactNode) => React.ReactNode)>;\n }\n ) => React.ReactNode;\n Actions: (props: ActionsProps & { to?: string } & FlexProps) => React.ReactNode;\n};\n\nconst ActionsContainer = styled(Flex)`\n border-top: ${({ theme }) => `1px solid ${theme.colors.neutral150}`};\n`;\n\nconst ContentContainer = styled(Box)`\n p {\n margin-top: ${({ theme }) => theme.spaces[5]};\n }\n ul {\n list-style-type: disc;\n padding-left: ${({ theme }) => theme.spaces[4]};\n }\n`;\n\n/**\n * TODO:\n * We should probably move all arrow styles + svg to the DS\n */\nconst PopoverArrow = styled(Popover.Arrow)`\n fill: ${({ theme }) => theme.colors.neutral0};\n transform: translateY(-16px) rotate(-90deg);\n`;\n\nconst createStepComponents = (tourName: ValidTourName): Step => ({\n Root: React.forwardRef(({ withArrow = true, ...props }, ref) => {\n return (\n <Popover.Content\n ref={ref}\n aria-labelledby=\"guided-tour-title\"\n side=\"top\"\n align=\"center\"\n style={{ border: 'none' }}\n onClick={(e) => e.stopPropagation()}\n {...props}\n >\n {withArrow && (\n <PopoverArrow asChild>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"23\"\n height=\"25\"\n viewBox=\"0 0 23 25\"\n fill=\"none\"\n >\n <path d=\"M11 24.5L1.82843 15.3284C0.266332 13.7663 0.26633 11.2337 1.82843 9.67157L11 0.5L23 12.5L11 24.5Z\" />\n </svg>\n </PopoverArrow>\n )}\n <Flex width=\"360px\" direction=\"column\" alignItems=\"start\">\n {props.children}\n </Flex>\n </Popover.Content>\n );\n }),\n\n Title: (props) => {\n return (\n <Box paddingTop={5} paddingLeft={5} paddingRight={5} paddingBottom={1} width=\"100%\">\n {'children' in props ? (\n props.children\n ) : (\n <Typography tag=\"h1\" id=\"guided-tour-title\" variant=\"omega\" fontWeight=\"bold\">\n <FormattedMessage id={props.id} defaultMessage={props.defaultMessage} />\n </Typography>\n )}\n </Box>\n );\n },\n\n Content: (props) => {\n const { formatMessage } = useIntl();\n let content = '';\n if (!('children' in props)) {\n content = formatMessage({\n id: props.id,\n defaultMessage: props.defaultMessage,\n });\n }\n return (\n <Box paddingBottom={5} paddingLeft={5} paddingRight={5} width=\"100%\">\n {'children' in props ? (\n props.children\n ) : (\n <ContentContainer>\n <Typography tag=\"div\" variant=\"omega\" dangerouslySetInnerHTML={{ __html: content }} />\n </ContentContainer>\n )}\n </Box>\n );\n },\n\n Actions: ({\n showStepCount = true,\n showPrevious = true,\n showSkip = false,\n to,\n children,\n ...flexProps\n }) => {\n return (\n <ActionsContainer\n width=\"100%\"\n padding={3}\n paddingLeft={5}\n justifyContent={showStepCount ? 'space-between' : 'flex-end'}\n {...flexProps}\n >\n {children ? (\n children\n ) : (\n <>\n {showStepCount && <StepCount tourName={tourName} />}\n <DefaultActions\n tourName={tourName}\n showSkip={showSkip}\n showPrevious={!showSkip && showPrevious}\n to={to}\n />\n </>\n )}\n </ActionsContainer>\n );\n },\n});\n\nexport type { Step };\nexport { createStepComponents, GotItAction, StepCount, DefaultActions };\n"],"names":["StepCount","tourName","displayedCurrentStep","displayedTourLength","state","useGuidedTour","s","currentStep","tours","displayedStepCount","_meta","_jsx","Typography","variant","fontSize","FormattedMessage","id","defaultMessage","values","tourLength","GotItAction","onClick","Button","DefaultActions","showSkip","showPrevious","to","onNextStep","onPreviousStep","trackUsage","useTracking","dispatch","actualTourLength","totalStepCount","handleSkip","name","type","payload","handleNextStep","handlePreviousStep","_jsxs","Flex","gap","LinkButton","tag","NavLink","ActionsContainer","styled","theme","colors","neutral150","ContentContainer","Box","spaces","PopoverArrow","Popover","Arrow","neutral0","createStepComponents","Root","React","forwardRef","withArrow","props","ref","Content","aria-labelledby","side","align","style","border","e","stopPropagation","asChild","svg","xmlns","width","height","viewBox","fill","path","d","direction","alignItems","children","Title","paddingTop","paddingLeft","paddingRight","paddingBottom","fontWeight","formatMessage","useIntl","content","dangerouslySetInnerHTML","__html","Actions","showStepCount","flexProps","padding","justifyContent","_Fragment"],"mappings":";;;;;;;;;;AAmBA;;qGAIA,MAAMA,YAAY,CAAC,EACjBC,QAAQ,EACRC,oBAAoB,EACpBC,mBAAmB,EAKpB,GAAA;AACC,IAAA,MAAMC,QAAQC,aAAc,CAAA,mBAAA,EAAqB,CAACC,CAAAA,GAAMA,EAAEF,KAAK,CAAA;IAC/D,MAAMG,WAAAA,GAAcL,wBAAwBE,KAAMI,CAAAA,KAAK,CAACP,QAAS,CAAA,CAACM,WAAW,GAAG,CAAA;IAChF,MAAME,kBAAAA,GAAqBN,uBAAuBK,KAAK,CAACP,SAAS,CAACS,KAAK,CAACD,kBAAkB;AAE1F,IAAA,qBACEE,GAACC,CAAAA,UAAAA,EAAAA;QAAWC,OAAQ,EAAA,OAAA;QAAQC,QA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D,gBAAA,GAAGC,SAAS;AAEZd,gBAAAA,QAAAA,EAAAA,QAAAA,GACCA,QAEA,iBAAA5C,IAAA,CAAA6D,QAAA,EAAA;;AACGJ,wBAAAA,aAAAA,kBAAiBtF,GAACX,CAAAA,SAAAA,EAAAA;4BAAUC,QAAUA,EAAAA;;sCACvCU,GAACY,CAAAA,cAAAA,EAAAA;4BACCtB,QAAUA,EAAAA,QAAAA;4BACVuB,QAAUA,EAAAA,QAAAA;AACVC,4BAAAA,YAAAA,EAAc,CAACD,QAAYC,IAAAA,YAAAA;4BAC3BC,EAAIA,EAAAA;;;;;AAMhB;KACF;;;;"}
1
+ {"version":3,"file":"Step.mjs","sources":["../../../../../../../admin/src/components/GuidedTour/Steps/Step.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Popover,\n Box,\n Flex,\n Button,\n Typography,\n LinkButton,\n FlexProps,\n} from '@strapi/design-system';\nimport { FormattedMessage, useIntl, type MessageDescriptor } from 'react-intl';\nimport { To, NavLink } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { useTracking } from '../../../features/Tracking';\nimport { useGuidedTour, type ValidTourName } from '../Context';\nimport { tours } from '../Tours';\n\n/* -------------------------------------------------------------------------------------------------\n * Common Step Components\n * -----------------------------------------------------------------------------------------------*/\n\nconst StepCount = ({\n tourName,\n displayedCurrentStep,\n displayedTourLength,\n}: {\n tourName: ValidTourName;\n displayedCurrentStep?: number;\n displayedTourLength?: number;\n}) => {\n const state = useGuidedTour('GuidedTourPopover', (s) => s.state);\n const currentStep = displayedCurrentStep ?? state.tours[tourName].currentStep + 1;\n const displayedStepCount = displayedTourLength ?? tours[tourName]._meta.displayedStepCount;\n\n return (\n <Typography variant=\"omega\" fontSize=\"12px\">\n <FormattedMessage\n id=\"tours.stepCount\"\n defaultMessage=\"Step {currentStep} of {tourLength}\"\n values={{ currentStep, tourLength: displayedStepCount }}\n />\n </Typography>\n );\n};\n\nconst GotItAction = ({ onClick }: { onClick: () => void }) => {\n return (\n <Button onClick={onClick}>\n <FormattedMessage id=\"tours.gotIt\" defaultMessage=\"Got it\" />\n </Button>\n );\n};\n\nexport type DefaultActionsProps = {\n showSkip?: boolean;\n showPrevious?: boolean;\n to?: To;\n onNextStep?: () => void;\n onPreviousStep?: () => void;\n tourName: ValidTourName;\n};\nconst DefaultActions = ({\n showSkip,\n showPrevious,\n to,\n tourName,\n onNextStep,\n onPreviousStep,\n}: DefaultActionsProps) => {\n const { trackUsage } = useTracking();\n const dispatch = useGuidedTour('GuidedTourPopover', (s) => s.dispatch);\n const state = useGuidedTour('GuidedTourPopover', (s) => s.state);\n\n // Safety check: if tours state is missing, return null\n if (!state.tours || !state.tours[tourName]) {\n return null;\n }\n\n const currentStep = state.tours[tourName].currentStep + 1;\n const actualTourLength = tours[tourName]._meta.totalStepCount;\n\n const handleSkip = () => {\n trackUsage('didSkipGuidedTour', { name: tourName });\n dispatch({ type: 'skip_tour', payload: tourName });\n };\n\n const handleNextStep = () => {\n if (currentStep === actualTourLength) {\n trackUsage('didCompleteGuidedTour', { name: tourName });\n }\n\n if (onNextStep) {\n onNextStep();\n } else {\n dispatch({ type: 'next_step', payload: tourName });\n }\n };\n\n const handlePreviousStep = () => {\n if (onPreviousStep) {\n onPreviousStep();\n } else {\n dispatch({ type: 'previous_step', payload: tourName });\n }\n };\n\n return (\n <Flex gap={2}>\n {showSkip && (\n <Button variant=\"tertiary\" onClick={handleSkip}>\n <FormattedMessage id=\"tours.skip\" defaultMessage=\"Skip\" />\n </Button>\n )}\n {!showSkip && showPrevious && (\n <Button variant=\"tertiary\" onClick={handlePreviousStep}>\n <FormattedMessage id=\"tours.previous\" defaultMessage=\"Previous\" />\n </Button>\n )}\n {to ? (\n <LinkButton tag={NavLink} to={to} onClick={handleNextStep}>\n <FormattedMessage id=\"tours.next\" defaultMessage=\"Next\" />\n </LinkButton>\n ) : (\n <Button onClick={handleNextStep}>\n <FormattedMessage id=\"tours.next\" defaultMessage=\"Next\" />\n </Button>\n )}\n </Flex>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Step factory\n * -----------------------------------------------------------------------------------------------*/\n\ntype WithChildren = {\n children: React.ReactNode;\n id?: never;\n defaultMessage?: never;\n};\n\ntype WithIntl = {\n children?: undefined;\n id: MessageDescriptor['id'];\n defaultMessage: MessageDescriptor['defaultMessage'];\n withArrow?: boolean;\n};\n\ntype WithActionsChildren = {\n children: React.ReactNode;\n showStepCount?: boolean;\n showSkip?: boolean;\n showPrevious?: boolean;\n};\n\ntype WithActionsProps = {\n children?: undefined;\n showStepCount?: boolean;\n showSkip?: boolean;\n showPrevious?: boolean;\n};\n\ntype StepProps = WithChildren | WithIntl;\ntype ActionsProps = WithActionsChildren | WithActionsProps;\n\ntype Step = {\n Root: React.ForwardRefExoticComponent<\n React.ComponentProps<typeof Popover.Content> & { withArrow?: boolean }\n >;\n Title: (props: StepProps) => React.ReactNode;\n Content: (\n props: StepProps & {\n values?: Record<string, React.ReactNode | ((chunks: React.ReactNode) => React.ReactNode)>;\n }\n ) => React.ReactNode;\n Actions: (props: ActionsProps & { to?: string } & FlexProps) => React.ReactNode;\n};\n\nconst ActionsContainer = styled(Flex)`\n border-top: ${({ theme }) => `1px solid ${theme.colors.neutral150}`};\n`;\n\nconst ContentContainer = styled(Box)`\n p {\n margin-top: ${({ theme }) => theme.spaces[5]};\n }\n ul {\n list-style-type: disc;\n padding-left: ${({ theme }) => theme.spaces[4]};\n }\n`;\n\n/**\n * TODO:\n * We should probably move all arrow styles + svg to the DS\n */\nconst PopoverArrow = styled(Popover.Arrow)`\n fill: ${({ theme }) => theme.colors.neutral0};\n transform: translateY(-16px) rotate(-90deg);\n`;\n\nconst createStepComponents = (tourName: ValidTourName): Step => ({\n Root: React.forwardRef(({ withArrow = true, ...props }, ref) => {\n return (\n <Popover.Content\n ref={ref}\n aria-labelledby=\"guided-tour-title\"\n side=\"top\"\n align=\"center\"\n style={{ border: 'none' }}\n onClick={(e) => e.stopPropagation()}\n {...props}\n >\n {withArrow && (\n <PopoverArrow asChild>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"23\"\n height=\"25\"\n viewBox=\"0 0 23 25\"\n fill=\"none\"\n >\n <path d=\"M11 24.5L1.82843 15.3284C0.266332 13.7663 0.26633 11.2337 1.82843 9.67157L11 0.5L23 12.5L11 24.5Z\" />\n </svg>\n </PopoverArrow>\n )}\n <Flex width=\"360px\" direction=\"column\" alignItems=\"start\">\n {props.children}\n </Flex>\n </Popover.Content>\n );\n }),\n\n Title: (props) => {\n return (\n <Box paddingTop={5} paddingLeft={5} paddingRight={5} paddingBottom={1} width=\"100%\">\n {'children' in props ? (\n props.children\n ) : (\n <Typography tag=\"h1\" id=\"guided-tour-title\" variant=\"omega\" fontWeight=\"bold\">\n <FormattedMessage id={props.id} defaultMessage={props.defaultMessage} />\n </Typography>\n )}\n </Box>\n );\n },\n\n Content: (props) => {\n const { formatMessage } = useIntl();\n let content = '';\n if (!('children' in props)) {\n content = formatMessage({\n id: props.id,\n defaultMessage: props.defaultMessage,\n });\n }\n return (\n <Box paddingBottom={5} paddingLeft={5} paddingRight={5} width=\"100%\">\n {'children' in props ? (\n props.children\n ) : (\n <ContentContainer>\n <Typography tag=\"div\" variant=\"omega\" dangerouslySetInnerHTML={{ __html: content }} />\n </ContentContainer>\n )}\n </Box>\n );\n },\n\n Actions: ({\n showStepCount = true,\n showPrevious = true,\n showSkip = false,\n to,\n children,\n ...flexProps\n }) => {\n return (\n <ActionsContainer\n width=\"100%\"\n padding={3}\n paddingLeft={5}\n justifyContent={showStepCount ? 'space-between' : 'flex-end'}\n {...flexProps}\n >\n {children ? (\n children\n ) : (\n <>\n {showStepCount && <StepCount tourName={tourName} />}\n <DefaultActions\n tourName={tourName}\n showSkip={showSkip}\n showPrevious={!showSkip && showPrevious}\n to={to}\n />\n </>\n )}\n </ActionsContainer>\n );\n },\n});\n\nexport type { Step };\nexport { createStepComponents, GotItAction, StepCount, DefaultActions };\n"],"names":["StepCount","tourName","displayedCurrentStep","displayedTourLength","state","useGuidedTour","s","currentStep","tours","displayedStepCount","_meta","_jsx","Typography","variant","fontSize","FormattedMessage","id","defaultMessage","values","tourLength","GotItAction","onClick","Button","DefaultActions","showSkip","showPrevious","to","onNextStep","onPreviousStep","trackUsage","useTracking","dispatch","actualTourLength","totalStepCount","handleSkip","name","type","payload","handleNextStep","handlePreviousStep","_jsxs","Flex","gap","LinkButton","tag","NavLink","ActionsContainer","styled","theme","colors","neutral150","ContentContainer","Box","spaces","PopoverArrow","Popover","Arrow","neutral0","createStepComponents","Root","React","forwardRef","withArrow","props","ref","Content","aria-labelledby","side","align","style","border","e","stopPropagation","asChild","svg","xmlns","width","height","viewBox","fill","path","d","direction","alignItems","children","Title","paddingTop","paddingLeft","paddingRight","paddingBottom","fontWeight","formatMessage","useIntl","content","dangerouslySetInnerHTML","__html","Actions","showStepCount","flexProps","padding","justifyContent","_Fragment"],"mappings":";;;;;;;;;;AAmBA;;qGAIA,MAAMA,YAAY,CAAC,EACjBC,QAAQ,EACRC,oBAAoB,EACpBC,mBAAmB,EAKpB,GAAA;AACC,IAAA,MAAMC,QAAQC,aAAc,CAAA,mBAAA,EAAqB,CAACC,CAAAA,GAAMA,EAAEF,KAAK,CAAA;IAC/D,MAAMG,WAAAA,GAAcL,wBAAwBE,KAAMI,CAAAA,KAAK,CAACP,QAAS,CAAA,CAACM,WAAW,GAAG,CAAA;IAChF,MAAME,kBAAAA,GAAqBN,uBAAuBK,KAAK,CAACP,SAAS,CAACS,KAAK,CAACD,kBAAkB;AAE1F,IAAA,qBACEE,GAACC,CAAAA,UAAAA,EAAAA;QAAWC,OAAQ,EAAA,OAAA;QAAQC,QAAS,EAAA,MAAA;AACnC,QAAA,QAAA,gBAAAH,GAACI,CAAAA,gBAAAA,EAAAA;YACCC,EAAG,EAAA,iBAAA;YACHC,cAAe,EAAA,oCAAA;YACfC,MAAQ,EAAA;AAAEX,gBAAAA,WAAAA;gBAAaY,UAAYV,EAAAA;AAAmB;;;A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IAAA,CAAA6D,QAAA,EAAA;;AACGJ,wBAAAA,aAAAA,kBAAiBtF,GAACX,CAAAA,SAAAA,EAAAA;4BAAUC,QAAUA,EAAAA;;sCACvCU,GAACY,CAAAA,cAAAA,EAAAA;4BACCtB,QAAUA,EAAAA,QAAAA;4BACVuB,QAAUA,EAAAA,QAAAA;AACVC,4BAAAA,YAAAA,EAAc,CAACD,QAAYC,IAAAA,YAAAA;4BAC3BC,EAAIA,EAAAA;;;;;AAMhB;KACF;;;;"}
@@ -62,9 +62,10 @@ const GuidedTourTooltipImpl = ({ children, content, tourName, step, when })=>{
62
62
  const { data: guidedTourMeta } = admin.useGetGuidedTourMetaQuery();
63
63
  const state = Context.useGuidedTour('GuidedTourTooltip', (s)=>s.state);
64
64
  const dispatch = Context.useGuidedTour('GuidedTourTooltip', (s)=>s.dispatch);
65
- const isCurrentStep = state.tours[tourName].currentStep === step;
65
+ const tourState = state.tours?.[tourName];
66
+ const isCurrentStep = tourState?.currentStep === step;
66
67
  const isStepConditionMet = when ? when(state.completedActions) : true;
67
- const isPopoverOpen = guidedTourMeta?.data?.isFirstSuperAdminUser && !state.tours[tourName].isCompleted && isCurrentStep && isStepConditionMet;
68
+ const isPopoverOpen = guidedTourMeta?.data?.isFirstSuperAdminUser && !tourState?.isCompleted && isCurrentStep && isStepConditionMet;
68
69
  // Lock the scroll
69
70
  React__namespace.useEffect(()=>{
70
71
  if (!isPopoverOpen) return;
@@ -102,6 +103,12 @@ const GuidedTourTooltipImpl = ({ children, content, tourName, step, when })=>{
102
103
  step,
103
104
  tourName
104
105
  ]);
106
+ // Safety check: if tours state is corrupted or missing, render without tooltip (after all hooks)
107
+ if (!state.tours || !state.tours[tourName]) {
108
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
109
+ children: children
110
+ });
111
+ }
105
112
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
106
113
  children: [
107
114
  isPopoverOpen && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Portal, {
@@ -1 +1 @@
1
- {"version":3,"file":"Tours.js","sources":["../../../../../../admin/src/components/GuidedTour/Tours.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, Popover, Portal } from '@strapi/design-system';\nimport { styled } from 'styled-components';\n\nimport { useGetGuidedTourMetaQuery } from '../../services/admin';\n\nimport { type State, type Action, useGuidedTour, ValidTourName, CompletedActions } from './Context';\nimport { apiTokensSteps } from './Steps/ApiTokensSteps';\nimport { contentManagerSteps } from './Steps/ContentManagerSteps';\nimport { contentTypeBuilderSteps } from './Steps/ContentTypeBuilderSteps';\nimport { type Step, createStepComponents } from './Steps/Step';\nimport { GUIDED_TOUR_REQUIRED_ACTIONS } from './utils/constants';\n\n/* -------------------------------------------------------------------------------------------------\n * Tours\n * -----------------------------------------------------------------------------------------------*/\n\nconst tours = {\n contentTypeBuilder: createTour('contentTypeBuilder', contentTypeBuilderSteps),\n contentManager: createTour('contentManager', contentManagerSteps),\n apiTokens: createTour('apiTokens', apiTokensSteps),\n strapiCloud: createTour('strapiCloud', []),\n} as const;\n\ntype Tours = typeof tours;\n\n/* -------------------------------------------------------------------------------------------------\n * GuidedTourTooltip\n * -----------------------------------------------------------------------------------------------*/\n\nexport type StepContentProps = {\n Step: Step;\n state: State;\n dispatch: React.Dispatch<Action>;\n};\ntype Content = (props: StepContentProps) => React.ReactNode;\n\ntype GuidedTourTooltipProps = {\n children: React.ReactNode;\n content: Content;\n tourName: ValidTourName;\n step: number;\n when?: (completedActions: CompletedActions) => boolean;\n};\n\nconst GuidedTourTooltip = ({ children, ...props }: GuidedTourTooltipProps) => {\n const state = useGuidedTour('TooltipWrapper', (s) => s.state);\n\n if (!state.enabled || state.hidden || process.env.NODE_ENV !== 'development') {\n return children;\n }\n\n return <GuidedTourTooltipImpl {...props}>{children}</GuidedTourTooltipImpl>;\n};\n\nconst GuidedTourOverlay = styled(Box)`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(50, 50, 77, 0.2);\n z-index: 10;\n`;\n\nconst GuidedTourTooltipImpl = ({\n children,\n content,\n tourName,\n step,\n when,\n}: GuidedTourTooltipProps) => {\n const { data: guidedTourMeta } = useGetGuidedTourMetaQuery();\n const state = useGuidedTour('GuidedTourTooltip', (s) => s.state);\n const dispatch = useGuidedTour('GuidedTourTooltip', (s) => s.dispatch);\n\n const isCurrentStep = state.tours[tourName].currentStep === step;\n const isStepConditionMet = when ? when(state.completedActions) : true;\n const isPopoverOpen =\n guidedTourMeta?.data?.isFirstSuperAdminUser &&\n !state.tours[tourName].isCompleted &&\n isCurrentStep &&\n isStepConditionMet;\n\n // Lock the scroll\n React.useEffect(() => {\n if (!isPopoverOpen) return;\n\n const originalStyle = window.getComputedStyle(document.body).overflow;\n document.body.style.overflow = 'hidden';\n\n return () => {\n document.body.style.overflow = originalStyle;\n };\n }, [isPopoverOpen]);\n\n const Step = React.useMemo(() => createStepComponents(tourName), [tourName]);\n\n const hasApiSchema =\n Object.keys(guidedTourMeta?.data?.schemas ?? {}).filter((key) => key.startsWith('api::'))\n .length > 0;\n\n React.useEffect(() => {\n if (hasApiSchema) {\n /**\n * Fallback sync:\n *\n * When the user already has a schema (ie started project from template with seeded data),\n * allow them to proceed to the content manager tour.\n *\n * When the CTB fails to restart after saving a schema (as it often does)\n */\n dispatch({\n type: 'set_completed_actions',\n payload: [GUIDED_TOUR_REQUIRED_ACTIONS.contentTypeBuilder.createSchema],\n });\n }\n }, [dispatch, hasApiSchema, step, tourName]);\n\n return (\n <>\n {isPopoverOpen && (\n <Portal>\n <GuidedTourOverlay />\n </Portal>\n )}\n <Popover.Root open={isPopoverOpen}>\n <Popover.Anchor>{children}</Popover.Anchor>\n {content({ Step, state, dispatch })}\n </Popover.Root>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Tour factory\n * -----------------------------------------------------------------------------------------------*/\n\nexport type TourStep<P extends string> = {\n name: P;\n content: Content;\n when?: (completedActions: CompletedActions) => boolean;\n excludeFromStepCount?: boolean;\n};\n\nexport function createTour<const T extends ReadonlyArray<TourStep<string>>>(\n tourName: string,\n steps: T\n) {\n type Components = {\n [K in T[number]['name']]: React.ComponentType<{ children: React.ReactNode }>;\n };\n\n const tour = steps.reduce(\n (acc, step, index) => {\n const name = step.name as keyof Components;\n\n if (name in acc) {\n throw Error(`The tour: ${tourName} with step: ${step.name} has already been registered`);\n }\n\n (acc as Components)[name] = ({ children }: { children: React.ReactNode }) => {\n return (\n <GuidedTourTooltip\n tourName={tourName as ValidTourName}\n step={index}\n content={step.content}\n when={step.when}\n >\n {children}\n </GuidedTourTooltip>\n );\n };\n\n if (step.excludeFromStepCount) {\n // Subtract all steps registered to be excluded from the step count\n acc._meta.displayedStepCount--;\n }\n\n return acc;\n },\n { _meta: { totalStepCount: steps.length, displayedStepCount: steps.length } } as Components & {\n _meta: { totalStepCount: number; displayedStepCount: number };\n }\n );\n\n return tour;\n}\n\nexport type { Content, Tours };\nexport { tours };\n"],"names":["tours","contentTypeBuilder","createTour","contentTypeBuilderSteps","contentManager","contentManagerSteps","apiTokens","apiTokensSteps","strapiCloud","GuidedTourTooltip","children","props","state","useGuidedTour","s","enabled","hidden","process","env","NODE_ENV","_jsx","GuidedTourTooltipImpl","GuidedTourOverlay","styled","Box","content","tourName","step","when","data","guidedTourMeta","useGetGuidedTourMetaQuery","dispatch","isCurrentStep","currentStep","isStepConditionMet","completedActions","isPopoverOpen","isFirstSuperAdminUser","isCompleted","React","useEffect","originalStyle","window","getComputedStyle","document","body","overflow","style","Step","useMemo","createStepComponents","hasApiSchema","Object","keys","schemas","filter","key","startsWith","length","type","payload","GUIDED_TOUR_REQUIRED_ACTIONS","createSchema","_jsxs","_Fragment","Portal","Popover","Root","open","Anchor","steps","tour","reduce","acc","index","name","Error","excludeFromStepCount","_meta","displayedStepCount","totalStepCount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;AAEkG,2GAE5FA,KAAQ,GAAA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AAKC,IAAI;AAEdlB,gBAAAA,QAAAA,EAAAA;;AAGP,SAAA;QAEA,IAAIiB,IAAAA,CAAKmD,oBAAoB,EAAE;;YAE7BJ,GAAIK,CAAAA,KAAK,CAACC,kBAAkB,EAAA;AAC9B;QAEA,OAAON,GAAAA;KAET,EAAA;QAAEK,KAAO,EAAA;AAAEE,YAAAA,cAAAA,EAAgBV,MAAMZ,MAAM;AAAEqB,YAAAA,kBAAAA,EAAoBT,MAAMZ;AAAO;AAAE,KAAA,CAAA;IAK9E,OAAOa,IAAAA;AACT;;;;;"}
1
+ {"version":3,"file":"Tours.js","sources":["../../../../../../admin/src/components/GuidedTour/Tours.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, Popover, Portal } from '@strapi/design-system';\nimport { styled } from 'styled-components';\n\nimport { useGetGuidedTourMetaQuery } from '../../services/admin';\n\nimport { type State, type Action, useGuidedTour, ValidTourName, CompletedActions } from './Context';\nimport { apiTokensSteps } from './Steps/ApiTokensSteps';\nimport { contentManagerSteps } from './Steps/ContentManagerSteps';\nimport { contentTypeBuilderSteps } from './Steps/ContentTypeBuilderSteps';\nimport { type Step, createStepComponents } from './Steps/Step';\nimport { GUIDED_TOUR_REQUIRED_ACTIONS } from './utils/constants';\n\n/* -------------------------------------------------------------------------------------------------\n * Tours\n * -----------------------------------------------------------------------------------------------*/\n\nconst tours = {\n contentTypeBuilder: createTour('contentTypeBuilder', contentTypeBuilderSteps),\n contentManager: createTour('contentManager', contentManagerSteps),\n apiTokens: createTour('apiTokens', apiTokensSteps),\n strapiCloud: createTour('strapiCloud', []),\n} as const;\n\ntype Tours = typeof tours;\n\n/* -------------------------------------------------------------------------------------------------\n * GuidedTourTooltip\n * -----------------------------------------------------------------------------------------------*/\n\nexport type StepContentProps = {\n Step: Step;\n state: State;\n dispatch: React.Dispatch<Action>;\n};\ntype Content = (props: StepContentProps) => React.ReactNode;\n\ntype GuidedTourTooltipProps = {\n children: React.ReactNode;\n content: Content;\n tourName: ValidTourName;\n step: number;\n when?: (completedActions: CompletedActions) => boolean;\n};\n\nconst GuidedTourTooltip = ({ children, ...props }: GuidedTourTooltipProps) => {\n const state = useGuidedTour('TooltipWrapper', (s) => s.state);\n\n if (!state.enabled || state.hidden || process.env.NODE_ENV !== 'development') {\n return children;\n }\n\n return <GuidedTourTooltipImpl {...props}>{children}</GuidedTourTooltipImpl>;\n};\n\nconst GuidedTourOverlay = styled(Box)`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(50, 50, 77, 0.2);\n z-index: 10;\n`;\n\nconst GuidedTourTooltipImpl = ({\n children,\n content,\n tourName,\n step,\n when,\n}: GuidedTourTooltipProps) => {\n const { data: guidedTourMeta } = useGetGuidedTourMetaQuery();\n const state = useGuidedTour('GuidedTourTooltip', (s) => s.state);\n const dispatch = useGuidedTour('GuidedTourTooltip', (s) => s.dispatch);\n\n const tourState = state.tours?.[tourName];\n const isCurrentStep = tourState?.currentStep === step;\n const isStepConditionMet = when ? when(state.completedActions) : true;\n const isPopoverOpen =\n guidedTourMeta?.data?.isFirstSuperAdminUser &&\n !tourState?.isCompleted &&\n isCurrentStep &&\n isStepConditionMet;\n\n // Lock the scroll\n React.useEffect(() => {\n if (!isPopoverOpen) return;\n\n const originalStyle = window.getComputedStyle(document.body).overflow;\n document.body.style.overflow = 'hidden';\n\n return () => {\n document.body.style.overflow = originalStyle;\n };\n }, [isPopoverOpen]);\n\n const Step = React.useMemo(() => createStepComponents(tourName), [tourName]);\n\n const hasApiSchema =\n Object.keys(guidedTourMeta?.data?.schemas ?? {}).filter((key) => key.startsWith('api::'))\n .length > 0;\n\n React.useEffect(() => {\n if (hasApiSchema) {\n /**\n * Fallback sync:\n *\n * When the user already has a schema (ie started project from template with seeded data),\n * allow them to proceed to the content manager tour.\n *\n * When the CTB fails to restart after saving a schema (as it often does)\n */\n dispatch({\n type: 'set_completed_actions',\n payload: [GUIDED_TOUR_REQUIRED_ACTIONS.contentTypeBuilder.createSchema],\n });\n }\n }, [dispatch, hasApiSchema, step, tourName]);\n\n // Safety check: if tours state is corrupted or missing, render without tooltip (after all hooks)\n if (!state.tours || !state.tours[tourName]) {\n return <>{children}</>;\n }\n\n return (\n <>\n {isPopoverOpen && (\n <Portal>\n <GuidedTourOverlay />\n </Portal>\n )}\n <Popover.Root open={isPopoverOpen}>\n <Popover.Anchor>{children}</Popover.Anchor>\n {content({ Step, state, dispatch })}\n </Popover.Root>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Tour factory\n * -----------------------------------------------------------------------------------------------*/\n\nexport type TourStep<P extends string> = {\n name: P;\n content: Content;\n when?: (completedActions: CompletedActions) => boolean;\n excludeFromStepCount?: boolean;\n};\n\nexport function createTour<const T extends ReadonlyArray<TourStep<string>>>(\n tourName: string,\n steps: T\n) {\n type Components = {\n [K in T[number]['name']]: React.ComponentType<{ children: React.ReactNode }>;\n };\n\n const tour = steps.reduce(\n (acc, step, index) => {\n const name = step.name as keyof Components;\n\n if (name in acc) {\n throw Error(`The tour: ${tourName} with step: ${step.name} has already been registered`);\n }\n\n (acc as Components)[name] = ({ children }: { children: React.ReactNode }) => {\n return (\n <GuidedTourTooltip\n tourName={tourName as ValidTourName}\n step={index}\n content={step.content}\n when={step.when}\n >\n {children}\n </GuidedTourTooltip>\n );\n };\n\n if (step.excludeFromStepCount) {\n // Subtract all steps registered to be excluded from the step count\n acc._meta.displayedStepCount--;\n }\n\n return acc;\n },\n { _meta: { totalStepCount: steps.length, displayedStepCount: steps.length } } as Components & {\n _meta: { totalStepCount: number; displayedStepCount: number };\n }\n );\n\n return tour;\n}\n\nexport type { Content, Tours };\nexport { tours };\n"],"names":["tours","contentTypeBuilder","createTour","contentTypeBuilderSteps","contentManager","contentManagerSteps","apiTokens","apiTokensSteps","strapiCloud","GuidedTourTooltip","children","props","state","useGuidedTour","s","enabled","hidden","process","env","NODE_ENV","_jsx","GuidedTourTooltipImpl","GuidedTourOverlay","styled","Box","content","tourName","step","when","data","guidedTourMeta","useGetGuidedTourMetaQuery","dispatch","tourState","isCurrentStep","currentStep","isStepConditionMet","completedActions","isPopoverOpen","isFirstSuperAdminUser","isCompleted","React","useEffect","originalStyle","window","getComputedStyle","document","body","overflow","style","Step","useMemo","createStepComponents","hasApiSchema","Object","keys","schemas","filter","key","startsWith","length","type","payload","GUIDED_TOUR_REQUIRED_ACTIONS","createSchema","_Fragment","_jsxs","Portal","Popover","Root","open","Anchor","steps","tour","reduce","acc","index","name","Error","excludeFromStepCount","_meta","displayedStepCount","totalStepCount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;AAEkG,2GAE5FA,KAAQ,GAAA;AACZC,IAAAA,kBAAAA,EAAoBC,WAAW,oBAAsBC,EAAAA,+CAAAA,CAAAA;AACrDC,IAAAA,cAAAA,EAAgBF,WAAW,gBAAkBG,EAAAA,uCAAAA,CAAAA;AAC7CC,IAAAA,SAAAA,EAAWJ,WAAW,WAAaK,EAAAA,6BAAAA,CAAAA;IACnCC,WAAaN,EAAAA,UAAAA,CAAW,eAAe,EAAE;AAC3C;AAuBA,MAAMO,oBAAoB,CAAC,EAAEC,QAAQ,EAAE,GAAGC,KAA+B,EAAA,GAAA;AACvE,IAAA,MAAMC,QAAQC,qBAAc,CAAA,gBAAA,EAAkB,CAACC,CAAAA,GAAMA,EAAEF,KAAK,CAAA;AAE5D,IAAA,IAAI,CAACA,KAAAA,CAAMG,OAAO,IAAIH,KAAMI,CAAAA,MAAM,IAAIC,OAAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,aAAe,EAAA;QAC5E,OAAOT,QAAAA;AACT;AAEA,IAAA,qBAAOU,cAACC,CAAAA,qBAAAA,EAAAA;AAAuB,QAAA,GAAGV,KAAK;AAAGD,QAAAA,QAAAA,EAAAA;;AAC5C,CAAA;AAEA,MAAMY,iBAAAA,GAAoBC,aAAOC,CAAAA,gBAAAA,CAAI;;;;;;;;AAQrC,CAAC;AAED,MAAMH,qBAAwB,GA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,EAAA;AAMR,IAAA,MAAMC,OAAOD,KAAME,CAAAA,MAAM,CACvB,CAACC,KAAKhD,IAAMiD,EAAAA,KAAAA,GAAAA;QACV,MAAMC,IAAAA,GAAOlD,KAAKkD,IAAI;AAEtB,QAAA,IAAIA,QAAQF,GAAK,EAAA;YACf,MAAMG,KAAAA,CAAM,CAAC,UAAU,EAAEpD,QAAAA,CAAS,YAAY,EAAEC,IAAKkD,CAAAA,IAAI,CAAC,4BAA4B,CAAC,CAAA;AACzF;AAECF,QAAAA,GAAkB,CAACE,IAAK,CAAA,GAAG,CAAC,EAAEnE,QAAQ,EAAiC,GAAA;AACtE,YAAA,qBACEU,cAACX,CAAAA,iBAAAA,EAAAA;gBACCiB,QAAUA,EAAAA,QAAAA;gBACVC,IAAMiD,EAAAA,KAAAA;AACNnD,gBAAAA,OAAAA,EAASE,KAAKF,OAAO;AACrBG,gBAAAA,IAAAA,EAAMD,KAAKC,IAAI;AAEdlB,gBAAAA,QAAAA,EAAAA;;AAGP,SAAA;QAEA,IAAIiB,IAAAA,CAAKoD,oBAAoB,EAAE;;YAE7BJ,GAAIK,CAAAA,KAAK,CAACC,kBAAkB,EAAA;AAC9B;QAEA,OAAON,GAAAA;KAET,EAAA;QAAEK,KAAO,EAAA;AAAEE,YAAAA,cAAAA,EAAgBV,MAAMZ,MAAM;AAAEqB,YAAAA,kBAAAA,EAAoBT,MAAMZ;AAAO;AAAE,KAAA,CAAA;IAK9E,OAAOa,IAAAA;AACT;;;;;"}
@@ -1,4 +1,4 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { Box, Portal, Popover } from '@strapi/design-system';
4
4
  import { styled } from 'styled-components';
@@ -41,9 +41,10 @@ const GuidedTourTooltipImpl = ({ children, content, tourName, step, when })=>{
41
41
  const { data: guidedTourMeta } = useGetGuidedTourMetaQuery();
42
42
  const state = useGuidedTour('GuidedTourTooltip', (s)=>s.state);
43
43
  const dispatch = useGuidedTour('GuidedTourTooltip', (s)=>s.dispatch);
44
- const isCurrentStep = state.tours[tourName].currentStep === step;
44
+ const tourState = state.tours?.[tourName];
45
+ const isCurrentStep = tourState?.currentStep === step;
45
46
  const isStepConditionMet = when ? when(state.completedActions) : true;
46
- const isPopoverOpen = guidedTourMeta?.data?.isFirstSuperAdminUser && !state.tours[tourName].isCompleted && isCurrentStep && isStepConditionMet;
47
+ const isPopoverOpen = guidedTourMeta?.data?.isFirstSuperAdminUser && !tourState?.isCompleted && isCurrentStep && isStepConditionMet;
47
48
  // Lock the scroll
48
49
  React.useEffect(()=>{
49
50
  if (!isPopoverOpen) return;
@@ -81,6 +82,12 @@ const GuidedTourTooltipImpl = ({ children, content, tourName, step, when })=>{
81
82
  step,
82
83
  tourName
83
84
  ]);
85
+ // Safety check: if tours state is corrupted or missing, render without tooltip (after all hooks)
86
+ if (!state.tours || !state.tours[tourName]) {
87
+ return /*#__PURE__*/ jsx(Fragment, {
88
+ children: children
89
+ });
90
+ }
84
91
  return /*#__PURE__*/ jsxs(Fragment, {
85
92
  children: [
86
93
  isPopoverOpen && /*#__PURE__*/ jsx(Portal, {
@@ -1 +1 @@
1
- {"version":3,"file":"Tours.mjs","sources":["../../../../../../admin/src/components/GuidedTour/Tours.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, Popover, Portal } from '@strapi/design-system';\nimport { styled } from 'styled-components';\n\nimport { useGetGuidedTourMetaQuery } from '../../services/admin';\n\nimport { type State, type Action, useGuidedTour, ValidTourName, CompletedActions } from './Context';\nimport { apiTokensSteps } from './Steps/ApiTokensSteps';\nimport { contentManagerSteps } from './Steps/ContentManagerSteps';\nimport { contentTypeBuilderSteps } from './Steps/ContentTypeBuilderSteps';\nimport { type Step, createStepComponents } from './Steps/Step';\nimport { GUIDED_TOUR_REQUIRED_ACTIONS } from './utils/constants';\n\n/* -------------------------------------------------------------------------------------------------\n * Tours\n * -----------------------------------------------------------------------------------------------*/\n\nconst tours = {\n contentTypeBuilder: createTour('contentTypeBuilder', contentTypeBuilderSteps),\n contentManager: createTour('contentManager', contentManagerSteps),\n apiTokens: createTour('apiTokens', apiTokensSteps),\n strapiCloud: createTour('strapiCloud', []),\n} as const;\n\ntype Tours = typeof tours;\n\n/* -------------------------------------------------------------------------------------------------\n * GuidedTourTooltip\n * -----------------------------------------------------------------------------------------------*/\n\nexport type StepContentProps = {\n Step: Step;\n state: State;\n dispatch: React.Dispatch<Action>;\n};\ntype Content = (props: StepContentProps) => React.ReactNode;\n\ntype GuidedTourTooltipProps = {\n children: React.ReactNode;\n content: Content;\n tourName: ValidTourName;\n step: number;\n when?: (completedActions: CompletedActions) => boolean;\n};\n\nconst GuidedTourTooltip = ({ children, ...props }: GuidedTourTooltipProps) => {\n const state = useGuidedTour('TooltipWrapper', (s) => s.state);\n\n if (!state.enabled || state.hidden || process.env.NODE_ENV !== 'development') {\n return children;\n }\n\n return <GuidedTourTooltipImpl {...props}>{children}</GuidedTourTooltipImpl>;\n};\n\nconst GuidedTourOverlay = styled(Box)`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(50, 50, 77, 0.2);\n z-index: 10;\n`;\n\nconst GuidedTourTooltipImpl = ({\n children,\n content,\n tourName,\n step,\n when,\n}: GuidedTourTooltipProps) => {\n const { data: guidedTourMeta } = useGetGuidedTourMetaQuery();\n const state = useGuidedTour('GuidedTourTooltip', (s) => s.state);\n const dispatch = useGuidedTour('GuidedTourTooltip', (s) => s.dispatch);\n\n const isCurrentStep = state.tours[tourName].currentStep === step;\n const isStepConditionMet = when ? when(state.completedActions) : true;\n const isPopoverOpen =\n guidedTourMeta?.data?.isFirstSuperAdminUser &&\n !state.tours[tourName].isCompleted &&\n isCurrentStep &&\n isStepConditionMet;\n\n // Lock the scroll\n React.useEffect(() => {\n if (!isPopoverOpen) return;\n\n const originalStyle = window.getComputedStyle(document.body).overflow;\n document.body.style.overflow = 'hidden';\n\n return () => {\n document.body.style.overflow = originalStyle;\n };\n }, [isPopoverOpen]);\n\n const Step = React.useMemo(() => createStepComponents(tourName), [tourName]);\n\n const hasApiSchema =\n Object.keys(guidedTourMeta?.data?.schemas ?? {}).filter((key) => key.startsWith('api::'))\n .length > 0;\n\n React.useEffect(() => {\n if (hasApiSchema) {\n /**\n * Fallback sync:\n *\n * When the user already has a schema (ie started project from template with seeded data),\n * allow them to proceed to the content manager tour.\n *\n * When the CTB fails to restart after saving a schema (as it often does)\n */\n dispatch({\n type: 'set_completed_actions',\n payload: [GUIDED_TOUR_REQUIRED_ACTIONS.contentTypeBuilder.createSchema],\n });\n }\n }, [dispatch, hasApiSchema, step, tourName]);\n\n return (\n <>\n {isPopoverOpen && (\n <Portal>\n <GuidedTourOverlay />\n </Portal>\n )}\n <Popover.Root open={isPopoverOpen}>\n <Popover.Anchor>{children}</Popover.Anchor>\n {content({ Step, state, dispatch })}\n </Popover.Root>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Tour factory\n * -----------------------------------------------------------------------------------------------*/\n\nexport type TourStep<P extends string> = {\n name: P;\n content: Content;\n when?: (completedActions: CompletedActions) => boolean;\n excludeFromStepCount?: boolean;\n};\n\nexport function createTour<const T extends ReadonlyArray<TourStep<string>>>(\n tourName: string,\n steps: T\n) {\n type Components = {\n [K in T[number]['name']]: React.ComponentType<{ children: React.ReactNode }>;\n };\n\n const tour = steps.reduce(\n (acc, step, index) => {\n const name = step.name as keyof Components;\n\n if (name in acc) {\n throw Error(`The tour: ${tourName} with step: ${step.name} has already been registered`);\n }\n\n (acc as Components)[name] = ({ children }: { children: React.ReactNode }) => {\n return (\n <GuidedTourTooltip\n tourName={tourName as ValidTourName}\n step={index}\n content={step.content}\n when={step.when}\n >\n {children}\n </GuidedTourTooltip>\n );\n };\n\n if (step.excludeFromStepCount) {\n // Subtract all steps registered to be excluded from the step count\n acc._meta.displayedStepCount--;\n }\n\n return acc;\n },\n { _meta: { totalStepCount: steps.length, displayedStepCount: steps.length } } as Components & {\n _meta: { totalStepCount: number; displayedStepCount: number };\n }\n );\n\n return tour;\n}\n\nexport type { Content, Tours };\nexport { tours };\n"],"names":["tours","contentTypeBuilder","createTour","contentTypeBuilderSteps","contentManager","contentManagerSteps","apiTokens","apiTokensSteps","strapiCloud","GuidedTourTooltip","children","props","state","useGuidedTour","s","enabled","hidden","process","env","NODE_ENV","_jsx","GuidedTourTooltipImpl","GuidedTourOverlay","styled","Box","content","tourName","step","when","data","guidedTourMeta","useGetGuidedTourMetaQuery","dispatch","isCurrentStep","currentStep","isStepConditionMet","completedActions","isPopoverOpen","isFirstSuperAdminUser","isCompleted","React","useEffect","originalStyle","window","getComputedStyle","document","body","overflow","style","Step","useMemo","createStepComponents","hasApiSchema","Object","keys","schemas","filter","key","startsWith","length","type","payload","GUIDED_TOUR_REQUIRED_ACTIONS","createSchema","_jsxs","_Fragment","Portal","Popover","Root","open","Anchor","steps","tour","reduce","acc","index","name","Error","excludeFromStepCount","_meta","displayedStepCount","totalStepCount"],"mappings":";;;;;;;;;;;;AAcA;;AAEkG,2GAE5FA,KAAQ,GAAA;AACZC,IAAAA,kBAAAA,EAAoBC,WAAW,oBAAsBC,EAAAA,uBAAAA,CAAAA;AACrDC,IAAAA,cAAAA,EAAgBF,WAAW,gBAAkBG,EAAAA,mBAAAA,CAAAA;AAC7CC,IAAAA,SAAAA,EAAWJ,WAAW,WAAaK,EAAAA,cAAAA,CAAAA;IACnCC,WAAaN,EAAAA,UAAAA,CAAW,eAAe,EAAE;AAC3C;AAuBA,MAAMO,oBAAoB,CAAC,EAAEC,QAAQ,EAAE,GAAGC,KAA+B,EAAA,GAAA;AACvE,IAAA,MAAMC,QAAQC,aAAc,CAAA,gBAAA,EAAkB,CAACC,CAAAA,GAAMA,EAAEF,KAAK,CAAA;AAE5D,IAAA,IAAI,CAACA,KAAAA,CAAMG,OAAO,IAAIH,KAAMI,CAAAA,MAAM,IAAIC,OAAAA,CAAQC,GAAG,CAACC,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AAAA,KAAAA;AAAOoB,wBAAAA;AAAS,qBAAA;;;;;AAIzC,CAAA;AAaO,SAAS9B,UAAAA,CACdwB,QAAgB,EAChB6C,KAAQ,EAAA;AAMR,IAAA,MAAMC,OAAOD,KAAME,CAAAA,MAAM,CACvB,CAACC,KAAK/C,IAAMgD,EAAAA,KAAAA,GAAAA;QACV,MAAMC,IAAAA,GAAOjD,KAAKiD,IAAI;AAEtB,QAAA,IAAIA,QAAQF,GAAK,EAAA;YACf,MAAMG,KAAAA,CAAM,CAAC,UAAU,EAAEnD,QAAAA,CAAS,YAAY,EAAEC,IAAKiD,CAAAA,IAAI,CAAC,4BAA4B,CAAC,CAAA;AACzF;AAECF,QAAAA,GAAkB,CAACE,IAAK,CAAA,GAAG,CAAC,EAAElE,QAAQ,EAAiC,GAAA;AACtE,YAAA,qBACEU,GAACX,CAAAA,iBAAAA,EAAAA;gBACCiB,QAAUA,EAAAA,QAAAA;gBACVC,IAAMgD,EAAAA,KAAAA;AACNlD,gBAAAA,OAAAA,EAASE,KAAKF,OAAO;AACrBG,gBAAAA,IAAAA,EAAMD,KAAKC,IAAI;AAEdlB,gBAAAA,QAAAA,EAAAA;;AAGP,SAAA;QAEA,IAAIiB,IAAAA,CAAKmD,oBAAoB,EAAE;;YAE7BJ,GAAIK,CAAAA,KAAK,CAACC,kBAAkB,EAAA;AAC9B;QAEA,OAAON,GAAAA;KAET,EAAA;QAAEK,KAAO,EAAA;AAAEE,YAAAA,cAAAA,EAAgBV,MAAMZ,MAAM;AAAEqB,YAAAA,kBAAAA,EAAoBT,MAAMZ;AAAO;AAAE,KAAA,CAAA;IAK9E,OAAOa,IAAAA;AACT;;;;"}
1
+ {"version":3,"file":"Tours.mjs","sources":["../../../../../../admin/src/components/GuidedTour/Tours.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, Popover, Portal } from '@strapi/design-system';\nimport { styled } from 'styled-components';\n\nimport { useGetGuidedTourMetaQuery } from '../../services/admin';\n\nimport { type State, type Action, useGuidedTour, ValidTourName, CompletedActions } from './Context';\nimport { apiTokensSteps } from './Steps/ApiTokensSteps';\nimport { contentManagerSteps } from './Steps/ContentManagerSteps';\nimport { contentTypeBuilderSteps } from './Steps/ContentTypeBuilderSteps';\nimport { type Step, createStepComponents } from './Steps/Step';\nimport { GUIDED_TOUR_REQUIRED_ACTIONS } from './utils/constants';\n\n/* -------------------------------------------------------------------------------------------------\n * Tours\n * -----------------------------------------------------------------------------------------------*/\n\nconst tours = {\n contentTypeBuilder: createTour('contentTypeBuilder', contentTypeBuilderSteps),\n contentManager: createTour('contentManager', contentManagerSteps),\n apiTokens: createTour('apiTokens', apiTokensSteps),\n strapiCloud: createTour('strapiCloud', []),\n} as const;\n\ntype Tours = typeof tours;\n\n/* -------------------------------------------------------------------------------------------------\n * GuidedTourTooltip\n * -----------------------------------------------------------------------------------------------*/\n\nexport type StepContentProps = {\n Step: Step;\n state: State;\n dispatch: React.Dispatch<Action>;\n};\ntype Content = (props: StepContentProps) => React.ReactNode;\n\ntype GuidedTourTooltipProps = {\n children: React.ReactNode;\n content: Content;\n tourName: ValidTourName;\n step: number;\n when?: (completedActions: CompletedActions) => boolean;\n};\n\nconst GuidedTourTooltip = ({ children, ...props }: GuidedTourTooltipProps) => {\n const state = useGuidedTour('TooltipWrapper', (s) => s.state);\n\n if (!state.enabled || state.hidden || process.env.NODE_ENV !== 'development') {\n return children;\n }\n\n return <GuidedTourTooltipImpl {...props}>{children}</GuidedTourTooltipImpl>;\n};\n\nconst GuidedTourOverlay = styled(Box)`\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(50, 50, 77, 0.2);\n z-index: 10;\n`;\n\nconst GuidedTourTooltipImpl = ({\n children,\n content,\n tourName,\n step,\n when,\n}: GuidedTourTooltipProps) => {\n const { data: guidedTourMeta } = useGetGuidedTourMetaQuery();\n const state = useGuidedTour('GuidedTourTooltip', (s) => s.state);\n const dispatch = useGuidedTour('GuidedTourTooltip', (s) => s.dispatch);\n\n const tourState = state.tours?.[tourName];\n const isCurrentStep = tourState?.currentStep === step;\n const isStepConditionMet = when ? when(state.completedActions) : true;\n const isPopoverOpen =\n guidedTourMeta?.data?.isFirstSuperAdminUser &&\n !tourState?.isCompleted &&\n isCurrentStep &&\n isStepConditionMet;\n\n // Lock the scroll\n React.useEffect(() => {\n if (!isPopoverOpen) return;\n\n const originalStyle = window.getComputedStyle(document.body).overflow;\n document.body.style.overflow = 'hidden';\n\n return () => {\n document.body.style.overflow = originalStyle;\n };\n }, [isPopoverOpen]);\n\n const Step = React.useMemo(() => createStepComponents(tourName), [tourName]);\n\n const hasApiSchema =\n Object.keys(guidedTourMeta?.data?.schemas ?? {}).filter((key) => key.startsWith('api::'))\n .length > 0;\n\n React.useEffect(() => {\n if (hasApiSchema) {\n /**\n * Fallback sync:\n *\n * When the user already has a schema (ie started project from template with seeded data),\n * allow them to proceed to the content manager tour.\n *\n * When the CTB fails to restart after saving a schema (as it often does)\n */\n dispatch({\n type: 'set_completed_actions',\n payload: [GUIDED_TOUR_REQUIRED_ACTIONS.contentTypeBuilder.createSchema],\n });\n }\n }, [dispatch, hasApiSchema, step, tourName]);\n\n // Safety check: if tours state is corrupted or missing, render without tooltip (after all hooks)\n if (!state.tours || !state.tours[tourName]) {\n return <>{children}</>;\n }\n\n return (\n <>\n {isPopoverOpen && (\n <Portal>\n <GuidedTourOverlay />\n </Portal>\n )}\n <Popover.Root open={isPopoverOpen}>\n <Popover.Anchor>{children}</Popover.Anchor>\n {content({ Step, state, dispatch })}\n </Popover.Root>\n </>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Tour factory\n * -----------------------------------------------------------------------------------------------*/\n\nexport type TourStep<P extends string> = {\n name: P;\n content: Content;\n when?: (completedActions: CompletedActions) => boolean;\n excludeFromStepCount?: boolean;\n};\n\nexport function createTour<const T extends ReadonlyArray<TourStep<string>>>(\n tourName: string,\n steps: T\n) {\n type Components = {\n [K in T[number]['name']]: React.ComponentType<{ children: React.ReactNode }>;\n };\n\n const tour = steps.reduce(\n (acc, step, index) => {\n const name = step.name as keyof Components;\n\n if (name in acc) {\n throw Error(`The tour: ${tourName} with step: ${step.name} has already been registered`);\n }\n\n (acc as Components)[name] = ({ children }: { children: React.ReactNode }) => {\n return (\n <GuidedTourTooltip\n tourName={tourName as ValidTourName}\n step={index}\n content={step.content}\n when={step.when}\n >\n {children}\n </GuidedTourTooltip>\n );\n };\n\n if (step.excludeFromStepCount) {\n // Subtract all steps registered to be excluded from the step count\n acc._meta.displayedStepCount--;\n }\n\n return acc;\n },\n { _meta: { totalStepCount: steps.length, displayedStepCount: steps.length } } as Components & {\n _meta: { totalStepCount: number; displayedStepCount: number };\n }\n );\n\n return tour;\n}\n\nexport type { Content, Tours };\nexport { tours };\n"],"names":["tours","contentTypeBuilder","createTour","contentTypeBuilderSteps","contentManager","contentManagerSteps","apiTokens","apiTokensSteps","strapiCloud","GuidedTourTooltip","children","props","state","useGuidedTour","s","enabled","hidden","process","env","NODE_ENV","_jsx","GuidedTourTooltipImpl","GuidedTourOverlay","styled","Box","content","tourName","step","when","data","guidedTourMeta","useGetGuidedTourMetaQuery","dispatch","tourState","isCurrentStep","currentStep","isStepConditionMet","completedActions","isPopoverOpen","isFirstSuperAdminUser","isCompleted","React","useEffect","originalStyle","window","getComputedStyle","document","body","overflow","style","Step","useMemo","createStepComponents","hasApiSchema","Object","keys","schemas","filter","key","startsWith","length","type","payload","GUIDED_TOUR_REQUIRED_ACTIONS","createSchema","_Fragment","_jsxs","Portal","Popover","Root","open","Anchor","steps","tour","reduce","acc","index","name","Error","excludeFromStepCount","_meta","displayedStepCount","totalStepCount"],"mappings":";;;;;;;;;;;;AAcA;;AAEkG,2GAE5FA,KAAQ,GAAA;AACZC,IAAAA,kBAAAA,EAAoBC,WAAW,oBAAsBC,EAAAA,uBAAAA,CAAAA;AACrDC,IAAAA,cAAAA,EAAgBF,WAAW,gBAAkBG,EAAAA,mBAAAA,CAAAA;AAC7CC,IAAA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dlB,gBAAAA,QAAAA,EAAAA;;AAGP,SAAA;QAEA,IAAIiB,IAAAA,CAAKoD,oBAAoB,EAAE;;YAE7BJ,GAAIK,CAAAA,KAAK,CAACC,kBAAkB,EAAA;AAC9B;QAEA,OAAON,GAAAA;KAET,EAAA;QAAEK,KAAO,EAAA;AAAEE,YAAAA,cAAAA,EAAgBV,MAAMZ,MAAM;AAAEqB,YAAAA,kBAAAA,EAAoBT,MAAMZ;AAAO;AAAE,KAAA,CAAA;IAK9E,OAAOa,IAAAA;AACT;;;;"}
@@ -4,8 +4,28 @@ var immer = require('immer');
4
4
  var Tours = require('../Tours.js');
5
5
 
6
6
  /**
7
- * Migrates tours added or removed from the tours object
7
+ * Build default tour state (used when stored state is missing tours)
8
+ */ const getDefaultTours = ()=>Object.keys(Tours.tours).reduce((acc, tourName)=>{
9
+ acc[tourName] = {
10
+ currentStep: 0,
11
+ isCompleted: false,
12
+ tourType: undefined
13
+ };
14
+ return acc;
15
+ }, {});
16
+ /**
17
+ * Migrates tours added or removed from the tours object.
18
+ * Handles missing or corrupted stored state (e.g. old localStorage without `tours`).
8
19
  */ const migrateTours = (storedTourState)=>{
20
+ if (!storedTourState?.tours || typeof storedTourState.tours !== 'object') {
21
+ return {
22
+ ...storedTourState,
23
+ tours: getDefaultTours(),
24
+ enabled: storedTourState?.enabled ?? true,
25
+ completedActions: Array.isArray(storedTourState?.completedActions) ? storedTourState.completedActions : [],
26
+ hidden: storedTourState?.hidden ?? false
27
+ };
28
+ }
9
29
  const storedTourNames = Object.keys(storedTourState.tours);
10
30
  const currentTourNames = Object.keys(Tours.tours);
11
31
  return immer.produce(storedTourState, (draft)=>{
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.js","sources":["../../../../../../../admin/src/components/GuidedTour/utils/migrations.ts"],"sourcesContent":["import { produce } from 'immer';\n\nimport { tours } from '../Tours';\n\nimport type { State, ValidTourName } from '../Context';\n\n/**\n * Migrates tours added or removed from the tours object\n */\nconst migrateTours = (storedTourState: State) => {\n const storedTourNames = Object.keys(storedTourState.tours) as ValidTourName[];\n const currentTourNames = Object.keys(tours) as ValidTourName[];\n\n return produce(storedTourState, (draft) => {\n // Add new tours that don't exist in stored state\n currentTourNames.forEach((tourName) => {\n if (!storedTourNames.includes(tourName)) {\n draft.tours[tourName] = {\n currentStep: 0,\n isCompleted: false,\n tourType: undefined,\n };\n }\n });\n\n // Remove tours that no longer exist in current tours\n storedTourNames.forEach((tourName) => {\n if (!currentTourNames.includes(tourName)) {\n delete draft.tours[tourName];\n }\n });\n });\n};\n\nexport { migrateTours };\n"],"names":["migrateTours","storedTourState","storedTourNames","Object","keys","tours","currentTourNames","produce","draft","forEach","tourName","includes","currentStep","isCompleted","tourType","undefined"],"mappings":";;;;;AAMA;;IAGA,MAAMA,eAAe,CAACC,eAAAA,GAAAA;AACpB,IAAA,MAAMC,eAAkBC,GAAAA,MAAAA,CAAOC,IAAI,CAACH,gBAAgBI,KAAK,CAAA;IACzD,MAAMC,gBAAAA,GAAmBH,MAAOC,CAAAA,IAAI,CAACC,WAAAA,CAAAA;IAErC,OAAOE,aAAAA,CAAQN,iBAAiB,CAACO,KAAAA,GAAAA;;QAE/BF,gBAAiBG,CAAAA,OAAO,CAAC,CAACC,QAAAA,GAAAA;AACxB,YAAA,IAAI,CAACR,eAAAA,CAAgBS,QAAQ,CAACD,QAAW,CAAA,EAAA;gBACvCF,KAAMH,CAAAA,KAAK,CAACK,QAAAA,CAAS,GAAG;oBACtBE,WAAa,EAAA,CAAA;oBACbC,WAAa,EAAA,KAAA;oBACbC,QAAUC,EAAAA;AACZ,iBAAA;AACF;AACF,SAAA,CAAA;;QAGAb,eAAgBO,CAAAA,OAAO,CAAC,CAACC,QAAAA,GAAAA;AACvB,YAAA,IAAI,CAACJ,gBAAAA,CAAiBK,QAAQ,CAACD,QAAW,CAAA,EAAA;gBACxC,OAAOF,KAAAA,CAAMH,KAAK,CAACK,QAAS,CAAA;AAC9B;AACF,SAAA,CAAA;AACF,KAAA,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"migrations.js","sources":["../../../../../../../admin/src/components/GuidedTour/utils/migrations.ts"],"sourcesContent":["import { produce } from 'immer';\n\nimport { tours } from '../Tours';\n\nimport type { State, ValidTourName } from '../Context';\n\n/**\n * Build default tour state (used when stored state is missing tours)\n */\nconst getDefaultTours = () =>\n (Object.keys(tours) as ValidTourName[]).reduce(\n (acc, tourName) => {\n acc[tourName] = { currentStep: 0, isCompleted: false, tourType: undefined };\n return acc;\n },\n {} as State['tours']\n );\n\n/**\n * Migrates tours added or removed from the tours object.\n * Handles missing or corrupted stored state (e.g. old localStorage without `tours`).\n */\nconst migrateTours = (storedTourState: State) => {\n if (!storedTourState?.tours || typeof storedTourState.tours !== 'object') {\n return {\n ...storedTourState,\n tours: getDefaultTours(),\n enabled: storedTourState?.enabled ?? true,\n completedActions: Array.isArray(storedTourState?.completedActions)\n ? storedTourState.completedActions\n : [],\n hidden: storedTourState?.hidden ?? false,\n } as State;\n }\n\n const storedTourNames = Object.keys(storedTourState.tours) as ValidTourName[];\n const currentTourNames = Object.keys(tours) as ValidTourName[];\n\n return produce(storedTourState, (draft) => {\n // Add new tours that don't exist in stored state\n currentTourNames.forEach((tourName) => {\n if (!storedTourNames.includes(tourName)) {\n draft.tours[tourName] = {\n currentStep: 0,\n isCompleted: false,\n tourType: undefined,\n };\n }\n });\n\n // Remove tours that no longer exist in current tours\n storedTourNames.forEach((tourName) => {\n if (!currentTourNames.includes(tourName)) {\n delete draft.tours[tourName];\n }\n });\n });\n};\n\nexport { migrateTours };\n"],"names":["getDefaultTours","Object","keys","tours","reduce","acc","tourName","currentStep","isCompleted","tourType","undefined","migrateTours","storedTourState","enabled","completedActions","Array","isArray","hidden","storedTourNames","currentTourNames","produce","draft","forEach","includes"],"mappings":";;;;;AAMA;;IAGA,MAAMA,eAAkB,GAAA,IACtB,MAACC,CAAOC,IAAI,CAACC,WAA2BC,CAAAA,CAAAA,MAAM,CAC5C,CAACC,GAAKC,EA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BAAAA,CAAiBI,QAAQ,CAACjB,QAAW,CAAA,EAAA;gBACxC,OAAOe,KAAAA,CAAMlB,KAAK,CAACG,QAAS,CAAA;AAC9B;AACF,SAAA,CAAA;AACF,KAAA,CAAA;AACF;;;;"}
@@ -2,8 +2,28 @@ import { produce } from 'immer';
2
2
  import { tours } from '../Tours.mjs';
3
3
 
4
4
  /**
5
- * Migrates tours added or removed from the tours object
5
+ * Build default tour state (used when stored state is missing tours)
6
+ */ const getDefaultTours = ()=>Object.keys(tours).reduce((acc, tourName)=>{
7
+ acc[tourName] = {
8
+ currentStep: 0,
9
+ isCompleted: false,
10
+ tourType: undefined
11
+ };
12
+ return acc;
13
+ }, {});
14
+ /**
15
+ * Migrates tours added or removed from the tours object.
16
+ * Handles missing or corrupted stored state (e.g. old localStorage without `tours`).
6
17
  */ const migrateTours = (storedTourState)=>{
18
+ if (!storedTourState?.tours || typeof storedTourState.tours !== 'object') {
19
+ return {
20
+ ...storedTourState,
21
+ tours: getDefaultTours(),
22
+ enabled: storedTourState?.enabled ?? true,
23
+ completedActions: Array.isArray(storedTourState?.completedActions) ? storedTourState.completedActions : [],
24
+ hidden: storedTourState?.hidden ?? false
25
+ };
26
+ }
7
27
  const storedTourNames = Object.keys(storedTourState.tours);
8
28
  const currentTourNames = Object.keys(tours);
9
29
  return produce(storedTourState, (draft)=>{
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.mjs","sources":["../../../../../../../admin/src/components/GuidedTour/utils/migrations.ts"],"sourcesContent":["import { produce } from 'immer';\n\nimport { tours } from '../Tours';\n\nimport type { State, ValidTourName } from '../Context';\n\n/**\n * Migrates tours added or removed from the tours object\n */\nconst migrateTours = (storedTourState: State) => {\n const storedTourNames = Object.keys(storedTourState.tours) as ValidTourName[];\n const currentTourNames = Object.keys(tours) as ValidTourName[];\n\n return produce(storedTourState, (draft) => {\n // Add new tours that don't exist in stored state\n currentTourNames.forEach((tourName) => {\n if (!storedTourNames.includes(tourName)) {\n draft.tours[tourName] = {\n currentStep: 0,\n isCompleted: false,\n tourType: undefined,\n };\n }\n });\n\n // Remove tours that no longer exist in current tours\n storedTourNames.forEach((tourName) => {\n if (!currentTourNames.includes(tourName)) {\n delete draft.tours[tourName];\n }\n });\n });\n};\n\nexport { migrateTours };\n"],"names":["migrateTours","storedTourState","storedTourNames","Object","keys","tours","currentTourNames","produce","draft","forEach","tourName","includes","currentStep","isCompleted","tourType","undefined"],"mappings":";;;AAMA;;IAGA,MAAMA,eAAe,CAACC,eAAAA,GAAAA;AACpB,IAAA,MAAMC,eAAkBC,GAAAA,MAAAA,CAAOC,IAAI,CAACH,gBAAgBI,KAAK,CAAA;IACzD,MAAMC,gBAAAA,GAAmBH,MAAOC,CAAAA,IAAI,CAACC,KAAAA,CAAAA;IAErC,OAAOE,OAAAA,CAAQN,iBAAiB,CAACO,KAAAA,GAAAA;;QAE/BF,gBAAiBG,CAAAA,OAAO,CAAC,CAACC,QAAAA,GAAAA;AACxB,YAAA,IAAI,CAACR,eAAAA,CAAgBS,QAAQ,CAACD,QAAW,CAAA,EAAA;gBACvCF,KAAMH,CAAAA,KAAK,CAACK,QAAAA,CAAS,GAAG;oBACtBE,WAAa,EAAA,CAAA;oBACbC,WAAa,EAAA,KAAA;oBACbC,QAAUC,EAAAA;AACZ,iBAAA;AACF;AACF,SAAA,CAAA;;QAGAb,eAAgBO,CAAAA,OAAO,CAAC,CAACC,QAAAA,GAAAA;AACvB,YAAA,IAAI,CAACJ,gBAAAA,CAAiBK,QAAQ,CAACD,QAAW,CAAA,EAAA;gBACxC,OAAOF,KAAAA,CAAMH,KAAK,CAACK,QAAS,CAAA;AAC9B;AACF,SAAA,CAAA;AACF,KAAA,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"migrations.mjs","sources":["../../../../../../../admin/src/components/GuidedTour/utils/migrations.ts"],"sourcesContent":["import { produce } from 'immer';\n\nimport { tours } from '../Tours';\n\nimport type { State, ValidTourName } from '../Context';\n\n/**\n * Build default tour state (used when stored state is missing tours)\n */\nconst getDefaultTours = () =>\n (Object.keys(tours) as ValidTourName[]).reduce(\n (acc, tourName) => {\n acc[tourName] = { currentStep: 0, isCompleted: false, tourType: undefined };\n return acc;\n },\n {} as State['tours']\n );\n\n/**\n * Migrates tours added or removed from the tours object.\n * Handles missing or corrupted stored state (e.g. old localStorage without `tours`).\n */\nconst migrateTours = (storedTourState: State) => {\n if (!storedTourState?.tours || typeof storedTourState.tours !== 'object') {\n return {\n ...storedTourState,\n tours: getDefaultTours(),\n enabled: storedTourState?.enabled ?? true,\n completedActions: Array.isArray(storedTourState?.completedActions)\n ? storedTourState.completedActions\n : [],\n hidden: storedTourState?.hidden ?? false,\n } as State;\n }\n\n const storedTourNames = Object.keys(storedTourState.tours) as ValidTourName[];\n const currentTourNames = Object.keys(tours) as ValidTourName[];\n\n return produce(storedTourState, (draft) => {\n // Add new tours that don't exist in stored state\n currentTourNames.forEach((tourName) => {\n if (!storedTourNames.includes(tourName)) {\n draft.tours[tourName] = {\n currentStep: 0,\n isCompleted: false,\n tourType: undefined,\n };\n }\n });\n\n // Remove tours that no longer exist in current tours\n storedTourNames.forEach((tourName) => {\n if (!currentTourNames.includes(tourName)) {\n delete draft.tours[tourName];\n }\n });\n });\n};\n\nexport { migrateTours };\n"],"names":["getDefaultTours","Object","keys","tours","reduce","acc","tourName","currentStep","isCompleted","tourType","undefined","migrateTours","storedTourState","enabled","completedActions","Array","isArray","hidden","storedTourNames","currentTourNames","produce","draft","forEach","includes"],"mappings":";;;AAMA;;IAGA,MAAMA,eAAkB,GAAA,IACtB,MAACC,CAAOC,IAAI,CAACC,KAA2BC,CAAAA,CAAAA,MAAM,CAC5C,CAACC,GAAKC,EAAAA,QAAAA,GAAAA;QACJD,GAAG,CAACC,SAAS,GAAG;YAAEC,WAAa,EAAA,CAAA;YAAGC,WAAa,EAAA,KAAA;YAAOC,QAAUC,EAAAA;AAAU,SAAA;QAC1E,OAAOL,GAAAA;AACT,KAAA,EACA,EAAC,CAAA;AAGL;;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