@blaze-cms/react-page-builder 0.147.0-rc-eagle.4 → 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/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/helpers/get-component-id.js +9 -3
- package/lib-es/helpers/get-component-id.js.map +1 -1
- package/package.json +6 -6
- 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/helpers/get-component-id.js +7 -4
|
@@ -13,10 +13,11 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
13
13
|
var _constants = require("./constants");
|
|
14
14
|
var _ContentGroupTabs = _interopRequireDefault(require("./ContentGroupTabs"));
|
|
15
15
|
var _ContentGroupAccordion = _interopRequireDefault(require("./ContentGroupAccordion"));
|
|
16
|
+
var _ContentGroupDataFetcher = _interopRequireDefault(require("./ContentGroupDataFetcher"));
|
|
16
17
|
var _helpers = require("./helpers");
|
|
17
18
|
var _getStructuredDataProperties = _interopRequireDefault(require("./helpers/get-structured-data-properties"));
|
|
18
19
|
var _helpers2 = require("../../helpers");
|
|
19
|
-
const _excluded = ["contentType", "isFaqContent", "children", "customHtmlProps"],
|
|
20
|
+
const _excluded = ["contentType", "isFaqContent", "children", "customHtmlProps", "simpleData", "dataProperty"],
|
|
20
21
|
_excluded2 = ["topWrapperProps"];
|
|
21
22
|
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); }
|
|
22
23
|
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; }
|
|
@@ -28,10 +29,15 @@ const ContentGroup = _ref => {
|
|
|
28
29
|
contentType,
|
|
29
30
|
isFaqContent,
|
|
30
31
|
children,
|
|
31
|
-
customHtmlProps
|
|
32
|
+
customHtmlProps,
|
|
33
|
+
simpleData,
|
|
34
|
+
dataProperty
|
|
32
35
|
} = _ref,
|
|
33
36
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
34
|
-
const
|
|
37
|
+
const hasSimpleData = Array.isArray(simpleData) && simpleData.length > 0;
|
|
38
|
+
const dataPropertyName = Array.isArray(dataProperty) ? dataProperty[0] : dataProperty;
|
|
39
|
+
const hasDataProperty = !!dataPropertyName;
|
|
40
|
+
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];
|
|
35
41
|
const GroupComponent = (0, _react.useMemo)(() => contentType === _constants.CONTENT_GROUP_TYPES.ACCORDION ? _ContentGroupAccordion.default : _ContentGroupTabs.default, [contentType]);
|
|
36
42
|
const WrapperComponent = (0, _react.useMemo)(() => !isFaqContent ? _react.Fragment : 'div', [isFaqContent]);
|
|
37
43
|
const _useMemo = (0, _react.useMemo)(() => {
|
|
@@ -46,8 +52,26 @@ const ContentGroup = _ref => {
|
|
|
46
52
|
topWrapperProps
|
|
47
53
|
} = _useMemo,
|
|
48
54
|
schemaProperties = (0, _objectWithoutProperties2.default)(_useMemo, _excluded2);
|
|
49
|
-
if (!
|
|
50
|
-
|
|
55
|
+
if (!VALID_TYPES.includes(contentType)) return '';
|
|
56
|
+
if (!hasSimpleData && hasDataProperty) {
|
|
57
|
+
return /*#__PURE__*/_react.default.createElement(WrapperComponent, topWrapperProps, /*#__PURE__*/_react.default.createElement(_ContentGroupDataFetcher.default, (0, _extends2.default)({
|
|
58
|
+
dataProperty: dataPropertyName,
|
|
59
|
+
contentType: contentType
|
|
60
|
+
}, props, schemaProperties)));
|
|
61
|
+
}
|
|
62
|
+
let groupSections;
|
|
63
|
+
let sectionsData;
|
|
64
|
+
if (hasSimpleData) {
|
|
65
|
+
({
|
|
66
|
+
groupSections,
|
|
67
|
+
sectionsData
|
|
68
|
+
} = (0, _helpers.buildDataSections)(simpleData));
|
|
69
|
+
} else {
|
|
70
|
+
groupSections = childGroupSections;
|
|
71
|
+
if (!groupSections || !groupSections.length) return '';
|
|
72
|
+
sectionsData = (0, _helpers.getSectionsData)(groupSections);
|
|
73
|
+
}
|
|
74
|
+
if (!groupSections || !groupSections.length) return '';
|
|
51
75
|
return /*#__PURE__*/_react.default.createElement(WrapperComponent, topWrapperProps, /*#__PURE__*/_react.default.createElement(GroupComponent, (0, _extends2.default)({
|
|
52
76
|
contentType: contentType,
|
|
53
77
|
groupSections: groupSections,
|
|
@@ -55,17 +79,25 @@ const ContentGroup = _ref => {
|
|
|
55
79
|
}, props, schemaProperties)));
|
|
56
80
|
};
|
|
57
81
|
ContentGroup.propTypes = {
|
|
58
|
-
children: _propTypes.default.object
|
|
82
|
+
children: _propTypes.default.object,
|
|
59
83
|
contentType: _propTypes.default.oneOf(VALID_TYPES).isRequired,
|
|
60
84
|
isFaqContent: _propTypes.default.bool,
|
|
61
85
|
customHtmlProps: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
62
86
|
name: _propTypes.default.string,
|
|
63
87
|
value: _propTypes.default.string
|
|
64
|
-
}))
|
|
88
|
+
})),
|
|
89
|
+
simpleData: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
90
|
+
label: _propTypes.default.string,
|
|
91
|
+
text: _propTypes.default.string
|
|
92
|
+
})),
|
|
93
|
+
dataProperty: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)])
|
|
65
94
|
};
|
|
66
95
|
ContentGroup.defaultProps = {
|
|
96
|
+
children: null,
|
|
67
97
|
isFaqContent: false,
|
|
68
|
-
customHtmlProps: []
|
|
98
|
+
customHtmlProps: [],
|
|
99
|
+
simpleData: null,
|
|
100
|
+
dataProperty: null
|
|
69
101
|
};
|
|
70
102
|
var _default = exports.default = ContentGroup;
|
|
71
103
|
//# sourceMappingURL=ContentGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentGroup.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_constants","_ContentGroupTabs","_ContentGroupAccordion","_helpers","_getStructuredDataProperties","_helpers2","_excluded","_excluded2","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","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;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IACb8B,WAAW,EAAEA,WAAY;IACzBM,aAAa,EAAEA,aAAc;IAC7Be,YAAY,EAAEA;EAAa,GACvBjB,KAAK,EACLe,gBAAgB,CACrB,CACe,CAAC;AAEvB,CAAC;AAEDvB,YAAY,CAAC6B,SAAS,GAAG;EACvBvB,QAAQ,EAAEwB,kBAAS,CAACC,MAAM,CAACC,UAAU;EACrC5B,WAAW,EAAE0B,kBAAS,CAACG,KAAK,CAACpC,WAAW,CAAC,CAACmC,UAAU;EACpD3B,YAAY,EAAEyB,kBAAS,CAACI,IAAI;EAC5B3B,eAAe,EAAEuB,kBAAS,CAACK,OAAO,CAChCL,kBAAS,CAACM,KAAK,CAAC;IACdC,IAAI,EAAEP,kBAAS,CAACQ,MAAM;IACtBC,KAAK,EAAET,kBAAS,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,CAAApE,OAAA,GAEa0B,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ContentGroup.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_constants","_ContentGroupTabs","_ContentGroupAccordion","_ContentGroupDataFetcher","_helpers","_getStructuredDataProperties","_helpers2","_excluded","_excluded2","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","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","simpleData","dataProperty","props","_objectWithoutProperties2","hasSimpleData","Array","isArray","dataPropertyName","hasDataProperty","childGroupSections","GroupComponent","useMemo","ACCORDION","ContentGroupAccordion","ContentGroupTabs","WrapperComponent","Fragment","_useMemo","structuredDataProperties","getStructuredDataProperties","topWrapperProps","getCustomHtmlProperties","schemaProperties","includes","createElement","_extends2","groupSections","sectionsData","buildDataSections","getSectionsData","propTypes","PropTypes","object","oneOf","isRequired","bool","arrayOf","shape","name","string","value","label","text","oneOfType","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 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,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,wBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,4BAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAAwD,MAAAU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C;IACdC,IAAI,EAAEP,kBAAS,CAACQ,MAAM;IACtBC,KAAK,EAAET,kBAAS,CAACQ;EACnB,CAAC,CACH,CAAC;EACDvC,UAAU,EAAE+B,kBAAS,CAACK,OAAO,CAC3BL,kBAAS,CAACM,KAAK,CAAC;IACdI,KAAK,EAAEV,kBAAS,CAACQ,MAAM;IACvBG,IAAI,EAAEX,kBAAS,CAACQ;EAClB,CAAC,CACH,CAAC;EACDtC,YAAY,EAAE8B,kBAAS,CAACY,SAAS,CAAC,CAACZ,kBAAS,CAACQ,MAAM,EAAER,kBAAS,CAACK,OAAO,CAACL,kBAAS,CAACQ,MAAM,CAAC,CAAC;AAC3F,CAAC;AAED/C,YAAY,CAACoD,YAAY,GAAG;EAC1B9C,QAAQ,EAAE,IAAI;EACdD,YAAY,EAAE,KAAK;EACnBE,eAAe,EAAE,EAAE;EACnBC,UAAU,EAAE,IAAI;EAChBC,YAAY,EAAE;AAChB,CAAC;AAAC,IAAA4C,QAAA,GAAAC,OAAA,CAAAhF,OAAA,GAEa0B,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,96 @@
|
|
|
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 _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var _client = require("@apollo/client");
|
|
13
|
+
var _nextjsComponents = require("@blaze-cms/nextjs-components");
|
|
14
|
+
var _query = require("../../application/query");
|
|
15
|
+
var _ContentGroupTabs = _interopRequireDefault(require("./ContentGroupTabs"));
|
|
16
|
+
var _ContentGroupAccordion = _interopRequireDefault(require("./ContentGroupAccordion"));
|
|
17
|
+
var _helpers = require("./helpers");
|
|
18
|
+
var _constants = require("./constants");
|
|
19
|
+
const _excluded = ["dataProperty", "parent", "contentType"];
|
|
20
|
+
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); }
|
|
21
|
+
const PLACEHOLDER_QUERY = (0, _client.gql)`
|
|
22
|
+
query {
|
|
23
|
+
__typename
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
const ContentGroupDataFetcher = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
dataProperty,
|
|
29
|
+
parent,
|
|
30
|
+
contentType
|
|
31
|
+
} = _ref,
|
|
32
|
+
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
33
|
+
const {
|
|
34
|
+
isPreview
|
|
35
|
+
} = (0, _react.useContext)(_nextjsComponents.MainContext);
|
|
36
|
+
const dataPropertyName = Array.isArray(dataProperty) ? dataProperty[0] : dataProperty;
|
|
37
|
+
const {
|
|
38
|
+
data: schemaData,
|
|
39
|
+
loading: schemaLoading
|
|
40
|
+
} = (0, _client.useQuery)(_query.getSingleEntitySchema, {
|
|
41
|
+
variables: {
|
|
42
|
+
id: parent === null || parent === void 0 ? void 0 : parent.itemEntity
|
|
43
|
+
},
|
|
44
|
+
skip: !(parent === null || parent === void 0 ? void 0 : parent.itemEntity) || !dataPropertyName
|
|
45
|
+
});
|
|
46
|
+
const dataQuery = (0, _react.useMemo)(() => {
|
|
47
|
+
if (!schemaData) return null;
|
|
48
|
+
const {
|
|
49
|
+
getEntitySchema
|
|
50
|
+
} = schemaData;
|
|
51
|
+
const {
|
|
52
|
+
actions: {
|
|
53
|
+
getPublished,
|
|
54
|
+
get
|
|
55
|
+
} = {}
|
|
56
|
+
} = getEntitySchema;
|
|
57
|
+
const actionKey = isPreview ? get : getPublished || get;
|
|
58
|
+
if (!actionKey) return null;
|
|
59
|
+
return (0, _query.generateSingleItemQuery)(actionKey, `${dataPropertyName} { label text }`);
|
|
60
|
+
}, [schemaData, isPreview, dataPropertyName]);
|
|
61
|
+
const {
|
|
62
|
+
data: recordData,
|
|
63
|
+
loading: recordLoading
|
|
64
|
+
} = (0, _client.useQuery)(dataQuery || PLACEHOLDER_QUERY, {
|
|
65
|
+
variables: {
|
|
66
|
+
id: parent === null || parent === void 0 ? void 0 : parent.itemId
|
|
67
|
+
},
|
|
68
|
+
skip: !dataQuery || !(parent === null || parent === void 0 ? void 0 : parent.itemId)
|
|
69
|
+
});
|
|
70
|
+
if (schemaLoading || recordLoading) return '';
|
|
71
|
+
if (!(recordData === null || recordData === void 0 ? void 0 : recordData.entityData)) return null;
|
|
72
|
+
const propertyData = recordData.entityData[dataPropertyName];
|
|
73
|
+
if (!propertyData || !propertyData.length) return null;
|
|
74
|
+
const {
|
|
75
|
+
groupSections,
|
|
76
|
+
sectionsData
|
|
77
|
+
} = (0, _helpers.buildDataSections)(propertyData);
|
|
78
|
+
if (!groupSections.length) return null;
|
|
79
|
+
const GroupComponent = contentType === _constants.CONTENT_GROUP_TYPES.ACCORDION ? _ContentGroupAccordion.default : _ContentGroupTabs.default;
|
|
80
|
+
return /*#__PURE__*/_react.default.createElement(GroupComponent, (0, _extends2.default)({
|
|
81
|
+
contentType: contentType,
|
|
82
|
+
groupSections: groupSections,
|
|
83
|
+
sectionsData: sectionsData
|
|
84
|
+
}, props));
|
|
85
|
+
};
|
|
86
|
+
ContentGroupDataFetcher.propTypes = {
|
|
87
|
+
dataProperty: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
88
|
+
parent: _propTypes.default.object,
|
|
89
|
+
contentType: _propTypes.default.string.isRequired
|
|
90
|
+
};
|
|
91
|
+
ContentGroupDataFetcher.defaultProps = {
|
|
92
|
+
dataProperty: null,
|
|
93
|
+
parent: null
|
|
94
|
+
};
|
|
95
|
+
var _default = exports.default = ContentGroupDataFetcher;
|
|
96
|
+
//# sourceMappingURL=ContentGroupDataFetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentGroupDataFetcher.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_client","_nextjsComponents","_query","_ContentGroupTabs","_ContentGroupAccordion","_helpers","_constants","_excluded","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","PLACEHOLDER_QUERY","gql","ContentGroupDataFetcher","_ref","dataProperty","parent","contentType","props","_objectWithoutProperties2","isPreview","useContext","MainContext","dataPropertyName","Array","isArray","data","schemaData","loading","schemaLoading","useQuery","getSingleEntitySchema","variables","id","itemEntity","skip","dataQuery","useMemo","getEntitySchema","actions","getPublished","actionKey","generateSingleItemQuery","recordData","recordLoading","itemId","entityData","propertyData","length","groupSections","sectionsData","buildDataSections","GroupComponent","CONTENT_GROUP_TYPES","ACCORDION","ContentGroupAccordion","ContentGroupTabs","createElement","_extends2","propTypes","PropTypes","oneOfType","string","arrayOf","object","isRequired","defaultProps","_default","exports"],"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,IAAAA,MAAA,GAAAC,uBAAA,C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,CAACE,MAAM,EAAEF,kBAAS,CAACG,OAAO,CAACH,kBAAS,CAACE,MAAM,CAAC,CAAC,CAAC;EAC1F9C,MAAM,EAAE4C,kBAAS,CAACI,MAAM;EACxB/C,WAAW,EAAE2C,kBAAS,CAACE,MAAM,CAACG;AAChC,CAAC;AAEDpD,uBAAuB,CAACqD,YAAY,GAAG;EACrCnD,YAAY,EAAE,IAAI;EAClBC,MAAM,EAAE;AACV,CAAC;AAAC,IAAAmD,QAAA,GAAAC,OAAA,CAAAlE,OAAA,GAEaW,uBAAuB","ignoreList":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
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 _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _dynamic = _interopRequireDefault(require("next/dynamic"));
|
|
10
|
+
var _getComponentId = _interopRequireDefault(require("../../../helpers/get-component-id"));
|
|
11
|
+
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); }
|
|
12
|
+
const TextBlock = (0, _dynamic.default)(() => Promise.resolve().then(() => _interopRequireWildcard(require('../../TextBlock'))));
|
|
13
|
+
const ContentGroupSection = (0, _dynamic.default)(() => Promise.resolve().then(() => _interopRequireWildcard(require('../../ContentGroupSection'))));
|
|
14
|
+
const buildDataSections = (items = []) => {
|
|
15
|
+
const itemData = items.map((item, i) => {
|
|
16
|
+
if (!item || !item.text || !item.label) return null;
|
|
17
|
+
const sectionName = (0, _getComponentId.default)(item.label || `section-${i}`, true, true);
|
|
18
|
+
return {
|
|
19
|
+
sectionName,
|
|
20
|
+
label: item.label,
|
|
21
|
+
sectionContent: /*#__PURE__*/_react.default.createElement(ContentGroupSection, {
|
|
22
|
+
key: sectionName,
|
|
23
|
+
name: sectionName,
|
|
24
|
+
disableChildCheck: true
|
|
25
|
+
}, /*#__PURE__*/_react.default.createElement(TextBlock, {
|
|
26
|
+
html: item.text,
|
|
27
|
+
name: `${sectionName}-text`
|
|
28
|
+
}))
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
return itemData.filter(Boolean).reduce((acc, {
|
|
32
|
+
sectionName,
|
|
33
|
+
label,
|
|
34
|
+
sectionContent
|
|
35
|
+
}) => {
|
|
36
|
+
if (!sectionName || !sectionContent) return acc;
|
|
37
|
+
acc.groupSections.push(sectionContent);
|
|
38
|
+
acc.sectionsData.push([sectionName, label]);
|
|
39
|
+
return acc;
|
|
40
|
+
}, {
|
|
41
|
+
groupSections: [],
|
|
42
|
+
sectionsData: []
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var _default = exports.default = buildDataSections;
|
|
46
|
+
//# sourceMappingURL=build-data-sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-data-sections.js","names":["_react","_interopRequireDefault","require","_dynamic","_getComponentId","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","TextBlock","dynamic","Promise","resolve","then","ContentGroupSection","buildDataSections","items","itemData","map","item","text","label","sectionName","getComponentId","sectionContent","createElement","key","name","disableChildCheck","html","filter","Boolean","reduce","acc","groupSections","push","sectionsData","_default","exports"],"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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,eAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA+D,SAAAG,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,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,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,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ACX,mBAAmB;QAACY,GAAG,EAAEJ,WAAY;QAACK,IAAI,EAAEL,WAAY;QAACM,iBAAiB;MAAA,gBACzE5C,MAAA,CAAAgB,OAAA,CAAAyB,aAAA,CAAChB,SAAS;QAACoB,IAAI,EAAEV,IAAI,CAACC,IAAK;QAACO,IAAI,EAAE,GAAGL,WAAW;MAAQ,CAAE,CACvC;IAEzB,CAAC;EACH,CAAC,CAAC;EAEF,OAAOL,QAAQ,CAACa,MAAM,CAACC,OAAO,CAAC,CAACC,MAAM,CACpC,CAACC,GAAG,EAAE;IAAEX,WAAW;IAAED,KAAK;IAAEG;EAAe,CAAC,KAAK;IAC/C,IAAI,CAACF,WAAW,IAAI,CAACE,cAAc,EAAE,OAAOS,GAAG;IAC/CA,GAAG,CAACC,aAAa,CAACC,IAAI,CAACX,cAAc,CAAC;IACtCS,GAAG,CAACG,YAAY,CAACD,IAAI,CAAC,CAACb,WAAW,EAAED,KAAK,CAAC,CAAC;IAC3C,OAAOY,GAAG;EACZ,CAAC,EACD;IAAEC,aAAa,EAAE,EAAE;IAAEE,YAAY,EAAE;EAAG,CACxC,CAAC;AACH,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAtC,OAAA,GAEae,iBAAiB","ignoreList":[]}
|
|
@@ -4,6 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
Object.defineProperty(exports, "buildDataSections", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _buildDataSections.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
7
13
|
Object.defineProperty(exports, "getActiveTab", {
|
|
8
14
|
enumerable: true,
|
|
9
15
|
get: function () {
|
|
@@ -18,4 +24,5 @@ Object.defineProperty(exports, "getSectionsData", {
|
|
|
18
24
|
});
|
|
19
25
|
var _getSectionsData = _interopRequireDefault(require("./get-sections-data"));
|
|
20
26
|
var _getActiveTab = _interopRequireDefault(require("./get-active-tab"));
|
|
27
|
+
var _buildDataSections = _interopRequireDefault(require("./build-data-sections"));
|
|
21
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_getSectionsData","_interopRequireDefault","require","_getActiveTab"],"sources":["../../../../src/components/ContentGroup/helpers/index.js"],"sourcesContent":["import getSectionsData from './get-sections-data';\nimport getActiveTab from './get-active-tab';\n\nexport { getSectionsData, getActiveTab };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_getSectionsData","_interopRequireDefault","require","_getActiveTab","_buildDataSections"],"sources":["../../../../src/components/ContentGroup/helpers/index.js"],"sourcesContent":["import getSectionsData from './get-sections-data';\nimport getActiveTab from './get-active-tab';\nimport buildDataSections from './build-data-sections';\n\nexport { getSectionsData, getActiveTab, buildDataSections };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,kBAAA,GAAAH,sBAAA,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -10,9 +10,10 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
10
10
|
var _helpers = require("../../helpers");
|
|
11
11
|
const ContentGroupSection = ({
|
|
12
12
|
children,
|
|
13
|
-
name
|
|
13
|
+
name,
|
|
14
|
+
disableChildCheck
|
|
14
15
|
}) => {
|
|
15
|
-
if (!(0, _helpers.hasChildren)(children)) return null;
|
|
16
|
+
if (!disableChildCheck && !(0, _helpers.hasChildren)(children)) return null;
|
|
16
17
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
17
18
|
key: name,
|
|
18
19
|
className: "content-group-section"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentGroupSection.js","names":["_react","_interopRequireDefault","require","_propTypes","_helpers","ContentGroupSection","children","name","hasChildren","default","createElement","key","className","propTypes","PropTypes","oneOfType","arrayOf","node","string","defaultProps","_default","exports"],"sources":["../../../src/components/ContentGroupSection/ContentGroupSection.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { hasChildren } from '../../helpers';\n\nconst ContentGroupSection = ({ children, name }) => {\n if (!hasChildren(children)) return null;\n\n return (\n <div key={name} className=\"content-group-section\">\n {children}\n </div>\n );\n};\n\nContentGroupSection.propTypes = {\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),\n name: PropTypes.string\n};\n\nContentGroupSection.defaultProps = { children: null, name: '' };\n\nexport default ContentGroupSection;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,MAAMG,mBAAmB,GAAGA,CAAC;EAAEC,QAAQ;EAAEC;
|
|
1
|
+
{"version":3,"file":"ContentGroupSection.js","names":["_react","_interopRequireDefault","require","_propTypes","_helpers","ContentGroupSection","children","name","disableChildCheck","hasChildren","default","createElement","key","className","propTypes","PropTypes","oneOfType","arrayOf","node","string","defaultProps","_default","exports"],"sources":["../../../src/components/ContentGroupSection/ContentGroupSection.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { hasChildren } from '../../helpers';\n\nconst ContentGroupSection = ({ children, name, disableChildCheck }) => {\n if (!disableChildCheck && !hasChildren(children)) return null;\n\n return (\n <div key={name} className=\"content-group-section\">\n {children}\n </div>\n );\n};\n\nContentGroupSection.propTypes = {\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),\n name: PropTypes.string\n};\n\nContentGroupSection.defaultProps = { children: null, name: '' };\n\nexport default ContentGroupSection;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,MAAMG,mBAAmB,GAAGA,CAAC;EAAEC,QAAQ;EAAEC,IAAI;EAAEC;AAAkB,CAAC,KAAK;EACrE,IAAI,CAACA,iBAAiB,IAAI,CAAC,IAAAC,oBAAW,EAACH,QAAQ,CAAC,EAAE,OAAO,IAAI;EAE7D,oBACEN,MAAA,CAAAU,OAAA,CAAAC,aAAA;IAAKC,GAAG,EAAEL,IAAK;IAACM,SAAS,EAAC;EAAuB,GAC9CP,QACE,CAAC;AAEV,CAAC;AAEDD,mBAAmB,CAACS,SAAS,GAAG;EAC9BR,QAAQ,EAAES,kBAAS,CAACC,SAAS,CAAC,CAACD,kBAAS,CAACE,OAAO,CAACF,kBAAS,CAACG,IAAI,CAAC,EAAEH,kBAAS,CAACG,IAAI,CAAC,CAAC;EAClFX,IAAI,EAAEQ,kBAAS,CAACI;AAClB,CAAC;AAEDd,mBAAmB,CAACe,YAAY,GAAG;EAAEd,QAAQ,EAAE,IAAI;EAAEC,IAAI,EAAE;AAAG,CAAC;AAAC,IAAAc,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GAEjDL,mBAAmB","ignoreList":[]}
|
|
@@ -8,15 +8,22 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _iframeResizerReact = _interopRequireDefault(require("iframe-resizer-react"));
|
|
11
|
+
var _utilsHandlebars = require("@blaze-cms/utils-handlebars");
|
|
11
12
|
var _constants = require("./constants");
|
|
13
|
+
const UNSAFE_URL_PATTERN = /^(javascript|data):/i;
|
|
14
|
+
const isSafeUrl = url => !UNSAFE_URL_PATTERN.test(url.trim());
|
|
12
15
|
const Iframe = ({
|
|
13
16
|
src,
|
|
14
17
|
modifier,
|
|
15
18
|
width,
|
|
16
19
|
height,
|
|
17
|
-
enableScrolling
|
|
20
|
+
enableScrolling,
|
|
21
|
+
parent
|
|
18
22
|
}) => {
|
|
19
|
-
|
|
23
|
+
const {
|
|
24
|
+
data: [resolvedSrc]
|
|
25
|
+
} = (0, _utilsHandlebars.useStringTemplate)(parent, [src || '']);
|
|
26
|
+
if (!resolvedSrc || !isSafeUrl(resolvedSrc)) return null;
|
|
20
27
|
const modifierString = modifier ? ` ${modifier}` : '';
|
|
21
28
|
const iframeClassName = `${_constants.IFRAME_CLASS}${modifierString}`;
|
|
22
29
|
const defaultWidth = !width ? _constants.DEFAULT_WIDTH : {};
|
|
@@ -25,7 +32,7 @@ const Iframe = ({
|
|
|
25
32
|
}, /*#__PURE__*/_react.default.createElement(_iframeResizerReact.default, {
|
|
26
33
|
scrolling: enableScrolling,
|
|
27
34
|
autoResize: true,
|
|
28
|
-
src:
|
|
35
|
+
src: resolvedSrc,
|
|
29
36
|
sizeHeight: !height,
|
|
30
37
|
height: height,
|
|
31
38
|
width: width,
|
|
@@ -33,17 +40,20 @@ const Iframe = ({
|
|
|
33
40
|
}));
|
|
34
41
|
};
|
|
35
42
|
Iframe.propTypes = {
|
|
36
|
-
src: _propTypes.default.string
|
|
43
|
+
src: _propTypes.default.string,
|
|
37
44
|
enableScrolling: _propTypes.default.bool,
|
|
38
45
|
modifier: _propTypes.default.string,
|
|
39
46
|
width: _propTypes.default.string,
|
|
40
|
-
height: _propTypes.default.string
|
|
47
|
+
height: _propTypes.default.string,
|
|
48
|
+
parent: _propTypes.default.object
|
|
41
49
|
};
|
|
42
50
|
Iframe.defaultProps = {
|
|
51
|
+
src: '',
|
|
43
52
|
enableScrolling: false,
|
|
44
53
|
modifier: '',
|
|
45
54
|
width: '',
|
|
46
|
-
height: ''
|
|
55
|
+
height: '',
|
|
56
|
+
parent: {}
|
|
47
57
|
};
|
|
48
58
|
var _default = exports.default = Iframe;
|
|
49
59
|
//# sourceMappingURL=Iframe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Iframe.js","names":["_react","_interopRequireDefault","require","_propTypes","_iframeResizerReact","_constants","Iframe","src","modifier","width","height","enableScrolling","modifierString","iframeClassName","IFRAME_CLASS","defaultWidth","DEFAULT_WIDTH","default","createElement","className","scrolling","autoResize","sizeHeight","style","propTypes","PropTypes","string","
|
|
1
|
+
{"version":3,"file":"Iframe.js","names":["_react","_interopRequireDefault","require","_propTypes","_iframeResizerReact","_utilsHandlebars","_constants","UNSAFE_URL_PATTERN","isSafeUrl","url","test","trim","Iframe","src","modifier","width","height","enableScrolling","parent","data","resolvedSrc","useStringTemplate","modifierString","iframeClassName","IFRAME_CLASS","defaultWidth","DEFAULT_WIDTH","default","createElement","className","scrolling","autoResize","sizeHeight","style","propTypes","PropTypes","string","bool","object","defaultProps","_default","exports"],"sources":["../../../src/components/Iframe/Iframe.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport IframeResizer from 'iframe-resizer-react';\nimport { useStringTemplate } from '@blaze-cms/utils-handlebars';\nimport { IFRAME_CLASS, DEFAULT_WIDTH } from './constants';\n\nconst UNSAFE_URL_PATTERN = /^(javascript|data):/i;\n\nconst isSafeUrl = url => !UNSAFE_URL_PATTERN.test(url.trim());\n\nconst Iframe = ({ src, modifier, width, height, enableScrolling, parent }) => {\n const {\n data: [resolvedSrc]\n } = useStringTemplate(parent, [src || '']);\n if (!resolvedSrc || !isSafeUrl(resolvedSrc)) return null;\n const modifierString = modifier ? ` ${modifier}` : '';\n const iframeClassName = `${IFRAME_CLASS}${modifierString}`;\n const defaultWidth = !width ? DEFAULT_WIDTH : {};\n return (\n <div className={iframeClassName}>\n <IframeResizer\n scrolling={enableScrolling}\n autoResize\n src={resolvedSrc}\n sizeHeight={!height}\n height={height}\n width={width}\n style={defaultWidth}\n />\n </div>\n );\n};\n\nIframe.propTypes = {\n src: PropTypes.string,\n enableScrolling: PropTypes.bool,\n modifier: PropTypes.string,\n width: PropTypes.string,\n height: PropTypes.string,\n parent: PropTypes.object\n};\n\nIframe.defaultProps = {\n src: '',\n enableScrolling: false,\n modifier: '',\n width: '',\n height: '',\n parent: {}\n};\n\nexport default Iframe;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,mBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAEA,MAAMK,kBAAkB,GAAG,sBAAsB;AAEjD,MAAMC,SAAS,GAAGC,GAAG,IAAI,CAACF,kBAAkB,CAACG,IAAI,CAACD,GAAG,CAACE,IAAI,CAAC,CAAC,CAAC;AAE7D,MAAMC,MAAM,GAAGA,CAAC;EAAEC,GAAG;EAAEC,QAAQ;EAAEC,KAAK;EAAEC,MAAM;EAAEC,eAAe;EAAEC;AAAO,CAAC,KAAK;EAC5E,MAAM;IACJC,IAAI,EAAE,CAACC,WAAW;EACpB,CAAC,GAAG,IAAAC,kCAAiB,EAACH,MAAM,EAAE,CAACL,GAAG,IAAI,EAAE,CAAC,CAAC;EAC1C,IAAI,CAACO,WAAW,IAAI,CAACZ,SAAS,CAACY,WAAW,CAAC,EAAE,OAAO,IAAI;EACxD,MAAME,cAAc,GAAGR,QAAQ,GAAG,IAAIA,QAAQ,EAAE,GAAG,EAAE;EACrD,MAAMS,eAAe,GAAG,GAAGC,uBAAY,GAAGF,cAAc,EAAE;EAC1D,MAAMG,YAAY,GAAG,CAACV,KAAK,GAAGW,wBAAa,GAAG,CAAC,CAAC;EAChD,oBACE1B,MAAA,CAAA2B,OAAA,CAAAC,aAAA;IAAKC,SAAS,EAAEN;EAAgB,gBAC9BvB,MAAA,CAAA2B,OAAA,CAAAC,aAAA,CAACxB,mBAAA,CAAAuB,OAAa;IACZG,SAAS,EAAEb,eAAgB;IAC3Bc,UAAU;IACVlB,GAAG,EAAEO,WAAY;IACjBY,UAAU,EAAE,CAAChB,MAAO;IACpBA,MAAM,EAAEA,MAAO;IACfD,KAAK,EAAEA,KAAM;IACbkB,KAAK,EAAER;EAAa,CACrB,CACE,CAAC;AAEV,CAAC;AAEDb,MAAM,CAACsB,SAAS,GAAG;EACjBrB,GAAG,EAAEsB,kBAAS,CAACC,MAAM;EACrBnB,eAAe,EAAEkB,kBAAS,CAACE,IAAI;EAC/BvB,QAAQ,EAAEqB,kBAAS,CAACC,MAAM;EAC1BrB,KAAK,EAAEoB,kBAAS,CAACC,MAAM;EACvBpB,MAAM,EAAEmB,kBAAS,CAACC,MAAM;EACxBlB,MAAM,EAAEiB,kBAAS,CAACG;AACpB,CAAC;AAED1B,MAAM,CAAC2B,YAAY,GAAG;EACpB1B,GAAG,EAAE,EAAE;EACPI,eAAe,EAAE,KAAK;EACtBH,QAAQ,EAAE,EAAE;EACZC,KAAK,EAAE,EAAE;EACTC,MAAM,EAAE,EAAE;EACVE,MAAM,EAAE,CAAC;AACX,CAAC;AAAC,IAAAsB,QAAA,GAAAC,OAAA,CAAAd,OAAA,GAEaf,MAAM","ignoreList":[]}
|
|
@@ -10,13 +10,14 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
10
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
var _utilsHandlebars = require("@blaze-cms/utils-handlebars");
|
|
13
14
|
var _Wrapper = _interopRequireDefault(require("../Wrapper"));
|
|
14
15
|
var _utils = require("../../utils");
|
|
15
16
|
var _hooks = require("../../hooks");
|
|
16
17
|
var _helpers = require("./helpers");
|
|
17
18
|
var _helpers2 = require("../../helpers");
|
|
18
19
|
var _constants = require("../../constants");
|
|
19
|
-
const _excluded = ["type", "children", "settings", "modifier", "backgroundImage", "tagType", "dataNoSnippet", "sticky", "VariantComponent", "customHtmlProps"];
|
|
20
|
+
const _excluded = ["type", "children", "settings", "modifier", "backgroundImage", "backgroundImageUrl", "parent", "tagType", "dataNoSnippet", "sticky", "VariantComponent", "customHtmlProps"];
|
|
20
21
|
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; }
|
|
21
22
|
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) { (0, _defineProperty2.default)(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; }
|
|
22
23
|
const Layout = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
@@ -26,6 +27,8 @@ const Layout = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
26
27
|
settings,
|
|
27
28
|
modifier,
|
|
28
29
|
backgroundImage,
|
|
30
|
+
backgroundImageUrl,
|
|
31
|
+
parent,
|
|
29
32
|
tagType,
|
|
30
33
|
dataNoSnippet,
|
|
31
34
|
sticky,
|
|
@@ -33,15 +36,19 @@ const Layout = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
33
36
|
customHtmlProps = []
|
|
34
37
|
} = _ref,
|
|
35
38
|
otherProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
39
|
+
const {
|
|
40
|
+
data: [resolvedBackgroundImageUrl]
|
|
41
|
+
} = (0, _utilsHandlebars.useStringTemplate)(parent, [backgroundImageUrl || '']);
|
|
36
42
|
const {
|
|
37
43
|
data: {
|
|
38
44
|
getFile: {
|
|
39
45
|
url = null
|
|
40
46
|
} = {}
|
|
41
47
|
}
|
|
42
|
-
} = (0, _hooks.useGetImages)(backgroundImage);
|
|
48
|
+
} = (0, _hooks.useGetImages)(backgroundImage, false, !!resolvedBackgroundImageUrl);
|
|
49
|
+
const backgroundUrl = resolvedBackgroundImageUrl || url;
|
|
43
50
|
const style = (0, _helpers.getStylesToUpdate)({
|
|
44
|
-
backgroundImage:
|
|
51
|
+
backgroundImage: backgroundUrl
|
|
45
52
|
});
|
|
46
53
|
const {
|
|
47
54
|
title
|
|
@@ -76,6 +83,8 @@ Layout.propTypes = {
|
|
|
76
83
|
}),
|
|
77
84
|
modifier: _propTypes.default.string,
|
|
78
85
|
backgroundImage: _propTypes.default.string,
|
|
86
|
+
backgroundImageUrl: _propTypes.default.string,
|
|
87
|
+
parent: _propTypes.default.object,
|
|
79
88
|
tagType: _propTypes.default.string,
|
|
80
89
|
dataNoSnippet: _propTypes.default.bool,
|
|
81
90
|
VariantComponent: _propTypes.default.func,
|
|
@@ -90,6 +99,8 @@ Layout.defaultProps = {
|
|
|
90
99
|
title: ''
|
|
91
100
|
},
|
|
92
101
|
backgroundImage: '',
|
|
102
|
+
backgroundImageUrl: '',
|
|
103
|
+
parent: {},
|
|
93
104
|
modifier: '',
|
|
94
105
|
tagType: '',
|
|
95
106
|
dataNoSnippet: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.js","names":["_react","_interopRequireDefault","require","_propTypes","_Wrapper","_utils","_hooks","_helpers","_helpers2","_constants","_excluded","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","Layout","React","forwardRef","_ref","ref","type","children","settings","modifier","backgroundImage","tagType","dataNoSnippet","sticky","VariantComponent","customHtmlProps","otherProps","_objectWithoutProperties2","data","getFile","url","useGetImages","style","getStylesToUpdate","title","classModifiers","getClassModifiers","additionalRowModifier","checkIfRowHasColumns","COLUMN","hasChildren","otherWrapperProps","customHtmlProperties","getCustomHtmlProperties","WrapperComponent","Wrapper","createElement","_extends2","className","modifiers","renderChildren","propTypes","PropTypes","string","isRequired","bool","shape","func","arrayOf","name","value","oneOfType","node","defaultProps","_default","exports"],"sources":["../../../src/components/Layout/Layout.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Wrapper from '../Wrapper';\nimport { getClassModifiers } from '../../utils';\nimport { useGetImages } from '../../hooks';\nimport { getStylesToUpdate, checkIfRowHasColumns } from './helpers';\nimport { renderChildren, hasChildren, getCustomHtmlProperties } from '../../helpers';\nimport { COLUMN } from '../../constants';\n\nconst Layout = React.forwardRef(\n (\n {\n type,\n children,\n settings,\n modifier,\n backgroundImage,\n tagType,\n dataNoSnippet,\n sticky,\n VariantComponent,\n customHtmlProps = [],\n ...otherProps\n },\n ref\n ) => {\n const {\n data: { getFile: { url = null } = {} }\n } = useGetImages(backgroundImage);\n const style = getStylesToUpdate({ backgroundImage:
|
|
1
|
+
{"version":3,"file":"Layout.js","names":["_react","_interopRequireDefault","require","_propTypes","_utilsHandlebars","_Wrapper","_utils","_hooks","_helpers","_helpers2","_constants","_excluded","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","Layout","React","forwardRef","_ref","ref","type","children","settings","modifier","backgroundImage","backgroundImageUrl","parent","tagType","dataNoSnippet","sticky","VariantComponent","customHtmlProps","otherProps","_objectWithoutProperties2","data","resolvedBackgroundImageUrl","useStringTemplate","getFile","url","useGetImages","backgroundUrl","style","getStylesToUpdate","title","classModifiers","getClassModifiers","additionalRowModifier","checkIfRowHasColumns","COLUMN","hasChildren","otherWrapperProps","customHtmlProperties","getCustomHtmlProperties","WrapperComponent","Wrapper","createElement","_extends2","className","modifiers","renderChildren","propTypes","PropTypes","string","isRequired","bool","shape","object","func","arrayOf","name","value","oneOfType","node","defaultProps","_default","exports"],"sources":["../../../src/components/Layout/Layout.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { useStringTemplate } from '@blaze-cms/utils-handlebars';\nimport Wrapper from '../Wrapper';\nimport { getClassModifiers } from '../../utils';\nimport { useGetImages } from '../../hooks';\nimport { getStylesToUpdate, checkIfRowHasColumns } from './helpers';\nimport { renderChildren, hasChildren, getCustomHtmlProperties } from '../../helpers';\nimport { COLUMN } from '../../constants';\n\nconst Layout = React.forwardRef(\n (\n {\n type,\n children,\n settings,\n modifier,\n backgroundImage,\n backgroundImageUrl,\n parent,\n tagType,\n dataNoSnippet,\n sticky,\n VariantComponent,\n customHtmlProps = [],\n ...otherProps\n },\n ref\n ) => {\n const {\n data: [resolvedBackgroundImageUrl]\n } = useStringTemplate(parent, [backgroundImageUrl || '']);\n const {\n data: { getFile: { url = null } = {} }\n } = useGetImages(backgroundImage, false, !!resolvedBackgroundImageUrl);\n const backgroundUrl = resolvedBackgroundImageUrl || url;\n const style = getStylesToUpdate({ backgroundImage: backgroundUrl });\n const { title } = settings;\n const classModifiers = getClassModifiers(type, { modifier, sticky, ...otherProps });\n const additionalRowModifier = checkIfRowHasColumns(type, children) ? ' display-row' : '';\n\n if (type === COLUMN && !hasChildren(children)) return null;\n\n const otherWrapperProps = {};\n if (dataNoSnippet) otherWrapperProps['data-nosnippet'] = true;\n\n const customHtmlProperties = getCustomHtmlProperties({ customHtmlProps });\n\n const WrapperComponent = VariantComponent || Wrapper;\n\n return (\n <WrapperComponent\n ref={ref}\n tagType={tagType}\n className={type}\n modifiers={`${classModifiers}${additionalRowModifier}`}\n style={style}\n {...otherWrapperProps}\n {...customHtmlProperties}>\n {title && <h2 className=\"heading heading--section\">{title}</h2>}\n {renderChildren(children, otherProps)}\n </WrapperComponent>\n );\n }\n);\n\nLayout.propTypes = {\n type: PropTypes.string.isRequired,\n sticky: PropTypes.bool,\n settings: PropTypes.shape({\n title: PropTypes.string\n }),\n modifier: PropTypes.string,\n backgroundImage: PropTypes.string,\n backgroundImageUrl: PropTypes.string,\n parent: PropTypes.object,\n tagType: PropTypes.string,\n dataNoSnippet: PropTypes.bool,\n VariantComponent: PropTypes.func,\n customHtmlProps: PropTypes.arrayOf(\n PropTypes.shape({\n name: PropTypes.string,\n value: PropTypes.string\n })\n ),\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired\n};\n\nLayout.defaultProps = {\n settings: {\n title: ''\n },\n backgroundImage: '',\n backgroundImageUrl: '',\n parent: {},\n modifier: '',\n tagType: '',\n dataNoSnippet: false,\n sticky: false,\n VariantComponent: null,\n customHtmlProps: []\n};\n\nexport default Layout;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAAyC,MAAAS,SAAA;AAAA,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA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;AAAC,IAAA2C,QAAA,GAAAC,OAAA,CAAAhE,OAAA,GAEaI,MAAM","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":[]}
|