@norges-domstoler/dds-components 24.2.1 → 24.3.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.
package/dist/index.cjs CHANGED
@@ -7349,22 +7349,15 @@ const TextArea = ({ id, value, defaultValue, onChange, errorMessage, required =
7349
7349
  };
7350
7350
  TextArea.displayName = "TextArea";
7351
7351
  //#endregion
7352
- //#region src/components/Feedback/utils.tsx
7353
- const getIconSize = (layout) => layout === "vertical" ? "large" : "medium";
7354
- //#endregion
7355
7352
  //#region src/components/Feedback/CommentComponent.tsx
7356
- const CommentComponent = ({ layout, rating, feedbackText, positiveFeedbackLabel, negativeFeedbackLabel, ratingSubmittedTitle, textAreaTip, loading, handleSubmit, handleFeedbackTextChange }) => {
7353
+ const CommentComponent = ({ rating, feedbackText, positiveFeedbackLabel, negativeFeedbackLabel, ratingSubmittedTitle, textAreaTip, loading, handleSubmit, handleFeedbackTextChange }) => {
7357
7354
  const { t } = useTranslation();
7358
7355
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(VStack, {
7359
7356
  gap: "x1",
7360
7357
  children: [
7361
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
7358
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
7362
7359
  className: Feedback_module_default["rating-submitted-title"],
7363
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
7364
- icon: rating === "positive" ? ThumbUpFilledIcon : ThumbDownFilledIcon,
7365
- color: "icon-action-resting",
7366
- iconSize: getIconSize(layout)
7367
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Paragraph, { children: [ratingSubmittedTitle, " "] })]
7360
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Paragraph, { children: [ratingSubmittedTitle, " "] })
7368
7361
  }),
7369
7362
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextArea, {
7370
7363
  value: feedbackText,
@@ -7390,6 +7383,9 @@ const texts$17 = createTexts({ send: {
7390
7383
  se: "Sádde"
7391
7384
  } });
7392
7385
  //#endregion
7386
+ //#region src/components/Feedback/utils.tsx
7387
+ const getButtonSize = (layout) => layout === "vertical" ? "medium" : "small";
7388
+ //#endregion
7393
7389
  //#region src/components/Tooltip/Tooltip.tsx
7394
7390
  const Tooltip = ({ text, placement = "bottom", children, tooltipId, delay = 100, style, onMouseLeave, onMouseOver, keepMounted = true, id, ref, className, htmlProps, ...rest }) => {
7395
7391
  const generatedId = (0, react.useId)();
@@ -7485,26 +7481,32 @@ Tooltip.displayName = "Tooltip";
7485
7481
  //#region src/components/Feedback/RatingComponent.tsx
7486
7482
  const RatingComponent = ({ layout, ratingLabel, loading, thumbUpTooltip, thumbDownTooltip, handleRatingChange }) => {
7487
7483
  const { t } = useTranslation();
7488
- const button = (rating, layout, tooltip) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineIconButton, {
7489
- "aria-label": tooltip,
7490
- onClick: () => handleRatingChange(rating),
7491
- size: getIconSize(layout),
7492
- icon: rating === "positive" ? ThumbUpIcon : ThumbDownIcon,
7493
- color: "icon-medium"
7494
- });
7484
+ const buttonSize = getButtonSize(layout);
7495
7485
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
7496
7486
  className: cn(Feedback_module_default["rating-container"], Feedback_module_default[`rating-container--${layout}`]),
7497
7487
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
7498
7488
  className: typographyStyles_module_default["label-medium"],
7499
7489
  children: ratingLabel
7500
7490
  }), loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Spinner, { tooltip: t(texts$16.uploadingFeedback) }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HStack, {
7501
- gap: "x1",
7491
+ gap: "x0.75",
7502
7492
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tooltip, {
7503
7493
  text: thumbUpTooltip,
7504
- children: button("positive", layout, thumbUpTooltip)
7494
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
7495
+ purpose: "secondary",
7496
+ "aria-label": thumbUpTooltip,
7497
+ onClick: () => handleRatingChange("positive"),
7498
+ size: buttonSize,
7499
+ icon: ThumbUpIcon
7500
+ })
7505
7501
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tooltip, {
7506
7502
  text: thumbDownTooltip,
7507
- children: button("negative", layout, thumbDownTooltip)
7503
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
7504
+ purpose: "secondary",
7505
+ "aria-label": thumbDownTooltip,
7506
+ onClick: () => handleRatingChange("negative"),
7507
+ size: buttonSize,
7508
+ icon: ThumbDownIcon
7509
+ })
7508
7510
  })]
7509
7511
  })]
7510
7512
  });
@@ -7562,7 +7564,6 @@ const Feedback = ({ layout = "vertical", ratingLabel, positiveFeedbackLabel, neg
7562
7564
  handleRatingChange
7563
7565
  });
7564
7566
  if (!feedbackTextAreaExcluded && !isFeedbackSubmitted) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CommentComponent, {
7565
- layout,
7566
7567
  rating,
7567
7568
  feedbackText,
7568
7569
  positiveFeedbackLabel: tPositiveFeedbackLabel,
@@ -9507,15 +9508,23 @@ const getCustomStyles = (size, hasError, isReadOnly) => ({
9507
9508
  //#endregion
9508
9509
  //#region src/components/Select/SelectComponents.tsx
9509
9510
  const { Option, NoOptionsMessage, Input, SingleValue, ClearIndicator, DropdownIndicator, MultiValueRemove, Control } = react_select.components;
9510
- const DDSOption = ({ ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Option, {
9511
+ const DDSOption = ({ testId, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Option, {
9511
9512
  ...props,
9513
+ innerProps: {
9514
+ ...props.innerProps,
9515
+ "data-testid": testId
9516
+ },
9512
9517
  children: [props.isSelected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
9513
9518
  icon: CheckIcon,
9514
9519
  iconSize: "small"
9515
9520
  }), props.children]
9516
9521
  });
9517
- const CustomOption = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Option, {
9522
+ const CustomOption = ({ testId, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Option, {
9518
9523
  ...props,
9524
+ innerProps: {
9525
+ ...props.innerProps,
9526
+ "data-testid": testId
9527
+ },
9519
9528
  children: react.default.createElement(props.customElement, props)
9520
9529
  });
9521
9530
  const CustomSingleValue = ({ id, Element, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SingleValue, {
@@ -9628,12 +9637,21 @@ function Select({ id, label, componentSize = "medium", errorMessage, tip, "aria-
9628
9637
  dataTestId
9629
9638
  ]);
9630
9639
  const customOptionComponent = (0, react.useCallback)((props) => {
9640
+ const optionTestId = dataTestId ? `${dataTestId}-option-${String(rest.getOptionValue?.(props.data) ?? props.data.value)}` : void 0;
9631
9641
  if (customOptionElement) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomOption, {
9632
9642
  ...props,
9633
- customElement: customOptionElement
9643
+ customElement: customOptionElement,
9644
+ testId: optionTestId
9645
+ });
9646
+ else return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DDSOption, {
9647
+ ...props,
9648
+ testId: optionTestId
9634
9649
  });
9635
- else return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DDSOption, { ...props });
9636
- }, [customOptionElement, componentSize]);
9650
+ }, [
9651
+ customOptionElement,
9652
+ dataTestId,
9653
+ rest.getOptionValue
9654
+ ]);
9637
9655
  const reactSelectProps = {
9638
9656
  options,
9639
9657
  value,