@genai-fi/base 4.0.0 → 4.0.1

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
@@ -1,18 +1,15 @@
1
- # Introduction
1
+ # Introduction
2
+
2
3
  [Generation AI](https://www.generation-ai-stn.fi) base code library for all common components of our educational apps.
3
4
 
4
5
  # Getting Started
6
+
5
7
  ```bash
6
- npm install @knicos/genai-base
8
+ npm install @genai-fi/base
7
9
  ```
8
10
 
9
- ```typescript
10
- import { ConnectionMonitor } from '@knicos/genai-base';
11
-
12
- function MyComponent() {
13
- return <ConnectionMonitor />;
14
- }
15
- ```
11
+ See the Ladle stories in the `src` folder.
16
12
 
17
13
  # Build and Test
14
+
18
15
  Use `npm run build` to build the library in the `dist` folder. Testing uses vitest with `npm test`.
@@ -12,6 +12,7 @@ import "./style/theme.js";
12
12
  import "./util/canvas.js";
13
13
  import "./FileSaver.min-DhePf63e.js";
14
14
  import "./components/BusyButton/BusyButton.js";
15
+ import "./components/WorkflowLayout/lines.js";
15
16
  import "./components/WorkflowLayout/Widget.js";
16
17
  import "./components/IconMenu/context.js";
17
18
  import "@emotion/react";
@@ -1567,7 +1568,7 @@ const ze = /* @__PURE__ */ le(ke), Ve = "_link_1udre_3", He = "_container_1udre_
1567
1568
  }, Ye = me(/* @__PURE__ */ U("path", {
1568
1569
  d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"
1569
1570
  }), "ContentCopy");
1570
- function ln({ url: r, open: o, onClose: i }) {
1571
+ function fn({ url: r, open: o, onClose: i }) {
1571
1572
  var s;
1572
1573
  const { t: n } = he("translation"), t = ue(null), e = ae(() => {
1573
1574
  navigator.clipboard.writeText(r);
@@ -1624,7 +1625,7 @@ function ln({ url: r, open: o, onClose: i }) {
1624
1625
  );
1625
1626
  }
1626
1627
  export {
1627
- ln as D,
1628
+ fn as D,
1628
1629
  ze as q,
1629
1630
  je as s
1630
1631
  };
@@ -1,24 +1,25 @@
1
1
  import { jsx as o } from "react/jsx-runtime";
2
- import './assets/SvgLayer.css';const n = "_svglayer_yu6sc_3", y = "_workspace_yu6sc_10", d = "_container_yu6sc_19", g = {
3
- svglayer: n,
4
- workspace: y,
5
- container: d
2
+ import './assets/SvgLayer.css';const d = "_svglayer_yu6sc_3", n = "_workspace_yu6sc_10", y = "_container_yu6sc_19", i = {
3
+ svglayer: d,
4
+ workspace: n,
5
+ container: y
6
6
  }, a = 20;
7
- function i({ lines: c }) {
7
+ function h({ lines: c }) {
8
8
  return /* @__PURE__ */ o(
9
9
  "svg",
10
10
  {
11
- className: g.svglayer,
11
+ className: i.svglayer,
12
12
  xmlns: "http://www.w3.org/2000/svg",
13
13
  width: "100%",
14
14
  height: "100%",
15
15
  "aria-hidden": !0,
16
- children: c.map((r, e) => {
17
- const s = r.direction === "horizontal" ? a : 0, t = r.direction === "vertical" ? a : 0;
16
+ children: c.map((t, e) => {
17
+ const r = t.direction === "horizontal" ? a : 0, s = t.direction === "vertical" ? a : 0;
18
18
  return /* @__PURE__ */ o(
19
19
  "path",
20
20
  {
21
- d: `M ${r.x1} ${r.y1} C ${r.x1 + s} ${r.y1 + t}, ${r.x2 - s} ${r.y2 - t}, ${r.x2} ${r.y2}`,
21
+ "data-testid": `line-${t.id1}-${t.id2}`,
22
+ d: `M ${t.x1} ${t.y1} C ${t.x1 + r} ${t.y1 + s}, ${t.x2 - r} ${t.y2 - s}, ${t.x2} ${t.y2}`,
22
23
  fill: "none",
23
24
  stroke: "rgb(174, 37, 174)",
24
25
  strokeWidth: "2",
@@ -31,6 +32,6 @@ function i({ lines: c }) {
31
32
  );
32
33
  }
33
34
  export {
34
- i as S,
35
- g as s
35
+ h as S,
36
+ i as s
36
37
  };
@@ -1 +1 @@
1
- ._widget_becos_3{background:#fff;border-radius:6px;padding:0;display:flex;flex-direction:column;box-shadow:2px 2px 4px #bbb;flex-shrink:0;animation:_fadein_becos_1 .5s 1;box-sizing:border-box;border:1px solid white;position:relative}@media only screen and (max-height: 500px),(max-width: 700px){._widget_becos_3{max-width:100%}}@keyframes _fadein_becos_1{0%{opacity:.1}to{opacity:1}}._widgetDisabled_becos_32{pointer-events:none;opacity:.5}._widgetActive_becos_38{border:1px dashed #008297}._widget_title_becos_43{font-size:14pt;font-weight:700;margin:0}._widget_header_becos_49{display:flex;justify-content:left;border-bottom:1px solid #008297;padding:.6rem 1rem;align-items:center}._widget_header_becos_49 input{padding:.2rem;height:initial;box-sizing:border-box;border:2px solid transparent;cursor:pointer;margin-right:1rem}._widget_header_becos_49 input:focus{border:2px solid #008297;border-radius:5px;cursor:initial}._widget_header_becos_49 fieldset{border:none}._widget_menu_becos_76{flex-grow:1;text-align:right}._widget_content_becos_81{padding:1rem;display:flex;flex-direction:column}._widget_content_becos_81>p{color:#444;font-size:12pt;margin:1rem 1.4rem}
1
+ ._widget_9aoli_3{background:#fff;border-radius:6px;padding:0;display:flex;flex-direction:column;box-shadow:2px 2px 4px #bbb;flex-shrink:0;animation:_fadein_9aoli_1 .5s 1;box-sizing:border-box;position:relative;overflow:hidden}@media only screen and (max-height: 500px),(max-width: 700px){._widget_9aoli_3{max-width:100%}}@keyframes _fadein_9aoli_1{0%{opacity:.1}to{opacity:1}}._widgetDisabled_9aoli_33{pointer-events:none;opacity:.5}._widgetActive_9aoli_39{border:1px dashed #008297}._widget_title_9aoli_44{font-size:14pt;font-weight:700;margin:0}._widget_header_9aoli_50{display:flex;justify-content:left;padding:.6rem 1rem;align-items:center}._widget_header_9aoli_50 input{padding:.2rem;height:initial;box-sizing:border-box;border:2px solid transparent;cursor:pointer;margin-right:1rem}._widget_header_9aoli_50 input:focus{border:2px solid #008297;border-radius:5px;cursor:initial}._widget_header_9aoli_50 fieldset{border:none}._widget_menu_9aoli_77{flex-grow:1;text-align:right}._widget_content_9aoli_82{padding:1rem;display:flex;flex-direction:column}._widget_content_9aoli_82>p{color:#444;font-size:12pt;margin:1rem 1.4rem}
@@ -1,6 +1,6 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
- import { D as g } from "../../DialogQR-CyZcX7ul.js";
3
+ import { D as h } from "../../DialogQR-wJru73YO.js";
4
4
  import "@mui/material";
5
5
  import "react-i18next";
6
6
  import "../../state/webrtcState.js";
@@ -11,9 +11,10 @@ import "../../style/theme.js";
11
11
  import "../../util/canvas.js";
12
12
  import "../../FileSaver.min-DhePf63e.js";
13
13
  import "../BusyButton/BusyButton.js";
14
+ import "../WorkflowLayout/lines.js";
14
15
  import "../WorkflowLayout/Widget.js";
15
16
  import "../IconMenu/context.js";
16
17
  import "@emotion/react";
17
18
  export {
18
- g as default
19
+ h as default
19
20
  };
@@ -1,6 +1,6 @@
1
1
  import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
2
  import { useRef as h, useState as m, useEffect as u, Suspense as v } from "react";
3
- import { q as p, s as o, D as b } from "../../DialogQR-CyZcX7ul.js";
3
+ import { q as p, s as o, D as b } from "../../DialogQR-wJru73YO.js";
4
4
  function q({ url: a, size: r, code: c, label: l, dialog: d }) {
5
5
  const t = h(null), [f, n] = m(!1);
6
6
  return u(() => {
@@ -1,43 +1,44 @@
1
- import { jsx as c, jsxs as m } from "react/jsx-runtime";
2
- import { useState as d, useRef as i, useEffect as p } from "react";
3
- import { extractNodesFromElements as v, generateLines as y } from "./lines.js";
4
- import { s as a, S as g } from "../../SvgLayer-CA0elY7q.js";
5
- function L({ children: n, connections: o }) {
6
- const [l, u] = d([]), r = i(null), s = i();
7
- return p(() => {
1
+ import { jsx as a, jsxs as d } from "react/jsx-runtime";
2
+ import { useState as p, useRef as l, useEffect as v } from "react";
3
+ import { extractNodesFromElements as y, generateLines as g } from "./lines.js";
4
+ import { s as u, S as h } from "../../SvgLayer-DQQ6Pb5G.js";
5
+ function k({ children: n, connections: i }) {
6
+ const [f, m] = p([]), r = l(null), t = l();
7
+ return v(() => {
8
8
  if (r.current) {
9
- s.current = new ResizeObserver(() => {
9
+ const s = () => {
10
10
  if (r.current) {
11
- const e = v(r.current);
12
- u(y(e, o));
11
+ const e = y(r.current), c = g(e, i);
12
+ m(c);
13
13
  }
14
- }), s.current.observe(r.current);
15
- const t = r.current.children;
16
- if (t)
17
- for (let e = 0; e < t.length; ++e) {
18
- const f = t[e];
19
- s.current.observe(f);
14
+ };
15
+ t.current = new ResizeObserver(s), t.current.observe(r.current);
16
+ const o = r.current.children;
17
+ if (o)
18
+ for (let e = 0; e < o.length; ++e) {
19
+ const c = o[e];
20
+ t.current.observe(c);
20
21
  }
21
- return () => {
22
+ return s(), () => {
22
23
  var e;
23
- (e = s.current) == null || e.disconnect();
24
+ (e = t.current) == null || e.disconnect();
24
25
  };
25
26
  }
26
- }, [o]), /* @__PURE__ */ c("div", { className: a.workspace, children: /* @__PURE__ */ m(
27
+ }, [i]), /* @__PURE__ */ a("div", { className: u.workspace, children: /* @__PURE__ */ d(
27
28
  "div",
28
29
  {
29
- className: a.container,
30
+ className: u.container,
30
31
  ref: r,
31
32
  style: {
32
- gridTemplateColumns: `repeat(${Array.isArray(n) ? n.filter((t) => !!t).length : 1}, max-content)`
33
+ gridTemplateColumns: `repeat(${Array.isArray(n) ? n.filter((s) => !!s).length : 1}, max-content)`
33
34
  },
34
35
  children: [
35
- /* @__PURE__ */ c(g, { lines: l }),
36
+ /* @__PURE__ */ a(h, { lines: f }),
36
37
  n
37
38
  ]
38
39
  }
39
40
  ) });
40
41
  }
41
42
  export {
42
- L as default
43
+ k as default
43
44
  };
@@ -1,5 +1,5 @@
1
1
  import "react/jsx-runtime";
2
- import { S as a } from "../../SvgLayer-CA0elY7q.js";
2
+ import { S as a } from "../../SvgLayer-DQQ6Pb5G.js";
3
3
  export {
4
4
  a as default
5
5
  };
@@ -13,6 +13,7 @@ interface Props extends React.HTMLProps<HTMLDivElement> {
13
13
  id?: string;
14
14
  noPadding?: boolean;
15
15
  contentStyle?: CSSProperties;
16
+ headerColour?: string;
16
17
  }
17
- export declare function Widget({ disabled, focus, title, setTitle, children, menu, className, hidden, dataWidget, id, noPadding, active, contentStyle, ...props }: Props): import("react/jsx-runtime").JSX.Element;
18
+ export declare function Widget({ disabled, focus, title, setTitle, children, menu, className, hidden, dataWidget, id, noPadding, active, contentStyle, headerColour, ...props }: Props): import("react/jsx-runtime").JSX.Element;
18
19
  export {};