@altinn/altinn-components 0.2.0 → 0.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.2](https://github.com/Altinn/altinn-components/compare/v0.2.1...v0.2.2) (2024-11-06)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * dialog-props ([#28](https://github.com/Altinn/altinn-components/issues/28)) ([59b6a8f](https://github.com/Altinn/altinn-components/commit/59b6a8fb04abece013218402587f93863c1b9012))
9
+
10
+ ## [0.2.1](https://github.com/Altinn/altinn-components/compare/v0.2.0...v0.2.1) (2024-11-06)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * export members and add use client if needed for next support ([#26](https://github.com/Altinn/altinn-components/issues/26)) ([cb2c52e](https://github.com/Altinn/altinn-components/commit/cb2c52e8f8bd3b2633b439285bb8f4e5dc36d2ed))
16
+
3
17
  ## [0.2.0](https://github.com/Altinn/altinn-components/compare/v0.1.0...v0.2.0) (2024-11-06)
4
18
 
5
19
 
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import cx from 'classnames';
2
3
  import { useMemo } from 'react';
3
4
  import { Avatar, type AvatarProps, type AvatarSize, type AvatarType } from '.';
@@ -4,7 +4,7 @@ import { Icon } from '../Icon';
4
4
  import { Menu, type MenuGroups, type MenuItemProps } from '../Menu';
5
5
  import styles from './contextMenu.module.css';
6
6
 
7
- export interface DialogContextMenuProps {
7
+ export interface ContextMenuProps {
8
8
  onToggle?: MouseEventHandler;
9
9
  label: string;
10
10
  value: string | number;
@@ -14,7 +14,7 @@ export interface DialogContextMenuProps {
14
14
  className?: string;
15
15
  }
16
16
 
17
- export const ContextMenu = ({ expanded = true, onToggle, groups = {}, items }: DialogContextMenuProps) => {
17
+ export const ContextMenu = ({ expanded = true, onToggle, groups = {}, items }: ContextMenuProps) => {
18
18
  return (
19
19
  <div className={styles.toggle}>
20
20
  <ButtonBase className={styles.button} as="button" color="secondary" onClick={onToggle}>
@@ -0,0 +1 @@
1
+ export * from './ContextMenu';
@@ -10,7 +10,13 @@ const meta = {
10
10
  parameters: {},
11
11
  argTypes: { body: { control: 'text' } },
12
12
  args: {
13
+ menu: [
14
+ {
15
+ items: [{ label: 'Menu 1' }],
16
+ },
17
+ ],
13
18
  updatedAt: '1999-05-26',
19
+ updatedAtLabel: '26. mai 1999',
14
20
  title: 'Title',
15
21
  summary: 'Summary',
16
22
  },
@@ -9,8 +9,10 @@ import { DialogFooter } from './DialogFooter';
9
9
  import { DialogHeader } from './DialogHeader';
10
10
  import { DialogSeenBy, type DialogSeenByProps } from './DialogSeenBy';
11
11
 
12
+ import type { ContextMenuProps } from '../ContextMenu/';
13
+
12
14
  import type { ReactNode } from 'react';
13
- import { DialogAction, type DialogActionButtonProps } from './DialogAction';
15
+ import { type DialogActionButtonProps, DialogActions } from './DialogActions.tsx';
14
16
  import type { DialogRecipientProps, DialogSenderProps } from './DialogHeadings.tsx';
15
17
  import { DialogHistory, type DialogHistoryProps } from './DialogHistory';
16
18
  import { type DialogBackButtonProps, DialogNav } from './DialogNav';
@@ -21,14 +23,18 @@ export interface DialogProps {
21
23
  title: string;
22
24
  /** Back button */
23
25
  backButton?: DialogBackButtonProps;
26
+ /** Context menu */
27
+ menu?: ContextMenuProps;
24
28
  /** Dialog status */
25
29
  status?: DialogStatusProps;
26
30
  /** Updated date time */
27
31
  updatedAt?: string;
28
- /** Latest updated by name */
29
- updatedByName?: string;
32
+ /** Updated label */
33
+ updatedAtLabel?: string;
30
34
  /** Due date */
31
35
  dueAt?: string;
36
+ /** Due at label */
37
+ dueAtLabel?: string;
32
38
  /** Sender */
33
39
  sender?: DialogSenderProps;
34
40
  /** Recipient */
@@ -57,9 +63,11 @@ export interface DialogProps {
57
63
 
58
64
  export const Dialog = ({
59
65
  backButton,
66
+ menu,
60
67
  updatedAt,
61
- updatedByName,
68
+ updatedAtLabel,
62
69
  dueAt,
70
+ dueAtLabel,
63
71
  status,
64
72
  title,
65
73
  sender,
@@ -75,7 +83,7 @@ export const Dialog = ({
75
83
  }: DialogProps) => {
76
84
  return (
77
85
  <DialogBase>
78
- <DialogNav status={status} dueAt={dueAt} backButton={backButton} />
86
+ <DialogNav status={status} dueAt={dueAt} dueAtLabel={dueAtLabel} backButton={backButton} menu={menu} />
79
87
  <DialogArticleBase>
80
88
  <DialogHeader
81
89
  title={title}
@@ -85,9 +93,9 @@ export const Dialog = ({
85
93
  variant="neutral"
86
94
  />
87
95
  <DialogBodyBase>
88
- <DialogContent updatedAt={updatedAt} updatedByName={updatedByName} summary={summary} body={body} />
96
+ <DialogContent updatedAt={updatedAt} updatedAtLabel={updatedAtLabel} summary={summary} body={body} />
89
97
  {attachments && <DialogAttachments {...attachments} />}
90
- {actions?.length > 0 && <DialogAction items={actions} />}
98
+ {actions?.length > 0 && <DialogActions items={actions} />}
91
99
  <MetaBase>
92
100
  {seenBy && <DialogSeenBy {...seenBy} />}
93
101
  {activityLog && <DialogActivityLog {...activityLog} />}
@@ -1,23 +1,25 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { DialogAction } from './DialogAction';
2
+ import { DialogActions } from './DialogActions';
3
3
 
4
4
  const meta = {
5
- title: 'Dialog/Sections/DialogAction',
6
- component: DialogAction,
5
+ title: 'Dialog/Sections/DialogActions',
6
+ component: DialogActions,
7
7
  tags: ['autodocs'],
8
8
  args: {
9
9
  items: [
10
10
  {
11
11
  label: 'Primary',
12
12
  priority: 'primary',
13
+ id: 'primary',
13
14
  },
14
15
  {
15
16
  label: 'Secondary',
16
17
  priority: 'secondary',
18
+ id: 'secondary',
17
19
  },
18
20
  ],
19
21
  },
20
- } satisfies Meta<typeof DialogAction>;
22
+ } satisfies Meta<typeof DialogActions>;
21
23
 
22
24
  export default meta;
23
25
  type Story = StoryObj<typeof meta>;
@@ -34,18 +36,22 @@ export const MultipleButtons: Story = {
34
36
  args: {
35
37
  items: [
36
38
  {
39
+ id: 'primary',
37
40
  label: 'Primary',
38
41
  priority: 'primary',
39
42
  },
40
43
  {
44
+ id: 'secondary-1',
41
45
  label: 'Secondary',
42
46
  priority: 'secondary',
43
47
  },
44
48
  {
49
+ id: 'tertiary-1',
45
50
  label: 'Third action',
46
51
  priority: 'tertiary',
47
52
  },
48
53
  {
54
+ id: 'tertiary-2',
49
55
  label: 'Fourth action',
50
56
  priority: 'tertiary',
51
57
  },
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { type MouseEventHandler, useMemo, useState } from 'react';
2
3
  import { Button, ComboButton } from '../Button';
3
4
  import { Menu, type MenuItemProps } from '../Menu';
@@ -13,14 +14,14 @@ export interface DialogActionButtonProps {
13
14
  loading?: boolean;
14
15
  }
15
16
 
16
- export interface DialogActionProps {
17
+ export interface DialogActionsProps {
17
18
  /** List of actions */
18
19
  items: DialogActionButtonProps[];
19
20
  /** How many actions to display before turning into a ComboButton */
20
21
  maxItems?: number;
21
22
  }
22
23
 
23
- export const DialogAction = ({ items, maxItems = 2 }: DialogActionProps) => {
24
+ export const DialogActions = ({ items, maxItems = 2 }: DialogActionsProps) => {
24
25
  const [expanded, setExpanded] = useState<boolean>(false);
25
26
  const sortedItems = useMemo(() => {
26
27
  return (items || []).sort((a, b) => {
@@ -3,7 +3,6 @@ import { Typography } from '../Typography';
3
3
  import { DialogMetadata } from './DialogMetadata';
4
4
 
5
5
  export interface DialogContentProps {
6
- updatedByName?: string;
7
6
  updatedAt?: string;
8
7
  updatedAtLabel?: string;
9
8
  summary?: string;
@@ -1,10 +1,10 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import styles from './dialogHeaderBase.module.css';
3
3
 
4
- export interface DialogHeaderProps {
4
+ export interface DialogHeaderBaseProps {
5
5
  children?: ReactNode;
6
6
  }
7
7
 
8
- export const DialogHeaderBase = ({ children }: DialogHeaderProps) => {
8
+ export const DialogHeaderBase = ({ children }: DialogHeaderBaseProps) => {
9
9
  return <header className={styles.header}>{children}</header>;
10
10
  };
@@ -2,7 +2,7 @@
2
2
  import { useState } from 'react';
3
3
  import type { ElementType } from 'react';
4
4
  import { Button } from '../Button';
5
- import { ContextMenu, type DialogContextMenuProps } from '../ContextMenu/ContextMenu.tsx';
5
+ import { ContextMenu, type ContextMenuProps } from '../ContextMenu/ContextMenu.tsx';
6
6
  import { MetaTimestamp } from '../Meta';
7
7
  import { DialogStatus, type DialogStatusProps } from './DialogStatus';
8
8
  import { DialogTouchedBy, type DialogTouchedByActor } from './DialogTouchedBy';
@@ -17,10 +17,10 @@ export interface DialogBackButtonProps {
17
17
  export interface DialogNavProps {
18
18
  status?: DialogStatusProps;
19
19
  dueAt?: string;
20
- duaAtLabel?: string;
20
+ dueAtLabel?: string;
21
21
  touchedBy?: DialogTouchedByActor[];
22
22
  backButton?: DialogBackButtonProps;
23
- menu?: DialogContextMenuProps;
23
+ menu?: ContextMenuProps;
24
24
  }
25
25
 
26
26
  /**
@@ -33,8 +33,8 @@ export const DialogNav = ({
33
33
  },
34
34
  status,
35
35
  dueAt,
36
+ dueAtLabel,
36
37
  touchedBy,
37
- duaAtLabel,
38
38
  menu,
39
39
  }: DialogNavProps) => {
40
40
  const [expandedItem, setexpandedItem] = useState<boolean>(false);
@@ -46,9 +46,9 @@ export const DialogNav = ({
46
46
  {backButton?.label || 'Back'}
47
47
  </Button>
48
48
  <div className={styles.action}>
49
- {duaAtLabel && duaAtLabel && (
49
+ {dueAt && dueAtLabel && (
50
50
  <MetaTimestamp datetime={dueAt} size="xs">
51
- {duaAtLabel}
51
+ {dueAtLabel}
52
52
  </MetaTimestamp>
53
53
  )}
54
54
  {status && <DialogStatus {...status} />}
@@ -1,2 +1,24 @@
1
+ export * from './Dialog';
2
+ export * from './DialogList';
1
3
  export * from './DialogMetadata';
2
4
  export * from './DialogListItem';
5
+ export * from './DialogListItemBase';
6
+ export * from './DialogActions.tsx';
7
+ export * from './DialogActivityLog';
8
+ export * from './DialogArticleBase';
9
+ export * from './DialogBase';
10
+ export * from './DialogBodyBase';
11
+ export * from './DialogBorder';
12
+ export * from './DialogContent';
13
+ export * from './DialogFooter';
14
+ export * from './DialogHeader';
15
+ export * from './DialogHeaderBase';
16
+ export * from './DialogHeadings';
17
+ export * from './DialogHistory';
18
+ export * from './DialogNav';
19
+ export * from './DialogSectionBase';
20
+ export * from './DialogSeenBy';
21
+ export * from './DialogSelect';
22
+ export * from './DialogStatus';
23
+ export * from './DialogTitle';
24
+ export * from './DialogTouchedBy';
@@ -2,3 +2,5 @@ export * from './ListItemBase';
2
2
  export * from './ListItem';
3
3
  export * from './ListBase';
4
4
  export * from './List';
5
+ export * from './ListItemLabel';
6
+ export * from './ListItemMedia';
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { type RefObject, useEffect } from 'react';
2
3
 
3
4
  export const useClickOutside = (ref: RefObject<HTMLDivElement>, callback: () => void) => {
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { useEffect } from 'react';
2
3
 
3
4
  export const useEscapeKey = (onEscape: () => void): void => {
@@ -1,6 +1,8 @@
1
1
  export * from './MetaBase';
2
2
  export * from './MetaList';
3
3
  export * from './MetaItemBase';
4
+ export * from './MetaItemMedia';
5
+ export * from './MetaItemLabel';
4
6
  export * from './MetaItem';
5
7
  export * from './MetaProgress';
6
8
  export * from './MetaTimestamp';
@@ -1,10 +1,15 @@
1
+ export * from './Attachment';
1
2
  export * from './Avatar';
2
- export * from './Button';
3
3
  export * from './Badge';
4
+ export * from './Button';
5
+ export * from './ContextMenu';
6
+ export * from './Dialog';
4
7
  export * from './Header';
8
+ export * from './History';
5
9
  export * from './Icon';
6
10
  export * from './Layout';
7
11
  export * from './List';
8
12
  export * from './Menu';
9
13
  export * from './Meta';
10
14
  export * from './Toolbar';
15
+ export * from './Typography';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "main": "lib/index.ts",
5
5
  "description": "Reusable react components",
6
6
  "publishConfig": {