@ubnt/store.core 9.9.0-alpha.8 → 9.9.0-konutis.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.
- package/CHANGELOG.md +0 -26
- package/lib/_virtual/_virtual_multi-entry.js +16 -4
- package/lib/_virtual/_virtual_multi-entry.js.map +1 -1
- package/lib/_virtual/_virtual_multi-entry.mjs +2 -2
- package/lib/assets/minus4.svg +8 -8
- package/lib/assets/minus5.svg +8 -8
- package/lib/assets/plus5.svg +9 -9
- package/lib/assets/plus6.svg +9 -9
- package/lib/assets/socialMedia/{x.svg.js → twitter.svg.js} +6 -6
- package/lib/assets/socialMedia/twitter.svg.js.map +1 -0
- package/lib/assets/socialMedia/twitter.svg.mjs +3 -0
- package/lib/assets/socialMedia/twitter.svg.mjs.map +1 -0
- package/lib/assets/twitter.svg +3 -0
- package/lib/assets/udmPro.jpg +0 -0
- package/lib/assets/udmPro2.jpg +0 -0
- package/lib/assets/udmProMax.jpg +0 -0
- package/lib/assets/udmProMax2.jpg +0 -0
- package/lib/assets/udmProSpecial.jpg +0 -0
- package/lib/assets/udmProSpecial2.jpg +0 -0
- package/lib/components/Footer/Footer.d.ts +1 -1
- package/lib/components/Footer/Footer.js +74 -192
- package/lib/components/Footer/Footer.js.map +1 -1
- package/lib/components/Footer/Footer.mjs +76 -174
- package/lib/components/Footer/Footer.mjs.map +1 -1
- package/lib/components/Footer/Footer.styles.d.ts +5 -17
- package/lib/components/Footer/Footer.styles.js +44 -90
- package/lib/components/Footer/Footer.styles.js.map +1 -1
- package/lib/components/Footer/Footer.styles.mjs +44 -86
- package/lib/components/Footer/Footer.styles.mjs.map +1 -1
- package/lib/components/Footer/Footer.types.d.ts +0 -40
- package/lib/components/Footer/Footer.types.js +0 -16
- package/lib/components/Footer/Footer.types.js.map +1 -1
- package/lib/components/Footer/Footer.types.mjs +0 -15
- package/lib/components/Footer/Footer.types.mjs.map +1 -1
- package/lib/components/Footer/index.js +1 -3
- package/lib/components/Footer/index.js.map +1 -1
- package/lib/components/Footer/index.mjs +1 -1
- package/lib/components/Header/AccountMenu/AccountMenu.js +3 -6
- package/lib/components/Header/AccountMenu/AccountMenu.js.map +1 -1
- package/lib/components/Header/AccountMenu/AccountMenu.mjs +3 -6
- package/lib/components/Header/AccountMenu/AccountMenu.mjs.map +1 -1
- package/lib/components/Header/Navigation/MobileMenu/MobileMenu.js +6 -11
- package/lib/components/Header/Navigation/MobileMenu/MobileMenu.js.map +1 -1
- package/lib/components/Header/Navigation/MobileMenu/MobileMenu.mjs +6 -11
- package/lib/components/Header/Navigation/MobileMenu/MobileMenu.mjs.map +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.js +4 -8
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.js.map +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.mjs +4 -8
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.mjs.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.js +2 -19
- package/lib/components/Header/ProHeader/ProHeader.js.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.mjs +2 -19
- package/lib/components/Header/ProHeader/ProHeader.mjs.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.styles.d.ts +0 -1
- package/lib/components/Header/ProHeader/ProHeader.styles.js +0 -6
- package/lib/components/Header/ProHeader/ProHeader.styles.js.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.styles.mjs +0 -6
- package/lib/components/Header/ProHeader/ProHeader.styles.mjs.map +1 -1
- package/lib/components/LandingPagePro/LandingPagePro.d.ts +0 -3
- package/lib/components/LandingPagePro/LandingPagePro.js +3 -3
- package/lib/components/LandingPagePro/LandingPagePro.js.map +1 -1
- package/lib/components/LandingPagePro/LandingPagePro.mjs +2 -2
- package/lib/components/LandingPagePro/LandingPagePro.mjs.map +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/data/CloudGateways.js +9 -9
- package/lib/components/ModelCompareV3/data/CloudGateways.mjs +6 -6
- package/lib/components/ModelCompareV3/data/products/udmPro.js +1 -1
- package/lib/components/ModelCompareV3/data/products/udmPro.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/udmProMax.js +1 -1
- package/lib/components/ModelCompareV3/data/products/udmProMax.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/udmProSpecial.js +1 -1
- package/lib/components/ModelCompareV3/data/products/udmProSpecial.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js +1 -6
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs +1 -6
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js +0 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs +0 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.js +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.mjs +2 -2
- package/lib/constants/footerContent.d.ts +145 -0
- package/lib/constants/footerContent.js +313 -0
- package/lib/constants/footerContent.js.map +1 -0
- package/lib/constants/footerContent.mjs +293 -0
- package/lib/constants/footerContent.mjs.map +1 -0
- package/lib/constants/icons/options/colors/black.svg.js +5 -5
- package/lib/constants/icons/options/colors/index.js +3 -3
- package/lib/constants/icons/options/styles/black.svg.js +5 -5
- package/lib/constants/icons/options/styles/index.js +3 -3
- package/lib/constants/optionIcons.js +6 -6
- package/lib/constants/optionIcons.mjs +4 -4
- package/lib/constants/proStoreCategories/mapping/index.d.ts +0 -3
- package/lib/constants/proStoreCategories/mapping/index.js +10 -20
- package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/index.mjs +10 -20
- package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.d.ts +1 -3
- package/lib/constants/proStoreCategories/mapping/unifi.js +0 -2
- package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.mjs +0 -2
- package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/ar.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/ar.json.mjs +1 -1
- package/lib/constants/proStoreCategories/translations/de.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/de.json.mjs +1 -1
- package/lib/constants/proStoreCategories/translations/el.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/el.json.mjs +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.js +0 -5
- package/lib/constants/proStoreCategories/translations/en.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.mjs +1 -5
- package/lib/constants/proStoreCategories/translations/en.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/es.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/es.json.mjs +1 -1
- package/lib/constants/proStoreCategories/translations/fr.json.js +2 -2
- package/lib/constants/proStoreCategories/translations/fr.json.mjs +2 -2
- package/lib/constants/proStoreCategories/translations/it.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/it.json.mjs +1 -1
- package/lib/constants/proStoreCategories/translations/ja.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/ja.json.mjs +1 -1
- package/lib/constants/proStoreCategories/translations/pt-BR.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +2 -2
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +2 -2
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +2 -2
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +2 -2
- package/lib/constants/url.d.ts +4 -4
- package/lib/constants/url.js +4 -4
- package/lib/constants/url.js.map +1 -1
- package/lib/constants/url.mjs +4 -4
- package/lib/constants/url.mjs.map +1 -1
- package/lib/contexts/MenuContext/mapping.js +0 -41
- package/lib/contexts/MenuContext/mapping.js.map +1 -1
- package/lib/contexts/MenuContext/mapping.mjs +0 -41
- package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
- package/lib/contexts/MenuContext/presets.js.map +1 -1
- package/lib/contexts/MenuContext/presets.mjs.map +1 -1
- package/lib/helpers/index.d.ts +1 -0
- package/lib/helpers/index.js +12 -0
- package/lib/helpers/index.js.map +1 -1
- package/lib/helpers/index.mjs +1 -0
- package/lib/helpers/index.mjs.map +1 -1
- package/lib/helpers/product.d.ts +96 -0
- package/lib/helpers/product.js +360 -0
- package/lib/helpers/product.js.map +1 -0
- package/lib/helpers/product.mjs +348 -0
- package/lib/helpers/product.mjs.map +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +2 -0
- package/lib/types/index.js.map +1 -1
- package/lib/types/index.mjs +1 -0
- package/lib/types/index.mjs.map +1 -1
- package/lib/types/product.d.ts +87 -0
- package/lib/types/product.js +14 -0
- package/lib/types/product.js.map +1 -0
- package/lib/types/product.mjs +13 -0
- package/lib/types/product.mjs.map +1 -0
- package/lib/utils/address.d.ts +61 -61
- package/lib/utils/array.d.ts +4 -0
- package/lib/utils/array.js +10 -0
- package/lib/utils/array.js.map +1 -1
- package/lib/utils/array.mjs +10 -1
- package/lib/utils/array.mjs.map +1 -1
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -2
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/index.mjs +0 -2
- package/lib/utils/index.mjs.map +1 -1
- package/lib/utils/money/constants.d.ts +25 -56
- package/lib/utils/money/constants.js +7 -72
- package/lib/utils/money/constants.js.map +1 -1
- package/lib/utils/money/constants.mjs +7 -70
- package/lib/utils/money/constants.mjs.map +1 -1
- package/lib/utils/money/format.d.ts +5 -10
- package/lib/utils/money/format.js +14 -22
- package/lib/utils/money/format.js.map +1 -1
- package/lib/utils/money/format.mjs +16 -23
- package/lib/utils/money/format.mjs.map +1 -1
- package/lib/utils/money/index.d.ts +1 -4
- package/lib/utils/money/index.js +8 -26
- package/lib/utils/money/index.js.map +1 -1
- package/lib/utils/money/index.mjs +4 -8
- package/lib/utils/money/index.mjs.map +1 -1
- package/lib/utils/money/misc.d.ts +28 -68
- package/lib/utils/money/misc.js +64 -35
- package/lib/utils/money/misc.js.map +1 -1
- package/lib/utils/money/misc.mjs +43 -32
- package/lib/utils/money/misc.mjs.map +1 -1
- package/lib/utils/money/tax.d.ts +2 -38
- package/lib/utils/money/tax.js +10 -46
- package/lib/utils/money/tax.js.map +1 -1
- package/lib/utils/money/tax.mjs +11 -42
- package/lib/utils/money/tax.mjs.map +1 -1
- package/lib/utils/money/types.d.ts +3 -78
- package/lib/utils/number.d.ts +1 -1
- package/lib/utils/number.js +1 -1
- package/lib/utils/number.js.map +1 -1
- package/lib/utils/number.mjs +1 -1
- package/lib/utils/number.mjs.map +1 -1
- package/lib/utils/productSort.d.ts +41 -0
- package/lib/utils/productSort.js +66 -0
- package/lib/utils/productSort.js.map +1 -0
- package/lib/utils/productSort.mjs +59 -0
- package/lib/utils/productSort.mjs.map +1 -0
- package/lib/utils/validations.d.ts +15 -0
- package/lib/utils/validations.js +23 -0
- package/lib/utils/validations.js.map +1 -0
- package/lib/utils/validations.mjs +21 -0
- package/lib/utils/validations.mjs.map +1 -0
- package/package.json +1 -1
- package/lib/assets/socialMedia/x.svg.js.map +0 -1
- package/lib/assets/socialMedia/x.svg.mjs +0 -3
- package/lib/assets/socialMedia/x.svg.mjs.map +0 -1
- package/lib/assets/x.svg +0 -3
- package/lib/components/Footer/hooks/useFooterContent.d.ts +0 -94
- package/lib/components/Footer/hooks/useFooterContent.js +0 -384
- package/lib/components/Footer/hooks/useFooterContent.js.map +0 -1
- package/lib/components/Footer/hooks/useFooterContent.mjs +0 -348
- package/lib/components/Footer/hooks/useFooterContent.mjs.map +0 -1
- package/lib/components/Footer/translations/ar.json.js +0 -47
- package/lib/components/Footer/translations/ar.json.js.map +0 -1
- package/lib/components/Footer/translations/ar.json.mjs +0 -42
- package/lib/components/Footer/translations/ar.json.mjs.map +0 -1
- package/lib/components/Footer/translations/de.json.js +0 -47
- package/lib/components/Footer/translations/de.json.js.map +0 -1
- package/lib/components/Footer/translations/de.json.mjs +0 -42
- package/lib/components/Footer/translations/de.json.mjs.map +0 -1
- package/lib/components/Footer/translations/el.json.js +0 -47
- package/lib/components/Footer/translations/el.json.js.map +0 -1
- package/lib/components/Footer/translations/el.json.mjs +0 -42
- package/lib/components/Footer/translations/el.json.mjs.map +0 -1
- package/lib/components/Footer/translations/en.json.js +0 -46
- package/lib/components/Footer/translations/en.json.js.map +0 -1
- package/lib/components/Footer/translations/en.json.mjs +0 -41
- package/lib/components/Footer/translations/en.json.mjs.map +0 -1
- package/lib/components/Footer/translations/es.json.js +0 -47
- package/lib/components/Footer/translations/es.json.js.map +0 -1
- package/lib/components/Footer/translations/es.json.mjs +0 -42
- package/lib/components/Footer/translations/es.json.mjs.map +0 -1
- package/lib/components/Footer/translations/fr.json.js +0 -47
- package/lib/components/Footer/translations/fr.json.js.map +0 -1
- package/lib/components/Footer/translations/fr.json.mjs +0 -42
- package/lib/components/Footer/translations/fr.json.mjs.map +0 -1
- package/lib/components/Footer/translations/it.json.js +0 -47
- package/lib/components/Footer/translations/it.json.js.map +0 -1
- package/lib/components/Footer/translations/it.json.mjs +0 -42
- package/lib/components/Footer/translations/it.json.mjs.map +0 -1
- package/lib/components/Footer/translations/ja.json.js +0 -47
- package/lib/components/Footer/translations/ja.json.js.map +0 -1
- package/lib/components/Footer/translations/ja.json.mjs +0 -42
- package/lib/components/Footer/translations/ja.json.mjs.map +0 -1
- package/lib/components/Footer/translations/pt-BR.json.js +0 -47
- package/lib/components/Footer/translations/pt-BR.json.js.map +0 -1
- package/lib/components/Footer/translations/pt-BR.json.mjs +0 -42
- package/lib/components/Footer/translations/pt-BR.json.mjs.map +0 -1
- package/lib/components/Footer/translations/zh-Hans.json.js +0 -47
- package/lib/components/Footer/translations/zh-Hans.json.js.map +0 -1
- package/lib/components/Footer/translations/zh-Hans.json.mjs +0 -42
- package/lib/components/Footer/translations/zh-Hans.json.mjs.map +0 -1
- package/lib/components/Footer/translations/zh-Hant-TW.json.js +0 -47
- package/lib/components/Footer/translations/zh-Hant-TW.json.js.map +0 -1
- package/lib/components/Footer/translations/zh-Hant-TW.json.mjs +0 -42
- package/lib/components/Footer/translations/zh-Hant-TW.json.mjs.map +0 -1
- package/lib/components/Tooltip/Tooltip.d.ts +0 -2
- package/lib/components/Tooltip/Tooltip.js +0 -45
- package/lib/components/Tooltip/Tooltip.js.map +0 -1
- package/lib/components/Tooltip/Tooltip.mjs +0 -43
- package/lib/components/Tooltip/Tooltip.mjs.map +0 -1
- package/lib/components/Tooltip/Tooltip.styles.d.ts +0 -32
- package/lib/components/Tooltip/Tooltip.styles.js +0 -44
- package/lib/components/Tooltip/Tooltip.styles.js.map +0 -1
- package/lib/components/Tooltip/Tooltip.styles.mjs +0 -34
- package/lib/components/Tooltip/Tooltip.styles.mjs.map +0 -1
- package/lib/components/Tooltip/index.d.ts +0 -1
- package/lib/components/Tooltip/index.js +0 -6
- package/lib/components/Tooltip/index.js.map +0 -1
- package/lib/components/Tooltip/index.mjs +0 -3
- package/lib/components/Tooltip/index.mjs.map +0 -1
- package/lib/utils/money/allocators/fixedAmount.d.ts +0 -26
- package/lib/utils/money/allocators/fixedAmount.js +0 -55
- package/lib/utils/money/allocators/fixedAmount.js.map +0 -1
- package/lib/utils/money/allocators/fixedAmount.mjs +0 -53
- package/lib/utils/money/allocators/fixedAmount.mjs.map +0 -1
- package/lib/utils/money/allocators/index.d.ts +0 -2
- package/lib/utils/money/allocators/index.js +0 -8
- package/lib/utils/money/allocators/index.js.map +0 -1
- package/lib/utils/money/allocators/index.mjs +0 -4
- package/lib/utils/money/allocators/index.mjs.map +0 -1
- package/lib/utils/money/allocators/productAmount.d.ts +0 -13
- package/lib/utils/money/allocators/productAmount.js +0 -110
- package/lib/utils/money/allocators/productAmount.js.map +0 -1
- package/lib/utils/money/allocators/productAmount.mjs +0 -108
- package/lib/utils/money/allocators/productAmount.mjs.map +0 -1
- package/lib/utils/money/exchangeRate.d.ts +0 -31
- package/lib/utils/money/exchangeRate.js +0 -27
- package/lib/utils/money/exchangeRate.js.map +0 -1
- package/lib/utils/money/exchangeRate.mjs +0 -23
- package/lib/utils/money/exchangeRate.mjs.map +0 -1
- package/lib/utils/money/misc.private.d.ts +0 -23
- package/lib/utils/money/misc.private.js +0 -46
- package/lib/utils/money/misc.private.js.map +0 -1
- package/lib/utils/money/misc.private.mjs +0 -21
- package/lib/utils/money/misc.private.mjs.map +0 -1
- package/lib/utils/money/shipping.d.ts +0 -5
- package/lib/utils/money/shipping.js +0 -8
- package/lib/utils/money/shipping.js.map +0 -1
- package/lib/utils/money/shipping.mjs +0 -6
- package/lib/utils/money/shipping.mjs.map +0 -1
- package/lib/utils/money/tax.private.d.ts +0 -17
- package/lib/utils/money/tax.private.js +0 -65
- package/lib/utils/money/tax.private.js.map +0 -1
- package/lib/utils/money/tax.private.mjs +0 -60
- package/lib/utils/money/tax.private.mjs.map +0 -1
- package/lib/utils/typeGuards.d.ts +0 -1
- package/lib/utils/typeGuards.js +0 -6
- package/lib/utils/typeGuards.js.map +0 -1
- package/lib/utils/typeGuards.mjs +0 -5
- package/lib/utils/typeGuards.mjs.map +0 -1
package/lib/utils/number.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.mjs","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(
|
|
1
|
+
{"version":3,"file":"number.mjs","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(rate: number, scale: number): string;\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber: true,\n): number;\nexport function toFixedRate(rate: number, scale = 0, asNumber = false) {\n // Verify rate\n isFloat(rate, \"Rate\");\n\n const fixedRate = rate.toFixed(scale);\n\n return asNumber ? +fixedRate : fixedRate;\n}\n\n/**\n * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of\n * doing it. Removes any redundant trailing zeros.\n * @example\n * numberToString(1.23) // => \"1.23\"\n * numberToString(10.00) // => \"10\"\n * @throws If given input is not a valid number\n */\nexport const numberToString = (num: number): string => {\n isFloat(num);\n return num.toString(10);\n};\n\n/**\n * @see https://stackoverflow.com/a/35000557\n */\nexport const findClosestNumber = <T extends number>(\n haystack: T[],\n needle: number,\n): T => {\n return haystack.reduce((prev, curr) =>\n Math.abs(curr - needle) < Math.abs(prev - needle) ? curr : prev,\n );\n};\n\n/**\n * Splits number into array by max value provided.\n * E.g. splitNumberBy(100, 30) => [30, 30, 30, 10]\n */\nexport const splitNumberBy = (value: number, by: number) => {\n const chunks = new Array(Math.floor(value / by)).fill(by);\n const remainder = value % by;\n\n if (remainder > 0) {\n chunks.push(remainder);\n }\n\n return chunks;\n};\n\n/**\n * Clamp value to a given range\n */\nexport const clamp = (val: number, min: number, max: number) => {\n const trueMin = Math.min(min, max);\n const trueMax = Math.max(min, max);\n\n return Math.min(trueMax, Math.max(trueMin, val));\n};\n\n/**\n * Interpolate a number to a new range\n *\n * @example\n * linearInterpolate(5, [0, 10], [0, 100]); // 50\n */\nexport const linearInterpolate = (\n inputY: number,\n [fromMin, fromMax]: [number, number],\n [toMin, toMax]: [number, number],\n clampResult = true,\n) => {\n const percent = (inputY - fromMin) / (fromMax - fromMin);\n const outputX = percent * (toMax - toMin) + toMin;\n\n return clampResult ? clamp(outputX, toMin, toMax) : outputX;\n};\n\n/**\n * Increase value and start over once the range is overflown\n */\nexport const incrementLoopValue = (\n value: number,\n [min, max]: [number, number],\n) => {\n if (value === max) {\n return min;\n }\n return value + 1;\n};\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger","isFloat","toFixedRate","rate","scale","asNumber","fixedRate","toFixed","numberToString","num","toString","findClosestNumber","haystack","needle","reduce","prev","curr","Math","abs","splitNumberBy","by","chunks","Array","floor","fill","remainder","push","clamp","val","min","max","trueMin","trueMax","linearInterpolate","inputY","fromMin","fromMax","toMin","toMax","clampResult","percent","outputX","incrementLoopValue"],"mappings":"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"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Nullish, StorefrontProduct, StoreId, UnionToAllPossibleTuples } from "../types";
|
|
2
|
+
import { DisplayProductStatus } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Narrow MinimalProProductFragment type even more to the union of fields that are needed to sort product
|
|
5
|
+
*/
|
|
6
|
+
type ProductMinFieldsForSorting = Pick<StorefrontProduct, "status" | "tags" | "minDisplayPrice"> & {
|
|
7
|
+
variants: {
|
|
8
|
+
availableInOtherStores: Array<{
|
|
9
|
+
__typename: string;
|
|
10
|
+
}>;
|
|
11
|
+
}[];
|
|
12
|
+
linkedProducts?: {
|
|
13
|
+
status: StorefrontProduct["status"];
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
export declare enum Sort {
|
|
17
|
+
HighestPrice = "highest-price",
|
|
18
|
+
LowestPrice = "lowest-price",
|
|
19
|
+
Availability = "availability"
|
|
20
|
+
}
|
|
21
|
+
export declare enum SortOrder {
|
|
22
|
+
Asc = "Asc",
|
|
23
|
+
Desc = "Desc"
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Variants statuses sorted in ascending order from least preferable to most, so if some new status comes in, then the
|
|
27
|
+
* lookup for `.indexOf()` would return `-1`, thus being "worse" then DisplayProductStatus.SoldOut and moved to the very
|
|
28
|
+
* back of list
|
|
29
|
+
*/
|
|
30
|
+
export declare const sortedStatusesByPriorityAsc: UnionToAllPossibleTuples<DisplayProductStatus>;
|
|
31
|
+
export declare const sortByAvailabilityDesc: (current: ProductMinFieldsForSorting, next: ProductMinFieldsForSorting) => number;
|
|
32
|
+
export declare const sortByPrice: (order: SortOrder) => (current: ProductMinFieldsForSorting, next: ProductMinFieldsForSorting) => number;
|
|
33
|
+
/**
|
|
34
|
+
* Sorts products based on the given sort type.
|
|
35
|
+
* @param currentSort - sort type
|
|
36
|
+
* @param sortByWeightTag - if false, then sort by weight tag is
|
|
37
|
+
* ignored (e.g. for `Related Add-ons` where
|
|
38
|
+
* we don't want to sort by weight tag)
|
|
39
|
+
*/
|
|
40
|
+
export declare const sortProducts: (currentSort: Nullish<string | Sort>, storeId?: StoreId, sortByWeightTag?: boolean) => (current: ProductMinFieldsForSorting, next: ProductMinFieldsForSorting) => number;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../types/index.js');
|
|
4
|
+
var array = require('./array.js');
|
|
5
|
+
var product$1 = require('./product.js');
|
|
6
|
+
var product = require('../types/product.js');
|
|
7
|
+
"use strict";
|
|
8
|
+
var Sort = /* @__PURE__ */(Sort2 => {
|
|
9
|
+
Sort2["HighestPrice"] = "highest-price";
|
|
10
|
+
Sort2["LowestPrice"] = "lowest-price";
|
|
11
|
+
Sort2["Availability"] = "availability";
|
|
12
|
+
return Sort2;
|
|
13
|
+
})(Sort || {});
|
|
14
|
+
var SortOrder = /* @__PURE__ */(SortOrder2 => {
|
|
15
|
+
SortOrder2["Asc"] = "Asc";
|
|
16
|
+
SortOrder2["Desc"] = "Desc";
|
|
17
|
+
return SortOrder2;
|
|
18
|
+
})(SortOrder || {});
|
|
19
|
+
const sortedStatusesByPriorityAsc = [product.DisplayProductStatus.Unavailable, product.DisplayProductStatus.ComingSoon, product.DisplayProductStatus.SoldOut, product.DisplayProductStatus.RegionNotAvailable, product.DisplayProductStatus.Backorder, product.DisplayProductStatus.Available];
|
|
20
|
+
const getProductStatusPriority = product$1 => {
|
|
21
|
+
let sortStatus = product$1.status;
|
|
22
|
+
if (product$1.variants.some(variant => variant.availableInOtherStores.length) || product$1.linkedProducts && product$1.linkedProducts.some(linkedProduct => linkedProduct.status === product.DisplayProductStatus.Available)) {
|
|
23
|
+
sortStatus = product.DisplayProductStatus.Available;
|
|
24
|
+
}
|
|
25
|
+
return sortedStatusesByPriorityAsc.indexOf(sortStatus);
|
|
26
|
+
};
|
|
27
|
+
const sortByAvailabilityDesc = (current, next) => {
|
|
28
|
+
return array.normalizeSortResult(getProductStatusPriority(next) - getProductStatusPriority(current));
|
|
29
|
+
};
|
|
30
|
+
const sortByPrice = order => (current, next) => {
|
|
31
|
+
const currentProductPrice = current.minDisplayPrice.amount;
|
|
32
|
+
const nextProductPrice = next.minDisplayPrice.amount;
|
|
33
|
+
if (order === "Desc" /* Desc */) {
|
|
34
|
+
return nextProductPrice - currentProductPrice;
|
|
35
|
+
} else {
|
|
36
|
+
return currentProductPrice - nextProductPrice;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const sortProducts = (currentSort, storeId, sortByWeightTag = true) => (current, next) => {
|
|
40
|
+
switch (currentSort) {
|
|
41
|
+
case "highest-price" /* HighestPrice */:
|
|
42
|
+
case "lowest-price" /* LowestPrice */:
|
|
43
|
+
{
|
|
44
|
+
return sortByPrice(currentSort === "highest-price" /* HighestPrice */ ? "Desc" /* Desc */ : "Asc" /* Asc */)(current, next);
|
|
45
|
+
}
|
|
46
|
+
case "availability" /* Availability */:
|
|
47
|
+
{
|
|
48
|
+
return sortByAvailabilityDesc(current, next);
|
|
49
|
+
}
|
|
50
|
+
default:
|
|
51
|
+
{
|
|
52
|
+
const sorts = [sortByAvailabilityDesc];
|
|
53
|
+
if (sortByWeightTag) {
|
|
54
|
+
sorts.push(product$1.sortByTagWeight(product$1.SortSiteId.Store, storeId));
|
|
55
|
+
}
|
|
56
|
+
return array.combineSorts(sorts)(current, next);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
exports.Sort = Sort;
|
|
61
|
+
exports.SortOrder = SortOrder;
|
|
62
|
+
exports.sortByAvailabilityDesc = sortByAvailabilityDesc;
|
|
63
|
+
exports.sortByPrice = sortByPrice;
|
|
64
|
+
exports.sortProducts = sortProducts;
|
|
65
|
+
exports.sortedStatusesByPriorityAsc = sortedStatusesByPriorityAsc;
|
|
66
|
+
//# sourceMappingURL=productSort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productSort.js","sources":["../../src/utils/productSort.ts"],"sourcesContent":["import type { Nullish, StorefrontProduct, StoreId, UnionToAllPossibleTuples } from \"../types\";\nimport { DisplayProductStatus } from \"../types\";\nimport { combineSorts, normalizeSortResult } from \"./array\";\nimport { sortByTagWeight, SortSiteId } from \"./product\";\n\n/**\n * Narrow MinimalProProductFragment type even more to the union of fields that are needed to sort product\n */\ntype ProductMinFieldsForSorting = Pick<\n StorefrontProduct,\n \"status\" | \"tags\" | \"minDisplayPrice\"\n> & {\n variants: {\n // We only need bare minimum from array to compare array length\n // FIXME: move it to backend as a boolean field so we don't need to fetch entire array to reduce it to a boolean ourselves\n availableInOtherStores: Array<{ __typename: string }>;\n }[];\n linkedProducts?: {\n status: StorefrontProduct[\"status\"];\n }[];\n};\n\nexport enum Sort {\n HighestPrice = \"highest-price\",\n LowestPrice = \"lowest-price\",\n Availability = \"availability\",\n}\n\nexport enum SortOrder {\n Asc = \"Asc\",\n Desc = \"Desc\",\n}\n\n/**\n * Variants statuses sorted in ascending order from least preferable to most, so if some new status comes in, then the\n * lookup for `.indexOf()` would return `-1`, thus being \"worse\" then DisplayProductStatus.SoldOut and moved to the very\n * back of list\n */\nexport const sortedStatusesByPriorityAsc: UnionToAllPossibleTuples<DisplayProductStatus> =\n [\n DisplayProductStatus.Unavailable,\n DisplayProductStatus.ComingSoon,\n DisplayProductStatus.SoldOut,\n DisplayProductStatus.RegionNotAvailable,\n DisplayProductStatus.Backorder,\n DisplayProductStatus.Available,\n ];\n/**\n * Due to currently variant status being nullable for historical reasons we need to have a fallback state\n * TODO: remove once display status is StorefrontProductVariant.status is non-nullable\n */\nconst getProductStatusPriority = (\n product: ProductMinFieldsForSorting,\n): number => {\n let sortStatus = product.status;\n\n // Virtually set sort status as available if it has alternative stores\n if (\n product.variants.some((variant) => variant.availableInOtherStores.length) ||\n (product.linkedProducts &&\n product.linkedProducts.some(\n (linkedProduct) =>\n linkedProduct.status === DisplayProductStatus.Available,\n ))\n ) {\n sortStatus = DisplayProductStatus.Available;\n }\n\n return sortedStatusesByPriorityAsc.indexOf(sortStatus);\n};\n\nexport const sortByAvailabilityDesc = (\n current: ProductMinFieldsForSorting,\n next: ProductMinFieldsForSorting,\n): number => {\n return normalizeSortResult(\n getProductStatusPriority(next) - getProductStatusPriority(current),\n );\n};\n\nexport const sortByPrice =\n (order: SortOrder) => (\n current: ProductMinFieldsForSorting,\n next: ProductMinFieldsForSorting,\n ): number => {\n const currentProductPrice = current.minDisplayPrice.amount;\n\n const nextProductPrice = next.minDisplayPrice.amount;\n\n if (order === SortOrder.Desc) {\n return nextProductPrice - currentProductPrice;\n } else {\n return currentProductPrice - nextProductPrice;\n }\n };\n\n\n/**\n * Sorts products based on the given sort type.\n * @param currentSort - sort type\n * @param sortByWeightTag - if false, then sort by weight tag is\n * ignored (e.g. for `Related Add-ons` where\n * we don't want to sort by weight tag)\n */\nexport const sortProducts = (\n currentSort: Nullish<string | Sort>,\n storeId?: StoreId,\n sortByWeightTag = true,\n ) =>\n (current: ProductMinFieldsForSorting, next: ProductMinFieldsForSorting) => {\n switch (currentSort) {\n // Sort by price\n case Sort.HighestPrice:\n case Sort.LowestPrice: {\n return sortByPrice(\n currentSort === Sort.HighestPrice ? SortOrder.Desc : SortOrder.Asc,\n )(current, next);\n }\n\n case Sort.Availability: {\n return sortByAvailabilityDesc(current, next);\n }\n\n default: {\n const sorts = [sortByAvailabilityDesc];\n\n // Add sorting by tag weight\n if (sortByWeightTag) {\n sorts.push(sortByTagWeight(SortSiteId.Store, storeId));\n }\n\n // Do additional sorting by tag weight only after initial sorting resulting in \"same group\"\n return combineSorts(sorts)(current, next);\n }\n }\n };"],"names":["Sort","SortOrder","sortedStatusesByPriorityAsc","DisplayProductStatus","Unavailable","ComingSoon","SoldOut","RegionNotAvailable","Backorder","Available","getProductStatusPriority","product","sortStatus","status","variants","some","variant","availableInOtherStores","length","linkedProducts","linkedProduct","indexOf","sortByAvailabilityDesc","current","next","normalizeSortResult","sortByPrice","order","currentProductPrice","minDisplayPrice","amount","nextProductPrice","sortProducts","currentSort","storeId","sortByWeightTag","sorts","push","sortByTagWeight","SortSiteId","Store","combineSorts"],"mappings":"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"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import '../types/index.mjs';
|
|
2
|
+
import { normalizeSortResult, combineSorts } from './array.mjs';
|
|
3
|
+
import { sortByTagWeight, SortSiteId } from './product.mjs';
|
|
4
|
+
import { DisplayProductStatus } from '../types/product.mjs';
|
|
5
|
+
"use strict";
|
|
6
|
+
var Sort = /* @__PURE__ */(Sort2 => {
|
|
7
|
+
Sort2["HighestPrice"] = "highest-price";
|
|
8
|
+
Sort2["LowestPrice"] = "lowest-price";
|
|
9
|
+
Sort2["Availability"] = "availability";
|
|
10
|
+
return Sort2;
|
|
11
|
+
})(Sort || {});
|
|
12
|
+
var SortOrder = /* @__PURE__ */(SortOrder2 => {
|
|
13
|
+
SortOrder2["Asc"] = "Asc";
|
|
14
|
+
SortOrder2["Desc"] = "Desc";
|
|
15
|
+
return SortOrder2;
|
|
16
|
+
})(SortOrder || {});
|
|
17
|
+
const sortedStatusesByPriorityAsc = [DisplayProductStatus.Unavailable, DisplayProductStatus.ComingSoon, DisplayProductStatus.SoldOut, DisplayProductStatus.RegionNotAvailable, DisplayProductStatus.Backorder, DisplayProductStatus.Available];
|
|
18
|
+
const getProductStatusPriority = product => {
|
|
19
|
+
let sortStatus = product.status;
|
|
20
|
+
if (product.variants.some(variant => variant.availableInOtherStores.length) || product.linkedProducts && product.linkedProducts.some(linkedProduct => linkedProduct.status === DisplayProductStatus.Available)) {
|
|
21
|
+
sortStatus = DisplayProductStatus.Available;
|
|
22
|
+
}
|
|
23
|
+
return sortedStatusesByPriorityAsc.indexOf(sortStatus);
|
|
24
|
+
};
|
|
25
|
+
const sortByAvailabilityDesc = (current, next) => {
|
|
26
|
+
return normalizeSortResult(getProductStatusPriority(next) - getProductStatusPriority(current));
|
|
27
|
+
};
|
|
28
|
+
const sortByPrice = order => (current, next) => {
|
|
29
|
+
const currentProductPrice = current.minDisplayPrice.amount;
|
|
30
|
+
const nextProductPrice = next.minDisplayPrice.amount;
|
|
31
|
+
if (order === "Desc" /* Desc */) {
|
|
32
|
+
return nextProductPrice - currentProductPrice;
|
|
33
|
+
} else {
|
|
34
|
+
return currentProductPrice - nextProductPrice;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const sortProducts = (currentSort, storeId, sortByWeightTag = true) => (current, next) => {
|
|
38
|
+
switch (currentSort) {
|
|
39
|
+
case "highest-price" /* HighestPrice */:
|
|
40
|
+
case "lowest-price" /* LowestPrice */:
|
|
41
|
+
{
|
|
42
|
+
return sortByPrice(currentSort === "highest-price" /* HighestPrice */ ? "Desc" /* Desc */ : "Asc" /* Asc */)(current, next);
|
|
43
|
+
}
|
|
44
|
+
case "availability" /* Availability */:
|
|
45
|
+
{
|
|
46
|
+
return sortByAvailabilityDesc(current, next);
|
|
47
|
+
}
|
|
48
|
+
default:
|
|
49
|
+
{
|
|
50
|
+
const sorts = [sortByAvailabilityDesc];
|
|
51
|
+
if (sortByWeightTag) {
|
|
52
|
+
sorts.push(sortByTagWeight(SortSiteId.Store, storeId));
|
|
53
|
+
}
|
|
54
|
+
return combineSorts(sorts)(current, next);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
export { Sort, SortOrder, sortByAvailabilityDesc, sortByPrice, sortProducts, sortedStatusesByPriorityAsc };
|
|
59
|
+
//# sourceMappingURL=productSort.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"productSort.mjs","sources":["../../src/utils/productSort.ts"],"sourcesContent":["import type { Nullish, StorefrontProduct, StoreId, UnionToAllPossibleTuples } from \"../types\";\nimport { DisplayProductStatus } from \"../types\";\nimport { combineSorts, normalizeSortResult } from \"./array\";\nimport { sortByTagWeight, SortSiteId } from \"./product\";\n\n/**\n * Narrow MinimalProProductFragment type even more to the union of fields that are needed to sort product\n */\ntype ProductMinFieldsForSorting = Pick<\n StorefrontProduct,\n \"status\" | \"tags\" | \"minDisplayPrice\"\n> & {\n variants: {\n // We only need bare minimum from array to compare array length\n // FIXME: move it to backend as a boolean field so we don't need to fetch entire array to reduce it to a boolean ourselves\n availableInOtherStores: Array<{ __typename: string }>;\n }[];\n linkedProducts?: {\n status: StorefrontProduct[\"status\"];\n }[];\n};\n\nexport enum Sort {\n HighestPrice = \"highest-price\",\n LowestPrice = \"lowest-price\",\n Availability = \"availability\",\n}\n\nexport enum SortOrder {\n Asc = \"Asc\",\n Desc = \"Desc\",\n}\n\n/**\n * Variants statuses sorted in ascending order from least preferable to most, so if some new status comes in, then the\n * lookup for `.indexOf()` would return `-1`, thus being \"worse\" then DisplayProductStatus.SoldOut and moved to the very\n * back of list\n */\nexport const sortedStatusesByPriorityAsc: UnionToAllPossibleTuples<DisplayProductStatus> =\n [\n DisplayProductStatus.Unavailable,\n DisplayProductStatus.ComingSoon,\n DisplayProductStatus.SoldOut,\n DisplayProductStatus.RegionNotAvailable,\n DisplayProductStatus.Backorder,\n DisplayProductStatus.Available,\n ];\n/**\n * Due to currently variant status being nullable for historical reasons we need to have a fallback state\n * TODO: remove once display status is StorefrontProductVariant.status is non-nullable\n */\nconst getProductStatusPriority = (\n product: ProductMinFieldsForSorting,\n): number => {\n let sortStatus = product.status;\n\n // Virtually set sort status as available if it has alternative stores\n if (\n product.variants.some((variant) => variant.availableInOtherStores.length) ||\n (product.linkedProducts &&\n product.linkedProducts.some(\n (linkedProduct) =>\n linkedProduct.status === DisplayProductStatus.Available,\n ))\n ) {\n sortStatus = DisplayProductStatus.Available;\n }\n\n return sortedStatusesByPriorityAsc.indexOf(sortStatus);\n};\n\nexport const sortByAvailabilityDesc = (\n current: ProductMinFieldsForSorting,\n next: ProductMinFieldsForSorting,\n): number => {\n return normalizeSortResult(\n getProductStatusPriority(next) - getProductStatusPriority(current),\n );\n};\n\nexport const sortByPrice =\n (order: SortOrder) => (\n current: ProductMinFieldsForSorting,\n next: ProductMinFieldsForSorting,\n ): number => {\n const currentProductPrice = current.minDisplayPrice.amount;\n\n const nextProductPrice = next.minDisplayPrice.amount;\n\n if (order === SortOrder.Desc) {\n return nextProductPrice - currentProductPrice;\n } else {\n return currentProductPrice - nextProductPrice;\n }\n };\n\n\n/**\n * Sorts products based on the given sort type.\n * @param currentSort - sort type\n * @param sortByWeightTag - if false, then sort by weight tag is\n * ignored (e.g. for `Related Add-ons` where\n * we don't want to sort by weight tag)\n */\nexport const sortProducts = (\n currentSort: Nullish<string | Sort>,\n storeId?: StoreId,\n sortByWeightTag = true,\n ) =>\n (current: ProductMinFieldsForSorting, next: ProductMinFieldsForSorting) => {\n switch (currentSort) {\n // Sort by price\n case Sort.HighestPrice:\n case Sort.LowestPrice: {\n return sortByPrice(\n currentSort === Sort.HighestPrice ? SortOrder.Desc : SortOrder.Asc,\n )(current, next);\n }\n\n case Sort.Availability: {\n return sortByAvailabilityDesc(current, next);\n }\n\n default: {\n const sorts = [sortByAvailabilityDesc];\n\n // Add sorting by tag weight\n if (sortByWeightTag) {\n sorts.push(sortByTagWeight(SortSiteId.Store, storeId));\n }\n\n // Do additional sorting by tag weight only after initial sorting resulting in \"same group\"\n return combineSorts(sorts)(current, next);\n }\n }\n };"],"names":["Sort","SortOrder","sortedStatusesByPriorityAsc","DisplayProductStatus","Unavailable","ComingSoon","SoldOut","RegionNotAvailable","Backorder","Available","getProductStatusPriority","product","sortStatus","status","variants","some","variant","availableInOtherStores","length","linkedProducts","linkedProduct","indexOf","sortByAvailabilityDesc","current","next","normalizeSortResult","sortByPrice","order","currentProductPrice","minDisplayPrice","amount","nextProductPrice","sortProducts","currentSort","storeId","sortByWeightTag","sorts","push","sortByTagWeight","SortSiteId","Store","combineSorts"],"mappings":";;;;;AAsBY,IAAAA,IAAA,GAAA,gBAAAA,KAAL,IAAA;EACLA,MAAA,cAAe,CAAA,GAAA,eAAA;EACfA,MAAA,aAAc,CAAA,GAAA,cAAA;EACdA,MAAA,cAAe,CAAA,GAAA,cAAA;EAHLA,OAAAA,KAAAA;AAAA,CAAA,EAAAA,IAAA,IAAA,CAAA,CAAA,CAAA;AAMA,IAAAC,SAAA,GAAA,gBAAAA,UAAL,IAAA;EACLA,WAAA,KAAM,CAAA,GAAA,KAAA;EACNA,WAAA,MAAO,CAAA,GAAA,MAAA;EAFGA,OAAAA,UAAAA;AAAA,CAAA,EAAAA,SAAA,IAAA,CAAA,CAAA,CAAA;AAUL,MAAMC,2BACX,GAAA,CACEC,oBAAqB,CAAAC,WAAA,EACrBD,oBAAqB,CAAAE,UAAA,EACrBF,oBAAqB,CAAAG,OAAA,EACrBH,oBAAqB,CAAAI,kBAAA,EACrBJ,oBAAqB,CAAAK,SAAA,EACrBL,oBAAqB,CAAAM,SAAA,CACvB;AAKF,MAAMC,wBAAA,GACJC,OACW,IAAA;EACX,IAAIC,aAAaD,OAAQ,CAAAE,MAAA;EAGzB,IACEF,OAAQ,CAAAG,QAAA,CAASC,IAAK,CAACC,OAAY,IAAAA,OAAA,CAAQC,sBAAuB,CAAAC,MAAM,CACvE,IAAAP,OAAA,CAAQQ,cACP,IAAAR,OAAA,CAAQQ,cAAe,CAAAJ,IAAA,CACpBK,aAAA,IACCA,aAAc,CAAAP,MAAA,KAAWV,oBAAqB,CAAAM,SAAA,CAEpD,EAAA;IACAG,UAAA,GAAaT,oBAAqB,CAAAM,SAAA;EACpC;EAEO,OAAAP,2BAAA,CAA4BmB,QAAQT,UAAU,CAAA;AACvD,CAAA;AAEa,MAAAU,sBAAA,GAAyBA,CACpCC,OAAA,EACAC,IACW,KAAA;EACJ,OAAAC,mBAAA,CACLf,wBAAyB,CAAAc,IAAI,CAAI,GAAAd,wBAAA,CAAyBa,OAAO,CAAA,CACnE;AACF,CAAA;AAEO,MAAMG,WACX,GAACC,KAAqB,IAAA,CACpBJ,SACAC,IACW,KAAA;EACL,MAAAI,mBAAA,GAAsBL,QAAQM,eAAgB,CAAAC,MAAA;EAE9C,MAAAC,gBAAA,GAAmBP,KAAKK,eAAgB,CAAAC,MAAA;EAE9C,IAAIH,UAAU,MAAgB,CAAA,YAAA;IAC5B,OAAOI,gBAAmB,GAAAH,mBAAA;EAAA,CACrB,MAAA;IACL,OAAOA,mBAAsB,GAAAG,gBAAA;EAC/B;AACF,CAAA;AAUW,MAAAC,YAAA,GAAeA,CACxBC,WACA,EAAAC,OAAA,EACAC,kBAAkB,IAEpB,KAAA,CAACZ,SAAqCC,IAAqC,KAAA;EACzE,QAAQS,WAAa;IAEnB,KAAK,eAAA,CAAA;IACL,KAAK,cAAkB,CAAA;MAAA;QACd,OAAAP,WAAA,CACLO,WAAA,KAAgB,gBAAoB,qBAAA,MAAiB,cAAA,KAAA,CAAA,SAAA,CACvD,CAAEV,SAASC,IAAI,CAAA;MACjB;IAEA,KAAK,cAAmB,CAAA;MAAA;QACf,OAAAF,sBAAA,CAAuBC,SAASC,IAAI,CAAA;MAC7C;IAEA;MAAS;QACD,MAAAY,KAAA,GAAQ,CAACd,sBAAsB,CAAA;QAGrC,IAAIa,eAAiB,EAAA;UACnBC,KAAA,CAAMC,IAAK,CAAAC,eAAA,CAAgBC,UAAW,CAAAC,KAAA,EAAON,OAAO,CAAC,CAAA;QACvD;QAGA,OAAOO,YAAa,CAAAL,KAAK,CAAE,CAAAb,OAAA,EAASC,IAAI,CAAA;MAC1C;EACF;AACF,CAAA;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)
|
|
3
|
+
* @throws If given input is not a finite number
|
|
4
|
+
*/
|
|
5
|
+
export declare function isFiniteNumber(value: unknown, entity?: string, ErrorClass?: new (message: string) => void): asserts value is number;
|
|
6
|
+
/**
|
|
7
|
+
* Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a
|
|
8
|
+
* Number.isSafeInteger would be sufficient.
|
|
9
|
+
*
|
|
10
|
+
* Code inspired from graphql-scalars library.
|
|
11
|
+
* @see
|
|
12
|
+
* https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32
|
|
13
|
+
* @throws If given input is not a valid integer
|
|
14
|
+
*/
|
|
15
|
+
export declare function isInt(value: unknown, entity?: string, ErrorClass?: new (message: string) => void): asserts value is number;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
function isFiniteNumber(value, entity = "Value", ErrorClass = TypeError) {
|
|
5
|
+
if (typeof value !== "number" || Number.isNaN(value)) {
|
|
6
|
+
throw new ErrorClass(`${entity} is not a number: ${value}`);
|
|
7
|
+
}
|
|
8
|
+
if (!Number.isFinite(value)) {
|
|
9
|
+
throw new ErrorClass(`${entity} is not a finite number: ${value}`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function isInt(value, entity = "Value", ErrorClass = TypeError) {
|
|
13
|
+
isFiniteNumber(value, entity, ErrorClass);
|
|
14
|
+
if (!Number.isInteger(value)) {
|
|
15
|
+
throw new ErrorClass(`${entity} is not an integer: ${value}`);
|
|
16
|
+
}
|
|
17
|
+
if (!Number.isSafeInteger(value)) {
|
|
18
|
+
throw new ErrorClass(`${entity} is not a safe integer: ${value}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.isFiniteNumber = isFiniteNumber;
|
|
22
|
+
exports.isInt = isInt;
|
|
23
|
+
//# sourceMappingURL=validations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validations.js","sources":["../../src/utils/validations.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger"],"mappings":";;;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IAEpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,KAAO,EAAA,CAAA;EAC5D;EAEA,IAAI,CAACI,MAAA,CAAOE,QAAS,CAAAN,KAAK,CAAG,EAAA;IAE3B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,4BAA4BD,KAAO,EAAA,CAAA;EACnE;AACF;AAWO,SAASO,KACdA,CAAAP,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;EAExC,IAAI,CAACE,MAAA,CAAOI,SAAU,CAAAR,KAAK,CAAG,EAAA;IAE5B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,uBAAuBD,KAAO,EAAA,CAAA;EAC9D;EAEA,IAAI,CAACI,MAAA,CAAOK,aAAc,CAAAT,KAAK,CAAG,EAAA;IAEhC,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,2BAA2BD,KAAO,EAAA,CAAA;EAClE;AACF;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function isFiniteNumber(value, entity = "Value", ErrorClass = TypeError) {
|
|
4
|
+
if (typeof value !== "number" || Number.isNaN(value)) {
|
|
5
|
+
throw new ErrorClass(`${entity} is not a number: ${value}`);
|
|
6
|
+
}
|
|
7
|
+
if (!Number.isFinite(value)) {
|
|
8
|
+
throw new ErrorClass(`${entity} is not a finite number: ${value}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function isInt(value, entity = "Value", ErrorClass = TypeError) {
|
|
12
|
+
isFiniteNumber(value, entity, ErrorClass);
|
|
13
|
+
if (!Number.isInteger(value)) {
|
|
14
|
+
throw new ErrorClass(`${entity} is not an integer: ${value}`);
|
|
15
|
+
}
|
|
16
|
+
if (!Number.isSafeInteger(value)) {
|
|
17
|
+
throw new ErrorClass(`${entity} is not a safe integer: ${value}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export { isFiniteNumber, isInt };
|
|
21
|
+
//# sourceMappingURL=validations.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validations.mjs","sources":["../../src/utils/validations.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger"],"mappings":";;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IAEpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,KAAO,EAAA,CAAA;EAC5D;EAEA,IAAI,CAACI,MAAA,CAAOE,QAAS,CAAAN,KAAK,CAAG,EAAA;IAE3B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,4BAA4BD,KAAO,EAAA,CAAA;EACnE;AACF;AAWO,SAASO,KACdA,CAAAP,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;EAExC,IAAI,CAACE,MAAA,CAAOI,SAAU,CAAAR,KAAK,CAAG,EAAA;IAE5B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,uBAAuBD,KAAO,EAAA,CAAA;EAC9D;EAEA,IAAI,CAACI,MAAA,CAAOK,aAAc,CAAAT,KAAK,CAAG,EAAA;IAEhC,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,2BAA2BD,KAAO,EAAA,CAAA;EAClE;AACF;"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"x.svg.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"x.svg.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/lib/assets/x.svg
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path opacity="0.9" d="M8.32633 5.92873L13.5347 0H12.3009L7.77659 5.14678L4.16573 0H0L5.46152 7.78358L0 14H1.23377L6.00846 8.56366L9.82261 14H13.9883M1.67907 0.911107H3.57449L12.3 13.1337H10.4041" fill="black" fill-opacity="0.45"/>
|
|
3
|
-
</svg>
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { StaticImageData } from "next/image";
|
|
2
|
-
import { ExternalUrl } from "../../../constants/url";
|
|
3
|
-
export declare enum FooterHeaderId {
|
|
4
|
-
Company = "company",
|
|
5
|
-
Training = "training",
|
|
6
|
-
Buy = "buy",
|
|
7
|
-
Tools = "tools",
|
|
8
|
-
Social = "social",
|
|
9
|
-
Terms = "terms"
|
|
10
|
-
}
|
|
11
|
-
export declare enum FooterLinkId {
|
|
12
|
-
Careers = "careers",
|
|
13
|
-
Contact = "contact",
|
|
14
|
-
Investors = "investors",
|
|
15
|
-
Courses = "courses",
|
|
16
|
-
Calendar = "calendar",
|
|
17
|
-
Trainers = "trainers",
|
|
18
|
-
BecomeTrainer = "becomeTrainer",
|
|
19
|
-
FindDistributor = "findDistributor",
|
|
20
|
-
BecomeDistributor = "becomeDistributor",
|
|
21
|
-
DesignCenter = "designCenter",
|
|
22
|
-
WiFiman = "wifiman",
|
|
23
|
-
UISP = "uisp",
|
|
24
|
-
UispDesignCenter = "uispDesignCenter",
|
|
25
|
-
Facebook = "facebook",
|
|
26
|
-
X = "x",// Twitter
|
|
27
|
-
Youtube = "youtube",
|
|
28
|
-
Instagram = "instagram",
|
|
29
|
-
Conditions = "conditions",
|
|
30
|
-
Service = "service",
|
|
31
|
-
Privacy = "privacy",
|
|
32
|
-
Return = "return",
|
|
33
|
-
Cookie = "cookie",
|
|
34
|
-
Legal = "legal",
|
|
35
|
-
Store = "store",
|
|
36
|
-
Faq = "faq",
|
|
37
|
-
Downloads = "downloads"
|
|
38
|
-
}
|
|
39
|
-
export declare const FOOTER_LINKS: {
|
|
40
|
-
careers: ExternalUrl;
|
|
41
|
-
contact: ExternalUrl;
|
|
42
|
-
investors: ExternalUrl;
|
|
43
|
-
courses: ExternalUrl;
|
|
44
|
-
calendar: ExternalUrl;
|
|
45
|
-
trainers: ExternalUrl;
|
|
46
|
-
becomeTrainer: ExternalUrl;
|
|
47
|
-
findDistributor: ExternalUrl;
|
|
48
|
-
becomeDistributor: ExternalUrl;
|
|
49
|
-
designCenter: ExternalUrl;
|
|
50
|
-
wifiman: ExternalUrl;
|
|
51
|
-
uisp: ExternalUrl;
|
|
52
|
-
uispDesignCenter: ExternalUrl;
|
|
53
|
-
facebook: ExternalUrl;
|
|
54
|
-
x: ExternalUrl;
|
|
55
|
-
youtube: ExternalUrl;
|
|
56
|
-
instagram: ExternalUrl;
|
|
57
|
-
service: ExternalUrl;
|
|
58
|
-
privacy: ExternalUrl;
|
|
59
|
-
return: ExternalUrl;
|
|
60
|
-
};
|
|
61
|
-
type FooterItem = {
|
|
62
|
-
id: FooterLinkId;
|
|
63
|
-
label: string;
|
|
64
|
-
src: string;
|
|
65
|
-
target?: string;
|
|
66
|
-
icon?: string | StaticImageData;
|
|
67
|
-
};
|
|
68
|
-
type FooterSection = {
|
|
69
|
-
header: {
|
|
70
|
-
id: FooterHeaderId;
|
|
71
|
-
label: string;
|
|
72
|
-
};
|
|
73
|
-
items: FooterItem[];
|
|
74
|
-
};
|
|
75
|
-
type FooterSections = {
|
|
76
|
-
company: FooterSection;
|
|
77
|
-
training: FooterSection;
|
|
78
|
-
buy: FooterSection;
|
|
79
|
-
tools: FooterSection;
|
|
80
|
-
};
|
|
81
|
-
export declare const useFooterContent: () => {
|
|
82
|
-
footerContent: FooterSections;
|
|
83
|
-
socialContent: FooterSection;
|
|
84
|
-
termsContent: FooterSection;
|
|
85
|
-
urls: {
|
|
86
|
-
termsAndConditions: string;
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* One-trust cookie policy related id & class that connects with their SDK's
|
|
91
|
-
*/
|
|
92
|
-
export declare const COOKIE_POLICY_BTN_ID = "ot-sdk-btn";
|
|
93
|
-
export declare const COOKIE_POLICY_BTN_ID_CLASSNAME = "ot-sdk-show-settings";
|
|
94
|
-
export {};
|