@blaze-cms/nextjs-tools 0.146.0-node18-core-styles-tooltips.56 → 0.146.0-node18-core-styles-tooltips.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/lib/components/DebugSidebar/DebugSidebarRender.js.map +1 -1
- package/lib/hooks/use-hash-observer.js.map +1 -1
- package/lib-es/components/DebugSidebar/DebugSidebarRender.js.map +1 -1
- package/lib-es/hooks/use-hash-observer.js.map +1 -1
- package/package.json +16 -16
- package/src/components/DebugSidebar/DebugSidebarRender.js +15 -18
- package/src/hooks/use-hash-observer.js +87 -90
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.146.0-node18-core-styles-tooltips.58](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.57...v0.146.0-node18-core-styles-tooltips.58) (2026-04-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* fix lint and tests errors across repository ([#5047](https://github.com/thebyte9/blaze/issues/5047)) ([c2b86dd](https://github.com/thebyte9/blaze/commit/c2b86dd7aebb12198a49097692a549a9f9378d6e))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [0.146.0-node18-core-styles-tooltips.56](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.55...v0.146.0-node18-core-styles-tooltips.56) (2026-03-27)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @blaze-cms/nextjs-tools
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DebugSidebarRender.js","names":["_react","_interopRequireWildcard","require","_dynamic","_interopRequireDefault","_propTypes","_router","_helpers","_constants","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof2","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DebugSidebar","dynamic","Promise","resolve","then","DebugSidebarRender","_ref","itemEntity","itemId","updatedDebugOptions","debugMode","_useState","useState","_useState2","_slicedToArray2","isDebugMode","setIsDebugMode","router","useRouter","useEffect","currentDebugValue","getFromLocal","BLAZE_DEBUG","setBlazeDebug","handleRouteChange","url","hasDebug","includes","concat","asPath","events","on","off","createElement","propTypes","PropTypes","func","isRequired","string","bool","defaultProps","_default","exports"],"sources":["../../../src/components/DebugSidebar/DebugSidebarRender.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport dynamic from 'next/dynamic';\nimport PropTypes from 'prop-types';\nimport { useRouter } from 'next/router';\nimport { setBlazeDebug, getFromLocal } from '../../helpers';\nimport { BLAZE_DEBUG } from '../../constants';\n\nconst DebugSidebar = dynamic(() => import('./DebugSidebar'));\n\nconst DebugSidebarRender = ({ itemEntity, itemId, updatedDebugOptions, debugMode }) => {\n const [isDebugMode, setIsDebugMode] = useState(debugMode);\n const router = useRouter();\n\n useEffect(() => {\n const currentDebugValue = getFromLocal(BLAZE_DEBUG);\n setIsDebugMode(currentDebugValue);\n setBlazeDebug(setIsDebugMode);\n }, []);\n\n useEffect(
|
|
1
|
+
{"version":3,"file":"DebugSidebarRender.js","names":["_react","_interopRequireWildcard","require","_dynamic","_interopRequireDefault","_propTypes","_router","_helpers","_constants","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof2","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DebugSidebar","dynamic","Promise","resolve","then","DebugSidebarRender","_ref","itemEntity","itemId","updatedDebugOptions","debugMode","_useState","useState","_useState2","_slicedToArray2","isDebugMode","setIsDebugMode","router","useRouter","useEffect","currentDebugValue","getFromLocal","BLAZE_DEBUG","setBlazeDebug","handleRouteChange","url","hasDebug","includes","concat","asPath","events","on","off","createElement","propTypes","PropTypes","func","isRequired","string","bool","defaultProps","_default","exports"],"sources":["../../../src/components/DebugSidebar/DebugSidebarRender.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport dynamic from 'next/dynamic';\nimport PropTypes from 'prop-types';\nimport { useRouter } from 'next/router';\nimport { setBlazeDebug, getFromLocal } from '../../helpers';\nimport { BLAZE_DEBUG } from '../../constants';\n\nconst DebugSidebar = dynamic(() => import('./DebugSidebar'));\n\nconst DebugSidebarRender = ({ itemEntity, itemId, updatedDebugOptions, debugMode }) => {\n const [isDebugMode, setIsDebugMode] = useState(debugMode);\n const router = useRouter();\n\n useEffect(() => {\n const currentDebugValue = getFromLocal(BLAZE_DEBUG);\n setIsDebugMode(currentDebugValue);\n setBlazeDebug(setIsDebugMode);\n }, []);\n\n useEffect(() => {\n const handleRouteChange = url => {\n const hasDebug = url.includes(`${BLAZE_DEBUG}=1`);\n if (hasDebug) {\n setBlazeDebug(setIsDebugMode);\n }\n };\n\n if (router.asPath.includes(`${BLAZE_DEBUG}=1`)) {\n handleRouteChange(router.asPath);\n }\n\n router.events.on('routeChangeComplete', handleRouteChange);\n return () => {\n router.events.off('routeChangeComplete', handleRouteChange);\n };\n }, [router.events, router.asPath]);\n\n if (!isDebugMode) return null;\n\n return (\n <DebugSidebar\n itemEntity={itemEntity}\n itemId={itemId}\n updatedDebugOptions={updatedDebugOptions}\n debugMode={debugMode}\n setIsDebugMode={setIsDebugMode}\n />\n );\n};\n\nDebugSidebarRender.propTypes = {\n updatedDebugOptions: PropTypes.func.isRequired,\n itemEntity: PropTypes.string,\n itemId: PropTypes.string,\n debugMode: PropTypes.bool\n};\n\nDebugSidebarRender.defaultProps = {\n itemEntity: '',\n itemId: '',\n debugMode: false\n};\n\nexport default DebugSidebarRender;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sB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CAACC,EAAE,CAAC,qBAAqB,EAAEP,iBAAiB,CAAC;IAC1D,OAAO,YAAM;MACXP,MAAM,CAACa,MAAM,CAACE,GAAG,CAAC,qBAAqB,EAAER,iBAAiB,CAAC;IAC7D,CAAC;EACH,CAAC,EAAE,CAACP,MAAM,CAACa,MAAM,EAAEb,MAAM,CAACY,MAAM,CAAC,CAAC;EAElC,IAAI,CAACd,WAAW,EAAE,OAAO,IAAI;EAE7B,oBACE5C,MAAA,YAAA8D,aAAA,CAACjC,YAAY;IACXO,UAAU,EAAEA,UAAW;IACvBC,MAAM,EAAEA,MAAO;IACfC,mBAAmB,EAAEA,mBAAoB;IACzCC,SAAS,EAAEA,SAAU;IACrBM,cAAc,EAAEA;EAAe,CAChC,CAAC;AAEN,CAAC;AAEDX,kBAAkB,CAAC6B,SAAS,GAAG;EAC7BzB,mBAAmB,EAAE0B,qBAAS,CAACC,IAAI,CAACC,UAAU;EAC9C9B,UAAU,EAAE4B,qBAAS,CAACG,MAAM;EAC5B9B,MAAM,EAAE2B,qBAAS,CAACG,MAAM;EACxB5B,SAAS,EAAEyB,qBAAS,CAACI;AACvB,CAAC;AAEDlC,kBAAkB,CAACmC,YAAY,GAAG;EAChCjC,UAAU,EAAE,EAAE;EACdC,MAAM,EAAE,EAAE;EACVE,SAAS,EAAE;AACb,CAAC;AAAC,IAAA+B,QAAA,GAAAC,OAAA,cAEarC,kBAAkB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-hash-observer.js","names":["_react","require","_router","_interopRequireDefault","DEFAULT_TIMEOUT","useHashObserver","timeout","arguments","length","undefined","useEffect","window","observer","timeoutId","currentHash","isObserving","scrollToElement","hash","id","startsWith","slice","element","document","getElementById","scrollIntoView","stopObserving","disconnect","clearTimeout","startObserving","MutationObserver","targetNode","body","observe","childList","subtree","setTimeout","handleRouteChange","url","hashIndex","indexOf","handleHashChange","Router","events","on","location","off","_default","exports"],"sources":["../../src/hooks/use-hash-observer.js"],"sourcesContent":["import { useEffect } from 'react';\nimport Router from 'next/router';\n\nconst DEFAULT_TIMEOUT = 3000;\n\nfunction useHashObserver(timeout = DEFAULT_TIMEOUT) {\n useEffect(
|
|
1
|
+
{"version":3,"file":"use-hash-observer.js","names":["_react","require","_router","_interopRequireDefault","DEFAULT_TIMEOUT","useHashObserver","timeout","arguments","length","undefined","useEffect","window","observer","timeoutId","currentHash","isObserving","scrollToElement","hash","id","startsWith","slice","element","document","getElementById","scrollIntoView","stopObserving","disconnect","clearTimeout","startObserving","MutationObserver","targetNode","body","observe","childList","subtree","setTimeout","handleRouteChange","url","hashIndex","indexOf","handleHashChange","Router","events","on","location","off","_default","exports"],"sources":["../../src/hooks/use-hash-observer.js"],"sourcesContent":["import { useEffect } from 'react';\nimport Router from 'next/router';\n\nconst DEFAULT_TIMEOUT = 3000;\n\nfunction useHashObserver(timeout = DEFAULT_TIMEOUT) {\n useEffect(() => {\n if (typeof window === 'undefined') return undefined;\n\n let observer = null;\n let timeoutId = null;\n let currentHash = null;\n let isObserving = false;\n\n const scrollToElement = hash => {\n if (!hash) return false;\n\n const id = hash.startsWith('#') ? hash.slice(1) : hash;\n const element = document.getElementById(id);\n\n if (element) {\n element.scrollIntoView();\n return true;\n }\n\n return false;\n };\n\n const stopObserving = () => {\n if (observer) {\n observer.disconnect();\n observer = null;\n }\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n isObserving = false;\n currentHash = null;\n };\n\n const startObserving = hash => {\n if (isObserving) {\n stopObserving();\n }\n\n currentHash = hash;\n isObserving = true;\n\n if (scrollToElement(hash)) {\n stopObserving();\n return;\n }\n\n observer = new MutationObserver(() => {\n if (scrollToElement(currentHash)) {\n stopObserving();\n }\n });\n\n const targetNode =\n document.getElementById('__next') || document.getElementById('root') || document.body;\n observer.observe(targetNode, {\n childList: true,\n subtree: true\n });\n\n timeoutId = setTimeout(() => {\n stopObserving();\n }, timeout);\n };\n\n const handleRouteChange = url => {\n const hashIndex = url.indexOf('#');\n if (hashIndex === -1) {\n stopObserving();\n return;\n }\n\n const hash = url.slice(hashIndex);\n if (hash) {\n startObserving(hash);\n }\n };\n\n const handleHashChange = url => {\n const hashIndex = url.indexOf('#');\n if (hashIndex === -1) {\n stopObserving();\n return;\n }\n\n const hash = url.slice(hashIndex);\n if (hash) {\n startObserving(hash);\n } else {\n stopObserving();\n }\n };\n\n Router.events.on('routeChangeComplete', handleRouteChange);\n Router.events.on('hashChangeComplete', handleHashChange);\n\n if (window.location.hash) {\n startObserving(window.location.hash);\n }\n\n return () => {\n stopObserving();\n Router.events.off('routeChangeComplete', handleRouteChange);\n Router.events.off('hashChangeComplete', handleHashChange);\n };\n }, [timeout]);\n}\n\nexport default useHashObserver;\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAMG,eAAe,GAAG,IAAI;AAE5B,SAASC,eAAeA,CAAA,EAA4B;EAAA,IAA3BC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGH,eAAe;EAChD,IAAAM,gBAAS,EAAC,YAAM;IACd,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE,OAAOF,SAAS;IAEnD,IAAIG,QAAQ,GAAG,IAAI;IACnB,IAAIC,SAAS,GAAG,IAAI;IACpB,IAAIC,WAAW,GAAG,IAAI;IACtB,IAAIC,WAAW,GAAG,KAAK;IAEvB,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,CAAGC,IAAI,EAAI;MAC9B,IAAI,CAACA,IAAI,EAAE,OAAO,KAAK;MAEvB,IAAMC,EAAE,GAAGD,IAAI,CAACE,UAAU,CAAC,GAAG,CAAC,GAAGF,IAAI,CAACG,KAAK,CAAC,CAAC,CAAC,GAAGH,IAAI;MACtD,IAAMI,OAAO,GAAGC,QAAQ,CAACC,cAAc,CAACL,EAAE,CAAC;MA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}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DebugSidebarRender.js","names":["React","useState","useEffect","dynamic","PropTypes","useRouter","setBlazeDebug","getFromLocal","BLAZE_DEBUG","DebugSidebar","DebugSidebarRender","itemEntity","itemId","updatedDebugOptions","debugMode","isDebugMode","setIsDebugMode","router","currentDebugValue","handleRouteChange","url","hasDebug","includes","asPath","events","on","off","createElement","propTypes","func","isRequired","string","bool","defaultProps"],"sources":["../../../src/components/DebugSidebar/DebugSidebarRender.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport dynamic from 'next/dynamic';\nimport PropTypes from 'prop-types';\nimport { useRouter } from 'next/router';\nimport { setBlazeDebug, getFromLocal } from '../../helpers';\nimport { BLAZE_DEBUG } from '../../constants';\n\nconst DebugSidebar = dynamic(() => import('./DebugSidebar'));\n\nconst DebugSidebarRender = ({ itemEntity, itemId, updatedDebugOptions, debugMode }) => {\n const [isDebugMode, setIsDebugMode] = useState(debugMode);\n const router = useRouter();\n\n useEffect(() => {\n const currentDebugValue = getFromLocal(BLAZE_DEBUG);\n setIsDebugMode(currentDebugValue);\n setBlazeDebug(setIsDebugMode);\n }, []);\n\n useEffect(
|
|
1
|
+
{"version":3,"file":"DebugSidebarRender.js","names":["React","useState","useEffect","dynamic","PropTypes","useRouter","setBlazeDebug","getFromLocal","BLAZE_DEBUG","DebugSidebar","DebugSidebarRender","itemEntity","itemId","updatedDebugOptions","debugMode","isDebugMode","setIsDebugMode","router","currentDebugValue","handleRouteChange","url","hasDebug","includes","asPath","events","on","off","createElement","propTypes","func","isRequired","string","bool","defaultProps"],"sources":["../../../src/components/DebugSidebar/DebugSidebarRender.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport dynamic from 'next/dynamic';\nimport PropTypes from 'prop-types';\nimport { useRouter } from 'next/router';\nimport { setBlazeDebug, getFromLocal } from '../../helpers';\nimport { BLAZE_DEBUG } from '../../constants';\n\nconst DebugSidebar = dynamic(() => import('./DebugSidebar'));\n\nconst DebugSidebarRender = ({ itemEntity, itemId, updatedDebugOptions, debugMode }) => {\n const [isDebugMode, setIsDebugMode] = useState(debugMode);\n const router = useRouter();\n\n useEffect(() => {\n const currentDebugValue = getFromLocal(BLAZE_DEBUG);\n setIsDebugMode(currentDebugValue);\n setBlazeDebug(setIsDebugMode);\n }, []);\n\n useEffect(() => {\n const handleRouteChange = url => {\n const hasDebug = url.includes(`${BLAZE_DEBUG}=1`);\n if (hasDebug) {\n setBlazeDebug(setIsDebugMode);\n }\n };\n\n if (router.asPath.includes(`${BLAZE_DEBUG}=1`)) {\n handleRouteChange(router.asPath);\n }\n\n router.events.on('routeChangeComplete', handleRouteChange);\n return () => {\n router.events.off('routeChangeComplete', handleRouteChange);\n };\n }, [router.events, router.asPath]);\n\n if (!isDebugMode) return null;\n\n return (\n <DebugSidebar\n itemEntity={itemEntity}\n itemId={itemId}\n updatedDebugOptions={updatedDebugOptions}\n debugMode={debugMode}\n setIsDebugMode={setIsDebugMode}\n />\n );\n};\n\nDebugSidebarRender.propTypes = {\n updatedDebugOptions: PropTypes.func.isRequired,\n itemEntity: PropTypes.string,\n itemId: PropTypes.string,\n debugMode: PropTypes.bool\n};\n\nDebugSidebarRender.defaultProps = {\n itemEntity: '',\n itemId: '',\n debugMode: false\n};\n\nexport default DebugSidebarRender;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,OAAOC,OAAO,MAAM,cAAc;AAClC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,aAAa,EAAEC,YAAY,QAAQ,eAAe;AAC3D,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,MAAMC,YAAY,GAAGN,OAAO,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE5D,MAAMO,kBAAkB,GAAGA,CAAC;EAAEC,UAAU;EAAEC,MAAM;EAAEC,mBAAmB;EAAEC;AA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SAAS,CAACyB,IAAI,CAACC,UAAU;EAC9CnB,UAAU,EAAEP,SAAS,CAAC2B,MAAM;EAC5BnB,MAAM,EAAER,SAAS,CAAC2B,MAAM;EACxBjB,SAAS,EAAEV,SAAS,CAAC4B;AACvB,CAAC;AAEDtB,kBAAkB,CAACuB,YAAY,GAAG;EAChCtB,UAAU,EAAE,EAAE;EACdC,MAAM,EAAE,EAAE;EACVE,SAAS,EAAE;AACb,CAAC;AAED,eAAeJ,kBAAkB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-hash-observer.js","names":["useEffect","Router","DEFAULT_TIMEOUT","useHashObserver","timeout","window","undefined","observer","timeoutId","currentHash","isObserving","scrollToElement","hash","id","startsWith","slice","element","document","getElementById","scrollIntoView","stopObserving","disconnect","clearTimeout","startObserving","MutationObserver","targetNode","body","observe","childList","subtree","setTimeout","handleRouteChange","url","hashIndex","indexOf","handleHashChange","events","on","location","off"],"sources":["../../src/hooks/use-hash-observer.js"],"sourcesContent":["import { useEffect } from 'react';\nimport Router from 'next/router';\n\nconst DEFAULT_TIMEOUT = 3000;\n\nfunction useHashObserver(timeout = DEFAULT_TIMEOUT) {\n useEffect(
|
|
1
|
+
{"version":3,"file":"use-hash-observer.js","names":["useEffect","Router","DEFAULT_TIMEOUT","useHashObserver","timeout","window","undefined","observer","timeoutId","currentHash","isObserving","scrollToElement","hash","id","startsWith","slice","element","document","getElementById","scrollIntoView","stopObserving","disconnect","clearTimeout","startObserving","MutationObserver","targetNode","body","observe","childList","subtree","setTimeout","handleRouteChange","url","hashIndex","indexOf","handleHashChange","events","on","location","off"],"sources":["../../src/hooks/use-hash-observer.js"],"sourcesContent":["import { useEffect } from 'react';\nimport Router from 'next/router';\n\nconst DEFAULT_TIMEOUT = 3000;\n\nfunction useHashObserver(timeout = DEFAULT_TIMEOUT) {\n useEffect(() => {\n if (typeof window === 'undefined') return undefined;\n\n let observer = null;\n let timeoutId = null;\n let currentHash = null;\n let isObserving = false;\n\n const scrollToElement = hash => {\n if (!hash) return false;\n\n const id = hash.startsWith('#') ? hash.slice(1) : hash;\n const element = document.getElementById(id);\n\n if (element) {\n element.scrollIntoView();\n return true;\n }\n\n return false;\n };\n\n const stopObserving = () => {\n if (observer) {\n observer.disconnect();\n observer = null;\n }\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n isObserving = false;\n currentHash = null;\n };\n\n const startObserving = hash => {\n if (isObserving) {\n stopObserving();\n }\n\n currentHash = hash;\n isObserving = true;\n\n if (scrollToElement(hash)) {\n stopObserving();\n return;\n }\n\n observer = new MutationObserver(() => {\n if (scrollToElement(currentHash)) {\n stopObserving();\n }\n });\n\n const targetNode =\n document.getElementById('__next') || document.getElementById('root') || document.body;\n observer.observe(targetNode, {\n childList: true,\n subtree: true\n });\n\n timeoutId = setTimeout(() => {\n stopObserving();\n }, timeout);\n };\n\n const handleRouteChange = url => {\n const hashIndex = url.indexOf('#');\n if (hashIndex === -1) {\n stopObserving();\n return;\n }\n\n const hash = url.slice(hashIndex);\n if (hash) {\n startObserving(hash);\n }\n };\n\n const handleHashChange = url => {\n const hashIndex = url.indexOf('#');\n if (hashIndex === -1) {\n stopObserving();\n return;\n }\n\n const hash = url.slice(hashIndex);\n if (hash) {\n startObserving(hash);\n } else {\n stopObserving();\n }\n };\n\n Router.events.on('routeChangeComplete', handleRouteChange);\n Router.events.on('hashChangeComplete', handleHashChange);\n\n if (window.location.hash) {\n startObserving(window.location.hash);\n }\n\n return () => {\n stopObserving();\n Router.events.off('routeChangeComplete', handleRouteChange);\n Router.events.off('hashChangeComplete', handleHashChange);\n };\n }, [timeout]);\n}\n\nexport default useHashObserver;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,OAAOC,MAAM,MAAM,aAAa;AAEhC,MAAMC,eAAe,GAAG,IAAI;AAE5B,SAASC,eAAeA,CAACC,OAAO,GAAGF,eAAe,EAAE;EAClDF,SAAS,CAAC,MAAM;IAC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Ac,CAAClB,MAAM,CAACiC,QAAQ,CAAC1B,IAAI,CAAC;IACtC;IAEA,OAAO,MAAM;MACXQ,aAAa,CAAC,CAAC;MACfnB,MAAM,CAACmC,MAAM,CAACG,GAAG,CAAC,qBAAqB,EAAER,iBAAiB,CAAC;MAC3D9B,MAAM,CAACmC,MAAM,CAACG,GAAG,CAAC,oBAAoB,EAAEJ,gBAAgB,CAAC;IAC3D,CAAC;EACH,CAAC,EAAE,CAAC/B,OAAO,CAAC,CAAC;AACf;AAEA,eAAeD,eAAe","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/nextjs-tools",
|
|
3
|
-
"version": "0.146.0-node18-core-styles-tooltips.
|
|
3
|
+
"version": "0.146.0-node18-core-styles-tooltips.58",
|
|
4
4
|
"description": "Blaze nextjs tools",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -28,22 +28,22 @@
|
|
|
28
28
|
"license": "GPL-3.0",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@apollo/client": "3.13.8",
|
|
31
|
-
"@blaze-cms/core-auth-ui": "0.146.0-node18-core-styles-tooltips.
|
|
31
|
+
"@blaze-cms/core-auth-ui": "0.146.0-node18-core-styles-tooltips.58",
|
|
32
32
|
"@blaze-cms/core-errors": "0.146.0-node18-core-styles-tooltips.46",
|
|
33
33
|
"@blaze-cms/core-errors-ui": "0.146.0-node18-core-styles-tooltips.46",
|
|
34
|
-
"@blaze-cms/core-ui": "0.146.0-node18-core-styles-tooltips.
|
|
35
|
-
"@blaze-cms/nextjs-components": "0.146.0-node18-core-styles-tooltips.
|
|
36
|
-
"@blaze-cms/plugin-auth-fe": "0.146.0-node18-core-styles-tooltips.
|
|
37
|
-
"@blaze-cms/plugin-auth-local-fe": "0.146.0-node18-core-styles-tooltips.
|
|
38
|
-
"@blaze-cms/plugin-chart": "0.146.0-node18-core-styles-tooltips.
|
|
39
|
-
"@blaze-cms/plugin-google-maps-fe": "0.146.0-node18-core-styles-tooltips.
|
|
40
|
-
"@blaze-cms/plugin-gtm-fe": "0.146.0-node18-core-styles-tooltips.
|
|
41
|
-
"@blaze-cms/plugin-page-builder-fe": "0.146.0-node18-core-styles-tooltips.
|
|
42
|
-
"@blaze-cms/plugin-preview-fe": "0.146.0-node18-core-styles-tooltips.
|
|
43
|
-
"@blaze-cms/plugin-search-ui": "0.146.0-node18-core-styles-tooltips.
|
|
44
|
-
"@blaze-cms/plugin-structured-data-fe": "0.146.0-node18-core-styles-tooltips.
|
|
34
|
+
"@blaze-cms/core-ui": "0.146.0-node18-core-styles-tooltips.58",
|
|
35
|
+
"@blaze-cms/nextjs-components": "0.146.0-node18-core-styles-tooltips.58",
|
|
36
|
+
"@blaze-cms/plugin-auth-fe": "0.146.0-node18-core-styles-tooltips.58",
|
|
37
|
+
"@blaze-cms/plugin-auth-local-fe": "0.146.0-node18-core-styles-tooltips.58",
|
|
38
|
+
"@blaze-cms/plugin-chart": "0.146.0-node18-core-styles-tooltips.58",
|
|
39
|
+
"@blaze-cms/plugin-google-maps-fe": "0.146.0-node18-core-styles-tooltips.58",
|
|
40
|
+
"@blaze-cms/plugin-gtm-fe": "0.146.0-node18-core-styles-tooltips.58",
|
|
41
|
+
"@blaze-cms/plugin-page-builder-fe": "0.146.0-node18-core-styles-tooltips.58",
|
|
42
|
+
"@blaze-cms/plugin-preview-fe": "0.146.0-node18-core-styles-tooltips.58",
|
|
43
|
+
"@blaze-cms/plugin-search-ui": "0.146.0-node18-core-styles-tooltips.58",
|
|
44
|
+
"@blaze-cms/plugin-structured-data-fe": "0.146.0-node18-core-styles-tooltips.58",
|
|
45
45
|
"@blaze-cms/plugin-translation-fe": "0.146.0-node18-core-styles-tooltips.46",
|
|
46
|
-
"@blaze-cms/react-page-builder": "0.146.0-node18-core-styles-tooltips.
|
|
46
|
+
"@blaze-cms/react-page-builder": "0.146.0-node18-core-styles-tooltips.58",
|
|
47
47
|
"@blaze-cms/setup-ui": "0.146.0-node18-core-styles-tooltips.46",
|
|
48
48
|
"@blaze-react/switches": "0.8.0-alpha.112",
|
|
49
49
|
"autoprefixer": "^10.2.3",
|
|
@@ -66,11 +66,11 @@
|
|
|
66
66
|
"react": "^18.2.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"nock": "^
|
|
69
|
+
"nock": "^14.0.12"
|
|
70
70
|
},
|
|
71
71
|
"eslintIgnore": [
|
|
72
72
|
"lib/*",
|
|
73
73
|
"lib-es/*"
|
|
74
74
|
],
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "f7a6d4bdce550c1edced07053c611a4e5aa28d8b"
|
|
76
76
|
}
|
|
@@ -17,26 +17,23 @@ const DebugSidebarRender = ({ itemEntity, itemId, updatedDebugOptions, debugMode
|
|
|
17
17
|
setBlazeDebug(setIsDebugMode);
|
|
18
18
|
}, []);
|
|
19
19
|
|
|
20
|
-
useEffect(
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
setBlazeDebug(setIsDebugMode);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
if (router.asPath.includes(`${BLAZE_DEBUG}=1`)) {
|
|
30
|
-
handleRouteChange(router.asPath);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const handleRouteChange = url => {
|
|
22
|
+
const hasDebug = url.includes(`${BLAZE_DEBUG}=1`);
|
|
23
|
+
if (hasDebug) {
|
|
24
|
+
setBlazeDebug(setIsDebugMode);
|
|
31
25
|
}
|
|
26
|
+
};
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
if (router.asPath.includes(`${BLAZE_DEBUG}=1`)) {
|
|
29
|
+
handleRouteChange(router.asPath);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
router.events.on('routeChangeComplete', handleRouteChange);
|
|
33
|
+
return () => {
|
|
34
|
+
router.events.off('routeChangeComplete', handleRouteChange);
|
|
35
|
+
};
|
|
36
|
+
}, [router.events, router.asPath]);
|
|
40
37
|
|
|
41
38
|
if (!isDebugMode) return null;
|
|
42
39
|
|
|
@@ -4,116 +4,113 @@ import Router from 'next/router';
|
|
|
4
4
|
const DEFAULT_TIMEOUT = 3000;
|
|
5
5
|
|
|
6
6
|
function useHashObserver(timeout = DEFAULT_TIMEOUT) {
|
|
7
|
-
useEffect(
|
|
8
|
-
()
|
|
9
|
-
if (typeof window === 'undefined') return undefined;
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (typeof window === 'undefined') return undefined;
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
let observer = null;
|
|
11
|
+
let timeoutId = null;
|
|
12
|
+
let currentHash = null;
|
|
13
|
+
let isObserving = false;
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const scrollToElement = hash => {
|
|
16
|
+
if (!hash) return false;
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const id = hash.startsWith('#') ? hash.slice(1) : hash;
|
|
19
|
+
const element = document.getElementById(id);
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return false;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const stopObserving = () => {
|
|
31
|
-
if (observer) {
|
|
32
|
-
observer.disconnect();
|
|
33
|
-
observer = null;
|
|
34
|
-
}
|
|
35
|
-
if (timeoutId) {
|
|
36
|
-
clearTimeout(timeoutId);
|
|
37
|
-
timeoutId = null;
|
|
38
|
-
}
|
|
39
|
-
isObserving = false;
|
|
40
|
-
currentHash = null;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const startObserving = hash => {
|
|
44
|
-
if (isObserving) {
|
|
45
|
-
stopObserving();
|
|
46
|
-
}
|
|
21
|
+
if (element) {
|
|
22
|
+
element.scrollIntoView();
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
47
25
|
|
|
48
|
-
|
|
49
|
-
|
|
26
|
+
return false;
|
|
27
|
+
};
|
|
50
28
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
29
|
+
const stopObserving = () => {
|
|
30
|
+
if (observer) {
|
|
31
|
+
observer.disconnect();
|
|
32
|
+
observer = null;
|
|
33
|
+
}
|
|
34
|
+
if (timeoutId) {
|
|
35
|
+
clearTimeout(timeoutId);
|
|
36
|
+
timeoutId = null;
|
|
37
|
+
}
|
|
38
|
+
isObserving = false;
|
|
39
|
+
currentHash = null;
|
|
40
|
+
};
|
|
55
41
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
});
|
|
42
|
+
const startObserving = hash => {
|
|
43
|
+
if (isObserving) {
|
|
44
|
+
stopObserving();
|
|
45
|
+
}
|
|
61
46
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
observer.observe(targetNode, {
|
|
65
|
-
childList: true,
|
|
66
|
-
subtree: true
|
|
67
|
-
});
|
|
47
|
+
currentHash = hash;
|
|
48
|
+
isObserving = true;
|
|
68
49
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
50
|
+
if (scrollToElement(hash)) {
|
|
51
|
+
stopObserving();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
73
54
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (hashIndex === -1) {
|
|
55
|
+
observer = new MutationObserver(() => {
|
|
56
|
+
if (scrollToElement(currentHash)) {
|
|
77
57
|
stopObserving();
|
|
78
|
-
return;
|
|
79
58
|
}
|
|
59
|
+
});
|
|
80
60
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
61
|
+
const targetNode =
|
|
62
|
+
document.getElementById('__next') || document.getElementById('root') || document.body;
|
|
63
|
+
observer.observe(targetNode, {
|
|
64
|
+
childList: true,
|
|
65
|
+
subtree: true
|
|
66
|
+
});
|
|
86
67
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
68
|
+
timeoutId = setTimeout(() => {
|
|
69
|
+
stopObserving();
|
|
70
|
+
}, timeout);
|
|
71
|
+
};
|
|
93
72
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
};
|
|
73
|
+
const handleRouteChange = url => {
|
|
74
|
+
const hashIndex = url.indexOf('#');
|
|
75
|
+
if (hashIndex === -1) {
|
|
76
|
+
stopObserving();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
101
79
|
|
|
102
|
-
|
|
103
|
-
|
|
80
|
+
const hash = url.slice(hashIndex);
|
|
81
|
+
if (hash) {
|
|
82
|
+
startObserving(hash);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
104
85
|
|
|
105
|
-
|
|
106
|
-
|
|
86
|
+
const handleHashChange = url => {
|
|
87
|
+
const hashIndex = url.indexOf('#');
|
|
88
|
+
if (hashIndex === -1) {
|
|
89
|
+
stopObserving();
|
|
90
|
+
return;
|
|
107
91
|
}
|
|
108
92
|
|
|
109
|
-
|
|
93
|
+
const hash = url.slice(hashIndex);
|
|
94
|
+
if (hash) {
|
|
95
|
+
startObserving(hash);
|
|
96
|
+
} else {
|
|
110
97
|
stopObserving();
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
Router.events.on('routeChangeComplete', handleRouteChange);
|
|
102
|
+
Router.events.on('hashChangeComplete', handleHashChange);
|
|
103
|
+
|
|
104
|
+
if (window.location.hash) {
|
|
105
|
+
startObserving(window.location.hash);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return () => {
|
|
109
|
+
stopObserving();
|
|
110
|
+
Router.events.off('routeChangeComplete', handleRouteChange);
|
|
111
|
+
Router.events.off('hashChangeComplete', handleHashChange);
|
|
112
|
+
};
|
|
113
|
+
}, [timeout]);
|
|
117
114
|
}
|
|
118
115
|
|
|
119
116
|
export default useHashObserver;
|