@blaze-cms/react-page-builder 0.146.0-node18-core-styles-tooltips.5 → 0.146.0-node18-core-styles-tooltips.12

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +1 -0
  3. package/lib/components/SearchContent/SearchContent.js +19 -11
  4. package/lib/components/SearchContent/SearchContent.js.map +1 -1
  5. package/lib/components/SearchFilter/SearchFilter/FiltersList.js +3 -1
  6. package/lib/components/SearchFilter/SearchFilter/FiltersList.js.map +1 -1
  7. package/lib/components/SearchFilter/components/Range.js +11 -4
  8. package/lib/components/SearchFilter/components/Range.js.map +1 -1
  9. package/lib/hooks/helpers/RenderComponent.js +6 -4
  10. package/lib/hooks/helpers/RenderComponent.js.map +1 -1
  11. package/lib/hooks/use-app-sync-event-hook.js +17 -5
  12. package/lib/hooks/use-app-sync-event-hook.js.map +1 -1
  13. package/lib/system-components/EditorMode/BlazeLogo.js +90 -0
  14. package/lib/system-components/EditorMode/BlazeLogo.js.map +1 -0
  15. package/lib/system-components/EditorMode/PbWrapper.js +55 -0
  16. package/lib/system-components/EditorMode/PbWrapper.js.map +1 -0
  17. package/lib/system-components/EditorMode/constants.js +10 -0
  18. package/lib/system-components/EditorMode/constants.js.map +1 -0
  19. package/lib/system-components/EditorMode/helpers/add-editor-mode-event-listeners.js +127 -0
  20. package/lib/system-components/EditorMode/helpers/add-editor-mode-event-listeners.js.map +1 -0
  21. package/lib/system-components/index.js +25 -0
  22. package/lib/system-components/index.js.map +1 -0
  23. package/lib-es/components/SearchContent/SearchContent.js +22 -12
  24. package/lib-es/components/SearchContent/SearchContent.js.map +1 -1
  25. package/lib-es/components/SearchFilter/SearchFilter/FiltersList.js +4 -2
  26. package/lib-es/components/SearchFilter/SearchFilter/FiltersList.js.map +1 -1
  27. package/lib-es/components/SearchFilter/components/Range.js +11 -4
  28. package/lib-es/components/SearchFilter/components/Range.js.map +1 -1
  29. package/lib-es/hooks/helpers/RenderComponent.js +6 -4
  30. package/lib-es/hooks/helpers/RenderComponent.js.map +1 -1
  31. package/lib-es/hooks/use-app-sync-event-hook.js +18 -6
  32. package/lib-es/hooks/use-app-sync-event-hook.js.map +1 -1
  33. package/lib-es/system-components/EditorMode/BlazeLogo.js +64 -0
  34. package/lib-es/system-components/EditorMode/BlazeLogo.js.map +1 -0
  35. package/lib-es/system-components/EditorMode/PbWrapper.js +34 -0
  36. package/lib-es/system-components/EditorMode/PbWrapper.js.map +1 -0
  37. package/lib-es/system-components/EditorMode/constants.js +3 -0
  38. package/lib-es/system-components/EditorMode/constants.js.map +1 -0
  39. package/lib-es/system-components/EditorMode/helpers/add-editor-mode-event-listeners.js +80 -0
  40. package/lib-es/system-components/EditorMode/helpers/add-editor-mode-event-listeners.js.map +1 -0
  41. package/lib-es/system-components/index.js +3 -0
  42. package/lib-es/system-components/index.js.map +1 -0
  43. package/package.json +3 -3
  44. package/src/components/SearchContent/SearchContent.js +21 -12
  45. package/src/components/SearchFilter/SearchFilter/FiltersList.js +75 -72
  46. package/src/components/SearchFilter/components/Range.js +12 -4
  47. package/src/hooks/helpers/RenderComponent.js +3 -2
  48. package/src/hooks/use-app-sync-event-hook.js +20 -6
  49. package/src/system-components/EditorMode/BlazeLogo.js +45 -0
  50. package/src/system-components/EditorMode/PbWrapper.js +27 -0
  51. package/src/system-components/EditorMode/constants.js +2 -0
  52. package/src/system-components/EditorMode/helpers/add-editor-mode-event-listeners.js +83 -0
  53. package/src/system-components/index.js +3 -0
  54. package/tests/unit/src/components/SearchFilter/components/Range.test.js +10 -0
  55. package/tests/unit/src/components/SearchFilter/components/__snapshots__/Range.test.js.snap +50 -0
  56. package/tests/unit/src/hooks/use-app-sync-evet-hook.test.js +35 -15
@@ -1,22 +1,34 @@
1
- import { useContext } from 'react';
1
+ import { useContext, useCallback } from 'react';
2
2
  import { AppContext } from '@blaze-cms/nextjs-components';
3
3
  const EVENET_PREFIX = 'plugin:page-builder:';
4
4
  const EVENET_SUFIX = ':sync';
5
5
  const useAppSyncEventHook = ({
6
6
  eventName,
7
7
  data,
8
- props
8
+ props,
9
+ returnFunction
9
10
  }) => {
10
11
  const {
11
12
  blazeApp
12
13
  } = useContext(AppContext);
14
+ const runHook = useCallback(newData => {
15
+ const eventData = newData || data;
16
+ blazeApp.events.emit(`${EVENET_PREFIX}${eventName}${EVENET_SUFIX}`, {
17
+ data: eventData,
18
+ props
19
+ });
20
+ return eventData;
21
+ }, [blazeApp, eventName, data, props]);
13
22
  if (!blazeApp) return {
14
23
  data
15
24
  };
16
- blazeApp.events.emit(`${EVENET_PREFIX}${eventName}${EVENET_SUFIX}`, {
17
- data,
18
- props
19
- });
25
+ if (returnFunction) {
26
+ return {
27
+ data,
28
+ runHook
29
+ };
30
+ }
31
+ runHook();
20
32
  return {
21
33
  data
22
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-app-sync-event-hook.js","names":["useContext","AppContext","EVENET_PREFIX","EVENET_SUFIX","useAppSyncEventHook","eventName","data","props","blazeApp","events","emit"],"sources":["../../src/hooks/use-app-sync-event-hook.js"],"sourcesContent":["import { useContext } from 'react';\nimport { AppContext } from '@blaze-cms/nextjs-components';\n\nconst EVENET_PREFIX = 'plugin:page-builder:';\nconst EVENET_SUFIX = ':sync';\n\nconst useAppSyncEventHook = ({ eventName, data, props }) => {\n const { blazeApp } = useContext(AppContext);\n if (!blazeApp) return { data };\n\n blazeApp.events.emit(`${EVENET_PREFIX}${eventName}${EVENET_SUFIX}`, {\n data,\n props\n });\n\n return { data };\n};\n\nexport default useAppSyncEventHook;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,UAAU,QAAQ,8BAA8B;AAEzD,MAAMC,aAAa,GAAG,sBAAsB;AAC5C,MAAMC,YAAY,GAAG,OAAO;AAE5B,MAAMC,mBAAmB,GAAGA,CAAC;EAAEC,SAAS;EAAEC,IAAI;EAAEC;AAAM,CAAC,KAAK;EAC1D,MAAM;IAAEC;EAAS,CAAC,GAAGR,UAAU,CAACC,UAAU,CAAC;EAC3C,IAAI,CAACO,QAAQ,EAAE,OAAO;IAAEF;EAAK,CAAC;EAE9BE,QAAQ,CAACC,MAAM,CAACC,IAAI,CAAC,GAAGR,aAAa,GAAGG,SAAS,GAAGF,YAAY,EAAE,EAAE;IAClEG,IAAI;IACJC;EACF,CAAC,CAAC;EAEF,OAAO;IAAED;EAAK,CAAC;AACjB,CAAC;AAED,eAAeF,mBAAmB","ignoreList":[]}
1
+ {"version":3,"file":"use-app-sync-event-hook.js","names":["useContext","useCallback","AppContext","EVENET_PREFIX","EVENET_SUFIX","useAppSyncEventHook","eventName","data","props","returnFunction","blazeApp","runHook","newData","eventData","events","emit"],"sources":["../../src/hooks/use-app-sync-event-hook.js"],"sourcesContent":["import { useContext, useCallback } from 'react';\nimport { AppContext } from '@blaze-cms/nextjs-components';\n\nconst EVENET_PREFIX = 'plugin:page-builder:';\nconst EVENET_SUFIX = ':sync';\n\nconst useAppSyncEventHook = ({ eventName, data, props, returnFunction }) => {\n const { blazeApp } = useContext(AppContext);\n\n const runHook = useCallback(\n newData => {\n const eventData = newData || data;\n blazeApp.events.emit(`${EVENET_PREFIX}${eventName}${EVENET_SUFIX}`, {\n data: eventData,\n props\n });\n\n return eventData;\n },\n [blazeApp, eventName, data, props]\n );\n\n if (!blazeApp) return { data };\n\n if (returnFunction) {\n return { data, runHook };\n }\n\n runHook();\n return { data };\n};\n\nexport default useAppSyncEventHook;\n"],"mappings":"AAAA,SAASA,UAAU,EAAEC,WAAW,QAAQ,OAAO;AAC/C,SAASC,UAAU,QAAQ,8BAA8B;AAEzD,MAAMC,aAAa,GAAG,sBAAsB;AAC5C,MAAMC,YAAY,GAAG,OAAO;AAE5B,MAAMC,mBAAmB,GAAGA,CAAC;EAAEC,SAAS;EAAEC,IAAI;EAAEC,KAAK;EAAEC;AAAe,CAAC,KAAK;EAC1E,MAAM;IAAEC;EAAS,CAAC,GAAGV,UAAU,CAACE,UAAU,CAAC;EAE3C,MAAMS,OAAO,GAAGV,WAAW,CACzBW,OAAO,IAAI;IACT,MAAMC,SAAS,GAAGD,OAAO,IAAIL,IAAI;IACjCG,QAAQ,CAACI,MAAM,CAACC,IAAI,CAAC,GAAGZ,aAAa,GAAGG,SAAS,GAAGF,YAAY,EAAE,EAAE;MAClEG,IAAI,EAAEM,SAAS;MACfL;IACF,CAAC,CAAC;IAEF,OAAOK,SAAS;EAClB,CAAC,EACD,CAACH,QAAQ,EAAEJ,SAAS,EAAEC,IAAI,EAAEC,KAAK,CACnC,CAAC;EAED,IAAI,CAACE,QAAQ,EAAE,OAAO;IAAEH;EAAK,CAAC;EAE9B,IAAIE,cAAc,EAAE;IAClB,OAAO;MAAEF,IAAI;MAAEI;IAAQ,CAAC;EAC1B;EAEAA,OAAO,CAAC,CAAC;EACT,OAAO;IAAEJ;EAAK,CAAC;AACjB,CAAC;AAED,eAAeF,mBAAmB","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ const _excluded = ["childNode"];
5
+ 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; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ import React, { useState, useEffect } from 'react';
8
+ import { EDITOR_MODE_ICON_CLASS, EDITOR_MODE_HIGHLIGHT_CLASS } from './constants';
9
+ const BlazeLogo = _ref => {
10
+ let {
11
+ childNode
12
+ } = _ref,
13
+ props = _objectWithoutProperties(_ref, _excluded);
14
+ const {
15
+ id
16
+ } = props;
17
+ const [style, setStyle] = useState({});
18
+ useEffect(() => {
19
+ if (!childNode) return;
20
+ const rect = childNode.getBoundingClientRect();
21
+ const left = rect.width / 2 + rect.left + window.scrollX;
22
+ const top = rect.top - 20 + window.scrollY;
23
+ const display = childNode.classList.contains(EDITOR_MODE_HIGHLIGHT_CLASS) ? null : 'none';
24
+ const newStyle = {
25
+ display,
26
+ top,
27
+ left
28
+ };
29
+ setStyle(newStyle);
30
+ const observer = new MutationObserver(mutations => {
31
+ mutations.forEach(mutation => {
32
+ if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
33
+ const isHighlighted = childNode.classList.contains(EDITOR_MODE_HIGHLIGHT_CLASS);
34
+ setStyle(_objectSpread(_objectSpread({}, newStyle), {}, {
35
+ display: isHighlighted ? null : 'none'
36
+ }));
37
+ }
38
+ });
39
+ });
40
+ observer.observe(childNode, {
41
+ attributes: true
42
+ });
43
+ return () => observer.disconnect();
44
+ }, [childNode, id]);
45
+
46
+ // todo: fix icon hover/click activation while using position absolute
47
+ return /*#__PURE__*/React.createElement("button", _extends({
48
+ type: "button",
49
+ className: EDITOR_MODE_ICON_CLASS
50
+ }, props, {
51
+ style: style
52
+ }), /*#__PURE__*/React.createElement("svg", {
53
+ xmlns: "http://www.w3.org/2000/svg",
54
+ width: "22",
55
+ height: "33"
56
+ }, /*#__PURE__*/React.createElement("path", {
57
+ fill: "currentColor",
58
+ transform: "translate(1.0415 1.85962)",
59
+ d: "M7.0214715 6.2017469C7.0214715 6.2017469 4.6948299 13.380771 5.2965479 15.065234C5.6174636 15.947572 6.3796396 16.18821 7.3022733 15.386085C9.1074257 13.781834 13.078762 6.3621721 9.949831 0.42644304C8.7463951 -1.8596147 18.293648 5.1589837 16.328037 18.755013C16.087351 20.559793 16.809412 19.998306 17.250671 19.236286C19.176168 15.947572 17.972733 11.616095 17.972733 10.894181C17.972733 10.172268 19.657541 12.939602 19.777885 18.353949C19.89823 23.768295 17.050098 29.022219 11.393953 29.98477C10.03006 30.225407 13.199106 27.578392 13.640366 24.610529C13.68048 24.329784 10.39109 28.300306 9.5888004 27.738817C9.2277699 27.49818 15.36529 19.877987 13.199106 13.300558C13.158992 13.140133 11.754984 24.409996 6.3796396 27.097116C3.3309369 28.621155 0.60315031 25.051697 0.12177619 21.963514C-1.0415446 13.862046 6.4999828 8.7284422 7.0214715 6.2017469Z",
60
+ fillRule: "evenodd"
61
+ })));
62
+ };
63
+ export default BlazeLogo;
64
+ //# sourceMappingURL=BlazeLogo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlazeLogo.js","names":["React","useState","useEffect","EDITOR_MODE_ICON_CLASS","EDITOR_MODE_HIGHLIGHT_CLASS","BlazeLogo","_ref","childNode","props","_objectWithoutProperties","_excluded","id","style","setStyle","rect","getBoundingClientRect","left","width","window","scrollX","top","scrollY","display","classList","contains","newStyle","observer","MutationObserver","mutations","forEach","mutation","type","attributeName","isHighlighted","_objectSpread","observe","attributes","disconnect","createElement","_extends","className","xmlns","height","fill","transform","d","fillRule"],"sources":["../../../src/system-components/EditorMode/BlazeLogo.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { EDITOR_MODE_ICON_CLASS, EDITOR_MODE_HIGHLIGHT_CLASS } from './constants';\n\nconst BlazeLogo = ({ childNode, ...props }) => {\n const { id } = props;\n const [style, setStyle] = useState({});\n\n useEffect(() => {\n if (!childNode) return;\n\n const rect = childNode.getBoundingClientRect();\n const left = rect.width / 2 + rect.left + window.scrollX;\n const top = rect.top - 20 + window.scrollY;\n const display = childNode.classList.contains(EDITOR_MODE_HIGHLIGHT_CLASS) ? null : 'none';\n const newStyle = { display, top, left };\n setStyle(newStyle);\n\n const observer = new MutationObserver(mutations => {\n mutations.forEach(mutation => {\n if (mutation.type === 'attributes' && mutation.attributeName === 'class') {\n const isHighlighted = childNode.classList.contains(EDITOR_MODE_HIGHLIGHT_CLASS);\n setStyle({ ...newStyle, display: isHighlighted ? null : 'none' });\n }\n });\n });\n observer.observe(childNode, { attributes: true });\n return () => observer.disconnect();\n }, [childNode, id]);\n\n // todo: fix icon hover/click activation while using position absolute\n return (\n <button type=\"button\" className={EDITOR_MODE_ICON_CLASS} {...props} style={style}>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"22\" height=\"33\">\n <path\n fill=\"currentColor\"\n transform=\"translate(1.0415 1.85962)\"\n d=\"M7.0214715 6.2017469C7.0214715 6.2017469 4.6948299 13.380771 5.2965479 15.065234C5.6174636 15.947572 6.3796396 16.18821 7.3022733 15.386085C9.1074257 13.781834 13.078762 6.3621721 9.949831 0.42644304C8.7463951 -1.8596147 18.293648 5.1589837 16.328037 18.755013C16.087351 20.559793 16.809412 19.998306 17.250671 19.236286C19.176168 15.947572 17.972733 11.616095 17.972733 10.894181C17.972733 10.172268 19.657541 12.939602 19.777885 18.353949C19.89823 23.768295 17.050098 29.022219 11.393953 29.98477C10.03006 30.225407 13.199106 27.578392 13.640366 24.610529C13.68048 24.329784 10.39109 28.300306 9.5888004 27.738817C9.2277699 27.49818 15.36529 19.877987 13.199106 13.300558C13.158992 13.140133 11.754984 24.409996 6.3796396 27.097116C3.3309369 28.621155 0.60315031 25.051697 0.12177619 21.963514C-1.0415446 13.862046 6.4999828 8.7284422 7.0214715 6.2017469Z\"\n fillRule=\"evenodd\"\n />\n </svg>\n </button>\n );\n};\n\nexport default BlazeLogo;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,SAASC,sBAAsB,EAAEC,2BAA2B,QAAQ,aAAa;AAEjF,MAAMC,SAAS,GAAGC,IAAA,IAA6B;EAAA,IAA5B;MAAEC;IAAoB,CAAC,GAAAD,IAAA;IAAPE,KAAK,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EACtC,MAAM;IAAEC;EAAG,CAAC,GAAGH,KAAK;EACpB,MAAM,CAACI,KAAK,EAAEC,QAAQ,CAAC,GAAGZ,QAAQ,CAAC,CAAC,CAAC,CAAC;EAEtCC,SAAS,CAAC,MAAM;IACd,IAAI,CAACK,SAAS,EAAE;IAEhB,MAAMO,IAAI,GAAGP,SAAS,CAACQ,qBAAqB,CAAC,CAAC;IAC9C,MAAMC,IAAI,GAAGF,IAAI,CAACG,KAAK,GAAG,CAAC,GAAGH,IAAI,CAACE,IAAI,GAAGE,MAAM,CAACC,OAAO;IACxD,MAAMC,GAAG,GAAGN,IAAI,CAACM,GAAG,GAAG,EAAE,GAAGF,MAAM,CAACG,OAAO;IAC1C,MAAMC,OAAO,GAAGf,SAAS,CAACgB,SAAS,CAACC,QAAQ,CAACpB,2BAA2B,CAAC,GAAG,IAAI,GAAG,MAAM;IACzF,MAAMqB,QAAQ,GAAG;MAAEH,OAAO;MAAEF,GAAG;MAAEJ;IAAK,CAAC;IACvCH,QAAQ,CAACY,QAAQ,CAAC;IAElB,MAAMC,QAAQ,GAAG,IAAIC,gBAAgB,CAACC,SAAS,IAAI;MACjDA,SAAS,CAACC,OAAO,CAACC,QAAQ,IAAI;QAC5B,IAAIA,QAAQ,CAACC,IAAI,KAAK,YAAY,IAAID,QAAQ,CAACE,aAAa,KAAK,OAAO,EAAE;UACxE,MAAMC,aAAa,GAAG1B,SAAS,CAACgB,SAAS,CAACC,QAAQ,CAACpB,2BAA2B,CAAC;UAC/ES,QAAQ,CAAAqB,aAAA,CAAAA,aAAA,KAAMT,QAAQ;YAAEH,OAAO,EAAEW,aAAa,GAAG,IAAI,GAAG;UAAM,EAAE,CAAC;QACnE;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;IACFP,QAAQ,CAACS,OAAO,CAAC5B,SAAS,EAAE;MAAE6B,UAAU,EAAE;IAAK,CAAC,CAAC;IACjD,OAAO,MAAMV,QAAQ,CAACW,UAAU,CAAC,CAAC;EACpC,CAAC,EAAE,CAAC9B,SAAS,EAAEI,EAAE,CAAC,CAAC;;EAEnB;EACA,oBACEX,KAAA,CAAAsC,aAAA,WAAAC,QAAA;IAAQR,IAAI,EAAC,QAAQ;IAACS,SAAS,EAAErC;EAAuB,GAAKK,KAAK;IAAEI,KAAK,EAAEA;EAAM,iBAC/EZ,KAAA,CAAAsC,aAAA;IAAKG,KAAK,EAAC,4BAA4B;IAACxB,KAAK,EAAC,IAAI;IAACyB,MAAM,EAAC;EAAI,gBAC5D1C,KAAA,CAAAsC,aAAA;IACEK,IAAI,EAAC,cAAc;IACnBC,SAAS,EAAC,2BAA2B;IACrCC,CAAC,EAAC,21BAA21B;IAC71BC,QAAQ,EAAC;EAAS,CACnB,CACE,CACC,CAAC;AAEb,CAAC;AAED,eAAezC,SAAS","ignoreList":[]}
@@ -0,0 +1,34 @@
1
+ import React, { useRef, useEffect, useState } from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import { useMainContext } from '@blaze-cms/nextjs-components';
4
+ import addEditorModeEventListeners from './helpers/add-editor-mode-event-listeners';
5
+ import BlazeLogo from './BlazeLogo';
6
+ const PbWrapper = ({
7
+ name,
8
+ type = 'start'
9
+ }) => {
10
+ const ref = useRef(null);
11
+ const [logoProps, setLogoProps] = useState(null);
12
+ const {
13
+ debugOptions: {
14
+ adminHref
15
+ } = {}
16
+ } = useMainContext();
17
+ useEffect(() => {
18
+ const unmount = addEditorModeEventListeners({
19
+ ref,
20
+ name,
21
+ adminHref,
22
+ type,
23
+ setLogoProps
24
+ });
25
+ return unmount;
26
+ }, [adminHref, name, type]);
27
+ const TagName = `pb-wrapper-${type}`;
28
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TagName, {
29
+ ref: ref,
30
+ "pb-component-name": name
31
+ }), logoProps && createPortal(/*#__PURE__*/React.createElement(BlazeLogo, logoProps), document.body));
32
+ };
33
+ export default PbWrapper;
34
+ //# sourceMappingURL=PbWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PbWrapper.js","names":["React","useRef","useEffect","useState","createPortal","useMainContext","addEditorModeEventListeners","BlazeLogo","PbWrapper","name","type","ref","logoProps","setLogoProps","debugOptions","adminHref","unmount","TagName","createElement","Fragment","document","body"],"sources":["../../../src/system-components/EditorMode/PbWrapper.js"],"sourcesContent":["import React, { useRef, useEffect, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { useMainContext } from '@blaze-cms/nextjs-components';\nimport addEditorModeEventListeners from './helpers/add-editor-mode-event-listeners';\nimport BlazeLogo from './BlazeLogo';\n\nconst PbWrapper = ({ name, type = 'start' }) => {\n const ref = useRef(null);\n const [logoProps, setLogoProps] = useState(null);\n const { debugOptions: { adminHref } = {} } = useMainContext();\n\n useEffect(() => {\n const unmount = addEditorModeEventListeners({ ref, name, adminHref, type, setLogoProps });\n\n return unmount;\n }, [adminHref, name, type]);\n\n const TagName = `pb-wrapper-${type}`;\n return (\n <>\n <TagName ref={ref} pb-component-name={name} />\n {logoProps && createPortal(<BlazeLogo {...logoProps} />, document.body)}\n </>\n );\n};\n\nexport default PbWrapper;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC1D,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,cAAc,QAAQ,8BAA8B;AAC7D,OAAOC,2BAA2B,MAAM,2CAA2C;AACnF,OAAOC,SAAS,MAAM,aAAa;AAEnC,MAAMC,SAAS,GAAGA,CAAC;EAAEC,IAAI;EAAEC,IAAI,GAAG;AAAQ,CAAC,KAAK;EAC9C,MAAMC,GAAG,GAAGV,MAAM,CAAC,IAAI,CAAC;EACxB,MAAM,CAACW,SAAS,EAAEC,YAAY,CAAC,GAAGV,QAAQ,CAAC,IAAI,CAAC;EAChD,MAAM;IAAEW,YAAY,EAAE;MAAEC;IAAU,CAAC,GAAG,CAAC;EAAE,CAAC,GAAGV,cAAc,CAAC,CAAC;EAE7DH,SAAS,CAAC,MAAM;IACd,MAAMc,OAAO,GAAGV,2BAA2B,CAAC;MAAEK,GAAG;MAAEF,IAAI;MAAEM,SAAS;MAAEL,IAAI;MAAEG;IAAa,CAAC,CAAC;IAEzF,OAAOG,OAAO;EAChB,CAAC,EAAE,CAACD,SAAS,EAAEN,IAAI,EAAEC,IAAI,CAAC,CAAC;EAE3B,MAAMO,OAAO,GAAG,cAAcP,IAAI,EAAE;EACpC,oBACEV,KAAA,CAAAkB,aAAA,CAAAlB,KAAA,CAAAmB,QAAA,qBACEnB,KAAA,CAAAkB,aAAA,CAACD,OAAO;IAACN,GAAG,EAAEA,GAAI;IAAC,qBAAmBF;EAAK,CAAE,CAAC,EAC7CG,SAAS,IAAIR,YAAY,cAACJ,KAAA,CAAAkB,aAAA,CAACX,SAAS,EAAKK,SAAY,CAAC,EAAEQ,QAAQ,CAACC,IAAI,CACtE,CAAC;AAEP,CAAC;AAED,eAAeb,SAAS","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export const EDITOR_MODE_HIGHLIGHT_CLASS = 'blaze-pb-editor-highlight';
2
+ export const EDITOR_MODE_ICON_CLASS = 'blaze-pb-editor-icon';
3
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","names":["EDITOR_MODE_HIGHLIGHT_CLASS","EDITOR_MODE_ICON_CLASS"],"sources":["../../../src/system-components/EditorMode/constants.js"],"sourcesContent":["export const EDITOR_MODE_HIGHLIGHT_CLASS = 'blaze-pb-editor-highlight';\nexport const EDITOR_MODE_ICON_CLASS = 'blaze-pb-editor-icon';\n"],"mappings":"AAAA,OAAO,MAAMA,2BAA2B,GAAG,2BAA2B;AACtE,OAAO,MAAMC,sBAAsB,GAAG,sBAAsB","ignoreList":[]}
@@ -0,0 +1,80 @@
1
+ import { getComponentId } from '../../../helpers';
2
+ import { EDITOR_MODE_HIGHLIGHT_CLASS } from '../constants';
3
+ const addEditorModeEventListeners = ({
4
+ ref,
5
+ name,
6
+ adminHref,
7
+ type,
8
+ setLogoProps
9
+ }) => {
10
+ const listeners = [];
11
+
12
+ // ignore start tags and if parent not found
13
+ if (type !== 'end' || !ref.current || !ref.current.parentNode) return listeners;
14
+ const siblings = ref.current.parentNode.children;
15
+ const foundChildren = [];
16
+ let foundStart = false;
17
+ // eslint-disable-next-line no-restricted-syntax, no-unused-vars
18
+ for (const child of siblings) {
19
+ if (!foundStart) {
20
+ // find start tag
21
+ if (child.getAttribute('pb-component-name') === name) {
22
+ foundStart = true;
23
+ }
24
+ // eslint-disable-next-line no-continue
25
+ continue;
26
+ }
27
+ if (child === ref.current) {
28
+ // end tag found
29
+ break;
30
+ }
31
+ foundChildren.push(child); // all nodes between start and end tags - PB component nodes
32
+ }
33
+ const cleanUpFunctions = Object.values(siblings).map(childNode => {
34
+ const componentId = getComponentId(name);
35
+ const clickItemId = `click-${componentId}`;
36
+ const click = e => {
37
+ e.stopPropagation();
38
+ e.preventDefault();
39
+ window.open(`${adminHref}#${componentId}`, adminHref);
40
+ };
41
+ const mouseenter = e => {
42
+ document.querySelectorAll(`.${EDITOR_MODE_HIGHLIGHT_CLASS}`).forEach(node => {
43
+ node.classList.remove(EDITOR_MODE_HIGHLIGHT_CLASS);
44
+ });
45
+ childNode.classList.add(EDITOR_MODE_HIGHLIGHT_CLASS);
46
+ setLogoProps({
47
+ id: clickItemId,
48
+ 'aria-label': `Edit ${name}`,
49
+ childNode,
50
+ onclick: click
51
+ });
52
+ };
53
+ const mouseleave = e => {
54
+ childNode.classList.remove(EDITOR_MODE_HIGHLIGHT_CLASS);
55
+ setLogoProps(null);
56
+ };
57
+ childNode.addEventListener('click', click); // todo: remove listener and trigger on icon click
58
+ childNode.addEventListener('mouseenter', mouseenter);
59
+ childNode.addEventListener('mouseleave', mouseleave);
60
+ listeners.push([childNode, {
61
+ click,
62
+ mouseenter,
63
+ mouseleave
64
+ }]);
65
+ const nodeCleanup = () => {
66
+ listeners.forEach(([, events]) => {
67
+ Object.entries(events).forEach(([event, handler]) => {
68
+ childNode.removeEventListener(event, handler);
69
+ });
70
+ });
71
+ };
72
+ return nodeCleanup;
73
+ });
74
+ const unmount = () => {
75
+ cleanUpFunctions.forEach(fn => fn());
76
+ };
77
+ return unmount;
78
+ };
79
+ export default addEditorModeEventListeners;
80
+ //# sourceMappingURL=add-editor-mode-event-listeners.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-editor-mode-event-listeners.js","names":["getComponentId","EDITOR_MODE_HIGHLIGHT_CLASS","addEditorModeEventListeners","ref","name","adminHref","type","setLogoProps","listeners","current","parentNode","siblings","children","foundChildren","foundStart","child","getAttribute","push","cleanUpFunctions","Object","values","map","childNode","componentId","clickItemId","click","e","stopPropagation","preventDefault","window","open","mouseenter","document","querySelectorAll","forEach","node","classList","remove","add","id","onclick","mouseleave","addEventListener","nodeCleanup","events","entries","event","handler","removeEventListener","unmount","fn"],"sources":["../../../../src/system-components/EditorMode/helpers/add-editor-mode-event-listeners.js"],"sourcesContent":["import { getComponentId } from '../../../helpers';\nimport { EDITOR_MODE_HIGHLIGHT_CLASS } from '../constants';\n\nconst addEditorModeEventListeners = ({ ref, name, adminHref, type, setLogoProps }) => {\n const listeners = [];\n\n // ignore start tags and if parent not found\n if (type !== 'end' || !ref.current || !ref.current.parentNode) return listeners;\n\n const siblings = ref.current.parentNode.children;\n\n const foundChildren = [];\n let foundStart = false;\n // eslint-disable-next-line no-restricted-syntax, no-unused-vars\n for (const child of siblings) {\n if (!foundStart) {\n // find start tag\n if (child.getAttribute('pb-component-name') === name) {\n foundStart = true;\n }\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (child === ref.current) {\n // end tag found\n break;\n }\n\n foundChildren.push(child); // all nodes between start and end tags - PB component nodes\n }\n\n const cleanUpFunctions = Object.values(siblings).map(childNode => {\n const componentId = getComponentId(name);\n const clickItemId = `click-${componentId}`;\n const click = e => {\n e.stopPropagation();\n e.preventDefault();\n window.open(`${adminHref}#${componentId}`, adminHref);\n };\n const mouseenter = e => {\n document.querySelectorAll(`.${EDITOR_MODE_HIGHLIGHT_CLASS}`).forEach(node => {\n node.classList.remove(EDITOR_MODE_HIGHLIGHT_CLASS);\n });\n childNode.classList.add(EDITOR_MODE_HIGHLIGHT_CLASS);\n\n setLogoProps({\n id: clickItemId,\n 'aria-label': `Edit ${name}`,\n childNode,\n onclick: click\n });\n };\n const mouseleave = e => {\n childNode.classList.remove(EDITOR_MODE_HIGHLIGHT_CLASS);\n setLogoProps(null);\n };\n\n childNode.addEventListener('click', click); // todo: remove listener and trigger on icon click\n childNode.addEventListener('mouseenter', mouseenter);\n childNode.addEventListener('mouseleave', mouseleave);\n\n listeners.push([childNode, { click, mouseenter, mouseleave }]);\n\n const nodeCleanup = () => {\n listeners.forEach(([, events]) => {\n Object.entries(events).forEach(([event, handler]) => {\n childNode.removeEventListener(event, handler);\n });\n });\n };\n\n return nodeCleanup;\n });\n\n const unmount = () => {\n cleanUpFunctions.forEach(fn => fn());\n };\n\n return unmount;\n};\n\nexport default addEditorModeEventListeners;\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,kBAAkB;AACjD,SAASC,2BAA2B,QAAQ,cAAc;AAE1D,MAAMC,2BAA2B,GAAGA,CAAC;EAAEC,GAAG;EAAEC,IAAI;EAAEC,SAAS;EAAEC,IAAI;EAAEC;AAAa,CAAC,KAAK;EACpF,MAAMC,SAAS,GAAG,EAAE;;EAEpB;EACA,IAAIF,IAAI,KAAK,KAAK,IAAI,CAACH,GAAG,CAACM,OAAO,IAAI,CAACN,GAAG,CAACM,OAAO,CAACC,UAAU,EAAE,OAAOF,SAAS;EAE/E,MAAMG,QAAQ,GAAGR,GAAG,CAACM,OAAO,CAACC,UAAU,CAACE,QAAQ;EAEhD,MAAMC,aAAa,GAAG,EAAE;EACxB,IAAIC,UAAU,GAAG,KAAK;EACtB;EACA,KAAK,MAAMC,KAAK,IAAIJ,QAAQ,EAAE;IAC5B,IAAI,CAACG,UAAU,EAAE;MACf;MACA,IAAIC,KAAK,CAACC,YAAY,CAAC,mBAAmB,CAAC,KAAKZ,IAAI,EAAE;QACpDU,UAAU,GAAG,IAAI;MACnB;MACA;MACA;IACF;IAEA,IAAIC,KAAK,KAAKZ,GAAG,CAACM,OAAO,EAAE;MACzB;MACA;IACF;IAEAI,aAAa,CAACI,IAAI,CAACF,KAAK,CAAC,CAAC,CAAC;EAC7B;EAEA,MAAMG,gBAAgB,GAAGC,MAAM,CAACC,MAAM,CAACT,QAAQ,CAAC,CAACU,GAAG,CAACC,SAAS,IAAI;IAChE,MAAMC,WAAW,GAAGvB,cAAc,CAACI,IAAI,CAAC;IACxC,MAAMoB,WAAW,GAAG,SAASD,WAAW,EAAE;IAC1C,MAAME,KAAK,GAAGC,CAAC,IAAI;MACjBA,CAAC,CAACC,eAAe,CAAC,CAAC;MACnBD,CAAC,CAACE,cAAc,CAAC,CAAC;MAClBC,MAAM,CAACC,IAAI,CAAC,GAAGzB,SAAS,IAAIkB,WAAW,EAAE,EAAElB,SAAS,CAAC;IACvD,CAAC;IACD,MAAM0B,UAAU,GAAGL,CAAC,IAAI;MACtBM,QAAQ,CAACC,gBAAgB,CAAC,IAAIhC,2BAA2B,EAAE,CAAC,CAACiC,OAAO,CAACC,IAAI,IAAI;QAC3EA,IAAI,CAACC,SAAS,CAACC,MAAM,CAACpC,2BAA2B,CAAC;MACpD,CAAC,CAAC;MACFqB,SAAS,CAACc,SAAS,CAACE,GAAG,CAACrC,2BAA2B,CAAC;MAEpDM,YAAY,CAAC;QACXgC,EAAE,EAAEf,WAAW;QACf,YAAY,EAAE,QAAQpB,IAAI,EAAE;QAC5BkB,SAAS;QACTkB,OAAO,EAAEf;MACX,CAAC,CAAC;IACJ,CAAC;IACD,MAAMgB,UAAU,GAAGf,CAAC,IAAI;MACtBJ,SAAS,CAACc,SAAS,CAACC,MAAM,CAACpC,2BAA2B,CAAC;MACvDM,YAAY,CAAC,IAAI,CAAC;IACpB,CAAC;IAEDe,SAAS,CAACoB,gBAAgB,CAAC,OAAO,EAAEjB,KAAK,CAAC,CAAC,CAAC;IAC5CH,SAAS,CAACoB,gBAAgB,CAAC,YAAY,EAAEX,UAAU,CAAC;IACpDT,SAAS,CAACoB,gBAAgB,CAAC,YAAY,EAAED,UAAU,CAAC;IAEpDjC,SAAS,CAACS,IAAI,CAAC,CAACK,SAAS,EAAE;MAAEG,KAAK;MAAEM,UAAU;MAAEU;IAAW,CAAC,CAAC,CAAC;IAE9D,MAAME,WAAW,GAAGA,CAAA,KAAM;MACxBnC,SAAS,CAAC0B,OAAO,CAAC,CAAC,GAAGU,MAAM,CAAC,KAAK;QAChCzB,MAAM,CAAC0B,OAAO,CAACD,MAAM,CAAC,CAACV,OAAO,CAAC,CAAC,CAACY,KAAK,EAAEC,OAAO,CAAC,KAAK;UACnDzB,SAAS,CAAC0B,mBAAmB,CAACF,KAAK,EAAEC,OAAO,CAAC;QAC/C,CAAC,CAAC;MACJ,CAAC,CAAC;IACJ,CAAC;IAED,OAAOJ,WAAW;EACpB,CAAC,CAAC;EAEF,MAAMM,OAAO,GAAGA,CAAA,KAAM;IACpB/B,gBAAgB,CAACgB,OAAO,CAACgB,EAAE,IAAIA,EAAE,CAAC,CAAC,CAAC;EACtC,CAAC;EAED,OAAOD,OAAO;AAChB,CAAC;AAED,eAAe/C,2BAA2B","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import dynamic from 'next/dynamic';
2
+ export const PbWrapper = dynamic(() => import('./EditorMode/PbWrapper'));
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["dynamic","PbWrapper"],"sources":["../../src/system-components/index.js"],"sourcesContent":["import dynamic from 'next/dynamic';\n\nexport const PbWrapper = dynamic(() => import('./EditorMode/PbWrapper'));\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,cAAc;AAElC,OAAO,MAAMC,SAAS,GAAGD,OAAO,CAAC,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC","ignoreList":[]}
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.5",
3
+ "version": "0.146.0-node18-core-styles-tooltips.12",
4
4
  "description": "Blaze react page builder",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -32,7 +32,7 @@
32
32
  "@blaze-cms/core-errors-ui": "0.146.0-node18-core-styles-tooltips.3",
33
33
  "@blaze-cms/image-cdn-react": "0.3.0-alpha.7",
34
34
  "@blaze-cms/nextjs-components": "0.146.0-node18-core-styles-tooltips.3",
35
- "@blaze-cms/plugin-search-ui": "0.146.0-node18-core-styles-tooltips.5",
35
+ "@blaze-cms/plugin-search-ui": "0.146.0-node18-core-styles-tooltips.11",
36
36
  "@blaze-cms/setup-ui": "0.146.0-node18-core-styles-tooltips.3",
37
37
  "@blaze-cms/utils": "0.146.0-node18-core-styles-tooltips.3",
38
38
  "@blaze-cms/utils-handlebars": "0.146.0-node18-core-styles-tooltips.3",
@@ -92,5 +92,5 @@
92
92
  "lib/*",
93
93
  "lib-es/*"
94
94
  ],
95
- "gitHead": "d6b0cd14687e7fe634aade939e3b28c67aabda02"
95
+ "gitHead": "3d94cd5b7bc0a84390240a9dfed23f1408908f06"
96
96
  }
@@ -4,27 +4,36 @@ import { useRouter } from 'next/router';
4
4
  import { useDebounceSearch } from '@blaze-cms/plugin-search-ui';
5
5
  import SearchContentResults from './SearchContentResults';
6
6
  import SearchContentToggleIcon from './SearchContentToggleIcon';
7
+ import { useAppSyncEventHook } from '../../hooks';
7
8
 
8
- const SearchContent = ({
9
- entities,
10
- searchInputWrapperMobile,
11
- searchInputWrapperDesktop,
12
- isMobile,
13
- placeholder,
14
- modifier,
15
- collapsedSearch,
16
- searchUrl,
17
- navigateToSingleSearchResult
18
- }) => {
9
+ const SearchContent = props => {
10
+ const {
11
+ entities,
12
+ searchInputWrapperMobile,
13
+ searchInputWrapperDesktop,
14
+ isMobile,
15
+ placeholder,
16
+ modifier,
17
+ collapsedSearch,
18
+ searchUrl,
19
+ navigateToSingleSearchResult
20
+ } = props;
19
21
  const searchContentRef = useRef(null);
20
22
  const [collapsed, setCollapsed] = useState(collapsedSearch);
21
23
  const [showResults, setShowResults] = useState(false);
22
24
  const router = useRouter();
23
25
 
26
+ const { runHook } = useAppSyncEventHook({
27
+ eventName: 'searchcontent:query-variables',
28
+ props,
29
+ returnFunction: true
30
+ });
31
+
24
32
  const { results, searchTerm, setSearchTerm, debouncedSearchTerm } = useDebounceSearch({
25
33
  entities,
26
34
  initialSearchTerm: '',
27
- resultKeys: 'id, name, image { url }, url'
35
+ resultKeys: 'id, name, image { url }, url',
36
+ queryHook: runHook
28
37
  });
29
38
 
30
39
  useEffect(() => {
@@ -15,90 +15,93 @@ const FiltersList = ({
15
15
  }) => {
16
16
  const { itemId } = useContext(MainContext);
17
17
 
18
- return filters.map(({ type, label, propsToDisplay, elementTitle, ...otherProps }, index) => {
19
- if (!propsToDisplay && !propsToDisplay.length) return null;
20
- const dynamicKey = [itemId, index].join('-');
21
- const isDataAvailable = !!data && Object.keys(data).length;
22
- const dataAggregations = isDataAvailable ? data : null;
23
- const areAggregationsAvailable = isDataAvailable && !!dataAggregations;
18
+ return filters.map(
19
+ ({ type, label, propsToDisplay, elementTitle, unit, ...otherProps }, index) => {
20
+ if (!propsToDisplay && !propsToDisplay.length) return null;
21
+ const dynamicKey = [itemId, index].join('-');
22
+ const isDataAvailable = !!data && Object.keys(data).length;
23
+ const dataAggregations = isDataAvailable ? data : null;
24
+ const areAggregationsAvailable = isDataAvailable && !!dataAggregations;
24
25
 
25
- switch (type) {
26
- case TEXT_SEARCH:
27
- return (
28
- <div
29
- key={dynamicKey}
30
- className="filter__section filter__section--search-refine filter__section--search">
31
- <TextSearch
32
- {...otherProps}
33
- label={label}
34
- elementTitle={elementTitle}
35
- searchValue={filterValues[SEARCH_TERM]}
36
- updateFilterValues={updateFilterValues}
37
- filterValues={filterValues}
38
- />
39
- </div>
40
- );
41
-
42
- case CHECKBOX:
43
- return (
44
- <div
45
- key={dynamicKey}
46
- className="filter__section filter__section--search-refine filter__section--checkboxes">
47
- <Checkbox
48
- {...otherProps}
49
- data={data}
50
- prop={propsToDisplay[0]}
51
- label={label}
52
- elementTitle={elementTitle}
53
- hasUrl={hasUrl}
54
- filterValues={filterValues}
55
- updateFilterValues={updateFilterValues}
56
- shouldSearch={shouldSearch}
57
- />
58
- </div>
59
- );
26
+ switch (type) {
27
+ case TEXT_SEARCH:
28
+ return (
29
+ <div
30
+ key={dynamicKey}
31
+ className="filter__section filter__section--search-refine filter__section--search">
32
+ <TextSearch
33
+ {...otherProps}
34
+ label={label}
35
+ elementTitle={elementTitle}
36
+ searchValue={filterValues[SEARCH_TERM]}
37
+ updateFilterValues={updateFilterValues}
38
+ filterValues={filterValues}
39
+ />
40
+ </div>
41
+ );
60
42
 
61
- case SELECT:
62
- return (
63
- <div
64
- key={dynamicKey}
65
- className="filter__section filter__section--search-refine filter__section--selects">
66
- <SelectFilter
67
- {...otherProps}
68
- data={data}
69
- prop={propsToDisplay[0]}
70
- label={label}
71
- elementTitle={elementTitle}
72
- hasUrl={hasUrl}
73
- filterValues={filterValues}
74
- updateFilterValues={updateFilterValues}
75
- shouldSearch={shouldSearch}
76
- />
77
- </div>
78
- );
43
+ case CHECKBOX:
44
+ return (
45
+ <div
46
+ key={dynamicKey}
47
+ className="filter__section filter__section--search-refine filter__section--checkboxes">
48
+ <Checkbox
49
+ {...otherProps}
50
+ data={data}
51
+ prop={propsToDisplay[0]}
52
+ label={label}
53
+ elementTitle={elementTitle}
54
+ hasUrl={hasUrl}
55
+ filterValues={filterValues}
56
+ updateFilterValues={updateFilterValues}
57
+ shouldSearch={shouldSearch}
58
+ />
59
+ </div>
60
+ );
79
61
 
80
- case RANGE:
81
- return (
82
- !!areAggregationsAvailable && (
83
- <div key={dynamicKey} className="range-slider__wrapper">
84
- <Range
62
+ case SELECT:
63
+ return (
64
+ <div
65
+ key={dynamicKey}
66
+ className="filter__section filter__section--search-refine filter__section--selects">
67
+ <SelectFilter
85
68
  {...otherProps}
86
- dataAggregations={dataAggregations}
87
- propsToDisplay={propsToDisplay}
69
+ data={data}
70
+ prop={propsToDisplay[0]}
88
71
  label={label}
89
72
  elementTitle={elementTitle}
90
- entity={entity}
73
+ hasUrl={hasUrl}
91
74
  filterValues={filterValues}
92
75
  updateFilterValues={updateFilterValues}
93
76
  shouldSearch={shouldSearch}
94
77
  />
95
78
  </div>
96
- )
97
- );
98
- default:
99
- return null;
79
+ );
80
+
81
+ case RANGE:
82
+ return (
83
+ !!areAggregationsAvailable && (
84
+ <div key={dynamicKey} className="range-slider__wrapper">
85
+ <Range
86
+ {...otherProps}
87
+ dataAggregations={dataAggregations}
88
+ propsToDisplay={propsToDisplay}
89
+ label={label}
90
+ elementTitle={elementTitle}
91
+ unit={unit}
92
+ entity={entity}
93
+ filterValues={filterValues}
94
+ updateFilterValues={updateFilterValues}
95
+ shouldSearch={shouldSearch}
96
+ />
97
+ </div>
98
+ )
99
+ );
100
+ default:
101
+ return null;
102
+ }
100
103
  }
101
- });
104
+ );
102
105
  };
103
106
 
104
107
  FiltersList.propTypes = {
@@ -18,7 +18,8 @@ const Range = ({
18
18
  updateFilterValues,
19
19
  filterValues,
20
20
  shouldSearch,
21
- elementTitle
21
+ elementTitle,
22
+ unit
22
23
  }) => {
23
24
  const router = useRouter();
24
25
  const debounceAmount = shouldSearch ? 1200 : 400;
@@ -48,6 +49,11 @@ const Range = ({
48
49
  updateFilterValues({ [option]: { ...value, selectedOption: rangeOption } }, shouldSearch);
49
50
  }, debounceAmount);
50
51
 
52
+ let displayLabel = '';
53
+ if (!hasMultipleOptions) {
54
+ displayLabel = unit ? `${label} (${unit})` : label;
55
+ }
56
+
51
57
  return (
52
58
  <>
53
59
  {elementTitle && <div className="heading heading--section">{elementTitle}</div>}
@@ -75,7 +81,7 @@ const Range = ({
75
81
  <RangeFilter
76
82
  key={`${rangeOption}-${minValue}-${maxValue}`}
77
83
  name={rangeOption}
78
- label={hasMultipleOptions ? '' : label}
84
+ label={displayLabel}
79
85
  value={valueToUse}
80
86
  id={rangeOption}
81
87
  onChange={({ value }) => {
@@ -95,14 +101,16 @@ Range.propTypes = {
95
101
  rangeInterval: PropTypes.number,
96
102
  label: PropTypes.string,
97
103
  elementTitle: PropTypes.string,
98
- dataAggregations: PropTypes.object.isRequired
104
+ dataAggregations: PropTypes.object.isRequired,
105
+ unit: PropTypes.string
99
106
  };
100
107
 
101
108
  Range.defaultProps = {
102
109
  shouldSearch: false,
103
110
  rangeInterval: 1,
104
111
  label: '',
105
- elementTitle: ''
112
+ elementTitle: '',
113
+ unit: ''
106
114
  };
107
115
 
108
116
  export default Range;
@@ -7,6 +7,7 @@ import getVariant from './getVariant';
7
7
  import appendGtmClassName from './append-gtm-classname';
8
8
  import { PB_TYPE_IMAGE, PB_TYPE_BANNER, PB_TYPE_TEXTBLOCK, PB_TYPE_CAROUSEL } from './constants';
9
9
  import { BannerContextProvider } from '../../BannerContext';
10
+ import { PbWrapper } from '../../system-components';
10
11
 
11
12
  const RenderComponent = ({
12
13
  component,
@@ -31,7 +32,7 @@ const RenderComponent = ({
31
32
 
32
33
  return (
33
34
  <ErrorBoundary>
34
- {editorModeEnabled && <pb-wrapper-start pb-component-name={name} />}
35
+ {editorModeEnabled && <PbWrapper name={name} />}
35
36
  <Component
36
37
  key={id}
37
38
  type={type}
@@ -50,7 +51,7 @@ const RenderComponent = ({
50
51
  childComponents
51
52
  )}
52
53
  </Component>
53
- {editorModeEnabled && <pb-wrapper-end pb-component-name={name} />}
54
+ {editorModeEnabled && <PbWrapper name={name} type="end" />}
54
55
  </ErrorBoundary>
55
56
  );
56
57
  };
@@ -1,18 +1,32 @@
1
- import { useContext } from 'react';
1
+ import { useContext, useCallback } from 'react';
2
2
  import { AppContext } from '@blaze-cms/nextjs-components';
3
3
 
4
4
  const EVENET_PREFIX = 'plugin:page-builder:';
5
5
  const EVENET_SUFIX = ':sync';
6
6
 
7
- const useAppSyncEventHook = ({ eventName, data, props }) => {
7
+ const useAppSyncEventHook = ({ eventName, data, props, returnFunction }) => {
8
8
  const { blazeApp } = useContext(AppContext);
9
+
10
+ const runHook = useCallback(
11
+ newData => {
12
+ const eventData = newData || data;
13
+ blazeApp.events.emit(`${EVENET_PREFIX}${eventName}${EVENET_SUFIX}`, {
14
+ data: eventData,
15
+ props
16
+ });
17
+
18
+ return eventData;
19
+ },
20
+ [blazeApp, eventName, data, props]
21
+ );
22
+
9
23
  if (!blazeApp) return { data };
10
24
 
11
- blazeApp.events.emit(`${EVENET_PREFIX}${eventName}${EVENET_SUFIX}`, {
12
- data,
13
- props
14
- });
25
+ if (returnFunction) {
26
+ return { data, runHook };
27
+ }
15
28
 
29
+ runHook();
16
30
  return { data };
17
31
  };
18
32