@norges-domstoler/dds-components 13.5.0 → 13.6.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 (89) hide show
  1. package/dist/cjs/components/Button/Button.stories.d.ts +3 -3
  2. package/dist/cjs/components/Checkbox/Checkbox.stories.d.ts +2 -2
  3. package/dist/cjs/components/Chip/Chip.stories.d.ts +1 -1
  4. package/dist/cjs/components/DescriptionList/DescriptionList.stories.d.ts +2 -2
  5. package/dist/cjs/components/Divider/Divider.stories.d.ts +1 -1
  6. package/dist/cjs/components/Drawer/Drawer.stories.d.ts +1 -1
  7. package/dist/cjs/components/Feedback/CommentComponent.d.ts +13 -0
  8. package/dist/cjs/components/Feedback/Feedback.d.ts +2 -0
  9. package/dist/cjs/components/Feedback/Feedback.stories.d.ts +66 -0
  10. package/dist/cjs/components/Feedback/Feedback.types.d.ts +36 -0
  11. package/dist/cjs/components/Feedback/FlexContainer.d.ts +6 -0
  12. package/dist/cjs/components/Feedback/RatingComponent.d.ts +11 -0
  13. package/dist/cjs/components/Feedback/index.d.ts +2 -0
  14. package/dist/cjs/components/GlobalMessage/GlobalMessage.stories.d.ts +1 -1
  15. package/dist/cjs/components/InlineEdit/InlineEdit.stories.d.ts +1 -1
  16. package/dist/cjs/components/InlineEdit/InlineEditInput.stories.d.ts +1 -1
  17. package/dist/cjs/components/InlineEdit/InlineEditTextArea.stories.d.ts +1 -1
  18. package/dist/cjs/components/InputMessage/InputMessage.stories.d.ts +1 -1
  19. package/dist/cjs/components/List/List.stories.d.ts +1 -1
  20. package/dist/cjs/components/LocalMessage/LocalMessage.stories.d.ts +1 -1
  21. package/dist/cjs/components/Modal/Modal.stories.d.ts +1 -1
  22. package/dist/cjs/components/OverflowMenu/OverflowMenu.stories.d.ts +2 -2
  23. package/dist/cjs/components/Pagination/Pagination.stories.d.ts +1 -1
  24. package/dist/cjs/components/Popover/Popover.stories.d.ts +1 -1
  25. package/dist/cjs/components/ProgressTracker/ProgressTracker.stories.d.ts +3 -3
  26. package/dist/cjs/components/RadioButton/RadioButton.stories.d.ts +5 -5
  27. package/dist/cjs/components/RadioButton/RadioButtonGroup.stories.d.ts +1 -1
  28. package/dist/cjs/components/Search/Search.stories.d.ts +1 -1
  29. package/dist/cjs/components/SkipToContent/SkipToContent.stories.d.ts +1 -1
  30. package/dist/cjs/components/Stack/Stack.stories.d.ts +1 -1
  31. package/dist/cjs/components/Tabs/Tabs.stories.d.ts +3 -3
  32. package/dist/cjs/components/Tag/Tag.stories.d.ts +1 -1
  33. package/dist/cjs/components/ToggleButton/ToggleButton.stories.d.ts +2 -2
  34. package/dist/cjs/components/Tooltip/Tooltip.stories.d.ts +1 -1
  35. package/dist/cjs/components/Typography/Caption/Caption.stories.d.ts +1 -1
  36. package/dist/cjs/components/Typography/Heading/Heading.stories.d.ts +1 -1
  37. package/dist/cjs/components/Typography/Label/Label.stories.d.ts +1 -1
  38. package/dist/cjs/components/Typography/Legend/Legend.stories.d.ts +1 -1
  39. package/dist/cjs/components/Typography/Link/Link.stories.d.ts +3 -3
  40. package/dist/cjs/components/Typography/Paragraph/Paragraph.stories.d.ts +1 -1
  41. package/dist/cjs/index.d.ts +1 -0
  42. package/dist/cjs/index.js +196 -0
  43. package/dist/components/Button/Button.stories.d.ts +3 -3
  44. package/dist/components/Checkbox/Checkbox.stories.d.ts +2 -2
  45. package/dist/components/Chip/Chip.stories.d.ts +1 -1
  46. package/dist/components/DescriptionList/DescriptionList.stories.d.ts +2 -2
  47. package/dist/components/Divider/Divider.stories.d.ts +1 -1
  48. package/dist/components/Drawer/Drawer.stories.d.ts +1 -1
  49. package/dist/components/Feedback/CommentComponent.d.ts +13 -0
  50. package/dist/components/Feedback/CommentComponent.js +59 -0
  51. package/dist/components/Feedback/Feedback.d.ts +2 -0
  52. package/dist/components/Feedback/Feedback.js +103 -0
  53. package/dist/components/Feedback/Feedback.stories.d.ts +66 -0
  54. package/dist/components/Feedback/Feedback.types.d.ts +36 -0
  55. package/dist/components/Feedback/FlexContainer.d.ts +6 -0
  56. package/dist/components/Feedback/FlexContainer.js +12 -0
  57. package/dist/components/Feedback/RatingComponent.d.ts +11 -0
  58. package/dist/components/Feedback/RatingComponent.js +79 -0
  59. package/dist/components/Feedback/index.d.ts +2 -0
  60. package/dist/components/GlobalMessage/GlobalMessage.stories.d.ts +1 -1
  61. package/dist/components/InlineEdit/InlineEdit.stories.d.ts +1 -1
  62. package/dist/components/InlineEdit/InlineEditInput.stories.d.ts +1 -1
  63. package/dist/components/InlineEdit/InlineEditTextArea.stories.d.ts +1 -1
  64. package/dist/components/InputMessage/InputMessage.stories.d.ts +1 -1
  65. package/dist/components/List/List.stories.d.ts +1 -1
  66. package/dist/components/LocalMessage/LocalMessage.stories.d.ts +1 -1
  67. package/dist/components/Modal/Modal.stories.d.ts +1 -1
  68. package/dist/components/OverflowMenu/OverflowMenu.stories.d.ts +2 -2
  69. package/dist/components/Pagination/Pagination.stories.d.ts +1 -1
  70. package/dist/components/Popover/Popover.stories.d.ts +1 -1
  71. package/dist/components/ProgressTracker/ProgressTracker.stories.d.ts +3 -3
  72. package/dist/components/RadioButton/RadioButton.stories.d.ts +5 -5
  73. package/dist/components/RadioButton/RadioButtonGroup.stories.d.ts +1 -1
  74. package/dist/components/Search/Search.stories.d.ts +1 -1
  75. package/dist/components/SkipToContent/SkipToContent.stories.d.ts +1 -1
  76. package/dist/components/Stack/Stack.stories.d.ts +1 -1
  77. package/dist/components/Tabs/Tabs.stories.d.ts +3 -3
  78. package/dist/components/Tag/Tag.stories.d.ts +1 -1
  79. package/dist/components/ToggleButton/ToggleButton.stories.d.ts +2 -2
  80. package/dist/components/Tooltip/Tooltip.stories.d.ts +1 -1
  81. package/dist/components/Typography/Caption/Caption.stories.d.ts +1 -1
  82. package/dist/components/Typography/Heading/Heading.stories.d.ts +1 -1
  83. package/dist/components/Typography/Label/Label.stories.d.ts +1 -1
  84. package/dist/components/Typography/Legend/Legend.stories.d.ts +1 -1
  85. package/dist/components/Typography/Link/Link.stories.d.ts +3 -3
  86. package/dist/components/Typography/Paragraph/Paragraph.stories.d.ts +1 -1
  87. package/dist/index.d.ts +1 -0
  88. package/dist/index.js +1 -0
  89. package/package.json +1 -1
@@ -48,3 +48,4 @@ export * from './types/BaseComponentProps';
48
48
  export * from './helpers/ScreenSize';
49
49
  export * from './components/EmptyContent';
50
50
  export * from './components/BackLink';
51
+ export * from './components/Feedback';
package/dist/cjs/index.js CHANGED
@@ -11495,6 +11495,201 @@ var BackLink = /*#__PURE__*/React.forwardRef(function (props, ref) {
11495
11495
  });
11496
11496
  BackLink.displayName = 'BackLink';
11497
11497
 
11498
+ var FlexContainer = styled__default.default.div.withConfig({
11499
+ displayName: "FlexContainer",
11500
+ componentId: "sc-se7ebh-0"
11501
+ })(["display:flex;", ";"], function (_ref) {
11502
+ var flexDirection = _ref.flexDirection;
11503
+ return styled.css(["flex-direction:", ";gap:", ";"], flexDirection, ddsDesignTokens.ddsBaseTokens.spacing.SizesDdsSpacingLocalX1);
11504
+ });
11505
+
11506
+ var RatingContainer = styled__default.default.div.withConfig({
11507
+ displayName: "RatingComponent__RatingContainer",
11508
+ componentId: "sc-3siwxn-0"
11509
+ })(["display:flex;gap:", ";", ""], ddsDesignTokens.ddsBaseTokens.spacing.SizesDdsSpacingLocalX1, function (_ref) {
11510
+ var layout = _ref.layout;
11511
+ return styled.css(["flex-direction:", ";align-items:", ";"], layout === 'horizontal' ? 'row' : 'column', layout === 'horizontal' ? 'center' : 'start');
11512
+ });
11513
+ var RatingButton = styled__default.default(Button$1).withConfig({
11514
+ displayName: "RatingComponent__RatingButton",
11515
+ componentId: "sc-3siwxn-1"
11516
+ })(["padding:0px;color:", ";"], ddsDesignTokens.ddsBaseTokens.colors.DdsColorNeutralsGray7);
11517
+ var RatingComponent = function RatingComponent(_ref2) {
11518
+ var layout = _ref2.layout,
11519
+ ratingLabel = _ref2.ratingLabel,
11520
+ loading = _ref2.loading,
11521
+ thumbUpTooltip = _ref2.thumbUpTooltip,
11522
+ thumbDownTooltip = _ref2.thumbDownTooltip,
11523
+ handleRatingChange = _ref2.handleRatingChange;
11524
+ return jsxRuntime.jsxs(RatingContainer, {
11525
+ layout: layout,
11526
+ children: [jsxRuntime.jsx(Label$2, {
11527
+ children: ratingLabel
11528
+ }), loading ? jsxRuntime.jsx(Spinner, {
11529
+ tooltip: "Laster opp tilbakemelding ..."
11530
+ }) : jsxRuntime.jsxs(FlexContainer, {
11531
+ flexDirection: "row",
11532
+ children: [jsxRuntime.jsx(Tooltip, {
11533
+ text: thumbUpTooltip,
11534
+ children: jsxRuntime.jsx(RatingButton, {
11535
+ htmlProps: {
11536
+ 'aria-label': thumbUpTooltip
11537
+ },
11538
+ icon: Thumbup,
11539
+ appearance: "borderless",
11540
+ onClick: function onClick() {
11541
+ return handleRatingChange('positive');
11542
+ },
11543
+ size: "large"
11544
+ })
11545
+ }), jsxRuntime.jsx(Tooltip, {
11546
+ text: thumbDownTooltip,
11547
+ children: jsxRuntime.jsx("div", {
11548
+ children: jsxRuntime.jsx(RatingButton, {
11549
+ htmlProps: {
11550
+ 'aria-label': thumbDownTooltip
11551
+ },
11552
+ icon: Thumbdown,
11553
+ appearance: "borderless",
11554
+ onClick: function onClick() {
11555
+ return handleRatingChange('negative');
11556
+ },
11557
+ size: "large"
11558
+ })
11559
+ })
11560
+ })]
11561
+ })]
11562
+ });
11563
+ };
11564
+
11565
+ var IconLabelSpan = styled__default.default.span.withConfig({
11566
+ displayName: "CommentComponent__IconLabelSpan",
11567
+ componentId: "sc-15c6vik-0"
11568
+ })(["display:inline-flex;align-items:center;gap:", ";"], ddsDesignTokens.ddsBaseTokens.spacing.SizesDdsSpacingLocalX05);
11569
+ var CommentComponent = function CommentComponent(_ref) {
11570
+ var rating = _ref.rating,
11571
+ feedbackText = _ref.feedbackText,
11572
+ positiveFeedbackLabel = _ref.positiveFeedbackLabel,
11573
+ negativeFeedbackLabel = _ref.negativeFeedbackLabel,
11574
+ ratingSubmittedTitle = _ref.ratingSubmittedTitle,
11575
+ loading = _ref.loading,
11576
+ handleSubmit = _ref.handleSubmit,
11577
+ handleFeedbackTextChange = _ref.handleFeedbackTextChange;
11578
+ return jsxRuntime.jsxs(FlexContainer, {
11579
+ flexDirection: "column",
11580
+ children: [jsxRuntime.jsxs(IconLabelSpan, {
11581
+ children: [jsxRuntime.jsx(Icon, {
11582
+ icon: rating === 'positive' ? ThumbupFilled : ThumbdownFilled,
11583
+ color: ddsDesignTokens.ddsBaseTokens.colors.DdsColorInteractiveBase
11584
+ }), jsxRuntime.jsxs(Paragraph, {
11585
+ children: [ratingSubmittedTitle, " "]
11586
+ })]
11587
+ }), jsxRuntime.jsx(TextArea, {
11588
+ value: feedbackText,
11589
+ onChange: function onChange(e) {
11590
+ return handleFeedbackTextChange(e.target.value);
11591
+ },
11592
+ label: rating === 'positive' ? positiveFeedbackLabel : negativeFeedbackLabel,
11593
+ tip: "Ikke send inn personopplysninger eller annen sensitiv informasjon"
11594
+ }), jsxRuntime.jsx(Button$1, {
11595
+ label: "Send inn",
11596
+ purpose: "secondary",
11597
+ size: "small",
11598
+ onClick: handleSubmit,
11599
+ loading: loading
11600
+ })]
11601
+ });
11602
+ };
11603
+
11604
+ var Feedback = function Feedback(_ref) {
11605
+ var _ref$layout = _ref.layout,
11606
+ layout = _ref$layout === void 0 ? 'vertical' : _ref$layout,
11607
+ _ref$ratingLabel = _ref.ratingLabel,
11608
+ ratingLabel = _ref$ratingLabel === void 0 ? 'Hva syns du om tjenesten?' : _ref$ratingLabel,
11609
+ _ref$positiveFeedback = _ref.positiveFeedbackLabel,
11610
+ positiveFeedbackLabel = _ref$positiveFeedback === void 0 ? 'Hva kan vi forbedre? (valgfritt)' : _ref$positiveFeedback,
11611
+ _ref$negativeFeedback = _ref.negativeFeedbackLabel,
11612
+ negativeFeedbackLabel = _ref$negativeFeedback === void 0 ? 'Hva kan vi forbedre? (valgfritt)' : _ref$negativeFeedback,
11613
+ _ref$ratingSubmittedT = _ref.ratingSubmittedTitle,
11614
+ ratingSubmittedTitle = _ref$ratingSubmittedT === void 0 ? 'Tusen takk! Tilbakemeldingen din hjelper oss å forbedre løsningen' : _ref$ratingSubmittedT,
11615
+ _ref$submittedTitle = _ref.submittedTitle,
11616
+ submittedTitle = _ref$submittedTitle === void 0 ? 'Tusen takk! Tilbakemeldingen din hjelper oss å forbedre løsningen' : _ref$submittedTitle,
11617
+ ratingProp = _ref.ratingValue,
11618
+ feedbackTextProp = _ref.feedbackTextValue,
11619
+ _ref$thumbUpTooltip = _ref.thumbUpTooltip,
11620
+ thumbUpTooltip = _ref$thumbUpTooltip === void 0 ? 'Bra' : _ref$thumbUpTooltip,
11621
+ _ref$thumbDownTooltip = _ref.thumbDownTooltip,
11622
+ thumbDownTooltip = _ref$thumbDownTooltip === void 0 ? 'Dårlig' : _ref$thumbDownTooltip,
11623
+ _ref$feedbackTextArea = _ref.feedbackTextAreaExcluded,
11624
+ feedbackTextAreaExcluded = _ref$feedbackTextArea === void 0 ? false : _ref$feedbackTextArea,
11625
+ _ref$loading = _ref.loading,
11626
+ loading = _ref$loading === void 0 ? false : _ref$loading,
11627
+ isSubmittedProp = _ref.isSubmitted,
11628
+ onRating = _ref.onRating,
11629
+ onFeedbackTextChange = _ref.onFeedbackTextChange,
11630
+ onSubmit = _ref.onSubmit;
11631
+ var _useState = React.useState(null),
11632
+ _useState2 = _slicedToArray(_useState, 2),
11633
+ rating = _useState2[0],
11634
+ setRating = _useState2[1];
11635
+ var _useState3 = React.useState(),
11636
+ _useState4 = _slicedToArray(_useState3, 2),
11637
+ feedbackText = _useState4[0],
11638
+ setFeedbackText = _useState4[1];
11639
+ var _useState5 = React.useState(false),
11640
+ _useState6 = _slicedToArray(_useState5, 2),
11641
+ isFeedbackSubmitted = _useState6[0],
11642
+ setIsFeedbackSubmitted = _useState6[1];
11643
+ React.useEffect(function () {
11644
+ ratingProp !== undefined && setRating(ratingProp);
11645
+ }, [ratingProp]);
11646
+ React.useEffect(function () {
11647
+ feedbackTextProp !== undefined && setFeedbackText(feedbackTextProp);
11648
+ }, [feedbackTextProp]);
11649
+ React.useEffect(function () {
11650
+ isSubmittedProp !== undefined && setIsFeedbackSubmitted(isSubmittedProp);
11651
+ }, [isSubmittedProp]);
11652
+ var handleRatingChange = function handleRatingChange(newRating) {
11653
+ onRating && onRating(newRating);
11654
+ onSubmit && feedbackTextAreaExcluded && onSubmit(newRating, '');
11655
+ ratingProp === undefined && setRating(newRating);
11656
+ };
11657
+ var handleFeedbackTextChange = function handleFeedbackTextChange(newFeedbackText) {
11658
+ onFeedbackTextChange && onFeedbackTextChange(newFeedbackText);
11659
+ feedbackTextProp === undefined && setFeedbackText(newFeedbackText);
11660
+ };
11661
+ var handleSubmit = function handleSubmit() {
11662
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Ved submit er rating alltid satt
11663
+ onSubmit && onSubmit(rating, feedbackText !== null && feedbackText !== void 0 ? feedbackText : '');
11664
+ isSubmittedProp === undefined && setIsFeedbackSubmitted(true);
11665
+ };
11666
+ if (rating === null && !isFeedbackSubmitted) {
11667
+ return jsxRuntime.jsx(RatingComponent, {
11668
+ layout: layout,
11669
+ ratingLabel: ratingLabel,
11670
+ loading: loading,
11671
+ thumbUpTooltip: thumbUpTooltip,
11672
+ thumbDownTooltip: thumbDownTooltip,
11673
+ handleRatingChange: handleRatingChange
11674
+ });
11675
+ }
11676
+ if (!feedbackTextAreaExcluded && !isFeedbackSubmitted) {
11677
+ return jsxRuntime.jsx(CommentComponent, {
11678
+ rating: rating,
11679
+ feedbackText: feedbackText,
11680
+ positiveFeedbackLabel: positiveFeedbackLabel,
11681
+ negativeFeedbackLabel: negativeFeedbackLabel,
11682
+ ratingSubmittedTitle: ratingSubmittedTitle,
11683
+ loading: loading,
11684
+ handleSubmit: handleSubmit,
11685
+ handleFeedbackTextChange: handleFeedbackTextChange
11686
+ });
11687
+ }
11688
+ return jsxRuntime.jsx(Paragraph, {
11689
+ children: submittedTitle
11690
+ });
11691
+ };
11692
+
11498
11693
  exports.AgreementIcon = AgreementIcon;
11499
11694
  exports.AppsIcon = AppsIcon;
11500
11695
  exports.ArchiveIcon = ArchiveIcon;
@@ -11573,6 +11768,7 @@ exports.ExclaimIcon = ExclaimIcon;
11573
11768
  exports.ExpandIcon = ExpandIcon;
11574
11769
  exports.FacebookIcon = FacebookIcon;
11575
11770
  exports.FamilyIcon = FamilyIcon;
11771
+ exports.Feedback = Feedback;
11576
11772
  exports.FeedbackIcon = FeedbackIcon;
11577
11773
  exports.FileAddIcon = FileAddIcon;
11578
11774
  exports.FileIcon = FileIcon;
@@ -2,7 +2,7 @@
2
2
  import { ButtonProps } from '.';
3
3
  declare const _default: {
4
4
  title: string;
5
- component: import("react").ForwardRefExoticComponent<Pick<Omit<import("react").ButtonHTMLAttributes<HTMLButtonElement>, "onFocus" | "onBlur" | "onClick" | "type">, "id" | "className"> & {
5
+ component: import("react").ForwardRefExoticComponent<Pick<Omit<import("react").ButtonHTMLAttributes<HTMLButtonElement>, "type" | "onFocus" | "onBlur" | "onClick">, "className" | "id"> & {
6
6
  size?: import("./Button.types").ButtonSize | undefined;
7
7
  label?: string | undefined;
8
8
  purpose?: import("./Button.types").ButtonPurpose | undefined;
@@ -15,12 +15,12 @@ declare const _default: {
15
15
  href?: string | undefined;
16
16
  target?: string | undefined;
17
17
  } & {
18
+ type?: "button" | "submit" | "reset" | undefined;
18
19
  onFocus?: import("react").FocusEventHandler<HTMLButtonElement> | undefined;
19
20
  onBlur?: import("react").FocusEventHandler<HTMLButtonElement> | undefined;
20
21
  onClick?: import("react").MouseEventHandler<HTMLButtonElement> | undefined;
21
- type?: "button" | "submit" | "reset" | undefined;
22
22
  } & {
23
- htmlProps?: Omit<import("react").ButtonHTMLAttributes<HTMLButtonElement>, "onFocus" | "onBlur" | "onClick" | "type"> | undefined;
23
+ htmlProps?: Omit<import("react").ButtonHTMLAttributes<HTMLButtonElement>, "type" | "onFocus" | "onBlur" | "onClick"> | undefined;
24
24
  } & import("react").RefAttributes<HTMLButtonElement>>;
25
25
  argTypes: {
26
26
  label: {
@@ -2,14 +2,14 @@
2
2
  import { CheckboxProps } from '.';
3
3
  declare const _default: {
4
4
  title: string;
5
- component: import("react").ForwardRefExoticComponent<Pick<Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "defaultChecked" | "defaultValue" | "aria-describedby" | "onBlur" | "onChange" | "name" | "value" | "checked">, "id" | "className"> & {
5
+ component: import("react").ForwardRefExoticComponent<Pick<Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "name" | "defaultChecked" | "defaultValue" | "aria-describedby" | "onBlur" | "onChange" | "value" | "checked">, "className" | "id"> & {
6
6
  label?: string | undefined;
7
7
  error?: boolean | undefined;
8
8
  disabled?: boolean | undefined;
9
9
  readOnly?: boolean | undefined;
10
10
  indeterminate?: boolean | undefined;
11
11
  } & import("../../types").CheckboxPickedHTMLAttributes & {
12
- htmlProps?: Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "defaultChecked" | "defaultValue" | "aria-describedby" | "onBlur" | "onChange" | "name" | "value" | "checked"> | undefined;
12
+ htmlProps?: Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "name" | "defaultChecked" | "defaultValue" | "aria-describedby" | "onBlur" | "onChange" | "value" | "checked"> | undefined;
13
13
  } & import("react").RefAttributes<HTMLInputElement>>;
14
14
  argTypes: {
15
15
  label: {
@@ -2,7 +2,7 @@
2
2
  import { ChipProps } from '.';
3
3
  declare const _default: {
4
4
  title: string;
5
- component: import("react").ForwardRefExoticComponent<Pick<import("react").HTMLAttributes<HTMLDivElement>, "id" | "className"> & {
5
+ component: import("react").ForwardRefExoticComponent<Pick<import("react").HTMLAttributes<HTMLDivElement>, "className" | "id"> & {
6
6
  text?: string | undefined;
7
7
  onClose?: (() => void) | undefined;
8
8
  } & {
@@ -2,9 +2,9 @@
2
2
  import { DescriptionListProps } from '.';
3
3
  declare const _default: {
4
4
  title: string;
5
- component: import("react").ForwardRefExoticComponent<Pick<import("react").HTMLAttributes<HTMLDListElement>, "id" | "className"> & {
5
+ component: import("react").ForwardRefExoticComponent<Pick<import("react").HTMLAttributes<HTMLDListElement>, "className" | "id"> & {
6
6
  appearance?: import("./DescriptionList").DescriptionListAppearance | undefined;
7
- direction?: "row" | "column" | undefined;
7
+ direction?: "column" | "row" | undefined;
8
8
  } & {
9
9
  children?: import("react").ReactNode;
10
10
  } & {
@@ -2,7 +2,7 @@
2
2
  import { DividerProps } from '.';
3
3
  declare const _default: {
4
4
  title: string;
5
- component: import("react").ForwardRefExoticComponent<Pick<import("react").HTMLAttributes<HTMLHRElement>, "id" | "className"> & {
5
+ component: import("react").ForwardRefExoticComponent<Pick<import("react").HTMLAttributes<HTMLHRElement>, "className" | "id"> & {
6
6
  color?: import("./Divider").DividerColor | undefined;
7
7
  } & {
8
8
  htmlProps?: import("react").HTMLAttributes<HTMLHRElement> | undefined;
@@ -2,7 +2,7 @@
2
2
  import { DrawerProps } from '.';
3
3
  declare const _default: {
4
4
  title: string;
5
- component: import("react").ForwardRefExoticComponent<Pick<import("react").HTMLAttributes<HTMLDivElement>, "id" | "className"> & {
5
+ component: import("react").ForwardRefExoticComponent<Pick<import("react").HTMLAttributes<HTMLDivElement>, "className" | "id"> & {
6
6
  size?: import("./Drawer").DrawerSize | undefined;
7
7
  placement?: import("./Drawer").DrawerPlacement | undefined;
8
8
  header?: import("react").ReactNode;
@@ -0,0 +1,13 @@
1
+ import { Rating } from './Feedback.types';
2
+ type CommentComponentType = {
3
+ rating: Rating | null;
4
+ feedbackText: string | undefined;
5
+ positiveFeedbackLabel: string;
6
+ negativeFeedbackLabel: string;
7
+ ratingSubmittedTitle: string;
8
+ loading: boolean;
9
+ handleSubmit: () => void;
10
+ handleFeedbackTextChange: (newText: string) => void;
11
+ };
12
+ export declare const CommentComponent: ({ rating, feedbackText, positiveFeedbackLabel, negativeFeedbackLabel, ratingSubmittedTitle, loading, handleSubmit, handleFeedbackTextChange, }: CommentComponentType) => import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,59 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import styled from 'styled-components';
3
+ import { FlexContainer } from './FlexContainer.js';
4
+ import { ddsBaseTokens } from '@norges-domstoler/dds-design-tokens';
5
+ import { Icon } from '../Icon/Icon.js';
6
+ import 'tslib';
7
+ import '../../icons/utils/StyledSvg.js';
8
+ import { ThumbdownFilled } from '../../icons/tsx/thumbdownFilled.js';
9
+ import { ThumbupFilled } from '../../icons/tsx/thumbupFilled.js';
10
+ import { Button } from '../Button/Button.js';
11
+ import { TextArea } from '../TextArea/TextArea.js';
12
+ import '../Typography/Typography/Typography.js';
13
+ import '../Typography/Label/Label.js';
14
+ import { Paragraph } from '../Typography/Paragraph/Paragraph.js';
15
+ import '../Typography/Heading/Heading.js';
16
+ import '../Typography/Link/Link.js';
17
+ import '../Typography/Legend/Legend.js';
18
+ import '../Typography/Caption/Caption.js';
19
+
20
+ var IconLabelSpan = styled.span.withConfig({
21
+ displayName: "CommentComponent__IconLabelSpan",
22
+ componentId: "sc-15c6vik-0"
23
+ })(["display:inline-flex;align-items:center;gap:", ";"], ddsBaseTokens.spacing.SizesDdsSpacingLocalX05);
24
+ var CommentComponent = function CommentComponent(_ref) {
25
+ var rating = _ref.rating,
26
+ feedbackText = _ref.feedbackText,
27
+ positiveFeedbackLabel = _ref.positiveFeedbackLabel,
28
+ negativeFeedbackLabel = _ref.negativeFeedbackLabel,
29
+ ratingSubmittedTitle = _ref.ratingSubmittedTitle,
30
+ loading = _ref.loading,
31
+ handleSubmit = _ref.handleSubmit,
32
+ handleFeedbackTextChange = _ref.handleFeedbackTextChange;
33
+ return jsxs(FlexContainer, {
34
+ flexDirection: "column",
35
+ children: [jsxs(IconLabelSpan, {
36
+ children: [jsx(Icon, {
37
+ icon: rating === 'positive' ? ThumbupFilled : ThumbdownFilled,
38
+ color: ddsBaseTokens.colors.DdsColorInteractiveBase
39
+ }), jsxs(Paragraph, {
40
+ children: [ratingSubmittedTitle, " "]
41
+ })]
42
+ }), jsx(TextArea, {
43
+ value: feedbackText,
44
+ onChange: function onChange(e) {
45
+ return handleFeedbackTextChange(e.target.value);
46
+ },
47
+ label: rating === 'positive' ? positiveFeedbackLabel : negativeFeedbackLabel,
48
+ tip: "Ikke send inn personopplysninger eller annen sensitiv informasjon"
49
+ }), jsx(Button, {
50
+ label: "Send inn",
51
+ purpose: "secondary",
52
+ size: "small",
53
+ onClick: handleSubmit,
54
+ loading: loading
55
+ })]
56
+ });
57
+ };
58
+
59
+ export { CommentComponent };
@@ -0,0 +1,2 @@
1
+ import { FeedbackProps } from './Feedback.types';
2
+ export declare const Feedback: ({ layout, ratingLabel, positiveFeedbackLabel, negativeFeedbackLabel, ratingSubmittedTitle, submittedTitle, ratingValue: ratingProp, feedbackTextValue: feedbackTextProp, thumbUpTooltip, thumbDownTooltip, feedbackTextAreaExcluded, loading, isSubmitted: isSubmittedProp, onRating, onFeedbackTextChange, onSubmit, }: FeedbackProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,103 @@
1
+ import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useState, useEffect } from 'react';
4
+ import '../Typography/Typography/Typography.js';
5
+ import '../Typography/Label/Label.js';
6
+ import { Paragraph } from '../Typography/Paragraph/Paragraph.js';
7
+ import '../Typography/Heading/Heading.js';
8
+ import '../Typography/Link/Link.js';
9
+ import '../Typography/Legend/Legend.js';
10
+ import '../Typography/Caption/Caption.js';
11
+ import { RatingComponent } from './RatingComponent.js';
12
+ import { CommentComponent } from './CommentComponent.js';
13
+
14
+ var Feedback = function Feedback(_ref) {
15
+ var _ref$layout = _ref.layout,
16
+ layout = _ref$layout === void 0 ? 'vertical' : _ref$layout,
17
+ _ref$ratingLabel = _ref.ratingLabel,
18
+ ratingLabel = _ref$ratingLabel === void 0 ? 'Hva syns du om tjenesten?' : _ref$ratingLabel,
19
+ _ref$positiveFeedback = _ref.positiveFeedbackLabel,
20
+ positiveFeedbackLabel = _ref$positiveFeedback === void 0 ? 'Hva kan vi forbedre? (valgfritt)' : _ref$positiveFeedback,
21
+ _ref$negativeFeedback = _ref.negativeFeedbackLabel,
22
+ negativeFeedbackLabel = _ref$negativeFeedback === void 0 ? 'Hva kan vi forbedre? (valgfritt)' : _ref$negativeFeedback,
23
+ _ref$ratingSubmittedT = _ref.ratingSubmittedTitle,
24
+ ratingSubmittedTitle = _ref$ratingSubmittedT === void 0 ? 'Tusen takk! Tilbakemeldingen din hjelper oss å forbedre løsningen' : _ref$ratingSubmittedT,
25
+ _ref$submittedTitle = _ref.submittedTitle,
26
+ submittedTitle = _ref$submittedTitle === void 0 ? 'Tusen takk! Tilbakemeldingen din hjelper oss å forbedre løsningen' : _ref$submittedTitle,
27
+ ratingProp = _ref.ratingValue,
28
+ feedbackTextProp = _ref.feedbackTextValue,
29
+ _ref$thumbUpTooltip = _ref.thumbUpTooltip,
30
+ thumbUpTooltip = _ref$thumbUpTooltip === void 0 ? 'Bra' : _ref$thumbUpTooltip,
31
+ _ref$thumbDownTooltip = _ref.thumbDownTooltip,
32
+ thumbDownTooltip = _ref$thumbDownTooltip === void 0 ? 'Dårlig' : _ref$thumbDownTooltip,
33
+ _ref$feedbackTextArea = _ref.feedbackTextAreaExcluded,
34
+ feedbackTextAreaExcluded = _ref$feedbackTextArea === void 0 ? false : _ref$feedbackTextArea,
35
+ _ref$loading = _ref.loading,
36
+ loading = _ref$loading === void 0 ? false : _ref$loading,
37
+ isSubmittedProp = _ref.isSubmitted,
38
+ onRating = _ref.onRating,
39
+ onFeedbackTextChange = _ref.onFeedbackTextChange,
40
+ onSubmit = _ref.onSubmit;
41
+ var _useState = useState(null),
42
+ _useState2 = _slicedToArray(_useState, 2),
43
+ rating = _useState2[0],
44
+ setRating = _useState2[1];
45
+ var _useState3 = useState(),
46
+ _useState4 = _slicedToArray(_useState3, 2),
47
+ feedbackText = _useState4[0],
48
+ setFeedbackText = _useState4[1];
49
+ var _useState5 = useState(false),
50
+ _useState6 = _slicedToArray(_useState5, 2),
51
+ isFeedbackSubmitted = _useState6[0],
52
+ setIsFeedbackSubmitted = _useState6[1];
53
+ useEffect(function () {
54
+ ratingProp !== undefined && setRating(ratingProp);
55
+ }, [ratingProp]);
56
+ useEffect(function () {
57
+ feedbackTextProp !== undefined && setFeedbackText(feedbackTextProp);
58
+ }, [feedbackTextProp]);
59
+ useEffect(function () {
60
+ isSubmittedProp !== undefined && setIsFeedbackSubmitted(isSubmittedProp);
61
+ }, [isSubmittedProp]);
62
+ var handleRatingChange = function handleRatingChange(newRating) {
63
+ onRating && onRating(newRating);
64
+ onSubmit && feedbackTextAreaExcluded && onSubmit(newRating, '');
65
+ ratingProp === undefined && setRating(newRating);
66
+ };
67
+ var handleFeedbackTextChange = function handleFeedbackTextChange(newFeedbackText) {
68
+ onFeedbackTextChange && onFeedbackTextChange(newFeedbackText);
69
+ feedbackTextProp === undefined && setFeedbackText(newFeedbackText);
70
+ };
71
+ var handleSubmit = function handleSubmit() {
72
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Ved submit er rating alltid satt
73
+ onSubmit && onSubmit(rating, feedbackText !== null && feedbackText !== void 0 ? feedbackText : '');
74
+ isSubmittedProp === undefined && setIsFeedbackSubmitted(true);
75
+ };
76
+ if (rating === null && !isFeedbackSubmitted) {
77
+ return jsx(RatingComponent, {
78
+ layout: layout,
79
+ ratingLabel: ratingLabel,
80
+ loading: loading,
81
+ thumbUpTooltip: thumbUpTooltip,
82
+ thumbDownTooltip: thumbDownTooltip,
83
+ handleRatingChange: handleRatingChange
84
+ });
85
+ }
86
+ if (!feedbackTextAreaExcluded && !isFeedbackSubmitted) {
87
+ return jsx(CommentComponent, {
88
+ rating: rating,
89
+ feedbackText: feedbackText,
90
+ positiveFeedbackLabel: positiveFeedbackLabel,
91
+ negativeFeedbackLabel: negativeFeedbackLabel,
92
+ ratingSubmittedTitle: ratingSubmittedTitle,
93
+ loading: loading,
94
+ handleSubmit: handleSubmit,
95
+ handleFeedbackTextChange: handleFeedbackTextChange
96
+ });
97
+ }
98
+ return jsx(Paragraph, {
99
+ children: submittedTitle
100
+ });
101
+ };
102
+
103
+ export { Feedback };
@@ -0,0 +1,66 @@
1
+ import { FeedbackProps } from '.';
2
+ declare const _default: {
3
+ title: string;
4
+ component: ({ layout, ratingLabel, positiveFeedbackLabel, negativeFeedbackLabel, ratingSubmittedTitle, submittedTitle, ratingValue: ratingProp, feedbackTextValue: feedbackTextProp, thumbUpTooltip, thumbDownTooltip, feedbackTextAreaExcluded, loading, isSubmitted: isSubmittedProp, onRating, onFeedbackTextChange, onSubmit, }: FeedbackProps) => import("react/jsx-runtime").JSX.Element;
5
+ argTypes: {
6
+ layout: {
7
+ control: {
8
+ type: string;
9
+ options: {
10
+ vertical: string;
11
+ horizontal: string;
12
+ };
13
+ };
14
+ };
15
+ ratingLabel: {
16
+ control: string;
17
+ };
18
+ ratingValue: {
19
+ control: {
20
+ type: string;
21
+ options: {
22
+ null: null;
23
+ positive: string;
24
+ negative: string;
25
+ };
26
+ };
27
+ };
28
+ positiveFeedbackLabel: {
29
+ control: string;
30
+ };
31
+ negativeFeedbackLabel: {
32
+ control: string;
33
+ };
34
+ feedbackTextValue: {
35
+ control: string;
36
+ };
37
+ thumbUpTooltip: {
38
+ control: string;
39
+ };
40
+ thumbDownTooltip: {
41
+ control: string;
42
+ };
43
+ feedbackTextAreaExcluded: {
44
+ control: string;
45
+ };
46
+ loading: {
47
+ control: string;
48
+ };
49
+ isSubmitted: {
50
+ control: string;
51
+ };
52
+ };
53
+ parameters: {
54
+ controls: {
55
+ exclude: string[];
56
+ };
57
+ };
58
+ };
59
+ export default _default;
60
+ export declare const Default: (args: FeedbackProps) => import("react/jsx-runtime").JSX.Element;
61
+ export declare const HorizontalLayout: (args: FeedbackProps) => import("react/jsx-runtime").JSX.Element;
62
+ export declare const WithoutTextArea: (args: FeedbackProps) => import("react/jsx-runtime").JSX.Element;
63
+ export declare const CustomLabels: (args: FeedbackProps) => import("react/jsx-runtime").JSX.Element;
64
+ export declare const CustomButtonTooltips: (args: FeedbackProps) => import("react/jsx-runtime").JSX.Element;
65
+ export declare const LoadingState: (args: FeedbackProps) => import("react/jsx-runtime").JSX.Element;
66
+ export declare const ControlledComponent: (args: FeedbackProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,36 @@
1
+ export type FeedbackProps = {
2
+ /**Om knappene skal være plassert under eller ved siden av teksten. */
3
+ layout?: Layout;
4
+ /**Label som er plassert over tommel opp/ned knappene */
5
+ ratingLabel: string;
6
+ /**Label til fritekstfeltet når bruker har gitt tommel opp */
7
+ positiveFeedbackLabel?: string;
8
+ /**Label til fritekstfeltet når bruker har gitt tommel ned */
9
+ negativeFeedbackLabel?: string;
10
+ /**Tittel som vises når bruker har gitt tommel opp/ned, og enda ikke sendt inn kommentar */
11
+ ratingSubmittedTitle?: string;
12
+ /**Tittel som vises når bruker har gitt feedback (inkl. eventuell kommentar) */
13
+ submittedTitle?: string;
14
+ /**Om tommel opp eller ned er valgt. Brukes når komponenten skal være styrt utenfra. */
15
+ ratingValue?: Rating | null;
16
+ /**Verdien til fritekstfeltet. Brukes når komponenten skal være styrt utenfra. */
17
+ feedbackTextValue?: string;
18
+ /**Tooltip-teksten til tommel-opp-knappen*/
19
+ thumbUpTooltip?: string;
20
+ /**Tooltip-teksten til tommel-ned-knappen*/
21
+ thumbDownTooltip?: string;
22
+ /**Om tilbakemeldingskomponenten skal ekskludere fritekstfeltet (i.e. kun ha tommel opp/ned).*/
23
+ feedbackTextAreaExcluded?: boolean;
24
+ /**Om knappene skal vise spinner. Gjelder både tommel opp/ned knappene, og "send inn" knappen. */
25
+ loading?: boolean;
26
+ /**Om tilbakemelding er sendt inn. Brukes når komponenten skal være styrt utenfra. */
27
+ isSubmitted?: boolean;
28
+ /**Callback når bruker har gitt tommelrating */
29
+ onRating?: (rating: Rating) => void;
30
+ /**Callback når bruker skriver noe i fritekstfeltet */
31
+ onFeedbackTextChange?: (feedbackText: string) => void;
32
+ /**Callback når bruker sender inn feedback */
33
+ onSubmit?: (rating: Rating, feedbackText: string) => void;
34
+ };
35
+ export type Rating = 'positive' | 'negative';
36
+ export type Layout = 'vertical' | 'horizontal';
@@ -0,0 +1,6 @@
1
+ import { CSSProperties } from 'react';
2
+ type FlexContainerProps = {
3
+ flexDirection: CSSProperties['flexDirection'];
4
+ };
5
+ export declare const FlexContainer: import("styled-components").StyledComponent<"div", any, FlexContainerProps, never>;
6
+ export {};
@@ -0,0 +1,12 @@
1
+ import styled, { css } from 'styled-components';
2
+ import { ddsBaseTokens } from '@norges-domstoler/dds-design-tokens';
3
+
4
+ var FlexContainer = styled.div.withConfig({
5
+ displayName: "FlexContainer",
6
+ componentId: "sc-se7ebh-0"
7
+ })(["display:flex;", ";"], function (_ref) {
8
+ var flexDirection = _ref.flexDirection;
9
+ return css(["flex-direction:", ";gap:", ";"], flexDirection, ddsBaseTokens.spacing.SizesDdsSpacingLocalX1);
10
+ });
11
+
12
+ export { FlexContainer };
@@ -0,0 +1,11 @@
1
+ import { Layout, Rating } from './Feedback.types';
2
+ type RatingComponentType = {
3
+ layout: Layout;
4
+ ratingLabel: string;
5
+ loading: boolean;
6
+ thumbUpTooltip: string;
7
+ thumbDownTooltip: string;
8
+ handleRatingChange: (rating: Rating) => void;
9
+ };
10
+ export declare const RatingComponent: ({ layout, ratingLabel, loading, thumbUpTooltip, thumbDownTooltip, handleRatingChange, }: RatingComponentType) => import("react/jsx-runtime").JSX.Element;
11
+ export {};