@altinn/altinn-components 0.4.1 → 0.5.0

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 (178) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/biome.jsonc +1 -1
  3. package/lib/components/Attachment/AttachmentLink.stories.ts +1 -1
  4. package/lib/components/Attachment/AttachmentList.stories.ts +1 -1
  5. package/lib/components/Button/Button.tsx +13 -10
  6. package/lib/components/Button/ButtonBase.tsx +1 -1
  7. package/lib/components/Button/ButtonIcon.tsx +16 -0
  8. package/lib/components/Button/ButtonLabel.tsx +16 -0
  9. package/lib/components/Button/Buttons.stories.tsx +64 -0
  10. package/lib/components/Button/ComboButton.tsx +9 -7
  11. package/lib/components/Button/IconButton.stories.tsx +47 -0
  12. package/lib/components/Button/IconButton.tsx +15 -5
  13. package/lib/components/Button/button.module.css +5 -46
  14. package/lib/components/Button/buttonBase.module.css +55 -23
  15. package/lib/components/Button/buttonIcon.module.css +17 -0
  16. package/lib/components/Button/buttonLabel.module.css +17 -0
  17. package/lib/components/Button/comboButton.module.css +15 -65
  18. package/lib/components/Button/iconButton.module.css +21 -4
  19. package/lib/components/Button/index.ts +2 -0
  20. package/lib/components/ContextMenu/ContextMenu.stories.ts +49 -0
  21. package/lib/components/ContextMenu/ContextMenu.tsx +12 -20
  22. package/lib/components/ContextMenu/ContextMenuBase.tsx +33 -0
  23. package/lib/components/Dialog/Dialog.tsx +2 -0
  24. package/lib/components/Dialog/DialogGroup.tsx +24 -0
  25. package/lib/components/Dialog/DialogList.stories.ts +14 -10
  26. package/lib/components/Dialog/DialogList.tsx +26 -11
  27. package/lib/components/Dialog/DialogListItem.tsx +12 -2
  28. package/lib/components/Dialog/DialogListItemBase.tsx +4 -2
  29. package/lib/components/Dialog/DialogNav.stories.ts +5 -5
  30. package/lib/components/Dialog/DialogNav.tsx +2 -6
  31. package/lib/components/Dialog/DialogSelect.tsx +1 -1
  32. package/lib/components/Dialog/dialogGroup.module.css +35 -0
  33. package/lib/components/Dropdown/Backdrop.tsx +4 -3
  34. package/lib/components/Dropdown/DrawerBase.tsx +5 -2
  35. package/lib/components/Dropdown/DrawerBody.tsx +12 -0
  36. package/lib/components/Dropdown/DrawerButton.tsx +17 -0
  37. package/lib/components/Dropdown/DrawerFooter.tsx +12 -0
  38. package/lib/components/Dropdown/DrawerHeader.tsx +19 -0
  39. package/lib/components/Dropdown/DrawerOrDropdown.tsx +29 -0
  40. package/lib/components/Dropdown/DropdownBase.tsx +5 -2
  41. package/lib/components/Dropdown/backdrop.module.css +3 -0
  42. package/lib/components/Dropdown/drawerBase.module.css +9 -0
  43. package/lib/components/Dropdown/drawerBody.module.css +5 -0
  44. package/lib/components/Dropdown/drawerButton.module.css +6 -0
  45. package/lib/components/Dropdown/drawerFooter.module.css +13 -0
  46. package/lib/components/Dropdown/drawerHeader.module.css +17 -0
  47. package/lib/components/Dropdown/drawerOrDropdown.module.css +19 -0
  48. package/lib/components/Dropdown/dropdownBase.module.css +15 -3
  49. package/lib/components/Dropdown/index.ts +7 -1
  50. package/lib/components/Footer/footerMenu.module.css +5 -0
  51. package/lib/components/GlobalMenu/GlobalMenu.stories.tsx +9 -9
  52. package/lib/components/GlobalMenu/GlobalMenu.tsx +5 -5
  53. package/lib/components/Header/{Header.stories.ts → Header.stories.tsx} +79 -20
  54. package/lib/components/Header/Header.tsx +24 -37
  55. package/lib/components/Header/HeaderBase.tsx +7 -3
  56. package/lib/components/Header/header.module.css +10 -42
  57. package/lib/components/Header/headerBase.module.css +43 -0
  58. package/lib/components/Header/headerButton.module.css +1 -0
  59. package/lib/components/Layout/Layout.stories.tsx +77 -38
  60. package/lib/components/Layout/Layout.tsx +5 -3
  61. package/lib/components/Layout/LayoutBase.tsx +3 -2
  62. package/lib/components/Layout/layoutBase.module.css +11 -0
  63. package/lib/components/Layout/layoutBody.module.css +1 -0
  64. package/lib/components/LayoutAction/ActionHeader.tsx +1 -1
  65. package/lib/components/LayoutAction/ActionMenu.tsx +2 -4
  66. package/lib/components/LayoutAction/actionMenu.module.css +3 -0
  67. package/lib/components/List/List.stories.tsx +43 -0
  68. package/lib/components/List/List.tsx +6 -6
  69. package/lib/components/List/ListBase.tsx +6 -6
  70. package/lib/components/List/ListItem.tsx +4 -1
  71. package/lib/components/List/ListItemBase.tsx +20 -4
  72. package/lib/components/List/listBase.module.css +3 -3
  73. package/lib/components/List/listItemBase.module.css +4 -0
  74. package/lib/components/Menu/Menu.stories.ts +46 -46
  75. package/lib/components/Menu/Menu.tsx +3 -102
  76. package/lib/components/Menu/MenuBase.tsx +47 -3
  77. package/lib/components/Menu/MenuItem.tsx +6 -4
  78. package/lib/components/Menu/MenuItemBase.tsx +7 -0
  79. package/lib/components/Menu/MenuItems.stories.ts +438 -0
  80. package/lib/components/Menu/MenuItems.tsx +96 -0
  81. package/lib/components/Menu/MenuOption.tsx +4 -1
  82. package/lib/components/Menu/{MenuGroup.tsx → __MenuGroup.tsx} +1 -1
  83. package/lib/components/Menu/index.ts +1 -1
  84. package/lib/components/Menu/menu.module.css +2 -3
  85. package/lib/components/Menu/menuBase.module.css +25 -0
  86. package/lib/components/Menu/menuItemBase.module.css +5 -4
  87. package/lib/components/Meta/MetaItemBase.tsx +1 -1
  88. package/lib/components/Meta/MetaItemLabel.tsx +1 -1
  89. package/lib/components/Meta/MetaItemMedia.tsx +1 -1
  90. package/lib/components/Page/PageBase.tsx +14 -0
  91. package/lib/components/Page/PageHeader.tsx +21 -0
  92. package/lib/components/Page/PageHeaderMedia.tsx +25 -0
  93. package/lib/components/Page/SectionBase.tsx +52 -0
  94. package/lib/components/Page/SectionFooter.tsx +15 -0
  95. package/lib/components/Page/SectionHeader.tsx +16 -0
  96. package/lib/components/Page/index.ts +5 -0
  97. package/lib/components/Page/pageHeader.module.css +5 -0
  98. package/lib/components/Page/sectionBase.module.css +82 -0
  99. package/lib/components/Page/sectionFooter.module.css +8 -0
  100. package/lib/components/Page/sectionHeader.module.css +9 -0
  101. package/lib/components/RootProvider/RootProvider.tsx +43 -7
  102. package/lib/components/Searchbar/Autocomplete.stories.tsx +77 -0
  103. package/lib/components/Searchbar/Autocomplete.tsx +44 -0
  104. package/lib/components/Searchbar/AutocompleteBase.tsx +16 -0
  105. package/lib/components/Searchbar/AutocompleteGroup.tsx +17 -0
  106. package/lib/components/Searchbar/AutocompleteItem.tsx +23 -0
  107. package/lib/components/Searchbar/SearchField.tsx +78 -0
  108. package/lib/components/Searchbar/Searchbar.stories.tsx +151 -0
  109. package/lib/components/Searchbar/Searchbar.tsx +18 -0
  110. package/lib/components/Searchbar/SearchbarBase.tsx +23 -0
  111. package/lib/components/Searchbar/autocompleteBase.module.css +17 -0
  112. package/lib/components/Searchbar/autocompleteGroup.module.css +3 -0
  113. package/lib/components/Searchbar/autocompleteItem.module.css +19 -0
  114. package/lib/components/Searchbar/index.ts +1 -0
  115. package/lib/components/Searchbar/searchField.module.css +54 -0
  116. package/lib/components/Searchbar/searchbarBase.module.css +20 -0
  117. package/lib/components/Toolbar/Toolbar.stories.tsx +10 -10
  118. package/lib/components/Toolbar/Toolbar.tsx +28 -10
  119. package/lib/components/Toolbar/ToolbarAdd.tsx +6 -5
  120. package/lib/components/Toolbar/ToolbarBase.tsx +5 -20
  121. package/lib/components/Toolbar/ToolbarButton.tsx +1 -1
  122. package/lib/components/Toolbar/ToolbarFilter.tsx +11 -6
  123. package/lib/components/Toolbar/ToolbarMenu.tsx +8 -7
  124. package/lib/components/Toolbar/ToolbarOptions.stories.ts +5 -5
  125. package/lib/components/Toolbar/ToolbarOptions.tsx +34 -21
  126. package/lib/components/Toolbar/toolbarAdd.module.css +7 -0
  127. package/lib/components/Toolbar/toolbarBase.module.css +19 -0
  128. package/lib/components/Toolbar/toolbarButton.module.css +1 -1
  129. package/lib/components/Toolbar/toolbarFilter.module.css +25 -0
  130. package/lib/components/Toolbar/toolbarMenu.module.css +7 -0
  131. package/lib/components/Typography/Heading.tsx +23 -0
  132. package/lib/components/Typography/Typography.tsx +8 -5
  133. package/lib/components/Typography/heading.module.css +21 -0
  134. package/lib/components/Typography/index.ts +1 -0
  135. package/lib/components/Typography/typography.module.css +8 -0
  136. package/lib/components/index.ts +2 -0
  137. package/lib/hooks/index.ts +3 -0
  138. package/lib/{components/Menu → hooks}/useEscapeKey.ts +2 -2
  139. package/lib/hooks/useMenu.tsx +80 -0
  140. package/lib/index.ts +1 -0
  141. package/lib/stories/Color/MenuItem.stories.tsx +43 -0
  142. package/lib/stories/Color/Swatches.stories.tsx +19 -0
  143. package/lib/stories/Color/Swatches.tsx +42 -0
  144. package/lib/stories/Color/colors.json +62 -0
  145. package/lib/stories/Color/swatches.module.css +14 -0
  146. package/lib/stories/Inbox/BookmarksPage.tsx +52 -0
  147. package/lib/stories/Inbox/DialogPage.tsx +15 -0
  148. package/lib/stories/Inbox/Inbox.stories.tsx +55 -0
  149. package/lib/stories/Inbox/Inbox.tsx +12 -0
  150. package/lib/stories/Inbox/InboxLayout.tsx +50 -0
  151. package/lib/stories/Inbox/InboxPage.tsx +50 -0
  152. package/lib/stories/Inbox/InboxProvider.tsx +136 -0
  153. package/lib/stories/Inbox/InboxSection.tsx +39 -0
  154. package/lib/stories/Inbox/InboxToolbar.tsx +94 -0
  155. package/lib/stories/Inbox/ProfilePage.tsx +35 -0
  156. package/lib/stories/Inbox/SettingsPage.tsx +19 -0
  157. package/lib/stories/Inbox/accounts/accounts.ts +24 -0
  158. package/lib/stories/Inbox/accounts/index.ts +1 -0
  159. package/lib/stories/Inbox/actionMenu.ts +24 -0
  160. package/lib/stories/Inbox/dialogs/brreg-completed.json +35 -0
  161. package/lib/stories/Inbox/dialogs/brreg-draft.json +45 -0
  162. package/lib/stories/Inbox/dialogs/index.ts +10 -0
  163. package/lib/stories/Inbox/dialogs/skatt-2023.json +33 -0
  164. package/lib/stories/Inbox/groupBy.ts +19 -0
  165. package/lib/stories/Inbox/inboxSection.module.css +19 -0
  166. package/lib/stories/Inbox/index.ts +15 -0
  167. package/lib/stories/Inbox/layout/footer.ts +27 -0
  168. package/lib/stories/Inbox/layout/header.ts +11 -0
  169. package/lib/stories/Inbox/layout/index.ts +3 -0
  170. package/lib/stories/Inbox/layout/menu.ts +64 -0
  171. package/package.json +1 -1
  172. package/tsconfig.json +7 -2
  173. package/lib/components/Header/HeaderSearch.stories.ts +0 -20
  174. package/lib/components/Header/HeaderSearch.tsx +0 -44
  175. package/lib/components/Header/headerSearch.module.css +0 -30
  176. package/lib/components/Toolbar/toolbar.module.css +0 -43
  177. /package/lib/components/ContextMenu/{contextMenu.module.css → contextMenuBase.module.css} +0 -0
  178. /package/lib/{components/Menu → hooks}/useClickOutside.ts +0 -0
@@ -0,0 +1,27 @@
1
+ export const footer = {
2
+ address: 'Postboks 1382 Vika, 0114 Oslo.',
3
+ menu: {
4
+ items: [
5
+ {
6
+ id: '1',
7
+ href: '#',
8
+ title: 'Om Altinn',
9
+ },
10
+ {
11
+ id: '2',
12
+ href: '#',
13
+ title: 'Driftsmeldinger',
14
+ },
15
+ {
16
+ id: '3',
17
+ href: '#',
18
+ title: 'Personvern',
19
+ },
20
+ {
21
+ id: '4',
22
+ href: '#',
23
+ title: 'Tilgjengelighet',
24
+ },
25
+ ],
26
+ },
27
+ };
@@ -0,0 +1,11 @@
1
+ import { accounts } from '../accounts/';
2
+
3
+ export const header = {
4
+ search: {
5
+ name: 'search',
6
+ placeholder: 'Søk i innboksen',
7
+ },
8
+ menu: {
9
+ accounts,
10
+ },
11
+ };
@@ -0,0 +1,3 @@
1
+ export * from './menu';
2
+ export * from './footer';
3
+ export * from './header';
@@ -0,0 +1,64 @@
1
+ export const menu = {
2
+ groups: {
3
+ shortcuts: {
4
+ title: 'Snarveier',
5
+ defaultItemColor: 'neutral',
6
+ },
7
+ },
8
+ items: [
9
+ {
10
+ id: 'inbox',
11
+ groupId: 1,
12
+ size: 'lg',
13
+ icon: 'inbox',
14
+ title: 'Innboks',
15
+ color: 'strong',
16
+ },
17
+ {
18
+ id: 'drafts',
19
+ groupId: 2,
20
+ icon: 'doc-pencil',
21
+ title: 'Utkast',
22
+ },
23
+ {
24
+ id: 'sent',
25
+ groupId: 2,
26
+ icon: 'file-checkmark',
27
+ selected: true,
28
+ title: 'Sendt',
29
+ },
30
+ {
31
+ id: 'bookmarks',
32
+ groupId: 3,
33
+ icon: 'bookmark',
34
+ // disabled: true,
35
+ title: 'Lagrede søk',
36
+ },
37
+ {
38
+ id: 'archived',
39
+ groupId: 4,
40
+ disabled: true,
41
+ icon: 'archive',
42
+ title: 'Arkivert',
43
+ },
44
+ {
45
+ id: 'trash',
46
+ groupId: 4,
47
+ disabled: true,
48
+ icon: 'trash',
49
+ title: 'Papirkurv',
50
+ },
51
+ {
52
+ id: 'profile',
53
+ groupId: 'shortcuts',
54
+ icon: 'person-circle',
55
+ title: 'Din profil',
56
+ },
57
+ {
58
+ id: 'settings',
59
+ groupId: 'shortcuts',
60
+ icon: 'cog',
61
+ title: 'Innstillinger',
62
+ },
63
+ ],
64
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "main": "lib/index.ts",
5
5
  "description": "Reusable react components",
6
6
  "publishConfig": {
package/tsconfig.json CHANGED
@@ -17,7 +17,12 @@
17
17
  "noFallthroughCasesInSwitch": true,
18
18
  "allowSyntheticDefaultImports": true
19
19
  },
20
- "include": ["./lib/**/*.ts", "./lib/**/*.tsx", "./**/*.d.ts"],
21
- "exclude": ["./lib/**/*.stories.tsx", "./lib/**/*.stories.ts", "./lib/components/Icon/__AkselIcon.tsx"],
20
+ "include": ["./lib/**/*.ts", "./lib/hooks/*.tsx", "./**/*.d.ts"],
21
+ "exclude": [
22
+ "./lib/stories/**/*",
23
+ "lib/components/**/*.stories.ts",
24
+ "lib/components/**/*.stories.tsx",
25
+ "./lib/components/Icon/__AkselIcon.tsx"
26
+ ],
22
27
  "references": [{ "path": "./tsconfig.node.json" }]
23
28
  }
@@ -1,20 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import { HeaderSearch } from './HeaderSearch';
3
-
4
- const meta = {
5
- title: 'Header/HeaderSearch',
6
- component: HeaderSearch,
7
- tags: ['autodocs'],
8
- parameters: {},
9
- args: {},
10
- } satisfies Meta<typeof HeaderSearch>;
11
-
12
- export default meta;
13
- type Story = StoryObj<typeof meta>;
14
-
15
- export const Default: Story = {
16
- args: {
17
- placeholder: 'Search',
18
- name: 'search',
19
- },
20
- };
@@ -1,44 +0,0 @@
1
- import cx from 'classnames';
2
- import type { ChangeEventHandler, FocusEventHandler } from 'react';
3
- import { Icon } from '../Icon';
4
- import styles from './headerSearch.module.css';
5
-
6
- export interface HeaderSearchProps {
7
- className?: string;
8
- expanded?: boolean;
9
- placeholder?: string;
10
- name: string;
11
- value?: string;
12
- onFocus?: FocusEventHandler;
13
- onBlur?: FocusEventHandler;
14
- onChange?: ChangeEventHandler;
15
- }
16
-
17
- export const HeaderSearch = ({
18
- className,
19
- expanded = false,
20
- name = 'q',
21
- value,
22
- placeholder = 'Søk',
23
- onFocus,
24
- onBlur,
25
- onChange,
26
- }: HeaderSearchProps) => {
27
- return (
28
- <div className={cx(styles.form, className)} aria-expanded={expanded}>
29
- <div className={styles.field}>
30
- <input
31
- onFocus={onFocus}
32
- onBlur={onBlur}
33
- name={name}
34
- value={value}
35
- onChange={onChange}
36
- placeholder={placeholder}
37
- className={styles.input}
38
- type="search"
39
- />
40
- <Icon name="magnifying-glass" className={styles.icon} />
41
- </div>
42
- </div>
43
- );
44
- };
@@ -1,30 +0,0 @@
1
- .field {
2
- position: relative;
3
- display: flex;
4
- align-items: center;
5
- font-size: 1.125rem;
6
- color: currentColor;
7
- }
8
-
9
- .input {
10
- font-size: inherit;
11
- flex-grow: 1;
12
- padding-left: 2.5rem;
13
- padding-right: 1rem;
14
- padding-top: 1rem;
15
- padding-bottom: 1rem;
16
- border-radius: 4px;
17
- border: 2px solid;
18
- background-color: transparent;
19
- }
20
-
21
- .input[value] {
22
- background-color: white;
23
- }
24
-
25
- .icon {
26
- position: absolute;
27
- left: 0;
28
- font-size: 1.25rem;
29
- margin: 0 1rem;
30
- }
@@ -1,43 +0,0 @@
1
- .toolbar {
2
- display: flex;
3
- align-items: center;
4
- flex-wrap: wrap;
5
- width: 100%;
6
- gap: 0.5rem;
7
- padding: 0 0.5rem;
8
- margin: 1.125rem 0;
9
- }
10
-
11
- @media (min-width: 1024px) {
12
- .toolbar {
13
- padding: 0;
14
- }
15
- }
16
-
17
- /* TIDI; move styles below */
18
-
19
- .button {
20
- display: inline-block;
21
- }
22
-
23
- .remove-button > button:hover + * + * {
24
- text-decoration: line-through;
25
- }
26
-
27
- .dropdown {
28
- display: none;
29
- }
30
-
31
- .dropdown[aria-expanded="true"] {
32
- display: block;
33
- position: absolute;
34
- z-index: 2;
35
- }
36
-
37
- .dropdown {
38
- margin-top: 0.5rem;
39
- padding: 0 0.5rem;
40
- background-color: var(--neutral-background-default);
41
- border-radius: 2px;
42
- box-shadow: 0 0 1px 0 rgba(0, 0, 0, 0.15), 0 1px 2px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.1);
43
- }