@altinn/altinn-components 0.35.3 → 0.35.5

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.
@@ -1,15 +1,15 @@
1
1
  "use client";
2
- import { jsxs as f, jsx as e } from "react/jsx-runtime";
3
- import { useState as m, createElement as u } from "react";
2
+ import { jsxs as g, jsx as e } from "react/jsx-runtime";
3
+ import { useState as f, createElement as u } from "react";
4
4
  import "../../index-L8X2o7IH.js";
5
5
  import { Button as h } from "../Button/Button.js";
6
6
  import "../RootProvider/RootProvider.js";
7
- import { Timeline as y } from "../Timeline/Timeline.js";
7
+ import { Timeline as m } from "../Timeline/Timeline.js";
8
8
  import "../Searchbar/AutocompleteBase.js";
9
9
  import "../Snackbar/useSnackbar.js";
10
- import { Section as v } from "../Page/Section.js";
11
- import { ActivityLogSegment as x } from "./ActivityLogSegment.js";
12
- const q = ({
10
+ import { Section as y } from "../Page/Section.js";
11
+ import { ActivityLogSegment as v } from "./ActivityLogSegment.js";
12
+ const b = ({
13
13
  items: o,
14
14
  maxItems: t,
15
15
  expandLabel: i = "Expand history",
@@ -17,14 +17,14 @@ const q = ({
17
17
  }) => {
18
18
  if (!(o != null && o.length))
19
19
  return null;
20
- const [n, p] = m(!1), c = () => {
20
+ const [n, p] = f(!1), c = () => {
21
21
  p((r) => !r);
22
22
  }, d = t ? o.slice(0, t) : o, s = n ? o : d, a = t && o.length > t;
23
- return /* @__PURE__ */ f(v, { spacing: 4, children: [
24
- /* @__PURE__ */ e(y, { children: s.map((r, g) => /* @__PURE__ */ u(x, { ...r, key: g })) }),
23
+ return /* @__PURE__ */ g(y, { spacing: 4, children: [
24
+ /* @__PURE__ */ e(m, { children: s.map((r) => /* @__PURE__ */ u(v, { ...r, key: r.id })) }),
25
25
  a && /* @__PURE__ */ e(h, { variant: "outline", onClick: c, children: n ? l : i })
26
26
  ] });
27
27
  };
28
28
  export {
29
- q as ActivityLog
29
+ b as ActivityLog
30
30
  };
@@ -1,17 +1,17 @@
1
1
  "use client";
2
- import { jsxs as b, jsx as s } from "react/jsx-runtime";
3
- import { c as h } from "../../index-L8X2o7IH.js";
4
- import * as m from "react";
5
- import { forwardRef as w, useRef as y } from "react";
6
- import { IconButton as I } from "../Button/IconButton.js";
7
- import { useClickOutside as j } from "../../hooks/useClickOutside.js";
8
- import { DropdownBase as C } from "../Dropdown/DropdownBase.js";
9
- import { MenuItems as _ } from "../Menu/MenuItems.js";
10
- import { useRootContext as R } from "../RootProvider/RootProvider.js";
2
+ import { jsxs as v, jsx as s } from "react/jsx-runtime";
3
+ import { c as O } from "../../index-L8X2o7IH.js";
4
+ import * as a from "react";
5
+ import { forwardRef as b, useRef as h, useMemo as w } from "react";
6
+ import { IconButton as y } from "../Button/IconButton.js";
7
+ import { useClickOutside as I } from "../../hooks/useClickOutside.js";
8
+ import { DropdownBase as j } from "../Dropdown/DropdownBase.js";
9
+ import { MenuItems as C } from "../Menu/MenuItems.js";
10
+ import { useRootContext as _ } from "../RootProvider/RootProvider.js";
11
11
  import "../Searchbar/AutocompleteBase.js";
12
12
  import "../Snackbar/useSnackbar.js";
13
- import { u as E } from "../../useId-BVFxCjkq.js";
14
- import '../../assets/ContextMenu.css';var k = function(e, l) {
13
+ import { u as R } from "../../useId-BVFxCjkq.js";
14
+ import '../../assets/ContextMenu.css';var E = function(e, l) {
15
15
  var r = {};
16
16
  for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && l.indexOf(t) < 0 && (r[t] = e[t]);
17
17
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
@@ -19,18 +19,18 @@ import '../../assets/ContextMenu.css';var k = function(e, l) {
19
19
  l.indexOf(t[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[o]) && (r[t[o]] = e[t[o]]);
20
20
  return r;
21
21
  };
22
- const M = w((e, l) => {
23
- var { title: r, titleId: t } = e, o = k(e, ["title", "titleId"]);
24
- let n = E();
25
- return n = r ? t || "title-" + n : void 0, m.createElement(
22
+ const M = b((e, l) => {
23
+ var { title: r, titleId: t } = e, o = E(e, ["title", "titleId"]);
24
+ let n = R();
25
+ return n = r ? t || "title-" + n : void 0, a.createElement(
26
26
  "svg",
27
27
  Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: l, "aria-labelledby": n }, o),
28
- r ? m.createElement("title", { id: n }, r) : null,
29
- m.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M6 10.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3m4.5 1.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0m6 0a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0", clipRule: "evenodd" })
28
+ r ? a.createElement("title", { id: n }, r) : null,
29
+ a.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M6 10.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3m4.5 1.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0m6 0a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0", clipRule: "evenodd" })
30
30
  );
31
- }), B = "_toggle_nol5i_1", P = {
32
- toggle: B
33
- }, G = ({
31
+ }), k = "_toggle_nol5i_1", B = {
32
+ toggle: k
33
+ }, F = ({
34
34
  id: e = "context-menu",
35
35
  ariaLabel: l,
36
36
  placement: r = "right",
@@ -38,21 +38,20 @@ const M = w((e, l) => {
38
38
  className: o,
39
39
  items: n
40
40
  }) => {
41
- const { currentId: u, toggleId: a, closeAll: d } = R(), f = y(null), g = () => a(e), i = u === e;
42
- j(f, () => {
43
- i && a(e);
41
+ const { currentId: d, toggleId: m, closeAll: u } = _(), f = h(null), g = () => m(e), c = d === e;
42
+ I(f, () => {
43
+ c && m(e);
44
44
  });
45
- const x = n.map((v, O) => ({
46
- ...v,
45
+ const x = w(() => n.map((i) => ({
46
+ ...i,
47
47
  onClick: () => {
48
48
  var p;
49
- const c = n[O];
50
- (p = c.onClick) == null || p.call(c), d();
49
+ (p = i.onClick) == null || p.call(i), u();
51
50
  }
52
- }));
53
- return /* @__PURE__ */ b("div", { className: h(P.toggle, o), "data-color": "neutral", ref: f, children: [
51
+ })), [n, u]);
52
+ return /* @__PURE__ */ v("div", { className: O(B.toggle, o), "data-color": "neutral", ref: f, children: [
54
53
  /* @__PURE__ */ s(
55
- I,
54
+ y,
56
55
  {
57
56
  size: "xs",
58
57
  rounded: !0,
@@ -62,9 +61,9 @@ const M = w((e, l) => {
62
61
  iconAltText: l || `Open ${e}`
63
62
  }
64
63
  ),
65
- i && /* @__PURE__ */ s(C, { placement: r, open: i, children: /* @__PURE__ */ s(_, { groups: t, items: x }) })
64
+ c && /* @__PURE__ */ s(j, { placement: r, open: c, children: /* @__PURE__ */ s(C, { groups: t, items: x }) })
66
65
  ] });
67
66
  };
68
67
  export {
69
- G as ContextMenu
68
+ F as ContextMenu
70
69
  };
@@ -1,13 +1,14 @@
1
1
  "use client";
2
- import { useEffect as o } from "react";
3
- const s = (e, t) => (o(() => {
4
- const n = (u) => {
5
- e.current && !e.current.contains(u.target) && (t == null || t());
2
+ import { useEffect as u } from "react";
3
+ const c = (t, e) => (u(() => {
4
+ const n = (r) => {
5
+ const o = r.target;
6
+ o.closest("button[data-context-menu-trigger]") || o.closest(".context-menu-trigger") || o.closest("button") || o.closest('[role="button"]') || t.current && !t.current.contains(r.target) && (e == null || e());
6
7
  };
7
8
  return document.addEventListener("mouseup", n), document.addEventListener("touchend", n), () => {
8
9
  document.removeEventListener("mouseup", n), document.removeEventListener("touchend", n);
9
10
  };
10
- }, [t, e]), e);
11
+ }, [e, t]), t);
11
12
  export {
12
- s as useClickOutside
13
+ c as useClickOutside
13
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.35.3",
3
+ "version": "0.35.5",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",