@blaze-cms/react-page-builder 0.146.0-node18-core-styles-tooltips.56 → 0.146.0-node18-core-styles-tooltips.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/lib/HOC/withTitle.js +1 -1
- package/lib/HOC/withTitle.js.map +1 -1
- package/lib/components/ContentGroup/ContentGroup.js.map +1 -1
- package/lib/components/ContentGroup/ContentGroupAccordion.js.map +1 -1
- package/lib/hooks/use-app-event-hook.js.map +1 -1
- package/lib-es/HOC/withTitle.js +1 -1
- package/lib-es/HOC/withTitle.js.map +1 -1
- package/lib-es/components/ContentGroup/ContentGroup.js.map +1 -1
- package/lib-es/components/ContentGroup/ContentGroupAccordion.js.map +1 -1
- package/lib-es/hooks/use-app-event-hook.js.map +1 -1
- package/package.json +7 -7
- package/src/HOC/withTitle.js +2 -2
- package/src/components/ContentGroup/ContentGroup.js +10 -13
- package/src/components/ContentGroup/ContentGroupAccordion.js +5 -8
- package/src/hooks/use-app-event-hook.js +14 -20
- package/tests/unit/src/components/Breadcrumb/__snapshots__/Breadcrumb.test.js.snap +1 -13
- package/tests/unit/src/components/Button.test.js +5 -0
- package/tests/unit/src/components/Card/Card.test.js +2 -4
- package/tests/unit/src/components/Card/__snapshots__/Card.test.js.snap +9 -24
- package/tests/unit/src/components/Card/__snapshots__/CardContainer.test.js.snap +1 -13
- package/tests/unit/src/components/Carousel/Carousel.test.js +4 -1
- package/tests/unit/src/components/Carousel/CarouselImage/CarouselImage.test.js +7 -3
- package/tests/unit/src/components/Carousel/CarouselRender/CarouselRender.test.js +20 -10
- package/tests/unit/src/components/Carousel/CarouselRender/__snapshots__/CarouselRender.test.js.snap +5 -3
- package/tests/unit/src/components/Carousel/__snapshots__/Carousel.test.js.snap +17 -3
- package/tests/unit/src/components/Code/Code.test.js +7 -3
- package/tests/unit/src/components/EmailConfirm/__snapshots__/EmailConfirm.test.js.snap +8 -6
- package/tests/unit/src/components/MenuItem/MenuItemRender.test.js +2 -2
- package/tests/unit/src/components/MenuItem/__snapshots__/MenuItem.test.js.snap +2 -2
- package/tests/unit/src/components/TextBlock/__snapshots__/TextBlock.test.js.snap +1 -13
- package/tests/unit/src/helpers/__snapshots__/parse-textBlock.test.js.snap +0 -3
- package/tests/unit/src/helpers/get-current-offset.test.js +2 -2
- package/tests/unit/src/helpers/get-custom-html-properties.test.js +4 -1
- package/tests/unit/src/helpers/parse-textBlock.test.js +1 -3
- package/tests/unit/src/hooks/use-check-mobile-screen.test.js +18 -12
- package/tests/unit/src/variants/Infographic/Infographic.test.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.146.0-node18-core-styles-tooltips.58](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.57...v0.146.0-node18-core-styles-tooltips.58) (2026-04-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* fix lint and tests errors across repository ([#5047](https://github.com/thebyte9/blaze/issues/5047)) ([c2b86dd](https://github.com/thebyte9/blaze/commit/c2b86dd7aebb12198a49097692a549a9f9378d6e))
|
|
12
|
+
* revert react-cookie for 7.x until context requirement is updated ([#5135](https://github.com/thebyte9/blaze/issues/5135)) ([4a7f4a1](https://github.com/thebyte9/blaze/commit/4a7f4a16d91d7c0d761febfbf4d558145e7e733b))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
# [0.146.0-node18-core-styles-tooltips.56](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.55...v0.146.0-node18-core-styles-tooltips.56) (2026-03-27)
|
|
7
19
|
|
|
8
20
|
|
package/lib/HOC/withTitle.js
CHANGED
|
@@ -31,7 +31,7 @@ var withTitle = function withTitle(Component) {
|
|
|
31
31
|
_useStringTemplate$da = (0, _slicedToArray2["default"])(_useStringTemplate.data, 1),
|
|
32
32
|
elementTitleToUse = _useStringTemplate$da[0];
|
|
33
33
|
if (loading) return '';
|
|
34
|
-
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, shouldDisplayTitle && /*#__PURE__*/_react["default"].createElement("h2", {
|
|
34
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, shouldDisplayTitle && /*#__PURE__*/_react["default"].createElement("h2", {
|
|
35
35
|
className: "heading heading--section"
|
|
36
36
|
}, elementTitleToUse), /*#__PURE__*/_react["default"].createElement(Component, props));
|
|
37
37
|
};
|
package/lib/HOC/withTitle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTitle.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_utilsHandlebars","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","withTitle","Component","InnerComponent","props","elementTitle","isHeroImg","parent","shouldDisplayTitle","_useStringTemplate","useStringTemplate","loading","_useStringTemplate$da","_slicedToArray2","data","elementTitleToUse","createElement","Fragment","className","WrappedComponent","displayName","concat","name","propTypes","PropTypes","object","string","bool","defaultProps","_default","exports"],"sources":["../../src/HOC/withTitle.js"],"sourcesContent":["import React, { Fragment } from 'react';\nimport PropTypes from 'prop-types';\nimport { useStringTemplate } from '@blaze-cms/utils-handlebars';\n\nconst withTitle = Component => {\n const InnerComponent = props => {\n const { elementTitle, isHeroImg, parent } = props;\n\n const shouldDisplayTitle = elementTitle && !isHeroImg;\n const {\n loading,\n data: [elementTitleToUse]\n } = useStringTemplate(parent, [elementTitle]);\n\n if (loading) return '';\n\n return (\n
|
|
1
|
+
{"version":3,"file":"withTitle.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_utilsHandlebars","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","withTitle","Component","InnerComponent","props","elementTitle","isHeroImg","parent","shouldDisplayTitle","_useStringTemplate","useStringTemplate","loading","_useStringTemplate$da","_slicedToArray2","data","elementTitleToUse","createElement","Fragment","className","WrappedComponent","displayName","concat","name","propTypes","PropTypes","object","string","bool","defaultProps","_default","exports"],"sources":["../../src/HOC/withTitle.js"],"sourcesContent":["import React, { Fragment } from 'react';\nimport PropTypes from 'prop-types';\nimport { useStringTemplate } from '@blaze-cms/utils-handlebars';\n\nconst withTitle = Component => {\n const InnerComponent = props => {\n const { elementTitle, isHeroImg, parent } = props;\n\n const shouldDisplayTitle = elementTitle && !isHeroImg;\n const {\n loading,\n data: [elementTitleToUse]\n } = useStringTemplate(parent, [elementTitle]);\n\n if (loading) return '';\n\n return (\n <>\n {shouldDisplayTitle && <h2 className=\"heading heading--section\">{elementTitleToUse}</h2>}\n <Component {...props} />\n </>\n );\n };\n\n InnerComponent.WrappedComponent = Component;\n\n InnerComponent.displayName = `WithTitle(${\n Component.displayName || Component.name || 'Component'\n })`;\n\n InnerComponent.propTypes = {\n parent: PropTypes.object,\n elementTitle: PropTypes.string,\n isHeroImg: PropTypes.bool\n };\n InnerComponent.defaultProps = {\n parent: {},\n elementTitle: '',\n isHeroImg: false\n };\n\n return InnerComponent;\n};\n\nexport default withTitle;\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAAgE,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,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AAG,kBAAA,GAGI,IAAAC,kCAAiB,EAACH,MAAM,EAAE,CAACF,YAAY,CAAC,CAAC;MAF3CM,OAAO,GAAAF,kBAAA,CAAPE,OAAO;MAAAC,qBAAA,OAAAC,eAAA,aAAAJ,kBAAA,CACPK,IAAI;MAAGC,iBAAiB,GAAAH,qBAAA;IAG1B,IAAID,OAAO,EAAE,OAAO,EAAE;IAEtB,oBACEpC,MAAA,YAAAyC,aAAA,CAAAzC,MAAA,YAAA0C,QAAA,QACGT,kBAAkB,iBAAIjC,MAAA,YAAAyC,aAAA;MAAIE,SAAS,EAAC;IAA0B,GAAEH,iBAAsB,CAAC,eACxFxC,MAAA,YAAAyC,aAAA,CAACd,SAAS,EAAKE,KAAQ,CACvB,CAAC;EAEP,CAAC;EAEDD,cAAc,CAACgB,gBAAgB,GAAGjB,SAAS;EAE3CC,cAAc,CAACiB,WAAW,gBAAAC,MAAA,CACxBnB,SAAS,CAACkB,WAAW,IAAIlB,SAAS,CAACoB,IAAI,IAAI,WAAW,MACrD;EAEHnB,cAAc,CAACoB,SAAS,GAAG;IACzBhB,MAAM,EAAEiB,qBAAS,CAACC,MAAM;IACxBpB,YAAY,EAAEmB,qBAAS,CAACE,MAAM;IAC9BpB,SAAS,EAAEkB,qBAAS,CAACG;EACvB,CAAC;EACDxB,cAAc,CAACyB,YAAY,GAAG;IAC5BrB,MAAM,EAAE,CAAC,CAAC;IACVF,YAAY,EAAE,EAAE;IAChBC,SAAS,EAAE;EACb,CAAC;EAED,OAAOH,cAAc;AACvB,CAAC;AAAC,IAAA0B,QAAA,GAAAC,OAAA,cAEa7B,SAAS","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentGroup.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_constants","_ContentGroupTabs","_ContentGroupAccordion","_helpers","_getStructuredDataProperties","_helpers2","_excluded","_excluded2","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ownKeys","keys","getOwnPropertySymbols","o","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","VALID_TYPES","values","CONTENT_GROUP_TYPES","ContentGroup","_ref","_children$props","_children$props$child","contentType","isFaqContent","children","customHtmlProps","props","_objectWithoutProperties2","groupSections","GroupComponent","useMemo","ACCORDION","ContentGroupAccordion","ContentGroupTabs","WrapperComponent","Fragment","_useMemo","structuredDataProperties","getStructuredDataProperties","topWrapperProps","getCustomHtmlProperties","schemaProperties","includes","sectionsData","getSectionsData","createElement","_extends2","propTypes","PropTypes","object","isRequired","oneOf","bool","arrayOf","shape","name","string","value","defaultProps","_default","exports"],"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 { getSectionsData } 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 = ({ contentType, isFaqContent, children, customHtmlProps, ...props }) => {\n const groupSections = 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(
|
|
1
|
+
{"version":3,"file":"ContentGroup.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_constants","_ContentGroupTabs","_ContentGroupAccordion","_helpers","_getStructuredDataProperties","_helpers2","_excluded","_excluded2","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ownKeys","keys","getOwnPropertySymbols","o","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","VALID_TYPES","values","CONTENT_GROUP_TYPES","ContentGroup","_ref","_children$props","_children$props$child","contentType","isFaqContent","children","customHtmlProps","props","_objectWithoutProperties2","groupSections","GroupComponent","useMemo","ACCORDION","ContentGroupAccordion","ContentGroupTabs","WrapperComponent","Fragment","_useMemo","structuredDataProperties","getStructuredDataProperties","topWrapperProps","getCustomHtmlProperties","schemaProperties","includes","sectionsData","getSectionsData","createElement","_extends2","propTypes","PropTypes","object","isRequired","oneOf","bool","arrayOf","shape","name","string","value","defaultProps","_default","exports"],"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 { getSectionsData } 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 = ({ contentType, isFaqContent, children, customHtmlProps, ...props }) => {\n const groupSections = 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 (!groupSections || !groupSections.length || !VALID_TYPES.includes(contentType)) return '';\n\n const sectionsData = getSectionsData(groupSections);\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.isRequired,\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};\n\nContentGroup.defaultProps = {\n isFaqContent: false,\n customHtmlProps: []\n};\n\nexport default ContentGroup;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,sBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,4BAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAAwD,IAAAS,SAAA;EAAAC,UAAA;AAAA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAb,wBAAAa,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,gBAAAK,OAAA,CAAAL,CAAA,0BAA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CAAC,CAACmC,UAAU;EACpD3B,YAAY,EAAEyB,qBAAS,CAACI,IAAI;EAC5B3B,eAAe,EAAEuB,qBAAS,CAACK,OAAO,CAChCL,qBAAS,CAACM,KAAK,CAAC;IACdC,IAAI,EAAEP,qBAAS,CAACQ,MAAM;IACtBC,KAAK,EAAET,qBAAS,CAACQ;EACnB,CAAC,CACH;AACF,CAAC;AAEDtC,YAAY,CAACwC,YAAY,GAAG;EAC1BnC,YAAY,EAAE,KAAK;EACnBE,eAAe,EAAE;AACnB,CAAC;AAAC,IAAAkC,QAAA,GAAAC,OAAA,cAEa1C,YAAY","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentGroupAccordion.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_classnames3","_router","_vsc","_constants","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ContentGroupAccordion","_ref","name","groupSections","sectionsData","VariantComponent","openState","groupSectionProps","groupSectionTitleProps","groupContentWrapperProps","groupContentProps","router","useRouter","asPath","sectionPairs","useMemo","map","_ref2","_ref3","_slicedToArray2","sectionName","sectionLabel","panelId","concat","sectionNames","p","baseInitialOpen","OPEN_STATES","ALL_OPEN","Set","ALL_CLOSED","length","_useState","useState","_useState2","openSet","setOpenSet","useEffect","rawHash","split","trim","includes","prev","next","add","WrapperComponent","baseClass","CONTENT_GROUP","itemsClass","itemClass","headerBtnClass","panelClass","headingClass","titleClass","chevronClass","chevronIconClass","onToggle","willOpen","baseUrl","newUrl","replace","shallow","scroll","createElement","className","groupSection","index","_sectionPairs$index","isOpen","_extends2","key","classnames","_defineProperty2","id","type","onClick","VscChevronUp","VscChevronDown","role","hidden","propTypes","PropTypes","string","isRequired","array","oneOfType","func","elementType","oneOf","values","object","defaultProps","_default","exports"],"sources":["../../../src/components/ContentGroup/ContentGroupAccordion.js"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport { useRouter } from 'next/router';\nimport { VscChevronUp, VscChevronDown } from 'react-icons/vsc';\nimport { CONTENT_GROUP, OPEN_STATES } from './constants';\n\nconst ContentGroupAccordion = ({\n name,\n groupSections,\n sectionsData,\n VariantComponent,\n openState,\n groupSectionProps,\n groupSectionTitleProps,\n groupContentWrapperProps,\n groupContentProps\n}) => {\n const router = useRouter();\n const { asPath } = router;\n\n const sectionPairs = useMemo(\n () =>\n sectionsData.map(([sectionName, sectionLabel]) => ({\n sectionName,\n sectionLabel,\n panelId: `${sectionName}-panel`\n })),\n [sectionsData]\n );\n\n const sectionNames = useMemo(() => sectionPairs.map(p => p.sectionName), [sectionPairs]);\n\n const baseInitialOpen = useMemo(\n () => {\n if (openState === OPEN_STATES.ALL_OPEN) return new Set(sectionNames);\n if (openState === OPEN_STATES.ALL_CLOSED && sectionNames.length) return new Set();\n\n return new Set([sectionNames[0]]);\n },\n [openState, sectionNames]\n );\n\n const [openSet, setOpenSet] = useState(baseInitialOpen);\n\n useEffect(\n () => {\n const rawHash = (asPath.split('#')[1] || '').trim();\n if (rawHash && sectionNames.includes(rawHash) && !openSet.has(rawHash)) {\n setOpenSet(prev => {\n const next = new Set(prev);\n next.add(rawHash);\n return next;\n });\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [asPath, sectionNames]\n );\n\n const WrapperComponent = VariantComponent || 'div';\n\n const baseClass = `${CONTENT_GROUP}-accordion`;\n const itemsClass = `${baseClass}__items`;\n const itemClass = `${baseClass}__item`;\n const headerBtnClass = `${baseClass}__header-btn`;\n const panelClass = `${baseClass}__panel`;\n const headingClass = `${baseClass}__heading`;\n const titleClass = `${baseClass}__title`;\n const chevronClass = `${baseClass}__chevron`;\n const chevronIconClass = `${baseClass}__chevron-icon`;\n\n const onToggle = sectionName => {\n setOpenSet(prev => {\n const next = new Set(prev);\n const willOpen = !next.has(sectionName);\n\n if (willOpen) next.add(sectionName);\n else next.delete(sectionName);\n\n const baseUrl = asPath.split('#')[0];\n const newUrl = willOpen ? `${baseUrl}#${sectionName}` : baseUrl;\n\n router.replace(`/Resolver`, newUrl, { shallow: true, scroll: false });\n\n return next;\n });\n };\n\n return (\n <div className={baseClass}>\n <div className={itemsClass} aria-label={name}>\n {groupSections.map((groupSection, index) => {\n const { sectionName, sectionLabel, panelId } = sectionPairs[index];\n const isOpen = openSet.has(sectionName);\n\n return (\n <div\n key={sectionName}\n className={classnames(itemClass, { [`${itemClass}--open`]: isOpen })}\n {...groupSectionProps}>\n <h3 className={headingClass}>\n <button\n id={sectionName}\n type=\"button\"\n className={classnames(headerBtnClass, { [`${headerBtnClass}--open`]: isOpen })}\n aria-expanded={isOpen}\n aria-controls={panelId}\n onClick={() => onToggle(sectionName)}>\n <span className={titleClass} {...groupSectionTitleProps}>\n {sectionLabel}\n </span>\n\n <span aria-hidden=\"true\" className={chevronClass}>\n {isOpen ? (\n <VscChevronUp className={chevronIconClass} />\n ) : (\n <VscChevronDown className={chevronIconClass} />\n )}\n </span>\n </button>\n </h3>\n\n <WrapperComponent\n id={panelId}\n role=\"region\"\n aria-labelledby={sectionName}\n className={panelClass}\n hidden={!isOpen}\n data-section={sectionName}\n {...groupContentWrapperProps}>\n <div {...groupContentProps}>{groupSection}</div>\n </WrapperComponent>\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n\nContentGroupAccordion.propTypes = {\n name: PropTypes.string.isRequired,\n groupSections: PropTypes.array.isRequired,\n sectionsData: PropTypes.array.isRequired,\n VariantComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.elementType]),\n openState: PropTypes.oneOf(Object.values(OPEN_STATES)),\n groupSectionProps: PropTypes.object,\n groupSectionTitleProps: PropTypes.object,\n groupContentWrapperProps: PropTypes.object,\n groupContentProps: PropTypes.object\n};\n\nContentGroupAccordion.defaultProps = {\n VariantComponent: null,\n openState: OPEN_STATES.ALL_CLOSED,\n groupSectionPro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AAsB,EAAE,CAAC,CAAC;EAC1BC,wBAAwB,EAAE,CAAC,CAAC;EAC5BC,iBAAiB,EAAE,CAAC;AACtB,CAAC;AAAC,IAAAkF,QAAA,GAAAC,OAAA,cAEa7F,qBAAqB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ContentGroupAccordion.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_classnames3","_router","_vsc","_constants","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ContentGroupAccordion","_ref","name","groupSections","sectionsData","VariantComponent","openState","groupSectionProps","groupSectionTitleProps","groupContentWrapperProps","groupContentProps","router","useRouter","asPath","sectionPairs","useMemo","map","_ref2","_ref3","_slicedToArray2","sectionName","sectionLabel","panelId","concat","sectionNames","p","baseInitialOpen","OPEN_STATES","ALL_OPEN","Set","ALL_CLOSED","length","_useState","useState","_useState2","openSet","setOpenSet","useEffect","rawHash","split","trim","includes","prev","next","add","WrapperComponent","baseClass","CONTENT_GROUP","itemsClass","itemClass","headerBtnClass","panelClass","headingClass","titleClass","chevronClass","chevronIconClass","onToggle","willOpen","baseUrl","newUrl","replace","shallow","scroll","createElement","className","groupSection","index","_sectionPairs$index","isOpen","_extends2","key","classnames","_defineProperty2","id","type","onClick","VscChevronUp","VscChevronDown","role","hidden","propTypes","PropTypes","string","isRequired","array","oneOfType","func","elementType","oneOf","values","object","defaultProps","_default","exports"],"sources":["../../../src/components/ContentGroup/ContentGroupAccordion.js"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport { useRouter } from 'next/router';\nimport { VscChevronUp, VscChevronDown } from 'react-icons/vsc';\nimport { CONTENT_GROUP, OPEN_STATES } from './constants';\n\nconst ContentGroupAccordion = ({\n name,\n groupSections,\n sectionsData,\n VariantComponent,\n openState,\n groupSectionProps,\n groupSectionTitleProps,\n groupContentWrapperProps,\n groupContentProps\n}) => {\n const router = useRouter();\n const { asPath } = router;\n\n const sectionPairs = useMemo(\n () =>\n sectionsData.map(([sectionName, sectionLabel]) => ({\n sectionName,\n sectionLabel,\n panelId: `${sectionName}-panel`\n })),\n [sectionsData]\n );\n\n const sectionNames = useMemo(() => sectionPairs.map(p => p.sectionName), [sectionPairs]);\n\n const baseInitialOpen = useMemo(() => {\n if (openState === OPEN_STATES.ALL_OPEN) return new Set(sectionNames);\n if (openState === OPEN_STATES.ALL_CLOSED && sectionNames.length) return new Set();\n\n return new Set([sectionNames[0]]);\n }, [openState, sectionNames]);\n\n const [openSet, setOpenSet] = useState(baseInitialOpen);\n\n useEffect(\n () => {\n const rawHash = (asPath.split('#')[1] || '').trim();\n if (rawHash && sectionNames.includes(rawHash) && !openSet.has(rawHash)) {\n setOpenSet(prev => {\n const next = new Set(prev);\n next.add(rawHash);\n return next;\n });\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [asPath, sectionNames]\n );\n\n const WrapperComponent = VariantComponent || 'div';\n\n const baseClass = `${CONTENT_GROUP}-accordion`;\n const itemsClass = `${baseClass}__items`;\n const itemClass = `${baseClass}__item`;\n const headerBtnClass = `${baseClass}__header-btn`;\n const panelClass = `${baseClass}__panel`;\n const headingClass = `${baseClass}__heading`;\n const titleClass = `${baseClass}__title`;\n const chevronClass = `${baseClass}__chevron`;\n const chevronIconClass = `${baseClass}__chevron-icon`;\n\n const onToggle = sectionName => {\n setOpenSet(prev => {\n const next = new Set(prev);\n const willOpen = !next.has(sectionName);\n\n if (willOpen) next.add(sectionName);\n else next.delete(sectionName);\n\n const baseUrl = asPath.split('#')[0];\n const newUrl = willOpen ? `${baseUrl}#${sectionName}` : baseUrl;\n\n router.replace(`/Resolver`, newUrl, { shallow: true, scroll: false });\n\n return next;\n });\n };\n\n return (\n <div className={baseClass}>\n <div className={itemsClass} aria-label={name}>\n {groupSections.map((groupSection, index) => {\n const { sectionName, sectionLabel, panelId } = sectionPairs[index];\n const isOpen = openSet.has(sectionName);\n\n return (\n <div\n key={sectionName}\n className={classnames(itemClass, { [`${itemClass}--open`]: isOpen })}\n {...groupSectionProps}>\n <h3 className={headingClass}>\n <button\n id={sectionName}\n type=\"button\"\n className={classnames(headerBtnClass, { [`${headerBtnClass}--open`]: isOpen })}\n aria-expanded={isOpen}\n aria-controls={panelId}\n onClick={() => onToggle(sectionName)}>\n <span className={titleClass} {...groupSectionTitleProps}>\n {sectionLabel}\n </span>\n\n <span aria-hidden=\"true\" className={chevronClass}>\n {isOpen ? (\n <VscChevronUp className={chevronIconClass} />\n ) : (\n <VscChevronDown className={chevronIconClass} />\n )}\n </span>\n </button>\n </h3>\n\n <WrapperComponent\n id={panelId}\n role=\"region\"\n aria-labelledby={sectionName}\n className={panelClass}\n hidden={!isOpen}\n data-section={sectionName}\n {...groupContentWrapperProps}>\n <div {...groupContentProps}>{groupSection}</div>\n </WrapperComponent>\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n\nContentGroupAccordion.propTypes = {\n name: PropTypes.string.isRequired,\n groupSections: PropTypes.array.isRequired,\n sectionsData: PropTypes.array.isRequired,\n VariantComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.elementType]),\n openState: PropTypes.oneOf(Object.values(OPEN_STATES)),\n groupSectionProps: PropTypes.object,\n groupSectionTitleProps: PropTypes.object,\n groupContentWrapperProps: PropTypes.object,\n groupContentProps: PropTypes.object\n};\n\nContentGroupAccordion.defaultProps = {\n VariantComponent: null,\n openState: OPEN_STATES.ALL_CLOSED,\n groupSectionProps: {},\n groupSectionTitleProps: {},\n groupContentWrapperProps: {},\n groupContentProps: {}\n};\n\nexport default ContentGroupAccordion;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,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AiB1D,WAAY;MAC7B4C,SAAS,EAAEb,UAAW;MACtB4B,MAAM,EAAE,CAACX,MAAO;MAChB,gBAAchD;IAAY,GACtBX,wBAAwB,gBAC5BtC,MAAA,YAAA4F,aAAA,QAASrD,iBAAiB,EAAGuD,YAAkB,CAC/B,CACf,CAAC;EAEV,CAAC,CACE,CACF,CAAC;AAEV,CAAC;AAEDjE,qBAAqB,CAACgF,SAAS,GAAG;EAChC9E,IAAI,EAAE+E,qBAAS,CAACC,MAAM,CAACC,UAAU;EACjChF,aAAa,EAAE8E,qBAAS,CAACG,KAAK,CAACD,UAAU;EACzC/E,YAAY,EAAE6E,qBAAS,CAACG,KAAK,CAACD,UAAU;EACxC9E,gBAAgB,EAAE4E,qBAAS,CAACI,SAAS,CAAC,CAACJ,qBAAS,CAACK,IAAI,EAAEL,qBAAS,CAACM,WAAW,CAAC,CAAC;EAC9EjF,SAAS,EAAE2E,qBAAS,CAACO,KAAK,CAAChG,MAAM,CAACiG,MAAM,CAAC9D,sBAAW,CAAC,CAAC;EACtDpB,iBAAiB,EAAE0E,qBAAS,CAACS,MAAM;EACnClF,sBAAsB,EAAEyE,qBAAS,CAACS,MAAM;EACxCjF,wBAAwB,EAAEwE,qBAAS,CAACS,MAAM;EAC1ChF,iBAAiB,EAAEuE,qBAAS,CAACS;AAC/B,CAAC;AAED1F,qBAAqB,CAAC2F,YAAY,GAAG;EACnCtF,gBAAgB,EAAE,IAAI;EACtBC,SAAS,EAAEqB,sBAAW,CAACG,UAAU;EACjCvB,iBAAiB,EAAE,CAAC,CAAC;EACrBC,sBAAsB,EAAE,CAAC,CAAC;EAC1BC,wBAAwB,EAAE,CAAC,CAAC;EAC5BC,iBAAiB,EAAE,CAAC;AACtB,CAAC;AAAC,IAAAkF,QAAA,GAAAC,OAAA,cAEa7F,qBAAqB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-app-event-hook.js","names":["_nextjsComponents","require","_react","useAppEventHook","_ref","eventName","data","props","_useContext","useContext","AppContext","blazeApp","hasListener","events","hasListeners","concat","_useState","useState","_useState2","_slicedToArray2","loading","setLoading","_useState3","_useState4","updatedData","setUpdatedData","stableData","useMemo","JSON","stringify","stableProps","useEffect","emitEvent","_emitEvent","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_callee$","_context","prev","next","emitAsync","stop","_default","exports"],"sources":["../../src/hooks/use-app-event-hook.js"],"sourcesContent":["import { AppContext } from '@blaze-cms/nextjs-components';\nimport { useContext, useEffect, useState, useMemo } from 'react';\n\nconst useAppEventHook = ({ eventName, data, props }) => {\n const { blazeApp } = useContext(AppContext);\n const hasListener =\n blazeApp && blazeApp.events && blazeApp.events.hasListeners(`plugin:page-builder:${eventName}`);\n const [loading, setLoading] = useState(hasListener);\n const [updatedData, setUpdatedData] = useState(null);\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableData = useMemo(() => data, [JSON.stringify(data)]);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProps = useMemo(() => props, [JSON.stringify(props)]);\n\n useEffect(
|
|
1
|
+
{"version":3,"file":"use-app-event-hook.js","names":["_nextjsComponents","require","_react","useAppEventHook","_ref","eventName","data","props","_useContext","useContext","AppContext","blazeApp","hasListener","events","hasListeners","concat","_useState","useState","_useState2","_slicedToArray2","loading","setLoading","_useState3","_useState4","updatedData","setUpdatedData","stableData","useMemo","JSON","stringify","stableProps","useEffect","emitEvent","_emitEvent","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","wrap","_callee$","_context","prev","next","emitAsync","stop","_default","exports"],"sources":["../../src/hooks/use-app-event-hook.js"],"sourcesContent":["import { AppContext } from '@blaze-cms/nextjs-components';\nimport { useContext, useEffect, useState, useMemo } from 'react';\n\nconst useAppEventHook = ({ eventName, data, props }) => {\n const { blazeApp } = useContext(AppContext);\n const hasListener =\n blazeApp && blazeApp.events && blazeApp.events.hasListeners(`plugin:page-builder:${eventName}`);\n const [loading, setLoading] = useState(hasListener);\n const [updatedData, setUpdatedData] = useState(null);\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableData = useMemo(() => data, [JSON.stringify(data)]);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProps = useMemo(() => props, [JSON.stringify(props)]);\n\n useEffect(() => {\n async function emitEvent() {\n // setLoading(true);\n await blazeApp.events.emitAsync(`plugin:page-builder:${eventName}`, {\n data: updatedData,\n props: stableProps\n });\n setLoading(false);\n }\n if (hasListener && updatedData) emitEvent();\n }, [updatedData, eventName, hasListener, blazeApp.events, stableProps]);\n\n useEffect(() => {\n setUpdatedData(stableData);\n }, [stableData]);\n\n return { data: updatedData || stableData, loading };\n};\nexport default useAppEventHook;\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAME,eAAe,GAAG,SAAlBA,eAAeA,CAAAC,IAAA,EAAmC;EAAA,IAA7BC,SAAS,GAAAD,IAAA,CAATC,SAAS;IAAEC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IAAEC,KAAK,GAAAH,IAAA,CAALG,KAAK;EAC/C,IAAAC,WAAA,GAAqB,IAAAC,iBAAU,EAACC,4BAAU,CAAC;IAAnCC,QAAQ,GAAAH,WAAA,CAARG,QAAQ;EAChB,IAAMC,WAAW,GACfD,QAAQ,IAAIA,QAAQ,CAACE,MAAM,IAAIF,QAAQ,CAACE,MAAM,CAACC,YAAY,wBAAAC,MAAA,CAAwBV,SAAS,CAAE,CAAC;EACjG,IAAAW,SAAA,GAA8B,IAAAC,eAAQ,EAACL,WAAW,CAAC;IAAAM,UAAA,OAAAC,eAAA,aAAAH,SAAA;IAA5CI,OAAO,GAAAF,UAAA;IAAEG,UAAU,GAAAH,UAAA;EAC1B,IAAAI,UAAA,GAAsC,IAAAL,eAAQ,EAAC,IAAI,CAAC;IAAAM,UAAA,OAAAJ,eAAA,aAAAG,UAAA;IAA7CE,WAAW,GAAAD,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C,EAAE,CAACA,UAAU,CAAC,CAAC;EAEhB,OAAO;IAAEpB,IAAI,EAAEkB,WAAW,IAAIE,UAAU;IAAEN,OAAO,EAAPA;EAAQ,CAAC;AACrD,CAAC;AAAC,IAAA2B,QAAA,GAAAC,OAAA,cACa7C,eAAe","ignoreList":[]}
|
package/lib-es/HOC/withTitle.js
CHANGED
|
@@ -14,7 +14,7 @@ const withTitle = Component => {
|
|
|
14
14
|
data: [elementTitleToUse]
|
|
15
15
|
} = useStringTemplate(parent, [elementTitle]);
|
|
16
16
|
if (loading) return '';
|
|
17
|
-
return /*#__PURE__*/React.createElement(Fragment, null, shouldDisplayTitle && /*#__PURE__*/React.createElement("h2", {
|
|
17
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, shouldDisplayTitle && /*#__PURE__*/React.createElement("h2", {
|
|
18
18
|
className: "heading heading--section"
|
|
19
19
|
}, elementTitleToUse), /*#__PURE__*/React.createElement(Component, props));
|
|
20
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTitle.js","names":["React","Fragment","PropTypes","useStringTemplate","withTitle","Component","InnerComponent","props","elementTitle","isHeroImg","parent","shouldDisplayTitle","loading","data","elementTitleToUse","createElement","className","WrappedComponent","displayName","name","propTypes","object","string","bool","defaultProps"],"sources":["../../src/HOC/withTitle.js"],"sourcesContent":["import React, { Fragment } from 'react';\nimport PropTypes from 'prop-types';\nimport { useStringTemplate } from '@blaze-cms/utils-handlebars';\n\nconst withTitle = Component => {\n const InnerComponent = props => {\n const { elementTitle, isHeroImg, parent } = props;\n\n const shouldDisplayTitle = elementTitle && !isHeroImg;\n const {\n loading,\n data: [elementTitleToUse]\n } = useStringTemplate(parent, [elementTitle]);\n\n if (loading) return '';\n\n return (\n
|
|
1
|
+
{"version":3,"file":"withTitle.js","names":["React","Fragment","PropTypes","useStringTemplate","withTitle","Component","InnerComponent","props","elementTitle","isHeroImg","parent","shouldDisplayTitle","loading","data","elementTitleToUse","createElement","className","WrappedComponent","displayName","name","propTypes","object","string","bool","defaultProps"],"sources":["../../src/HOC/withTitle.js"],"sourcesContent":["import React, { Fragment } from 'react';\nimport PropTypes from 'prop-types';\nimport { useStringTemplate } from '@blaze-cms/utils-handlebars';\n\nconst withTitle = Component => {\n const InnerComponent = props => {\n const { elementTitle, isHeroImg, parent } = props;\n\n const shouldDisplayTitle = elementTitle && !isHeroImg;\n const {\n loading,\n data: [elementTitleToUse]\n } = useStringTemplate(parent, [elementTitle]);\n\n if (loading) return '';\n\n return (\n <>\n {shouldDisplayTitle && <h2 className=\"heading heading--section\">{elementTitleToUse}</h2>}\n <Component {...props} />\n </>\n );\n };\n\n InnerComponent.WrappedComponent = Component;\n\n InnerComponent.displayName = `WithTitle(${\n Component.displayName || Component.name || 'Component'\n })`;\n\n InnerComponent.propTypes = {\n parent: PropTypes.object,\n elementTitle: PropTypes.string,\n isHeroImg: PropTypes.bool\n };\n InnerComponent.defaultProps = {\n parent: {},\n elementTitle: '',\n isHeroImg: false\n };\n\n return InnerComponent;\n};\n\nexport default withTitle;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,iBAAiB,QAAQ,6BAA6B;AAE/D,MAAMC,SAAS,GAAGC,SAAS,IAAI;EAC7B,MAAMC,cAAc,GAAGC,KAAK,IAAI;IAC9B,MAAM;MAAEC,YAAY;MAAEC,SAAS;MAAEC;IAAO,CAAC,GAAGH,KAAK;IAEjD,MAAMI,kBAAkB,GAAGH,YAAY,IAAI,CAACC,SAAS;IACrD,MAAM;MACJG,OAAO;MACPC,IAAI,EAAE,CAACC,iBAAiB;IAC1B,CAAC,GAAGX,iBAAiB,CAACO,MAAM,EAAE,CAACF,YAAY,CAAC,CAAC;IAE7C,IAAII,OAAO,EAAE,OAAO,EAAE;IAEtB,oBACEZ,KAAA,CAAAe,aAAA,CAAAf,KAAA,CAAAC,QAAA,QACGU,kBAAkB,iBAAIX,KAAA,CAAAe,aAAA;MAAIC,SAAS,EAAC;IAA0B,GAAEF,iBAAsB,CAAC,eACxFd,KAAA,CAAAe,aAAA,CAACV,SAAS,EAAKE,KAAQ,CACvB,CAAC;EAEP,CAAC;EAEDD,cAAc,CAACW,gBAAgB,GAAGZ,SAAS;EAE3CC,cAAc,CAACY,WAAW,GAAG,aAC3Bb,SAAS,CAACa,WAAW,IAAIb,SAAS,CAACc,IAAI,IAAI,WAAW,GACrD;EAEHb,cAAc,CAACc,SAAS,GAAG;IACzBV,MAAM,EAAER,SAAS,CAACmB,MAAM;IACxBb,YAAY,EAAEN,SAAS,CAACoB,MAAM;IAC9Bb,SAAS,EAAEP,SAAS,CAACqB;EACvB,CAAC;EACDjB,cAAc,CAACkB,YAAY,GAAG;IAC5Bd,MAAM,EAAE,CAAC,CAAC;IACVF,YAAY,EAAE,EAAE;IAChBC,SAAS,EAAE;EACb,CAAC;EAED,OAAOH,cAAc;AACvB,CAAC;AAED,eAAeF,SAAS","ignoreList":[]}
|
|
@@ -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","groupSections","GroupComponent","ACCORDION","WrapperComponent","_useMemo","structuredDataProperties","_objectSpread","topWrapperProps","schemaProperties","_excluded2","length","includes","sectionsData","createElement","_extends","propTypes","object","isRequired","oneOf","bool","arrayOf","shape","name","string","value","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 { getSectionsData } 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 = ({ contentType, isFaqContent, children, customHtmlProps, ...props }) => {\n const groupSections = 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(
|
|
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","groupSections","GroupComponent","ACCORDION","WrapperComponent","_useMemo","structuredDataProperties","_objectSpread","topWrapperProps","schemaProperties","_excluded2","length","includes","sectionsData","createElement","_extends","propTypes","object","isRequired","oneOf","bool","arrayOf","shape","name","string","value","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 { getSectionsData } 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 = ({ contentType, isFaqContent, children, customHtmlProps, ...props }) => {\n const groupSections = 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 (!groupSections || !groupSections.length || !VALID_TYPES.includes(contentType)) return '';\n\n const sectionsData = getSectionsData(groupSections);\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.isRequired,\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};\n\nContentGroup.defaultProps = {\n isFaqContent: false,\n customHtmlProps: []\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,SAASC,eAAe,QAAQ,WAAW;AAC3C,OAAOC,2BAA2B,MAAM,0CAA0C;AAClF,SAASC,uBAAuB,QAAQ,eAAe;AAEvD,MAAMC,WAAW,GAAGC,MAAM,CAACC,MAAM,CAACR,mBAAmB,CAAC;AAEtD,MAAMS,YAAY,GAAGC,IAAA,IAAwE;EAAA,IAAAC,eAAA,EAAAC,qBAAA;EAAA,IAAvE;MAAEC,W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AACV,gBAAgB,EAAKI,eAAe,eACnC/B,KAAA,CAAAqC,aAAA,CAACZ,cAAc,EAAAa,QAAA;IACbrB,WAAW,EAAEA,WAAY;IACzBO,aAAa,EAAEA,aAAc;IAC7BY,YAAY,EAAEA;EAAa,GACvBf,KAAK,EACLW,gBAAgB,CACrB,CACe,CAAC;AAEvB,CAAC;AAEDnB,YAAY,CAAC0B,SAAS,GAAG;EACvBpB,QAAQ,EAAEhB,SAAS,CAACqC,MAAM,CAACC,UAAU;EACrCxB,WAAW,EAAEd,SAAS,CAACuC,KAAK,CAAChC,WAAW,CAAC,CAAC+B,UAAU;EACpDvB,YAAY,EAAEf,SAAS,CAACwC,IAAI;EAC5BvB,eAAe,EAAEjB,SAAS,CAACyC,OAAO,CAChCzC,SAAS,CAAC0C,KAAK,CAAC;IACdC,IAAI,EAAE3C,SAAS,CAAC4C,MAAM;IACtBC,KAAK,EAAE7C,SAAS,CAAC4C;EACnB,CAAC,CACH;AACF,CAAC;AAEDlC,YAAY,CAACoC,YAAY,GAAG;EAC1B/B,YAAY,EAAE,KAAK;EACnBE,eAAe,EAAE;AACnB,CAAC;AAED,eAAeP,YAAY","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentGroupAccordion.js","names":["React","useEffect","useMemo","useState","PropTypes","classnames","useRouter","VscChevronUp","VscChevronDown","CONTENT_GROUP","OPEN_STATES","ContentGroupAccordion","name","groupSections","sectionsData","VariantComponent","openState","groupSectionProps","groupSectionTitleProps","groupContentWrapperProps","groupContentProps","router","asPath","sectionPairs","map","sectionName","sectionLabel","panelId","sectionNames","p","baseInitialOpen","ALL_OPEN","Set","ALL_CLOSED","length","openSet","setOpenSet","rawHash","split","trim","includes","has","prev","next","add","WrapperComponent","baseClass","itemsClass","itemClass","headerBtnClass","panelClass","headingClass","titleClass","chevronClass","chevronIconClass","onToggle","willOpen","delete","baseUrl","newUrl","replace","shallow","scroll","createElement","className","groupSection","index","isOpen","_extends","key","id","type","onClick","role","hidden","propTypes","string","isRequired","array","oneOfType","func","elementType","oneOf","Object","values","object","defaultProps"],"sources":["../../../src/components/ContentGroup/ContentGroupAccordion.js"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport { useRouter } from 'next/router';\nimport { VscChevronUp, VscChevronDown } from 'react-icons/vsc';\nimport { CONTENT_GROUP, OPEN_STATES } from './constants';\n\nconst ContentGroupAccordion = ({\n name,\n groupSections,\n sectionsData,\n VariantComponent,\n openState,\n groupSectionProps,\n groupSectionTitleProps,\n groupContentWrapperProps,\n groupContentProps\n}) => {\n const router = useRouter();\n const { asPath } = router;\n\n const sectionPairs = useMemo(\n () =>\n sectionsData.map(([sectionName, sectionLabel]) => ({\n sectionName,\n sectionLabel,\n panelId: `${sectionName}-panel`\n })),\n [sectionsData]\n );\n\n const sectionNames = useMemo(() => sectionPairs.map(p => p.sectionName), [sectionPairs]);\n\n const baseInitialOpen = useMemo(\n () => {\n if (openState === OPEN_STATES.ALL_OPEN) return new Set(sectionNames);\n if (openState === OPEN_STATES.ALL_CLOSED && sectionNames.length) return new Set();\n\n return new Set([sectionNames[0]]);\n },\n [openState, sectionNames]\n );\n\n const [openSet, setOpenSet] = useState(baseInitialOpen);\n\n useEffect(\n () => {\n const rawHash = (asPath.split('#')[1] || '').trim();\n if (rawHash && sectionNames.includes(rawHash) && !openSet.has(rawHash)) {\n setOpenSet(prev => {\n const next = new Set(prev);\n next.add(rawHash);\n return next;\n });\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [asPath, sectionNames]\n );\n\n const WrapperComponent = VariantComponent || 'div';\n\n const baseClass = `${CONTENT_GROUP}-accordion`;\n const itemsClass = `${baseClass}__items`;\n const itemClass = `${baseClass}__item`;\n const headerBtnClass = `${baseClass}__header-btn`;\n const panelClass = `${baseClass}__panel`;\n const headingClass = `${baseClass}__heading`;\n const titleClass = `${baseClass}__title`;\n const chevronClass = `${baseClass}__chevron`;\n const chevronIconClass = `${baseClass}__chevron-icon`;\n\n const onToggle = sectionName => {\n setOpenSet(prev => {\n const next = new Set(prev);\n const willOpen = !next.has(sectionName);\n\n if (willOpen) next.add(sectionName);\n else next.delete(sectionName);\n\n const baseUrl = asPath.split('#')[0];\n const newUrl = willOpen ? `${baseUrl}#${sectionName}` : baseUrl;\n\n router.replace(`/Resolver`, newUrl, { shallow: true, scroll: false });\n\n return next;\n });\n };\n\n return (\n <div className={baseClass}>\n <div className={itemsClass} aria-label={name}>\n {groupSections.map((groupSection, index) => {\n const { sectionName, sectionLabel, panelId } = sectionPairs[index];\n const isOpen = openSet.has(sectionName);\n\n return (\n <div\n key={sectionName}\n className={classnames(itemClass, { [`${itemClass}--open`]: isOpen })}\n {...groupSectionProps}>\n <h3 className={headingClass}>\n <button\n id={sectionName}\n type=\"button\"\n className={classnames(headerBtnClass, { [`${headerBtnClass}--open`]: isOpen })}\n aria-expanded={isOpen}\n aria-controls={panelId}\n onClick={() => onToggle(sectionName)}>\n <span className={titleClass} {...groupSectionTitleProps}>\n {sectionLabel}\n </span>\n\n <span aria-hidden=\"true\" className={chevronClass}>\n {isOpen ? (\n <VscChevronUp className={chevronIconClass} />\n ) : (\n <VscChevronDown className={chevronIconClass} />\n )}\n </span>\n </button>\n </h3>\n\n <WrapperComponent\n id={panelId}\n role=\"region\"\n aria-labelledby={sectionName}\n className={panelClass}\n hidden={!isOpen}\n data-section={sectionName}\n {...groupContentWrapperProps}>\n <div {...groupContentProps}>{groupSection}</div>\n </WrapperComponent>\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n\nContentGroupAccordion.propTypes = {\n name: PropTypes.string.isRequired,\n groupSections: PropTypes.array.isRequired,\n sectionsData: PropTypes.array.isRequired,\n VariantComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.elementType]),\n openState: PropTypes.oneOf(Object.values(OPEN_STATES)),\n groupSectionProps: PropTypes.object,\n groupSectionTitleProps: PropTypes.object,\n groupContentWrapperProps: PropTypes.object,\n groupContentProps: PropTypes.object\n};\n\nContentGroupAccordion.defaultProps = {\n VariantComponent: null,\n openState: OPEN_STATES.ALL_CLOSED,\n groupSectionProps: {},\n groupSectionTitleProps: {},\n groupContentWrapperProps: {},\n groupContentProps: {}\n};\n\nexport default ContentGroupAccordion;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAC3D,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,YAAY,EAAEC,cAAc,QAAQ,iBAAiB;AAC9D,SAASC,aAAa,EAAEC,WAAW,QAAQ,aAAa;AAExD,MAAMC,qBAAqB,GAAGA,CAAC;EAC7BC,IAAI;EACJC,aAAa;EACbC,YAAY;EACZC,gBAAgB;EAChBC,SAAS;EACTC,iBAAiB;EACjBC,sBAAsB;EACtBC,wBAAwB;EACxBC;AACF,CAAC,KAAK;EACJ,MAAMC,MAAM,GAAGf,SAAS,CAAC,CAAC;EAC1B,MAAM;IAAEgB;EAAO,CAAC,GAAGD,MAAM;EAEzB,MAAME,YAAY,GAAGrB,OAAO,CAC1B,MACEY,YAAY,CAACU,GAAG,CAAC,CAAC,CAACC,WAAW,EAAEC,YAAY,CAAC,MAAM;IACjDD,WAAW;IACXC,YAAY;IACZC,OAAO,EAAE,GAAGF,WAAW;EACzB,CAAC,CAAC,CAAC,EACL,CAACX,YAAY,CACf,CAAC;EAED,MAAMc,YAAY,GAAG1B,OAAO,CAAC,MAAMqB,YAAY,CAACC,GAAG,CAACK,CAAC,IAAIA,CAAC,CAACJ,WAAW,CAAC,EAAE,CAACF,YAAY,CAAC,CAAC;EAExF,MAAMO,eAAe,GAAG5B,OAAO,CAC7B,MAAM;IACJ,IAAIc,SAAS,KAAKN,WAAW,CAACqB,QAAQ,EAAE,OAAO,IAAIC,GAAG,CAACJ,YAAY,CAAC;I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ACjChE,aAAa,EAAET,SAAS,CAAC0E,KAAK,CAACD,UAAU;EACzC/D,YAAY,EAAEV,SAAS,CAAC0E,KAAK,CAACD,UAAU;EACxC9D,gBAAgB,EAAEX,SAAS,CAAC2E,SAAS,CAAC,CAAC3E,SAAS,CAAC4E,IAAI,EAAE5E,SAAS,CAAC6E,WAAW,CAAC,CAAC;EAC9EjE,SAAS,EAAEZ,SAAS,CAAC8E,KAAK,CAACC,MAAM,CAACC,MAAM,CAAC1E,WAAW,CAAC,CAAC;EACtDO,iBAAiB,EAAEb,SAAS,CAACiF,MAAM;EACnCnE,sBAAsB,EAAEd,SAAS,CAACiF,MAAM;EACxClE,wBAAwB,EAAEf,SAAS,CAACiF,MAAM;EAC1CjE,iBAAiB,EAAEhB,SAAS,CAACiF;AAC/B,CAAC;AAED1E,qBAAqB,CAAC2E,YAAY,GAAG;EACnCvE,gBAAgB,EAAE,IAAI;EACtBC,SAAS,EAAEN,WAAW,CAACuB,UAAU;EACjChB,iBAAiB,EAAE,CAAC,CAAC;EACrBC,sBAAsB,EAAE,CAAC,CAAC;EAC1BC,wBAAwB,EAAE,CAAC,CAAC;EAC5BC,iBAAiB,EAAE,CAAC;AACtB,CAAC;AAED,eAAeT,qBAAqB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ContentGroupAccordion.js","names":["React","useEffect","useMemo","useState","PropTypes","classnames","useRouter","VscChevronUp","VscChevronDown","CONTENT_GROUP","OPEN_STATES","ContentGroupAccordion","name","groupSections","sectionsData","VariantComponent","openState","groupSectionProps","groupSectionTitleProps","groupContentWrapperProps","groupContentProps","router","asPath","sectionPairs","map","sectionName","sectionLabel","panelId","sectionNames","p","baseInitialOpen","ALL_OPEN","Set","ALL_CLOSED","length","openSet","setOpenSet","rawHash","split","trim","includes","has","prev","next","add","WrapperComponent","baseClass","itemsClass","itemClass","headerBtnClass","panelClass","headingClass","titleClass","chevronClass","chevronIconClass","onToggle","willOpen","delete","baseUrl","newUrl","replace","shallow","scroll","createElement","className","groupSection","index","isOpen","_extends","key","id","type","onClick","role","hidden","propTypes","string","isRequired","array","oneOfType","func","elementType","oneOf","Object","values","object","defaultProps"],"sources":["../../../src/components/ContentGroup/ContentGroupAccordion.js"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport { useRouter } from 'next/router';\nimport { VscChevronUp, VscChevronDown } from 'react-icons/vsc';\nimport { CONTENT_GROUP, OPEN_STATES } from './constants';\n\nconst ContentGroupAccordion = ({\n name,\n groupSections,\n sectionsData,\n VariantComponent,\n openState,\n groupSectionProps,\n groupSectionTitleProps,\n groupContentWrapperProps,\n groupContentProps\n}) => {\n const router = useRouter();\n const { asPath } = router;\n\n const sectionPairs = useMemo(\n () =>\n sectionsData.map(([sectionName, sectionLabel]) => ({\n sectionName,\n sectionLabel,\n panelId: `${sectionName}-panel`\n })),\n [sectionsData]\n );\n\n const sectionNames = useMemo(() => sectionPairs.map(p => p.sectionName), [sectionPairs]);\n\n const baseInitialOpen = useMemo(() => {\n if (openState === OPEN_STATES.ALL_OPEN) return new Set(sectionNames);\n if (openState === OPEN_STATES.ALL_CLOSED && sectionNames.length) return new Set();\n\n return new Set([sectionNames[0]]);\n }, [openState, sectionNames]);\n\n const [openSet, setOpenSet] = useState(baseInitialOpen);\n\n useEffect(\n () => {\n const rawHash = (asPath.split('#')[1] || '').trim();\n if (rawHash && sectionNames.includes(rawHash) && !openSet.has(rawHash)) {\n setOpenSet(prev => {\n const next = new Set(prev);\n next.add(rawHash);\n return next;\n });\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [asPath, sectionNames]\n );\n\n const WrapperComponent = VariantComponent || 'div';\n\n const baseClass = `${CONTENT_GROUP}-accordion`;\n const itemsClass = `${baseClass}__items`;\n const itemClass = `${baseClass}__item`;\n const headerBtnClass = `${baseClass}__header-btn`;\n const panelClass = `${baseClass}__panel`;\n const headingClass = `${baseClass}__heading`;\n const titleClass = `${baseClass}__title`;\n const chevronClass = `${baseClass}__chevron`;\n const chevronIconClass = `${baseClass}__chevron-icon`;\n\n const onToggle = sectionName => {\n setOpenSet(prev => {\n const next = new Set(prev);\n const willOpen = !next.has(sectionName);\n\n if (willOpen) next.add(sectionName);\n else next.delete(sectionName);\n\n const baseUrl = asPath.split('#')[0];\n const newUrl = willOpen ? `${baseUrl}#${sectionName}` : baseUrl;\n\n router.replace(`/Resolver`, newUrl, { shallow: true, scroll: false });\n\n return next;\n });\n };\n\n return (\n <div className={baseClass}>\n <div className={itemsClass} aria-label={name}>\n {groupSections.map((groupSection, index) => {\n const { sectionName, sectionLabel, panelId } = sectionPairs[index];\n const isOpen = openSet.has(sectionName);\n\n return (\n <div\n key={sectionName}\n className={classnames(itemClass, { [`${itemClass}--open`]: isOpen })}\n {...groupSectionProps}>\n <h3 className={headingClass}>\n <button\n id={sectionName}\n type=\"button\"\n className={classnames(headerBtnClass, { [`${headerBtnClass}--open`]: isOpen })}\n aria-expanded={isOpen}\n aria-controls={panelId}\n onClick={() => onToggle(sectionName)}>\n <span className={titleClass} {...groupSectionTitleProps}>\n {sectionLabel}\n </span>\n\n <span aria-hidden=\"true\" className={chevronClass}>\n {isOpen ? (\n <VscChevronUp className={chevronIconClass} />\n ) : (\n <VscChevronDown className={chevronIconClass} />\n )}\n </span>\n </button>\n </h3>\n\n <WrapperComponent\n id={panelId}\n role=\"region\"\n aria-labelledby={sectionName}\n className={panelClass}\n hidden={!isOpen}\n data-section={sectionName}\n {...groupContentWrapperProps}>\n <div {...groupContentProps}>{groupSection}</div>\n </WrapperComponent>\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n\nContentGroupAccordion.propTypes = {\n name: PropTypes.string.isRequired,\n groupSections: PropTypes.array.isRequired,\n sectionsData: PropTypes.array.isRequired,\n VariantComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.elementType]),\n openState: PropTypes.oneOf(Object.values(OPEN_STATES)),\n groupSectionProps: PropTypes.object,\n groupSectionTitleProps: PropTypes.object,\n groupContentWrapperProps: PropTypes.object,\n groupContentProps: PropTypes.object\n};\n\nContentGroupAccordion.defaultProps = {\n VariantComponent: null,\n openState: OPEN_STATES.ALL_CLOSED,\n groupSectionProps: {},\n groupSectionTitleProps: {},\n groupContentWrapperProps: {},\n groupContentProps: {}\n};\n\nexport default ContentGroupAccordion;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAC3D,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,YAAY,EAAEC,cAAc,QAAQ,iBAAiB;AAC9D,SAASC,aAAa,EAAEC,WAAW,QAAQ,aAAa;AAExD,MAAMC,qBAAqB,GAAGA,CAAC;EAC7BC,IAAI;EACJC,aAAa;EACbC,YAAY;EACZC,gBAAgB;EAChBC,SAAS;EACTC,iBAAiB;EACjBC,sBAAsB;EACtBC,wBAAwB;EACxBC;AACF,CAAC,KAAK;EACJ,MAAMC,MAAM,GAAGf,SAAS,CAAC,CAAC;EAC1B,MAAM;IAAEgB;EAAO,CAAC,GAAGD,MAAM;EAEzB,MAAME,YAAY,GAAGrB,OAAO,CAC1B,MACEY,YAAY,CAACU,GAAG,CAAC,CAAC,CAACC,WAAW,EAAEC,YAAY,CAAC,MAAM;IACjDD,WAAW;IACXC,YAAY;IACZC,OAAO,EAAE,GAAGF,WAAW;EACzB,CAAC,CAAC,CAAC,EACL,CAACX,YAAY,CACf,CAAC;EAED,MAAMc,YAAY,GAAG1B,OAAO,CAAC,MAAMqB,YAAY,CAACC,GAAG,CAACK,CAAC,IAAIA,CAAC,CAACJ,WAAW,CAAC,EAAE,CAACF,YAAY,CAAC,CAAC;EAExF,MAAMO,eAAe,GAAG5B,OAAO,CAAC,MAAM;IACpC,IAAIc,SAAS,KAAKN,WAAW,CAACqB,QAAQ,EAAE,OAAO,IAAIC,GAAG,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wE,MAAM,CAACC,UAAU;EACjChE,aAAa,EAAET,SAAS,CAAC0E,KAAK,CAACD,UAAU;EACzC/D,YAAY,EAAEV,SAAS,CAAC0E,KAAK,CAACD,UAAU;EACxC9D,gBAAgB,EAAEX,SAAS,CAAC2E,SAAS,CAAC,CAAC3E,SAAS,CAAC4E,IAAI,EAAE5E,SAAS,CAAC6E,WAAW,CAAC,CAAC;EAC9EjE,SAAS,EAAEZ,SAAS,CAAC8E,KAAK,CAACC,MAAM,CAACC,MAAM,CAAC1E,WAAW,CAAC,CAAC;EACtDO,iBAAiB,EAAEb,SAAS,CAACiF,MAAM;EACnCnE,sBAAsB,EAAEd,SAAS,CAACiF,MAAM;EACxClE,wBAAwB,EAAEf,SAAS,CAACiF,MAAM;EAC1CjE,iBAAiB,EAAEhB,SAAS,CAACiF;AAC/B,CAAC;AAED1E,qBAAqB,CAAC2E,YAAY,GAAG;EACnCvE,gBAAgB,EAAE,IAAI;EACtBC,SAAS,EAAEN,WAAW,CAACuB,UAAU;EACjChB,iBAAiB,EAAE,CAAC,CAAC;EACrBC,sBAAsB,EAAE,CAAC,CAAC;EAC1BC,wBAAwB,EAAE,CAAC,CAAC;EAC5BC,iBAAiB,EAAE,CAAC;AACtB,CAAC;AAED,eAAeT,qBAAqB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-app-event-hook.js","names":["AppContext","useContext","useEffect","useState","useMemo","useAppEventHook","eventName","data","props","blazeApp","hasListener","events","hasListeners","loading","setLoading","updatedData","setUpdatedData","stableData","JSON","stringify","stableProps","emitEvent","emitAsync"],"sources":["../../src/hooks/use-app-event-hook.js"],"sourcesContent":["import { AppContext } from '@blaze-cms/nextjs-components';\nimport { useContext, useEffect, useState, useMemo } from 'react';\n\nconst useAppEventHook = ({ eventName, data, props }) => {\n const { blazeApp } = useContext(AppContext);\n const hasListener =\n blazeApp && blazeApp.events && blazeApp.events.hasListeners(`plugin:page-builder:${eventName}`);\n const [loading, setLoading] = useState(hasListener);\n const [updatedData, setUpdatedData] = useState(null);\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableData = useMemo(() => data, [JSON.stringify(data)]);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProps = useMemo(() => props, [JSON.stringify(props)]);\n\n useEffect(
|
|
1
|
+
{"version":3,"file":"use-app-event-hook.js","names":["AppContext","useContext","useEffect","useState","useMemo","useAppEventHook","eventName","data","props","blazeApp","hasListener","events","hasListeners","loading","setLoading","updatedData","setUpdatedData","stableData","JSON","stringify","stableProps","emitEvent","emitAsync"],"sources":["../../src/hooks/use-app-event-hook.js"],"sourcesContent":["import { AppContext } from '@blaze-cms/nextjs-components';\nimport { useContext, useEffect, useState, useMemo } from 'react';\n\nconst useAppEventHook = ({ eventName, data, props }) => {\n const { blazeApp } = useContext(AppContext);\n const hasListener =\n blazeApp && blazeApp.events && blazeApp.events.hasListeners(`plugin:page-builder:${eventName}`);\n const [loading, setLoading] = useState(hasListener);\n const [updatedData, setUpdatedData] = useState(null);\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableData = useMemo(() => data, [JSON.stringify(data)]);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProps = useMemo(() => props, [JSON.stringify(props)]);\n\n useEffect(() => {\n async function emitEvent() {\n // setLoading(true);\n await blazeApp.events.emitAsync(`plugin:page-builder:${eventName}`, {\n data: updatedData,\n props: stableProps\n });\n setLoading(false);\n }\n if (hasListener && updatedData) emitEvent();\n }, [updatedData, eventName, hasListener, blazeApp.events, stableProps]);\n\n useEffect(() => {\n setUpdatedData(stableData);\n }, [stableData]);\n\n return { data: updatedData || stableData, loading };\n};\nexport default useAppEventHook;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,8BAA8B;AACzD,SAASC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,OAAO,QAAQ,OAAO;AAEhE,MAAMC,eAAe,GAAGA,CAAC;EAAEC,SAAS;EAAEC,IAAI;E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}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.146.0-node18-core-styles-tooltips.
|
|
3
|
+
"version": "0.146.0-node18-core-styles-tooltips.58",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "GPL-3.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@blaze-cms/core-auth-ui": "0.146.0-node18-core-styles-tooltips.
|
|
30
|
+
"@blaze-cms/core-auth-ui": "0.146.0-node18-core-styles-tooltips.58",
|
|
31
31
|
"@blaze-cms/core-errors": "0.146.0-node18-core-styles-tooltips.46",
|
|
32
32
|
"@blaze-cms/core-errors-ui": "0.146.0-node18-core-styles-tooltips.46",
|
|
33
33
|
"@blaze-cms/image-cdn-react": "0.3.0-alpha.7",
|
|
34
|
-
"@blaze-cms/nextjs-components": "0.146.0-node18-core-styles-tooltips.
|
|
35
|
-
"@blaze-cms/plugin-search-ui": "0.146.0-node18-core-styles-tooltips.
|
|
34
|
+
"@blaze-cms/nextjs-components": "0.146.0-node18-core-styles-tooltips.58",
|
|
35
|
+
"@blaze-cms/plugin-search-ui": "0.146.0-node18-core-styles-tooltips.58",
|
|
36
36
|
"@blaze-cms/setup-ui": "0.146.0-node18-core-styles-tooltips.46",
|
|
37
37
|
"@blaze-cms/utils": "0.146.0-node18-core-styles-tooltips.46",
|
|
38
|
-
"@blaze-cms/utils-handlebars": "0.146.0-node18-core-styles-tooltips.
|
|
38
|
+
"@blaze-cms/utils-handlebars": "0.146.0-node18-core-styles-tooltips.58",
|
|
39
39
|
"@blaze-react/badge": "^0.7.0",
|
|
40
40
|
"@blaze-react/breadcrumb": "0.8.0-alpha.60",
|
|
41
41
|
"@blaze-react/button": "0.8.0-alpha.82",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"lodash.uniq": "^4.5.0",
|
|
61
61
|
"lodash.upperfirst": "^4.3.1",
|
|
62
62
|
"query-string": "^6.9.0",
|
|
63
|
-
"react-cookie": "^
|
|
63
|
+
"react-cookie": "^7.2.2",
|
|
64
64
|
"react-dfp": "^0.19.0",
|
|
65
65
|
"react-html-parser": "2.0.2",
|
|
66
66
|
"react-jw-player": "^1.19.1",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"lib/*",
|
|
93
93
|
"lib-es/*"
|
|
94
94
|
],
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "f7a6d4bdce550c1edced07053c611a4e5aa28d8b"
|
|
96
96
|
}
|
package/src/HOC/withTitle.js
CHANGED
|
@@ -15,10 +15,10 @@ const withTitle = Component => {
|
|
|
15
15
|
if (loading) return '';
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
|
-
|
|
18
|
+
<>
|
|
19
19
|
{shouldDisplayTitle && <h2 className="heading heading--section">{elementTitleToUse}</h2>}
|
|
20
20
|
<Component {...props} />
|
|
21
|
-
|
|
21
|
+
</>
|
|
22
22
|
);
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -19,19 +19,16 @@ const ContentGroup = ({ contentType, isFaqContent, children, customHtmlProps, ..
|
|
|
19
19
|
);
|
|
20
20
|
const WrapperComponent = useMemo(() => (!isFaqContent ? Fragment : 'div'), [isFaqContent]);
|
|
21
21
|
|
|
22
|
-
const { topWrapperProps, ...schemaProperties } = useMemo(
|
|
23
|
-
()
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
topWrapperProps
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
[isFaqContent, customHtmlProps]
|
|
34
|
-
);
|
|
22
|
+
const { topWrapperProps, ...schemaProperties } = useMemo(() => {
|
|
23
|
+
const structuredDataProperties = getStructuredDataProperties(isFaqContent);
|
|
24
|
+
return {
|
|
25
|
+
...structuredDataProperties,
|
|
26
|
+
topWrapperProps: {
|
|
27
|
+
...structuredDataProperties.topWrapperProps,
|
|
28
|
+
...getCustomHtmlProperties({ customHtmlProps })
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}, [isFaqContent, customHtmlProps]);
|
|
35
32
|
|
|
36
33
|
if (!groupSections || !groupSections.length || !VALID_TYPES.includes(contentType)) return '';
|
|
37
34
|
|
|
@@ -31,15 +31,12 @@ const ContentGroupAccordion = ({
|
|
|
31
31
|
|
|
32
32
|
const sectionNames = useMemo(() => sectionPairs.map(p => p.sectionName), [sectionPairs]);
|
|
33
33
|
|
|
34
|
-
const baseInitialOpen = useMemo(
|
|
35
|
-
()
|
|
36
|
-
|
|
37
|
-
if (openState === OPEN_STATES.ALL_CLOSED && sectionNames.length) return new Set();
|
|
34
|
+
const baseInitialOpen = useMemo(() => {
|
|
35
|
+
if (openState === OPEN_STATES.ALL_OPEN) return new Set(sectionNames);
|
|
36
|
+
if (openState === OPEN_STATES.ALL_CLOSED && sectionNames.length) return new Set();
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
[openState, sectionNames]
|
|
42
|
-
);
|
|
38
|
+
return new Set([sectionNames[0]]);
|
|
39
|
+
}, [openState, sectionNames]);
|
|
43
40
|
|
|
44
41
|
const [openSet, setOpenSet] = useState(baseInitialOpen);
|
|
45
42
|
|
|
@@ -13,27 +13,21 @@ const useAppEventHook = ({ eventName, data, props }) => {
|
|
|
13
13
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
14
14
|
const stableProps = useMemo(() => props, [JSON.stringify(props)]);
|
|
15
15
|
|
|
16
|
-
useEffect(
|
|
17
|
-
()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
[updatedData, eventName, hasListener, blazeApp.events, stableProps]
|
|
29
|
-
);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
async function emitEvent() {
|
|
18
|
+
// setLoading(true);
|
|
19
|
+
await blazeApp.events.emitAsync(`plugin:page-builder:${eventName}`, {
|
|
20
|
+
data: updatedData,
|
|
21
|
+
props: stableProps
|
|
22
|
+
});
|
|
23
|
+
setLoading(false);
|
|
24
|
+
}
|
|
25
|
+
if (hasListener && updatedData) emitEvent();
|
|
26
|
+
}, [updatedData, eventName, hasListener, blazeApp.events, stableProps]);
|
|
30
27
|
|
|
31
|
-
useEffect(
|
|
32
|
-
()
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
[stableData]
|
|
36
|
-
);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
setUpdatedData(stableData);
|
|
30
|
+
}, [stableData]);
|
|
37
31
|
|
|
38
32
|
return { data: updatedData || stableData, loading };
|
|
39
33
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
2
|
|
|
3
3
|
exports[`Breadcrumb component should match snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
@@ -14,9 +14,6 @@ exports[`Breadcrumb component should match snapshot 1`] = `
|
|
|
14
14
|
<a
|
|
15
15
|
aria-label="Home"
|
|
16
16
|
href="/"
|
|
17
|
-
/>
|
|
18
|
-
<a
|
|
19
|
-
href="/"
|
|
20
17
|
>
|
|
21
18
|
Home
|
|
22
19
|
</a>
|
|
@@ -27,7 +24,6 @@ exports[`Breadcrumb component should match snapshot 1`] = `
|
|
|
27
24
|
<a
|
|
28
25
|
href="/Resolver"
|
|
29
26
|
/>
|
|
30
|
-
<a />
|
|
31
27
|
</li>
|
|
32
28
|
</ul>
|
|
33
29
|
</div>
|
|
@@ -48,9 +44,6 @@ exports[`Breadcrumb component should not render if loading, err or no data exist
|
|
|
48
44
|
<a
|
|
49
45
|
aria-label="Home"
|
|
50
46
|
href="/"
|
|
51
|
-
/>
|
|
52
|
-
<a
|
|
53
|
-
href="/"
|
|
54
47
|
>
|
|
55
48
|
Home
|
|
56
49
|
</a>
|
|
@@ -61,7 +54,6 @@ exports[`Breadcrumb component should not render if loading, err or no data exist
|
|
|
61
54
|
<a
|
|
62
55
|
href="/Resolver"
|
|
63
56
|
/>
|
|
64
|
-
<a />
|
|
65
57
|
</li>
|
|
66
58
|
</ul>
|
|
67
59
|
</div>
|
|
@@ -82,9 +74,6 @@ exports[`Breadcrumb component should render 1`] = `
|
|
|
82
74
|
<a
|
|
83
75
|
aria-label="Home"
|
|
84
76
|
href="/"
|
|
85
|
-
/>
|
|
86
|
-
<a
|
|
87
|
-
href="/"
|
|
88
77
|
>
|
|
89
78
|
Home
|
|
90
79
|
</a>
|
|
@@ -95,7 +84,6 @@ exports[`Breadcrumb component should render 1`] = `
|
|
|
95
84
|
<a
|
|
96
85
|
href="/Resolver"
|
|
97
86
|
/>
|
|
98
|
-
<a />
|
|
99
87
|
</li>
|
|
100
88
|
</ul>
|
|
101
89
|
</div>
|
|
@@ -6,6 +6,11 @@ import { act, render, fireEvent, waitFor } from '@testing-library/react';
|
|
|
6
6
|
import '@testing-library/jest-dom/extend-expect';
|
|
7
7
|
import Button from '../../../../src/components/Button';
|
|
8
8
|
|
|
9
|
+
jest.mock('react-cookie', () => ({
|
|
10
|
+
useCookies: jest.fn(() => [{ blazeCookie: 'blazeCookie' }, jest.fn(), jest.fn()]),
|
|
11
|
+
CookiesProvider: ({ children }) => children
|
|
12
|
+
}));
|
|
13
|
+
|
|
9
14
|
jest.mock('@blaze-cms/utils-handlebars', () => ({
|
|
10
15
|
useStringTemplate: jest.fn((parent, [title]) => ({ loadig: false, data: [title] }))
|
|
11
16
|
}));
|
|
@@ -33,9 +33,7 @@ const propsToDisplay = [
|
|
|
33
33
|
htmlAttribute: 'data-testid'
|
|
34
34
|
}
|
|
35
35
|
];
|
|
36
|
-
const getMockedParsedProp = children => {
|
|
37
|
-
children;
|
|
38
|
-
};
|
|
36
|
+
const getMockedParsedProp = children => React.createElement(React.Fragment, {}, ...children);
|
|
39
37
|
const firstPropValue = 'some description';
|
|
40
38
|
const secondPropValue = 'extra props';
|
|
41
39
|
const firstPropToDisplay = getMockedParsedProp(['', '', firstPropValue, '', '']);
|
|
@@ -77,7 +75,7 @@ const alternativeHeadline = 'Alternative headline';
|
|
|
77
75
|
jest.mock(
|
|
78
76
|
'../../../../../src/components/LazyImage',
|
|
79
77
|
() =>
|
|
80
|
-
function ({ src, alt }) {
|
|
78
|
+
function LazyImage({ src, alt }) {
|
|
81
79
|
return <img src={src} alt={alt} />;
|
|
82
80
|
}
|
|
83
81
|
);
|
|
@@ -28,7 +28,7 @@ exports[`Card component should not render alternative headline if alternativePre
|
|
|
28
28
|
<a
|
|
29
29
|
aria-label="category-name"
|
|
30
30
|
class="badge badge--label"
|
|
31
|
-
href="published-url"
|
|
31
|
+
href="/published-url"
|
|
32
32
|
>
|
|
33
33
|
category-name
|
|
34
34
|
</a>
|
|
@@ -38,9 +38,6 @@ exports[`Card component should not render alternative headline if alternativePre
|
|
|
38
38
|
<a
|
|
39
39
|
aria-label="mock name"
|
|
40
40
|
href="/mockurl"
|
|
41
|
-
/>
|
|
42
|
-
<a
|
|
43
|
-
href="/mockurl"
|
|
44
41
|
>
|
|
45
42
|
mock name
|
|
46
43
|
</a>
|
|
@@ -71,7 +68,7 @@ exports[`Card component should not render alternative headline if alternativePre
|
|
|
71
68
|
</div>
|
|
72
69
|
<div
|
|
73
70
|
class="child_2"
|
|
74
|
-
modifier="child-
|
|
71
|
+
data-modifier="child-modifier"
|
|
75
72
|
>
|
|
76
73
|
another child
|
|
77
74
|
</div>
|
|
@@ -112,9 +109,6 @@ exports[`Card component should not render alternative headline if displayCategor
|
|
|
112
109
|
<a
|
|
113
110
|
aria-label="mock name"
|
|
114
111
|
href="/mockurl"
|
|
115
|
-
/>
|
|
116
|
-
<a
|
|
117
|
-
href="/mockurl"
|
|
118
112
|
>
|
|
119
113
|
mock name
|
|
120
114
|
</a>
|
|
@@ -145,7 +139,7 @@ exports[`Card component should not render alternative headline if displayCategor
|
|
|
145
139
|
</div>
|
|
146
140
|
<div
|
|
147
141
|
class="child_2"
|
|
148
|
-
modifier="child-
|
|
142
|
+
data-modifier="child-modifier"
|
|
149
143
|
>
|
|
150
144
|
another child
|
|
151
145
|
</div>
|
|
@@ -183,7 +177,7 @@ exports[`Card component should not render preHeader if alternativeHeadline is no
|
|
|
183
177
|
<a
|
|
184
178
|
aria-label="category-name"
|
|
185
179
|
class="badge badge--label"
|
|
186
|
-
href="published-url"
|
|
180
|
+
href="/published-url"
|
|
187
181
|
>
|
|
188
182
|
category-name
|
|
189
183
|
</a>
|
|
@@ -193,9 +187,6 @@ exports[`Card component should not render preHeader if alternativeHeadline is no
|
|
|
193
187
|
<a
|
|
194
188
|
aria-label="mock name"
|
|
195
189
|
href="/mockurl"
|
|
196
|
-
/>
|
|
197
|
-
<a
|
|
198
|
-
href="/mockurl"
|
|
199
190
|
>
|
|
200
191
|
mock name
|
|
201
192
|
</a>
|
|
@@ -226,7 +217,7 @@ exports[`Card component should not render preHeader if alternativeHeadline is no
|
|
|
226
217
|
</div>
|
|
227
218
|
<div
|
|
228
219
|
class="child_2"
|
|
229
|
-
modifier="child-
|
|
220
|
+
data-modifier="child-modifier"
|
|
230
221
|
>
|
|
231
222
|
another child
|
|
232
223
|
</div>
|
|
@@ -272,9 +263,6 @@ exports[`Card component should render customPreheader and alternativeHeadline in
|
|
|
272
263
|
<a
|
|
273
264
|
aria-label="Alternative headline"
|
|
274
265
|
href="/mockurl"
|
|
275
|
-
/>
|
|
276
|
-
<a
|
|
277
|
-
href="/mockurl"
|
|
278
266
|
>
|
|
279
267
|
Alternative headline
|
|
280
268
|
</a>
|
|
@@ -305,7 +293,7 @@ exports[`Card component should render customPreheader and alternativeHeadline in
|
|
|
305
293
|
</div>
|
|
306
294
|
<div
|
|
307
295
|
class="child_2"
|
|
308
|
-
modifier="child-
|
|
296
|
+
data-modifier="child-modifier"
|
|
309
297
|
>
|
|
310
298
|
another child
|
|
311
299
|
</div>
|
|
@@ -388,7 +376,7 @@ exports[`Card component should render link wrapper 1`] = `
|
|
|
388
376
|
</div>
|
|
389
377
|
<div
|
|
390
378
|
class="child_2"
|
|
391
|
-
modifier="child-
|
|
379
|
+
data-modifier="child-modifier"
|
|
392
380
|
>
|
|
393
381
|
another child
|
|
394
382
|
</div>
|
|
@@ -426,7 +414,7 @@ exports[`Card component should render without throwing an error and match snapsh
|
|
|
426
414
|
<a
|
|
427
415
|
aria-label="category-name"
|
|
428
416
|
class="badge badge--label"
|
|
429
|
-
href="published-url"
|
|
417
|
+
href="/published-url"
|
|
430
418
|
>
|
|
431
419
|
category-name
|
|
432
420
|
</a>
|
|
@@ -436,9 +424,6 @@ exports[`Card component should render without throwing an error and match snapsh
|
|
|
436
424
|
<a
|
|
437
425
|
aria-label="mock name"
|
|
438
426
|
href="/mockurl"
|
|
439
|
-
/>
|
|
440
|
-
<a
|
|
441
|
-
href="/mockurl"
|
|
442
427
|
>
|
|
443
428
|
mock name
|
|
444
429
|
</a>
|
|
@@ -469,7 +454,7 @@ exports[`Card component should render without throwing an error and match snapsh
|
|
|
469
454
|
</div>
|
|
470
455
|
<div
|
|
471
456
|
class="child_2"
|
|
472
|
-
modifier="child-
|
|
457
|
+
data-modifier="child-modifier"
|
|
473
458
|
>
|
|
474
459
|
another child
|
|
475
460
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
2
|
|
|
3
3
|
exports[`CardsContainer component should render with carousel if option is enabled 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
@@ -43,9 +43,6 @@ exports[`CardsContainer component should render with carousel if option is enabl
|
|
|
43
43
|
<a
|
|
44
44
|
aria-label="Swan 78"
|
|
45
45
|
href="/nautors-swan/swan-78"
|
|
46
|
-
/>
|
|
47
|
-
<a
|
|
48
|
-
href="/nautors-swan/swan-78"
|
|
49
46
|
>
|
|
50
47
|
Swan 78
|
|
51
48
|
</a>
|
|
@@ -85,9 +82,6 @@ exports[`CardsContainer component should render with carousel if option is enabl
|
|
|
85
82
|
<a
|
|
86
83
|
aria-label="Swan 98"
|
|
87
84
|
href="/nautors-swan/swan-98"
|
|
88
|
-
/>
|
|
89
|
-
<a
|
|
90
|
-
href="/nautors-swan/swan-98"
|
|
91
85
|
>
|
|
92
86
|
Swan 98
|
|
93
87
|
</a>
|
|
@@ -141,9 +135,6 @@ exports[`CardsContainer component should render without throwing error and match
|
|
|
141
135
|
<a
|
|
142
136
|
aria-label="Swan 78"
|
|
143
137
|
href="/nautors-swan/swan-78"
|
|
144
|
-
/>
|
|
145
|
-
<a
|
|
146
|
-
href="/nautors-swan/swan-78"
|
|
147
138
|
>
|
|
148
139
|
Swan 78
|
|
149
140
|
</a>
|
|
@@ -183,9 +174,6 @@ exports[`CardsContainer component should render without throwing error and match
|
|
|
183
174
|
<a
|
|
184
175
|
aria-label="Swan 98"
|
|
185
176
|
href="/nautors-swan/swan-98"
|
|
186
|
-
/>
|
|
187
|
-
<a
|
|
188
|
-
href="/nautors-swan/swan-98"
|
|
189
177
|
>
|
|
190
178
|
Swan 98
|
|
191
179
|
</a>
|
|
@@ -96,7 +96,10 @@ describe('Carousel component', () => {
|
|
|
96
96
|
...MOCK_RELATION,
|
|
97
97
|
...mocks
|
|
98
98
|
]);
|
|
99
|
-
await waitFor(() =>
|
|
99
|
+
await waitFor(() => {
|
|
100
|
+
expect(container.childNodes.length).toBeGreaterThan(0);
|
|
101
|
+
expect(container.querySelectorAll('img').length).toBeGreaterThan(1);
|
|
102
|
+
});
|
|
100
103
|
expect(asFragment()).toMatchSnapshot();
|
|
101
104
|
});
|
|
102
105
|
|
|
@@ -8,9 +8,13 @@ import CarouselImage from '../../../../../../src/components/Carousel/CarouselIma
|
|
|
8
8
|
import getMockedProps from './helpers';
|
|
9
9
|
import mocks from './mocks';
|
|
10
10
|
|
|
11
|
-
jest.mock(
|
|
12
|
-
|
|
13
|
-
)
|
|
11
|
+
jest.mock(
|
|
12
|
+
'../../../../../../src/components/LazyImage',
|
|
13
|
+
() =>
|
|
14
|
+
function ({ alt, ...props }) {
|
|
15
|
+
return <img {...props} alt={alt} data-testid="lazy-image-mock" />;
|
|
16
|
+
}
|
|
17
|
+
);
|
|
14
18
|
|
|
15
19
|
const [MOCK_WITH_DATA, MOCK_WITH_ERROR] = mocks;
|
|
16
20
|
|
|
@@ -13,14 +13,23 @@ jest.mock('@blaze-cms/utils-handlebars', () => ({
|
|
|
13
13
|
useStringTemplate: jest.fn((_, [title]) => ({ loadig: false, data: [title] }))
|
|
14
14
|
}));
|
|
15
15
|
|
|
16
|
-
jest.mock('
|
|
17
|
-
|
|
18
|
-
useContext: () => ({ isPreview: false })
|
|
16
|
+
jest.mock('next/router', () => ({
|
|
17
|
+
useRouter: jest.fn(() => ({ asPath: '/' }))
|
|
19
18
|
}));
|
|
20
19
|
|
|
20
|
+
jest.mock('@blaze-cms/nextjs-components', () => {
|
|
21
|
+
// eslint-disable-next-line global-require, no-shadow
|
|
22
|
+
const React = require('react');
|
|
23
|
+
const MainContext = React.createContext({ isPreview: false });
|
|
24
|
+
return {
|
|
25
|
+
...jest.requireActual('@blaze-cms/nextjs-components'),
|
|
26
|
+
MainContext
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
21
30
|
const getMockedProps = overrides => ({
|
|
22
31
|
imageIds: ['test-id', 'test-altText', 'test-caption'],
|
|
23
|
-
|
|
32
|
+
shouldDisplayCount: true,
|
|
24
33
|
enableLightbox: true,
|
|
25
34
|
toggleModal: jest.fn(),
|
|
26
35
|
handleSelectedImage: jest.fn(),
|
|
@@ -28,11 +37,11 @@ const getMockedProps = overrides => ({
|
|
|
28
37
|
});
|
|
29
38
|
|
|
30
39
|
describe('CarouselRender component', () => {
|
|
31
|
-
const router = useRouter();
|
|
32
40
|
const mockedProps = getMockedProps();
|
|
33
41
|
|
|
34
42
|
it('should render one image button if there is one image to display', async () => {
|
|
35
|
-
const
|
|
43
|
+
const countMessage = '1 image';
|
|
44
|
+
const overrides = { imageIds: ['test-id'], countMessage };
|
|
36
45
|
const { getByText } = render(
|
|
37
46
|
<MockedRoot mocks={MOCK_BASIC}>
|
|
38
47
|
<CarouselRender {...mockedProps} {...overrides} />
|
|
@@ -40,12 +49,13 @@ describe('CarouselRender component', () => {
|
|
|
40
49
|
);
|
|
41
50
|
|
|
42
51
|
await waitFor(() => {
|
|
43
|
-
expect(getByText(
|
|
52
|
+
expect(getByText(countMessage)).toBeInTheDocument();
|
|
44
53
|
});
|
|
45
54
|
});
|
|
46
55
|
|
|
47
56
|
it('should render n images button if there is more than one image to display', async () => {
|
|
48
|
-
const
|
|
57
|
+
const countMessage = '2 images';
|
|
58
|
+
const overrides = { imageIds: ['test-id', 'test-id-2'], countMessage };
|
|
49
59
|
const { getByText } = render(
|
|
50
60
|
<MockedRoot mocks={MOCK_RELATION}>
|
|
51
61
|
<CarouselRender {...mockedProps} {...overrides} />
|
|
@@ -53,12 +63,12 @@ describe('CarouselRender component', () => {
|
|
|
53
63
|
);
|
|
54
64
|
|
|
55
65
|
await waitFor(() => {
|
|
56
|
-
expect(getByText(
|
|
66
|
+
expect(getByText(countMessage)).toBeInTheDocument();
|
|
57
67
|
});
|
|
58
68
|
});
|
|
59
69
|
|
|
60
70
|
it('should not render number count if display count is disabled', async () => {
|
|
61
|
-
const overrides = {
|
|
71
|
+
const overrides = { shouldDisplayCount: false };
|
|
62
72
|
const { asFragment, container } = render(
|
|
63
73
|
<MockedRoot mocks={MOCK_BASIC}>
|
|
64
74
|
<CarouselRender {...mockedProps} {...overrides} />
|
package/tests/unit/src/components/Carousel/CarouselRender/__snapshots__/CarouselRender.test.js.snap
CHANGED
|
@@ -7,6 +7,7 @@ exports[`CarouselRender component should not render number count if display coun
|
|
|
7
7
|
>
|
|
8
8
|
<div>
|
|
9
9
|
<div
|
|
10
|
+
aria-label="Previous Slide"
|
|
10
11
|
class="carousel__button carousel__button--previous"
|
|
11
12
|
role="button"
|
|
12
13
|
>
|
|
@@ -20,20 +21,21 @@ exports[`CarouselRender component should not render number count if display coun
|
|
|
20
21
|
<div
|
|
21
22
|
class="carousel__slide"
|
|
22
23
|
>
|
|
23
|
-
<
|
|
24
|
+
<span />
|
|
24
25
|
</div>
|
|
25
26
|
<div
|
|
26
27
|
class="carousel__slide"
|
|
27
28
|
>
|
|
28
|
-
<
|
|
29
|
+
<span />
|
|
29
30
|
</div>
|
|
30
31
|
<div
|
|
31
32
|
class="carousel__slide"
|
|
32
33
|
>
|
|
33
|
-
<
|
|
34
|
+
<span />
|
|
34
35
|
</div>
|
|
35
36
|
</div>
|
|
36
37
|
<div
|
|
38
|
+
aria-label="Next Slide"
|
|
37
39
|
class="carousel__button carousel__button--next"
|
|
38
40
|
role="button"
|
|
39
41
|
>
|
|
@@ -21,7 +21,7 @@ exports[`Carousel component should render carousel and match snapshot 1`] = `
|
|
|
21
21
|
<div
|
|
22
22
|
class="carousel__slide"
|
|
23
23
|
>
|
|
24
|
-
<
|
|
24
|
+
<span />
|
|
25
25
|
</div>
|
|
26
26
|
</div>
|
|
27
27
|
<div
|
|
@@ -64,12 +64,26 @@ exports[`Carousel component should render image fetching data from relation 1`]
|
|
|
64
64
|
<div
|
|
65
65
|
class="carousel__slide"
|
|
66
66
|
>
|
|
67
|
-
<span
|
|
67
|
+
<span>
|
|
68
|
+
<img
|
|
69
|
+
alt="Carousel image"
|
|
70
|
+
aria-label="View Image"
|
|
71
|
+
role="button"
|
|
72
|
+
src="test-url"
|
|
73
|
+
/>
|
|
74
|
+
</span>
|
|
68
75
|
</div>
|
|
69
76
|
<div
|
|
70
77
|
class="carousel__slide"
|
|
71
78
|
>
|
|
72
|
-
<span
|
|
79
|
+
<span>
|
|
80
|
+
<img
|
|
81
|
+
alt="Carousel image"
|
|
82
|
+
aria-label="View Image"
|
|
83
|
+
role="button"
|
|
84
|
+
src="test-url"
|
|
85
|
+
/>
|
|
86
|
+
</span>
|
|
73
87
|
</div>
|
|
74
88
|
</div>
|
|
75
89
|
<div
|
|
@@ -9,9 +9,13 @@ jest.mock('@blaze-cms/utils-handlebars', () => ({
|
|
|
9
9
|
useStringTemplate: jest.fn((parent, [title]) => ({ loadig: false, data: [title] }))
|
|
10
10
|
}));
|
|
11
11
|
|
|
12
|
-
jest.mock(
|
|
13
|
-
|
|
14
|
-
)
|
|
12
|
+
jest.mock(
|
|
13
|
+
'../../../../../src/components/Code/ScriptTag',
|
|
14
|
+
() =>
|
|
15
|
+
function () {
|
|
16
|
+
return <span data-testid="scriptTag" />;
|
|
17
|
+
}
|
|
18
|
+
);
|
|
15
19
|
|
|
16
20
|
const props = {
|
|
17
21
|
code: '<p>Lorem ipsum</p>',
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
2
|
|
|
3
3
|
exports[`EmailConfirm component should render children if token is in url and mutation is successfull 1`] = `<DocumentFragment />`;
|
|
4
4
|
|
|
5
5
|
exports[`EmailConfirm component should render with error if no token is in url 1`] = `
|
|
6
6
|
<DocumentFragment>
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
<div>
|
|
8
|
+
<span
|
|
9
|
+
class="error-modifier"
|
|
10
|
+
>
|
|
11
|
+
something went wrong
|
|
12
|
+
</span>
|
|
13
|
+
</div>
|
|
12
14
|
</DocumentFragment>
|
|
13
15
|
`;
|
|
@@ -103,11 +103,11 @@ describe('MenuRender component', () => {
|
|
|
103
103
|
const chevronIcon = container.querySelector('.menu--item--link--icon');
|
|
104
104
|
expect(chevronIcon).toBeInTheDocument();
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
fireEvent.click(chevronIcon);
|
|
107
107
|
childContainer = container.querySelector(`.${MENU_ITEM_CHILDREN_CLASS}`);
|
|
108
108
|
expect(childContainer).not.toHaveClass('hidden');
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
fireEvent.click(chevronIcon);
|
|
111
111
|
childContainer = container.querySelector(`.${MENU_ITEM_CHILDREN_CLASS}`);
|
|
112
112
|
expect(childContainer).toHaveClass('hidden');
|
|
113
113
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
2
|
|
|
3
3
|
exports[`MenuItem component should render a MenuItem based on passed parameters 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
@@ -39,7 +39,7 @@ exports[`MenuItem component should render a MenuItem based on passed parameters
|
|
|
39
39
|
>
|
|
40
40
|
<div
|
|
41
41
|
class="child_1"
|
|
42
|
-
component="
|
|
42
|
+
data-component="{\\"type\\":\\"menuitem\\"}"
|
|
43
43
|
>
|
|
44
44
|
menu child
|
|
45
45
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
2
|
|
|
3
3
|
exports[`TextBlock component With wrapper flag should render with wrapper and legacy class and modifier 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
@@ -14,9 +14,6 @@ exports[`TextBlock component With wrapper flag should render with wrapper and le
|
|
|
14
14
|
<a
|
|
15
15
|
aria-label="link"
|
|
16
16
|
href="/"
|
|
17
|
-
/>
|
|
18
|
-
<a
|
|
19
|
-
href="/"
|
|
20
17
|
>
|
|
21
18
|
link
|
|
22
19
|
</a>
|
|
@@ -40,9 +37,6 @@ exports[`TextBlock component With wrapper flag should render with wrapper and le
|
|
|
40
37
|
<a
|
|
41
38
|
aria-label="link"
|
|
42
39
|
href="/"
|
|
43
|
-
/>
|
|
44
|
-
<a
|
|
45
|
-
href="/"
|
|
46
40
|
>
|
|
47
41
|
link
|
|
48
42
|
</a>
|
|
@@ -66,9 +60,6 @@ exports[`TextBlock component should match snapshot 1`] = `
|
|
|
66
60
|
<a
|
|
67
61
|
aria-label="link"
|
|
68
62
|
href="/"
|
|
69
|
-
/>
|
|
70
|
-
<a
|
|
71
|
-
href="/"
|
|
72
63
|
>
|
|
73
64
|
link
|
|
74
65
|
</a>
|
|
@@ -89,9 +80,6 @@ exports[`TextBlock component should not render wrapper if no modifier 1`] = `
|
|
|
89
80
|
<a
|
|
90
81
|
aria-label="link"
|
|
91
82
|
href="/"
|
|
92
|
-
/>
|
|
93
|
-
<a
|
|
94
|
-
href="/"
|
|
95
83
|
>
|
|
96
84
|
link
|
|
97
85
|
</a>
|
|
@@ -9,7 +9,7 @@ const mockedArgs = [
|
|
|
9
9
|
[1, 5, 3, 5]
|
|
10
10
|
];
|
|
11
11
|
|
|
12
|
-
const mockedResults = [
|
|
12
|
+
const mockedResults = [3, 2, 0, 3, 5];
|
|
13
13
|
|
|
14
14
|
describe('get pagination index from url', () => {
|
|
15
15
|
const offsetWithAllParams = getCurrentOffset(...mockedArgs[0]);
|
|
@@ -32,7 +32,7 @@ describe('get pagination index from url', () => {
|
|
|
32
32
|
it('should return the current offset', () => {
|
|
33
33
|
expect(offsetWithAllParams).toEqual(mockedResults[0]);
|
|
34
34
|
expect(offsetWithNoDefaultOffset).toEqual(mockedResults[1]);
|
|
35
|
-
expect(offsetWithNoItemsPerPage).toEqual(mockedResults[
|
|
35
|
+
expect(offsetWithNoItemsPerPage).toEqual(mockedResults[2]);
|
|
36
36
|
expect(offsetWithNoPagination).toEqual(mockedResults[3]);
|
|
37
37
|
expect(offsetWithLimit).toEqual(mockedResults[4]);
|
|
38
38
|
});
|
|
@@ -42,7 +42,10 @@ describe('getCustomHtmlProperties function', () => {
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
it('should return an empty object when all entries are invalid', () => {
|
|
45
|
-
const customHtmlProps = [
|
|
45
|
+
const customHtmlProps = [
|
|
46
|
+
{ name: '', value: 'foo' },
|
|
47
|
+
{ name: 'bar', value: 'null' }
|
|
48
|
+
];
|
|
46
49
|
expect(getCustomHtmlProperties({ customHtmlProps })).toEqual({});
|
|
47
50
|
});
|
|
48
51
|
});
|
|
@@ -14,9 +14,7 @@ describe('Parse textBlock', () => {
|
|
|
14
14
|
|
|
15
15
|
beforeAll(() => {
|
|
16
16
|
const parsedTextBlock = parseTextBlock({ html, LinkWrapper: BlazeLink });
|
|
17
|
-
expectedMarkup = () =>
|
|
18
|
-
parsedTextBlock;
|
|
19
|
-
};
|
|
17
|
+
expectedMarkup = () => parsedTextBlock;
|
|
20
18
|
});
|
|
21
19
|
|
|
22
20
|
test('it should match snapshot', () => {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @jest-environment jsdom
|
|
3
3
|
*/
|
|
4
|
-
import { renderHook } from '@testing-library/react';
|
|
4
|
+
import { renderHook, waitFor, act } from '@testing-library/react';
|
|
5
5
|
import { useCheckMobileScreen } from '../../../../src/hooks';
|
|
6
6
|
// TODO fix breaking test
|
|
7
7
|
describe('Check Mobile Screen hook', () => {
|
|
8
8
|
it('should server render will always be mobile', () => {
|
|
9
|
-
|
|
10
|
-
global.dispatchEvent(new Event('resize'));
|
|
9
|
+
delete window.innerWidth;
|
|
11
10
|
const { result } = renderHook(() => useCheckMobileScreen());
|
|
12
11
|
expect(result.current).toBe(true);
|
|
13
12
|
});
|
|
@@ -17,25 +16,32 @@ describe('Check Mobile Screen hook', () => {
|
|
|
17
16
|
expect(result.current).toBe(true);
|
|
18
17
|
});
|
|
19
18
|
|
|
20
|
-
it('should return false if on desktop', () => {
|
|
19
|
+
it('should return false if on desktop', async () => {
|
|
21
20
|
const screenSize = 1080;
|
|
22
21
|
const isMobile = false;
|
|
23
|
-
resizeCheck(screenSize, isMobile);
|
|
22
|
+
await resizeCheck(screenSize, isMobile);
|
|
24
23
|
});
|
|
25
24
|
|
|
26
|
-
it('should return true if on mobile', () => {
|
|
25
|
+
it('should return true if on mobile', async () => {
|
|
27
26
|
const screenSize = 600;
|
|
28
27
|
const isMobile = true;
|
|
29
|
-
resizeCheck(screenSize, isMobile);
|
|
28
|
+
await resizeCheck(screenSize, isMobile);
|
|
30
29
|
});
|
|
31
30
|
});
|
|
32
31
|
|
|
33
|
-
function resizeCheck(screenSize, isMobile) {
|
|
32
|
+
async function resizeCheck(screenSize, isMobile) {
|
|
34
33
|
const { result, rerender } = renderHook(() => useCheckMobileScreen());
|
|
35
|
-
rerender();
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
act(() => {
|
|
36
|
+
Object.defineProperty(window, 'innerWidth', {
|
|
37
|
+
writable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
value: screenSize
|
|
40
|
+
});
|
|
41
|
+
window.dispatchEvent(new Event('resize'));
|
|
42
|
+
});
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
await waitFor(() => {
|
|
45
|
+
expect(result.current).toBe(isMobile);
|
|
46
|
+
});
|
|
41
47
|
}
|