@navikt/ds-react 2.1.5 → 2.1.7

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 (177) hide show
  1. package/README.md +4 -5
  2. package/_docs.json +356 -293
  3. package/cjs/accordion/AccordionContent.js +2 -2
  4. package/cjs/accordion/AccordionHeader.js +2 -2
  5. package/cjs/alert/Alert.js +2 -2
  6. package/cjs/chat/Chat.js +3 -3
  7. package/cjs/date/hooks/useDatepicker.js +2 -2
  8. package/cjs/date/hooks/useMonthPicker.js +2 -2
  9. package/cjs/date/hooks/useRangeDatepicker.js +3 -3
  10. package/esm/accordion/AccordionContent.js +1 -1
  11. package/esm/accordion/AccordionContent.js.map +1 -1
  12. package/esm/accordion/AccordionHeader.js +1 -1
  13. package/esm/accordion/AccordionHeader.js.map +1 -1
  14. package/esm/accordion/index.d.ts +1 -1
  15. package/esm/accordion/index.js.map +1 -1
  16. package/esm/alert/Alert.js +1 -1
  17. package/esm/alert/Alert.js.map +1 -1
  18. package/esm/alert/index.d.ts +1 -1
  19. package/esm/button/index.d.ts +1 -1
  20. package/esm/chat/Chat.js +1 -1
  21. package/esm/chat/Chat.js.map +1 -1
  22. package/esm/chat/index.d.ts +1 -1
  23. package/esm/chat/index.js.map +1 -1
  24. package/esm/chips/Removable.d.ts +1 -1
  25. package/esm/chips/Toggle.d.ts +1 -1
  26. package/esm/chips/index.d.ts +1 -1
  27. package/esm/chips/index.js.map +1 -1
  28. package/esm/date/hooks/useDatepicker.d.ts +5 -0
  29. package/esm/date/hooks/useDatepicker.js +2 -2
  30. package/esm/date/hooks/useDatepicker.js.map +1 -1
  31. package/esm/date/hooks/useMonthPicker.d.ts +5 -0
  32. package/esm/date/hooks/useMonthPicker.js +2 -2
  33. package/esm/date/hooks/useMonthPicker.js.map +1 -1
  34. package/esm/date/hooks/useRangeDatepicker.js +3 -3
  35. package/esm/date/hooks/useRangeDatepicker.js.map +1 -1
  36. package/esm/date/index.d.ts +6 -6
  37. package/esm/date/utils/index.d.ts +1 -1
  38. package/esm/date/utils/index.js.map +1 -1
  39. package/esm/form/Fieldset/index.d.ts +1 -1
  40. package/esm/form/checkbox/index.d.ts +2 -2
  41. package/esm/form/checkbox/index.js +1 -1
  42. package/esm/form/checkbox/index.js.map +1 -1
  43. package/esm/form/error-summary/index.d.ts +1 -1
  44. package/esm/form/index.d.ts +10 -10
  45. package/esm/form/index.js +1 -1
  46. package/esm/form/index.js.map +1 -1
  47. package/esm/form/radio/index.d.ts +2 -2
  48. package/esm/form/radio/index.js.map +1 -1
  49. package/esm/form/search/index.d.ts +1 -1
  50. package/esm/form/search/index.js +1 -1
  51. package/esm/form/search/index.js.map +1 -1
  52. package/esm/grid/index.d.ts +3 -3
  53. package/esm/grid/index.js.map +1 -1
  54. package/esm/guide-panel/index.d.ts +2 -2
  55. package/esm/guide-panel/index.js.map +1 -1
  56. package/esm/help-text/index.d.ts +1 -1
  57. package/esm/link/Link.d.ts +1 -1
  58. package/esm/link/index.d.ts +1 -1
  59. package/esm/link-panel/LinkPanelTitle.d.ts +1 -1
  60. package/esm/link-panel/index.d.ts +1 -1
  61. package/esm/loader/index.d.ts +1 -1
  62. package/esm/modal/index.d.ts +2 -2
  63. package/esm/modal/index.js.map +1 -1
  64. package/esm/pagination/index.d.ts +1 -1
  65. package/esm/pagination/index.js.map +1 -1
  66. package/esm/panel/Panel.d.ts +1 -1
  67. package/esm/panel/index.d.ts +1 -1
  68. package/esm/popover/index.d.ts +2 -2
  69. package/esm/popover/index.js.map +1 -1
  70. package/esm/read-more/index.d.ts +1 -1
  71. package/esm/stepper/index.d.ts +1 -1
  72. package/esm/stepper/index.js.map +1 -1
  73. package/esm/table/index.d.ts +8 -8
  74. package/esm/table/index.js.map +1 -1
  75. package/esm/tabs/index.d.ts +4 -4
  76. package/esm/tabs/index.js.map +1 -1
  77. package/esm/tag/index.d.ts +1 -1
  78. package/esm/tag/index.js.map +1 -1
  79. package/esm/toggle-group/index.d.ts +2 -2
  80. package/esm/toggle-group/index.js.map +1 -1
  81. package/esm/tooltip/index.d.ts +1 -1
  82. package/esm/tooltip/index.js.map +1 -1
  83. package/esm/typography/BodyLong.d.ts +1 -1
  84. package/esm/typography/BodyShort.d.ts +1 -1
  85. package/esm/typography/Detail.d.ts +1 -1
  86. package/esm/typography/ErrorMessage.d.ts +1 -1
  87. package/esm/typography/Heading.d.ts +1 -1
  88. package/esm/typography/Ingress.d.ts +1 -1
  89. package/esm/typography/Label.d.ts +1 -1
  90. package/esm/typography/index.d.ts +7 -7
  91. package/esm/typography/index.js +1 -1
  92. package/esm/typography/index.js.map +1 -1
  93. package/package.json +3 -3
  94. package/src/accordion/AccordionContent.tsx +1 -1
  95. package/src/accordion/AccordionHeader.tsx +1 -1
  96. package/src/accordion/accordion.stories.tsx +16 -14
  97. package/src/accordion/index.ts +1 -1
  98. package/src/alert/Alert.tsx +1 -1
  99. package/src/alert/alert.stories.tsx +35 -27
  100. package/src/alert/index.ts +1 -1
  101. package/src/button/button.stories.tsx +95 -83
  102. package/src/button/index.ts +1 -1
  103. package/src/chat/Chat.tsx +1 -1
  104. package/src/chat/chat.stories.tsx +27 -25
  105. package/src/chat/index.ts +1 -1
  106. package/src/chips/Removable.tsx +1 -1
  107. package/src/chips/Toggle.tsx +1 -1
  108. package/src/chips/chips.stories.tsx +32 -29
  109. package/src/chips/index.ts +1 -1
  110. package/src/date/datepicker/datepicker.stories.tsx +103 -81
  111. package/src/date/hooks/useDatepicker.tsx +7 -1
  112. package/src/date/hooks/useMonthPicker.tsx +7 -1
  113. package/src/date/hooks/useRangeDatepicker.tsx +3 -2
  114. package/src/date/index.ts +8 -8
  115. package/src/date/monthpicker/monthpicker.stories.tsx +13 -11
  116. package/src/date/utils/index.ts +1 -1
  117. package/src/form/Fieldset/index.ts +1 -1
  118. package/src/form/checkbox/checkbox.stories.tsx +66 -61
  119. package/src/form/checkbox/index.ts +5 -2
  120. package/src/form/error-summary/error-summary.stories.tsx +16 -14
  121. package/src/form/error-summary/index.ts +1 -1
  122. package/src/form/index.ts +16 -11
  123. package/src/form/radio/index.ts +2 -2
  124. package/src/form/radio/radio.stories.tsx +39 -34
  125. package/src/form/search/index.ts +5 -1
  126. package/src/form/search/search.stories.tsx +26 -23
  127. package/src/form/stories/confirmation-panel.stories.tsx +19 -17
  128. package/src/form/stories/fieldset.stories.tsx +13 -11
  129. package/src/form/stories/select.stories.tsx +12 -10
  130. package/src/form/stories/switch.stories.tsx +9 -7
  131. package/src/form/stories/text-field.stories.tsx +8 -6
  132. package/src/form/stories/textarea.stories.tsx +16 -14
  133. package/src/grid/index.ts +3 -3
  134. package/src/guide-panel/guidepanel.stories.tsx +21 -19
  135. package/src/guide-panel/index.ts +2 -2
  136. package/src/help-text/help-text.stories.tsx +11 -9
  137. package/src/help-text/index.ts +1 -1
  138. package/src/link/Link.tsx +1 -1
  139. package/src/link/index.ts +1 -1
  140. package/src/link/link.stories.tsx +24 -22
  141. package/src/link-panel/LinkPanelTitle.tsx +1 -1
  142. package/src/link-panel/index.ts +1 -1
  143. package/src/link-panel/link-panel.stories.tsx +19 -17
  144. package/src/loader/index.ts +1 -1
  145. package/src/loader/loader.stories.tsx +8 -6
  146. package/src/modal/index.ts +2 -2
  147. package/src/modal/modal.stories.tsx +35 -30
  148. package/src/pagination/index.ts +1 -1
  149. package/src/pagination/pagination.stories.tsx +41 -36
  150. package/src/panel/Panel.tsx +1 -1
  151. package/src/panel/index.ts +1 -1
  152. package/src/panel/panel.stories.tsx +17 -15
  153. package/src/popover/index.ts +2 -2
  154. package/src/popover/popover.stories.tsx +25 -19
  155. package/src/read-more/index.ts +1 -1
  156. package/src/read-more/readmore.stories.tsx +20 -17
  157. package/src/stepper/index.ts +1 -1
  158. package/src/stepper/stepper.stories.tsx +44 -41
  159. package/src/table/index.ts +8 -8
  160. package/src/tabs/Tabs.stories.tsx +24 -22
  161. package/src/tabs/index.ts +4 -4
  162. package/src/tag/index.ts +1 -1
  163. package/src/tag/tag.stories.tsx +9 -7
  164. package/src/toggle-group/ToggleGroup.stories.tsx +21 -18
  165. package/src/toggle-group/index.ts +2 -2
  166. package/src/tooltip/index.ts +1 -1
  167. package/src/tooltip/tooltip.stories.tsx +22 -20
  168. package/src/typography/BodyLong.tsx +1 -1
  169. package/src/typography/BodyShort.tsx +1 -1
  170. package/src/typography/Detail.tsx +1 -1
  171. package/src/typography/ErrorMessage.tsx +1 -1
  172. package/src/typography/Heading.tsx +1 -1
  173. package/src/typography/Ingress.tsx +1 -1
  174. package/src/typography/Label.tsx +1 -1
  175. package/src/typography/heading.stories.tsx +5 -3
  176. package/src/typography/index.ts +10 -7
  177. package/src/typography/typography.stories.tsx +0 -44
@@ -42,6 +42,11 @@ export interface UseMonthPickerOptions
42
42
  * In 2023 this equals to 1943 - 2042
43
43
  */
44
44
  allowTwoDigitYear?: boolean;
45
+ /**
46
+ * Opens datepicker on input-focus
47
+ * @default true
48
+ */
49
+ openOnFocus?: boolean;
45
50
  }
46
51
 
47
52
  interface UseMonthPickerValue {
@@ -104,6 +109,7 @@ export const useMonthpicker = (
104
109
  onValidate,
105
110
  defaultYear,
106
111
  allowTwoDigitYear = true,
112
+ openOnFocus = true,
107
113
  } = opt;
108
114
 
109
115
  const [defaultSelected, setDefaultSelected] = useState(_defaultSelected);
@@ -180,7 +186,7 @@ export const useMonthpicker = (
180
186
  };
181
187
 
182
188
  const handleFocus: React.FocusEventHandler<HTMLInputElement> = (e) => {
183
- !open && setOpen(true);
189
+ !open && openOnFocus && setOpen(true);
184
190
  let day = parseDate(
185
191
  e.target.value,
186
192
  today,
@@ -204,6 +204,7 @@ export const useRangeDatepicker = (
204
204
  onValidate,
205
205
  defaultMonth,
206
206
  allowTwoDigitYear = true,
207
+ openOnFocus = true,
207
208
  } = opt;
208
209
 
209
210
  const locale = getLocaleFromString(_locale);
@@ -323,7 +324,7 @@ export const useRangeDatepicker = (
323
324
  };
324
325
 
325
326
  const handleFocus = (e, src: RangeT) => {
326
- !open && setOpen(true);
327
+ !open && openOnFocus && setOpen(true);
327
328
  let day = parseDate(
328
329
  e.target.value,
329
330
  today,
@@ -387,11 +388,11 @@ export const useRangeDatepicker = (
387
388
  formatDateForInput(prevToRange, locale, "date", inputFormat)
388
389
  )
389
390
  : setToInputValue("");
391
+ updateRange({ from: range?.from, to: resetTo ? undefined : prevToRange });
390
392
  updateValidation(
391
393
  { isValidDate: !!range?.from, isEmpty: !range?.from },
392
394
  { isValidDate: !!range?.to, isEmpty: !prevToRange || resetTo }
393
395
  );
394
- updateRange({ from: range?.from, to: resetTo ? undefined : prevToRange });
395
396
  };
396
397
 
397
398
  const fromChange = (
package/src/date/index.ts CHANGED
@@ -1,19 +1,19 @@
1
- export { DateInputProps } from "./DateInput";
1
+ export { type DateInputProps } from "./DateInput";
2
2
  export {
3
- DatePickerProps,
3
+ type DatePickerProps,
4
4
  default as UNSAFE_DatePicker,
5
5
  } from "./datepicker/DatePicker";
6
- export { DatePickerStandaloneProps } from "./datepicker/DatePickerStandalone";
7
- export { MonthPickerStandaloneProps } from "./monthpicker/MonthPickerStandalone";
6
+ export { type DatePickerStandaloneProps } from "./datepicker/DatePickerStandalone";
7
+ export { type MonthPickerStandaloneProps } from "./monthpicker/MonthPickerStandalone";
8
8
  export {
9
9
  UNSAFE_useDatepicker,
10
10
  UNSAFE_useMonthpicker,
11
11
  UNSAFE_useRangeDatepicker,
12
- RangeValidationT,
13
- DateValidationT,
14
- MonthValidationT,
12
+ type RangeValidationT,
13
+ type DateValidationT,
14
+ type MonthValidationT,
15
15
  } from "./hooks";
16
16
  export {
17
17
  default as UNSAFE_MonthPicker,
18
- MonthPickerProps,
18
+ type MonthPickerProps,
19
19
  } from "./monthpicker/MonthPicker";
@@ -54,17 +54,19 @@ export const NB = () => <MonthPicker.Standalone locale="nb" />;
54
54
  export const NN = () => <MonthPicker.Standalone locale="nn" />;
55
55
  export const EN = () => <MonthPicker.Standalone locale="en" />;
56
56
 
57
- export const DisabledMonths = (props) => {
58
- return (
59
- <MonthPicker.Standalone
60
- disabled={[
61
- { from: new Date("Jan 1 2022"), to: new Date("Jul 6 2022") },
62
- { from: new Date("Apr 2 2023"), to: new Date("Dec 4 2023") },
63
- new Date("Sep 5 2022"),
64
- new Date("Jan 5 2023"),
65
- ]}
66
- />
67
- );
57
+ export const DisabledMonths = {
58
+ render: (props) => {
59
+ return (
60
+ <MonthPicker.Standalone
61
+ disabled={[
62
+ { from: new Date("Jan 1 2022"), to: new Date("Jul 6 2022") },
63
+ { from: new Date("Apr 2 2023"), to: new Date("Dec 4 2023") },
64
+ new Date("Sep 5 2022"),
65
+ new Date("Jan 5 2023"),
66
+ ]}
67
+ />
68
+ );
69
+ },
68
70
  };
69
71
 
70
72
  export const Standalone = () => {
@@ -17,5 +17,5 @@ export { disableDate } from "./dates-disabled";
17
17
 
18
18
  export { dateIsInCurrentMonth, isValidDate, hasNextYear } from "./check-dates";
19
19
  export { getInitialYear } from "./get-initial-year";
20
- export { isMatch, isDateInRange, Matcher } from "./is-match";
20
+ export { isMatch, isDateInRange, type Matcher } from "./is-match";
21
21
  export { nextEnabled } from "./navigation";
@@ -1,5 +1,5 @@
1
1
  export {
2
2
  default as Fieldset,
3
- FieldsetProps,
3
+ type FieldsetProps,
4
4
  FieldsetContext,
5
5
  } from "./Fieldset";
@@ -1,9 +1,10 @@
1
+ /* eslint-disable react-hooks/rules-of-hooks */
1
2
  import React, { useState } from "react";
2
3
  import { Checkbox, CheckboxGroup } from "../../index";
3
- import { Meta } from "@storybook/react/types-6-0";
4
+ import { Meta } from "@storybook/react";
4
5
 
5
6
  export default {
6
- title: "ds-react/Form/Checkbox",
7
+ title: "ds-react/Checkbox",
7
8
  component: Checkbox,
8
9
  subcomponents: {
9
10
  CheckboxGroup,
@@ -13,69 +14,73 @@ export default {
13
14
  },
14
15
  } as Meta;
15
16
 
16
- export const Default = (props) => {
17
- const [state, setState] = useState(["checkbox1"]);
17
+ export const Default = {
18
+ render: (props) => {
19
+ const [state, setState] = useState(["checkbox1"]);
18
20
 
19
- return (
20
- <div>
21
- <CheckboxGroup
22
- legend={props.legend}
23
- description={props.description}
24
- value={props.controlled ? state : undefined}
25
- onChange={props.controlled ? setState : undefined}
26
- hideLegend={props.hideLegend}
27
- error={props.errorGroup ? "Errormelding for checkboxgruppe" : undefined}
28
- size={props?.size}
29
- >
30
- <Checkbox
31
- value="checkbox1"
32
- indeterminate={props.indeterminate}
33
- hideLabel={props.hideLabel}
34
- >
35
- {props.children || "Apple"}
36
- </Checkbox>
37
- <Checkbox
38
- value="checkbox2"
39
- error={props.errorSingle}
40
- description={
41
- props.checkboxDescription
42
- ? "Quis laborum culpa enim amet cillum veniam."
43
- : undefined
21
+ return (
22
+ <div>
23
+ <CheckboxGroup
24
+ legend={props.legend}
25
+ description={props.description}
26
+ value={props.controlled ? state : undefined}
27
+ onChange={props.controlled ? setState : undefined}
28
+ hideLegend={props.hideLegend}
29
+ error={
30
+ props.errorGroup ? "Errormelding for checkboxgruppe" : undefined
44
31
  }
45
- indeterminate={props.indeterminate}
46
- hideLabel={props.hideLabel}
47
- >
48
- {props.children || "Orange"}
49
- </Checkbox>
50
- <Checkbox
51
- value="checkbox3"
52
- indeterminate={props.indeterminate}
53
- hideLabel={props.hideLabel}
32
+ size={props?.size}
54
33
  >
55
- {props.children || "Banana"}
56
- </Checkbox>
57
- <Checkbox
58
- value="checkbox4"
59
- indeterminate={props.indeterminate}
60
- hideLabel={props.hideLabel}
61
- >
62
- {props.children || "Melon"}
63
- </Checkbox>
64
- </CheckboxGroup>
65
- </div>
66
- );
67
- };
34
+ <Checkbox
35
+ value="checkbox1"
36
+ indeterminate={props.indeterminate}
37
+ hideLabel={props.hideLabel}
38
+ >
39
+ {props.children || "Apple"}
40
+ </Checkbox>
41
+ <Checkbox
42
+ value="checkbox2"
43
+ error={props.errorSingle}
44
+ description={
45
+ props.checkboxDescription
46
+ ? "Quis laborum culpa enim amet cillum veniam."
47
+ : undefined
48
+ }
49
+ indeterminate={props.indeterminate}
50
+ hideLabel={props.hideLabel}
51
+ >
52
+ {props.children || "Orange"}
53
+ </Checkbox>
54
+ <Checkbox
55
+ value="checkbox3"
56
+ indeterminate={props.indeterminate}
57
+ hideLabel={props.hideLabel}
58
+ >
59
+ {props.children || "Banana"}
60
+ </Checkbox>
61
+ <Checkbox
62
+ value="checkbox4"
63
+ indeterminate={props.indeterminate}
64
+ hideLabel={props.hideLabel}
65
+ >
66
+ {props.children || "Melon"}
67
+ </Checkbox>
68
+ </CheckboxGroup>
69
+ </div>
70
+ );
71
+ },
68
72
 
69
- Default.args = {
70
- controlled: false,
71
- legend: "Legend-tekst",
72
- checkboxDescription: false,
73
- hideLabel: false,
74
- hideLegend: false,
75
- errorSingle: false,
76
- errorGroup: false,
77
- children: "",
78
- description: "",
73
+ args: {
74
+ controlled: false,
75
+ legend: "Legend-tekst",
76
+ checkboxDescription: false,
77
+ hideLabel: false,
78
+ hideLegend: false,
79
+ errorSingle: false,
80
+ errorGroup: false,
81
+ children: "",
82
+ description: "",
83
+ },
79
84
  };
80
85
 
81
86
  export const Group = () => (
@@ -1,2 +1,5 @@
1
- export { default as Checkbox, CheckboxProps } from "./Checkbox";
2
- export { default as CheckboxGroup, CheckboxGroupProps } from "./CheckboxGroup";
1
+ export { default as Checkbox, type CheckboxProps } from "./Checkbox";
2
+ export {
3
+ default as CheckboxGroup,
4
+ type CheckboxGroupProps,
5
+ } from "./CheckboxGroup";
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
- import { Meta } from "@storybook/react/types-6-0";
2
+ import { Meta } from "@storybook/react";
3
3
  import { ErrorSummary } from "..";
4
4
  export default {
5
- title: "ds-react/Form/Errorsummary",
5
+ title: "ds-react/Errorsummary",
6
6
  component: ErrorSummary,
7
7
  argTypes: {
8
8
  headingTag: {
@@ -19,18 +19,20 @@ export default {
19
19
  },
20
20
  } as Meta;
21
21
 
22
- export const Default = (props) => (
23
- <ErrorSummary
24
- heading="Feiloppsummering komponent"
25
- headingTag={props.headingTag || "h2"}
26
- size={props.size ?? undefined}
27
- >
28
- <ErrorSummary.Item href="#1">Checkbox må fylles ut</ErrorSummary.Item>
29
- <ErrorSummary.Item href="#2">
30
- Tekstfeltet må ha en godkjent e-mail
31
- </ErrorSummary.Item>
32
- </ErrorSummary>
33
- );
22
+ export const Default = {
23
+ render: (props) => (
24
+ <ErrorSummary
25
+ heading="Feiloppsummering komponent"
26
+ headingTag={props.headingTag || "h2"}
27
+ size={props.size ?? undefined}
28
+ >
29
+ <ErrorSummary.Item href="#1">Checkbox må fylles ut</ErrorSummary.Item>
30
+ <ErrorSummary.Item href="#2">
31
+ Tekstfeltet må ha en godkjent e-mail
32
+ </ErrorSummary.Item>
33
+ </ErrorSummary>
34
+ ),
35
+ };
34
36
 
35
37
  export const Small = () => (
36
38
  <ErrorSummary heading="Feiloppsummering komponent" size="small">
@@ -1,2 +1,2 @@
1
1
  export { default as ErrorSummary } from "./ErrorSummary";
2
- export { ErrorSummaryProps } from "./ErrorSummary";
2
+ export { type ErrorSummaryProps } from "./ErrorSummary";
package/src/form/index.ts CHANGED
@@ -1,18 +1,23 @@
1
1
  export {
2
2
  Checkbox,
3
3
  CheckboxGroup,
4
- CheckboxGroupProps,
5
- CheckboxProps,
4
+ type CheckboxGroupProps,
5
+ type CheckboxProps,
6
6
  } from "./checkbox";
7
7
  export {
8
- ConfirmationPanelProps,
8
+ type ConfirmationPanelProps,
9
9
  default as ConfirmationPanel,
10
10
  } from "./ConfirmationPanel";
11
- export { ErrorSummary, ErrorSummaryProps } from "./error-summary";
12
- export { Fieldset, FieldsetContext, FieldsetProps } from "./Fieldset";
13
- export { Radio, RadioGroup, RadioGroupProps, RadioProps } from "./radio";
14
- export { Search, SearchClearEvent, SearchProps } from "./search";
15
- export { default as Select, SelectProps } from "./Select";
16
- export { default as Switch, SwitchProps } from "./Switch";
17
- export { Counter, default as Textarea, TextareaProps } from "./Textarea";
18
- export { default as TextField, TextFieldProps } from "./TextField";
11
+ export { ErrorSummary, type ErrorSummaryProps } from "./error-summary";
12
+ export { Fieldset, FieldsetContext, type FieldsetProps } from "./Fieldset";
13
+ export {
14
+ Radio,
15
+ RadioGroup,
16
+ type RadioGroupProps,
17
+ type RadioProps,
18
+ } from "./radio";
19
+ export { Search, type SearchClearEvent, type SearchProps } from "./search";
20
+ export { default as Select, type SelectProps } from "./Select";
21
+ export { default as Switch, type SwitchProps } from "./Switch";
22
+ export { Counter, default as Textarea, type TextareaProps } from "./Textarea";
23
+ export { default as TextField, type TextFieldProps } from "./TextField";
@@ -1,2 +1,2 @@
1
- export { default as Radio, RadioProps } from "./Radio";
2
- export { default as RadioGroup, RadioGroupProps } from "./RadioGroup";
1
+ export { default as Radio, type RadioProps } from "./Radio";
2
+ export { default as RadioGroup, type RadioGroupProps } from "./RadioGroup";
@@ -1,9 +1,10 @@
1
- import { Meta } from "@storybook/react/types-6-0";
1
+ /* eslint-disable react-hooks/rules-of-hooks */
2
+ import { Meta } from "@storybook/react";
2
3
  import React, { useState } from "react";
3
4
  import { Radio, RadioGroup } from "../../index";
4
5
 
5
6
  export default {
6
- title: "ds-react/Form/Radio",
7
+ title: "ds-react/Radio",
7
8
  component: Radio,
8
9
  subcomponents: {
9
10
  RadioGroup,
@@ -13,41 +14,45 @@ export default {
13
14
  },
14
15
  } as Meta;
15
16
 
16
- export const Default = (props) => {
17
- const [state, setState] = useState("radio1");
17
+ export const Default = {
18
+ render: (props) => {
19
+ const [state, setState] = useState("radio1");
18
20
 
19
- return (
20
- <RadioGroup
21
- legend={props.legend}
22
- description={props.description}
23
- value={props.controlled ? state : undefined}
24
- onChange={props.controlled ? setState : undefined}
25
- hideLegend={props.hideLegend}
26
- error={props.error ? "Errormelding" : undefined}
27
- size={props?.size}
28
- >
29
- <Radio value="radio1">{props.children || "Apple"}</Radio>
30
- <Radio
31
- value="radio2"
32
- description={props.radioDescription ? "Orange description" : undefined}
21
+ return (
22
+ <RadioGroup
23
+ legend={props.legend}
24
+ description={props.description}
25
+ value={props.controlled ? state : undefined}
26
+ onChange={props.controlled ? setState : undefined}
27
+ hideLegend={props.hideLegend}
28
+ error={props.error ? "Errormelding" : undefined}
29
+ size={props?.size}
33
30
  >
34
- {props.children || "Orange"}
35
- </Radio>
36
- <Radio value="radio3">{props.children || "Banana"}</Radio>
37
- <Radio value="radio4">{props.children || "Melon"}</Radio>
38
- </RadioGroup>
39
- );
40
- };
31
+ <Radio value="radio1">{props.children || "Apple"}</Radio>
32
+ <Radio
33
+ value="radio2"
34
+ description={
35
+ props.radioDescription ? "Orange description" : undefined
36
+ }
37
+ >
38
+ {props.children || "Orange"}
39
+ </Radio>
40
+ <Radio value="radio3">{props.children || "Banana"}</Radio>
41
+ <Radio value="radio4">{props.children || "Melon"}</Radio>
42
+ </RadioGroup>
43
+ );
44
+ },
41
45
 
42
- Default.args = {
43
- controlled: false,
44
- error: false,
45
- size: "medium",
46
- legend: "Legend-tekst",
47
- radioDescription: false,
48
- hideLegend: false,
49
- children: "",
50
- description: "",
46
+ args: {
47
+ controlled: false,
48
+ error: false,
49
+ size: "medium",
50
+ legend: "Legend-tekst",
51
+ radioDescription: false,
52
+ hideLegend: false,
53
+ children: "",
54
+ description: "",
55
+ },
51
56
  };
52
57
 
53
58
  export const Group = () => (
@@ -1 +1,5 @@
1
- export { default as Search, SearchProps, SearchClearEvent } from "./Search";
1
+ export {
2
+ default as Search,
3
+ type SearchProps,
4
+ type SearchClearEvent,
5
+ } from "./Search";
@@ -1,9 +1,10 @@
1
- import { Meta } from "@storybook/react/types-6-0";
1
+ /* eslint-disable react-hooks/rules-of-hooks */
2
+ import { Meta } from "@storybook/react";
2
3
  import React, { useState } from "react";
3
4
 
4
5
  import { Search } from "../index";
5
6
  export default {
6
- title: "ds-react/Form/Search",
7
+ title: "ds-react/Search",
7
8
  component: Search,
8
9
  argTypes: {
9
10
  clearButton: {
@@ -31,28 +32,30 @@ export default {
31
32
  },
32
33
  } as Meta;
33
34
 
34
- export const Default = (props) => {
35
- const [state, setState] = useState("");
36
- return (
37
- <div data-theme={props.darkmode ? "dark" : "light"}>
38
- <Search
39
- value={props.controlled ? state : undefined}
40
- onChange={props.controlled ? setState : null}
41
- label="Søk"
42
- size={props.size}
43
- clearButton={props.clearButton}
44
- variant={props.variant}
45
- hideLabel={props.hideLabel}
46
- error={props.error}
47
- />
48
- </div>
49
- );
50
- };
35
+ export const Default = {
36
+ render: (props) => {
37
+ const [state, setState] = useState("");
38
+ return (
39
+ <div data-theme={props.darkmode ? "dark" : "light"}>
40
+ <Search
41
+ value={props.controlled ? state : undefined}
42
+ onChange={props.controlled ? setState : undefined}
43
+ label="Søk"
44
+ size={props.size}
45
+ clearButton={props.clearButton}
46
+ variant={props.variant}
47
+ hideLabel={props.hideLabel}
48
+ error={props.error}
49
+ />
50
+ </div>
51
+ );
52
+ },
51
53
 
52
- Default.args = {
53
- controlled: false,
54
- darkmode: false,
55
- hideLabel: true,
54
+ args: {
55
+ controlled: false,
56
+ darkmode: false,
57
+ hideLabel: true,
58
+ },
56
59
  };
57
60
 
58
61
  export const Small = () => (
@@ -1,9 +1,9 @@
1
1
  import React, { useState } from "react";
2
2
  import { ConfirmationPanel } from "../index";
3
- import { Meta } from "@storybook/react/types-6-0";
3
+ import { Meta } from "@storybook/react";
4
4
  import { Link } from "../..";
5
5
  export default {
6
- title: "ds-react/form/ConfirmationPanel",
6
+ title: "ds-react/ConfirmationPanel",
7
7
  component: ConfirmationPanel,
8
8
  argTypes: {
9
9
  size: {
@@ -25,22 +25,24 @@ const content = (
25
25
  </>
26
26
  );
27
27
 
28
- export const Default = (props) => {
29
- return (
30
- <ConfirmationPanel
31
- error={props?.error}
32
- size={props?.size}
33
- checked={props?.checked ?? undefined}
34
- label={props?.label ?? "Checkbox label text"}
35
- >
36
- {content}
37
- </ConfirmationPanel>
38
- );
39
- };
28
+ export const Default = {
29
+ render: (props) => {
30
+ return (
31
+ <ConfirmationPanel
32
+ error={props?.error}
33
+ size={props?.size}
34
+ checked={props?.checked ?? undefined}
35
+ label={props?.label ?? "Checkbox label text"}
36
+ >
37
+ {content}
38
+ </ConfirmationPanel>
39
+ );
40
+ },
40
41
 
41
- Default.args = {
42
- label: "Checkbox label text",
43
- checked: false,
42
+ args: {
43
+ label: "Checkbox label text",
44
+ checked: false,
45
+ },
44
46
  };
45
47
 
46
48
  export const Small = () => {
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
2
  import { Fieldset } from "../index";
3
- import { Meta } from "@storybook/react/types-6-0";
3
+ import { Meta } from "@storybook/react";
4
4
  import { TextField } from "../../index";
5
5
  export default {
6
- title: "ds-react/form/Fieldset",
6
+ title: "ds-react/Fieldset",
7
7
  component: Fieldset,
8
8
  argTypes: {
9
9
  size: {
@@ -34,16 +34,18 @@ const content = (
34
34
  </>
35
35
  );
36
36
 
37
- export const Default = (props) => {
38
- return (
39
- <Fieldset legend="Mollit eiusmod" {...props}>
40
- {content}
41
- </Fieldset>
42
- );
43
- };
37
+ export const Default = {
38
+ render: (props) => {
39
+ return (
40
+ <Fieldset legend="Mollit eiusmod" {...props}>
41
+ {content}
42
+ </Fieldset>
43
+ );
44
+ },
44
45
 
45
- Default.args = {
46
- errorPropagation: true,
46
+ args: {
47
+ errorPropagation: true,
48
+ },
47
49
  };
48
50
 
49
51
  export const Small = () => (