@flamingo-stack/openframe-frontend-core 0.0.744 → 0.0.747

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 (129) hide show
  1. package/dist/build/export-map.json +1 -1
  2. package/dist/{chunk-HTQJYN47.cjs → chunk-2CEQGGRN.cjs} +32 -32
  3. package/dist/{chunk-PYWHDPVC.cjs → chunk-4AWI6CCU.cjs} +38 -38
  4. package/dist/{chunk-FTYQS6VI.cjs → chunk-4DT5YXTM.cjs} +13 -13
  5. package/dist/{chunk-YJRMCFX3.cjs → chunk-4MGZYY6U.cjs} +7 -7
  6. package/dist/{chunk-HMSUYWSB.cjs → chunk-6RTHHU3S.cjs} +4 -4
  7. package/dist/{chunk-7YDF3QBN.cjs → chunk-7Y5U3Y4S.cjs} +320 -207
  8. package/dist/{chunk-GAGNKWOC.cjs → chunk-BBM2ICOY.cjs} +2 -2
  9. package/dist/{chunk-4N7KGOBS.cjs → chunk-BEC43GHL.cjs} +3 -3
  10. package/dist/{chunk-OC2LBQQJ.cjs → chunk-C7NTL2GV.cjs} +80 -80
  11. package/dist/{chunk-QZYF2YQ3.cjs → chunk-FCQCEQBY.cjs} +6 -6
  12. package/dist/{chunk-URVIPSAJ.cjs → chunk-HNLI4OU5.cjs} +14 -14
  13. package/dist/{chunk-2UBR53AN.cjs → chunk-HTMHDEIV.cjs} +4 -4
  14. package/dist/{chunk-NURAL5HD.cjs → chunk-IJA3OZWF.cjs} +24 -24
  15. package/dist/{chunk-ABLUMGCI.cjs → chunk-JHQNUWFM.cjs} +83 -33
  16. package/dist/{chunk-QSO56JZ2.cjs → chunk-JPSMPXCH.cjs} +90 -90
  17. package/dist/{chunk-UY6A6TEY.cjs → chunk-L2IQESTQ.cjs} +2 -2
  18. package/dist/{chunk-AT6ZI4CO.cjs → chunk-LLAKQT3B.cjs} +12 -12
  19. package/dist/{chunk-HHL23RFC.cjs → chunk-MA7T36JY.cjs} +35 -35
  20. package/dist/{chunk-H62FNZGG.cjs → chunk-O6QQ44I3.cjs} +18 -18
  21. package/dist/{chunk-LJ46XYYP.cjs → chunk-P7KTAXXE.cjs} +41 -27
  22. package/dist/{chunk-2JRCJV3M.cjs → chunk-PIQRV4EQ.cjs} +5 -5
  23. package/dist/{chunk-OWGLRE74.cjs → chunk-PSIKUDUV.cjs} +8 -8
  24. package/dist/{chunk-4A6OF4HI.cjs → chunk-PSSGIZXZ.cjs} +44 -44
  25. package/dist/{chunk-YIOWV7LS.cjs → chunk-QPSQ5WLG.cjs} +2 -2
  26. package/dist/{chunk-HJ4KGA2M.cjs → chunk-R3FXJXSQ.cjs} +1226 -1012
  27. package/dist/{chunk-65LJNDR2.cjs → chunk-TYW7NBP7.cjs} +20 -20
  28. package/dist/{chunk-U2O5YQRP.cjs → chunk-U6XWGK53.cjs} +33 -33
  29. package/dist/{chunk-35IQLGV3.cjs → chunk-WY4FKKCV.cjs} +74 -74
  30. package/dist/{chunk-JGZEHBBD.cjs → chunk-YIRX6C7V.cjs} +10 -10
  31. package/dist/{chunk-5TCIRWHL.cjs → chunk-YRULLK7N.cjs} +5 -5
  32. package/dist/{cloud-tenants-JPXAXSPE.cjs → cloud-tenants-QJZIF2JS.cjs} +13 -13
  33. package/dist/components/case-studies/index.cjs +31 -29
  34. package/dist/components/case-studies/share-experience-section.d.ts.map +1 -1
  35. package/dist/components/case-studies/share-experience-section.js +6 -5
  36. package/dist/components/chat/index.cjs +9 -9
  37. package/dist/components/contact/index.cjs +14 -14
  38. package/dist/components/docs/index.cjs +17 -17
  39. package/dist/components/embeds/index.cjs +14 -14
  40. package/dist/components/embeds/reddit-embed-client.d.ts +3 -1
  41. package/dist/components/embeds/reddit-embed-client.d.ts.map +1 -1
  42. package/dist/components/embeds/reddit-embed-client.js +5 -3
  43. package/dist/components/embeds/twitter-embed-client.d.ts +3 -1
  44. package/dist/components/embeds/twitter-embed-client.d.ts.map +1 -1
  45. package/dist/components/embeds/twitter-embed-client.js +5 -3
  46. package/dist/components/faq/index.cjs +15 -15
  47. package/dist/components/features/index.cjs +13 -13
  48. package/dist/components/help-center-pages/index.cjs +116 -116
  49. package/dist/components/index.cjs +125 -125
  50. package/dist/components/layout/page-heading.d.ts +16 -0
  51. package/dist/components/layout/page-heading.d.ts.map +1 -1
  52. package/dist/components/layout/page-heading.js +16 -2
  53. package/dist/components/meeting-scheduler/index.cjs +63 -63
  54. package/dist/components/navigation/index.cjs +16 -16
  55. package/dist/components/onboarding-guides/index.cjs +16 -16
  56. package/dist/components/product-demo/index.cjs +9 -9
  57. package/dist/components/related-content/index.cjs +7 -7
  58. package/dist/components/tickets/index.cjs +19 -19
  59. package/dist/components/ui/filter-checkbox-item.d.ts +8 -2
  60. package/dist/components/ui/filter-checkbox-item.d.ts.map +1 -1
  61. package/dist/components/ui/filter-checkbox-item.js +14 -4
  62. package/dist/components/ui/index.cjs +19 -13
  63. package/dist/components/ui/index.d.ts +1 -0
  64. package/dist/components/ui/index.d.ts.map +1 -1
  65. package/dist/components/ui/index.js +1 -0
  66. package/dist/components/ui/layout-hold.d.ts +4 -3
  67. package/dist/components/ui/layout-hold.d.ts.map +1 -1
  68. package/dist/components/ui/layout-hold.js +29 -9
  69. package/dist/components/ui/markdown/base-components.d.ts.map +1 -1
  70. package/dist/components/ui/markdown/base-components.js +3 -2
  71. package/dist/components/ui/markdown/rich/embed-overrides.d.ts.map +1 -1
  72. package/dist/components/ui/markdown/rich/embed-overrides.js +11 -8
  73. package/dist/components/ui/markdown-editor.d.ts.map +1 -1
  74. package/dist/components/ui/markdown-editor.js +4 -0
  75. package/dist/components/ui/markdown-link-command.d.ts +37 -0
  76. package/dist/components/ui/markdown-link-command.d.ts.map +1 -0
  77. package/dist/components/ui/markdown-link-command.js +180 -0
  78. package/dist/components/unified-filter-logic.js +1 -1
  79. package/dist/components/vendor-tag.d.ts +12 -0
  80. package/dist/components/vendor-tag.d.ts.map +1 -1
  81. package/dist/components/vendor-tag.js +50 -47
  82. package/dist/{devices-ONC4JOVH.cjs → devices-V55KQCAL.cjs} +14 -14
  83. package/dist/{embeddable-chat-7ZEGCDVF.cjs → embeddable-chat-5CDR4I6E.cjs} +80 -80
  84. package/dist/index.cjs +38 -18
  85. package/dist/{knowledge-G7XU5YST.cjs → knowledge-S3VGDRKR.cjs} +14 -14
  86. package/dist/{logs-5B7NY4G6.cjs → logs-K5E2BGZE.cjs} +21 -21
  87. package/dist/{policies-OYR3SLJN.cjs → policies-BWU4FRFE.cjs} +17 -17
  88. package/dist/{remote-session-N4PJB5FW.cjs → remote-session-IYT4LWJC.cjs} +7 -7
  89. package/dist/{scripts-6CWHTY6U.cjs → scripts-25UPGXZU.cjs} +20 -20
  90. package/dist/{software-update-AJPIY4SQ.cjs → software-update-F6UC7ULZ.cjs} +17 -17
  91. package/dist/{tickets-board-O753S4ZB.cjs → tickets-board-4MT6ZB4F.cjs} +8 -8
  92. package/dist/utils/format.d.ts.map +1 -1
  93. package/dist/utils/format.js +2 -3
  94. package/dist/utils/index.cjs +193 -28
  95. package/dist/utils/index.d.ts +2 -1
  96. package/dist/utils/index.d.ts.map +1 -1
  97. package/dist/utils/index.js +9 -6
  98. package/dist/utils/markdown-link.d.ts +44 -0
  99. package/dist/utils/markdown-link.d.ts.map +1 -0
  100. package/dist/utils/markdown-link.js +83 -0
  101. package/dist/utils/markdown-to-plain.d.ts +3 -16
  102. package/dist/utils/markdown-to-plain.d.ts.map +1 -1
  103. package/dist/utils/markdown-to-plain.js +33 -3
  104. package/dist/utils/vendor-classification.d.ts +43 -17
  105. package/dist/utils/vendor-classification.d.ts.map +1 -1
  106. package/dist/utils/vendor-classification.js +73 -22
  107. package/package.json +3 -1
  108. package/src/components/case-studies/share-experience-section.tsx +9 -6
  109. package/src/components/embeds/reddit-embed-client.tsx +7 -3
  110. package/src/components/embeds/twitter-embed-client.tsx +7 -3
  111. package/src/components/layout/page-heading.tsx +52 -11
  112. package/src/components/ui/filter-checkbox-item.tsx +21 -5
  113. package/src/components/ui/index.ts +1 -0
  114. package/src/components/ui/layout-hold.tsx +38 -10
  115. package/src/components/ui/markdown/base-components.tsx +5 -2
  116. package/src/components/ui/markdown/rich/embed-overrides.tsx +12 -9
  117. package/src/components/ui/markdown-editor.tsx +6 -0
  118. package/src/components/ui/markdown-link-command.tsx +252 -0
  119. package/src/components/unified-filter-logic.tsx +1 -1
  120. package/src/components/vendor-tag.tsx +73 -69
  121. package/src/utils/format.ts +2 -3
  122. package/src/utils/index.ts +8 -5
  123. package/src/utils/markdown-link.ts +148 -0
  124. package/src/utils/markdown-to-plain.ts +64 -22
  125. package/src/utils/vendor-classification.ts +113 -34
  126. package/dist/utils/format-text-stub.d.ts +0 -5
  127. package/dist/utils/format-text-stub.d.ts.map +0 -1
  128. package/dist/utils/format-text-stub.js +0 -20
  129. package/src/utils/format-text-stub.ts +0 -17
@@ -0,0 +1,148 @@
1
+ /**
2
+ * One link format for the markdown editors and one `rel` rule for the renderers.
3
+ *
4
+ * A FOLLOWED link is written as markdown, `[text](url)`, exactly as the editors always wrote it.
5
+ * A link with an authored `rel` (nofollow, sponsored or ugc, the values Google reads) is written as
6
+ * an HTML anchor, `<a href="url" rel="sponsored">text</a>`: markdown has no attribute syntax, and
7
+ * an HTML anchor is what stored content already uses for links that carry attributes (the
8
+ * sanitizer keeps `rel` on `a`). Reading back accepts both forms, so a link can be switched either
9
+ * way. Nothing is rewritten unless an editor changes a link.
10
+ *
11
+ * Server-safe: no React, no DOM.
12
+ */
13
+
14
+ /** The `rel` tokens an author may set on a link. Search engines read these; nothing else is kept. */
15
+ export const AUTHORED_LINK_REL_TOKENS = ['nofollow', 'ugc', 'sponsored'] as const;
16
+
17
+ export type AuthoredLinkRel = (typeof AUTHORED_LINK_REL_TOKENS)[number];
18
+
19
+ /** What a renderer adds to every link that opens in a new tab. */
20
+ const NEW_TAB_REL = 'noopener noreferrer';
21
+
22
+ /** The authored SEO tokens in a `rel` value, in their canonical order. */
23
+ export function authoredRelTokens(rel: string | readonly string[] | null | undefined): AuthoredLinkRel[] {
24
+ if (!rel) return [];
25
+ const given = new Set(
26
+ (typeof rel === 'string' ? rel.split(/\s+/) : rel).map(token => token.trim().toLowerCase()).filter(Boolean),
27
+ );
28
+ return AUTHORED_LINK_REL_TOKENS.filter(token => given.has(token));
29
+ }
30
+
31
+ /** Whether an authored `rel` asks search engines not to follow the link. */
32
+ export function isNofollowRel(rel: string | readonly string[] | null | undefined): boolean {
33
+ return authoredRelTokens(rel).includes('nofollow');
34
+ }
35
+
36
+ /**
37
+ * The `rel` a renderer writes for a link: the author's SEO tokens, plus `noopener noreferrer` when
38
+ * the link opens in a new tab. `undefined` when there is nothing to write.
39
+ */
40
+ export function renderedLinkRel(
41
+ authoredRel: string | readonly string[] | null | undefined,
42
+ opensInNewTab: boolean,
43
+ ): string | undefined {
44
+ const tokens: string[] = authoredRelTokens(authoredRel);
45
+ if (opensInNewTab) tokens.push(NEW_TAB_REL);
46
+ return tokens.length > 0 ? tokens.join(' ') : undefined;
47
+ }
48
+
49
+ /** A link as the editor's dialog edits it. */
50
+ export interface MarkdownLinkFields {
51
+ text: string;
52
+ url: string;
53
+ /** The authored `rel` values. Empty = a followed link. */
54
+ rel: AuthoredLinkRel[];
55
+ }
56
+
57
+ /** A link found in the editor's text, with the range it occupies. */
58
+ export interface MarkdownLinkMatch extends MarkdownLinkFields {
59
+ start: number;
60
+ end: number;
61
+ }
62
+
63
+ // `[text](url)` or `[text](url "title")`, never an image (`![…]`). The text may hold escaped brackets.
64
+ const MARKDOWN_LINK_RE = /(?<!!)\[((?:\\.|[^\]\\])*)\]\(\s*<?([^\s)>]*)>?(?:\s+"[^"]*")?\s*\)/g;
65
+ // One HTML anchor, attributes and text. Nested anchors are not valid HTML, so the first `</a>` ends it.
66
+ const HTML_LINK_RE = /<a\s([^>]*)>([\s\S]*?)<\/a\s*>/gi;
67
+
68
+ function htmlAttribute(attributes: string, name: string): string | null {
69
+ const match = new RegExp(`(?:^|\\s)${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s"'>]+))`, 'i').exec(attributes);
70
+ if (!match) return null;
71
+ return match[1] ?? match[2] ?? match[3] ?? '';
72
+ }
73
+
74
+ function decodeHtmlEntities(value: string): string {
75
+ return value
76
+ .replace(/&quot;/g, '"')
77
+ .replace(/&#39;/g, "'")
78
+ .replace(/&lt;/g, '<')
79
+ .replace(/&gt;/g, '>')
80
+ .replace(/&amp;/g, '&');
81
+ }
82
+
83
+ function escapeHtmlAttribute(value: string): string {
84
+ return value.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
85
+ }
86
+
87
+ function escapeHtmlText(value: string): string {
88
+ return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
89
+ }
90
+
91
+ /** Brackets end the link text and `<` would open raw HTML (CommonMark), so all three are escaped. */
92
+ function escapeMarkdownLinkText(value: string): string {
93
+ return value.replace(/([\\[\]<])/g, '\\$1');
94
+ }
95
+
96
+ function unescapeMarkdownLinkText(value: string): string {
97
+ return value.replace(/\\([\\[\]<])/g, '$1');
98
+ }
99
+
100
+ /** A URL inside `(…)` breaks on whitespace and unbalanced parentheses; percent-encode them. */
101
+ function encodeMarkdownUrl(url: string): string {
102
+ return url.replace(/\s/g, match => encodeURIComponent(match)).replace(/[()]/g, match => encodeURIComponent(match));
103
+ }
104
+
105
+ /**
106
+ * The link the selection `[selectionStart, selectionEnd]` is in or on, if any: a markdown link or an
107
+ * HTML anchor that contains the whole selection (a caret counts when it touches the link).
108
+ */
109
+ export function findMarkdownLinkAt(
110
+ text: string,
111
+ selectionStart: number,
112
+ selectionEnd: number = selectionStart,
113
+ ): MarkdownLinkMatch | null {
114
+ const from = Math.min(selectionStart, selectionEnd);
115
+ const to = Math.max(selectionStart, selectionEnd);
116
+ const contains = (start: number, end: number) => start <= from && to <= end;
117
+
118
+ for (const match of text.matchAll(HTML_LINK_RE)) {
119
+ const start = match.index ?? 0;
120
+ const end = start + match[0].length;
121
+ if (!contains(start, end)) continue;
122
+ const attributes = match[1] ?? '';
123
+ return {
124
+ start,
125
+ end,
126
+ text: decodeHtmlEntities(match[2] ?? ''),
127
+ url: decodeHtmlEntities(htmlAttribute(attributes, 'href') ?? ''),
128
+ rel: authoredRelTokens(htmlAttribute(attributes, 'rel')),
129
+ };
130
+ }
131
+ for (const match of text.matchAll(MARKDOWN_LINK_RE)) {
132
+ const start = match.index ?? 0;
133
+ const end = start + match[0].length;
134
+ if (!contains(start, end)) continue;
135
+ return { start, end, text: unescapeMarkdownLinkText(match[1] ?? ''), url: match[2] ?? '', rel: [] };
136
+ }
137
+ return null;
138
+ }
139
+
140
+ /** The text that writes a link: markdown when followed, an HTML anchor when it carries a `rel`. */
141
+ export function formatMarkdownLink({ text, url, rel }: MarkdownLinkFields): string {
142
+ const label = text.length > 0 ? text : url;
143
+ const tokens = authoredRelTokens(rel);
144
+ if (tokens.length > 0) {
145
+ return `<a href="${escapeHtmlAttribute(url)}" rel="${tokens.join(' ')}">${escapeHtmlText(label)}</a>`;
146
+ }
147
+ return `[${escapeMarkdownLinkText(label)}](${encodeMarkdownUrl(url)})`;
148
+ }
@@ -3,15 +3,24 @@
3
3
  * (article-body echo in JSON-LD) and chat entity-card preview (clamped previews
4
4
  * inside chat cards).
5
5
  *
6
- * The two consumers differ only in pre/post processing — `mode: 'article'`
7
- * strips code blocks + images + headings + list bullets and preserves paragraph
8
- * breaks; `mode: 'preview'` collapses everything to a single line. Both share
9
- * the same inline-marker strip (link / bold / italic / inline-code).
6
+ * The text is what a reader of the rendered page reads: the markdown is parsed with the SAME
7
+ * pipeline the renderer uses (remark with GFM and line breaks, then rehype with raw HTML, as in
8
+ * `components/ui/markdown/engine.tsx`), and the result is the `innerText` of that HTML
9
+ * (`hast-util-to-text`). So link, emphasis and heading syntax, raw HTML tags (`<a rel>`, `<div>`),
10
+ * escapes (`\<`) and entities (`&amp;`) all come out as their text; script and style content and
11
+ * comments do not. Code blocks and images are left out: their content is not prose.
10
12
  *
11
- * All regex patterns are linear (negated character classes, non-greedy with
12
- * bounded targets) — no nested quantifiers, no catastrophic backtracking on
13
- * pathological input.
13
+ * The two consumers differ only in whitespace — `mode: 'article'` keeps paragraph breaks;
14
+ * `mode: 'preview'` collapses everything to a single line.
14
15
  */
16
+ import type { Element, Root } from 'hast';
17
+ import { toText } from 'hast-util-to-text';
18
+ import rehypeRaw from 'rehype-raw';
19
+ import { remark } from 'remark';
20
+ import remarkBreaks from 'remark-breaks';
21
+ import remarkGfm from 'remark-gfm';
22
+ import remarkRehype from 'remark-rehype';
23
+ import { SKIP, visit } from 'unist-util-visit';
15
24
 
16
25
  export interface MarkdownToPlainOptions {
17
26
  /**
@@ -27,8 +36,9 @@ export interface MarkdownToPlainOptions {
27
36
  maxChars?: number;
28
37
  }
29
38
 
30
- /** Strip inline markdown markers (bold, italic, inline-code, links). Shared
31
- * by `extractSections`'s `stripFormattingMarkers` and `markdownToPlainText`. */
39
+ /** Strip inline markdown markers (bold, italic, inline-code, links) from ONE line of text.
40
+ * Shared by `extractSections`'s `stripFormattingMarkers` and the heading ids, whose output is
41
+ * an anchor: it stays a fixed, regex-only rule so no heading id ever moves. */
32
42
  export function stripInlineMarkdown(s: string): string {
33
43
  return s
34
44
  .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // [text](url) → text
@@ -37,26 +47,58 @@ export function stripInlineMarkdown(s: string): string {
37
47
  .replace(/`([^`]+)`/g, '$1'); // `inline code` → inline code
38
48
  }
39
49
 
50
+ // The renderer's own pipeline, up to the HTML tree. Built once; `runSync` has no async plugins.
51
+ const toHtmlTree = remark()
52
+ .use(remarkGfm)
53
+ .use(remarkBreaks)
54
+ .use(remarkRehype, { allowDangerousHtml: true })
55
+ .use(rehypeRaw);
56
+
57
+ /** Elements whose content is not prose: code blocks and images. */
58
+ const NOT_PROSE = new Set(['pre', 'img']);
59
+
60
+ const TABLE_SECTIONS = new Set(['thead', 'tbody', 'tfoot']);
61
+
62
+ function proseTree(markdown: string): Root {
63
+ const tree: Root = toHtmlTree.runSync(toHtmlTree.parse(markdown));
64
+ visit(tree, 'element', (node: Element, index, parent) => {
65
+ if (NOT_PROSE.has(node.tagName) && parent && index !== undefined) {
66
+ parent.children.splice(index, 1);
67
+ return [SKIP, index];
68
+ }
69
+ // `innerText` breaks between rows of the same `thead` / `tbody` only, so the last header row
70
+ // ran into the first body row ("What it buysEnthusiast"). A section followed by another ends
71
+ // its last row with a line break.
72
+ if (TABLE_SECTIONS.has(node.tagName) && parent && index !== undefined) {
73
+ const followedBySection = parent.children
74
+ .slice(index + 1)
75
+ .some(sibling => sibling.type === 'element' && TABLE_SECTIONS.has(sibling.tagName));
76
+ const rows = node.children.filter(
77
+ (child): child is Element => child.type === 'element' && child.tagName === 'tr',
78
+ );
79
+ const lastRow = rows[rows.length - 1];
80
+ if (followedBySection && lastRow) {
81
+ lastRow.children.push({ type: 'element', tagName: 'br', properties: {}, children: [] });
82
+ }
83
+ }
84
+ return undefined;
85
+ });
86
+ return tree;
87
+ }
88
+
40
89
  export function markdownToPlainText(markdown: string, options: MarkdownToPlainOptions = {}): string {
41
90
  const { mode = 'article', maxChars } = options;
42
91
 
43
- let out = markdown
44
- // Fenced code blocks — must run BEFORE inline strippers (otherwise the
45
- // backtick-grave strip below grazes them).
46
- .replace(/```[\s\S]*?```/g, '')
47
- // Images — `![alt](src)` → empty (we drop them entirely in plain text).
48
- .replace(/!\[[^\]]*\]\([^)]+\)/g, '');
49
-
50
- out = stripInlineMarkdown(out)
51
- // Heading markers (any depth).
52
- .replace(/^#+\s*/gm, '')
53
- // List bullets at start-of-line.
54
- .replace(/^\s*[-*+]\s+/gm, '');
92
+ let out = toText(proseTree(markdown));
55
93
 
56
94
  if (mode === 'preview') {
57
95
  out = out.replace(/\s+/g, ' ').trim();
58
96
  } else {
59
- out = out.replace(/\n{3,}/g, '\n\n').trim();
97
+ out = out
98
+ // No spaces around a line break (a soft break keeps the space that followed it).
99
+ .replace(/[^\S\n]*\n[^\S\n]*/g, '\n')
100
+ .replace(/\n{3,}/g, '\n\n')
101
+ .trim();
60
102
  }
61
103
 
62
104
  if (maxChars != null && out.length > maxChars) {
@@ -1,59 +1,138 @@
1
1
  /**
2
- * Vendor classifications: the ONE vocabulary of `vendor_classification.classification`.
2
+ * Vendor classifications: whatever `vendor_classification.classification` holds on the
3
+ * server. The database owns the vocabulary (its CHECK constraint is the list), the catalog
4
+ * builds its filters from the rows that exist, and nothing here limits which values are valid.
3
5
  *
4
- * A vendor may carry several (an OpenFrame product is `open_source` and
5
- * `openframe_selected`). The two OpenFrame ones are drawn with the OpenFrame
6
- * mark and ONE word, everywhere: a tag on a card, a filter in the catalog.
6
+ * This module only ENRICHES the values we want to present specially: a curated label, a
7
+ * tooltip description and a group. A value with no entry still works everywhere, labelled
8
+ * by title case. To present a new value better, add an entry here; to make it exist, add it
9
+ * to the database.
7
10
  *
8
- * - `openframe_selected`: a tool OpenFrame is built on, picked by the team.
9
- * - `openframe_shipped`: a tool or OpenFrame product that is in the released product today.
10
- * - `openframe_connect`: a service OpenFrame connects to and manages.
11
+ * Groups:
12
+ * - `license`: how the software is licensed.
13
+ * - `lifecycle`: where the product is in its life (a tag and a filter; a card's one tag stays the license).
14
+ * - `openframe`: drawn with the OpenFrame mark and ONE word (`word`).
11
15
  */
12
- export const VENDOR_CLASSIFICATIONS = [
13
- 'open_source',
14
- 'commercial',
15
- 'openframe_selected',
16
- 'openframe_shipped',
17
- 'openframe_connect',
18
- ] as const;
19
-
20
- export type VendorClassificationValue = (typeof VENDOR_CLASSIFICATIONS)[number];
21
-
22
- export type OpenFrameClassification = Extract<VendorClassificationValue, `openframe_${string}`>;
23
-
24
- export interface OpenFrameClassificationCopy {
25
- /** The word drawn beside the OpenFrame mark. */
26
- word: string;
27
- /** The full name, for plain-text surfaces (a select option, an aria label). */
16
+ export type VendorClassificationValue = string;
17
+
18
+ export type VendorClassificationGroup = 'license' | 'lifecycle' | 'openframe';
19
+
20
+ export interface VendorClassificationCopy {
21
+ /** The label on a tag, a filter and a plain-text surface. */
28
22
  label: string;
29
23
  /** What the classification means, for a tooltip. */
30
24
  description: string;
25
+ group: VendorClassificationGroup;
26
+ /** OpenFrame group only: the one word drawn beside the OpenFrame mark. */
27
+ word?: string;
28
+ /** The icon drawn beside the label, by name (resolved by the shared icon resolver), and its tone. */
29
+ icon?: VendorClassificationIconConfig;
30
+ }
31
+
32
+ /**
33
+ * A classification's icon, as data: `name` is any name the shared resolver knows (an alias such
34
+ * as `openframe-logo`, an icon of the design set by its kebab name, or a lucide name). `tone`:
35
+ * `accent` (the brand colour), `neutral` (secondary text on a tile) or `warning`.
36
+ */
37
+ export interface VendorClassificationIconConfig {
38
+ name: string;
39
+ tone: 'accent' | 'neutral' | 'warning';
31
40
  }
32
41
 
33
- export const OPENFRAME_CLASSIFICATIONS: Record<OpenFrameClassification, OpenFrameClassificationCopy> = {
42
+ /** In display order: a filter list shows OpenFrame first, then license, then lifecycle. */
43
+ export const VENDOR_CLASSIFICATION_COPY: Readonly<Record<string, VendorClassificationCopy>> = {
34
44
  openframe_selected: {
35
- word: 'Selected',
36
45
  label: 'OpenFrame Selected',
46
+ word: 'Selected',
37
47
  description:
38
48
  'OpenFrame is a unified platform that integrates multiple open-source IT and security tools into a single dashboard for MSPs. This filter shows vendors selected by our team for their excellence, community support, and MSP-specific value.',
49
+ group: 'openframe',
50
+ icon: { name: 'openframe-logo', tone: 'accent' },
51
+ },
52
+ openframe_connect: {
53
+ label: 'OpenFrame Connect',
54
+ word: 'Connect',
55
+ description:
56
+ 'Services OpenFrame connects to and manages for every client, such as Microsoft 365 and Google Workspace, beside devices and tickets.',
57
+ group: 'openframe',
58
+ icon: { name: 'openframe-logo', tone: 'accent' },
39
59
  },
40
60
  openframe_shipped: {
41
- word: 'Shipped',
42
61
  label: 'OpenFrame Shipped',
62
+ word: 'Shipped',
43
63
  description: 'Tools and OpenFrame products that are in the released OpenFrame product today, not on the roadmap.',
64
+ group: 'openframe',
65
+ icon: { name: 'openframe-logo', tone: 'accent' },
44
66
  },
45
- openframe_connect: {
46
- word: 'Connect',
47
- label: 'OpenFrame Connect',
67
+ open_source: {
68
+ label: 'Open Source',
69
+ description: 'Released under an OSI-approved open-source license.',
70
+ group: 'license',
71
+ icon: { name: 'code', tone: 'accent' },
72
+ },
73
+ source_available: {
74
+ label: 'Source-available',
48
75
  description:
49
- 'Services OpenFrame connects to and manages for every client, such as Microsoft 365 and Google Workspace, beside devices and tickets.',
76
+ 'The source code is public, but the license restricts how it may be used (for example SSPL, BSL, the Elastic License, or limits on company size or on offering it as a service).',
77
+ group: 'license',
78
+ icon: { name: 'file-code', tone: 'neutral' },
79
+ },
80
+ commercial: {
81
+ label: 'Commercial',
82
+ description: 'Proprietary software sold by the vendor.',
83
+ group: 'license',
84
+ icon: { name: 'dollar', tone: 'neutral' },
85
+ },
86
+ end_of_life: {
87
+ label: 'End of life',
88
+ description: 'The vendor has discontinued or retired the product. No new releases.',
89
+ group: 'lifecycle',
90
+ icon: { name: 'alert-triangle', tone: 'warning' },
91
+ },
92
+ end_of_support: {
93
+ label: 'End of support',
94
+ description: 'The vendor no longer provides support or security fixes, though the product can still be obtained.',
95
+ group: 'lifecycle',
96
+ icon: { name: 'clock', tone: 'warning' },
97
+ },
98
+ unmaintained: {
99
+ label: 'Unmaintained',
100
+ description: 'No release for years and no official end-of-life notice.',
101
+ group: 'lifecycle',
102
+ icon: { name: 'pause-circle', tone: 'warning' },
50
103
  },
51
104
  };
52
105
 
53
- export function isVendorClassification(value: string): value is VendorClassificationValue {
54
- return (VENDOR_CLASSIFICATIONS as readonly string[]).includes(value);
106
+ /** The enrichment of a classification, or undefined for a value we do not present specially. */
107
+ export function vendorClassificationCopy(value: string | null | undefined): VendorClassificationCopy | undefined {
108
+ if (!value || !Object.prototype.hasOwnProperty.call(VENDOR_CLASSIFICATION_COPY, value)) return undefined;
109
+ return VENDOR_CLASSIFICATION_COPY[value];
110
+ }
111
+
112
+ /** The group of a classification, or undefined for a value with no enrichment. */
113
+ export function vendorClassificationGroup(value: string | null | undefined): VendorClassificationGroup | undefined {
114
+ return vendorClassificationCopy(value)?.group;
115
+ }
116
+
117
+ /** A classification drawn with the OpenFrame mark (it has a `word`). */
118
+ export function isOpenFrameClassification(value: string | null | undefined): boolean {
119
+ return vendorClassificationGroup(value) === 'openframe';
55
120
  }
56
121
 
57
- export function isOpenFrameClassification(value: string | null | undefined): value is OpenFrameClassification {
58
- return !!value && Object.prototype.hasOwnProperty.call(OPENFRAME_CLASSIFICATIONS, value);
122
+ const DISPLAY_ORDER = Object.keys(VENDOR_CLASSIFICATION_COPY);
123
+
124
+ /**
125
+ * Sort order for a list of classifications (a filter list): the enriched values in their
126
+ * display order (OpenFrame Selected, Connect, Shipped, then license, then lifecycle), then
127
+ * every other value the server holds, alphabetically.
128
+ */
129
+ export function compareVendorClassifications(a: string, b: string): number {
130
+ const ia = DISPLAY_ORDER.indexOf(a);
131
+ const ib = DISPLAY_ORDER.indexOf(b);
132
+ if (ia !== -1 || ib !== -1) {
133
+ if (ia === -1) return 1;
134
+ if (ib === -1) return -1;
135
+ return ia - ib;
136
+ }
137
+ return a.localeCompare(b);
59
138
  }
@@ -1,5 +0,0 @@
1
- export declare function formatText(text: string): string;
2
- export declare function truncateText(text: string, maxLength: number): string;
3
- export declare function formatClassification(classification: string): string;
4
- export declare function formatPricingModel(pricing: string): string;
5
- //# sourceMappingURL=format-text-stub.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-text-stub.d.ts","sourceRoot":"","sources":["../../src/utils/format-text-stub.ts"],"names":[],"mappings":"AACA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAGpE;AAED,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1D"}
@@ -1,20 +0,0 @@
1
- "use client";
2
- function formatText(text) {
3
- return text;
4
- }
5
- function truncateText(text, maxLength) {
6
- if (text.length <= maxLength) return text;
7
- return text.slice(0, maxLength) + "...";
8
- }
9
- function formatClassification(classification) {
10
- return classification.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
11
- }
12
- function formatPricingModel(pricing) {
13
- return pricing.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
14
- }
15
- export {
16
- formatClassification,
17
- formatPricingModel,
18
- formatText,
19
- truncateText
20
- };
@@ -1,17 +0,0 @@
1
- // Stub for format-text utilities
2
- export function formatText(text: string): string {
3
- return text;
4
- }
5
-
6
- export function truncateText(text: string, maxLength: number): string {
7
- if (text.length <= maxLength) return text;
8
- return text.slice(0, maxLength) + '...';
9
- }
10
-
11
- export function formatClassification(classification: string): string {
12
- return classification.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase());
13
- }
14
-
15
- export function formatPricingModel(pricing: string): string {
16
- return pricing.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase());
17
- }