@favish/staffbase-utils 0.7.0 → 0.9.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,8 @@ minimumReleaseAgeExclude:
24
24
  | Subpath | Exports |
25
25
  | --- | --- |
26
26
  | `@favish/staffbase-utils/log` | `logError`, `logWarn`, `logDebug`, `setLoggingEnabled` |
27
+ | `@favish/staffbase-utils/dom` | `getDynamicClasses` |
28
+ | `@favish/staffbase-utils/types` | `Channel`, `ChannelLink`, `ChannelLinkParameter`, `DropdownOption` (type-only) |
27
29
 
28
30
  More modules (`/env`, `/device`, `/html`, `/links`, `/widgets`) are added per the
29
31
  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"}
@@ -0,0 +1,70 @@
1
+ import { ChannelLink } from './ChannelLink';
2
+ /**
3
+ * Partial shape of a Staffbase content channel as returned by the channels API.
4
+ *
5
+ * Shared verbatim by the alerts, unacknowledged-bulletins and global-content
6
+ * widgets. The smart-search widget consumes a different (search-API) channel
7
+ * shape and keeps its own type. Marked partial because the platform may add
8
+ * fields; only the documented subset the widgets rely on is typed here.
9
+ */
10
+ export interface Channel {
11
+ pluginID: string;
12
+ menuFolderIDs: string[];
13
+ defaultMenuFolderId: string;
14
+ config: {
15
+ localization: Record<string, {
16
+ title: string;
17
+ description: string | null;
18
+ }>;
19
+ sidebarVisible: boolean;
20
+ showPageBackground: boolean;
21
+ showAdminActions: boolean;
22
+ };
23
+ availableInPublicArea: boolean;
24
+ contentType: string;
25
+ notificationChannelsAllowed: string[] | null;
26
+ notificationChannelsDefault: string[];
27
+ postCount: number;
28
+ id: string;
29
+ spaceID: string;
30
+ visibleInPublicArea: boolean;
31
+ displayAuthor: boolean;
32
+ acknowledgingAllowed: boolean;
33
+ commentingAllowed: boolean;
34
+ highlightingAllowed: boolean;
35
+ layout: {
36
+ primaryMedia: string;
37
+ };
38
+ likingAllowed: boolean;
39
+ sharingAllowed: boolean;
40
+ internalSharingAllowed: boolean;
41
+ externalSharingAllowed: boolean;
42
+ lastPostPublishedAt: string;
43
+ commentingEnabledDefault: boolean;
44
+ highlightingEnabledDefault: boolean;
45
+ likingEnabledDefault: boolean;
46
+ sharingEnabledDefault: boolean;
47
+ acknowledgingEnabledDefault: boolean;
48
+ internalSharingEnabledDefault: boolean;
49
+ externalSharingEnabledDefault: boolean;
50
+ published: string;
51
+ created: string;
52
+ entityType: string;
53
+ updated: string;
54
+ links: {
55
+ preview: ChannelLink;
56
+ create_post: ChannelLink;
57
+ move: ChannelLink;
58
+ accessors: ChannelLink;
59
+ available_news_pages: ChannelLink;
60
+ get_posts: ChannelLink;
61
+ menu_items: ChannelLink;
62
+ update: ChannelLink;
63
+ feeds: ChannelLink;
64
+ delete: ChannelLink;
65
+ users: ChannelLink;
66
+ update_news_pages: ChannelLink;
67
+ };
68
+ rights: string[];
69
+ }
70
+ //# sourceMappingURL=Channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Channel.d.ts","sourceRoot":"","sources":["../../../../src/types/content/Channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD;;;;;;;GAOG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,MAAM,EAAE;QACN,YAAY,EAAE,MAAM,CAClB,MAAM,EACN;YACE,KAAK,EAAE,MAAM,CAAA;YACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;SAC3B,CACF,CAAA;QACD,cAAc,EAAE,OAAO,CAAA;QACvB,kBAAkB,EAAE,OAAO,CAAA;QAC3B,gBAAgB,EAAE,OAAO,CAAA;KAC1B,CAAA;IACD,qBAAqB,EAAE,OAAO,CAAA;IAC9B,WAAW,EAAE,M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W,CAAA;QACnB,KAAK,EAAE,WAAW,CAAA;QAClB,iBAAiB,EAAE,WAAW,CAAA;KAC/B,CAAA;IACD,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB"}
@@ -0,0 +1,12 @@
1
+ import { ChannelLinkParameter } from './ChannelLinkParameter';
2
+ /**
3
+ * A single HAL link on a channel (method + href, with optional parameter and
4
+ * form descriptors). Used for each entry of a channel's `links` map.
5
+ */
6
+ export interface ChannelLink {
7
+ method: string;
8
+ href: string;
9
+ parameters?: Record<string, ChannelLinkParameter>;
10
+ form?: ChannelLinkParameter[];
11
+ }
12
+ //# sourceMappingURL=ChannelLink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChannelLink.d.ts","sourceRoot":"","sources":["../../../../src/types/content/ChannelLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAElE;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IACjD,IAAI,CAAC,EAAE,oBAAoB,EAAE,CAAA;CAC9B"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A single parameter descriptor on a channel HAL link (an entry in a link's
3
+ * `parameters` map or `form` array). Mirrors the Staffbase channels API; the
4
+ * alerts, unacknowledged-bulletins and global-content widgets share this shape.
5
+ */
6
+ export interface ChannelLinkParameter {
7
+ type: string;
8
+ id: string;
9
+ format?: string;
10
+ value?: string | number;
11
+ required: boolean;
12
+ }
13
+ //# sourceMappingURL=ChannelLinkParameter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChannelLinkParameter.d.ts","sourceRoot":"","sources":["../../../../src/types/content/ChannelLinkParameter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;CAClB"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Option shape for channel/article selector dropdowns.
3
+ *
4
+ * `spaceName` and `spaceId` are optional enrichment used by widgets that group
5
+ * options by space; widgets that do not group simply omit them. This is the
6
+ * superset of the alerts (id/title) and unacknowledged-bulletins (+space)
7
+ * variants.
8
+ */
9
+ export interface DropdownOption {
10
+ id: string;
11
+ title: string;
12
+ /** Optional space name for display in selectors. */
13
+ spaceName?: string;
14
+ /** Optional space id for enrichment. */
15
+ spaceId?: string;
16
+ }
17
+ //# sourceMappingURL=DropdownOption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropdownOption.d.ts","sourceRoot":"","sources":["../../../../src/types/content/DropdownOption.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
@@ -0,0 +1,5 @@
1
+ export type { Channel } from './Channel';
2
+ export type { ChannelLink } from './ChannelLink';
3
+ export type { ChannelLinkParameter } from './ChannelLinkParameter';
4
+ export type { DropdownOption } from './DropdownOption';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/content/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACxC,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAClE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@favish/staffbase-utils",
3
- "version": "0.7.0",
3
+ "version": "0.9.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",
@@ -37,6 +42,11 @@
37
42
  "types": "./dist/src/widgets/react/index.d.ts",
38
43
  "import": "./dist/widgets/react.es.mjs",
39
44
  "require": "./dist/widgets/react.cjs.js"
45
+ },
46
+ "./types": {
47
+ "types": "./dist/src/types/content/index.d.ts",
48
+ "import": "./dist/types.es.mjs",
49
+ "require": "./dist/types.cjs.js"
40
50
  }
41
51
  },
42
52
  "repository": {