@altinn/altinn-components 0.8.1 → 0.8.2

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,5 +1,5 @@
1
1
  "use client";
2
- import { jsxs as V, jsx as c } from "react/jsx-runtime";
2
+ import { jsxs as V, jsx as i } from "react/jsx-runtime";
3
3
  import { useState as d, useMemo as C } from "react";
4
4
  import { useRootContext as q } from "../RootProvider/RootProvider.js";
5
5
  import { ToolbarAdd as w } from "./ToolbarAdd.js";
@@ -16,44 +16,44 @@ const Y = ({
16
16
  getFilterLabel: A,
17
17
  children: N
18
18
  }) => {
19
- const { currentId: i, openId: R, closeAll: y } = q(), [e, s] = d(null), [j, v] = d(
19
+ const { currentId: c, openId: R, closeAll: y } = q(), [e, s] = d(null), [j, v] = d(
20
20
  u ?? {}
21
- ), p = typeof g == "function" ? g : v, r = u || j, [b, S] = d(
22
- (l == null ? void 0 : l.filter((o) => !(o.removable && typeof r[o.name] > "u")).map((o) => o.name)) ?? []
21
+ ), p = typeof g == "function" ? g : v, t = u || j, [b, S] = d(
22
+ (l == null ? void 0 : l.filter((o) => !(o.removable && typeof t[o.name] > "u")).map((o) => o.name)) ?? []
23
23
  ), h = l == null ? void 0 : l.filter((o) => !b.includes(o.name)), L = C(
24
24
  () => b.map((o) => l.find((n) => n.name === o)).filter((o) => typeof o < "u"),
25
25
  [l, b]
26
26
  ), a = C(
27
27
  () => l.filter((o) => h.includes(o)),
28
28
  [l, h]
29
- ), t = (o, n) => {
29
+ ), r = (o, n) => {
30
30
  (e == null ? void 0 : e.name) === n && e.type === o ? (y(), s(null)) : (R("toolbar"), s({ name: n, type: o }));
31
31
  }, M = () => {
32
32
  s(null), y();
33
33
  }, k = (o, n, m) => {
34
34
  m === "radio" ? (p({
35
- ...r,
35
+ ...t,
36
36
  [o]: n
37
- }), t("filter", o)) : p({
38
- ...r,
39
- [o]: r[o] ? r[o].some((f) => n == null ? void 0 : n.includes(f)) ? r[o].filter((f) => !(n || []).includes(f)) : [...r[o], ...n || []] : n
37
+ }), r("filter", o)) : p({
38
+ ...t,
39
+ [o]: t[o] ? t[o].some((f) => n == null ? void 0 : n.includes(f)) ? t[o].filter((f) => !(n || []).includes(f)) : [...t[o], ...n || []] : n
40
40
  });
41
41
  }, B = (o) => {
42
42
  S((n) => n.filter((m) => m !== o)), p({
43
- ...r,
43
+ ...t,
44
44
  [o]: void 0
45
45
  });
46
46
  }, E = (o) => {
47
- S((n) => [...n, o]), t("filter", o);
47
+ S((n) => [...n, o]), r("filter", o);
48
48
  };
49
- return /* @__PURE__ */ V(z, { open: i === "toolbar", onClose: M, children: [
50
- F && /* @__PURE__ */ c(G, { onToggle: () => t("menu", ""), expanded: (e == null ? void 0 : e.type) === "menu", ...F }),
51
- T && /* @__PURE__ */ c(H, { ...T }),
52
- L.map((o) => /* @__PURE__ */ c(
49
+ return /* @__PURE__ */ V(z, { open: c === "toolbar", onClose: M, children: [
50
+ F && /* @__PURE__ */ i(G, { onToggle: () => r("menu", ""), expanded: (e == null ? void 0 : e.type) === "menu", ...F }),
51
+ T && /* @__PURE__ */ i(H, { ...T }),
52
+ L.map((o) => /* @__PURE__ */ i(
53
53
  D,
54
54
  {
55
- onToggle: () => t("filter", o.name),
56
- expanded: i === "toolbar" && o.name === (e == null ? void 0 : e.name) && (e == null ? void 0 : e.type) === "filter",
55
+ onToggle: () => r("filter", o.name),
56
+ expanded: c === "toolbar" && o.name === (e == null ? void 0 : e.name) && (e == null ? void 0 : e.type) === "filter",
57
57
  onRemove: () => {
58
58
  B(o.name);
59
59
  },
@@ -63,21 +63,21 @@ const Y = ({
63
63
  name: o.name,
64
64
  options: o.options,
65
65
  label: o.label,
66
- value: r[o.name],
66
+ value: t[o.name],
67
67
  optionType: o.optionType,
68
68
  removable: o.removable,
69
69
  getSelectedLabel: A
70
70
  },
71
71
  o.name
72
72
  )),
73
- (a == null ? void 0 : a.length) > 0 && /* @__PURE__ */ c(
73
+ (a == null ? void 0 : a.length) > 0 && /* @__PURE__ */ i(
74
74
  w,
75
75
  {
76
- expanded: i === "toolbar" && (e == null ? void 0 : e.type) === "add-filter",
77
- onToggle: () => t("add-filter", ""),
76
+ expanded: c === "toolbar" && (e == null ? void 0 : e.type) === "add-filter",
77
+ onToggle: () => r("add-filter", ""),
78
78
  items: a.map((o) => ({
79
79
  id: o.name,
80
- label: o.label,
80
+ title: o.label,
81
81
  name: o.name,
82
82
  onClick: () => {
83
83
  E(o.name);
@@ -1,7 +1,7 @@
1
1
  import { jsx as s } from "react/jsx-runtime";
2
2
  import n from "react";
3
3
  import { Toolbar as o } from "./Toolbar.js";
4
- const d = {
4
+ const b = {
5
5
  title: "Toolbar/Toolbar",
6
6
  component: o,
7
7
  tags: ["autodocs"],
@@ -17,13 +17,15 @@ const d = {
17
17
  avatar: {
18
18
  name: "Ola Nordmann"
19
19
  },
20
- label: "Ola Nordmann"
20
+ title: "Ola Nordmann",
21
+ id: "ola"
21
22
  },
22
23
  {
23
24
  avatar: {
24
25
  name: "Kari Nordmann"
25
26
  },
26
- label: "Kari Nordmann"
27
+ title: "Kari Nordmann",
28
+ id: "kari"
27
29
  }
28
30
  ]
29
31
  },
@@ -110,12 +112,12 @@ const d = {
110
112
  }
111
113
  ]
112
114
  }
113
- }, m = {
115
+ }, g = {
114
116
  args: {
115
117
  ...a.args,
116
118
  getFilterLabel: (t, e) => Array.isArray(e) && e.length > 1 ? `${e.length} selected` : e
117
119
  }
118
- }, g = {
120
+ }, m = {
119
121
  args: {
120
122
  ...a.args,
121
123
  filters: []
@@ -177,10 +179,10 @@ const p = {
177
179
  };
178
180
  export {
179
181
  v as ControlledStateFilters,
180
- m as CustomFilterLabel,
182
+ g as CustomFilterLabel,
181
183
  a as Default,
182
184
  c as FilterAndSearch,
183
- g as NoFilters,
185
+ m as NoFilters,
184
186
  p as StaticFilters,
185
- d as default
187
+ b as default
186
188
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [