@helsenorge/designsystem-react 7.6.0 → 7.8.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 (77) hide show
  1. package/CHANGELOG.md +40 -3
  2. package/components/AnchorLink/styles.module.scss +6 -5
  3. package/components/Badge/Badge.d.ts +7 -1
  4. package/components/Badge/Badge.js +19 -9
  5. package/components/Badge/Badge.js.map +1 -1
  6. package/components/Badge/Badge.stories.d.ts +11 -0
  7. package/components/Badge/NotificationBadge.d.ts +17 -0
  8. package/components/Badge/NotificationBadge.js +68 -0
  9. package/components/Badge/NotificationBadge.js.map +1 -0
  10. package/components/Button/Button.d.ts +3 -0
  11. package/components/Button/Button.js +68 -66
  12. package/components/Button/Button.js.map +1 -1
  13. package/components/Button/styles.module.scss +6 -0
  14. package/components/Button/styles.module.scss.d.ts +1 -0
  15. package/components/Expander/styles.module.scss +4 -2
  16. package/components/ExpanderHierarchy/ExpanderHierarchy.stories.d.ts +13 -12
  17. package/components/LinkList/LinkList.stories.d.ts +1 -0
  18. package/components/List/List.stories.d.ts +19 -2
  19. package/components/ListHeader/ListHeader.d.ts +1 -1
  20. package/components/ListHeader/ListHeader.js +32 -28
  21. package/components/ListHeader/ListHeader.js.map +1 -1
  22. package/components/NotificationPanel/NotificationPanel.d.ts +1 -1
  23. package/components/NotificationPanel/NotificationPanel.js +69 -103
  24. package/components/NotificationPanel/NotificationPanel.js.map +1 -1
  25. package/components/NotificationPanel/NotificationPanel.stories.d.ts +1 -1
  26. package/components/NotificationPanel/styles.module.scss +14 -0
  27. package/components/NotificationPanel/styles.module.scss.d.ts +1 -0
  28. package/components/ServiceMessage/ServiceMessage.js +66 -75
  29. package/components/ServiceMessage/ServiceMessage.js.map +1 -1
  30. package/components/ServiceMessage/ServiceMessage.stories.d.ts +1 -1
  31. package/components/ServiceMessage/styles.module.scss +13 -0
  32. package/components/ServiceMessage/styles.module.scss.d.ts +1 -0
  33. package/components/Tabs/Tab.d.ts +17 -0
  34. package/components/Tabs/Tab.js +6 -0
  35. package/components/Tabs/Tab.js.map +1 -0
  36. package/components/Tabs/TabList/TabList.d.ts +11 -0
  37. package/components/Tabs/TabList/TabList.js +51 -0
  38. package/components/Tabs/TabList/TabList.js.map +1 -0
  39. package/components/Tabs/TabList/index.d.ts +3 -0
  40. package/components/Tabs/TabList/index.js +5 -0
  41. package/components/Tabs/TabList/index.js.map +1 -0
  42. package/components/Tabs/TabList/styles.module.scss +109 -0
  43. package/components/Tabs/TabList/styles.module.scss.d.ts +18 -0
  44. package/components/Tabs/TabPanel/TabPanel.d.ts +9 -0
  45. package/components/Tabs/TabPanel/TabPanel.js +13 -0
  46. package/components/Tabs/TabPanel/TabPanel.js.map +1 -0
  47. package/components/Tabs/TabPanel/index.d.ts +3 -0
  48. package/components/Tabs/TabPanel/index.js +5 -0
  49. package/components/Tabs/TabPanel/index.js.map +1 -0
  50. package/components/Tabs/TabPanel/styles.module.scss +37 -0
  51. package/components/Tabs/TabPanel/styles.module.scss.d.ts +15 -0
  52. package/components/Tabs/Tabs.d.ts +22 -0
  53. package/components/Tabs/Tabs.js +19 -0
  54. package/components/Tabs/Tabs.js.map +1 -0
  55. package/components/Tabs/Tabs.stories.d.ts +50 -0
  56. package/components/Tabs/index.d.ts +3 -0
  57. package/components/Tabs/index.js +5 -0
  58. package/components/Tabs/index.js.map +1 -0
  59. package/components/Tabs/styles.module.scss +3 -0
  60. package/components/Tabs/styles.module.scss.d.ts +9 -0
  61. package/components/Tile/Tile.stories.d.ts +26 -2
  62. package/constants.d.ts +5 -1
  63. package/constants.js +1 -1
  64. package/constants.js.map +1 -1
  65. package/docs/index.js +7 -7
  66. package/docs/index.js.map +1 -1
  67. package/hooks/useRovingFocus.d.ts +1 -0
  68. package/hooks/useRovingFocus.js +27 -0
  69. package/hooks/useRovingFocus.js.map +1 -0
  70. package/hooks/useRovingFocus.stories.d.ts +17 -0
  71. package/package.json +1 -1
  72. package/scss/typography.module.scss +7 -5
  73. package/components/NotificationPanel/DetailButton/DetailButton.d.ts +0 -9
  74. package/components/NotificationPanel/DetailButton/DetailButton.js +0 -28
  75. package/components/NotificationPanel/DetailButton/DetailButton.js.map +0 -1
  76. package/components/NotificationPanel/DetailButton/styles.module.scss +0 -38
  77. package/components/NotificationPanel/DetailButton/styles.module.scss.d.ts +0 -13
@@ -0,0 +1,15 @@
1
+ export type Styles = {
2
+ 'tab-panel': string;
3
+ 'tab-panel--blueberry': string;
4
+ 'tab-panel--first': string;
5
+ 'tab-panel--framed': string;
6
+ 'tab-panel--neutral': string;
7
+ 'tab-panel--normal': string;
8
+ 'tab-panel--white': string;
9
+ };
10
+
11
+ export type ClassNames = keyof Styles;
12
+
13
+ declare const styles: Styles;
14
+
15
+ export default styles;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import Tab from './Tab';
3
+ import { PaletteNames } from '../../theme/palette';
4
+ export type { TabProps } from './Tab';
5
+ export type TabsColors = Extract<PaletteNames, 'blueberry' | 'neutral' | 'white'>;
6
+ export type TabsType = 'normal' | 'framed';
7
+ export interface TabsProps {
8
+ /** Sets the data-testid attribute. */
9
+ testId?: string;
10
+ /** Sets the color of the tabs. Default: white */
11
+ color?: TabsColors;
12
+ /** Sets the visual type of the tabs */
13
+ type?: TabsType;
14
+ /** Controlled state for Tabs component */
15
+ activeTab?: number;
16
+ }
17
+ declare const TabsRoot: React.FC<TabsProps>;
18
+ type TabsComponent = typeof TabsRoot & {
19
+ Tab: typeof Tab;
20
+ };
21
+ declare const Tabs: TabsComponent;
22
+ export default Tabs;
@@ -0,0 +1,19 @@
1
+ import t, { useState as T } from "react";
2
+ import f from "./Tab.js";
3
+ import u from "./TabList/TabList.js";
4
+ import p from "./TabPanel/TabPanel.js";
5
+ import C from "../Tabs/styles.module.scss";
6
+ const y = ({ children: s, testId: m, color: n = "white", type: r = "normal", activeTab: l }) => {
7
+ const i = l !== void 0, [b, c] = T(0), d = (o) => {
8
+ i || c(o);
9
+ }, e = i ? l : b;
10
+ return /* @__PURE__ */ t.createElement("div", { className: C.tabs, "data-testid": m }, /* @__PURE__ */ t.createElement(u, { onTabListClick: (o) => d(o), selectedTab: e, color: n, type: r }, s), /* @__PURE__ */ t.createElement(p, { color: n, type: r, isFirst: e == 0 }, t.Children.toArray(s)[e]));
11
+ }, a = y;
12
+ a.displayName = "Tabs";
13
+ a.Tab = f;
14
+ a.Tab.displayName = "Tabs.Tab";
15
+ const x = a;
16
+ export {
17
+ x as default
18
+ };
19
+ //# sourceMappingURL=Tabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tabs.js","sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport Tab from './Tab';\nimport TabList from './TabList';\nimport TabPanel from './TabPanel';\nimport { PaletteNames } from '../../theme/palette';\nexport type { TabProps } from './Tab';\n\nimport styles from './styles.module.scss';\n\nexport type TabsColors = Extract<PaletteNames, 'blueberry' | 'neutral' | 'white'>;\n\nexport type TabsType = 'normal' | 'framed';\n\nexport interface TabsProps {\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets the color of the tabs. Default: white */\n color?: TabsColors;\n /** Sets the visual type of the tabs */\n type?: TabsType;\n /** Controlled state for Tabs component */\n activeTab?: number;\n}\n\nconst TabsRoot: React.FC<TabsProps> = ({ children, testId, color = 'white', type = 'normal', activeTab }) => {\n const isControlled = activeTab !== undefined;\n const [uncontrolledValue, setUncontrolledValue] = useState(0);\n\n const onValueChange = (newValue: number): void => {\n if (!isControlled) {\n setUncontrolledValue(newValue);\n }\n };\n\n const activeTabIndex = isControlled ? activeTab : uncontrolledValue;\n\n return (\n <div className={styles.tabs} data-testid={testId}>\n <TabList onTabListClick={(index: number) => onValueChange(index)} selectedTab={activeTabIndex} color={color} type={type}>\n {children}\n </TabList>\n <TabPanel color={color} type={type} isFirst={activeTabIndex == 0}>\n {React.Children.toArray(children)[activeTabIndex]}\n </TabPanel>\n </div>\n );\n};\n\ntype TabsComponent = typeof TabsRoot & {\n Tab: typeof Tab;\n};\nconst Tabs = TabsRoot as TabsComponent;\nTabs.displayName = 'Tabs';\nTabs.Tab = Tab;\nTabs.Tab.displayName = 'Tabs.Tab';\n\nexport default Tabs;\n"],"names":["TabsRoot","children","testId","color","type","activeTab","isControlled","uncontrolledValue","setUncontrolledValue","useState","onValueChange","newValue","activeTabIndex","React","styles","TabList","index","TabPanel","Tabs","Tab","Tabs$1"],"mappings":";;;;;AAyBA,MAAMA,IAAgC,CAAC,EAAE,UAAAC,GAAU,QAAAC,GAAQ,OAAAC,IAAQ,SAAS,MAAAC,IAAO,UAAU,WAAAC,QAAgB;AAC3G,QAAMC,IAAeD,MAAc,QAC7B,CAACE,GAAmBC,CAAoB,IAAIC,EAAS,CAAC,GAEtDC,IAAgB,CAACC,MAA2B;AAChD,IAAKL,KACHE,EAAqBG,CAAQ;AAAA,EAC/B,GAGIC,IAAiBN,IAAeD,IAAYE;AAElD,SACGM,gBAAAA,EAAA,cAAA,OAAA,EAAI,WAAWC,EAAO,MAAM,eAAaZ,EAAA,GACvCW,gBAAAA,EAAA,cAAAE,GAAA,EAAQ,gBAAgB,CAACC,MAAkBN,EAAcM,CAAK,GAAG,aAAaJ,GAAgB,OAAAT,GAAc,MAAAC,EAAA,GAC1GH,CACH,GACAY,gBAAAA,EAAA,cAACI,GAAS,EAAA,OAAAd,GAAc,MAAAC,GAAY,SAASQ,KAAkB,EAC5D,GAAAC,EAAM,SAAS,QAAQZ,CAAQ,EAAEW,CAAc,CAClD,CACF;AAEJ,GAKMM,IAAOlB;AACbkB,EAAK,cAAc;AACnBA,EAAK,MAAMC;AACXD,EAAK,IAAI,cAAc;AAEvB,MAAAE,IAAeF;"}
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import { StoryObj } from '@storybook/react';
3
+ declare const meta: {
4
+ title: string;
5
+ component: React.FC<import("./Tabs").TabsProps> & {
6
+ Tab: React.FC<import("./Tab").TabProps>;
7
+ };
8
+ subcomponents: {
9
+ Tab: React.FC<import("./Tab").TabProps>;
10
+ };
11
+ parameters: {
12
+ docs: {
13
+ description: {
14
+ component: string;
15
+ };
16
+ page: () => React.JSX.Element;
17
+ };
18
+ };
19
+ args: {
20
+ color: "white";
21
+ type: "normal";
22
+ };
23
+ argTypes: {
24
+ color: {
25
+ control: string;
26
+ options: string[];
27
+ description: string;
28
+ };
29
+ testId: {
30
+ control: string;
31
+ description: string;
32
+ };
33
+ type: {
34
+ control: string;
35
+ options: string[];
36
+ describtion: string;
37
+ };
38
+ activeTab: {
39
+ control: string;
40
+ description: string;
41
+ };
42
+ };
43
+ };
44
+ export default meta;
45
+ type Story = StoryObj<typeof meta>;
46
+ export declare const Default: Story;
47
+ export declare const WithIcon: Story;
48
+ export declare const Framed: Story;
49
+ export declare const Colors: Story;
50
+ export declare const Controlled: Story;
@@ -0,0 +1,3 @@
1
+ import Tabs from './Tabs';
2
+ export * from './Tabs';
3
+ export default Tabs;
@@ -0,0 +1,5 @@
1
+ import o from "./Tabs.js";
2
+ export {
3
+ o as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,3 @@
1
+ .tabs {
2
+ background-color: transparent;
3
+ }
@@ -0,0 +1,9 @@
1
+ export type Styles = {
2
+ tabs: string;
3
+ };
4
+
5
+ export type ClassNames = keyof Styles;
6
+
7
+ declare const styles: Styles;
8
+
9
+ export default styles;
@@ -12,23 +12,47 @@ declare const meta: {
12
12
  };
13
13
  };
14
14
  args: {
15
+ title: React.JSX.Element;
16
+ icon: React.JSX.Element;
15
17
  fixed: false;
16
18
  highlighted: false;
17
19
  href: string;
18
20
  description: string;
19
21
  };
20
22
  argTypes: {
21
- fixed: {
23
+ children: {
24
+ control: string;
25
+ };
26
+ className: {
27
+ control: string;
28
+ description: string;
29
+ };
30
+ icon: {
31
+ control: string;
32
+ description: string;
33
+ };
34
+ title: {
22
35
  control: string;
36
+ description: string;
23
37
  };
24
38
  highlighted: {
25
39
  control: string;
40
+ description: string;
41
+ };
42
+ description: {
43
+ control: string;
44
+ description: string;
45
+ };
46
+ fixed: {
47
+ control: string;
48
+ description: string;
26
49
  };
27
50
  href: {
28
51
  control: string;
29
52
  };
30
- description: {
53
+ testId: {
31
54
  control: string;
55
+ description: string;
32
56
  };
33
57
  };
34
58
  };
package/constants.d.ts CHANGED
@@ -112,6 +112,10 @@ export declare enum KeyboardEventKey {
112
112
  Escape = "Escape",
113
113
  ArrowDown = "ArrowDown",
114
114
  ArrowUp = "ArrowUp",
115
+ ArrowRight = "ArrowRight",
116
+ ArrowLeft = "ArrowLeft",
115
117
  Home = "Home",
116
- End = "End"
118
+ End = "End",
119
+ Space = " ",
120
+ Tab = "Tab"
117
121
  }
package/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var e = /* @__PURE__ */ ((r) => (r[r.XXSmall = 24] = "XXSmall", r[r.XSmall = 38] = "XSmall", r[r.Small = 48] = "Small", r[r.Medium = 64] = "Medium", r[r.Large = 80] = "Large", r[r.XLarge = 130] = "XLarge", r))(e || {}), o = /* @__PURE__ */ ((r) => (r[r.Modal = 13e5] = "Modal", r[r.PopOver = 11e3] = "PopOver", r[r.ExpanderTrigger = 1e4] = "ExpanderTrigger", r))(o || {});
2
2
  const g = 12;
3
- var p = /* @__PURE__ */ ((r) => (r.onwhite = "onwhite", r.ongrey = "ongrey", r.onblueberry = "onblueberry", r.ondark = "ondark", r.oninvalid = "oninvalid", r))(p || {}), a = /* @__PURE__ */ ((r) => (r.medium = "medium", r.large = "large", r))(a || {}), t = /* @__PURE__ */ ((r) => (r.AnchorLink = "anchor-link", r.Avatar = "avatar", r.Badge = "badge", r.Button = "button", r.Checkbox = "checkbox", r.Close = "close", r.DictionaryTrigger = "dictionary-trigger", r.Dropdown = "dropdown", r.Duolist = "duolist", r.EmptyState = "empty-state", r.Expander = "expander", r.ExpanderHierarchy = "expander-hierarchy", r.ExpanderHierarchyExpander = "expander-hierarchy-expander", r.ExpanderList = "expander-list", r.ExpanderListExpander = "expander-list-expander", r.FormGroup = "form-group", r.FormLayout = "form-layout", r.HelpBubble = "help-bubble", r.HelpQuestion = "help-question", r.HighlightBox = "highlight-box", r.Icon = "icon", r.Illustration = "Illustration", r.Input = "input", r.Label = "label", r.Link = "link", r.LinkList = "link-list", r.List = "list", r.Loader = "loader", r.Logo = "logo", r.Modal = "modal", r.NotificationPanel = "notification-panel", r.Panel = "panel", r.PanelList = "panel-list", r.PopMenu = "pop-menu", r.PopOver = "pop-over", r.Portal = "portal", r.PromoPanel = "promo-panel", r.RadioButton = "radio-button", r.Select = "select", r.SharingStatus = "sharing-status", r.Slider = "slider", r.Spacer = "spacer", r.StatusDot = "status-dot", r.Step = "step", r.StepButtons = "step-buttons", r.Stepper = "stepper", r.Sublabel = "sublabel", r.Table = "table", r.Tag = "tag", r.TagList = "tag-list", r.Textarea = "textarea", r.Tile = "tile", r.Title = "title", r.Tooltip = "tooltip", r.Trigger = "trigger", r.Validation = "validation", r))(t || {}), u = /* @__PURE__ */ ((r) => (r.Enter = "Enter", r.Escape = "Escape", r.ArrowDown = "ArrowDown", r.ArrowUp = "ArrowUp", r.Home = "Home", r.End = "End", r))(u || {});
3
+ var p = /* @__PURE__ */ ((r) => (r.onwhite = "onwhite", r.ongrey = "ongrey", r.onblueberry = "onblueberry", r.ondark = "ondark", r.oninvalid = "oninvalid", r))(p || {}), a = /* @__PURE__ */ ((r) => (r.medium = "medium", r.large = "large", r))(a || {}), t = /* @__PURE__ */ ((r) => (r.AnchorLink = "anchor-link", r.Avatar = "avatar", r.Badge = "badge", r.Button = "button", r.Checkbox = "checkbox", r.Close = "close", r.DictionaryTrigger = "dictionary-trigger", r.Dropdown = "dropdown", r.Duolist = "duolist", r.EmptyState = "empty-state", r.Expander = "expander", r.ExpanderHierarchy = "expander-hierarchy", r.ExpanderHierarchyExpander = "expander-hierarchy-expander", r.ExpanderList = "expander-list", r.ExpanderListExpander = "expander-list-expander", r.FormGroup = "form-group", r.FormLayout = "form-layout", r.HelpBubble = "help-bubble", r.HelpQuestion = "help-question", r.HighlightBox = "highlight-box", r.Icon = "icon", r.Illustration = "Illustration", r.Input = "input", r.Label = "label", r.Link = "link", r.LinkList = "link-list", r.List = "list", r.Loader = "loader", r.Logo = "logo", r.Modal = "modal", r.NotificationPanel = "notification-panel", r.Panel = "panel", r.PanelList = "panel-list", r.PopMenu = "pop-menu", r.PopOver = "pop-over", r.Portal = "portal", r.PromoPanel = "promo-panel", r.RadioButton = "radio-button", r.Select = "select", r.SharingStatus = "sharing-status", r.Slider = "slider", r.Spacer = "spacer", r.StatusDot = "status-dot", r.Step = "step", r.StepButtons = "step-buttons", r.Stepper = "stepper", r.Sublabel = "sublabel", r.Table = "table", r.Tag = "tag", r.TagList = "tag-list", r.Textarea = "textarea", r.Tile = "tile", r.Title = "title", r.Tooltip = "tooltip", r.Trigger = "trigger", r.Validation = "validation", r))(t || {}), u = /* @__PURE__ */ ((r) => (r.Enter = "Enter", r.Escape = "Escape", r.ArrowDown = "ArrowDown", r.ArrowUp = "ArrowUp", r.ArrowRight = "ArrowRight", r.ArrowLeft = "ArrowLeft", r.Home = "Home", r.End = "End", r.Space = " ", r.Tab = "Tab", r))(u || {});
4
4
  export {
5
5
  g as AVERAGE_CHARACTER_WIDTH_PX,
6
6
  t as AnalyticsId,
package/constants.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export enum IconSize {\n XXSmall = 24,\n XSmall = 38,\n Small = 48,\n Medium = 64,\n Large = 80,\n XLarge = 130,\n}\n\nexport enum ZIndex {\n Modal = 1300000,\n PopOver = 11000,\n ExpanderTrigger = 10000,\n // TODO: Skille mellom ExpanderTrigger isSticky og isHovered? Skulle tro isHovered trenger vesentlig mindre z-index\n}\n\nexport const AVERAGE_CHARACTER_WIDTH_PX = 12;\n\nexport interface HTMLButtonProps {\n autoFocus?: boolean;\n disabled?: boolean;\n form?: string;\n formAction?: string;\n formEncType?: string;\n formMethod?: string;\n formNoValidate?: boolean;\n formTarget?: string;\n name?: string;\n type?: 'submit' | 'reset' | 'button' | string;\n value?: string | string[] | number;\n id?: string;\n}\n\nexport type AnchorTarget = '_self' | '_blank' | '_parent' | '_top';\n\nexport interface HTMLAnchorProps {\n download?: string;\n href?: string;\n hrefLang?: string;\n media?: string;\n ping?: string;\n rel?: AnchorTarget;\n target?: string;\n referrerPolicy?:\n | ''\n | 'same-origin'\n | 'no-referrer'\n | 'no-referrer-when-downgrade'\n | 'origin'\n | 'origin-when-cross-origin'\n | 'strict-origin'\n | 'strict-origin-when-cross-origin'\n | 'unsafe-url';\n}\n\nexport type ButtonVariant = 'secondary' | 'tertiary' | string | undefined | null;\n\nexport enum FormMode {\n onwhite = 'onwhite',\n ongrey = 'ongrey',\n onblueberry = 'onblueberry',\n ondark = 'ondark',\n oninvalid = 'oninvalid',\n}\n\nexport enum FormSize {\n medium = 'medium',\n large = 'large',\n}\n\nexport enum AnalyticsId {\n AnchorLink = 'anchor-link',\n Avatar = 'avatar',\n Badge = 'badge',\n Button = 'button',\n Checkbox = 'checkbox',\n Close = 'close',\n DictionaryTrigger = 'dictionary-trigger',\n Dropdown = 'dropdown',\n Duolist = 'duolist',\n EmptyState = 'empty-state',\n Expander = 'expander',\n ExpanderHierarchy = 'expander-hierarchy',\n ExpanderHierarchyExpander = 'expander-hierarchy-expander',\n ExpanderList = 'expander-list',\n ExpanderListExpander = 'expander-list-expander',\n FormGroup = 'form-group',\n FormLayout = 'form-layout',\n HelpBubble = 'help-bubble',\n HelpQuestion = 'help-question',\n HighlightBox = 'highlight-box',\n Icon = 'icon',\n Illustration = 'Illustration',\n Input = 'input',\n Label = 'label',\n Link = 'link',\n LinkList = 'link-list',\n List = 'list',\n Loader = 'loader',\n Logo = 'logo',\n Modal = 'modal',\n NotificationPanel = 'notification-panel',\n Panel = 'panel',\n PanelList = 'panel-list',\n PopMenu = 'pop-menu',\n PopOver = 'pop-over',\n Portal = 'portal',\n PromoPanel = 'promo-panel',\n RadioButton = 'radio-button',\n Select = 'select',\n SharingStatus = 'sharing-status',\n Slider = 'slider',\n Spacer = 'spacer',\n StatusDot = 'status-dot',\n Step = 'step',\n StepButtons = 'step-buttons',\n Stepper = 'stepper',\n Sublabel = 'sublabel',\n Table = 'table',\n Tag = 'tag',\n TagList = 'tag-list',\n Textarea = 'textarea',\n Tile = 'tile',\n Title = 'title',\n Tooltip = 'tooltip',\n Trigger = 'trigger',\n Validation = 'validation',\n}\n\nexport enum KeyboardEventKey {\n Enter = 'Enter',\n Escape = 'Escape',\n ArrowDown = 'ArrowDown',\n ArrowUp = 'ArrowUp',\n Home = 'Home',\n End = 'End',\n}\n"],"names":["IconSize","ZIndex","AVERAGE_CHARACTER_WIDTH_PX","FormMode","FormSize","AnalyticsId","KeyboardEventKey"],"mappings":"AAAY,IAAAA,sBAAAA,OACVA,EAAAA,EAAA,UAAU,EAAV,IAAA,WACAA,EAAAA,EAAA,SAAS,EAAT,IAAA,UACAA,EAAAA,EAAA,QAAQ,EAAR,IAAA,SACAA,EAAAA,EAAA,SAAS,EAAT,IAAA,UACAA,EAAAA,EAAA,QAAQ,EAAR,IAAA,SACAA,EAAAA,EAAA,SAAS,GAAT,IAAA,UANUA,IAAAA,KAAA,CAAA,CAAA,GASAC,sBAAAA,OACVA,EAAAA,EAAA,QAAQ,IAAR,IAAA,SACAA,EAAAA,EAAA,UAAU,IAAV,IAAA,WACAA,EAAAA,EAAA,kBAAkB,GAAlB,IAAA,mBAHUA,IAAAA,KAAA,CAAA,CAAA;AAOL,MAAMC,IAA6B;AAyC9B,IAAAC,sBAAAA,OACVA,EAAA,UAAU,WACVA,EAAA,SAAS,UACTA,EAAA,cAAc,eACdA,EAAA,SAAS,UACTA,EAAA,YAAY,aALFA,IAAAA,KAAA,CAAA,CAAA,GAQAC,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,QAAQ,SAFEA,IAAAA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O,QACPA,EAAA,MAAM,OANIA,IAAAA,KAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export enum IconSize {\n XXSmall = 24,\n XSmall = 38,\n Small = 48,\n Medium = 64,\n Large = 80,\n XLarge = 130,\n}\n\nexport enum ZIndex {\n Modal = 1300000,\n PopOver = 11000,\n ExpanderTrigger = 10000,\n // TODO: Skille mellom ExpanderTrigger isSticky og isHovered? Skulle tro isHovered trenger vesentlig mindre z-index\n}\n\nexport const AVERAGE_CHARACTER_WIDTH_PX = 12;\n\nexport interface HTMLButtonProps {\n autoFocus?: boolean;\n disabled?: boolean;\n form?: string;\n formAction?: string;\n formEncType?: string;\n formMethod?: string;\n formNoValidate?: boolean;\n formTarget?: string;\n name?: string;\n type?: 'submit' | 'reset' | 'button' | string;\n value?: string | string[] | number;\n id?: string;\n}\n\nexport type AnchorTarget = '_self' | '_blank' | '_parent' | '_top';\n\nexport interface HTMLAnchorProps {\n download?: string;\n href?: string;\n hrefLang?: string;\n media?: string;\n ping?: string;\n rel?: AnchorTarget;\n target?: string;\n referrerPolicy?:\n | ''\n | 'same-origin'\n | 'no-referrer'\n | 'no-referrer-when-downgrade'\n | 'origin'\n | 'origin-when-cross-origin'\n | 'strict-origin'\n | 'strict-origin-when-cross-origin'\n | 'unsafe-url';\n}\n\nexport type ButtonVariant = 'secondary' | 'tertiary' | string | undefined | null;\n\nexport enum FormMode {\n onwhite = 'onwhite',\n ongrey = 'ongrey',\n onblueberry = 'onblueberry',\n ondark = 'ondark',\n oninvalid = 'oninvalid',\n}\n\nexport enum FormSize {\n medium = 'medium',\n large = 'large',\n}\n\nexport enum AnalyticsId {\n AnchorLink = 'anchor-link',\n Avatar = 'avatar',\n Badge = 'badge',\n Button = 'button',\n Checkbox = 'checkbox',\n Close = 'close',\n DictionaryTrigger = 'dictionary-trigger',\n Dropdown = 'dropdown',\n Duolist = 'duolist',\n EmptyState = 'empty-state',\n Expander = 'expander',\n ExpanderHierarchy = 'expander-hierarchy',\n ExpanderHierarchyExpander = 'expander-hierarchy-expander',\n ExpanderList = 'expander-list',\n ExpanderListExpander = 'expander-list-expander',\n FormGroup = 'form-group',\n FormLayout = 'form-layout',\n HelpBubble = 'help-bubble',\n HelpQuestion = 'help-question',\n HighlightBox = 'highlight-box',\n Icon = 'icon',\n Illustration = 'Illustration',\n Input = 'input',\n Label = 'label',\n Link = 'link',\n LinkList = 'link-list',\n List = 'list',\n Loader = 'loader',\n Logo = 'logo',\n Modal = 'modal',\n NotificationPanel = 'notification-panel',\n Panel = 'panel',\n PanelList = 'panel-list',\n PopMenu = 'pop-menu',\n PopOver = 'pop-over',\n Portal = 'portal',\n PromoPanel = 'promo-panel',\n RadioButton = 'radio-button',\n Select = 'select',\n SharingStatus = 'sharing-status',\n Slider = 'slider',\n Spacer = 'spacer',\n StatusDot = 'status-dot',\n Step = 'step',\n StepButtons = 'step-buttons',\n Stepper = 'stepper',\n Sublabel = 'sublabel',\n Table = 'table',\n Tag = 'tag',\n TagList = 'tag-list',\n Textarea = 'textarea',\n Tile = 'tile',\n Title = 'title',\n Tooltip = 'tooltip',\n Trigger = 'trigger',\n Validation = 'validation',\n}\n\nexport enum KeyboardEventKey {\n Enter = 'Enter',\n Escape = 'Escape',\n ArrowDown = 'ArrowDown',\n ArrowUp = 'ArrowUp',\n ArrowRight = 'ArrowRight',\n ArrowLeft = 'ArrowLeft',\n Home = 'Home',\n End = 'End',\n Space = ' ',\n Tab = 'Tab',\n}\n"],"names":["IconSize","ZIndex","AVERAGE_CHARACTER_WIDTH_PX","FormMode","FormSize","AnalyticsId","KeyboardEventKey"],"mappings":"AAAY,IAAAA,sBAAAA,OACVA,EAAAA,EAAA,UAAU,EAAV,IAAA,WACAA,EAAAA,EAAA,SAAS,EAAT,IAAA,UACAA,EAAAA,EAAA,QAAQ,EAAR,IAAA,SACAA,EAAAA,EAAA,SAAS,EAAT,IAAA,UACAA,EAAAA,EAAA,QAAQ,EAAR,IA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A,EAAA,SAAS,UACTA,EAAA,gBAAgB,kBAChBA,EAAA,SAAS,UACTA,EAAA,SAAS,UACTA,EAAA,YAAY,cACZA,EAAA,OAAO,QACPA,EAAA,cAAc,gBACdA,EAAA,UAAU,WACVA,EAAA,WAAW,YACXA,EAAA,QAAQ,SACRA,EAAA,MAAM,OACNA,EAAA,UAAU,YACVA,EAAA,WAAW,YACXA,EAAA,OAAO,QACPA,EAAA,QAAQ,SACRA,EAAA,UAAU,WACVA,EAAA,UAAU,WACVA,EAAA,aAAa,cAxDHA,IAAAA,KAAA,CAAA,CAAA,GA2DAC,sBAAAA,OACVA,EAAA,QAAQ,SACRA,EAAA,SAAS,UACTA,EAAA,YAAY,aACZA,EAAA,UAAU,WACVA,EAAA,aAAa,cACbA,EAAA,YAAY,aACZA,EAAA,OAAO,QACPA,EAAA,MAAM,OACNA,EAAA,QAAQ,KACRA,EAAA,MAAM,OAVIA,IAAAA,KAAA,CAAA,CAAA;"}
package/docs/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import * as e from "react";
2
2
  import "../node_modules/@storybook/addon-docs/dist/chunk-HLWAVYOI.js";
3
- import { ArgTypes as n, Title as o, Subtitle as l, Description as i, Primary as c, Stories as s } from "../node_modules/@storybook/blocks/dist/index.js";
4
- const m = () => (window.location != window.parent.location ? document.referrer : document.location.href).startsWith("https://frankenstein.helsenorge.design") || window.location.search.includes("isSupernova"), w = (t) => {
5
- if (m())
6
- return /* @__PURE__ */ e.createElement(n, { of: t.component });
7
- const r = new URLSearchParams(window.location.search), a = `${window.location.pathname}?id=${r.get("id")}&viewMode=docs`;
8
- return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", justifyContent: "space-between" } }, /* @__PURE__ */ e.createElement(o, null), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("a", { target: "_blank", href: a, rel: "noreferrer" }, "Åpne i ny fane"))), /* @__PURE__ */ e.createElement(l, null), /* @__PURE__ */ e.createElement(i, null), /* @__PURE__ */ e.createElement(c, null), /* @__PURE__ */ e.createElement(n, { of: t.component }), !t.hideStories && /* @__PURE__ */ e.createElement(s, null));
3
+ import { ArgTypes as l, Title as a, Subtitle as o, Description as i, Primary as s, Controls as c, Stories as m } from "../node_modules/@storybook/blocks/dist/index.js";
4
+ const u = () => (window.location != window.parent.location ? document.referrer : document.location.href).startsWith("https://frankenstein.helsenorge.design") || window.location.search.includes("isSupernova"), w = (t) => {
5
+ if (u())
6
+ return /* @__PURE__ */ e.createElement(l, null);
7
+ const n = new URLSearchParams(window.location.search), r = `${window.location.pathname}?id=${n.get("id")}&viewMode=docs`;
8
+ return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", justifyContent: "space-between" } }, /* @__PURE__ */ e.createElement(a, null), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("a", { target: "_blank", href: r, rel: "noreferrer" }, "Åpne i ny fane"))), /* @__PURE__ */ e.createElement(o, null), /* @__PURE__ */ e.createElement(i, null), /* @__PURE__ */ e.createElement(s, null), /* @__PURE__ */ e.createElement(c, null), !t.hideStories && /* @__PURE__ */ e.createElement(m, null));
9
9
  };
10
10
  export {
11
11
  w as default,
12
- m as isSupernova
12
+ u as isSupernova
13
13
  };
14
14
  //# sourceMappingURL=index.js.map
package/docs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/docs/index.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Title, Subtitle, Description, Primary, ArgTypes, Stories } from '@storybook/addon-docs';\n\ninterface DocsProps<T> {\n component: T;\n hideStories?: boolean;\n}\n\nexport const isSupernova = (): boolean => {\n const url = window.location != window.parent.location ? document.referrer : document.location.href;\n return url.startsWith('https://frankenstein.helsenorge.design') || window.location.search.includes('isSupernova');\n};\n\nconst Docs = <T,>(props: DocsProps<T>): React.JSX.Element => {\n if (isSupernova()) {\n return <ArgTypes of={props.component} />;\n }\n\n const searchParams = new URLSearchParams(window.location.search);\n const newWindowUrl = `${window.location.pathname}?id=${searchParams.get('id')}&viewMode=docs`;\n\n return (\n <>\n <div style={{ display: 'flex', justifyContent: 'space-between' }}>\n <Title />\n <div>\n <a target=\"_blank\" href={newWindowUrl} rel=\"noreferrer\">\n {'Åpne i ny fane'}\n </a>\n </div>\n </div>\n <Subtitle />\n <Description />\n <Primary />\n <ArgTypes of={props.component} />\n {!props.hideStories && <Stories />}\n </>\n );\n};\n\nexport default Docs;\n"],"names":["isSupernova","Docs","props","React","ArgTypes","searchParams","newWindowUrl","Title","Subtitle","Description","Primary","Stories"],"mappings":";;;AASO,MAAMA,IAAc,OACb,OAAO,YAAY,OAAO,OAAO,WAAW,SAAS,WAAW,SAAS,SAAS,MACnF,WAAW,wCAAwC,KAAK,OAAO,SAAS,OAAO,SAAS,aAAa,GAG5GC,IAAO,CAAKC,MAA2C;AAC3D,MAAIF;AACF,WAAQ,gBAAAG,EAAA,cAAAC,GAAA,EAAS,IAAIF,EAAM,UAAW,CAAA;AAGxC,QAAMG,IAAe,IAAI,gBAAgB,OAAO,SAAS,MAAM,GACzDC,IAAe,GAAG,OAAO,SAAS,QAAQ,OAAOD,EAAa,IAAI,IAAI,CAAC;AAG3E,SAAA,gBAAAF,EAAA,cAAAA,EAAA,UAAA,sCACG,OAAI,EAAA,OAAO,EAAE,SAAS,QAAQ,gBAAgB,kBAAgB,mCAC5DI,GAAM,IAAA,mCACN,OACC,MAAA,gBAAAJ,EAAA,cAAC,OAAE,QAAO,UAAS,MAAMG,GAAc,KAAI,aAAA,GACxC,gBACH,CACF,CACF,GACC,gBAAAH,EAAA,cAAAK,GAAA,IAAS,GACT,gBAAAL,EAAA,cAAAM,GAAA,IAAY,GACb,gBAAAN,EAAA,cAACO,GAAQ,IAAA,mCACRN,GAAS,EAAA,IAAIF,EAAM,UAAW,CAAA,GAC9B,CAACA,EAAM,eAAgB,gBAAAC,EAAA,cAAAQ,GAAA,IAAQ,CAClC;AAEJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/docs/index.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Title, Subtitle, Description, Primary, ArgTypes, Stories, Controls } from '@storybook/addon-docs';\n\ninterface DocsProps<T> {\n component: T;\n hideStories?: boolean;\n}\n\nexport const isSupernova = (): boolean => {\n const url = window.location != window.parent.location ? document.referrer : document.location.href;\n return url.startsWith('https://frankenstein.helsenorge.design') || window.location.search.includes('isSupernova');\n};\n\nconst Docs = <T,>(props: DocsProps<T>): React.JSX.Element => {\n if (isSupernova()) {\n return <ArgTypes />;\n }\n\n const searchParams = new URLSearchParams(window.location.search);\n const newWindowUrl = `${window.location.pathname}?id=${searchParams.get('id')}&viewMode=docs`;\n\n return (\n <>\n <div style={{ display: 'flex', justifyContent: 'space-between' }}>\n <Title />\n <div>\n <a target=\"_blank\" href={newWindowUrl} rel=\"noreferrer\">\n {'Åpne i ny fane'}\n </a>\n </div>\n </div>\n <Subtitle />\n <Description />\n <Primary />\n <Controls />\n {!props.hideStories && <Stories />}\n </>\n );\n};\n\nexport default Docs;\n"],"names":["isSupernova","Docs","props","ArgTypes","searchParams","newWindowUrl","React","Title","Subtitle","Description","Primary","Controls","Stories"],"mappings":";;;AASO,MAAMA,IAAc,OACb,OAAO,YAAY,OAAO,OAAO,WAAW,SAAS,WAAW,SAAS,SAAS,MACnF,WAAW,wCAAwC,KAAK,OAAO,SAAS,OAAO,SAAS,aAAa,GAG5GC,IAAO,CAAKC,MAA2C;AAC3D,MAAIF;AACF,2CAAQG,GAAS,IAAA;AAGnB,QAAMC,IAAe,IAAI,gBAAgB,OAAO,SAAS,MAAM,GACzDC,IAAe,GAAG,OAAO,SAAS,QAAQ,OAAOD,EAAa,IAAI,IAAI,CAAC;AAG3E,SAAA,gBAAAE,EAAA,cAAAA,EAAA,UAAA,sCACG,OAAI,EAAA,OAAO,EAAE,SAAS,QAAQ,gBAAgB,gBAAgB,EAAA,mCAC5DC,GAAM,IAAA,mCACN,OACC,MAAA,gBAAAD,EAAA,cAAC,OAAE,QAAO,UAAS,MAAMD,GAAc,KAAI,gBACxC,gBACH,CACF,CACF,GACA,gBAAAC,EAAA,cAACE,OAAS,GACV,gBAAAF,EAAA,cAACG,OAAY,GACb,gBAAAH,EAAA,cAACI,OAAQ,GACT,gBAAAJ,EAAA,cAACK,OAAS,GACT,CAACT,EAAM,eAAe,gBAAAI,EAAA,cAACM,OAAQ,CAClC;AAEJ;"}
@@ -0,0 +1 @@
1
+ export declare const useRovingFocus: (handleNewIndex: (index: number) => void, inputRefList: React.MutableRefObject<React.RefObject<HTMLElement>[] | null | undefined>, containerRef: React.RefObject<HTMLElement>, leftRightNavigation?: boolean) => void;
@@ -0,0 +1,27 @@
1
+ import { useEffect as x } from "react";
2
+ import { useKeyboardEvent as K } from "./useKeyboardEvent.js";
3
+ import { KeyboardEventKey as r } from "../constants.js";
4
+ const D = (k, c, m, a) => {
5
+ a = a ?? !1, x(() => {
6
+ var e, n;
7
+ c.current && (c.current.forEach((o) => {
8
+ var t;
9
+ (t = o.current) == null || t.setAttribute("tabIndex", "-1");
10
+ }), (n = (e = c.current[0]) == null ? void 0 : e.current) == null || n.setAttribute("tabIndex", "0"));
11
+ }, []);
12
+ const A = (e) => {
13
+ var t, d, f, s, u, w;
14
+ if (e.key === r.Tab || (e.preventDefault(), !c.current))
15
+ return;
16
+ const n = c.current.findIndex((y) => y.current === e.target);
17
+ let o = n;
18
+ e.key === r.Home ? o = 0 : e.key === r.End ? o = c.current.length - 1 : (e.key === r.ArrowDown || e.key === r.ArrowRight) && n < c.current.length - 1 ? o = n + 1 : (e.key === r.ArrowUp || e.key === r.ArrowLeft) && n > 0 ? o = n - 1 : (e.key === r.Enter || e.key === r.Space) && (o = n), o !== -1 && ((t = c.current) == null || t.forEach((y, l) => {
19
+ y.current && (y.current.tabIndex = l === o ? 0 : -1);
20
+ }), (f = (d = c.current[o]) == null ? void 0 : d.current) == null || f.focus(), (w = (u = (s = c.current[o]) == null ? void 0 : s.current) == null ? void 0 : u.click) == null || w.call(u), k(o));
21
+ }, E = [r.End, r.Enter, r.Escape, r.Home], b = a ? [r.ArrowRight, r.ArrowLeft] : [r.ArrowUp, r.ArrowDown];
22
+ K(m, A, [...E, ...b]);
23
+ };
24
+ export {
25
+ D as useRovingFocus
26
+ };
27
+ //# sourceMappingURL=useRovingFocus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRovingFocus.js","sources":["../../src/hooks/useRovingFocus.tsx"],"sourcesContent":["// Inspiration from https://www.joshuawootonn.com/react-roving-tabindex\nimport { useEffect } from 'react';\n\nimport { useKeyboardEvent } from './useKeyboardEvent';\nimport { KeyboardEventKey } from '../constants';\n\nexport const useRovingFocus = (\n /** Function to run when new index is set */\n handleNewIndex: (index: number) => void,\n /** List of elements that should have rocing focus */\n inputRefList: React.MutableRefObject<React.RefObject<HTMLElement>[] | null | undefined>,\n /** Ref of container that should have the keyboard event handler */\n containerRef: React.RefObject<HTMLElement>,\n /** Indicated wether right/left or up/down arrows should be used for navigation. Default is up/down. */\n leftRightNavigation?: boolean\n): void => {\n leftRightNavigation = leftRightNavigation ?? false;\n\n // Initialize only first index to be tabbable\n useEffect(() => {\n if (!inputRefList.current) {\n return;\n }\n inputRefList.current.forEach(ref => {\n ref.current?.setAttribute('tabIndex', '-1');\n });\n inputRefList.current[0]?.current?.setAttribute('tabIndex', '0');\n }, []);\n\n const handleKeyboardNavigation = (event: KeyboardEvent): void => {\n if (event.key === KeyboardEventKey.Tab) {\n return;\n }\n event.preventDefault();\n\n if (!inputRefList.current) {\n return;\n }\n const index = inputRefList.current.findIndex(x => x.current === event.target);\n let nextIndex = index;\n\n if (event.key === KeyboardEventKey.Home) {\n nextIndex = 0;\n } else if (event.key === KeyboardEventKey.End) {\n nextIndex = inputRefList.current.length - 1;\n } else if (\n (event.key === KeyboardEventKey.ArrowDown || event.key === KeyboardEventKey.ArrowRight) &&\n index < inputRefList.current.length - 1\n ) {\n nextIndex = index + 1;\n } else if ((event.key === KeyboardEventKey.ArrowUp || event.key === KeyboardEventKey.ArrowLeft) && index > 0) {\n nextIndex = index - 1;\n } else if (event.key === KeyboardEventKey.Enter || event.key === KeyboardEventKey.Space) {\n nextIndex = index;\n }\n\n if (nextIndex !== -1) {\n inputRefList.current?.forEach((ref, i) => {\n if (ref.current) {\n ref.current.tabIndex = i === nextIndex ? 0 : -1;\n }\n });\n inputRefList.current[nextIndex]?.current?.focus();\n inputRefList.current[nextIndex]?.current?.click?.();\n handleNewIndex(nextIndex);\n }\n };\n\n const commonKeys = [KeyboardEventKey.End, KeyboardEventKey.Enter, KeyboardEventKey.Escape, KeyboardEventKey.Home];\n\n const arrowKeys = leftRightNavigation\n ? [KeyboardEventKey.ArrowRight, KeyboardEventKey.ArrowLeft]\n : [KeyboardEventKey.ArrowUp, KeyboardEventKey.ArrowDown];\n\n useKeyboardEvent(containerRef, handleKeyboardNavigation, [...commonKeys, ...arrowKeys]);\n};\n"],"names":["useRovingFocus","handleNewIndex","inputRefList","containerRef","leftRightNavigation","useEffect","ref","_a","_b","handleKeyboardNavigation","event","KeyboardEventKey","index","x","nextIndex","i","_c","_f","_e","_d","commonKeys","arrowKeys","useKeyboardEvent"],"mappings":";;;AAMO,MAAMA,IAAiB,CAE5BC,GAEAC,GAEAC,GAEAC,MACS;AACT,EAAAA,IAAsBA,KAAuB,IAG7CC,EAAU,MAAM;;AACV,IAACH,EAAa,YAGLA,EAAA,QAAQ,QAAQ,CAAOI,MAAA;;AAC9B,OAAAC,IAAAD,EAAA,YAAA,QAAAC,EAAS,aAAa,YAAY;AAAA,IAAI,CAC3C,IACDC,KAAAD,IAAAL,EAAa,QAAQ,CAAC,MAAtB,gBAAAK,EAAyB,YAAzB,QAAAC,EAAkC,aAAa,YAAY;AAAA,EAC7D,GAAG,CAAE,CAAA;AAEC,QAAAC,IAA2B,CAACC,MAA+B;;AAM3D,QALAA,EAAM,QAAQC,EAAiB,QAGnCD,EAAM,eAAe,GAEj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
+ title: string;
5
+ component: React.FC<{}>;
6
+ parameters: {
7
+ docs: {
8
+ description: {
9
+ component: string;
10
+ };
11
+ };
12
+ };
13
+ };
14
+ export default meta;
15
+ type Story = StoryObj<typeof meta>;
16
+ export declare const Default: Story;
17
+ export declare const WithLeftRightNavigation: Story;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "git+https://github.com/helsenorge/designsystem.git"
8
8
  },
9
9
  "homepage": "https://helsenorge.design",
10
- "version": "7.6.0",
10
+ "version": "7.8.0",
11
11
  "author": "Helsenorge",
12
12
  "license": "MIT",
13
13
  "peerDependencies": {
@@ -114,20 +114,22 @@ import designsystemtypography from './scss/typography.scss'
114
114
  overflow-wrap: break-word;
115
115
  word-break: break-word;
116
116
  text-align: left;
117
- text-decoration: none;
118
117
  color: $blueberry600;
119
- padding: 0.15rem;
120
- border-bottom: 1px solid $neutral700;
118
+ border: $focus-width solid transparent;
119
+ text-decoration: underline;
120
+ text-underline-offset: 0.16rem;
121
+ text-decoration-color: $blueberry400;
122
+ text-decoration-thickness: $underline-width;
123
+ padding: 0.1rem;
121
124
 
122
125
  &:hover {
123
126
  cursor: pointer;
124
127
  color: $blueberry700;
125
128
  background-color: $blueberry50;
126
- border-bottom-color: $blueberry600;
129
+ text-decoration-color: $blueberry600;
127
130
  }
128
131
 
129
132
  &:focus {
130
- padding: 0 0 0.15rem;
131
133
  outline: none;
132
134
  border: 0.15rem solid $black;
133
135
  }
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- type Props = {
3
- content: React.ReactNode;
4
- buttonClosedText: string;
5
- buttonText: string;
6
- expanderOpenFromStart: boolean;
7
- };
8
- export declare const DetailButton: React.FC<Props>;
9
- export {};
@@ -1,28 +0,0 @@
1
- import e, { useState as f } from "react";
2
- import n from "classnames";
3
- import { AnalyticsId as _ } from "../../../constants.js";
4
- import { useUuid as u } from "../../../hooks/useUuid.js";
5
- import { getAriaLabelAttributes as b } from "../../../utils/accessibility.js";
6
- import v from "../../Button/Button.js";
7
- import { Icon as x } from "../../Icon/Icon.js";
8
- import E from "../../Icons/ChevronDown.js";
9
- import I from "../../Icons/ChevronUp.js";
10
- import a from "../../NotificationPanel/DetailButton/styles.module.scss";
11
- const T = ({ content: i, buttonText: r, buttonClosedText: s, expanderOpenFromStart: c }) => {
12
- const [t, l] = f(c), o = t ? r : s, m = u(), p = b({
13
- label: o,
14
- id: m,
15
- prefer: "label"
16
- }), d = {
17
- onClick: () => l(!t),
18
- variant: "borderless",
19
- className: n(a["notification-panel__detail"], a["notification-panel__detail-button"]),
20
- "aria-expanded": t,
21
- ...p
22
- };
23
- return /* @__PURE__ */ e.createElement("div", { className: a["notification-panel__detail-section"] }, /* @__PURE__ */ e.createElement("div", { className: a["notification-panel__detail-section__button--wrapper"] }, /* @__PURE__ */ e.createElement(v, { testId: "expand", "data-analyticsid": _.Expander, ...d }, o, /* @__PURE__ */ e.createElement(x, { svgIcon: t ? I : E }))), t && /* @__PURE__ */ e.createElement("div", { className: n(a["notification-panel__detail-section__content"]) }, i));
24
- };
25
- export {
26
- T as DetailButton
27
- };
28
- //# sourceMappingURL=DetailButton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DetailButton.js","sources":["../../../../src/components/NotificationPanel/DetailButton/DetailButton.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../../constants';\nimport { useUuid } from '../../../hooks/useUuid';\nimport { AriaLabelAttributes, getAriaLabelAttributes } from '../../../utils/accessibility';\nimport Button, { ButtonProps } from '../../Button';\nimport Icon from '../../Icon';\nimport ChevronDown from '../../Icons/ChevronDown';\nimport ChevronUp from '../../Icons/ChevronUp';\n\nimport styles from './styles.module.scss';\n\ntype Props = {\n content: React.ReactNode;\n buttonClosedText: string;\n buttonText: string;\n expanderOpenFromStart: boolean;\n};\nexport const DetailButton: React.FC<Props> = ({ content, buttonText, buttonClosedText, expanderOpenFromStart }: Props): JSX.Element => {\n const [isExpanded, setIsExpanded] = useState<boolean>(expanderOpenFromStart);\n const activeButtonText = isExpanded ? buttonText : buttonClosedText;\n\n const buttonTextId = useUuid();\n\n const ariaLabelAttributes = getAriaLabelAttributes({\n label: activeButtonText,\n id: buttonTextId,\n prefer: 'label',\n });\n\n const commonProps: Partial<ButtonProps> & AriaLabelAttributes = {\n onClick: () => setIsExpanded(!isExpanded),\n variant: 'borderless',\n className: classNames(styles['notification-panel__detail'], styles['notification-panel__detail-button']),\n 'aria-expanded': isExpanded,\n ...ariaLabelAttributes,\n };\n\n return (\n <div className={styles['notification-panel__detail-section']}>\n <div className={styles['notification-panel__detail-section__button--wrapper']}>\n <Button testId=\"expand\" data-analyticsid={AnalyticsId.Expander} {...commonProps}>\n {activeButtonText}\n <Icon svgIcon={isExpanded ? ChevronUp : ChevronDown} />\n </Button>\n </div>\n {isExpanded && <div className={classNames(styles['notification-panel__detail-section__content'])}>{content}</div>}\n </div>\n );\n};\n"],"names":["DetailButton","content","buttonText","buttonClosedText","expanderOpenFromStart","isExpanded","setIsExpanded","useState","activeButtonText","buttonTextId","useUuid","ariaLabelAttributes","getAriaLabelAttributes","commonProps","classNames","styles","React","Button","AnalyticsId","Icon","ChevronUp","ChevronDown"],"mappings":";;;;;;;;;;AAoBO,MAAMA,IAAgC,CAAC,EAAE,SAAAC,GAAS,YAAAC,GAAY,kBAAAC,GAAkB,uBAAAC,QAAgD;AACrI,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAkBH,CAAqB,GACrEI,IAAmBH,IAAaH,IAAaC,GAE7CM,IAAeC,KAEfC,IAAsBC,EAAuB;AAAA,IACjD,OAAOJ;AAAA,IACP,IAAIC;AAAA,IACJ,QAAQ;AAAA,EAAA,CACT,GAEKI,IAA0D;AAAA,IAC9D,SAAS,MAAMP,EAAc,CAACD,CAAU;AAAA,IACxC,SAAS;AAAA,IACT,WAAWS,EAAWC,EAAO,4BAA4B,GAAGA,EAAO,mCAAmC,CAAC;AAAA,IACvG,iBAAiBV;AAAA,IACjB,GAAGM;AAAA,EAAA;AAGL,yCACG,OAAI,EAAA,WAAWI,EAAO,oCAAoC,EAAA,mCACxD,OAAI,EAAA,WAAWA,EAAO,qDAAqD,KACzEC,gBAAAA,EAAA,cAAAC,GAAA,EAAO,QAAO,UAAS,oBAAkBC,EAAY,UAAW,GAAGL,EACjE,GAAAL,mCACAW,GAAK,EAAA,SAASd,IAAae,IAAYC,EAAA,CAAa,CACvD,CACF,GACChB,KAAeW,gBAAAA,EAAA,cAAA,OAAA,EAAI,WAAWF,EAAWC,EAAO,6CAA6C,CAAC,KAAId,CAAQ,CAC7G;AAEJ;"}
@@ -1,38 +0,0 @@
1
- @import '../../../scss/spacers';
2
- @import '../../../scss/breakpoints';
3
- @import '../../../scss/font-settings';
4
- @import '../../../scss/palette';
5
-
6
- .notification-panel__detail-section {
7
- display: flex;
8
- flex-direction: column-reverse;
9
-
10
- &__button--wrapper {
11
- padding: 0.375rem 0 0.625rem;
12
- font-size: $font-size-xs;
13
- line-height: $lineheight-size-xs;
14
- }
15
-
16
- &__content {
17
- padding: getSpacer(3xs) 0;
18
- font-size: $font-size-xs;
19
- line-height: $lineheight-size-xs;
20
- }
21
- }
22
-
23
- html .notification-panel__detail.notification-panel__detail-button {
24
- text-decoration: underline;
25
- text-decoration-color: $blueberry600;
26
- margin-left: -0.25rem;
27
- padding: 0 0 0 getSpacer(3xs);
28
- white-space: nowrap;
29
- overflow: initial;
30
- text-overflow: clip;
31
- font-size: $font-size-sm;
32
- line-height: 1.625rem;
33
- height: 1.625rem;
34
-
35
- @media (width >= 0) {
36
- min-height: unset;
37
- }
38
- }
@@ -1,13 +0,0 @@
1
- export type Styles = {
2
- 'notification-panel__detail': string;
3
- 'notification-panel__detail-button': string;
4
- 'notification-panel__detail-section': string;
5
- 'notification-panel__detail-section__button--wrapper': string;
6
- 'notification-panel__detail-section__content': string;
7
- };
8
-
9
- export type ClassNames = keyof Styles;
10
-
11
- declare const styles: Styles;
12
-
13
- export default styles;