@blaze-cms/react-page-builder 0.147.0-rc-eagle.2 → 0.147.0-rc-eagle.6
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/lib/components/ContentGroup/ContentGroup.js +40 -8
- package/lib/components/ContentGroup/ContentGroup.js.map +1 -1
- package/lib/components/ContentGroup/ContentGroupDataFetcher.js +96 -0
- package/lib/components/ContentGroup/ContentGroupDataFetcher.js.map +1 -0
- package/lib/components/ContentGroup/helpers/build-data-sections.js +46 -0
- package/lib/components/ContentGroup/helpers/build-data-sections.js.map +1 -0
- package/lib/components/ContentGroup/helpers/index.js +7 -0
- package/lib/components/ContentGroup/helpers/index.js.map +1 -1
- package/lib/components/ContentGroupSection/ContentGroupSection.js +3 -2
- package/lib/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
- package/lib/components/Iframe/Iframe.js +16 -6
- package/lib/components/Iframe/Iframe.js.map +1 -1
- package/lib/components/Layout/Layout.js +14 -3
- package/lib/components/Layout/Layout.js.map +1 -1
- package/lib/components/Menu/Menu.js +4 -1
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/MenuContext.js +2 -1
- package/lib/components/Menu/MenuContext.js.map +1 -1
- package/lib/components/MenuItem/MenuItemRender.js +24 -9
- package/lib/components/MenuItem/MenuItemRender.js.map +1 -1
- package/lib/components/MenuItem/helpers/has-active-child.js +12 -0
- package/lib/components/MenuItem/helpers/has-active-child.js.map +1 -0
- package/lib/components/MenuItem/helpers/index.js +14 -0
- package/lib/components/MenuItem/helpers/index.js.map +1 -1
- package/lib/components/MenuItem/helpers/isUrlPathMatch.js +14 -0
- package/lib/components/MenuItem/helpers/isUrlPathMatch.js.map +1 -0
- package/lib/helpers/get-component-id.js +9 -3
- package/lib/helpers/get-component-id.js.map +1 -1
- package/lib-es/components/ContentGroup/ContentGroup.js +41 -9
- package/lib-es/components/ContentGroup/ContentGroup.js.map +1 -1
- package/lib-es/components/ContentGroup/ContentGroupDataFetcher.js +88 -0
- package/lib-es/components/ContentGroup/ContentGroupDataFetcher.js.map +1 -0
- package/lib-es/components/ContentGroup/helpers/build-data-sections.js +38 -0
- package/lib-es/components/ContentGroup/helpers/build-data-sections.js.map +1 -0
- package/lib-es/components/ContentGroup/helpers/index.js +2 -1
- package/lib-es/components/ContentGroup/helpers/index.js.map +1 -1
- package/lib-es/components/ContentGroupSection/ContentGroupSection.js +3 -2
- package/lib-es/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
- package/lib-es/components/Iframe/Iframe.js +16 -6
- package/lib-es/components/Iframe/Iframe.js.map +1 -1
- package/lib-es/components/Layout/Layout.js +14 -3
- package/lib-es/components/Layout/Layout.js.map +1 -1
- package/lib-es/components/Menu/Menu.js +4 -1
- package/lib-es/components/Menu/Menu.js.map +1 -1
- package/lib-es/components/Menu/MenuContext.js +2 -1
- package/lib-es/components/Menu/MenuContext.js.map +1 -1
- package/lib-es/components/MenuItem/MenuItemRender.js +25 -11
- package/lib-es/components/MenuItem/MenuItemRender.js.map +1 -1
- package/lib-es/components/MenuItem/helpers/has-active-child.js +5 -0
- package/lib-es/components/MenuItem/helpers/has-active-child.js.map +1 -0
- package/lib-es/components/MenuItem/helpers/index.js +3 -1
- package/lib-es/components/MenuItem/helpers/index.js.map +1 -1
- package/lib-es/components/MenuItem/helpers/isUrlPathMatch.js +8 -0
- package/lib-es/components/MenuItem/helpers/isUrlPathMatch.js.map +1 -0
- package/lib-es/helpers/get-component-id.js +9 -3
- package/lib-es/helpers/get-component-id.js.map +1 -1
- package/package.json +10 -11
- package/src/components/ContentGroup/ContentGroup.js +54 -8
- package/src/components/ContentGroup/ContentGroupDataFetcher.js +74 -0
- package/src/components/ContentGroup/helpers/build-data-sections.js +35 -0
- package/src/components/ContentGroup/helpers/index.js +2 -1
- package/src/components/ContentGroupSection/ContentGroupSection.js +2 -2
- package/src/components/Iframe/Iframe.js +22 -6
- package/src/components/Layout/Layout.js +13 -2
- package/src/components/Menu/Menu.js +3 -1
- package/src/components/Menu/MenuContext.js +1 -1
- package/src/components/MenuItem/MenuItemRender.js +40 -12
- package/src/components/MenuItem/helpers/has-active-child.js +10 -0
- package/src/components/MenuItem/helpers/index.js +3 -1
- package/src/components/MenuItem/helpers/isUrlPathMatch.js +10 -0
- package/src/helpers/get-component-id.js +7 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_button","_classnames","_router","_md","_nextjsComponents","_MenuContext","_BlazeLink","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Menu","children","collapse","modifier","mobileMenuModifier","mobileMenuChildrenModifier","mobileIconAlignment","mobileButtonModifier","hamburgerIconModifier","logoOnMobile","logoOnDesktop","logoOnMobileUrl","logoOnMobileAlt","logoOnMobileModifier","logoOnDesktopModifier","closeIconModifier","router","useRouter","showMobileMenu","setShowMobileMenu","useState","useEffect","handleRouteChange","events","on","off","shouldDisplayChildren","childModifiers","classnames","isMobileMenuExpanded","menuWrapperClasses","createElement","Provider","value","className","onClick","label","MdClose","MdMenu","Link","href","name","src","alt","propTypes","PropTypes","bool","isRequired","string","oneOfType","arrayOf","node","defaultProps","_default","exports"],"sources":["../../../src/components/Menu/Menu.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport BlazeButton from '@blaze-react/button';\nimport classnames from 'classnames';\nimport { useRouter } from 'next/router';\nimport { MdMenu, MdClose } from 'react-icons/md';\nimport { Link } from '@blaze-cms/nextjs-components';\nimport MenuContext from './MenuContext';\nimport BlazeLink from '../BlazeLink';\n\nconst Menu = ({\n children,\n collapse,\n modifier,\n mobileMenuModifier,\n mobileMenuChildrenModifier,\n mobileIconAlignment,\n mobileButtonModifier,\n hamburgerIconModifier,\n logoOnMobile,\n logoOnDesktop,\n logoOnMobileUrl,\n logoOnMobileAlt,\n logoOnMobileModifier,\n logoOnDesktopModifier,\n closeIconModifier\n}) => {\n const router = useRouter();\n const [showMobileMenu, setShowMobileMenu] = useState(false);\n\n useEffect(() => {\n const handleRouteChange = () => setShowMobileMenu(false);\n router.events.on('routeChangeStart', handleRouteChange);\n\n return () => {\n router.events.off('routeChangeStart', handleRouteChange);\n };\n }, [router.events]);\n\n const shouldDisplayChildren = collapse ? showMobileMenu : true;\n\n const childModifiers = classnames({\n [mobileMenuChildrenModifier]: shouldDisplayChildren,\n [modifier]: !showMobileMenu\n });\n\n const isMobileMenuExpanded = showMobileMenu ? `${mobileMenuModifier}` : '';\n const menuWrapperClasses = classnames('menu--wrapper', {\n 'menu--wrapper--mobile-open': showMobileMenu,\n 'menu--wrapper--mobile-closed': collapse && !showMobileMenu\n });\n\n return (\n <MenuContext.Provider value={{ showMobileMenu }}>\n <div className={menuWrapperClasses}>\n {collapse && (\n <div className=\"menu--mobile-wrapper\">\n <div\n className={`flex w-screen z-50 justify-${mobileIconAlignment} ${isMobileMenuExpanded}`}>\n <BlazeButton\n className={`menu--mobile-button ${mobileButtonModifier}`}\n onClick={() => setShowMobileMenu(!showMobileMenu)}\n label={showMobileMenu ? 'Close mobile menu' : 'Open mobile menu'}>\n <i>\n {showMobileMenu ? (\n <MdClose className={closeIconModifier} />\n ) : (\n <MdMenu className={hamburgerIconModifier} />\n )}\n </i>\n </BlazeButton>\n </div>\n </div>\n )}\n {logoOnMobile && !showMobileMenu && (\n <Link href=\"/\" name=\"mobile menu\">\n <img src={logoOnMobileUrl} alt={logoOnMobileAlt} className={logoOnMobileModifier} />\n </Link>\n )}\n\n <div className=\"menu--desktop-wrapper\">\n <ul className={childModifiers}>\n {logoOnDesktop && (\n <BlazeLink href=\"/\" className=\"\">\n <img\n src={logoOnMobileUrl}\n alt={logoOnMobileAlt}\n className={logoOnDesktopModifier}\n />\n </BlazeLink>\n )}\n {children}\n </ul>\n </div>\n </div>\n </MenuContext.Provider>\n );\n};\n\nMenu.propTypes = {\n collapse: PropTypes.bool.isRequired,\n logoOnMobile: PropTypes.bool.isRequired,\n logoOnDesktop: PropTypes.bool,\n logoOnMobileUrl: PropTypes.string,\n logoOnMobileAlt: PropTypes.string,\n logoOnMobileModifier: PropTypes.string,\n logoOnDesktopModifier: PropTypes.string,\n hamburgerIconModifier: PropTypes.string,\n closeIconModifier: PropTypes.string,\n mobileButtonModifier: PropTypes.string,\n mobileMenuModifier: PropTypes.string,\n mobileMenuChildrenModifier: PropTypes.string,\n modifier: PropTypes.string,\n mobileIconAlignment: PropTypes.string,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])\n};\n\nMenu.defaultProps = {\n logoOnDesktop: false,\n logoOnMobileUrl: '',\n logoOnMobileAlt: '',\n logoOnMobileModifier: '',\n logoOnDesktopModifier: '',\n hamburgerIconModifier: '',\n closeIconModifier: '',\n mobileButtonModifier: '',\n mobileIconAlignment: '',\n mobileMenuModifier: '',\n mobileMenuChildrenModifier: '',\n modifier: '',\n children: []\n};\n\nexport default Menu;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,WAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,GAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,UAAA,GAAAP,sBAAA,CAAAF,OAAA;AAAqC,SAAAD,wBAAAW,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAb,uBAAA,YAAAA,CAAAW,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CA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Menu.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_button","_classnames","_router","_md","_nextjsComponents","_MenuContext","_BlazeLink","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Menu","children","collapse","openActiveSubmenus","modifier","mobileMenuModifier","mobileMenuChildrenModifier","mobileIconAlignment","mobileButtonModifier","hamburgerIconModifier","logoOnMobile","logoOnDesktop","logoOnMobileUrl","logoOnMobileAlt","logoOnMobileModifier","logoOnDesktopModifier","closeIconModifier","router","useRouter","showMobileMenu","setShowMobileMenu","useState","useEffect","handleRouteChange","events","on","off","shouldDisplayChildren","childModifiers","classnames","isMobileMenuExpanded","menuWrapperClasses","createElement","Provider","value","className","onClick","label","MdClose","MdMenu","Link","href","name","src","alt","propTypes","PropTypes","bool","isRequired","string","oneOfType","arrayOf","node","defaultProps","_default","exports"],"sources":["../../../src/components/Menu/Menu.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport BlazeButton from '@blaze-react/button';\nimport classnames from 'classnames';\nimport { useRouter } from 'next/router';\nimport { MdMenu, MdClose } from 'react-icons/md';\nimport { Link } from '@blaze-cms/nextjs-components';\nimport MenuContext from './MenuContext';\nimport BlazeLink from '../BlazeLink';\n\nconst Menu = ({\n children,\n collapse,\n openActiveSubmenus,\n modifier,\n mobileMenuModifier,\n mobileMenuChildrenModifier,\n mobileIconAlignment,\n mobileButtonModifier,\n hamburgerIconModifier,\n logoOnMobile,\n logoOnDesktop,\n logoOnMobileUrl,\n logoOnMobileAlt,\n logoOnMobileModifier,\n logoOnDesktopModifier,\n closeIconModifier\n}) => {\n const router = useRouter();\n const [showMobileMenu, setShowMobileMenu] = useState(false);\n\n useEffect(() => {\n const handleRouteChange = () => setShowMobileMenu(false);\n router.events.on('routeChangeStart', handleRouteChange);\n\n return () => {\n router.events.off('routeChangeStart', handleRouteChange);\n };\n }, [router.events]);\n\n const shouldDisplayChildren = collapse ? showMobileMenu : true;\n\n const childModifiers = classnames({\n [mobileMenuChildrenModifier]: shouldDisplayChildren,\n [modifier]: !showMobileMenu\n });\n\n const isMobileMenuExpanded = showMobileMenu ? `${mobileMenuModifier}` : '';\n const menuWrapperClasses = classnames('menu--wrapper', {\n 'menu--wrapper--mobile-open': showMobileMenu,\n 'menu--wrapper--mobile-closed': collapse && !showMobileMenu\n });\n\n return (\n <MenuContext.Provider value={{ showMobileMenu, openActiveSubmenus }}>\n <div className={menuWrapperClasses}>\n {collapse && (\n <div className=\"menu--mobile-wrapper\">\n <div\n className={`flex w-screen z-50 justify-${mobileIconAlignment} ${isMobileMenuExpanded}`}>\n <BlazeButton\n className={`menu--mobile-button ${mobileButtonModifier}`}\n onClick={() => setShowMobileMenu(!showMobileMenu)}\n label={showMobileMenu ? 'Close mobile menu' : 'Open mobile menu'}>\n <i>\n {showMobileMenu ? (\n <MdClose className={closeIconModifier} />\n ) : (\n <MdMenu className={hamburgerIconModifier} />\n )}\n </i>\n </BlazeButton>\n </div>\n </div>\n )}\n {logoOnMobile && !showMobileMenu && (\n <Link href=\"/\" name=\"mobile menu\">\n <img src={logoOnMobileUrl} alt={logoOnMobileAlt} className={logoOnMobileModifier} />\n </Link>\n )}\n\n <div className=\"menu--desktop-wrapper\">\n <ul className={childModifiers}>\n {logoOnDesktop && (\n <BlazeLink href=\"/\" className=\"\">\n <img\n src={logoOnMobileUrl}\n alt={logoOnMobileAlt}\n className={logoOnDesktopModifier}\n />\n </BlazeLink>\n )}\n {children}\n </ul>\n </div>\n </div>\n </MenuContext.Provider>\n );\n};\n\nMenu.propTypes = {\n collapse: PropTypes.bool.isRequired,\n openActiveSubmenus: PropTypes.bool.isRequired,\n logoOnMobile: PropTypes.bool.isRequired,\n logoOnDesktop: PropTypes.bool,\n logoOnMobileUrl: PropTypes.string,\n logoOnMobileAlt: PropTypes.string,\n logoOnMobileModifier: PropTypes.string,\n logoOnDesktopModifier: PropTypes.string,\n hamburgerIconModifier: PropTypes.string,\n closeIconModifier: PropTypes.string,\n mobileButtonModifier: PropTypes.string,\n mobileMenuModifier: PropTypes.string,\n mobileMenuChildrenModifier: PropTypes.string,\n modifier: PropTypes.string,\n mobileIconAlignment: PropTypes.string,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])\n};\n\nMenu.defaultProps = {\n logoOnDesktop: false,\n logoOnMobileUrl: '',\n logoOnMobileAlt: '',\n logoOnMobileModifier: '',\n logoOnDesktopModifier: '',\n hamburgerIconModifier: '',\n closeIconModifier: '',\n mobileButtonModifier: '',\n mobileIconAlignment: '',\n mobileMenuModifier: '',\n mobileMenuChildrenModifier: '',\n modifier: '',\n children: []\n};\n\nexport default Menu;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,WAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,GAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,UAAA,GAAAP,sBAAA,CAAAF,OAAA;AAAqC,SAAAD,wBAAAW,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAb,uBAAA,YAAAA,CAAAW,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,G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C,IAAI;EAC7BnC,eAAe,EAAEkC,kBAAS,CAACG,MAAM;EACjCpC,eAAe,EAAEiC,kBAAS,CAACG,MAAM;EACjCnC,oBAAoB,EAAEgC,kBAAS,CAACG,MAAM;EACtClC,qBAAqB,EAAE+B,kBAAS,CAACG,MAAM;EACvCxC,qBAAqB,EAAEqC,kBAAS,CAACG,MAAM;EACvCjC,iBAAiB,EAAE8B,kBAAS,CAACG,MAAM;EACnCzC,oBAAoB,EAAEsC,kBAAS,CAACG,MAAM;EACtC5C,kBAAkB,EAAEyC,kBAAS,CAACG,MAAM;EACpC3C,0BAA0B,EAAEwC,kBAAS,CAACG,MAAM;EAC5C7C,QAAQ,EAAE0C,kBAAS,CAACG,MAAM;EAC1B1C,mBAAmB,EAAEuC,kBAAS,CAACG,MAAM;EACrChD,QAAQ,EAAE6C,kBAAS,CAACI,SAAS,CAAC,CAACJ,kBAAS,CAACK,OAAO,CAACL,kBAAS,CAACM,IAAI,CAAC,EAAEN,kBAAS,CAACM,IAAI,CAAC;AACnF,CAAC;AAEDpD,IAAI,CAACqD,YAAY,GAAG;EAClB1C,aAAa,EAAE,KAAK;EACpBC,eAAe,EAAE,EAAE;EACnBC,eAAe,EAAE,EAAE;EACnBC,oBAAoB,EAAE,EAAE;EACxBC,qBAAqB,EAAE,EAAE;EACzBN,qBAAqB,EAAE,EAAE;EACzBO,iBAAiB,EAAE,EAAE;EACrBR,oBAAoB,EAAE,EAAE;EACxBD,mBAAmB,EAAE,EAAE;EACvBF,kBAAkB,EAAE,EAAE;EACtBC,0BAA0B,EAAE,EAAE;EAC9BF,QAAQ,EAAE,EAAE;EACZH,QAAQ,EAAE;AACZ,CAAC;AAAC,IAAAqD,QAAA,GAAAC,OAAA,CAAAhE,OAAA,GAEaS,IAAI","ignoreList":[]}
|
|
@@ -7,7 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
const MenuContext = /*#__PURE__*/_react.default.createContext({
|
|
10
|
-
showMobileMenu: false
|
|
10
|
+
showMobileMenu: false,
|
|
11
|
+
openActiveSubmenus: false
|
|
11
12
|
});
|
|
12
13
|
var _default = exports.default = MenuContext;
|
|
13
14
|
//# sourceMappingURL=MenuContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuContext.js","names":["_react","_interopRequireDefault","require","MenuContext","React","createContext","showMobileMenu","_default","exports","default"],"sources":["../../../src/components/Menu/MenuContext.js"],"sourcesContent":["import React from 'react';\n\nconst MenuContext = React.createContext({ showMobileMenu: false });\n\nexport default MenuContext;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,MAAMC,WAAW,gBAAGC,cAAK,CAACC,aAAa,CAAC;EAAEC,cAAc,EAAE;AAAM,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,
|
|
1
|
+
{"version":3,"file":"MenuContext.js","names":["_react","_interopRequireDefault","require","MenuContext","React","createContext","showMobileMenu","openActiveSubmenus","_default","exports","default"],"sources":["../../../src/components/Menu/MenuContext.js"],"sourcesContent":["import React from 'react';\n\nconst MenuContext = React.createContext({ showMobileMenu: false, openActiveSubmenus: false });\n\nexport default MenuContext;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,MAAMC,WAAW,gBAAGC,cAAK,CAACC,aAAa,CAAC;EAAEC,cAAc,EAAE,KAAK;EAAEC,kBAAkB,EAAE;AAAM,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAE/EP,WAAW","ignoreList":[]}
|
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _fa = require("react-icons/fa");
|
|
11
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
12
|
var _router = require("next/router");
|
|
12
13
|
var _utilsHandlebars = require("@blaze-cms/utils-handlebars");
|
|
13
14
|
var _constants = require("../../constants");
|
|
@@ -16,6 +17,8 @@ var _BlazeLink = _interopRequireDefault(require("../BlazeLink"));
|
|
|
16
17
|
var _MenuContext = _interopRequireDefault(require("../Menu/MenuContext"));
|
|
17
18
|
var _helpers2 = require("./helpers");
|
|
18
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
20
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
21
|
+
|
|
19
22
|
const MenuItemRender = ({
|
|
20
23
|
children,
|
|
21
24
|
eventType,
|
|
@@ -24,10 +27,13 @@ const MenuItemRender = ({
|
|
|
24
27
|
url,
|
|
25
28
|
parent
|
|
26
29
|
}) => {
|
|
27
|
-
const
|
|
30
|
+
const router = (0, _router.useRouter)();
|
|
28
31
|
const {
|
|
29
|
-
showMobileMenu
|
|
32
|
+
showMobileMenu,
|
|
33
|
+
openActiveSubmenus
|
|
30
34
|
} = (0, _react.useContext)(_MenuContext.default);
|
|
35
|
+
const isHoverEvent = eventType === _constants.HOVER;
|
|
36
|
+
const isClickEvent = eventType === _constants.CLICK;
|
|
31
37
|
const {
|
|
32
38
|
loading: loadingText,
|
|
33
39
|
data: [textToUse]
|
|
@@ -36,19 +42,21 @@ const MenuItemRender = ({
|
|
|
36
42
|
loading: loadingUrl,
|
|
37
43
|
data: [urlToUse]
|
|
38
44
|
} = (0, _utilsHandlebars.useStringTemplate)(parent, [(0, _helpers2.injectHelperIntoTemplate)(url, 'url_encode')]);
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
45
|
+
const isActive = router ? (0, _helpers2.isUrlPathMatch)(router.asPath, urlToUse) : false;
|
|
46
|
+
const isActiveParent = router ? (0, _helpers2.hasActiveChild)(router.asPath, children) : false;
|
|
47
|
+
const shouldPreOpen = openActiveSubmenus && isActiveParent && isClickEvent;
|
|
42
48
|
const hasValidChildren = (0, _helpers.hasChildren)(children);
|
|
49
|
+
const [displayChildren, setDisplayChildren] = (0, _react.useState)(shouldPreOpen);
|
|
43
50
|
(0, _react.useEffect)(() => {
|
|
44
|
-
if (!showMobileMenu) setDisplayChildren(false);
|
|
45
|
-
}, [showMobileMenu]);
|
|
51
|
+
if (!showMobileMenu && !shouldPreOpen) setDisplayChildren(false);
|
|
52
|
+
}, [children, isClickEvent, loadingUrl, openActiveSubmenus, router, shouldPreOpen, showMobileMenu]);
|
|
46
53
|
(0, _react.useEffect)(() => {
|
|
47
54
|
if (isHoverEvent) {
|
|
48
55
|
setDisplayChildren(false);
|
|
49
56
|
}
|
|
50
57
|
}, [router.asPath, isHoverEvent]);
|
|
51
58
|
if (loadingUrl || loadingText) return '';
|
|
59
|
+
const childrenDisplayClass = displayChildren ? '' : _constants.HIDDEN;
|
|
52
60
|
const handleItemEvent = ({
|
|
53
61
|
type
|
|
54
62
|
}) => {
|
|
@@ -66,18 +74,25 @@ const MenuItemRender = ({
|
|
|
66
74
|
setDisplayChildren(!displayChildren);
|
|
67
75
|
}
|
|
68
76
|
};
|
|
77
|
+
const menuItemLinkClassname = (0, _classnames.default)('menu--item--link', {
|
|
78
|
+
'menu--item--link--active': isActive,
|
|
79
|
+
'menu--item--link--active-parent': isActiveParent
|
|
80
|
+
});
|
|
69
81
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
70
82
|
className: modifier,
|
|
71
83
|
onMouseEnter: handleItemEvent,
|
|
72
84
|
onMouseLeave: handleItemEvent
|
|
73
85
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
74
|
-
className:
|
|
86
|
+
className: menuItemLinkClassname,
|
|
75
87
|
onClick: handleMobileClick,
|
|
76
88
|
role: !urlToUse && hasValidChildren ? 'button' : undefined,
|
|
77
89
|
tabIndex: !urlToUse && hasValidChildren ? 0 : undefined
|
|
78
90
|
}, urlToUse ? /*#__PURE__*/_react.default.createElement(_BlazeLink.default, {
|
|
79
91
|
href: urlToUse
|
|
80
|
-
}, textToUse) : /*#__PURE__*/_react.default.createElement("span",
|
|
92
|
+
}, textToUse) : /*#__PURE__*/_react.default.createElement("span", {
|
|
93
|
+
role: "button",
|
|
94
|
+
onClick: handleItemEvent
|
|
95
|
+
}, textToUse), hasValidChildren && /*#__PURE__*/_react.default.createElement("i", {
|
|
81
96
|
role: "button",
|
|
82
97
|
className: "menu--item--link--icon",
|
|
83
98
|
onClick: e => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItemRender.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_fa","_router","_utilsHandlebars","_constants","_helpers","_BlazeLink","_MenuContext","_helpers2","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MenuItemRender","children","eventType","text","modifier","url","parent","displayChildren","setDisplayChildren","useState","showMobileMenu","useContext","MenuContext","loading","loadingText","data","textToUse","useStringTemplate","loadingUrl","urlToUse","injectHelperIntoTemplate","router","useRouter","isHoverEvent","HOVER","childrenDisplayClass","HIDDEN","hasValidChildren","hasChildren","useEffect","asPath","handleItemEvent","type","MOUSE_ENTER","MOUSE_LEAVE","handleMobileClick","createElement","className","onMouseEnter","onMouseLeave","onClick","role","undefined","tabIndex","href","stopPropagation","FaChevronUp","FaChevronDown","propTypes","PropTypes","string","isRequired","object","oneOfType","arrayOf","node","defaultProps","_default","exports"],"sources":["../../../src/components/MenuItem/MenuItemRender.js"],"sourcesContent":["import React, { useState, useContext, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport { FaChevronDown, FaChevronUp } from 'react-icons/fa';\nimport { useRouter } from 'next/router';\nimport { useStringTemplate } from '@blaze-cms/utils-handlebars';\nimport { HOVER, MOUSE_ENTER, MOUSE_LEAVE, HIDDEN } from '../../constants';\nimport { hasChildren } from '../../helpers';\nimport BlazeLink from '../BlazeLink';\nimport MenuContext from '../Menu/MenuContext';\nimport { injectHelperIntoTemplate } from './helpers';\n\nconst MenuItemRender = ({ children, eventType, text, modifier, url, parent }) => {\n const [displayChildren, setDisplayChildren] = useState(false);\n const { showMobileMenu } = useContext(MenuContext);\n const {\n loading: loadingText,\n data: [textToUse]\n } = useStringTemplate(parent, [text]);\n const {\n loading: loadingUrl,\n data: [urlToUse]\n } = useStringTemplate(parent, [injectHelperIntoTemplate(url, 'url_encode')]);\n\n const router = useRouter();\n const isHoverEvent = eventType === HOVER;\n const childrenDisplayClass = displayChildren ? '' : HIDDEN;\n const hasValidChildren = hasChildren(children);\n\n useEffect(() => {\n if (!showMobileMenu) setDisplayChildren(false);\n }, [showMobileMenu]);\n\n useEffect(() => {\n if (isHoverEvent) {\n setDisplayChildren(false);\n }\n }, [router.asPath, isHoverEvent]);\n\n if (loadingUrl || loadingText) return '';\n\n const handleItemEvent = ({ type }) => {\n if (isHoverEvent) {\n if (type === MOUSE_ENTER) {\n setDisplayChildren(true);\n }\n if (type === MOUSE_LEAVE) {\n setDisplayChildren(false);\n }\n }\n };\n\n const handleMobileClick = () => {\n if (!urlToUse && hasValidChildren) {\n setDisplayChildren(!displayChildren);\n }\n };\n\n return (\n <li className={modifier} onMouseEnter={handleItemEvent} onMouseLeave={handleItemEvent}>\n <div\n className=\"menu--item--link\"\n onClick={handleMobileClick}\n role={!urlToUse && hasValidChildren ? 'button' : undefined}\n tabIndex={!urlToUse && hasValidChildren ? 0 : undefined}>\n {urlToUse ? <BlazeLink href={urlToUse}>{textToUse}</BlazeLink> : <span>{textToUse}</span>}\n\n {hasValidChildren && (\n <i\n role=\"button\"\n className=\"menu--item--link--icon\"\n onClick={e => {\n e.stopPropagation();\n setDisplayChildren(!displayChildren);\n }}\n tabIndex={0}>\n {displayChildren ? <FaChevronUp /> : <FaChevronDown />}\n </i>\n )}\n </div>\n\n {hasValidChildren && (\n <div className={`menu--item-children ${childrenDisplayClass}`}>{children}</div>\n )}\n </li>\n );\n};\n\nMenuItemRender.propTypes = {\n modifier: PropTypes.string,\n text: PropTypes.string,\n url: PropTypes.string,\n eventType: PropTypes.string.isRequired,\n parent: PropTypes.object,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])\n};\n\nMenuItemRender.defaultProps = {\n url: '',\n modifier: '',\n text: '',\n children: null,\n parent: {}\n};\n\nexport default MenuItemRender;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,GAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,YAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,SAAA,GAAAV,OAAA;AAAqD,SAAAD,wBAAAY,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAd,uBAAA,YAAAA,CAAAY,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC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AAM,EAAE2C,kBAAS,CAACG,MAAM;EACxBnD,QAAQ,EAAEgD,kBAAS,CAACI,SAAS,CAAC,CAACJ,kBAAS,CAACK,OAAO,CAACL,kBAAS,CAACM,IAAI,CAAC,EAAEN,kBAAS,CAACM,IAAI,CAAC;AACnF,CAAC;AAEDvD,cAAc,CAACwD,YAAY,GAAG;EAC5BnD,GAAG,EAAE,EAAE;EACPD,QAAQ,EAAE,EAAE;EACZD,IAAI,EAAE,EAAE;EACRF,QAAQ,EAAE,IAAI;EACdK,MAAM,EAAE,CAAC;AACX,CAAC;AAAC,IAAAmD,QAAA,GAAAC,OAAA,CAAAnE,OAAA,GAEaS,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"MenuItemRender.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_fa","_classnames","_router","_utilsHandlebars","_constants","_helpers","_BlazeLink","_MenuContext","_helpers2","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MenuItemRender","children","eventType","text","modifier","url","parent","router","useRouter","showMobileMenu","openActiveSubmenus","useContext","MenuContext","isHoverEvent","HOVER","isClickEvent","CLICK","loading","loadingText","data","textToUse","useStringTemplate","loadingUrl","urlToUse","injectHelperIntoTemplate","isActive","isUrlPathMatch","asPath","isActiveParent","hasActiveChild","shouldPreOpen","hasValidChildren","hasChildren","displayChildren","setDisplayChildren","useState","useEffect","childrenDisplayClass","HIDDEN","handleItemEvent","type","MOUSE_ENTER","MOUSE_LEAVE","handleMobileClick","menuItemLinkClassname","classnames","createElement","className","onMouseEnter","onMouseLeave","onClick","role","undefined","tabIndex","href","stopPropagation","FaChevronUp","FaChevronDown","propTypes","PropTypes","string","isRequired","object","oneOfType","arrayOf","node","defaultProps","_default","exports"],"sources":["../../../src/components/MenuItem/MenuItemRender.js"],"sourcesContent":["/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport React, { useState, useContext, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport { FaChevronDown, FaChevronUp } from 'react-icons/fa';\nimport classnames from 'classnames';\nimport { useRouter } from 'next/router';\nimport { useStringTemplate } from '@blaze-cms/utils-handlebars';\nimport { HOVER, MOUSE_ENTER, MOUSE_LEAVE, HIDDEN, CLICK } from '../../constants';\nimport { hasChildren } from '../../helpers';\nimport BlazeLink from '../BlazeLink';\nimport MenuContext from '../Menu/MenuContext';\nimport { injectHelperIntoTemplate, isUrlPathMatch, hasActiveChild } from './helpers';\n\nconst MenuItemRender = ({ children, eventType, text, modifier, url, parent }) => {\n const router = useRouter();\n const { showMobileMenu, openActiveSubmenus } = useContext(MenuContext);\n\n const isHoverEvent = eventType === HOVER;\n const isClickEvent = eventType === CLICK;\n\n const {\n loading: loadingText,\n data: [textToUse]\n } = useStringTemplate(parent, [text]);\n const {\n loading: loadingUrl,\n data: [urlToUse]\n } = useStringTemplate(parent, [injectHelperIntoTemplate(url, 'url_encode')]);\n\n const isActive = router ? isUrlPathMatch(router.asPath, urlToUse) : false;\n const isActiveParent = router ? hasActiveChild(router.asPath, children) : false;\n const shouldPreOpen = openActiveSubmenus && isActiveParent && isClickEvent;\n const hasValidChildren = hasChildren(children);\n\n const [displayChildren, setDisplayChildren] = useState(shouldPreOpen);\n\n useEffect(() => {\n if (!showMobileMenu && !shouldPreOpen) setDisplayChildren(false);\n }, [\n children,\n isClickEvent,\n loadingUrl,\n openActiveSubmenus,\n router,\n shouldPreOpen,\n showMobileMenu\n ]);\n\n useEffect(() => {\n if (isHoverEvent) {\n setDisplayChildren(false);\n }\n }, [router.asPath, isHoverEvent]);\n\n if (loadingUrl || loadingText) return '';\n\n const childrenDisplayClass = displayChildren ? '' : HIDDEN;\n\n const handleItemEvent = ({ type }) => {\n if (isHoverEvent) {\n if (type === MOUSE_ENTER) {\n setDisplayChildren(true);\n }\n if (type === MOUSE_LEAVE) {\n setDisplayChildren(false);\n }\n }\n };\n\n const handleMobileClick = () => {\n if (!urlToUse && hasValidChildren) {\n setDisplayChildren(!displayChildren);\n }\n };\n\n const menuItemLinkClassname = classnames('menu--item--link', {\n 'menu--item--link--active': isActive,\n 'menu--item--link--active-parent': isActiveParent\n });\n\n return (\n <li className={modifier} onMouseEnter={handleItemEvent} onMouseLeave={handleItemEvent}>\n <div\n className={menuItemLinkClassname}\n onClick={handleMobileClick}\n role={!urlToUse && hasValidChildren ? 'button' : undefined}\n tabIndex={!urlToUse && hasValidChildren ? 0 : undefined}>\n {urlToUse ? (\n <BlazeLink href={urlToUse}>{textToUse}</BlazeLink>\n ) : (\n <span role=\"button\" onClick={handleItemEvent}>\n {textToUse}\n </span>\n )}\n {hasValidChildren && (\n <i\n role=\"button\"\n className=\"menu--item--link--icon\"\n onClick={e => {\n e.stopPropagation();\n setDisplayChildren(!displayChildren);\n }}\n tabIndex={0}>\n {displayChildren ? <FaChevronUp /> : <FaChevronDown />}\n </i>\n )}\n </div>\n\n {hasValidChildren && (\n <div className={`menu--item-children ${childrenDisplayClass}`}>{children}</div>\n )}\n </li>\n );\n};\n\nMenuItemRender.propTypes = {\n modifier: PropTypes.string,\n text: PropTypes.string,\n url: PropTypes.string,\n eventType: PropTypes.string.isRequired,\n parent: PropTypes.object,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])\n};\n\nMenuItemRender.defaultProps = {\n url: '',\n modifier: '',\n text: '',\n children: null,\n parent: {}\n};\n\nexport default MenuItemRender;\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,GAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,UAAA,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;AAEDjE,cAAc,CAACkE,YAAY,GAAG;EAC5B7D,GAAG,EAAE,EAAE;EACPD,QAAQ,EAAE,EAAE;EACZD,IAAI,EAAE,EAAE;EACRF,QAAQ,EAAE,IAAI;EACdK,MAAM,EAAE,CAAC;AACX,CAAC;AAAC,IAAA6D,QAAA,GAAAC,OAAA,CAAA7E,OAAA,GAEaS,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _isUrlPathMatch = _interopRequireDefault(require("./isUrlPathMatch"));
|
|
9
|
+
var _helpers = require("../../../helpers");
|
|
10
|
+
const hasActiveChild = (path, children) => (0, _helpers.hasChildren)(children) && children.props.children[1][0].props.component.items.find(menuItem => (0, _isUrlPathMatch.default)(path, menuItem.settings.url));
|
|
11
|
+
var _default = exports.default = hasActiveChild;
|
|
12
|
+
//# sourceMappingURL=has-active-child.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-active-child.js","names":["_isUrlPathMatch","_interopRequireDefault","require","_helpers","hasActiveChild","path","children","hasChildren","props","component","items","find","menuItem","isUrlPathMatch","settings","url","_default","exports","default"],"sources":["../../../../src/components/MenuItem/helpers/has-active-child.js"],"sourcesContent":["import isUrlPathMatch from './isUrlPathMatch';\nimport { hasChildren } from '../../../helpers';\n\nconst hasActiveChild = (path, children) =>\n hasChildren(children) &&\n children.props.children[1][0].props.component.items.find(menuItem =>\n isUrlPathMatch(path, menuItem.settings.url)\n );\n\nexport default hasActiveChild;\n"],"mappings":";;;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,cAAc,GAAGA,CAACC,IAAI,EAAEC,QAAQ,KACpC,IAAAC,oBAAW,EAACD,QAAQ,CAAC,IACrBA,QAAQ,CAACE,KAAK,CAACF,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACE,KAAK,CAACC,SAAS,CAACC,KAAK,CAACC,IAAI,CAACC,QAAQ,IAC/D,IAAAC,uBAAc,EAACR,IAAI,EAAEO,QAAQ,CAACE,QAAQ,CAACC,GAAG,CAC5C,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEWd,cAAc","ignoreList":[]}
|
|
@@ -4,11 +4,25 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
Object.defineProperty(exports, "hasActiveChild", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _hasActiveChild.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
7
13
|
Object.defineProperty(exports, "injectHelperIntoTemplate", {
|
|
8
14
|
enumerable: true,
|
|
9
15
|
get: function () {
|
|
10
16
|
return _injectHelperIntoTemplate.default;
|
|
11
17
|
}
|
|
12
18
|
});
|
|
19
|
+
Object.defineProperty(exports, "isUrlPathMatch", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _isUrlPathMatch.default;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
13
25
|
var _injectHelperIntoTemplate = _interopRequireDefault(require("./inject-helper-into-template"));
|
|
26
|
+
var _isUrlPathMatch = _interopRequireDefault(require("./isUrlPathMatch"));
|
|
27
|
+
var _hasActiveChild = _interopRequireDefault(require("./has-active-child"));
|
|
14
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_injectHelperIntoTemplate","_interopRequireDefault","require"],"sources":["../../../../src/components/MenuItem/helpers/index.js"],"sourcesContent":["import injectHelperIntoTemplate from './inject-helper-into-template';\n\nexport { injectHelperIntoTemplate };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_injectHelperIntoTemplate","_interopRequireDefault","require","_isUrlPathMatch","_hasActiveChild"],"sources":["../../../../src/components/MenuItem/helpers/index.js"],"sourcesContent":["import injectHelperIntoTemplate from './inject-helper-into-template';\nimport isUrlPathMatch from './isUrlPathMatch';\nimport hasActiveChild from './has-active-child';\n\nexport { injectHelperIntoTemplate, isUrlPathMatch, hasActiveChild };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,yBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,eAAA,GAAAH,sBAAA,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const isUrlPathMatch = (path, itemUrl) => {
|
|
8
|
+
if (!itemUrl || !path) return false;
|
|
9
|
+
const reg = new RegExp(/^[^#?]+/);
|
|
10
|
+
const _path = reg.exec(path)[0];
|
|
11
|
+
return _path === itemUrl || _path === `/${itemUrl}`;
|
|
12
|
+
};
|
|
13
|
+
var _default = exports.default = isUrlPathMatch;
|
|
14
|
+
//# sourceMappingURL=isUrlPathMatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isUrlPathMatch.js","names":["isUrlPathMatch","path","itemUrl","reg","RegExp","_path","exec","_default","exports","default"],"sources":["../../../../src/components/MenuItem/helpers/isUrlPathMatch.js"],"sourcesContent":["const isUrlPathMatch = (path, itemUrl) => {\n if (!itemUrl || !path) return false;\n\n const reg = new RegExp(/^[^#?]+/);\n const _path = reg.exec(path)[0];\n\n return _path === itemUrl || _path === `/${itemUrl}`;\n};\n\nexport default isUrlPathMatch;\n"],"mappings":";;;;;;AAAA,MAAMA,cAAc,GAAGA,CAACC,IAAI,EAAEC,OAAO,KAAK;EACxC,IAAI,CAACA,OAAO,IAAI,CAACD,IAAI,EAAE,OAAO,KAAK;EAEnC,MAAME,GAAG,GAAG,IAAIC,MAAM,CAAC,SAAS,CAAC;EACjC,MAAMC,KAAK,GAAGF,GAAG,CAACG,IAAI,CAACL,IAAI,CAAC,CAAC,CAAC,CAAC;EAE/B,OAAOI,KAAK,KAAKH,OAAO,IAAIG,KAAK,KAAK,IAAIH,OAAO,EAAE;AACrD,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaT,cAAc","ignoreList":[]}
|
|
@@ -7,8 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _cssesc = _interopRequireDefault(require("cssesc"));
|
|
9
9
|
var _constants = require("../constants");
|
|
10
|
-
const getComponentId = componentName
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const getComponentId = (componentName, noPrefix = false, toLowerCase = false) => {
|
|
11
|
+
let id = `${noPrefix ? '' : _constants.COMPONENT_ID_PREFIX}${componentName.replace(/\s+/g, '-')}`;
|
|
12
|
+
if (toLowerCase) {
|
|
13
|
+
id = id.toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
return (0, _cssesc.default)(id, {
|
|
16
|
+
isIdentifier: true
|
|
17
|
+
});
|
|
18
|
+
};
|
|
13
19
|
var _default = exports.default = getComponentId;
|
|
14
20
|
//# sourceMappingURL=get-component-id.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-component-id.js","names":["_cssesc","_interopRequireDefault","require","_constants","getComponentId","componentName","
|
|
1
|
+
{"version":3,"file":"get-component-id.js","names":["_cssesc","_interopRequireDefault","require","_constants","getComponentId","componentName","noPrefix","toLowerCase","id","COMPONENT_ID_PREFIX","replace","cssesc","isIdentifier","_default","exports","default"],"sources":["../../src/helpers/get-component-id.js"],"sourcesContent":["import cssesc from 'cssesc';\nimport { COMPONENT_ID_PREFIX } from '../constants';\n\nconst getComponentId = (componentName, noPrefix = false, toLowerCase = false) => {\n let id = `${noPrefix ? '' : COMPONENT_ID_PREFIX}${componentName.replace(/\\s+/g, '-')}`;\n if (toLowerCase) {\n id = id.toLowerCase();\n }\n return cssesc(id, { isIdentifier: true });\n};\n\nexport default getComponentId;\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,MAAME,cAAc,GAAGA,CAACC,aAAa,EAAEC,QAAQ,GAAG,KAAK,EAAEC,WAAW,GAAG,KAAK,KAAK;EAC/E,IAAIC,EAAE,GAAG,GAAGF,QAAQ,GAAG,EAAE,GAAGG,8BAAmB,GAAGJ,aAAa,CAACK,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;EACtF,IAAIH,WAAW,EAAE;IACfC,EAAE,GAAGA,EAAE,CAACD,WAAW,CAAC,CAAC;EACvB;EACA,OAAO,IAAAI,eAAM,EAACH,EAAE,EAAE;IAAEI,YAAY,EAAE;EAAK,CAAC,CAAC;AAC3C,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaX,cAAc","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
const _excluded = ["contentType", "isFaqContent", "children", "customHtmlProps"],
|
|
4
|
+
const _excluded = ["contentType", "isFaqContent", "children", "customHtmlProps", "simpleData", "dataProperty"],
|
|
5
5
|
_excluded2 = ["topWrapperProps"];
|
|
6
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -10,7 +10,8 @@ import PropTypes from 'prop-types';
|
|
|
10
10
|
import { CONTENT_GROUP_TYPES } from './constants';
|
|
11
11
|
import ContentGroupTabs from './ContentGroupTabs';
|
|
12
12
|
import ContentGroupAccordion from './ContentGroupAccordion';
|
|
13
|
-
import
|
|
13
|
+
import ContentGroupDataFetcher from './ContentGroupDataFetcher';
|
|
14
|
+
import { getSectionsData, buildDataSections } from './helpers';
|
|
14
15
|
import getStructuredDataProperties from './helpers/get-structured-data-properties';
|
|
15
16
|
import { getCustomHtmlProperties } from '../../helpers';
|
|
16
17
|
const VALID_TYPES = Object.values(CONTENT_GROUP_TYPES);
|
|
@@ -20,10 +21,15 @@ const ContentGroup = _ref => {
|
|
|
20
21
|
contentType,
|
|
21
22
|
isFaqContent,
|
|
22
23
|
children,
|
|
23
|
-
customHtmlProps
|
|
24
|
+
customHtmlProps,
|
|
25
|
+
simpleData,
|
|
26
|
+
dataProperty
|
|
24
27
|
} = _ref,
|
|
25
28
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
-
const
|
|
29
|
+
const hasSimpleData = Array.isArray(simpleData) && simpleData.length > 0;
|
|
30
|
+
const dataPropertyName = Array.isArray(dataProperty) ? dataProperty[0] : dataProperty;
|
|
31
|
+
const hasDataProperty = !!dataPropertyName;
|
|
32
|
+
const childGroupSections = children === null || children === void 0 ? void 0 : (_children$props = children.props) === null || _children$props === void 0 ? void 0 : (_children$props$child = _children$props.children) === null || _children$props$child === void 0 ? void 0 : _children$props$child[1];
|
|
27
33
|
const GroupComponent = useMemo(() => contentType === CONTENT_GROUP_TYPES.ACCORDION ? ContentGroupAccordion : ContentGroupTabs, [contentType]);
|
|
28
34
|
const WrapperComponent = useMemo(() => !isFaqContent ? Fragment : 'div', [isFaqContent]);
|
|
29
35
|
const _useMemo = useMemo(() => {
|
|
@@ -38,8 +44,26 @@ const ContentGroup = _ref => {
|
|
|
38
44
|
topWrapperProps
|
|
39
45
|
} = _useMemo,
|
|
40
46
|
schemaProperties = _objectWithoutProperties(_useMemo, _excluded2);
|
|
41
|
-
if (!
|
|
42
|
-
|
|
47
|
+
if (!VALID_TYPES.includes(contentType)) return '';
|
|
48
|
+
if (!hasSimpleData && hasDataProperty) {
|
|
49
|
+
return /*#__PURE__*/React.createElement(WrapperComponent, topWrapperProps, /*#__PURE__*/React.createElement(ContentGroupDataFetcher, _extends({
|
|
50
|
+
dataProperty: dataPropertyName,
|
|
51
|
+
contentType: contentType
|
|
52
|
+
}, props, schemaProperties)));
|
|
53
|
+
}
|
|
54
|
+
let groupSections;
|
|
55
|
+
let sectionsData;
|
|
56
|
+
if (hasSimpleData) {
|
|
57
|
+
({
|
|
58
|
+
groupSections,
|
|
59
|
+
sectionsData
|
|
60
|
+
} = buildDataSections(simpleData));
|
|
61
|
+
} else {
|
|
62
|
+
groupSections = childGroupSections;
|
|
63
|
+
if (!groupSections || !groupSections.length) return '';
|
|
64
|
+
sectionsData = getSectionsData(groupSections);
|
|
65
|
+
}
|
|
66
|
+
if (!groupSections || !groupSections.length) return '';
|
|
43
67
|
return /*#__PURE__*/React.createElement(WrapperComponent, topWrapperProps, /*#__PURE__*/React.createElement(GroupComponent, _extends({
|
|
44
68
|
contentType: contentType,
|
|
45
69
|
groupSections: groupSections,
|
|
@@ -47,17 +71,25 @@ const ContentGroup = _ref => {
|
|
|
47
71
|
}, props, schemaProperties)));
|
|
48
72
|
};
|
|
49
73
|
ContentGroup.propTypes = {
|
|
50
|
-
children: PropTypes.object
|
|
74
|
+
children: PropTypes.object,
|
|
51
75
|
contentType: PropTypes.oneOf(VALID_TYPES).isRequired,
|
|
52
76
|
isFaqContent: PropTypes.bool,
|
|
53
77
|
customHtmlProps: PropTypes.arrayOf(PropTypes.shape({
|
|
54
78
|
name: PropTypes.string,
|
|
55
79
|
value: PropTypes.string
|
|
56
|
-
}))
|
|
80
|
+
})),
|
|
81
|
+
simpleData: PropTypes.arrayOf(PropTypes.shape({
|
|
82
|
+
label: PropTypes.string,
|
|
83
|
+
text: PropTypes.string
|
|
84
|
+
})),
|
|
85
|
+
dataProperty: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)])
|
|
57
86
|
};
|
|
58
87
|
ContentGroup.defaultProps = {
|
|
88
|
+
children: null,
|
|
59
89
|
isFaqContent: false,
|
|
60
|
-
customHtmlProps: []
|
|
90
|
+
customHtmlProps: [],
|
|
91
|
+
simpleData: null,
|
|
92
|
+
dataProperty: null
|
|
61
93
|
};
|
|
62
94
|
export default ContentGroup;
|
|
63
95
|
//# sourceMappingURL=ContentGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentGroup.js","names":["React","Fragment","useMemo","PropTypes","CONTENT_GROUP_TYPES","ContentGroupTabs","ContentGroupAccordion","getSectionsData","getStructuredDataProperties","getCustomHtmlProperties","VALID_TYPES","Object","values","ContentGroup","_ref","_children$props","_children$props$child","contentType","isFaqContent","children","customHtmlProps","props","_objectWithoutProperties","_excluded","
|
|
1
|
+
{"version":3,"file":"ContentGroup.js","names":["React","Fragment","useMemo","PropTypes","CONTENT_GROUP_TYPES","ContentGroupTabs","ContentGroupAccordion","ContentGroupDataFetcher","getSectionsData","buildDataSections","getStructuredDataProperties","getCustomHtmlProperties","VALID_TYPES","Object","values","ContentGroup","_ref","_children$props","_children$props$child","contentType","isFaqContent","children","customHtmlProps","simpleData","dataProperty","props","_objectWithoutProperties","_excluded","hasSimpleData","Array","isArray","length","dataPropertyName","hasDataProperty","childGroupSections","GroupComponent","ACCORDION","WrapperComponent","_useMemo","structuredDataProperties","_objectSpread","topWrapperProps","schemaProperties","_excluded2","includes","createElement","_extends","groupSections","sectionsData","propTypes","object","oneOf","isRequired","bool","arrayOf","shape","name","string","value","label","text","oneOfType","defaultProps"],"sources":["../../../src/components/ContentGroup/ContentGroup.js"],"sourcesContent":["import React, { Fragment, useMemo } from 'react';\nimport PropTypes from 'prop-types';\nimport { CONTENT_GROUP_TYPES } from './constants';\nimport ContentGroupTabs from './ContentGroupTabs';\nimport ContentGroupAccordion from './ContentGroupAccordion';\nimport ContentGroupDataFetcher from './ContentGroupDataFetcher';\nimport { getSectionsData, buildDataSections } from './helpers';\nimport getStructuredDataProperties from './helpers/get-structured-data-properties';\nimport { getCustomHtmlProperties } from '../../helpers';\n\nconst VALID_TYPES = Object.values(CONTENT_GROUP_TYPES);\n\nconst ContentGroup = ({\n contentType,\n isFaqContent,\n children,\n customHtmlProps,\n simpleData,\n dataProperty,\n ...props\n}) => {\n const hasSimpleData = Array.isArray(simpleData) && simpleData.length > 0;\n const dataPropertyName = Array.isArray(dataProperty) ? dataProperty[0] : dataProperty;\n const hasDataProperty = !!dataPropertyName;\n\n const childGroupSections = children?.props?.children?.[1];\n\n const GroupComponent = useMemo(\n () =>\n contentType === CONTENT_GROUP_TYPES.ACCORDION ? ContentGroupAccordion : ContentGroupTabs,\n [contentType]\n );\n const WrapperComponent = useMemo(() => (!isFaqContent ? Fragment : 'div'), [isFaqContent]);\n\n const { topWrapperProps, ...schemaProperties } = useMemo(() => {\n const structuredDataProperties = getStructuredDataProperties(isFaqContent);\n return {\n ...structuredDataProperties,\n topWrapperProps: {\n ...structuredDataProperties.topWrapperProps,\n ...getCustomHtmlProperties({ customHtmlProps })\n }\n };\n }, [isFaqContent, customHtmlProps]);\n\n if (!VALID_TYPES.includes(contentType)) return '';\n\n if (!hasSimpleData && hasDataProperty) {\n return (\n <WrapperComponent {...topWrapperProps}>\n <ContentGroupDataFetcher\n dataProperty={dataPropertyName}\n contentType={contentType}\n {...props}\n {...schemaProperties}\n />\n </WrapperComponent>\n );\n }\n\n let groupSections;\n let sectionsData;\n\n if (hasSimpleData) {\n ({ groupSections, sectionsData } = buildDataSections(simpleData));\n } else {\n groupSections = childGroupSections;\n if (!groupSections || !groupSections.length) return '';\n sectionsData = getSectionsData(groupSections);\n }\n if (!groupSections || !groupSections.length) return '';\n\n return (\n <WrapperComponent {...topWrapperProps}>\n <GroupComponent\n contentType={contentType}\n groupSections={groupSections}\n sectionsData={sectionsData}\n {...props}\n {...schemaProperties}\n />\n </WrapperComponent>\n );\n};\n\nContentGroup.propTypes = {\n children: PropTypes.object,\n contentType: PropTypes.oneOf(VALID_TYPES).isRequired,\n isFaqContent: PropTypes.bool,\n customHtmlProps: PropTypes.arrayOf(\n PropTypes.shape({\n name: PropTypes.string,\n value: PropTypes.string\n })\n ),\n simpleData: PropTypes.arrayOf(\n PropTypes.shape({\n label: PropTypes.string,\n text: PropTypes.string\n })\n ),\n dataProperty: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)])\n};\n\nContentGroup.defaultProps = {\n children: null,\n isFaqContent: false,\n customHtmlProps: [],\n simpleData: null,\n dataProperty: null\n};\n\nexport default ContentGroup;\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,OAAO,QAAQ,OAAO;AAChD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,mBAAmB,QAAQ,aAAa;AACjD,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,qBAAqB,MAAM,yBAAyB;AAC3D,OAAOC,uBAAuB,MAAM,2BAA2B;AAC/D,SAASC,eAAe,EAAEC,iBAAiB,QAAQ,WAAW;AAC9D,OAAOC,2BAA2B,MAAM,0CAA0C;AAClF,SAASC,uBAAuB,QAA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AC;AAEvB,CAAC;AAED3B,YAAY,CAACkC,SAAS,GAAG;EACvB5B,QAAQ,EAAElB,SAAS,CAAC+C,MAAM;EAC1B/B,WAAW,EAAEhB,SAAS,CAACgD,KAAK,CAACvC,WAAW,CAAC,CAACwC,UAAU;EACpDhC,YAAY,EAAEjB,SAAS,CAACkD,IAAI;EAC5B/B,eAAe,EAAEnB,SAAS,CAACmD,OAAO,CAChCnD,SAAS,CAACoD,KAAK,CAAC;IACdC,IAAI,EAAErD,SAAS,CAACsD,MAAM;IACtBC,KAAK,EAAEvD,SAAS,CAACsD;EACnB,CAAC,CACH,CAAC;EACDlC,UAAU,EAAEpB,SAAS,CAACmD,OAAO,CAC3BnD,SAAS,CAACoD,KAAK,CAAC;IACdI,KAAK,EAAExD,SAAS,CAACsD,MAAM;IACvBG,IAAI,EAAEzD,SAAS,CAACsD;EAClB,CAAC,CACH,CAAC;EACDjC,YAAY,EAAErB,SAAS,CAAC0D,SAAS,CAAC,CAAC1D,SAAS,CAACsD,MAAM,EAAEtD,SAAS,CAACmD,OAAO,CAACnD,SAAS,CAACsD,MAAM,CAAC,CAAC;AAC3F,CAAC;AAED1C,YAAY,CAAC+C,YAAY,GAAG;EAC1BzC,QAAQ,EAAE,IAAI;EACdD,YAAY,EAAE,KAAK;EACnBE,eAAe,EAAE,EAAE;EACnBC,UAAU,EAAE,IAAI;EAChBC,YAAY,EAAE;AAChB,CAAC;AAED,eAAeT,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
const _excluded = ["dataProperty", "parent", "contentType"];
|
|
4
|
+
import React, { useContext, useMemo } from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { useQuery, gql } from '@apollo/client';
|
|
7
|
+
import { MainContext } from '@blaze-cms/nextjs-components';
|
|
8
|
+
import { getSingleEntitySchema, generateSingleItemQuery } from '../../application/query';
|
|
9
|
+
import ContentGroupTabs from './ContentGroupTabs';
|
|
10
|
+
import ContentGroupAccordion from './ContentGroupAccordion';
|
|
11
|
+
import { buildDataSections } from './helpers';
|
|
12
|
+
import { CONTENT_GROUP_TYPES } from './constants';
|
|
13
|
+
const PLACEHOLDER_QUERY = gql`
|
|
14
|
+
query {
|
|
15
|
+
__typename
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
const ContentGroupDataFetcher = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
dataProperty,
|
|
21
|
+
parent,
|
|
22
|
+
contentType
|
|
23
|
+
} = _ref,
|
|
24
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
const {
|
|
26
|
+
isPreview
|
|
27
|
+
} = useContext(MainContext);
|
|
28
|
+
const dataPropertyName = Array.isArray(dataProperty) ? dataProperty[0] : dataProperty;
|
|
29
|
+
const {
|
|
30
|
+
data: schemaData,
|
|
31
|
+
loading: schemaLoading
|
|
32
|
+
} = useQuery(getSingleEntitySchema, {
|
|
33
|
+
variables: {
|
|
34
|
+
id: parent === null || parent === void 0 ? void 0 : parent.itemEntity
|
|
35
|
+
},
|
|
36
|
+
skip: !(parent === null || parent === void 0 ? void 0 : parent.itemEntity) || !dataPropertyName
|
|
37
|
+
});
|
|
38
|
+
const dataQuery = useMemo(() => {
|
|
39
|
+
if (!schemaData) return null;
|
|
40
|
+
const {
|
|
41
|
+
getEntitySchema
|
|
42
|
+
} = schemaData;
|
|
43
|
+
const {
|
|
44
|
+
actions: {
|
|
45
|
+
getPublished,
|
|
46
|
+
get
|
|
47
|
+
} = {}
|
|
48
|
+
} = getEntitySchema;
|
|
49
|
+
const actionKey = isPreview ? get : getPublished || get;
|
|
50
|
+
if (!actionKey) return null;
|
|
51
|
+
return generateSingleItemQuery(actionKey, `${dataPropertyName} { label text }`);
|
|
52
|
+
}, [schemaData, isPreview, dataPropertyName]);
|
|
53
|
+
const {
|
|
54
|
+
data: recordData,
|
|
55
|
+
loading: recordLoading
|
|
56
|
+
} = useQuery(dataQuery || PLACEHOLDER_QUERY, {
|
|
57
|
+
variables: {
|
|
58
|
+
id: parent === null || parent === void 0 ? void 0 : parent.itemId
|
|
59
|
+
},
|
|
60
|
+
skip: !dataQuery || !(parent === null || parent === void 0 ? void 0 : parent.itemId)
|
|
61
|
+
});
|
|
62
|
+
if (schemaLoading || recordLoading) return '';
|
|
63
|
+
if (!(recordData === null || recordData === void 0 ? void 0 : recordData.entityData)) return null;
|
|
64
|
+
const propertyData = recordData.entityData[dataPropertyName];
|
|
65
|
+
if (!propertyData || !propertyData.length) return null;
|
|
66
|
+
const {
|
|
67
|
+
groupSections,
|
|
68
|
+
sectionsData
|
|
69
|
+
} = buildDataSections(propertyData);
|
|
70
|
+
if (!groupSections.length) return null;
|
|
71
|
+
const GroupComponent = contentType === CONTENT_GROUP_TYPES.ACCORDION ? ContentGroupAccordion : ContentGroupTabs;
|
|
72
|
+
return /*#__PURE__*/React.createElement(GroupComponent, _extends({
|
|
73
|
+
contentType: contentType,
|
|
74
|
+
groupSections: groupSections,
|
|
75
|
+
sectionsData: sectionsData
|
|
76
|
+
}, props));
|
|
77
|
+
};
|
|
78
|
+
ContentGroupDataFetcher.propTypes = {
|
|
79
|
+
dataProperty: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
|
80
|
+
parent: PropTypes.object,
|
|
81
|
+
contentType: PropTypes.string.isRequired
|
|
82
|
+
};
|
|
83
|
+
ContentGroupDataFetcher.defaultProps = {
|
|
84
|
+
dataProperty: null,
|
|
85
|
+
parent: null
|
|
86
|
+
};
|
|
87
|
+
export default ContentGroupDataFetcher;
|
|
88
|
+
//# sourceMappingURL=ContentGroupDataFetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentGroupDataFetcher.js","names":["React","useContext","useMemo","PropTypes","useQuery","gql","MainContext","getSingleEntitySchema","generateSingleItemQuery","ContentGroupTabs","ContentGroupAccordion","buildDataSections","CONTENT_GROUP_TYPES","PLACEHOLDER_QUERY","ContentGroupDataFetcher","_ref","dataProperty","parent","contentType","props","_objectWithoutProperties","_excluded","isPreview","dataPropertyName","Array","isArray","data","schemaData","loading","schemaLoading","variables","id","itemEntity","skip","dataQuery","getEntitySchema","actions","getPublished","get","actionKey","recordData","recordLoading","itemId","entityData","propertyData","length","groupSections","sectionsData","GroupComponent","ACCORDION","createElement","_extends","propTypes","oneOfType","string","arrayOf","object","isRequired","defaultProps"],"sources":["../../../src/components/ContentGroup/ContentGroupDataFetcher.js"],"sourcesContent":["import React, { useContext, useMemo } from 'react';\nimport PropTypes from 'prop-types';\nimport { useQuery, gql } from '@apollo/client';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport { getSingleEntitySchema, generateSingleItemQuery } from '../../application/query';\nimport ContentGroupTabs from './ContentGroupTabs';\nimport ContentGroupAccordion from './ContentGroupAccordion';\nimport { buildDataSections } from './helpers';\nimport { CONTENT_GROUP_TYPES } from './constants';\n\nconst PLACEHOLDER_QUERY = gql`\n query {\n __typename\n }\n`;\n\nconst ContentGroupDataFetcher = ({ dataProperty, parent, contentType, ...props }) => {\n const { isPreview } = useContext(MainContext);\n const dataPropertyName = Array.isArray(dataProperty) ? dataProperty[0] : dataProperty;\n\n const { data: schemaData, loading: schemaLoading } = useQuery(getSingleEntitySchema, {\n variables: { id: parent?.itemEntity },\n skip: !parent?.itemEntity || !dataPropertyName\n });\n\n const dataQuery = useMemo(() => {\n if (!schemaData) return null;\n const { getEntitySchema } = schemaData;\n const { actions: { getPublished, get } = {} } = getEntitySchema;\n const actionKey = isPreview ? get : getPublished || get;\n if (!actionKey) return null;\n return generateSingleItemQuery(actionKey, `${dataPropertyName} { label text }`);\n }, [schemaData, isPreview, dataPropertyName]);\n\n const { data: recordData, loading: recordLoading } = useQuery(dataQuery || PLACEHOLDER_QUERY, {\n variables: { id: parent?.itemId },\n skip: !dataQuery || !parent?.itemId\n });\n\n if (schemaLoading || recordLoading) return '';\n if (!recordData?.entityData) return null;\n\n const propertyData = recordData.entityData[dataPropertyName];\n if (!propertyData || !propertyData.length) return null;\n\n const { groupSections, sectionsData } = buildDataSections(propertyData);\n\n if (!groupSections.length) return null;\n\n const GroupComponent =\n contentType === CONTENT_GROUP_TYPES.ACCORDION ? ContentGroupAccordion : ContentGroupTabs;\n\n return (\n <GroupComponent\n contentType={contentType}\n groupSections={groupSections}\n sectionsData={sectionsData}\n {...props}\n />\n );\n};\n\nContentGroupDataFetcher.propTypes = {\n dataProperty: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),\n parent: PropTypes.object,\n contentType: PropTypes.string.isRequired\n};\n\nContentGroupDataFetcher.defaultProps = {\n dataProperty: null,\n parent: null\n};\n\nexport default ContentGroupDataFetcher;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,QAAQ,EAAEC,GAAG,QAAQ,gBAAgB;AAC9C,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,qBAAqB,EAAEC,uBAAuB,QAAQ,yBAAyB;AACxF,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,qBAAqB,MAAM,yBAAyB;AAC3D,SAASC,iBAAiB,QAAQ,WAAW;AAC7C,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,MAAMC,iBAAiB,GAAGR,GAAG;AAC7B;AACA;AACA;AACA,CAAC;AAED,MAAMS,uBAAuB,GAAGC,IAAA,IAAqD;EAAA,IAApD;MAAEC,YAAY;MAAEC,MAAM;MAAEC;IAAsB,CAAC,GAAAH,IAAA;IAAPI,KAAK,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA;EAC5E,MAAM;IAAEC;EAAU,CAAC,GAAGrB,UAAU,CAACK,WAAW,CAAC;EAC7C,MAAMiB,gBAAgB,G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AAa,IAAIY,aAAa,EAAE,OAAO,EAAE;EAC7C,IAAI,EAACD,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEG,UAAU,GAAE,OAAO,IAAI;EAExC,MAAMC,YAAY,GAAGJ,UAAU,CAACG,UAAU,CAACpB,gBAAgB,CAAC;EAC5D,IAAI,CAACqB,YAAY,IAAI,CAACA,YAAY,CAACC,MAAM,EAAE,OAAO,IAAI;EAEtD,MAAM;IAAEC,aAAa;IAAEC;EAAa,CAAC,GAAGpC,iBAAiB,CAACiC,YAAY,CAAC;EAEvE,IAAI,CAACE,aAAa,CAACD,MAAM,EAAE,OAAO,IAAI;EAEtC,MAAMG,cAAc,GAClB9B,WAAW,KAAKN,mBAAmB,CAACqC,SAAS,GAAGvC,qBAAqB,GAAGD,gBAAgB;EAE1F,oBACET,KAAA,CAAAkD,aAAA,CAACF,cAAc,EAAAG,QAAA;IACbjC,WAAW,EAAEA,WAAY;IACzB4B,aAAa,EAAEA,aAAc;IAC7BC,YAAY,EAAEA;EAAa,GACvB5B,KAAK,CACV,CAAC;AAEN,CAAC;AAEDL,uBAAuB,CAACsC,SAAS,GAAG;EAClCpC,YAAY,EAAEb,SAAS,CAACkD,SAAS,CAAC,CAAClD,SAAS,CAACmD,MAAM,EAAEnD,SAAS,CAACoD,OAAO,CAACpD,SAAS,CAACmD,MAAM,CAAC,CAAC,CAAC;EAC1FrC,MAAM,EAAEd,SAAS,CAACqD,MAAM;EACxBtC,WAAW,EAAEf,SAAS,CAACmD,MAAM,CAACG;AAChC,CAAC;AAED3C,uBAAuB,CAAC4C,YAAY,GAAG;EACrC1C,YAAY,EAAE,IAAI;EAClBC,MAAM,EAAE;AACV,CAAC;AAED,eAAeH,uBAAuB","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import dynamic from 'next/dynamic';
|
|
3
|
+
import getComponentId from '../../../helpers/get-component-id';
|
|
4
|
+
const TextBlock = dynamic(() => import('../../TextBlock'));
|
|
5
|
+
const ContentGroupSection = dynamic(() => import('../../ContentGroupSection'));
|
|
6
|
+
const buildDataSections = (items = []) => {
|
|
7
|
+
const itemData = items.map((item, i) => {
|
|
8
|
+
if (!item || !item.text || !item.label) return null;
|
|
9
|
+
const sectionName = getComponentId(item.label || `section-${i}`, true, true);
|
|
10
|
+
return {
|
|
11
|
+
sectionName,
|
|
12
|
+
label: item.label,
|
|
13
|
+
sectionContent: /*#__PURE__*/React.createElement(ContentGroupSection, {
|
|
14
|
+
key: sectionName,
|
|
15
|
+
name: sectionName,
|
|
16
|
+
disableChildCheck: true
|
|
17
|
+
}, /*#__PURE__*/React.createElement(TextBlock, {
|
|
18
|
+
html: item.text,
|
|
19
|
+
name: `${sectionName}-text`
|
|
20
|
+
}))
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
return itemData.filter(Boolean).reduce((acc, {
|
|
24
|
+
sectionName,
|
|
25
|
+
label,
|
|
26
|
+
sectionContent
|
|
27
|
+
}) => {
|
|
28
|
+
if (!sectionName || !sectionContent) return acc;
|
|
29
|
+
acc.groupSections.push(sectionContent);
|
|
30
|
+
acc.sectionsData.push([sectionName, label]);
|
|
31
|
+
return acc;
|
|
32
|
+
}, {
|
|
33
|
+
groupSections: [],
|
|
34
|
+
sectionsData: []
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
export default buildDataSections;
|
|
38
|
+
//# sourceMappingURL=build-data-sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-data-sections.js","names":["React","dynamic","getComponentId","TextBlock","ContentGroupSection","buildDataSections","items","itemData","map","item","i","text","label","sectionName","sectionContent","createElement","key","name","disableChildCheck","html","filter","Boolean","reduce","acc","groupSections","push","sectionsData"],"sources":["../../../../src/components/ContentGroup/helpers/build-data-sections.js"],"sourcesContent":["import React from 'react';\nimport dynamic from 'next/dynamic';\nimport getComponentId from '../../../helpers/get-component-id';\n\nconst TextBlock = dynamic(() => import('../../TextBlock'));\nconst ContentGroupSection = dynamic(() => import('../../ContentGroupSection'));\n\nconst buildDataSections = (items = []) => {\n const itemData = items.map((item, i) => {\n if (!item || !item.text || !item.label) return null;\n\n const sectionName = getComponentId(item.label || `section-${i}`, true, true);\n return {\n sectionName,\n label: item.label,\n sectionContent: (\n <ContentGroupSection key={sectionName} name={sectionName} disableChildCheck>\n <TextBlock html={item.text} name={`${sectionName}-text`} />\n </ContentGroupSection>\n )\n };\n });\n\n return itemData.filter(Boolean).reduce(\n (acc, { sectionName, label, sectionContent }) => {\n if (!sectionName || !sectionContent) return acc;\n acc.groupSections.push(sectionContent);\n acc.sectionsData.push([sectionName, label]);\n return acc;\n },\n { groupSections: [], sectionsData: [] }\n );\n};\n\nexport default buildDataSections;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,OAAO,MAAM,cAAc;AAClC,OAAOC,cAAc,MAAM,mCAAmC;AAE9D,MAAMC,SAAS,GAAGF,OAAO,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAC1D,MAAMG,mBAAmB,GAAGH,OAAO,CAAC,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAE9E,MAAMI,iBAAiB,GAAGA,CAACC,KAAK,GAAG,EAAE,KAAK;EACxC,MAAMC,QAAQ,GAAGD,KAAK,CAACE,GAAG,CAAC,CAACC,IAAI,EAAEC,CAAC,KAAK;IACtC,IAAI,CAACD,IAAI,IAAI,CAACA,IAAI,CAACE,IAAI,IAAI,CAACF,IAAI,CAACG,KAAK,EAAE,OAAO,IAAI;IAEnD,MAAMC,WAAW,GAAGX,cAAc,CAACO,IAAI,CAACG,KAAK,IAAI,WAAWF,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC;IAC5E,OAAO;MACLG,WAAW;MACXD,KAAK,EAAEH,IAAI,CAACG,KAAK;MACjBE,cAAc,eACZd,KAAA,CAAAe,aAAA,CAACX,mBAAmB;QAACY,GAAG,EAAEH,WAAY;QAACI,IAAI,EAAEJ,WAAY;QAACK,iBAAiB;MAAA,gBACzElB,KAAA,CAAAe,aAAA,CAACZ,SAAS;QAACgB,IAAI,EAAEV,IAAI,CAACE,IAAK;QAACM,IAAI,EAAE,GAAGJ,WAAW;MAAQ,CAAE,CACvC;IAEzB,CAAC;EACH,CAAC,CAAC;EAEF,OAAON,QAAQ,CAACa,MAAM,CAACC,OAAO,CAAC,CAACC,MAAM,CACpC,CAACC,GAAG,EAAE;IAAEV,WAAW;IAAED,KAAK;IAAEE;EAAe,CAAC,KAAK;IAC/C,IAAI,CAACD,WAAW,IAAI,CAACC,cAAc,EAAE,OAAOS,GAAG;IAC/CA,GAAG,CAACC,aAAa,CAACC,IAAI,CAACX,cAAc,CAAC;IACtCS,GAAG,CAACG,YAAY,CAACD,IAAI,CAAC,CAACZ,WAAW,EAAED,KAAK,CAAC,CAAC;IAC3C,OAAOW,GAAG;EACZ,CAAC,EACD;IAAEC,aAAa,EAAE,EAAE;IAAEE,YAAY,EAAE;EAAG,CACxC,CAAC;AACH,CAAC;AAED,eAAerB,iBAAiB","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import getSectionsData from './get-sections-data';
|
|
2
2
|
import getActiveTab from './get-active-tab';
|
|
3
|
-
|
|
3
|
+
import buildDataSections from './build-data-sections';
|
|
4
|
+
export { getSectionsData, getActiveTab, buildDataSections };
|
|
4
5
|
//# sourceMappingURL=index.js.map
|