@favish/staffbase-utils 0.14.0 → 0.15.0
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/README.md +2 -1
- package/dist/shadow/portal.cjs.js +1 -0
- package/dist/shadow/portal.es.mjs +2 -0
- package/dist/shadow/react.cjs.js +1 -1
- package/dist/shadow/react.cjs.js.map +1 -1
- package/dist/shadow/react.es.mjs +10 -10
- package/dist/shadow/react.es.mjs.map +1 -1
- package/dist/src/shadow/portal/PortalContainerContext.d.ts.map +1 -0
- package/dist/src/shadow/portal/PortalContainerProvider.d.ts.map +1 -0
- package/dist/src/shadow/portal/index.d.ts +4 -0
- package/dist/src/shadow/portal/index.d.ts.map +1 -0
- package/dist/src/shadow/portal/usePortalContainer.d.ts.map +1 -0
- package/dist/src/shadow/react/index.d.ts +3 -3
- package/dist/src/shadow/react/index.d.ts.map +1 -1
- package/dist/usePortalContainer-BYW2B6g7.mjs +7 -0
- package/dist/usePortalContainer-BYW2B6g7.mjs.map +1 -0
- package/dist/usePortalContainer-BcMPb5ai.js +2 -0
- package/dist/usePortalContainer-BcMPb5ai.js.map +1 -0
- package/package.json +7 -1
- package/dist/src/shadow/react/PortalContainerContext.d.ts.map +0 -1
- package/dist/src/shadow/react/PortalContainerProvider.d.ts.map +0 -1
- package/dist/src/shadow/react/usePortalContainer.d.ts.map +0 -1
- /package/dist/src/shadow/{react → portal}/PortalContainerContext.d.ts +0 -0
- /package/dist/src/shadow/{react → portal}/PortalContainerProvider.d.ts +0 -0
- /package/dist/src/shadow/{react → portal}/usePortalContainer.d.ts +0 -0
package/README.md
CHANGED
|
@@ -27,7 +27,8 @@ minimumReleaseAgeExclude:
|
|
|
27
27
|
| `@favish/staffbase-utils/content` | `resolveLocalizedContent`, `resolveActiveLanguage`, `detectEditorLanguage`, `detectPreviewLanguage` |
|
|
28
28
|
| `@favish/staffbase-utils/links/react` | `useInAppLinkHandling` (React peer) |
|
|
29
29
|
| `@favish/staffbase-utils/shadow` | `injectShadowStyles`, `isShadowRoot` |
|
|
30
|
-
| `@favish/staffbase-utils/shadow/
|
|
30
|
+
| `@favish/staffbase-utils/shadow/portal` | `PortalContainerProvider`, `usePortalContainer` (React peer only, no Emotion) |
|
|
31
|
+
| `@favish/staffbase-utils/shadow/react` | `ensureShadowMount` (+ re-exports portal) (React + @emotion/cache peers) |
|
|
31
32
|
| `@favish/staffbase-utils/log` | `logError`, `logWarn`, `logDebug`, `setLoggingEnabled` |
|
|
32
33
|
| `@favish/staffbase-utils/dom` | `getDynamicClasses` |
|
|
33
34
|
| `@favish/staffbase-utils/types` | `Channel`, `ChannelLink`, `ChannelLinkParameter`, `DropdownOption`, `LocalizedContent`, `ArticleImage`, `ArticleImageVariant` (type-only) |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../usePortalContainer-BcMPb5ai.js");exports.PortalContainerProvider=e.n,exports.usePortalContainer=e.t;
|
package/dist/shadow/react.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../chunk-CMqjfN_6.js"),t=require("../injectShadowStyles-SjxVBpXH.js")
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../chunk-CMqjfN_6.js"),t=require("../injectShadowStyles-SjxVBpXH.js"),n=require("../usePortalContainer-BcMPb5ai.js");let r=require("@emotion/cache");r=e.t(r);var i=(e,t)=>{let n=e.getElementById(t);if(n instanceof HTMLDivElement)return n;let r=document.createElement(`div`);return r.id=t,e.appendChild(r),r},a=(e,t)=>{let n=e.getElementById(t);if(n instanceof HTMLMetaElement)return n;let r=document.createElement(`meta`);return r.id=t,r.setAttribute(`name`,`emotion-insertion-point`),e.appendChild(r),r},o=`sbu-shadow-styles`,s=`sbu-react-root`,c=`sbu-portal-root`,l=`sbu-emotion-insertion-point`,u=(e,{cacheKey:n,cssText:u})=>{let d=e.shadowRoot??e.attachShadow({mode:`open`}),f=i(d,`${s}-${n}`),p=i(d,`${c}-${n}`),m=a(d,`${l}-${n}`);return t.t(d,u,`${o}-${n}`),{shadowRoot:d,reactMountEl:f,portalContainerEl:p,emotionCache:(0,r.default)({key:n,container:d,insertionPoint:m})}};exports.PortalContainerProvider=n.n,exports.ensureShadowMount=u,exports.usePortalContainer=n.t;
|
|
2
2
|
//# sourceMappingURL=react.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.cjs.js","names":[],"sources":["../../src/shadow/react/getOrCreateDiv.ts","../../src/shadow/react/getOrCreateEmotionInsertionPoint.ts","../../src/shadow/react/ensureShadowMount.ts"
|
|
1
|
+
{"version":3,"file":"react.cjs.js","names":[],"sources":["../../src/shadow/react/getOrCreateDiv.ts","../../src/shadow/react/getOrCreateEmotionInsertionPoint.ts","../../src/shadow/react/ensureShadowMount.ts"],"sourcesContent":["/**\n * Returns the shadow-root child `<div>` with the given id, creating it if absent.\n * @param {ShadowRoot} root - The shadow root to search/append within.\n * @param {string} id - The element id.\n * @returns {HTMLDivElement} The existing or newly created div.\n */\nexport const getOrCreateDiv = (\n root: ShadowRoot,\n id: string,\n): HTMLDivElement => {\n const existing = root.getElementById(id)\n if (existing instanceof HTMLDivElement) return existing\n\n const el = document.createElement('div')\n el.id = id\n root.appendChild(el)\n return el\n}\n","/**\n * Returns the shadow-root `<meta name=\"emotion-insertion-point\">` with the given\n * id, creating it if absent. Keeps Emotion's styles ordered before shadow content.\n * @param {ShadowRoot} root - The shadow root to search/append within.\n * @param {string} id - The element id.\n * @returns {HTMLMetaElement} The existing or newly created insertion-point meta.\n */\nexport const getOrCreateEmotionInsertionPoint = (\n root: ShadowRoot,\n id: string,\n): HTMLMetaElement => {\n const existing = root.getElementById(id)\n if (existing instanceof HTMLMetaElement) return existing\n\n const el = document.createElement('meta')\n el.id = id\n el.setAttribute('name', 'emotion-insertion-point')\n root.appendChild(el)\n return el\n}\n","import createCache from '@emotion/cache'\n\nimport type { EnsureShadowMountOptions } from '../../types/shadow/EnsureShadowMountOptions'\nimport type { ShadowMount } from '../../types/shadow/ShadowMount'\nimport { injectShadowStyles } from '../injectShadowStyles'\nimport { getOrCreateDiv } from './getOrCreateDiv'\nimport { getOrCreateEmotionInsertionPoint } from './getOrCreateEmotionInsertionPoint'\n\nconst STYLE_ELEMENT_ID = 'sbu-shadow-styles'\nconst REACT_MOUNT_ID = 'sbu-react-root'\nconst PORTAL_CONTAINER_ID = 'sbu-portal-root'\nconst EMOTION_INSERTION_POINT_ID = 'sbu-emotion-insertion-point'\n\n/**\n * Ensures a ShadowRoot mount exists on the host element for a widget.\n *\n * Creates stable React-mount and portal-container nodes, injects the widget's CSS\n * into the shadow root only (never into the document), and configures an Emotion\n * cache scoped to the shadow root. All internal ids are namespaced by `cacheKey`\n * so editor and runtime mounts on the same host never collide.\n * @param {HTMLElement} host - The host element to attach the shadow root to.\n * @param {EnsureShadowMountOptions} options - The cache key and the widget's CSS text.\n * @returns {ShadowMount} The shadow root, mount nodes and the scoped Emotion cache.\n */\nexport const ensureShadowMount = (\n host: HTMLElement,\n { cacheKey, cssText }: EnsureShadowMountOptions,\n): ShadowMount => {\n const shadowRoot = host.shadowRoot ?? host.attachShadow({ mode: 'open' })\n\n const reactMountEl = getOrCreateDiv(\n shadowRoot,\n `${REACT_MOUNT_ID}-${cacheKey}`,\n )\n const portalContainerEl = getOrCreateDiv(\n shadowRoot,\n `${PORTAL_CONTAINER_ID}-${cacheKey}`,\n )\n const insertionPoint = getOrCreateEmotionInsertionPoint(\n shadowRoot,\n `${EMOTION_INSERTION_POINT_ID}-${cacheKey}`,\n )\n\n injectShadowStyles(shadowRoot, cssText, `${STYLE_ELEMENT_ID}-${cacheKey}`)\n\n // Emotion's `container` is typed as HTMLElement but supports ShadowRoot targets\n // at runtime; the localized cast keeps the rest of the call type-safe.\n const emotionCache = createCache({\n key: cacheKey,\n container: shadowRoot as unknown as HTMLElement,\n insertionPoint,\n })\n\n return { shadowRoot, reactMountEl, portalContainerEl, emotionCache }\n}\n"],"mappings":"kPAMA,IAAa,GACX,EACA,IACmB,CACnB,IAAM,EAAW,EAAK,eAAe,CAAE,EACvC,GAAI,aAAoB,eAAgB,OAAO,EAE/C,IAAM,EAAK,SAAS,cAAc,KAAK,EAGvC,MAFA,GAAG,GAAK,EACR,EAAK,YAAY,CAAE,EACZ,CACT,ECVa,GACX,EACA,IACoB,CACpB,IAAM,EAAW,EAAK,eAAe,CAAE,EACvC,GAAI,aAAoB,gBAAiB,OAAO,EAEhD,IAAM,EAAK,SAAS,cAAc,MAAM,EAIxC,MAHA,GAAG,GAAK,EACR,EAAG,aAAa,OAAQ,yBAAyB,EACjD,EAAK,YAAY,CAAE,EACZ,CACT,ECXM,EAAmB,oBACnB,EAAiB,iBACjB,EAAsB,kBACtB,EAA6B,8BAatB,GACX,EACA,CAAE,WAAU,aACI,CAChB,IAAM,EAAa,EAAK,YAAc,EAAK,aAAa,CAAE,KAAM,MAAO,CAAC,EAElE,EAAe,EACnB,EACA,GAAG,EAAe,GAAG,GACvB,EACM,EAAoB,EACxB,EACA,GAAG,EAAoB,GAAG,GAC5B,EACM,EAAiB,EACrB,EACA,GAAG,EAA2B,GAAG,GACnC,EAYA,OAVA,EAAA,EAAmB,EAAY,EAAS,GAAG,EAAiB,GAAG,GAAU,EAUlE,CAAE,aAAY,eAAc,oBAAmB,cAAA,EAAA,EAAA,SANrB,CAC/B,IAAK,EACL,UAAW,EACX,gBACF,CAEsD,CAAa,CACrE"}
|
package/dist/shadow/react.es.mjs
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { t as e } from "../injectShadowStyles-C40qdwKI.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { n as t, t as n } from "../usePortalContainer-BYW2B6g7.mjs";
|
|
3
|
+
import r from "@emotion/cache";
|
|
4
4
|
//#region src/shadow/react/getOrCreateDiv.ts
|
|
5
|
-
var
|
|
5
|
+
var i = (e, t) => {
|
|
6
6
|
let n = e.getElementById(t);
|
|
7
7
|
if (n instanceof HTMLDivElement) return n;
|
|
8
8
|
let r = document.createElement("div");
|
|
9
9
|
return r.id = t, e.appendChild(r), r;
|
|
10
|
-
},
|
|
10
|
+
}, a = (e, t) => {
|
|
11
11
|
let n = e.getElementById(t);
|
|
12
12
|
if (n instanceof HTMLMetaElement) return n;
|
|
13
13
|
let r = document.createElement("meta");
|
|
14
14
|
return r.id = t, r.setAttribute("name", "emotion-insertion-point"), e.appendChild(r), r;
|
|
15
|
-
},
|
|
16
|
-
let d = t.shadowRoot ?? t.attachShadow({ mode: "open" }), f =
|
|
17
|
-
return e(d,
|
|
15
|
+
}, o = "sbu-shadow-styles", s = "sbu-react-root", c = "sbu-portal-root", l = "sbu-emotion-insertion-point", u = (t, { cacheKey: n, cssText: u }) => {
|
|
16
|
+
let d = t.shadowRoot ?? t.attachShadow({ mode: "open" }), f = i(d, `${s}-${n}`), p = i(d, `${c}-${n}`), m = a(d, `${l}-${n}`);
|
|
17
|
+
return e(d, u, `${o}-${n}`), {
|
|
18
18
|
shadowRoot: d,
|
|
19
19
|
reactMountEl: f,
|
|
20
20
|
portalContainerEl: p,
|
|
21
|
-
emotionCache:
|
|
21
|
+
emotionCache: r({
|
|
22
22
|
key: n,
|
|
23
23
|
container: d,
|
|
24
24
|
insertionPoint: m
|
|
25
25
|
})
|
|
26
26
|
};
|
|
27
|
-
}
|
|
27
|
+
};
|
|
28
28
|
//#endregion
|
|
29
|
-
export {
|
|
29
|
+
export { t as PortalContainerProvider, u as ensureShadowMount, n as usePortalContainer };
|
|
30
30
|
|
|
31
31
|
//# sourceMappingURL=react.es.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.es.mjs","names":[],"sources":["../../src/shadow/react/getOrCreateDiv.ts","../../src/shadow/react/getOrCreateEmotionInsertionPoint.ts","../../src/shadow/react/ensureShadowMount.ts"
|
|
1
|
+
{"version":3,"file":"react.es.mjs","names":[],"sources":["../../src/shadow/react/getOrCreateDiv.ts","../../src/shadow/react/getOrCreateEmotionInsertionPoint.ts","../../src/shadow/react/ensureShadowMount.ts"],"sourcesContent":["/**\n * Returns the shadow-root child `<div>` with the given id, creating it if absent.\n * @param {ShadowRoot} root - The shadow root to search/append within.\n * @param {string} id - The element id.\n * @returns {HTMLDivElement} The existing or newly created div.\n */\nexport const getOrCreateDiv = (\n root: ShadowRoot,\n id: string,\n): HTMLDivElement => {\n const existing = root.getElementById(id)\n if (existing instanceof HTMLDivElement) return existing\n\n const el = document.createElement('div')\n el.id = id\n root.appendChild(el)\n return el\n}\n","/**\n * Returns the shadow-root `<meta name=\"emotion-insertion-point\">` with the given\n * id, creating it if absent. Keeps Emotion's styles ordered before shadow content.\n * @param {ShadowRoot} root - The shadow root to search/append within.\n * @param {string} id - The element id.\n * @returns {HTMLMetaElement} The existing or newly created insertion-point meta.\n */\nexport const getOrCreateEmotionInsertionPoint = (\n root: ShadowRoot,\n id: string,\n): HTMLMetaElement => {\n const existing = root.getElementById(id)\n if (existing instanceof HTMLMetaElement) return existing\n\n const el = document.createElement('meta')\n el.id = id\n el.setAttribute('name', 'emotion-insertion-point')\n root.appendChild(el)\n return el\n}\n","import createCache from '@emotion/cache'\n\nimport type { EnsureShadowMountOptions } from '../../types/shadow/EnsureShadowMountOptions'\nimport type { ShadowMount } from '../../types/shadow/ShadowMount'\nimport { injectShadowStyles } from '../injectShadowStyles'\nimport { getOrCreateDiv } from './getOrCreateDiv'\nimport { getOrCreateEmotionInsertionPoint } from './getOrCreateEmotionInsertionPoint'\n\nconst STYLE_ELEMENT_ID = 'sbu-shadow-styles'\nconst REACT_MOUNT_ID = 'sbu-react-root'\nconst PORTAL_CONTAINER_ID = 'sbu-portal-root'\nconst EMOTION_INSERTION_POINT_ID = 'sbu-emotion-insertion-point'\n\n/**\n * Ensures a ShadowRoot mount exists on the host element for a widget.\n *\n * Creates stable React-mount and portal-container nodes, injects the widget's CSS\n * into the shadow root only (never into the document), and configures an Emotion\n * cache scoped to the shadow root. All internal ids are namespaced by `cacheKey`\n * so editor and runtime mounts on the same host never collide.\n * @param {HTMLElement} host - The host element to attach the shadow root to.\n * @param {EnsureShadowMountOptions} options - The cache key and the widget's CSS text.\n * @returns {ShadowMount} The shadow root, mount nodes and the scoped Emotion cache.\n */\nexport const ensureShadowMount = (\n host: HTMLElement,\n { cacheKey, cssText }: EnsureShadowMountOptions,\n): ShadowMount => {\n const shadowRoot = host.shadowRoot ?? host.attachShadow({ mode: 'open' })\n\n const reactMountEl = getOrCreateDiv(\n shadowRoot,\n `${REACT_MOUNT_ID}-${cacheKey}`,\n )\n const portalContainerEl = getOrCreateDiv(\n shadowRoot,\n `${PORTAL_CONTAINER_ID}-${cacheKey}`,\n )\n const insertionPoint = getOrCreateEmotionInsertionPoint(\n shadowRoot,\n `${EMOTION_INSERTION_POINT_ID}-${cacheKey}`,\n )\n\n injectShadowStyles(shadowRoot, cssText, `${STYLE_ELEMENT_ID}-${cacheKey}`)\n\n // Emotion's `container` is typed as HTMLElement but supports ShadowRoot targets\n // at runtime; the localized cast keeps the rest of the call type-safe.\n const emotionCache = createCache({\n key: cacheKey,\n container: shadowRoot as unknown as HTMLElement,\n insertionPoint,\n })\n\n return { shadowRoot, reactMountEl, portalContainerEl, emotionCache }\n}\n"],"mappings":";;;;AAMA,IAAa,KACX,GACA,MACmB;CACnB,IAAM,IAAW,EAAK,eAAe,CAAE;CACvC,IAAI,aAAoB,gBAAgB,OAAO;CAE/C,IAAM,IAAK,SAAS,cAAc,KAAK;CAGvC,OAFA,EAAG,KAAK,GACR,EAAK,YAAY,CAAE,GACZ;AACT,GCVa,KACX,GACA,MACoB;CACpB,IAAM,IAAW,EAAK,eAAe,CAAE;CACvC,IAAI,aAAoB,iBAAiB,OAAO;CAEhD,IAAM,IAAK,SAAS,cAAc,MAAM;CAIxC,OAHA,EAAG,KAAK,GACR,EAAG,aAAa,QAAQ,yBAAyB,GACjD,EAAK,YAAY,CAAE,GACZ;AACT,GCXM,IAAmB,qBACnB,IAAiB,kBACjB,IAAsB,mBACtB,IAA6B,+BAatB,KACX,GACA,EAAE,aAAU,iBACI;CAChB,IAAM,IAAa,EAAK,cAAc,EAAK,aAAa,EAAE,MAAM,OAAO,CAAC,GAElE,IAAe,EACnB,GACA,GAAG,EAAe,GAAG,GACvB,GACM,IAAoB,EACxB,GACA,GAAG,EAAoB,GAAG,GAC5B,GACM,IAAiB,EACrB,GACA,GAAG,EAA2B,GAAG,GACnC;CAYA,OAVA,EAAmB,GAAY,GAAS,GAAG,EAAiB,GAAG,GAAU,GAUlE;EAAE;EAAY;EAAc;EAAmB,cANjC,EAAY;GAC/B,KAAK;GACL,WAAW;GACX;EACF,CAEsD;CAAa;AACrE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PortalContainerContext.d.ts","sourceRoot":"","sources":["../../../../src/shadow/portal/PortalContainerContext.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,sBAAsB,6CAA0C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PortalContainerProvider.d.ts","sourceRoot":"","sources":["../../../../src/shadow/portal/PortalContainerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAA;AAGnG;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,gCAGrC,4BAA4B,KAAG,YAK/B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shadow/portal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,YAAY,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePortalContainer.d.ts","sourceRoot":"","sources":["../../../../src/shadow/portal/usePortalContainer.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAO,WAAW,GAAG,IAEnD,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
export { ensureShadowMount } from './ensureShadowMount';
|
|
2
|
+
export { PortalContainerProvider } from '../portal/PortalContainerProvider';
|
|
3
|
+
export { usePortalContainer } from '../portal/usePortalContainer';
|
|
1
4
|
export type { EnsureShadowMountOptions } from '../../types/shadow/EnsureShadowMountOptions';
|
|
2
5
|
export type { PortalContainerProviderProps } from '../../types/shadow/PortalContainerProviderProps';
|
|
3
6
|
export type { ShadowMount } from '../../types/shadow/ShadowMount';
|
|
4
|
-
export { ensureShadowMount } from './ensureShadowMount';
|
|
5
|
-
export { PortalContainerProvider } from './PortalContainerProvider';
|
|
6
|
-
export { usePortalContainer } from './usePortalContainer';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shadow/react/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shadow/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAA;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AACjE,YAAY,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAA;AAC3F,YAAY,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAA;AACnG,YAAY,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext as e, createElement as t, useContext as n } from "react";
|
|
2
|
+
//#region src/shadow/portal/PortalContainerContext.ts
|
|
3
|
+
var r = e(null), i = ({ portalContainer: e, children: n }) => t(r.Provider, { value: e }, n), a = () => n(r);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { i as n, a as t };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=usePortalContainer-BYW2B6g7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePortalContainer-BYW2B6g7.mjs","names":[],"sources":["../src/shadow/portal/PortalContainerContext.ts","../src/shadow/portal/PortalContainerProvider.ts","../src/shadow/portal/usePortalContainer.ts"],"sourcesContent":["import { createContext } from 'react'\n\n/**\n * Holds the DOM element portalled components should render into, so portals stay\n * inside the widget's ShadowRoot (preserving style isolation).\n */\nexport const PortalContainerContext = createContext<HTMLElement | null>(null)\n","import type { ReactElement } from 'react'\nimport { createElement } from 'react'\n\nimport type { PortalContainerProviderProps } from '../../types/shadow/PortalContainerProviderProps'\nimport { PortalContainerContext } from './PortalContainerContext'\n\n/**\n * Provides the portal container element to descendants. Built with createElement\n * (no JSX) so the library has no JSX-runtime build coupling.\n * @param {PortalContainerProviderProps} props - The portal container and children.\n * @returns {ReactElement} The provider element wrapping the children.\n */\nexport const PortalContainerProvider = ({\n portalContainer,\n children,\n}: PortalContainerProviderProps): ReactElement =>\n createElement(\n PortalContainerContext.Provider,\n { value: portalContainer },\n children,\n )\n","import { useContext } from 'react'\n\nimport { PortalContainerContext } from './PortalContainerContext'\n\n/**\n * Returns the portal container element used to keep portals inside the ShadowRoot.\n * @returns {HTMLElement | null} The portal container, or null when not provided.\n */\nexport const usePortalContainer = (): HTMLElement | null => {\n return useContext(PortalContainerContext)\n}\n"],"mappings":";;AAMA,IAAa,IAAyB,EAAkC,IAAI,GCM/D,KAA2B,EACtC,oBACA,kBAEA,EACE,EAAuB,UACvB,EAAE,OAAO,EAAgB,GACzB,CACF,GCZW,UACJ,EAAW,CAAsB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e=require("react");var t=(0,e.createContext)(null),n=({portalContainer:n,children:r})=>(0,e.createElement)(t.Provider,{value:n},r),r=()=>(0,e.useContext)(t);Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}});
|
|
2
|
+
//# sourceMappingURL=usePortalContainer-BcMPb5ai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePortalContainer-BcMPb5ai.js","names":[],"sources":["../src/shadow/portal/PortalContainerContext.ts","../src/shadow/portal/PortalContainerProvider.ts","../src/shadow/portal/usePortalContainer.ts"],"sourcesContent":["import { createContext } from 'react'\n\n/**\n * Holds the DOM element portalled components should render into, so portals stay\n * inside the widget's ShadowRoot (preserving style isolation).\n */\nexport const PortalContainerContext = createContext<HTMLElement | null>(null)\n","import type { ReactElement } from 'react'\nimport { createElement } from 'react'\n\nimport type { PortalContainerProviderProps } from '../../types/shadow/PortalContainerProviderProps'\nimport { PortalContainerContext } from './PortalContainerContext'\n\n/**\n * Provides the portal container element to descendants. Built with createElement\n * (no JSX) so the library has no JSX-runtime build coupling.\n * @param {PortalContainerProviderProps} props - The portal container and children.\n * @returns {ReactElement} The provider element wrapping the children.\n */\nexport const PortalContainerProvider = ({\n portalContainer,\n children,\n}: PortalContainerProviderProps): ReactElement =>\n createElement(\n PortalContainerContext.Provider,\n { value: portalContainer },\n children,\n )\n","import { useContext } from 'react'\n\nimport { PortalContainerContext } from './PortalContainerContext'\n\n/**\n * Returns the portal container element used to keep portals inside the ShadowRoot.\n * @returns {HTMLElement | null} The portal container, or null when not provided.\n */\nexport const usePortalContainer = (): HTMLElement | null => {\n return useContext(PortalContainerContext)\n}\n"],"mappings":"uBAMA,IAAa,GAAA,EAAA,EAAA,eAA2D,IAAI,ECM/D,GAA2B,CACtC,kBACA,eAAA,EAAA,EAAA,eAGE,EAAuB,SACvB,CAAE,MAAO,CAAgB,EACzB,CACF,ECZW,OACX,EAAA,EAAA,YAAkB,CAAsB"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@favish/staffbase-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Shared internal/host utilities for Staffbase widgets",
|
|
5
5
|
"author": "Favish <dev@favish.com>",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
|
+
"sideEffects": false,
|
|
7
8
|
"files": [
|
|
8
9
|
"dist"
|
|
9
10
|
],
|
|
@@ -58,6 +59,11 @@
|
|
|
58
59
|
"import": "./dist/shadow.es.mjs",
|
|
59
60
|
"require": "./dist/shadow.cjs.js"
|
|
60
61
|
},
|
|
62
|
+
"./shadow/portal": {
|
|
63
|
+
"types": "./dist/src/shadow/portal/index.d.ts",
|
|
64
|
+
"import": "./dist/shadow/portal.es.mjs",
|
|
65
|
+
"require": "./dist/shadow/portal.cjs.js"
|
|
66
|
+
},
|
|
61
67
|
"./shadow/react": {
|
|
62
68
|
"types": "./dist/src/shadow/react/index.d.ts",
|
|
63
69
|
"import": "./dist/shadow/react.es.mjs",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PortalContainerContext.d.ts","sourceRoot":"","sources":["../../../../src/shadow/react/PortalContainerContext.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,sBAAsB,6CAA0C,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PortalContainerProvider.d.ts","sourceRoot":"","sources":["../../../../src/shadow/react/PortalContainerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAA;AAGnG;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,gCAGrC,4BAA4B,KAAG,YAK/B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePortalContainer.d.ts","sourceRoot":"","sources":["../../../../src/shadow/react/usePortalContainer.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAO,WAAW,GAAG,IAEnD,CAAA"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|