@altinn/altinn-components 0.56.24 → 0.56.26

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,78 +1,82 @@
1
- import { jsx as c, jsxs as f } from "react/jsx-runtime";
1
+ import { jsx as c, jsxs as S } from "react/jsx-runtime";
2
2
  import { c as p } from "../../index-p1eeF8LQ.js";
3
3
  import { useState as _, useEffect as g } from "react";
4
- import { AccountMenu as w } from "../Account/AccountMenu.js";
4
+ import { useLockBodyScroll as L } from "../../hooks/useLockBodyScroll.js";
5
+ import { AccountMenu as A } from "../Account/AccountMenu.js";
5
6
  import "../Button/Button.js";
6
7
  import "react-dom";
7
- import { useRootContext as N } from "../RootProvider/RootProvider.js";
8
+ import { useRootContext as M } from "../RootProvider/RootProvider.js";
8
9
  import "../Snackbar/useSnackbar.js";
9
- import { S as A } from "../../SearchField-QTfebYdU.js";
10
- import { S as L } from "../../button-BB5sYVKY.js";
11
- import { H as M, S as F } from "../../switch-Cemfhx0H.js";
12
- import '../../assets/AccountSelector.css';const T = "_accountSelector_139de_1", j = "_heading_139de_11", C = "_searchSection_139de_17", H = "_searchField_139de_26", V = "_accountMenu_139de_30", y = "_virtualized_139de_38", E = "_spinner_139de_47", r = {
13
- accountSelector: T,
14
- heading: j,
15
- searchSection: C,
16
- searchField: H,
17
- accountMenu: V,
18
- virtualized: y,
19
- spinner: E
20
- }, Z = ({
10
+ import { S as F } from "../../SearchField-QTfebYdU.js";
11
+ import { S as T } from "../../button-BB5sYVKY.js";
12
+ import { H as j, S as y } from "../../switch-Cemfhx0H.js";
13
+ import '../../assets/AccountSelector.css';const C = "_accountSelector_139de_1", H = "_heading_139de_11", V = "_searchSection_139de_17", I = "_searchField_139de_26", E = "_accountMenu_139de_30", R = "_virtualized_139de_38", $ = "_spinner_139de_47", n = {
14
+ accountSelector: C,
15
+ heading: H,
16
+ searchSection: V,
17
+ searchField: I,
18
+ accountMenu: E,
19
+ virtualized: R,
20
+ spinner: $
21
+ }, ee = ({
21
22
  accountMenu: e,
22
23
  forceOpenFullScreen: t,
23
24
  className: i,
24
25
  loading: v,
25
26
  showDeletedUnits: s,
26
- onShowDeletedUnitsChange: x
27
+ onShowDeletedUnitsChange: k,
28
+ scrollLock: x
27
29
  }) => {
28
- const { openId: o, closeAll: l, languageCode: d } = N(), [u, h] = _(""), [a, m] = _(t);
30
+ const { openId: o, closeAll: l, languageCode: d, currentId: z } = M();
31
+ L(x ? z === "account" : !1);
32
+ const [u, h] = _(""), [a, m] = _(t);
29
33
  g(() => {
30
34
  !t && a && l(), m(t);
31
35
  }, [t]), g(() => {
32
36
  a === !0 && o("account");
33
37
  }, [a, o]);
34
- const { searchText: S, heading: z, switchLabel: b } = I(d), k = (n) => {
35
- e.onSelectAccount?.(n), l(), m(!1);
38
+ const { searchText: f, heading: b, switchLabel: w } = B(d), N = (r) => {
39
+ e.onSelectAccount?.(r), l(), m(!1);
36
40
  };
37
- return v ? /* @__PURE__ */ c(L, { "aria-hidden": !0, "data-color": "neutral", className: r.spinner }) : /* @__PURE__ */ f("div", { className: p(i, r.accountSelector), children: [
38
- /* @__PURE__ */ c(M, { "data-size": "sm", level: 2, className: r.heading, children: z }),
39
- /* @__PURE__ */ f("div", { className: r.searchSection, children: [
41
+ return v ? /* @__PURE__ */ c(T, { "aria-hidden": !0, "data-color": "neutral", className: n.spinner }) : /* @__PURE__ */ S("div", { className: p(i, n.accountSelector), children: [
42
+ /* @__PURE__ */ c(j, { "data-size": "sm", level: 2, className: n.heading, children: b }),
43
+ /* @__PURE__ */ S("div", { className: n.searchSection, children: [
40
44
  /* @__PURE__ */ c(
41
- A,
45
+ F,
42
46
  {
43
- name: S,
44
- placeholder: S,
47
+ name: f,
48
+ placeholder: f,
45
49
  value: u,
46
- onChange: (n) => h(n.target.value),
50
+ onChange: (r) => h(r.target.value),
47
51
  onClear: () => h(""),
48
- className: r.searchField
52
+ className: n.searchField
49
53
  }
50
54
  ),
51
55
  s !== void 0 && /* @__PURE__ */ c(
52
- F,
56
+ y,
53
57
  {
54
58
  checked: s,
55
- onChange: (n) => x?.(n.target.checked),
56
- label: b
59
+ onChange: (r) => k?.(r.target.checked),
60
+ label: w
57
61
  }
58
62
  )
59
63
  ] }),
60
- /* @__PURE__ */ c("div", { className: p(r.accountMenu, e.virtualized && r.virtualized), children: /* @__PURE__ */ c(
61
- w,
64
+ /* @__PURE__ */ c("div", { className: p(n.accountMenu, e.virtualized && n.virtualized), children: /* @__PURE__ */ c(
65
+ A,
62
66
  {
63
67
  ...e,
64
- onSelectAccount: k,
68
+ onSelectAccount: N,
65
69
  keyboardEvents: !1,
66
70
  search: {
67
71
  hidden: !0,
68
72
  name: "",
69
73
  value: u,
70
- getResultsLabel: (n) => R(n, d)
74
+ getResultsLabel: (r) => K(r, d)
71
75
  }
72
76
  }
73
77
  ) })
74
78
  ] });
75
- }, I = (e) => {
79
+ }, B = (e) => {
76
80
  switch (e) {
77
81
  case "nn":
78
82
  return {
@@ -99,10 +103,10 @@ import '../../assets/AccountSelector.css';const T = "_accountSelector_139de_1",
99
103
  switchLabel: "Vis slettede"
100
104
  };
101
105
  }
102
- }, R = (e, t) => {
106
+ }, K = (e, t) => {
103
107
  const i = t === "nb" || t === "nn";
104
108
  return e === 0 ? i ? "Ingen treff" : "No hits" : i ? `${e} treff` : e === 1 ? "1 hit" : `${e} hits`;
105
109
  };
106
110
  export {
107
- Z as AccountSelector
111
+ ee as AccountSelector
108
112
  };
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { useEffect as n } from "react";
3
+ const c = (t) => {
4
+ n(() => {
5
+ if (!t) return;
6
+ const { overflow: e, paddingRight: d } = document.body.style, o = window.innerWidth - document.documentElement.clientWidth;
7
+ return document.body.style.overflow = "hidden", o > 0 && (document.body.style.paddingRight = `${o}px`), () => {
8
+ document.body.style.overflow = e, document.body.style.paddingRight = d;
9
+ };
10
+ }, [t]);
11
+ };
12
+ export {
13
+ c as useLockBodyScroll
14
+ };
@@ -11,5 +11,7 @@ export interface AccountSelectorProps {
11
11
  showDeletedUnits?: boolean;
12
12
  /** Function to handle changes to the include deleted accounts switch */
13
13
  onShowDeletedUnitsChange?: (newValue: boolean) => void;
14
+ /** Enable scroll lock to prevent background scrolling **/
15
+ scrollLock?: boolean;
14
16
  }
15
- export declare const AccountSelector: ({ accountMenu, forceOpenFullScreen, className, loading, showDeletedUnits, onShowDeletedUnitsChange, }: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const AccountSelector: ({ accountMenu, forceOpenFullScreen, className, loading, showDeletedUnits, onShowDeletedUnitsChange, scrollLock, }: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { AccountSelectorProps } from './AccountSelector';
2
2
  declare const meta: {
3
3
  title: string;
4
- component: ({ accountMenu, forceOpenFullScreen, className, loading, showDeletedUnits, onShowDeletedUnitsChange, }: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
4
+ component: ({ accountMenu, forceOpenFullScreen, className, loading, showDeletedUnits, onShowDeletedUnitsChange, scrollLock, }: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
5
5
  tags: string[];
6
6
  parameters: {
7
7
  layout: string;
@@ -0,0 +1 @@
1
+ export declare const useLockBodyScroll: (locked: boolean) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.56.24",
3
+ "version": "0.56.26",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",