@gravity-ui/page-constructor 8.13.1 → 8.14.0
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/build/cjs/_vendor/swiper-modules.js +187 -136
- package/build/cjs/_vendor/swiper-modules.js.map +3 -3
- package/build/cjs/_vendor/swiper-react.js +770 -481
- package/build/cjs/_vendor/swiper-react.js.map +3 -3
- package/build/cjs/_vendor/swiper.js +693 -404
- package/build/cjs/_vendor/swiper.js.map +3 -3
- package/build/cjs/blocks/Footer/Footer.css +53 -0
- package/build/cjs/blocks/Footer/Footer.d.ts +5 -0
- package/build/cjs/blocks/Footer/Footer.js +34 -0
- package/build/cjs/blocks/Footer/Footer.js.map +1 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/CopyrightFloor.css +201 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/CopyrightFloor.d.ts +6 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/CopyrightFloor.js +142 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/CopyrightFloor.js.map +1 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/index.d.ts +1 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/index.js +6 -0
- package/build/cjs/blocks/Footer/components/CopyrightFloor/index.js.map +1 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.css +28 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.d.ts +6 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.js +18 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.js.map +1 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/index.d.ts +1 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/index.js +6 -0
- package/build/cjs/blocks/Footer/components/DisclaimerFloor/index.js.map +1 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/LangSwitcher.css +14 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/LangSwitcher.d.ts +11 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/LangSwitcher.js +38 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/LangSwitcher.js.map +1 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/index.d.ts +1 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/index.js +6 -0
- package/build/cjs/blocks/Footer/components/LangSwitcher/index.js.map +1 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/NavigationFloor.css +93 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/NavigationFloor.d.ts +12 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/NavigationFloor.js +37 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/NavigationFloor.js.map +1 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/index.d.ts +1 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/index.js +6 -0
- package/build/cjs/blocks/Footer/components/NavigationFloor/index.js.map +1 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/SocialFloor.css +77 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/SocialFloor.d.ts +6 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/SocialFloor.js +38 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/SocialFloor.js.map +1 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/index.d.ts +1 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/index.js +6 -0
- package/build/cjs/blocks/Footer/components/SocialFloor/index.js.map +1 -0
- package/build/cjs/blocks/Footer/hooks/useLogoImageProps.d.ts +2 -0
- package/build/cjs/blocks/Footer/hooks/useLogoImageProps.js +21 -0
- package/build/cjs/blocks/Footer/hooks/useLogoImageProps.js.map +1 -0
- package/build/cjs/blocks/Footer/hooks/useOverflowListItems.d.ts +18 -0
- package/build/cjs/blocks/Footer/hooks/useOverflowListItems.js +108 -0
- package/build/cjs/blocks/Footer/hooks/useOverflowListItems.js.map +1 -0
- package/build/cjs/blocks/Footer/schema.d.ts +347 -0
- package/build/cjs/blocks/Footer/schema.js +123 -0
- package/build/cjs/blocks/Footer/schema.js.map +1 -0
- package/build/cjs/blocks/index.d.ts +1 -0
- package/build/cjs/blocks/index.js +3 -1
- package/build/cjs/blocks/index.js.map +1 -1
- package/build/cjs/blocks/validators.d.ts +1 -0
- package/build/cjs/blocks/validators.js +1 -0
- package/build/cjs/blocks/validators.js.map +1 -1
- package/build/cjs/components/BrandFooter/BrandFooter.css +2 -2
- package/build/cjs/constructor-items.d.ts +2 -1
- package/build/cjs/constructor-items.js +1 -0
- package/build/cjs/constructor-items.js.map +1 -1
- package/build/cjs/containers/PageConstructor/PageConstructor.d.ts +0 -1
- package/build/cjs/containers/PageConstructor/PageConstructor.js +0 -1
- package/build/cjs/containers/PageConstructor/PageConstructor.js.map +1 -1
- package/build/cjs/models/constructor-items/blocks.d.ts +77 -2
- package/build/cjs/models/constructor-items/blocks.js +1 -0
- package/build/cjs/models/constructor-items/blocks.js.map +1 -1
- package/build/cjs/models/navigation.d.ts +1 -0
- package/build/cjs/models/navigation.js.map +1 -1
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.d.ts +1 -1
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js +2 -2
- package/build/cjs/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js.map +1 -1
- package/build/cjs/navigation/components/NavigationItem/hooks/useNavigationItemMap.d.ts +1 -1
- package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.d.ts +1 -1
- package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.js +2 -2
- package/build/cjs/navigation/components/NavigationPopup/NavigationPopup.js.map +1 -1
- package/build/cjs/navigation/hooks/useActiveNavItem.d.ts +2 -0
- package/build/cjs/navigation/models.d.ts +1 -0
- package/build/cjs/navigation/models.js.map +1 -1
- package/build/cjs/navigation/utils.d.ts +1 -0
- package/build/cjs/node_modules/swiper/modules/index.js +187 -136
- package/build/cjs/node_modules/swiper/modules/pagination.css +108 -104
- package/build/cjs/node_modules/swiper/package.json +1 -1
- package/build/cjs/node_modules/swiper/swiper-react.d.ts +5 -0
- package/build/cjs/node_modules/swiper/swiper-react.js +770 -481
- package/build/cjs/node_modules/swiper/swiper.css +124 -102
- package/build/cjs/node_modules/swiper/swiper.js +693 -404
- package/build/cjs/node_modules/swiper/types/modules/index.d.ts +0 -2
- package/build/cjs/schema/constants.js +2 -0
- package/build/cjs/schema/constants.js.map +1 -1
- package/build/cjs/schema/validators/blocks.d.ts +1 -0
- package/build/cjs/schema/validators/blocks.js +1 -0
- package/build/cjs/schema/validators/blocks.js.map +1 -1
- package/build/cjs/text-transform/config.js +13 -0
- package/build/cjs/text-transform/config.js.map +1 -1
- package/build/esm/blocks/Footer/Footer.css +53 -0
- package/build/esm/blocks/Footer/Footer.d.ts +6 -0
- package/build/esm/blocks/Footer/Footer.js +31 -0
- package/build/esm/blocks/Footer/Footer.js.map +1 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/CopyrightFloor.css +201 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/CopyrightFloor.d.ts +7 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/CopyrightFloor.js +138 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/CopyrightFloor.js.map +1 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/index.d.ts +1 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/index.js +2 -0
- package/build/esm/blocks/Footer/components/CopyrightFloor/index.js.map +1 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.css +28 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.d.ts +7 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.js +15 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/DisclaimerFloor.js.map +1 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/index.d.ts +1 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/index.js +2 -0
- package/build/esm/blocks/Footer/components/DisclaimerFloor/index.js.map +1 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/LangSwitcher.css +14 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/LangSwitcher.d.ts +12 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/LangSwitcher.js +34 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/LangSwitcher.js.map +1 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/index.d.ts +1 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/index.js +2 -0
- package/build/esm/blocks/Footer/components/LangSwitcher/index.js.map +1 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/NavigationFloor.css +93 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/NavigationFloor.d.ts +13 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/NavigationFloor.js +33 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/NavigationFloor.js.map +1 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/index.d.ts +1 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/index.js +2 -0
- package/build/esm/blocks/Footer/components/NavigationFloor/index.js.map +1 -0
- package/build/esm/blocks/Footer/components/SocialFloor/SocialFloor.css +77 -0
- package/build/esm/blocks/Footer/components/SocialFloor/SocialFloor.d.ts +7 -0
- package/build/esm/blocks/Footer/components/SocialFloor/SocialFloor.js +35 -0
- package/build/esm/blocks/Footer/components/SocialFloor/SocialFloor.js.map +1 -0
- package/build/esm/blocks/Footer/components/SocialFloor/index.d.ts +1 -0
- package/build/esm/blocks/Footer/components/SocialFloor/index.js +2 -0
- package/build/esm/blocks/Footer/components/SocialFloor/index.js.map +1 -0
- package/build/esm/blocks/Footer/hooks/useLogoImageProps.d.ts +2 -0
- package/build/esm/blocks/Footer/hooks/useLogoImageProps.js +17 -0
- package/build/esm/blocks/Footer/hooks/useLogoImageProps.js.map +1 -0
- package/build/esm/blocks/Footer/hooks/useOverflowListItems.d.ts +18 -0
- package/build/esm/blocks/Footer/hooks/useOverflowListItems.js +104 -0
- package/build/esm/blocks/Footer/hooks/useOverflowListItems.js.map +1 -0
- package/build/esm/blocks/Footer/schema.d.ts +347 -0
- package/build/esm/blocks/Footer/schema.js +120 -0
- package/build/esm/blocks/Footer/schema.js.map +1 -0
- package/build/esm/blocks/index.d.ts +1 -0
- package/build/esm/blocks/index.js +1 -0
- package/build/esm/blocks/index.js.map +1 -1
- package/build/esm/blocks/validators.d.ts +1 -0
- package/build/esm/blocks/validators.js +1 -0
- package/build/esm/blocks/validators.js.map +1 -1
- package/build/esm/components/BrandFooter/BrandFooter.css +2 -2
- package/build/esm/constructor-items.d.ts +2 -1
- package/build/esm/constructor-items.js +2 -1
- package/build/esm/constructor-items.js.map +1 -1
- package/build/esm/containers/PageConstructor/PageConstructor.d.ts +0 -1
- package/build/esm/containers/PageConstructor/PageConstructor.js +0 -1
- package/build/esm/containers/PageConstructor/PageConstructor.js.map +1 -1
- package/build/esm/models/constructor-items/blocks.d.ts +77 -2
- package/build/esm/models/constructor-items/blocks.js +1 -0
- package/build/esm/models/constructor-items/blocks.js.map +1 -1
- package/build/esm/models/navigation.d.ts +1 -0
- package/build/esm/models/navigation.js.map +1 -1
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.d.ts +1 -1
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js +2 -2
- package/build/esm/navigation/components/NavigationItem/components/NavigationDropdown/NavigationDropdown.js.map +1 -1
- package/build/esm/navigation/components/NavigationItem/hooks/useNavigationItemMap.d.ts +1 -1
- package/build/esm/navigation/components/NavigationPopup/NavigationPopup.d.ts +1 -1
- package/build/esm/navigation/components/NavigationPopup/NavigationPopup.js +2 -2
- package/build/esm/navigation/components/NavigationPopup/NavigationPopup.js.map +1 -1
- package/build/esm/navigation/hooks/useActiveNavItem.d.ts +2 -0
- package/build/esm/navigation/models.d.ts +1 -0
- package/build/esm/navigation/models.js.map +1 -1
- package/build/esm/navigation/utils.d.ts +1 -0
- package/build/esm/schema/constants.js +3 -1
- package/build/esm/schema/constants.js.map +1 -1
- package/build/esm/schema/validators/blocks.d.ts +1 -0
- package/build/esm/schema/validators/blocks.js +1 -0
- package/build/esm/schema/validators/blocks.js.map +1 -1
- package/build/esm/text-transform/config.js +13 -0
- package/build/esm/text-transform/config.js.map +1 -1
- package/package.json +3 -2
- package/schema/index.js +1 -1
- package/server/models/constructor-items/blocks.d.ts +77 -2
- package/server/models/constructor-items/blocks.js +1 -0
- package/server/models/navigation.d.ts +1 -0
- package/server/text-transform/config.js +10 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LangSwitcher = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const React = tslib_1.__importStar(require("react"));
|
|
7
|
+
const innerContext_1 = require("../../../../context/innerContext/index.js");
|
|
8
|
+
const models_1 = require("../../../../models/index.js");
|
|
9
|
+
const utils_1 = require("../../../../utils/index.js");
|
|
10
|
+
const b = (0, utils_1.block)('lang-switcher');
|
|
11
|
+
const LangSwitcher = ({ buttonText, items, image }) => {
|
|
12
|
+
const [isActive, setIsActive] = React.useState(false);
|
|
13
|
+
const { navItemMap } = React.useContext(innerContext_1.InnerContext);
|
|
14
|
+
const navigationItems = React.useMemo(() => items.map((item) => ({
|
|
15
|
+
type: models_1.NavigationItemType.Link,
|
|
16
|
+
text: item.text,
|
|
17
|
+
url: item.href,
|
|
18
|
+
})), [items]);
|
|
19
|
+
const hidePopup = React.useCallback(() => {
|
|
20
|
+
setIsActive(false);
|
|
21
|
+
}, []);
|
|
22
|
+
const onClick = React.useCallback((event) => {
|
|
23
|
+
event.stopPropagation();
|
|
24
|
+
setIsActive((active) => !active);
|
|
25
|
+
}, []);
|
|
26
|
+
const text = buttonText ?? 'Language';
|
|
27
|
+
const data = {
|
|
28
|
+
type: models_1.NavigationItemType.Dropdown,
|
|
29
|
+
text,
|
|
30
|
+
items: navigationItems,
|
|
31
|
+
isActive,
|
|
32
|
+
hidePopup,
|
|
33
|
+
};
|
|
34
|
+
const NavigationDropdown = navItemMap[models_1.NavigationItemType.Dropdown];
|
|
35
|
+
return ((0, jsx_runtime_1.jsx)(NavigationDropdown, { data: data, text: text, type: models_1.NavigationItemType.Dropdown, items: navigationItems, isActive: isActive, hidePopup: hidePopup, onClick: onClick, className: b(), placement: "top-start", icon: image, iconSize: 20 }));
|
|
36
|
+
};
|
|
37
|
+
exports.LangSwitcher = LangSwitcher;
|
|
38
|
+
//# sourceMappingURL=LangSwitcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LangSwitcher.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/LangSwitcher/LangSwitcher.tsx"],"names":[],"mappings":";;;;;AAAA,qDAA+B;AAE/B,4EAA8D;AAC9D,wDAK4B;AAC5B,sDAAwC;AAaxC,MAAM,CAAC,GAAG,IAAA,aAAK,EAAC,eAAe,CAAC,CAAC;AAE1B,MAAM,YAAY,GAAG,CAAC,EAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAwB,EAAE,EAAE;IAC9E,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,EAAC,UAAU,EAAC,GAAG,KAAK,CAAC,UAAU,CAAC,2BAAY,CAAC,CAAC;IAEpD,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CACjC,GAAG,EAAE,CACD,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACjB,IAAI,EAAE,2BAAkB,CAAC,IAAI;QAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,IAAI;KACjB,CAAC,CAAC,EACP,CAAC,KAAK,CAAC,CACV,CAAC;IAEF,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACrC,WAAW,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,KAAuB,EAAE,EAAE;QAC1D,KAAK,CAAC,eAAe,EAAE,CAAC;QACxB,WAAW,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,IAAI,GAAG,UAAU,IAAI,UAAU,CAAC;IACtC,MAAM,IAAI,GAA2B;QACjC,IAAI,EAAE,2BAAkB,CAAC,QAAQ;QACjC,IAAI;QACJ,KAAK,EAAE,eAAe;QACtB,QAAQ;QACR,SAAS;KACZ,CAAC;IAEF,MAAM,kBAAkB,GAAG,UAAU,CAAC,2BAAkB,CAAC,QAAQ,CAAC,CAAC;IAEnE,OAAO,CACH,uBAAC,kBAAkB,IACf,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,2BAAkB,CAAC,QAAQ,EACjC,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,EAAE,EACd,SAAS,EAAC,WAAW,EACrB,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,EAAE,GACd,CACL,CAAC;AACN,CAAC,CAAC;AAjDW,QAAA,YAAY,gBAiDvB","sourcesContent":["import * as React from 'react';\n\nimport {InnerContext} from '../../../../context/innerContext';\nimport {\n ImageProps,\n NavigationDropdownItem,\n NavigationItemType,\n NavigationLinkItem,\n} from '../../../../models';\nimport {block} from '../../../../utils';\n\nimport './LangSwitcher.scss';\n\ntype LanguageSwitcherProps = {\n buttonText?: string;\n items: {\n text: string;\n href: string;\n }[];\n image?: ImageProps;\n};\n\nconst b = block('lang-switcher');\n\nexport const LangSwitcher = ({buttonText, items, image}: LanguageSwitcherProps) => {\n const [isActive, setIsActive] = React.useState(false);\n const {navItemMap} = React.useContext(InnerContext);\n\n const navigationItems = React.useMemo<NavigationLinkItem[]>(\n () =>\n items.map((item) => ({\n type: NavigationItemType.Link,\n text: item.text,\n url: item.href,\n })),\n [items],\n );\n\n const hidePopup = React.useCallback(() => {\n setIsActive(false);\n }, []);\n\n const onClick = React.useCallback((event: React.MouseEvent) => {\n event.stopPropagation();\n setIsActive((active) => !active);\n }, []);\n\n const text = buttonText ?? 'Language';\n const data: NavigationDropdownItem = {\n type: NavigationItemType.Dropdown,\n text,\n items: navigationItems,\n isActive,\n hidePopup,\n };\n\n const NavigationDropdown = navItemMap[NavigationItemType.Dropdown];\n\n return (\n <NavigationDropdown\n data={data}\n text={text}\n type={NavigationItemType.Dropdown}\n items={navigationItems}\n isActive={isActive}\n hidePopup={hidePopup}\n onClick={onClick}\n className={b()}\n placement=\"top-start\"\n icon={image}\n iconSize={20}\n />\n );\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LangSwitcher } from "./LangSwitcher.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LangSwitcher = void 0;
|
|
4
|
+
var LangSwitcher_1 = require("./LangSwitcher.js");
|
|
5
|
+
Object.defineProperty(exports, "LangSwitcher", { enumerable: true, get: function () { return LangSwitcher_1.LangSwitcher; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/LangSwitcher/index.ts"],"names":[],"mappings":";;;AAAA,kDAA4C;AAApC,4GAAA,YAAY,OAAA","sourcesContent":["export {LangSwitcher} from './LangSwitcher';\n"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-footer-block .pc-footer-block__floor.pc-footer-block__floor_navigation {
|
|
4
|
+
margin: 0 auto;
|
|
5
|
+
padding: 32px 0 var(--g-spacing-10);
|
|
6
|
+
border: none;
|
|
7
|
+
}
|
|
8
|
+
.pc-footer-block__floor .pc-footer-block__columns-container {
|
|
9
|
+
padding: 0;
|
|
10
|
+
}
|
|
11
|
+
.pc-footer-block__floor_logo-placement_left .pc-footer-block__logo-col.col {
|
|
12
|
+
padding: 0 0 32px;
|
|
13
|
+
}
|
|
14
|
+
.pc-footer-block__floor_logo-placement_left .pc-footer-block__logo-col.col .row {
|
|
15
|
+
margin: 0;
|
|
16
|
+
}
|
|
17
|
+
.pc-footer-block__floor_logo-placement_top {
|
|
18
|
+
padding-top: 0;
|
|
19
|
+
}
|
|
20
|
+
.pc-footer-block__floor_logo-placement_top .pc-footer-block__logo-col_top.col {
|
|
21
|
+
padding: 0 0 24px;
|
|
22
|
+
margin-bottom: 32px;
|
|
23
|
+
border-bottom: 1px solid var(--g-color-line-generic);
|
|
24
|
+
}
|
|
25
|
+
.pc-footer-block__column {
|
|
26
|
+
min-width: 0;
|
|
27
|
+
padding-right: 16px;
|
|
28
|
+
}
|
|
29
|
+
.pc-footer-block__column-inner {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
gap: 20px;
|
|
33
|
+
}
|
|
34
|
+
.pc-footer-block__nav-row {
|
|
35
|
+
width: calc(100% + 24px);
|
|
36
|
+
min-width: 0;
|
|
37
|
+
gap: 48px 0;
|
|
38
|
+
}
|
|
39
|
+
@media (min-width: 1081px) {
|
|
40
|
+
.pc-footer-block__nav-row_custom-columns > .pc-footer-block__column {
|
|
41
|
+
flex: 0 0 var(--pc-footer-navigation-column-width);
|
|
42
|
+
max-width: var(--pc-footer-navigation-column-width);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
.pc-footer-block__column-title {
|
|
46
|
+
font-size: var(--g-text-subheader-3-font-size);
|
|
47
|
+
line-height: var(--g-text-subheader-3-line-height);
|
|
48
|
+
font-weight: var(--g-text-accent-font-weight);
|
|
49
|
+
color: var(--g-color-text-primary);
|
|
50
|
+
margin: 0;
|
|
51
|
+
}
|
|
52
|
+
.pc-footer-block__links {
|
|
53
|
+
list-style: none;
|
|
54
|
+
margin: 0;
|
|
55
|
+
padding: 0;
|
|
56
|
+
}
|
|
57
|
+
.pc-footer-block__link-item {
|
|
58
|
+
margin: 0;
|
|
59
|
+
}
|
|
60
|
+
.pc-footer-block__link-item:not(:last-child) {
|
|
61
|
+
margin-bottom: 16px;
|
|
62
|
+
}
|
|
63
|
+
.pc-footer-block__link {
|
|
64
|
+
font-size: var(--g-text-body-2-font-size);
|
|
65
|
+
line-height: var(--g-text-body-2-line-height);
|
|
66
|
+
outline: none;
|
|
67
|
+
color: var(--g-color-text-link);
|
|
68
|
+
text-decoration: none;
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
color: var(--g-color-text-primary);
|
|
71
|
+
text-decoration: none;
|
|
72
|
+
line-height: var(--g-text-body-2-line-height);
|
|
73
|
+
}
|
|
74
|
+
.utilityfocus .pc-footer-block__link:focus {
|
|
75
|
+
outline: 2px solid #ffdb4d;
|
|
76
|
+
}
|
|
77
|
+
.pc-footer-block__link:hover, .pc-footer-block__link:active {
|
|
78
|
+
--pc-text-header-color: var(--g-color-text-link-hover);
|
|
79
|
+
color: var(--g-color-text-link-hover);
|
|
80
|
+
}
|
|
81
|
+
.pc-footer-block__link:hover {
|
|
82
|
+
color: var(--g-color-text-secondary);
|
|
83
|
+
}
|
|
84
|
+
@media (max-width: 1081px) {
|
|
85
|
+
.pc-footer-block__floor_logo-placement_top .pc-footer-block__logo-col.col {
|
|
86
|
+
padding: 0 0 32px;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
@media (max-width: 769px) {
|
|
90
|
+
.pc-footer-block__floor_navigation .pc-footer-block__logo {
|
|
91
|
+
height: 48px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { GridColumnSizesType } from "../../../../grid/index.js";
|
|
3
|
+
import { FooterLinkColumn } from "../../../../models/index.js";
|
|
4
|
+
type NavigationFloorProps = {
|
|
5
|
+
columns: FooterLinkColumn[];
|
|
6
|
+
logoContent: React.ReactNode;
|
|
7
|
+
colSizes?: GridColumnSizesType;
|
|
8
|
+
columnsPerRow?: number;
|
|
9
|
+
logoPlacement?: 'left' | 'top';
|
|
10
|
+
};
|
|
11
|
+
export declare const NavigationFloor: ({ columns, logoContent, colSizes, columnsPerRow, logoPlacement, }: NavigationFloorProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NavigationFloor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const React = tslib_1.__importStar(require("react"));
|
|
7
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
8
|
+
const grid_1 = require("../../../../grid/index.js");
|
|
9
|
+
const utils_1 = require("../../../../utils/index.js");
|
|
10
|
+
const b = (0, utils_1.block)('footer-block');
|
|
11
|
+
const DEFAULT_COL_SIZES_WITH_LOGO = { all: 6, sm: 4, md: 3, lg: 3 };
|
|
12
|
+
const DEFAULT_COL_SIZES_WITHOUT_LOGO = { all: 6, sm: 4, md: 3, lg: 3 };
|
|
13
|
+
const DEFAULT_LOGO_COL_SIZES = { all: 12, md: 4 };
|
|
14
|
+
function NavigationColumns({ columns, hasLogo, colSizes, columnsPerRow }) {
|
|
15
|
+
const defaultColSizes = hasLogo
|
|
16
|
+
? DEFAULT_COL_SIZES_WITH_LOGO
|
|
17
|
+
: DEFAULT_COL_SIZES_WITHOUT_LOGO;
|
|
18
|
+
const resolvedColSizes = React.useMemo(() => ({
|
|
19
|
+
all: colSizes?.all ?? defaultColSizes.all,
|
|
20
|
+
sm: colSizes?.sm ?? defaultColSizes.sm,
|
|
21
|
+
md: colSizes?.md ?? defaultColSizes.md,
|
|
22
|
+
lg: colSizes?.lg ?? defaultColSizes.lg,
|
|
23
|
+
}), [colSizes, defaultColSizes]);
|
|
24
|
+
const customColumnsStyle = columnsPerRow
|
|
25
|
+
? {
|
|
26
|
+
'--pc-footer-navigation-column-width': `${100 / columnsPerRow}%`,
|
|
27
|
+
}
|
|
28
|
+
: undefined;
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(grid_1.Col, { className: b('columns-container'), children: (0, jsx_runtime_1.jsx)(grid_1.Row, { className: b('nav-row', { 'custom-columns': Boolean(columnsPerRow) }), style: customColumnsStyle, children: columns.map((column, columnIndex) => ((0, jsx_runtime_1.jsx)(grid_1.Col, { className: b('column'), sizes: resolvedColSizes, children: (0, jsx_runtime_1.jsxs)("div", { className: b('column-inner'), children: [(0, jsx_runtime_1.jsx)("h6", { className: b('column-title'), children: column.title }), (0, jsx_runtime_1.jsx)("ul", { className: b('links'), children: column.links.map((link, linkIndex) => ((0, jsx_runtime_1.jsx)("li", { className: b('link-item'), children: (0, jsx_runtime_1.jsx)(uikit_1.Link, { href: link.url, className: b('link'), title: link.urlTitle, target: link.target, children: link.text }) }, linkIndex))) })] }) }, columnIndex))) }) }));
|
|
30
|
+
}
|
|
31
|
+
const NavigationFloor = ({ columns, logoContent, colSizes, columnsPerRow, logoPlacement, }) => {
|
|
32
|
+
const isTopLogoPlacement = logoPlacement === 'top';
|
|
33
|
+
const hasSideLogo = Boolean(logoContent) && !isTopLogoPlacement;
|
|
34
|
+
return ((0, jsx_runtime_1.jsxs)(grid_1.Row, { className: b('floor', { navigation: true, 'logo-placement': logoPlacement }), children: [logoContent && isTopLogoPlacement && ((0, jsx_runtime_1.jsx)(grid_1.Col, { className: b('logo-col', { top: true }), sizes: { all: 12 }, children: logoContent })), logoContent && !isTopLogoPlacement && ((0, jsx_runtime_1.jsx)(grid_1.Col, { className: b('logo-col'), sizes: DEFAULT_LOGO_COL_SIZES, children: (0, jsx_runtime_1.jsx)(grid_1.Row, { children: logoContent }) })), (0, jsx_runtime_1.jsx)(NavigationColumns, { columns: columns, hasLogo: hasSideLogo, colSizes: colSizes, columnsPerRow: columnsPerRow })] }));
|
|
35
|
+
};
|
|
36
|
+
exports.NavigationFloor = NavigationFloor;
|
|
37
|
+
//# sourceMappingURL=NavigationFloor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavigationFloor.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/NavigationFloor/NavigationFloor.tsx"],"names":[],"mappings":";;;;;AAAA,qDAA+B;AAE/B,6CAAuC;AAGvC,oDAA0C;AAE1C,sDAAwC;AAIxC,MAAM,CAAC,GAAG,IAAA,aAAK,EAAC,cAAc,CAAC,CAAC;AAEhC,MAAM,2BAA2B,GAAwB,EAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAC,CAAC;AACvF,MAAM,8BAA8B,GAAwB,EAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAC,CAAC;AAC1F,MAAM,sBAAsB,GAAwB,EAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAC,CAAC;AASrE,SAAS,iBAAiB,CAAC,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAyB;IAC1F,MAAM,eAAe,GAAwB,OAAO;QAChD,CAAC,CAAC,2BAA2B;QAC7B,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sourcesContent":["import * as React from 'react';\n\nimport {Link} from '@gravity-ui/uikit';\n\nimport type {GridColumnSizesType} from '../../../../grid';\nimport {Col, Row} from '../../../../grid';\nimport {FooterLinkColumn} from '../../../../models';\nimport {block} from '../../../../utils';\n\nimport './NavigationFloor.scss';\n\nconst b = block('footer-block');\n\nconst DEFAULT_COL_SIZES_WITH_LOGO: GridColumnSizesType = {all: 6, sm: 4, md: 3, lg: 3};\nconst DEFAULT_COL_SIZES_WITHOUT_LOGO: GridColumnSizesType = {all: 6, sm: 4, md: 3, lg: 3};\nconst DEFAULT_LOGO_COL_SIZES: GridColumnSizesType = {all: 12, md: 4};\n\ntype NavigationColumnsProps = {\n columns: FooterLinkColumn[];\n hasLogo: boolean;\n colSizes?: GridColumnSizesType;\n columnsPerRow?: number;\n};\n\nfunction NavigationColumns({columns, hasLogo, colSizes, columnsPerRow}: NavigationColumnsProps) {\n const defaultColSizes: GridColumnSizesType = hasLogo\n ? DEFAULT_COL_SIZES_WITH_LOGO\n : DEFAULT_COL_SIZES_WITHOUT_LOGO;\n const resolvedColSizes: GridColumnSizesType = React.useMemo(\n () => ({\n all: colSizes?.all ?? defaultColSizes.all,\n sm: colSizes?.sm ?? defaultColSizes.sm,\n md: colSizes?.md ?? defaultColSizes.md,\n lg: colSizes?.lg ?? defaultColSizes.lg,\n }),\n [colSizes, defaultColSizes],\n );\n const customColumnsStyle = columnsPerRow\n ? ({\n '--pc-footer-navigation-column-width': `${100 / columnsPerRow}%`,\n } as React.CSSProperties)\n : undefined;\n\n return (\n <Col className={b('columns-container')}>\n <Row\n className={b('nav-row', {'custom-columns': Boolean(columnsPerRow)})}\n style={customColumnsStyle}\n >\n {columns.map((column, columnIndex) => (\n <Col key={columnIndex} className={b('column')} sizes={resolvedColSizes}>\n <div className={b('column-inner')}>\n <h6 className={b('column-title')}>{column.title}</h6>\n <ul className={b('links')}>\n {column.links.map((link, linkIndex) => (\n <li key={linkIndex} className={b('link-item')}>\n <Link\n href={link.url}\n className={b('link')}\n title={link.urlTitle}\n target={link.target}\n >\n {link.text}\n </Link>\n </li>\n ))}\n </ul>\n </div>\n </Col>\n ))}\n </Row>\n </Col>\n );\n}\n\ntype NavigationFloorProps = {\n columns: FooterLinkColumn[];\n logoContent: React.ReactNode;\n colSizes?: GridColumnSizesType;\n columnsPerRow?: number;\n logoPlacement?: 'left' | 'top';\n};\n\nexport const NavigationFloor = ({\n columns,\n logoContent,\n colSizes,\n columnsPerRow,\n logoPlacement,\n}: NavigationFloorProps) => {\n const isTopLogoPlacement = logoPlacement === 'top';\n const hasSideLogo = Boolean(logoContent) && !isTopLogoPlacement;\n\n return (\n <Row className={b('floor', {navigation: true, 'logo-placement': logoPlacement})}>\n {logoContent && isTopLogoPlacement && (\n <Col className={b('logo-col', {top: true})} sizes={{all: 12}}>\n {logoContent}\n </Col>\n )}\n {logoContent && !isTopLogoPlacement && (\n <Col className={b('logo-col')} sizes={DEFAULT_LOGO_COL_SIZES}>\n <Row>{logoContent}</Row>\n </Col>\n )}\n <NavigationColumns\n columns={columns}\n hasLogo={hasSideLogo}\n colSizes={colSizes}\n columnsPerRow={columnsPerRow}\n />\n </Row>\n );\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NavigationFloor } from "./NavigationFloor.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NavigationFloor = void 0;
|
|
4
|
+
var NavigationFloor_1 = require("./NavigationFloor.js");
|
|
5
|
+
Object.defineProperty(exports, "NavigationFloor", { enumerable: true, get: function () { return NavigationFloor_1.NavigationFloor; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/NavigationFloor/index.ts"],"names":[],"mappings":";;;AAAA,wDAAkD;AAA1C,kHAAA,eAAe,OAAA","sourcesContent":["export {NavigationFloor} from './NavigationFloor';\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* use this for style redefinitions to awoid problems with
|
|
2
|
+
unpredictable css rules order in build */
|
|
3
|
+
.pc-footer-block__social-floor-inner {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-wrap: wrap;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: 24px;
|
|
8
|
+
}
|
|
9
|
+
.pc-footer-block__social-floor-inner_title-position_top {
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
align-items: unset;
|
|
12
|
+
}
|
|
13
|
+
.pc-footer-block__social-floor-inner_links-position_center {
|
|
14
|
+
align-items: center;
|
|
15
|
+
}
|
|
16
|
+
.pc-footer-block__social-floor-inner_links-position_center .pc-footer-block__social-icons-list {
|
|
17
|
+
justify-content: center;
|
|
18
|
+
}
|
|
19
|
+
.pc-footer-block__social-floor-inner_size_m .pc-footer-block__social-icons-list {
|
|
20
|
+
gap: 24px;
|
|
21
|
+
}
|
|
22
|
+
.pc-footer-block__social-floor-inner_size_m .pc-footer-block__social-icon-item {
|
|
23
|
+
width: 32px;
|
|
24
|
+
height: 32px;
|
|
25
|
+
}
|
|
26
|
+
.pc-footer-block__social-floor-inner_size_l .pc-footer-block__social-icons-list {
|
|
27
|
+
gap: var(--g-spacing-10);
|
|
28
|
+
}
|
|
29
|
+
.pc-footer-block__social-floor-inner_size_l .pc-footer-block__social-icon-item {
|
|
30
|
+
width: 48px;
|
|
31
|
+
height: 48px;
|
|
32
|
+
}
|
|
33
|
+
.pc-footer-block__social-icon-item {
|
|
34
|
+
margin-right: 0;
|
|
35
|
+
}
|
|
36
|
+
.pc-footer-block__social-floor-title {
|
|
37
|
+
font-size: var(--g-text-body-3-font-size);
|
|
38
|
+
line-height: var(--g-text-body-3-line-height);
|
|
39
|
+
font-weight: var(--g-text-accent-font-weight);
|
|
40
|
+
margin: 0;
|
|
41
|
+
color: var(--g-color-text-primary);
|
|
42
|
+
}
|
|
43
|
+
.pc-footer-block__social-icons-list {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-wrap: wrap;
|
|
46
|
+
align-items: center;
|
|
47
|
+
list-style: none;
|
|
48
|
+
margin: 0;
|
|
49
|
+
padding: 0;
|
|
50
|
+
}
|
|
51
|
+
.pc-footer-block__social-icons-item {
|
|
52
|
+
margin: 0;
|
|
53
|
+
transition: transform 200ms ease-in-out;
|
|
54
|
+
}
|
|
55
|
+
.pc-footer-block__social-icons-item:hover {
|
|
56
|
+
transform: translateY(-4px);
|
|
57
|
+
}
|
|
58
|
+
.pc-footer-block__social-icon-link, .pc-footer-block__social-icon-link:hover {
|
|
59
|
+
text-decoration: none;
|
|
60
|
+
color: var(--g-color-text-primary);
|
|
61
|
+
}
|
|
62
|
+
.pc-footer-block__social-icon-item {
|
|
63
|
+
margin-right: 0;
|
|
64
|
+
}
|
|
65
|
+
.pc-footer-block__social-icon-item_size_m {
|
|
66
|
+
width: 32px;
|
|
67
|
+
height: 32px;
|
|
68
|
+
}
|
|
69
|
+
.pc-footer-block__social-icon-item_size_l {
|
|
70
|
+
width: 48px;
|
|
71
|
+
height: 48px;
|
|
72
|
+
}
|
|
73
|
+
@media (max-width: 577px) {
|
|
74
|
+
.pc-footer-block__floor_social.col {
|
|
75
|
+
padding: 24px 0;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FooterBlockProps } from "../../../../models/index.js";
|
|
2
|
+
type SocialFloorProps = {
|
|
3
|
+
contacts: NonNullable<FooterBlockProps['contacts']>;
|
|
4
|
+
};
|
|
5
|
+
export declare const SocialFloor: ({ contacts }: SocialFloorProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SocialFloor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
6
|
+
const components_1 = require("../../../../components/index.js");
|
|
7
|
+
const theme_1 = require("../../../../context/theme/index.js");
|
|
8
|
+
const grid_1 = require("../../../../grid/index.js");
|
|
9
|
+
const utils_1 = require("../../../../utils/index.js");
|
|
10
|
+
const useLogoImageProps_1 = require("../../hooks/useLogoImageProps.js");
|
|
11
|
+
const b = (0, utils_1.block)('footer-block');
|
|
12
|
+
const SocialIconItem = ({ contact, theme }) => {
|
|
13
|
+
const iconResolved = contact.icon && (0, utils_1.getThemedValue)(contact.icon, theme);
|
|
14
|
+
const iconProps = (0, useLogoImageProps_1.useLogoImageProps)(iconResolved);
|
|
15
|
+
if (!iconProps) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const content = ((0, jsx_runtime_1.jsx)("li", { className: b('social-icons-item'), children: (0, jsx_runtime_1.jsx)(uikit_1.Link, { className: b('social-icon-link'), href: contact.url, target: "_blank", rel: "noopener noreferrer", children: (0, jsx_runtime_1.jsx)(uikit_1.Flex, { direction: "column", alignItems: "center", gap: 2, children: (0, jsx_runtime_1.jsx)(components_1.Image, { ...iconProps, alt: contact.urlTitle ?? '', className: b('social-icon-item') }) }) }) }));
|
|
19
|
+
return contact.urlTitle ? ((0, jsx_runtime_1.jsx)(uikit_1.Tooltip, { content: contact.urlTitle, openDelay: 500, children: content })) : (content);
|
|
20
|
+
};
|
|
21
|
+
const SocialIcons = ({ links, theme }) => {
|
|
22
|
+
if (!links?.length)
|
|
23
|
+
return null;
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)("ul", { className: b('social-icons-list'), children: links.map((contact, index) => ((0, jsx_runtime_1.jsx)(SocialIconItem, { contact: contact, theme: theme }, index))) }));
|
|
25
|
+
};
|
|
26
|
+
const SocialFloor = ({ contacts }) => {
|
|
27
|
+
const theme = (0, theme_1.useTheme)();
|
|
28
|
+
if (!contacts.links?.length) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(grid_1.Col, { sizes: { all: 12 }, className: b('floor', { social: true }), children: (0, jsx_runtime_1.jsxs)("div", { className: b('social-floor-inner', {
|
|
32
|
+
'title-position': contacts.titlePosition || 'top',
|
|
33
|
+
'links-position': contacts.linksPosition || 'left',
|
|
34
|
+
size: contacts.iconsSize ?? 'l',
|
|
35
|
+
}), children: [contacts.title && (0, jsx_runtime_1.jsx)("h3", { className: b('social-floor-title'), children: contacts.title }), (0, jsx_runtime_1.jsx)(SocialIcons, { links: contacts.links, theme: theme })] }) }));
|
|
36
|
+
};
|
|
37
|
+
exports.SocialFloor = SocialFloor;
|
|
38
|
+
//# sourceMappingURL=SocialFloor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocialFloor.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/SocialFloor/SocialFloor.tsx"],"names":[],"mappings":";;;;AAAA,6CAAsD;AAEtD,gEAA6C;AAC7C,8DAAmD;AACnD,oDAAqC;AAErC,sDAAwD;AACxD,wEAAgE;AAIhE,MAAM,CAAC,GAAG,IAAA,aAAK,EAAC,cAAc,CAAC,CAAC;AAgBhC,MAAM,cAAc,GAAG,CAAC,EAAC,OAAO,EAAE,KAAK,EAAsB,EAAE,EAAE;IAC7D,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,IAAI,IAAA,sBAAc,EAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzE,MAAM,SAAS,GAAG,IAAA,qCAAiB,EAAC,YAAY,CAAC,CAAC;IAElD,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAG,CACZ,+BAAI,SAAS,EAAE,CAAC,CAAC,mBAAmB,CAAC,YACjC,uBAAC,YAAI,IACD,SAAS,EAAE,CAAC,CAAC,kBAAkB,CAAC,EAChC,IAAI,EAAE,OAAO,CAAC,GA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,CAAC,OAAO,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,YACxD,iCACI,SAAS,EAAE,CAAC,CAAC,oBAAoB,EAAE;gBAC/B,gBAAgB,EAAE,QAAQ,CAAC,aAAa,IAAI,KAAK;gBACjD,gBAAgB,EAAE,QAAQ,CAAC,aAAa,IAAI,MAAM;gBAClD,IAAI,EAAE,QAAQ,CAAC,SAAS,IAAI,GAAG;aAClC,CAAC,aAED,QAAQ,CAAC,KAAK,IAAI,+BAAI,SAAS,EAAE,CAAC,CAAC,oBAAoB,CAAC,YAAG,QAAQ,CAAC,KAAK,GAAM,EAChF,uBAAC,WAAW,IAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,GAAI,IAClD,GACJ,CACT,CAAC;AACN,CAAC,CAAC;AArBW,QAAA,WAAW,eAqBtB","sourcesContent":["import {Flex, Link, Tooltip} from '@gravity-ui/uikit';\n\nimport {Image} from '../../../../components';\nimport {useTheme} from '../../../../context/theme';\nimport {Col} from '../../../../grid';\nimport type {FooterBlockProps, FooterContactItem} from '../../../../models';\nimport {block, getThemedValue} from '../../../../utils';\nimport {useLogoImageProps} from '../../hooks/useLogoImageProps';\n\nimport './SocialFloor.scss';\n\nconst b = block('footer-block');\n\ntype SocialFloorProps = {\n contacts: NonNullable<FooterBlockProps['contacts']>;\n};\n\ntype SocialIconsProps = {\n links: SocialFloorProps['contacts']['links'];\n theme: ReturnType<typeof useTheme>;\n};\n\ntype SocialIconItemProps = {\n contact: FooterContactItem;\n theme: ReturnType<typeof useTheme>;\n};\n\nconst SocialIconItem = ({contact, theme}: SocialIconItemProps) => {\n const iconResolved = contact.icon && getThemedValue(contact.icon, theme);\n const iconProps = useLogoImageProps(iconResolved);\n\n if (!iconProps) {\n return null;\n }\n\n const content = (\n <li className={b('social-icons-item')}>\n <Link\n className={b('social-icon-link')}\n href={contact.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n <Flex direction=\"column\" alignItems=\"center\" gap={2}>\n <Image\n {...iconProps}\n alt={contact.urlTitle ?? ''}\n className={b('social-icon-item')}\n />\n </Flex>\n </Link>\n </li>\n );\n\n return contact.urlTitle ? (\n <Tooltip content={contact.urlTitle} openDelay={500}>\n {content}\n </Tooltip>\n ) : (\n content\n );\n};\n\nconst SocialIcons = ({links, theme}: SocialIconsProps) => {\n if (!links?.length) return null;\n\n return (\n <ul className={b('social-icons-list')}>\n {links.map((contact, index) => (\n <SocialIconItem key={index} contact={contact} theme={theme} />\n ))}\n </ul>\n );\n};\n\nexport const SocialFloor = ({contacts}: SocialFloorProps) => {\n const theme = useTheme();\n\n if (!contacts.links?.length) {\n return null;\n }\n\n return (\n <Col sizes={{all: 12}} className={b('floor', {social: true})}>\n <div\n className={b('social-floor-inner', {\n 'title-position': contacts.titlePosition || 'top',\n 'links-position': contacts.linksPosition || 'left',\n size: contacts.iconsSize ?? 'l',\n })}\n >\n {contacts.title && <h3 className={b('social-floor-title')}>{contacts.title}</h3>}\n <SocialIcons links={contacts.links} theme={theme} />\n </div>\n </Col>\n );\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SocialFloor } from "./SocialFloor.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SocialFloor = void 0;
|
|
4
|
+
var SocialFloor_1 = require("./SocialFloor.js");
|
|
5
|
+
Object.defineProperty(exports, "SocialFloor", { enumerable: true, get: function () { return SocialFloor_1.SocialFloor; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["blocks/Footer/components/SocialFloor/index.ts"],"names":[],"mappings":";;;AAAA,gDAA0C;AAAlC,0GAAA,WAAW,OAAA","sourcesContent":["export {SocialFloor} from './SocialFloor';\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLogoImageProps = useLogoImageProps;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const React = tslib_1.__importStar(require("react"));
|
|
6
|
+
const utils_1 = require("../../../components/Media/Image/utils.js");
|
|
7
|
+
function useLogoImageProps(logoImage) {
|
|
8
|
+
return React.useMemo(() => {
|
|
9
|
+
if (!logoImage) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const resolved = (0, utils_1.getMediaImage)(logoImage);
|
|
13
|
+
if (typeof resolved === 'string') {
|
|
14
|
+
return { src: resolved };
|
|
15
|
+
}
|
|
16
|
+
return resolved && typeof resolved === 'object'
|
|
17
|
+
? resolved
|
|
18
|
+
: null;
|
|
19
|
+
}, [logoImage]);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=useLogoImageProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLogoImageProps.js","sourceRoot":"../../../../../src","sources":["blocks/Footer/hooks/useLogoImageProps.ts"],"names":[],"mappings":";;AAKA,8CAiBC;;AAtBD,qDAA+B;AAE/B,oEAAoE;AAGpE,SAAgB,iBAAiB,CAC7B,SAAkC;IAElC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACtB,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,QAAQ,GAAG,IAAA,qBAAa,EAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,CAAC;QAC3B,CAAC;QAED,OAAO,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;YAC3C,CAAC,CAAE,QAA+C;YAClD,CAAC,CAAC,IAAI,CAAC;IACf,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;AACpB,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {getMediaImage} from '../../../components/Media/Image/utils';\nimport type {ImageProps as ModelImageProps} from '../../../models';\n\nexport function useLogoImageProps(\n logoImage?: ModelImageProps | null,\n): Record<string, unknown> | null {\n return React.useMemo(() => {\n if (!logoImage) {\n return null;\n }\n\n const resolved = getMediaImage(logoImage);\n if (typeof resolved === 'string') {\n return {src: resolved};\n }\n\n return resolved && typeof resolved === 'object'\n ? (resolved as unknown as Record<string, unknown>)\n : null;\n }, [logoImage]);\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DropdownMenuItem } from '@gravity-ui/uikit';
|
|
3
|
+
import { LinkProps } from "../../../models/index.js";
|
|
4
|
+
export type LinkItem = Required<Pick<LinkProps, 'text' | 'url'>>;
|
|
5
|
+
type UseOverflowListItemsProps = {
|
|
6
|
+
isDropdown?: boolean;
|
|
7
|
+
containerRef: React.RefObject<HTMLElement>;
|
|
8
|
+
items?: LinkItem[];
|
|
9
|
+
itemSelector: string;
|
|
10
|
+
moreButtonWidth?: number;
|
|
11
|
+
};
|
|
12
|
+
type OverflowListItemsResult = {
|
|
13
|
+
visibleItems: LinkItem[];
|
|
14
|
+
hiddenItems: DropdownMenuItem[];
|
|
15
|
+
measured: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function useOverflowListItems({ isDropdown, containerRef, items, itemSelector, moreButtonWidth, }: UseOverflowListItemsProps): OverflowListItemsResult;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useOverflowListItems = useOverflowListItems;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const React = tslib_1.__importStar(require("react"));
|
|
6
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
|
+
const throttle_1 = tslib_1.__importDefault(require("lodash/throttle.js"));
|
|
8
|
+
function parseCssPixelValue(value) {
|
|
9
|
+
const parsedValue = parseFloat(value);
|
|
10
|
+
return Number.isNaN(parsedValue) ? 0 : parsedValue;
|
|
11
|
+
}
|
|
12
|
+
function getElementWidth(element) {
|
|
13
|
+
return Math.ceil(Math.max(element.scrollWidth, element.getBoundingClientRect().width));
|
|
14
|
+
}
|
|
15
|
+
function useOverflowListItems({ isDropdown = false, containerRef, items, itemSelector, moreButtonWidth = 0, }) {
|
|
16
|
+
const [containerWidth, setContainerWidth] = React.useState(0);
|
|
17
|
+
const [itemWidths, setItemWidths] = React.useState([]);
|
|
18
|
+
const [itemGap, setItemGap] = React.useState(0);
|
|
19
|
+
const itemsCount = items?.length ?? 0;
|
|
20
|
+
const areItemsMeasured = !isDropdown || itemWidths.length === itemsCount;
|
|
21
|
+
const updateItemWidths = React.useCallback(() => {
|
|
22
|
+
if (!containerRef.current || !itemsCount) {
|
|
23
|
+
setItemWidths([]);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const itemElements = Array.from(containerRef.current.querySelectorAll(itemSelector));
|
|
27
|
+
if (itemElements.length !== itemsCount) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const listElement = itemElements[0]?.parentElement;
|
|
31
|
+
setItemWidths(itemElements.map(getElementWidth));
|
|
32
|
+
if (listElement) {
|
|
33
|
+
const listStyles = window.getComputedStyle(listElement);
|
|
34
|
+
setItemGap(parseCssPixelValue(listStyles.columnGap));
|
|
35
|
+
}
|
|
36
|
+
}, [containerRef, itemSelector, itemsCount]);
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
setItemWidths((currentItemWidths) => (currentItemWidths.length ? [] : currentItemWidths));
|
|
39
|
+
}, [items, isDropdown]);
|
|
40
|
+
React.useLayoutEffect(() => {
|
|
41
|
+
if (isDropdown && !areItemsMeasured) {
|
|
42
|
+
updateItemWidths();
|
|
43
|
+
}
|
|
44
|
+
}, [areItemsMeasured, isDropdown, updateItemWidths]);
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
if (!isDropdown || typeof document === 'undefined' || !('fonts' in document)) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
let cancelled = false;
|
|
50
|
+
document.fonts.ready.then(() => {
|
|
51
|
+
if (!cancelled) {
|
|
52
|
+
setItemWidths((currentItemWidths) => currentItemWidths.length ? [] : currentItemWidths);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return () => {
|
|
56
|
+
cancelled = true;
|
|
57
|
+
};
|
|
58
|
+
}, [items, isDropdown]);
|
|
59
|
+
const updateContainerSize = React.useMemo(() => (0, throttle_1.default)(() => {
|
|
60
|
+
if (!containerRef.current) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
setContainerWidth(containerRef.current.clientWidth);
|
|
64
|
+
}, 100), [containerRef]);
|
|
65
|
+
(0, uikit_1.useResizeObserver)({ ref: containerRef, onResize: updateContainerSize });
|
|
66
|
+
const isMeasured = containerWidth > 0 && areItemsMeasured;
|
|
67
|
+
const { visibleItems, hiddenItems } = React.useMemo(() => {
|
|
68
|
+
if (!isDropdown) {
|
|
69
|
+
return {
|
|
70
|
+
visibleItems: items ?? [],
|
|
71
|
+
hiddenItems: [],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (!isMeasured) {
|
|
75
|
+
return {
|
|
76
|
+
visibleItems: items ?? [],
|
|
77
|
+
hiddenItems: [],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const linksCount = itemWidths.length;
|
|
81
|
+
let visibleItemsCount = 0;
|
|
82
|
+
let remainingContainerWidth = containerWidth;
|
|
83
|
+
for (const width of itemWidths) {
|
|
84
|
+
const isMoreThanOneItemLeft = linksCount !== visibleItemsCount + 1;
|
|
85
|
+
const currentItemWidth = width + (visibleItemsCount === 0 ? 0 : itemGap);
|
|
86
|
+
remainingContainerWidth -= currentItemWidth;
|
|
87
|
+
const hasNoSpaceForTheLastItem = remainingContainerWidth < 0;
|
|
88
|
+
if (remainingContainerWidth < moreButtonWidth &&
|
|
89
|
+
(isMoreThanOneItemLeft || hasNoSpaceForTheLastItem)) {
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
visibleItemsCount++;
|
|
93
|
+
}
|
|
94
|
+
visibleItemsCount = Math.max(visibleItemsCount, 1);
|
|
95
|
+
return {
|
|
96
|
+
visibleItems: items?.slice(0, visibleItemsCount) ?? [],
|
|
97
|
+
hiddenItems: transformItemsToDropdownMenuItems(items?.slice(visibleItemsCount) ?? []),
|
|
98
|
+
};
|
|
99
|
+
}, [containerWidth, isMeasured, itemGap, itemWidths, items, moreButtonWidth, isDropdown]);
|
|
100
|
+
return { visibleItems, hiddenItems, measured: isMeasured };
|
|
101
|
+
}
|
|
102
|
+
function transformItemsToDropdownMenuItems(items) {
|
|
103
|
+
return items.map((item) => ({
|
|
104
|
+
text: item.text,
|
|
105
|
+
href: item.url,
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=useOverflowListItems.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOverflowListItems.js","sourceRoot":"../../../../../src","sources":["blocks/Footer/hooks/useOverflowListItems.ts"],"names":[],"mappings":";;AAiCA,oDAgIC;;AAjKD,qDAA+B;AAE/B,6CAAsE;AACtE,0EAAyC;AAoBzC,SAAS,kBAAkB,CAAC,KAAa;IACrC,MAAM,WAAW,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAEtC,OAAO,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;AACvD,CAAC;AAED,SAAS,eAAe,CAAC,OAAoB;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,qBAAqB,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;A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BAAqB,IAAI,wBAAwB,CAAC,EACrD,CAAC;gBACC,MAAM;YACV,CAAC;YAED,iBAAiB,EAAE,CAAC;QACxB,CAAC;QAED,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;QAEnD,OAAO;YACH,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,IAAI,EAAE;YACtD,WAAW,EAAE,iCAAiC,CAAC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;SACxF,CAAC;IACN,CAAC,EAAE,CAAC,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC;IAE1F,OAAO,EAAC,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAC,CAAC;AAC7D,CAAC;AAED,SAAS,iCAAiC,CACtC,KAAiB;IAEjB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACxB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,GAAG;KACjB,CAAC,CAAC,CAAC;AACR,CAAC","sourcesContent":["import * as React from 'react';\n\nimport {DropdownMenuItem, useResizeObserver} from '@gravity-ui/uikit';\nimport throttleFn from 'lodash/throttle';\n\nimport {LinkProps} from '../../../models';\n\nexport type LinkItem = Required<Pick<LinkProps, 'text' | 'url'>>;\n\ntype UseOverflowListItemsProps = {\n isDropdown?: boolean;\n containerRef: React.RefObject<HTMLElement>;\n items?: LinkItem[];\n itemSelector: string;\n moreButtonWidth?: number;\n};\n\ntype OverflowListItemsResult = {\n visibleItems: LinkItem[];\n hiddenItems: DropdownMenuItem[];\n measured: boolean;\n};\n\nfunction parseCssPixelValue(value: string) {\n const parsedValue = parseFloat(value);\n\n return Number.isNaN(parsedValue) ? 0 : parsedValue;\n}\n\nfunction getElementWidth(element: HTMLElement) {\n return Math.ceil(Math.max(element.scrollWidth, element.getBoundingClientRect().width));\n}\n\nexport function useOverflowListItems({\n isDropdown = false,\n containerRef,\n items,\n itemSelector,\n moreButtonWidth = 0,\n}: UseOverflowListItemsProps): OverflowListItemsResult {\n const [containerWidth, setContainerWidth] = React.useState<number>(0);\n const [itemWidths, setItemWidths] = React.useState<number[]>([]);\n const [itemGap, setItemGap] = React.useState<number>(0);\n const itemsCount = items?.length ?? 0;\n const areItemsMeasured = !isDropdown || itemWidths.length === itemsCount;\n\n const updateItemWidths = React.useCallback(() => {\n if (!containerRef.current || !itemsCount) {\n setItemWidths([]);\n return;\n }\n\n const itemElements = Array.from(\n containerRef.current.querySelectorAll(itemSelector),\n ) as HTMLElement[];\n\n if (itemElements.length !== itemsCount) {\n return;\n }\n\n const listElement = itemElements[0]?.parentElement;\n\n setItemWidths(itemElements.map(getElementWidth));\n\n if (listElement) {\n const listStyles = window.getComputedStyle(listElement);\n setItemGap(parseCssPixelValue(listStyles.columnGap));\n }\n }, [containerRef, itemSelector, itemsCount]);\n\n React.useEffect(() => {\n setItemWidths((currentItemWidths) => (currentItemWidths.length ? [] : currentItemWidths));\n }, [items, isDropdown]);\n\n React.useLayoutEffect(() => {\n if (isDropdown && !areItemsMeasured) {\n updateItemWidths();\n }\n }, [areItemsMeasured, isDropdown, updateItemWidths]);\n\n React.useEffect(() => {\n if (!isDropdown || typeof document === 'undefined' || !('fonts' in document)) {\n return undefined;\n }\n\n let cancelled = false;\n\n document.fonts.ready.then(() => {\n if (!cancelled) {\n setItemWidths((currentItemWidths) =>\n currentItemWidths.length ? [] : currentItemWidths,\n );\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [items, isDropdown]);\n\n const updateContainerSize = React.useMemo(\n () =>\n throttleFn(() => {\n if (!containerRef.current) {\n return;\n }\n\n setContainerWidth(containerRef.current.clientWidth);\n }, 100),\n [containerRef],\n );\n\n useResizeObserver({ref: containerRef, onResize: updateContainerSize});\n\n const isMeasured = containerWidth > 0 && areItemsMeasured;\n\n const {visibleItems, hiddenItems} = React.useMemo(() => {\n if (!isDropdown) {\n return {\n visibleItems: items ?? [],\n hiddenItems: [],\n };\n }\n\n if (!isMeasured) {\n return {\n visibleItems: items ?? [],\n hiddenItems: [],\n };\n }\n\n const linksCount = itemWidths.length;\n let visibleItemsCount = 0;\n let remainingContainerWidth = containerWidth;\n\n for (const width of itemWidths) {\n const isMoreThanOneItemLeft = linksCount !== visibleItemsCount + 1;\n const currentItemWidth = width + (visibleItemsCount === 0 ? 0 : itemGap);\n\n remainingContainerWidth -= currentItemWidth;\n\n const hasNoSpaceForTheLastItem = remainingContainerWidth < 0;\n if (\n remainingContainerWidth < moreButtonWidth &&\n (isMoreThanOneItemLeft || hasNoSpaceForTheLastItem)\n ) {\n break;\n }\n\n visibleItemsCount++;\n }\n\n visibleItemsCount = Math.max(visibleItemsCount, 1);\n\n return {\n visibleItems: items?.slice(0, visibleItemsCount) ?? [],\n hiddenItems: transformItemsToDropdownMenuItems(items?.slice(visibleItemsCount) ?? []),\n };\n }, [containerWidth, isMeasured, itemGap, itemWidths, items, moreButtonWidth, isDropdown]);\n\n return {visibleItems, hiddenItems, measured: isMeasured};\n}\n\nfunction transformItemsToDropdownMenuItems<ItemType extends {text: string; url: string}>(\n items: ItemType[],\n): DropdownMenuItem[] {\n return items.map((item) => ({\n text: item.text,\n href: item.url,\n }));\n}\n"]}
|