@favish/staffbase-utils 0.7.0 → 0.8.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 CHANGED
@@ -24,6 +24,7 @@ minimumReleaseAgeExclude:
24
24
  | Subpath | Exports |
25
25
  | --- | --- |
26
26
  | `@favish/staffbase-utils/log` | `logError`, `logWarn`, `logDebug`, `setLoggingEnabled` |
27
+ | `@favish/staffbase-utils/dom` | `getDynamicClasses` |
27
28
 
28
29
  More modules (`/env`, `/device`, `/html`, `/links`, `/widgets`) are added per the
29
30
  delivery roadmap; each is its own subpath so consumers only bundle what they import.
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=(e=`.fullscreen-preview-wrapper section`,t=`rich-text news-detail-post-content`)=>typeof document>`u`?t:document.querySelector(e)?.className||t;exports.getDynamicClasses=e;
2
+ //# sourceMappingURL=dom.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.cjs.js","names":[],"sources":["../src/dom/getDynamicClasses.ts"],"sourcesContent":["/**\n * Reads the host's dynamic rich-text CSS classes from the rendered article DOM.\n *\n * Staffbase applies tenant/theme-specific classes to the article body; mirroring\n * them on the widget's own rich-text container keeps typography consistent with\n * the host. Falls back to the stable default classes when the element is absent\n * or when there is no DOM (SSR/tests), so callers always get a usable string.\n * @param {string} [query] - CSS selector locating the source element.\n * @param {string} [defaultClasses] - Classes returned when the element is not found.\n * @returns {string} The host's dynamic rich-text classes, or the defaults.\n */\nexport const getDynamicClasses = (\n query = '.fullscreen-preview-wrapper section',\n defaultClasses = 'rich-text news-detail-post-content',\n): string => {\n if (typeof document === 'undefined') return defaultClasses\n\n const sectionElement = document.querySelector(query)\n return sectionElement?.className || defaultClasses\n}\n"],"mappings":"mEAWA,IAAa,GACX,EAAQ,sCACR,EAAiB,uCAEb,OAAO,SAAa,IAAoB,EAErB,SAAS,cAAc,CACvC,GAAgB,WAAa"}
@@ -0,0 +1,6 @@
1
+ //#region src/dom/getDynamicClasses.ts
2
+ var e = (e = ".fullscreen-preview-wrapper section", t = "rich-text news-detail-post-content") => typeof document > "u" ? t : document.querySelector(e)?.className || t;
3
+ //#endregion
4
+ export { e as getDynamicClasses };
5
+
6
+ //# sourceMappingURL=dom.es.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.es.mjs","names":[],"sources":["../src/dom/getDynamicClasses.ts"],"sourcesContent":["/**\n * Reads the host's dynamic rich-text CSS classes from the rendered article DOM.\n *\n * Staffbase applies tenant/theme-specific classes to the article body; mirroring\n * them on the widget's own rich-text container keeps typography consistent with\n * the host. Falls back to the stable default classes when the element is absent\n * or when there is no DOM (SSR/tests), so callers always get a usable string.\n * @param {string} [query] - CSS selector locating the source element.\n * @param {string} [defaultClasses] - Classes returned when the element is not found.\n * @returns {string} The host's dynamic rich-text classes, or the defaults.\n */\nexport const getDynamicClasses = (\n query = '.fullscreen-preview-wrapper section',\n defaultClasses = 'rich-text news-detail-post-content',\n): string => {\n if (typeof document === 'undefined') return defaultClasses\n\n const sectionElement = document.querySelector(query)\n return sectionElement?.className || defaultClasses\n}\n"],"mappings":";AAWA,IAAa,KACX,IAAQ,uCACR,IAAiB,yCAEb,OAAO,WAAa,MAAoB,IAErB,SAAS,cAAc,CACvC,GAAgB,aAAa"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Reads the host's dynamic rich-text CSS classes from the rendered article DOM.
3
+ *
4
+ * Staffbase applies tenant/theme-specific classes to the article body; mirroring
5
+ * them on the widget's own rich-text container keeps typography consistent with
6
+ * the host. Falls back to the stable default classes when the element is absent
7
+ * or when there is no DOM (SSR/tests), so callers always get a usable string.
8
+ * @param {string} [query] - CSS selector locating the source element.
9
+ * @param {string} [defaultClasses] - Classes returned when the element is not found.
10
+ * @returns {string} The host's dynamic rich-text classes, or the defaults.
11
+ */
12
+ export declare const getDynamicClasses: (query?: string, defaultClasses?: string) => string;
13
+ //# sourceMappingURL=getDynamicClasses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDynamicClasses.d.ts","sourceRoot":"","sources":["../../../src/dom/getDynamicClasses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAC5B,cAA6C,EAC7C,uBAAqD,KACpD,MAKF,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { getDynamicClasses } from './getDynamicClasses';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dom/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@favish/staffbase-utils",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Shared internal/host utilities for Staffbase widgets",
5
5
  "author": "Favish <dev@favish.com>",
6
6
  "license": "UNLICENSED",
@@ -18,6 +18,11 @@
18
18
  "import": "./dist/device.es.mjs",
19
19
  "require": "./dist/device.cjs.js"
20
20
  },
21
+ "./dom": {
22
+ "types": "./dist/src/dom/index.d.ts",
23
+ "import": "./dist/dom.es.mjs",
24
+ "require": "./dist/dom.cjs.js"
25
+ },
21
26
  "./html": {
22
27
  "types": "./dist/src/html/index.d.ts",
23
28
  "import": "./dist/html.es.mjs",