@scalio-cloud/ui 0.68.0 → 0.70.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
@@ -749,6 +749,13 @@ markdownOutline(page.body) // [{ level, text, id }] for a table of contents; h
749
749
  `labels` overrides the callout titles (`{ note, tip, important, warning, caution }`). Also exported:
750
750
  `parseMarkdownBlocks`, `parseMarkdownInline`, `markdownHeadingId`, `safeHref`. Test IDs: `callout-<kind>`.
751
751
 
752
+ From 0.70.0: `pageLinks` reads `[[Title]]`, `[[KEY:Title]]` and `[[Title|text]]` as page links (shown as text with a
753
+ dotted line, `.scalio-md-pagelink`, unless the app renders them). `render={{ image, link, pagelink }}` puts the app's
754
+ own elements in: `image(node, key)`, `link(node, key, children)`, `pagelink(node, key)`; a function that returns
755
+ `undefined` keeps the building block's element (Folio: images of the space, router links, resolved page links). Also
756
+ `markdownPageLinks(text)` (every page link once, not in code), `markdownPageLinkKey(space, title)` and
757
+ `parseMarkdownPageLink(inner)`.
758
+
752
759
  ## shadcn/ui components (from 0.38.0)
753
760
 
754
761
  One copy of the shadcn/ui components the apps used to keep in `src/components/ui` (code-quality plan QA6, decision
package/nav.css CHANGED
@@ -330,6 +330,21 @@
330
330
  .dark .scalio-notice.is-warn { --notice-tone: 245 158 11; }
331
331
  .dark .scalio-notice.is-error { --notice-tone: 248 113 113; }
332
332
  .dark .scalio-notice { background: rgb(var(--notice-tone) / 0.12); }
333
+ /* On/off switch: <input type="checkbox" role="switch" class="scalio-switch">, a slider like the shadcn Switch. */
334
+ .scalio-switch {
335
+ appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 2.75rem; height: 1.5rem; margin: 0;
336
+ border: 2px solid transparent; border-radius: 9999px; background: hsl(var(--input)); cursor: pointer;
337
+ transition: background-color 0.15s ease;
338
+ }
339
+ .scalio-switch::before {
340
+ content: ""; position: absolute; top: 0; left: 0; width: 1.25rem; height: 1.25rem; border-radius: 50%;
341
+ background: hsl(var(--background)); box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); transition: transform 0.15s ease;
342
+ }
343
+ .scalio-switch:checked { background: hsl(var(--primary)); }
344
+ .scalio-switch:checked::before { transform: translateX(1.25rem); }
345
+ .scalio-switch:disabled { cursor: not-allowed; opacity: 0.5; }
346
+ .scalio-switch:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
347
+ @media (prefers-reduced-motion: reduce) { .scalio-switch, .scalio-switch::before { transition: none; } }
333
348
  .scalio-badge {
334
349
  display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.0625rem 0.375rem; border: 1px solid; border-radius: 2px;
335
350
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap;
@@ -932,6 +947,7 @@ ul.scalio-notice { flex-direction: column; gap: 0.25rem; padding-left: 2rem; lis
932
947
  .scalio-md-h5, .scalio-md-h6 { font-size: 0.875rem; }
933
948
  .scalio-md-h6 { color: hsl(var(--muted-foreground)); }
934
949
  .scalio-md-link { color: hsl(var(--primary)); text-decoration: underline; }
950
+ .scalio-md-pagelink { text-decoration: underline dotted; }
935
951
  .scalio-md-code { padding: 0.125rem 0.25rem; border-radius: 2px; background: hsl(var(--secondary)); font-family: 'JetBrains Mono', monospace; font-size: 0.85em; }
936
952
  .scalio-md-pre { padding: 0.75rem; border-radius: 2px; background: hsl(var(--secondary)); font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; overflow-x: auto; white-space: pre; }
937
953
  .scalio-md-rule { border: 0; border-top: 1px solid hsl(var(--border)); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalio-cloud/ui",
3
- "version": "0.68.0",
3
+ "version": "0.70.0",
4
4
  "description": "Scalio Control Room design tokens, Tailwind preset, self-hosted fonts, the shared app header, sign-in layout, sidebar and page blocks",
5
5
  "license": "SEE LICENSE IN README.md",
6
6
  "private": false,
package/react/ai.js CHANGED
@@ -31,7 +31,7 @@ const LABELS = {
31
31
  title: "KI-Assistent",
32
32
  hint: "KI ist eine Option: Sie erklärt, fasst zusammen und schlägt vor. Was etwas ändert, bestätigen Sie immer selbst.",
33
33
  enable: "KI einschalten",
34
- enableHint: "Aus: alle KI-Funktionen sind ausgeblendet.",
34
+ enableHint: "Ausgeschaltet sind alle KI-Funktionen ausgeblendet.",
35
35
  statusOff: "Aus",
36
36
  statusReady: "Bereit",
37
37
  statusSetup: "Einrichtung nötig",
@@ -96,7 +96,7 @@ const LABELS = {
96
96
  title: "AI assistant",
97
97
  hint: "AI is optional: it explains, summarises and suggests. Anything that changes something you always confirm yourself.",
98
98
  enable: "Turn on AI",
99
- enableHint: "Off: all AI features are hidden.",
99
+ enableHint: "When off, all AI features are hidden.",
100
100
  statusOff: "Off",
101
101
  statusReady: "Ready",
102
102
  statusSetup: "Setup needed",
package/react/markdown.js CHANGED
@@ -129,14 +129,26 @@ function parseBlocks(src) {
129
129
  return blocks;
130
130
  }
131
131
 
132
- // code | image | link | bold | strike | italic | bare url
133
- const INLINE = /(`+)([\s\S]*?[^`])\1(?!`)|!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|\*\*([\s\S]+?)\*\*|__([\s\S]+?)__|~~([\s\S]+?)~~|\*([^*\s][^*]*?)\*|(?<![\w])_([^_\s][^_]*?)_(?![\w])|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g;
132
+ // [[Title]], [[KEY:Title]] and [[Title|text]]: a link to another page by its title (Folio). KEY is a space key.
133
+ const PAGE_LINK = /^\s*(?:([A-Z][A-Z0-9]{1,9})\s*:\s*)?([^|]*?)\s*(?:\\?\|\s*(.*?)\s*)?$/; // \| in a table cell
134
+ function parsePageLink(inner) {
135
+ const m = String(inner || "").match(PAGE_LINK);
136
+ const title = m ? m[2].replace(/\s+/g, " ") : "";
137
+ return title ? { space: m[1] || "", title, label: m[3] || "" } : null;
138
+ }
139
+
140
+ // code | image | link | bold | strike | italic | bare url (| page link, only with the option pageLinks)
141
+ const INLINE_SRC = "(`+)([\\s\\S]*?[^`])\\1(?!`)|!\\[([^\\]]*)\\]\\(([^)\\s]+)(?:\\s+\"[^\"]*\")?\\)|\\[([^\\]]+)\\]\\(([^)\\s]+)(?:\\s+\"[^\"]*\")?\\)|\\*\\*([\\s\\S]+?)\\*\\*|__([\\s\\S]+?)__|~~([\\s\\S]+?)~~|\\*([^*\\s][^*]*?)\\*|(?<![\\w])_([^_\\s][^_]*?)_(?![\\w])|(https?:\\/\\/[^\\s<>()]+[^\\s<>().,;:!?])";
142
+ const INLINE = new RegExp(INLINE_SRC, "g");
143
+ const INLINE_PAGES = new RegExp(INLINE_SRC + "|\\[\\[([^[\\]\\n]+)\\]\\]", "g");
134
144
 
135
- function parseInline(src) {
145
+ // opts.pageLinks: [[...]] becomes {type: "pagelink", space, title, label} (else it stays text).
146
+ function parseInline(src, opts) {
147
+ const pages = !!(opts && opts.pageLinks);
136
148
  const out = [];
137
149
  const text = String(src || "");
138
150
  let last = 0;
139
- for (const m of text.matchAll(INLINE)) {
151
+ for (const m of text.matchAll(pages ? INLINE_PAGES : INLINE)) {
140
152
  if (m.index > last) out.push({ type: "text", text: text.slice(last, m.index) });
141
153
  if (m[1]) out.push({ type: "code", text: m[2].trim() ? m[2].replace(/^ (.*) $/, "$1") : m[2] });
142
154
  else if (m[4] !== undefined) {
@@ -144,11 +156,15 @@ function parseInline(src) {
144
156
  out.push(href ? { type: "image", alt: m[3], href } : { type: "text", text: m[0] });
145
157
  } else if (m[6] !== undefined) {
146
158
  const href = safeHref(m[6]);
147
- out.push(href ? { type: "link", href, children: parseInline(m[5]) } : { type: "text", text: m[5] });
148
- } else if (m[7] !== undefined || m[8] !== undefined) out.push({ type: "bold", children: parseInline(m[7] ?? m[8]) });
149
- else if (m[9] !== undefined) out.push({ type: "strike", children: parseInline(m[9]) });
150
- else if (m[10] !== undefined || m[11] !== undefined) out.push({ type: "italic", children: parseInline(m[10] ?? m[11]) });
159
+ out.push(href ? { type: "link", href, children: parseInline(m[5], opts) } : { type: "text", text: m[5] });
160
+ } else if (m[7] !== undefined || m[8] !== undefined) out.push({ type: "bold", children: parseInline(m[7] ?? m[8], opts) });
161
+ else if (m[9] !== undefined) out.push({ type: "strike", children: parseInline(m[9], opts) });
162
+ else if (m[10] !== undefined || m[11] !== undefined) out.push({ type: "italic", children: parseInline(m[10] ?? m[11], opts) });
151
163
  else if (m[12]) out.push({ type: "link", href: m[12], children: [{ type: "text", text: m[12] }] });
164
+ else if (m[13] !== undefined) {
165
+ const link = parsePageLink(m[13]);
166
+ out.push(link ? Object.assign({ type: "pagelink" }, link) : { type: "text", text: m[0] });
167
+ }
152
168
  last = m.index + m[0].length;
153
169
  }
154
170
  if (last < text.length) out.push({ type: "text", text: text.slice(last) });
@@ -165,8 +181,53 @@ function outline(src) {
165
181
  .map((b) => ({ level: b.level, text: b.text, id: headingId(b.text) }));
166
182
  }
167
183
 
184
+ const pageLinkKey = (space, title) => `${space || ""}:${String(title || "").trim().replace(/\s+/g, " ").toLowerCase()}`;
185
+
186
+ // Every [[page link]] of a text (not in code), once per space and title.
187
+ function pageLinks(src) {
188
+ const found = new Map();
189
+ const nodes = (ns) => ns.forEach((n) => {
190
+ if (n.type === "pagelink") { const k = pageLinkKey(n.space, n.title); if (!found.has(k)) found.set(k, { space: n.space, title: n.title }); }
191
+ else if (n.children) nodes(n.children);
192
+ });
193
+ const inl = (text) => nodes(parseInline(text, { pageLinks: true }));
194
+ const list = (l) => l.items.forEach((it) => { inl(it.text); if (it.children) list(it.children); });
195
+ const walk = (blocks) => blocks.forEach((b) => {
196
+ if (b.type === "heading" || b.type === "paragraph") inl(b.text);
197
+ else if (b.type === "list") list(b);
198
+ else if (b.type === "table") [b.head, ...b.rows].forEach((r) => r.forEach(inl));
199
+ else if (b.blocks) walk(b.blocks);
200
+ });
201
+ walk(parseBlocks(src));
202
+ return [...found.values()];
203
+ }
204
+
205
+ // The app's own elements (props.render): image(node, key), link(node, key, children), pagelink(node, key). A function
206
+ // that returns undefined leaves the building block's own element.
207
+ const Ctx = React.createContext({ render: {}, opts: null });
208
+
209
+ function own(ctx, kind, args) {
210
+ const fn = ctx.render && ctx.render[kind];
211
+ if (typeof fn !== "function") return undefined;
212
+ return fn.apply(null, args);
213
+ }
214
+
168
215
  function Inline(props) {
216
+ const ctx = React.useContext(Ctx);
169
217
  return h(React.Fragment, null, props.nodes.map((n, i) => {
218
+ if (n.type === "image") {
219
+ const mine = own(ctx, "image", [n, i]);
220
+ if (mine !== undefined) return mine;
221
+ }
222
+ if (n.type === "link") {
223
+ const mine = own(ctx, "link", [n, i, h(Inline, { nodes: n.children })]);
224
+ if (mine !== undefined) return mine;
225
+ }
226
+ if (n.type === "pagelink") {
227
+ const mine = own(ctx, "pagelink", [n, i]);
228
+ if (mine !== undefined) return mine;
229
+ return h("span", { key: i, className: "scalio-md-pagelink" }, n.label || n.title);
230
+ }
170
231
  if (n.type === "code") return h("code", { key: i, className: "scalio-md-code" }, n.text);
171
232
  if (n.type === "bold") return h("strong", { key: i }, h(Inline, { nodes: n.children }));
172
233
  if (n.type === "italic") return h("em", { key: i }, h(Inline, { nodes: n.children }));
@@ -183,7 +244,11 @@ function Inline(props) {
183
244
  }));
184
245
  }
185
246
 
186
- const inline = (text) => h(Inline, { nodes: parseInline(text) });
247
+ function InlineText(props) {
248
+ const ctx = React.useContext(Ctx);
249
+ return h(Inline, { nodes: parseInline(props.text, ctx.opts) });
250
+ }
251
+ const inline = (text) => h(InlineText, { text });
187
252
 
188
253
  function List(props) {
189
254
  const list = props.list;
@@ -223,11 +288,16 @@ function Blocks(props) {
223
288
  }));
224
289
  }
225
290
 
226
- // <Markdown text="..." lang="de" /> shows the text; labels.markdown overrides the callout titles.
291
+ // <Markdown text="..." lang="de" /> shows the text; labels.markdown overrides the callout titles. pageLinks reads
292
+ // [[...]] as page links; render = {image, link, pagelink} puts the app's own elements in (Folio: images of the space,
293
+ // router links, resolved page links).
227
294
  function Markdown(props) {
228
295
  const L = Object.assign({}, labelsFor(props.lang).markdown, props.labels);
229
- return h("div", { className: "scalio-md" + (props.className ? " " + props.className : ""), "data-testid": props.testId },
230
- h(Blocks, { blocks: parseBlocks(props.text), labels: L }));
296
+ const ctx = React.useMemo(() => ({ render: props.render || {}, opts: props.pageLinks ? { pageLinks: true } : null }),
297
+ [props.render, props.pageLinks]);
298
+ return h(Ctx.Provider, { value: ctx },
299
+ h("div", { className: "scalio-md" + (props.className ? " " + props.className : ""), "data-testid": props.testId },
300
+ h(Blocks, { blocks: parseBlocks(props.text), labels: L })));
231
301
  }
232
302
 
233
303
  module.exports = {
@@ -236,5 +306,8 @@ module.exports = {
236
306
  parseMarkdownInline: parseInline,
237
307
  markdownOutline: outline,
238
308
  markdownHeadingId: headingId,
309
+ markdownPageLinks: pageLinks,
310
+ markdownPageLinkKey: pageLinkKey,
311
+ parseMarkdownPageLink: parsePageLink,
239
312
  safeHref,
240
313
  };