@ubnt/store.core 9.38.0-alpha.7 → 9.38.0-alpha.8

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 (89) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/lib/assets/ai-dome.jpg +0 -0
  3. package/lib/assets/ai-dome2.jpg +0 -0
  4. package/lib/assets/ai-dslr.jpg +0 -0
  5. package/lib/assets/ai-dslr2.jpg +0 -0
  6. package/lib/assets/building-bridge.jpg +0 -0
  7. package/lib/assets/building-bridge2.jpg +0 -0
  8. package/lib/assets/icons/wizard/plus.svg.js +1 -1
  9. package/lib/assets/icons/wizard/plus.svg.mjs +2 -2
  10. package/lib/assets/interior-design.svg +2 -2
  11. package/lib/assets/interior-design2.svg +2 -2
  12. package/lib/assets/plus.svg +4 -22
  13. package/lib/assets/plus2.svg +22 -4
  14. package/lib/assets/udmPro.jpg +0 -0
  15. package/lib/assets/udmPro2.jpg +0 -0
  16. package/lib/assets/udmProMax.jpg +0 -0
  17. package/lib/assets/udmProMax2.jpg +0 -0
  18. package/lib/assets/udmProSpecial.jpg +0 -0
  19. package/lib/assets/udmProSpecial2.jpg +0 -0
  20. package/lib/components/FeaturesSection_deprecated/AllFeaturesButton/AllFeaturesButton.js +1 -1
  21. package/lib/components/FeaturesSection_deprecated/AllFeaturesButton/AllFeaturesButton.mjs +1 -1
  22. package/lib/components/FeaturesSection_deprecated/assets/plus.svg.js +1 -1
  23. package/lib/components/FeaturesSection_deprecated/assets/plus.svg.mjs +2 -2
  24. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.js +2 -2
  25. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.js.map +1 -1
  26. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.mjs +2 -2
  27. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.mjs.map +1 -1
  28. package/lib/components/MicrositeHeader/components/HeaderContent/_components/NavigationItem/NavigationItem.js.map +1 -1
  29. package/lib/components/MicrositeHeader/components/HeaderContent/_components/NavigationItem/NavigationItem.mjs.map +1 -1
  30. package/lib/components/MicrositeHeader/components/HeaderContent/_components/SubNavigation/SubNavigation.js.map +1 -1
  31. package/lib/components/MicrositeHeader/components/HeaderContent/_components/SubNavigation/SubNavigation.mjs.map +1 -1
  32. package/lib/components/ProductWizard/ProductWizard.js +1 -1
  33. package/lib/components/ProductWizard/ProductWizard.mjs +1 -1
  34. package/lib/components/QuantityInput/QuantityInput.js +1 -1
  35. package/lib/components/QuantityInput/QuantityInput.mjs +1 -1
  36. package/lib/constants/modelCompareData/assets/BuildingBridge/building-bridge.jpg.js +1 -1
  37. package/lib/constants/modelCompareData/assets/BuildingBridge/building-bridge.jpg.mjs +2 -2
  38. package/lib/constants/modelCompareData/assets/Bullet/ai-dslr.jpg.js +1 -1
  39. package/lib/constants/modelCompareData/assets/Bullet/ai-dslr.jpg.mjs +2 -2
  40. package/lib/constants/modelCompareData/assets/Consoles/bigCompare/udmPro.jpg.js +5 -5
  41. package/lib/constants/modelCompareData/assets/Consoles/bigCompare/udmPro.jpg.mjs +2 -2
  42. package/lib/constants/modelCompareData/assets/Consoles/bigCompare/udmProMax.jpg.js +5 -5
  43. package/lib/constants/modelCompareData/assets/Consoles/bigCompare/udmProMax.jpg.mjs +2 -2
  44. package/lib/constants/modelCompareData/assets/Consoles/bigCompare/udmProSpecial.jpg.js +5 -5
  45. package/lib/constants/modelCompareData/assets/Consoles/bigCompare/udmProSpecial.jpg.mjs +2 -2
  46. package/lib/constants/modelCompareData/assets/Consoles/udmPro.jpg.js +1 -1
  47. package/lib/constants/modelCompareData/assets/Consoles/udmPro.jpg.mjs +2 -2
  48. package/lib/constants/modelCompareData/assets/Consoles/udmProMax.jpg.js +1 -1
  49. package/lib/constants/modelCompareData/assets/Consoles/udmProMax.jpg.mjs +2 -2
  50. package/lib/constants/modelCompareData/assets/Consoles/udmProSpecial.jpg.js +1 -1
  51. package/lib/constants/modelCompareData/assets/Consoles/udmProSpecial.jpg.mjs +2 -2
  52. package/lib/constants/modelCompareData/assets/DomeTurret/ai-dome.jpg.js +1 -1
  53. package/lib/constants/modelCompareData/assets/DomeTurret/ai-dome.jpg.mjs +2 -2
  54. package/lib/constants/modelCompareData/assets/interior-design.svg.js +1 -1
  55. package/lib/constants/modelCompareData/assets/interior-design.svg.mjs +2 -2
  56. package/lib/constants/modelCompareData/assets/product-list-assets/cameras/bullet/ai-dslr.jpg.js +1 -1
  57. package/lib/constants/modelCompareData/assets/product-list-assets/cameras/bullet/ai-dslr.jpg.mjs +2 -2
  58. package/lib/constants/modelCompareData/assets/product-list-assets/cameras/dome-and-turret/ai-dome.jpg.js +1 -1
  59. package/lib/constants/modelCompareData/assets/product-list-assets/cameras/dome-and-turret/ai-dome.jpg.mjs +2 -2
  60. package/lib/constants/modelCompareData/assets/product-list-assets/interior-design.svg.js +1 -1
  61. package/lib/constants/modelCompareData/assets/product-list-assets/interior-design.svg.mjs +2 -2
  62. package/lib/constants/modelCompareData/assets/product-list-assets/wifi/building-bridge/building-bridge.jpg.js +1 -1
  63. package/lib/constants/modelCompareData/assets/product-list-assets/wifi/building-bridge/building-bridge.jpg.mjs +2 -2
  64. package/lib/constants/modelCompareData/data/CloudGateways.js +9 -9
  65. package/lib/constants/modelCompareData/data/CloudGateways.mjs +6 -6
  66. package/lib/constants/modelCompareData/data/product-groups/cameraSecurity/InteriorDesign.js +1 -1
  67. package/lib/constants/modelCompareData/data/product-groups/cameraSecurity/InteriorDesign.mjs +1 -1
  68. package/lib/constants/modelCompareData/data/product-list-groups/interiorDesign.js +1 -1
  69. package/lib/constants/modelCompareData/data/product-list-groups/interiorDesign.mjs +1 -1
  70. package/lib/constants/modelCompareData/data/products/aiDome.js +2 -2
  71. package/lib/constants/modelCompareData/data/products/aiDome.mjs +2 -2
  72. package/lib/constants/modelCompareData/data/products/aiDslr.js +2 -2
  73. package/lib/constants/modelCompareData/data/products/aiDslr.mjs +2 -2
  74. package/lib/constants/modelCompareData/data/products/buildingBridge.js +2 -2
  75. package/lib/constants/modelCompareData/data/products/buildingBridge.mjs +2 -2
  76. package/lib/constants/modelCompareData/data/products/udmPro.js +1 -1
  77. package/lib/constants/modelCompareData/data/products/udmPro.mjs +1 -1
  78. package/lib/constants/modelCompareData/data/products/udmProMax.js +1 -1
  79. package/lib/constants/modelCompareData/data/products/udmProMax.mjs +1 -1
  80. package/lib/constants/modelCompareData/data/products/udmProSpecial.js +1 -1
  81. package/lib/constants/modelCompareData/data/products/udmProSpecial.mjs +1 -1
  82. package/lib/contexts/MicrositeMenuContext/context.js +5 -9
  83. package/lib/contexts/MicrositeMenuContext/context.js.map +1 -1
  84. package/lib/contexts/MicrositeMenuContext/context.mjs +5 -9
  85. package/lib/contexts/MicrositeMenuContext/context.mjs.map +1 -1
  86. package/lib/contexts/MicrositeMenuContext/types.d.ts +3 -3
  87. package/lib/contexts/MicrositeMenuContext/types.js.map +1 -1
  88. package/lib/contexts/MicrositeMenuContext/types.mjs.map +1 -1
  89. package/package.json +1 -1
@@ -6,7 +6,6 @@ require('../MenuContext/index.js');
6
6
  var mapping = require('../MenuContext/mapping.js');
7
7
  var utils = require('../MenuContext/utils.js');
8
8
  var mapping$1 = require('./mapping.js');
9
- var translations = require('./translations.js');
10
9
  var context = require('../MenuContext/context.js');
11
10
  "use strict";
12
11
  const MicrositeMenuContext = React.createContext(null);
@@ -21,9 +20,6 @@ const MicrositeMenuContextProvider = ({
21
20
  createSiteUrl
22
21
  } = context.useMenu();
23
22
  const isUIContext = React.useMemo(() => context$1 === mapping.SiteId.Ui, [context$1]);
24
- const {
25
- formatMessage
26
- } = translations.useMicrositeMenuTranslations(language);
27
23
  const isSiteUrlActive = React.useCallback(url => {
28
24
  return (
29
25
  // Do not check for active items if not in UI context
@@ -50,16 +46,16 @@ const MicrositeMenuContextProvider = ({
50
46
  }
51
47
  return {
52
48
  ...item,
53
- label: formatMessage(item.label),
54
- collapsedLabel: item.collapsedLabel ? formatMessage(item.collapsedLabel) : void 0,
55
- description: item.description ? formatMessage(item.description) : void 0,
56
- actionLabel: item.actionLabel ? formatMessage(item.actionLabel) : void 0,
49
+ label: item.label,
50
+ collapsedLabel: item?.collapsedLabel,
51
+ description: item?.description,
52
+ actionLabel: item?.actionLabel,
57
53
  active: !!active,
58
54
  possible: !!possible,
59
55
  items: childItems,
60
56
  url
61
57
  };
62
- }, [createSiteUrl, currentPathname, formatMessage, isSiteUrlActive]);
58
+ }, [createSiteUrl, currentPathname, isSiteUrlActive]);
63
59
  const menu = React.useMemo(() => {
64
60
  return parseMenuItem(mapping$1.MICROSITE_HEADER_MAPPING);
65
61
  }, [parseMenuItem]);
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sources":["../../../src/contexts/MicrositeMenuContext/context.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nimport type { GlobalStoreId, Language } from \"../../types\";\nimport { useMenu } from \"../MenuContext\";\nimport { SiteId } from \"../MenuContext/mapping\";\nimport type { SiteUrl } from \"../MenuContext/mapping\";\nimport type { GlobalSiteConfig } from \"../MenuContext/types\";\nimport { isPartOfUrlPathname, isUrlPathname } from \"../MenuContext/utils\";\nimport { DEFAULT_LANGUAGE, MICROSITE_HEADER_MAPPING } from \"./mapping\";\nimport { useMicrositeMenuTranslations } from \"./translations\";\nimport type {\n MicrositeHeaderItem,\n MicrositeMenuContextValue,\n ParsedMicrositeHeaderItem,\n} from \"./types\";\n\nexport const MicrositeMenuContext =\n createContext<MicrositeMenuContextValue | null>(null);\n\nexport const MicrositeMenuContextProvider = ({\n context,\n pathname: currentPathname = \"/\",\n hash: currentHash = \"\",\n children,\n language = DEFAULT_LANGUAGE,\n}: {\n /**\n * Set how the navigation behave as - ui.com/creators.ui.com/...\n */\n context: SiteId;\n /**\n * (optionally) Hints which language currently us currently in use\n */\n language?: Language;\n /**\n * Store context for determining which path to use\n * Will fall-back to US if not found\n * @example GlobalStoreId.Ca\n */\n storeId?: GlobalStoreId;\n /**\n * Pathname of the current URL\n * Used as a prop to be in sync with e.g. Next.js\n */\n pathname?: string;\n /**\n * Hash of the current URL (the part of the URL that starts with #)\n */\n hash?: string;\n /**\n * Global Site Config that define available urls/languages/regions enabled for globally\n */\n globalSiteConfig: GlobalSiteConfig;\n\n children: React.ReactNode;\n}) => {\n // TODO: Recouple from MenuContext\n const { createSiteUrl } = useMenu();\n const isUIContext = useMemo(() => context === SiteId.Ui, [context]);\n\n const { formatMessage } = useMicrositeMenuTranslations(language);\n\n // #############################################################################\n // Parsing\n // #############################################################################\n /**\n * Detects if a menu item is active based on the current pathname\n */\n const isSiteUrlActive = useCallback(\n (url: SiteUrl): boolean => {\n return (\n // Do not check for active items if not in UI context\n isUIContext &&\n // Check if the siteId matches the current context\n url[0] === context &&\n // Check if the pathname matches the current pathname\n isUrlPathname(currentPathname, url[1]) &&\n // If there's a hash in the SiteUrl, it should match the current hash for the item to be active\n (!url[3] || currentHash.replace(/^#/, \"\") === url[3])\n );\n },\n [context, currentHash, currentPathname, isUIContext],\n );\n\n /**\n * Parse a menu item and its children recursively\n */\n const parseMenuItem = useCallback(\n (item: MicrositeHeaderItem): ParsedMicrositeHeaderItem | null => {\n // Parse child items\n const childItems = item?.items\n ?.map(parseMenuItem)\n .filter((item): item is ParsedMicrositeHeaderItem => !!item);\n\n // Determine if menu item is active\n const active =\n // If any child is active, the parent is active\n childItems?.some((item) => item.active) ||\n childItems?.some((item) => item.possible) ||\n // If the item has a URL, check if it's active\n (item.url && typeof item.url !== \"string\" && isSiteUrlActive(item.url)); //\n\n // Get the final URL\n const url = item.url\n ? typeof item.url === \"string\"\n ? item.url\n : createSiteUrl(item.url)\n : childItems?.[0]?.url;\n\n const possible =\n item.url &&\n typeof item.url !== \"string\" &&\n isPartOfUrlPathname(currentPathname, item.url[1]);\n\n if (!url) {\n return null;\n }\n\n return {\n ...item,\n label: formatMessage(item.label),\n collapsedLabel: item.collapsedLabel\n ? formatMessage(item.collapsedLabel)\n : undefined,\n description: item.description\n ? formatMessage(item.description)\n : undefined,\n actionLabel: item.actionLabel\n ? formatMessage(item.actionLabel)\n : undefined,\n active: !!active,\n possible: !!possible,\n items: childItems,\n url,\n };\n },\n [createSiteUrl, currentPathname, formatMessage, isSiteUrlActive],\n );\n\n const menu = useMemo((): ParsedMicrositeHeaderItem => {\n return parseMenuItem(MICROSITE_HEADER_MAPPING)!;\n }, [parseMenuItem]);\n\n // #############################################################################\n // Active modal\n // #############################################################################\n const [{ activeModal, prevActiveModal }, _setActiveModal] = useState<{\n activeModal: MicrositeMenuContextValue[\"activeModal\"];\n prevActiveModal: MicrositeMenuContextValue[\"prevActiveModal\"];\n }>({\n activeModal: null,\n prevActiveModal: null,\n });\n\n const setActiveModal = useCallback<\n MicrositeMenuContextValue[\"setActiveModal\"]\n >(\n (id) => {\n _setActiveModal({\n activeModal: id,\n prevActiveModal: activeModal,\n });\n },\n [activeModal],\n );\n\n // #############################################################################\n // Render\n // #############################################################################\n return (\n <MicrositeMenuContext.Provider\n value={{\n menu,\n language,\n\n activeModal,\n prevActiveModal,\n setActiveModal,\n }}\n >\n {children}\n </MicrositeMenuContext.Provider>\n );\n};\n\nexport function useMicrositeMenu(): MicrositeMenuContextValue {\n const context = useContext(MicrositeMenuContext);\n if (context === null) {\n throw new Error(\n \"useMicrositeMenu must be used within a MicrositeMenuContextProvider\",\n );\n }\n return context;\n}\n"],"names":["MicrositeMenuContext","createContext","MicrositeMenuContextProvider","context","pathname","currentPathname","hash","currentHash","children","language","DEFAULT_LANGUAGE","createSiteUrl","useMenu","isUIContext","useMemo","SiteId","Ui","formatMessage","useMicrositeMenuTranslations","isSiteUrlActive","useCallback","url","isUrlPathname","replace","parseMenuItem","item","childItems","items","map","filter","active","some","possible","isPartOfUrlPathname","label","collapsedLabel","description","actionLabel","menu","MICROSITE_HEADER_MAPPING","activeModal","prevActiveModal","_setActiveModal","useState","setActiveModal","id","jsx","Provider","value","useMicrositeMenu","useContext","Error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e,CAAA,CACjE;EAEM,MAAAmB,IAAA,GAAOxB,KAAAA,CAAAA,QAAQ,MAAiC;IACpD,OAAOU,cAAce,SAAAA,CAAAA,wBAAwB,CAAA;EAAA,CAC/C,EAAG,CAACf,aAAa,CAAC,CAAA;EAKlB,MAAM,CAAC;IAAEgB,WAAA;IAAaC;EAAmB,CAAA,EAAAC,eAAe,IAAIC,KAAAA,CAAAA,QAGzD,CAAA;IACDH,WAAa,EAAA,IAAA;IACbC,eAAiB,EAAA;EAAA,CAClB,CAAA;EAED,MAAMG,cAAiB,GAAAxB,KAAA,CAAAA,WAAA,CAGpByB,EAAO,IAAA;IACUH,eAAA,CAAA;MACdF,WAAa,EAAAK,EAAA;MACbJ,eAAiB,EAAAD;IAAA,CAClB,CAAA;EACH,CAAA,EACA,CAACA,WAAW,CAAA,CACd;EAME,sBAAAM,UAAA,CAAAA,GAAA,CAAC9C,oBAAqB,CAAA+C,QAAA,EAArB;IACCC,KAAO,EAAA;MACLV,IAAA;MACA7B,QAAA;MAEA+B,WAAA;MACAC,eAAA;MACAG;IACF,CAAA;IAECpC;EAAA,CAAA,CACH;AAEJ,CAAA;AAEO,SAASyC,gBAA8CA,CAAA,EAAA;EACtD,MAAA9C,OAAA,GAAU+C,iBAAWlD,oBAAoB,CAAA;EAC/C,IAAIG,YAAY,IAAM,EAAA;IACpB,MAAM,IAAIgD,KAAA,CACR,qEAAA,CACF;EACF;EACO,OAAAhD,OAAA;AACT;;;"}
1
+ {"version":3,"file":"context.js","sources":["../../../src/contexts/MicrositeMenuContext/context.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nimport type { GlobalStoreId, Language } from \"../../types\";\nimport { useMenu } from \"../MenuContext\";\nimport { SiteId } from \"../MenuContext/mapping\";\nimport type { SiteUrl } from \"../MenuContext/mapping\";\nimport type { GlobalSiteConfig } from \"../MenuContext/types\";\nimport { isPartOfUrlPathname, isUrlPathname } from \"../MenuContext/utils\";\nimport { DEFAULT_LANGUAGE, MICROSITE_HEADER_MAPPING } from \"./mapping\";\nimport type {\n MicrositeHeaderItem,\n MicrositeMenuContextValue,\n ParsedMicrositeHeaderItem,\n} from \"./types\";\n\nexport const MicrositeMenuContext =\n createContext<MicrositeMenuContextValue | null>(null);\n\nexport const MicrositeMenuContextProvider = ({\n context,\n pathname: currentPathname = \"/\",\n hash: currentHash = \"\",\n children,\n language = DEFAULT_LANGUAGE,\n}: {\n /**\n * Set how the navigation behave as - ui.com/creators.ui.com/...\n */\n context: SiteId;\n /**\n * (optionally) Hints which language currently us currently in use\n */\n language?: Language;\n /**\n * Store context for determining which path to use\n * Will fall-back to US if not found\n * @example GlobalStoreId.Ca\n */\n storeId?: GlobalStoreId;\n /**\n * Pathname of the current URL\n * Used as a prop to be in sync with e.g. Next.js\n */\n pathname?: string;\n /**\n * Hash of the current URL (the part of the URL that starts with #)\n */\n hash?: string;\n /**\n * Global Site Config that define available urls/languages/regions enabled for globally\n */\n globalSiteConfig: GlobalSiteConfig;\n\n children: React.ReactNode;\n}) => {\n // TODO: Recouple from MenuContext\n const { createSiteUrl } = useMenu();\n const isUIContext = useMemo(() => context === SiteId.Ui, [context]);\n\n // #############################################################################\n // Parsing\n // #############################################################################\n /**\n * Detects if a menu item is active based on the current pathname\n */\n const isSiteUrlActive = useCallback(\n (url: SiteUrl): boolean => {\n return (\n // Do not check for active items if not in UI context\n isUIContext &&\n // Check if the siteId matches the current context\n url[0] === context &&\n // Check if the pathname matches the current pathname\n isUrlPathname(currentPathname, url[1]) &&\n // If there's a hash in the SiteUrl, it should match the current hash for the item to be active\n (!url[3] || currentHash.replace(/^#/, \"\") === url[3])\n );\n },\n [context, currentHash, currentPathname, isUIContext],\n );\n\n /**\n * Parse a menu item and its children recursively\n */\n const parseMenuItem = useCallback(\n (item: MicrositeHeaderItem): ParsedMicrositeHeaderItem | null => {\n // Parse child items\n const childItems = item?.items\n ?.map(parseMenuItem)\n .filter((item): item is ParsedMicrositeHeaderItem => !!item);\n\n // Determine if menu item is active\n const active =\n // If any child is active, the parent is active\n childItems?.some((item) => item.active) ||\n childItems?.some((item) => item.possible) ||\n // If the item has a URL, check if it's active\n (item.url && typeof item.url !== \"string\" && isSiteUrlActive(item.url)); //\n\n // Get the final URL\n const url = item.url\n ? typeof item.url === \"string\"\n ? item.url\n : createSiteUrl(item.url)\n : childItems?.[0]?.url;\n\n const possible =\n item.url &&\n typeof item.url !== \"string\" &&\n isPartOfUrlPathname(currentPathname, item.url[1]);\n\n if (!url) {\n return null;\n }\n\n return {\n ...item,\n label: item.label,\n collapsedLabel: item?.collapsedLabel,\n description: item?.description,\n actionLabel: item?.actionLabel,\n active: !!active,\n possible: !!possible,\n items: childItems,\n url,\n };\n },\n [createSiteUrl, currentPathname, isSiteUrlActive],\n );\n\n const menu = useMemo((): ParsedMicrositeHeaderItem => {\n return parseMenuItem(MICROSITE_HEADER_MAPPING)!;\n }, [parseMenuItem]);\n\n // #############################################################################\n // Active modal\n // #############################################################################\n const [{ activeModal, prevActiveModal }, _setActiveModal] = useState<{\n activeModal: MicrositeMenuContextValue[\"activeModal\"];\n prevActiveModal: MicrositeMenuContextValue[\"prevActiveModal\"];\n }>({\n activeModal: null,\n prevActiveModal: null,\n });\n\n const setActiveModal = useCallback<\n MicrositeMenuContextValue[\"setActiveModal\"]\n >(\n (id) => {\n _setActiveModal({\n activeModal: id,\n prevActiveModal: activeModal,\n });\n },\n [activeModal],\n );\n\n // #############################################################################\n // Render\n // #############################################################################\n return (\n <MicrositeMenuContext.Provider\n value={{\n menu,\n language,\n\n activeModal,\n prevActiveModal,\n setActiveModal,\n }}\n >\n {children}\n </MicrositeMenuContext.Provider>\n );\n};\n\nexport function useMicrositeMenu(): MicrositeMenuContextValue {\n const context = useContext(MicrositeMenuContext);\n if (context === null) {\n throw new Error(\n \"useMicrositeMenu must be used within a MicrositeMenuContextProvider\",\n );\n }\n return context;\n}\n"],"names":["MicrositeMenuContext","createContext","MicrositeMenuContextProvider","context","pathname","currentPathname","hash","currentHash","children","language","DEFAULT_LANGUAGE","createSiteUrl","useMenu","isUIContext","useMemo","SiteId","Ui","isSiteUrlActive","useCallback","url","isUrlPathname","replace","parseMenuItem","item","childItems","items","map","filter","active","some","possible","isPartOfUrlPathname","label","collapsedLabel","description","actionLabel","menu","MICROSITE_HEADER_MAPPING","activeModal","prevActiveModal","_setActiveModal","useState","setActiveModal","id","jsx","Provider","value","useMicrositeMenu","useContext","Error"],"mappings":";;;;;;;;;;AAqBa,MAAAA,oBAAA,GACXC,oBAAgD,IAAI,CAAA;AAE/C,MAAMC,+BAA+BA,CAAC;EAAAC,OAAA,EAC3CA,SAAA;EACAC,UAAUC,eAAkB,GAAA,GAAA;EAC5BC,MAAMC,WAAc,GAAA,EAAA;EACpBC,QAAA;EACAC,QAAW,GAAAC,SAAA,CAAAA;AACb,CA8BM,KAAA;EAEE,MAAA;IAAEC;GAAc,GAAIC,OAAAA,CAAAA,OAAQ,EAAA;EAC5B,MAAAC,WAAA,GAAcC,cAAQ,MAAMX,SAAA,KAAYY,eAAOC,EAAI,EAAA,CAACb,SAAO,CAAC,CAAA;EAQlE,MAAMc,eAAkB,GAAAC,KAAA,CAAAA,WAAA,CACrBC,GAA0B,IAAA;IACzB;MAAA;MAEEN,WAAA;MAAA;MAEAM,GAAA,CAAI,CAAC,CAAM,KAAAhB,SAAA;MAAA;MAEXiB,KAAAA,CAAAA,aAAc,CAAAf,eAAA,EAAiBc,GAAI,CAAA,CAAC,CAAC,CAAA;MAAA;MAEpC,CAACA,GAAI,CAAA,CAAC,CAAK,IAAAZ,WAAA,CAAYc,QAAQ,IAAM,EAAA,EAAE,CAAM,KAAAF,GAAA,CAAI,CAAC,CAAA;IAAA;EAEvD,CAAA,EACA,CAAChB,SAAA,EAASI,WAAa,EAAAF,eAAA,EAAiBQ,WAAW,CAAA,CACrD;EAKA,MAAMS,aAAgB,GAAAJ,KAAA,CAAAA,WAAA,CACnBK,IAAgE,IAAA;IAEzD,MAA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AOtB,KAAAA,CAAAA,QAAQ,MAAiC;IACpD,OAAOQ,cAAce,SAAAA,CAAAA,wBAAwB,CAAA;EAAA,CAC/C,EAAG,CAACf,aAAa,CAAC,CAAA;EAKlB,MAAM,CAAC;IAAEgB,WAAA;IAAaC;EAAmB,CAAA,EAAAC,eAAe,IAAIC,KAAAA,CAAAA,QAGzD,CAAA;IACDH,WAAa,EAAA,IAAA;IACbC,eAAiB,EAAA;EAAA,CAClB,CAAA;EAED,MAAMG,cAAiB,GAAAxB,KAAA,CAAAA,WAAA,CAGpByB,EAAO,IAAA;IACUH,eAAA,CAAA;MACdF,WAAa,EAAAK,EAAA;MACbJ,eAAiB,EAAAD;IAAA,CAClB,CAAA;EACH,CAAA,EACA,CAACA,WAAW,CAAA,CACd;EAME,sBAAAM,UAAA,CAAAA,GAAA,CAAC5C,oBAAqB,CAAA6C,QAAA,EAArB;IACCC,KAAO,EAAA;MACLV,IAAA;MACA3B,QAAA;MAEA6B,WAAA;MACAC,eAAA;MACAG;IACF,CAAA;IAEClC;EAAA,CAAA,CACH;AAEJ,CAAA;AAEO,SAASuC,gBAA8CA,CAAA,EAAA;EACtD,MAAA5C,OAAA,GAAU6C,iBAAWhD,oBAAoB,CAAA;EAC/C,IAAIG,YAAY,IAAM,EAAA;IACpB,MAAM,IAAI8C,KAAA,CACR,qEAAA,CACF;EACF;EACO,OAAA9C,OAAA;AACT;;;"}
@@ -4,7 +4,6 @@ import '../MenuContext/index.mjs';
4
4
  import { SiteId } from '../MenuContext/mapping.mjs';
5
5
  import { isUrlPathname, isPartOfUrlPathname } from '../MenuContext/utils.mjs';
6
6
  import { MICROSITE_HEADER_MAPPING, DEFAULT_LANGUAGE } from './mapping.mjs';
7
- import { useMicrositeMenuTranslations } from './translations.mjs';
8
7
  import { useMenu } from '../MenuContext/context.mjs';
9
8
  "use strict";
10
9
  const MicrositeMenuContext = createContext(null);
@@ -19,9 +18,6 @@ const MicrositeMenuContextProvider = ({
19
18
  createSiteUrl
20
19
  } = useMenu();
21
20
  const isUIContext = useMemo(() => context === SiteId.Ui, [context]);
22
- const {
23
- formatMessage
24
- } = useMicrositeMenuTranslations(language);
25
21
  const isSiteUrlActive = useCallback(url => {
26
22
  return (
27
23
  // Do not check for active items if not in UI context
@@ -48,16 +44,16 @@ const MicrositeMenuContextProvider = ({
48
44
  }
49
45
  return {
50
46
  ...item,
51
- label: formatMessage(item.label),
52
- collapsedLabel: item.collapsedLabel ? formatMessage(item.collapsedLabel) : void 0,
53
- description: item.description ? formatMessage(item.description) : void 0,
54
- actionLabel: item.actionLabel ? formatMessage(item.actionLabel) : void 0,
47
+ label: item.label,
48
+ collapsedLabel: item?.collapsedLabel,
49
+ description: item?.description,
50
+ actionLabel: item?.actionLabel,
55
51
  active: !!active,
56
52
  possible: !!possible,
57
53
  items: childItems,
58
54
  url
59
55
  };
60
- }, [createSiteUrl, currentPathname, formatMessage, isSiteUrlActive]);
56
+ }, [createSiteUrl, currentPathname, isSiteUrlActive]);
61
57
  const menu = useMemo(() => {
62
58
  return parseMenuItem(MICROSITE_HEADER_MAPPING);
63
59
  }, [parseMenuItem]);
@@ -1 +1 @@
1
- {"version":3,"file":"context.mjs","sources":["../../../src/contexts/MicrositeMenuContext/context.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nimport type { GlobalStoreId, Language } from \"../../types\";\nimport { useMenu } from \"../MenuContext\";\nimport { SiteId } from \"../MenuContext/mapping\";\nimport type { SiteUrl } from \"../MenuContext/mapping\";\nimport type { GlobalSiteConfig } from \"../MenuContext/types\";\nimport { isPartOfUrlPathname, isUrlPathname } from \"../MenuContext/utils\";\nimport { DEFAULT_LANGUAGE, MICROSITE_HEADER_MAPPING } from \"./mapping\";\nimport { useMicrositeMenuTranslations } from \"./translations\";\nimport type {\n MicrositeHeaderItem,\n MicrositeMenuContextValue,\n ParsedMicrositeHeaderItem,\n} from \"./types\";\n\nexport const MicrositeMenuContext =\n createContext<MicrositeMenuContextValue | null>(null);\n\nexport const MicrositeMenuContextProvider = ({\n context,\n pathname: currentPathname = \"/\",\n hash: currentHash = \"\",\n children,\n language = DEFAULT_LANGUAGE,\n}: {\n /**\n * Set how the navigation behave as - ui.com/creators.ui.com/...\n */\n context: SiteId;\n /**\n * (optionally) Hints which language currently us currently in use\n */\n language?: Language;\n /**\n * Store context for determining which path to use\n * Will fall-back to US if not found\n * @example GlobalStoreId.Ca\n */\n storeId?: GlobalStoreId;\n /**\n * Pathname of the current URL\n * Used as a prop to be in sync with e.g. Next.js\n */\n pathname?: string;\n /**\n * Hash of the current URL (the part of the URL that starts with #)\n */\n hash?: string;\n /**\n * Global Site Config that define available urls/languages/regions enabled for globally\n */\n globalSiteConfig: GlobalSiteConfig;\n\n children: React.ReactNode;\n}) => {\n // TODO: Recouple from MenuContext\n const { createSiteUrl } = useMenu();\n const isUIContext = useMemo(() => context === SiteId.Ui, [context]);\n\n const { formatMessage } = useMicrositeMenuTranslations(language);\n\n // #############################################################################\n // Parsing\n // #############################################################################\n /**\n * Detects if a menu item is active based on the current pathname\n */\n const isSiteUrlActive = useCallback(\n (url: SiteUrl): boolean => {\n return (\n // Do not check for active items if not in UI context\n isUIContext &&\n // Check if the siteId matches the current context\n url[0] === context &&\n // Check if the pathname matches the current pathname\n isUrlPathname(currentPathname, url[1]) &&\n // If there's a hash in the SiteUrl, it should match the current hash for the item to be active\n (!url[3] || currentHash.replace(/^#/, \"\") === url[3])\n );\n },\n [context, currentHash, currentPathname, isUIContext],\n );\n\n /**\n * Parse a menu item and its children recursively\n */\n const parseMenuItem = useCallback(\n (item: MicrositeHeaderItem): ParsedMicrositeHeaderItem | null => {\n // Parse child items\n const childItems = item?.items\n ?.map(parseMenuItem)\n .filter((item): item is ParsedMicrositeHeaderItem => !!item);\n\n // Determine if menu item is active\n const active =\n // If any child is active, the parent is active\n childItems?.some((item) => item.active) ||\n childItems?.some((item) => item.possible) ||\n // If the item has a URL, check if it's active\n (item.url && typeof item.url !== \"string\" && isSiteUrlActive(item.url)); //\n\n // Get the final URL\n const url = item.url\n ? typeof item.url === \"string\"\n ? item.url\n : createSiteUrl(item.url)\n : childItems?.[0]?.url;\n\n const possible =\n item.url &&\n typeof item.url !== \"string\" &&\n isPartOfUrlPathname(currentPathname, item.url[1]);\n\n if (!url) {\n return null;\n }\n\n return {\n ...item,\n label: formatMessage(item.label),\n collapsedLabel: item.collapsedLabel\n ? formatMessage(item.collapsedLabel)\n : undefined,\n description: item.description\n ? formatMessage(item.description)\n : undefined,\n actionLabel: item.actionLabel\n ? formatMessage(item.actionLabel)\n : undefined,\n active: !!active,\n possible: !!possible,\n items: childItems,\n url,\n };\n },\n [createSiteUrl, currentPathname, formatMessage, isSiteUrlActive],\n );\n\n const menu = useMemo((): ParsedMicrositeHeaderItem => {\n return parseMenuItem(MICROSITE_HEADER_MAPPING)!;\n }, [parseMenuItem]);\n\n // #############################################################################\n // Active modal\n // #############################################################################\n const [{ activeModal, prevActiveModal }, _setActiveModal] = useState<{\n activeModal: MicrositeMenuContextValue[\"activeModal\"];\n prevActiveModal: MicrositeMenuContextValue[\"prevActiveModal\"];\n }>({\n activeModal: null,\n prevActiveModal: null,\n });\n\n const setActiveModal = useCallback<\n MicrositeMenuContextValue[\"setActiveModal\"]\n >(\n (id) => {\n _setActiveModal({\n activeModal: id,\n prevActiveModal: activeModal,\n });\n },\n [activeModal],\n );\n\n // #############################################################################\n // Render\n // #############################################################################\n return (\n <MicrositeMenuContext.Provider\n value={{\n menu,\n language,\n\n activeModal,\n prevActiveModal,\n setActiveModal,\n }}\n >\n {children}\n </MicrositeMenuContext.Provider>\n );\n};\n\nexport function useMicrositeMenu(): MicrositeMenuContextValue {\n const context = useContext(MicrositeMenuContext);\n if (context === null) {\n throw new Error(\n \"useMicrositeMenu must be used within a MicrositeMenuContextProvider\",\n );\n }\n return context;\n}\n"],"names":["MicrositeMenuContext","createContext","MicrositeMenuContextProvider","context","pathname","currentPathname","hash","currentHash","children","language","DEFAULT_LANGUAGE","createSiteUrl","useMenu","isUIContext","useMemo","SiteId","Ui","formatMessage","useMicrositeMenuTranslations","isSiteUrlActive","useCallback","url","isUrlPathname","replace","parseMenuItem","item","childItems","items","map","filter","active","some","possible","isPartOfUrlPathname","label","collapsedLabel","description","actionLabel","menu","MICROSITE_HEADER_MAPPING","activeModal","prevActiveModal","_setActiveModal","useState","setActiveModal","id","jsx","Provider","value","useMicrositeMenu","useContext","Error"],"mappings":";;;;;;;;;AAsBa,MAAAA,oBAAA,GACXC,cAAgD,IAAI,CAAA;AAE/C,MAAMC,+BAA+BA,CAAC;EAC3CC,OAAA;EACAC,UAAUC,eAAkB,GAAA,GAAA;EAC5BC,MAAMC,WAAc,GAAA,EAAA;EACpBC,QAAA;EACAC,QAAW,GAAAC;AACb,CA8BM,KAAA;EAEE,MAAA;IAAEC;GAAc,GAAIC,OAAQ,EAAA;EAC5B,MAAAC,WAAA,GAAcC,QAAQ,MAAMX,OAAA,KAAYY,OAAOC,EAAI,EAAA,CAACb,OAAO,CAAC,CAAA;EAElE,MAAM;IAAEc;EAAA,CAAkB,GAAAC,4BAAA,CAA6BT,QAAQ,CAAA;EAQ/D,MAAMU,eAAkB,GAAAC,WAAA,CACrBC,GAA0B,IAAA;IACzB;MAAA;MAEER,WAAA;MAAA;MAEAQ,GAAA,CAAI,CAAC,CAAM,KAAAlB,OAAA;MAAA;MAEXmB,aAAc,CAAAjB,eAAA,EAAiBgB,GAAI,CAAA,CAAC,CAAC,CAAA;MAAA;MAEpC,CAACA,GAAI,CAAA,CAAC,CAAK,IAAAd,WAAA,CAAYgB,QAAQ,IAAM,EAAA,EAAE,CAAM,KAAAF,GAAA,CAAI,CAAC,CAAA;IAAA;EAEvD,CAAA,EACA,CAAClB,OAAA,EAASI,WAAa,EAAAF,eAAA,EAAiBQ,WAAW,CAAA,CACrD;EAKA,MAAMW,aAAgB,GAAAJ,WAAA,CACnBK,IAAgE,IAAA;IAEzD,MAAAC,UAAA,GAAaD,IAAM,E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CAAC,CAACA,MAAA;MACVE,QAAA,EAAU,CAAC,CAACA,QAAA;MACZL,KAAO,EAAAD,UAAA;MACPL;IAAA,CACF;EACF,CAAA,EACA,CAACV,aAAA,EAAeN,eAAiB,EAAAY,aAAA,EAAeE,eAAe,CAAA,CACjE;EAEM,MAAAmB,IAAA,GAAOxB,QAAQ,MAAiC;IACpD,OAAOU,cAAce,wBAAwB,CAAA;EAAA,CAC/C,EAAG,CAACf,aAAa,CAAC,CAAA;EAKlB,MAAM,CAAC;IAAEgB,WAAA;IAAaC;EAAmB,CAAA,EAAAC,eAAe,IAAIC,QAGzD,CAAA;IACDH,WAAa,EAAA,IAAA;IACbC,eAAiB,EAAA;EAAA,CAClB,CAAA;EAED,MAAMG,cAAiB,GAAAxB,WAAA,CAGpByB,EAAO,IAAA;IACUH,eAAA,CAAA;MACdF,WAAa,EAAAK,EAAA;MACbJ,eAAiB,EAAAD;IAAA,CAClB,CAAA;EACH,CAAA,EACA,CAACA,WAAW,CAAA,CACd;EAME,sBAAAM,GAAA,CAAC9C,oBAAqB,CAAA+C,QAAA,EAArB;IACCC,KAAO,EAAA;MACLV,IAAA;MACA7B,QAAA;MAEA+B,WAAA;MACAC,eAAA;MACAG;IACF,CAAA;IAECpC;EAAA,CAAA,CACH;AAEJ,CAAA;AAEO,SAASyC,gBAA8CA,CAAA,EAAA;EACtD,MAAA9C,OAAA,GAAU+C,WAAWlD,oBAAoB,CAAA;EAC/C,IAAIG,YAAY,IAAM,EAAA;IACpB,MAAM,IAAIgD,KAAA,CACR,qEAAA,CACF;EACF;EACO,OAAAhD,OAAA;AACT;"}
1
+ {"version":3,"file":"context.mjs","sources":["../../../src/contexts/MicrositeMenuContext/context.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nimport type { GlobalStoreId, Language } from \"../../types\";\nimport { useMenu } from \"../MenuContext\";\nimport { SiteId } from \"../MenuContext/mapping\";\nimport type { SiteUrl } from \"../MenuContext/mapping\";\nimport type { GlobalSiteConfig } from \"../MenuContext/types\";\nimport { isPartOfUrlPathname, isUrlPathname } from \"../MenuContext/utils\";\nimport { DEFAULT_LANGUAGE, MICROSITE_HEADER_MAPPING } from \"./mapping\";\nimport type {\n MicrositeHeaderItem,\n MicrositeMenuContextValue,\n ParsedMicrositeHeaderItem,\n} from \"./types\";\n\nexport const MicrositeMenuContext =\n createContext<MicrositeMenuContextValue | null>(null);\n\nexport const MicrositeMenuContextProvider = ({\n context,\n pathname: currentPathname = \"/\",\n hash: currentHash = \"\",\n children,\n language = DEFAULT_LANGUAGE,\n}: {\n /**\n * Set how the navigation behave as - ui.com/creators.ui.com/...\n */\n context: SiteId;\n /**\n * (optionally) Hints which language currently us currently in use\n */\n language?: Language;\n /**\n * Store context for determining which path to use\n * Will fall-back to US if not found\n * @example GlobalStoreId.Ca\n */\n storeId?: GlobalStoreId;\n /**\n * Pathname of the current URL\n * Used as a prop to be in sync with e.g. Next.js\n */\n pathname?: string;\n /**\n * Hash of the current URL (the part of the URL that starts with #)\n */\n hash?: string;\n /**\n * Global Site Config that define available urls/languages/regions enabled for globally\n */\n globalSiteConfig: GlobalSiteConfig;\n\n children: React.ReactNode;\n}) => {\n // TODO: Recouple from MenuContext\n const { createSiteUrl } = useMenu();\n const isUIContext = useMemo(() => context === SiteId.Ui, [context]);\n\n // #############################################################################\n // Parsing\n // #############################################################################\n /**\n * Detects if a menu item is active based on the current pathname\n */\n const isSiteUrlActive = useCallback(\n (url: SiteUrl): boolean => {\n return (\n // Do not check for active items if not in UI context\n isUIContext &&\n // Check if the siteId matches the current context\n url[0] === context &&\n // Check if the pathname matches the current pathname\n isUrlPathname(currentPathname, url[1]) &&\n // If there's a hash in the SiteUrl, it should match the current hash for the item to be active\n (!url[3] || currentHash.replace(/^#/, \"\") === url[3])\n );\n },\n [context, currentHash, currentPathname, isUIContext],\n );\n\n /**\n * Parse a menu item and its children recursively\n */\n const parseMenuItem = useCallback(\n (item: MicrositeHeaderItem): ParsedMicrositeHeaderItem | null => {\n // Parse child items\n const childItems = item?.items\n ?.map(parseMenuItem)\n .filter((item): item is ParsedMicrositeHeaderItem => !!item);\n\n // Determine if menu item is active\n const active =\n // If any child is active, the parent is active\n childItems?.some((item) => item.active) ||\n childItems?.some((item) => item.possible) ||\n // If the item has a URL, check if it's active\n (item.url && typeof item.url !== \"string\" && isSiteUrlActive(item.url)); //\n\n // Get the final URL\n const url = item.url\n ? typeof item.url === \"string\"\n ? item.url\n : createSiteUrl(item.url)\n : childItems?.[0]?.url;\n\n const possible =\n item.url &&\n typeof item.url !== \"string\" &&\n isPartOfUrlPathname(currentPathname, item.url[1]);\n\n if (!url) {\n return null;\n }\n\n return {\n ...item,\n label: item.label,\n collapsedLabel: item?.collapsedLabel,\n description: item?.description,\n actionLabel: item?.actionLabel,\n active: !!active,\n possible: !!possible,\n items: childItems,\n url,\n };\n },\n [createSiteUrl, currentPathname, isSiteUrlActive],\n );\n\n const menu = useMemo((): ParsedMicrositeHeaderItem => {\n return parseMenuItem(MICROSITE_HEADER_MAPPING)!;\n }, [parseMenuItem]);\n\n // #############################################################################\n // Active modal\n // #############################################################################\n const [{ activeModal, prevActiveModal }, _setActiveModal] = useState<{\n activeModal: MicrositeMenuContextValue[\"activeModal\"];\n prevActiveModal: MicrositeMenuContextValue[\"prevActiveModal\"];\n }>({\n activeModal: null,\n prevActiveModal: null,\n });\n\n const setActiveModal = useCallback<\n MicrositeMenuContextValue[\"setActiveModal\"]\n >(\n (id) => {\n _setActiveModal({\n activeModal: id,\n prevActiveModal: activeModal,\n });\n },\n [activeModal],\n );\n\n // #############################################################################\n // Render\n // #############################################################################\n return (\n <MicrositeMenuContext.Provider\n value={{\n menu,\n language,\n\n activeModal,\n prevActiveModal,\n setActiveModal,\n }}\n >\n {children}\n </MicrositeMenuContext.Provider>\n );\n};\n\nexport function useMicrositeMenu(): MicrositeMenuContextValue {\n const context = useContext(MicrositeMenuContext);\n if (context === null) {\n throw new Error(\n \"useMicrositeMenu must be used within a MicrositeMenuContextProvider\",\n );\n }\n return context;\n}\n"],"names":["MicrositeMenuContext","createContext","MicrositeMenuContextProvider","context","pathname","currentPathname","hash","currentHash","children","language","DEFAULT_LANGUAGE","createSiteUrl","useMenu","isUIContext","useMemo","SiteId","Ui","isSiteUrlActive","useCallback","url","isUrlPathname","replace","parseMenuItem","item","childItems","items","map","filter","active","some","possible","isPartOfUrlPathname","label","collapsedLabel","description","actionLabel","menu","MICROSITE_HEADER_MAPPING","activeModal","prevActiveModal","_setActiveModal","useState","setActiveModal","id","jsx","Provider","value","useMicrositeMenu","useContext","Error"],"mappings":";;;;;;;;AAqBa,MAAAA,oBAAA,GACXC,cAAgD,IAAI,CAAA;AAE/C,MAAMC,+BAA+BA,CAAC;EAC3CC,OAAA;EACAC,UAAUC,eAAkB,GAAA,GAAA;EAC5BC,MAAMC,WAAc,GAAA,EAAA;EACpBC,QAAA;EACAC,QAAW,GAAAC;AACb,CA8BM,KAAA;EAEE,MAAA;IAAEC;GAAc,GAAIC,OAAQ,EAAA;EAC5B,MAAAC,WAAA,GAAcC,QAAQ,MAAMX,OAAA,KAAYY,OAAOC,EAAI,EAAA,CAACb,OAAO,CAAC,CAAA;EAQlE,MAAMc,eAAkB,GAAAC,WAAA,CACrBC,GAA0B,IAAA;IACzB;MAAA;MAEEN,WAAA;MAAA;MAEAM,GAAA,CAAI,CAAC,CAAM,KAAAhB,OAAA;MAAA;MAEXiB,aAAc,CAAAf,eAAA,EAAiBc,GAAI,CAAA,CAAC,CAAC,CAAA;MAAA;MAEpC,CAACA,GAAI,CAAA,CAAC,CAAK,IAAAZ,WAAA,CAAYc,QAAQ,IAAM,EAAA,EAAE,CAAM,KAAAF,GAAA,CAAI,CAAC,CAAA;IAAA;EAEvD,CAAA,EACA,CAAChB,OAAA,EAASI,WAAa,EAAAF,eAAA,EAAiBQ,WAAW,CAAA,CACrD;EAKA,MAAMS,aAAgB,GAAAJ,WAAA,CACnBK,IAAgE,IAAA;IAEz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AQ,MAAiC;IACpD,OAAOQ,cAAce,wBAAwB,CAAA;EAAA,CAC/C,EAAG,CAACf,aAAa,CAAC,CAAA;EAKlB,MAAM,CAAC;IAAEgB,WAAA;IAAaC;EAAmB,CAAA,EAAAC,eAAe,IAAIC,QAGzD,CAAA;IACDH,WAAa,EAAA,IAAA;IACbC,eAAiB,EAAA;EAAA,CAClB,CAAA;EAED,MAAMG,cAAiB,GAAAxB,WAAA,CAGpByB,EAAO,IAAA;IACUH,eAAA,CAAA;MACdF,WAAa,EAAAK,EAAA;MACbJ,eAAiB,EAAAD;IAAA,CAClB,CAAA;EACH,CAAA,EACA,CAACA,WAAW,CAAA,CACd;EAME,sBAAAM,GAAA,CAAC5C,oBAAqB,CAAA6C,QAAA,EAArB;IACCC,KAAO,EAAA;MACLV,IAAA;MACA3B,QAAA;MAEA6B,WAAA;MACAC,eAAA;MACAG;IACF,CAAA;IAEClC;EAAA,CAAA,CACH;AAEJ,CAAA;AAEO,SAASuC,gBAA8CA,CAAA,EAAA;EACtD,MAAA5C,OAAA,GAAU6C,WAAWhD,oBAAoB,CAAA;EAC/C,IAAIG,YAAY,IAAM,EAAA;IACpB,MAAM,IAAI8C,KAAA,CACR,qEAAA,CACF;EACF;EACO,OAAA9C,OAAA;AACT;"}
@@ -74,10 +74,10 @@ export type MicrositeHeaderItem = MicrositeHeaderItemBase & ({
74
74
  items: MicrositeHeaderItem[];
75
75
  });
76
76
  export type ParsedMicrositeHeaderItem = Omit<MicrositeHeaderItem, "url" | "items" | "label" | "collapsedLabel" | "description" | "actionLabel"> & {
77
- label: string;
77
+ label: TranslationKey;
78
78
  collapsedLabel?: string;
79
- description?: string;
80
- actionLabel?: string;
79
+ description?: TranslationKey;
80
+ actionLabel?: TranslationKey;
81
81
  url: string;
82
82
  active: boolean;
83
83
  possible: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../src/contexts/MicrositeMenuContext/types.ts"],"sourcesContent":["import type { StaticImageData } from \"next/image\";\n\nimport type { HeaderAccountCustomer } from \"../../components/Header/Header.types\";\nimport type { Language, Nullish } from \"../../types\";\nimport type { SiteUrl } from \"../MenuContext/mapping\";\nimport type EN_TRANSLATIONS from \"./translations/en.json\";\n\n// #############################################################################\n// Translations\n// #############################################################################\ntype TranslationKey = keyof typeof EN_TRANSLATIONS;\n\n// #############################################################################\n// Mapping types\n// #############################################################################\nenum ItemVariant {\n Default = \"default\",\n Dropdown = \"dropdown\",\n ColumnList = \"column-list\",\n}\n\ntype MicrositeHeaderItemBase = {\n /**\n * Unique identifier of the item\n */\n id: string;\n /**\n * Label of the item\n */\n label: TranslationKey;\n /**\n * Label of the item when if menu is collapsed (e.g. Overview -> Switching Overview)\n */\n collapsedLabel?: TranslationKey;\n /**\n * Description of the item\n */\n description?: TranslationKey;\n /**\n * Action label of the item (e.g. \"Learn more\")\n */\n actionLabel?: TranslationKey;\n /**\n * Image of the item\n */\n image?: {\n src: StaticImageData | string;\n height?: number;\n width?: number;\n };\n\n isOverview?: boolean;\n hasDarkText?: boolean;\n shouldHideCompare?: boolean;\n\n /**\n * Groups of the items\n */\n groups?: number[];\n\n /**\n * Icon of the item\n */\n icon?: {\n src: StaticImageData | string;\n height: number;\n width: number;\n };\n\n /**\n * Flag to indicate if the item is new (blue indicator)\n */\n isNew?: boolean;\n};\n\nexport type MicrositeHeaderItem = MicrositeHeaderItemBase &\n (\n | {\n url: SiteUrl | string; // TODO: Decouple from MenuContext\n /**\n * If there is no items, we cannot show a dropdown since there is nothing to show\n */\n variant?: `${ItemVariant.Default}`;\n items?: never;\n }\n | {\n url?: SiteUrl | string; // TODO: Decouple from MenuContext\n /**\n * If there are items, we can show a dropdown or a default navigation\n */\n variant?: `${ItemVariant}`;\n items: MicrositeHeaderItem[];\n }\n );\n\n// #############################################################################\n// Microsite menu context value\n// #############################################################################\nexport type ParsedMicrositeHeaderItem = Omit<\n MicrositeHeaderItem,\n \"url\" | \"items\" | \"label\" | \"collapsedLabel\" | \"description\" | \"actionLabel\"\n> & {\n label: string;\n collapsedLabel?: string;\n description?: string;\n actionLabel?: string;\n url: string;\n active: boolean;\n possible: boolean;\n items?: ParsedMicrositeHeaderItem[];\n};\n\nexport interface HeaderAccount {\n loading?: boolean;\n customer?: Nullish<HeaderAccountCustomer>;\n handleLogin?: () => void;\n handleLogout?: () => void;\n handleRegister?: () => void;\n handleManageAccount?: () => void;\n handleOrderHistory?: () => void;\n renderStorePicker?: (onClose: () => void) => JSX.Element;\n}\n\nexport enum ModalId {\n // Support = \"support\",\n Account = \"account\",\n // Cart = \"cart\",\n Language = \"language\",\n // MobileMenu = \"mobileMenu\",\n // ProMobileMenu = \"proMobileMenu\",\n // Search = \"search\",\n}\n\nexport type MicrositeMenuContextValue = {\n menu: ParsedMicrositeHeaderItem;\n language: Language;\n\n // Modals\n activeModal: ModalId | null;\n prevActiveModal: ModalId | null;\n setActiveModal: (id: ModalId | null) => void;\n};\n"],"names":["ItemVariant","ModalId"],"mappings":";;;AAeA,IAAKA,WAAA,GAAA,gBAAAA,YAAL,IAAA;EACEA,aAAA,SAAU,CAAA,GAAA,SAAA;EACVA,aAAA,UAAW,CAAA,GAAA,UAAA;EACXA,aAAA,YAAa,CAAA,GAAA,aAAA;EAHVA,OAAAA,YAAAA;AAAA,CAAA,EAAAA,WAAA,IAAA,CAAA,CAAA,CAAA;AA4GO,IAAAC,OAAA,GAAA,gBAAAA,QAAL,IAAA;EAELA,SAAA,SAAU,CAAA,GAAA,SAAA;EAEVA,SAAA,UAAW,CAAA,GAAA,UAAA;EAJDA,OAAAA,QAAAA;AAAA,CAAA,EAAAA,OAAA,IAAA,CAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"types.js","sources":["../../../src/contexts/MicrositeMenuContext/types.ts"],"sourcesContent":["import type { StaticImageData } from \"next/image\";\n\nimport type { HeaderAccountCustomer } from \"../../components/Header/Header.types\";\nimport type { Language, Nullish } from \"../../types\";\nimport type { SiteUrl } from \"../MenuContext/mapping\";\nimport type EN_TRANSLATIONS from \"./translations/en.json\";\n\n// #############################################################################\n// Translations\n// #############################################################################\ntype TranslationKey = keyof typeof EN_TRANSLATIONS;\n\n// #############################################################################\n// Mapping types\n// #############################################################################\nenum ItemVariant {\n Default = \"default\",\n Dropdown = \"dropdown\",\n ColumnList = \"column-list\",\n}\n\ntype MicrositeHeaderItemBase = {\n /**\n * Unique identifier of the item\n */\n id: string;\n /**\n * Label of the item\n */\n label: TranslationKey;\n /**\n * Label of the item when if menu is collapsed (e.g. Overview -> Switching Overview)\n */\n collapsedLabel?: TranslationKey;\n /**\n * Description of the item\n */\n description?: TranslationKey;\n /**\n * Action label of the item (e.g. \"Learn more\")\n */\n actionLabel?: TranslationKey;\n /**\n * Image of the item\n */\n image?: {\n src: StaticImageData | string;\n height?: number;\n width?: number;\n };\n\n isOverview?: boolean;\n hasDarkText?: boolean;\n shouldHideCompare?: boolean;\n\n /**\n * Groups of the items\n */\n groups?: number[];\n\n /**\n * Icon of the item\n */\n icon?: {\n src: StaticImageData | string;\n height: number;\n width: number;\n };\n\n /**\n * Flag to indicate if the item is new (blue indicator)\n */\n isNew?: boolean;\n};\n\nexport type MicrositeHeaderItem = MicrositeHeaderItemBase &\n (\n | {\n url: SiteUrl | string; // TODO: Decouple from MenuContext\n /**\n * If there is no items, we cannot show a dropdown since there is nothing to show\n */\n variant?: `${ItemVariant.Default}`;\n items?: never;\n }\n | {\n url?: SiteUrl | string; // TODO: Decouple from MenuContext\n /**\n * If there are items, we can show a dropdown or a default navigation\n */\n variant?: `${ItemVariant}`;\n items: MicrositeHeaderItem[];\n }\n );\n\n// #############################################################################\n// Microsite menu context value\n// #############################################################################\nexport type ParsedMicrositeHeaderItem = Omit<\n MicrositeHeaderItem,\n \"url\" | \"items\" | \"label\" | \"collapsedLabel\" | \"description\" | \"actionLabel\"\n> & {\n label: TranslationKey;\n collapsedLabel?: string;\n description?: TranslationKey;\n actionLabel?: TranslationKey;\n url: string;\n active: boolean;\n possible: boolean;\n items?: ParsedMicrositeHeaderItem[];\n};\n\nexport interface HeaderAccount {\n loading?: boolean;\n customer?: Nullish<HeaderAccountCustomer>;\n handleLogin?: () => void;\n handleLogout?: () => void;\n handleRegister?: () => void;\n handleManageAccount?: () => void;\n handleOrderHistory?: () => void;\n renderStorePicker?: (onClose: () => void) => JSX.Element;\n}\n\nexport enum ModalId {\n // Support = \"support\",\n Account = \"account\",\n // Cart = \"cart\",\n Language = \"language\",\n // MobileMenu = \"mobileMenu\",\n // ProMobileMenu = \"proMobileMenu\",\n // Search = \"search\",\n}\n\nexport type MicrositeMenuContextValue = {\n menu: ParsedMicrositeHeaderItem;\n language: Language;\n\n // Modals\n activeModal: ModalId | null;\n prevActiveModal: ModalId | null;\n setActiveModal: (id: ModalId | null) => void;\n};\n"],"names":["ItemVariant","ModalId"],"mappings":";;;AAeA,IAAKA,WAAA,GAAA,gBAAAA,YAAL,IAAA;EACEA,aAAA,SAAU,CAAA,GAAA,SAAA;EACVA,aAAA,UAAW,CAAA,GAAA,UAAA;EACXA,aAAA,YAAa,CAAA,GAAA,aAAA;EAHVA,OAAAA,YAAAA;AAAA,CAAA,EAAAA,WAAA,IAAA,CAAA,CAAA,CAAA;AA4GO,IAAAC,OAAA,GAAA,gBAAAA,QAAL,IAAA;EAELA,SAAA,SAAU,CAAA,GAAA,SAAA;EAEVA,SAAA,UAAW,CAAA,GAAA,UAAA;EAJDA,OAAAA,QAAAA;AAAA,CAAA,EAAAA,OAAA,IAAA,CAAA,CAAA,CAAA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sources":["../../../src/contexts/MicrositeMenuContext/types.ts"],"sourcesContent":["import type { StaticImageData } from \"next/image\";\n\nimport type { HeaderAccountCustomer } from \"../../components/Header/Header.types\";\nimport type { Language, Nullish } from \"../../types\";\nimport type { SiteUrl } from \"../MenuContext/mapping\";\nimport type EN_TRANSLATIONS from \"./translations/en.json\";\n\n// #############################################################################\n// Translations\n// #############################################################################\ntype TranslationKey = keyof typeof EN_TRANSLATIONS;\n\n// #############################################################################\n// Mapping types\n// #############################################################################\nenum ItemVariant {\n Default = \"default\",\n Dropdown = \"dropdown\",\n ColumnList = \"column-list\",\n}\n\ntype MicrositeHeaderItemBase = {\n /**\n * Unique identifier of the item\n */\n id: string;\n /**\n * Label of the item\n */\n label: TranslationKey;\n /**\n * Label of the item when if menu is collapsed (e.g. Overview -> Switching Overview)\n */\n collapsedLabel?: TranslationKey;\n /**\n * Description of the item\n */\n description?: TranslationKey;\n /**\n * Action label of the item (e.g. \"Learn more\")\n */\n actionLabel?: TranslationKey;\n /**\n * Image of the item\n */\n image?: {\n src: StaticImageData | string;\n height?: number;\n width?: number;\n };\n\n isOverview?: boolean;\n hasDarkText?: boolean;\n shouldHideCompare?: boolean;\n\n /**\n * Groups of the items\n */\n groups?: number[];\n\n /**\n * Icon of the item\n */\n icon?: {\n src: StaticImageData | string;\n height: number;\n width: number;\n };\n\n /**\n * Flag to indicate if the item is new (blue indicator)\n */\n isNew?: boolean;\n};\n\nexport type MicrositeHeaderItem = MicrositeHeaderItemBase &\n (\n | {\n url: SiteUrl | string; // TODO: Decouple from MenuContext\n /**\n * If there is no items, we cannot show a dropdown since there is nothing to show\n */\n variant?: `${ItemVariant.Default}`;\n items?: never;\n }\n | {\n url?: SiteUrl | string; // TODO: Decouple from MenuContext\n /**\n * If there are items, we can show a dropdown or a default navigation\n */\n variant?: `${ItemVariant}`;\n items: MicrositeHeaderItem[];\n }\n );\n\n// #############################################################################\n// Microsite menu context value\n// #############################################################################\nexport type ParsedMicrositeHeaderItem = Omit<\n MicrositeHeaderItem,\n \"url\" | \"items\" | \"label\" | \"collapsedLabel\" | \"description\" | \"actionLabel\"\n> & {\n label: string;\n collapsedLabel?: string;\n description?: string;\n actionLabel?: string;\n url: string;\n active: boolean;\n possible: boolean;\n items?: ParsedMicrositeHeaderItem[];\n};\n\nexport interface HeaderAccount {\n loading?: boolean;\n customer?: Nullish<HeaderAccountCustomer>;\n handleLogin?: () => void;\n handleLogout?: () => void;\n handleRegister?: () => void;\n handleManageAccount?: () => void;\n handleOrderHistory?: () => void;\n renderStorePicker?: (onClose: () => void) => JSX.Element;\n}\n\nexport enum ModalId {\n // Support = \"support\",\n Account = \"account\",\n // Cart = \"cart\",\n Language = \"language\",\n // MobileMenu = \"mobileMenu\",\n // ProMobileMenu = \"proMobileMenu\",\n // Search = \"search\",\n}\n\nexport type MicrositeMenuContextValue = {\n menu: ParsedMicrositeHeaderItem;\n language: Language;\n\n // Modals\n activeModal: ModalId | null;\n prevActiveModal: ModalId | null;\n setActiveModal: (id: ModalId | null) => void;\n};\n"],"names":["ItemVariant","ModalId"],"mappings":";;AAeA,IAAKA,WAAA,GAAA,gBAAAA,YAAL,IAAA;EACEA,aAAA,SAAU,CAAA,GAAA,SAAA;EACVA,aAAA,UAAW,CAAA,GAAA,UAAA;EACXA,aAAA,YAAa,CAAA,GAAA,aAAA;EAHVA,OAAAA,YAAAA;AAAA,CAAA,EAAAA,WAAA,IAAA,CAAA,CAAA,CAAA;AA4GO,IAAAC,OAAA,GAAA,gBAAAA,QAAL,IAAA;EAELA,SAAA,SAAU,CAAA,GAAA,SAAA;EAEVA,SAAA,UAAW,CAAA,GAAA,UAAA;EAJDA,OAAAA,QAAAA;AAAA,CAAA,EAAAA,OAAA,IAAA,CAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"types.mjs","sources":["../../../src/contexts/MicrositeMenuContext/types.ts"],"sourcesContent":["import type { StaticImageData } from \"next/image\";\n\nimport type { HeaderAccountCustomer } from \"../../components/Header/Header.types\";\nimport type { Language, Nullish } from \"../../types\";\nimport type { SiteUrl } from \"../MenuContext/mapping\";\nimport type EN_TRANSLATIONS from \"./translations/en.json\";\n\n// #############################################################################\n// Translations\n// #############################################################################\ntype TranslationKey = keyof typeof EN_TRANSLATIONS;\n\n// #############################################################################\n// Mapping types\n// #############################################################################\nenum ItemVariant {\n Default = \"default\",\n Dropdown = \"dropdown\",\n ColumnList = \"column-list\",\n}\n\ntype MicrositeHeaderItemBase = {\n /**\n * Unique identifier of the item\n */\n id: string;\n /**\n * Label of the item\n */\n label: TranslationKey;\n /**\n * Label of the item when if menu is collapsed (e.g. Overview -> Switching Overview)\n */\n collapsedLabel?: TranslationKey;\n /**\n * Description of the item\n */\n description?: TranslationKey;\n /**\n * Action label of the item (e.g. \"Learn more\")\n */\n actionLabel?: TranslationKey;\n /**\n * Image of the item\n */\n image?: {\n src: StaticImageData | string;\n height?: number;\n width?: number;\n };\n\n isOverview?: boolean;\n hasDarkText?: boolean;\n shouldHideCompare?: boolean;\n\n /**\n * Groups of the items\n */\n groups?: number[];\n\n /**\n * Icon of the item\n */\n icon?: {\n src: StaticImageData | string;\n height: number;\n width: number;\n };\n\n /**\n * Flag to indicate if the item is new (blue indicator)\n */\n isNew?: boolean;\n};\n\nexport type MicrositeHeaderItem = MicrositeHeaderItemBase &\n (\n | {\n url: SiteUrl | string; // TODO: Decouple from MenuContext\n /**\n * If there is no items, we cannot show a dropdown since there is nothing to show\n */\n variant?: `${ItemVariant.Default}`;\n items?: never;\n }\n | {\n url?: SiteUrl | string; // TODO: Decouple from MenuContext\n /**\n * If there are items, we can show a dropdown or a default navigation\n */\n variant?: `${ItemVariant}`;\n items: MicrositeHeaderItem[];\n }\n );\n\n// #############################################################################\n// Microsite menu context value\n// #############################################################################\nexport type ParsedMicrositeHeaderItem = Omit<\n MicrositeHeaderItem,\n \"url\" | \"items\" | \"label\" | \"collapsedLabel\" | \"description\" | \"actionLabel\"\n> & {\n label: TranslationKey;\n collapsedLabel?: string;\n description?: TranslationKey;\n actionLabel?: TranslationKey;\n url: string;\n active: boolean;\n possible: boolean;\n items?: ParsedMicrositeHeaderItem[];\n};\n\nexport interface HeaderAccount {\n loading?: boolean;\n customer?: Nullish<HeaderAccountCustomer>;\n handleLogin?: () => void;\n handleLogout?: () => void;\n handleRegister?: () => void;\n handleManageAccount?: () => void;\n handleOrderHistory?: () => void;\n renderStorePicker?: (onClose: () => void) => JSX.Element;\n}\n\nexport enum ModalId {\n // Support = \"support\",\n Account = \"account\",\n // Cart = \"cart\",\n Language = \"language\",\n // MobileMenu = \"mobileMenu\",\n // ProMobileMenu = \"proMobileMenu\",\n // Search = \"search\",\n}\n\nexport type MicrositeMenuContextValue = {\n menu: ParsedMicrositeHeaderItem;\n language: Language;\n\n // Modals\n activeModal: ModalId | null;\n prevActiveModal: ModalId | null;\n setActiveModal: (id: ModalId | null) => void;\n};\n"],"names":["ItemVariant","ModalId"],"mappings":";;AAeA,IAAKA,WAAA,GAAA,gBAAAA,YAAL,IAAA;EACEA,aAAA,SAAU,CAAA,GAAA,SAAA;EACVA,aAAA,UAAW,CAAA,GAAA,UAAA;EACXA,aAAA,YAAa,CAAA,GAAA,aAAA;EAHVA,OAAAA,YAAAA;AAAA,CAAA,EAAAA,WAAA,IAAA,CAAA,CAAA,CAAA;AA4GO,IAAAC,OAAA,GAAA,gBAAAA,QAAL,IAAA;EAELA,SAAA,SAAU,CAAA,GAAA,SAAA;EAEVA,SAAA,UAAW,CAAA,GAAA,UAAA;EAJDA,OAAAA,QAAAA;AAAA,CAAA,EAAAA,OAAA,IAAA,CAAA,CAAA,CAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubnt/store.core",
3
- "version": "9.38.0-alpha.7",
3
+ "version": "9.38.0-alpha.8",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "scripts": {