@altinn/altinn-components 0.41.4 → 0.41.6

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.
Files changed (35) hide show
  1. package/dist/assets/MenuItemBase.css +1 -1
  2. package/dist/assets/MenuOption.css +1 -1
  3. package/dist/components/Account/AccountList.js +20 -32
  4. package/dist/components/Account/AccountMenu.js +18 -16
  5. package/dist/components/Avatar/AvatarGroup.js +12 -12
  6. package/dist/components/List/ListItemBase.js +35 -33
  7. package/dist/components/Menu/MenuBase.js +17 -15
  8. package/dist/components/Menu/MenuItem.js +47 -46
  9. package/dist/components/Menu/MenuItemBase.js +38 -38
  10. package/dist/components/Menu/MenuItemLabel.js +36 -42
  11. package/dist/components/Menu/MenuOption.js +46 -46
  12. package/dist/components/Settings/SettingsItem.js +42 -27
  13. package/dist/components/Settings/SettingsItemBase.js +29 -28
  14. package/dist/components/Settings/SettingsModal.js +33 -9
  15. package/dist/components/Toolbar/ToolbarOptions.js +9 -9
  16. package/dist/components/Typography/Heading.js +30 -28
  17. package/dist/hooks/useMenu.js +31 -31
  18. package/dist/types/lib/components/Account/AccountList.d.ts +1 -1
  19. package/dist/types/lib/components/Account/AccountList.stories.d.ts +1 -1
  20. package/dist/types/lib/components/Account/AccountListItem.stories.d.ts +1 -0
  21. package/dist/types/lib/components/List/ListItemBase.d.ts +2 -1
  22. package/dist/types/lib/components/Menu/MenuBase.d.ts +2 -1
  23. package/dist/types/lib/components/Menu/MenuItem.d.ts +1 -1
  24. package/dist/types/lib/components/Menu/MenuItemLabel.d.ts +2 -3
  25. package/dist/types/lib/components/Menu/MenuOption.d.ts +3 -3
  26. package/dist/types/lib/components/Settings/SettingsItem.d.ts +9 -2
  27. package/dist/types/lib/components/Settings/SettingsItem.stories.d.ts +4 -1
  28. package/dist/types/lib/components/Settings/SettingsItemBase.d.ts +1 -1
  29. package/dist/types/lib/components/Settings/SettingsModal.d.ts +6 -2
  30. package/dist/types/lib/components/Settings/SettingsModal.stories.d.ts +10 -2
  31. package/dist/types/lib/components/Toolbar/ToolbarFilter.stories.d.ts +1 -3
  32. package/dist/types/lib/components/Transmission/Transmission.stories.d.ts +1 -0
  33. package/dist/types/lib/components/Typography/Heading.d.ts +3 -2
  34. package/dist/types/lib/components/Typography/Heading.stories.d.ts +1 -1
  35. package/package.json +1 -1
@@ -1,39 +1,39 @@
1
1
  "use client";
2
- import { useState as w, useMemo as x, useCallback as k, useEffect as m } from "react";
3
- import { useEnterKey as A } from "./useEnterKey.js";
4
- const L = ({
5
- items: u,
2
+ import { useState as w, useMemo as x, useCallback as k, useEffect as A } from "react";
3
+ import { useEnterKey as D } from "./useEnterKey.js";
4
+ const M = ({
5
+ items: s,
6
6
  groups: p,
7
- groupByKey: a,
8
- keyboardEvents: i = !1,
7
+ groupByKey: i,
8
+ keyboardEvents: a = !1,
9
9
  sortGroupBy: v,
10
- onSelect: c,
11
- ref: l
10
+ onSelect: l,
11
+ ref: c
12
12
  }) => {
13
- const [f, s] = w(-1);
14
- A((n) => {
15
- if (i) {
16
- const t = l && "current" in l ? l.current : null, e = t == null ? void 0 : t.querySelector('[data-active="true"]');
17
- n.stopPropagation(), n.preventDefault(), e && (e.tagName === "A" && e.hasAttribute("href") ? e.click() : e.dispatchEvent(new MouseEvent("click", { bubbles: !0 }))), c == null || c();
13
+ const [d, u] = w(-1);
14
+ D((t) => {
15
+ if (a) {
16
+ const n = c && "current" in c ? c.current : null, e = n == null ? void 0 : n.querySelector('[data-active="true"]');
17
+ t.stopPropagation(), t.preventDefault(), e && (e.tagName === "A" && e.hasAttribute("href") ? e.click() : e.dispatchEvent(new MouseEvent("click", { bubbles: !0 }))), l == null || l();
18
18
  }
19
19
  });
20
20
  const h = x(() => {
21
- const n = u.reduce(
21
+ const t = s.reduce(
22
22
  (e, o) => {
23
- const r = a && o[a] ? o[a] : "ungrouped";
23
+ const r = i && o[i] ? o[i] : "ungrouped";
24
24
  return e[r] = e[r] || [], e[r].push(o), e;
25
25
  },
26
26
  {}
27
- ), t = Object.values(n).flat();
28
- return Object.entries(n).sort(v || (() => 0)).map(([e, o]) => ({
27
+ ), n = Object.values(t).flat().filter((e) => !(e != null && e.disabled));
28
+ return Object.entries(t).sort(v || (() => 0)).map(([e, o]) => ({
29
29
  items: o.map((r) => ({
30
- menuIndex: t.indexOf(r),
31
- active: f === t.indexOf(r),
32
- onMouseEnter: i ? () => {
33
- s(t.indexOf(r));
30
+ menuIndex: n.indexOf(r),
31
+ active: d === n.indexOf(r),
32
+ onMouseEnter: a ? () => {
33
+ u(n.indexOf(r));
34
34
  } : void 0,
35
- onMouseLeave: i ? () => {
36
- s(-1);
35
+ onMouseLeave: a ? () => {
36
+ u(-1);
37
37
  } : void 0,
38
38
  props: r
39
39
  })),
@@ -41,16 +41,16 @@ const L = ({
41
41
  ...p[e] || {}
42
42
  }
43
43
  }));
44
- }, [u, a, f, p]), d = k(
45
- (n) => {
46
- n.key === "ArrowDown" ? (n.preventDefault(), s((t) => (t + 1) % u.length)) : n.key === "ArrowUp" && (n.preventDefault(), s((t) => (t - 1 + u.length) % u.length));
44
+ }, [s, i, d, p]), f = k(
45
+ (t) => {
46
+ t.key === "ArrowDown" ? (t.preventDefault(), u((n) => (n + 1) % s.length)) : t.key === "ArrowUp" && (t.preventDefault(), u((n) => (n - 1 + s.length) % s.length));
47
47
  },
48
- [u.length]
48
+ [s.length]
49
49
  );
50
- return m(() => (i && (s(0), document.addEventListener("keydown", d)), () => {
51
- document.removeEventListener("keydown", d);
52
- }), [d, i]), { menu: h, activeIndex: f, setActiveIndex: s };
50
+ return A(() => (a && (u(0), document.addEventListener("keydown", f)), () => {
51
+ document.removeEventListener("keydown", f);
52
+ }), [f, a]), { menu: h, activeIndex: d, setActiveIndex: u };
53
53
  };
54
54
  export {
55
- L as useMenu
55
+ M as useMenu
56
56
  };
@@ -10,4 +10,4 @@ export interface AccountListProps {
10
10
  emptyTitle?: string;
11
11
  emptyDescription?: string;
12
12
  }
13
- export declare const AccountList: ({ items, groups, sortGroupBy, emptyTitle, emptyDescription, }: AccountListProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const AccountList: ({ items, groups, sortGroupBy }: AccountListProps) => import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ import { AccountListItemProps, AccountListProps } from '..';
3
3
  import { UseAccountsProps } from '../../../examples';
4
4
  declare const meta: {
5
5
  title: string;
6
- component: ({ items, groups, sortGroupBy, emptyTitle, emptyDescription, }: AccountListProps) => import("react/jsx-runtime").JSX.Element;
6
+ component: ({ items, groups, sortGroupBy }: AccountListProps) => import("react/jsx-runtime").JSX.Element;
7
7
  tags: string[];
8
8
  parameters: {};
9
9
  args: AccountListProps;
@@ -35,6 +35,7 @@ declare const meta: {
35
35
  icon?: import('..').SvgElement | import('..').IconProps | React.ReactNode | import('..').AvatarProps | import('..').AvatarGroupProps;
36
36
  badge?: React.ReactNode | import('..').BadgeProps;
37
37
  linkIcon?: boolean | undefined;
38
+ ref?: React.Ref<HTMLElement> | undefined;
38
39
  interactive?: boolean | undefined;
39
40
  as?: React.ElementType | undefined;
40
41
  tabIndex?: number | undefined;
@@ -4,6 +4,7 @@ export type ListItemSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
4
4
  export type ListItemBorder = 'none' | 'solid' | 'dotted';
5
5
  export type ListItemColor = Color;
6
6
  export interface ListItemBaseProps {
7
+ ref?: React.Ref<HTMLElement>;
7
8
  /** If true, the list item is interactive and has a hover state. */
8
9
  interactive?: boolean;
9
10
  /** The element type to render as. */
@@ -41,4 +42,4 @@ export interface ListItemBaseProps {
41
42
  /** Id of list item. */
42
43
  id?: string;
43
44
  }
44
- export declare const ListItemBase: ({ as, interactive, size, color, variant, shadow, border, hidden, selected, className, onMouseEnter, id, children, }: ListItemBaseProps) => import("react/jsx-runtime").JSX.Element;
45
+ export declare const ListItemBase: ({ ref, as, interactive, size, color, variant, shadow, border, hidden, selected, className, onMouseEnter, id, children, }: ListItemBaseProps) => import("react/jsx-runtime").JSX.Element;
@@ -31,6 +31,7 @@ export interface MenuListItemProps {
31
31
  children?: ReactNode;
32
32
  style?: React.CSSProperties;
33
33
  dataIndex?: number;
34
+ disabled?: boolean;
34
35
  onMouseEnter?: MouseEventHandler;
35
36
  onMouseLeave?: MouseEventHandler;
36
37
  ref?: HTMLUListElement;
@@ -38,4 +39,4 @@ export interface MenuListItemProps {
38
39
  }
39
40
  export declare const MenuBase: ({ as, color, variant, className, children, ref }: MenuBaseProps) => import("react/jsx-runtime").JSX.Element;
40
41
  export declare const MenuList: ({ as, role, className, children, ref, onMouseEnter, onMouseLeave, onBlurCapture, }: MenuListProps) => import("react/jsx-runtime").JSX.Element;
41
- export declare const MenuListItem: ({ as, role, className, children, style, dataIndex, onMouseEnter, onMouseLeave, "aria-checked": ariaChecked, }: MenuListItemProps) => import("react/jsx-runtime").JSX.Element;
42
+ export declare const MenuListItem: ({ as, role, className, children, style, dataIndex, disabled, onMouseEnter, onMouseLeave, "aria-checked": ariaChecked, }: MenuListItemProps) => import("react/jsx-runtime").JSX.Element;
@@ -15,7 +15,7 @@ export interface MenuItemProps extends MenuItemBaseProps {
15
15
  icon?: MenuItemIconProps['icon'];
16
16
  iconTheme?: MenuItemIconProps['theme'];
17
17
  iconBadge?: MenuItemIconProps['badge'];
18
- badge?: BadgeProps | undefined;
18
+ badge?: BadgeProps | ReactNode | undefined;
19
19
  /** Custom controls */
20
20
  controls?: ReactNode;
21
21
  linkIcon?: boolean;
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { BadgeProps, HeadingProps } from '..';
2
+ import { HeadingProps } from '..';
3
3
  import { MenuItemSize } from './MenuItemBase';
4
4
  export interface MenuItemLabelProps {
5
5
  className?: string;
@@ -9,8 +9,7 @@ export interface MenuItemLabelProps {
9
9
  highlightWords?: string[];
10
10
  title?: HeadingProps | ReactNode | string;
11
11
  description?: HeadingProps | ReactNode | string;
12
- badge?: BadgeProps;
13
12
  children?: ReactNode;
14
13
  }
15
14
  export declare function getAriaLabelFromTitle(title: HeadingProps | ReactNode | string): string | undefined;
16
- export declare const MenuItemLabel: ({ className, size, title, badge, description, highlightWords, loading, children, }: MenuItemLabelProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const MenuItemLabel: ({ className, size, title, description, highlightWords, loading, children, }: MenuItemLabelProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { BadgeProps, MenuItemProps } from '..';
1
+ import { MenuItemProps } from '..';
2
2
  import { MenuItemBaseProps, MenuItemSize } from './MenuItemBase';
3
3
  export type MenuOptionType = 'checkbox' | 'radio';
4
4
  export interface MenuOptionProps extends MenuItemBaseProps {
@@ -10,11 +10,11 @@ export interface MenuOptionProps extends MenuItemBaseProps {
10
10
  groupId?: string;
11
11
  size?: MenuItemSize;
12
12
  name?: string;
13
- badge?: BadgeProps | undefined;
13
+ count?: number;
14
14
  checked?: boolean;
15
15
  disabled?: boolean;
16
16
  type?: MenuOptionType;
17
17
  hidden?: boolean;
18
18
  role?: string;
19
19
  }
20
- export declare const MenuOption: ({ size, type, name, active, value, label, title, description, icon, badge, checked, disabled, onMouseEnter, onClick, role, ...rest }: MenuOptionProps) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const MenuOption: ({ size, type, name, active, value, label, title, description, icon, count, checked, disabled, onMouseEnter, onClick, role, ...rest }: MenuOptionProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,12 @@
1
- import { InputProps, SettingsItemBaseProps } from '..';
1
+ import { InputProps, SettingsItemBaseProps, SettingsModalProps } from '..';
2
2
  import { ReactNode } from 'react';
3
3
  export type SettingsItemVariant = 'default' | 'modal' | 'switch';
4
+ export interface SettingsItemModalProps {
5
+ icon?: SettingsModalProps['icon'];
6
+ title?: SettingsModalProps['title'];
7
+ description?: SettingsModalProps['description'];
8
+ buttons?: SettingsModalProps['buttons'];
9
+ }
4
10
  export interface SettingsItemProps extends SettingsItemBaseProps {
5
11
  variant?: SettingsItemVariant;
6
12
  id: string;
@@ -10,6 +16,7 @@ export interface SettingsItemProps extends SettingsItemBaseProps {
10
16
  name?: InputProps['name'];
11
17
  checked?: InputProps['checked'];
12
18
  onChange?: InputProps['onChange'];
19
+ modalProps?: SettingsItemModalProps;
13
20
  children?: ReactNode;
14
21
  }
15
- export declare const SettingsItem: ({ loading, variant, id, name, checked, onChange, children, ...props }: SettingsItemProps) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const SettingsItem: ({ loading, variant, id, name, checked, onChange, modalProps, children, ...props }: SettingsItemProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { StoryObj } from '@storybook/react-vite';
2
2
  declare const meta: {
3
3
  title: string;
4
- component: ({ loading, variant, id, name, checked, onChange, children, ...props }: import('./SettingsItem').SettingsItemProps) => import("react/jsx-runtime").JSX.Element;
4
+ component: ({ loading, variant, id, name, checked, onChange, modalProps, children, ...props }: import('./SettingsItem').SettingsItemProps) => import("react/jsx-runtime").JSX.Element;
5
5
  tags: string[];
6
6
  parameters: {};
7
7
  args: {
@@ -19,12 +19,14 @@ declare const meta: {
19
19
  name?: string | undefined;
20
20
  checked?: boolean | undefined;
21
21
  onChange?: React.ChangeEventHandler<HTMLInputElement> | undefined;
22
+ modalProps?: import('./SettingsItem').SettingsItemModalProps | undefined;
22
23
  children?: React.ReactNode;
23
24
  groupId?: string | undefined;
24
25
  collapsible?: boolean | undefined;
25
26
  expanded?: boolean | undefined;
26
27
  icon?: import('..').SvgElement | import('..').IconProps | React.ReactNode | import('..').AvatarProps | import('..').AvatarGroupProps;
27
28
  label?: React.ReactNode;
29
+ ref?: React.Ref<HTMLElement> | undefined;
28
30
  interactive?: boolean | undefined;
29
31
  as?: React.ElementType | undefined;
30
32
  tabIndex?: number | undefined;
@@ -57,6 +59,7 @@ export declare const Value: Story;
57
59
  export declare const Loading: Story;
58
60
  export declare const Switch: Story;
59
61
  export declare const Modal: Story;
62
+ export declare const ModalProps: Story;
60
63
  export declare const Company: Story;
61
64
  export declare const Person: Story;
62
65
  export declare const Bookmark: () => import("react/jsx-runtime").JSX.Element;
@@ -10,4 +10,4 @@ export interface SettingsItemBaseProps extends ListItemBaseProps, ListItemHeader
10
10
  value?: ListItemLabelProps['value'];
11
11
  description?: ListItemLabelProps['description'];
12
12
  }
13
- export declare const SettingsItemBase: ({ loading, color, size, expanded, icon, label, title, value, description, children, highlightWords, ...props }: SettingsItemBaseProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const SettingsItemBase: ({ ref, loading, color, size, expanded, icon, label, title, value, description, children, highlightWords, ...props }: SettingsItemBaseProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,11 @@
1
- import { ModalBaseProps, ModalHeaderProps } from '..';
1
+ import { ButtonProps, ModalBaseProps, ModalHeaderProps } from '..';
2
+ export interface SettingsModalButtonProps extends ButtonProps {
3
+ close?: boolean;
4
+ }
2
5
  export interface SettingsModalProps extends ModalBaseProps {
3
6
  icon?: ModalHeaderProps['icon'];
4
7
  title?: ModalHeaderProps['title'];
5
8
  description?: ModalHeaderProps['description'];
9
+ buttons?: SettingsModalButtonProps[];
6
10
  }
7
- export declare const SettingsModal: ({ icon, title, description, open, onClose, children, ...args }: SettingsModalProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const SettingsModal: ({ icon, title, description, open, onClose, buttons, children, ...args }: SettingsModalProps) => import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,7 @@ import { ChangeEvent } from 'react';
2
2
  import { AccountListItemProps, SettingsModalProps, UsedByLogProps } from '..';
3
3
  declare const meta: {
4
4
  title: string;
5
- component: ({ icon, title, description, open, onClose, children, ...args }: SettingsModalProps) => import("react/jsx-runtime").JSX.Element;
5
+ component: ({ icon, title, description, open, onClose, buttons, children, ...args }: SettingsModalProps) => import("react/jsx-runtime").JSX.Element;
6
6
  tags: string[];
7
7
  parameters: {};
8
8
  args: {
@@ -28,9 +28,17 @@ export interface AccountAlertsModalProps extends SettingsModalProps {
28
28
  emailLabel?: string;
29
29
  smsAlerts?: boolean;
30
30
  emailAlerts?: boolean;
31
+ readOnly?: boolean;
31
32
  onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
32
33
  }
33
- export declare const AccountAlertsModal: ({ open, onClose, icon, title, description, phone, phoneLabel, email, emailLabel, smsAlerts, emailAlerts, onChange, }: AccountAlertsModalProps) => import("react/jsx-runtime").JSX.Element;
34
+ export declare const AccountAlertsModal: ({ open, onClose, icon, title, description, phone, phoneLabel, email, emailLabel, smsAlerts, emailAlerts, readOnly, onChange, }: AccountAlertsModalProps) => import("react/jsx-runtime").JSX.Element;
35
+ export declare const UserAccountAlertsModal: ({ open, onClose, phone, email, ...props }: {
36
+ [x: string]: any;
37
+ open?: boolean | undefined;
38
+ onClose?: (() => void) | undefined;
39
+ phone?: string | undefined;
40
+ email?: string | undefined;
41
+ }) => import("react/jsx-runtime").JSX.Element;
34
42
  interface AccountGroupsModalProps extends SettingsModalProps {
35
43
  items?: AccountListItemProps[];
36
44
  }
@@ -9,9 +9,7 @@ declare const meta: {
9
9
  options: {
10
10
  label: string;
11
11
  value: string;
12
- badge: {
13
- label: string;
14
- };
12
+ count: number;
15
13
  }[];
16
14
  };
17
15
  };
@@ -24,6 +24,7 @@ declare const meta: {
24
24
  size?: import('..').ListItemSize | undefined;
25
25
  color?: import('..').ListItemColor | undefined;
26
26
  className?: string | undefined;
27
+ ref?: React.Ref<HTMLElement> | undefined;
27
28
  icon?: import('..').SvgElement | import('..').IconProps | React.ReactNode | import('..').AvatarProps | import('..').AvatarGroupProps;
28
29
  as?: React.ElementType | undefined;
29
30
  label?: React.ReactNode | (() => React.ReactElement);
@@ -3,8 +3,9 @@ import { TypographyProps } from '..';
3
3
  export type HeadingSize = 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'inherit';
4
4
  export type HeadingWeight = 'normal' | 'medium' | 'bold';
5
5
  export type HeadingLeading = 'none' | 'tight' | 'normal';
6
- export type HeadingComponent = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'div' | 'span';
6
+ export type HeadingComponent = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'div' | 'span' | 'label';
7
7
  export interface HeadingProps {
8
+ id?: string;
8
9
  loading?: boolean;
9
10
  highlightWords?: string[];
10
11
  as?: HeadingComponent;
@@ -18,4 +19,4 @@ export interface HeadingProps {
18
19
  style?: CSSProperties;
19
20
  children?: ReactNode;
20
21
  }
21
- export declare const Heading: ({ loading, highlightWords, as, size, leading, weight, color, variant, maxRows, className, style, children, }: HeadingProps) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const Heading: ({ id, loading, highlightWords, as, size, leading, weight, color, variant, maxRows, className, style, children, }: HeadingProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { StoryObj } from '@storybook/react-vite';
2
2
  declare const meta: {
3
3
  title: string;
4
- component: ({ loading, highlightWords, as, size, leading, weight, color, variant, maxRows, className, style, children, }: import('./Heading').HeadingProps) => import("react/jsx-runtime").JSX.Element;
4
+ component: ({ id, loading, highlightWords, as, size, leading, weight, color, variant, maxRows, className, style, children, }: import('./Heading').HeadingProps) => import("react/jsx-runtime").JSX.Element;
5
5
  tags: string[];
6
6
  parameters: {};
7
7
  args: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.41.4",
3
+ "version": "0.41.6",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",